Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManoj Palat2020-07-20 02:31:05 +0000
committerManoj Palat2020-07-20 02:31:05 +0000
commit3c9dec433efd25951176f08ec77f5c8f1773adf1 (patch)
tree89a7102d398f7adb3961b28d4e26de6243c28baf
parentdd4fbbaff0d4a897e572d0dae3ee62fee6b8f131 (diff)
parent9d7c381780b74aa91cbdd6ac5cbc4c20b2605bc8 (diff)
downloadeclipse.jdt.core-3c9dec433efd25951176f08ec77f5c8f1773adf1.tar.gz
eclipse.jdt.core-3c9dec433efd25951176f08ec77f5c8f1773adf1.tar.xz
eclipse.jdt.core-3c9dec433efd25951176f08ec77f5c8f1773adf1.zip
Merge branch 'master' into BETA_JAVA15
-rw-r--r--org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuilderTests.java11
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionsYieldTest.java245
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/JDIStackFrame.java15
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/target/CodeSnippetRunner.java12
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/junit/extension/PerformanceTestSuite.java13
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/DRLVMLauncher.java44
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/J9VMLauncher.java56
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/JRockitVMLauncher.java51
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/LocalVMLauncher.java17
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/MacVMLauncher.java48
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/SideCarJ9VMLauncher.java50
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/SideCarVMLauncher.java46
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/StandardVMLauncher.java59
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java33
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaSearchTests.java11
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CodeCorrectionTestsRequestor.java16
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTestsRequestor.java56
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CreateMembersTests.java48
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java4
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/MatchingRegionsTest.java25
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SearchTests.java14
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/WorkingCopyTests.java15
-rw-r--r--org.eclipse.jdt.core.tests.model/workspace/CreateMembers/src/OuterRecord.java2
-rw-r--r--org.eclipse.jdt.core.tests.model/workspace/CreateMembers/src/testBug565015/PkgRecord.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/SubwordMatcher.java84
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/BranchStatement.java8
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchExpression.java1
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/YieldStatement.java118
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java4
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTRecoveryPropagator.java14
-rw-r--r--org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/linewrap/WrapPreparator.java4
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateTypeMemberOperation.java3
32 files changed, 751 insertions, 380 deletions
diff --git a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuilderTests.java b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuilderTests.java
index 1938645b43..cec546b49a 100644
--- a/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuilderTests.java
+++ b/org.eclipse.jdt.core.tests.builder/src/org/eclipse/jdt/core/tests/builder/BuilderTests.java
@@ -25,7 +25,6 @@ import java.util.Collections;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.List;
-import java.util.Vector;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.core.IClasspathEntry;
@@ -75,25 +74,25 @@ public class BuilderTests extends TestCase {
String expectingOutput,
String expectedError) {
TestVerifier verifier = new TestVerifier(false);
- Vector classpath = new Vector(5);
+ ArrayList<String> classpath = new ArrayList<>(5);
IPath workspacePath = env.getWorkspaceRootPath();
- classpath.addElement(workspacePath.append(env.getOutputLocation(projectPath)).toOSString());
+ classpath.add(workspacePath.append(env.getOutputLocation(projectPath)).toOSString());
IClasspathEntry[] cp = env.getClasspath(projectPath);
for (int i = 0; i < cp.length; i++) {
IPath c = cp[i].getPath();
String ext = c.getFileExtension();
if (ext != null && (ext.equals("zip") || ext.equals("jar"))) { //$NON-NLS-1$ //$NON-NLS-2$
if (c.getDevice() == null) {
- classpath.addElement(workspacePath.append(c).toOSString());
+ classpath.add(workspacePath.append(c).toOSString());
} else {
- classpath.addElement(c.toOSString());
+ classpath.add(c.toOSString());
}
}
}
- verifier.execute(className, (String[]) classpath.toArray(new String[0]));
+ verifier.execute(className, classpath.toArray(new String[0]));
if (DEBUG) {
System.out.println("ERRORS\n"); //$NON-NLS-1$
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionsYieldTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionsYieldTest.java
index 0cb6f7e8fc..6bfeff329d 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionsYieldTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/SwitchExpressionsYieldTest.java
@@ -26,7 +26,7 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
static {
// TESTS_NUMBERS = new int [] { 40 };
// TESTS_RANGE = new int[] { 1, -1 };
-// TESTS_NAMES = new String[] { "testBug561766" };
+// TESTS_NAMES = new String[] { "testBug545567_14" };
}
public static Class<?> testClass() {
@@ -5192,4 +5192,247 @@ public class SwitchExpressionsYieldTest extends AbstractRegressionTest {
"The target type of this expression must be a functional interface\n" +
"----------\n");
}
+ public void testBug565156_001() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " public int test() {\n"+
+ " return switch (0) {\n"+
+ " default -> {\n"+
+ " try {\n"+
+ " yield 0;\n"+
+ " }\n"+
+ " catch (RuntimeException e) {\n"+
+ " throw e;\n"+
+ " }\n"+
+ " }\n"+
+ " };\n"+
+ " } \n"+
+ " public static void main(String[] args) {\n"+
+ " int i = new X().test();\n"+
+ " System.out.println(i);\n"+
+ " }\n"+
+ "}\n"
+ },
+ "0");
+ }
+ public void testBug565156_002() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " public int test() {\n"+
+ " return switch (0) {\n"+
+ " default -> {\n"+
+ " try {\n"+
+ " yield 0;\n"+
+ " }\n"+
+ " finally {\n"+
+ " //do nothing\n"+
+ " }\n"+
+ " }\n"+
+ " };\n"+
+ " } \n"+
+ " public static void main(String[] args) {\n"+
+ " int i = new X().test();\n"+
+ " System.out.println(i);\n"+
+ " }\n"+
+ "}\n"
+ },
+ "0");
+ }
+ public void testBug565156_003() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " public int test() {\n"+
+ " return switch (0) {\n"+
+ " default -> {\n"+
+ " try {\n"+
+ " yield 0;\n"+
+ " }\n"+
+ " finally {\n"+
+ " int i = 20;"+
+ " yield 20;"+
+ " }\n"+
+ " }\n"+
+ " };\n"+
+ " } \n"+
+ " public static void main(String[] args) {\n"+
+ " int i = new X().test();\n"+
+ " System.out.println(i);\n"+
+ " }\n"+
+ "}\n"
+ },
+ "20");
+ }
+ public void testBug565156_004() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " public int test() {\n"+
+ " return switch (0) {\n"+
+ " default -> {\n"+
+ " try {\n"+
+ " yield switch (0) {\n"+
+ " default -> {\n"+
+ " try {\n"+
+ " yield 100;\n"+
+ " }\n"+
+ " finally {\n"+
+ " yield 200; \n"+
+ " }\n"+
+ " }\n"+
+ " };\n"+
+ " }\n"+
+ " finally {\n"+
+ " yield 20;\n"+
+ " }\n"+
+ " }\n"+
+ " };\n"+
+ " }\n"+
+ " public static void main(String[] args){\n"+
+ " int i = new X().test();\n"+
+ " System.out.println(i);\n"+
+ " }\n"+
+ "}"
+ },
+ "20");
+ }
+ public void testBug565156_005() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " public int test() {\n"+
+ " return switch (0) {\n"+
+ " default -> {\n"+
+ " try {\n"+
+ " yield switch (0) {\n"+
+ " default -> {\n"+
+ " try {\n"+
+ " yield 100;\n"+
+ " }\n"+
+ " finally {\n"+
+ " // do nothing\n"+
+ " }\n"+
+ " }\n"+
+ " };\n"+
+ " }\n"+
+ " finally {\n"+
+ " // do nothing\n"+
+ " }\n"+
+ " }\n"+
+ " };\n"+
+ " }\n"+
+ " public static void main(String[] args){\n"+
+ " int i = new X().test();\n"+
+ " System.out.println(i);\n"+
+ " }\n"+
+ "}"
+ },
+ "100");
+ }
+ public void testBug565156_006() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " public static void main(String[] args) {\n"+
+ " new X().foo(args);\n"+
+ " }\n"+
+ "\n"+
+ " @SuppressWarnings({ \"finally\" })\n"+
+ " public void foo(String[] args) {\n"+
+ " int t = switch (0) {\n"+
+ " default -> {\n"+
+ " try {\n"+
+ " if (args == null)\n"+
+ " yield 1;\n"+
+ " else if (args.length ==2)\n"+
+ " yield 2; \n"+
+ " else if (args.length == 4)\n"+
+ " yield 4;\n"+
+ " else yield 5; \n"+
+ " } finally {\n"+
+ " yield 3; \n"+
+ " }\n"+
+ " }\n"+
+ " }; \n"+
+ " t = switch (100) {\n"+
+ " default -> {\n"+
+ " try {\n"+
+ " yield 10;\n"+
+ " } finally {\n"+
+ " }\n"+
+ " } \n"+
+ " }; \n"+
+ " System.out.println(t);\n"+
+ " }\n"+
+ "}"
+ },
+ "10");
+ }
+ public void testBug565156_007() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " public static void main(String[] args) {\n"+
+ " new X().foo(args);\n"+
+ " }\n"+
+ "\n"+
+ " @SuppressWarnings({ \"finally\" })\n"+
+ " public void foo(String[] args) {\n"+
+ " int t = switch (0) {\n"+
+ " case 101 -> {yield 101;}\n"+
+ " default -> {\n"+
+ " try {\n"+
+ " if (args == null)\n"+
+ " yield 1;\n"+
+ " else if (args.length ==2)\n"+
+ " yield 2; \n"+
+ " else if (args.length == 4)\n"+
+ " yield 4;\n"+
+ " else yield 5; \n"+
+ " } finally {\n"+
+ " yield 3; \n"+
+ " }\n"+
+ " }\n"+
+ " }; \n"+
+ " t = switch (100) {\n"+
+ " default -> {\n"+
+ " try {\n"+
+ " yield 10;\n"+
+ " } finally {\n"+
+ " }\n"+
+ " } \n"+
+ " }; \n"+
+ " System.out.println(t);\n"+
+ " }\n"+
+ "}"
+ },
+ "10");
+ }
+ public void testBug547193_001() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " public static void main(String[] args) {\n"+
+ " System.out.println(switch (0) {default -> {\n"+
+ " try {\n"+
+ " yield 1;\n"+
+ " } catch (Exception ex) {\n"+
+ " yield 2;\n"+
+ " }\n"+
+ " }});\n"+
+ " }\n"+
+ "}"
+ },
+ "1");
+ }
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/JDIStackFrame.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/JDIStackFrame.java
index 4d866619eb..a07548a83e 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/JDIStackFrame.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/JDIStackFrame.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -16,7 +16,6 @@ package org.eclipse.jdt.core.tests.eval;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import java.util.Vector;
import junit.framework.TestCase;
@@ -244,13 +243,13 @@ public char[][] localVariableNames() {
try {
StackFrame frame = getStackFrame();
Iterator variables = frame.visibleVariables().iterator();
- Vector names = new Vector();
+ List<char[]> names = new ArrayList<>();
while (variables.hasNext()) {
LocalVariable var = (LocalVariable)variables.next();
- names.addElement(var.name().toCharArray());
+ names.add(var.name().toCharArray());
}
char[][] result = new char[names.size()][];
- names.copyInto(result);
+ names.toArray(result);
return result;
} catch (AbsentInformationException e) {
return null;
@@ -260,13 +259,13 @@ public char[][] localVariableTypeNames() {
try {
StackFrame frame = getStackFrame();
Iterator variables = frame.visibleVariables().iterator();
- Vector names = new Vector();
+ List<char[]> names = new ArrayList();
while (variables.hasNext()) {
LocalVariable var = (LocalVariable)variables.next();
- names.addElement(var.typeName().toCharArray());
+ names.add(var.typeName().toCharArray());
}
char[][] result = new char[names.size()][];
- names.copyInto(result);
+ names.toArray(result);
return result;
} catch (AbsentInformationException e) {
return null;
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/target/CodeSnippetRunner.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/target/CodeSnippetRunner.java
index 8243de27e5..102ee6d844 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/target/CodeSnippetRunner.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/eval/target/CodeSnippetRunner.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -278,7 +278,7 @@ void processClasses(boolean mustRun, byte[][] classDefinitions) {
}
// load the classes and collect code snippet classes
- Vector codeSnippetClasses = new Vector();
+ List<Class> codeSnippetClasses = new ArrayList<>();
for (int i = 0; i < newClasses.length; i++) {
String className = newClasses[i];
Class clazz = null;
@@ -311,7 +311,7 @@ void processClasses(boolean mustRun, byte[][] classDefinitions) {
} else if (superclass.equals(this.codeSnippetClass)) {
// It may be a code snippet class with no global variable
if (methods.length == 1 && methods[0].getName().equals(RUN_METHOD_NAME)) {
- codeSnippetClasses.addElement(clazz);
+ codeSnippetClasses.add(clazz);
}
// Evaluate global variables and send result back
Field[] fields = clazz.getDeclaredFields();
@@ -329,14 +329,14 @@ void processClasses(boolean mustRun, byte[][] classDefinitions) {
}
} else if (this.codeSnippetClass.equals(superclass.getSuperclass()) && methods.length == 1 && methods[0].getName().equals("run")) {
// It is a code snippet class with a global variable superclass
- codeSnippetClasses.addElement(clazz);
+ codeSnippetClasses.add(clazz);
}
}
// run the code snippet classes
if (codeSnippetClasses.size() != 0 && mustRun) {
- for (Enumeration e = codeSnippetClasses.elements(); e.hasMoreElements();) {
- Object codeSnippet = createCodeSnippet((Class) e.nextElement());
+ for (Class class1 : codeSnippetClasses) {
+ Object codeSnippet = createCodeSnippet(class1);
if (codeSnippet != null) {
runCodeSnippet(codeSnippet);
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/junit/extension/PerformanceTestSuite.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/junit/extension/PerformanceTestSuite.java
index 14e51e207e..f25cbb7b49 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/junit/extension/PerformanceTestSuite.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/junit/extension/PerformanceTestSuite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2014 IBM Corporation and others.
+ * Copyright (c) 2004, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -15,13 +15,14 @@ package org.eclipse.jdt.core.tests.junit.extension;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
-import java.util.Vector;
+import java.util.ArrayList;
+import java.util.List;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
-@SuppressWarnings({ "unchecked", "rawtypes" })
+@SuppressWarnings({ "rawtypes" })
public class PerformanceTestSuite extends TestSuite {
/**
@@ -43,7 +44,7 @@ public class PerformanceTestSuite extends TestSuite {
}
Class superClass= theClass;
- Vector names= new Vector();
+ List<String> names= new ArrayList<>();
while (Test.class.isAssignableFrom(superClass)) {
Method[] methods= superClass.getDeclaredMethods();
for (int i= 0; i < methods.length; i++) {
@@ -59,7 +60,7 @@ public class PerformanceTestSuite extends TestSuite {
setName(name);
}
- private void addTestMethod(Method m, Vector names, Class theClass) {
+ private void addTestMethod(Method m, List<String> names, Class theClass) {
String name= m.getName();
if (names.contains(name))
return;
@@ -68,7 +69,7 @@ public class PerformanceTestSuite extends TestSuite {
addTest(addWarningTest("Test method isn't public: "+m.getName()));
return;
}
- names.addElement(name);
+ names.add(name);
addTest(createTest(theClass, name));
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/DRLVMLauncher.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/DRLVMLauncher.java
index e19bb7add2..4e88b85dfe 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/DRLVMLauncher.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/DRLVMLauncher.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -16,13 +16,13 @@
package org.eclipse.jdt.core.tests.runtime;
import java.io.File;
-import java.util.Vector;
+import java.util.ArrayList;
+import java.util.List;
/**
* This is a new vm launcher to support Apache Harmony
* (http://harmony.apache.org) settings
*/
-@SuppressWarnings({ "unchecked", "rawtypes" })
public class DRLVMLauncher extends StandardVMLauncher {
/**
@@ -30,7 +30,7 @@ public class DRLVMLauncher extends StandardVMLauncher {
*/
@Override
public String[] getCommandLine() {
- Vector commandLine= new Vector();
+ List<String> commandLine= new ArrayList<>();
// VM binary
String vmLocation = this.vmPath +
@@ -42,59 +42,59 @@ public String[] getCommandLine() {
if (osName.indexOf("win32") == -1 && !new File(vmLocation).exists()) {
vmLocation = vmLocation.substring(0, vmLocation.length()-1);
}
- commandLine.addElement(vmLocation);
+ commandLine.add(vmLocation);
// VM arguments
if (this.vmArguments != null) {
for (int i = 0; i < this.vmArguments.length; i++) {
- commandLine.addElement(this.vmArguments[i]);
+ commandLine.add(this.vmArguments[i]);
}
}
// boot classpath
- commandLine.addElement("-Xbootclasspath/a:" + buildBootClassPath());
+ commandLine.add("-Xbootclasspath/a:" + buildBootClassPath());
// debug mode
if (this.debugPort != -1) {
- commandLine.addElement("-Xdebug");
- commandLine.addElement("-Xnoagent");
+ commandLine.add("-Xdebug");
+ commandLine.add("-Xnoagent");
// commandLine.addElement("-Djava.compiler=NONE");
- commandLine.addElement(
+ commandLine.add(
"-Xrunjdwp:transport=dt_socket,address=" +
this.debugPort +
",server=y,suspend=n");
}
// regular classpath
- commandLine.addElement("-classpath");
- commandLine.addElement(buildClassPath());
+ commandLine.add("-classpath");
+ commandLine.add(buildClassPath());
// code snippet runner class
if (this.evalPort != -1) {
- commandLine.addElement(CODE_SNIPPET_RUNNER_CLASS_NAME);
+ commandLine.add(CODE_SNIPPET_RUNNER_CLASS_NAME);
}
// code snippet runner arguments
if (this.evalPort != -1) {
- commandLine.addElement(EVALPORT_ARG);
- commandLine.addElement(Integer.toString(this.evalPort));
+ commandLine.add(EVALPORT_ARG);
+ commandLine.add(Integer.toString(this.evalPort));
if (TARGET_HAS_FILE_SYSTEM) {
- commandLine.addElement(CODESNIPPET_CLASSPATH_ARG);
- commandLine.addElement(this.evalTargetPath + File.separator + REGULAR_CLASSPATH_DIRECTORY);
- commandLine.addElement(CODESNIPPET_BOOTPATH_ARG);
- commandLine.addElement(this.evalTargetPath + File.separator + BOOT_CLASSPATH_DIRECTORY);
+ commandLine.add(CODESNIPPET_CLASSPATH_ARG);
+ commandLine.add(this.evalTargetPath + File.separator + REGULAR_CLASSPATH_DIRECTORY);
+ commandLine.add(CODESNIPPET_BOOTPATH_ARG);
+ commandLine.add(this.evalTargetPath + File.separator + BOOT_CLASSPATH_DIRECTORY);
}
}
// program class
if (this.programClass != null) {
- commandLine.addElement(this.programClass);
+ commandLine.add(this.programClass);
}
// program arguments
if (this.programArguments != null) {
for (int i=0;i<this.programArguments.length;i++) {
- commandLine.addElement(this.programArguments[i]);
+ commandLine.add(this.programArguments[i]);
}
}
@@ -105,7 +105,7 @@ public String[] getCommandLine() {
result = new String[] {this.batchFileName};
} else {
result = new String[commandLine.size()];
- commandLine.copyInto(result);
+ commandLine.toArray(result);
}
// check for spaces in result
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/J9VMLauncher.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/J9VMLauncher.java
index adadab7808..d8129a3dd8 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/J9VMLauncher.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/J9VMLauncher.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -15,7 +15,8 @@ package org.eclipse.jdt.core.tests.runtime;
import java.io.File;
import java.io.IOException;
-import java.util.Vector;
+import java.util.ArrayList;
+import java.util.List;
import org.eclipse.jdt.core.tests.util.Util;
@@ -29,7 +30,6 @@ import org.eclipse.jdt.core.tests.util.Util;
* must also be specified. This port is used for the communication between the
* Proxy and the VM.
*/
-@SuppressWarnings({ "unchecked", "rawtypes" })
public class J9VMLauncher extends LocalVMLauncher {
int internalDebugPort = -1;
String proxyOutFile;
@@ -93,10 +93,10 @@ protected Process execCommandLine() throws TargetException {
*/
@Override
public String[] getCommandLine() {
- Vector commandLine = new Vector();
+ List<String> commandLine = new ArrayList<>();
// VM binary
- commandLine.addElement(
+ commandLine.add(
this.vmPath +
(this.vmPath.endsWith(File.separator) ? "" : File.separator) +
"bin" +
@@ -106,53 +106,53 @@ public String[] getCommandLine() {
// VM arguments
if (this.vmArguments != null) {
for (int i = 0; i < this.vmArguments.length; i++) {
- commandLine.addElement(this.vmArguments[i]);
+ commandLine.add(this.vmArguments[i]);
}
}
// debug mode
if (this.debugPort != -1 && this.internalDebugPort != -1) {
- commandLine.addElement("-debug:" + this.internalDebugPort);
+ commandLine.add("-debug:" + this.internalDebugPort);
}
// boot class path
- commandLine.addElement("-Xbootclasspath:" + buildBootClassPath());
+ commandLine.add("-Xbootclasspath:" + buildBootClassPath());
// regular class path
- commandLine.addElement("-classpath");
- commandLine.addElement(buildClassPath());
+ commandLine.add("-classpath");
+ commandLine.add(buildClassPath());
// code snippet runner class
if (this.evalPort != -1) {
- commandLine.addElement(CODE_SNIPPET_RUNNER_CLASS_NAME);
+ commandLine.add(CODE_SNIPPET_RUNNER_CLASS_NAME);
}
// code snippet runner arguments
if (this.evalPort != -1) {
- commandLine.addElement(EVALPORT_ARG);
- commandLine.addElement(Integer.toString(this.evalPort));
+ commandLine.add(EVALPORT_ARG);
+ commandLine.add(Integer.toString(this.evalPort));
if (TARGET_HAS_FILE_SYSTEM) {
- commandLine.addElement(CODESNIPPET_CLASSPATH_ARG);
- commandLine.addElement(this.evalTargetPath + File.separator + REGULAR_CLASSPATH_DIRECTORY);
- commandLine.addElement(CODESNIPPET_BOOTPATH_ARG);
- commandLine.addElement(this.evalTargetPath + File.separator + BOOT_CLASSPATH_DIRECTORY);
+ commandLine.add(CODESNIPPET_CLASSPATH_ARG);
+ commandLine.add(this.evalTargetPath + File.separator + REGULAR_CLASSPATH_DIRECTORY);
+ commandLine.add(CODESNIPPET_BOOTPATH_ARG);
+ commandLine.add(this.evalTargetPath + File.separator + BOOT_CLASSPATH_DIRECTORY);
}
}
// program class
if (this.programClass != null) {
- commandLine.addElement(this.programClass);
+ commandLine.add(this.programClass);
}
// program arguments
if (this.programArguments != null) {
for (int i=0;i<this.programArguments.length;i++) {
- commandLine.addElement(this.programArguments[i]);
+ commandLine.add(this.programArguments[i]);
}
}
String[] result= new String[commandLine.size()];
- commandLine.copyInto(result);
+ commandLine.toArray(result);
// check for spaces in result
for (int i = 0; i < result.length; i++) {
@@ -177,10 +177,10 @@ public int getInternalDebugPort() {
* Returns the command line which will be used to launch the Proxy.
*/
public String[] getProxyCommandLine() {
- Vector commandLine = new Vector();
+ List<String> commandLine = new ArrayList<>();
// Proxy binary
- commandLine.addElement(
+ commandLine.add(
this.vmPath +
(this.vmPath.endsWith(File.separator) ? "" : File.separator) +
"bin" +
@@ -188,14 +188,14 @@ public String[] getProxyCommandLine() {
"j9proxy");
// Arguments
- commandLine.addElement(getTargetAddress() + ":" + this.internalDebugPort);
- commandLine.addElement(Integer.toString(this.debugPort));
+ commandLine.add(getTargetAddress() + ":" + this.internalDebugPort);
+ commandLine.add(Integer.toString(this.debugPort));
if (this.symbolPath != null && this.symbolPath != "") {
- commandLine.addElement(this.symbolPath);
+ commandLine.add(this.symbolPath);
}
String[] result= new String[commandLine.size()];
- commandLine.copyInto(result);
+ commandLine.toArray(result);
return result;
}
/**
@@ -246,9 +246,9 @@ public LocalVirtualMachine launch() throws TargetException {
// Transform launched VM into J9 VM
Process vmProcess = localVM.process;
- this.runningVMs.removeElement(localVM);
+ this.runningVMs.remove(localVM);
J9VirtualMachine vm= new J9VirtualMachine(vmProcess, this.debugPort, this.evalTargetPath, proxyProcess, this.proxyOutFile);
- this.runningVMs.addElement(vm);
+ this.runningVMs.add(vm);
return vm;
}
/* (non-Javadoc)
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/JRockitVMLauncher.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/JRockitVMLauncher.java
index 45c987b433..03c586958b 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/JRockitVMLauncher.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/JRockitVMLauncher.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2014 IBM Corporation and others.
+ * Copyright (c) 2006, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -18,14 +18,13 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
-import java.util.Enumeration;
-import java.util.Vector;
+import java.util.ArrayList;
+import java.util.List;
/**
* A standard VM launcher launches an external standard VM with
* the given arguments on the same machine.
*/
-@SuppressWarnings({ "unchecked", "rawtypes" })
public class JRockitVMLauncher extends LocalVMLauncher {
String batchFileName;
/**
@@ -61,11 +60,11 @@ public String getBatchFileName() {
*/
@Override
public String[] getCommandLine() {
- Vector commandLine= new Vector();
+ List<String> commandLine = new ArrayList<>();
// VM binary
if (System.getProperty("java.vm.version").startsWith("1.4.2")) {
- commandLine.addElement(
+ commandLine.add(
this.vmPath +
(this.vmPath.endsWith(File.separator) ? "" : File.separator) +
"bin" +
@@ -89,21 +88,21 @@ public String[] getCommandLine() {
File.separator +
"java";
}
- commandLine.addElement(vmLocation);
+ commandLine.add(vmLocation);
}
// VM arguments
if (this.vmArguments != null) {
for (int i = 0; i < this.vmArguments.length; i++) {
- commandLine.addElement(this.vmArguments[i]);
+ commandLine.add(this.vmArguments[i]);
}
}
// debug mode
if (this.debugPort != -1) {
- commandLine.addElement("-Xdebug");
- commandLine.addElement("-Xnoagent");
- commandLine.addElement(
+ commandLine.add("-Xdebug");
+ commandLine.add("-Xnoagent");
+ commandLine.add(
"-Xrunjdwp:transport=dt_socket,address=" +
this.debugPort +
",server=y,suspend=n");
@@ -112,37 +111,37 @@ public String[] getCommandLine() {
// set the classpath
// we don't set the bootclasspath as for StandardVMLauncher as this breaks the debug mode of JRockit
// we would get: [JRockit] ERROR: failed to set up MAPI gc reporting
- commandLine.addElement("-classpath");
+ commandLine.add("-classpath");
String classpath = buildBootClassPath() + File.pathSeparator + buildClassPath();
System.out.println(classpath);
- commandLine.addElement(classpath);
+ commandLine.add(classpath);
// code snippet runner class
if (this.evalPort != -1) {
- commandLine.addElement(CODE_SNIPPET_RUNNER_CLASS_NAME);
+ commandLine.add(CODE_SNIPPET_RUNNER_CLASS_NAME);
}
// code snippet runner arguments
if (this.evalPort != -1) {
- commandLine.addElement(EVALPORT_ARG);
- commandLine.addElement(Integer.toString(this.evalPort));
+ commandLine.add(EVALPORT_ARG);
+ commandLine.add(Integer.toString(this.evalPort));
if (TARGET_HAS_FILE_SYSTEM) {
- commandLine.addElement(CODESNIPPET_CLASSPATH_ARG);
- commandLine.addElement(this.evalTargetPath + File.separator + REGULAR_CLASSPATH_DIRECTORY);
- commandLine.addElement(CODESNIPPET_BOOTPATH_ARG);
- commandLine.addElement(this.evalTargetPath + File.separator + BOOT_CLASSPATH_DIRECTORY);
+ commandLine.add(CODESNIPPET_CLASSPATH_ARG);
+ commandLine.add(this.evalTargetPath + File.separator + REGULAR_CLASSPATH_DIRECTORY);
+ commandLine.add(CODESNIPPET_BOOTPATH_ARG);
+ commandLine.add(this.evalTargetPath + File.separator + BOOT_CLASSPATH_DIRECTORY);
}
}
// program class
if (this.programClass != null) {
- commandLine.addElement(this.programClass);
+ commandLine.add(this.programClass);
}
// program arguments
if (this.programArguments != null) {
for (int i=0;i<this.programArguments.length;i++) {
- commandLine.addElement(this.programArguments[i]);
+ commandLine.add(this.programArguments[i]);
}
}
@@ -153,7 +152,7 @@ public String[] getCommandLine() {
result = new String[] {this.batchFileName};
} else {
result = new String[commandLine.size()];
- commandLine.copyInto(result);
+ commandLine.toArray(result);
}
// check for spaces in result
@@ -175,13 +174,13 @@ public String[] getCommandLine() {
public void setBatchFileName(String batchFileName) {
this.batchFileName = batchFileName;
}
-protected void writeBatchFile(String fileName, Vector commandLine) {
+protected void writeBatchFile(String fileName, List<String> commandLine) {
FileOutputStream output = null;
try {
output = new FileOutputStream(fileName);
PrintWriter out= new PrintWriter(output);
- for (Enumeration e = commandLine.elements(); e.hasMoreElements();) {
- out.print((String)e.nextElement());
+ for (String string : commandLine) {
+ out.print(string);
out.print(" ");
}
out.println("pause");
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/LocalVMLauncher.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/LocalVMLauncher.java
index 647f93cda1..048dbc3754 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/LocalVMLauncher.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/LocalVMLauncher.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -31,7 +31,6 @@ import org.eclipse.jdt.core.tests.util.Util;
* instances will be able to retrieve only a part of the running VMs.
* </ul>
*/
-@SuppressWarnings({ "unchecked", "rawtypes" })
public abstract class LocalVMLauncher implements RuntimeConstants {
static final String[] env = System.getenv().entrySet().stream()
@@ -55,7 +54,7 @@ public abstract class LocalVMLauncher implements RuntimeConstants {
protected String evalTargetPath;
protected String[] programArguments;
protected String programClass;
- protected Vector runningVMs = new Vector(); // a Vector of LocalVirtualMachine
+ protected List<LocalVirtualMachine> runningVMs = new ArrayList<>(); // a Vector of LocalVirtualMachine
protected String[] vmArguments;
protected String vmPath;
@@ -226,12 +225,10 @@ public String getProgramClass() {
*/
public LocalVirtualMachine[] getRunningVirtualMachines() {
// Select the VMs that are actually running
- Vector actuallyRunning = new Vector();
- Enumeration en = this.runningVMs.elements();
- while (en.hasMoreElements()) {
- LocalVirtualMachine vm = (LocalVirtualMachine)en.nextElement();
+ List<LocalVirtualMachine> actuallyRunning = new ArrayList<>();
+ for (LocalVirtualMachine vm : this.runningVMs) {
if (vm.isRunning())
- actuallyRunning.addElement(vm);
+ actuallyRunning.add(vm);
}
this.runningVMs = actuallyRunning;
@@ -239,7 +236,7 @@ public LocalVirtualMachine[] getRunningVirtualMachines() {
int size = actuallyRunning.size();
LocalVirtualMachine[] result = new LocalVirtualMachine[size];
for (int i=0; i<size; i++)
- result[i] = (LocalVirtualMachine)actuallyRunning.elementAt(i);
+ result[i] = actuallyRunning.get(i);
return result;
}
/**
@@ -408,7 +405,7 @@ public LocalVirtualMachine launch() throws TargetException {
// from happening.
// add VM to list of known running VMs
- this.runningVMs.addElement(vm);
+ this.runningVMs.add(vm);
return vm;
}
/**
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/MacVMLauncher.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/MacVMLauncher.java
index 34ae7f09c6..af6e8f9120 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/MacVMLauncher.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/MacVMLauncher.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -14,21 +14,21 @@
package org.eclipse.jdt.core.tests.runtime;
import java.io.File;
-import java.util.Vector;
+import java.util.ArrayList;
+import java.util.List;
/**
* This is a new vm launcher to support sidecar settings
*/
-@SuppressWarnings({ "unchecked", "rawtypes" })
public class MacVMLauncher extends StandardVMLauncher {
/**
* @see LocalVMLauncher#getCommandLine
*/
@Override
public String[] getCommandLine() {
- Vector commandLine= new Vector();
+ List<String> commandLine = new ArrayList<>();
// VM binary
- commandLine.addElement(
+ commandLine.add(
this.vmPath +
(this.vmPath.endsWith(File.separator) ? "" : File.separator) +
"bin" +
@@ -38,56 +38,56 @@ public String[] getCommandLine() {
// VM arguments
if (this.vmArguments != null) {
for (int i = 0; i < this.vmArguments.length; i++) {
- commandLine.addElement(this.vmArguments[i]);
+ commandLine.add(this.vmArguments[i]);
}
}
// boot classpath
- commandLine.addElement("-Xbootclasspath/a:" + buildBootClassPath());
+ commandLine.add("-Xbootclasspath/a:" + buildBootClassPath());
// debug mode
if (this.debugPort != -1) {
- commandLine.addElement("-Xdebug");
- commandLine.addElement("-Xnoagent");
- // commandLine.addElement("-Djava.compiler=NONE");
- commandLine.addElement(
+ commandLine.add("-Xdebug");
+ commandLine.add("-Xnoagent");
+ // commandLine.add("-Djava.compiler=NONE");
+ commandLine.add(
"-Xrunjdwp:transport=dt_socket,address=" +
this.debugPort +
",server=y,suspend=n");
} else {
- commandLine.addElement("-Xdebug");
+ commandLine.add("-Xdebug");
}
// regular classpath
- commandLine.addElement("-classpath");
- commandLine.addElement(buildClassPath());
+ commandLine.add("-classpath");
+ commandLine.add(buildClassPath());
// code snippet runner class
if (this.evalPort != -1) {
- commandLine.addElement(CODE_SNIPPET_RUNNER_CLASS_NAME);
+ commandLine.add(CODE_SNIPPET_RUNNER_CLASS_NAME);
}
// code snippet runner arguments
if (this.evalPort != -1) {
- commandLine.addElement(EVALPORT_ARG);
- commandLine.addElement(Integer.toString(this.evalPort));
+ commandLine.add(EVALPORT_ARG);
+ commandLine.add(Integer.toString(this.evalPort));
if (TARGET_HAS_FILE_SYSTEM) {
- commandLine.addElement(CODESNIPPET_CLASSPATH_ARG);
- commandLine.addElement(this.evalTargetPath + File.separator + REGULAR_CLASSPATH_DIRECTORY);
- commandLine.addElement(CODESNIPPET_BOOTPATH_ARG);
- commandLine.addElement(this.evalTargetPath + File.separator + BOOT_CLASSPATH_DIRECTORY);
+ commandLine.add(CODESNIPPET_CLASSPATH_ARG);
+ commandLine.add(this.evalTargetPath + File.separator + REGULAR_CLASSPATH_DIRECTORY);
+ commandLine.add(CODESNIPPET_BOOTPATH_ARG);
+ commandLine.add(this.evalTargetPath + File.separator + BOOT_CLASSPATH_DIRECTORY);
}
}
// program class
if (this.programClass != null) {
- commandLine.addElement(this.programClass);
+ commandLine.add(this.programClass);
}
// program arguments
if (this.programArguments != null) {
for (int i=0;i<this.programArguments.length;i++) {
- commandLine.addElement(this.programArguments[i]);
+ commandLine.add(this.programArguments[i]);
}
}
@@ -98,7 +98,7 @@ public String[] getCommandLine() {
result = new String[] {this.batchFileName};
} else {
result = new String[commandLine.size()];
- commandLine.copyInto(result);
+ commandLine.toArray(result);
}
// check for spaces in result
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/SideCarJ9VMLauncher.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/SideCarJ9VMLauncher.java
index 7e087673e5..8df922a9c7 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/SideCarJ9VMLauncher.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/SideCarJ9VMLauncher.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -14,21 +14,21 @@
package org.eclipse.jdt.core.tests.runtime;
import java.io.File;
-import java.util.Vector;
+import java.util.ArrayList;
+import java.util.List;
/**
* This is a new vm launcher to support sidecar settings
*/
-@SuppressWarnings({ "unchecked", "rawtypes" })
public class SideCarJ9VMLauncher extends StandardVMLauncher {
/**
* @see LocalVMLauncher#getCommandLine
*/
@Override
public String[] getCommandLine() {
- Vector commandLine= new Vector();
+ List<String> commandLine = new ArrayList<>();
// VM binary
- commandLine.addElement(
+ commandLine.add(
this.vmPath +
(this.vmPath.endsWith(File.separator) ? "" : File.separator) +
"bin" +
@@ -38,57 +38,57 @@ public String[] getCommandLine() {
// VM arguments
if (this.vmArguments != null) {
for (int i = 0; i < this.vmArguments.length; i++) {
- commandLine.addElement(this.vmArguments[i]);
+ commandLine.add(this.vmArguments[i]);
}
}
// boot classpath
- commandLine.addElement("-Xbootclasspath/a:" + buildBootClassPath());
+ commandLine.add("-Xbootclasspath/a:" + buildBootClassPath());
// debug mode
- commandLine.addElement("-Xdebug");
+ commandLine.add("-Xdebug");
if (this.debugPort != -1) {
- commandLine.addElement("-Xnoagent");
- // commandLine.addElement("-Djava.compiler=NONE");
- commandLine.addElement(
+ commandLine.add("-Xnoagent");
+ // commandLine.add("-Djava.compiler=NONE");
+ commandLine.add(
"-Xrunjdwp:transport=dt_socket,address=" +
this.debugPort +
",server=y,suspend=n");
}
- commandLine.addElement("-Xj9");
- commandLine.addElement("-Xprod");
+ commandLine.add("-Xj9");
+ commandLine.add("-Xprod");
// regular classpath
- commandLine.addElement("-classpath");
- commandLine.addElement(buildClassPath());
+ commandLine.add("-classpath");
+ commandLine.add(buildClassPath());
// code snippet runner class
if (this.evalPort != -1) {
- commandLine.addElement(CODE_SNIPPET_RUNNER_CLASS_NAME);
+ commandLine.add(CODE_SNIPPET_RUNNER_CLASS_NAME);
}
// code snippet runner arguments
if (this.evalPort != -1) {
- commandLine.addElement(EVALPORT_ARG);
- commandLine.addElement(Integer.toString(this.evalPort));
+ commandLine.add(EVALPORT_ARG);
+ commandLine.add(Integer.toString(this.evalPort));
if (TARGET_HAS_FILE_SYSTEM) {
- commandLine.addElement(CODESNIPPET_CLASSPATH_ARG);
- commandLine.addElement(this.evalTargetPath + File.separator + REGULAR_CLASSPATH_DIRECTORY);
- commandLine.addElement(CODESNIPPET_BOOTPATH_ARG);
- commandLine.addElement(this.evalTargetPath + File.separator + BOOT_CLASSPATH_DIRECTORY);
+ commandLine.add(CODESNIPPET_CLASSPATH_ARG);
+ commandLine.add(this.evalTargetPath + File.separator + REGULAR_CLASSPATH_DIRECTORY);
+ commandLine.add(CODESNIPPET_BOOTPATH_ARG);
+ commandLine.add(this.evalTargetPath + File.separator + BOOT_CLASSPATH_DIRECTORY);
}
}
// program class
if (this.programClass != null) {
- commandLine.addElement(this.programClass);
+ commandLine.add(this.programClass);
}
// program arguments
if (this.programArguments != null) {
for (int i=0;i<this.programArguments.length;i++) {
- commandLine.addElement(this.programArguments[i]);
+ commandLine.add(this.programArguments[i]);
}
}
@@ -99,7 +99,7 @@ public String[] getCommandLine() {
result = new String[] {this.batchFileName};
} else {
result = new String[commandLine.size()];
- commandLine.copyInto(result);
+ commandLine.toArray(result);
}
// check for spaces in result
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/SideCarVMLauncher.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/SideCarVMLauncher.java
index 6c0b8e4181..e7e243f2d8 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/SideCarVMLauncher.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/SideCarVMLauncher.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -14,21 +14,21 @@
package org.eclipse.jdt.core.tests.runtime;
import java.io.File;
-import java.util.Vector;
+import java.util.ArrayList;
+import java.util.List;
/**
* This is a new vm launcher to support sidecar settings
*/
-@SuppressWarnings({ "unchecked", "rawtypes" })
public class SideCarVMLauncher extends StandardVMLauncher {
/**
* @see LocalVMLauncher#getCommandLine
*/
@Override
public String[] getCommandLine() {
- Vector commandLine= new Vector();
+ List<String> commandLine = new ArrayList<>();
// VM binary
- commandLine.addElement(
+ commandLine.add(
this.vmPath +
(this.vmPath.endsWith(File.separator) ? "" : File.separator) +
"bin" +
@@ -38,54 +38,54 @@ public String[] getCommandLine() {
// VM arguments
if (this.vmArguments != null) {
for (int i = 0; i < this.vmArguments.length; i++) {
- commandLine.addElement(this.vmArguments[i]);
+ commandLine.add(this.vmArguments[i]);
}
}
// boot classpath
- commandLine.addElement("-Xbootclasspath/a:" + buildBootClassPath());
+ commandLine.add("-Xbootclasspath/a:" + buildBootClassPath());
// debug mode
if (this.debugPort != -1) {
- commandLine.addElement("-Xdebug");
- commandLine.addElement("-Xnoagent");
- // commandLine.addElement("-Djava.compiler=NONE");
- commandLine.addElement(
+ commandLine.add("-Xdebug");
+ commandLine.add("-Xnoagent");
+ // commandLine.add("-Djava.compiler=NONE");
+ commandLine.add(
"-Xrunjdwp:transport=dt_socket,address=" +
this.debugPort +
",server=y,suspend=n");
}
// regular classpath
- commandLine.addElement("-classpath");
- commandLine.addElement(buildClassPath());
+ commandLine.add("-classpath");
+ commandLine.add(buildClassPath());
// code snippet runner class
if (this.evalPort != -1) {
- commandLine.addElement(CODE_SNIPPET_RUNNER_CLASS_NAME);
+ commandLine.add(CODE_SNIPPET_RUNNER_CLASS_NAME);
}
// code snippet runner arguments
if (this.evalPort != -1) {
- commandLine.addElement(EVALPORT_ARG);
- commandLine.addElement(Integer.toString(this.evalPort));
+ commandLine.add(EVALPORT_ARG);
+ commandLine.add(Integer.toString(this.evalPort));
if (TARGET_HAS_FILE_SYSTEM) {
- commandLine.addElement(CODESNIPPET_CLASSPATH_ARG);
- commandLine.addElement(this.evalTargetPath + File.separator + REGULAR_CLASSPATH_DIRECTORY);
- commandLine.addElement(CODESNIPPET_BOOTPATH_ARG);
- commandLine.addElement(this.evalTargetPath + File.separator + BOOT_CLASSPATH_DIRECTORY);
+ commandLine.add(CODESNIPPET_CLASSPATH_ARG);
+ commandLine.add(this.evalTargetPath + File.separator + REGULAR_CLASSPATH_DIRECTORY);
+ commandLine.add(CODESNIPPET_BOOTPATH_ARG);
+ commandLine.add(this.evalTargetPath + File.separator + BOOT_CLASSPATH_DIRECTORY);
}
}
// program class
if (this.programClass != null) {
- commandLine.addElement(this.programClass);
+ commandLine.add(this.programClass);
}
// program arguments
if (this.programArguments != null) {
for (int i=0;i<this.programArguments.length;i++) {
- commandLine.addElement(this.programArguments[i]);
+ commandLine.add(this.programArguments[i]);
}
}
@@ -96,7 +96,7 @@ public String[] getCommandLine() {
result = new String[] {this.batchFileName};
} else {
result = new String[commandLine.size()];
- commandLine.copyInto(result);
+ commandLine.toArray(result);
}
// check for spaces in result
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/StandardVMLauncher.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/StandardVMLauncher.java
index 3e25d3cc41..223c31c0f3 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/StandardVMLauncher.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/runtime/StandardVMLauncher.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2019 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -18,8 +18,8 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
-import java.util.Enumeration;
-import java.util.Vector;
+import java.util.ArrayList;
+import java.util.List;
import org.eclipse.jdt.core.tests.util.Util;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
@@ -28,7 +28,6 @@ import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
* A standard VM launcher launches an external standard VM with
* the given arguments on the same machine.
*/
-@SuppressWarnings({ "rawtypes" ,"unchecked" })
public class StandardVMLauncher extends LocalVMLauncher {
String batchFileName;
private boolean isJrtBasedVM;
@@ -93,7 +92,7 @@ public String getBatchFileName() {
*/
@Override
public String[] getCommandLine() {
- Vector commandLine= new Vector();
+ List<String> commandLine = new ArrayList<>();
// VM binary
StringBuffer vmLocation = new StringBuffer(this.vmPath);
@@ -102,72 +101,72 @@ public String[] getCommandLine() {
.append("bin")
.append(File.separator)
.append("java");
- commandLine.addElement(String.valueOf(vmLocation));
+ commandLine.add(String.valueOf(vmLocation));
// VM arguments
if (this.vmArguments != null) {
for (int i = 0; i < this.vmArguments.length; i++) {
- commandLine.addElement(this.vmArguments[i]);
+ commandLine.add(this.vmArguments[i]);
}
}
long vmVersion = Util.getMajorMinorVMVersion();
if (vmVersion != -1) {
if (vmVersion < ClassFileConstants.JDK13) { // FailOverToOldVerifier deprecated from 13
- commandLine.addElement("-XX:-FailOverToOldVerifier");
+ commandLine.add("-XX:-FailOverToOldVerifier");
}
if (vmVersion >= ClassFileConstants.JDK1_6) {
- commandLine.addElement("-Xverify:all");
+ commandLine.add("-Xverify:all");
}
if (vmVersion >= ClassFileConstants.JDK1_7) {
- commandLine.addElement("-XX:+UnlockExperimentalVMOptions");
+ commandLine.add("-XX:+UnlockExperimentalVMOptions");
}
}
// debug mode
if (this.debugPort != -1) {
- commandLine.addElement("-Xdebug");
- commandLine.addElement("-Xnoagent");
- // commandLine.addElement("-Djava.compiler=NONE");
- commandLine.addElement(
+ commandLine.add("-Xdebug");
+ commandLine.add("-Xnoagent");
+ // commandLine.add("-Djava.compiler=NONE");
+ commandLine.add(
"-Xrunjdwp:transport=dt_socket,address=" +
this.debugPort +
",server=y,suspend=n");
}
// boot classpath
- commandLine.addElement("-Xbootclasspath/a:" + buildBootClassPath());
+ commandLine.add("-Xbootclasspath/a:" + buildBootClassPath());
// regular classpath
- commandLine.addElement("-classpath");
- commandLine.addElement(buildClassPath());
+ commandLine.add("-classpath");
+ commandLine.add(buildClassPath());
// code snippet runner class
if (this.evalPort != -1) {
- commandLine.addElement(CODE_SNIPPET_RUNNER_CLASS_NAME);
+ commandLine.add(CODE_SNIPPET_RUNNER_CLASS_NAME);
}
// code snippet runner arguments
if (this.evalPort != -1) {
- commandLine.addElement(EVALPORT_ARG);
- commandLine.addElement(Integer.toString(this.evalPort));
+ commandLine.add(EVALPORT_ARG);
+ commandLine.add(Integer.toString(this.evalPort));
if (TARGET_HAS_FILE_SYSTEM) {
- commandLine.addElement(CODESNIPPET_CLASSPATH_ARG);
- commandLine.addElement(this.evalTargetPath + File.separator + REGULAR_CLASSPATH_DIRECTORY);
- commandLine.addElement(CODESNIPPET_BOOTPATH_ARG);
- commandLine.addElement(this.evalTargetPath + File.separator + BOOT_CLASSPATH_DIRECTORY);
+ commandLine.add(CODESNIPPET_CLASSPATH_ARG);
+ commandLine.add(this.evalTargetPath + File.separator + REGULAR_CLASSPATH_DIRECTORY);
+ commandLine.add(CODESNIPPET_BOOTPATH_ARG);
+ commandLine.add(this.evalTargetPath + File.separator + BOOT_CLASSPATH_DIRECTORY);
}
}
// program class
if (this.programClass != null) {
- commandLine.addElement(this.programClass);
+ commandLine.add(this.programClass);
}
// program arguments
if (this.programArguments != null) {
for (int i=0;i<this.programArguments.length;i++) {
- commandLine.addElement(this.programArguments[i]);
+ commandLine.add(this.programArguments[i]);
}
}
@@ -178,7 +177,7 @@ public String[] getCommandLine() {
result = new String[] {this.batchFileName};
} else {
result = new String[commandLine.size()];
- commandLine.copyInto(result);
+ commandLine.toArray(result);
}
// check for spaces in result
@@ -200,13 +199,13 @@ public String[] getCommandLine() {
public void setBatchFileName(String batchFileName) {
this.batchFileName = batchFileName;
}
-protected void writeBatchFile(String fileName, Vector commandLine) {
+protected void writeBatchFile(String fileName, List<String> commandLine) {
FileOutputStream output = null;
try {
output = new FileOutputStream(fileName);
PrintWriter out= new PrintWriter(output);
- for (Enumeration e = commandLine.elements(); e.hasMoreElements();) {
- out.print((String)e.nextElement());
+ for (String string : commandLine) {
+ out.print(string);
out.print(" ");
}
out.println("pause");
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java
index 84dab8e485..defc484c20 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java
@@ -13059,7 +13059,7 @@ public void testBug220713() {
/**
* https://bugs.eclipse.org/558421 [formatter] Generate getter/setter creates unnecessary blank line
*/
-public void testBug() {
+public void testBug558421() {
this.formatterPrefs.blank_lines_after_last_class_body_declaration = 1;
String source =
"public int getA() {\n" +
@@ -13195,4 +13195,35 @@ public void testBug563487c() {
"}\n" +
"}");
}
+/**
+ * https://bugs.eclipse.org/565053 - [formatter] Parenthesis in "separate lines if wrapped": wrapping disruptions
+ */
+public void testBug565053a() {
+ this.formatterPrefs.parenthesis_positions_in_method_invocation = DefaultCodeFormatterConstants.SEPARATE_LINES_IF_WRAPPED;
+ this.formatterPrefs.page_width = 92;
+ formatSource(
+ "class Example {\n" +
+ "\n" +
+ " List SUPPORTED_THINGS = asList(\n" +
+ " new Thing(\n" +
+ " \"rocodileaaadasgasgasgasgasgasgaaaaasgsgasgasgasgasfafghasfaa aaadad\"\n" +
+ " ), \"new Thing()\"\n" +
+ " );\n" +
+ "}");
+}
+/**
+ * https://bugs.eclipse.org/565053 - [formatter] Parenthesis in "separate lines if wrapped": wrapping disruptions
+ */
+public void testBug565053b() {
+ this.formatterPrefs.parenthesis_positions_in_method_invocation = DefaultCodeFormatterConstants.SEPARATE_LINES_IF_WRAPPED;
+ this.formatterPrefs.page_width = 100;
+ formatSource(
+ "class Example {\n" +
+ "\n" +
+ " List SUPPORTED_THINGS = asList(\n" +
+ " new Thing(\"rocodileaaadasgasgasgasgasgasgaaaaasgsgasgasgasgasfafghasfaa aaadad\")\n" +
+ " \"new Thing()\"\n" +
+ " );\n" +
+ "}");
+}
}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaSearchTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaSearchTests.java
index d216ef7316..93a61dd24e 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaSearchTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaSearchTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -20,7 +20,6 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
-import java.util.Vector;
import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.*;
@@ -73,7 +72,7 @@ public class AbstractJavaSearchTests extends ModifyingResourceTests implements I
static protected final int SHOW_JAR_FILE = 0x0400;
public static class ConstructorDeclarationsCollector implements IRestrictedAccessConstructorRequestor {
- Vector results = new Vector();
+ List<String> results = new ArrayList<>();
public void acceptConstructor(
int modifiers,
@@ -136,7 +135,7 @@ public class AbstractJavaSearchTests extends ModifyingResourceTests implements I
buffer.append('*');
}
- this.results.addElement(buffer.toString());
+ this.results.add(buffer.toString());
}
@Override
@@ -165,7 +164,7 @@ public class AbstractJavaSearchTests extends ModifyingResourceTests implements I
buffer.append(c);
}
public static class MethodDeclarationsCollector implements IRestrictedAccessMethodRequestor {
- Vector results = new Vector();
+ List<String> results = new ArrayList<>();
@Override
public void acceptMethod(
@@ -225,7 +224,7 @@ public class AbstractJavaSearchTests extends ModifyingResourceTests implements I
if (parameterCount > 1 && i < parameterCount - 1) buffer.append(',');
}
buffer.append(')');
- this.results.addElement(buffer.toString());
+ this.results.add(buffer.toString());
}
private char[] getTypeErasure(char[] typeName) {
int index;
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CodeCorrectionTestsRequestor.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CodeCorrectionTestsRequestor.java
index d4ebf364f5..a6ebba28ac 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CodeCorrectionTestsRequestor.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CodeCorrectionTestsRequestor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -48,30 +48,30 @@ public class CodeCorrectionTestsRequestor implements ICorrectionRequestor {
}
- private Vector suggestions = new Vector(5);
+ private List<Suggestion> suggestions = new ArrayList<>(5);
public void acceptClass(char[] packageName,char[] className,char[] correctionName,int modifiers,int correctionStart,int correctionEnd){
- this.suggestions.addElement(new Suggestion(correctionName, correctionStart, correctionEnd));
+ this.suggestions.add(new Suggestion(correctionName, correctionStart, correctionEnd));
}
public void acceptField(char[] declaringTypePackageName,char[] declaringTypeName,char[] name,char[] typePackageName,char[] typeName,char[] correctionName,int modifiers,int correctionStart,int correctionEnd){
- this.suggestions.addElement(new Suggestion(correctionName, correctionStart, correctionEnd));
+ this.suggestions.add(new Suggestion(correctionName, correctionStart, correctionEnd));
}
public void acceptInterface(char[] packageName,char[] interfaceName,char[] correctionName,int modifiers,int correctionStart,int correctionEnd){
- this.suggestions.addElement(new Suggestion(correctionName, correctionStart, correctionEnd));
+ this.suggestions.add(new Suggestion(correctionName, correctionStart, correctionEnd));
}
public void acceptLocalVariable(char[] name,char[] typePackageName,char[] typeName,int modifiers,int correctionStart,int correctionEnd){
- this.suggestions.addElement(new Suggestion(name, correctionStart, correctionEnd));
+ this.suggestions.add(new Suggestion(name, correctionStart, correctionEnd));
}
public void acceptMethod(char[] declaringTypePackageName,char[] declaringTypeName,char[] selector,char[][] parameterPackageNames,char[][] parameterTypeNames,char[][] parameterNames,char[] returnTypePackageName,char[] returnTypeName,char[] correctionName,int modifiers,int correctionStart,int correctionEnd){
- this.suggestions.addElement(new Suggestion(correctionName, correctionStart, correctionEnd));
+ this.suggestions.add(new Suggestion(correctionName, correctionStart, correctionEnd));
}
public void acceptPackage(char[] packageName,char[] correctionName,int correctionStart,int correctionEnd){
- this.suggestions.addElement(new Suggestion(correctionName, correctionStart, correctionEnd));
+ this.suggestions.add(new Suggestion(correctionName, correctionStart, correctionEnd));
}
public String getSuggestions(){
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTestsRequestor.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTestsRequestor.java
index 44517d317b..e5f487d4ae 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTestsRequestor.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTestsRequestor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,7 +13,8 @@
*******************************************************************************/
package org.eclipse.jdt.core.tests.model;
-import java.util.Vector;
+import java.util.ArrayList;
+import java.util.List;
import org.eclipse.jdt.core.CompletionProposal;
import org.eclipse.jdt.core.CompletionRequestor;
@@ -24,28 +25,27 @@ import org.eclipse.jdt.core.Signature;
* {@link CompletionTestsRequestor} is deprecated. {@link CompletionTestsRequestor2} must be used instead.
*/
//TODO all instances of CompletionTestsRequestor should be replaced by an instance of CompletionTestsRequestor2
-@SuppressWarnings({"rawtypes", "unchecked"})
public class CompletionTestsRequestor extends CompletionRequestor {
- private Vector elements = new Vector();
- private Vector completions = new Vector();
- private Vector relevances = new Vector();
- private Vector completionStart = new Vector();
- private Vector completionEnd = new Vector();
+ private List<String> elements = new ArrayList<>();
+ private List<String> completions = new ArrayList<>();
+ private List<String> relevances = new ArrayList<>();
+ private List<String> completionStart = new ArrayList<>();
+ private List<String> completionEnd = new ArrayList<>();
public boolean debug = false;
private void acceptCommon(CompletionProposal proposal) {
- this.completions.addElement(new String(proposal.getCompletion()));
- this.relevances.addElement(String.valueOf(proposal.getRelevance()));
- this.completionStart.addElement(String.valueOf(proposal.getReplaceStart()));
- this.completionEnd.addElement(String.valueOf(proposal.getReplaceEnd()));
+ this.completions.add(new String(proposal.getCompletion()));
+ this.relevances.add(String.valueOf(proposal.getRelevance()));
+ this.completionStart.add(String.valueOf(proposal.getReplaceStart()));
+ this.completionEnd.add(String.valueOf(proposal.getReplaceEnd()));
}
public void accept(CompletionProposal proposal) {
char[] typeName = null;
switch(proposal.getKind()) {
case CompletionProposal.ANONYMOUS_CLASS_DECLARATION :
typeName = Signature.getSignatureSimpleName(proposal.getDeclarationSignature());
- this.elements.addElement(new String(typeName));
+ this.elements.add(new String(typeName));
acceptCommon(proposal);
if (this.debug)
System.out.println("anonymous type " + new String(typeName));
@@ -56,13 +56,13 @@ public class CompletionTestsRequestor extends CompletionRequestor {
} else if((proposal.getFlags() & Flags.AccInterface) != 0) {
typeName = Signature.getSignatureSimpleName(proposal.getSignature());
- this.elements.addElement(new String(typeName));
+ this.elements.add(new String(typeName));
acceptCommon(proposal);
if (this.debug)
System.out.println("Interface " + new String(typeName));
} else {
typeName = Signature.getSignatureSimpleName(proposal.getSignature());
- this.elements.addElement(new String(typeName));
+ this.elements.add(new String(typeName));
acceptCommon(proposal);
if (this.debug) {
if(Signature.getTypeSignatureKind(proposal.getSignature()) == Signature.TYPE_VARIABLE_SIGNATURE) {
@@ -75,56 +75,56 @@ public class CompletionTestsRequestor extends CompletionRequestor {
break;
case CompletionProposal.FIELD_REF :
- this.elements.addElement(new String(proposal.getName()));
+ this.elements.add(new String(proposal.getName()));
acceptCommon(proposal);
if (this.debug)
System.out.println("Field " + new String(proposal.getName()));
break;
case CompletionProposal.KEYWORD:
- this.elements.addElement(new String(proposal.getName()));
+ this.elements.add(new String(proposal.getName()));
acceptCommon(proposal);
if (this.debug)
System.out.println("Keyword " + new String(proposal.getName()));
break;
case CompletionProposal.LABEL_REF:
- this.elements.addElement(new String(proposal.getName()));
+ this.elements.add(new String(proposal.getName()));
acceptCommon(proposal);
if (this.debug)
System.out.println("Label " + new String(proposal.getName()));
break;
case CompletionProposal.LOCAL_VARIABLE_REF:
- this.elements.addElement(new String(proposal.getName()));
+ this.elements.add(new String(proposal.getName()));
acceptCommon(proposal);
if (this.debug)
System.out.println("Local variable " + new String(proposal.getName()));
break;
case CompletionProposal.METHOD_REF:
- this.elements.addElement(new String(proposal.getName()));
+ this.elements.add(new String(proposal.getName()));
acceptCommon(proposal);
if (this.debug)
System.out.println("method " + new String(proposal.getName()));
break;
case CompletionProposal.METHOD_DECLARATION:
- this.elements.addElement(new String(proposal.getName()));
+ this.elements.add(new String(proposal.getName()));
acceptCommon(proposal);
if (this.debug)
System.out.println("method declaration " + new String(proposal.getName()));
break;
case CompletionProposal.PACKAGE_REF:
- this.elements.addElement(new String(proposal.getDeclarationSignature()));
+ this.elements.add(new String(proposal.getDeclarationSignature()));
acceptCommon(proposal);
if (this.debug)
System.out.println("package " + new String(proposal.getDeclarationSignature()));
break;
case CompletionProposal.VARIABLE_DECLARATION:
- this.elements.addElement(new String(proposal.getName()));
+ this.elements.add(new String(proposal.getName()));
acceptCommon(proposal);
if (this.debug)
System.out.println("variable name " + new String(proposal.getName()));
@@ -168,19 +168,19 @@ public class CompletionTestsRequestor extends CompletionRequestor {
StringBuffer buffer = new StringBuffer();
buffer.append("element:");
- buffer.append(this.elements.elementAt(i));
+ buffer.append(this.elements.get(i));
buffer.append(" completion:");
- buffer.append(this.completions.elementAt(i));
+ buffer.append(this.completions.get(i));
if(position) {
buffer.append(" position:[");
- buffer.append(this.completionStart.elementAt(i));
+ buffer.append(this.completionStart.get(i));
buffer.append(",");
- buffer.append(this.completionEnd.elementAt(i));
+ buffer.append(this.completionEnd.get(i));
buffer.append("]");
}
if(relevance) {
buffer.append(" relevance:");
- buffer.append(this.relevances.elementAt(i));
+ buffer.append(this.relevances.get(i));
}
return buffer.toString();
}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CreateMembersTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CreateMembersTests.java
index f84241d7fd..95b645e750 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CreateMembersTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CreateMembersTests.java
@@ -220,4 +220,52 @@ public class CreateMembersTests extends AbstractJavaModelTests {
javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, old);
}
}
+
+ public void testBug565015_1() throws JavaModelException {
+ IJavaProject javaProject = getJavaProject("CreateMembers");
+ String old = javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, true);
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
+ try {
+ ICompilationUnit compilationUnit = getCompilationUnit("CreateMembers", "src", "", "OuterRecord.java");
+ assertNotNull("No compilation unit", compilationUnit);
+ IType[] types = compilationUnit.getTypes();
+ assertNotNull("No types", types);
+ assertEquals("Wrong size", 1, types.length);
+ IType type = types[0];
+ type.createType("record Point() {}", null, true, null);
+ String expectedSource =
+ "public record OuterRecord() {\n" +
+ "\n" +
+ " record Point() {}\n" +
+ "}";
+ assertSourceEquals("Unexpected source", expectedSource, type.getSource());
+ } finally {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, old);
+ }
+ }
+
+ public void testBug565015_2() throws JavaModelException {
+ IJavaProject javaProject = getJavaProject("CreateMembers");
+ String old = javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, true);
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, JavaCore.ENABLED);
+ try {
+ ICompilationUnit compilationUnit = getCompilationUnit("CreateMembers", "src", "testBug565015", "PkgRecord.java");
+ assertNotNull("No compilation unit", compilationUnit);
+ IType[] types = compilationUnit.getTypes();
+ assertNotNull("No types", types);
+ assertEquals("Wrong size", 1, types.length);
+ IType type = types[0];
+ type.createType("record Point() {}", null, true, null);
+ String expectedSource =
+ "package testBug565015;\n" +
+ "\n" +
+ "public record PkgRecord() {\n" +
+ "\n" +
+ " record Point() {}\n" +
+ "}";
+ assertSourceEquals("Unexpected source", expectedSource, compilationUnit.getSource());
+ } finally {
+ javaProject.setOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, old);
+ }
+ }
}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java
index 10d903c525..75b489cded 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -7014,7 +7014,7 @@ public void testBug127628() throws CoreException {
CharOperation.concatWith(enclosingTypeNames, '$'),
simpleTypeName,
'$');
- this.results.addElement(new String(CharOperation.concat(packageName, typeName, '.')));
+ this.results.add(new String(CharOperation.concat(packageName, typeName, '.')));
}
}
}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/MatchingRegionsTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/MatchingRegionsTest.java
index c890b46e7a..aa2aa77097 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/MatchingRegionsTest.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/MatchingRegionsTest.java
@@ -1609,6 +1609,11 @@ public void testSubword_caps_boundaries2() {
int[] regions = SearchPattern.getMatchingRegions("ini", name, SearchPattern.R_SUBWORD_MATCH);
assertEquals("Unexpected matching regions", null, printRegions(name, regions));
}
+public void testSubword_caps_boundaries3() {
+ String name = "CASE_INSENSITIVE_ORDER";
+ int[] regions = SearchPattern.getMatchingRegions("sensitive", name, SearchPattern.R_SUBWORD_MATCH);
+ assertEquals("Unexpected matching regions", null, printRegions(name, regions));
+}
public void testSubword_caps_backtracking() {
String name = "LIST_LISTENER";
int[] regions = SearchPattern.getMatchingRegions("listener", name, SearchPattern.R_SUBWORD_MATCH);
@@ -1619,4 +1624,24 @@ public void testSubword_snakeCase() {
int[] regions = SearchPattern.getMatchingRegions("addlistener", name, SearchPattern.R_SUBWORD_MATCH);
assertEquals("Unexpected matching regions", "[add]_list_[listener]", printRegions(name, regions));
}
+public void testSubword_mixedCamelCase1() {
+ String name = "IImportWizard";
+ int[] regions = SearchPattern.getMatchingRegions("import", name, SearchPattern.R_SUBWORD_MATCH);
+ assertEquals("Unexpected matching regions", "I[Import]Wizard", printRegions(name, regions));
+}
+public void testSubword_mixedCamelCase2() {
+ String name = "HTMLTable";
+ int[] regions = SearchPattern.getMatchingRegions("table", name, SearchPattern.R_SUBWORD_MATCH);
+ assertEquals("Unexpected matching regions", "HTML[Table]", printRegions(name, regions));
+}
+public void testSubword_mixedCamelCase3() {
+ String name = "CustomHTMLTable";
+ int[] regions = SearchPattern.getMatchingRegions("table", name, SearchPattern.R_SUBWORD_MATCH);
+ assertEquals("Unexpected matching regions", "CustomHTML[Table]", printRegions(name, regions));
+}
+public void testSubword_mixedCamelCase4() {
+ String name = "ImportHTML";
+ int[] regions = SearchPattern.getMatchingRegions("html", name, SearchPattern.R_SUBWORD_MATCH);
+ assertEquals("Unexpected matching regions", "Import[HTML]", printRegions(name, regions));
+}
}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SearchTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SearchTests.java
index d2b659fed5..7532db71b8 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SearchTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/SearchTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -15,7 +15,8 @@ package org.eclipse.jdt.core.tests.model;
import java.io.FileInputStream;
import java.io.IOException;
-import java.util.Vector;
+import java.util.ArrayList;
+import java.util.List;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
@@ -38,7 +39,6 @@ import junit.framework.Test;
/*
* Test indexing support.
*/
-@SuppressWarnings({"rawtypes", "unchecked"})
public class SearchTests extends ModifyingResourceTests implements IJavaSearchConstants {
/*
* Empty jar contents.
@@ -78,7 +78,7 @@ public class SearchTests extends ModifyingResourceTests implements IJavaSearchCo
}
}
public static class SearchMethodNameRequestor extends MethodNameRequestor {
- Vector results = new Vector<>();
+ List<String> results = new ArrayList<>();
@Override
public void acceptMethod(
char[] methodName,
@@ -136,7 +136,7 @@ public class SearchTests extends ModifyingResourceTests implements IJavaSearchCo
if (parameterCount > 1 && i < parameterCount - 1) buffer.append(',');
}
buffer.append(')');
- this.results.addElement(buffer.toString());
+ this.results.add(buffer.toString());
}
static void checkAndAddtoBuffer(StringBuffer buffer, char[] precond, char c) {
if (precond == null || precond.length == 0) return;
@@ -162,14 +162,14 @@ public class SearchTests extends ModifyingResourceTests implements IJavaSearchCo
}
}
public static class SearchTypeNameRequestor extends TypeNameRequestor {
- Vector results = new Vector();
+ List<String> results = new ArrayList<>();
public void acceptType(int modifiers, char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames, String path) {
char[] typeName =
CharOperation.concat(
CharOperation.concatWith(enclosingTypeNames, '$'),
simpleTypeName,
'$');
- this.results.addElement(new String(CharOperation.concat(packageName, typeName, '.')));
+ this.results.add(new String(CharOperation.concat(packageName, typeName, '.')));
}
public String toString(){
int length = this.results.size();
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/WorkingCopyTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/WorkingCopyTests.java
index 919f84655c..b28e9a2b82 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/WorkingCopyTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/WorkingCopyTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -14,7 +14,8 @@
package org.eclipse.jdt.core.tests.model;
import java.io.IOException;
-import java.util.Vector;
+import java.util.ArrayList;
+import java.util.List;
import junit.framework.Test;
@@ -27,8 +28,6 @@ import org.eclipse.jdt.internal.core.util.Util;
import org.eclipse.team.core.RepositoryProvider;
-
-@SuppressWarnings({"rawtypes", "unchecked"})
public class WorkingCopyTests extends ModifyingResourceTests {
ICompilationUnit cu = null;
ICompilationUnit copy = null;
@@ -462,14 +461,14 @@ public void testGetPrimaryInnerType() {
assertTrue("Element is not a method", primary instanceof IType);
assertTrue("Element should exist", primary.exists());
- Vector hierarchy = new Vector(5);
+ List<IJavaElement> hierarchy = new ArrayList<>(5);
IJavaElement parent= primary.getParent();
while (parent.getElementType() > IJavaElement.COMPILATION_UNIT) {
- hierarchy.addElement(parent);
+ hierarchy.add(parent);
parent = parent.getParent();
}
- hierarchy.addElement(parent);
- assertTrue("Compilation Unit should not be a working copy", !((ICompilationUnit)hierarchy.lastElement()).isWorkingCopy());
+ hierarchy.add(parent);
+ assertTrue("Compilation Unit should not be a working copy", !((ICompilationUnit)hierarchy.get(hierarchy.size() - 1)).isWorkingCopy());
}
/**
* Ensures that the primary method can be retrieved.
diff --git a/org.eclipse.jdt.core.tests.model/workspace/CreateMembers/src/OuterRecord.java b/org.eclipse.jdt.core.tests.model/workspace/CreateMembers/src/OuterRecord.java
new file mode 100644
index 0000000000..a7f1c6ca22
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/workspace/CreateMembers/src/OuterRecord.java
@@ -0,0 +1,2 @@
+public record OuterRecord() {
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.core.tests.model/workspace/CreateMembers/src/testBug565015/PkgRecord.java b/org.eclipse.jdt.core.tests.model/workspace/CreateMembers/src/testBug565015/PkgRecord.java
new file mode 100644
index 0000000000..a10860127c
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.model/workspace/CreateMembers/src/testBug565015/PkgRecord.java
@@ -0,0 +1,4 @@
+package testBug565015;
+
+public record PkgRecord() {
+} \ No newline at end of file
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/SubwordMatcher.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/SubwordMatcher.java
index 806091f882..9886aefd5c 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/SubwordMatcher.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/SubwordMatcher.java
@@ -7,7 +7,7 @@
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Contributors:
* Julian Honnen - initial API and implementation
*******************************************************************************/
@@ -29,16 +29,42 @@ class SubwordMatcher {
this.name = name.toCharArray();
this.wordBoundaries = new BitSet(name.length());
- BoundaryState state = BoundaryState.SEPARATOR;
for (int i = 0; i < this.name.length; i++) {
- char c = this.name[i];
- if (state.isWordBoundary(c)) {
+ if (isWordBoundary(caseAt(i - 1), caseAt(i), caseAt(i + 1))) {
this.wordBoundaries.set(i);
}
- state = state.next(c);
}
}
+ private Case caseAt(int index) {
+ if (index < 0 || index >= this.name.length)
+ return Case.SEPARATOR;
+
+ char c = this.name[index];
+ if (c == '_')
+ return Case.SEPARATOR;
+ if (ScannerHelper.isUpperCase(c))
+ return Case.UPPER;
+ return Case.LOWER;
+ }
+
+ private static boolean isWordBoundary(Case p, Case c, Case n) {
+ if (p == c && c == n)
+ return false; // a boundary needs some kind of gradient
+
+ if (p == Case.SEPARATOR)
+ return true; // boundary after every separator
+
+ // the remaining cases are boundaries for capitalization changes:
+ // lowerUpper, UPPERLower, lowerUPPER
+ // ^ ^ ^
+ return (c == Case.UPPER) && (p == Case.LOWER || n == Case.LOWER);
+ }
+
+ private enum Case {
+ SEPARATOR, LOWER, UPPER
+ }
+
public int[] getMatchingRegions(String pattern) {
int segmentStart = 0;
int[] segments = EMPTY_REGIONS;
@@ -131,52 +157,4 @@ class SubwordMatcher {
private boolean isWordBoundary(int iName) {
return this.wordBoundaries.get(iName);
}
-
- private enum BoundaryState {
- SEPARATOR() {
- @Override
- public BoundaryState next(char c) {
- if (c == '_')
- return SEPARATOR;
-
- return ScannerHelper.isUpperCase(c) ? CAPS_WORD : WORD;
- }
- @Override
- public boolean isWordBoundary(char c) {
- return true;
- }
- },
- WORD() {
- @Override
- public BoundaryState next(char c) {
- if (c == '_')
- return SEPARATOR;
-
- return WORD;
- }
-
- @Override
- public boolean isWordBoundary(char c) {
- return ScannerHelper.isUpperCase(c);
- }
- },
- CAPS_WORD() {
- @Override
- public BoundaryState next(char c) {
- if (c == '_')
- return SEPARATOR;
-
- return ScannerHelper.isUpperCase(c) ? CAPS_WORD : WORD;
- }
-
- @Override
- public boolean isWordBoundary(char c) {
- return next(c) == SEPARATOR;
- }
- };
-
- public abstract boolean isWordBoundary(char c);
-
- public abstract BoundaryState next(char c);
- }
} \ No newline at end of file
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/BranchStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/BranchStatement.java
index 62904f9308..59522dfa93 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/BranchStatement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/BranchStatement.java
@@ -32,12 +32,6 @@ public BranchStatement(char[] label, int sourceStart,int sourceEnd) {
this.sourceEnd = sourceEnd;
}
-protected void generateExpressionResultCode(BlockScope currentScope, CodeStream codeStream) {
- // do nothing here
-}
-protected void adjustStackSize(BlockScope currentScope, CodeStream codeStream) {
- // do nothing here
-}
protected void setSubroutineSwitchExpression(SubRoutineStatement sub) {
// Do nothing
}
@@ -54,7 +48,6 @@ public void generateCode(BlockScope currentScope, CodeStream codeStream) {
if ((this.bits & ASTNode.IsReachable) == 0) {
return;
}
- generateExpressionResultCode(currentScope, codeStream);
int pc = codeStream.position;
// generation of code responsible for invoking the finally
@@ -80,7 +73,6 @@ public void generateCode(BlockScope currentScope, CodeStream codeStream) {
}
// checkAndLoadSyntheticVars(codeStream);
codeStream.goto_(this.targetLabel);
- adjustStackSize(currentScope, codeStream);
codeStream.recordPositionsFrom(pc, this.sourceStart);
SubRoutineStatement.reenterAllExceptionHandlers(this.subroutines, -1, codeStream);
if (this.initStateIndex != -1) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchExpression.java
index e0c96327b4..3e258e3ebe 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SwitchExpression.java
@@ -302,6 +302,7 @@ public class SwitchExpression extends SwitchStatement implements IPolyExpression
public void loadStoredTypesAndKeep(CodeStream codeStream) {
List<LocalVariableBinding> tos = this.typesOnStack;
int sz = tos != null ? tos.size() : 0;
+ codeStream.clearTypeBindingStack();
int index = sz - 1;
while (index >= 0) {
LocalVariableBinding lvb = tos.get(index--);
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/YieldStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/YieldStatement.java
index 84a9106bc7..f626942837 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/YieldStatement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/YieldStatement.java
@@ -127,44 +127,96 @@ protected void addSecretYieldResultValue(BlockScope scope1) {
protected void restartExceptionLabels(CodeStream codeStream) {
SubRoutineStatement.reenterAllExceptionHandlers(this.subroutines, -1, codeStream);
}
-@Override
-protected void generateExpressionResultCode(BlockScope currentScope, CodeStream codeStream) {
+protected void generateExpressionResultCodeExpanded(BlockScope currentScope, CodeStream codeStream) {
SwitchExpression se = this.switchExpression;
- if (se != null && se.containsTry && se.resolvedType != null ) {
- addSecretYieldResultValue(this.scope);
- assert this.secretYieldResultValue != null;
- codeStream.record(this.secretYieldResultValue);
- SingleNameReference lhs = new SingleNameReference(this.secretYieldResultValue.name, 0);
- lhs.binding = this.secretYieldResultValue;
- lhs.bits &= ~ASTNode.RestrictiveFlagMASK; // clear bits
- lhs.bits |= Binding.LOCAL;
- lhs.bits |= ASTNode.IsSecretYieldValueUsage;
- ((LocalVariableBinding) lhs.binding).markReferenced(); // TODO : Can be skipped?
- Assignment assignment = new Assignment(lhs, this.expression, 0);
- assignment.generateCode(this.scope, codeStream);
- int l = this.subroutines == null ? 0 : this.subroutines.length;
- boolean foundFinally = false;
- if (l > 0) {
- for (int i = 0; i < l; ++i) {
- SubRoutineStatement srs = this.subroutines[i];
- srs.exitAnyExceptionHandler();
- srs.exitDeclaredExceptionHandlers(codeStream);
- if (srs instanceof TryStatement) {
- TryStatement ts = (TryStatement) srs;
- if (ts.finallyBlock != null) {
- foundFinally = true;
+ addSecretYieldResultValue(this.scope);
+ assert this.secretYieldResultValue != null;
+ codeStream.record(this.secretYieldResultValue);
+ SingleNameReference lhs = new SingleNameReference(this.secretYieldResultValue.name, 0);
+ lhs.binding = this.secretYieldResultValue;
+ lhs.bits &= ~ASTNode.RestrictiveFlagMASK; // clear bits
+ lhs.bits |= Binding.LOCAL;
+ lhs.bits |= ASTNode.IsSecretYieldValueUsage;
+ ((LocalVariableBinding) lhs.binding).markReferenced(); // TODO : Can be skipped?
+ Assignment assignment = new Assignment(lhs, this.expression, 0);
+ assignment.generateCode(this.scope, codeStream);
+
+ int pc = codeStream.position;
+ // generation of code responsible for invoking the finally
+ // blocks in sequence
+ if (this.subroutines != null){
+ for (int i = 0, max = this.subroutines.length; i < max; i++){
+ SubRoutineStatement sub = this.subroutines[i];
+ sub.exitAnyExceptionHandler();
+ sub.exitDeclaredExceptionHandlers(codeStream);
+ SwitchExpression se1 = sub.getSwitchExpression();
+ setSubroutineSwitchExpression(sub);
+ boolean didEscape = sub.generateSubRoutineInvocation(currentScope, codeStream, this.targetLabel, this.initStateIndex, null);
+ sub.setSwitchExpression(se1);
+ if (didEscape) {
+ codeStream.removeVariable(this.secretYieldResultValue);
+ codeStream.recordPositionsFrom(pc, this.sourceStart);
+ SubRoutineStatement.reenterAllExceptionHandlers(this.subroutines, i, codeStream);
+ if (this.initStateIndex != -1) {
+ codeStream.removeNotDefinitelyAssignedVariables(currentScope, this.initStateIndex);
+ codeStream.addDefinitelyAssignedVariables(currentScope, this.initStateIndex);
}
- }
+ restartExceptionLabels(codeStream);
+ return;
}
}
- if (!foundFinally) {
- // no finally - TODO: Check for SynSta?
- se.loadStoredTypesAndKeep(codeStream);
- codeStream.load(this.secretYieldResultValue);
+ }
+ se.loadStoredTypesAndKeep(codeStream);
+ codeStream.load(this.secretYieldResultValue);
+ codeStream.removeVariable(this.secretYieldResultValue);
+
+ codeStream.goto_(this.targetLabel);
+ codeStream.recordPositionsFrom(pc, this.sourceStart);
+ SubRoutineStatement.reenterAllExceptionHandlers(this.subroutines, -1, codeStream);
+ if (this.initStateIndex != -1) {
+ codeStream.removeNotDefinitelyAssignedVariables(currentScope, this.initStateIndex);
+ codeStream.addDefinitelyAssignedVariables(currentScope, this.initStateIndex);
+ }
+}
+@Override
+public void generateCode(BlockScope currentScope, CodeStream codeStream) {
+ if ((this.bits & ASTNode.IsReachable) == 0) {
+ return;
+ }
+ if (this.switchExpression != null && this.switchExpression.containsTry && this.switchExpression.resolvedType != null ) {
+ generateExpressionResultCodeExpanded(currentScope, codeStream);
+ return;
+ }
+ this.expression.generateCode(this.scope, codeStream, this.switchExpression != null);
+ int pc = codeStream.position;
+
+ // generation of code responsible for invoking the finally
+ // blocks in sequence
+ if (this.subroutines != null){
+ for (int i = 0, max = this.subroutines.length; i < max; i++){
+ SubRoutineStatement sub = this.subroutines[i];
+ SwitchExpression se = sub.getSwitchExpression();
+ setSubroutineSwitchExpression(sub);
+ boolean didEscape = sub.generateSubRoutineInvocation(currentScope, codeStream, this.targetLabel, this.initStateIndex, null);
+ sub.setSwitchExpression(se);
+ if (didEscape) {
+ codeStream.recordPositionsFrom(pc, this.sourceStart);
+ SubRoutineStatement.reenterAllExceptionHandlers(this.subroutines, i, codeStream);
+ if (this.initStateIndex != -1) {
+ codeStream.removeNotDefinitelyAssignedVariables(currentScope, this.initStateIndex);
+ codeStream.addDefinitelyAssignedVariables(currentScope, this.initStateIndex);
+ }
+ restartExceptionLabels(codeStream);
+ return;
+ }
}
- codeStream.removeVariable(this.secretYieldResultValue);
- } else {
- this.expression.generateCode(this.scope, codeStream, se != null);
+ }
+ codeStream.goto_(this.targetLabel);
+ codeStream.recordPositionsFrom(pc, this.sourceStart);
+ SubRoutineStatement.reenterAllExceptionHandlers(this.subroutines, -1, codeStream);
+ if (this.initStateIndex != -1) {
+ codeStream.removeNotDefinitelyAssignedVariables(currentScope, this.initStateIndex);
+ codeStream.addDefinitelyAssignedVariables(currentScope, this.initStateIndex);
}
}
private boolean isInsideTry() {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java
index 393398afcf..ddf658f3a8 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java
@@ -6823,7 +6823,7 @@ public void pop2() {
public void pushExceptionOnStack(TypeBinding binding) {
this.stackDepth = 1;
- clearTypeBindingStack();
+// clearTypeBindingStack();
pushTypeBinding(binding);
if (this.stackDepth > this.stackMax)
this.stackMax = this.stackDepth;
@@ -7689,7 +7689,7 @@ private void popTypeBinding(int nPop) {
for (int i = 0; i< nPop; ++i)
popTypeBinding();
}
-private void clearTypeBindingStack() {
+public void clearTypeBindingStack() {
if (!isSwitchStackTrackingActive())
return;
this.switchSaveTypeBindings.clear();
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTRecoveryPropagator.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTRecoveryPropagator.java
index ddfe2f8342..fc44454369 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTRecoveryPropagator.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTRecoveryPropagator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2017 IBM Corporation and others.
+ * Copyright (c) 2006, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -14,8 +14,8 @@
package org.eclipse.jdt.core.dom;
+import java.util.ArrayList;
import java.util.List;
-import java.util.Vector;
import org.eclipse.jdt.core.compiler.CategorizedProblem;
import org.eclipse.jdt.core.compiler.CharOperation;
@@ -28,7 +28,7 @@ import org.eclipse.jdt.internal.compiler.util.HashtableOfObjectToIntArray;
/**
* Internal AST visitor for propagating syntax errors.
*/
-@SuppressWarnings({"rawtypes", "unchecked"})
+@SuppressWarnings({"rawtypes"})
class ASTRecoveryPropagator extends DefaultASTVisitor {
private static final int NOTHING = -1;
HashtableOfObjectToIntArray endingTokens = new HashtableOfObjectToIntArray();
@@ -92,7 +92,7 @@ class ASTRecoveryPropagator extends DefaultASTVisitor {
private boolean[] removedTokensFlagged;
private boolean[] replacedTokensFlagged;
- private Vector stack = new Vector();
+ private ArrayList<ASTNode> stack = new ArrayList<>();
ASTRecoveryPropagator(CategorizedProblem[] problems, RecoveryScannerData data) {
// visit Javadoc.tags() as well
@@ -252,12 +252,12 @@ class ASTRecoveryPropagator extends DefaultASTVisitor {
if(this.insertedTokensKind != null && this.insertedTokensKind.length > 0) {
int s = this.stack.size();
for (int i = s - 1; i > -1; i--) {
- flagNodesWithInsertedTokensAtEnd((ASTNode)this.stack.get(i));
+ flagNodesWithInsertedTokensAtEnd(this.stack.get(i));
}
for (int i = 0; i < s; i++) {
- flagNodesWithInsertedTokensInside((ASTNode)this.stack.get(i));
+ flagNodesWithInsertedTokensInside(this.stack.get(i));
}
- this.stack = new Vector();
+ this.stack = new ArrayList<>();
}
}
diff --git a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/linewrap/WrapPreparator.java b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/linewrap/WrapPreparator.java
index 558fa885fe..6685c1d736 100644
--- a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/linewrap/WrapPreparator.java
+++ b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/linewrap/WrapPreparator.java
@@ -1465,9 +1465,9 @@ public class WrapPreparator extends ASTVisitor {
if (isEmpty)
break;
this.tm.get(openingParenIndex + 1).setWrapPolicy(new WrapPolicy(WrapMode.TOP_PRIORITY,
- openingParenIndex, closingParenIndex, this.options.indentation_size, 1, 1, true, false));
+ openingParenIndex, closingParenIndex, this.options.indentation_size, this.currentDepth, 1, true, false));
this.tm.get(closingParenIndex).setWrapPolicy(new WrapPolicy(WrapMode.TOP_PRIORITY,
- openingParenIndex, closingParenIndex, 0, 1, 1, false, false));
+ openingParenIndex, closingParenIndex, 0, this.currentDepth, 1, false, false));
break;
case DefaultCodeFormatterConstants.SEPARATE_LINES_IF_NOT_EMPTY:
if (isEmpty)
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateTypeMemberOperation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateTypeMemberOperation.java
index b12125fc65..99bd3977d0 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateTypeMemberOperation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CreateTypeMemberOperation.java
@@ -28,6 +28,7 @@ import org.eclipse.jdt.core.dom.ASTParser;
import org.eclipse.jdt.core.dom.AnnotationTypeDeclaration;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.EnumDeclaration;
+import org.eclipse.jdt.core.dom.RecordDeclaration;
import org.eclipse.jdt.core.dom.SimpleName;
import org.eclipse.jdt.core.dom.StructuralPropertyDescriptor;
import org.eclipse.jdt.core.dom.TypeDeclaration;
@@ -74,6 +75,8 @@ protected StructuralPropertyDescriptor getChildPropertyDescriptor(ASTNode parent
return EnumDeclaration.BODY_DECLARATIONS_PROPERTY;
case ASTNode.ANNOTATION_TYPE_DECLARATION:
return AnnotationTypeDeclaration.BODY_DECLARATIONS_PROPERTY;
+ case ASTNode.RECORD_DECLARATION:
+ return RecordDeclaration.BODY_DECLARATIONS_PROPERTY;
default:
return TypeDeclaration.BODY_DECLARATIONS_PROPERTY;
}

Back to the top