Skip to content

Commit

Permalink
8240235: jdk.test.lib.util.JarUtils updates jar files incorrectly
Browse files Browse the repository at this point in the history
Reviewed-by: martin, clanger, lancea
  • Loading branch information
simonis committed Mar 3, 2020
1 parent 850f313 commit f3af6a0
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions test/lib/jdk/test/lib/util/JarUtils.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -158,7 +158,7 @@ public static void updateJarFile(Path jarfile, Path dir, Path... files)
while (jentries.hasMoreElements()) {
JarEntry jentry = jentries.nextElement();
if (!names.contains(jentry.getName())) {
jos.putNextEntry(jentry);
jos.putNextEntry(copyEntry(jentry));
jf.getInputStream(jentry).transferTo(jos);
}
}
Expand Down Expand Up @@ -291,7 +291,7 @@ public static void updateJar(String src, String dest,
changes.remove(name);
} else {
System.out.println(String.format("- Copy %s", name));
jos.putNextEntry(entry);
jos.putNextEntry(copyEntry(entry));
srcJarFile.getInputStream(entry).transferTo(jos);
}
}
Expand Down Expand Up @@ -361,4 +361,17 @@ private static List<Path> findAllRegularFiles(Path dir, Path[] files) throws IOE
}
return entries;
}

private static JarEntry copyEntry(JarEntry e1) {
JarEntry e2 = new JarEntry(e1.getName());
e2.setMethod(e1.getMethod());
e2.setTime(e1.getTime());
e2.setComment(e1.getComment());
e2.setExtra(e1.getExtra());
if (e1.getMethod() == JarEntry.STORED) {
e2.setSize(e1.getSize());
e2.setCrc(e1.getCrc());
}
return e2;
}
}

0 comments on commit f3af6a0

Please sign in to comment.