Re: Potential Software Failure
Markus Dahm <[email protected]>
| Newsgroups | gmane.comp.jakarta.bcel.devel |
|---|---|
| Message-ID | <[email protected]> |
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 <[email protected]> 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