[jboss-user] [Javassist] - Re: $proceed($$) for private methods

settimer do-not-reply at jboss.com
Thu Jan 31 18:44:21 EST 2013


settimer [https://community.jboss.org/people/settimer] created the discussion

"Re: $proceed($$) for private methods"

To view the discussion, visit: https://community.jboss.org/message/795524#795524

--------------------------------------------------------------
I encoutered the same issue. Have you figured it out?

Below is a mored detailed description:

I try to instrument the call in the method:

    public static Currency getInstance(String currencyCode) {
        return getInstance(currencyCode, Integer.MIN_VALUE);
    }

, which is inside java/util/Currency.class. The call invokes "*private static* Currency getInstance(String, int)", which is enclosed in the same class as the caller.

I need to add some statements around the call "getInstance(currencyCode, Integer.MIN_VALUE);". So I used MethodCall.replace("{some statements; $_ = $proceed($$); other statements;}"), then I got the exception like below:

Caused by: compile error: Method getInstance is private
    at javassist.compiler.
MemberCodeGen.getAccessiblePrivate(MemberCodeGen.java:671)
    at javassist.compiler.MemberCodeGen.atMethodCallCore2(MemberCodeGen.java:612)
     at javassist.compiler.MemberCodeGen.atMethodCallCore(MemberCodeGen.java:575)
    at javassist.compiler.MemberCodeGen.atCallExpr(MemberCodeGen.java:523)
    at javassist.compiler.JvstCodeGen.atCallExpr(JvstCodeGen.java:244)
     at javassist.compiler.ast.CallExpr.accept(CallExpr.java:46)
    at javassist.compiler.CodeGen.compileExpr(CodeGen.java:230)
    at javassist.compiler.Javac$2.doit(Javac.java:490)
    at javassist.compiler.JvstCodeGen.atCallExpr(JvstCodeGen.java:235)
     at javassist.compiler.ast.CallExpr.accept(CallExpr.java:46)
    at javassist.compiler.CodeGen.atAssignCore(CodeGen.java:860)
    at javassist.compiler.CodeGen.atVariableAssign(CodeGen.java:793)
    at javassist.compiler.CodeGen.atAssignExpr(CodeGen.java:747)
     at javassist.compiler.CodeGen.atStmnt(CodeGen.java:332)
    at javassist.compiler.ast.Stmnt.accept(Stmnt.java:50)
    at javassist.compiler.CodeGen.atStmnt(CodeGen.java:351)
    at javassist.compiler.ast.Stmnt.accept(Stmnt.java:50)
     at javassist.compiler.Javac.compileStmnt(Javac.java:569)
    at javassist.expr.MethodCall.replace(MethodCall.java:235)
    ... 18 more

The bug can be reproduced. For example, in java.lang.securityManager, the method checkPackageAccess contains a call
 "packageAccess = getPackages(tmpPropertyStr);", The call invokes "*private static* String[] getPackages(String p)".

In both cases, it involves invocations to "private static" methods.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/795524#795524]

Start a new discussion in Javassist at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2062]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20130131/69a1984d/attachment-0001.html 


More information about the jboss-user mailing list