Skip to content

8266835: Add a --validate option to the jar tool #3971

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
wants to merge 7 commits into from

Conversation

JornVernee
Copy link
Member

@JornVernee JornVernee commented May 11, 2021

This patch adds a --validate option to the jar tool which can be used to validate a jar file that might be malformed. For instance, if a jar is a multi-release jar, it is malformed if different versions expose different APIs.

The implementation is straight forward since there already exists validation logic that is run when creating or updating a jar. This patch just exposes that logic directly under a new command line flag.

I've enhanced the existing ApiValidatorTest to also create malformed jars using the zip file APIs (the jar tool does not output malformed jars) and run them through jar --validate.

Note that while the jdk's jar tool does not output malformed jars, third-party archiving tools might, or the jar could have been manually edited.

Some prior discussion here: https://mail.openjdk.java.net/pipermail/core-libs-dev/2021-May/077420.html

Testing: running jdk/tools/jar test suite locally, tier 1-3 (in progress), manual testing.


Progress

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

Issue

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/3971/head:pull/3971
$ git checkout pull/3971

Update a local copy of the PR:
$ git checkout pull/3971
$ git pull https://git.openjdk.java.net/jdk pull/3971/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 3971

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/3971.diff

@JornVernee JornVernee changed the title 8266835: Add a --validate option to the jar too 8266835: Add a --validate option to the jar tool May 11, 2021
@bridgekeeper
Copy link

bridgekeeper bot commented May 11, 2021

👋 Welcome back jvernee! 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 May 11, 2021

@JornVernee The following labels will be automatically applied to this pull request:

  • compiler
  • core-libs

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

@openjdk openjdk bot added core-libs core-libs-dev@openjdk.org compiler compiler-dev@openjdk.org labels May 11, 2021
@JornVernee
Copy link
Member Author

/label remove compiler

@openjdk openjdk bot removed the compiler compiler-dev@openjdk.org label May 19, 2021
@openjdk
Copy link

openjdk bot commented May 19, 2021

@JornVernee
The compiler label was successfully removed.

- indent option in help message (to align with others)
@JornVernee JornVernee marked this pull request as ready for review May 19, 2021 14:16
@JornVernee
Copy link
Member Author

/csr needed

@openjdk openjdk bot added rfr Pull request is ready for review csr Pull request needs approved CSR before integration labels May 19, 2021
@openjdk
Copy link

openjdk bot commented May 19, 2021

@JornVernee this pull request will not be integrated until the CSR request JDK-8267402 for issue JDK-8266835 has been approved.

@mlbridge
Copy link

mlbridge bot commented May 19, 2021

Webrevs

@JornVernee
Copy link
Member Author

@AlanBateman
Copy link
Contributor

This all looks reasonable, I just wonder if the --validate description in the help output should provide a brief summary on what it does check. We can add to it as some validation is added. Without it then people will make assumptions on what it does.

@JornVernee
Copy link
Member Author

@AlanBateman Thanks for the suggestion. I think adding a description is good idea. I initially left the description vague, so that the behavior could be more easily amended. But, on second thought, such changes would seemingly require no less review, so I think it's better to include a description, as suggested.

I've updated the description to say the following:

\      --validate             Validate a jar. This process will validate that the API\n\
\                             exported by a multi-release jar is consistent across all\n\
\                             different release versions.

Copy link
Contributor

@LanceAndersen LanceAndersen left a comment

Choose a reason for hiding this comment

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

The changes look good

@JornVernee
Copy link
Member Author

JornVernee commented Jun 9, 2021

If the changes look good like this, please review the accompanying CSR for the command line option changes: https://bugs.openjdk.java.net/browse/JDK-8267402

Thanks

@openjdk openjdk bot removed the csr Pull request needs approved CSR before integration label Jun 9, 2021
@openjdk
Copy link

openjdk bot commented Jun 9, 2021

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

8266835: Add a --validate option to the jar tool

Reviewed-by: lancea

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

  • bb3d226: 8238213: Method resolution should stop on static error
  • 81fdeb5: 8268417: Add test from JDK-8268360
  • caf7f49: 8268122: Add specific gc cause for G1 full collections
  • 43e38a1: 8268377: Windows 32bit build fails after JDK-8268174
  • 5fbb62c: 8268163: Change the order of fallback full GCs in G1
  • 7b1e402: 8266598: Exception values for AnnotationTypeMismatchException are not always informative
  • 13d6180: 8264859: Implement Context-Specific Deserialization Filters
  • dd34a4c: 8268372: ZGC: dynamically select the number of concurrent GC threads used
  • 4388959: 8268056: Update java.net and java.nio to use switch expressions
  • 9cfd560: 8267663: [vector] Add unsigned comparison operators on AArch64
  • ... and 452 more: https://git.openjdk.java.net/jdk/compare/c8b744743bd54a00a4f7bf1e852d454fcd942abd...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 ready Pull request is ready to be integrated label Jun 9, 2021
@JornVernee
Copy link
Member Author

/integrate

@openjdk openjdk bot closed this Jun 9, 2021
@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 Jun 9, 2021
@openjdk
Copy link

openjdk bot commented Jun 9, 2021

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

  • db45ff0: 8268052: [JVMCI] non-default installed code must be marked as in_use
  • bb3d226: 8238213: Method resolution should stop on static error
  • 81fdeb5: 8268417: Add test from JDK-8268360
  • caf7f49: 8268122: Add specific gc cause for G1 full collections
  • 43e38a1: 8268377: Windows 32bit build fails after JDK-8268174
  • 5fbb62c: 8268163: Change the order of fallback full GCs in G1
  • 7b1e402: 8266598: Exception values for AnnotationTypeMismatchException are not always informative
  • 13d6180: 8264859: Implement Context-Specific Deserialization Filters
  • dd34a4c: 8268372: ZGC: dynamically select the number of concurrent GC threads used
  • 4388959: 8268056: Update java.net and java.nio to use switch expressions
  • ... and 453 more: https://git.openjdk.java.net/jdk/compare/c8b744743bd54a00a4f7bf1e852d454fcd942abd...master

Your commit was automatically rebased without conflicts.

Pushed as commit 79010f2.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core-libs core-libs-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

3 participants