Skip to content

Commit 9e2bfbc

Browse files
committed
1.4 Released
11/1/2014 - Fixed FernFlower save Java files on Unix. 11/1/2014 - FernFlower now uses the settings for save Java files. 11/1/2014 - Added Procyon save Java files (It uses the settings). 11/1/2014 - Updated CFR to cfr_0_89. 11/1/2014 - Added CFR save Java files (It uses the settings), however it relies on the file system, because of this if there is heavy name obfuscation, it could mess up for windows.
1 parent 2175437 commit 9e2bfbc

11 files changed

Lines changed: 214 additions & 68 deletions

File tree

BytecodeViewer Beta 1.4.jar

39.5 MB
Binary file not shown.

README.txt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ Changelog:
109109
10/29/2014 - Tried to fix the issue with JSyntaxPane by making it create the object in a background thread, it still freezes the UI. Changes kept for later implementation of another syntax highlighter.
110110
10/29/2014 - Sped up start up time
111111
--- Beta 1.3.1 ---:
112-
10/29/2014 - Replaced JSyntaxPane with RSyntaxArea, this sadly removes the search feature inside of source/bytecode files, I'll implement a search function soon.
112+
10/29/2014 - Replaced JSyntaxPane with RSyntaxArea, this sadly removes the search feature inside of source/bytecode files, I'll implement a search function soon. (This also fixes the JRE 1.8 issue)
113113
10/29/2014 - Added a new decompiler option to append brackets to labels.
114-
10/31/2014 - Fixed an issue with the decompiler still running when the source code pane isn't toggled.
114+
10/31/2014 - Fixed an issue with the decompiler still running when the source code pane isn't toggled.
115+
--- Beta 1.4 ---:
116+
11/1/2014 - Fixed FernFlower save Java files on Unix.
117+
11/1/2014 - FernFlower now uses the settings for save Java files.
118+
11/1/2014 - Added Procyon save Java files (It uses the settings).
119+
11/1/2014 - Updated CFR to cfr_0_89.
120+
11/1/2014 - Added CFR save Java files (It uses the settings), however it relies on the file system, because of this if there is heavy name obfuscation, it could mess up for windows.

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Beta 1.3.1
1+
Beta 1.4
Binary file not shown.

libs/jsyntaxpane-0.9.5-b29 (1).jar

-388 KB
Binary file not shown.

libs/rsyntaxtextarea.jar

961 KB
Binary file not shown.

