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

ClassParser.parse() throws NullPointerException if class does not exist and ClassParser(String) constructor is used

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 6.0
    • Main
    • None

    Description

      Reproduce:

      ClassParser cp = new ClassParser("does/not/exist/Classfile.class");
      JavaClass jc = cp.parse();
      --> throws NullPointerException instead of FileNotFoundException

      The problem is that when the constructor that accepts a string is used, the
      fileOwned flag is set and parse() attempts to close the file in the finally
      block. The guarded region for the finally block includes the attempt to open the
      input stream, which may fail, but the finally block itself erroneously assumes
      the input stream object has been created.

      Previously this situation caused the method to correctly throw a
      FileNotFoundException.

      Attachments

        1. ClassParser.patch
          0.5 kB
          Alex Kinneer

        Activity

          People

            issues@commons.apache.org Apache Commons Developers
            alkinneer@hotmail.com Alex Kinneer
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: