summaryrefslogtreecommitdiffstats
path: root/src/java/com/sun/gluegen/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/com/sun/gluegen/runtime')
-rwxr-xr-xsrc/java/com/sun/gluegen/runtime/CPU.java25
-rwxr-xr-xsrc/java/com/sun/gluegen/runtime/NativeLibrary.java2
2 files changed, 12 insertions, 15 deletions
diff --git a/src/java/com/sun/gluegen/runtime/CPU.java b/src/java/com/sun/gluegen/runtime/CPU.java
index c7e6bc1..ee6c9f5 100755
--- a/src/java/com/sun/gluegen/runtime/CPU.java
+++ b/src/java/com/sun/gluegen/runtime/CPU.java
@@ -38,6 +38,7 @@
*/
package com.sun.gluegen.runtime;
+import java.security.*;
/** Provides information to autogenerated struct accessors about what
kind of data model (32- or 64-bit) is being used by the currently
@@ -47,23 +48,16 @@ public class CPU {
private static boolean is32Bit;
static {
+ NativeLibrary.ensureNativeLibLoaded();
+
boolean done=false;
// Try to use Sun's sun.arch.data.model first ..
- int bits = 0;
- try {
- String bitS =
- (String) AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- return System.getProperty("sun.arch.data.model");
- }
- });
- if(null!=bitS && bitS.length()>0) {
- bits = Integer.parseInt(bitS);
- is32Bit = ( 32 == bits );
- done = true ;
- }
- } catch (NumberFormatException nfe) {}
+ int bits = getPointerSizeInBits();
+ if ( 32 == bits || 64 == bits ) {
+ is32Bit = ( 32 == bits );
+ done = true ;
+ }
if(!done) {
// We don't seem to need an AccessController.doPrivileged() block
@@ -114,4 +108,7 @@ public class CPU {
public static boolean is32Bit() {
return is32Bit;
}
+
+ public static native int getPointerSizeInBits();
+
}
diff --git a/src/java/com/sun/gluegen/runtime/NativeLibrary.java b/src/java/com/sun/gluegen/runtime/NativeLibrary.java
index 22063a5..c4c9f25 100755
--- a/src/java/com/sun/gluegen/runtime/NativeLibrary.java
+++ b/src/java/com/sun/gluegen/runtime/NativeLibrary.java
@@ -412,7 +412,7 @@ public class NativeLibrary {
}
private static volatile boolean loadedDynLinkNativeLib;
- private static void ensureNativeLibLoaded() {
+ static void ensureNativeLibLoaded() {
if (!loadedDynLinkNativeLib) {
synchronized (NativeLibrary.class) {
if (!loadedDynLinkNativeLib) {