src/the/bytecode/club/bytecodeviewer/BytecodeViewer.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,15 @@
138138
* 10/29/2014 - Tried to fix the issue with JSyntaxPane by making it create the object in a background thread, it still freezes the UI. Changes kept for later implementation of another syntax highlighter.
139139
* 10/29/2014 - Sped up start up time.
140140
* ----Beta 1.3.1-----:
141-
* 10/29/2014 - Replaced JSyntaxPane with RSyntaxArea, this sadly removes the search feature inside of source/bytecode files, I'll implement a search function soon.
141+
* 10/29/2014 - Replaced JSyntaxPane with RSyntaxArea, this sadly removes the search feature inside of source/bytecode files, I'll implement a search function soon. (This also fixes the JRE 1.8 issue)
142142
* 10/29/2014 - Added a new decompiler option to append brackets to labels.
143143
* 10/31/2014 - Fixed an issue with the decompiler still running when the source code pane isn't toggled.
144+
* ----Beta 1.4-----:
145+
* 11/1/2014 - Fixed FernFlower save Java files on Unix.
146+
* 11/1/2014 - FernFlower now uses the settings for save Java files.
147+
* 11/1/2014 - Added Procyon save Java files (It uses the settings).
148+
* 11/1/2014 - Updated CFR to cfr_0_89.
149+
* 11/1/2014 - Added CFR save Java files (It uses the settings), however it relies on the file system, because of this if there is heavy name obfuscation, it could mess up for windows.
144150
*
145151
* @author Konloch
146152
*
@@ -156,10 +162,10 @@ public class BytecodeViewer {
156162
private static ArrayList<String> recentFiles = DiskReader.loadArrayList(filesName, false);
157163
private static ArrayList<String> recentPlugins = DiskReader.loadArrayList(pluginsName, false);
158164
private static int maxRecentFiles = 25;
159-
public static String tempDirectory = "bcv_temp";
160165
public static String fs = System.getProperty("file.separator");
161166
public static String nl = System.getProperty("line.separator");
162-
public static String version = "Beta 1.3.1";
167+
public static String tempDirectory = "bcv_temp";
168+
public static String version = "Beta 1.4";
163169

164170
public static void main(String[] args) {
165171
cleanup();

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

Lines changed: 72 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
11
package the.bytecode.club.bytecodeviewer.decompilers.java;
22

3+
import java.io.Closeable;
34
import java.io.File;
5+
import java.io.FileInputStream;
46
import java.io.FileOutputStream;
57
import java.io.IOException;
8+
import java.io.InputStream;
9+
import java.io.OutputStream;
10+
import java.util.Deque;
11+
import java.util.LinkedList;
612
import java.util.Random;
13+
import java.util.zip.ZipEntry;
14+
import java.util.zip.ZipOutputStream;
715

816
import me.konloch.kontainer.io.DiskReader;
917

1018
import org.objectweb.asm.ClassWriter;
1119
import org.objectweb.asm.tree.ClassNode;
1220

1321
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
22+
import the.bytecode.club.bytecodeviewer.JarUtils;
1423

1524
/**
1625
*
@@ -168,29 +177,82 @@ public String[] generateMainMethod(String filePath, String outputPath) {
168177
};
169178
}
170179

180+
byte[] buffer = new byte[1024];
171181
@Override
172182
public void decompileToZip(String zipName) {
173-
/*
174183
File tempZip = new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + "temp.jar");
175184
if(tempZip.exists())
176185
tempZip.delete();
177186

178187
JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), tempZip.getAbsolutePath());
179-
180188

181189
String fileStart = BytecodeViewer.tempDirectory + BytecodeViewer.fs + "temp";
182190

183-
184191
String fuckery = fuckery(fileStart);
185-
org.benf.cfr.reader.Main.main(generateMainMethod(tempZip.getAbsolutePath(), fuckery));
186192

193+
org.benf.cfr.reader.Main.main(generateMainMethod(tempZip.getAbsolutePath(), fuckery));
194+
187195
tempZip.delete();
188-
189-
for(File f : new File(fuckery).listFiles()) {
190-
//put contents into a zipfile
191-
}*/
192-
BytecodeViewer.showMessage("CFRDecompiler currently doesn't decompile as zip, please wait till Beta 1.4 of Bytecode Viewer.");
193-
196+
File fuck = new File(fuckery);
197+
198+
try {
199+
zip(fuck, new File(zipName));
200+
} catch (IOException e) {
201+
e.printStackTrace();
202+
}
203+
204+
fuck.delete();
194205
}
206+
207+
@SuppressWarnings("resource")
208+
public void zip(File directory, File zipfile) throws IOException {
209+
java.net.URI base = directory.toURI();
210+
Deque<File> queue = new LinkedList<File>();
211+
queue.push(directory);
212+
OutputStream out = new FileOutputStream(zipfile);
213+
Closeable res = out;
214+
try {
215+
ZipOutputStream zout = new ZipOutputStream(out);
216+
res = zout;
217+
while (!queue.isEmpty()) {
218+
directory = queue.pop();
219+
for (File kid : directory.listFiles()) {
220+
String name = base.relativize(kid.toURI()).getPath();
221+
if (kid.isDirectory()) {
222+
queue.push(kid);
223+
name = name.endsWith("/") ? name : name + "/";
224+
zout.putNextEntry(new ZipEntry(name));
225+
} else {
226+
zout.putNextEntry(new ZipEntry(name));
227+
copy(kid, zout);
228+
zout.closeEntry();
229+
}
230+
}
231+
}
232+
} finally {
233+
res.close();
234+
out.close();
235+
}
236+
}
237+
238+
private static void copy(InputStream in, OutputStream out) throws IOException {
239+
byte[] buffer = new byte[1024];
240+
while (true) {
241+
int readCount = in.read(buffer);
242+
if (readCount < 0) {
243+
break;
244+
}
245+
out.write(buffer, 0, readCount);
246+
}
247+
}
195248

249+
private static void copy(File file, OutputStream out) throws IOException {
250+
InputStream in = new FileInputStream(file);
251+
try {
252+
copy(in, out);
253+
} finally {
254+
in.close();
255+
}
256+
}
257+
196258
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ public void decompileToZip(String zipName) {
2828
if(tempZip.exists())
2929
tempZip.delete();
3030

31-
File f = new File(BytecodeViewer.tempDirectory + "./temp/");
31+
File f = new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs +"temp" + BytecodeViewer.fs);
3232
f.mkdir();
3333

3434
JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), tempZip.getAbsolutePath());
3535

36-
org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler.main(new String[] {tempZip.getAbsolutePath(), BytecodeViewer.tempDirectory + "./temp/"});
36+
org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler.main(generateMainMethod(tempZip.getAbsolutePath(), BytecodeViewer.tempDirectory + "./temp/"));
3737
File tempZip2 = new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + "temp" + BytecodeViewer.fs +tempZip.getName());
3838
if(tempZip2.exists())
3939
tempZip2.renameTo(new File(zipName));

0 commit comments

Comments
 (0)