jakarta-bcel-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Max Spring" <mspr...@cisco.com>
Subject Re: Verifies chokes
Date Mon, 23 Sep 2002 20:23:23 GMT
> Mailing-List: contact bcel-user-help@jakarta.apache.org; run by ezmlm
> List-Unsubscribe: <mailto:bcel-user-unsubscribe@jakarta.apache.org>
> List-Subscribe: <mailto:bcel-user-subscribe@jakarta.apache.org>
> List-Help: <mailto:bcel-user-help@jakarta.apache.org>
> List-Post: <mailto:bcel-user@jakarta.apache.org>
> List-Id: "BCEL Users List" <bcel-user.jakarta.apache.org>
> X-Antivirus: nagoya (v4218 created Aug 14 2002)
> From: "Peter Schneider" <schneidp@lathanda.de>
> Date: Mon, 23 Sep 2002 21:12:59 +0200
> X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N
> 
> 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

I didn't "generate" the usage of local 0.  That was the Java compiler.

> 
> insert before the first instruction of any exception handler
> DUP

Initially, I tried that.  But then I was unable to make the handlerPC of the
corresponding exception point to this new pre-prended instruction.

So, I went with the pattern

     astore X
INS> aload X
INS> invokevirtual printStackTrace
     ...

observing that any catch statement seems to start with an astore.

> INVOKEVIRTUAL Throwable.printStackTrace
> and everything should be fine
> if you need to avoid double stack traces you are in trouble.

Double stacktrace wouldn't be a problem.  I'm just doing a throw-away tool.

-Max


> 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>


--
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