diff --git a/src/java5/java/net/anawesomguy/clsdump/Dumper.java b/src/java5/java/net/anawesomguy/clsdump/Dumper.java index 4382df7..af730ff 100644 --- a/src/java5/java/net/anawesomguy/clsdump/Dumper.java +++ b/src/java5/java/net/anawesomguy/clsdump/Dumper.java @@ -21,13 +21,13 @@ public Dumper(boolean debug) { this.debug = debug; } - private static void rm(File f) { - if (f.isDirectory()) + private static void rm(File file) { + if (file.isDirectory()) //noinspection DataFlowIssue - for (File c : f.listFiles()) - rm(c); - if (!f.delete()) - throw new RuntimeException("Failed to delete: ".concat(f.getPath())); + for (File f : file.listFiles()) + rm(f); + if (!file.delete()) + throw new RuntimeException("Failed to delete: ".concat(file.getPath())); } public static void premain(String args, Instrumentation inst) { @@ -45,10 +45,10 @@ public static void premain(String args, Instrumentation inst) { InputStream in = c.getResourceAsStream(cls.substring(name.lastIndexOf('/') + 1)); if (in != null) { try { - File f = new File(DIR, cls); + File file = new File(DIR, cls); //noinspection ResultOfMethodCallIgnored ???????? (what) - f.getParentFile().mkdirs(); - FileOutputStream out = new FileOutputStream(f); + file.getParentFile().mkdirs(); + FileOutputStream out = new FileOutputStream(file); try { byte[] buf = new byte[8192]; for (int i; (i = in.read(buf)) != -1;) @@ -73,10 +73,10 @@ public static void premain(String args, Instrumentation inst) { public byte[] transform(ClassLoader classLoader, String name, Class clazz, ProtectionDomain protectionDomain, byte[] buf) { try { - File f = new File(DIR, name.concat(".class")); + File file = new File(DIR, name.concat(".class")); //noinspection ResultOfMethodCallIgnored ???????? (what) - f.getParentFile().mkdirs(); - FileOutputStream out = new FileOutputStream(f); + file.getParentFile().mkdirs(); + FileOutputStream out = new FileOutputStream(file); try { out.write(buf); } finally { diff --git a/src/main/java/net/anawesomguy/clsdump/Dumper.java b/src/main/java/net/anawesomguy/clsdump/Dumper.java index d33057a..46b5a30 100644 --- a/src/main/java/net/anawesomguy/clsdump/Dumper.java +++ b/src/main/java/net/anawesomguy/clsdump/Dumper.java @@ -18,19 +18,19 @@ public final class Dumper implements ClassFileTransformer { static { if (Files.exists(DIR)) try { - try (Stream s = Files.walk(DIR)) { - s.sorted(Comparator.reverseOrder()).forEach(Dumper::rm); + try (Stream walk = Files.walk(DIR)) { + walk.sorted(Comparator.reverseOrder()).forEach(Dumper::rm); } } catch (IOException e) { throw new RuntimeException(e); } } - private static void rm(Path p) { + private static void rm(Path path) { try { - Files.delete(p); + Files.delete(path); } catch (IOException e) { - throw new RuntimeException(p.toString(), e); + throw new RuntimeException(path.toString(), e); } } @@ -46,16 +46,16 @@ public static void premain(String args, Instrumentation inst) { inst.addTransformer(new Dumper(debug)); //already loaded classes - for (Class c : inst.getAllLoadedClasses()) { - if (c.isArray()) + for (Class cls : inst.getAllLoadedClasses()) { + if (cls.isArray()) continue; - String name = c.getName().replace('.', '/'); + String name = cls.getName().replace('.', '/'); try { - String cls = name + ".class"; - InputStream in = c.getResourceAsStream(cls.substring(name.lastIndexOf('/') + 1)); + String clsName = name + ".class"; + InputStream in = cls.getResourceAsStream(clsName.substring(name.lastIndexOf('/') + 1)); if (in != null) { try { - Path path = DIR.resolve(cls); + Path path = DIR.resolve(clsName); Files.createDirectories(path.getParent()); Files.copy(in, path, StandardCopyOption.REPLACE_EXISTING); } finally { @@ -75,9 +75,9 @@ public static void premain(String args, Instrumentation inst) { public byte[] transform(ClassLoader classLoader, String name, Class clazz, ProtectionDomain protectionDomain, byte[] buf) { try { - Path p = DIR.resolve(name + ".class"); - Files.createDirectories(p.getParent()); - Files.write(p, buf); + Path path = DIR.resolve(name + ".class"); + Files.createDirectories(path.getParent()); + Files.write(path, buf); if (debug) System.out.println("Dumped class " + name); } catch (Exception e) {