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

8297875: jar should not compress the manifest directory entry #11441

Closed
wants to merge 4 commits into from

Conversation

cushon
Copy link
Contributor

@cushon cushon commented Nov 30, 2022

This causes jar to not compress the META-INF/ directory entry, for consistency with the handling of other directory entries and compliance with APPNOTE.TXT, and for compatibility with other zip implementations.


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

Issue

  • JDK-8297875: jar should not compress the manifest directory entry

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 11441

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Nov 30, 2022

👋 Welcome back cushon! 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 openjdk bot added the rfr Pull request is ready for review label Nov 30, 2022
@openjdk
Copy link

openjdk bot commented Nov 30, 2022

@cushon 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 Nov 30, 2022
@mlbridge
Copy link

mlbridge bot commented Nov 30, 2022

Webrevs

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.

I don't necessarily see anything wrong with the change. This code dates back to at least JDK 1.2.1.

I am not sure their is an actual issue based on my read of the APP.NOTE and a quick look at the generated bytes, but I also do not see any harm with the change as to your point this is done for other directories via the jar tool as well as other zip tools such as info zip

The test does not check to see if the method is stored. I would also consider converting the test to TestNG as you can leverage its assertXXX methods and remove the need for the doTest() method

@cushon
Copy link
Contributor Author

cushon commented Nov 30, 2022

Thanks for the review!

I am not sure their is an actual issue based on my read of the APP.NOTE and a quick look at the generated bytes, but I also do not see any harm with the change as to your point this is done for other directories via the jar tool as well as other zip tools such as info zip

I agree APP.NOTE isn't completely clear on this. I think "directories ... must not include file data" could be read as saying that the uncompressed size must be zero, or that the uncompressed and compressed size should be zero. But I also agree with your summary that seems harmless and is consistent with the handling of other directories. It seems likely to me this was an oversight in the original implementation.

The test does not check to see if the method is stored.

Done

I would also consider converting the test to TestNG as you can leverage its assertXXX methods and remove the need for the doTest() method

Done

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.

Thanks for the quick set up updates. a few minor nit comments to make the test feel more TestNG friendly and inline with a few of our other tests.

Will approve tomorrow with some of these tweaks and giving time for some others to scan.

Thank you again for your contribution, it is appreciated :-)

test/jdk/tools/jar/ManifestDirectoryCompression.java Outdated Show resolved Hide resolved
}
}
Files.delete(dir);
} catch (IOException e) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Have the method throw IOException and you do not need the catch block

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately it's recursing on cleanup in the lambda, so it can't throw checked exceptions without more refactoring. This is imitating the recursive deletion approach in another jar test, I'm happy to swap this out if you'd prefer a different approach

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the reminder regarding lambada/checked exceptions. I think this can be simplified to just write the jar and test file to the current directory and then just call

Files.deleteIfExists(Path.of(JAR_FILE_NAME));
Files.deleteIfExists(Path.of(FILE_NAME));

as they are the only files used by the test .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, thanks

Path entry = Files.writeString(topDir.resolve("test.txt"), "Some text...");
doTest(topDir.resolve("test.jar"), entry);
} finally {
cleanup(topDir);
Copy link
Contributor

Choose a reason for hiding this comment

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

See comment above regarding cleanup()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I moved the cleanup into a separate @AfterMethod

@@ -875,6 +875,7 @@ void create(OutputStream out, Manifest manifest) throws IOException
}
ZipEntry e = new ZipEntry(MANIFEST_DIR);
setZipEntryTime(e);
e.setMethod(ZipEntry.STORED);
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be okay, consistent with addFile where it will use STORED for directories.

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.

Thank you again for the latest updates. I think we are close. Please see the comments to further streamline the test and once addressed we should be good to go.

}
}
Files.delete(dir);
} catch (IOException e) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the reminder regarding lambada/checked exceptions. I think this can be simplified to just write the jar and test file to the current directory and then just call

