jakarta-bcel-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Hovemeyer <dav...@cs.umd.edu>
Subject Repository problems, fixes
Date Wed, 30 Apr 2003 18:44:07 GMT
Hi all,

There are serious flaws in the current implementation of the Repository
classes and in all classes that look up classes at runtime.  The main
problem is that they do not have a consistent strategy for dealing
with lookup failures.  Some of methods (e.g.,
org.apache.bcel.Repository.lookupClass()) return null on such failures.
Some methods (e.g. org.apache.bcel.util.SyntheticRepository.loadClass())
throw ClassNotFoundException.  What is worse, there is lots of code
(org.apache.bcel.Repostory, the entire verifier) that simply blindly
assumes that all repository/classpath lookups will succeed.  This leads to
NullPointerExceptions in many cases.

I've submitted several bug reports describing some of these problems:
numbers 19068, 19122, 19476.

To fix these problems, I decided to change all methods which (either
directly or indirectly) perform repository lookups to throw
ClassNotFoundException.  There are two important benefits from
this change:

  - Users of the Repository may now safely assume that lookups
    will not return null.  This makes a significant amount of
    previously buggy code in org.apache.bcel.Repository correct.

  - Users of the Repository have a simple and consistent way of
    detecting lookup failures.

Of course, now users of the Repository have a new exception to deal
with.  I see this as an advantage.  It forces users to deal with the
fact that repository lookups can fail, and take approrpriate steps to
recover.  Because it's an exception, they don't have to clutter their
primary logic with error recovery.

I made a patch against the latest CVS code as of April 30 which implements
the changes I've described above.  It's available at

  http://www.cs.umd.edu/~pugh/java/bugs/bcel-30-April-2003.patch

It contains fixes for bug reports 19068, 19122, 19476, and 19014.

I would really like to see this incorporated into BCEL, because my
application makes significant use of the Repository, and these bugs are
causing a lot of problems for me.

Regards,
Dave

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


Mime
View raw message