commons-bcel icon indicating copy to clipboard operation
commons-bcel copied to clipboard

Update ClassParser.java

Open jjestrada2 opened this issue 11 months ago • 3 comments

Refactored ClassParser to Use instanceof for ZIP/JAR Detection

Problem:

The previous implementation used getClass().getName() to detect if an InputStream was from a ZIP/JAR file. This approach relied on string matching, which was inefficient and prone to break if class names changed.

Solution:

  • Replaced reflection-based detection with instanceof checks for ZipInputStream and JarInputStream.
  • Improved maintainability by eliminating unnecessary string operations.
  • Added missing imports for ZipInputStream and JarInputStream.

Testing:

  • Ran mvn clean install successfully.
  • Verified existing tests pass.
  • No breaking changes observed.

jjestrada2 avatar Jan 31 '25 17:01 jjestrada2