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 Hovemeyer <da...@cs.umd.edu> on 2003/04/30 20:44:07 UTC

Repository problems, fixes

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-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bcel-dev-help@jakarta.apache.org