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

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

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 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 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 compiler labels May 11, 2021
@JornVernee
Copy link
Member Author

@JornVernee JornVernee commented May 19, 2021

/label remove compiler

@openjdk openjdk bot removed the compiler label May 19, 2021
@openjdk
Copy link

@openjdk 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
@JornVernee
Copy link
Member Author

@JornVernee JornVernee commented May 19, 2021

/csr needed

@openjdk openjdk bot added rfr csr labels May 19, 2021
@openjdk
Copy link

@openjdk 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 mlbridge bot commented May 19, 2021

Webrevs

@JornVernee
Copy link
Member Author

@JornVernee JornVernee commented May 19, 2021

@AlanBateman
Copy link
Contributor

@AlanBateman AlanBateman commented Jun 8, 2021

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

@JornVernee JornVernee commented Jun 8, 2021

@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

The changes look good

@JornVernee
Copy link
Member Author

@JornVernee 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 label Jun 9, 2021
@openjdk
Copy link

@openjdk 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 label Jun 9, 2021
@JornVernee
Copy link
Member Author

@JornVernee JornVernee commented Jun 9, 2021

/integrate

@openjdk openjdk bot closed this Jun 9, 2021
@openjdk openjdk bot added integrated and removed ready rfr labels Jun 9, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Jun 9, 2021

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

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 integrated
3 participants