public static ClassNode getClassNode(Class<?> clazz, boolean skipCode) throws IOException { return getClassNode(getClassInputStream(clazz), skipCode); }
public static ClassNode getClassNode(String className, ClassLoader cl, boolean skipCode) throws IOException { final ClassNode cn = getClassNode(getClassInputStream(className, cl), skipCode); if (cn == null) throw new IOException("Resource " + classToResource(className) + " not found."); return cn; }
private void scanSuspendablesFile() throws Exception { // scan classes in suspendables file if (ssc != null) { Set<String> classes = new HashSet<>(); for (String susCls : ssc.getSuspendableClasses()) classes.add(susCls); for (String susMethod : ssc.getSuspendables()) classes.add(susMethod.substring(0, susMethod.indexOf('.'))); for (String className : classes) { log("scanning suspendable class:" + className, Project.MSG_VERBOSE); scanClass(getClassNode(className, cl, true)); } } }
private void scanClass(File file) throws Exception { log("Scanning " + file, Project.MSG_VERBOSE); if (file != null) { if (USE_REFLECTION) scanClass(Class.forName(extractClassName(file))); else scanClass(getClassNode(new FileInputStream(file), true)); } }
private static boolean isAssignableFrom0(String supertypeName, String className, ClassLoader cl) { try { if (className == null) return false; if (supertypeName.equals(className)) return true; ClassNode cn = getClassNode(className, cl, true); if (supertypeName.equals(cn.superName)) return true; if (isAssignableFrom0(supertypeName, cn.superName, cl)) return true; if (cn.interfaces != null) { for (String iface : (List<String>) cn.interfaces) { if (supertypeName.equals(iface)) return true; if (isAssignableFrom0(supertypeName, iface, cl)) return true; } } return false; } catch (IOException e) { // e.printStackTrace(); throw new RuntimeException(e); } }
private boolean findSuperDeclarations(ClassNode cls, ClassNode declaringClass, MethodNode method) throws IOException { if (cls == null) return false; boolean foundMethod = false; MethodNode m; if ((m = getMethod(method, cls)) != null) { foundMethod = true; if (!ASMUtil.equals(cls, declaringClass) && !isSuspendable(cls, m)) { log("Found parent of annotated method: " + declaringClass.name + "." + method.name + method.signature + " in " + cls.name, Project.MSG_VERBOSE); results.add(cls.name.replace('/', '.') + '.' + method.name); } } // recursively look in superclass and interfaces boolean methodInParent = false; methodInParent |= findSuperDeclarations(getClassNode(cls.superName, cl, true), declaringClass, method); for (String iface : (List<String>) cls.interfaces) methodInParent |= findSuperDeclarations(getClassNode(iface, cl, true), declaringClass, method); if (!foundMethod && methodInParent) { log("Found parent of annotated method in a parent of: " + declaringClass.name + "." + method.name + method.signature + " in " + cls.name, Project.MSG_VERBOSE); results.add(cls.name.replace('/', '.') + '.' + method.name); } return foundMethod | methodInParent; }