update jdt.core to S4_17_0_M3
diff --git a/org.eclipse.jdt.core.tests.compiler/.classpath b/org.eclipse.jdt.core.tests.compiler/.classpath
index 3e5654f..73d6894 100644
--- a/org.eclipse.jdt.core.tests.compiler/.classpath
+++ b/org.eclipse.jdt.core.tests.compiler/.classpath
@@ -1,6 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
+ <attributes>
+ <attribute name="module" value="true"/>
+ </attributes>
+ </classpathentry>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src">
<attributes>
diff --git a/org.eclipse.jdt.core.tests.compiler/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.jdt.core.tests.compiler/.settings/org.eclipse.jdt.core.prefs
index 9426fc4..239da54 100644
--- a/org.eclipse.jdt.core.tests.compiler/.settings/org.eclipse.jdt.core.prefs
+++ b/org.eclipse.jdt.core.tests.compiler/.settings/org.eclipse.jdt.core.prefs
@@ -15,9 +15,9 @@
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.compliance=11
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
@@ -33,6 +33,7 @@
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled
org.eclipse.jdt.core.compiler.problem.discouragedReference=ignore
org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
+org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
@@ -87,6 +88,7 @@
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
+org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
@@ -120,6 +122,7 @@
org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.8
+org.eclipse.jdt.core.compiler.release=enabled
+org.eclipse.jdt.core.compiler.source=11
org.eclipse.jdt.core.incompatibleJDKLevel=ignore
org.eclipse.jdt.core.incompleteClasspath=error
diff --git a/org.eclipse.jdt.core.tests.compiler/META-INF/MANIFEST.MF b/org.eclipse.jdt.core.tests.compiler/META-INF/MANIFEST.MF
index a3ff4d5..6857c2a 100644
--- a/org.eclipse.jdt.core.tests.compiler/META-INF/MANIFEST.MF
+++ b/org.eclipse.jdt.core.tests.compiler/META-INF/MANIFEST.MF
@@ -25,7 +25,7 @@
org.eclipse.objectteams.otdt,
javax.annotation
Import-Package: org.eclipse.jdt.internal.compiler.apt.dispatch
-Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Bundle-RequiredExecutionEnvironment: JavaSE-11
Eclipse-BundleShape: dir
Bundle-Activator: org.eclipse.jdt.core.tests.compiler.Activator
Bundle-ActivationPolicy: lazy
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java
index ae23301..7eccd90 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java
@@ -3162,7 +3162,7 @@
javacTestOptions,
Charset.defaultCharset());
}
- private void runTest(
+ protected void runTest(
// test directory preparation
boolean shouldFlushOutputDirectory,
String[] testFiles,
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest_14.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest_14.java
new file mode 100644
index 0000000..75c3005
--- /dev/null
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest_14.java
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2020 IBM Corporation.
+ *
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.core.tests.compiler.regression;
+
+import java.io.File;
+
+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
+
+import junit.framework.Test;
+
+@SuppressWarnings({ "rawtypes" })
+public class BatchCompilerTest_14 extends AbstractBatchCompilerTest {
+
+ static {
+// TESTS_NAMES = new String[] { "testBatchBug565787_001" };
+// TESTS_NUMBERS = new int[] { 306 };
+// TESTS_RANGE = new int[] { 298, -1 };
+ }
+
+ public static Test suite() {
+ return buildMinimalComplianceTestSuite(testClass(), F_14);
+ }
+ public static Class testClass() {
+ return BatchCompilerTest_14.class;
+ }
+ public BatchCompilerTest_14(String name) {
+ super(name);
+ }
+public void testBatchBug565787_001() throws Exception {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "import java.util.Arrays;\n" +
+ "public class X {\n"+
+ " class MR {\n"+
+ " public int mrCompare(String str1, String str2) {\n"+
+ " return 0;\n"+
+ " }\n"+
+ " };\n"+
+ " \n"+
+ " void m1() {\n"+
+ " MR mr = new MR();\n"+
+ " String[] array = {\"one\"};\n"+
+ " Arrays.sort(array, mr::mrCompare);\n"+
+ " }\n"+
+ "}\n",
+ "Y.java",
+ "import java.util.HashSet;\n" +
+ "import java.util.function.Supplier;\n" +
+ "public class Y {\n"+
+ " class MR {\n"+
+ " public <T> void mr(Supplier<T> supplier) {}\n"+
+ " };\n"+
+ " \n"+
+ " void m1() {\n"+
+ " MR mr = new MR();\n"+
+ " mr.mr(HashSet<String>::new);\n"+
+ " }\n"+
+ "}\n"
+ },
+ "\"" + OUTPUT_DIR + File.separator + "Y.java\""
+ +" \"" + OUTPUT_DIR + File.separator + "X.java\""
+ + " -source " + CompilerOptions.getLatestVersion(),
+ "",
+ "",
+ true);
+ String expectedOutput = "Bootstrap methods:\n" +
+ " 0 : # 44 invokestatic java/lang/invoke/LambdaMetafactory.metafactory:(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;\n" +
+ " Method arguments:\n" +
+ " #46 (Ljava/lang/Object;Ljava/lang/Object;)I\n" +
+ " #51 X$MR.mrCompare:(Ljava/lang/String;Ljava/lang/String;)I\n" +
+ " #52 (Ljava/lang/String;Ljava/lang/String;)I\n";
+ checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput);
+}
+}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/PatternMatching14Test.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/PatternMatching14Test.java
index 016414f..7473aaf 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/PatternMatching14Test.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/PatternMatching14Test.java
@@ -1290,6 +1290,27 @@
"one",
options);
}
+ public void test024b() {
+ Map<String, String> options = getCompilerOptions(true);
+ runConformTest(
+ new String[] {
+ "X24a.java",
+ "@SuppressWarnings(\"preview\")\n" +
+ "public class X24a {\n" +
+ " public static void main(String[] o) {\n" +
+ " foo(\"one\");\n" +
+ " }\n" +
+ " public static void foo(Object o) {\n" +
+ " for (;!(o instanceof String s);) {\n" +
+ " throw new IllegalArgumentException();\n" +
+ " }\n" +
+ " System.out.println(s);\n" +
+ " }\n" +
+ "}\n",
+ },
+ "one",
+ options);
+ }
/*
* It's not a problem to define the same var in two operands of a binary expression,
* but then it is not in scope below.
@@ -1695,7 +1716,7 @@
/*
* Failing with VerifyError
*/
- public void _test039() {
+ public void test039() {
runConformTest(
new String[] {
"X39.java",
@@ -1984,7 +2005,7 @@
compilerOptions);
compilerOptions.put(CompilerOptions.OPTION_PreserveUnusedLocal, old);
}
- public void _test051() {
+ public void test051() {
Map<String, String> compilerOptions = getCompilerOptions(true);
String old = compilerOptions.get(CompilerOptions.OPTION_PreserveUnusedLocal);
compilerOptions.put(CompilerOptions.OPTION_PreserveUnusedLocal, CompilerOptions.OPTIMIZE_OUT);
@@ -2583,4 +2604,71 @@
true,
compilerOptions);
}
+ public void test059() {
+ Map<String, String> compilerOptions = getCompilerOptions(true);
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " static int count;\n"+
+ " public static void main(String[] args) {\n"+
+ " int i = 10;\n"+
+ " if (foo() instanceof String s) {\n"+
+ " ++i;\n"+
+ " }\n"+
+ " System.out.println(\"count:\"+X.count+\" i:\"+i);\n"+
+ " }\n"+
+ " public static Object foo() {\n"+
+ " ++X.count;\n"+
+ " return new Object();\n"+
+ " } \n"+
+ "}",
+ },
+ "count:1 i:10",
+ compilerOptions);
+ }
+ public void test060() {
+ Map<String, String> compilerOptions = getCompilerOptions(true);
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " static int count;\n"+
+ " public static void main(String[] args) {\n"+
+ " int i = 10;\n"+
+ " if (foo() instanceof String s) {\n"+
+ " ++i;\n"+
+ " }\n"+
+ " System.out.println(\"count:\"+X.count+\" i:\"+i);\n"+
+ " }\n"+
+ " public static Object foo() {\n"+
+ " ++X.count;\n"+
+ " return new String(\"hello\");\n"+
+ " } \n"+
+ "}",
+ },
+ "count:1 i:11",
+ compilerOptions);
+ }
+ public void test061() {
+ Map<String, String> compilerOptions = getCompilerOptions(true);
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " static int count;\n"+
+ " static String STR = \"FAIL\";\n"+
+ " @SuppressWarnings(\"preview\")\n"+
+ " public static void main(String[] args) {\n"+
+ " if ( switch(STR) {\n"+
+ " default -> \"PASS\";\n"+
+ " } instanceof String s) {\n"+
+ " System.out.println(s);\n"+
+ " }\n"+
+ " }\n"+
+ "}",
+ },
+ "PASS",
+ compilerOptions);
+ }
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RecordsRestrictedClassTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RecordsRestrictedClassTest.java
index 314a553..8aa63ad 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RecordsRestrictedClassTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/RecordsRestrictedClassTest.java
@@ -3898,4 +3898,45 @@
},
"10");
}
+public void testBug565830_01() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "class X {\n"+
+ " void bar() throws Exception {\n"+
+ " record Bar(int x) implements java.io.Serializable {\n"+
+ " void printMyFields() {\n"+
+ " for (var field : this.getClass().getDeclaredFields()) {\n"+
+ " System.out.println(field);\n"+
+ " }\n"+
+ " }\n"+
+ " }\n"+
+ " var bar = new Bar(1);\n"+
+ " bar.printMyFields();\n"+
+ " new java.io.ObjectOutputStream(java.io.OutputStream.nullOutputStream()).writeObject(bar);\n"+
+ " }\n"+
+ " public static void main(String[] args) throws Exception {\n"+
+ " new X().bar();\n"+
+ " }\n"+
+ "}",
+ },
+ "private final int X$1Bar.x");
+}
+public void testBug565787_01() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public record X(String s) {\n"+
+ " public X {\n"+
+ " s.codePoints()\n"+
+ " .forEach(cp -> System.out.println((java.util.function.Predicate<String>) \"\"::equals));\n"+
+ " }\n"+
+ " public static void main(String[] args) {\n"+
+ " X a = new X(\"\");\n"+
+ " a.equals(a);\n"+
+ " }\n"+
+ "}",
+ },
+ "");
+}
}
\ No newline at end of file
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 0cb6f7e..bb95d47 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 @@
static {
// TESTS_NUMBERS = new int [] { 40 };
// TESTS_RANGE = new int[] { 1, -1 };
-// TESTS_NAMES = new String[] { "testBug561766" };
+// TESTS_NAMES = new String[] { "testBug565844_yy" };
}
public static Class<?> testClass() {
@@ -5192,4 +5192,737 @@
"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");
+ }
+ public void testBug565844_01() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " public final static int j = 5;\n" +
+ " public static void main(String argv[]) {\n" +
+ " boolean b = \n" +
+ " switch (j) {\n" +
+ " case j != 1 ? 2 : 3 -> true;\n" +
+ " default -> false;\n" +
+ " }; \n" +
+ " System.out.println(b);\n" +
+ " }\n"+
+ "}"
+ },
+ "false");
+ }
+ public void testBug565844_02() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " public final static int j = 2;\n" +
+ " public static void main(String argv[]) {\n" +
+ " boolean b = \n" +
+ " switch (j) {\n" +
+ " case j != 1 ? 2 : (j == 2 ? 4 : 5) -> true;\n" +
+ " default -> false;\n" +
+ " }; \n" +
+ " System.out.println(b);\n" +
+ " }\n"+
+ "}"
+ },
+ "true");
+ }
+ public void testBug565844_03() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " public final static int j = 5;\n" +
+ " public static void main(String argv[]) {\n" +
+ " boolean b = \n" +
+ " switch (j) {\n" +
+ " case j != 1 ? 2 : 3 -> {\n" +
+ " yield true;\n" +
+ " }\n" +
+ " default -> { yield false;}\n" +
+ " }; \n" +
+ " System.out.println(b);\n" +
+ " }\n"+
+ "}"
+ },
+ "false");
+ }
+ public void testBug565844_04() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " public final static int j = 5;\n" +
+ " public static void main(String argv[]) {\n" +
+ " boolean b = \n" +
+ " switch (j) {\n" +
+ " case j != 1 ? 2 : 3 : {\n" +
+ " yield true;\n" +
+ " }\n" +
+ " default : { yield false;}\n" +
+ " }; \n" +
+ " System.out.println(b);\n" +
+ " }\n"+
+ "}"
+ },
+ "false");
+ }
+ public void testBug565844_05() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " public static int j = 5;\n" +
+ " public static void main(String argv[]) {\n" +
+ " boolean b = \n" +
+ " switch (j) {\n" +
+ " case j != 1 ? 2 : 3 -> {\n" +
+ " yield true;\n" +
+ " }\n" +
+ " default -> { yield false;}\n" +
+ " }; \n" +
+ " System.out.println(b);\n" +
+ " }\n"+
+ "}"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 6)\n" +
+ " case j != 1 ? 2 : 3 -> {\n" +
+ " ^^^^^^^^^^^^^^\n" +
+ "case expressions must be constant expressions\n" +
+ "----------\n");
+ }
+ public void testBug565844_06() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " public final static int j = 5;\n" +
+ " public static void main(String argv[]) {\n" +
+ " boolean b = \n" +
+ " switch (j) {\n" +
+ " case j != 1 ? ( j != 1 ? 2: 3 ) : 3 -> false;\n" +
+ " default -> false;\n" +
+ " }; \n" +
+ " System.out.println(b);\n" +
+ " }\n"+
+ "}"
+ },
+ "false");
+ }
+ public void testBug565844_07() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ "\n"+
+ " void foo() {\n"+
+ " Object value2 = switch(1) {\n"+
+ " case AAABBB -> 1;\n"+
+ " (I)()->();\n"+
+ " default -> 0;\n"+
+ " };\n"+
+ " }\n"+
+ "}\n"+
+ "interface I {\n"+
+ " void apply();\n"+
+ "}"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " case AAABBB -> 1;\n" +
+ " ^\n" +
+ "Syntax error on token \";\", case expected after this token\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 6)\n" +
+ " (I)()->();\n" +
+ " ^^^^^\n" +
+ "Syntax error on token(s), misplaced construct(s)\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 6)\n" +
+ " (I)()->();\n" +
+ " ^\n" +
+ "Syntax error, insert \")\" to complete Expression\n" +
+ "----------\n" +
+ "4. ERROR in X.java (at line 6)\n" +
+ " (I)()->();\n" +
+ " ^\n" +
+ "Syntax error, insert \":\" to complete SwitchLabel\n" +
+ "----------\n");
+ }
+ public void _testBug565844SwitchConst_07() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " public final static int j = 5;\n" +
+ " public static void main(String argv[]) {\n" +
+ " boolean b = \n" +
+ " switch (j) {\n" +
+ " case switch(1) {default -> 2;} -> false;\n" +
+ " default -> false;\n" +
+ " }; \n" +
+ " System.out.println(b);\n" +
+ " }\n"+
+ "}"
+ },
+ "false");
+ }
+ public void _testBug565844SwitchConst_08() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " public final static int j = 5;\n" +
+ " public static void main(String argv[]) {\n" +
+ " boolean b = \n" +
+ " switch (j) {\n" +
+ " case switch(1) {case 1 -> 2; default -> 0;} -> false;\n" +
+ " default -> false;\n" +
+ " }; \n" +
+ " System.out.println(b);\n" +
+ " }\n"+
+ "}"
+ },
+ "false");
+ }
+ public void _testBug565844SwitchConst_09() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " public final static int j = 5;\n" +
+ " public static void main(String argv[]) {\n" +
+ " boolean b = \n" +
+ " switch (j) {\n" +
+ " case switch(1) {default -> 2;}, switch(2) {default -> 3;} -> false;\n" +
+ " default -> false;\n" +
+ " }; \n" +
+ " System.out.println(b);\n" +
+ " }\n"+
+ "}"
+ },
+ "false");
+ }
+ public void _testBug565844SwitchConst_10() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n"+
+ " public final static int j = 5;\n" +
+ " public static void main(String argv[]) {\n" +
+ " boolean b = \n" +
+ " switch (j) {\n" +
+ " case switch(1) {case 1 -> 2; default -> 0;}," +
+ " switch(2) {case 1 -> 3; default -> 4;} -> false;\n" +
+ " default -> false;\n" +
+ " }; \n" +
+ " System.out.println(b);\n" +
+ " }\n"+
+ "}"
+ },
+ "false");
+ }
+ public void testBug566125_01() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " new X().bar(0);\n" +
+ " }\n" +
+ " @SuppressWarnings(\"deprecation\")\n" +
+ " public void bar(int i) {\n" +
+ " boolean b = foo( switch(i+1) {\n" +
+ " case 0 -> new Short((short)0);\n" +
+ " case 2 -> new Double(2.0d);\n" +
+ " default -> new Integer((short)6);\n" +
+ " });\n" +
+ " System.out.println(b);\n" +
+ " }\n" +
+ " boolean foo(short data){ return false; }\n" +
+ " boolean foo(byte data){ return false; }\n" +
+ " boolean foo(int data){ return false; }\n" +
+ " boolean foo(float data){ return false; }\n" +
+ " boolean foo(long data){ return false; }\n" +
+ " boolean foo(double data){ return true; }\n" +
+ "}"
+ },
+ "true");
+
+ }
+ // Same as above, but with explicit yield
+ public void testBug566125_02() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " new X().bar(0);\n" +
+ " }\n" +
+ " @SuppressWarnings(\"deprecation\")\n" +
+ " public void bar(int i) {\n" +
+ " boolean b = foo( switch(i+1) {\n" +
+ " case 0 : yield new Short((short)0);\n" +
+ " case 2 : yield new Double(2.0d);\n" +
+ " default : yield new Integer((short)6);\n" +
+ " });\n" +
+ " System.out.println(b);\n" +
+ " }\n" +
+ " boolean foo(short data){ return false; }\n" +
+ " boolean foo(byte data){ return false; }\n" +
+ " boolean foo(int data){ return false; }\n" +
+ " boolean foo(float data){ return false; }\n" +
+ " boolean foo(long data){ return false; }\n" +
+ " boolean foo(double data){ return true; }\n" +
+ "}"
+ },
+ "true");
+
+ }
+ public void testBug566125_03() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " new X().bar(0);\n" +
+ " }\n" +
+ " @SuppressWarnings(\"deprecation\")\n" +
+ " public void bar(int i) {\n" +
+ " boolean b = foo( switch(i+1) {\n" +
+ " case 0 -> new Short((short)0);\n" +
+ " case 2 -> 2.0d;\n" +
+ " default -> new Integer((short)6);\n" +
+ " });\n" +
+ " System.out.println(b);\n" +
+ " }\n" +
+ " boolean foo(short data){ return false; }\n" +
+ " boolean foo(byte data){ return false; }\n" +
+ " boolean foo(int data){ return false; }\n" +
+ " boolean foo(float data){ return false; }\n" +
+ " boolean foo(long data){ return false; }\n" +
+ " boolean foo(double data){ return true; }\n" +
+ "}"
+ },
+ "true");
+
+ }
+ // Long -> float is accepted
+ public void testBug566125_04() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " new X().bar(0);\n" +
+ " }\n" +
+ " @SuppressWarnings(\"deprecation\")\n" +
+ " public void bar(int i) {\n" +
+ " boolean b = foo( switch(i+1) {\n" +
+ " case 0 -> new Integer((short)0);\n" +
+ " default -> 2l;\n" +
+ " });\n" +
+ " System.out.println(b);\n" +
+ " }\n" +
+ " boolean foo(int data){ return false; }\n" +
+ " boolean foo(long data){ return true; }\n" +
+ "}"
+ },
+ "true");
+
+ }
+ public void testBug566125_05() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " new X().bar(0);\n" +
+ " }\n" +
+ " @SuppressWarnings(\"deprecation\")\n" +
+ " public void bar(int i) {\n" +
+ " boolean b = foo(\n" +
+ " switch(i%2) {\n" +
+ " case 1 -> switch(i) {\n" +
+ " case 1 -> new Byte((byte)1);\n" +
+ " case 3 -> new Float(3);\n" +
+ " case 5 -> new Long(5);\n" +
+ " default -> new Short((short)6);\n" +
+ " }; \n" +
+ " default -> switch(i) {\n" +
+ " case 0 -> new Integer((byte)2);\n" +
+ " case 2 -> new Double(4);\n" +
+ " case 4 -> new Long(6);\n" +
+ " default -> new Short((short)8);\n" +
+ " };\n" +
+ " }\n" +
+ " );\n" +
+ " System.out.println(b);\n" +
+ " }\n" +
+ " boolean foo(short data){ return false; }\n" +
+ " boolean foo(byte data){ return false; }\n" +
+ " boolean foo(int data){ return false; }\n" +
+ " boolean foo(float data){ return false; }\n" +
+ " boolean foo(long data){ return false; }\n" +
+ " boolean foo(double data){ return true; }\n" +
+ "}"
+ },
+ "true"
+ );
+
+ }
+ public void testBug566125_06() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " new X().bar(0);\n" +
+ " }\n" +
+ " @SuppressWarnings(\"deprecation\")\n" +
+ " public void bar(int i) {\n" +
+ " boolean b = foo( switch(i+1) {\n" +
+ " case 0 -> new Short((short)0);\n" +
+ " default -> new Double(2.0d);\n" +
+ " });\n" +
+ " System.out.println(b);\n" +
+ " }\n" +
+ " boolean foo(short data){ return false; }\n" +
+ " boolean foo(byte data){ return false; }\n" +
+ " boolean foo(int data){ return false; }\n" +
+ " boolean foo(float data){ return false; }\n" +
+ " boolean foo(long data){ return false; }\n" +
+ "}"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 7)\n" +
+ " boolean b = foo( switch(i+1) {\n" +
+ " ^^^\n" +
+ "The method foo(short) in the type X is not applicable for the arguments (double)\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 9)\n" +
+ " default -> new Double(2.0d);\n" +
+ " ^^^^^^^^^^^^^^^^\n" +
+ "Type mismatch: cannot convert from Double to short\n" +
+ "----------\n"
+ );
+ }
+ public void testBug566125_07() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " new X().bar(0);\n" +
+ " }\n" +
+ " @SuppressWarnings(\"deprecation\")\n" +
+ " public void bar(int i) {\n" +
+ " boolean b = foo( switch(i+1) {\n" +
+ " case 0 -> new Short((short)0);\n" +
+ " default -> 2.0d;\n" +
+ " });\n" +
+ " System.out.println(b);\n" +
+ " }\n" +
+ " boolean foo(short data){ return false; }\n" +
+ " boolean foo(byte data){ return false; }\n" +
+ " boolean foo(int data){ return false; }\n" +
+ " boolean foo(float data){ return false; }\n" +
+ " boolean foo(long data){ return false; }\n" +
+ "}"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 7)\n" +
+ " boolean b = foo( switch(i+1) {\n" +
+ " ^^^\n" +
+ "The method foo(short) in the type X is not applicable for the arguments (double)\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 9)\n" +
+ " default -> 2.0d;\n" +
+ " ^^^^\n" +
+ "Type mismatch: cannot convert from double to short\n" +
+ "----------\n"
+ );
+ }
+ // Same as 07() but with explicit yield
+ public void testBug566125_08() {
+ runNegativeTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " new X().bar(0);\n" +
+ " }\n" +
+ " @SuppressWarnings(\"deprecation\")\n" +
+ " public void bar(int i) {\n" +
+ " boolean b = foo( switch(i+1) {\n" +
+ " case 0 : yield new Short((short)0);\n" +
+ " default : yield 2.0d;\n" +
+ " });\n" +
+ " System.out.println(b);\n" +
+ " }\n" +
+ " boolean foo(short data){ return false; }\n" +
+ " boolean foo(byte data){ return false; }\n" +
+ " boolean foo(int data){ return false; }\n" +
+ " boolean foo(float data){ return false; }\n" +
+ " boolean foo(long data){ return false; }\n" +
+ "}"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 7)\n" +
+ " boolean b = foo( switch(i+1) {\n" +
+ " ^^^\n" +
+ "The method foo(short) in the type X is not applicable for the arguments (double)\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 9)\n" +
+ " default : yield 2.0d;\n" +
+ " ^^^^\n" +
+ "Type mismatch: cannot convert from double to short\n" +
+ "----------\n"
+ );
+ }
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java
index 379bbb1..e08709e 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java
@@ -200,6 +200,7 @@
since_14.add(RecordsRestrictedClassTest.class);
since_14.add(PatternMatching14Test.class);
since_14.add(JavadocTestForRecord.class);
+ since_14.add(BatchCompilerTest_14.class);
// Build final test suite
TestSuite all = new TestSuite(TestAll.class.getName());
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TextBlockTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TextBlockTest.java
index 99244e5..f9400d4 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TextBlockTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TextBlockTest.java
@@ -61,6 +61,42 @@
protected void runConformTest(String[] testFiles, String expectedOutput, Map<String, String> customOptions, String[] vmArguments) {
runConformTest(testFiles, expectedOutput, customOptions, vmArguments, new JavacTestOptions("-source 14 --enable-preview"));
}
+ protected void runConformTest(
+ // test directory preparation
+ boolean shouldFlushOutputDirectory,
+ String[] testFiles,
+ //compiler options
+ String[] classLibraries /* class libraries */,
+ Map<String, String> customOptions /* custom options */,
+ // compiler results
+ String expectedCompilerLog,
+ // runtime results
+ String expectedOutputString,
+ String expectedErrorString,
+ String[] vmarguments,
+ // javac options
+ JavacTestOptions javacTestOptions) {
+ runTest(
+ // test directory preparation
+ shouldFlushOutputDirectory /* should flush output directory */,
+ testFiles /* test files */,
+ // compiler options
+ classLibraries /* class libraries */,
+ customOptions /* custom options */,
+ false /* do not perform statements recovery */,
+ null /* no custom requestor */,
+ // compiler results
+ false /* expecting no compiler errors */,
+ expectedCompilerLog /* expected compiler log */,
+ // runtime options
+ false /* do not force execution */,
+ vmarguments /* no vm arguments */,
+ // runtime results
+ expectedOutputString /* expected output string */,
+ expectedErrorString /* expected error string */,
+ // javac options
+ javacTestOptions /* javac test options */);
+ }
public void test001() {
runNegativeTest(
new String[] {
@@ -1352,4 +1388,150 @@
getCompilerOptions(),
new String[] {"--enable-preview"});
}
+ public void testBug565639_1() {
+ runConformTest(true,
+ new String[]{
+ "X.java",
+ "public class X {\n" +
+ " static final String TEXT_BLOCK = \"\"\"\n" +
+ " 1\n" +
+ " 2\n" +
+ " 3\n" +
+ " 4\n" +
+ " 5\n" +
+ " \"\"\";\n" +
+ " public static void main(String[] args) {\n" +
+ " throw new RuntimeException(\"This is line 10.\");\n" +
+ " }\n" +
+ "}\n"
+ },
+ null,
+ getCompilerOptions(),
+ "",
+ "",
+ "Exception in thread \"main\" java.lang.RuntimeException: This is line 10.\n" +
+ " at X.main(X.java:10)",
+ new String[] {"--enable-preview"},
+ new JavacTestOptions("-source 14 --enable-preview"));
+ }
+ public void testBug565639_2() {
+ runConformTest(true,
+ new String[]{
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " String TEXT_BLOCK = \"\"\"\n" +
+ " 1\n" +
+ " 2\n" +
+ " 3\n" +
+ " 4\n" +
+ " 5\n" +
+ " \"\"\";\n" +
+ " throw new RuntimeException(\"This is line 10.\");\n" +
+ " }\n" +
+ "}\n"
+ },
+ null,
+ getCompilerOptions(),
+ "",
+ "",
+ "Exception in thread \"main\" java.lang.RuntimeException: This is line 10.\n" +
+ " at X.main(X.java:10)",
+ new String[] {"--enable-preview"},
+ new JavacTestOptions("-source 14 --enable-preview"));
+ }
+ public void testBug565639_3() {
+ runNegativeTest(new String[]{
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " String TEXT_BLOCK = \"\"\"\n" +
+ " 1\n" +
+ " 2\n" +
+ " 3\n" +
+ " 4\n" +
+ " 5\n" +
+ " \"\"\"\";\n" +
+ " throw new RuntimeException(\"This is line 10.\");\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 9)\n" +
+ " \"\"\"\";\n" +
+ " ^^\n" +
+ "String literal is not properly closed by a double-quote\n" +
+ "----------\n");
+ }
+ public void testBug565639_4() {
+ runNegativeTest(new String[]{
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " String TEXT_BLOCK = \"\"\"\n" +
+ " 1\n" +
+ " 2\n" +
+ " 3\n" +
+ " 4\n" +
+ " 5\n" +
+ " \"\"\"\"\";\n" +
+ " throw new RuntimeException(\"This is line 10.\");\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 9)\n" +
+ " \"\"\"\"\";\n" +
+ " ^^\n" +
+ "Syntax error on token \"\"\"\", delete this token\n" +
+ "----------\n");
+ }
+ public void testBug565639_5() {
+ runNegativeTest(new String[]{
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " String TEXT_BLOCK = \"\"\"\n" +
+ " 1\n" +
+ " 2\n" +
+ " 3\n" +
+ " 4\n" +
+ " 5\n" +
+ " \\\"\"\"\"\"\";\n" +
+ " throw new RuntimeException(\"This is line 10.\");\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 9)\n" +
+ " \\\"\"\"\"\"\";\n" +
+ " ^^\n" +
+ "Syntax error on token \"\"\"\", delete this token\n" +
+ "----------\n");
+ }
+ public void testBug565639_6() {
+ runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " String TEXT_BLOCK = \"\"\"\n" +
+ " 1\n" +
+ " 2\n" +
+ " 3\n" +
+ " 4\n" +
+ " \\\"\"\"\n" +
+ " \"\"\";\n" +
+ " System.out.println(TEXT_BLOCK);\n" +
+ " }\n" +
+ "}\n"
+ },
+ "1\n" +
+ "2\n" +
+ "3\n" +
+ "4\n" +
+ "\"\"\"",
+ getCompilerOptions(),
+ new String[] {"--enable-preview"});
+ }
}
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 4d86661..a07548a 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 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import java.util.Vector;
import junit.framework.TestCase;
@@ -244,13 +243,13 @@
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 @@
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 8243de2..102ee6d 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 @@
}
// 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 @@
} 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 @@
}
} 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 14e51e2..f25cbb7 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 @@
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 @@
}
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 @@
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 @@
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 e19bb7a..4e88b85 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 @@
*/
@Override
public String[] getCommandLine() {
- Vector commandLine= new Vector();
+ List<String> commandLine= new ArrayList<>();
// VM binary
String vmLocation = this.vmPath +
@@ -42,59 +42,59 @@
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 @@
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 adadab7..d8129a3 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 @@
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 @@
* 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 @@
*/
@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 @@
// 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 @@
* 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 @@
"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 @@
// 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 45c987b..03c5869 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.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 @@
*/
@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 @@
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 @@
// 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 @@
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 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 05a6622..ff85b4a 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 @@
* instances will be able to retrieve only a part of the running VMs.
* </ul>
*/
-@SuppressWarnings({ "unchecked", "rawtypes" })
public abstract class LocalVMLauncher implements RuntimeConstants {
private static final boolean PWR_DEBUG = Boolean.getBoolean("ot.debug.pwr");
@@ -57,7 +56,7 @@
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;
@@ -231,12 +230,10 @@
*/
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;
@@ -244,7 +241,7 @@
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;
}
/**
@@ -413,7 +410,7 @@
// 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 34ae7f0..af6e8f9 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 @@
// 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 @@
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 7e08767..8df922a 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 @@
// 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 @@
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 6c0b8e4..e7e243f 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 @@
// 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 @@
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 3e25d3c..223c31c 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.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 @@
* 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 @@
*/
@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 @@
.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 @@
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 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");