Skip to content

Commit 0db4c35

Browse files
committed
Fixed CFR not returning code + some improvements over all
1 parent 3ebcc40 commit 0db4c35

File tree

4 files changed

+38
-37
lines changed

4 files changed

+38
-37
lines changed

src/the/bytecode/club/bytecodeviewer/decompilers/CFRDecompiler.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ public String decompileClassNode(ClassNode cn, byte[] b) {
6767
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
6868
}
6969

70-
String fuckery = fuckery(fileStart);
71-
if (!BytecodeViewer.fatJar) {
70+
String fileThing = fileThing(fileStart);
71+
/*if (!BytecodeViewer.fatJar) {
7272
try {
7373
ProcessBuilder pb = new ProcessBuilder(ArrayUtils.addAll(
7474
new String[]{BytecodeViewer.getJavaCommand(), "-jar", Resources.findLibrary("cfr")},
75-
generateMainMethod(tempClass.getAbsolutePath(), fuckery)
75+
generateMainMethod(tempClass.getAbsolutePath(), fileThing)
7676
));
7777
BytecodeViewer.sm.stopBlocking();
7878
Process p = pb.start();
@@ -84,19 +84,19 @@ public String decompileClassNode(ClassNode cn, byte[] b) {
8484
BytecodeViewer.sm.setBlocking();
8585
}
8686
} else {
87-
org.benf.cfr.reader.Main.main(generateMainMethod(tempClass.getAbsolutePath(), fuckery));
88-
}
87+
org.benf.cfr.reader.Main.main(generateMainMethod(tempClass.getAbsolutePath(), fileThing));
88+
}*/
89+
org.benf.cfr.reader.Main.main(generateMainMethod(tempClass.getAbsolutePath(), fileThing));
8990

9091
tempClass.delete();
9192

92-
return findFile(new File(fuckery).listFiles());
93-
93+
return findFile(new File(fileThing).listFiles());
9494
}
9595

9696
Random r = new Random();
9797
File f;
9898

99-
public String fuckery(String start) {
99+
public String fileThing(String start) {
100100
boolean b = false;
101101
while (!b) {
102102
f = new File(start + r.nextInt(Integer.MAX_VALUE));
@@ -257,21 +257,21 @@ public void decompileToZip(String zipName) {
257257

258258
String fileStart = BytecodeViewer.tempDirectory + BytecodeViewer.fs;
259259

260-
String fuckery = fuckery(fileStart);
260+
String fileThing = fileThing(fileStart);
261261

262262
org.benf.cfr.reader.Main.main(generateMainMethod(
263-
tempZip.getAbsolutePath(), fuckery));
263+
tempZip.getAbsolutePath(), fileThing));
264264

265265
tempZip.delete();
266-
File fuck = new File(fuckery);
266+
File file = new File(fileThing);
267267

268268
try {
269-
zip(fuck, new File(zipName));
269+
zip(file, new File(zipName));
270270
} catch (IOException e) {
271271
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
272272
}
273273

274-
fuck.delete();
274+
file.delete();
275275
}
276276

277277
@SuppressWarnings("resource")

src/the/bytecode/club/bytecodeviewer/decompilers/bytecode/ClassNodeDecompiler.java

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,23 @@ protected static PrefixedStringBuilder decompile(
6767
}
6868
sb.append(" {");
6969
sb.append(BytecodeViewer.nl);
70+
if (cn.sourceDebug != null) {
71+
sb.append(" ");
72+
sb.append("<SourceDebug=" + cn.sourceDebug + ">");
73+
sb.append(BytecodeViewer.nl);
74+
}
75+
76+
if (cn.sourceFile != null) {
77+
sb.append(" ");
78+
sb.append("<SourceFile=" + cn.sourceFile + ">");
79+
sb.append(BytecodeViewer.nl);
80+
}
81+
82+
if (cn.signature != null) {
83+
sb.append(" ");
84+
sb.append("<Sig=" + cn.signature + ">");
85+
}
86+
7087
for (FieldNode fn : cn.fields) {
7188
sb.append(BytecodeViewer.nl);
7289
sb.append(" ");
@@ -115,24 +132,6 @@ protected static PrefixedStringBuilder decompile(
115132
}
116133
}
117134

118-
if (cn.sourceDebug != null) {
119-
sb.append(BytecodeViewer.nl);
120-
sb.append(" ");
121-
sb.append("SourceDebug: " + cn.sourceDebug);
122-
}
123-
124-
if (cn.sourceFile != null) {
125-
sb.append(BytecodeViewer.nl);
126-
sb.append(" ");
127-
sb.append("SourceFile: " + cn.sourceFile);
128-
}
129-
130-
if (cn.signature != null) {
131-
sb.append(BytecodeViewer.nl);
132-
sb.append(" ");
133-
sb.append("Signature: " + cn.sourceFile);
134-
}
135-
136135
sb.append(BytecodeViewer.nl);
137136
sb.append("}");
138137
// System.out.println("Wrote end for " + cn.name +

src/the/bytecode/club/bytecodeviewer/decompilers/bytecode/InstructionPrinter.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -328,10 +328,10 @@ private String printFrameNode(FrameNode frame) {
328328
StringBuilder sb = new StringBuilder();
329329
sb.append(nameOpcode(frame.opcode()) + " ");
330330

331-
sb.append("(Locals: ");
331+
sb.append("(Locals");
332332
if (frame.local != null
333333
&& frame.local.size() > 0) {
334-
sb.append(frame.local.size());
334+
sb.append("[" + frame.local.size() + "]:");
335335
sb.append(" ");
336336
sb.append(frame.local.get(0).toString());
337337
if (frame.local.size() > 1) {
@@ -341,14 +341,14 @@ private String printFrameNode(FrameNode frame) {
341341
}
342342
}
343343
} else {
344-
sb.append("0, null");
344+
sb.append("[0]: null");
345345
}
346346
sb.append(") ");
347347

348-
sb.append("(Stack: ");
348+
sb.append("(Stack");
349349
if (frame.stack != null
350350
&& frame.stack.size() > 0) {
351-
sb.append(frame.stack.size());
351+
sb.append("[" + frame.stack.size() + "]:");
352352
sb.append(" ");
353353
sb.append(frame.stack.get(0).toString());
354354
if (frame.stack.size() > 1) {
@@ -358,7 +358,7 @@ private String printFrameNode(FrameNode frame) {
358358
}
359359
}
360360
} else {
361-
sb.append("0, null");
361+
sb.append("[0]: null");
362362
}
363363
sb.append(")");
364364

src/the/bytecode/club/bytecodeviewer/decompilers/bytecode/MethodNodeDecompiler.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,8 @@ private static String getAccessString(int access) {
237237
tokens.add("strictfp");
238238
if ((access & Opcodes.ACC_BRIDGE) != 0)
239239
tokens.add("bridge");
240+
if ((access & Opcodes.ACC_SYNTHETIC) != 0)
241+
tokens.add("synthetic");
240242
if ((access & Opcodes.ACC_VARARGS) != 0)
241243
tokens.add("varargs");
242244
if (tokens.size() == 0)

0 commit comments

Comments
 (0)