Repository navigation
AnnotationFileParser: accept a stub record whose library type is a class - #2207
Merged
Merged
Conversation
A stub file written for a newer JDK declares a record where an older JDK has a class of the same name (JDK 21's Collectors.CollectorImpl, a class in JDK 8 to 17). processTypeDecl's CLASS case cast every nested declaration to ClassOrInterfaceDeclaration, so the RecordDeclaration threw a ClassCastException. It was reported as a stub parse problem and everything after the record in the enclosing class was lost; the binary-stub differential check showed this as a mismatch for Collectors.toList and Collectors.joining on JDK 8, 11, and 17 with the JDK 21 annotated JDK. Cast to TypeDeclaration instead, skip a component with no field in the class, and store a record stub only for a record element, as the binary stub files do. The jtreg test fails without the change. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
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.
With the
jdk-21annotated JDK (eisop/jdk#159), the binary-stub differential check failed on JDK 8, 11 and 17 (Collectors.toListandCollectors.joiningdiffered between binary and text).Cause. JDK 21's
Collectors.javadeclaresrecord CollectorImpl, which is a plain class in JDK 8-17. InAnnotationFileParser.processTypeDecl, theCLASScase cast every nested declaration toClassOrInterfaceDeclaration, so theRecordDeclarationthrew aClassCastException. It was reported as a stub parse problem and everything after the record in the enclosing class was lost. Swapping in the JDK 17Collectors.javamade the mismatch disappear.Fix.
TypeDeclaration.records[...]: in text but not in binary).Tests. New jtreg test
checker/jtreg/stubs/recordstubclass; it fails without the change (also on JDK 21, because only the library type being a class matters). With the jdk-21 annotated JDK:BinaryStubsCommandLineTest16/16 on JDK 8 and 21,NullnessBinaryStubDiffTeston JDK 8,:framework:test, and allstubsjtreg tests pass. JDK 11 and 17 are covered by CI only.