DO NOT REPLY [Bug 19068] New: - JavaClass.getAllInterfaces() can throw NullPointerException when classpath is incomplete

[email protected]
Newsgroups gmane.comp.jakarta.bcel.devel
Message-ID <[email protected]>
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19068>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19068

JavaClass.getAllInterfaces() can throw NullPointerException when classpath is incomplete

           Summary: JavaClass.getAllInterfaces() can throw
                    NullPointerException when classpath is incomplete
           Product: BCEL
           Version: unspecified
          Platform: All
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Main
        AssignedTo: [email protected]
        ReportedBy: [email protected]


This bug affects revision 1.13 of JavaClass.java.

The org.apache.bcel.classfile.JavaClass.getAllInterfaces() method calls
JavaClass.getInterfaces(), which uses a Repository to look up the class's
interfaces.  If any of the interfaces are not found, then getInterfaces()
returns null.  However, getAllInterfaces() tries to dereference this null
reference, leading to the exception.

A simple fix would be to return a zero-length array from getInterfaces() in the
case where a repository lookup fails.

A better fix would be to have getInterfaces() throw the ClassNotFoundException
out of the method.  In general, I think repository lookup failures should be
propagated as much as possible, so the program using BCEL can detect them. 
Right now there is a println() to System.err in getInterfaces(), which is not a
very useful way to report the failure.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.