Repository navigation
Conversation
StringRepresentation reports every class file attribute that the verifier does not know, and its contract is that toString() never throws for a Node. It had no representation for the Module attribute of a module descriptor, for the ModulePackages and ModuleMainClass attributes, or for the ModuleExports, ModuleOpens, ModuleProvides and ModuleRequires entries, so verifying a module descriptor failed with an internal error: org.apache.bcel.verifier.exc.AssertionViolatedException: INTERNAL ERROR: Please adapt 'class org.apache.bcel.verifier.statics.StringRepresentation' to deal with objects of class 'class org.apache.bcel.classfile.Module'. Add the missing visit methods, following the pattern of the attribute types that are already handled. Pass 2 of the verifier now reports the Module attribute and rejects the module descriptor with the existing message about its missing superclass instead of throwing an internal error. Assisted-By: DeepSeek Harness (dsv41)
Comment on lines
+96
to
+98
| entries.addAll(Arrays.asList(module.getOpensTable())); | ||
| entries.addAll(Arrays.asList(module.getProvidesTable())); | ||
| assertFalse(entries.isEmpty(), "The module descriptor is expected to have entries"); |
Comment on lines
+108
to
+115
| final ConstantPool constantPool = constantPoolGen.getConstantPool(); | ||
| final ModulePackages modulePackages = new ModulePackages(constantPoolGen.addUtf8("ModulePackages"), 0, | ||
| new int[] {constantPoolGen.addClass("org.apache.commons.io.IOUtils")}, constantPool); | ||
| final ModuleMainClass moduleMainClass = new ModuleMainClass(constantPoolGen.addUtf8("ModuleMainClass"), 0, moduleInfo.getClassNameIndex(), | ||
| constantPool); | ||
| for (final Node node : Arrays.asList(modulePackages, moduleMainClass)) { | ||
| assertNotNull(new StringRepresentation(node).toString(), node.getClass().getName()); | ||
| } |
Member
|
@simpleqt |
garydgregory
added a commit
that referenced
this pull request
Nov 7, 2026
- Add visitors for module attributes and entries so verifier diagnostics no longer throw AssertionViolatedException for these nodes. - See PR #543
Member
|
Closing: Done with better tests in git master. Thank you for the PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

StringRepresentationhas no representation for the attributes of a module descriptor, so JustIce fails with an internal error instead of reporting them:Pass2Verifierreports every class attribute it does not know throughStringRepresentation(Pass2Verifier.java,visitJavaClass), and the contract ofStringRepresentationis thattoString()never throws for aNode("A (new StringRepresentation(Node n)).toString() never throws any exception",StringRepresentation.java). TheModuleattribute, theModulePackagesandModuleMainClassattributes, and theModuleExports,ModuleOpens,ModuleProvidesandModuleRequiresentries of a module descriptor were the remaining class file nodes without avisitmethod, so any module descriptor ended in that internal error.How
The missing
visitmethods are added, following the pattern of the attribute types that are already handled (tostring = toString(obj);):visitModule,visitModuleExports,visitModuleMainClass,visitModuleOpens,visitModulePackages,visitModuleProvides,visitModuleRequires.With this change
doPass2()on a module descriptor completes: theModuleattribute is reported as an attribute the verifier does not know and the class file is then rejected with the existing, accurate message "Superclass of 'module-info' missing but not java.lang.Object itself!" (a module descriptor has no superclass), instead of an internal error.Tests
src/test/java/org/apache/bcel/verifier/statics/StringRepresentationTest.javauses the existingsrc/test/resources/jpms/java17/commons-io/module-info.classfixture:Moduleattribute has a string representation that equals itstoString();requires,exports,opensandprovidesentries do too;ModulePackagesandModuleMainClassdo too (built on the fixture's constant pool);doPass2()on the module descriptor does not throw.Result with the fix:
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0. Without the fix (only the main source change reverted) the same four tests fail with 1 failure and 3 errors:Full build:
mvn test->Tests run: 3441, Failures: 0, Errors: 0, Skipped: 17,mvn checkstyle:check-> 0 violations.AI disclosure
The change was produced with the DeepSeek Harness (dsv41) coding agent: it found the failing path by running the verifier over a corpus of javac compiled class files and module descriptors, wrote the fix and the test, and ran the build. I reviewed the diff and the test results, and I am responsible for the contribution. The commit carries the
Assisted-By:trailer required bycommons-parent/AGENTS.md.