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

8255342: Remove non-specified JVM checks on Classes with Record attributes #845

Closed
wants to merge 2 commits into from

Conversation

@hseigel
Copy link
Member

@hseigel hseigel commented Oct 23, 2020

Please review this fix to remove the checks for non-final and abstract classes containing Record attributes and checks for classes containing Record attributes whose supers are not java.lang.Record. These checks are not specified in the JVM Spec and so should not be done by the JVM.

The change removes the checks and updates Record tests as needed.

The fix was tested with mach5 tiers 1 and 2 on Linux, Windows, and Mac, and tiers 3-5 on Linux x64 and with JCK lang, vm, and api/java_lang tests.

Thanks, Harold


Progress

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

Issue

  • JDK-8255342: Remove non-specified JVM checks on Classes with Record attributes

Reviewers

Download

$ git fetch https://git.openjdk.java.net/jdk pull/845/head:pull/845
$ git checkout pull/845

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Oct 23, 2020

👋 Welcome back hseigel! 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.

Loading

@openjdk openjdk bot added the rfr label Oct 23, 2020
@openjdk
Copy link

@openjdk openjdk bot commented Oct 23, 2020

@hseigel The following label will be automatically applied to this pull request:

  • hotspot-runtime

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.

Loading

@mlbridge
Copy link

@mlbridge mlbridge bot commented Oct 23, 2020

Webrevs

Loading

Copy link
Member

@dholmes-ora dholmes-ora left a comment

Hi Harold,
Generally looks good, but you need a new test case - see below.
Thanks,
David

Loading

// Test that loading a class causes the Record attribute to get parsed
// even if its super class is not java.lang.Record
runTest("superNotJLRecord", "Truncated class file");
Copy link
Member

@dholmes-ora dholmes-ora Oct 26, 2020

Choose a reason for hiding this comment

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

This simple "inversion" of the test is not sufficient. The original test was that a bad record attribute is ignored when not a subclass of j.l.Record. The modified test should be that a bad record attribute is never ignored. But in addition there should be a new test that a good record attribute in a class that does not subclass j.l.Record, is also okay.

Loading

@hseigel
Copy link
Member Author

@hseigel hseigel commented Oct 26, 2020

Hi David,
Thanks for looking at this change. Please review the updated commit that adds the missing test case.
Thanks, Haorld

Loading

Copy link
Member

@dholmes-ora dholmes-ora left a comment

Thanks for adding the additional test.

David

Loading

@openjdk
Copy link

@openjdk openjdk bot commented Oct 26, 2020

@hseigel 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:

8255342: Remove non-specified JVM checks on Classes with Record attributes

Reviewed-by: dholmes, coleenp

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

  • 7679650: 8231231: The printing result is different from the case instruction
  • f7c59c6: 8255231: Avoid upcalls when initializing the statSampler
  • dccfd2b: 8255389: ConcurrentHashTable::NoOp omits return in non-void return method
  • d735f91: 8255040: Replace __sync_add_and_fetch with __atomic_add_fetch to avoid build errors with clang
  • bcdeeaa: 8199054: Test javax/swing/UIDefaults/8149879/InternalResourceBundle.java is unstable
  • dee31d0: 8167355: [macos 10.12] Timeout in javax/swing/JTextArea/TextViewOOM/TextViewOOM.java
  • abdbbe3: 8254370: Update the classes in the java.awt.color package
  • 8ca59c9: 8255206: [macos] LicenseTest fails on macOS 11
  • ca8bba6: 8238263: Create at-requires mechanism for containers
  • a7fa1b7: 8251994: VM crashed running TestComplexAddrExpr.java test with -XX:UseAVX=X
  • ... and 21 more: https://git.openjdk.java.net/jdk/compare/3f6abd220fa9d39bd5bd60bee3827a4680437cc6...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.

Loading

@openjdk openjdk bot added the ready label Oct 26, 2020
Copy link
Contributor

@coleenp coleenp left a comment

Looks good, Harold!

Loading

@hseigel
Copy link
Member Author

@hseigel hseigel commented Oct 27, 2020

Thanks David and Coleen for the reviews!

Loading

@hseigel
Copy link
Member Author

@hseigel hseigel commented Oct 27, 2020

/integrate

Loading

@openjdk openjdk bot closed this Oct 27, 2020
@openjdk openjdk bot added integrated and removed ready rfr labels Oct 27, 2020
@openjdk
Copy link

@openjdk openjdk bot commented Oct 27, 2020

@hseigel Since your change was applied there have been 31 commits pushed to the master branch:

  • 7679650: 8231231: The printing result is different from the case instruction
  • f7c59c6: 8255231: Avoid upcalls when initializing the statSampler
  • dccfd2b: 8255389: ConcurrentHashTable::NoOp omits return in non-void return method
  • d735f91: 8255040: Replace __sync_add_and_fetch with __atomic_add_fetch to avoid build errors with clang
  • bcdeeaa: 8199054: Test javax/swing/UIDefaults/8149879/InternalResourceBundle.java is unstable
  • dee31d0: 8167355: [macos 10.12] Timeout in javax/swing/JTextArea/TextViewOOM/TextViewOOM.java
  • abdbbe3: 8254370: Update the classes in the java.awt.color package
  • 8ca59c9: 8255206: [macos] LicenseTest fails on macOS 11
  • ca8bba6: 8238263: Create at-requires mechanism for containers
  • a7fa1b7: 8251994: VM crashed running TestComplexAddrExpr.java test with -XX:UseAVX=X
  • ... and 21 more: https://git.openjdk.java.net/jdk/compare/3f6abd220fa9d39bd5bd60bee3827a4680437cc6...master

Your commit was automatically rebased without conflicts.

Pushed as commit 18d9905.

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

Loading

@rose00
Copy link
Contributor

@rose00 rose00 commented Oct 27, 2020

This was a good example of a VM anti-pattern that's easy to fall into, which I call "The Gratuitous Restriction". There's a wide range of correctness checks the VM could do, but deciding which ones it should do is surprisingly subtle. When designing a new feature, there's a certain impulse to reject every suspicious input, and even to fish around in the design asking "what can we reject, that doesn't appear to have a meaning?" This impulse is (often) rooted in a legitimate desire to reduce implementation work by constraining inputs (rejecting a class file before trying to interpret something that smells funny). But there are four downsides:

  1. The rejected thing might turn out to have a meaning after all, but now we are blocked from discovering what it might be. (This is my favorite. When once we said "value types can't extend abstract classes", I thought, "yeah, that's what we're saying now; just wait a while.")

  2. The rejection we threw into the code to save ourselves work has to be rigorously specified in the JVMS and kept there forever. (We may get tired of looking at it, and it may obscure more important material in the JVMS.)

  3. The rejection we threw into the code to save ourselves work has to be maintained forever, and if we ever disturb it our own VM will be non-compliant with the JVMS. (We may get tired of maintaining it.)

  4. Maybe, if you get into the habit of making them, they can build up as performance debt. Enough extra checks will start to slow down the JVM.

Loading

@mlbridge
Copy link

@mlbridge mlbridge bot commented Oct 27, 2020

Mailing list message from Remi Forax on hotspot-runtime-dev:

----- Mail original -----

De: "John R Rose" <jrose at openjdk.java.net>
?: "hotspot-runtime-dev" <hotspot-runtime-dev at openjdk.java.net>
Envoy?: Mardi 27 Octobre 2020 17:47:24
Objet: Re: RFR: 8255342: Remove non-specified JVM checks on Classes with Record attributes [v2]

On Tue, 27 Oct 2020 12:21:22 GMT, Harold Seigel <hseigel at openjdk.org> wrote:

Looks good, Harold!

Thanks David and Coleen for the reviews!

This was a good example of a VM anti-pattern that's easy to fall into, which I
call "The Gratuitous Restriction". There's a wide range of correctness checks
the VM *could* do, but deciding which ones it *should* do is surprisingly
subtle. When designing a new feature, there's a certain impulse to reject
every suspicious input, and even to fish around in the design asking "what can
we reject, that doesn't appear to have a meaning?" This impulse is (often)
rooted in a legitimate desire to reduce implementation work by constraining
inputs (rejecting a class file before trying to interpret something that smells
funny). But there are four downsides:

1. The rejected thing might turn out to have a meaning after all, but now we are
blocked from discovering what it might be. (This is my favorite. When once we
said "value types can't extend abstract classes", I thought, "yeah, that's what
we're saying now; just wait a while.")

by example, in the future an enum may have record components but not inherits from java.lang.Record
enum Color(int red, int green, blue) { RED(255, 0, 0), ... }

2. The rejection we threw into the code to save ourselves work has to be
rigorously specified in the JVMS and kept there forever. (We may get tired of
looking at it, and it may obscure more important material in the JVMS.)

3. The rejection we threw into the code to save ourselves work has to be
maintained forever, and if we ever disturb it our own VM will be non-compliant
with the JVMS. (We may get tired of maintaining it.)

4. Maybe, if you get into the habit of making them, they can build up as
performance debt. Enough extra checks will start to slow down the JVM.

R?mi

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
4 participants