On Wed, 16 Jun 2021 15:59:44 GMT, Mandy Chung <mch...@openjdk.org> wrote:

>> Aleksei Voitylov has updated the pull request incrementally with one 
>> additional commit since the last revision:
>> 
>>   address review comments
>
> test/jdk/java/lang/ClassLoader/loadLibraryDeadlock/TestLoadLibraryDeadlock.java
>  line 95:
> 
>> 93:         Collections.addAll(args, "cvf", Paths.get(testClassPath, 
>> outputJar).toString());
>> 94:         for (String c : classes) {
>> 95:             Collections.addAll(args, "-C", testClassPath, c);
> 
> I believe only one single `-C` option is good enough for this case since the 
> classes are all in one single directory.

Contrary to the man which says "-C DIR Changes the specified directory and 
includes the files specified at the end of the command line.", here is how it 
works:


bash-3.2$ find .
.
./dir
./dir/B.class
./dir/A.class
bash-3.2$ jar cvf a.jar -C dir A.class B.class
B.class : no such file or directory
added manifest
adding: A.class(in = 176) (out= 149)(deflated 15%)


and no jar is produced. Lines 614 and 647 of 
src/jdk.jartool/share/classes/sun/tools/jar/Main.java explain why. IIRC the 
intent was to mimic tar -C behaviour where -C applies to all files that follow, 
but jar does not work that way currently. 

It's probably worth reaching consensus that it's a problem worth fixing first 
(a scary one to fix by the way, provided how many tools could rely on the 
current behaviour). Alternatively, man could be adjusted to reflect the current 
order. I could work on that as a follow up.

-------------

PR: https://git.openjdk.java.net/jdk/pull/3976

Reply via email to