private static IMethodInfo[] getSortedMethods(IClassFileReader cfReader) { IMethodInfo[] allMethods = cfReader.getMethodInfos(); Arrays.sort(allMethods, new Comparator<IMethodInfo>() { @Override public int compare(IMethodInfo mi1, IMethodInfo mi2) { if (mi1.isConstructor() != mi2.isConstructor()) { return mi1.isConstructor() ? -1 : 1; } else if (mi1.isConstructor()) { return 0; } int res = CharOperation.compareTo(mi1.getName(), mi2.getName()); if (res != 0) { return res; } return CharOperation.compareTo(mi1.getDescriptor(), mi2.getDescriptor()); } }); return allMethods; }
private static IMethodInfo[] getSortedMethods(IClassFileReader cfReader) { IMethodInfo[] allMethods= cfReader.getMethodInfos(); Arrays.sort(allMethods, new Comparator<IMethodInfo>() { public int compare(IMethodInfo mi1, IMethodInfo mi2) { if (mi1.isConstructor() != mi2.isConstructor()) { return mi1.isConstructor() ? -1 : 1; } else if (mi1.isConstructor()) { return 0; } int res= CharOperation.compareTo(mi1.getName(), mi2.getName()); if (res != 0) { return res; } return CharOperation.compareTo(mi1.getDescriptor(), mi2.getDescriptor()); } }); return allMethods; }
private static boolean hasStaticClassInitializer(IClassFileReader cfReader) { IMethodInfo[] methodInfos = cfReader.getMethodInfos(); for (int i = 0; i < methodInfos.length; i++) { if (methodInfos[i].isClinit()) { return true; } } return false; }
public static IClassFileAttribute getAttribute(IMethodInfo methodInfo, char[] attributeName) { IClassFileAttribute[] attributes = methodInfo.getAttributes(); for (int i = 0, max = attributes.length; i < max; i++) { if (CharOperation.equals(attributes[i].getAttributeName(), attributeName)) { return attributes[i]; } } return null; }
private static boolean hasStaticClassInitializer(IClassFileReader cfReader) { IMethodInfo[] methodInfos= cfReader.getMethodInfos(); for (int i= 0; i < methodInfos.length; i++) { if (methodInfos[i].isClinit()) { return true; } } return false; }
private boolean checkClassFile(IClassFileReader classFileReader) { IMethodInfo[] methodInfos = classFileReader.getMethodInfos(); for (int i = 0, max = methodInfos.length; i < max; i++) { ICodeAttribute codeAttribute = methodInfos[i].getCodeAttribute(); if (codeAttribute != null && codeAttribute.getLineNumberAttribute() != null) { return true; } } return false; }
/** * @see IClassFileReader#getMethodInfos() */ public IMethodInfo[] getMethodInfos() { return this.methods; }