test/java/lang/instrument/ilib/Inject.java

Print this page
rev 3509 : 7021209: convert lang, math, util to use try-with-resources
Reviewed-by: XXX

*** 116,128 **** public void reinit(int tracker) { this.tracker = tracker; } void dump(File outDir, String filename) throws IOException { ! FileOutputStream fileOut = new FileOutputStream(new File(outDir, filename)); ! DataOutputStream dataOut = new DataOutputStream(fileOut); ! String currentClassName = null; dataOut.writeInt(infoList.size()); for (Iterator<Info> it = infoList.iterator(); it.hasNext(); ) { Info info = it.next(); --- 116,129 ---- public void reinit(int tracker) { this.tracker = tracker; } void dump(File outDir, String filename) throws IOException { ! try (FileOutputStream fileOut = ! new FileOutputStream(new File(outDir, filename)); ! DataOutputStream dataOut = new DataOutputStream(fileOut)) ! { String currentClassName = null; dataOut.writeInt(infoList.size()); for (Iterator<Info> it = infoList.iterator(); it.hasNext(); ) { Info info = it.next();
*** 132,142 **** dataOut.writeUTF(currentClassName); } dataOut.writeInt(info.location); dataOut.writeUTF(info.methodName); } ! dataOut.close(); } public byte[] bytecodes(String className, String methodName, int location) { byte[] injection = new byte[6]; int injectedIndex = options.fixedIndex != 0? options.fixedIndex : ++counter; --- 133,143 ---- dataOut.writeUTF(currentClassName); } dataOut.writeInt(info.location); dataOut.writeUTF(info.methodName); } ! } } public byte[] bytecodes(String className, String methodName, int location) { byte[] injection = new byte[6]; int injectedIndex = options.fixedIndex != 0? options.fixedIndex : ++counter;