Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Arthanareeswaran2016-07-14 05:59:33 +0000
committerJay Arthanareeswaran2016-07-14 05:59:33 +0000
commit8c20364cec20db9df028ee3c438a99040d64efe6 (patch)
treebc165a306a5ef792798a893477a2bb90d8dd6b8d /org.eclipse.jdt.compiler.apt.tests
parent225d59ef8bf19c3509603a756a5a06ed9b38fadd (diff)
downloadeclipse.jdt.core-8c20364cec20db9df028ee3c438a99040d64efe6.tar.gz
eclipse.jdt.core-8c20364cec20db9df028ee3c438a99040d64efe6.tar.xz
eclipse.jdt.core-8c20364cec20db9df028ee3c438a99040d64efe6.zip
Bug 317216 - NPE in ParameterizedTypeBinding.readableName
Adding regression test
Diffstat (limited to 'org.eclipse.jdt.compiler.apt.tests')
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors.jarbin199681 -> 203199 bytes
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors8.jarbin210594 -> 210595 bytes
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/AnnotationProcessorTests/Bug317216Proc.java81
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/resources/targets/AnnotationProcessorTests/bug317216/Foo.java9
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/resources/targets/AnnotationProcessorTests/bug317216/Gen.java4
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/AnnotationProcessorTests.java21
6 files changed, 115 insertions, 0 deletions
diff --git a/org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors.jar b/org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors.jar
index 821e180e49..02469079c9 100644
--- a/org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors.jar
+++ b/org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors.jar
Binary files differ
diff --git a/org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors8.jar b/org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors8.jar
index 177bbda441..2c4c285f5d 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/processors/org/eclipse/jdt/compiler/apt/tests/processors/AnnotationProcessorTests/Bug317216Proc.java b/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/AnnotationProcessorTests/Bug317216Proc.java
new file mode 100644
index 0000000000..9e23e07ad4
--- /dev/null
+++ b/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/AnnotationProcessorTests/Bug317216Proc.java
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2016 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ *******************************************************************************/
+
+package org.eclipse.jdt.compiler.apt.tests.processors.AnnotationProcessorTests;
+
+import java.util.Set;
+
+import javax.annotation.processing.ProcessingEnvironment;
+import javax.annotation.processing.RoundEnvironment;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.annotation.processing.SupportedSourceVersion;
+import javax.lang.model.SourceVersion;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ElementKind;
+import javax.lang.model.element.ExecutableElement;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.type.DeclaredType;
+import javax.lang.model.type.TypeMirror;
+import javax.lang.model.util.ElementFilter;
+
+import org.eclipse.jdt.compiler.apt.tests.processors.base.BaseProcessor;
+
+/**
+ * A processor that should not be invoked. Reports an error if invoked.
+ */
+@SupportedAnnotationTypes({"targets.AnnotationProcessorTests.bug317216.Gen"})
+@SupportedSourceVersion(SourceVersion.RELEASE_6)
+public class Bug317216Proc extends BaseProcessor {
+
+ @Override
+ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+ for (TypeElement typeElement : annotations) {
+ if (typeElement.getQualifiedName().toString().equals("targets.AnnotationProcessorTests.bug317216.Gen")) {
+ for (Element element : roundEnv.getElementsAnnotatedWith(typeElement)) {
+ if (element.getKind() == ElementKind.CLASS) {
+ printEntrySet((TypeElement) element);
+ }
+ }
+ }
+ }
+ return true;
+ }
+
+ public void printEntrySet(TypeElement element) {
+ ProcessingEnvironment pe = processingEnv;
+ for (ExecutableElement method : ElementFilter.methodsIn(pe.getElementUtils().getAllMembers(element))) {
+ if (!method.toString().contains("getFoo")) {
+ continue;
+ }
+ TypeElement element2 = (TypeElement) pe.getTypeUtils().asElement(method.getReturnType());
+ // element2 == java.util.Map
+ for (ExecutableElement method2 : ElementFilter.methodsIn(pe.getElementUtils().getAllMembers(element2))) {
+ if (method2.getSimpleName().toString().contains("entrySet")) {
+ TypeMirror s = method2.getReturnType();
+ DeclaredType st = (DeclaredType) s;
+
+ TypeMirror e = st.getTypeArguments().get(0);
+ DeclaredType de = (DeclaredType) e;
+ TypeMirror[] eargs = new TypeMirror[2];
+ eargs[0] = de.getTypeArguments().get(0);
+ eargs[1] = de.getTypeArguments().get(1);
+ TypeMirror e2 = pe.getTypeUtils().getDeclaredType((TypeElement) de.asElement(), eargs);
+ // e2.toString breaks without fix
+ e2.toString();
+ TypeMirror[] sargs = new TypeMirror[1];
+ sargs[0] = e2;
+
+ s = pe.getTypeUtils().getDeclaredType((TypeElement) st.asElement(), sargs);
+ s.toString();
+ }
+ }
+ }
+ }
+
+}
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/AnnotationProcessorTests/bug317216/Foo.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/AnnotationProcessorTests/bug317216/Foo.java
new file mode 100644
index 0000000000..abae7237a1
--- /dev/null
+++ b/org.eclipse.jdt.compiler.apt.tests/resources/targets/AnnotationProcessorTests/bug317216/Foo.java
@@ -0,0 +1,9 @@
+package targets.AnnotationProcessorTests.bug317216;
+
+import java.util.Map;
+
+@Gen
+public class Foo {
+ Map<String, String> getFoo() { return null; }
+}
+
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/AnnotationProcessorTests/bug317216/Gen.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/AnnotationProcessorTests/bug317216/Gen.java
new file mode 100644
index 0000000000..63a07bb9eb
--- /dev/null
+++ b/org.eclipse.jdt.compiler.apt.tests/resources/targets/AnnotationProcessorTests/bug317216/Gen.java
@@ -0,0 +1,4 @@
+package targets.AnnotationProcessorTests.bug317216;
+
+public @interface Gen {
+}
diff --git a/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/AnnotationProcessorTests.java b/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/AnnotationProcessorTests.java
index f15338ca89..574420def5 100644
--- a/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/AnnotationProcessorTests.java
+++ b/org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/AnnotationProcessorTests.java
@@ -41,6 +41,11 @@ public class AnnotationProcessorTests extends TestCase {
count++;
buffer.append(diagnostic.getMessage(Locale.getDefault()));
buffer.append("\n");
+ } else if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
+ count++;
+ buffer.append(diagnostic.getMessage(Locale.getDefault()));
+ buffer.append("\n");
+ System.out.println(buffer.toString());
}
}
public Diagnostic<? extends S> getErrorAt(int index) {
@@ -140,4 +145,20 @@ public class AnnotationProcessorTests extends TestCase {
options.add("-proc:only");
BatchTestUtils.compileTree(compiler, options, targetFolder, null);
}
+ public void testBug317216() throws IOException {
+ JavaCompiler compiler = BatchTestUtils.getEclipseCompiler();
+ File targetFolder = TestUtils.concatPath(BatchTestUtils.getSrcFolderName(), "targets", "AnnotationProcessorTests", "bug317216");
+ BatchTestUtils.copyResources("targets/AnnotationProcessorTests/bug317216", targetFolder);
+ List<String> options = new ArrayList<String>();
+ final String PROC = "org.eclipse.jdt.compiler.apt.tests.processors.AnnotationProcessorTests.Bug317216Proc";
+ options.add("-processorpath");
+ options.add(" ");
+ options.add("-processor");
+ options.add(PROC);
+ DiagnosticReport<JavaFileObject> diagnosticListener = new DiagnosticReport<JavaFileObject>();
+ BatchTestUtils.compileTreeWithErrors(compiler, options, targetFolder, diagnosticListener, true);
+ assertNull(System.getProperty(PROC));
+ assertEquals("incorrect number of messages", 0, diagnosticListener.count);
+ assertNull(System.getProperty(PROC));
+ }
}

Back to the top