blob: bc22912a09e427d98531042c68d9ccbde058d0d0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
package jau.pkg;
import java.security.AccessController;
import java.security.PrivilegedAction;
import org.jau.net.Uri;
import org.jau.pkg.JNIJarLibrary;
import org.jau.pkg.JarUtil;
import org.jau.pkg.cache.TempJarCache;
import org.jau.sys.JNILibrary;
import org.jau.sys.MachineDataInfo;
import org.jau.sys.PlatformProps;
import org.jau.sys.PlatformTypes.OSType;
import org.jau.sys.PropertyAccess;
import jau.sys.MachineDataInfoRuntime;
/**
* Initialized by {@link org.jau.sys.PlatformProps}
*/
public class PlatformRuntime {
private static final String useTempJarCachePropName = "jau.pkg.UseTempJarCache";
private static final String[] libBaseNames = { "jaulib_jni_jni", "jaulib_pkg_jni"} ;
//
// static initialization order:
//
/**
* System property: 'jogamp.gluegen.UseTempJarCache',
* defaults to true if {@link #OS_TYPE} is not {@link OSType#ANDROID}.
*/
public static final boolean USE_TEMP_JAR_CACHE;
//
// post loading native lib:
//
public static final boolean isRunningFromJarURL;
/** Runtime determined {@link MachineDataInfo}. */
public static final MachineDataInfo MACH_DESC_RT;
static {
final boolean[] _isRunningFromJarURL = new boolean[] { false };
final boolean[] _USE_TEMP_JAR_CACHE = new boolean[] { false };
AccessController.doPrivileged(new PrivilegedAction<Object>() {
@Override
public Object run() {
final ClassLoader cl = PlatformRuntime.class.getClassLoader();
final Uri platformClassJarURI;
{
Uri _platformClassJarURI = null;
try {
_platformClassJarURI = JarUtil.getJarUri(PlatformRuntime.class.getName(), cl);
} catch (final Exception e) { }
platformClassJarURI = _platformClassJarURI;
}
_isRunningFromJarURL[0] = null != platformClassJarURI;
_USE_TEMP_JAR_CACHE[0] = ( PlatformProps.OS != OSType.ANDROID ) && ( PlatformProps.OS != OSType.IOS ) &&
( null != platformClassJarURI ) &&
PropertyAccess.getBooleanProperty(useTempJarCachePropName, true, true);
// load GluegenRT native library
if(_USE_TEMP_JAR_CACHE[0] && TempJarCache.initSingleton() && TempJarCache.isInitialized(true) ) {
try {
JNIJarLibrary.addNativeJarLibs(new Class<?>[] { org.jau.sys.Debug.class }, null);
} catch (final Exception e0) {
// IllegalArgumentException, IOException
System.err.println("Caught "+e0.getClass().getSimpleName()+": "+e0.getMessage()+", while JNILibLoaderBase.addNativeJarLibs(..)");
}
}
for(final String libBaseName : libBaseNames) {
JNILibrary.loadLibrary(libBaseName, false, cl);
}
return null;
} } );
isRunningFromJarURL = _isRunningFromJarURL[0];
USE_TEMP_JAR_CACHE = _USE_TEMP_JAR_CACHE[0];
//
// Validate and setup MachineDataInfo.StaticConfig
//
MachineDataInfoRuntime.initialize();
MACH_DESC_RT = MachineDataInfoRuntime.getRuntime();
}
/**
* kick off static initialization of <i>platform property information</i> and <i>native gluegen_rt lib loading</i>
*/
public static void initSingleton() { }
/**
* Returns the MachineDataInfo of the running machine.
*/
public static MachineDataInfo getMachineDataInfo() {
return MACH_DESC_RT;
}
}
|