diff options
author | jay | 2018-10-22 10:34:04 +0000 |
---|---|---|
committer | jay | 2018-10-23 10:15:25 +0000 |
commit | 13677b0b27b6c715be648424eaf9c38c9ae5c410 (patch) | |
tree | cfef9a09c063fc8eb664e55a286ba064e63fb347 | |
parent | 0584f9821f03fdb5e3f6fd3dc072cc2e936cc4ff (diff) | |
download | eclipse.jdt.core-13677b0b27b6c715be648424eaf9c38c9ae5c410.tar.gz eclipse.jdt.core-13677b0b27b6c715be648424eaf9c38c9ae5c410.tar.xz eclipse.jdt.core-13677b0b27b6c715be648424eaf9c38c9ae5c410.zip |
Bug 540123 - Comparator errors in I20181014-2350 after moving to 4.10M1I20181023-1200I20181023-0800
compiler
Change-Id: I3602c6ab91e55f370635196e082ad1872234498b
Signed-off-by: jay <jarthana@in.ibm.com>
2 files changed, 171 insertions, 4 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest2.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest2.java index 4353188719..8d21da2704 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest2.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest2.java @@ -196,4 +196,169 @@ public void test006() throws Exception { String expectedOutput = "// Compiled from X.java (version 11 : 55.0, super bit)"; checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput); } -}
\ No newline at end of file +public void testBug540123a() throws Exception { + this.runConformTest( + new String[] { + "SecurePrefs.java", + "public class SecurePrefs {\n" + + " public SecurePrefs node (String s) {\n" + + " System.out.println(s);\n" + + " return null;\n" + + " }\n" + + "}", + "SecurePrefsRoot.java", + "public class SecurePrefsRoot extends SecurePrefs {\n" + + "\n" + + " public void foo() {\n" + + " SecurePrefs node = node(\"Hello\");\n" + + " if (node != null)\n" + + " System.out.println(node.toString());\n" + + " }\n" + + " \n" + + " public static void main(String[] args) {\n" + + " new SecurePrefsRoot().foo();\n" + + " }\n" + + "}" + }, + "\"" + OUTPUT_DIR + File.separator + "SecurePrefsRoot.java\"" + +" \"" + OUTPUT_DIR + File.separator + "SecurePrefs.java\"" + + " -source 1.3 -target 1.2", + "", + "", + true); + String expectedOutput = "invokevirtual SecurePrefsRoot.node(java.lang.String) : SecurePrefs [14]"; + checkDisassembledClassFile(OUTPUT_DIR + File.separator + "SecurePrefsRoot.class", "SecurePrefsRoot", expectedOutput); +} +public void testBug540123b() throws Exception { + this.runConformTest( + new String[] { + "SecurePrefs.java", + "public class SecurePrefs {\n" + + " public SecurePrefs node (String s) {\n" + + " System.out.println(s);\n" + + " return null;\n" + + " }\n" + + "}", + "SecurePrefsRoot.java", + "public class SecurePrefsRoot extends SecurePrefs {\n" + + "\n" + + " public void foo() {\n" + + " SecurePrefs node = node(\"Hello\");\n" + + " if (node != null)\n" + + " System.out.println(node.toString());\n" + + " }\n" + + " \n" + + " public static void main(String[] args) {\n" + + " new SecurePrefsRoot().foo();\n" + + " }\n" + + "}" + }, + "\"" + OUTPUT_DIR + File.separator + "SecurePrefsRoot.java\"" + +" \"" + OUTPUT_DIR + File.separator + "SecurePrefs.java\"" + + " -source 1.3", + "", + "", + true); + String expectedOutput = "invokevirtual SecurePrefsRoot.node(java.lang.String) : SecurePrefs [14]"; + checkDisassembledClassFile(OUTPUT_DIR + File.separator + "SecurePrefsRoot.class", "SecurePrefsRoot", expectedOutput); +} +public void testBug540123c() throws Exception { + this.runConformTest( + new String[] { + "SecurePrefs.java", + "public class SecurePrefs {\n" + + " public SecurePrefs node (String s) {\n" + + " System.out.println(s);\n" + + " return null;\n" + + " }\n" + + "}", + "SecurePrefsRoot.java", + "public class SecurePrefsRoot extends SecurePrefs {\n" + + "\n" + + " public void foo() {\n" + + " SecurePrefs node = node(\"Hello\");\n" + + " if (node != null)\n" + + " System.out.println(node.toString());\n" + + " }\n" + + " \n" + + " public static void main(String[] args) {\n" + + " new SecurePrefsRoot().foo();\n" + + " }\n" + + "}" + }, + "\"" + OUTPUT_DIR + File.separator + "SecurePrefsRoot.java\"" + +" \"" + OUTPUT_DIR + File.separator + "SecurePrefs.java\"" + + " -target 1.3", + "", + "", + true); + String expectedOutput = "invokevirtual SecurePrefsRoot.node(java.lang.String) : SecurePrefs [14]"; + checkDisassembledClassFile(OUTPUT_DIR + File.separator + "SecurePrefsRoot.class", "SecurePrefsRoot", expectedOutput); +} +public void testBug540123d() throws Exception { + this.runConformTest( + new String[] { + "SecurePrefs.java", + "public class SecurePrefs {\n" + + " public SecurePrefs node (String s) {\n" + + " System.out.println(s);\n" + + " return null;\n" + + " }\n" + + "}", + "SecurePrefsRoot.java", + "public class SecurePrefsRoot extends SecurePrefs {\n" + + "\n" + + " public void foo() {\n" + + " SecurePrefs node = node(\"Hello\");\n" + + " if (node != null)\n" + + " System.out.println(node.toString());\n" + + " }\n" + + " \n" + + " public static void main(String[] args) {\n" + + " new SecurePrefsRoot().foo();\n" + + " }\n" + + "}" + }, + "\"" + OUTPUT_DIR + File.separator + "SecurePrefsRoot.java\"" + +" \"" + OUTPUT_DIR + File.separator + "SecurePrefs.java\"" + + " -1.4", + "", + "", + true); + String expectedOutput = "invokevirtual SecurePrefsRoot.node(java.lang.String) : SecurePrefs [14]"; + checkDisassembledClassFile(OUTPUT_DIR + File.separator + "SecurePrefsRoot.class", "SecurePrefsRoot", expectedOutput); +} +public void testBug540123e() throws Exception { + this.runConformTest( + new String[] { + "SecurePrefs.java", + "public class SecurePrefs {\n" + + " public SecurePrefs node (String s) {\n" + + " System.out.println(s);\n" + + " return null;\n" + + " }\n" + + "}", + "SecurePrefsRoot.java", + "public class SecurePrefsRoot extends SecurePrefs {\n" + + "\n" + + " public void foo() {\n" + + " SecurePrefs node = node(\"Hello\");\n" + + " if (node != null)\n" + + " System.out.println(node.toString());\n" + + " }\n" + + " \n" + + " public static void main(String[] args) {\n" + + " new SecurePrefsRoot().foo();\n" + + " }\n" + + "}" + }, + "\"" + OUTPUT_DIR + File.separator + "SecurePrefsRoot.java\"" + +" \"" + OUTPUT_DIR + File.separator + "SecurePrefs.java\"" + + " -1.3", + "", + "", + true); + String expectedOutput = "invokevirtual SecurePrefs.node(java.lang.String) : SecurePrefs [14]"; + checkDisassembledClassFile(OUTPUT_DIR + File.separator + "SecurePrefsRoot.class", "SecurePrefsRoot", expectedOutput); +} +} diff --git a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java index 0c08f07347..614e0198fd 100644 --- a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java +++ b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java @@ -5408,11 +5408,13 @@ protected void validateOptions(boolean didSpecifyCompliance) { || CompilerOptions.VERSION_1_6.equals(source)) { this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_6); } else { - if (CompilerOptions.versionToJdkLevel(source) > 0) + // 1.3 is the lowest version that can be specified as -source + // The following check will ensure '0' is ignored. + if (CompilerOptions.versionToJdkLevel(source) >= ClassFileConstants.JDK1_7) this.options.put(CompilerOptions.OPTION_TargetPlatform, source); } } else { - if (CompilerOptions.versionToJdkLevel(version) > 0) { + if (CompilerOptions.versionToJdkLevel(version) > ClassFileConstants.JDK10) { this.options.put(CompilerOptions.OPTION_Source, version); this.options.put(CompilerOptions.OPTION_TargetPlatform, version); } @@ -5445,7 +5447,7 @@ protected void validateOptions(boolean didSpecifyCompliance) { if (!didSpecifyCompliance) this.options.put(CompilerOptions.OPTION_Compliance, CompilerOptions.VERSION_10); if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_10); } else { - if (CompilerOptions.versionToJdkLevel(version) > 0) { + if (CompilerOptions.versionToJdkLevel(version) > ClassFileConstants.JDK10) { if (!didSpecifyCompliance) this.options.put(CompilerOptions.OPTION_Compliance, version); if (!this.didSpecifyTarget) this.options.put(CompilerOptions.OPTION_TargetPlatform, version); } |