Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Arthanareeswaran2018-03-26 21:01:33 +0000
committerJay Arthanareeswaran2018-03-27 10:56:21 +0000
commitf681464dfa69db9aae16eb9d092ce3c97e835de6 (patch)
tree36f025788a890a2639f6f93f3ade889212757f01 /org.eclipse.jdt.compiler.apt.tests
parent79d5afecf5f237634a5562279fdceca6591b2b58 (diff)
downloadeclipse.jdt.core-f681464dfa69db9aae16eb9d092ce3c97e835de6.tar.gz
eclipse.jdt.core-f681464dfa69db9aae16eb9d092ce3c97e835de6.tar.xz
eclipse.jdt.core-f681464dfa69db9aae16eb9d092ce3c97e835de6.zip
Bug 532913 - Testcase
Change-Id: Ieccc1767cf1fd9426e09691acd55726802e8d3bd Signed-off-by: Jay Arthanareeswaran <jarthana@in.ibm.com>
Diffstat (limited to 'org.eclipse.jdt.compiler.apt.tests')
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors8.jarbin235791 -> 235843 bytes
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/processors8/org/eclipse/jdt/compiler/apt/tests/processors/elements/Java8ElementProcessor.java12
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/resources/targets/model9/Y.java16
-rw-r--r--org.eclipse.jdt.compiler.apt.tests/src/org/eclipse/jdt/compiler/apt/tests/Java8ElementsTests.java58
4 files changed, 73 insertions, 13 deletions
diff --git a/org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors8.jar b/org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors8.jar
index 121c0dbeb0..de6b974816 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 809ea6a05f..1e3acee3e7 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
@@ -1067,6 +1067,18 @@ public class Java8ElementProcessor extends BaseProcessor {
erasure = _typeUtils.erasure(nullType);
assertSame("NoType should be same", nullType, erasure);
}
+ public void testMethodAnnotation() {
+ TypeElement annotatedType = _elementUtils.getTypeElement("targets.model9.Y");
+ List<? extends Element> members = _elementUtils.getAllMembers(annotatedType);
+ ExecutableElement method = null;
+ for (Element member : members) {
+ if ("m".equals(member.getSimpleName().toString())) {
+ method = (ExecutableElement) member;
+ }
+ }
+ assertNotNull("Method should not be null", method);
+ verifyAnnotations(method, new String[]{"@Deprecated()"});
+ }
private void createPackageBinary() throws IOException {
String path = packageName.replace('.', '/');
ClassLoader loader = getClass().getClassLoader();
diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/model9/Y.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/model9/Y.java
new file mode 100644
index 0000000000..3137ef4064
--- /dev/null
+++ b/org.eclipse.jdt.compiler.apt.tests/resources/targets/model9/Y.java
@@ -0,0 +1,16 @@
+package targets.model9;
+
+import java.lang.annotation.Documented;
+
+import org.eclipse.jdt.compiler.apt.tests.annotations.Type;
+
+class Y_s {
+ void m() {
+ }
+}
+
+public class Y extends Y_s {
+ @Deprecated void m() {
+ }
+}
+
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 a2beb52682..3c36c6d1ca 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
@@ -175,8 +175,10 @@ public class Java8ElementsTests extends TestCase {
internalTest(compiler, JAVA8_ANNOTATION_PROC, "testTypeAnnotations12");
}
public void _testTypeAnnotations12Binary() throws Exception { // FIXME: disabled after 3 consecutive failures on hudson, which could not be reproduced locally
+ if (!canRunJava9())
+ return;
JavaCompiler compiler = BatchTestUtils.getEclipseCompiler();
- internalTestWithBinary(compiler, JAVA8_ANNOTATION_PROC, "testTypeAnnotations12Binary", null, "model9");
+ internalTestWithBinary(compiler, JAVA8_ANNOTATION_PROC, "testTypeAnnotations12Binary", null, "model9", "9");
}
public void testTypeAnnotations13() throws Exception {
JavaCompiler compiler = BatchTestUtils.getEclipseCompiler();
@@ -312,21 +314,29 @@ public class Java8ElementsTests extends TestCase {
internalTest(compiler, JAVA8_ANNOTATION_PROC, "testTypeAnnotations27");
}
public void testPackageAnnotations() throws Exception {
+ if (!canRunJava9())
+ return;
JavaCompiler compiler = BatchTestUtils.getEclipseCompiler();
- internalTest(compiler, JAVA8_ANNOTATION_PROC, "testPackageAnnotations", null, "filer8");
+ internalTest(compiler, JAVA8_ANNOTATION_PROC, "testPackageAnnotations", null, "filer8", "9");
}
// See Java8ElementProcessor.testPackageAnnotations()
public void _testPackageAnnotationsWithJavac() throws Exception {
+ if (!canRunJava9())
+ return;
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
- internalTest(compiler, JAVA8_ANNOTATION_PROC, "testPackageAnnotations", null, "filer8");
+ internalTest(compiler, JAVA8_ANNOTATION_PROC, "testPackageAnnotations", null, "filer8", "9");
}
public void testBug520540a() throws Exception {
+ if (!canRunJava9())
+ return;
JavaCompiler compiler = BatchTestUtils.getEclipseCompiler();
- internalTest(compiler, JAVA8_ANNOTATION_PROC, "testBug520540", null, "bug520540");
+ internalTest(compiler, JAVA8_ANNOTATION_PROC, "testBug520540", null, "bug520540", "9");
}
public void testBug520540aJavac() throws Exception {
+ if (!canRunJava9())
+ return;
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
- internalTest(compiler, JAVA8_ANNOTATION_PROC, "testBug520540", null, "bug520540");
+ internalTest(compiler, JAVA8_ANNOTATION_PROC, "testBug520540", null, "bug520540", "9");
}
public void testBug520540b() throws Exception {
JavaCompiler compiler = BatchTestUtils.getEclipseCompiler();
@@ -363,23 +373,39 @@ public class Java8ElementsTests extends TestCase {
}
public void testBug526288() throws Exception {
JavaCompiler compiler = BatchTestUtils.getEclipseCompiler();
- internalTest(compiler, JAVA8_ANNOTATION_PROC, "testBug526288", "Bug526288.java", "bug526288");
+ internalTest(compiler, JAVA8_ANNOTATION_PROC, "testBug526288", "Bug526288.java", "bug526288", "8");
}
public void testEnumConstArgumentsBinary() throws Exception {
+ if (!canRunJava9())
+ return;
JavaCompiler compiler = BatchTestUtils.getEclipseCompiler();
- internalTestWithBinary(compiler, JAVA8_ANNOTATION_PROC, "testEnumConstArguments", null, "bug521812");
+ internalTestWithBinary(compiler, JAVA8_ANNOTATION_PROC, "testEnumConstArguments", null, "bug521812", "9");
}
public void testBug531717() throws Exception {
+ if (!canRunJava9())
+ return;
+ JavaCompiler compiler = BatchTestUtils.getEclipseCompiler();
+ internalTestWithBinary(compiler, JAVA8_ANNOTATION_PROC, "testBug531717", null, "bug521812", "9");
+ }
+ public void testMethodAnnotation() throws Exception {
+ if (!canRunJava9())
+ return;
JavaCompiler compiler = BatchTestUtils.getEclipseCompiler();
- internalTestWithBinary(compiler, JAVA8_ANNOTATION_PROC, "testBug531717", null, "bug521812");
+ internalTestWithBinary(compiler, JAVA8_ANNOTATION_PROC, "testMethodAnnotation", null, "model9", "9");
+ }
+ public void testMethodAnnotationJavac() throws Exception {
+ if (!canRunJava9())
+ return;
+ JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
+ internalTestWithBinary(compiler, JAVA8_ANNOTATION_PROC, "testMethodAnnotation", null, "model9", "9");
}
private void internalTest(JavaCompiler compiler, String processor, String testMethod) throws IOException {
internalTest(compiler, processor, testMethod, null);
}
private void internalTest(JavaCompiler compiler, String processor, String testMethod, String testClass) throws IOException {
- internalTest(compiler, processor, testMethod, testClass, "model8");
+ internalTest(compiler, processor, testMethod, testClass, "model8", "8");
}
- private void internalTest(JavaCompiler compiler, String processor, String testMethod, String testClass, String resourceArea) throws IOException {
+ private void internalTest(JavaCompiler compiler, String processor, String testMethod, String testClass, String resourceArea, String compliance) throws IOException {
if (!canRunJava8()) {
return;
}
@@ -397,7 +423,10 @@ public class Java8ElementsTests extends TestCase {
options.add("-A" + testMethod);
// Javac 1.8 doesn't (yet?) support the -1.8 option
if (compiler instanceof EclipseCompiler) {
- options.add("-1.8");
+ options.add("-" + compliance);
+ } else {
+ options.add("-source");
+ options.add(compliance);
}
BatchTestUtils.compileTree(compiler, options, targetFolder, true);
@@ -405,7 +434,7 @@ public class Java8ElementsTests extends TestCase {
// if not, it will set it to an error value.
assertEquals("succeeded", System.getProperty(processor));
}
- private void internalTestWithBinary(JavaCompiler compiler, String processor, String testMethod, String testClass, String resourceArea) throws IOException {
+ private void internalTestWithBinary(JavaCompiler compiler, String processor, String testMethod, String testClass, String resourceArea, String compliance) throws IOException {
if (!canRunJava8()) {
return;
}
@@ -425,7 +454,10 @@ public class Java8ElementsTests extends TestCase {
options.add(processor);
// Javac 1.8 doesn't (yet?) support the -1.8 option
if (compiler instanceof EclipseCompiler) {
- options.add("-1.8");
+ options.add("-" + compliance);
+ } else {
+ options.add("-source");
+ options.add(compliance);
}
BatchTestUtils.compileTreeAndProcessBinaries(compiler, options, processor, targetFolder, null);

Back to the top