use of org.jetbrains.org.objectweb.asm.ClassVisitor in project intellij-community by JetBrains.
the class DefaultOutputConsumer method readClassName.
private static String readClassName(byte[] classBytes) throws IOException {
final Ref<String> nameRef = Ref.create(null);
new ClassReader(classBytes).accept(new ClassVisitor(Opcodes.API_VERSION) {
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
nameRef.set(name.replace('/', '.'));
}
}, ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES);
return nameRef.get();
}
use of org.jetbrains.org.objectweb.asm.ClassVisitor in project kotlin by JetBrains.
the class InnerClassInfoGenTest method extractInnerClasses.
@NotNull
private List<InnerClassAttribute> extractInnerClasses(@NotNull String className) {
OutputFile outputFile = generateClassesInFile().get(className + ".class");
assertNotNull(outputFile);
byte[] bytes = outputFile.asByteArray();
ClassReader reader = new ClassReader(bytes);
final List<InnerClassAttribute> result = new ArrayList<InnerClassAttribute>();
reader.accept(new ClassVisitor(ASM5) {
@Override
public void visitInnerClass(@NotNull String name, String outerName, String innerName, int access) {
result.add(new InnerClassAttribute(name, outerName, innerName, access));
}
}, ClassReader.SKIP_CODE | ClassReader.SKIP_FRAMES);
return result;
}
use of org.jetbrains.org.objectweb.asm.ClassVisitor in project kotlin by JetBrains.
the class OuterClassGenTest method readOuterClassInfo.
@Nullable
private static OuterClassInfo readOuterClassInfo(@NotNull ClassReader reader) {
final Ref<OuterClassInfo> info = Ref.create();
reader.accept(new ClassVisitor(Opcodes.ASM5) {
@Override
public void visitOuterClass(@NotNull String owner, @Nullable String name, @Nullable String desc) {
info.set(new OuterClassInfo(owner, name, desc));
}
}, 0);
return info.get();
}
use of org.jetbrains.org.objectweb.asm.ClassVisitor in project kotlin by JetBrains.
the class SourceInfoGenTest method getProducerInfo.
private String getProducerInfo(String name) {
OutputFile file = generateClassesInFile().get(name);
assertNotNull(file);
ClassReader classReader = new ClassReader(file.asByteArray());
final String[] producer = new String[1];
classReader.accept(new ClassVisitor(Opcodes.ASM5) {
@Override
public void visitSource(String source, String debug) {
producer[0] = source;
}
}, 0);
return producer[0];
}
Aggregations