jakarta-bcel-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter Schneider" <schne...@lathanda.de>
Subject RE: Verifies chokes
Date Mon, 23 Sep 2002 19:12:59 GMT
Hi

[...]
Some code i don't like to read
[...]
> and I try to execute Target, I get a message 
> 
>    Exception in thread "main" java.lang.VerifyError: (class: 
> com/cisco/nm/tools/transposer/Target, method: m1 signature: 
> ()V) Illegal use of nonvirtual function call

[...] 
>      11 astore_0
>      12 aload_0
>      13 invokespecial #49 <Method void printStackTrace()>
>      16 getstatic #2 <Field java.io.PrintStream out>
>      19 ldc #6 <String "def">
>      21 invokevirtual #4 <Method void println(java.lang.String)>
>      24 getstatic #2 <Field java.io.PrintStream out>
>      27 ldc #7 <String "abc">
>      29 invokevirtual #4 <Method void println(java.lang.String)>
>      32 return
>    Exception table:
>       from   to  target type
>         0     8    11   <Class java.lang.Exception>
> 
>    Method void main(java.lang.String[])
>       0 invokestatic #8 <Method void m1()>
>       3 return
> 
> I'm clearly missing something -- but what is it?
You can't use invokespecial for printStackTrace,
it's only legit for static final or private methods.
btw it's no good idea to use local 0 to store the exception better use
dup

insert before the first instruction of any exception handler
DUP
INVOKEVIRTUAL Throwable.printStackTrace
and everything should be fine
if you need to avoid double stack traces you are in trouble.
I'm not sure if it's even possible.





--
To unsubscribe, e-mail:   <mailto:bcel-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:bcel-user-help@jakarta.apache.org>


Mime
View raw message