Skip to content

AnnotationFileParser: accept a stub record whose library type is a class - #2207

Merged
wmdietl merged 1 commit into
masterfrom
fix-binary-stub-record-nested
Oct 2, 2026
Merged

wmdietl merged 1 commit into
masterfrom
fix-binary-stub-record-nested

Conversation

@wmdietl

@wmdietl wmdietl commented Oct 2, 2026

Copy link
Copy Markdown
Member

With the jdk-21 annotated JDK (eisop/jdk#159), the binary-stub differential check failed on JDK 8, 11 and 17 (Collectors.toList and Collectors.joining differed between binary and text).

Cause. JDK 21's Collectors.java declares record CollectorImpl, which is a plain class in JDK 8-17. In AnnotationFileParser.processTypeDecl, the 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. Swapping in the JDK 17 Collectors.java made the mismatch disappear.

Fix.

  • Cast to TypeDeclaration.
  • Skip a record component that has no field in the class.
  • Store a record stub only for a record element, as the binary stub files do (otherwise the differential check reports 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: BinaryStubsCommandLineTest 16/16 on JDK 8 and 21, NullnessBinaryStubDiffTest on JDK 8, :framework:test, and all stubs jtreg tests pass. JDK 11 and 17 are covered by CI only.

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]>
Copilot AI balanced review requested due to automatic review settings October 2, 2026 20:25

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@wmdietl
wmdietl merged commit 0b3fa1b into master Oct 2, 2026
48 checks passed
@wmdietl
wmdietl deleted the fix-binary-stub-record-nested branch October 2, 2026 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants