mirror of
https://github.com/AngelAuraMC/angelauramc-openjdk-build.git
synced 2025-09-12 13:45:30 -04:00
Add patch for AWT_OnLoad path
This patch makes the runtime work properly on devices with old Android versions - originally it doesn't work due to a dlinfo bug in Android < 7
This commit is contained in:
parent
17e0a04f4d
commit
7039d84be4
@ -60816,3 +60816,50 @@ index edd3bc69e1..a28d3540f0 100644
|
||||
|
||||
#include "utf.h"
|
||||
|
||||
diff --git a/jdk/src/solaris/native/sun/awt/awt_LoadLibrary.c b/jdk/src/solaris/native/sun/awt/awt_LoadLibrary.c
|
||||
index 5948302713..76755e98aa 100644
|
||||
--- a/jdk/src/solaris/native/sun/awt/awt_LoadLibrary.c
|
||||
+++ b/jdk/src/solaris/native/sun/awt/awt_LoadLibrary.c
|
||||
@@ -93,6 +93,29 @@ JNIEXPORT jboolean JNICALL AWTIsHeadless() {
|
||||
#define DEFAULT_PATH XAWT_PATH
|
||||
#define HEADLESS_PATH "/libawt_headless.so"
|
||||
#endif
|
||||
+static bool read_so_path_from_maps(const char* so_name, char* buf) {
|
||||
+ FILE *fp = fopen("/proc/self/maps", "r");
|
||||
+ assert(fp, "Failed to open /proc/self/maps");
|
||||
+ if (!fp) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ char maps_buffer[2048];
|
||||
+ while (fgets(maps_buffer, 2048, fp) != NULL) {
|
||||
+ if (strstr(maps_buffer, so_name) == NULL) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ char *so_path = strchr(maps_buffer, '/');
|
||||
+ so_path[strlen(so_path) - 1] = '\0'; // Cut trailing \n
|
||||
+ strcpy(buf,so_path);
|
||||
+ fclose(fp);
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ fclose(fp);
|
||||
+ return false;
|
||||
+}
|
||||
|
||||
jint
|
||||
AWT_OnLoad(JavaVM *vm, void *reserved)
|
||||
@@ -117,7 +140,11 @@ AWT_OnLoad(JavaVM *vm, void *reserved)
|
||||
|
||||
/* Get address of this library and the directory containing it. */
|
||||
dladdr((void *)AWT_OnLoad, &dlinfo);
|
||||
- realpath((char *)dlinfo.dli_fname, buf);
|
||||
+ if (strrchr(dlinfo.dli_fname, '/') != NULL) {
|
||||
+ realpath((char *)dlinfo.dli_fname, buf);
|
||||
+ }else{
|
||||
+ read_so_path_from_maps(dlinfo.dli_fname,buf);
|
||||
+ }
|
||||
len = strlen(buf);
|
||||
p = strrchr(buf, '/');
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user