[jboss-jira] [JBoss JIRA] (JASSIST-232) BadBytecode when trying access localVariable using insertAfter and asFinally = true
Marvin Herman Froeder (JIRA)
issues at jboss.org
Sat Aug 9 09:54:29 EDT 2014
Marvin Herman Froeder created JASSIST-232:
---------------------------------------------
Summary: BadBytecode when trying access localVariable using insertAfter and asFinally = true
Key: JASSIST-232
URL: https://issues.jboss.org/browse/JASSIST-232
Project: Javassist
Issue Type: Bug
Security Level: Public (Everyone can see)
Affects Versions: 3.18.2-GA
Reporter: Marvin Herman Froeder
Assignee: Shigeru Chiba
What I was trying to do:
I wanna init a variable calling a method and then I wanna run a cleanup on
finally.
{code:java}
private void originalMethod() {
String aVar = null;
try{
aVar = initVar(); // routine to create something added instrumenting
runOriginalCode();
}finally {
dismiss(aVar); //cleanup routine added instrumenting
}
}
{code}
I tried that by doing:
{code:java}
ctMethod.addLocalVariable("aVar", StringCtClass));
ctMethod.insertBefore("aVar = initVar();");
ctMethod.insertAfter(" dismiss( aVar );" , true);
{code}
But I got:
{quote}
javassist.CannotCompileException: by javassist.bytecode.BadBytecode: success ()Ljava/lang/Boolean; in com.contaazul.Sample: conflict: *top* and java.lang.String
at javassist.CtBehavior.insertAfter(CtBehavior.java:880)
at com.marvinformatics.dbadvisor.agent.DbAdvisorClassFileTransformer.trackThread(DbAdvisorClassFileTransformer.java:127)
at com.marvinformatics.dbadvisor.agent.DbAdvisorClassFileTransformer.trackThread(DbAdvisorClassFileTransformer.java:120)
at com.marvinformatics.dbadvisor.agent.DbAdvisorClassFileTransformer.instrumentContaAzul(DbAdvisorClassFileTransformer.java:66)
at com.marvinformatics.dbadvisor.agent.DbAdvisorClassFileTransformer.transform(DbAdvisorClassFileTransformer.java:38)
at com.marvinformatics.dbadvisor.agent.DbAdvisorClassFileTransformerTest$1.loadClass(DbAdvisorClassFileTransformerTest.java:39)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at com.marvinformatics.dbadvisor.agent.DbAdvisorClassFileTransformerTest.contaazulish(DbAdvisorClassFileTransformerTest.java:93)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
at org.testng.TestNG.run(TestNG.java:1057)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
Caused by: javassist.bytecode.BadBytecode: success ()Ljava/lang/Boolean; in com.contaazul.Sample: conflict: *top* and java.lang.String
at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:111)
at javassist.bytecode.MethodInfo.rebuildStackMap(MethodInfo.java:423)
at javassist.bytecode.MethodInfo.rebuildStackMapIf6(MethodInfo.java:405)
at javassist.CtBehavior.insertAfter(CtBehavior.java:871)
... 31 more
Caused by: javassist.bytecode.BadBytecode: conflict: *top* and java.lang.String
at javassist.bytecode.stackmap.TypeData$BasicType.setType(TypeData.java:134)
at javassist.bytecode.stackmap.Tracer.checkParamTypes(Tracer.java:930)
at javassist.bytecode.stackmap.Tracer.doInvokeMethod(Tracer.java:801)
at javassist.bytecode.stackmap.Tracer.doOpcode148_201(Tracer.java:597)
at javassist.bytecode.stackmap.Tracer.doOpcode(Tracer.java:81)
at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:187)
at javassist.bytecode.stackmap.MapMaker.traceException(MapMaker.java:221)
at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:182)
at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:164)
at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:108)
... 34 more
{quote}
and I also tried the other way around (insertAfter first and insertBefore later):
{code:java}
ctMethod.addLocalVariable("aVar", StringCtClass));
ctMethod.insertAfter(" dismiss( aVar );" , true);
ctMethod.insertBefore("aVar = initVar();");
{code}
still, same error
{quote}
javassist.CannotCompileException: by javassist.bytecode.BadBytecode: success ()Ljava/lang/Boolean; in com.contaazul.Sample: conflict: *top* and java.lang.String
at javassist.CtBehavior.insertAfter(CtBehavior.java:880)
at com.marvinformatics.dbadvisor.agent.DbAdvisorClassFileTransformer.trackThread(DbAdvisorClassFileTransformer.java:126)
at com.marvinformatics.dbadvisor.agent.DbAdvisorClassFileTransformer.trackThread(DbAdvisorClassFileTransformer.java:120)
at com.marvinformatics.dbadvisor.agent.DbAdvisorClassFileTransformer.instrumentContaAzul(DbAdvisorClassFileTransformer.java:66)
at com.marvinformatics.dbadvisor.agent.DbAdvisorClassFileTransformer.transform(DbAdvisorClassFileTransformer.java:38)
at com.marvinformatics.dbadvisor.agent.DbAdvisorClassFileTransformerTest$1.loadClass(DbAdvisorClassFileTransformerTest.java:39)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at com.marvinformatics.dbadvisor.agent.DbAdvisorClassFileTransformerTest.contaazulish(DbAdvisorClassFileTransformerTest.java:93)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
at org.testng.TestNG.run(TestNG.java:1057)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
Caused by: javassist.bytecode.BadBytecode: success ()Ljava/lang/Boolean; in com.contaazul.Sample: conflict: *top* and java.lang.String
at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:111)
at javassist.bytecode.MethodInfo.rebuildStackMap(MethodInfo.java:423)
at javassist.bytecode.MethodInfo.rebuildStackMapIf6(MethodInfo.java:405)
at javassist.CtBehavior.insertAfter(CtBehavior.java:871)
... 31 more
Caused by: javassist.bytecode.BadBytecode: conflict: *top* and java.lang.String
at javassist.bytecode.stackmap.TypeData$BasicType.setType(TypeData.java:134)
at javassist.bytecode.stackmap.Tracer.checkParamTypes(Tracer.java:930)
at javassist.bytecode.stackmap.Tracer.doInvokeMethod(Tracer.java:801)
at javassist.bytecode.stackmap.Tracer.doOpcode148_201(Tracer.java:597)
at javassist.bytecode.stackmap.Tracer.doOpcode(Tracer.java:81)
at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:187)
at javassist.bytecode.stackmap.MapMaker.traceException(MapMaker.java:221)
at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:182)
at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:164)
at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:108)
... 34 more
{quote}
--
This message was sent by Atlassian JIRA
(v6.2.6#6264)
More information about the jboss-jira
mailing list