Re: IllegalStateException: Try catch blocks must be visited before their labels
Tronje Krop <[email protected]>
| Newsgroups | gmane.comp.java.objectweb.asm |
|---|---|
| Organization | Darmstadt University of Technology |
| Message-ID | <[email protected]> |
Hi Rajaraman, it is difficult because you don't provide a proper example. Currently, it is unclear, which transformations your system does before your CheckClassAdaptor and which ones after - and it is totally unclear whether your transformation holds the verification criteria in between. Only If we know all this facts, we can conclude about a concrete problem an whether output of CheckClassAdaptor gives the right hint. Best regards Tronje Rajaraman Santhanam wrote: > Hi, > > Can anybody comment on this? > > > Thanks. > > ---- On Mon, 31 Jan 2011 19:43:31 +0530 Rajaraman Santhanam <[email protected]> wrote ---- > > Hi Tronje, > > What you say makes sense. Either VM is a bit lenient or CheckClassAdaptor is strict. > > > I tried with a simple java file and this seems to be the behavior. I get the issue only when I keep CheckClassAdapter in front of my visitors. > MyClassAdapter adapter = new MyClassAdapter(new CheckClassAdapter(writer), className, classBeingRedefined); > > > > Also I found that, if I run the CheckClassAdapter(as below) after bytecode transformation I don't see any issue at all. > StringWriter checkClassSW = new StringWriter(); > PrintWriter checkClassPW = new PrintWriter(checkClassSW); > CheckClassAdapter.verify(reader, loader, dump, checkClassPW); > System.out.println(checkClassSW.toString()); > try > { > checkClassPW.close(); > checkClassSW.close(); > } > catch(Exception ex) > { > ex.printStackTrace(); > } > > > It looks like CheckClassAdaptor looks for some state and it finds visitLabel called before trycatchblock. However the same adaptor behaves differently :-( > > Also attaching the sources I used for testing. > > > Thanks, > Rajaraman > > > > > ---- On Sat, 29 Jan 2011 21:15:52 +0530 Tronje Krop <[email protected]> wrote ---- > > Hi Rajaraman, > > it is as the error says. You have instrumented the byte-code in a way > that at least one of the labels has been visited before defining the > try-catch-block. The CheckMethodAdapter checks this requirement and > throws the exception. > > If you are right with your claim, it seems that the VM-Verifier has a > relaxed condition which allows to define the try-catch-block using labels > have being visited before. > > I didn't find a rule in the VM-specification that prohibits this, but > I have not looked very close. Therefore, I think the CheckClassAdapter > may be to restrictive unless ASM has a problem with this relaxed > condition. > > I think we must investigate this issue closer. > > CU Tronje > > > Rajaraman Santhanam wrote: > > Hi, > > > > I get this exception if I put CheckClassAdapter in the visitors chain before ClassWriter. The code I use is below: > > ClassReader reader = new ClassReader(classfileBuffer); > > ClassWriter writer = new ClassWriter(reader, ClassWriter.COMPUTE_MAXS); > > > > > > BasicClassAdapter adapter = new BasicClassAdapter(new CheckClassAdapter(writer), className, classBeingRedefined); > > reader.accept(adapter, ClassReader.SKIP_DEBUG); > > > > By running this I get error with details: > > java.lang.IllegalStateException: Try catch blocks must be visited before their labels > > at org.objectweb.asm.util.CheckMethodAdapter.visitTryCatchBlock(CheckMethodAdapter.java:679) > > at org.objectweb.asm.MethodAdapter.visitTryCatchBlock(MethodAdapter.java:170) > > at test.agent.instrumentation.BasicMethodAdapter.visitMaxs(BasicMethodAdapter.java:86) > > > > However my instrumentation code work perfectly well if run this without CheckClassAdapter. Not sure what I'm missing here. > > > > > > I tried this when seeing the mail from Eugene to use CheckClassAdapter to catch various issues. > > > > > > My BasicClassAdapter is the implementation of FinallyAdapter from asm-transformations.pdf > > > > > > Can somebody help me out here? > > > > > > Regards, > > Rajaraman > > > > > > > > > > -- Tronje Krop <[email protected]> Encrypted eMail welcome! GPG/PGP-Key: 0x9AD43A05 68E5 A3D3 75A0 B096 AC75 62D5 8EEE 3D18 9AD4 3A05 No responsibility is taken for the correctness of the previous information. Please delete if you receive this mail unintentional.
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