src/share/classes/com/sun/java/util/jar/pack/PackageReader.java

Print this page
rev 3516 : 7021582: convert jar/zip code and tests to use try-with-resources
Reviewed-by: XXX

*** 538,550 **** } Index index = initCPIndex(tag, cpMap); if (optDumpBands) { ! PrintStream ps = new PrintStream(getDumpStream(index, ".idx")); printArrayTo(ps, index.cpMap, 0, index.cpMap.length); ! ps.close(); } } cp_bands.doneDisbursing(); --- 538,550 ---- } Index index = initCPIndex(tag, cpMap); if (optDumpBands) { ! try (PrintStream ps = new PrintStream(getDumpStream(index, ".idx"))) { printArrayTo(ps, index.cpMap, 0, index.cpMap.length); ! } } } cp_bands.doneDisbursing();
*** 826,837 **** attr_definition_name.expectLength(numAttrDefs); attr_definition_layout.expectLength(numAttrDefs); attr_definition_headers.readFrom(in); attr_definition_name.readFrom(in); attr_definition_layout.readFrom(in); ! PrintStream dump = !optDumpBands ? null ! : new PrintStream(getDumpStream(attr_definition_headers, ".def")); for (int i = 0; i < numAttrDefs; i++) { int header = attr_definition_headers.getByte(); Utf8Entry name = (Utf8Entry) attr_definition_name.getRef(); Utf8Entry layout = (Utf8Entry) attr_definition_layout.getRef(); int ctype = (header & ADH_CONTEXT_MASK); --- 826,838 ---- attr_definition_name.expectLength(numAttrDefs); attr_definition_layout.expectLength(numAttrDefs); attr_definition_headers.readFrom(in); attr_definition_name.readFrom(in); attr_definition_layout.readFrom(in); ! try (PrintStream dump = !optDumpBands ? null ! : new PrintStream(getDumpStream(attr_definition_headers, ".def"))) ! { for (int i = 0; i < numAttrDefs; i++) { int header = attr_definition_headers.getByte(); Utf8Entry name = (Utf8Entry) attr_definition_name.getRef(); Utf8Entry layout = (Utf8Entry) attr_definition_layout.getRef(); int ctype = (header & ADH_CONTEXT_MASK);
*** 845,855 **** throw new IOException("Bad attribute layout in version 150 archive: "+def.layout()); } this.setAttributeLayoutIndex(def, index); if (dump != null) dump.println(index+" "+def); } ! if (dump != null) dump.close(); attr_definition_headers.doneDisbursing(); attr_definition_name.doneDisbursing(); attr_definition_layout.doneDisbursing(); // Attribute layouts define bands, one per layout element. // Create them now, all at once. --- 846,856 ---- throw new IOException("Bad attribute layout in version 150 archive: "+def.layout()); } this.setAttributeLayoutIndex(def, index); if (dump != null) dump.println(index+" "+def); } ! } // TODO TWR: this relies on new null treatment for TWR's close() attr_definition_headers.doneDisbursing(); attr_definition_name.doneDisbursing(); attr_definition_layout.doneDisbursing(); // Attribute layouts define bands, one per layout element. // Create them now, all at once.