jaulib v1.3.0
Jau Support Library (C++, Java, ..)
RuntimeProps.java
Go to the documentation of this file.
1/**
2 * Author: Sven Gothel <sgothel@jausoft.com>
3 * Copyright (c) 2010-2023 Gothel Software e.K.
4 * Copyright (c) 2010 JogAmp Community.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining
7 * a copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sublicense, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be
15 * included in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 */
25package org.jau.sys;
26
27import org.jau.lang.ReflectionUtil;
28import org.jau.sys.PlatformTypes.OSType;
29
30/**
31 * Runtime platform properties derived from {@link PlatformProps} and runtime query.
32 *
33 * Static initializer loads the native jaulib library, if available.
34 */
35public class RuntimeProps {
36 private static final String prt_name = "jau.pkg.PlatformRuntime";
37
38 //
39 // static initialization order:
40 //
41
42 public static final boolean DEBUG;
43
44 /** Runtime determined {@link MachineDataInfo}, null if not available (i.e. no JNI libs loaded). */
45 public static final MachineDataInfo MACH_DESC_RT;
46
47 /**
48 * true if enabled and in use.
49 * <p>
50 * System property: 'jau.pkg.UseTempJarCache',
51 * defaults to true if {@link #OS_TYPE} is not {@link OSType#ANDROID}.
52 * </p>
53 */
54 public static final boolean USE_TEMP_JAR_CACHE;
55
56 static {
58
59 {
60 boolean _USE_TEMP_JAR_CACHE = false;
61 Class<?> prt = null;
62 try {
63 prt = ReflectionUtil.getClass(prt_name, true /* initializeClazz */, RuntimeProps.class.getClassLoader());
64 } catch (final Throwable t) {
65 if( DEBUG ) {
66 System.err.println("Platform.RT: Exception: "+t.getMessage());
67 t.printStackTrace();
68 }
69 }
70 if( null != prt ) {
71 final ReflectionUtil.MethodAccessor prtGetMachDesc = new ReflectionUtil.MethodAccessor(prt, "getMachineDataInfo");
72 final ReflectionUtil.MethodAccessor prtGetUseTempJarCache = new ReflectionUtil.MethodAccessor(prt, "getUseTempJarCache");
73 if( null != prtGetMachDesc && prtGetMachDesc.available() ) {
74 MACH_DESC_RT = prtGetMachDesc.callStaticMethod();
75 _USE_TEMP_JAR_CACHE = null != MACH_DESC_RT;
76 if( DEBUG ) {
77 System.err.println("Platform.RT: Available <"+prt_name+".getMachineDataInfo()>");
78 }
79 } else {
80 MACH_DESC_RT = null;
81 if( DEBUG ) {
82 System.err.println("Platform.RT: Not available (2) <"+prt_name+".getMachineDataInfo()>");
83 }
84 }
85 if( null != prtGetUseTempJarCache && prtGetUseTempJarCache.available() ) {
86 _USE_TEMP_JAR_CACHE = prtGetUseTempJarCache.callStaticMethod();
87 if( DEBUG ) {
88 System.err.println("Platform.RT: Available <"+prt_name+".getUseTempJarCache()> = "+_USE_TEMP_JAR_CACHE);
89 }
90 } else {
91 if( DEBUG ) {
92 System.err.println("Platform.RT: Not available (3) <"+prt_name+".getUseTempJarCache()>");
93 }
94 }
95 } else {
96 MACH_DESC_RT = null;
97 if( DEBUG ) {
98 System.err.println("Platform.RT: Not available (1) <"+prt_name+">");
99 }
100 }
101 USE_TEMP_JAR_CACHE = _USE_TEMP_JAR_CACHE;
102 }
103
104 if( DEBUG ) {
105 System.err.println("Platform.MD.RT: "+MACH_DESC_RT);
106 System.err.println("Platform.sys: USE_TEMP_JAR_CACHE "+USE_TEMP_JAR_CACHE);
107 }
108 }
109 public static void initSingleton() { }
110
111 /**
112 * Returns true if enabled and in use.
113 * <p>
114 * System property: 'jau.pkg.UseTempJarCache',
115 * defaults to true if {@link #O} is not {@link OSType#ANDROID}.
116 * </p>
117 */
118 public static final boolean getUseTempJarCache() { return USE_TEMP_JAR_CACHE; }
119
120 protected RuntimeProps() {}
121
122}
Utility methods to simplify reflection access.
static final Class<?> getClass(final String clazzName, final boolean initializeClazz, final ClassLoader cl)
Loads and returns the class or null.
Machine data description for alignment and size onle, see com.jogamp.gluegen.
Platform Properties derived from Java properties.
static final boolean DEBUG
Runtime platform properties derived from PlatformProps and runtime query.
static final boolean USE_TEMP_JAR_CACHE
true if enabled and in use.
static final boolean getUseTempJarCache()
Returns true if enabled and in use.
static final boolean DEBUG
static final MachineDataInfo MACH_DESC_RT
Runtime determined MachineDataInfo, null if not available (i.e.