/** * get constructor desc. * "()V", "(Ljava/lang/String;I)V" * * @param c constructor. * @return desc */ public static String getDesc(final CtConstructor c) throws NotFoundException { StringBuilder ret = new StringBuilder("("); CtClass[] parameterTypes = c.getParameterTypes(); for (int i = 0; i < parameterTypes.length; i++) { ret.append(getDesc(parameterTypes[i])); } ret.append(')').append('V'); return ret.toString(); }
/** * get constructor desc. * "()V", "(Ljava/lang/String;I)V" * * @param c constructor. * @return desc */ public static String getDesc(final CtConstructor c) throws NotFoundException { StringBuilder ret = new StringBuilder("("); CtClass[] parameterTypes = c.getParameterTypes(); for (int i = 0; i < parameterTypes.length; i++) { ret.append(getDesc(parameterTypes[i])); } ret.append(')').append('V'); return ret.toString(); }
if (isInheritable(mod, superclazz)) { CtConstructor cons = CtNewConstructor.make(c.getParameterTypes(), c.getExceptionTypes(), this); cons.setModifiers(mod & (Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE));
if (implConstructors != null) { for (CtConstructor cons : implConstructors) { if (cons.getParameterTypes().length == 0) { defaultConstructorFound = true; break;
if (isInheritable(mod, superclazz)) { CtConstructor cons = CtNewConstructor.make(c.getParameterTypes(), c.getExceptionTypes(), this); cons.setModifiers(mod & (Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE));
/** * get constructor desc. * "()V", "(Ljava/lang/String;I)V" * * @param c constructor. * @return desc */ public static String getDesc(final CtConstructor c) throws NotFoundException { StringBuilder ret = new StringBuilder("("); CtClass[] parameterTypes = c.getParameterTypes(); for (int i = 0; i < parameterTypes.length; i++) { ret.append(getDesc(parameterTypes[i])); } ret.append(')').append('V'); return ret.toString(); }
Javac jv = new Javac(b, cc); try { jv.recordParams(getParameterTypes(), false); jv.compileStmnt(src); ca.setMaxStack(b.getMaxStack());
Javac jv = new Javac(b, cc); try { jv.recordParams(getParameterTypes(), false); jv.compileStmnt(src); ca.setMaxStack(b.getMaxStack());
@Override public int getNumberOfParams() { try { return ctConstructor.getParameterTypes().length; } catch (NotFoundException e) { throw new RuntimeException(e); } }
public boolean patternMatches(CtConstructor constructor) throws NotFoundException { // the wildcard matches everything if (signature.equals("*")) { return true; } String sig = MethodConfig.getSignature(constructor.getParameterTypes()); return sig.equals(signature); }
/** * Create a new Signature. * * @param constructor the constructor * @throws javassist.NotFoundException for any errors */ public JavassistConstructorSignature(CtConstructor constructor) throws NotFoundException { super(JavassistSignatureFactory.convertParameters(constructor.getParameterTypes())); } }
private static String calcSignature(CtConstructor constructor) throws NotFoundException { List<String> paramTypesSignatures = Arrays.stream(constructor.getParameterTypes()).map((t) -> calcSignature(t)).collect(Collectors.toList()); return "(" + String.join("", paramTypesSignatures) + ")V"; } }
public CtClass getParameterType(int i) throws NotFoundException { if (method != null) { return method.getParameterTypes()[i]; } else { return constructor.getParameterTypes()[i]; } } }
/** * Create a new Signature. * * @param constructor the method * @param param the parameter number * @throws javassist.NotFoundException for any error */ public JavassistConstructorParametersSignature(CtConstructor constructor, int param) throws NotFoundException { super(param, JavassistSignatureFactory.convertParameters(constructor.getParameterTypes())); } }
public boolean matches(CtConstructor con) throws NotFoundException { Matcher cm = classExpr.matcher(con.getDeclaringClass().getName()); if (cm.matches() == false) return false; return params.matches(con.getParameterTypes()); } }
private List<CtConstructor> extractExistingConstructors(final InsertableConstructor insertableConstructor) throws NotFoundException, AfterBurnerImpossibleException { List<CtConstructor> constructors = new ArrayList<CtConstructor>(); CtConstructor[] declaredConstructors = insertableConstructor .getClassToInsertInto().getDeclaredConstructors(); for (CtConstructor constructor : declaredConstructors) { CtClass[] paramClasses = constructor.getParameterTypes(); if (insertableConstructor.acceptParameters(paramClasses)) { constructors.add(constructor); } } return constructors; }
private List<CtConstructor> extractExistingConstructors(final InsertableConstructor insertableConstructor) throws NotFoundException, AfterBurnerImpossibleException { List<CtConstructor> constructors = new ArrayList<CtConstructor>(); CtConstructor[] declaredConstructors = insertableConstructor .getClassToInsertInto().getDeclaredConstructors(); for (CtConstructor constructor : declaredConstructors) { CtClass[] paramClasses = constructor.getParameterTypes(); if (insertableConstructor.acceptParameters(paramClasses)) { constructors.add(constructor); } } return constructors; }
private void insertWrapperCallInCtor(CtConstructor constructor, String wrapperName)throws NotFoundException, CannotCompileException { String wrapperCall = "((" + GeneratedAdvisorInstrumentor.getAdvisorFQN(constructor.getDeclaringClass())+ ")" + GeneratedAdvisorInstrumentor.GET_CURRENT_ADVISOR + ")." + wrapperName + "(this" + ((constructor.getParameterTypes().length == 0) ? "" : ", $$") + ");"; constructor.insertAfter(wrapperCall, false); }
private CtMethod getInnerWrapperMethod(CtConstructor constructor)throws NotFoundException { CtClass genadvisor = getGenAdvisor(); return genadvisor.getDeclaredMethod( getInnerWrapperMethodName(constructor), constructor.getParameterTypes()); }
protected CtMethod getWrapperMethod(CtConstructor constructor) throws NotFoundException { CtClass clazz = constructor.getDeclaringClass(); return clazz.getDeclaredMethod( constructorFactory(clazz.getSimpleName()), constructor.getParameterTypes()); }