Uploaded image for project: 'Commons BCEL'
  1. Commons BCEL
  2. BCEL-22

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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 5.2
    • Main
    • None
    • Operating System: other
      Platform: All

    Description

      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.

      Attachments

        Activity

          People

            issues@commons.apache.org Apache Commons Developers
            daveho@cs.umd.edu David Hovemeyer
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: