Adding try/finally block
Nikolas Nehmer <[email protected]>
| Newsgroups | gmane.comp.java.objectweb.asm |
|---|---|
| Organization | FB Informatik, TU Kaiserslautern, GERMANY |
| Message-ID | <10336658.1272637814658.OPEN-XCHANGE.WebMail.tomcat@groupmail.informatik.uni-kl.de> |
Hi, I'm trying to add a try/finally block to every method in my system. Unfortunately I have to do so, to ensure a counter to set/reset properly in every case - i.e. normal execution of a method, exception raised in a specific method (i.e. athrow executed in the same method) and methods terminated by exception propagation. Conceptually I'm trying to do the following: methodStartLabel ... <<<counter increment injected manually before every return statement methodReturnStatement <<<inject code here <<<newTryBlockEndLabel <<<counterIncrement <<<athrowStatement methodEndLabel the TryCatckBlockNode is created with the following parameters: methodStartLabel, newTryBlockEndLabel, newTryBlockEndlabel, null For most cases I just don't use the visitor pattern, but inject the new statements into the instruction list directly. Accordingly, I add the TryCatchBlockNode just created into the tryCatchBlocks list. While executing the instrumented application the following NullPointerException is raised :( Any ideas or suggestions? I know there is an example in one of the ASM papers related to my usecase. Unfortunalty this doesn't help me a lot. java.lang.NullPointerException at org.objectweb.asm.MethodWriter.visitMaxs(Unknown Source) at org.objectweb.asm.tree.MethodNode.accept(Unknown Source) at de.kl.uni.cs.nehmer.setup.bci.SimpleBCIMethodAdapter.visitEnd(SimpleBCIMethodAdapter.java:51) at org.objectweb.asm.ClassReader.accept(Unknown Source) at org.objectweb.asm.ClassReader.accept(Unknown Source) at de.kl.uni.cs.nehmer.setup.bci.BCIAgent.transform(BCIAgent.java:32) at sun.instrument.TransformerManager.transform(TransformerManager.java:169) at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:365) at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:621) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124) at java.net.URLClassLoader.defineClass(URLClassLoader.java:260) at java.net.URLClassLoader.access$000(URLClassLoader.java:56) at java.net.URLClassLoader$1.run(URLClassLoader.java:195) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:252) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) cheers Nikolas
message-footer.txt
(text/plain, 238 B)
-- You receive this message as a subscriber of the [email protected] mailing list. To unsubscribe: mailto:[email protected] For general help: mailto:[email protected]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws