Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8254784: javac should reject records with @SafeVarargs applied to varargs record component #690



Copy link

@vicente-romero-oracle vicente-romero-oracle commented Oct 16, 2020

Please review this fix for issue [1]. This is the background, for a record defined like:

record R(@SafeVarargs String... s) {}

an the following accessor will be generated:

`@SafeVararags public String[] s() { return s; }`

this code is incorrect as the accessor is not a varargs method. But still the compiler is not generating a compiler error. The reason for this is that the method defining the accessor is not generated until the compiler get to its backend phase (at Lower to be more specific) and the check for incorrect @SafeVarargs use in the compiler happen before that, in Attr.

We decided to do not generate record related code until late phases in order to avoid generating code in the compiler frontend and because if code is generated in early stages then APs could see ASTs not created from user defined code.

The proposed fix is to issue an error as soon as the compiler finds out that the @SafeVarargs annotation is applied to a compiler generated accessor because in other case the compiler would be forced to generate incorrect code.

TIA for the reviews,



  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed


Linux x64 Linux x86 Windows x64 macOS x64
Build ✔️ (5/5 passed) ✔️ (2/2 passed) ✔️ (2/2 passed) ✔️ (2/2 passed)
Test (tier1) ❌ (1/9 failed) ❌ (1/9 failed) ❌ (1/9 failed) ❌ (1/9 failed)

Failed test tasks




$ git fetch pull/690/head:pull/690
$ git checkout pull/690

Copy link

bridgekeeper bot commented Oct 16, 2020

👋 Welcome back vromero! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Pull request is ready for review label Oct 16, 2020
Copy link

openjdk bot commented Oct 16, 2020

@vicente-romero-oracle The following label will be automatically applied to this pull request:

  • compiler

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the compiler label Oct 16, 2020
Copy link

mlbridge bot commented Oct 16, 2020


Copy link

@mcimadamore mcimadamore left a comment

Choose a reason for hiding this comment

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

Seems sensible. A possible alternative would be to err immediately when we see (e.g. in TypeEnter?) that a record header contains a SafeVarargs annotation, in which case we know we can't support it.

Copy link

openjdk bot commented Nov 13, 2020

@vicente-romero-oracle This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file for details.

After integration, the commit message for the final commit will be:

8254784: javac should reject records with @SafeVarargs applied to varargs record component

Reviewed-by: mcimadamore

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 105 new commits pushed to the master branch:

  • e9956fe: 8256127: Add cross-compiled foreign architectures builds to submit workflow
  • c8dd0b5: 8256320: ZGC: Update zDebug to support UseCompressedClassPointers
  • 5973e91: 8253005: Add @throws IOException in javadoc for HttpEchange.sendResponseHeaders
  • 8c31bd2: 8256275: Optimized build is broken
  • b0c28fa: 8256011: Shenandoah: Don't resurrect finalizably reachable objects
  • 41139e3: 8255964: Add all details to jstack log in jtreg timeout handler
  • b4d0186: 8253525: Implement getInstanceSize/sizeOf intrinsics
  • ea576dd: 8254887: C2: assert(cl->trip_count() > 0) failed: peeling a fully unrolled loop
  • 05b8245: 8256290: javac/lambda/ fails with StackOverflowError on x86_32
  • c3139ab: 8256220: C1: x86_32 fails with -XX:UseSSE=1 after JDK-8210764 due to mishandled lir_neg
  • ... and 95 more:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Nov 13, 2020
Copy link
Contributor Author

thanks for the approval, yes we could have done what you are proposing too

Copy link
Contributor Author


@openjdk openjdk bot closed this Dec 7, 2020
@openjdk openjdk bot added integrated Pull request has been integrated and removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Dec 7, 2020
Copy link

openjdk bot commented Dec 7, 2020

@vicente-romero-oracle Since your change was applied there have been 498 commits pushed to the master branch:

  • dcf63f8: 8257788: Class fields could be local in the SunJSSE provider
  • d29c78d: 8257679: Improved unix compatibility layer in Windows build (winenv)
  • 74be819: 8257517: LogCompilation: Add -z to the help messages
  • 2c04fc0: 8257037: No javac warning when calling deprecated constructor with diamond
  • 46b35ac: 8257798: [PPC64] undefined reference to Klass::vtable_start_offset()
  • ecd7e47: 8257793: Shenandoah: SATB barrier should only filter out already strongly marked oops
  • e08b9ed: 8257820: Remove gc/ergonomics/ as it is too brittle
  • 637b0c6: 8246778: Compiler implementation for Sealed Classes (Second Preview)
  • 09707dd: 8252807: The jdk.jfr.Recording.getStream does not work when toDisk is disabled
  • 04ce8e3: 8257184: Upstream 8252504: Add a method to MemoryLayout which returns a offset-computing method handle
  • ... and 488 more:

Your commit was automatically rebased without conflicts.

Pushed as commit b4b9828.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@vicente-romero-oracle vicente-romero-oracle deleted the JDK-8254784 branch December 7, 2020 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
compiler integrated Pull request has been integrated
2 participants