Skip to content

Commit

Permalink
Merge pull request QuestCraftPlusPlus#40 from QuestCraftPlusPlus/Ques…
Browse files Browse the repository at this point in the history
…tCraft-JRE21

Update to JRE-21, use ZGC
  • Loading branch information
thejudge156 authored Apr 14, 2024
2 parents 94c5b1f + ddacafb commit 05effa3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
Binary file not shown.
6 changes: 3 additions & 3 deletions src/main/java/pojlib/UnityPlayerActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ protected String updateUnityCommandLineArguments(String cmdLine)
mUnityPlayer = new UnityPlayer(this, this);
setContentView(mUnityPlayer);
mUnityPlayer.requestFocus();
File zip = new File(this.getFilesDir() + "/runtimes/JRE-17.zip");
File zip = new File(this.getFilesDir() + "/runtimes/JRE-21.zip");
if(!zip.exists()) {
try {
FileUtils.writeByteArrayToFile(zip, FileUtil.loadFromAssetToByte(this, "JRE-17.zip"));
FileUtils.writeByteArrayToFile(zip, FileUtil.loadFromAssetToByte(this, "JRE-21.zip"));
byte[] buffer = new byte[1024];
ZipInputStream zis = new ZipInputStream(Files.newInputStream(zip.toPath()));
ZipEntry zipEntry = zis.getNextEntry();
while (zipEntry != null) {
File newFile = newFile(new File(this.getFilesDir() + "/runtimes/JRE-17"), zipEntry);
File newFile = newFile(new File(this.getFilesDir() + "/runtimes/JRE-21"), zipEntry);
if (zipEntry.isDirectory()) {
if (!newFile.isDirectory() && !newFile.mkdirs()) {
throw new IOException("Failed to create directory " + newFile);
Expand Down
17 changes: 10 additions & 7 deletions src/main/java/pojlib/util/JREUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,22 +130,22 @@ public void run() {
public static void relocateLibPath(final Context ctx) {
sNativeLibDir = ctx.getApplicationInfo().nativeLibraryDir;

LD_LIBRARY_PATH = ctx.getFilesDir() + "/runtimes/JRE-17/bin" + "/lib64/jli:" + ctx.getFilesDir() + "/runtimes/JRE-17/lib:" +
LD_LIBRARY_PATH = ctx.getFilesDir() + "/runtimes/JRE-21/bin:" + ctx.getFilesDir() + "/runtimes/JRE-21/lib:" +
"/system/lib64:/vendor/lib64:/vendor/lib64/hw:" +
sNativeLibDir;
}

public static void setJavaEnvironment(Activity activity) throws Throwable {
Map<String, String> envMap = new ArrayMap<>();
envMap.put("POJLIB_NATIVEDIR", activity.getApplicationInfo().nativeLibraryDir);
envMap.put("JAVA_HOME", activity.getFilesDir() + "/runtimes/JRE-17");
envMap.put("JAVA_HOME", activity.getFilesDir() + "/runtimes/JRE-21");
envMap.put("HOME", Constants.MC_DIR);
envMap.put("TMPDIR", activity.getCacheDir().getAbsolutePath());
envMap.put("VR_MODEL", API_V1.model);
envMap.put("POJLIB_RENDERER", "regal");

envMap.put("LD_LIBRARY_PATH", LD_LIBRARY_PATH);
envMap.put("PATH", activity.getFilesDir() + "/runtimes/JRE-17/bin:" + Os.getenv("PATH"));
envMap.put("PATH", activity.getFilesDir() + "/runtimes/JRE-21/bin:" + Os.getenv("PATH"));

File customEnvFile = new File(Constants.USER_HOME, "custom_env.txt");
if (customEnvFile.exists() && customEnvFile.isFile()) {
Expand All @@ -164,8 +164,8 @@ public static void setJavaEnvironment(Activity activity) throws Throwable {
Os.setenv(env.getKey(), env.getValue(), true);
}

File serverFile = new File(activity.getFilesDir() + "/runtimes/JRE-17/lib/server/libjvm.so");
jvmLibraryPath = activity.getFilesDir() + "/runtimes/JRE-17/lib/" + (serverFile.exists() ? "server" : "client");
File serverFile = new File(activity.getFilesDir() + "/runtimes/JRE-21/lib/server/libjvm.so");
jvmLibraryPath = activity.getFilesDir() + "/runtimes/JRE-21/lib/" + (serverFile.exists() ? "server" : "client");
Log.d("DynamicLoader","Base LD_LIBRARY_PATH: "+LD_LIBRARY_PATH);
Log.d("DynamicLoader","Internal LD_LIBRARY_PATH: "+jvmLibraryPath+":"+LD_LIBRARY_PATH);
setLdLibraryPath(jvmLibraryPath+":"+LD_LIBRARY_PATH);
Expand Down Expand Up @@ -193,6 +193,9 @@ public static int launchJavaVM(final Activity activity, final List<String> JVMAr
}
}

userArgs.add("-XX:+UseZGC");
userArgs.add("-XX:+ZGenerational");

userArgs.add("-Dorg.lwjgl.opengl.libname=" + graphicsLib);
userArgs.add("-Dorg.lwjgl.opengles.libname=" + "/system/lib64/libGLESv3.so");
userArgs.add("-Dorg.lwjgl.egl.libname=" + "/system/lib64/libEGL_dri.so");
Expand All @@ -201,7 +204,7 @@ public static int launchJavaVM(final Activity activity, final List<String> JVMAr
userArgs.addAll(JVMArgs);
System.out.println(JVMArgs);

runtimeDir = activity.getFilesDir() + "/runtimes/JRE-17";
runtimeDir = activity.getFilesDir() + "/runtimes/JRE-21";

initJavaRuntime();
chdir(Constants.MC_DIR);
Expand All @@ -220,7 +223,7 @@ public static int launchJavaVM(final Activity activity, final List<String> JVMAr
*/
public static List<String> getJavaArgs(Context ctx) {
return new ArrayList<>(Arrays.asList(
"-Djava.home=" + new File(ctx.getFilesDir(), "runtimes/JRE-17"),
"-Djava.home=" + new File(ctx.getFilesDir(), "runtimes/JRE-21"),
"-Djava.io.tmpdir=" + ctx.getCacheDir().getAbsolutePath(),
"-Duser.home=" + Constants.MC_DIR,
"-Duser.language=" + System.getProperty("user.language"),
Expand Down

0 comments on commit 05effa3

Please sign in to comment.