@@ -36,8 +36,6 @@ public class JREUtils {
3636 private JREUtils () {}
3737
3838 public static String LD_LIBRARY_PATH ;
39- public static Map <String , String > jreReleaseList ;
40- public static String instanceHome ;
4139 public static String jvmLibraryPath ;
4240 private static String sNativeLibDir ;
4341 private static String runtimeDir ;
@@ -62,21 +60,6 @@ public static String findInLdLibPath(String libName) {
6260 return libName ;
6361 }
6462
65- public static ArrayList <File > locateLibs (File path ) {
66- ArrayList <File > returnValue = new ArrayList <>();
67- File [] list = path .listFiles ();
68- if (list != null ) {
69- for (File f : list ) {
70- if (f .isFile () && f .getName ().endsWith (".so" )) {
71- returnValue .add (f );
72- }else if (f .isDirectory ()) {
73- returnValue .addAll (locateLibs (f ));
74- }
75- }
76- }
77- return returnValue ;
78- }
79-
8063 public static boolean initJavaRuntime () {
8164 dlopen (findInLdLibPath ("server/libjvm.so" ));
8265 dlopen (findInLdLibPath ("libverify.so" ));
@@ -98,6 +81,24 @@ public static boolean initJavaRuntime() {
9881 return true ;
9982 }
10083
84+ public static boolean initializeExtraNatives (MinecraftInstances .Instance instance ) {
85+ if (instance .extraNatives == null ) {
86+ return false ;
87+ }
88+
89+ for (String nativeLib : instance .extraNatives .split (File .pathSeparator )) {
90+ dlopen (nativeLib );
91+ }
92+
93+ String dlerr = dlerror ();
94+ if (dlerr .contains (runtimeDir )) {
95+ Logger .getInstance ().appendToLog ("ERROR! Could not dlopen extra natives! " + dlerr );
96+ return false ;
97+ }
98+
99+ return true ;
100+ }
101+
101102 public static void redirectAndPrintJRELog () {
102103 Log .v ("jrelog" ,"Log starts here" );
103104 JREUtils .logToLogger (Logger .getInstance ());
@@ -140,11 +141,11 @@ public void run() {
140141 Log .i ("jrelog-logcat" ,"Logcat thread started" );
141142 }
142143
143- public static void relocateLibPath (final Context ctx ) {
144+ public static void relocateLibPath (final Context ctx , MinecraftInstances . Instance instance ) {
144145 sNativeLibDir = ctx .getApplicationInfo ().nativeLibraryDir ;
145146
146147 LD_LIBRARY_PATH = ctx .getFilesDir () + "/runtimes/JRE/bin:" + ctx .getFilesDir () + "/runtimes/JRE/lib:" +
147- "/system/lib64:/vendor/lib64:/vendor/lib64/hw:" +
148+ "/system/lib64:/vendor/lib64:/vendor/lib64/hw:" + ctx . getDataDir (). toPath (). resolve ( instance . instanceName ) + ":" +
148149 sNativeLibDir ;
149150 }
150151
@@ -192,7 +193,7 @@ public static void setJavaEnvironment(Activity activity, MinecraftInstances.Inst
192193 // Called before game launch to ensure all files are present and correct
193194 public static boolean prelaunchCheck (Activity activity , MinecraftInstances .Instance instance ) throws Throwable {
194195 runtimeDir = activity .getFilesDir () + "/runtimes/JRE" ;
195- JREUtils .relocateLibPath (activity );
196+ JREUtils .relocateLibPath (activity , instance );
196197 setJavaEnvironment (activity , instance );
197198
198199 UnityPlayerActivity .installLWJGL (activity );
@@ -215,7 +216,7 @@ public static int launchJavaVM(final Activity activity, final List<String> JVMAr
215216
216217 //Add automatically generated args
217218 if (API .customRAMValue ) {
218- Logger .getInstance ().appendToLog ("QuestCraft: Setting JVM memory to " + API .memoryValue + "MB (Custom)" );
219+ Logger .getInstance ().appendToLog ("etting JVM memory to " + API .memoryValue + "MB (Custom)" );
219220 userArgs .add ("-Xms" + API .memoryValue + "M" );
220221 userArgs .add ("-Xmx" + API .memoryValue + "M" );
221222 } else {
@@ -225,18 +226,22 @@ public static int launchJavaVM(final Activity activity, final List<String> JVMAr
225226 long availMem = (ami .availMem -ami .threshold )/(1024 *1024 );
226227 long allocatedRam = Math .max (availMem , 1536 );
227228
228- Logger .getInstance ().appendToLog ("QuestCraft: Setting JVM memory to " + allocatedRam + "MB" );
229+ Logger .getInstance ().appendToLog ("Setting JVM memory to " + allocatedRam + "MB" );
229230
230231 userArgs .add ("-Xms" + 1024 + "M" );
231232 userArgs .add ("-Xmx" + allocatedRam + "M" );
232233 }
233234
235+ if (!initializeExtraNatives (instance )) {
236+ Logger .getInstance ().appendToLog ("Some libraries did not dlopen properly. This can be safely ignored in most cases." );
237+ }
234238
235239 // Garbage collection
236- userArgs .add ("-XX:+UseShenandoahGC " );
240+ userArgs .add ("-XX:+UseG1GC " );
237241 userArgs .add ("-XX:+UnlockDiagnosticVMOptions" );
238242
239243 userArgs .add ("-XX:+UnlockExperimentalVMOptions" );
244+ userArgs .add ("-XX:-TieredCompilation" );
240245
241246 // Android sig fix
242247 userArgs .add ("-XX:+UseSignalChaining" );
0 commit comments