mirror of
https://github.com/termux/termux-packages.git
synced 2024-12-11 23:00:52 +00:00
940a37f5f0
cherry-pick all patches, apply them on upstream JDK, and adapted for newer $UPDATE version fix: type redefinition introduced in 21.0.2
73 lines
2.9 KiB
Diff
73 lines
2.9 KiB
Diff
From 71f950a52f92029135ce60b8783de3d60c13d6ae Mon Sep 17 00:00:00 2001
|
|
From: Duy Tran Khanh <40482367+khanhduytran0@users.noreply.github.com>
|
|
Date: Fri, 11 Jun 2021 07:48:28 +0700
|
|
Subject: [PATCH 14/37] Fix libjvm.so path when run from Android app
|
|
|
|
---
|
|
src/java.base/unix/native/libjli/java_md.c | 49 ++++++++++++++++++++++
|
|
1 file changed, 49 insertions(+)
|
|
|
|
diff --git a/src/java.base/unix/native/libjli/java_md.c b/src/java.base/unix/native/libjli/java_md.c
|
|
index 024cec571..d11a921f1 100644
|
|
--- a/src/java.base/unix/native/libjli/java_md.c
|
|
+++ b/src/java.base/unix/native/libjli/java_md.c
|
|
@@ -594,6 +594,55 @@ SetExecname(char **argv)
|
|
exec_path = JLI_StringDup(buf);
|
|
}
|
|
}
|
|
+#elif defined(__ANDROID__)
|
|
+ char *__java_home = getenv("JAVA_HOME");
|
|
+ // From http://hg.openjdk.java.net/mobile/jdk9/jdk/file/17bb8a98d5e3/src/java.base/unix/native/libjli/java_md_solinux.c#l844
|
|
+ /* For Android, 'self' would point to /system/bin/app_process
|
|
+ * since we are really executing a Dalvik program at this point.
|
|
+ * argv[0] points to the Dalvik application name and we set the
|
|
+ * path to __java_home.
|
|
+ */
|
|
+ char buf[PATH_MAX+1];
|
|
+ char *p = NULL;
|
|
+ if ((p = JLI_StrRChr(argv[0], '/')) != 0) {
|
|
+ /* may be running from command line */
|
|
+ p++;
|
|
+ if ((JLI_StrLen(p) == 4) && JLI_StrCmp(p, "java") == 0) {
|
|
+ /* started as 'java'. Must be command line */
|
|
+ JLI_TraceLauncher("SetExecName maybe command line = %s\n", argv[0]);
|
|
+ if (*argv[0] != '/') {
|
|
+ char *curdir = NULL;
|
|
+ /* get absolute path */
|
|
+ getcwd(buf, PATH_MAX);
|
|
+ curdir = JLI_StringDup(buf);
|
|
+ JLI_Snprintf(buf, PATH_MAX, "%s/%s", curdir, argv[0]);
|
|
+ JLI_MemFree(curdir);
|
|
+ } else {
|
|
+ JLI_Snprintf(buf, PATH_MAX, "%s", argv[0]);
|
|
+ }
|
|
+ } else {
|
|
+ /* Not command line, see if __java_home set */
|
|
+ if (__java_home != NULL) {
|
|
+ JLI_TraceLauncher("SetExecName not java = %s\n", __java_home);
|
|
+ JLI_Snprintf(buf, PATH_MAX, "%s/bin/java", __java_home);
|
|
+ } else {
|
|
+ /* Fake it as best we can or should we punt? */
|
|
+ JLI_TraceLauncher("SetExecName fake it = %s\n", argv[0]);
|
|
+ JLI_Snprintf(buf, PATH_MAX, "@TERMUX_PREFIX@/bin/java");
|
|
+ }
|
|
+ }
|
|
+ } else {
|
|
+ /* Not started as 'java', see if __java_home set */
|
|
+ if (__java_home != NULL) {
|
|
+ JLI_TraceLauncher("SetExecName not command line = %s\n", __java_home);
|
|
+ JLI_Snprintf(buf, PATH_MAX, "%s/bin/java", __java_home);
|
|
+ } else {
|
|
+ /* Fake it as best we can or should we punt? */
|
|
+ JLI_TraceLauncher("SetExecName fake it 2 = %s\n", argv[0]);
|
|
+ JLI_Snprintf(buf, PATH_MAX, "@TERMUX_PREFIX@/bin/java");
|
|
+ }
|
|
+ }
|
|
+ exec_path = JLI_StringDup(buf);
|
|
#else /* !__linux__ */
|
|
{
|
|
/* Not implemented */
|
|
--
|
|
2.45.2
|
|
|