diff --git a/compiler/testData/javaDescriptorResolver/annotations/annotationWithAnnotationInParam.java b/compiler/testData/loadJava/compiledJava/annotations/AnnotationWithAnnotationInParam.java similarity index 92% rename from compiler/testData/javaDescriptorResolver/annotations/annotationWithAnnotationInParam.java rename to compiler/testData/loadJava/compiledJava/annotations/AnnotationWithAnnotationInParam.java index 9d5bb086682..8d1a1c5c984 100644 --- a/compiler/testData/javaDescriptorResolver/annotations/annotationWithAnnotationInParam.java +++ b/compiler/testData/loadJava/compiledJava/annotations/AnnotationWithAnnotationInParam.java @@ -1,6 +1,4 @@ -package annotations; - -import java.lang.String; +package test; @interface MyAnnotationWithParam { MyAnnotation value(); diff --git a/compiler/testData/javaDescriptorResolver/annotations/annotationWithArrayOfEnumInParam.java b/compiler/testData/loadJava/compiledJava/annotations/AnnotationWithArrayOfEnumInParam.java similarity index 89% rename from compiler/testData/javaDescriptorResolver/annotations/annotationWithArrayOfEnumInParam.java rename to compiler/testData/loadJava/compiledJava/annotations/AnnotationWithArrayOfEnumInParam.java index 4794e5922f3..af40752440a 100644 --- a/compiler/testData/javaDescriptorResolver/annotations/annotationWithArrayOfEnumInParam.java +++ b/compiler/testData/loadJava/compiledJava/annotations/AnnotationWithArrayOfEnumInParam.java @@ -1,4 +1,4 @@ -package annotations; +package test; import java.lang.annotation.ElementType; import java.lang.annotation.Target; diff --git a/compiler/testData/javaDescriptorResolver/annotations/annotationWithArrayOfStringInParam.java b/compiler/testData/loadJava/compiledJava/annotations/AnnotationWithArrayOfStringInParam.java similarity index 90% rename from compiler/testData/javaDescriptorResolver/annotations/annotationWithArrayOfStringInParam.java rename to compiler/testData/loadJava/compiledJava/annotations/AnnotationWithArrayOfStringInParam.java index 1790ac526fe..9223ffd344a 100644 --- a/compiler/testData/javaDescriptorResolver/annotations/annotationWithArrayOfStringInParam.java +++ b/compiler/testData/loadJava/compiledJava/annotations/AnnotationWithArrayOfStringInParam.java @@ -1,4 +1,4 @@ -package annotations; +package test; import java.lang.String; import java.lang.annotation.ElementType; diff --git a/compiler/testData/javaDescriptorResolver/annotations/annotationWithEmptyArrayInParam.java b/compiler/testData/loadJava/compiledJava/annotations/AnnotationWithEmptyArrayInParam.java similarity index 90% rename from compiler/testData/javaDescriptorResolver/annotations/annotationWithEmptyArrayInParam.java rename to compiler/testData/loadJava/compiledJava/annotations/AnnotationWithEmptyArrayInParam.java index 2198570f900..2746f53cabe 100644 --- a/compiler/testData/javaDescriptorResolver/annotations/annotationWithEmptyArrayInParam.java +++ b/compiler/testData/loadJava/compiledJava/annotations/AnnotationWithEmptyArrayInParam.java @@ -1,4 +1,4 @@ -package annotations; +package test; import java.lang.String; import java.lang.annotation.ElementType; diff --git a/compiler/testData/javaDescriptorResolver/annotations/annotationWithEnumInParam.java b/compiler/testData/loadJava/compiledJava/annotations/AnnotationWithEnumInParam.java similarity index 89% rename from compiler/testData/javaDescriptorResolver/annotations/annotationWithEnumInParam.java rename to compiler/testData/loadJava/compiledJava/annotations/AnnotationWithEnumInParam.java index 783dd98b55c..b5552b4de55 100644 --- a/compiler/testData/javaDescriptorResolver/annotations/annotationWithEnumInParam.java +++ b/compiler/testData/loadJava/compiledJava/annotations/AnnotationWithEnumInParam.java @@ -1,4 +1,4 @@ -package annotations; +package test; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; diff --git a/compiler/testData/javaDescriptorResolver/annotations/customAnnotation.java b/compiler/testData/loadJava/compiledJava/annotations/CustomAnnotation.java similarity index 84% rename from compiler/testData/javaDescriptorResolver/annotations/customAnnotation.java rename to compiler/testData/loadJava/compiledJava/annotations/CustomAnnotation.java index e7bdff6d2e7..bdb82beb07b 100644 --- a/compiler/testData/javaDescriptorResolver/annotations/customAnnotation.java +++ b/compiler/testData/loadJava/compiledJava/annotations/CustomAnnotation.java @@ -1,4 +1,4 @@ -package annotations; +package test; @MyAnnotation(MyEnum.ONE) class MyTest {} diff --git a/compiler/testData/javaDescriptorResolver/annotations/customAnnotationWithDefaultParameter.java b/compiler/testData/loadJava/compiledJava/annotations/CustomAnnotationWithDefaultParameter.java similarity index 87% rename from compiler/testData/javaDescriptorResolver/annotations/customAnnotationWithDefaultParameter.java rename to compiler/testData/loadJava/compiledJava/annotations/CustomAnnotationWithDefaultParameter.java index e3e2df2c1f4..b5b151fb012 100644 --- a/compiler/testData/javaDescriptorResolver/annotations/customAnnotationWithDefaultParameter.java +++ b/compiler/testData/loadJava/compiledJava/annotations/CustomAnnotationWithDefaultParameter.java @@ -1,4 +1,4 @@ -package annotations; +package test; @MyAnnotation(first = "f", second = "s") class MyTest {} diff --git a/compiler/testData/javaDescriptorResolver/annotations/recursiveAnnotation.java b/compiler/testData/loadJava/compiledJava/annotations/RecursiveAnnotation.java similarity index 75% rename from compiler/testData/javaDescriptorResolver/annotations/recursiveAnnotation.java rename to compiler/testData/loadJava/compiledJava/annotations/RecursiveAnnotation.java index 0c389274cbc..ecdcb1d5f5d 100644 --- a/compiler/testData/javaDescriptorResolver/annotations/recursiveAnnotation.java +++ b/compiler/testData/loadJava/compiledJava/annotations/RecursiveAnnotation.java @@ -1,11 +1,11 @@ -package annotations; - -@B(@A("test")) -@interface A { - String value(); -} - -@B(@A("test")) -@interface B { - A value(); -} +package test; + +@B(@A("test")) +@interface A { + String value(); +} + +@B(@A("test")) +@interface B { + A value(); +} diff --git a/compiler/testData/javaDescriptorResolver/annotations/recursiveAnnotation2.java b/compiler/testData/loadJava/compiledJava/annotations/RecursiveAnnotation2.java similarity index 80% rename from compiler/testData/javaDescriptorResolver/annotations/recursiveAnnotation2.java rename to compiler/testData/loadJava/compiledJava/annotations/RecursiveAnnotation2.java index c65aac41586..8d14dabe04a 100644 --- a/compiler/testData/javaDescriptorResolver/annotations/recursiveAnnotation2.java +++ b/compiler/testData/loadJava/compiledJava/annotations/RecursiveAnnotation2.java @@ -1,4 +1,4 @@ -package annotations; +package test; @interface A { B value(); diff --git a/compiler/tests/org/jetbrains/jet/jvm/compiler/AnnotationJavaDescriptorResolverTest.java b/compiler/tests/org/jetbrains/jet/jvm/compiler/AnnotationJavaDescriptorResolverTest.java index aff60b6c0cb..312078a1d91 100644 --- a/compiler/tests/org/jetbrains/jet/jvm/compiler/AnnotationJavaDescriptorResolverTest.java +++ b/compiler/tests/org/jetbrains/jet/jvm/compiler/AnnotationJavaDescriptorResolverTest.java @@ -69,126 +69,6 @@ public class AnnotationJavaDescriptorResolverTest extends AbstractJavaResolverDe checkSimpleCompileTimeConstant(actualCompileTimeConstant, DEFAULT_PACKAGE + ".MyEnum", "MyEnum.ONE"); } - public void testCustomAnnotation() throws IOException { - compileJavaFile("customAnnotation.java", null); - String annotationTypeName = DEFAULT_PACKAGE + ".MyAnnotation"; - AnnotationDescriptor annotation = getAnnotationInClassByType("MyTest", annotationTypeName); - - CompileTimeConstant actualCompileTimeConstant = getCompileTimeConstant(annotation, annotationTypeName, "value"); - checkSimpleCompileTimeConstant(actualCompileTimeConstant, DEFAULT_PACKAGE + ".MyEnum", "MyEnum.ONE"); - } - - public void testCustomAnnotationWithDefaultParameter() throws IOException { - compileJavaFile("customAnnotationWithDefaultParameter.java", null); - String annotationTypeName = DEFAULT_PACKAGE + ".MyAnnotation"; - AnnotationDescriptor annotation = getAnnotationInClassByType("MyTest", annotationTypeName); - CompileTimeConstant actualCompileTimeConstant = getCompileTimeConstant(annotation, annotationTypeName, "first"); - checkSimpleCompileTimeConstant(actualCompileTimeConstant, "jet.String", "\"f\""); - - actualCompileTimeConstant = getCompileTimeConstant(annotation, annotationTypeName, "second"); - checkSimpleCompileTimeConstant(actualCompileTimeConstant, "jet.String", "\"s\""); - } - - public void testAnnotationWithAnnotationInParam() throws IOException { - compileJavaFile("annotationWithAnnotationInParam.java", null); - String annotationTypeName = DEFAULT_PACKAGE + ".MyAnnotationWithParam"; - AnnotationDescriptor annotation = getAnnotationInClassByType("A", - annotationTypeName); - CompileTimeConstant actualCompileTimeConstant = getCompileTimeConstant(annotation, annotationTypeName, "value"); - assert actualCompileTimeConstant instanceof AnnotationValue; - checkAnnotationCompileTimeConstant((AnnotationValue) actualCompileTimeConstant, "value", - DEFAULT_PACKAGE + ".MyAnnotation", "jet.String", "\"test\""); - - String annotationTypeName2 = DEFAULT_PACKAGE + ".MyAnnotationWithParam2"; - AnnotationDescriptor annotation2 = getAnnotationInClassByType("B", annotationTypeName2); - actualCompileTimeConstant = getCompileTimeConstant(annotation2, annotationTypeName2, "value"); - assert actualCompileTimeConstant instanceof AnnotationValue; - checkAnnotationCompileTimeConstant((AnnotationValue) actualCompileTimeConstant, "value", - DEFAULT_PACKAGE + ".MyAnnotation2", "jet.Array?", "[\"test\", \"test2\"]"); - - String annotationTypeName3 = DEFAULT_PACKAGE + ".MyAnnotationWithParam3"; - AnnotationDescriptor annotation3 = getAnnotationInClassByType("C", annotationTypeName3); - - actualCompileTimeConstant = getCompileTimeConstant(annotation3, annotationTypeName3, "value"); - assert actualCompileTimeConstant instanceof AnnotationValue; - checkAnnotationCompileTimeConstant((AnnotationValue) actualCompileTimeConstant, "first", - DEFAULT_PACKAGE + ".MyAnnotation3", "jet.String", "\"f\""); - checkAnnotationCompileTimeConstant((AnnotationValue) actualCompileTimeConstant, "second", - DEFAULT_PACKAGE + ".MyAnnotation3", "jet.String", "\"s\""); - } - - public void testRecursiveAnnotation() throws IOException { - compileJavaFile("recursiveAnnotation.java", null); - String annotationTypeName = DEFAULT_PACKAGE + ".B"; - AnnotationDescriptor annotation = getAnnotationInClassByType("A", annotationTypeName); - CompileTimeConstant actualCompileTimeConstant = getCompileTimeConstant(annotation, annotationTypeName, "value"); - assert actualCompileTimeConstant instanceof AnnotationValue; - checkAnnotationCompileTimeConstant((AnnotationValue) actualCompileTimeConstant, "value", - DEFAULT_PACKAGE + ".A", "jet.String", "\"test\""); - - AnnotationDescriptor annotation2 = getAnnotationInClassByType("B", annotationTypeName); - actualCompileTimeConstant = getCompileTimeConstant(annotation2, annotationTypeName, "value"); - assert actualCompileTimeConstant instanceof AnnotationValue; - checkAnnotationCompileTimeConstant((AnnotationValue) actualCompileTimeConstant, "value", - DEFAULT_PACKAGE + ".A", "jet.String", "\"test\""); - } - - public void testRecursiveAnnotation2() throws IOException { - compileJavaFile("recursiveAnnotation2.java", null); - String annotationTypeName = DEFAULT_PACKAGE + ".A"; - AnnotationDescriptor annotation = getAnnotationInClassByType("B", annotationTypeName); - CompileTimeConstant actualCompileTimeConstant = getCompileTimeConstant(annotation, annotationTypeName, "value"); - assert actualCompileTimeConstant instanceof AnnotationValue; - checkAnnotationCompileTimeConstant((AnnotationValue) actualCompileTimeConstant, "value", - DEFAULT_PACKAGE + ".B", "jet.String", "\"test\""); - } - - public void testAnnotationWithEnumInParam() throws IOException { - compileJavaFile("annotationWithEnumInParam.java", null); - String annotationTypeName = "java.lang.annotation.Retention"; - AnnotationDescriptor annotation = getAnnotationInClassByType("retentionAnnotation", annotationTypeName); - CompileTimeConstant actualCompileTimeConstant = getCompileTimeConstant(annotation, annotationTypeName, "value"); - checkSimpleCompileTimeConstant(actualCompileTimeConstant, "java.lang.annotation.RetentionPolicy", "RetentionPolicy.RUNTIME"); - } - - public void testAnnotationWithArrayOfEnumInParam() throws IOException { - compileJavaFile("annotationWithArrayOfEnumInParam.java", null); - String annotationTypeName = "java.lang.annotation.Target"; - AnnotationDescriptor annotation = getAnnotationInClassByType("targetAnnotation", annotationTypeName); - assertEquals("Number of arguments is incorrect", 1, annotation.getAllValueArguments().size()); - String[] values = new String[] {"ElementType.FIELD", "ElementType.CONSTRUCTOR"}; - - CompileTimeConstant actualCompileTimeConstant = getCompileTimeConstant(annotation, annotationTypeName, "value"); - assert actualCompileTimeConstant instanceof ArrayValue; - checkArrayCompileTimeConstant((ArrayValue) actualCompileTimeConstant, "jet.Array?", - "java.lang.annotation.ElementType", values); - } - - public void testAnnotationWithArrayOfStringInParam() throws IOException { - compileJavaFile("annotationWithArrayOfStringInParam.java", null); - String annotationTypeName = DEFAULT_PACKAGE + ".MyAnnotation"; - AnnotationDescriptor annotation = getAnnotationInClassByType("A", annotationTypeName); - assertEquals("Number of arguments is incorrect", 1, annotation.getAllValueArguments().size()); - String[] values = new String[] {"\"a\"", "\"b\"", "\"c\""}; - - CompileTimeConstant actualCompileTimeConstant = getCompileTimeConstant(annotation, annotationTypeName, "value"); - assert actualCompileTimeConstant instanceof ArrayValue; - checkArrayCompileTimeConstant((ArrayValue) actualCompileTimeConstant, "jet.Array?", "jet.String", values); - } - - public void testAnnotationWithEmptyArrayInParam() throws IOException { - compileJavaFile("annotationWithEmptyArrayInParam.java", null); - String annotationTypeName = DEFAULT_PACKAGE + ".MyAnnotation"; - AnnotationDescriptor annotation = getAnnotationInClassByType("A", annotationTypeName); - - assertEquals("Number of arguments is incorrect", 1, annotation.getAllValueArguments().size()); - String[] values = new String[] {}; - - CompileTimeConstant actualCompileTimeConstant = getCompileTimeConstant(annotation, annotationTypeName, "value"); - assert actualCompileTimeConstant instanceof ArrayValue; - checkArrayCompileTimeConstant((ArrayValue) actualCompileTimeConstant, "jet.Array?", "jet.String", values); - } - private static void compareJetTypeWithClass(@NotNull JetType actualType, @NotNull String expectedType) { assertEquals(expectedType, DescriptorRenderer.TEXT.renderType(actualType)); } diff --git a/compiler/tests/org/jetbrains/jet/jvm/compiler/LoadJavaTestGenerated.java b/compiler/tests/org/jetbrains/jet/jvm/compiler/LoadJavaTestGenerated.java index 60fe62bf29c..93acdfcb4da 100644 --- a/compiler/tests/org/jetbrains/jet/jvm/compiler/LoadJavaTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/jvm/compiler/LoadJavaTestGenerated.java @@ -971,7 +971,7 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest { } @TestMetadata("compiler/testData/loadJava/compiledJava") - @InnerTestClasses({CompiledJava.ProtectedPackage.class, CompiledJava.ProtectedStatic.class, CompiledJava.SignaturePropagation.class, CompiledJava.Static.class}) + @InnerTestClasses({CompiledJava.Annotations.class, CompiledJava.ProtectedPackage.class, CompiledJava.ProtectedStatic.class, CompiledJava.SignaturePropagation.class, CompiledJava.Static.class}) public static class CompiledJava extends AbstractLoadJavaTest { public void testAllFilesPresentInCompiledJava() throws Exception { JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/loadJava/compiledJava"), Pattern.compile("^(.+)\\.java$"), true); @@ -987,6 +987,59 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest { doTestCompiledJava("compiler/testData/loadJava/compiledJava/SubclassFromNested.java"); } + @TestMetadata("compiler/testData/loadJava/compiledJava/annotations") + public static class Annotations extends AbstractLoadJavaTest { + public void testAllFilesPresentInAnnotations() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/loadJava/compiledJava/annotations"), Pattern.compile("^(.+)\\.java$"), true); + } + + @TestMetadata("AnnotationWithAnnotationInParam.java") + public void testAnnotationWithAnnotationInParam() throws Exception { + doTestCompiledJava("compiler/testData/loadJava/compiledJava/annotations/AnnotationWithAnnotationInParam.java"); + } + + @TestMetadata("AnnotationWithArrayOfEnumInParam.java") + public void testAnnotationWithArrayOfEnumInParam() throws Exception { + doTestCompiledJava("compiler/testData/loadJava/compiledJava/annotations/AnnotationWithArrayOfEnumInParam.java"); + } + + @TestMetadata("AnnotationWithArrayOfStringInParam.java") + public void testAnnotationWithArrayOfStringInParam() throws Exception { + doTestCompiledJava("compiler/testData/loadJava/compiledJava/annotations/AnnotationWithArrayOfStringInParam.java"); + } + + @TestMetadata("AnnotationWithEmptyArrayInParam.java") + public void testAnnotationWithEmptyArrayInParam() throws Exception { + doTestCompiledJava("compiler/testData/loadJava/compiledJava/annotations/AnnotationWithEmptyArrayInParam.java"); + } + + @TestMetadata("AnnotationWithEnumInParam.java") + public void testAnnotationWithEnumInParam() throws Exception { + doTestCompiledJava("compiler/testData/loadJava/compiledJava/annotations/AnnotationWithEnumInParam.java"); + } + + @TestMetadata("CustomAnnotation.java") + public void testCustomAnnotation() throws Exception { + doTestCompiledJava("compiler/testData/loadJava/compiledJava/annotations/CustomAnnotation.java"); + } + + @TestMetadata("CustomAnnotationWithDefaultParameter.java") + public void testCustomAnnotationWithDefaultParameter() throws Exception { + doTestCompiledJava("compiler/testData/loadJava/compiledJava/annotations/CustomAnnotationWithDefaultParameter.java"); + } + + @TestMetadata("RecursiveAnnotation.java") + public void testRecursiveAnnotation() throws Exception { + doTestCompiledJava("compiler/testData/loadJava/compiledJava/annotations/RecursiveAnnotation.java"); + } + + @TestMetadata("RecursiveAnnotation2.java") + public void testRecursiveAnnotation2() throws Exception { + doTestCompiledJava("compiler/testData/loadJava/compiledJava/annotations/RecursiveAnnotation2.java"); + } + + } + @TestMetadata("compiler/testData/loadJava/compiledJava/protectedPackage") public static class ProtectedPackage extends AbstractLoadJavaTest { public void testAllFilesPresentInProtectedPackage() throws Exception { @@ -1102,6 +1155,7 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest { public static Test innerSuite() { TestSuite suite = new TestSuite("CompiledJava"); suite.addTestSuite(CompiledJava.class); + suite.addTestSuite(Annotations.class); suite.addTestSuite(ProtectedPackage.class); suite.addTestSuite(ProtectedStatic.class); suite.addTestSuite(SignaturePropagation.class);