commons-bcel
commons-bcel copied to clipboard
Update ClassParser.java
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
instanceofchecks forZipInputStreamandJarInputStream. - Improved maintainability by eliminating unnecessary string operations.
- Added missing imports for
ZipInputStreamandJarInputStream.
Testing:
- Ran
mvn clean installsuccessfully. - Verified existing tests pass.
- No breaking changes observed.