-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8355652: Parse ClassFileFormatVersion from ClassFileVersion #26406
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
base: master
Are you sure you want to change the base?
Conversation
👋 Welcome back gustavosimon! A progress list of the required criteria for merging this PR into |
❗ This change is not yet ready to be integrated. |
@gustavosimon The following label will be automatically applied to this pull request:
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. |
Webrevs
|
@liach I know that I'm commenting on a weekend but it's to you see tomorrow. I'm commiting a 1.0 version for this implementation - to get your feedback about I think we should create some unit tests for this API and classes involved. Where do you think that is the most appropriate location in the project to do it? |
Unit tests for |
Great! Thanks! |
@Override | ||
public Optional<ClassFileFormatVersion> formatVersion() { | ||
try { | ||
return Optional.of(ClassFileFormatVersion.fromMajor(majorVersion)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should check the minor version to be 0 for major versions 54 and later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean something like this?
@Override
public Optional<ClassFileFormatVersion> formatVersion() {
if (majorVersion < 54 || minorVersion != 0) {
return Optional.empty();
}
try {
return Optional.of(ClassFileFormatVersion.fromMajor(majorVersion));
} catch (IllegalArgumentException e) {
return Optional.empty();
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this logic is wrong. It's more like the check in
jdk/src/java.base/share/classes/jdk/internal/misc/VM.java
Lines 174 to 180 in 441dbde
public static boolean isSupportedClassFileVersion(int major, int minor) { | |
if (major < ClassFile.JAVA_1_VERSION || major > ClassFile.latestMajorVersion()) return false; | |
// for major version is between 45 and 55 inclusive, the minor version may be any value | |
if (major < ClassFile.JAVA_12_VERSION) return true; | |
// otherwise, the minor version must be 0 or 65535 | |
return minor == 0 || (minor == ClassFile.PREVIEW_MINOR_VERSION && major == ClassFile.latestMajorVersion()); | |
} |
public Optional<ClassFileFormatVersion> formatVersion() {
if (majorVersion < ClassFile.JAVA_1_VERSION || majorVersion > ClassFile.latestMajorVersion()) return Optional.empty();
// for major version is between 45 and 55 inclusive, the minor version may be any value
if (majorVersion >= ClassFile.JAVA_12_VERSION && minorVersion != 0) return Optional.empty();
// otherwise, only minor version 0 is a defined, persistent format
return Optional.of(ClassFileFormatVersion.fromMajor(majorVersion));
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. Could you have this hook in a private class method or a static public method?
Maybe it can be reused in another points?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it can be reused in another points?
ClassFileFormatVersion and Optional are more user-oriented classes; internal code don't really ever use these two types, so I don't think you need to extract this logic specifically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean about the rule the version - similar to isSupportedClassFileVersion method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still don't think so. I intentionally proposed the original RFE so we have one place where we can consolidate this handling, and that place should be here instead of some other place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! I'll do this way
@@ -25,6 +25,8 @@ | |||
package jdk.internal.classfile.impl; | |||
|
|||
import java.lang.classfile.ClassFileVersion; | |||
import java.lang.reflect.ClassFileFormatVersion; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: copyright year :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@myankelev I updated the copyright year in ClassFileVersionImpl
/csr |
@liach has indicated that a compatibility and specification (CSR) request is needed for this pull request. @gustavosimon please create a CSR request for issue JDK-8355652 with the correct fix version. This pull request cannot be integrated until the CSR request is approved. |
8355652: add new method to return ClassFileFormatVersion from ClassFileVersion.
Progress
Issue
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/26406/head:pull/26406
$ git checkout pull/26406
Update a local copy of the PR:
$ git checkout pull/26406
$ git pull https://git.openjdk.org/jdk.git pull/26406/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 26406
View PR using the GUI difftool:
$ git pr show -t 26406
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/26406.diff
Using Webrev
Link to Webrev Comment
Progress
Issue
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/26406/head:pull/26406
$ git checkout pull/26406
Update a local copy of the PR:
$ git checkout pull/26406
$ git pull https://git.openjdk.org/jdk.git pull/26406/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 26406
View PR using the GUI difftool:
$ git pr show -t 26406
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/26406.diff
Using Webrev
Link to Webrev Comment