[java-access-bridge] Code to fix JNI problem with 64-bit JVM
- From: Ke Wang <kewang src gnome org>
- To: svn-commits-list gnome org
- Subject: [java-access-bridge] Code to fix JNI problem with 64-bit JVM
- Date: Tue, 9 Jun 2009 06:28:54 -0400 (EDT)
commit 3412bf14b5c379687aa83bc3e75d6447d3724eee
Author: Ke Wang <ke wang sun com>
Date: Tue Jun 9 18:05:17 2009 +0800
Code to fix JNI problem with 64-bit JVM
---
bridge/org/GNOME/Accessibility/JavaBridge.java | 75 ++++++++++++++----------
1 files changed, 45 insertions(+), 30 deletions(-)
diff --git a/bridge/org/GNOME/Accessibility/JavaBridge.java b/bridge/org/GNOME/Accessibility/JavaBridge.java
index 1f155f8..0e0bfdc 100644
--- a/bridge/org/GNOME/Accessibility/JavaBridge.java
+++ b/bridge/org/GNOME/Accessibility/JavaBridge.java
@@ -334,6 +334,47 @@ public class JavaBridge {
};
}
+ private boolean loadJni() {
+ try {
+ String javaHome = System.getProperty ("java.home");
+ String jvmArch = System.getProperty ("sun.arch.data.model");
+ String osArch = System.getProperty ("os.arch");
+ String fileSep = System.getProperty ("file.separator");
+ String libPath = javaHome + "/lib/ext/libjava-access-bridge-jni.so";
+
+ if ("64".equals(jvmArch)) {
+ String libPath64 = javaHome + "/lib/ext/" + osArch + "/libjava-access-bridge-jni.so";
+ java.io.File fileLib64 = new java.io.File( libPath64.replace('/', fileSep.charAt(0)) );
+ if (fileLib64.exists()) {
+ libPath = libPath64;
+ }
+ }
+
+ if (!libPath.equals("")) {
+ libPath = libPath.replace('/', fileSep.charAt(0));
+ System.load (libPath);
+
+ if (debugFlag) {
+ System.err.println ( libPath + " loaded" );
+ }
+ } else {
+ if (debugFlag) {
+ System.err.println ( "Error: jni library not found" );
+ }
+
+ return false;
+ }
+ }
+ catch (Throwable ex)
+ {
+ System.err.println(ex+" caught.");
+ ex.printStackTrace();
+ return false;
+ }
+
+ return true;
+ }
+
public static void main(String args[]) {
new JavaBridge();
@@ -347,36 +388,6 @@ public class JavaBridge {
if (debugFlag)
System.err.println ("Java Accessibility Bridge for GNOME loaded.\n");
- try {
- String javaHome = System.getProperty ("java.home");
- String jvmArch = System.getProperty ("sun.arch.data.model");
- String osArch = System.getProperty ("os.arch");
- String libPath = "";
-
- if ("32".equals(jvmArch)) {
- libPath = javaHome + "/lib/ext/libjava-access-bridge-jni.so";
- } else if ("64".equals(jvmArch)) {
- if ("amd64".equals(osArch)) {
- libPath = javaHome + "/lib/ext/amd64/libjava-access-bridge-jni.so";
- } else if ("sparcv9".equals(osArch)) {
- libPath = javaHome + "/lib/ext/sparcv9/libjava-access-bridge-jni.so";
- }
- }
-
- if (debugFlag) {
- if (!libPath.equals("")) {
- System.err.println ( libPath + " loaded" );
- } else {
- System.err.println ( "Error: jni library not found" );
- }
- }
- }
- catch (Exception ex)
- {
- System.err.println(ex+" caught.");
- ex.printStackTrace();
- }
-
// Not sure what kind of arguments should be sent to ORB
String vm_rev = System.getProperty("java.version");
@@ -1129,6 +1140,10 @@ public class JavaBridge {
return false;
}
+ if (! loadJni() ) {
+ return false;
+ }
+
if (AccessUtil.getRegistryObject() == null)
return false;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]