use of soot.SootClass in project robovm by robovm.
the class AnnotationsTest method testCopyParameterAnnotationsNoAnnotations.
@Test
public void testCopyParameterAnnotationsNoAnnotations() {
SootClass sc = toSootClass(getClass());
SootMethod src = sc.getMethodByName("src2");
SootMethod dest = sc.getMethodByName("dest2");
copyParameterAnnotations(src, dest, 0, 2, 0, Visibility.Any);
assertEquals("void dest2(int, int)", toString(dest));
}
use of soot.SootClass in project robovm by robovm.
the class AnnotationsTest method testCopyParameterAnnotationsMultipleAllNoShift.
@Test
public void testCopyParameterAnnotationsMultipleAllNoShift() {
SootClass sc = toSootClass(getClass());
SootMethod src = sc.getMethodByName("src6");
SootMethod dest = sc.getMethodByName("dest6");
copyParameterAnnotations(src, dest, 0, 2, 0, Visibility.Any);
assertEquals("void dest6(@A @B @C int, @B @C @D int)", toString(dest));
}
use of soot.SootClass in project robovm by robovm.
the class AnnotationImplPlugin method beforeClass.
@Override
public void beforeClass(Config config, Clazz clazz, ModuleBuilder moduleBuilder) {
init();
SootClass sootClass = clazz.getSootClass();
if ((sootClass.getModifiers() & MOD_ANNOTATION) > 0) {
try {
String implInternalName = clazz.getInternalName() + IMPL_CLASS_NAME_SUFFIX;
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);
cw.visit(V1_7, ACC_SUPER + ACC_FINAL + ACC_SYNTHETIC + ACC_PUBLIC, implInternalName, null, BASE_CLASS, new String[] { clazz.getInternalName() });
generateConstructor(clazz, cw);
generateAnnotationTypeMethod(clazz, cw);
generateMembersToStringMethod(clazz, cw);
generateFastEqualsMethod(clazz, cw);
generateSlowEqualsMethod(clazz, cw);
generateHashCodeMethod(clazz, cw);
generateMemberFieldsAndAccessorMethods(clazz, cw);
generateSetDefaultsMethod(clazz, cw);
generateSingletonFactoryMethod(clazz, cw);
generateFactoryMethod(clazz, cw);
cw.visitEnd();
File f = clazz.getPath().getGeneratedClassFile(implInternalName);
FileUtils.writeByteArrayToFile(f, cw.toByteArray());
// The impl class is created after the interface is compiled.
// This prevents the triggering of a recompile of the interface.
f.setLastModified(clazz.lastModified());
// Add the impl class as a dependency for the annotation interface.
// Important! This must be done AFTER the class file has been written.
clazz.getClazzInfo().addClassDependency(implInternalName, false);
// Make sure the factory methods are always linked in when the
// annotation class is referenced.
clazz.getClazzInfo().addInvokeMethodDependency(implInternalName, "$createSingleton", "()Ljava/lang/Object;", false);
clazz.getClazzInfo().addInvokeMethodDependency(implInternalName, "$create", "()Ljava/lang/Object;", false);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
use of soot.SootClass in project robovm by robovm.
the class VTableTest method testEmpty.
@Test
public void testEmpty() {
SootClass scJLO = getSootClass("java.lang.Object");
SootClass scEmpty = getSootClass("org.robovm.compiler.a.Empty");
VTable.Cache cache = new VTable.Cache();
VTable vtableJLO = cache.get(scJLO);
VTable vtableEmpty = cache.get(scEmpty);
assertArrayEquals(vtableJLO.getEntries(), vtableEmpty.getEntries());
}
use of soot.SootClass in project robovm by robovm.
the class VTableTest method testC.
@Test
public void testC() {
SootClass scA = getSootClass("org.robovm.compiler.a.A");
SootClass scC = getSootClass("org.robovm.compiler.a.C");
VTable.Cache cache = new VTable.Cache();
VTable vtableA = cache.get(scA);
VTable vtableC = cache.get(scC);
assertEquals(14, vtableC.size());
Entry fooEntry = vtableC.findEntry("org.robovm.compiler.a", "foo", "()V");
assertEquals(scC.getName(), fooEntry.getDeclaringClass());
Entry superFooEntry = vtableA.findEntry("org.robovm.compiler.a", "foo", "()V");
assertEquals(superFooEntry.getIndex(), fooEntry.getIndex());
assertNotSame(superFooEntry, fooEntry);
Entry barEntry = vtableC.findEntry("org.robovm.compiler.a", "bar", "()V");
assertEquals(scA.getName(), barEntry.getDeclaringClass());
Entry superBarEntry = vtableA.findEntry("org.robovm.compiler.a", "bar", "()V");
assertSame(superBarEntry, barEntry);
}
Aggregations