Files.deleteIfExists(Path.of(JAR_FILE_NAME));
Files.deleteIfExists(Path.of(FILE_NAME));

as they are the only files used by the test .


private static void doTest(Path jar, Path entry) throws Throwable {
String[] jarArgs = new String[] {"cf", jar.toString(), entry.toString()};
public void run() throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please rename run() to something like TestDirectoryCompressionMethod(). We are trying to make new tests have more meaningful names.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

String[] jarArgs = new String[] {"cf", jar.toString(), entry.toString()};
public void run() throws Exception {
Path entryPath = Files.writeString(tempDir.resolve("test.txt"), "Some text...");
Path jar = tempDir.resolve("test.jar");
Copy link
Contributor

Choose a reason for hiding this comment

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

Please see comment above regarding the cleanup method.

One other thought you could consider given you only create a jar and file to add to the jar, is to simply add File.deleteIfExists() calls and not bother with a cleanup method given the test case is small and pretty straight forward. Your choice though :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks - I left the cleanup in an @After method for now, but I'm happy to change it.

One small reason to keep the @After method is that I think it ensures the cleanup happens even if the test fails and exits early, without having to wrap the test body in a try/finally.

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.

Thank you for the updates. I think this is good to go :-)

@openjdk
Copy link

openjdk bot commented Dec 1, 2022

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

8297875: jar should not compress the manifest directory entry

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

  • c70d1e1: 8296710: Update to use jtreg 7.1
  • 4899d78: 8293294: Remove dead code in Parse::check_interpreter_type
  • 5459b11: 8297033: G1: Improve logging for Remembered Sets
  • c6156f9: 8297561: Redundant index check in String.offsetByCodePoints()
  • eec24aa: 8295350: JFR: Add stop methods for recording streams
  • 9430f3e: 8297934: [BACKOUT] Compiler should only use verified interface types for optimization
  • 2cb64a7: 8294943: Implement record patterns in enhanced for
  • fc9d419: 8297928: Update jdk.internal.javac.PreviewFeature.Feature to reflect JEP 432 and JEP 433
  • b60cce6: 8297118: Change IncompatibleClassChangeError to MatchException for exhaustive switch statements and switch expressions
  • cd77609: 8294278: ForkJoinPool.getAndAddPoolIds should use Unsafe.staticFieldBase
  • ... and 50 more: https://git.openjdk.org/jdk/compare/54e6d6aaeb5dec2dc1b9fb3ac9b34c8621df506d...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 Dec 1, 2022
@cushon
Copy link
Contributor Author

cushon commented Dec 1, 2022

/integrate

@openjdk
Copy link

openjdk bot commented Dec 1, 2022

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

  • 82031d3: 8297294: compiler/c2/irTests/TestMulNodeIdealization.java failed compilation
  • 337ca10: 8297978: Exclude vmTestbase/nsk/stress/except/except012.java until 8297977 is fixed
  • 770ff5a: 8297215: Update libs tests to use @enablePreview
  • c69aa42: 8297968: Crash in PrintOptoAssembly
  • 5a5ced3: 8297830: aarch64: Make Address a discriminated union internally
  • 391599b: 8297313: Refactor APIs for calculating address of CDS archive heap regions
  • 0962957: 8297449: Update JInternalFrame Metal Border code
  • 9f94cbe: 8271519: java/awt/event/SequencedEvent/MultipleContextsFunctionalTest.java failed with "Total [200] - Expected [400]"
  • c70d1e1: 8296710: Update to use jtreg 7.1
  • 4899d78: 8293294: Remove dead code in Parse::check_interpreter_type
  • ... and 58 more: https://git.openjdk.org/jdk/compare/54e6d6aaeb5dec2dc1b9fb3ac9b34c8621df506d...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Dec 1, 2022

@cushon Pushed as commit e846b04.

💡 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
compiler compiler-dev@openjdk.org core-libs core-libs-dev@openjdk.org integrated Pull request has been integrated
3 participants