Do not always generate synthetic "$annotations" as private
Since annotations are a part of the declaration, they must have the same visibility as the declaration in the bytecode. Otherwise obfuscators like Proguard might strip the "$annotations" method and no annotations would be found via Kotlin reflection #KT-15993 Fixed
This commit is contained in:
+1
-1
@@ -67,7 +67,7 @@ public class SyntheticMethodForAnnotatedPropertyGenTest extends CodegenTestCase
|
||||
assertTrue(method.isSynthetic());
|
||||
int modifiers = method.getModifiers();
|
||||
assertTrue(Modifier.isStatic(modifiers));
|
||||
assertTrue(Modifier.isPrivate(modifiers));
|
||||
assertTrue(Modifier.isPublic(modifiers));
|
||||
|
||||
Annotation[] annotations = method.getDeclaredAnnotations();
|
||||
assertSize(1, annotations);
|
||||
|
||||
@@ -1022,6 +1022,33 @@ public class WriteFlagsTestGenerated extends AbstractWriteFlagsTest {
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/writeFlags/property/syntheticAnnotationsMethod")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class SyntheticAnnotationsMethod extends AbstractWriteFlagsTest {
|
||||
public void testAllFilesPresentInSyntheticAnnotationsMethod() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/writeFlags/property/syntheticAnnotationsMethod"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("privateProperty.kt")
|
||||
public void testPrivateProperty() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/writeFlags/property/syntheticAnnotationsMethod/privateProperty.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("protectedProperty.kt")
|
||||
public void testProtectedProperty() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/writeFlags/property/syntheticAnnotationsMethod/protectedProperty.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("publicProperty.kt")
|
||||
public void testPublicProperty() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/writeFlags/property/syntheticAnnotationsMethod/publicProperty.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/writeFlags/property/visibility")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
@@ -1049,4 +1076,34 @@ public class WriteFlagsTestGenerated extends AbstractWriteFlagsTest {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/writeFlags/typealias")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Typealias extends AbstractWriteFlagsTest {
|
||||
public void testAllFilesPresentInTypealias() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/writeFlags/typealias"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/writeFlags/typealias/syntheticAnnotationsMethod")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class SyntheticAnnotationsMethod extends AbstractWriteFlagsTest {
|
||||
public void testAllFilesPresentInSyntheticAnnotationsMethod() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/writeFlags/typealias/syntheticAnnotationsMethod"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("privateTypealias.kt")
|
||||
public void testPrivateTypealias() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/writeFlags/typealias/syntheticAnnotationsMethod/privateTypealias.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("publicTypealias.kt")
|
||||
public void testPublicTypealias() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/writeFlags/typealias/syntheticAnnotationsMethod/publicTypealias.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user