Deserialize annotations on class members

Make 'Callable' message of descriptors.proto extensible, extend it in
java_descriptors.proto with a JVM signature of the member. This is needed in
order for annotation deserializer to find out which member in the compiled
bytecode corresponds to which descriptor in the hierarchy.

Create a new module 'serialization.java' containing everything related to
Java-specific serialization of descriptors.

Add an extension point to DescriptorSerializer, allowing to perform
platform-specific serialization on a callable
This commit is contained in:
Alexander Udalov
2013-07-05 22:38:46 +04:00
parent d0635aac3e
commit 67ca7b78c4
26 changed files with 368 additions and 99 deletions
@@ -70,13 +70,9 @@ public abstract class AbstractDescriptorSerializationTest extends KotlinTestWith
@NotNull
@Override
public List<AnnotationDescriptor> loadCallableAnnotations(@NotNull ProtoBuf.Callable callableProto) {
throw new UnsupportedOperationException(); // TODO
}
@NotNull
@Override
public List<AnnotationDescriptor> loadSetterAnnotations(@NotNull ProtoBuf.Callable callableProto) {
public List<AnnotationDescriptor> loadCallableAnnotations(
@NotNull ClassOrNamespaceDescriptor container, @NotNull ProtoBuf.Callable callableProto
) {
throw new UnsupportedOperationException(); // TODO
}
@@ -38,12 +38,25 @@ public class DescriptorSerializationTestGenerated extends AbstractDescriptorSeri
}
@TestMetadata("compiler/testData/loadKotlin/annotations")
@InnerTestClasses({Annotations.Classes.class})
@InnerTestClasses({Annotations.ClassMembers.class, Annotations.Classes.class})
public static class Annotations extends AbstractDescriptorSerializationTest {
public void testAllFilesPresentInAnnotations() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/loadKotlin/annotations"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("compiler/testData/loadKotlin/annotations/classMembers")
public static class ClassMembers extends AbstractDescriptorSerializationTest {
public void testAllFilesPresentInClassMembers() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/loadKotlin/annotations/classMembers"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("Function.kt")
public void testFunction() throws Exception {
doTest("compiler/testData/loadKotlin/annotations/classMembers/Function.kt");
}
}
@TestMetadata("compiler/testData/loadKotlin/annotations/classes")
public static class Classes extends AbstractDescriptorSerializationTest {
public void testAllFilesPresentInClasses() throws Exception {
@@ -95,6 +108,7 @@ public class DescriptorSerializationTestGenerated extends AbstractDescriptorSeri
public static Test innerSuite() {
TestSuite suite = new TestSuite("Annotations");
suite.addTestSuite(Annotations.class);
suite.addTestSuite(ClassMembers.class);
suite.addTestSuite(Classes.class);
return suite;
}
@@ -32,6 +32,8 @@ import org.jetbrains.jet.lang.resolve.name.FqNameUnsafe;
import java.io.IOException;
import static com.google.protobuf.ExtensionRegistryLite.getEmptyRegistry;
public class KotlinInfoForClassTest extends CodegenTestCase {
public static final FqName NAMESPACE_NAME = new FqName("test");
public static final FqNameUnsafe CLASS_NAME = new FqNameUnsafe("A");
@@ -68,7 +70,7 @@ public class KotlinInfoForClassTest extends CodegenTestCase {
public KotlinInfoBasedDescriptorFinder(@NotNull KotlinInfo kotlinInfo) throws IOException {
super(new LockBasedStorageManager(), AnnotationDeserializer.UNSUPPORTED);
this.classData = ClassData.read(kotlinInfo.data());
this.classData = ClassData.read(kotlinInfo.data(), getEmptyRegistry());
this.namespace = JetTestUtils.createTestNamespace(NAMESPACE_NAME.shortName());
}
@@ -38,12 +38,25 @@ public class LoadCompiledKotlinTestGenerated extends AbstractLoadCompiledKotlinT
}
@TestMetadata("compiler/testData/loadKotlin/annotations")
@InnerTestClasses({Annotations.Classes.class})
@InnerTestClasses({Annotations.ClassMembers.class, Annotations.Classes.class})
public static class Annotations extends AbstractLoadCompiledKotlinTest {
public void testAllFilesPresentInAnnotations() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/loadKotlin/annotations"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("compiler/testData/loadKotlin/annotations/classMembers")
public static class ClassMembers extends AbstractLoadCompiledKotlinTest {
public void testAllFilesPresentInClassMembers() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/loadKotlin/annotations/classMembers"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("Function.kt")
public void testFunction() throws Exception {
doTestWithAccessors("compiler/testData/loadKotlin/annotations/classMembers/Function.kt");
}
}
@TestMetadata("compiler/testData/loadKotlin/annotations/classes")
public static class Classes extends AbstractLoadCompiledKotlinTest {
public void testAllFilesPresentInClasses() throws Exception {
@@ -95,6 +108,7 @@ public class LoadCompiledKotlinTestGenerated extends AbstractLoadCompiledKotlinT
public static Test innerSuite() {
TestSuite suite = new TestSuite("Annotations");
suite.addTestSuite(Annotations.class);
suite.addTestSuite(ClassMembers.class);
suite.addTestSuite(Classes.class);
return suite;
}
@@ -40,12 +40,25 @@ public class LazyResolveNamespaceComparingTestGenerated extends AbstractLazyReso
}
@TestMetadata("compiler/testData/loadKotlin/annotations")
@InnerTestClasses({Annotations.Classes.class})
@InnerTestClasses({Annotations.ClassMembers.class, Annotations.Classes.class})
public static class Annotations extends AbstractLazyResolveNamespaceComparingTest {
public void testAllFilesPresentInAnnotations() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/loadKotlin/annotations"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("compiler/testData/loadKotlin/annotations/classMembers")
public static class ClassMembers extends AbstractLazyResolveNamespaceComparingTest {
public void testAllFilesPresentInClassMembers() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/loadKotlin/annotations/classMembers"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("Function.kt")
public void testFunction() throws Exception {
doTestCheckingPrimaryConstructorsAndAccessors("compiler/testData/loadKotlin/annotations/classMembers/Function.kt");
}
}
@TestMetadata("compiler/testData/loadKotlin/annotations/classes")
public static class Classes extends AbstractLazyResolveNamespaceComparingTest {
public void testAllFilesPresentInClasses() throws Exception {
@@ -97,6 +110,7 @@ public class LazyResolveNamespaceComparingTestGenerated extends AbstractLazyReso
public static Test innerSuite() {
TestSuite suite = new TestSuite("Annotations");
suite.addTestSuite(Annotations.class);
suite.addTestSuite(ClassMembers.class);
suite.addTestSuite(Classes.class);
return suite;
}