Bug 528350 - [10] update in JLS 7.5.3 re duplicate static imports
Change-Id: I8248570eb4da4244d1911f7f2238efc7759b8edf
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NonFatalErrorTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NonFatalErrorTest.java
index fb40737..e9f6f6e 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NonFatalErrorTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NonFatalErrorTest.java
@@ -528,4 +528,51 @@
"",
JavacTestOptions.SKIP);
}
+ public void testDuplicateImports1() {
+ if (this.complianceLevel < ClassFileConstants.JDK1_5) return; // uses static imports
+ runConformTest(
+ new String[] {
+ "Test.java",
+ "import java.lang.Character.Subset;\n" +
+ "import static java.lang.Character.Subset;\n" +
+ "\n" +
+ "public class Test {\n" +
+ " Subset s = null;\n" +
+ "}\n"
+ });
+ }
+ public void testDuplicateImports2() {
+ if (this.complianceLevel < ClassFileConstants.JDK1_5) return; // uses static imports
+ runConformTest(
+ new String[] {
+ "Test.java",
+ "import static java.awt.geom.Line2D.Double;\n" +
+ "import static java.awt.geom.Line2D.Double;\n" +
+ "\n" +
+ "public class Test {\n" +
+ " Double d = null;\n" +
+ "}\n"
+ });
+ }
+ public void testDuplicateImports3() {
+ if (this.complianceLevel < ClassFileConstants.JDK1_5) return; // uses static imports
+ runNegativeTest(
+ new String[] {
+ "Test.java",
+ // JLS doesn't really allow this duplication, but also javac defers the error to the use site, see:
+ // https://bugs.openjdk.java.net/browse/JDK-8133619?focusedCommentId=14133759&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14133759
+ "import static java.awt.geom.Line2D.Double;\n" +
+ "import static java.awt.geom.Point2D.Double;\n" +
+ "\n" +
+ "public class Test {\n" +
+ " Double d = null;\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in Test.java (at line 5)\n" +
+ " Double d = null;\n" +
+ " ^^^^^^\n" +
+ "The type Double is ambiguous\n" +
+ "----------\n");
+ }
}