Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NonFatalErrorTest.java47
1 files changed, 47 insertions, 0 deletions
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 fb40737360..e9f6f6e507 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 @@ public class NonFatalErrorTest extends AbstractRegressionTest {
"",
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");
+ }
}

Back to the top