Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2018-03-22 10:49:25 -0400
committerStephan Herrmann2018-03-22 10:49:25 -0400
commit4e2d7c2efe32b6527253cfa4f99ccfb23310c744 (patch)
tree82c1e7da9eea84969c8a07ac93b386550c1e3f0e
parent101576b4749a3dd59609609710f6e8e21366a1c2 (diff)
downloadeclipse.jdt.core-4e2d7c2efe32b6527253cfa4f99ccfb23310c744.tar.gz
eclipse.jdt.core-4e2d7c2efe32b6527253cfa4f99ccfb23310c744.tar.xz
eclipse.jdt.core-4e2d7c2efe32b6527253cfa4f99ccfb23310c744.zip
Bug 528350 - [10] update in JLS 7.5.3 re duplicate static importsS4_7_3_aRC1M20180323-1030M20180322-1835M20180322-1700
-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