/** * Returns a static initializer (class initializer), or null if it does not * exist. */ public MethodInfo getStaticInitializer() { return getMethod(MethodInfo.nameClinit); }
private String findAccessorName(ClassFile cf) { String accName; do { accName = "access$" + uniqueNumber++; } while (cf.getMethod(accName) != null); return accName; } }
private String findAccessorName(ClassFile cf) { String accName; do { accName = "access$" + uniqueNumber++; } while (cf.getMethod(accName) != null); return accName; } }
/** * Returns a static initializer (class initializer), or null if it does not * exist. */ public MethodInfo getStaticInitializer() { return getMethod(MethodInfo.nameClinit); }
private Object getDefault(String name, Method method) throws ClassNotFoundException, RuntimeException { String classname = annotation.getTypeName(); if (pool != null) { try { CtClass cc = pool.get(classname); ClassFile cf = cc.getClassFile2(); MethodInfo minfo = cf.getMethod(name); if (minfo != null) { AnnotationDefaultAttribute ainfo = (AnnotationDefaultAttribute) minfo.getAttribute(AnnotationDefaultAttribute.tag); if (ainfo != null) { MemberValue mv = ainfo.getDefaultValue(); return mv.getValue(classLoader, pool, method); } } } catch (NotFoundException e) { throw new RuntimeException("cannot find a class file: " + classname); } } throw new RuntimeException("no default value: " + classname + "." + name + "()"); }
private Object getDefault(String name, Method method) throws ClassNotFoundException, RuntimeException { String classname = annotation.getTypeName(); if (pool != null) { try { CtClass cc = pool.get(classname); ClassFile cf = cc.getClassFile2(); MethodInfo minfo = cf.getMethod(name); if (minfo != null) { AnnotationDefaultAttribute ainfo = (AnnotationDefaultAttribute) minfo.getAttribute(AnnotationDefaultAttribute.tag); if (ainfo != null) { MemberValue mv = ainfo.getDefaultValue(); return mv.getValue(classLoader, pool, method); } } } catch (NotFoundException e) { throw new RuntimeException("cannot find a class file: " + classname); } } throw new RuntimeException("no default value: " + classname + "." + name + "()"); }
private static String addBodyMethod(CtClassType clazz, ClassFile classfile, CtMethod src) throws BadBytecode, CannotCompileException { Hashtable bodies = clazz.getHiddenMethods(); String bodyname = (String)bodies.get(src); if (bodyname == null) { do { bodyname = addedWrappedMethod + clazz.getUniqueNumber(); } while (classfile.getMethod(bodyname) != null); ClassMap map = new ClassMap(); map.put(src.getDeclaringClass().getName(), clazz.getName()); MethodInfo body = new MethodInfo(classfile.getConstPool(), bodyname, src.getMethodInfo2(), map); int acc = body.getAccessFlags(); body.setAccessFlags(AccessFlag.setPrivate(acc)); body.addAttribute(new SyntheticAttribute(classfile.getConstPool())); // a stack map is copied. rebuilding it is not needed. classfile.addMethod(body); bodies.put(src, bodyname); CtMember.Cache cache = clazz.hasMemberCache(); if (cache != null) cache.addMethod(new CtMethod(body, clazz)); } return bodyname; }
private static String addBodyMethod(CtClassType clazz, ClassFile classfile, CtMethod src) throws BadBytecode, CannotCompileException { Map<CtMethod,String> bodies = clazz.getHiddenMethods(); String bodyname = bodies.get(src); if (bodyname == null) { do { bodyname = addedWrappedMethod + clazz.getUniqueNumber(); } while (classfile.getMethod(bodyname) != null); ClassMap map = new ClassMap(); map.put(src.getDeclaringClass().getName(), clazz.getName()); MethodInfo body = new MethodInfo(classfile.getConstPool(), bodyname, src.getMethodInfo2(), map); int acc = body.getAccessFlags(); body.setAccessFlags(AccessFlag.setPrivate(acc)); body.addAttribute(new SyntheticAttribute(classfile.getConstPool())); // a stack map is copied. rebuilding it is not needed. classfile.addMethod(body); bodies.put(src, bodyname); CtMember.Cache cache = clazz.hasMemberCache(); if (cache != null) cache.addMethod(new CtMethod(body, clazz)); } return bodyname; }
private String findAccessorName(ClassFile cf) { String accName; do { accName = "access$" + uniqueNumber++; } while (cf.getMethod(accName) != null); return accName; } }
private String findAccessorName(ClassFile cf) { String accName; do { accName = "access$" + uniqueNumber++; } while (cf.getMethod(accName) != null); return accName; } }
/** * Returns a static initializer (class initializer), or null if it does not * exist. */ public MethodInfo getStaticInitializer() { return getMethod(MethodInfo.nameClinit); }
private String findAccessorName(ClassFile cf) { String accName; do { accName = "access$" + uniqueNumber++; } while (cf.getMethod(accName) != null); return accName; } }
/** * Returns a static initializer (class initializer), or null if it does not * exist. */ public MethodInfo getStaticInitializer() { return getMethod(MethodInfo.nameClinit); }
/** * Returns a static initializer (class initializer), or null if it does not * exist. */ public MethodInfo getStaticInitializer() { return getMethod(MethodInfo.nameClinit); }
private String findAccessorName(ClassFile cf) { String accName; do { accName = "access$" + uniqueNumber++; } while (cf.getMethod(accName) != null); return accName; } }
/** * Returns a static initializer (class initializer), or null if it does not * exist. */ public MethodInfo getStaticInitializer() { return getMethod(MethodInfo.nameClinit); }
private String findAccessorName(ClassFile cf) { String accName; do { accName = "access$" + uniqueNumber++; } while (cf.getMethod(accName) != null); return accName; } }
/** * Returns a static initializer (class initializer), or null if it does not * exist. */ public MethodInfo getStaticInitializer() { return getMethod(MethodInfo.nameClinit); }
private Object getDefault(String name, Method method) throws ClassNotFoundException, RuntimeException { String classname = annotation.getTypeName(); if (pool != null) { try { CtClass cc = pool.get(classname); ClassFile cf = cc.getClassFile2(); MethodInfo minfo = cf.getMethod(name); if (minfo != null) { AnnotationDefaultAttribute ainfo = (AnnotationDefaultAttribute) minfo.getAttribute(AnnotationDefaultAttribute.tag); if (ainfo != null) { MemberValue mv = ainfo.getDefaultValue(); return mv.getValue(classLoader, pool, method); } } } catch (NotFoundException e) { throw new RuntimeException("cannot find a class file: " + classname); } } throw new RuntimeException("no default value: " + classname + "." + name + "()"); }
MethodInfo minfo = cf.getMethod("add"); CodeAttribute ca = minfo.getCodeAttribute(); for (CodeIterator ci = ca.iterator(); ci.hasNext();) {