< prev index next >

src/jdk.jlink/share/classes/jdk/tools/jmod/JmodOutputStream.java

Print this page
rev 58246 : 8240333: jmod incorrectly updates .jar and .jmod files during hashing
Reviewed-by: martin, alanb

*** 1,7 **** /* ! * Copyright (c) 2016, 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2016, 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 90,100 **** /** * Writes the given entry to the given input stream. */ public void writeEntry(InputStream in, Entry e) throws IOException { ! zos.putNextEntry(e.zipEntry()); zos.write(in.readAllBytes()); zos.closeEntry(); } private ZipEntry newEntry(Section section, String path) { --- 90,113 ---- /** * Writes the given entry to the given input stream. */ public void writeEntry(InputStream in, Entry e) throws IOException { ! ZipEntry e1 = e.zipEntry(); ! // Only preserve attributes which won't change by ! // inflating and deflating the entry. See: ! // sun.tools.jar.Main.update() ! ZipEntry e2 = new ZipEntry(e1.getName()); ! e2.setMethod(e1.getMethod()); ! e2.setTime(e1.getTime()); ! e2.setComment(e1.getComment()); ! e2.setExtra(e1.getExtra()); ! if (e1.getMethod() == ZipEntry.STORED) { ! e2.setSize(e1.getSize()); ! e2.setCrc(e1.getCrc()); ! } ! zos.putNextEntry(e2); zos.write(in.readAllBytes()); zos.closeEntry(); } private ZipEntry newEntry(Section section, String path) {
< prev index next >