diff options
Diffstat (limited to 'src/java')
-rw-r--r-- | src/java/com/jogamp/common/os/DynamicLibraryBundle.java | 2 | ||||
-rw-r--r-- | src/java/com/jogamp/common/os/MachineDataInfo.java | 10 | ||||
-rw-r--r-- | src/java/com/jogamp/common/os/NativeLibrary.java | 68 | ||||
-rw-r--r-- | src/java/com/jogamp/common/os/Platform.java | 12 | ||||
-rw-r--r-- | src/java/com/jogamp/common/util/IOUtil.java | 3 | ||||
-rw-r--r-- | src/java/com/jogamp/common/util/JarUtil.java | 2 | ||||
-rw-r--r-- | src/java/com/jogamp/common/util/VersionUtil.java | 2 | ||||
-rw-r--r-- | src/java/jogamp/common/os/DynamicLinkerImpl.java | 11 | ||||
-rw-r--r-- | src/java/jogamp/common/os/MachineDataInfoRuntime.java | 9 | ||||
-rw-r--r-- | src/java/jogamp/common/os/PlatformPropsImpl.java | 44 | ||||
-rw-r--r-- | src/java/jogamp/common/os/UnixDynamicLinkerImpl.java | 7 |
11 files changed, 119 insertions, 51 deletions
diff --git a/src/java/com/jogamp/common/os/DynamicLibraryBundle.java b/src/java/com/jogamp/common/os/DynamicLibraryBundle.java index a3d6198..fee3c01 100644 --- a/src/java/com/jogamp/common/os/DynamicLibraryBundle.java +++ b/src/java/com/jogamp/common/os/DynamicLibraryBundle.java @@ -282,7 +282,7 @@ public class DynamicLibraryBundle implements DynamicLookupHelper { } } else { if( null == dynLinkGlobal ) { - dynLinkGlobal = lib.getDynamicLinker(); + dynLinkGlobal = lib.dynamicLinker(); } nativeLibraries.add(lib); toolLibLoaded[i]=true; diff --git a/src/java/com/jogamp/common/os/MachineDataInfo.java b/src/java/com/jogamp/common/os/MachineDataInfo.java index 0192cd8..d6fa28c 100644 --- a/src/java/com/jogamp/common/os/MachineDataInfo.java +++ b/src/java/com/jogamp/common/os/MachineDataInfo.java @@ -64,6 +64,7 @@ public class MachineDataInfo { private final static int[] size_x86_32_windows = { 4, 4, 4, 8, 12, 4, 4096 }; private final static int[] size_lp64_unix = { 4, 8, 4, 8, 16, 8, 4096 }; private final static int[] size_x86_64_windows = { 4, 4, 4, 8, 16, 8, 4096 }; + private final static int[] size_arm64_ios = { 4, 8, 4, 8, 8, 8, 8192 }; /* arch os i8, i16, i32, i64, int, long, float, doubl, ldoubl, ptr */ private final static int[] align_arm_mips_32 = { 1, 2, 4, 8, 4, 4, 4, 8, 8, 4 }; @@ -74,11 +75,12 @@ public class MachineDataInfo { private final static int[] align_x86_32_windows = { 1, 2, 4, 8, 4, 4, 4, 8, 4, 4 }; private final static int[] align_lp64_unix = { 1, 2, 4, 8, 4, 8, 4, 8, 16, 8 }; private final static int[] align_x86_64_windows = { 1, 2, 4, 8, 4, 4, 4, 8, 16, 8 }; + private final static int[] align_arm64_ios = { 1, 2, 4, 8, 4, 8, 4, 8, 8, 8 }; /** * Static enumeration of {@link MachineDataInfo} instances * used for high performance data size and alignment lookups, - * e.g. for generated structures. + * e.g. for generated structures using the {@link MachineDataInfo.StaticConfig} index. * <p> * The value {@link MachineDataInfo#pageSizeInBytes} shall be ignored * for static instances! @@ -109,8 +111,10 @@ public class MachineDataInfo { /** LP64 Unix, e.g.: {@link Platform.CPUType#X86_64} Unix, {@link Platform.CPUType#ARM64} EABI, {@link Platform.CPUType#PPC64} Unix, .. */ LP64_UNIX( size_lp64_unix, align_lp64_unix), /** {@link Platform.CPUType#X86_64} Windows */ - X86_64_WINDOWS( size_x86_64_windows, align_x86_64_windows); - // 8 + X86_64_WINDOWS( size_x86_64_windows, align_x86_64_windows), + /** {@link Platform.CPUType#ARM64 } iOS */ + ARM64_IOS( size_arm64_ios, align_arm64_ios); + // 9 public final MachineDataInfo md; diff --git a/src/java/com/jogamp/common/os/NativeLibrary.java b/src/java/com/jogamp/common/os/NativeLibrary.java index 7c6aeca..1b05700 100644 --- a/src/java/com/jogamp/common/os/NativeLibrary.java +++ b/src/java/com/jogamp/common/os/NativeLibrary.java @@ -94,6 +94,12 @@ public final class NativeLibrary implements DynamicLookupHelper { isOSX = true; break; + case IOS: + prefixes = new String[] { "lib" }; + suffixes = new String[] { ".dylib" }; + isOSX = true; + break; + /* case ANDROID: case FREEBSD: @@ -210,28 +216,7 @@ public final class NativeLibrary implements DynamicLookupHelper { loader); Platform.initSingleton(); // loads native gluegen-rt library - final DynamicLinker dynLink; - switch (PlatformPropsImpl.OS_TYPE) { - case WINDOWS: - dynLink = new WindowsDynamicLinkerImpl(); - break; - - case MACOS: - dynLink = new MacOSXDynamicLinkerImpl(); - break; - - case ANDROID: - if( PlatformPropsImpl.CPU_ARCH.is32Bit ) { - dynLink = new BionicDynamicLinker32bitImpl(); - } else { - dynLink = new BionicDynamicLinker64BitImpl(); - } - break; - - default: - dynLink = new PosixDynamicLinkerImpl(); - break; - } + final DynamicLinker dynLink = getDynamicLinker(); // Iterate down these and see which one if any we can actually find. for (final Iterator<String> iter = possiblePaths.iterator(); iter.hasNext(); ) { @@ -310,7 +295,34 @@ public final class NativeLibrary implements DynamicLookupHelper { return dynLink.lookupSymbolGlobal(funcName); } - /* pp */ final DynamicLinker getDynamicLinker() { return dynLink; } + /* pp */ final DynamicLinker dynamicLinker() { return dynLink; } + + /* pp */ static DynamicLinker getDynamicLinker() { + final DynamicLinker dynLink; + switch (PlatformPropsImpl.OS_TYPE) { + case WINDOWS: + dynLink = new WindowsDynamicLinkerImpl(); + break; + + case MACOS: + case IOS: + dynLink = new MacOSXDynamicLinkerImpl(); + break; + + case ANDROID: + if( PlatformPropsImpl.CPU_ARCH.is32Bit ) { + dynLink = new BionicDynamicLinker32bitImpl(); + } else { + dynLink = new BionicDynamicLinker64BitImpl(); + } + break; + + default: + dynLink = new PosixDynamicLinkerImpl(); + break; + } + return dynLink; + } /** Retrieves the low-level library handle from this NativeLibrary object. On the Windows platform this is an HMODULE, and on Unix @@ -431,9 +443,9 @@ public final class NativeLibrary implements DynamicLookupHelper { // Add probable Mac OS X-specific paths if ( isOSX ) { // Add historical location - addPaths("/Library/Frameworks/" + libName + ".Framework", baseNames, paths); + addPaths("/Library/Frameworks/" + libName + ".framework", baseNames, paths); // Add current location - addPaths("/System/Library/Frameworks/" + libName + ".Framework", baseNames, paths); + addPaths("/System/Library/Frameworks/" + libName + ".framework", baseNames, paths); } } @@ -526,6 +538,7 @@ public final class NativeLibrary implements DynamicLookupHelper { return windowsLibName; case MACOS: + case IOS: return macOSXLibName; default: @@ -601,8 +614,11 @@ public final class NativeLibrary implements DynamicLookupHelper { private static boolean initializedFindLibraryMethod = false; private static Method findLibraryMethod = null; private static final String findLibraryImpl(final String libName, final ClassLoader loader) { + if( PlatformPropsImpl.JAVA_9 ) { + return null; + } if (loader == null) { - return null; + return null; } if (!initializedFindLibraryMethod) { AccessController.doPrivileged(new PrivilegedAction<Object>() { diff --git a/src/java/com/jogamp/common/os/Platform.java b/src/java/com/jogamp/common/os/Platform.java index 535b8a9..1bd3b9d 100644 --- a/src/java/com/jogamp/common/os/Platform.java +++ b/src/java/com/jogamp/common/os/Platform.java @@ -58,7 +58,7 @@ import jogamp.common.os.PlatformPropsImpl; public class Platform extends PlatformPropsImpl { public enum OSType { - LINUX, FREEBSD, ANDROID, MACOS, SUNOS, HPUX, WINDOWS, OPENKODE; + LINUX, FREEBSD, ANDROID, MACOS, SUNOS, HPUX, WINDOWS, OPENKODE, IOS; } public enum CPUFamily { @@ -255,8 +255,11 @@ public class Platform extends PlatformPropsImpl { private static final String useTempJarCachePropName = "jogamp.gluegen.UseTempJarCache"; - /** fixed basename of JAR file and native library */ - private static final String libBaseName = "gluegen-rt"; + /** + * Fixed basename of JAR file and native library. + * Dash replaced by underscore to allow static linkage via JEP 178. + */ + private static final String libBaseName = "gluegen_rt"; // // static initialization order: @@ -302,7 +305,8 @@ public class Platform extends PlatformPropsImpl { } _isRunningFromJarURL[0] = null != platformClassJarURI; - _USE_TEMP_JAR_CACHE[0] = ( OS_TYPE != OSType.ANDROID ) && ( null != platformClassJarURI ) && + _USE_TEMP_JAR_CACHE[0] = ( OS_TYPE != OSType.ANDROID ) && ( OS_TYPE != OSType.IOS ) && + ( null != platformClassJarURI ) && PropertyAccess.getBooleanProperty(useTempJarCachePropName, true, true); // load GluegenRT native library diff --git a/src/java/com/jogamp/common/util/IOUtil.java b/src/java/com/jogamp/common/util/IOUtil.java index 0bee22b..380cb00 100644 --- a/src/java/com/jogamp/common/util/IOUtil.java +++ b/src/java/com/jogamp/common/util/IOUtil.java @@ -863,6 +863,7 @@ public class IOUtil { switch(PlatformPropsImpl.OS_TYPE) { case ANDROID: case MACOS: + case IOS: case WINDOWS: case OPENKODE: return false; @@ -1273,7 +1274,7 @@ public class IOUtil { // 1) java.io.tmpdir/jogamp if( null == tempRootExec && null != java_io_tmpdir ) { - if( Platform.OSType.MACOS == PlatformPropsImpl.OS_TYPE ) { + if( Platform.OSType.MACOS == PlatformPropsImpl.OS_TYPE || Platform.OSType.IOS == PlatformPropsImpl.OS_TYPE ) { // Bug 865: Safari >= 6.1 [OSX] May employ xattr on 'com.apple.quarantine' on 'PluginProcess.app' // We attempt to fix this issue _after_ gluegen native lib is loaded, see JarUtil.fixNativeLibAttribs(File). tempRootExec = getSubTempDir(java_io_tmpdir, tmpSubDir, false /* executable */, "tempX1"); diff --git a/src/java/com/jogamp/common/util/JarUtil.java b/src/java/com/jogamp/common/util/JarUtil.java index d6c8fd4..aa5719c 100644 --- a/src/java/com/jogamp/common/util/JarUtil.java +++ b/src/java/com/jogamp/common/util/JarUtil.java @@ -660,7 +660,7 @@ public class JarUtil { // We tolerate UnsatisfiedLinkError (and derived) to solve the chicken and egg problem // of loading gluegen's native library. // On Safari(OSX), Bug 865, we simply hope the destination folder is executable. - if( Platform.OSType.MACOS == Platform.getOSType() ) { + if( Platform.OSType.MACOS == Platform.getOSType() || Platform.OSType.IOS == Platform.getOSType() ) { final String fileAbsPath = file.getAbsolutePath(); try { fixNativeLibAttribs(fileAbsPath); diff --git a/src/java/com/jogamp/common/util/VersionUtil.java b/src/java/com/jogamp/common/util/VersionUtil.java index 6fec8fa..1e09034 100644 --- a/src/java/com/jogamp/common/util/VersionUtil.java +++ b/src/java/com/jogamp/common/util/VersionUtil.java @@ -74,7 +74,9 @@ public class VersionUtil { sb.append(", Runtime: ").append(Platform.getJavaRuntimeName()).append(Platform.getNewline()); sb.append("Platform: Java Vendor: ").append(Platform.getJavaVendor()).append(", ").append(Platform.getJavaVendorURL()); sb.append(", JavaSE: ").append(PlatformPropsImpl.JAVA_SE); + sb.append(", Java9: ").append(PlatformPropsImpl.JAVA_9); sb.append(", Java6: ").append(PlatformPropsImpl.JAVA_6); + sb.append(", dynamicLib: ").append(PlatformPropsImpl.useDynamicLibraries); sb.append(", AWT enabled: ").append(Platform.AWT_AVAILABLE); sb.append(Platform.getNewline()).append(SEPERATOR); diff --git a/src/java/jogamp/common/os/DynamicLinkerImpl.java b/src/java/jogamp/common/os/DynamicLinkerImpl.java index 56a909e..5ce94c1 100644 --- a/src/java/jogamp/common/os/DynamicLinkerImpl.java +++ b/src/java/jogamp/common/os/DynamicLinkerImpl.java @@ -144,14 +144,15 @@ import com.jogamp.common.util.SecurityUtil; @Override public final void closeLibrary(final long libraryHandle, final boolean debug) throws SecurityException, IllegalArgumentException { final LibRef libRef = decrLibRefCount( libraryHandle ); - if( null == libRef ) { - throw new IllegalArgumentException("Library handle 0x"+Long.toHexString(libraryHandle)+" unknown."); - } - checkLinkPermission(libRef.getName()); + if( null != libRef ) { + checkLinkPermission(libRef.getName()); + } // else null libRef is OK for global lookup if( DEBUG || debug ) { System.err.println("DynamicLinkerImpl.closeLibrary(0x"+Long.toHexString(libraryHandle)+" -> "+libRef+")"); } - closeLibraryImpl(libraryHandle); + if( 0 != libraryHandle ) { + closeLibraryImpl(libraryHandle); + } } protected abstract void closeLibraryImpl(final long libraryHandle) throws SecurityException; diff --git a/src/java/jogamp/common/os/MachineDataInfoRuntime.java b/src/java/jogamp/common/os/MachineDataInfoRuntime.java index af90cc5..625e537 100644 --- a/src/java/jogamp/common/os/MachineDataInfoRuntime.java +++ b/src/java/jogamp/common/os/MachineDataInfoRuntime.java @@ -71,6 +71,11 @@ public class MachineDataInfoRuntime { } throw new InternalError("Already initialized"); } + /** + * The static {@link MachineDataInfo} is utilized for high performance + * precompiled size, offset, etc table lookup within generated structures + * using the {@link MachineDataInfo.StaticConfig} index. + */ public static MachineDataInfo.StaticConfig getStatic() { if(!initialized) { synchronized(MachineDataInfo.class) { // volatile dbl-checked-locking OK @@ -110,8 +115,10 @@ public class MachineDataInfoRuntime { return StaticConfig.X86_32_UNIX; } } else { - if( osType == Platform.OSType.WINDOWS ) { + if( Platform.OSType.WINDOWS == osType ) { return StaticConfig.X86_64_WINDOWS; + } else if( Platform.OSType.IOS == osType && Platform.CPUType.ARM64 == cpuType ) { + return StaticConfig.ARM64_IOS; } else { // for all 64bit unix types (x86_64, aarch64, sparcv9, ..) return StaticConfig.LP64_UNIX; diff --git a/src/java/jogamp/common/os/PlatformPropsImpl.java b/src/java/jogamp/common/os/PlatformPropsImpl.java index 55335c1..2900c99 100644 --- a/src/java/jogamp/common/os/PlatformPropsImpl.java +++ b/src/java/jogamp/common/os/PlatformPropsImpl.java @@ -38,7 +38,7 @@ import com.jogamp.common.util.VersionNumber; public abstract class PlatformPropsImpl { static final boolean DEBUG = Debug.debug("Platform"); - /** Selected {@link Platform.OSType#MACOS} {@link VersionNumber}s. */ + /** Selected {@link Platform.OSType#MACOS} or {@link Platform.OSType#IOS} {@link VersionNumber}s. */ public static class OSXVersion { /** OSX Tiger, i.e. 10.4.0 */ public static final VersionNumber Tiger = new VersionNumber(10,4,0); @@ -65,8 +65,8 @@ public abstract class PlatformPropsImpl { public static final VersionNumber Version17; /** Version 1.8. As a JVM version, it enables certain JVM 1.8 features. */ public static final VersionNumber Version18; - /** Version 1.9. As a JVM version, it enables certain JVM 1.9 features. */ - public static final VersionNumber Version19; + /** Version 1.9. As a JVM version, it enables certain JVM 1.9 features. Note the skipped first version number due to JEP 223. */ + public static final VersionNumber Version9; public static final String OS; public static final String OS_lower; @@ -93,6 +93,17 @@ public abstract class PlatformPropsImpl { * </p> */ public static final boolean JAVA_6; + /** + * True only if being compatible w/ language level 9, e.g. JRE 9. + * <p> + * Implies {@link #isJavaSE()} and {@link #JAVA_6}. + * </p> + * <p> + * Since JRE 9, the version string has dropped the major release number, + * see JEP 223: http://openjdk.java.net/jeps/223 + * </p> + */ + public static final boolean JAVA_9; public static final String NEWLINE; public static final boolean LITTLE_ENDIAN; @@ -101,12 +112,20 @@ public abstract class PlatformPropsImpl { public static final ABIType ABI_TYPE; public static final OSType OS_TYPE; public static final String os_and_arch; + /** + * Usually GlueGen and subsequent JogAmp modules are build using dynamic libraries on supported platforms, + * hence this boolean is expected to be true. + * <p> + * However, on certain systems static libraries are being used on which native JNI library loading is disabled. + * </p> + */ + public static final boolean useDynamicLibraries; static { Version16 = new VersionNumber(1, 6, 0); Version17 = new VersionNumber(1, 7, 0); Version18 = new VersionNumber(1, 8, 0); - Version19 = new VersionNumber(1, 9, 0); + Version9 = new VersionNumber(9, 0, 0); // We don't seem to need an AccessController.doPrivileged() block // here as these system properties are visible even to unsigned Applets. @@ -135,7 +154,8 @@ public abstract class PlatformPropsImpl { JAVA_VM_NAME = System.getProperty("java.vm.name"); JAVA_RUNTIME_NAME = getJavaRuntimeNameImpl(); JAVA_SE = initIsJavaSE(); - JAVA_6 = JAVA_SE && ( isAndroid || JAVA_VERSION_NUMBER.compareTo(Version16) >= 0 ) ; + JAVA_9 = JAVA_SE && JAVA_VERSION_NUMBER.compareTo(Version9) >= 0; + JAVA_6 = JAVA_SE && ( isAndroid || JAVA_9 || JAVA_VERSION_NUMBER.compareTo(Version16) >= 0 ) ; NEWLINE = System.getProperty("line.separator"); @@ -318,8 +338,13 @@ public abstract class PlatformPropsImpl { strategy = 220; } } + if( OSType.IOS == OS_TYPE ) { + useDynamicLibraries = false; + } else { + useDynamicLibraries = true; + } if( DEBUG ) { - System.err.println("Platform.Hard: ARCH "+ARCH+", CPU_ARCH "+CPU_ARCH+", ABI_TYPE "+ABI_TYPE+" - strategy "+strategy+"(isAndroid "+isAndroid+", elfValid "+elfValid+")"); + System.err.println("Platform.Hard: ARCH "+ARCH+", CPU_ARCH "+CPU_ARCH+", ABI_TYPE "+ABI_TYPE+" - strategy "+strategy+"(isAndroid "+isAndroid+", elfValid "+elfValid+"), useDynLibs "+useDynamicLibraries); } os_and_arch = getOSAndArch(OS_TYPE, CPU_ARCH, ABI_TYPE, LITTLE_ENDIAN); } @@ -492,6 +517,9 @@ public abstract class PlatformPropsImpl { if ( osLower.startsWith("kd") ) { return OSType.OPENKODE; } + if ( osLower.startsWith("ios") ) { + return OSType.IOS; + } throw new RuntimeException("Please port OS detection to your platform (" + OS_lower + "/" + ARCH_lower + ")"); } @@ -607,6 +635,10 @@ public abstract class PlatformPropsImpl { os_ = "macosx"; _and_arch_final = "universal"; break; + case IOS: + os_ = "ios"; + _and_arch_final = _and_arch_tmp; + break; case WINDOWS: os_ = "windows"; _and_arch_final = _and_arch_tmp; diff --git a/src/java/jogamp/common/os/UnixDynamicLinkerImpl.java b/src/java/jogamp/common/os/UnixDynamicLinkerImpl.java index 5e8ba9d..ddaeea2 100644 --- a/src/java/jogamp/common/os/UnixDynamicLinkerImpl.java +++ b/src/java/jogamp/common/os/UnixDynamicLinkerImpl.java @@ -49,15 +49,16 @@ package jogamp.common.os; @Override protected final long lookupSymbolLocalImpl(final long libraryHandle, final String symbolName) throws SecurityException { - return dlsym(libraryHandle, symbolName); + return 0 != libraryHandle ? dlsym(libraryHandle, symbolName) : 0; } @Override protected final void closeLibraryImpl(final long libraryHandle) throws SecurityException { - dlclose(libraryHandle); + if( 0 != libraryHandle ) { + dlclose(libraryHandle); + } } - @Override public final String getLastError() { return dlerror(); |