Skip to content

Commit 5cbd578

Browse files
committed
8342930: New tests from JDK-8335912 are failing
Reviewed-by: jpai
1 parent 1e35da8 commit 5cbd578

File tree

4 files changed

+27
-11
lines changed

4 files changed

+27
-11
lines changed

src/jdk.jartool/share/man/jar.1

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ Updates an existing JAR file.
118118
.TP
119119
\f[V]-x\f[R] or \f[V]--extract\f[R]
120120
Extracts the named (or all) files from the archive.
121+
If a file with the same name appears more than once in the archive, each
122+
copy will be extracted, with later copies overwriting (replacing)
123+
earlier copies unless -k is specified.
121124
.TP
122125
\f[V]-d\f[R] or \f[V]--describe-module\f[R]
123126
Prints the module descriptor or automatic module name.
@@ -212,6 +215,14 @@ time-zone format, to use for the timestamp of the entries, e.g.
212215
.TP
213216
\f[V]--dir\f[R] \f[I]DIR\f[R]
214217
Directory into which the JAR file will be extracted.
218+
.TP
219+
\f[V]-k\f[R] or \f[V]--keep-old-files\f[R]
220+
Do not overwrite existing files.
221+
If a Jar file entry with the same name exists in the target directory,
222+
the existing file will not be overwritten.
223+
As a result, if a file appears more than once in an archive, later
224+
copies will not overwrite earlier copies.
225+
Also note that some file system can be case insensitive.
215226
.SH OTHER OPTIONS
216227
.PP
217228
The following options are recognized by the \f[V]jar\f[R] command and

test/jdk/ProblemList.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -724,9 +724,6 @@ javax/swing/JMenuItem/ActionListenerCalledTwice/ActionListenerCalledTwiceTest.ja
724724

725725
# core_tools
726726

727-
tools/jar/ExtractFilesTest.java 8342930 generic-all
728-
tools/jar/MultipleManifestTest.java 8342930 generic-all
729-
730727

731728
############################################################################
732729

test/jdk/tools/jar/ExtractFilesTest.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public void testExtract() throws IOException {
8888
" inflated: testfile1" + nl +
8989
" inflated: testfile2" + nl;
9090
rm("META-INF testfile1 testfile2");
91-
Assertions.assertArrayEquals(baos.toByteArray(), output.getBytes());
91+
assertOutputContains(output);
9292
}
9393

9494
/**
@@ -105,7 +105,7 @@ public void testOverwrite() throws IOException {
105105
" inflated: testfile2" + nl;
106106
Assertions.assertEquals("testfile1", cat("testfile1"));
107107
rm("META-INF testfile1 testfile2");
108-
Assertions.assertArrayEquals(baos.toByteArray(), output.getBytes());
108+
assertOutputContains(output);
109109
}
110110

111111
/**
@@ -123,7 +123,7 @@ public void testKeptOldFile() throws IOException {
123123
Assertions.assertEquals("", cat("testfile1"));
124124
Assertions.assertEquals("testfile2", cat("testfile2"));
125125
rm("META-INF testfile1 testfile2");
126-
Assertions.assertArrayEquals(baos.toByteArray(), output.getBytes());
126+
assertOutputContains(output);
127127
}
128128

129129
/**
@@ -141,7 +141,7 @@ public void testGnuOptionsKeptOldFile() throws IOException {
141141
Assertions.assertEquals("", cat("testfile1"));
142142
Assertions.assertEquals("", cat("testfile2"));
143143
rm("META-INF testfile1 testfile2");
144-
Assertions.assertArrayEquals(baos.toByteArray(), output.getBytes());
144+
assertOutputContains(output);
145145
}
146146

147147
/**
@@ -159,7 +159,7 @@ public void testGnuLongOptionsKeptOldFile() throws IOException {
159159
Assertions.assertEquals("testfile1", cat("testfile1"));
160160
Assertions.assertEquals("", cat("testfile2"));
161161
rm("META-INF testfile1 testfile2");
162-
Assertions.assertArrayEquals(baos.toByteArray(), output.getBytes());
162+
assertOutputContains(output);
163163
}
164164

165165
/**
@@ -175,10 +175,14 @@ public void testWarningOnInvalidKeepOption() throws IOException {
175175
"testfile1" + nl +
176176
"testfile2" + nl;
177177

178-
Assertions.assertArrayEquals(baos.toByteArray(), output.getBytes());
178+
assertOutputContains(output);
179179
Assertions.assertEquals("Warning: The --keep-old-files/-k/k option is not valid with current usage, will be ignored." + nl, err);
180180
}
181181

182+
private void assertOutputContains(String expected) {
183+
Assertions.assertTrue(baos.toString().contains(expected));
184+
}
185+
182186
private Stream<Path> mkpath(String... args) {
183187
return Arrays.stream(args).map(d -> Path.of(".", d.split("/")));
184188
}

test/jdk/tools/jar/MultipleManifestTest.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ public void testOverwrite() throws IOException {
154154
" inflated: entry1.txt" + nl +
155155
" inflated: META-INF/MANIFEST.MF" + nl +
156156
" inflated: entry2.txt" + nl;
157-
Assertions.assertArrayEquals(baos.toByteArray(), output.getBytes());
157+
assertOutputContains(output);
158158
}
159159

160160
/**
@@ -170,7 +170,7 @@ public void testKeptOldFile() throws IOException {
170170
" inflated: entry1.txt" + nl +
171171
" skipped: META-INF/MANIFEST.MF exists" + nl +
172172
" inflated: entry2.txt" + nl;
173-
Assertions.assertArrayEquals(baos.toByteArray(), output.getBytes());
173+
assertOutputContains(output);
174174
}
175175

176176
private String getManifestVersion() throws IOException {
@@ -199,6 +199,10 @@ private void jar(String cmdline) throws IOException {
199199
}
200200
}
201201

202+
private void assertOutputContains(String expected) {
203+
Assertions.assertTrue(baos.toString().contains(expected));
204+
}
205+
202206
private void println() throws IOException {
203207
System.out.println(new String(baos.toByteArray()));
204208
}

0 commit comments

Comments
 (0)