Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2018-04-01 17:57:20 +0000
committerStephan Herrmann2018-04-01 17:57:20 +0000
commit509a5d5d16376875804532f15c85dc575c939c6c (patch)
treea58df595bd4d5859001d430236554c6ef312a4eb
parentf395e31ac969c27f9e714e461cf4d6089bc4f0ef (diff)
downloadorg.eclipse.objectteams-509a5d5d16376875804532f15c85dc575c939c6c.tar.gz
org.eclipse.objectteams-509a5d5d16376875804532f15c85dc575c939c6c.tar.xz
org.eclipse.objectteams-509a5d5d16376875804532f15c85dc575c939c6c.zip
Update jdt.core to 4.7.3a RC2
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JEP286Test.java416
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ModuleCompilationTests.java20
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NonFatalErrorTest.java21
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter10Test.java57
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/Java9ElementTests.java13
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java144
-rw-r--r--org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/TypeResolveTests.java76
-rw-r--r--org.eclipse.jdt.core/.settings/.api_filters59
-rw-r--r--org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJep247.java23
-rw-r--r--org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java9
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java12
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/AnnotationInfo.java59
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileReader.java3
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFormatException.java6
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/MethodInfo.java48
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java7
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java5
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/AnnotationBinding.java9
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CaptureBinding.java62
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java10
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemReferenceBinding.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/RawTypeBinding.java10
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java9
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java33
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties18
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/JRTUtil.java47
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/ast/MethodSpec.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/ast/PrecedenceDeclaration.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/ast/TypeAnchorReference.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/lookup/AnchorMapping.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/lookup/OTClassScope.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/util/RoleTypeCreator.java4
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java6
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java4
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SimpleName.java77
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/core/Signature.java99
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/AbstractClassFile.java3
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SelectionRequestor.java10
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJrt.java17
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathLocation.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/MementoTokenizer.java2
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Util.java28
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/nd/java/model/BinaryModuleFactory.java7
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/BinaryIndexer.java12
-rw-r--r--org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/JavaSearchNameEnvironment.java2
48 files changed, 1303 insertions, 168 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JEP286Test.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JEP286Test.java
index 20e5a1488..be264f964 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JEP286Test.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/JEP286Test.java
@@ -789,4 +789,420 @@ public void testBug532351() throws IOException {
"No enclosing instance of type X is accessible. Must qualify the allocation with an enclosing instance of type X (e.g. x.new A() where x is an instance of X).\n" +
"----------\n");
}
+public void testBug531025() {
+ runNegativeTest(
+ new String[] {
+ "a/Ann.java",
+ "package a;\n" +
+ "public @interface Ann {}\n",
+ "a/AnnM.java",
+ "package a;\n" +
+ "import java.lang.annotation.*;\n" +
+ "@Target(ElementType.METHOD)\n" +
+ "public @interface AnnM {}\n",
+ "a/AnnD.java",
+ "package a;\n" +
+ "import java.lang.annotation.*;\n" +
+ "@Target(ElementType.LOCAL_VARIABLE)\n" +
+ "public @interface AnnD {}\n",
+ "a/AnnT.java",
+ "package a;\n" +
+ "import java.lang.annotation.*;\n" +
+ "@Target(ElementType.TYPE_USE)\n" +
+ "public @interface AnnT {}\n",
+ "a/AnnDT.java",
+ "package a;\n" +
+ "import java.lang.annotation.*;\n" +
+ "@Target({ElementType.LOCAL_VARIABLE, ElementType.TYPE_USE})\n" +
+ "public @interface AnnDT {}\n",
+ "X.java",
+ "import a.*;\n" +
+ "import java.util.*;\n" +
+ "public class X {\n" +
+ " void test(List<String> strings) {\n" +
+ " @Ann var v = strings;\n" +
+ " @AnnM var vm = strings;\n" +
+ " @AnnD var vd = strings;\n" +
+ " @AnnT var vt = \"\";\n" +
+ " @AnnDT var vdt = this;\n" +
+ " for (@AnnD var fvd : strings) {}\n" +
+ " for (@AnnT var fvt : strings) {}\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 6)\n" +
+ " @AnnM var vm = strings;\n" +
+ " ^^^^^\n" +
+ "The annotation @AnnM is disallowed for this location\n" +
+ "----------\n" +
+ "2. ERROR in X.java (at line 8)\n" +
+ " @AnnT var vt = \"\";\n" +
+ " ^^^^^\n" +
+ "The annotation @AnnT is disallowed for this location\n" +
+ "----------\n" +
+ "3. ERROR in X.java (at line 11)\n" +
+ " for (@AnnT var fvt : strings) {}\n" +
+ " ^^^^^\n" +
+ "The annotation @AnnT is disallowed for this location\n" +
+ "----------\n");
+}
+public void testBug532349_001() throws IOException {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "class X {\n" +
+ " public static void foo() {\n" +
+ " Y<? extends Number> y = new Y<>();\n" +
+ " var v = y.t;\n" +
+ " Integer dsbType0 = v;\n" +
+ " }\n" +
+ "}\n" +
+ "class Y<T extends Integer> {\n" +
+ " public T t;\n" +
+ "}"
+ });
+}
+public void testBug532349_002() throws IOException {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "class X {\n" +
+ " public static void foo() {\n" +
+ " Y<? extends I> y = new Y<>();\n" +
+ " var v = y.t;\n" +
+ " Integer dsbType0 = v;\n" +
+ " }\n" +
+ "}\n" +
+ "interface I { }\n" +
+ "class Y<T extends Integer> {\n" +
+ " public T t;\n" +
+ "}"
+ });
+}
+public void testBug532349_003() throws IOException {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "class X {\n" +
+ " public static void foo(Y<? extends I> y) {\n" +
+ " var v = y.t;\n" +
+ " Integer dsbType0 = v;\n" +
+ " I i = v;\n" +
+ " }\n" +
+ "}\n" +
+ "interface I { }\n" +
+ "class Y<T extends Integer> {\n" +
+ " public T t;\n" +
+ "}"
+ });
+}
+public void testBug532349_004() throws IOException {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "import java.io.Serializable;\n" +
+ "class X {\n" +
+ " public static void foo() {\n" +
+ " Y<? extends Integer> y = new Y<>();\n" +
+ " var v = y.t;\n" +
+ " Integer dsbType0 = v;\n" +
+ " Serializable s = v;\n" +
+ " }\n" +
+ "}\n" +
+ "class Y<T extends Number&Serializable> {\n" +
+ " public T t;\n" +
+ "}"
+ });
+}
+public void testBug532349_005() throws IOException {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "import java.io.Serializable;\n" +
+ "class X {\n" +
+ " public static void foo() {\n" +
+ " Y<?> y = new Y<>();\n" +
+ " var v = y.t;\n" +
+ " I i = v;\n" +
+ " Serializable s = v;\n" +
+ " }\n" +
+ "}\n" +
+ "interface I { }\n" +
+ "class Y<T extends I&Serializable> {\n" +
+ " public T t;\n" +
+ "}"
+ });
+}
+public void testBug532349_006() throws IOException {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "import java.io.Serializable;\n" +
+ "class X {\n" +
+ " public static void foo() {\n" +
+ " Y<? extends I> y = new Y<>();\n" +
+ " var v = y.t;\n" +
+ " I i = v;\n" +
+ " Serializable s = v;\n" +
+ " }\n" +
+ "}\n" +
+ "interface I { }\n" +
+ "class Y<T extends Serializable> {\n" +
+ " public T t;\n" +
+ "}",
+ });
+}
+public void testBug532349_007() throws IOException {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "class X {\n" +
+ " public static void foo() {\n" +
+ " Z<? extends I> z = new Z<>();\n" +
+ " var v = z.t;\n" +
+ " X x = v.t;\n" +
+ " v.doSomething();\n" +
+ " }\n" +
+ "}\n" +
+ "interface I { void doSomething();}\n" +
+ "class Z<T extends Y<?>> {\n" +
+ " public T t;\n" +
+ "}\n" +
+ "class Y<T extends X> {\n" +
+ " public T t;\n" +
+ "}",
+ });
+}
+public void testBug532349_008() throws IOException {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "class X {\n" +
+ " public static void foo() {\n" +
+ " Z<? extends Y<? extends C>> z = new Z<>();\n" +
+ " var v = z.t;\n" +
+ " C c = v.t;\n" +
+ " v.doSomething();\n" +
+ " }\n" +
+ "}\n" +
+ "interface I { void doSomething();}\n" +
+ "class C extends X{ }\n" +
+ "class Z<T extends I> {\n" +
+ " public T t;\n" +
+ "}\n" +
+ "class Y<T extends X> {\n" +
+ " public T t;\n" +
+ "}",
+ });
+}
+public void testBug532349_009() throws IOException {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "import java.io.Serializable;\n" +
+ "class X {\n" +
+ " public static void foo() {\n" +
+ " Y<? super J> y = new Y<>();\n" +
+ " var v = y.t;\n" +
+ " I i = v;\n" +
+ " Serializable s = v;\n" +
+ " }\n" +
+ "}\n" +
+ "interface I { }\n" +
+ "interface J extends I{}" +
+ "class Y<T extends I> {\n" +
+ " public T t;\n" +
+ "}",
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 7)\n" +
+ " Serializable s = v;\n" +
+ " ^\n" +
+ "Type mismatch: cannot convert from I to Serializable\n" +
+ "----------\n");
+}
+public void testBug532349_010() throws IOException {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "import java.io.Serializable;\n" +
+ "class X {\n" +
+ " public static void foo(C<?> c) {\n" +
+ " var v = c.t;\n" +
+ " v = (I&Serializable) new D();\n" +
+ " v.doSomething();\n" +
+ " }\n" +
+ "}\n" +
+ "interface I { void doSomething();}\n" +
+ "class C<T extends I&Serializable>{ T t;}\n" +
+ "class D implements I, Serializable { public void doSomething() {} }\n"
+ });
+}
+public void testBug532349_11() throws IOException {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "class X {\n" +
+ " static <R extends D<? extends Y>> W<? extends R> boo() {\n" +
+ " return null;\n" +
+ " }\n" +
+ " public static void foo() {\n" +
+ " var v = boo();\n" +
+ " var var = v.t;\n" +
+ " Y y = var.r;\n" +
+ " }\n" +
+ "}\n" +
+ "class Y extends X { }\n" +
+ "class D<R extends X>{ R r;}\n" +
+ "class W<T extends D<?>> { T t; }\n"
+ });
+}
+public void testBug532349_12() throws IOException {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "class X {\n" +
+ " public static void foo(D<?> d) {\n" +
+ " var v = d;\n" +
+ " D<? extends Y> dy = v;\n" +
+ " D<? extends X> dx = v;\n" +
+ " }\n" +
+ "}\n" +
+ "class Y extends X{ }\n" +
+ "class D<R extends Y>{ R r;}\n"
+ });
+}
+public void testBug532349_13() throws IOException {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "class X {\n" +
+ " public static void foo(D<Y<? extends Integer>> d) {\n" +
+ " var v = d.r;\n" +
+ " Y<? extends Number> yn = v;\n" +
+ " Y<? extends Integer> yi = v;\n" +
+ " }\n" +
+ "}\n" +
+ "class Y<T extends Integer>{ }\n" +
+ "class D<R extends Y<? extends Number>>{ R r;}\n"
+ });
+}
+public void testBug532349_14() throws IOException {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "class X {\n" +
+ " public static void foo(A<? super C> ac) {\n" +
+ " C c = new C(100);\n" +
+ " var c1 = ac;\n" +
+ " A<? super C> a1 = c1;\n" +
+ " A<? super C> a2 = new A<B>(new B());\n" +
+ " a2 = c1;\n" +
+ " }\n" +
+ "}\n" +
+ "class C<T> extends B{\n" +
+ " T t;\n" +
+ " C(T t) {\n" +
+ " this.t = t;\n" +
+ " }\n" +
+ "}\n" +
+ "class B { }\n" +
+ "class A<Q> {\n" +
+ " A(Q e) {}\n" +
+ "}"
+ });
+}
+public void testBug532349_15() throws IOException {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static <T> A<T> m(T t) {\n" +
+ " return new A(t);\n" +
+ " }\n" +
+ " public static <U extends I1<?>> A<? extends U> m2(A<? super U> u) {\n" +
+ " return new A(u);\n" +
+ " }\n" +
+ " public static void main(String argv[]) {\n" +
+ " A<?> checkValue1 = new C(10);\n" +
+ " var varValue = m2(m(checkValue1));\n" +
+ " if(!varValue.t.t.equals(10)) {\n" +
+ " System.out.println(\"Error:\");\n" +
+ " }\n" +
+ " if(varValue.t.methodOnI1() != true) {\n" +
+ " System.out.println(\"Error:\");\n" +
+ " }\n" +
+ " }" +
+ "}\n" +
+ "class A<E> {\n" +
+ " E t;\n" +
+ " A(E t) {\n" +
+ " this.t = t;\n" +
+ " }\n" +
+ " A<E> u;\n" +
+ " A (A<E> u) {\n" +
+ " this(u.t);\n" +
+ " this.u = u;\n" +
+ " }\n" +
+ "}\n" +
+ "interface I1<E> {\n" +
+ " default boolean methodOnI1() {\n" +
+ " return true;\n" +
+ " }\n" +
+ "}\n" +
+ "class C<T> extends A implements I1 {\n" +
+ " C(T t) {\n" +
+ " super(t);\n" +
+ " }\n" +
+ "}"
+ }, "");
+}
+public void testBug532349_0016() throws IOException {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n" +
+ " public static void foo() {\n" +
+ " Y<? extends I> yi = new Y<>();\n" +
+ " var vi = yi.t;\n" +
+ " Y<Integer> yj = new Y<>();\n" +
+ " vi = yj.t;\n" +
+ " }\n" +
+ "}\n" +
+ "interface I { }\n" +
+ "class Y<T extends Number> {\n" +
+ " public T t;\n" +
+ "}"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 6)\n" +
+ " vi = yj.t;\n" +
+ " ^^^^\n" +
+ "Type mismatch: cannot convert from Integer to Number & I\n" +
+ "----------\n");
+}
+public void testBug532349_0017() throws IOException {
+ this.runNegativeTest(
+ new String[] {
+ "X.java",
+ "class X {\n" +
+ " public static <Q extends Number & I> void foo(Y<? super Q> y) {\n" +
+ " var vy = y;\n" +
+ " Y<Integer> yi = new Y<>();\n" +
+ " vy = yi;\n" +
+ " }\n" +
+ "}\n" +
+ "interface I { }\n" +
+ "class Y<T extends Number> {\n" +
+ " public T t;\n" +
+ "}"
+ },
+ "----------\n" +
+ "1. ERROR in X.java (at line 5)\n" +
+ " vy = yi;\n" +
+ " ^^\n" +
+ "Type mismatch: cannot convert from Y<Integer> to Y<? super Q>\n" +
+ "----------\n");
+}
}
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ModuleCompilationTests.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ModuleCompilationTests.java
index 458fa2589..71e59b955 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ModuleCompilationTests.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ModuleCompilationTests.java
@@ -4075,6 +4075,26 @@ public void testBug521362_emptyFile() {
"",
true);
}
+ public void testReleaseOption13a() {
+ runConformModuleTest(
+ new String[] {
+ "p/X.java",
+ "package p;\n" +
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " }\n" +
+ "}",
+ "module-info.java",
+ "module mod.one { \n" +
+ " requires java.base;\n" +
+ "}"
+ },
+ " --release 10 \"" + OUTPUT_DIR + File.separator + "module-info.java\" "
+ + "\"" + OUTPUT_DIR + File.separator + "p/X.java\"",
+ "",
+ "",
+ true);
+ }
public void testReleaseOption14() {
runNegativeModuleTest(
new String[] {
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 e9f6f6e50..6af278ef6 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
@@ -568,11 +568,20 @@ public class NonFatalErrorTest extends AbstractRegressionTest {
" 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");
+ (this.complianceLevel < ClassFileConstants.JDK1_8
+ ?
+ "----------\n" +
+ "1. ERROR in Test.java (at line 2)\n" +
+ " import static java.awt.geom.Point2D.Double;\n" +
+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" +
+ "The import java.awt.geom.Point2D.Double collides with another import statement\n" +
+ "----------\n"
+ :
+ "----------\n" +
+ "1. ERROR in Test.java (at line 5)\n" +
+ " Double d = null;\n" +
+ " ^^^^^^\n" +
+ "The type Double is ambiguous\n" +
+ "----------\n"));
}
}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter10Test.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter10Test.java
index 6150d12b8..cbfff29f6 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter10Test.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter10Test.java
@@ -146,5 +146,62 @@ public class ASTConverter10Test extends ConverterTestSetup {
assertTrue("null binding", binding != null);
assertTrue("binding incorrect", binding.getName().equals("Y<String>"));
}
+ public void testBug532535_001() throws JavaModelException {
+ String contents =
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " var s = new Y();\n" +
+ " }\n" +
+ "}\n" +
+ "class Y {}";
+ this.workingCopy = getWorkingCopy("/Converter10/src/X.java", true/*resolve*/);
+ ASTNode node = buildAST(contents, this.workingCopy, false);
+ assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType());
+ node = getASTNode((CompilationUnit)node, 0, 0);
+ MethodDeclaration methodDeclaration = (MethodDeclaration) node;
+ VariableDeclarationStatement vStmt = (VariableDeclarationStatement) methodDeclaration.getBody().statements().get(0);
+ checkSourceRange(vStmt, "var s = new Y();", contents);
+ Type type = vStmt.getType();
+ IBinding binding = type.resolveBinding();
+ assertTrue("null binding", binding != null);
+ assertTrue("binding incorrect", binding.getName().equals("Y"));
+ assertTrue("not a var", type.isVar());
+ SimpleType simpleType = (SimpleType) type;
+ Name name = simpleType.getName();
+ SimpleName simpleName = (SimpleName) name;
+ binding = simpleName.resolveBinding();
+ assertTrue(binding instanceof ITypeBinding);
+ ITypeBinding typeBinding = (ITypeBinding) binding;
+ assertTrue("wrong type binding", typeBinding.getName().equals("Y"));
+ }
+ public void testBug532535_002() throws JavaModelException {
+ String contents =
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ "for (var x= 10; x < 20; x++) {\n" +
+ " // do nothing\n" +
+ " }\n" +
+ "}\n" +
+ "class Y {}";
+ this.workingCopy = getWorkingCopy("/Converter10/src/X.java", true/*resolve*/);
+ ASTNode node = buildAST(contents, this.workingCopy, false);
+ assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType());
+ node = getASTNode((CompilationUnit)node, 0, 0);
+ MethodDeclaration methodDeclaration = (MethodDeclaration) node;
+ ForStatement forStmt = (ForStatement) methodDeclaration.getBody().statements().get(0);
+ VariableDeclarationExpression expr = (VariableDeclarationExpression) forStmt.initializers().get(0);
+ Type type = expr.getType();
+ IBinding binding = type.resolveBinding();
+ assertTrue("null binding", binding != null);
+ assertTrue("binding incorrect", binding.getName().equals("int"));
+ assertTrue("not a var", type.isVar());
+ SimpleType simpleType = (SimpleType) type;
+ Name name = simpleType.getName();
+ SimpleName simpleName = (SimpleName) name;
+ binding = simpleName.resolveBinding();
+ assertTrue(binding instanceof ITypeBinding);
+ ITypeBinding typeBinding = (ITypeBinding) binding;
+ assertTrue("wrong type binding", typeBinding.getName().equals("int"));
+ }
// Add new tests here
}
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/Java9ElementTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/Java9ElementTests.java
index a01c78dc7..352e04cef 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/Java9ElementTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/Java9ElementTests.java
@@ -1387,6 +1387,19 @@ public class Java9ElementTests extends AbstractJavaModelTests {
deleteProject("Java9Elements");
}
}
+ public void test528058() throws Exception {
+ try {
+ IJavaProject project1 = createJava9Project("Java9Elements", new String[] {"work/src/java"});
+ project1.open(null);
+ IJavaElement object = project1.findElement(new Path("java/lang/Object.class"));
+ String id = object.getHandleIdentifier();
+ IJavaElement object2 = JavaCore.create(id);
+ assertEquals("elements should be the same", object, object2);
+ }
+ finally {
+ deleteProject("Java9Elements");
+ }
+ }
private IJavaProject createJavaProjectWithBaseSql() throws CoreException {
IJavaProject project1 = createJava9Project("Java9Elements", new String[] {"src"});
project1.open(null);
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java
index 8f902e6f7..66e914456 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ModuleBuilderTests.java
@@ -31,6 +31,7 @@ import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IAccessRule;
import org.eclipse.jdt.core.IClasspathAttribute;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.ICompilationUnit;
@@ -60,7 +61,7 @@ public class ModuleBuilderTests extends ModifyingResourceTests {
}
static {
-// TESTS_NAMES = new String[] { "test_conflicting_packages" };
+ // TESTS_NAMES = new String[] { "testBug528467" };
}
private String sourceWorkspacePath = null;
protected ProblemRequestor problemRequestor;
@@ -6082,6 +6083,147 @@ public class ModuleBuilderTests extends ModifyingResourceTests {
deleteProject("nonmod1");
}
}
+ public void testBug528467a() throws CoreException {
+ if (!isJRE9) return;
+ IJavaProject p1 = createJava9Project("mod.one");
+ try {
+ IClasspathEntry[] rawClasspath = p1.getRawClasspath();
+ String jrtPath = null;
+ for (int i = 0; i < rawClasspath.length; i++) {
+ IClasspathEntry iClasspathEntry = rawClasspath[i];
+ if (iClasspathEntry.getEntryKind() == IClasspathEntry.CPE_LIBRARY &&
+ iClasspathEntry.getPath().toString().endsWith("jrt-fs.jar")) {
+ jrtPath = iClasspathEntry.getPath().toOSString();
+ IAccessRule[] pathRules = new IAccessRule[1];
+ pathRules[0] = JavaCore.newAccessRule(new Path("java/awt/**"), IAccessRule.K_NON_ACCESSIBLE);
+ IClasspathEntry newEntry = JavaCore.newLibraryEntry(iClasspathEntry.getPath(),
+ iClasspathEntry.getSourceAttachmentPath(),
+ iClasspathEntry.getSourceAttachmentRootPath(),
+ pathRules,
+ iClasspathEntry.getExtraAttributes(),
+ iClasspathEntry.isExported());
+ rawClasspath[i] = newEntry;
+ break;
+ }
+ }
+ p1.setRawClasspath(rawClasspath, null);
+ createFolder("/mod.one/src/p1");
+ createFile("/mod.one/src/module-info.java",
+ "module mod.one {\n" +
+ " exports p1;\n" +
+ " requires java.desktop;\n" +
+ "}\n");
+ createFile("/mod.one/src/p1/X.java",
+ "package p1;\n" +
+ "public class X {\n"
+ + " java.awt.Image im = null;\n"
+ + "}\n");
+
+ waitForManualRefresh();
+ waitForAutoBuild();
+ p1.getProject().build(IncrementalProjectBuilder.FULL_BUILD, null);
+ IMarker[] markers = p1.getProject().findMarkers(null, true, IResource.DEPTH_INFINITE);
+
+ assertMarkers("Unexpected markers", "Access restriction: The type 'Image' is not API (restriction on required library '"+
+ jrtPath + "')", markers);
+ } finally {
+ deleteProject(p1);
+ }
+ }
+ public void testBug528467b() throws CoreException {
+ if (!isJRE9) return;
+ IJavaProject p1 = createJava9Project("mod.one");
+ try {
+ IClasspathEntry[] rawClasspath = p1.getRawClasspath();
+ String jrtPath = null;
+ for (int i = 0; i < rawClasspath.length; i++) {
+ IClasspathEntry iClasspathEntry = rawClasspath[i];
+ if (iClasspathEntry.getEntryKind() == IClasspathEntry.CPE_LIBRARY &&
+ iClasspathEntry.getPath().toString().endsWith("jrt-fs.jar")) {
+ jrtPath = iClasspathEntry.getPath().toOSString();
+ IAccessRule[] pathRules = new IAccessRule[1];
+ pathRules[0] = JavaCore.newAccessRule(new Path("java/awt/Image"), IAccessRule.K_NON_ACCESSIBLE);
+ IClasspathEntry newEntry = JavaCore.newLibraryEntry(iClasspathEntry.getPath(),
+ iClasspathEntry.getSourceAttachmentPath(),
+ iClasspathEntry.getSourceAttachmentRootPath(),
+ pathRules,
+ iClasspathEntry.getExtraAttributes(),
+ iClasspathEntry.isExported());
+ rawClasspath[i] = newEntry;
+ break;
+ }
+ }
+ p1.setRawClasspath(rawClasspath, null);
+ createFolder("/mod.one/src/p1");
+ createFile("/mod.one/src/module-info.java",
+ "module mod.one {\n" +
+ " exports p1;\n" +
+ " requires java.desktop;\n" +
+ "}\n");
+ createFile("/mod.one/src/p1/X.java",
+ "package p1;\n" +
+ "import java.awt.*;\n" +
+ "public abstract class X extends Image {\n" +
+ " public Graphics foo() {\n" +
+ " return getGraphics();\n" +
+ " }\n"
+ + "}\n");
+
+ waitForManualRefresh();
+ waitForAutoBuild();
+ p1.getProject().build(IncrementalProjectBuilder.FULL_BUILD, null);
+ IMarker[] markers = p1.getProject().findMarkers(null, true, IResource.DEPTH_INFINITE);
+
+ assertMarkers("Unexpected markers",
+ "Access restriction: The type \'Image\' is not API (restriction on required library '"+ jrtPath + "')\n" +
+ "The type Graphics from module java.desktop may not be accessible to clients due to missing \'requires transitive\'\n" +
+ "Access restriction: The method \'Image.getGraphics()\' is not API (restriction on required library '"+ jrtPath + "')", markers);
+ } finally {
+ deleteProject(p1);
+ }
+ }
+ public void testBug528467c() throws CoreException {
+ if (!isJRE9) return;
+ IJavaProject p1 = createJava9Project("unnamed");
+ try {
+ IClasspathEntry[] rawClasspath = p1.getRawClasspath();
+ String jrtPath = null;
+ for (int i = 0; i < rawClasspath.length; i++) {
+ IClasspathEntry iClasspathEntry = rawClasspath[i];
+ if (iClasspathEntry.getEntryKind() == IClasspathEntry.CPE_LIBRARY &&
+ iClasspathEntry.getPath().toString().endsWith("jrt-fs.jar")) {
+ jrtPath = iClasspathEntry.getPath().toOSString();
+ IAccessRule[] pathRules = new IAccessRule[1];
+ pathRules[0] = JavaCore.newAccessRule(new Path("java/awt/**"), IAccessRule.K_NON_ACCESSIBLE);
+ IClasspathEntry newEntry = JavaCore.newLibraryEntry(iClasspathEntry.getPath(),
+ iClasspathEntry.getSourceAttachmentPath(),
+ iClasspathEntry.getSourceAttachmentRootPath(),
+ pathRules,
+ iClasspathEntry.getExtraAttributes(),
+ iClasspathEntry.isExported());
+ rawClasspath[i] = newEntry;
+ break;
+ }
+ }
+ p1.setRawClasspath(rawClasspath, null);
+ createFolder("/unnamed/src/p1");
+ createFile("/unnamed/src/p1/X.java",
+ "package p1;\n" +
+ "public class X {\n"
+ + " java.awt.Image im = null;\n"
+ + "}\n");
+
+ waitForManualRefresh();
+ waitForAutoBuild();
+ p1.getProject().build(IncrementalProjectBuilder.FULL_BUILD, null);
+ IMarker[] markers = p1.getProject().findMarkers(null, true, IResource.DEPTH_INFINITE);
+
+ assertMarkers("Unexpected markers", "Access restriction: The type 'Image' is not API (restriction on required library '"+
+ jrtPath + "')", markers);
+ } finally {
+ deleteProject(p1);
+ }
+ }
protected void assertNoErrors() throws CoreException {
for (IProject p : getWorkspace().getRoot().getProjects()) {
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/TypeResolveTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/TypeResolveTests.java
index 62bac3eb1..37295b883 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/TypeResolveTests.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/TypeResolveTests.java
@@ -1328,4 +1328,80 @@ public void test531046e() throws CoreException, IOException {
deleteProject("P");
}
}
+public void test531046f() throws CoreException, IOException {
+ if (!isJRE9) return;
+ try {
+ createJava10Project("P", new String[] {"src"});
+ String source = "package p;\n"
+ + "public class X {\n"
+ + " public static void main(java.lang.String[] args) {\n"
+ + " var e = (CharSequence & Comparable<String>) \"x\";\n"
+ + " }\n"
+ + "}\n";
+ createFolder("/P/src/p");
+ createFile("/P/src/p/X.java", source);
+ waitForAutoBuild();
+
+ ICompilationUnit unit = getCompilationUnit("/P/src/p/X.java");
+ String select = "var";
+ IJavaElement[] elements = unit.codeSelect(source.lastIndexOf(select), select.length());
+ assertEquals("should not be empty", 2, elements.length);
+ IType type = (IType) elements[0];
+ assertEquals("incorrect type", "java.lang.CharSequence", type.getFullyQualifiedParameterizedName());
+ type = (IType) elements[1];
+ assertEquals("incorrect type", "java.lang.Comparable<java.lang.String>", type.getFullyQualifiedParameterizedName());
+ } finally {
+ deleteProject("P");
+ }
+}
+public void test531046g() throws CoreException, IOException {
+ if (!isJRE9) return;
+ try {
+ createJava10Project("P", new String[] {"src"});
+ String source = "package p;\n"
+ + "public class X {\n"
+ + " public static void main(java.lang.String[] args) {\n"
+ + " var v_v = (CharSequence & Comparable<String>) \"x\";\n"
+ + " }\n"
+ + "}\n";
+ createFolder("/P/src/p");
+ createFile("/P/src/p/X.java", source);
+ waitForAutoBuild();
+
+ ICompilationUnit unit = getCompilationUnit("/P/src/p/X.java");
+ String select = "v_v";
+ IJavaElement[] elements = unit.codeSelect(source.lastIndexOf(select), select.length());
+ assertEquals("should not be empty", 1, elements.length);
+ ILocalVariable variable = (ILocalVariable) elements[0];
+ assertEquals("incorrect type", "&QCharSequence;:QComparable<QString;>;", variable.getTypeSignature());
+ } finally {
+ deleteProject("P");
+ }
+}
+public void test531046h() throws CoreException, IOException {
+ if (!isJRE9) return;
+ try {
+ createJava10Project("P", new String[] {"src"});
+ String source = "package p;\n"
+ + "public class X {\n"
+ + " public static void main(java.lang.String[] args) {\n"
+ + " var v_v = (CharSequence & Comparable<String>) \"x\";\n"
+ + " System.out.println(v_v);\n"
+ + " }\n"
+ + "}\n";
+ createFolder("/P/src/p");
+ createFile("/P/src/p/X.java", source);
+ waitForAutoBuild();
+
+ ICompilationUnit unit = getCompilationUnit("/P/src/p/X.java");
+ String select = "v_v";
+ IJavaElement[] elements = unit.codeSelect(source.lastIndexOf(select), select.length());
+ assertEquals("should not be empty", 1, elements.length);
+ ILocalVariable variable = (ILocalVariable) elements[0];
+ assertEquals("incorrect type", "&QCharSequence;:QComparable<QString;>;", variable.getTypeSignature());
+ } finally {
+ deleteProject("P");
+ }
+}
+
}
diff --git a/org.eclipse.jdt.core/.settings/.api_filters b/org.eclipse.jdt.core/.settings/.api_filters
index edcef091e..4d435777c 100644
--- a/org.eclipse.jdt.core/.settings/.api_filters
+++ b/org.eclipse.jdt.core/.settings/.api_filters
@@ -111,6 +111,35 @@
</message_arguments>
</filter>
</resource>
+ <resource path="dom/org/eclipse/jdt/core/dom/SimpleName.java" type="org.eclipse.jdt.core.dom.SimpleName">
+ <filter comment="jls 10 support for var" id="336658481">
+ <message_arguments>
+ <message_argument value="org.eclipse.jdt.core.dom.SimpleName"/>
+ <message_argument value="VAR_PROPERTY"/>
+ </message_arguments>
+ </filter>
+ <filter comment="jls 10 support for var" id="1141899266">
+ <message_arguments>
+ <message_argument value="3.14"/>
+ <message_argument value="3.13"/>
+ <message_argument value="VAR_PROPERTY"/>
+ </message_arguments>
+ </filter>
+ <filter comment="jls 10 support for var" id="1141899266">
+ <message_arguments>
+ <message_argument value="3.14"/>
+ <message_argument value="3.13"/>
+ <message_argument value="isVar()"/>
+ </message_arguments>
+ </filter>
+ <filter comment="jls 10 support for var" id="1141899266">
+ <message_arguments>
+ <message_argument value="3.14"/>
+ <message_argument value="3.13"/>
+ <message_argument value="setVar(boolean)"/>
+ </message_arguments>
+ </filter>
+ </resource>
<resource path="dom/org/eclipse/jdt/core/dom/Type.java" type="org.eclipse.jdt.core.dom.Type">
<filter id="1141899266">
<message_arguments>
@@ -143,4 +172,34 @@
</message_arguments>
</filter>
</resource>
+ <resource path="model/org/eclipse/jdt/core/Signature.java" type="org.eclipse.jdt.core.Signature">
+ <filter comment="Java 10 work backported to 4.7.3a" id="1141899266">
+ <message_arguments>
+ <message_argument value="3.14"/>
+ <message_argument value="3.13"/>
+ <message_argument value="C_UNION"/>
+ </message_arguments>
+ </filter>
+ <filter comment="Java 10 work backported to 4.7.3a" id="1141899266">
+ <message_arguments>
+ <message_argument value="3.14"/>
+ <message_argument value="3.13"/>
+ <message_argument value="UNION_TYPE_SIGNATURE"/>
+ </message_arguments>
+ </filter>
+ <filter comment="Java 10 work backported to 4.7.3a" id="1141899266">
+ <message_arguments>
+ <message_argument value="3.14"/>
+ <message_argument value="3.13"/>
+ <message_argument value="createUnionTypeSignature(String[])"/>
+ </message_arguments>
+ </filter>
+ <filter comment="Java 10 work backported to 4.7.3a" id="1141899266">
+ <message_arguments>
+ <message_argument value="3.14"/>
+ <message_argument value="3.13"/>
+ <message_argument value="getUnionTypeBounds(String)"/>
+ </message_arguments>
+ </filter>
+ </resource>
</component>
diff --git a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJep247.java b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJep247.java
index 69f9a6a50..b3a691beb 100644
--- a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJep247.java
+++ b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/ClasspathJep247.java
@@ -24,12 +24,14 @@ import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException;
import org.eclipse.jdt.internal.compiler.env.AccessRuleSet;
import org.eclipse.jdt.internal.compiler.env.IModule;
import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer;
+import org.eclipse.jdt.internal.compiler.util.JRTUtil;
import org.eclipse.jdt.internal.compiler.util.Util;
public class ClasspathJep247 extends ClasspathLocation {
private java.nio.file.FileSystem fs = null;
- private String release = null;
+ private String compliance = null;
+ private String releaseInHex = null;
private String[] subReleases = null;
private Path releasePath = null;
private File file = null;
@@ -37,7 +39,7 @@ public class ClasspathJep247 extends ClasspathLocation {
public ClasspathJep247(File jdkHome, String release, AccessRuleSet accessRuleSet) {
super(accessRuleSet, null);
- this.release = release;
+ this.compliance = release;
this.file = jdkHome;
}
public List<Classpath> fetchLinkedJars(FileSystem.ClasspathSectionProblemReporter problemReporter) {
@@ -59,13 +61,13 @@ public class ClasspathJep247 extends ClasspathLocation {
for (String rel : this.subReleases) {
Path p = this.fs.getPath(rel, qualifiedBinaryFileName);
if (Files.exists(p)) {
- content = Files.readAllBytes(p);
- if (content != null)
+ content = JRTUtil.safeReadBytes(p);
+ if (content != null)
break;
}
}
} else {
- content = Files.readAllBytes(this.fs.getPath(this.release, qualifiedBinaryFileName));
+ content = JRTUtil.safeReadBytes(this.fs.getPath(this.releaseInHex, qualifiedBinaryFileName));
}
if (content != null) {
reader = new ClassFileReader(content, qualifiedBinaryFileName.toCharArray());
@@ -88,9 +90,10 @@ public class ClasspathJep247 extends ClasspathLocation {
}
public void initialize() throws IOException {
- if (this.release == null) {
+ if (this.compliance == null) {
return;
}
+ this.releaseInHex = Integer.toHexString(Integer.parseInt(this.compliance));
Path filePath = this.file.toPath().resolve("lib").resolve("ct.sym"); //$NON-NLS-1$ //$NON-NLS-2$
URI t = filePath.toUri();
if (!Files.exists(filePath)) {
@@ -106,9 +109,9 @@ public class ClasspathJep247 extends ClasspathLocation {
HashMap<String, ?> env = new HashMap<>();
this.fs = FileSystems.newFileSystem(uri, env);
}
- this.releasePath = this.fs.getPath(""); //$NON-NLS-1$
- if (!Files.exists(this.fs.getPath(this.release))) {
- throw new IllegalArgumentException("release " + this.release + " is not found in the system"); //$NON-NLS-1$//$NON-NLS-2$
+ this.releasePath = this.fs.getPath("/"); //$NON-NLS-1$
+ if (!Files.exists(this.fs.getPath(this.releaseInHex))) {
+ throw new IllegalArgumentException("release " + this.compliance + " is not found in the system"); //$NON-NLS-1$//$NON-NLS-2$
}
}
void acceptModule(ClassFileReader reader) {
@@ -130,7 +133,7 @@ public class ClasspathJep247 extends ClasspathLocation {
try (DirectoryStream<java.nio.file.Path> stream = Files.newDirectoryStream(this.releasePath)) {
for (final java.nio.file.Path subdir: stream) {
String rel = subdir.getFileName().toString();
- if (rel.contains(this.release)) {
+ if (rel.contains(this.releaseInHex)) {
sub.add(rel);
} else {
continue;
diff --git a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java
index a510c09a8..db2cb5239 100644
--- a/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java
+++ b/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/SelectionEngine.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -81,6 +81,7 @@ import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
import org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope;
import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers;
import org.eclipse.jdt.internal.compiler.lookup.FieldBinding;
+import org.eclipse.jdt.internal.compiler.lookup.IntersectionTypeBinding18;
import org.eclipse.jdt.internal.compiler.lookup.LocalTypeBinding;
import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
import org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment;
@@ -1365,6 +1366,12 @@ public final class SelectionEngine extends Engine implements ISearchRequestor {
if (isLocal(typeBinding) && this.requestor instanceof SelectionRequestor) {
this.noProposal = false;
((SelectionRequestor)this.requestor).acceptLocalType(typeBinding);
+ } else if (binding instanceof IntersectionTypeBinding18) {
+ IntersectionTypeBinding18 intersection = (IntersectionTypeBinding18) binding;
+ ReferenceBinding[] intersectingTypes = intersection.intersectingTypes;
+ for (ReferenceBinding referenceBinding : intersectingTypes) {
+ selectFrom(referenceBinding, parsedUnit, isDeclaration);
+ }
} else {
this.noProposal = false;
//{ObjectTeams: handle role files and interface parts
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java
index a0fc2dbac..6caa72607 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java
@@ -482,8 +482,10 @@ public abstract class ASTNode implements TypeConstants, TypeIds {
}
if ((field.modifiers & ExtraCompilerModifiers.AccRestrictedAccess) != 0) {
+ ModuleBinding module = field.declaringClass.module();
+ LookupEnvironment env = (module == null) ? scope.environment() : module.environment;
AccessRestriction restriction =
- scope.environment().getAccessRestriction(field.declaringClass.erasure());
+ env.getAccessRestriction(field.declaringClass.erasure());
if (restriction != null) {
scope.problemReporter().forbiddenReference(field, this,
//{ObjectTeams: pass the whole restriction object (for use by the compiler.adaptor):
@@ -536,8 +538,10 @@ public abstract class ASTNode implements TypeConstants, TypeIds {
if (isExplicitUse && (method.modifiers & ExtraCompilerModifiers.AccRestrictedAccess) != 0) {
// note: explicit constructors calls warnings are kept despite the 'new C1()' case (two
// warnings, one on type, the other on constructor), because of the 'super()' case.
+ ModuleBinding module = method.declaringClass.module();
+ LookupEnvironment env = (module == null) ? scope.environment() : module.environment;
AccessRestriction restriction =
- scope.environment().getAccessRestriction(method.declaringClass.erasure());
+ env.getAccessRestriction(method.declaringClass.erasure());
if (restriction != null) {
scope.problemReporter().forbiddenReference(method, this,
//{ObjectTeams: pass the whole restriction object (for use by the compiler.adaptor):
@@ -609,7 +613,9 @@ public abstract class ASTNode implements TypeConstants, TypeIds {
}
if (refType.hasRestrictedAccess()) {
- AccessRestriction restriction = scope.environment().getAccessRestriction(type.erasure());
+ ModuleBinding module = refType.module();
+ LookupEnvironment env = (module == null) ? scope.environment() : module.environment;
+ AccessRestriction restriction = env.getAccessRestriction(type.erasure());
if (restriction != null) {
//{ObjectTeams: pass the whole access restriction object (for use by the compiler.adaptor):
/* orig:
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java
index 4c61a21a7..1c40c67a0 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Annotation.java
@@ -1176,7 +1176,9 @@ public abstract class Annotation extends Expression {
} else if ((annotationType.tagBits & TagBits.AnnotationForLocalVariable) != 0) {
return AnnotationTargetAllowed.YES;
} else if ((metaTagBits & TagBits.AnnotationForTypeUse) != 0) {
- if (isTypeUseCompatible(localVariableBinding.declaration.type, scope)) {
+ if (localVariableBinding.declaration.isTypeNameVar(scope)) {
+ return AnnotationTargetAllowed.NO;
+ } else if (isTypeUseCompatible(localVariableBinding.declaration.type, scope)) {
return AnnotationTargetAllowed.YES;
} else {
return AnnotationTargetAllowed.TYPE_ANNOTATION_ON_QUALIFIED_NAME;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/AnnotationInfo.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/AnnotationInfo.java
index 8927392c2..238799248 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/AnnotationInfo.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/AnnotationInfo.java
@@ -28,7 +28,7 @@ public class AnnotationInfo extends ClassFileStruct implements IBinaryAnnotation
* null until this annotation is initialized
* @see #getElementValuePairs()
*/
- private ElementValuePairInfo[] pairs;
+ private volatile ElementValuePairInfo[] pairs;
long standardAnnotationTagBits = 0;
int readOffset = 0;
@@ -57,14 +57,46 @@ private void decodeAnnotation() {
int numberOfPairs = u2At(2);
// u2 type_index + u2 num_member_value_pair
this.readOffset += 4;
- this.pairs = numberOfPairs == 0 ? ElementValuePairInfo.NoMembers : new ElementValuePairInfo[numberOfPairs];
- for (int i = 0; i < numberOfPairs; i++) {
- // u2 member_name_index;
- utf8Offset = this.constantPoolOffsets[u2At(this.readOffset)] - this.structOffset;
- char[] membername = utf8At(utf8Offset + 3, u2At(utf8Offset + 1));
- this.readOffset += 2;
- Object value = decodeDefaultValue();
- this.pairs[i] = new ElementValuePairInfo(membername, value);
+ ElementValuePairInfo[] decodedPairs = numberOfPairs == 0 ? ElementValuePairInfo.NoMembers : new ElementValuePairInfo[numberOfPairs];
+ int i = 0;
+ try {
+ while (i < numberOfPairs) {
+ // u2 member_name_index;
+ utf8Offset = this.constantPoolOffsets[u2At(this.readOffset)] - this.structOffset;
+ char[] membername = utf8At(utf8Offset + 3, u2At(utf8Offset + 1));
+ this.readOffset += 2;
+ Object value = decodeDefaultValue();
+ decodedPairs[i++] = new ElementValuePairInfo(membername, value);
+ }
+ this.pairs = decodedPairs;
+ } catch (RuntimeException any) {
+ sanitizePairs(decodedPairs);
+ StringBuilder newMessage = new StringBuilder(any.getMessage());
+ newMessage.append(" while decoding pair #").append(i).append(" of annotation @").append(this.typename); //$NON-NLS-1$ //$NON-NLS-2$
+ newMessage.append(", bytes at structOffset ").append(this.structOffset).append(":"); //$NON-NLS-1$ //$NON-NLS-2$
+ int offset = this.structOffset;
+ while (offset <= this.structOffset+this.readOffset && offset < this.reference.length) {
+ newMessage.append(' ').append(Integer.toHexString(this.reference[offset++] & 0xFF));
+ }
+ throw new IllegalStateException(newMessage.toString(), any);
+ }
+}
+private void sanitizePairs(ElementValuePairInfo[] oldPairs) {
+ if (oldPairs != null) {
+ ElementValuePairInfo[] newPairs = new ElementValuePairInfo[oldPairs.length];
+ int count = 0;
+ for (int i = 0; i < oldPairs.length; i++) {
+ ElementValuePairInfo evpInfo = oldPairs[i];
+ if (evpInfo != null)
+ newPairs[count++] = evpInfo;
+ }
+ if (count < oldPairs.length) {
+ this.pairs = Arrays.copyOf(newPairs, count);
+ } else {
+ this.pairs = newPairs;
+ }
+ } else {
+ this.pairs = ElementValuePairInfo.NoMembers;
}
}
Object decodeDefaultValue() {
@@ -151,13 +183,14 @@ Object decodeDefaultValue() {
}
break;
default:
- throw new IllegalStateException("Unrecognized tag " + (char) tag); //$NON-NLS-1$
+ String tagDisplay = tag == 0 ? "0x00" : (char) tag + " ("+Integer.toHexString(tag&0xFF)+')'; //$NON-NLS-1$//$NON-NLS-2$
+ throw new IllegalStateException("Unrecognized tag " + tagDisplay); //$NON-NLS-1$
}
return value;
}
public IBinaryElementValuePair[] getElementValuePairs() {
if (this.pairs == null)
- initialize();
+ lazyInitialize();
return this.pairs;
}
public char[] getTypeName() {
@@ -171,6 +204,10 @@ void initialize() {
if (this.pairs == null)
decodeAnnotation();
}
+synchronized void lazyInitialize() {
+ if (this.pairs == null)
+ decodeAnnotation();
+}
//{ObjectTeams: avoid reset before decode():
@Override
protected void reset() {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileReader.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileReader.java
index 300aed4e8..18802b972 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileReader.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileReader.java
@@ -563,7 +563,8 @@ public ClassFileReader(byte[] classFileBytes, char[] fileName, boolean fullyInit
} catch(ClassFormatException e) {
throw e;
} catch (Exception e) {
- throw new ClassFormatException(
+ throw new ClassFormatException(e,
+ this.classFileName,
ClassFormatException.ErrTruncatedInput,
readOffset);
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFormatException.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFormatException.java
index d465d9af6..dd2570982 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFormatException.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFormatException.java
@@ -47,7 +47,7 @@ public class ClassFormatException extends Exception {
private int errorCode;
private int bufferPosition;
- private RuntimeException nestedException;
+ private Exception nestedException;
private char[] fileName;
public ClassFormatException(RuntimeException e, char[] fileName) {
@@ -57,7 +57,9 @@ public class ClassFormatException extends Exception {
public ClassFormatException(int code) {
this.errorCode = code;
}
- public ClassFormatException(int code, int bufPos) {
+ public ClassFormatException(Exception e, char[] fileName, int code, int bufPos) {
+ this.nestedException = e;
+ this.fileName = fileName;
this.errorCode = code;
this.bufferPosition = bufPos;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/MethodInfo.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/MethodInfo.java
index c9606a054..64386b77a 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/MethodInfo.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/MethodInfo.java
@@ -63,12 +63,12 @@ public class MethodInfo extends ClassFileStruct implements IBinaryMethod, Compar
protected int accessFlags;
protected int attributeBytes;
protected char[] descriptor;
- protected char[][] exceptionNames;
+ protected volatile char[][] exceptionNames;
protected char[] name;
protected char[] signature;
protected int signatureUtf8Offset;
protected long tagBits;
- protected char[][] argumentNames;
+ protected volatile char[][] argumentNames;
protected long version;
//{ObjectTeams: method level attributes:
@@ -415,7 +415,6 @@ public char[] getMethodDescriptor() {
public int getModifiers() {
if (this.accessFlags == -1) {
// compute the accessflag. Don't forget the deprecated attribute
- this.accessFlags = u2At(0);
readModifierRelatedAttributes();
}
return this.accessFlags;
@@ -483,9 +482,10 @@ public boolean isConstructor() {
public boolean isSynthetic() {
return (getModifiers() & ClassFileConstants.AccSynthetic) != 0;
}
-private void readExceptionAttributes() {
+private synchronized void readExceptionAttributes() {
int attributesCount = u2At(6);
int readOffset = 8;
+ char[][] names = null;
for (int i = 0; i < attributesCount; i++) {
int utf8Offset = this.constantPoolOffsets[u2At(readOffset)] - this.structOffset;
char[] attributeName = utf8At(utf8Offset + 3, u2At(utf8Offset + 1));
@@ -495,15 +495,15 @@ private void readExceptionAttributes() {
// place the readOffset at the beginning of the exceptions table
readOffset += 8;
if (entriesNumber == 0) {
- this.exceptionNames = noException;
+ names = noException;
} else {
- this.exceptionNames = new char[entriesNumber][];
+ names = new char[entriesNumber][];
for (int j = 0; j < entriesNumber; j++) {
utf8Offset =
this.constantPoolOffsets[u2At(
this.constantPoolOffsets[u2At(readOffset)] - this.structOffset + 1)]
- this.structOffset;
- this.exceptionNames[j] = utf8At(utf8Offset + 3, u2At(utf8Offset + 1));
+ names[j] = utf8At(utf8Offset + 3, u2At(utf8Offset + 1));
readOffset += 2;
}
}
@@ -511,11 +511,14 @@ private void readExceptionAttributes() {
readOffset += (6 + u4At(readOffset + 2));
}
}
- if (this.exceptionNames == null) {
+ if (names == null) {
this.exceptionNames = noException;
+ } else {
+ this.exceptionNames = names;
}
}
-private void readModifierRelatedAttributes() {
+private synchronized void readModifierRelatedAttributes() {
+ int flags = u2At(0);
int attributesCount = u2At(6);
int readOffset = 8;
for (int i = 0; i < attributesCount; i++) {
@@ -526,19 +529,19 @@ private void readModifierRelatedAttributes() {
switch(attributeName[0]) {
case 'D' :
if (CharOperation.equals(attributeName, AttributeNamesConstants.DeprecatedName))
- this.accessFlags |= ClassFileConstants.AccDeprecated;
+ flags |= ClassFileConstants.AccDeprecated;
break;
case 'S' :
if (CharOperation.equals(attributeName, AttributeNamesConstants.SyntheticName))
- this.accessFlags |= ClassFileConstants.AccSynthetic;
+ flags |= ClassFileConstants.AccSynthetic;
break;
case 'A' :
if (CharOperation.equals(attributeName, AttributeNamesConstants.AnnotationDefaultName))
- this.accessFlags |= ClassFileConstants.AccAnnotationDefault;
+ flags |= ClassFileConstants.AccAnnotationDefault;
break;
case 'V' :
if (CharOperation.equals(attributeName, AttributeNamesConstants.VarargsName))
- this.accessFlags |= ClassFileConstants.AccVarargs;
+ flags |= ClassFileConstants.AccVarargs;
//{ObjectTeams: read method attributes
break;
default:
@@ -548,6 +551,7 @@ private void readModifierRelatedAttributes() {
}
readOffset += (6 + u4At(readOffset + 2));
}
+ this.accessFlags = flags;
}
//{ObjectTeams: OT method attributes:
/**
@@ -620,7 +624,7 @@ void toString(StringBuffer buffer) {
protected void toStringContent(StringBuffer buffer) {
BinaryTypeFormatter.methodToStringContent(buffer, this);
}
-private void readCodeAttribute() {
+private synchronized void readCodeAttribute() {
int attributesCount = u2At(6);
int readOffset = 8;
if (attributesCount != 0) {
@@ -667,7 +671,7 @@ private void decodeLocalVariableAttribute(int offset, int codeLength) {
final int length = u2At(readOffset);
if (length != 0) {
readOffset += 2;
- this.argumentNames = new char[length][];
+ char[][] names = new char[length][];
int argumentNamesIndex = 0;
for (int i = 0; i < length; i++) {
int startPC = u2At(readOffset);
@@ -676,17 +680,18 @@ private void decodeLocalVariableAttribute(int offset, int codeLength) {
int utf8Offset = this.constantPoolOffsets[nameIndex] - this.structOffset;
char[] localVariableName = utf8At(utf8Offset + 3, u2At(utf8Offset + 1));
if (!CharOperation.equals(localVariableName, ConstantPool.This)) {
- this.argumentNames[argumentNamesIndex++] = localVariableName;
+ names[argumentNamesIndex++] = localVariableName;
}
} else {
break;
}
readOffset += 10;
}
- if (argumentNamesIndex != this.argumentNames.length) {
+ if (argumentNamesIndex != names.length) {
// resize
- System.arraycopy(this.argumentNames, 0, (this.argumentNames = new char[argumentNamesIndex][]), 0, argumentNamesIndex);
+ System.arraycopy(names, 0, (names = new char[argumentNamesIndex][]), 0, argumentNamesIndex);
}
+ this.argumentNames = names;
}
}
private void decodeMethodParameters(int offset, MethodInfo methodInfo) {
@@ -694,18 +699,19 @@ private void decodeMethodParameters(int offset, MethodInfo methodInfo) {
final int length = u1At(readOffset);
if (length != 0) {
readOffset += 1;
- this.argumentNames = new char[length][];
+ char[][] names = new char[length][];
for (int i = 0; i < length; i++) {
int nameIndex = u2At(readOffset);
if (nameIndex != 0) {
int utf8Offset = this.constantPoolOffsets[nameIndex] - this.structOffset;
char[] parameterName = utf8At(utf8Offset + 3, u2At(utf8Offset + 1));
- this.argumentNames[i] = parameterName;
+ names[i] = parameterName;
} else {
- this.argumentNames[i] = CharOperation.concat(ARG, String.valueOf(i).toCharArray());
+ names[i] = CharOperation.concat(ARG, String.valueOf(i).toCharArray());
}
readOffset += 4;
}
+ this.argumentNames = names;
}
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java
index c1b504232..0f54dbaed 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -3529,8 +3529,9 @@ public static TypeBinding getConstantPoolDeclaringClass(Scope currentScope, Meth
&& (options.complianceLevel >= ClassFileConstants.JDK1_4 || !(isImplicitThisReceiver && codegenBinding.isStatic()))
&& codegenBinding.declaringClass.id != TypeIds.T_JavaLangObject) // no change for Object methods
|| !codegenBinding.declaringClass.canBeSeenBy(currentScope)) {
- if (actualReceiverType.isIntersectionType18()) {
- TypeBinding[] intersectingTypes = ((IntersectionTypeBinding18)actualReceiverType).getIntersectingTypes();
+ TypeBinding erasure = actualReceiverType.erasure();
+ if (erasure.isIntersectionType18()) {
+ TypeBinding[] intersectingTypes = ((IntersectionTypeBinding18)erasure).getIntersectingTypes();
for(int i = 0; i < intersectingTypes.length; i++) {
if (intersectingTypes[i].findSuperTypeOriginatingFrom(constantPoolDeclaringClass) != null) {
constantPoolDeclaringClass = intersectingTypes[i];
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java
index cd50062ff..95b4106b5 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java
@@ -996,6 +996,11 @@ public class CompilerOptions {
return ClassFileConstants.JDK1_8;
case '9':
return ClassFileConstants.JDK9;
+ case '1':
+ if (release.length() > 1 && release.charAt(1) == '0')
+ return ClassFileConstants.JDK10;
+ else
+ return 0;
default:
return 0; // unknown
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/AnnotationBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/AnnotationBinding.java
index 3e9e57564..b92eea605 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/AnnotationBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/AnnotationBinding.java
@@ -38,12 +38,19 @@ public static AnnotationBinding[] addStandardAnnotations(AnnotationBinding[] rec
if ((annotationTagBits & TagBits.AllStandardAnnotationsMask) == 0) {
return recordedAnnotations;
}
+ boolean haveDeprecated = false;
+ for (AnnotationBinding annotationBinding : recordedAnnotations) {
+ if (annotationBinding.getAnnotationType().id == TypeIds.T_JavaLangDeprecated) {
+ haveDeprecated = true;
+ break;
+ }
+ }
int count = 0;
if ((annotationTagBits & TagBits.AnnotationTargetMASK) != 0)
count++;
if ((annotationTagBits & TagBits.AnnotationRetentionMASK) != 0)
count++;
- if ((annotationTagBits & TagBits.AnnotationDeprecated) != 0)
+ if (!haveDeprecated && (annotationTagBits & TagBits.AnnotationDeprecated) != 0)
count++;
if ((annotationTagBits & TagBits.AnnotationDocumented) != 0)
count++;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CaptureBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CaptureBinding.java
index 234355022..da38fd549 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CaptureBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CaptureBinding.java
@@ -280,6 +280,68 @@ public class CaptureBinding extends TypeVariableBinding {
evaluateNullAnnotations(scope, null);
}
}
+ public ReferenceBinding upwardsProjection(Scope scope, TypeBinding[] mentionedTypeVariables) {
+ if (enterRecursiveProjectionFunction()) {
+ try {
+ for (int i = 0; i < mentionedTypeVariables.length; ++i) {
+ if (TypeBinding.equalsEquals(this, mentionedTypeVariables[i])) {
+ TypeBinding upperBoundForProjection = this.upperBoundForProjection();
+ return ((ReferenceBinding)upperBoundForProjection).upwardsProjection(scope, mentionedTypeVariables);
+ }
+ }
+ return this;
+ } finally {
+ exitRecursiveProjectionFunction();
+ }
+ } else {
+ return scope.getJavaLangObject();
+ }
+ }
+ public TypeBinding upperBoundForProjection() {
+ TypeBinding upperBound = null;
+ if (this.wildcard != null) {
+ ReferenceBinding[] supers = this.superInterfaces();
+ if (this.wildcard.boundKind == Wildcard.EXTENDS) {
+ if (supers.length > 0) {
+ ReferenceBinding[] allBounds = new ReferenceBinding[supers.length + 1];
+ System.arraycopy(supers, 0, allBounds, 1, supers.length);
+ allBounds[0] = this.superclass();
+ ReferenceBinding[] glbs = Scope.greaterLowerBound(allBounds);
+ if (glbs == null) {
+ upperBound = new ProblemReferenceBinding(null, null, ProblemReasons.ParameterBoundMismatch);
+ } else if (glbs.length == 1) {
+ upperBound = glbs[0];
+ } else {
+ upperBound = this.environment.createIntersectionType18(glbs);
+ }
+ } else {
+ upperBound = this.superclass;
+ }
+ } else {
+ // ITB18.isCompatibleWith does not handle the presence of j.l.Object among intersecting types,
+ // so it returns false when checking (I&J).isCompatibleWith(Object&I&J)
+ // TODO see if this can be handled in ITB18.isCompatibleWith() itself
+ boolean superClassIsObject = TypeBinding.equalsEquals(this.superclass(), this.environment.getResolvedJavaBaseType(TypeConstants.JAVA_LANG_OBJECT, null));
+ if (supers.length == 0) {
+ upperBound = this.superclass();
+ } else if (supers.length == 1) {
+ upperBound = superClassIsObject ? supers[0] : this.environment.createIntersectionType18(new ReferenceBinding[] {this.superclass(), supers[0]});
+ } else {
+ if (superClassIsObject) {
+ upperBound = this.environment.createIntersectionType18(supers);
+ } else {
+ ReferenceBinding[] allBounds = new ReferenceBinding[supers.length + 1];
+ System.arraycopy(supers, 0, allBounds, 1, supers.length);
+ allBounds[0] = this.superclass();
+ upperBound = this.environment.createIntersectionType18(allBounds);
+ }
+ }
+ }
+ } else {
+ upperBound = super.upperBound();
+ }
+ return upperBound;
+ }
/**
* @see org.eclipse.jdt.internal.compiler.lookup.TypeBinding#isCapture()
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java
index 64950c21d..07cf5b3d4 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java
@@ -521,17 +521,17 @@ public class ParameterizedTypeBinding extends ReferenceBinding implements Substi
// * Bi is not a subtype of U,
// then Ai' is an upper-bounded wildcard, ? extends U.
if (u.id != TypeIds.T_JavaLangObject
- && (b_i.mentionsAny(typeVariables, -1) || b_i.findSuperTypeOriginatingFrom(u) == null)) {
- a_i_primes[i] = this.environment().createWildcard(null, i, u, null, Wildcard.EXTENDS);
+ && (b_i.mentionsAny(typeVariables, -1) || !b_i.isSubtypeOf(u))) {
+ a_i_primes[i] = this.environment().createWildcard(genericType(), i, u, null, Wildcard.EXTENDS);
} else {
TypeBinding l = a_i.downwardsProjection(scope, mentionedTypeVariables);
// Otherwise, if the downward projection of Ai is L,
// then Ai' is a lower-bounded wildcard, ? super L.
if (l != null) {
- a_i_primes[i] = this.environment().createWildcard(null, i, l, null, Wildcard.SUPER);
+ a_i_primes[i] = this.environment().createWildcard(genericType(), i, l, null, Wildcard.SUPER);
} else {
// Otherwise, the downward projection of Ai is undefined and Ai' is an unbounded wildcard, ?.
- a_i_primes[i] = this.environment().createWildcard(null, i, null, null, Wildcard.UNBOUND);
+ a_i_primes[i] = this.environment().createWildcard(genericType(), i, null, null, Wildcard.UNBOUND);
}
}
} else {
@@ -1884,7 +1884,7 @@ public class ParameterizedTypeBinding extends ReferenceBinding implements Substi
if (newArguments[i] == null) {
newArguments[i] = new ProblemReferenceBinding(arg.internalName(),
(arg instanceof ReferenceBinding) ? (ReferenceBinding)arg: null,
- ProblemReasons.NotFound);
+ ProblemReasons.NotFound, true);
continue; // not a good modification
}
modified |= (newArguments[i] != arg); //$IDENTITY-COMPARISON$
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemReferenceBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemReferenceBinding.java
index 5a14567ea..747e291fc 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemReferenceBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemReferenceBinding.java
@@ -51,8 +51,8 @@ public TypeBinding closestMatch() {
}
//{ObjectTeams: special uses:
-// for role types
-public ProblemReferenceBinding(char[] name, ReferenceBinding closestMatch, int problemReason) {
+// for role types (otTagArg only serves to disambiguate invocations wrt ProblemReferenceBinding(char[][],ReferenceBinding,int))
+public ProblemReferenceBinding(char[] name, ReferenceBinding closestMatch, int problemReason, boolean otTagArg) {
this(new char[][] {name}, closestMatch, problemReason);
}
// for anchored types:
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/RawTypeBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/RawTypeBinding.java
index c2995043b..64b292d5c 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/RawTypeBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/RawTypeBinding.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -296,4 +296,12 @@ public class RawTypeBinding extends ParameterizedTypeBinding {
void collectInferenceVariables(Set<InferenceVariable> variables) {
// nothing to collect for a raw type.
}
+
+ public ReferenceBinding upwardsProjection(Scope scope, TypeBinding[] mentionedTypeVariables) {
+ return this;
+ }
+
+ public ReferenceBinding downwardsProjection(Scope scope, TypeBinding[] mentionedTypeVariables) {
+ return this;
+ }
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java
index d8c10fac8..f5d79a60e 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java
@@ -1754,6 +1754,14 @@ private boolean isCompatibleWith0(TypeBinding otherType, boolean useObjectShortc
// above if same erasure
}
ReferenceBinding otherReferenceType = (ReferenceBinding) otherType;
+ if (otherReferenceType.isIntersectionType18()) {
+ ReferenceBinding[] intersectingTypes = ((IntersectionTypeBinding18)otherReferenceType).intersectingTypes;
+ for (ReferenceBinding binding : intersectingTypes) {
+ if (!isCompatibleWith(binding))
+ return false;
+ }
+ return true;
+ }
if (otherReferenceType.isInterface()) { // could be annotation type
if (implementsInterface(otherReferenceType, true))
return true;
@@ -1786,7 +1794,6 @@ public boolean isCompatibleViaLowering(ReferenceBinding other) {
return false;
}
// SH}
-
public boolean isSubtypeOf(TypeBinding other) {
if (isSubTypeOfRTL(other))
return true;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java
index 8b2cae7c6..1b99f1811 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java
@@ -2647,7 +2647,7 @@ private MethodBinding resolveTypesWithSuspendedTempErrorHandlingPolicy(MethodBin
|| !parameterType.isCompatibleWith(declaredBaseclass))
{
ProblemReferenceBinding problemBinding = new ProblemReferenceBinding(
- parameterType.readableName(), (ReferenceBinding)parameterType, ProblemReasons.NotVisible);
+ parameterType.readableName(), (ReferenceBinding)parameterType, ProblemReasons.NotVisible, true);
this.scope.problemReporter().invalidType(arg.type, problemBinding);
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java
index 845538417..9259eda59 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java
@@ -1243,40 +1243,11 @@ public class TypeVariableBinding extends ReferenceBinding {
}
public ReferenceBinding upwardsProjection(Scope scope, TypeBinding[] mentionedTypeVariables) {
- if (enterRecursiveProjectionFunction()) {
- try {
- for (int i = 0; i < mentionedTypeVariables.length; ++i) {
- if (TypeBinding.equalsEquals(this, mentionedTypeVariables[i])) {
- TypeBinding upperBound = this.upperBound();
- ReferenceBinding projectedUpper = ((ReferenceBinding)upperBound).upwardsProjection(scope, mentionedTypeVariables);
- TypeBinding additionalBounds[] = this.additionalBounds();
- if (additionalBounds == null || additionalBounds.length == 0) {
- // Return upwards projection of upper bound
- return projectedUpper;
- } else {
- // If the type variable has more than one upper bound,
- // we'll need to make an intersection type of projections of all bounds
- int totalBounds = 1 + additionalBounds.length;
- ReferenceBinding[] projectedTypes = new ReferenceBinding[totalBounds];
- projectedTypes[0] = projectedUpper;
- for (int j = 0; j < additionalBounds.length; ++j) {
- projectedTypes[j+1] = (ReferenceBinding)additionalBounds[j].upwardsProjection(scope, mentionedTypeVariables);
- }
- return (ReferenceBinding) scope.environment().createIntersectionType18(projectedTypes);
- }
- }
- }
- return this;
- } finally {
- exitRecursiveProjectionFunction();
- }
- } else {
- return scope.getJavaLangObject();
- }
+ return this;
}
public ReferenceBinding downwardsProjection(Scope scope, TypeBinding[] mentionedTypeVariables) {
- return null;
+ return this;
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties
index 243a57b47..9460d8bbd 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties
@@ -942,18 +942,18 @@
1460 = Must declare a named package because this compilation unit is associated to the named module ''{0}''
# Local-Variable Type Inference
-1500 = ''var'' is not allowed in a compound declaration
-1501 = ''var'' is not allowed as an element type of an array
-1502 = Declaration using ''var'' may not contain references to itself
-1503 = Cannot use ''var'' on variable without initializer
-1504 = Cannot infer type for local variable initialized to ''null''
-1505 = Variable initializer is ''void'' -- cannot infer variable type
+1500 = 'var' is not allowed in a compound declaration
+1501 = 'var' is not allowed as an element type of an array
+1502 = Declaration using 'var' may not contain references to itself
+1503 = Cannot use 'var' on variable without initializer
+1504 = Cannot infer type for local variable initialized to 'null'
+1505 = Variable initializer is 'void' -- cannot infer variable type
1506 = Array initializer needs an explicit target-type
1507 = Lambda expression needs an explicit target-type
1508 = Method reference needs an explicit target-type
-1509 = ''var'' is not a valid type name
-1510 = ''var'' should not be used as an type name, since it is a reserved word from source level 10 on
-1511 = ''var'' is not allowed here
+1509 = 'var' is not a valid type name
+1510 = 'var' should not be used as an type name, since it is a reserved word from source level 10 on
+1511 = 'var' is not allowed here
### ELABORATIONS
## Access restrictions
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/JRTUtil.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/JRTUtil.java
index 8633fede5..e78fefcbb 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/JRTUtil.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/util/JRTUtil.java
@@ -16,6 +16,7 @@ import java.io.InputStream;
import java.net.URI;
import java.net.URL;
import java.net.URLClassLoader;
+import java.nio.channels.ClosedByInterruptException;
import java.nio.file.DirectoryStream;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
@@ -165,6 +166,22 @@ public class JRTUtil {
public static boolean hasCompilationUnit(File jrt, String qualifiedPackageName, String moduleName) {
return getJrtSystem(jrt).hasClassFile(qualifiedPackageName, moduleName);
}
+ /**
+ * Tries to read all bytes of the file denoted by path,
+ * returns null if the file could not be found or if the read was interrupted.
+ * @param path
+ * @return bytes or null
+ * @throws IOException any IO exception other than NoSuchFileException
+ */
+ public static byte[] safeReadBytes(Path path) throws IOException {
+ try {
+ return Files.readAllBytes(path);
+ } catch(ClosedByInterruptException e) {
+ return null;
+ } catch (NoSuchFileException e) {
+ return null;
+ }
+ }
}
class JrtFileSystem {
private final Map<String, String> packageToModule = new HashMap<String, String>();
@@ -287,14 +304,10 @@ class JrtFileSystem {
byte[] content = null;
String module = null;
for (String mod : modules) {
- try {
- content = Files.readAllBytes(this.jrtSystem.getPath(JRTUtil.MODULES_SUBDIR, mod, fileName));
- if (content != null) {
- module = mod;
- break;
- }
- } catch(NoSuchFileException e) {
- continue;
+ content = JRTUtil.safeReadBytes(this.jrtSystem.getPath(JRTUtil.MODULES_SUBDIR, mod, fileName));
+ if (content != null) {
+ module = mod;
+ break;
}
}
if (content != null) {
@@ -312,26 +325,16 @@ class JrtFileSystem {
} else {
String[] modules = getModules(fileName);
for (String mod : modules) {
- try {
- content = Files.readAllBytes(this.jrtSystem.getPath(JRTUtil.MODULES_SUBDIR, mod, fileName));
- if (content != null) {
- break;
- }
- } catch(NoSuchFileException e) {
- continue;
+ content = JRTUtil.safeReadBytes(this.jrtSystem.getPath(JRTUtil.MODULES_SUBDIR, mod, fileName));
+ if (content != null) {
+ break;
}
}
}
return content;
}
private byte[] getClassfileBytes(String fileName, String module) throws IOException, ClassFormatException {
- byte[] content = null;
- try {
- content = Files.readAllBytes(this.jrtSystem.getPath(JRTUtil.MODULES_SUBDIR, module, fileName));
- } catch(NoSuchFileException e) {
- return null;
- }
- return content;
+ return JRTUtil.safeReadBytes(this.jrtSystem.getPath(JRTUtil.MODULES_SUBDIR, module, fileName));
}
public ClassFileReader getClassfile(String fileName, String module) throws IOException, ClassFormatException {
ClassFileReader reader = null;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/ast/MethodSpec.java b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/ast/MethodSpec.java
index 32469e9c4..6d08afc8c 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/ast/MethodSpec.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/ast/MethodSpec.java
@@ -408,7 +408,7 @@ public class MethodSpec extends ASTNode implements InvocationSite
private TypeBinding boundMethodReturnType() {
if (this.resolvedMethod == null)
- return new ProblemReferenceBinding("<missing>".toCharArray(), null, ProblemReasons.NotFound); //$NON-NLS-1$
+ return new ProblemReferenceBinding("<missing>".toCharArray(), null, ProblemReasons.NotFound, true); //$NON-NLS-1$
if (this.resolvedMethod.isCallin())
return MethodModel.getReturnType(this.resolvedMethod);
return this.resolvedMethod.returnType;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/ast/PrecedenceDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/ast/PrecedenceDeclaration.java
index 2577b3385..b54371e9f 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/ast/PrecedenceDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/ast/PrecedenceDeclaration.java
@@ -186,7 +186,7 @@ public class PrecedenceDeclaration extends ASTNode {
if (roleBinding != null) {
if (!typeAllowed) {
scope.problemReporter().illegalDeepRoleReferenceInPrecedence(this, type, roleBinding);
- return new ProblemReferenceBinding(name, roleBinding, ProblemReasons.NotVisible);
+ return new ProblemReferenceBinding(name, roleBinding, ProblemReasons.NotVisible, true);
}
return roleBinding;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/ast/TypeAnchorReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/ast/TypeAnchorReference.java
index 31c4e46a7..6ad4d8ef7 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/ast/TypeAnchorReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/ast/TypeAnchorReference.java
@@ -338,7 +338,7 @@ public class TypeAnchorReference extends TypeReference implements InvocationSite
if (currentAnchor == null) {
currentAnchor = new ProblemFieldBinding(scope.enclosingReceiverType(), currentToken, ProblemReasons.NotFound);
((FieldBinding)currentAnchor).type =
- reference.resolvedType = new ProblemReferenceBinding("UnresolvedType".toCharArray(), null, ProblemReasons.NotFound); //$NON-NLS-1$
+ reference.resolvedType = new ProblemReferenceBinding("UnresolvedType".toCharArray(), null, ProblemReasons.NotFound, true); //$NON-NLS-1$
} else if (currentAnchor.isValidBinding()) {
if (prefix != null && !(prefix instanceof TThisBinding))
currentAnchor = currentAnchor.setPathPrefix(prefix);
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/lookup/AnchorMapping.java b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/lookup/AnchorMapping.java
index ca23363da..635c7406b 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/lookup/AnchorMapping.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/lookup/AnchorMapping.java
@@ -170,7 +170,7 @@ public class AnchorMapping {
// missing a required anchor?
if (anchor == null && paramDependentType.hasAnchorWithinThisMethodsSignature(currentMethod))
- return new ProblemReferenceBinding(paramDependentType.sourceName(), paramDependentType, ProblemReasons.AnchorNotFound);
+ return new ProblemReferenceBinding(paramDependentType.sourceName(), paramDependentType, ProblemReasons.AnchorNotFound, true);
if (anchor == null && AnchorMapping.this._receiver != null)
{
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/lookup/OTClassScope.java b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/lookup/OTClassScope.java
index c24b7c7c0..d0377bfb3 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/lookup/OTClassScope.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/lookup/OTClassScope.java
@@ -209,7 +209,7 @@ public class OTClassScope extends ClassScope {
{
if (problem instanceof ReferenceBinding)
return new ProblemReferenceBinding(compoundName,
- (ReferenceBinding)problem, ProblemReasons.Ambiguous);
+ (ReferenceBinding)problem, ProblemReasons.Ambiguous, true);
else
return null; // no ProblemBinding can be constructed (cf. Scope.TODO should improve).
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/util/RoleTypeCreator.java b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/util/RoleTypeCreator.java
index c2d004615..b602f980f 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/util/RoleTypeCreator.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/util/RoleTypeCreator.java
@@ -1214,7 +1214,7 @@ public class RoleTypeCreator implements TagBits {
roleType = anchor.getMemberTypeOfType(roleName);
problemReporter.referenceContext = contextSave;
if (roleType == null)
- return new ProblemReferenceBinding(roleName, null, ProblemReasons.NotFound);
+ return new ProblemReferenceBinding(roleName, null, ProblemReasons.NotFound, true);
}
// call the principal method:
@@ -1479,7 +1479,7 @@ public class RoleTypeCreator implements TagBits {
return new ProblemReferenceBinding(
site.sourceName(),
role,
- ProblemReasons.NoTeamContext);
+ ProblemReasons.NoTeamContext, true);
}
return teamBinding.getMemberType(role.internalName());
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java
index eaceb7bf5..af34c7bc8 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java
@@ -4006,7 +4006,8 @@ class ASTConverter {
if (this.resolveBindings) {
recordNodes(variableDeclarationFragment, localDeclaration);
if (this.ast.apiLevel() >= AST.JLS10_INTERNAL && type.isVar()) {
- Name varName = ((SimpleType) type).getName();
+ SimpleName varName = (SimpleName) ((SimpleType) type).getName();
+ varName.setVar(true);
recordNodes(varName, localDeclaration);
}
}
@@ -4209,6 +4210,9 @@ class ASTConverter {
type = simpleType;
type.setSourceRange(sourceStart, end - sourceStart + 1);
type = simpleType;
+ if (this.ast.apiLevel() >= AST.JLS10_INTERNAL && type.isVar()) {
+ simpleName.setVar(true);
+ }
if (this.resolveBindings) {
this.recordNodes(simpleName, typeReference);
}
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java
index 50c39e3f2..b7fcf051f 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/DefaultBindingResolver.java
@@ -1682,7 +1682,9 @@ class DefaultBindingResolver extends BindingResolver {
QualifiedSuperReference qualifiedSuperReference = (QualifiedSuperReference) node;
return this.getTypeBinding(qualifiedSuperReference.qualification.resolvedType);
} else if (node instanceof LocalDeclaration) {
- return this.getVariableBinding(((LocalDeclaration)node).binding);
+ return name.getAST().apiLevel() >= AST.JLS10_INTERNAL && name instanceof SimpleName && ((SimpleName) name).isVar() ?
+ resolveTypeBindingForName(name) :
+ this.getVariableBinding(((LocalDeclaration)node).binding);
} else if (node instanceof JavadocFieldReference) {
JavadocFieldReference fieldRef = (JavadocFieldReference) node;
if (fieldRef.methodBinding != null) {
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SimpleName.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SimpleName.java
index 68b971e08..124c68b6a 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SimpleName.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/SimpleName.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -44,6 +44,13 @@ public class SimpleName extends Name {
new SimplePropertyDescriptor(SimpleName.class, "identifier", String.class, MANDATORY); //$NON-NLS-1$
/**
+ * The "var" property of this node name (type: {@link Boolean}) (added in JLS10 API).
+ * @since 3.14
+ */
+ public static final SimplePropertyDescriptor VAR_PROPERTY =
+ new SimplePropertyDescriptor(SimpleName.class, "var", boolean.class, MANDATORY); //$NON-NLS-1$
+
+ /**
* A list of property descriptors (element type:
* {@link StructuralPropertyDescriptor}),
* or null if uninitialized.
@@ -51,12 +58,26 @@ public class SimpleName extends Name {
*/
private static final List PROPERTY_DESCRIPTORS;
+ /**
+ * A list of property descriptors (element type:
+ * {@link StructuralPropertyDescriptor}),
+ * or null if uninitialized.
+ * @since 3.14
+ */
+ private static final List PROPERTY_DESCRIPTORS_10_0;
+
static {
List propertyList = new ArrayList(2);
createPropertyList(SimpleName.class, propertyList);
addProperty(IDENTIFIER_PROPERTY, propertyList);
PROPERTY_DESCRIPTORS = reapPropertyList(propertyList);
- }
+
+ propertyList = new ArrayList(3);
+ createPropertyList(SimpleName.class, propertyList);
+ addProperty(IDENTIFIER_PROPERTY, propertyList);
+ addProperty(VAR_PROPERTY, propertyList);
+ PROPERTY_DESCRIPTORS_10_0 = reapPropertyList(propertyList);
+}
/**
* Returns a list of structural property descriptors for this node type.
@@ -68,7 +89,11 @@ public class SimpleName extends Name {
* @since 3.0
*/
public static List propertyDescriptors(int apiLevel) {
- return PROPERTY_DESCRIPTORS;
+ if (apiLevel < AST.JLS10_INTERNAL) {
+ return PROPERTY_DESCRIPTORS;
+ } else {
+ return PROPERTY_DESCRIPTORS_10_0;
+ }
}
/**
@@ -82,6 +107,14 @@ public class SimpleName extends Name {
private String identifier = MISSING_IDENTIFIER;
/**
+ * Indicates the whether this represents a var;
+ * defaults to false.
+ *
+ * @since 3.14
+ */
+ private boolean isVarType = false;
+
+ /**
* Creates a new AST node for a simple name owned by the given AST.
* The new node has an unspecified, legal Java identifier.
* <p>
@@ -104,6 +137,20 @@ public class SimpleName extends Name {
return propertyDescriptors(apiLevel);
}
+ @Override
+ final boolean internalGetSetBooleanProperty(SimplePropertyDescriptor property, boolean get, boolean value) {
+ if (property == VAR_PROPERTY) {
+ if (get) {
+ return isVar();
+ } else {
+ setVar(value);
+ return false;
+ }
+ }
+ // allow default implementation to flag the error
+ return super.internalGetSetBooleanProperty(property, get, value);
+ }
+
/* (omit javadoc for this method)
* Method declared on ASTNode.
*/
@@ -134,6 +181,9 @@ public class SimpleName extends Name {
SimpleName result = new SimpleName(target);
result.setSourceRange(getStartPosition(), getLength());
result.setIdentifier(getIdentifier());
+ if (this.ast.apiLevel >= AST.JLS10_INTERNAL) {
+ result.setVar(isVar());
+ }
return result;
}
@@ -220,6 +270,27 @@ public class SimpleName extends Name {
postValueChange(IDENTIFIER_PROPERTY);
}
+ /**
+ * Returns whether this represents a "var" type or not (added in JLS10 API).
+ *
+ * @return <code>true</code> if this is a var type
+ * and <code>false</code> otherwise
+ * @exception UnsupportedOperationException if this operation is used in
+ * an AST below JLS10
+ * @since 3.14
+ */
+ public boolean isVar() {
+ unsupportedBelow10();
+ return this.isVarType;
+ }
+
+ /* package */ void setVar(boolean isVar) {
+ unsupportedBelow10();
+ preValueChange(VAR_PROPERTY);
+ this.isVarType = isVar;
+ postValueChange(VAR_PROPERTY);
+ }
+
/* (omit javadoc for this method)
* This method is a copy of setIdentifier(String) that doesn't do any validation.
*/
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/Signature.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/Signature.java
index 3d16eeddd..72220e00b 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/Signature.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/Signature.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -41,10 +41,14 @@ import org.eclipse.jdt.internal.compiler.util.Util;
* with J2SE 1.4 or earlier, involved only <i>simple</i> signatures.
* </p>
* <p>
- * Note that the "Q", "!" and "|" formats are specific to Eclipse; the remainder
+ * Note that the "Q", "!", "|" and "&" formats are specific to Eclipse; the remainder
* are specified in the JVM spec.
* </p>
* <p>
+ * Due to historical reasons Eclipse uses "|" format for Intersection and "&" for Union
+ * which is opposite to their usage in source code.
+ * </p>
+ * <p>
* The syntax for a type signature is:
* <pre>
* TypeSignature ::=
@@ -273,6 +277,14 @@ public final class Signature {
public static final char C_INTERSECTION = '|';
/**
+ * Character constant indicating a union type in a
+ * signature. Value is <code>'&'</code>.
+ *
+ * @since 3.14
+ */
+ public static final char C_UNION = '&';
+
+ /**
* Character constant indicating the primitive type long in a signature.
* Value is <code>'J'</code>.
*/
@@ -391,6 +403,12 @@ public final class Signature {
* @since 3.7.1
*/
public static final int INTERSECTION_TYPE_SIGNATURE = 7;
+ /**
+ * Kind constant for the union type signature.
+ * @see #getTypeSignatureKind(String)
+ * @since 3.14
+ */
+ public static final int UNION_TYPE_SIGNATURE = 8;
private static final char[] LONG = "long".toCharArray(); //$NON-NLS-1$
@@ -1133,6 +1151,26 @@ public static String createIntersectionTypeSignature(char[][] typeSignatures) {
}
return String.valueOf(buffer);
}
+/**
+ * Creates a new union type signature from the given type signatures.
+ *
+ * <p>The encoded type signature is dot-based.</p>
+ *
+ * @param typeSignatures the given type signatures
+ * @return the encoded type signature
+ * @since 3.7.1
+ */
+private static String createUnionTypeSignature(char[][] typeSignatures) {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(Signature.C_UNION);
+ for (int i = 0, max = typeSignatures.length; i < max; i++) {
+ if (i > 0) {
+ buffer.append(Signature.C_COLON);
+ }
+ buffer.append(typeSignatures[i]);
+ }
+ return String.valueOf(buffer);
+}
/**
* Creates a new intersection type signature from the given type signatures.
@@ -1152,6 +1190,23 @@ public static String createIntersectionTypeSignature(String[] typeSignatures) {
return createIntersectionTypeSignature(signatures);
}
/**
+ * Creates a new union type signature from the given type signatures.
+ *
+ * <p>The encoded type signature is dot-based.</p>
+ *
+ * @param typeSignatures the given type signatures
+ * @return the encoded type signature
+ * @since 3.14
+ */
+public static String createUnionTypeSignature(String[] typeSignatures) {
+ int typeSignaturesLenth = typeSignatures.length;
+ char[][] signatures = new char[typeSignaturesLenth][];
+ for (int i = 0; i < typeSignaturesLenth; i++) {
+ signatures[i] = typeSignatures[i].toCharArray();
+ }
+ return createUnionTypeSignature(signatures);
+}
+/**
* Creates a method signature from the given parameter and return type
* signatures. The encoded method signature is dot-based.
*
@@ -1618,6 +1673,30 @@ public static char[][] getIntersectionTypeBounds(char[] intersectionTypeSignatur
i = e + 2; // add one to skip C_COLON
}
}
+private static char[][] getUnionTypeBounds(char[] unionTypeSignature) throws IllegalArgumentException {
+ if (getTypeSignatureKind(unionTypeSignature) != UNION_TYPE_SIGNATURE) {
+ return CharOperation.NO_CHAR_CHAR;
+ }
+ ArrayList args = new ArrayList();
+ int i = 1; // skip the '|'
+ int length = unionTypeSignature.length;
+ for (;;) {
+ int e = Util.scanClassTypeSignature(unionTypeSignature, i);
+ if (e < 0) {
+ throw new IllegalArgumentException("Invalid format"); //$NON-NLS-1$
+ }
+ args.add(CharOperation.subarray(unionTypeSignature, i, e + 1));
+ if (e == length - 1) {
+ int size = args.size();
+ char[][] result = new char[size][];
+ args.toArray(result);
+ return result;
+ } else if (unionTypeSignature[e + 1] != C_COLON) {
+ throw new IllegalArgumentException("Invalid format"); //$NON-NLS-1$
+ }
+ i = e + 2; // add one to skip C_COLON
+ }
+}
/**
* Extracts the type bounds' signatures from the given intersection type signature.
* Returns an empty array if the type signature is not an intersection type signature.
@@ -1633,6 +1712,20 @@ public static String[] getIntersectionTypeBounds(String intersectionTypeSignatur
return CharOperation.toStrings(args);
}
/**
+ * Extracts the type bounds' signatures from the given union type signature.
+ * Returns an empty array if the type signature is not an union type signature.
+ *
+ * @param unionSignature the union type signature
+ * @return the signatures of the type bounds
+ * @exception IllegalArgumentException if the signature is syntactically incorrect
+ *
+ * @since 3.14
+ */
+public static String[] getUnionTypeBounds(String unionSignature) throws IllegalArgumentException {
+ char[][] args = getUnionTypeBounds(unionSignature.toCharArray());
+ return CharOperation.toStrings(args);
+}
+/**
* Returns the number of parameter types in the given method signature.
*
* @param methodSignature the method signature
@@ -2549,6 +2642,8 @@ public static int getTypeSignatureKind(char[] typeSignature) {
return CAPTURE_TYPE_SIGNATURE;
case C_INTERSECTION :
return INTERSECTION_TYPE_SIGNATURE;
+ case C_UNION :
+ return UNION_TYPE_SIGNATURE;
//{ObjectTeams: type anchors mimic class type?
case C_ANCHOR :
return CLASS_TYPE_SIGNATURE;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/AbstractClassFile.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/AbstractClassFile.java
index d2e9a4fc8..2c6072996 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/AbstractClassFile.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/AbstractClassFile.java
@@ -27,6 +27,7 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Path;
import org.eclipse.jdt.core.*;
import org.eclipse.jdt.core.compiler.IProblem;
@@ -202,6 +203,8 @@ public abstract class AbstractClassFile extends Openable implements IClassFile,
JavaModelManager.getJavaModelManager().closeZipFile(zip);
}
}
+ if (contents == null && Thread.interrupted()) // reading from JRT is interruptible
+ throw new OperationCanceledException();
return contents;
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java
index bf5ce467f..f3e37330e 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageFragmentRoot.java
@@ -488,7 +488,7 @@ protected void getHandleMemento(StringBuffer buff) {
buff.append(getHandleMementoDelimiter());
escapeMementoName(buff, path.toString());
if (org.eclipse.jdt.internal.compiler.util.Util.isJrt(path.toOSString())) {
- buff.append(getHandleMementoDelimiter());
+ buff.append(JavaElement.JEM_MODULE);
escapeMementoName(buff, getElementName());
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SelectionRequestor.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SelectionRequestor.java
index f70ada942..f8f8061b2 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SelectionRequestor.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SelectionRequestor.java
@@ -28,10 +28,12 @@ import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.ITypeParameter;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.Signature;
-import org.eclipse.jdt.core.compiler.*;
+import org.eclipse.jdt.core.compiler.CategorizedProblem;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.codeassist.ISelectionRequestor;
import org.eclipse.jdt.internal.codeassist.SelectionEngine;
import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.CastExpression;
import org.eclipse.jdt.internal.compiler.ast.LambdaExpression;
import org.eclipse.jdt.internal.compiler.ast.LocalDeclaration;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
@@ -478,7 +480,11 @@ public void acceptLocalVariable(LocalVariableBinding binding, org.eclipse.jdt.in
// SH}
String typeSig = null;
if (local.type == null || local.type.isTypeNameVar(binding.declaringScope)) {
- typeSig = Signature.createTypeSignature(binding.type.signableName(), true);// : Util.typeSignature(local.type)
+ if (local.initialization instanceof CastExpression) {
+ typeSig = Util.typeSignature(((CastExpression) local.initialization).type);
+ } else {
+ typeSig = Signature.createTypeSignature(binding.type.signableName(), true);
+ }
} else {
typeSig = Util.typeSignature(local.type);
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJrt.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJrt.java
index e40883856..724528b16 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJrt.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathJrt.java
@@ -28,6 +28,7 @@ import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException;
import org.eclipse.jdt.internal.compiler.classfmt.ExternalAnnotationDecorator;
+import org.eclipse.jdt.internal.compiler.env.AccessRuleSet;
import org.eclipse.jdt.internal.compiler.env.IBinaryType;
import org.eclipse.jdt.internal.compiler.env.IModule;
import org.eclipse.jdt.internal.compiler.env.IModule.IModuleReference;
@@ -46,11 +47,13 @@ private static HashMap<String, Set<IModule>> ModulesCache = new HashMap<>();
private String externalAnnotationPath;
private ZipFile annotationZipFile;
String zipFilename; // keep for equals
+AccessRuleSet accessRuleSet;
static final Set<String> NO_LIMIT_MODULES = new HashSet<>();
-public ClasspathJrt(String zipFilename, IPath externalAnnotationPath) {
+public ClasspathJrt(String zipFilename, AccessRuleSet accessRuleSet, IPath externalAnnotationPath) {
this.zipFilename = zipFilename;
+ this.accessRuleSet = accessRuleSet;
if (externalAnnotationPath != null)
this.externalAnnotationPath = externalAnnotationPath.toString();
loadModules(this);
@@ -181,7 +184,9 @@ public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof ClasspathJrt)) return false;
ClasspathJrt jar = (ClasspathJrt) o;
-
+ if (this.accessRuleSet != jar.accessRuleSet)
+ if (this.accessRuleSet == null || !this.accessRuleSet.equals(jar.accessRuleSet))
+ return false;
return this.zipFilename.endsWith(jar.zipFilename) && areAllModuleOptionsEqual(jar);
}
@@ -192,8 +197,8 @@ public NameEnvironmentAnswer findClass(String binaryFileName, String qualifiedPa
try {
IBinaryType reader = ClassFileReader.readFromModule(new File(this.zipFilename), moduleName, qualifiedBinaryFileName);
if (reader != null) {
+ String fileNameWithoutExtension = qualifiedBinaryFileName.substring(0, qualifiedBinaryFileName.length() - SuffixConstants.SUFFIX_CLASS.length);
if (this.externalAnnotationPath != null) {
- String fileNameWithoutExtension = qualifiedBinaryFileName.substring(0, qualifiedBinaryFileName.length() - SuffixConstants.SUFFIX_CLASS.length);
try {
if (this.annotationZipFile == null) {
this.annotationZipFile = ExternalAnnotationDecorator.getAnnotationZipFile(this.externalAnnotationPath, null);
@@ -203,7 +208,11 @@ public NameEnvironmentAnswer findClass(String binaryFileName, String qualifiedPa
// don't let error on annotations fail class reading
}
}
- return new NameEnvironmentAnswer(reader, null, reader.getModule());
+ if (this.accessRuleSet == null)
+ return new NameEnvironmentAnswer(reader, null, reader.getModule());
+ return new NameEnvironmentAnswer(reader,
+ this.accessRuleSet.getViolatedRestriction(fileNameWithoutExtension.toCharArray()),
+ reader.getModule());
}
} catch (IOException e) { // treat as if class file is missing
} catch (ClassFormatException e) { // treat as if class file is missing
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathLocation.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathLocation.java
index bdbe6e505..0f43c83da 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathLocation.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathLocation.java
@@ -125,7 +125,7 @@ static ClasspathLocation forLibrary(String libraryPathname,
IPath annotationsPath,
boolean autoModule) {
return Util.isJrt(libraryPathname) ?
- new ClasspathJrt(libraryPathname, annotationsPath) :
+ new ClasspathJrt(libraryPathname, accessRuleSet, annotationsPath) :
Util.archiveFormat(libraryPathname) == Util.JMOD_FILE ?
new ClasspathJMod(libraryPathname, lastModified, accessRuleSet, annotationsPath) :
new ClasspathJar(libraryPathname, lastModified, accessRuleSet, annotationsPath, autoModule);
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/MementoTokenizer.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/MementoTokenizer.java
index a80ac4cd2..0ebb54b29 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/MementoTokenizer.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/MementoTokenizer.java
@@ -121,6 +121,8 @@ public class MementoTokenizer {
if (buffer == null) buffer = new StringBuffer();
buffer.append(this.memento, start, this.index - start);
start = ++this.index;
+ if (this.memento[this.index] == JavaElement.JEM_MODULE)
+ return buffer.toString();
break;
case JavaElement.JEM_COUNT:
case JavaElement.JEM_JAVAPROJECT:
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Util.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Util.java
index 8a66611c2..6503e5c2d 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Util.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Util.java
@@ -48,9 +48,10 @@ import org.eclipse.jdt.core.util.IMethodInfo;
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.AnnotationMethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.Argument;
-import org.eclipse.jdt.internal.compiler.ast.UnionTypeReference;
+import org.eclipse.jdt.internal.compiler.ast.IntersectionCastTypeReference;
import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
+import org.eclipse.jdt.internal.compiler.ast.UnionTypeReference;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException;
@@ -2754,14 +2755,13 @@ public class Util {
// special treatment for union type reference
UnionTypeReference unionTypeReference = (UnionTypeReference) type;
TypeReference[] typeReferences = unionTypeReference.typeReferences;
- int length = typeReferences.length;
- String[] typeSignatures = new String[length];
- for(int i = 0; i < length; i++) {
- char[][] compoundName = typeReferences[i].getParameterizedTypeName();
- char[] typeName = CharOperation.concatWith(compoundName, '.');
- typeSignatures[i] = Signature.createTypeSignature(typeName, false/*don't resolve*/);
- }
+ String[] typeSignatures = typeSignatures(typeReferences);
signature = Signature.createIntersectionTypeSignature(typeSignatures);
+ } else if (type instanceof IntersectionCastTypeReference) {
+ IntersectionCastTypeReference intersection = (IntersectionCastTypeReference) type;
+ TypeReference[] typeReferences = intersection.typeReferences;
+ String[] typeSignatures = typeSignatures(typeReferences);
+ signature = Signature.createUnionTypeSignature(typeSignatures);
} else {
char[][] compoundName = type.getParameterizedTypeName();
char[] typeName =CharOperation.concatWith(compoundName, '.');
@@ -2769,7 +2769,17 @@ public class Util {
}
return signature;
}
-
+
+ private static String[] typeSignatures(TypeReference[] types) {
+ int length = types.length;
+ String[] typeSignatures = new String[length];
+ for(int i = 0; i < length; i++) {
+ char[][] compoundName = types[i].getParameterizedTypeName();
+ char[] typeName = CharOperation.concatWith(compoundName, '.');
+ typeSignatures[i] = Signature.createTypeSignature(typeName, false/*don't resolve*/);
+ }
+ return typeSignatures;
+ }
/**
* Asserts that the given method signature is valid.
*/
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/nd/java/model/BinaryModuleFactory.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/nd/java/model/BinaryModuleFactory.java
index 4db9ae2d9..dc768bc38 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/nd/java/model/BinaryModuleFactory.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/nd/java/model/BinaryModuleFactory.java
@@ -33,6 +33,7 @@ import org.eclipse.jdt.internal.compiler.env.IDependent;
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
import org.eclipse.jdt.internal.core.JarPackageFragmentRoot;
import org.eclipse.jdt.internal.core.JavaModelManager;
+import org.eclipse.jdt.internal.core.JrtPackageFragmentRoot;
import org.eclipse.jdt.internal.core.ModularClassFile;
import org.eclipse.jdt.internal.core.PackageFragmentRoot;
import org.eclipse.jdt.internal.core.nd.java.JavaIndex;
@@ -58,18 +59,22 @@ public class BinaryModuleFactory {
String entryName = TypeConstants.MODULE_INFO_CLASS_NAME_STRING;
IPath workspacePath = root.getPath();
String indexPath;
+ char[] moduleName = null;
if (root instanceof JarPackageFragmentRoot) {
entryName = ((JarPackageFragmentRoot) root).getClassFilePath(entryName);
indexPath = root.getHandleIdentifier() + IDependent.JAR_FILE_ENTRY_SEPARATOR + entryName;
// see additional comments in BinaryTypeFactor.createDescriptor()
+ if (root instanceof JrtPackageFragmentRoot) {
+ moduleName = root.getElementName().toCharArray();
+ }
} else {
location = location.append(entryName);
indexPath = workspacePath.append(entryName).toString();
workspacePath = classFile.resource().getFullPath();
}
- return new BinaryModuleDescriptor(location.toString().toCharArray(), null, // TODO: module name not know at this point
+ return new BinaryModuleDescriptor(location.toString().toCharArray(), moduleName, // TODO: module name only known for JRT
workspacePath.toString().toCharArray(), indexPath.toCharArray());
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/BinaryIndexer.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/BinaryIndexer.java
index e7493a7b0..c9cd370cc 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/BinaryIndexer.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/BinaryIndexer.java
@@ -12,6 +12,8 @@
package org.eclipse.jdt.internal.core.search.indexing;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.Signature;
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.search.SearchDocument;
@@ -841,13 +843,19 @@ public class BinaryIndexer extends AbstractIndexer implements SuffixConstants {
} catch (ClassFormatException e) {
// ignore
this.document.removeAllIndexEntries();
- Util.log(IStatus.WARNING, "The Java indexing could not index " + this.document.getPath() + ". This .class file doesn't follow the class file format specification. Please report this issue against the .class file vendor"); //$NON-NLS-1$ //$NON-NLS-2$
+ Util.log(new Status(IStatus.WARNING,
+ JavaCore.PLUGIN_ID,
+ "The Java indexing could not index " + this.document.getPath() + ". This .class file doesn't follow the class file format specification. Please report this issue against the .class file vendor", //$NON-NLS-1$ //$NON-NLS-2$
+ e));
} catch (RuntimeException e) {
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=182154
// logging the entry that could not be indexed and continue with the next one
// we remove all entries relative to the boggus document
this.document.removeAllIndexEntries();
- Util.log(IStatus.WARNING, "The Java indexing could not index " + this.document.getPath() + ". This .class file doesn't follow the class file format specification. Please report this issue against the .class file vendor"); //$NON-NLS-1$ //$NON-NLS-2$
+ Util.log(new Status(IStatus.WARNING,
+ JavaCore.PLUGIN_ID,
+ "The Java indexing could not index " + this.document.getPath() + ". This .class file doesn't follow the class file format specification. Please report this issue against the .class file vendor", //$NON-NLS-1$ //$NON-NLS-2$
+ e));
}
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/JavaSearchNameEnvironment.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/JavaSearchNameEnvironment.java
index 484716707..8873296bc 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/JavaSearchNameEnvironment.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/JavaSearchNameEnvironment.java
@@ -157,7 +157,7 @@ private ClasspathLocation mapToClassPathLocation(JavaModelManager manager, Packa
if (root.isArchive()) {
ClasspathEntry rawClasspathEntry = (ClasspathEntry) root.getRawClasspathEntry();
cp = JavaModelManager.isJrt(path) ?
- new ClasspathJrt(path.toOSString(),
+ new ClasspathJrt(path.toOSString(), rawClasspathEntry.getAccessRuleSet(),
ClasspathEntry.getExternalAnnotationPath(rawClasspathEntry, ((IJavaProject)root.getParent()).getProject(), true)) :
new ClasspathJar(manager.getZipFile(path), rawClasspathEntry.getAccessRuleSet(),
ClasspathEntry.getExternalAnnotationPath(rawClasspathEntry,

Back to the top