[prev in list] [next in list] [prev in thread] [next in thread] 

List:       jboss-user
Subject:    [jboss-user] [Javassist] - Re: $proceed($$) for private methods
From:       settimer <do-not-reply () jboss ! com>
Date:       2013-01-31 23:44:21
Message-ID: 2-740844-3-89867-1339285470366-2-795524-3-117899-1359675854927.jivesbs.jivemailuser () https://community ! jboss ! org
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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]



[Attachment #5 (text/html)]

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; \
margin: 0; padding: 20px;">

<div>
	<table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: \
1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; \
-webkit-border-radius: 6px;">  <tbody>
			<tr>

				<td>

					<table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" \
style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: \
6px; -webkit-border-radius: 6px;">  <tbody>
							<tr>
								<td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px \
solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; \
-moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; \
                -webkit-border-top-left-radius: 5px;">
									<h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; \
                margin: 0; display: block !important;">
									<!-- To have a header image/logo replace the name below with your img tag \
                -->
									<!-- Email clients will render the images when the message is read so any \
                image -->
									<!-- must be made available on a public server, so that all recipients can \
                load the image. -->
									<a href="https://community.jboss.org/index.jspa" style="text-decoration: \
none; color: #E1E1E1">JBoss Community</a></h1>  </td>

							</tr>
							<tr>
								<td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; \
color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; \
-moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; \
-webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: \
17px; font-weight: normal;">  Re: $proceed($$) for private methods
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="https://community.jboss.org/people/settimer">settimer</a> in \
<i>Javassist</i> - <a href="https://community.jboss.org/message/795524#795524">View \
the full discussion</a> </span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>I encoutered the same issue. Have you figured \
it out?</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Below \
is a mored detailed description:</p><p style="min-height: 8pt; height: 8pt; padding: \
0px;">&#160;</p><p>I try to instrument the call in the method:</p><p \
style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&#160;&#160;&#160; \
public static Currency getInstance(String currencyCode) \
{</p><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; return getInstance(currencyCode, \
Integer.MIN_VALUE);</p><p>&#160;&#160;&#160; }</p><p style="min-height: 8pt; height: \
8pt; padding: 0px;">&#160;</p><p>, which is inside java/util/Currency.class. The call \
invokes "<strong>private static</strong> Currency getInstance(String, int)", which is \
enclosed in the same class as the caller.</p><p style="min-height: 8pt; height: 8pt; \
padding: 0px;">&#160;</p><p>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:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Caused \
by: compile error: Method getInstance is private</p><p>&#160;&#160;&#160; at \
javassist.compiler.</p><p>MemberCodeGen.getAccessiblePrivate(MemberCodeGen.java:671)<br/>&#160;&#160;&#160; \
at javassist.compiler.MemberCodeGen.atMethodCallCore2(MemberCodeGen.java:612)<br/>&#160;&#160;&#160;&#160; \
at javassist.compiler.MemberCodeGen.atMethodCallCore(MemberCodeGen.java:575)<br/>&#160;&#160;&#160; \
at javassist.compiler.MemberCodeGen.atCallExpr(MemberCodeGen.java:523)<br/>&#160;&#160;&#160; \
at javassist.compiler.JvstCodeGen.atCallExpr(JvstCodeGen.java:244)<br/>&#160;&#160;&#160;&#160; \
at javassist.compiler.ast.CallExpr.accept(CallExpr.java:46)<br/>&#160;&#160;&#160; at \
javassist.compiler.CodeGen.compileExpr(CodeGen.java:230)<br/>&#160;&#160;&#160; at \
javassist.compiler.Javac$2.doit(Javac.java:490)<br/>&#160;&#160;&#160; at \
javassist.compiler.JvstCodeGen.atCallExpr(JvstCodeGen.java:235)<br/>&#160;&#160;&#160;&#160; \
at javassist.compiler.ast.CallExpr.accept(CallExpr.java:46)<br/>&#160;&#160;&#160; at \
javassist.compiler.CodeGen.atAssignCore(CodeGen.java:860)<br/>&#160;&#160;&#160; at \
javassist.compiler.CodeGen.atVariableAssign(CodeGen.java:793)<br/>&#160;&#160;&#160; \
at javassist.compiler.CodeGen.atAssignExpr(CodeGen.java:747)<br/>&#160;&#160;&#160;&#160; \
at javassist.compiler.CodeGen.atStmnt(CodeGen.java:332)<br/>&#160;&#160;&#160; at \
javassist.compiler.ast.Stmnt.accept(Stmnt.java:50)<br/>&#160;&#160;&#160; at \
javassist.compiler.CodeGen.atStmnt(CodeGen.java:351)<br/>&#160;&#160;&#160; at \
javassist.compiler.ast.Stmnt.accept(Stmnt.java:50)<br/>&#160;&#160;&#160;&#160; at \
javassist.compiler.Javac.compileStmnt(Javac.java:569)<br/>&#160;&#160;&#160; at \
javassist.expr.MethodCall.replace(MethodCall.java:235)<br/>&#160;&#160;&#160; ... 18 \
more</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The bug \
can be reproduced. For example, in java.lang.securityManager, the method \
checkPackageAccess contains a call<br/> "packageAccess = \
getPackages(tmpPropertyStr);", The call invokes "<strong>private static</strong> \
String[] getPackages(String p)".</p><p style="min-height: 8pt; height: 8pt; padding: \
0px;">&#160;</p><p>In both cases, it involves invocations to "private static" \
methods.</p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a \
href="https://community.jboss.org/message/795524#795524">going to Community</a></p>  \
<p style="margin: 0;">Start a new discussion in Javassist at <a \
href="https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2062">Community</a></p>
 </div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>



_______________________________________________
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic