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 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.