Repository navigation
Conversation
- Stop skipping the rest of a class when a method's only bridges are in a subclass. The method itself is now still checked for a super method. - Don't add @OverRide to clone() or finalize() in interfaces unless a superinterface declares them. Interfaces don't inherit Object's non-public methods, so javac rejects the annotation (JLS 9.6.4.4). - Don't add @OverRide to synthetic methods, as they aren't declared in source.
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.
Fixes three bugs in
OverrideAnnotationAdder, with regression tests inFixJarPageTest.Fixes
Early
returnskipped the rest of the class. If a method's synthetic sources were all in other classes, the adder exited the whole class. This happens when a subclass inherits the method to implement a generic interface, which makes javac generate a bridge in the subclass:continuewouldn't be enough, becauseBase#mstill has its own super method. The adder now checkssuperMethod()first, then any bridges in the same class.@Overrideon interfaceclone()andfinalize(). Hypo treatsObjectas the superclass of interfaces, so these methods got a super method. Interfaces don't inheritObject's non-public methods, and javac rejects the annotation (JLS 9.2, 9.6.4.4). It's still added when a superinterface declares the method.@Overrideon synthetic methods. Bridges were annotated even though they aren't declared in source. Synthetic methods are now skipped.Output impact
@OverridebeforeThe
returnand interface fixes don't change the output of these two jars, as neither pattern occurs in them.Notes
superMethod()only matches exact descriptors, but no signature matching was added. javac 8, 9, 11, 16, 17, 21, 25 and 27 all emit bridges for abstract and default interface redeclarations, abstract class redeclarations, covariant returns and bounded generics, so the bridge lookup already finds them. The tests cover these cases.BridgeMethodHydratortreats any synthetic forwarding method as a bridge, even withoutACC_BRIDGE. This affects 950 methods on the obfuscated 1.21.11-pre1 server jar and none on the two jars above, so it's left alone here.Testing
./gradlew checkpasses.