Java Code Examples for javassist.expr.MethodCall#getLineNumber()

The following examples show how to use javassist.expr.MethodCall#getLineNumber() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SourceTargetTransformer.java    From DroidAssist with Apache License 2.0 5 votes vote down vote up
protected String getReplaceStatement(MethodCall methodCall, String statement) {
    int line = methodCall.getLineNumber();
    String name = methodCall.getMethodName();
    String className = methodCall.getClassName();
    String fileName = methodCall.getFileName();
    return getReplaceStatement(statement, line, name, className, fileName);
}
 
Example 2
Source File: MethodCallInsertTransformer.java    From DroidAssist with Apache License 2.0 4 votes vote down vote up
@Override
protected boolean execute(
        CtClass inputClass,
        String inputClassName,
        MethodCall methodCall)
        throws CannotCompileException, NotFoundException {

    if (methodCall.isSuper()) {
        return false;
    }
    String insnClassName = methodCall.getClassName();
    String insnName = methodCall.getMethodName();
    String insnSignature = methodCall.getSignature();

    CtClass insnClass = tryGetClass(insnClassName, inputClassName);
    if (insnClass == null) {
        return false;
    }
    if (!isMatchSourceMethod(insnClass, insnName, insnSignature)) {
        return false;
    }

    String target = getTarget();
    int line = methodCall.getLineNumber();
    if (!target.endsWith(";")) target = target + ";";

    String before = isAsBefore() ? target : "";
    String after = isAsAfter() ? target : "";

    String proceed = isVoidSourceReturnType() ? "$proceed($$);" : "$_ =$proceed($$);";

    String statement = before + proceed + after;

    String replacement = replaceInstrument(methodCall, statement);

    if (isAsBefore()) {
        Logger.warning(getPrettyName() + " insert before call by: " + replacement
                + " at " + inputClassName + ".java" + ":" + line);
    }

    if (isAsAfter()) {
        Logger.warning(getPrettyName() + " insert after call by: " + replacement
                + " at " + inputClassName + ".java" + ":" + line);
    }
    return true;
}