Re: Inconsistence in calculated stack map info
| Newsgroups | gmane.comp.java.objectweb.asm |
|---|---|
| Message-ID | <2024903812.2505411282906978563.JavaMail.root@zimbra7-e1.priv.proxad.net> |
[email protected] wrote: > Hello, > > I have a question about calculated frames information. It seems to be an issue, > but I didn't file a bug yet to discuss it here at first. > Consider the following sample: > Object [] arr = new String[5]; > try { > arr[0] = new Object(); > } catch (ArrayStoreException e) { > > } > The question is how this array local variable should be referenced in > StackMapTable? this program compiles but gives an exception at runtime. 'arr' can never contain objects that are not instances of String. So I think the ASM behavior is fine. > My understanding is that it should be "[Ljava/lang/Object;". If we compile the > sample with Java 6 we get exactly as expected (javap output): the compiler generates the StackMapTable from the Java sources, using the declared type of the local variable. In bytecode this declared type is lost, we can only rely on the 'new' instruction to find the type of 'arr' (the LocalVariableTable may not be present). The important point is that the StackMapTable produced by ASM is accepted by the JVM verifier. So this table is valid, even if it is not the same as the one produced by a compiler. > I'm not quite sure whether this behavior is expected or nor. > But it's an issue for us because we can't get the declared local type for this > array during instrumentation. Is it possible to do something here with asm? I > understand that it's not so easy to resolve this inconsistency, but it would be > great to have this issue fixed. you have the same "problem" with the following example: Object a = new String(); try { System.out.println(a); } catch (RuntimeException e) { } more generally, you can't expect to always be able to recover the exact Java types declared in source code from the bytecode, unless using LocalVariableTable (which is optional). Eric
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