You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bcel-dev@jakarta.apache.org by David Dixon-Peugh <di...@yahoo.com> on 2002/07/22 23:02:14 UTC
Potential Software Failure
I have found what I believe to be a bug in BCEL,
and would like to see if anyone else has seen
this in the wild.
Basically, I'm generating code that looks like this:
ACONST_NULL
ICONST( 0 )
INVOKEVIRTUAL ( runTest(I)I )
ICONST( 0 )
IRETURN
[catch NullPointerException]
ICONST( 0 )
IRETURN
The idea is to force a NullPointerException to be
raised, and then catch it with a Catch clause.
This is being done in a MethodGen object, using
"addExceptionHandler(...)" to create the
CodeExceptionGen inside the MethodGen. (Adding a
CodeExceptionGen is a good idea. We should be able
to do that directly.)
When the MethodGen.getMethod() is called, if you take
a look at the "getExceptionTable()" result, you
basically get nothing. (Catch table wasn't written
to Method.)
I presume this is a bug, if I'm doing something wrong
let me know.
DDP
__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Potential Software Failure
Posted by Markus Dahm <ma...@berlin.de>.
Hi,
the program works fine for me (I slightly modified it to work
without JUnit). I dump the code to a file to see what's
generated and for the testCatch it looks like
public int runTest(int x)
Code(max_stack = 2, max_locals = 2, code_length = 11)
0: aconst_null
1: iconst_0
2: invokevirtual test.Catch.runTest (I)I (10)
5: pop
6: iconst_1
7: ireturn
8: pop
9: iconst_1
10: ireturn
Exception handler(s) =
From To Handler Type
0 8 8 java.lang.NullPointerException(22)
BTW: I enhanced the code to use clazz.addEmptyConstructor(), but
that shouldn't make a difference.
When I run the program the output is
java CodeExceptionGenTest
true
NullPointerException thrown as expected
java.lang.NullPointerException
at test.NoCatch.runTest(test/NoCatch.java)
at CodeExceptionGenTest.testNoCatch(CodeExceptionGenTest.java:170)
at CodeExceptionGenTest.main(CodeExceptionGenTest.java:145)
Cheers
Markus
Re: Potential Software Failure
Posted by David Dixon-Peugh <di...@yahoo.com>.
Hmmm. I've attached a Unit test which does what
I was doing before, and the test seems to work.
I'll have to take a closer look at what I have and
see how it is different.
As for the tests, I would like to check them into
BCEL, but since we don't have any standards yet, I
would recommend we come up with some.
Any suggestions? (Or we can just go with Maven's
suggestions.)
DDP
--- Markus Dahm <ma...@berlin.de> wrote:
> The code looks ok, it should work this way, yet
> without an
> example I can't verify. Check your back up drives
> ... ;-)
>
> Cheers
> Markus
>
> David Dixon-Peugh wrote:
>
> > I don't have the file which has the problem here
> > (forgot to check it into CVS yesterday.)
> >
> > The code that it generates is exactly like I said
> > before. (Written so as not to be confusing about
> > the catch block. Positions made up.)
> >
> >
> > 0 ACONST_NULL
> > 1 ICONST( 0 )
> > 2 INVOKEVIRTUAL ( runTest(I)I )
> > 3 ICONST( 0 )
> > 4 IRETURN
> > 5 ICONST( 0 )
> > 6 IRETURN
> >
> > CATCH: From 0
> > To 4
> > Handler 5
> > Exc java.lang.NullPointerException
> >
> > The catch block is on the InstructionList, so
> > that isn't the problem.
> >
> > The code is supposed to do the following:
> > Call "runTest(I)I" on NULL.
> > Catch the NullPointerException.
> > Return 0 from the handler.
> >
> > It definitely throws the NPE, and it never
> > gets caught. (Once again, looking at the Method
> > that was generated, it didn't have any catch
> tables.)
> >
> > DDP
> >
> >
> > --- Markus Dahm <ma...@berlin.de> wrote:
> >
> >>David Dixon-Peugh wrote:
> >>
> >>
> >>>I have found what I believe to be a bug in BCEL,
> >>>and would like to see if anyone else has seen
> >>>this in the wild.
> >>>
> >>>Basically, I'm generating code that looks like
> >>>
> >>this:
> >>
> >>> ACONST_NULL
> >>> ICONST( 0 )
> >>> INVOKEVIRTUAL ( runTest(I)I )
> >>> ICONST( 0 )
> >>> IRETURN
> >>>[catch NullPointerException]
> >>> ICONST( 0 )
> >>> IRETURN
> >>>
> >>>The idea is to force a NullPointerException to be
> >>>raised, and then catch it with a Catch clause.
> >>>
> >>>This is being done in a MethodGen object, using
> >>>"addExceptionHandler(...)" to create the
> >>>CodeExceptionGen inside the MethodGen. (Adding a
> >>>CodeExceptionGen is a good idea. We should be
>
>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com
Re: Potential Software Failure
Posted by David Dixon-Peugh <di...@yahoo.com>.
My original is on my work computer, but I'll crank
out a JUnit test which checks for it. (Which can
be checked into BCEL when we are done.)
--- Markus Dahm <ma...@berlin.de> wrote:
> The code looks ok, it should work this way, yet
> without an
> example I can't verify. Check your back up drives
> ... ;-)
>
> Cheers
> Markus
>
> David Dixon-Peugh wrote:
>
> > I don't have the file which has the problem here
> > (forgot to check it into CVS yesterday.)
> >
> > The code that it generates is exactly like I said
> > before. (Written so as not to be confusing about
> > the catch block. Positions made up.)
> >
> >
> > 0 ACONST_NULL
> > 1 ICONST( 0 )
> > 2 INVOKEVIRTUAL ( runTest(I)I )
> > 3 ICONST( 0 )
> > 4 IRETURN
> > 5 ICONST( 0 )
> > 6 IRETURN
> >
> > CATCH: From 0
> > To 4
> > Handler 5
> > Exc java.lang.NullPointerException
> >
> > The catch block is on the InstructionList, so
> > that isn't the problem.
> >
> > The code is supposed to do the following:
> > Call "runTest(I)I" on NULL.
> > Catch the NullPointerException.
> > Return 0 from the handler.
> >
> > It definitely throws the NPE, and it never
> > gets caught. (Once again, looking at the Method
> > that was generated, it didn't have any catch
> tables.)
> >
> > DDP
> >
> >
> > --- Markus Dahm <ma...@berlin.de> wrote:
> >
> >>David Dixon-Peugh wrote:
> >>
> >>
> >>>I have found what I believe to be a bug in BCEL,
> >>>and would like to see if anyone else has seen
> >>>this in the wild.
> >>>
> >>>Basically, I'm generating code that looks like
> >>>
> >>this:
> >>
> >>> ACONST_NULL
> >>> ICONST( 0 )
> >>> INVOKEVIRTUAL ( runTest(I)I )
> >>> ICONST( 0 )
> >>> IRETURN
> >>>[catch NullPointerException]
> >>> ICONST( 0 )
> >>> IRETURN
> >>>
> >>>The idea is to force a NullPointerException to be
> >>>raised, and then catch it with a Catch clause.
> >>>
> >>>This is being done in a MethodGen object, using
> >>>"addExceptionHandler(...)" to create the
> >>>CodeExceptionGen inside the MethodGen. (Adding a
> >>>CodeExceptionGen is a good idea. We should be
>
>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Potential Software Failure
Posted by Markus Dahm <ma...@berlin.de>.
The code looks ok, it should work this way, yet without an
example I can't verify. Check your back up drives ... ;-)
Cheers
Markus
David Dixon-Peugh wrote:
> I don't have the file which has the problem here
> (forgot to check it into CVS yesterday.)
>
> The code that it generates is exactly like I said
> before. (Written so as not to be confusing about
> the catch block. Positions made up.)
>
>
> 0 ACONST_NULL
> 1 ICONST( 0 )
> 2 INVOKEVIRTUAL ( runTest(I)I )
> 3 ICONST( 0 )
> 4 IRETURN
> 5 ICONST( 0 )
> 6 IRETURN
>
> CATCH: From 0
> To 4
> Handler 5
> Exc java.lang.NullPointerException
>
> The catch block is on the InstructionList, so
> that isn't the problem.
>
> The code is supposed to do the following:
> Call "runTest(I)I" on NULL.
> Catch the NullPointerException.
> Return 0 from the handler.
>
> It definitely throws the NPE, and it never
> gets caught. (Once again, looking at the Method
> that was generated, it didn't have any catch tables.)
>
> DDP
>
>
> --- Markus Dahm <ma...@berlin.de> wrote:
>
>>David Dixon-Peugh wrote:
>>
>>
>>>I have found what I believe to be a bug in BCEL,
>>>and would like to see if anyone else has seen
>>>this in the wild.
>>>
>>>Basically, I'm generating code that looks like
>>>
>>this:
>>
>>> ACONST_NULL
>>> ICONST( 0 )
>>> INVOKEVIRTUAL ( runTest(I)I )
>>> ICONST( 0 )
>>> IRETURN
>>>[catch NullPointerException]
>>> ICONST( 0 )
>>> IRETURN
>>>
>>>The idea is to force a NullPointerException to be
>>>raised, and then catch it with a Catch clause.
>>>
>>>This is being done in a MethodGen object, using
>>>"addExceptionHandler(...)" to create the
>>>CodeExceptionGen inside the MethodGen. (Adding a
>>>CodeExceptionGen is a good idea. We should be
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Potential Software Failure
Posted by David Dixon-Peugh <di...@yahoo.com>.
I don't have the file which has the problem here
(forgot to check it into CVS yesterday.)
The code that it generates is exactly like I said
before. (Written so as not to be confusing about
the catch block. Positions made up.)
0 ACONST_NULL
1 ICONST( 0 )
2 INVOKEVIRTUAL ( runTest(I)I )
3 ICONST( 0 )
4 IRETURN
5 ICONST( 0 )
6 IRETURN
CATCH: From 0
To 4
Handler 5
Exc java.lang.NullPointerException
The catch block is on the InstructionList, so
that isn't the problem.
The code is supposed to do the following:
Call "runTest(I)I" on NULL.
Catch the NullPointerException.
Return 0 from the handler.
It definitely throws the NPE, and it never
gets caught. (Once again, looking at the Method
that was generated, it didn't have any catch tables.)
DDP
--- Markus Dahm <ma...@berlin.de> wrote:
> David Dixon-Peugh wrote:
>
> > I have found what I believe to be a bug in BCEL,
> > and would like to see if anyone else has seen
> > this in the wild.
> >
> > Basically, I'm generating code that looks like
> this:
> > ACONST_NULL
> > ICONST( 0 )
> > INVOKEVIRTUAL ( runTest(I)I )
> > ICONST( 0 )
> > IRETURN
> > [catch NullPointerException]
> > ICONST( 0 )
> > IRETURN
> >
> > The idea is to force a NullPointerException to be
> > raised, and then catch it with a Catch clause.
> >
> > This is being done in a MethodGen object, using
> > "addExceptionHandler(...)" to create the
> > CodeExceptionGen inside the MethodGen. (Adding a
> > CodeExceptionGen is a good idea. We should be
> able
> > to do that directly.)
>
>
> Hmm. Maybe :)
>
>
> > When the MethodGen.getMethod() is called, if you
> take
> > a look at the "getExceptionTable()" result, you
> > basically get nothing. (Catch table wasn't
> written
> > to Method.)
>
>
> Where is the code of the exception handler, i.e,
> have you short example of your code.
>
> Cheers
> Markus
>
>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Potential Software Failure
Posted by Markus Dahm <ma...@berlin.de>.
David Dixon-Peugh wrote:
> I have found what I believe to be a bug in BCEL,
> and would like to see if anyone else has seen
> this in the wild.
>
> Basically, I'm generating code that looks like this:
> ACONST_NULL
> ICONST( 0 )
> INVOKEVIRTUAL ( runTest(I)I )
> ICONST( 0 )
> IRETURN
> [catch NullPointerException]
> ICONST( 0 )
> IRETURN
>
> The idea is to force a NullPointerException to be
> raised, and then catch it with a Catch clause.
>
> This is being done in a MethodGen object, using
> "addExceptionHandler(...)" to create the
> CodeExceptionGen inside the MethodGen. (Adding a
> CodeExceptionGen is a good idea. We should be able
> to do that directly.)
Hmm. Maybe :)
> When the MethodGen.getMethod() is called, if you take
> a look at the "getExceptionTable()" result, you
> basically get nothing. (Catch table wasn't written
> to Method.)
Where is the code of the exception handler, i.e,
have you short example of your code.
Cheers
Markus
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Potential Software Failure
Posted by Juozas Baliuka <ba...@centras.lt>.
Hi,
It is not a bug, exception handler has no code, code must be in method
instruction list.
Exeption handler has only indexes on stack and exception type.
> I have found what I believe to be a bug in BCEL,
> and would like to see if anyone else has seen
> this in the wild.
>
> Basically, I'm generating code that looks like this:
> ACONST_NULL
> ICONST( 0 )
> INVOKEVIRTUAL ( runTest(I)I )
> ICONST( 0 )
> IRETURN
> [catch NullPointerException]
> ICONST( 0 )
> IRETURN
>
> The idea is to force a NullPointerException to be
> raised, and then catch it with a Catch clause.
>
> This is being done in a MethodGen object, using
> "addExceptionHandler(...)" to create the
> CodeExceptionGen inside the MethodGen. (Adding a
> CodeExceptionGen is a good idea. We should be able
> to do that directly.)
>
> When the MethodGen.getMethod() is called, if you take
> a look at the "getExceptionTable()" result, you
> basically get nothing. (Catch table wasn't written
> to Method.)
>
> I presume this is a bug, if I'm doing something wrong
> let me know.
>
> DDP
>
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Health - Feel better, live better
> http://health.yahoo.com
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>