diff options
author | ssankaran | 2013-11-11 18:17:41 +0000 |
---|---|---|
committer | ssankaran | 2013-11-11 18:18:31 +0000 |
commit | 9d4deb39cd596c4aac108a1983a0ab5432be976e (patch) | |
tree | f126d7e43cc12fbdc43a948a7fc96d5059259bf7 /org.eclipse.jdt.compiler.apt.tests | |
parent | fb2dd37cec63b32be19be47d4358718ed4d76649 (diff) | |
download | eclipse.jdt.core-9d4deb39cd596c4aac108a1983a0ab5432be976e.tar.gz eclipse.jdt.core-9d4deb39cd596c4aac108a1983a0ab5432be976e.tar.xz eclipse.jdt.core-9d4deb39cd596c4aac108a1983a0ab5432be976e.zip |
Fixed Bug 421473 - [1.8][compiler] Delayed assignment of declaring
scope for arguments creates a race condition.
Diffstat (limited to 'org.eclipse.jdt.compiler.apt.tests')
5 files changed, 97 insertions, 9 deletions
diff --git a/org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors.jar b/org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors.jar Binary files differindex cda42270c2..e3fc2835be 100644 --- a/org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors.jar +++ b/org.eclipse.jdt.compiler.apt.tests/lib/apttestprocessors.jar diff --git a/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/elements/Java8ElementProcessor.java b/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/elements/Java8ElementProcessor.java index 4d380be2a5..df5b3bdbad 100644 --- a/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/elements/Java8ElementProcessor.java +++ b/org.eclipse.jdt.compiler.apt.tests/processors/org/eclipse/jdt/compiler/apt/tests/processors/elements/Java8ElementProcessor.java @@ -61,7 +61,8 @@ import org.eclipse.jdt.compiler.apt.tests.processors.base.BaseProcessor; * -Aorg.eclipse.jdt.compiler.apt.tests.processors.elements.Java8ElementProcessor to the command line. * @since 3.9 BETA_JAVA8 */ -@SupportedAnnotationTypes({"org.eclipse.jdt.compiler.apt.tests.annotations.Type", "org.eclipse.jdt.compiler.apt.tests.annotations.Type$1", +@SupportedAnnotationTypes({"targets.model8.TypeAnnot", + "org.eclipse.jdt.compiler.apt.tests.annotations.Type", "org.eclipse.jdt.compiler.apt.tests.annotations.Type$1", "org.eclipse.jdt.compiler.apt.tests.annotations.Foo", "org.eclipse.jdt.compiler.apt.tests.annotations.FooContainer", "org.eclipse.jdt.compiler.apt.tests.annotations.IFoo", "org.eclipse.jdt.compiler.apt.tests.annotations.IFooContainer", "org.eclipse.jdt.compiler.apt.tests.annotations.Goo", "org.eclipse.jdt.compiler.apt.tests.annotations.GooNonContainer", @@ -155,6 +156,8 @@ public class Java8ElementProcessor extends BaseProcessor { testTypeAnnotations23(); testRepeatedAnnotations24(); testRepeatedAnnotations25(); + testTypeAnnotations26(); + testTypeAnnotations27(); } public void testLambdaSpecifics() { @@ -895,6 +898,37 @@ public class Java8ElementProcessor extends BaseProcessor { assertTrue("Should be equals", annotationOnJep7.equals(annotationOnSubclass)); } + public void testTypeAnnotations26() { + TypeElement annotatedType = _elementUtils.getTypeElement("targets.model8.Iface"); + List<? extends Element> members = _elementUtils.getAllMembers(annotatedType); + ExecutableElement method = null; + for (Element member : members) { + if ("foo".equals(member.getSimpleName().toString())) { + method = (ExecutableElement) member; + + List<? extends VariableElement> list = method.getParameters(); + VariableElement param = list.get(0); + verifyAnnotations(param, new String[]{}); + } + } + } + + public void testTypeAnnotations27() { + TypeElement annotatedType = _elementUtils.getTypeElement("targets.model8.a.Test"); + List<? extends Element> members = _elementUtils.getAllMembers(annotatedType); + for (Element member : members) { + if ("foo".equals(member.getSimpleName().toString())) { + ExecutableElement method = (ExecutableElement) member; + + List<? extends TypeParameterElement> list = method.getTypeParameters(); + TypeParameterElement tParam = list.get(0); + verifyAnnotations(tParam, new String[]{"@MarkerContainer(value=[@targets.model8.a.Marker, @targets.model8.a.Marker])"}); + } + } + + } + + private String getExceptionStackTrace(Throwable t) { StringBuffer buf = new StringBuffer(t.getMessage()); StackTraceElement[] traces = t.getStackTrace(); diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/model8/InterfaceTest.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/model8/InterfaceTest.java new file mode 100644 index 0000000000..53b1fde427 --- /dev/null +++ b/org.eclipse.jdt.compiler.apt.tests/resources/targets/model8/InterfaceTest.java @@ -0,0 +1,17 @@ +package targets.model8; +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; + +@Target({ElementType.TYPE_USE}) @interface TypeAnnot {} + +interface Iface { + static void foo(@TypeAnnot int i) {} +} + +public class InterfaceTest implements Iface { + + public static void main(String[] argv) { + Iface.foo(10); + } +} + diff --git a/org.eclipse.jdt.compiler.apt.tests/resources/targets/model8/a/TypeParameterTest.java b/org.eclipse.jdt.compiler.apt.tests/resources/targets/model8/a/TypeParameterTest.java new file mode 100644 index 0000000000..b2f934bba3 --- /dev/null +++ b/org.eclipse.jdt.compiler.apt.tests/resources/targets/model8/a/TypeParameterTest.java @@ -0,0 +1,17 @@ +package targets.model8.a; +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; +import java.lang.annotation.Repeatable; + + +@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER }) @interface MarkerContainer {Marker[] value();} +@Repeatable(MarkerContainer .class) +@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER }) @interface Marker {} + + +class Test { + <@Marker() @Marker() T> T foo() { return null; } +} + +public class TypeParameterTest { +} 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 ee6cd53bd6..c6d9b1b348 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 @@ -48,7 +48,7 @@ public class Java8ElementsTests extends TestCase { JavaCompiler compiler = BatchTestUtils.getEclipseCompiler(); internalTest(compiler, JAVA8_ANNOTATION_PROC, "testSE8Specifics"); } - public void testSE8SpecificsWithJavac() throws Exception { + public void _testSE8SpecificsWithJavac() throws Exception { JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); internalTest(compiler, JAVA8_ANNOTATION_PROC, "testSE8Specifics"); } @@ -64,7 +64,7 @@ public class Java8ElementsTests extends TestCase { JavaCompiler compiler = BatchTestUtils.getEclipseCompiler(); internalTest(compiler, JAVA8_ANNOTATION_PROC, "testTypeAnnotations"); } - public void testTypeAnnotationsWithJavac() throws Exception { + public void _testTypeAnnotationsWithJavac() throws Exception { JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); internalTest(compiler, JAVA8_ANNOTATION_PROC, "testTypeAnnotations"); } @@ -80,7 +80,7 @@ public class Java8ElementsTests extends TestCase { JavaCompiler compiler = BatchTestUtils.getEclipseCompiler(); internalTest(compiler, JAVA8_ANNOTATION_PROC, "testTypeAnnotations2"); } - public void testTypeAnnotations2WithJavac() throws Exception { + public void _testTypeAnnotations2WithJavac() throws Exception { JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); internalTest(compiler, JAVA8_ANNOTATION_PROC, "testTypeAnnotations2"); } @@ -88,7 +88,7 @@ public class Java8ElementsTests extends TestCase { JavaCompiler compiler = BatchTestUtils.getEclipseCompiler(); internalTest(compiler, JAVA8_ANNOTATION_PROC, "testTypeAnnotations3"); } - public void testTypeAnnotations3WithJavac() throws Exception { + public void _testTypeAnnotations3WithJavac() throws Exception { JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); internalTest(compiler, JAVA8_ANNOTATION_PROC, "testTypeAnnotations3"); } @@ -96,7 +96,7 @@ public class Java8ElementsTests extends TestCase { JavaCompiler compiler = BatchTestUtils.getEclipseCompiler(); internalTest(compiler, JAVA8_ANNOTATION_PROC, "testTypeAnnotations4"); } - public void testTypeAnnotations4WithJavac() throws Exception { + public void _testTypeAnnotations4WithJavac() throws Exception { JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); internalTest(compiler, JAVA8_ANNOTATION_PROC, "testTypeAnnotations4"); } @@ -104,7 +104,7 @@ public class Java8ElementsTests extends TestCase { JavaCompiler compiler = BatchTestUtils.getEclipseCompiler(); internalTest(compiler, JAVA8_ANNOTATION_PROC, "testTypeAnnotations5"); } - public void testTypeAnnotations5WithJavac() throws Exception { + public void _testTypeAnnotations5WithJavac() throws Exception { JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); internalTest(compiler, JAVA8_ANNOTATION_PROC, "testTypeAnnotations5"); } @@ -136,7 +136,7 @@ public class Java8ElementsTests extends TestCase { JavaCompiler compiler = BatchTestUtils.getEclipseCompiler(); internalTest(compiler, JAVA8_ANNOTATION_PROC, "testTypeAnnotations9"); } - public void testTypeAnnotations9WithJavac() throws Exception { + public void _testTypeAnnotations9WithJavac() throws Exception { JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); internalTest(compiler, JAVA8_ANNOTATION_PROC, "testTypeAnnotations9"); } @@ -152,7 +152,7 @@ public class Java8ElementsTests extends TestCase { JavaCompiler compiler = BatchTestUtils.getEclipseCompiler(); internalTest(compiler, JAVA8_ANNOTATION_PROC, "testTypeAnnotations11"); } - public void testTypeAnnotations11WithJavac() throws Exception { + public void _testTypeAnnotations11WithJavac() throws Exception { JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); internalTest(compiler, JAVA8_ANNOTATION_PROC, "testTypeAnnotations11"); } @@ -278,6 +278,26 @@ public class Java8ElementsTests extends TestCase { internalTest(compiler, JAVA8_ANNOTATION_PROC, "testRepeatedAnnotations25", "JEP120_7.java"); } + public void testTypeAnnotations26() throws Exception { + JavaCompiler compiler = BatchTestUtils.getEclipseCompiler(); + internalTest(compiler, JAVA8_ANNOTATION_PROC, "testTypeAnnotations26"); + } + + public void testTypeAnnotations26WithJavac() throws Exception { + JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); + internalTest(compiler, JAVA8_ANNOTATION_PROC, "testTypeAnnotations26"); + } + + public void testTypeAnnotations27() throws Exception { + JavaCompiler compiler = BatchTestUtils.getEclipseCompiler(); + internalTest(compiler, JAVA8_ANNOTATION_PROC, "testTypeAnnotations27"); + } + + public void _testTypeAnnotations27WithJavac() throws Exception { + JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); + internalTest(compiler, JAVA8_ANNOTATION_PROC, "testTypeAnnotations27"); + } + private void internalTest(JavaCompiler compiler, String processor, String testMethod) throws IOException { internalTest(compiler, processor, testMethod, null); } |