@Override
public void visitInnerClass(String name, String outerName, String innerName, int access) {
if (name.equals(slashedClassName) && outerName != null) {
if (cBuilder instanceof ClassInfo.Builder) {
ClassDescriptor outerClassDescriptor = DescriptorFactory.createClassDescriptor(outerName);
((ClassInfo.Builder) cBuilder).setImmediateEnclosingClass(outerClassDescriptor);
((ClassInfo.Builder) cBuilder).setAccessFlags(access);
}
}
}
@Override
public MethodVisitor visitMethod(final int access, final String methodName, final String methodDesc,
String signature, String[] exceptions) {
if (cBuilder instanceof ClassInfo.Builder) {
final MethodInfo.Builder mBuilder = new MethodInfo.Builder(slashedClassName, methodName, methodDesc, access);
mBuilder.setSourceSignature(signature);
mBuilder.setThrownExceptions(exceptions);
if ((access & Opcodes.ACC_SYNCHRONIZED) != 0) {
mBuilder.setUsesConcurrency();
}
return new ClassParserMethodVisitor(calledClassSet, mBuilder, methodName, access, methodDesc, cBuilder);
}
return null;
}
@Override
public void visitOuterClass(String owner, String name, String desc) {
}
@Override
public void visitSource(String arg0, String arg1) {
if (cBuilder instanceof ClassInfo.Builder) {
((ClassInfo.Builder) cBuilder).setSource(arg0);
}
}
}, ClassReader.SKIP_FRAMES);
HashSet<ClassDescriptor> referencedClassSet = new HashSet<ClassDescriptor>();
// collect class references
int constantPoolCount = classReader.readUnsignedShort(8);
int offset = 10;
char[] buf = new char[1024];
// System.out.println("constant pool count: " + constantPoolCount);
for (int count = 1; count < constantPoolCount; count++) {
int tag = classReader.readByte(offset);
int size;
switch (tag) {
case Constants.CONSTANT_Methodref:
case Constants.CONSTANT_InterfaceMethodref:
case Constants.CONSTANT_Fieldref:
case Constants.CONSTANT_Integer:
case Constants.CONSTANT_Float:
case Constants.CONSTANT_NameAndType:
case Constants.CONSTANT_InvokeDynamic:
size = 5;
break;
case Constants.CONSTANT_Long:
case Constants.CONSTANT_Double:
size = 9;
count++;
break;
case Constants.CONSTANT_Utf8:
size = 3 + classReader.readUnsignedShort(offset + 1);
break;
case Constants.CONSTANT_Class:
@SlashedClassName
String className = classReader.readUTF8(offset + 1, buf);
if (className.indexOf('[') >= 0) {
ClassParser.extractReferencedClassesFromSignature(referencedClassSet, className);
} else if (ClassName.isValidClassName(className)) {
ClassDescriptor classDescriptor = DescriptorFactory.instance().getClassDescriptor(className);
referencedClassSet.add(classDescriptor);
}
size = 3;
break;
case Constants.CONSTANT_String: