Skip to content

8332600: javac uses record components source position during compilation #20148

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

Closed

Conversation

vicente-romero-oracle
Copy link
Contributor

@vicente-romero-oracle vicente-romero-oracle commented Jul 11, 2024

javac uses the source position of record components to find and later probably remove a given record component during compilation. This could be necessary if annotation processors are present. This is done in part to provide better error messages for silly record definitions like:

record R(int i, float i) {} // two record components with the same name

but this is brittle and can backfire if the record is read from a class file as the source positions are not stored there. See JDK-8332297 for some context

The idea of this fix is not to use the source position but only the name to find a given record component. This could imply that if the user defines an erroneous record like the one above, then the record could end up with less record components than expected but records like this wouldn't compile anyway

TIA


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Warning

 ⚠️ Found leading lowercase letter in issue title for 8332600: javac uses record components source position during compilation

Issue

  • JDK-8332600: javac uses record components source position during compilation (Bug - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/20148/head:pull/20148
$ git checkout pull/20148

Update a local copy of the PR:
$ git checkout pull/20148
$ git pull https://git.openjdk.org/jdk.git pull/20148/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 20148

View PR using the GUI difftool:
$ git pr show -t 20148

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/20148.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jul 11, 2024

👋 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
Copy link

openjdk bot commented Jul 11, 2024

@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 CONTRIBUTING.md for details.

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

8332600: javac uses record components source position during compilation

Reviewed-by: jlahoda

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 77 new commits pushed to the master branch:

  • 4a73ed4: 8330144: Revise os::free_memory()
  • 35df48e: 8335860: compiler/vectorization/TestFloat16VectorConvChain.java fails with non-standard AVX/SSE settings
  • 7bf5313: 8335480: Only deoptimize threads if needed when closing shared arena
  • 1b83bd9: 8336661: Parallel: Remove stacks_empty assert in PSScavenge::invoke
  • 72297d2: 8317720: RISC-V: Implement Adler32 intrinsic
  • 21a6cf8: 8336587: failure_handler lldb command times out on macosx-aarch64 core file
  • 78cc0f9: 8336091: Fix HTML warnings in the generated HTML files
  • bcb5e69: 8335921: Fix HotSpot VM build without JVMTI
  • 10186ff: 8336300: DateFormatSymbols#getInstanceRef returns non-cached instance
  • 7ec55df: 8336638: Parallel: Remove redundant mangle in PSScavenge::invoke
  • ... and 67 more: https://git.openjdk.org/jdk/compare/5c612c230b0a852aed5fd36e58b82ebf2e1838af...master

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 rfr Pull request is ready for review label Jul 11, 2024
@openjdk
Copy link

openjdk bot commented Jul 11, 2024

@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 compiler-dev@openjdk.org label Jul 11, 2024
@mlbridge
Copy link

mlbridge bot commented Jul 11, 2024

Webrevs

@@ -1139,7 +1139,8 @@ public void visitMethodDef(JCMethodDecl tree) {
for (JCVariableDecl param: tree.params) {
boolean paramIsVarArgs = (param.sym.flags_field & VARARGS) != 0;
if (!types.isSameType(param.type, recordFieldTypes.head) ||
(recordComponents.head.isVarargs() != paramIsVarArgs)) {
(recordComponents.head != null &&
Copy link
Contributor

Choose a reason for hiding this comment

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

I am afraid recordComponents.head != null (which is basically recordComponents.isEmpty(), I think) is probably insufficient here. Consider e.g.:

record R(int x, int x, int x) {}

which will fail as recordComponents itself will be null, due to tail being null.

Looking at the last record component (.last()) might be one of the solutions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have changed the code a bit, I think it make more sense now, thanks for the comments

Copy link
Contributor

@lahodaj lahodaj left a comment

Choose a reason for hiding this comment

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

Seems OK to me.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jul 18, 2024
@vicente-romero-oracle
Copy link
Contributor Author

thanks for the review

@vicente-romero-oracle
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Jul 18, 2024

Going to push as commit 245c086.
Since your change was applied there have been 78 commits pushed to the master branch:

  • 5f7b007: 8336346: Fix -Wzero-as-null-pointer-constant warnings in jvmciJavaClasses.cpp
  • 4a73ed4: 8330144: Revise os::free_memory()
  • 35df48e: 8335860: compiler/vectorization/TestFloat16VectorConvChain.java fails with non-standard AVX/SSE settings
  • 7bf5313: 8335480: Only deoptimize threads if needed when closing shared arena
  • 1b83bd9: 8336661: Parallel: Remove stacks_empty assert in PSScavenge::invoke
  • 72297d2: 8317720: RISC-V: Implement Adler32 intrinsic
  • 21a6cf8: 8336587: failure_handler lldb command times out on macosx-aarch64 core file
  • 78cc0f9: 8336091: Fix HTML warnings in the generated HTML files
  • bcb5e69: 8335921: Fix HotSpot VM build without JVMTI
  • 10186ff: 8336300: DateFormatSymbols#getInstanceRef returns non-cached instance
  • ... and 68 more: https://git.openjdk.org/jdk/compare/5c612c230b0a852aed5fd36e58b82ebf2e1838af...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jul 18, 2024
@openjdk openjdk bot closed this Jul 18, 2024
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jul 18, 2024
@openjdk
Copy link

openjdk bot commented Jul 18, 2024

@vicente-romero-oracle Pushed as commit 245c086.

💡 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-8332600 branch July 18, 2024 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler compiler-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

2 participants