Methods Summary |
---|
private void | addClass(java.lang.String nameOrTypeDescriptor)
//sometimes we get names like Ljava.lang.Integer; or [I. So we need
// to decode the names.
if (nameOrTypeDescriptor.indexOf(';") != -1 ||
nameOrTypeDescriptor.indexOf('[") != -1) {
referencedClasses.addAll(
typeDescriptorToClassNames(nameOrTypeDescriptor));
} else {
referencedClasses.add(nameOrTypeDescriptor);
}
|
private void | addMethod(java.lang.String owner, java.lang.String name, java.lang.String desc)
addClass(owner);
// We don't need the following code as this is not required.
// because if everything is null, then no class gets loaded.
// for(String embeddedClassName : typeDescriptorToClassNames(desc)) {
// referencedClasses.add(embeddedClassName);
// }
referencedMethods.add(new MethodRef(owner, name, desc));
|
public static java.lang.String | decodeAccessFlag(int access)
StringBuilder result = new StringBuilder("");
if ((access & Opcodes.ACC_PRIVATE) == Opcodes.ACC_PRIVATE) {
result.append("private "); // NOI18N
} else if ((access & Opcodes.ACC_PROTECTED) == Opcodes.ACC_PROTECTED) {
result.append("protected "); // NOI18N
} else if ((access & Opcodes.ACC_PUBLIC) == Opcodes.ACC_PUBLIC) {
result.append("public "); // NOI18N
}
if ((access & Opcodes.ACC_ABSTRACT) == Opcodes.ACC_ABSTRACT) {
result.append("abstract "); // NOI18N
} else if ((access & Opcodes.ACC_FINAL) == Opcodes.ACC_FINAL) {
result.append("final "); // NOI18N
} else if ((access & Opcodes.ACC_STATIC) == Opcodes.ACC_STATIC) {
result.append("static "); // NOI18N
}
if ((access & Opcodes.ACC_NATIVE) == Opcodes.ACC_NATIVE) {
result.append("native "); // NOI18N
}
return result.toString();
|
public int | getAccess()
return access;
|
public java.lang.String | getDescriptor()
return descriptor;
|
public java.lang.String[] | getExceptions(){@inheritDoc}
return exceptions;
|
public java.lang.String | getName()
return name;
|
public ClassFile | getOwningClass()
return owningClass.get();
|
public java.util.Collection | getReferencedClasses()
return Collections.unmodifiableCollection(referencedClasses);
|
public java.util.Collection | getReferencedMethods()
return Collections.unmodifiableCollection(referencedMethods);
|
public MethodRef | getSelfReference()
if(methodRef==null){
methodRef = new MethodRef(owningClass.get().getInternalName(), name, descriptor);
}
return methodRef;
|
public java.lang.String | getSignature()
return signature;
|
public boolean | isNative()
return (access & Opcodes.ACC_NATIVE) == Opcodes.ACC_NATIVE;
|
public java.lang.String | toString()
StringBuilder sb = new StringBuilder(
decodeAccessFlag(access) +
name +
" " + // NOI18N
descriptor+
"{\n"); // NOI18N
for(MethodRef mr : referencedMethods){
sb.append(mr).append("\n"); // NOI18N
}
sb.append("}"); // NOI18N
return sb.toString();
|
private static java.util.List | typeDescriptorToClassNames(java.lang.String signature)
logger.entering(
"com.sun.enterprise.tools.verifier.apiscan.classfile.ASMMethod", "typeDescriptorToClassNames", // NOI18N
new Object[]{signature});
List<String> result = new ArrayList<String>();
int i = 0;
while ((i = signature.indexOf('L", i)) != -1) {
int j = signature.indexOf(';", i);
if (j > i) {
// get name, minus leading 'L' and trailing ';'
String className = signature.substring(i + 1, j);
if (!Util.isPrimitive(className)) result.add(className);
i = j + 1;
} else
break;
}
if (logger.isLoggable(Level.FINE)) {
StringBuffer sb = new StringBuffer("Class Names are {"); // NOI18N
int size = result.size();
for (int k = 0; k < size; k++) {
sb.append((String) result.get(k));
if (k != size - 1) sb.append(", "); // NOI18N
}
sb.append("}"); // NOI18N
logger.finer(sb.toString());
}
return result;
|
public void | visitFieldInsn(int opcode, java.lang.String owner, java.lang.String name, java.lang.String desc)
logger.entering(
"com.sun.enterprise.tools.verifier.apiscan.classfile.ASMMethod", "visitFieldInsn", // NOI18N
new Object[]{AbstractVisitor.OPCODES[opcode], owner, name, desc});
addClass(owner);
|
public void | visitMethodInsn(int opcode, java.lang.String owner, java.lang.String name, java.lang.String desc)
logger.entering(
"com.sun.enterprise.tools.verifier.apiscan.classfile.ASMMethod", "visitMethodInsn", new Object[]{ // NOI18N
AbstractVisitor.OPCODES[opcode], owner, name, desc});
addMethod(owner, name, desc);
|
public void | visitMultiANewArrayInsn(java.lang.String desc, int dims)
logger.entering(
"com.sun.enterprise.tools.verifier.apiscan.classfile.ASMMethod", "visitMultiANewArrayInsn", // NOI18N
new Object[]{desc});
addClass(desc);
|
public void | visitTryCatchBlock(com.sun.corba.ee.org.objectweb.asm.Label start, com.sun.corba.ee.org.objectweb.asm.Label end, com.sun.corba.ee.org.objectweb.asm.Label handler, java.lang.String type)
logger.entering(
"com.sun.enterprise.tools.verifier.apiscan.classfile.ASMMethod", "visitTryCatchBlock", // NOI18N
new Object[]{type});
if(type!=null) { // try-finally comes as null
addClass(type);
}
|
public void | visitTypeInsn(int opcode, java.lang.String desc)
logger.entering(
"com.sun.enterprise.tools.verifier.apiscan.classfile.ASMMethod", "visitTypeInsn", new Object[]{ // NOI18N
AbstractVisitor.OPCODES[opcode], desc});
switch (opcode) {
case Opcodes.INSTANCEOF:
case Opcodes.CHECKCAST:
case Opcodes.ANEWARRAY:
addClass(desc);
break;
case Opcodes.NEW:
// skip as class gets added during constructor call.
break;
case Opcodes.NEWARRAY:
// primitive type array, so skip
break;
default:
logger.logp(Level.WARNING, "com.sun.enterprise.tools.verifier.apiscan.classfile.ASMMethod", "visitTypeInsn", // NOI18N
getClass().getName() + ".warning1", AbstractVisitor.OPCODES[opcode]); // NOI18N
break;
}
|