public List<MethodInfo> getMethods(final ClassFile cls) { //noinspection unchecked return cls.getMethods(); }
public List<MethodInfo> getMethods(final ClassFile cls) { //noinspection unchecked return cls.getMethods(); }
public void rebuildClassFile(ClassFile cf) throws BadBytecode { if (ClassFile.MAJOR_VERSION < ClassFile.JAVA_6) return; Iterator methods = cf.getMethods().iterator(); while (methods.hasNext()) { MethodInfo mi = (MethodInfo)methods.next(); mi.rebuildStackMap(classPool); } } }
public void rebuildClassFile(ClassFile cf) throws BadBytecode { if (ClassFile.MAJOR_VERSION < ClassFile.JAVA_6) return; for (MethodInfo mi:cf.getMethods()) mi.rebuildStackMap(classPool); } }
public void instrument(ExprEditor editor) throws CannotCompileException { checkModify(); ClassFile cf = getClassFile2(); List list = cf.getMethods(); int n = list.size(); for (int i = 0; i < n; ++i) { MethodInfo minfo = (MethodInfo)list.get(i); editor.doit(this, minfo); } }
public void instrument(CodeConverter converter) throws CannotCompileException { checkModify(); ClassFile cf = getClassFile2(); ConstPool cp = cf.getConstPool(); List list = cf.getMethods(); int n = list.size(); for (int i = 0; i < n; ++i) { MethodInfo minfo = (MethodInfo)list.get(i); converter.doit(this, minfo, cp); } }
@Override public void instrument(ExprEditor editor) throws CannotCompileException { checkModify(); ClassFile cf = getClassFile2(); List<MethodInfo> methods = cf.getMethods(); for (MethodInfo minfo: methods.toArray(new MethodInfo[methods.size()])) editor.doit(this, minfo); }
@Override public void instrument(CodeConverter converter) throws CannotCompileException { checkModify(); ClassFile cf = getClassFile2(); ConstPool cp = cf.getConstPool(); List<MethodInfo> methods = cf.getMethods(); for (MethodInfo minfo: methods.toArray(new MethodInfo[methods.size()])) converter.doit(this, minfo, cp); }
private void makeBehaviorCache(CtMember.Cache cache) { List list = getClassFile3(false).getMethods(); int n = list.size(); for (int i = 0; i < n; ++i) { MethodInfo minfo = (MethodInfo)list.get(i); if (minfo.isMethod()) { CtMethod newMethod = new CtMethod(minfo, this); cache.addMethod(newMethod); } else { CtConstructor newCons = new CtConstructor(minfo, this); cache.addConstructor(newCons); } } }
public void removeConstructor(CtConstructor m) throws NotFoundException { checkModify(); MethodInfo mi = m.getMethodInfo2(); ClassFile cf = getClassFile2(); if (cf.getMethods().remove(mi)) { getMembers().remove(m); gcConstPool = true; } else throw new NotFoundException(m.toString()); }
public void removeMethod(CtMethod m) throws NotFoundException { checkModify(); MethodInfo mi = m.getMethodInfo2(); ClassFile cf = getClassFile2(); if (cf.getMethods().remove(mi)) { getMembers().remove(m); gcConstPool = true; } else throw new NotFoundException(m.toString()); }
List list = getClassFile2().getMethods(); int n = list.size(); for (int i = 0; i < n; i++) {
list = cf.getMethods(); n = list.size(); for (int i = 0; i < n; ++i) {
@Override public void removeConstructor(CtConstructor m) throws NotFoundException { checkModify(); MethodInfo mi = m.getMethodInfo2(); ClassFile cf = getClassFile2(); if (cf.getMethods().remove(mi)) { getMembers().remove(m); gcConstPool = true; } else throw new NotFoundException(m.toString()); }
@Override public void removeMethod(CtMethod m) throws NotFoundException { checkModify(); MethodInfo mi = m.getMethodInfo2(); ClassFile cf = getClassFile2(); if (cf.getMethods().remove(mi)) { getMembers().remove(m); gcConstPool = true; } else throw new NotFoundException(m.toString()); }
private static boolean hasMainMethod(ClassFile cls) { int flags = cls.getAccessFlags(); if (Modifier.isInterface(flags) || Modifier.isAnnotation(flags) || Modifier.isEnum(flags)) return false; for (Object m : cls.getMethods()) { if (m instanceof MethodInfo) { if (isMainMethod((MethodInfo) m)) return true; } } return false; }
private void makeBehaviorCache(CtMember.Cache cache) { List<MethodInfo> methods = getClassFile3(false).getMethods(); for (MethodInfo minfo:methods) if (minfo.isMethod()) cache.addMethod(new CtMethod(minfo, this)); else cache.addConstructor(new CtConstructor(minfo, this)); }
private void modifyConstructors(ClassFile cf) throws CannotCompileException, NotFoundException { if (fieldInitializers == null) return; ConstPool cp = cf.getConstPool(); List list = cf.getMethods(); int n = list.size(); for (int i = 0; i < n; ++i) { MethodInfo minfo = (MethodInfo)list.get(i); if (minfo.isConstructor()) { CodeAttribute codeAttr = minfo.getCodeAttribute(); if (codeAttr != null) try { Bytecode init = new Bytecode(cp, 0, codeAttr.getMaxLocals()); CtClass[] params = Descriptor.getParameterTypes( minfo.getDescriptor(), classPool); int stacksize = makeFieldInitializer(init, params); insertAuxInitializer(codeAttr, init, stacksize); minfo.rebuildStackMapIf6(classPool, cf); } catch (BadBytecode e) { throw new CannotCompileException(e); } } } }
private void makeMemberList(Map<Object,CtClassType> table) { int mod = getModifiers(); if (Modifier.isAbstract(mod) || Modifier.isInterface(mod)) try { CtClass[] ifs = getInterfaces(); for (CtClass ic : ifs) if (ic != null && ic instanceof CtClassType) ((CtClassType)ic).makeMemberList(table); } catch (NotFoundException e) {} try { CtClass s = getSuperclass(); if (s != null && s instanceof CtClassType) ((CtClassType)s).makeMemberList(table); } catch (NotFoundException e) {} List<MethodInfo> methods = getClassFile2().getMethods(); for (MethodInfo minfo:methods) table.put(minfo.getName(), this); List<FieldInfo> fields = getClassFile2().getFields(); for (FieldInfo finfo:fields) table.put(finfo.getName(), this); } }
private void modifyConstructors(ClassFile cf) throws CannotCompileException, NotFoundException { if (fieldInitializers == null) return; ConstPool cp = cf.getConstPool(); List<MethodInfo> methods = cf.getMethods(); for (MethodInfo minfo:methods) { if (minfo.isConstructor()) { CodeAttribute codeAttr = minfo.getCodeAttribute(); if (codeAttr != null) try { Bytecode init = new Bytecode(cp, 0, codeAttr.getMaxLocals()); CtClass[] params = Descriptor.getParameterTypes( minfo.getDescriptor(), classPool); int stacksize = makeFieldInitializer(init, params); insertAuxInitializer(codeAttr, init, stacksize); minfo.rebuildStackMapIf6(classPool, cf); } catch (BadBytecode e) { throw new CannotCompileException(e); } } } }