[jboss-jira] [JBoss JIRA] (JASSIST-165) VerifyError with addLocalVariable() and insertAfter() when the method body is in a try catch statement
Hua Zhang (JIRA)
jira-events at lists.jboss.org
Sat Apr 7 10:44:47 EDT 2012
[ https://issues.jboss.org/browse/JASSIST-165?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Hua Zhang resolved JASSIST-165.
-------------------------------
Resolution: Done
See my comment.
> VerifyError with addLocalVariable() and insertAfter() when the method body is in a try catch statement
> ------------------------------------------------------------------------------------------------------
>
> Key: JASSIST-165
> URL: https://issues.jboss.org/browse/JASSIST-165
> Project: Javassist
> Issue Type: Bug
> Affects Versions: 3.16.1-GA
> Environment: JDK 1.6, javassist3.16.1_GA
> Reporter: Hua Zhang
> Assignee: Shigeru Chiba
> Priority: Blocker
>
> CtClass cc = pool.get(className);
> CtMethod theMethod = ...;
> cc.defrost();
> theMethod.addLocalVariable("__t", pool.get("long"));
> theMethod.insertBefore("{long __t = System.nanoTime();}");
> theMethod.insertAfter("{System.out.println(System.nanoTime() - __t);}");
> cc.freeze();
> byte[] classFile = cc.toBytecode();
> swapper.reload(className, classFile); // swapper is javassist.util.HotSwapper
> This code snippet can work for the method which doesn't contain try catch statement. However, if the method likes this:
> public void method(...) {
> try {
> ......
> } catch (Exception e) {
> }
> }
> Error thrown:
> Exception in thread "HotSwap" java.lang.VerifyError: verifier detected internal
> inconsistency or security problem
> It is because __t is not visible in insertAfter() in this case. If modify the statement "theMethod.insertAfter("{System.out.println(System.nanoTime() - __t);}");" to be "theMethod.insertAfter("{System.out.println(System.nanoTime());}");" ( it removes the reference to variable __t), the code can work properly.
> Note I use insertAfter(String), not insertAfter(String, true).
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list