Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTill Brychcy2017-11-03 16:03:29 -0400
committerTill Brychcy2017-11-04 04:26:44 -0400
commit4a47b9f38b4027f001ec1a537fae914caac424b6 (patch)
tree261a8d5544379a32a61e93d2b73eee1edfb264e6
parent861cc48ad91650783a132ecb798b8db021bf1417 (diff)
downloadeclipse.jdt.core-4a47b9f38b4027f001ec1a537fae914caac424b6.tar.gz
eclipse.jdt.core-4a47b9f38b4027f001ec1a537fae914caac424b6.tar.xz
eclipse.jdt.core-4a47b9f38b4027f001ec1a537fae914caac424b6.zip
Bug 526288 - AutoValue annotation processor causes
java.lang.NoSuchFieldError: MODULE Change-Id: Iaa4f311ab9064e9f8e55cc80d0d6f4635b08141d
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors8.jarbin232966 -> 232878 bytes
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/processors8/org/eclipse/jdt/compiler/apt/tests/processors/elements/Java8ElementProcessor.java7
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/resources/targets/bug526288/Bug526288.java6
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/Java8ElementsTests.java4
-rw-r--r--org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/PackageElementImpl.java4
5 files changed, 21 insertions, 0 deletions
diff --git a/org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors8.jar b/org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors8.jar
index 4fc9a5e2e9..fb1d9f4e95 100644
--- a/org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors8.jar
+++ b/org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors8.jar
Binary files differ
diff --git a/org.eclipse.jdt.compiler.apt.tests/processors8/org/eclipse/jdt/compiler/apt/tests/processors/elements/Java8ElementProcessor.java b/org.eclipse.jdt.compiler.apt.tests/processors8/org/eclipse/jdt/compiler/apt/tests/processors/elements/Java8ElementProcessor.java
index 078e88f6f5..028b997c31 100644
--- a/org.eclipse.jdt.compiler.apt.tests/processors8/org/eclipse/jdt/compiler/apt/tests/processors/elements/Java8ElementProcessor.java
+++ b/org.eclipse.jdt.compiler.apt.tests/processors8/org/eclipse/jdt/compiler/apt/tests/processors/elements/Java8ElementProcessor.java
@@ -171,6 +171,7 @@ public class Java8ElementProcessor extends BaseProcessor {
testTypeAnnotations27();
//testPackageAnnotations();
testBug520540();
+ testBug526288();
testEnumConstArguments();
}
@@ -1031,6 +1032,11 @@ public class Java8ElementProcessor extends BaseProcessor {
}
assertEquals("found incorrect types", 0, typeElements.size());
}
+ public void testBug526288() {
+ PackageElement packageElement = _elementUtils.getPackageElement("targets.testBug526288");
+ assertNotNull("package element should not be null", packageElement);
+ assertNull("package should have no enclosing element", packageElement.getEnclosingElement());
+ }
public void testEnumConstArguments() {
TypeElement annotatedType = _elementUtils.getTypeElement("targets.bug521812.MyEnum");
List<? extends Element> enclosedElements = annotatedType.getEnclosedElements();
@@ -1051,6 +1057,7 @@ public class Java8ElementProcessor extends BaseProcessor {
assertEquals("Parameter type should be same", param.asType(), asType2);
}
}
+
private void createPackageBinary() throws IOException {
String path = packageName.replace('.', '/');
ClassLoader loader = getClass().getClassLoader();
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/bug526288/Bug526288.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/bug526288/Bug526288.java
new file mode 100644
index 0000000000..db9fd34e0a
--- /dev/null
+++ b/org.eclipse.jdt.compiler.apt.tests/resources/targets/bug526288/Bug526288.java
@@ -0,0 +1,6 @@
+package targets.bug526288;
+
+@org.eclipse.jdt.compiler.apt.tests.annotations.Type()
+public class Bug526288 {
+ //
+}
diff --git a/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/Java8ElementsTests.java b/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/Java8ElementsTests.java
index b2b88767b5..f19a85c423 100644
--- a/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/Java8ElementsTests.java
+++ b/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/Java8ElementsTests.java
@@ -361,6 +361,10 @@ public class Java8ElementsTests extends TestCase {
assertEquals(true, success);
assertEquals("succeeded", System.getProperty(JAVA8_ANNOTATION_PROC));
}
+ public void testBug526288() throws Exception {
+ JavaCompiler compiler = BatchTestUtils.getEclipseCompiler();
+ internalTest(compiler, JAVA8_ANNOTATION_PROC, "testBug526288", "Bug526288.java", "bug526288");
+ }
public void testEnumConstArgumentsBinary() throws Exception {
JavaCompiler compiler = BatchTestUtils.getEclipseCompiler();
internalTestWithBinary(compiler, JAVA8_ANNOTATION_PROC, "testEnumConstArguments", null, "bug521812");
diff --git a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/PackageElementImpl.java b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/PackageElementImpl.java
index 7a386dd9f3..ca276eeecd 100644
--- a/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/PackageElementImpl.java
+++ b/org.eclipse.jdt.compiler.apt/src/org/eclipse/jdt/internal/compiler/apt/model/PackageElementImpl.java
@@ -27,6 +27,7 @@ import javax.lang.model.element.PackageElement;
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.apt.dispatch.BaseProcessingEnvImpl;
import org.eclipse.jdt.internal.compiler.batch.FileSystem;
+import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.env.INameEnvironment;
import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding;
import org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment;
@@ -101,6 +102,9 @@ public class PackageElementImpl extends ElementImpl implements PackageElement {
@Override
public Element getEnclosingElement() {
+ if (super._env.getCompiler().options.sourceLevel < ClassFileConstants.JDK9) {
+ return null;
+ }
PackageBinding pBinding = (PackageBinding) _binding;
ModuleBinding module = pBinding.enclosingModule;
if (module == null)

Back to the top