@Override public void edit(NewExpr e) throws CannotCompileException { try { put(e.getConstructor().getDeclaringClass().getName() + "." + "<init>" + "(" + parameterNames(e.getConstructor().getMethodInfo()) + ")", e.getLineNumber(), key); } catch (NotFoundException e1) { throw new ReflectionsException("Could not find new instance usage in " + key, e1); } }
@Override public void edit(NewExpr e) throws CannotCompileException { try { put(e.getConstructor().getDeclaringClass().getName() + "." + "<init>" + "(" + parameterNames(e.getConstructor().getMethodInfo()) + ")", e.getLineNumber(), key); } catch (NotFoundException e1) { throw new ReflectionsException("Could not find new instance usage in " + key, e1); } }
@Override public void edit(ConstructorCall c) throws CannotCompileException { try { put(c.getConstructor().getDeclaringClass().getName() + "." + "<init>" + "(" + parameterNames(c.getConstructor().getMethodInfo()) + ")", c.getLineNumber(), key); } catch (NotFoundException e) { throw new ReflectionsException("Could not find member " + c.getClassName() + " in " + key, e); } }
@Override public void edit(ConstructorCall c) throws CannotCompileException { try { put(c.getConstructor().getDeclaringClass().getName() + "." + "<init>" + "(" + parameterNames(c.getConstructor().getMethodInfo()) + ")", c.getLineNumber(), key); } catch (NotFoundException e) { throw new ReflectionsException("Could not find member " + c.getClassName() + " in " + key, e); } }
cons.setModifiers(mod); md.accept(gen); cons.getMethodInfo().setCodeAttribute( bytecode.toCodeAttribute()); cons.setExceptionTypes(tlist);
cons.setModifiers(mod); md.accept(gen); cons.getMethodInfo().setCodeAttribute( bytecode.toCodeAttribute()); cons.setExceptionTypes(tlist);
public static void addSyntheticAttribute(CtConstructor ctor) { MethodInfo info = ctor.getMethodInfo(); ConstPool cp = info.getConstPool(); info.addAttribute(new SyntheticAttribute(cp)); }
private void addInjectAnnotation(ConstPool constPool, CtConstructor cc) { AnnotationsAttribute attribute = new AnnotationsAttribute(constPool, AnnotationsAttribute.visibleTag); attribute.setAnnotation(createAnnotation(constPool, Inject.class)); cc.getMethodInfo().addAttribute(attribute); }
private void addAssistedAnnotation(ConstPool constPool, CtConstructor cc) { ParameterAnnotationsAttribute attribute = new ParameterAnnotationsAttribute(constPool, ParameterAnnotationsAttribute.visibleTag); attribute.setAnnotations(new Annotation[][]{{createAnnotation(constPool, Assisted.class)}}); cc.getMethodInfo().addAttribute(attribute); }
@Override public void edit(NewExpr e) throws CannotCompileException { try { put(e.getConstructor().getDeclaringClass().getName() + "." + "<init>" + "(" + parameterNames(e.getConstructor().getMethodInfo()) + ")", e.getLineNumber(), key); } catch (NotFoundException e1) { throw new ReflectionsException("Could not find new instance usage in " + key, e1); } }
@Override public void edit(NewExpr e) throws CannotCompileException { try { put(e.getConstructor().getDeclaringClass().getName() + "." + "<init>" + "(" + parameterNames(e.getConstructor().getMethodInfo()) + ")", e.getLineNumber(), key); } catch (NotFoundException e1) { throw new ReflectionsException("Could not find new instance usage in " + key, e1); } }
@Override public void edit(NewExpr e) throws CannotCompileException { try { put(e.getConstructor().getDeclaringClass().getName() + "." + "<init>" + "(" + parameterNames(e.getConstructor().getMethodInfo()) + ")", e.getLineNumber(), key); } catch (NotFoundException e1) { throw new ReflectionsException("Could not find new instance usage in " + key, e1); } }
@Override public void edit(NewExpr e) throws CannotCompileException { try { put(e.getConstructor().getDeclaringClass().getName() + "." + "<init>" + "(" + parameterNames(e.getConstructor().getMethodInfo()) + ")" , e.getLineNumber() , key); } catch (NotFoundException e1) { throw new ReflectionsException("Could not find new instance usage in " + key , e1); } }
@Override public void edit(ConstructorCall c) throws CannotCompileException { try { put(c.getConstructor().getDeclaringClass().getName() + "." + "<init>" + "(" + parameterNames(c.getConstructor().getMethodInfo()) + ")", c.getLineNumber(), key); } catch (NotFoundException e) { throw new ReflectionsException("Could not find member " + c.getClassName() + " in " + key, e); } }
@Override public void edit(ConstructorCall c) throws CannotCompileException { try { put(c.getConstructor().getDeclaringClass().getName() + "." + "<init>" + "(" + parameterNames(c.getConstructor().getMethodInfo()) + ")", c.getLineNumber(), key); } catch (NotFoundException e) { throw new ReflectionsException("Could not find member " + c.getClassName() + " in " + key, e); } }
@Override public void edit(ConstructorCall c) throws CannotCompileException { try { put(c.getConstructor().getDeclaringClass().getName() + "." + "<init>" + "(" + parameterNames(c.getConstructor().getMethodInfo()) + ")", c.getLineNumber(), key); } catch (NotFoundException e) { throw new ReflectionsException("Could not find member " + c.getClassName() + " in " + key, e); } }
@Override public void edit(ConstructorCall c) throws CannotCompileException { try { put(c.getConstructor().getDeclaringClass().getName() + "." + "<init>" + "(" + parameterNames(c.getConstructor().getMethodInfo()) + ")" , c.getLineNumber() , key); } catch (NotFoundException e) { throw new ReflectionsException("Could not find member " + c.getClassName() + " in " + key , e); } }
private String[] getParameterNames(CtConstructor constructor) throws NotFoundException { MethodInfo methodInfo = constructor.getMethodInfo(); CodeAttribute codeAttribute = methodInfo.getCodeAttribute(); LocalVariableAttribute attribute = (LocalVariableAttribute) codeAttribute.getAttribute("LocalVariableTable"); String[] paramNames = new String[constructor.getParameterTypes().length]; int pos = Modifier.isStatic(constructor.getModifiers()) ? 0 : 1; for (int i = 0; i < paramNames.length; i++) paramNames[i] = attribute.variableName(i + pos); return paramNames; } }
private static void createAnchorConstructor(final CtClass impl, final CtClass anchor) throws Exception { final ClassPool classPool = impl.getClassPool(); final CtConstructor ctConstructor = CtNewConstructor.make( new CtClass[]{anchor}, null, CtNewConstructor.PASS_NONE, null, null, impl); final ConstPool constPool = impl.getClassFile().getConstPool(); final MethodInfo methodInfo = ctConstructor.getMethodInfo(); // add injection annotation final AnnotationsAttribute attr = new AnnotationsAttribute(constPool, AnnotationsAttribute.visibleTag); final Annotation annotation = new Annotation(constPool, classPool.get(javax.inject.Inject.class.getName())); attr.addAnnotation(annotation); methodInfo.addAttribute(attr); impl.addConstructor(ctConstructor); }
private void compileConstructor(JavaMethod method, AnnotationDocletTag tag, CtClass clazz, boolean isInnerClass) throws Exception { CtConstructor ctMethod = getJavassistConstructor(method, clazz, isInnerClass); MethodInfo minfo = ctMethod.getMethodInfo(); javassist.bytecode.annotation.Annotation info = AnnotationInfoCreator.createAnnotationInfo(pool, minfo.getConstPool(), tag.getAnnotation()); AnnotationsAttribute visible = (AnnotationsAttribute) minfo.getAttribute(AnnotationsAttribute.visibleTag); if (visible == null) { visible = new AnnotationsAttribute(minfo.getConstPool(), AnnotationsAttribute.visibleTag); minfo.addAttribute(visible); } visible.addAnnotation(info); } }