[JENKINS-67011] bridge-method-injector creates questionable bytecode #34
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.
Problem
JENKINS-67011 reported two problems with
bridge-method-injector
:bridge-method-injector
unnecessarily modified the class header.bridge-method-injector
inserted a duplicate class entry forhudson/model/Node
.Evaluation
I could reproduce the former but not the latter running on Java 11 with latest bits. Looking into why the class header is being unnecessarily modified, it is because of commit 9cbb78f, itself a fix for JENKINS-22525. Ironically, that commit was a workaround for a problem to eliminate duplicate class entries in the constant pool. So the workaround is now creating the very problem it was meant to eliminate. Moreover, this workaround is unnecessary for two reasons:
Solution
Revert commit 9cbb78f. Not only is that commit not needed, but it exposes us to JENKINS-67011.
Testing done
I ran
mvn clean verify -Dtest=jenkins.bugs.BridgeMethodsTest
on Jenkins core with these changes, successfully.I compared the generated bytecode before and after this change. Before this change the entire class file was rewritten by ASM, including the class header. After this change the class remains identical to what
javac
produced with only the additions made bybridge-method-injector
, the original class header untouched. Thus if the original output ofjavac
does not contain duplicate constant pool entries (and it indeed does not as of Java 8 and the fix for JDK-5053846) then neither does the output ofbridge-method-injector
. Therefore JENKINS-67011 bug is fixed.