Fix annotations on Java elements in reflection

#KT-10840 Fixed
This commit is contained in:
Alexander Udalov
2016-01-28 16:38:51 +03:00
parent b946d725d7
commit 2a5b4d2c83
6 changed files with 45 additions and 5 deletions
@@ -0,0 +1,11 @@
@Anno("J")
public class J {
@Anno("foo")
public static int foo = 42;
@Anno("bar")
public static void bar() {}
@Anno("constructor")
public J() {}
}
@@ -0,0 +1,12 @@
import kotlin.test.assertEquals
annotation class Anno(val value: String)
fun box(): String {
assertEquals("[@Anno(value=J)]", J::class.annotations.toString())
assertEquals("[@Anno(value=foo)]", J::foo.annotations.toString())
assertEquals("[@Anno(value=bar)]", J::bar.annotations.toString())
assertEquals("[@Anno(value=constructor)]", ::J.annotations.toString())
return "OK"
}
@@ -581,6 +581,12 @@ public class BlackBoxWithJavaCodegenTestGenerated extends AbstractBlackBoxCodege
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxWithJava/reflection"), Pattern.compile("^([^\\.]+)$"), true);
}
@TestMetadata("annotationsOnJavaMembers")
public void testAnnotationsOnJavaMembers() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxWithJava/reflection/annotationsOnJavaMembers/");
doTestWithJava(fileName);
}
@TestMetadata("callInstanceJavaMethod")
public void testCallInstanceJavaMethod() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxWithJava/reflection/callInstanceJavaMethod/");