Re: is this correct code?
Rémi Forax <[email protected]>
| Newsgroups | gmane.comp.java.objectweb.asm |
|---|---|
| Message-ID | <[email protected]> |
Le 09/12/2010 11:54, Jochen Theodorou a écrit : > Hi all, > > I am currently trying to find an bytecode problem in a strange > situation. The code is fine if verified and normally run, but fails if > debugged in IntelliJ with: > > java.lang.VerifyError: (class: > org/codehaus/groovy/ast/builder/AstBuilderTransformation, method: > <clinit> signature: ()V) Attempt to split long or double on the stack > > No clinit looks like this: > >> static <clinit>()V >> LDC 0 >> INVOKESTATIC >> org/codehaus/groovy/runtime/typehandling/DefaultTypeTransformation.box (J)Ljava/lang/Object; >> >> CHECKCAST java/lang/Long >> ASTORE 0 >> ALOAD 0 >> INVOKESTATIC >> org/codehaus/groovy/runtime/typehandling/DefaultTypeTransformation.longUnbox >> (Ljava/lang/Object;)J >> PUTSTATIC >> org/codehaus/groovy/ast/builder/AstBuilderTransformation.__timeStamp__239_neverHappen1291891067850 >> : J >> ALOAD 0 >> POP >> LDC 1291891067849 >> INVOKESTATIC >> org/codehaus/groovy/runtime/typehandling/DefaultTypeTransformation.box (J)Ljava/lang/Object; >> >> CHECKCAST java/lang/Long >> ASTORE 1 >> ALOAD 1 >> INVOKESTATIC >> org/codehaus/groovy/runtime/typehandling/DefaultTypeTransformation.longUnbox >> (Ljava/lang/Object;)J >> PUTSTATIC >> org/codehaus/groovy/ast/builder/AstBuilderTransformation.__timeStamp : J >> ALOAD 1 >> POP >> RETURN >> RETURN >> NOP >> MAXSTACK = 2 >> MAXLOCALS = 2 > > And I see two potential problems. > > First there is the LDC 1291891067849, which should produce an int or > long? I quite never understood how a constant can be long and int at > the same time here. Anyway, next is a method call that takes an long > and we may or may not have one. Now I know that there is actually no > way to represent a real long constant over 1l, so this is probably > right and what the java compiler would have done as well. > > But before that there is also a LDC 0 followed by a box call that > takes a long. This is the only place I can imagine could cause a > problem. And I recently had the case that I did "LDC 0; LSTORE 5" and > the verifier complained... sometimes. I could fix it there by instead > having "LCONST_0; LSTORE 5". > > Now I am wondering about some things: > (1) why is it valid to use LDC one time and at another not? > (2) if it is not valid, why is it sometimes a VerifyError and > sometimes not? > (3) shouldn't asm do a strict check here (I am using asm 3.2) and > point this out as error? > > bye blackdrag > Hi Jochen, ASM doesn't print if it's a LDC with a long or with an int (perhaps it should), but in the constant pool the constant storing a long is different from the one storing an int so there is no problem here. I think the problem is at the end of your dump, RETURN RETURN NOP is a weird sequence, while if think it's a valid one from the verifier point of view, it seems that it disturb IntellJ. Rémi
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