1616import java .nio .file .Files ;
1717import java .nio .file .Paths ;
1818import java .util .ArrayList ;
19- import java .util .Enumeration ;
2019import java .util .HashMap ;
2120import java .util .List ;
22- import java .util .jar .JarEntry ;
23- import java .util .jar .JarFile ;
24- import java .util .jar .JarOutputStream ;
2521
2622import javax .swing .JDialog ;
2723import javax .swing .JFileChooser ;
118114public class BytecodeViewer
119115{
120116 /*per version*/
121- public static final String VERSION = "2.9.19 " ;
117+ public static final String VERSION = "2.9.20 " ;
122118 public static String krakatauVersion = "12" ;
123119 public static String enjarifyVersion = "4" ;
124120 public static final boolean BLOCK_TAB_MENU = true ;
@@ -145,12 +141,13 @@ public class BytecodeViewer
145141 public static boolean currentlyDumping = false ;
146142 public static boolean needsReDump = true ;
147143 public static boolean warnForEditing = false ;
148- public static ArrayList <FileContainer > files = new ArrayList <FileContainer >(); //all of BCV's loaded files/classes/etc
144+ public static List <FileContainer > files = new ArrayList <FileContainer >(); //all of BCV's loaded files/classes/etc
149145 private static int maxRecentFiles = 25 ;
150146 public static String fs = System .getProperty ("file.separator" );
151147 public static String nl = System .getProperty ("line.separator" );
152148 private static File BCVDir = new File (System .getProperty ("user.home" ) + fs + ".Bytecode-Viewer" );
153- public static File RJ_JAR = new File (System .getProperty ("java.home" ) + fs + "lib" + fs + "rt.jar" );
149+ public static File RT_JAR = new File (System .getProperty ("java.home" ) + fs + "lib" + fs + "rt.jar" );
150+ public static File RT_JAR_DUMPED = new File (getBCVDirectory () + fs + "rt.jar" );
154151 private static String filesName = getBCVDirectory () + fs + "recentfiles.json" ;
155152 private static String pluginsName = getBCVDirectory () + fs + "recentplugins.json" ;
156153 public static String settingsName = getBCVDirectory () + fs + "settings.bcv" ;
@@ -161,15 +158,15 @@ public class BytecodeViewer
161158 public static boolean runningObfuscation = false ;
162159 private static long start = System .currentTimeMillis ();
163160 public static String lastDirectory = "." ;
164- public static ArrayList <Process > createdProcesses = new ArrayList <Process >();
161+ public static List <Process > createdProcesses = new ArrayList <Process >();
165162 public static Refactorer refactorer = new Refactorer ();
166163 public static boolean pingback = false ;
167164 public static boolean deleteForeignLibraries = true ;
168165 public static boolean canExit = false ;
169166 public static Gson gson ;
170167
171- private static ArrayList <String > recentPlugins ;
172- private static ArrayList <String > recentFiles ;
168+ private static List <String > recentPlugins ;
169+ private static List <String > recentFiles ;
173170
174171 static
175172 {
@@ -669,6 +666,10 @@ public static FileContainer getFileContainer(String name) {
669666 return null ;
670667 }
671668
669+ public static List <FileContainer > getFiles () {
670+ return files ;
671+ }
672+
672673 public static ClassNode getClassNode (FileContainer container , String name ) {
673674 for (ClassNode c : container .classes )
674675 if (c .name .equals (name ))
@@ -943,7 +944,7 @@ public void run() {
943944
944945 if (viewer .decodeAPKResources .isSelected ()) {
945946 File decodedResources = new File (tempDirectory + fs + MiscUtils .randomString (32 ) + ".apk" );
946- APKTool .decodeResources (tempCopy , decodedResources );
947+ APKTool .decodeResources (tempCopy , decodedResources , container );
947948 container .files = JarUtils .loadResources (decodedResources );
948949 }
949950
@@ -1080,7 +1081,7 @@ public static void resetWorkSpace(boolean ask)
10801081 the .bytecode .club .bytecodeviewer .api .BytecodeViewer .getClassNodeLoader ().clear ();
10811082 }
10821083
1083- private static ArrayList <String > killList = new ArrayList <String >();
1084+ private static List <String > killList = new ArrayList <String >();
10841085
10851086 /**
10861087 * Add the recent file
@@ -1109,7 +1110,7 @@ public static void addRecentFile(File f) {
11091110 resetRecentFilesMenu ();
11101111 }
11111112
1112- private static ArrayList <String > killList2 = new ArrayList <String >();
1113+ private static List <String > killList2 = new ArrayList <String >();
11131114
11141115 /**
11151116 * Add to the recent plugin list
@@ -1187,7 +1188,7 @@ public static void cleanup() {
11871188 tempF .mkdir ();
11881189 }
11891190
1190- public static ArrayList <String > createdRandomizedNames = new ArrayList <String >();
1191+ public static List <String > createdRandomizedNames = new ArrayList <String >();
11911192
11921193 /**
11931194 * Ensures it will only return a uniquely generated names, contains a dupe checker to be sure
@@ -1254,7 +1255,7 @@ private static void hideFile(File f) {
12541255 * @param a array
12551256 * @return string with newline per array object
12561257 */
1257- private static String quickConvert (ArrayList <String > a ) {
1258+ private static String quickConvert (List <String > a ) {
12581259 return gson .toJson (a );
12591260 }
12601261
@@ -1471,11 +1472,30 @@ else if (BytecodeViewer.viewer.panelGroup3.isSelected(BytecodeViewer.viewer.pane
14711472 return files ;
14721473 }
14731474
1474- public static void rtCheck ()
1475+ public synchronized static void rtCheck ()
14751476 {
1476- if (rt .equals ("" ) && RJ_JAR . exists () )
1477+ if (rt .equals ("" ))
14771478 {
1478- rt = RJ_JAR .getAbsolutePath ();
1479+ if (RT_JAR .exists ())
1480+ {
1481+ rt = RT_JAR .getAbsolutePath ();
1482+ }
1483+ else if (RT_JAR_DUMPED .exists ())
1484+ {
1485+ rt = RT_JAR_DUMPED .getAbsolutePath ();
1486+ }
1487+ else
1488+ {
1489+ try
1490+ {
1491+ JRTExtractor .extractRT (RT_JAR_DUMPED .getAbsolutePath ());
1492+ rt = RT_JAR_DUMPED .getAbsolutePath ();
1493+ }
1494+ catch (Throwable t )
1495+ {
1496+ t .printStackTrace ();
1497+ }
1498+ }
14791499 }
14801500 }
14811501
0 commit comments