@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); } }
ConByConDetail(CallerExprEditor editor, NewExpr call, String classname)throws NotFoundException { this.call = call; con = (CtConstructor) call.where(); callingIndex = editor.constructors.indexOf(con); calledHash = JavassistMethodHashing.constructorHash(call.getConstructor()); callerInfoField = getConByConInfoName(callingIndex, classname, calledHash); calledConstructor = call.getConstructor(); this.classname = classname; isTgtConAdvised = isTargetConstructorAdvised(calledConstructor); } }
ConByMethodDetail(CallerExprEditor editor, NewExpr call, String classname)throws NotFoundException { this.call = call; where = (CtMethod) call.where(); callingHash = JavassistMethodHashing.methodHash(where); calledHash = JavassistMethodHashing.constructorHash(call.getConstructor()); callerInfoField = getConByMethodInfoName(callingHash, classname, calledHash); calledConstructor = call.getConstructor(); this.classname = classname; isTgtConAdvised = isTargetConstructorAdvised(calledConstructor); } }
@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); } }
public Object visit(ASTHasField node, Object data) { ASTField f = (ASTField) node.jjtGetChild(0); CtConstructor con = null; try { con = call.getConstructor(); } catch (NotFoundException e) { throw new RuntimeException(e); //To change body of catch statement use Options | File Templates. } return new Boolean(Util.has(con.getDeclaringClass(), f, advisor)); } }
@Override public void edit(final NewExpr expr) throws CannotCompileException { if (expr.getClassName().equals(newClassName)) try { final CtClass[] parameterTypes = expr.getConstructor().getParameterTypes(); if (parameterTypes[parameterIndex - 1] != CodeHacker.this .getClass("java.lang.String")) { maybeThrow(new IllegalArgumentException("Parameter " + parameterIndex + " of " + expr.getConstructor() + " is not a String!")); return; } final String replace = replaceAppName(parameterIndex, parameterTypes.length, replacement); expr.replace("$_ = new " + newClassName + replace + ";"); markEdited(); } catch (final NotFoundException e) { maybeThrow(new IllegalArgumentException( "Cannot find the parameters of the constructor of " + newClassName, e)); } } }.instrument(method);
@Override public void edit(final NewExpr expr) throws CannotCompileException { if (expr.getClassName().equals(newClassName)) try { final CtClass[] parameterTypes = expr.getConstructor().getParameterTypes(); if (parameterTypes[parameterIndex - 1] != CodeHacker.this .getClass("java.lang.String")) { maybeThrow(new IllegalArgumentException("Parameter " + parameterIndex + " of " + expr.getConstructor() + " is not a String!")); return; } final String replace = replaceAppName(parameterIndex, parameterTypes.length, replacement); expr.replace("$_ = new " + newClassName + replace + ";"); markEdited(); } catch (final NotFoundException e) { maybeThrow(new IllegalArgumentException( "Cannot find the parameters of the constructor of " + newClassName, e)); } } }.instrument(method);
public Object visit(ASTHas node, Object data) { try { Node n = node.jjtGetChild(0); CtConstructor con = call.getConstructor(); if (n instanceof ASTMethod) { return new Boolean(Util.has(con.getDeclaringClass(), (ASTMethod) n, advisor)); } else { return new Boolean(Util.has(con.getDeclaringClass(), (ASTConstructor) n, advisor)); } } catch (NotFoundException e) { throw new RuntimeException(e); //To change body of catch statement use Options | File Templates. } }
addConstructor(sb, con); sb.append(" calls "); addConstructor(sb, newcall.getConstructor()); addMethod(sb, met); sb.append(" calls "); addConstructor(sb, newcall.getConstructor());
public Object visit(ASTCall node, Object data) { try { if (!(node.getBehavior() instanceof ASTConstructor)) return Boolean.FALSE; ASTConstructor astCon = (ASTConstructor) node.getBehavior(); // do simple checks to avoid loading CtClasses if (astCon.getClazz().isSimple()) { if (!astCon.getClazz().matches(call.getClassName())) return Boolean.FALSE; } CtConstructor calledCon = call.getConstructor(); ClassAdvisor calledAdvisor = AspectManager.instance().getTempClassAdvisor(calledCon.getDeclaringClass()); ConstructorMatcher conMatcher = new ConstructorMatcher(calledAdvisor, calledCon, null); return conMatcher.matches(astCon); } catch (Exception e) { throw new RuntimeException(e); //To change body of catch statement use Options | File Templates. } }