From e659f5994875275d4eb46e745676a3d84e27d1e9 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 3 Aug 2011 11:56:40 +0200 Subject: Hide DynamicLinker impl.; Remove public AndroidPackageUtil ; GluegenVersionActivity uses ApplicationContext Hide DynamicLinker impl.: - com.jogamp.common.os.*DynamicLinkerImpl -> jogamp.common.os --- src/java/com/jogamp/common/os/DynamicLinker.java | 2 +- .../jogamp/common/os/MacOSXDynamicLinkerImpl.java | 64 ------------------ src/java/com/jogamp/common/os/NativeLibrary.java | 4 ++ .../jogamp/common/os/UnixDynamicLinkerImpl.java | 63 ----------------- .../jogamp/common/os/WindowsDynamicLinkerImpl.java | 77 --------------------- .../com/jogamp/common/util/AndroidPackageUtil.java | 59 ---------------- src/java/com/jogamp/common/util/JogampVersion.java | 9 ++- .../jogamp/common/os/MacOSXDynamicLinkerImpl.java | 66 ++++++++++++++++++ .../jogamp/common/os/UnixDynamicLinkerImpl.java | 65 ++++++++++++++++++ .../jogamp/common/os/WindowsDynamicLinkerImpl.java | 79 ++++++++++++++++++++++ .../common/os/android/GluegenVersionActivity.java | 4 +- src/native/macosx/MacOSXDynamicLinkerImpl_JNI.c | 18 ++--- src/native/unix/UnixDynamicLinkerImpl_JNI.c | 18 ++--- src/native/windows/WindowsDynamicLinkerImpl_JNI.c | 18 ++--- 14 files changed, 252 insertions(+), 294 deletions(-) delete mode 100755 src/java/com/jogamp/common/os/MacOSXDynamicLinkerImpl.java delete mode 100755 src/java/com/jogamp/common/os/UnixDynamicLinkerImpl.java delete mode 100755 src/java/com/jogamp/common/os/WindowsDynamicLinkerImpl.java delete mode 100644 src/java/com/jogamp/common/util/AndroidPackageUtil.java create mode 100755 src/java/jogamp/common/os/MacOSXDynamicLinkerImpl.java create mode 100755 src/java/jogamp/common/os/UnixDynamicLinkerImpl.java create mode 100755 src/java/jogamp/common/os/WindowsDynamicLinkerImpl.java (limited to 'src') diff --git a/src/java/com/jogamp/common/os/DynamicLinker.java b/src/java/com/jogamp/common/os/DynamicLinker.java index d67a38f..924a776 100755 --- a/src/java/com/jogamp/common/os/DynamicLinker.java +++ b/src/java/com/jogamp/common/os/DynamicLinker.java @@ -42,7 +42,7 @@ package com.jogamp.common.os; /** Provides an abstract interface to the OS's low-level dynamic linking functionality. */ -interface DynamicLinker { +public interface DynamicLinker { public long openLibraryGlobal(String pathname, boolean debug); public long openLibraryLocal(String pathname, boolean debug); public long lookupSymbol(long libraryHandle, String symbolName); diff --git a/src/java/com/jogamp/common/os/MacOSXDynamicLinkerImpl.java b/src/java/com/jogamp/common/os/MacOSXDynamicLinkerImpl.java deleted file mode 100755 index 0e71d5d..0000000 --- a/src/java/com/jogamp/common/os/MacOSXDynamicLinkerImpl.java +++ /dev/null @@ -1,64 +0,0 @@ -/* !---- DO NOT EDIT: This file autogenerated by com\sun\gluegen\JavaEmitter.java on Mon Jul 31 16:27:00 PDT 2006 ----! */ - -package com.jogamp.common.os; - - -public class MacOSXDynamicLinkerImpl implements DynamicLinker { - - public static final long RTLD_DEFAULT = -2; - - public static final int RTLD_LAZY = 0x1; - public static final int RTLD_NOW = 0x2; - public static final int RTLD_LOCAL = 0x4; - public static final int RTLD_GLOBAL = 0x8; - - /** Interface to C language function:
int dlclose(void * __handle); */ - private static native int dlclose(long __handle); - - /** Interface to C language function:
char * dlerror(void); */ - private static native java.lang.String dlerror(); - - /** Interface to C language function:
void * dlopen(const char * __path, int __mode); */ - private static native long dlopen(java.lang.String __path, int __mode); - - /** Interface to C language function:
void * dlsym(void * __handle, const char * __symbol); */ - private static native long dlsym(long __handle, java.lang.String __symbol); - - - // --- Begin CustomJavaCode .cfg declarations - public long openLibraryLocal(String pathname, boolean debug) { - // Note we use RTLD_LOCAL visibility to _NOT_ allow this functionality to - // be used to pre-resolve dependent libraries of JNI code without - // requiring that all references to symbols in those libraries be - // looked up dynamically via the ProcAddressTable mechanism; in - // other words, one can actually link against the library instead of - // having to dlsym all entry points. System.loadLibrary() uses - // RTLD_LOCAL visibility so can't be used for this purpose. - return dlopen(pathname, RTLD_LAZY | RTLD_LOCAL); - } - - public long openLibraryGlobal(String pathname, boolean debug) { - // Note we use RTLD_GLOBAL visibility to allow this functionality to - // be used to pre-resolve dependent libraries of JNI code without - // requiring that all references to symbols in those libraries be - // looked up dynamically via the ProcAddressTable mechanism; in - // other words, one can actually link against the library instead of - // having to dlsym all entry points. System.loadLibrary() uses - // RTLD_LOCAL visibility so can't be used for this purpose. - return dlopen(pathname, RTLD_LAZY | RTLD_GLOBAL); - } - - public long lookupSymbol(long libraryHandle, String symbolName) { - return dlsym(libraryHandle, symbolName); - } - - public long lookupSymbolGlobal(String symbolName) { - return dlsym(RTLD_DEFAULT, symbolName); - } - - public void closeLibrary(long libraryHandle) { - dlclose(libraryHandle); - } - // ---- End CustomJavaCode .cfg declarations - -} // end of class MacOSXDynamicLinkerImpl diff --git a/src/java/com/jogamp/common/os/NativeLibrary.java b/src/java/com/jogamp/common/os/NativeLibrary.java index 47c73e6..1df0e61 100755 --- a/src/java/com/jogamp/common/os/NativeLibrary.java +++ b/src/java/com/jogamp/common/os/NativeLibrary.java @@ -41,6 +41,10 @@ package com.jogamp.common.os; import com.jogamp.gluegen.runtime.NativeLibLoader; import jogamp.common.Debug; +import jogamp.common.os.MacOSXDynamicLinkerImpl; +import jogamp.common.os.UnixDynamicLinkerImpl; +import jogamp.common.os.WindowsDynamicLinkerImpl; + import java.io.*; import java.lang.reflect.*; import java.security.*; diff --git a/src/java/com/jogamp/common/os/UnixDynamicLinkerImpl.java b/src/java/com/jogamp/common/os/UnixDynamicLinkerImpl.java deleted file mode 100755 index fcfe418..0000000 --- a/src/java/com/jogamp/common/os/UnixDynamicLinkerImpl.java +++ /dev/null @@ -1,63 +0,0 @@ -/* !---- DO NOT EDIT: This file autogenerated by com\sun\gluegen\JavaEmitter.java on Mon Jul 31 16:26:59 PDT 2006 ----! */ - -package com.jogamp.common.os; - - -public class UnixDynamicLinkerImpl implements DynamicLinker { - - public static final long RTLD_DEFAULT = 0; - public static final int RTLD_LAZY = 0x00001; - public static final int RTLD_NOW = 0x00002; - public static final int RTLD_GLOBAL = 0x00100; - public static final int RTLD_LOCAL = 0x00000; - - /** Interface to C language function:
int dlclose(void * ); */ - private static native int dlclose(long arg0); - - /** Interface to C language function:
char * dlerror(void); */ - private static native java.lang.String dlerror(); - - /** Interface to C language function:
void * dlopen(const char * , int); */ - private static native long dlopen(java.lang.String arg0, int arg1); - - /** Interface to C language function:
void * dlsym(void * , const char * ); */ - private static native long dlsym(long arg0, java.lang.String arg1); - - - // --- Begin CustomJavaCode .cfg declarations - public long openLibraryLocal(String pathname, boolean debug) { - // Note we use RTLD_GLOBAL visibility to _NOT_ allow this functionality to - // be used to pre-resolve dependent libraries of JNI code without - // requiring that all references to symbols in those libraries be - // looked up dynamically via the ProcAddressTable mechanism; in - // other words, one can actually link against the library instead of - // having to dlsym all entry points. System.loadLibrary() uses - // RTLD_LOCAL visibility so can't be used for this purpose. - return dlopen(pathname, RTLD_LAZY | RTLD_LOCAL); - } - - public long openLibraryGlobal(String pathname, boolean debug) { - // Note we use RTLD_GLOBAL visibility to allow this functionality to - // be used to pre-resolve dependent libraries of JNI code without - // requiring that all references to symbols in those libraries be - // looked up dynamically via the ProcAddressTable mechanism; in - // other words, one can actually link against the library instead of - // having to dlsym all entry points. System.loadLibrary() uses - // RTLD_LOCAL visibility so can't be used for this purpose. - return dlopen(pathname, RTLD_LAZY | RTLD_GLOBAL); - } - - public long lookupSymbol(long libraryHandle, String symbolName) { - return dlsym(libraryHandle, symbolName); - } - - public long lookupSymbolGlobal(String symbolName) { - return dlsym(RTLD_DEFAULT, symbolName); - } - - public void closeLibrary(long libraryHandle) { - dlclose(libraryHandle); - } - // ---- End CustomJavaCode .cfg declarations - -} // end of class UnixDynamicLinkerImpl diff --git a/src/java/com/jogamp/common/os/WindowsDynamicLinkerImpl.java b/src/java/com/jogamp/common/os/WindowsDynamicLinkerImpl.java deleted file mode 100755 index 7bbfe23..0000000 --- a/src/java/com/jogamp/common/os/WindowsDynamicLinkerImpl.java +++ /dev/null @@ -1,77 +0,0 @@ -/* !---- DO NOT EDIT: This file autogenerated by com\sun\gluegen\JavaEmitter.java on Tue May 27 02:37:55 PDT 2008 ----! */ - -package com.jogamp.common.os; - -import java.security.*; - -public class WindowsDynamicLinkerImpl implements DynamicLinker { - - private static boolean DEBUG; - - static { - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - DEBUG = (System.getProperty("jogamp.debug.NativeLibrary") != null); - return null; - } - }); - } - - /** Interface to C language function:
BOOL FreeLibrary(HANDLE hLibModule); */ - private static native int FreeLibrary(long hLibModule); - - /** Interface to C language function:
DWORD GetLastError(void); */ - private static native int GetLastError(); - - /** Interface to C language function:
PROC GetProcAddressA(HANDLE hModule, LPCSTR lpProcName); */ - private static native long GetProcAddressA(long hModule, java.lang.String lpProcName); - - /** Interface to C language function:
HANDLE LoadLibraryW(LPCWSTR lpLibFileName); */ - private static native long LoadLibraryW(java.lang.String lpLibFileName); - - - // --- Begin CustomJavaCode .cfg declarations - public long openLibraryLocal(String libraryName, boolean debug) { - // How does that work under Windows ? - // Don't know .. so it's an alias for the time being - return openLibraryGlobal(libraryName, debug); - } - - public long openLibraryGlobal(String libraryName, boolean debug) { - long handle = LoadLibraryW(libraryName); - if(0==handle && debug) { - int err = GetLastError(); - System.err.println("LoadLibraryW \""+libraryName+"\" failed, error code: 0x"+Integer.toHexString(err)+", "+err); - } - return handle; - } - - public long lookupSymbol(long libraryHandle, String symbolName) { - String _symbolName = symbolName; - long addr = GetProcAddressA(libraryHandle, _symbolName); - if(0==addr) { - // __stdcall hack: try some @nn decorations, - // the leading '_' must not be added (same with cdecl) - final int argAlignment=4; // 4 byte alignment of each argument - final int maxArguments=12; // experience .. - for(int arg=0; 0==addr && arg<=maxArguments; arg++) { - _symbolName = symbolName+"@"+(arg*argAlignment); - addr = GetProcAddressA(libraryHandle, _symbolName); - } - } - if(DEBUG) { - System.err.println("WindowsDynamicLinkerImpl.lookupSymbol(0x"+Long.toHexString(libraryHandle)+", "+symbolName+") -> "+_symbolName+", 0x"+Long.toHexString(addr)); - } - return addr; - } - - public long lookupSymbolGlobal(String symbolName) { - throw new RuntimeException("lookupSymbolGlobal: Not supported on Windows"); - } - - public void closeLibrary(long libraryHandle) { - FreeLibrary(libraryHandle); - } - // ---- End CustomJavaCode .cfg declarations - -} // end of class WindowsDynamicLinkerImpl diff --git a/src/java/com/jogamp/common/util/AndroidPackageUtil.java b/src/java/com/jogamp/common/util/AndroidPackageUtil.java deleted file mode 100644 index 86b25dd..0000000 --- a/src/java/com/jogamp/common/util/AndroidPackageUtil.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Copyright 2011 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.common.util; - -import java.lang.reflect.Method; - -public class AndroidPackageUtil { - - static final Method androidPackageInfoUtilGetVersionName; - static final boolean androidPackageInfoUtilAvailable; - static { - final ClassLoader cl = AndroidPackageUtil.class.getClassLoader(); - Method m=null; - try { - final Class c = ReflectionUtil.getClass("jogamp.common.os.android.PackageInfoUtil", true, cl); - m = ReflectionUtil.getMethod(c, "getPackageInfoVersionName", String.class); - } catch (Exception e) { /* n/a */ } - androidPackageInfoUtilGetVersionName = m; - androidPackageInfoUtilAvailable = null != m ; - } - - public static boolean isAndroidPackageInfoAvailable() { - return androidPackageInfoUtilAvailable; - } - - public static String getAndroidPackageInfoVersionName(String packageName) { - if(androidPackageInfoUtilAvailable) { - return (String) ReflectionUtil.callMethod(null, androidPackageInfoUtilGetVersionName, packageName); - } - return null; - } -} - diff --git a/src/java/com/jogamp/common/util/JogampVersion.java b/src/java/com/jogamp/common/util/JogampVersion.java index a2b1e2f..2461c3e 100644 --- a/src/java/com/jogamp/common/util/JogampVersion.java +++ b/src/java/com/jogamp/common/util/JogampVersion.java @@ -29,6 +29,7 @@ package com.jogamp.common.util; import com.jogamp.common.GlueGenVersion; +import com.jogamp.common.os.AndroidVersion; import com.jogamp.common.os.Platform; import java.util.Iterator; @@ -36,6 +37,8 @@ import java.util.Set; import java.util.jar.Attributes; import java.util.jar.Manifest; +import jogamp.common.os.android.PackageInfoUtil; + public class JogampVersion { public static final Attributes.Name IMPLEMENTATION_BRANCH = new Attributes.Name("Implementation-Branch"); @@ -55,7 +58,11 @@ public class JogampVersion { this.hash = this.mf.hashCode(); mainAttributes = this.mf.getMainAttributes(); mainAttributeNames = mainAttributes.keySet(); - androidPackageVersionName = AndroidPackageUtil.getAndroidPackageInfoVersionName(packageName); + if(AndroidVersion.isAvailable) { + androidPackageVersionName = PackageInfoUtil.getPackageInfoVersionName(packageName); + } else { + androidPackageVersionName = null; + } } @Override diff --git a/src/java/jogamp/common/os/MacOSXDynamicLinkerImpl.java b/src/java/jogamp/common/os/MacOSXDynamicLinkerImpl.java new file mode 100755 index 0000000..c1be2c2 --- /dev/null +++ b/src/java/jogamp/common/os/MacOSXDynamicLinkerImpl.java @@ -0,0 +1,66 @@ +/* !---- DO NOT EDIT: This file autogenerated by com\sun\gluegen\JavaEmitter.java on Mon Jul 31 16:27:00 PDT 2006 ----! */ + +package jogamp.common.os; + +import com.jogamp.common.os.DynamicLinker; + + +public class MacOSXDynamicLinkerImpl implements DynamicLinker { + + public static final long RTLD_DEFAULT = -2; + + public static final int RTLD_LAZY = 0x1; + public static final int RTLD_NOW = 0x2; + public static final int RTLD_LOCAL = 0x4; + public static final int RTLD_GLOBAL = 0x8; + + /** Interface to C language function:
int dlclose(void * __handle); */ + private static native int dlclose(long __handle); + + /** Interface to C language function:
char * dlerror(void); */ + private static native java.lang.String dlerror(); + + /** Interface to C language function:
void * dlopen(const char * __path, int __mode); */ + private static native long dlopen(java.lang.String __path, int __mode); + + /** Interface to C language function:
void * dlsym(void * __handle, const char * __symbol); */ + private static native long dlsym(long __handle, java.lang.String __symbol); + + + // --- Begin CustomJavaCode .cfg declarations + public long openLibraryLocal(String pathname, boolean debug) { + // Note we use RTLD_LOCAL visibility to _NOT_ allow this functionality to + // be used to pre-resolve dependent libraries of JNI code without + // requiring that all references to symbols in those libraries be + // looked up dynamically via the ProcAddressTable mechanism; in + // other words, one can actually link against the library instead of + // having to dlsym all entry points. System.loadLibrary() uses + // RTLD_LOCAL visibility so can't be used for this purpose. + return dlopen(pathname, RTLD_LAZY | RTLD_LOCAL); + } + + public long openLibraryGlobal(String pathname, boolean debug) { + // Note we use RTLD_GLOBAL visibility to allow this functionality to + // be used to pre-resolve dependent libraries of JNI code without + // requiring that all references to symbols in those libraries be + // looked up dynamically via the ProcAddressTable mechanism; in + // other words, one can actually link against the library instead of + // having to dlsym all entry points. System.loadLibrary() uses + // RTLD_LOCAL visibility so can't be used for this purpose. + return dlopen(pathname, RTLD_LAZY | RTLD_GLOBAL); + } + + public long lookupSymbol(long libraryHandle, String symbolName) { + return dlsym(libraryHandle, symbolName); + } + + public long lookupSymbolGlobal(String symbolName) { + return dlsym(RTLD_DEFAULT, symbolName); + } + + public void closeLibrary(long libraryHandle) { + dlclose(libraryHandle); + } + // ---- End CustomJavaCode .cfg declarations + +} // end of class MacOSXDynamicLinkerImpl diff --git a/src/java/jogamp/common/os/UnixDynamicLinkerImpl.java b/src/java/jogamp/common/os/UnixDynamicLinkerImpl.java new file mode 100755 index 0000000..677df32 --- /dev/null +++ b/src/java/jogamp/common/os/UnixDynamicLinkerImpl.java @@ -0,0 +1,65 @@ +/* !---- DO NOT EDIT: This file autogenerated by com\sun\gluegen\JavaEmitter.java on Mon Jul 31 16:26:59 PDT 2006 ----! */ + +package jogamp.common.os; + +import com.jogamp.common.os.DynamicLinker; + + +public class UnixDynamicLinkerImpl implements DynamicLinker { + + public static final long RTLD_DEFAULT = 0; + public static final int RTLD_LAZY = 0x00001; + public static final int RTLD_NOW = 0x00002; + public static final int RTLD_GLOBAL = 0x00100; + public static final int RTLD_LOCAL = 0x00000; + + /** Interface to C language function:
int dlclose(void * ); */ + private static native int dlclose(long arg0); + + /** Interface to C language function:
char * dlerror(void); */ + private static native java.lang.String dlerror(); + + /** Interface to C language function:
void * dlopen(const char * , int); */ + private static native long dlopen(java.lang.String arg0, int arg1); + + /** Interface to C language function:
void * dlsym(void * , const char * ); */ + private static native long dlsym(long arg0, java.lang.String arg1); + + + // --- Begin CustomJavaCode .cfg declarations + public long openLibraryLocal(String pathname, boolean debug) { + // Note we use RTLD_GLOBAL visibility to _NOT_ allow this functionality to + // be used to pre-resolve dependent libraries of JNI code without + // requiring that all references to symbols in those libraries be + // looked up dynamically via the ProcAddressTable mechanism; in + // other words, one can actually link against the library instead of + // having to dlsym all entry points. System.loadLibrary() uses + // RTLD_LOCAL visibility so can't be used for this purpose. + return dlopen(pathname, RTLD_LAZY | RTLD_LOCAL); + } + + public long openLibraryGlobal(String pathname, boolean debug) { + // Note we use RTLD_GLOBAL visibility to allow this functionality to + // be used to pre-resolve dependent libraries of JNI code without + // requiring that all references to symbols in those libraries be + // looked up dynamically via the ProcAddressTable mechanism; in + // other words, one can actually link against the library instead of + // having to dlsym all entry points. System.loadLibrary() uses + // RTLD_LOCAL visibility so can't be used for this purpose. + return dlopen(pathname, RTLD_LAZY | RTLD_GLOBAL); + } + + public long lookupSymbol(long libraryHandle, String symbolName) { + return dlsym(libraryHandle, symbolName); + } + + public long lookupSymbolGlobal(String symbolName) { + return dlsym(RTLD_DEFAULT, symbolName); + } + + public void closeLibrary(long libraryHandle) { + dlclose(libraryHandle); + } + // ---- End CustomJavaCode .cfg declarations + +} // end of class UnixDynamicLinkerImpl diff --git a/src/java/jogamp/common/os/WindowsDynamicLinkerImpl.java b/src/java/jogamp/common/os/WindowsDynamicLinkerImpl.java new file mode 100755 index 0000000..09f38df --- /dev/null +++ b/src/java/jogamp/common/os/WindowsDynamicLinkerImpl.java @@ -0,0 +1,79 @@ +/* !---- DO NOT EDIT: This file autogenerated by com\sun\gluegen\JavaEmitter.java on Tue May 27 02:37:55 PDT 2008 ----! */ + +package jogamp.common.os; + +import java.security.*; + +import com.jogamp.common.os.DynamicLinker; + +public class WindowsDynamicLinkerImpl implements DynamicLinker { + + private static boolean DEBUG; + + static { + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + DEBUG = (System.getProperty("jogamp.debug.NativeLibrary") != null); + return null; + } + }); + } + + /** Interface to C language function:
BOOL FreeLibrary(HANDLE hLibModule); */ + private static native int FreeLibrary(long hLibModule); + + /** Interface to C language function:
DWORD GetLastError(void); */ + private static native int GetLastError(); + + /** Interface to C language function:
PROC GetProcAddressA(HANDLE hModule, LPCSTR lpProcName); */ + private static native long GetProcAddressA(long hModule, java.lang.String lpProcName); + + /** Interface to C language function:
HANDLE LoadLibraryW(LPCWSTR lpLibFileName); */ + private static native long LoadLibraryW(java.lang.String lpLibFileName); + + + // --- Begin CustomJavaCode .cfg declarations + public long openLibraryLocal(String libraryName, boolean debug) { + // How does that work under Windows ? + // Don't know .. so it's an alias for the time being + return openLibraryGlobal(libraryName, debug); + } + + public long openLibraryGlobal(String libraryName, boolean debug) { + long handle = LoadLibraryW(libraryName); + if(0==handle && debug) { + int err = GetLastError(); + System.err.println("LoadLibraryW \""+libraryName+"\" failed, error code: 0x"+Integer.toHexString(err)+", "+err); + } + return handle; + } + + public long lookupSymbol(long libraryHandle, String symbolName) { + String _symbolName = symbolName; + long addr = GetProcAddressA(libraryHandle, _symbolName); + if(0==addr) { + // __stdcall hack: try some @nn decorations, + // the leading '_' must not be added (same with cdecl) + final int argAlignment=4; // 4 byte alignment of each argument + final int maxArguments=12; // experience .. + for(int arg=0; 0==addr && arg<=maxArguments; arg++) { + _symbolName = symbolName+"@"+(arg*argAlignment); + addr = GetProcAddressA(libraryHandle, _symbolName); + } + } + if(DEBUG) { + System.err.println("WindowsDynamicLinkerImpl.lookupSymbol(0x"+Long.toHexString(libraryHandle)+", "+symbolName+") -> "+_symbolName+", 0x"+Long.toHexString(addr)); + } + return addr; + } + + public long lookupSymbolGlobal(String symbolName) { + throw new RuntimeException("lookupSymbolGlobal: Not supported on Windows"); + } + + public void closeLibrary(long libraryHandle) { + FreeLibrary(libraryHandle); + } + // ---- End CustomJavaCode .cfg declarations + +} // end of class WindowsDynamicLinkerImpl diff --git a/src/java/jogamp/common/os/android/GluegenVersionActivity.java b/src/java/jogamp/common/os/android/GluegenVersionActivity.java index 34c6fb5..16222b6 100644 --- a/src/java/jogamp/common/os/android/GluegenVersionActivity.java +++ b/src/java/jogamp/common/os/android/GluegenVersionActivity.java @@ -43,7 +43,7 @@ public class GluegenVersionActivity extends Activity { public void onCreate(Bundle savedInstanceState) { Log.d(MD.TAG, "onCreate - S"); super.onCreate(savedInstanceState); - PackageInfoUtil.setContext(this); + PackageInfoUtil.setContext(this.getApplicationContext()); tv = new TextView(this); tv.setText(VersionUtil.getPlatformInfo()+Platform.NEWLINE+GlueGenVersion.getInstance()+Platform.NEWLINE+Platform.NEWLINE); setContentView(tv); @@ -108,8 +108,8 @@ public class GluegenVersionActivity extends Activity { if(null != tv) { tv.append("> destroyed"+Platform.NEWLINE); } - PackageInfoUtil.setContext(null); Log.d(MD.TAG, "onDestroy - x"); + PackageInfoUtil.setContext(null); super.onDestroy(); Log.d(MD.TAG, "onDestroy - X"); } diff --git a/src/native/macosx/MacOSXDynamicLinkerImpl_JNI.c b/src/native/macosx/MacOSXDynamicLinkerImpl_JNI.c index 5b67a42..757aeb0 100755 --- a/src/native/macosx/MacOSXDynamicLinkerImpl_JNI.c +++ b/src/native/macosx/MacOSXDynamicLinkerImpl_JNI.c @@ -4,18 +4,18 @@ #include -#include "com_jogamp_common_os_MacOSXDynamicLinkerImpl.h" +#include "jogamp_common_os_MacOSXDynamicLinkerImpl.h" #include #include /* Java->C glue code: - * Java package: com.jogamp.common.os.MacOSXDynamicLinkerImpl + * Java package: jogamp.common.os.MacOSXDynamicLinkerImpl * Java method: int dlclose(long __handle) * C function: int dlclose(void * __handle); */ JNIEXPORT jint JNICALL -Java_com_jogamp_common_os_MacOSXDynamicLinkerImpl_dlclose__J(JNIEnv *env, jclass _unused, jlong __handle) { +Java_jogamp_common_os_MacOSXDynamicLinkerImpl_dlclose__J(JNIEnv *env, jclass _unused, jlong __handle) { int _res; _res = dlclose((void *) (intptr_t) __handle); return _res; @@ -23,12 +23,12 @@ Java_com_jogamp_common_os_MacOSXDynamicLinkerImpl_dlclose__J(JNIEnv *env, jclass /* Java->C glue code: - * Java package: com.jogamp.common.os.MacOSXDynamicLinkerImpl + * Java package: jogamp.common.os.MacOSXDynamicLinkerImpl * Java method: java.lang.String dlerror() * C function: char * dlerror(void); */ JNIEXPORT jstring JNICALL -Java_com_jogamp_common_os_MacOSXDynamicLinkerImpl_dlerror__(JNIEnv *env, jclass _unused) { +Java_jogamp_common_os_MacOSXDynamicLinkerImpl_dlerror__(JNIEnv *env, jclass _unused) { char * _res; _res = dlerror(); if (_res == NULL) return NULL; return (*env)->NewStringUTF(env, _res); @@ -36,12 +36,12 @@ Java_com_jogamp_common_os_MacOSXDynamicLinkerImpl_dlerror__(JNIEnv *env, jclass /* Java->C glue code: - * Java package: com.jogamp.common.os.MacOSXDynamicLinkerImpl + * Java package: jogamp.common.os.MacOSXDynamicLinkerImpl * Java method: long dlopen(java.lang.String __path, int __mode) * C function: void * dlopen(const char * __path, int __mode); */ JNIEXPORT jlong JNICALL -Java_com_jogamp_common_os_MacOSXDynamicLinkerImpl_dlopen__Ljava_lang_String_2I(JNIEnv *env, jclass _unused, jstring __path, jint __mode) { +Java_jogamp_common_os_MacOSXDynamicLinkerImpl_dlopen__Ljava_lang_String_2I(JNIEnv *env, jclass _unused, jstring __path, jint __mode) { const char* _UTF8__path = NULL; void * _res; if (__path != NULL) { @@ -63,12 +63,12 @@ Java_com_jogamp_common_os_MacOSXDynamicLinkerImpl_dlopen__Ljava_lang_String_2I(J /* Java->C glue code: - * Java package: com.jogamp.common.os.MacOSXDynamicLinkerImpl + * Java package: jogamp.common.os.MacOSXDynamicLinkerImpl * Java method: long dlsym(long __handle, java.lang.String __symbol) * C function: void * dlsym(void * __handle, const char * __symbol); */ JNIEXPORT jlong JNICALL -Java_com_jogamp_common_os_MacOSXDynamicLinkerImpl_dlsym__JLjava_lang_String_2(JNIEnv *env, jclass _unused, jlong __handle, jstring __symbol) { +Java_jogamp_common_os_MacOSXDynamicLinkerImpl_dlsym__JLjava_lang_String_2(JNIEnv *env, jclass _unused, jlong __handle, jstring __symbol) { const char* _UTF8__symbol = NULL; void * _res; if (__symbol != NULL) { diff --git a/src/native/unix/UnixDynamicLinkerImpl_JNI.c b/src/native/unix/UnixDynamicLinkerImpl_JNI.c index cfe47f9..5741f22 100755 --- a/src/native/unix/UnixDynamicLinkerImpl_JNI.c +++ b/src/native/unix/UnixDynamicLinkerImpl_JNI.c @@ -4,18 +4,18 @@ #include -#include "com_jogamp_common_os_UnixDynamicLinkerImpl.h" +#include "jogamp_common_os_UnixDynamicLinkerImpl.h" #include #include /* Java->C glue code: - * Java package: com.jogamp.common.os.UnixDynamicLinkerImpl + * Java package: jogamp.common.os.UnixDynamicLinkerImpl * Java method: int dlclose(long arg0) * C function: int dlclose(void * ); */ JNIEXPORT jint JNICALL -Java_com_jogamp_common_os_UnixDynamicLinkerImpl_dlclose__J(JNIEnv *env, jclass _unused, jlong arg0) { +Java_jogamp_common_os_UnixDynamicLinkerImpl_dlclose__J(JNIEnv *env, jclass _unused, jlong arg0) { int _res; _res = dlclose((void *) (intptr_t) arg0); return _res; @@ -23,12 +23,12 @@ Java_com_jogamp_common_os_UnixDynamicLinkerImpl_dlclose__J(JNIEnv *env, jclass _ /* Java->C glue code: - * Java package: com.jogamp.common.os.UnixDynamicLinkerImpl + * Java package: jogamp.common.os.UnixDynamicLinkerImpl * Java method: java.lang.String dlerror() * C function: char * dlerror(void); */ JNIEXPORT jstring JNICALL -Java_com_jogamp_common_os_UnixDynamicLinkerImpl_dlerror__(JNIEnv *env, jclass _unused) { +Java_jogamp_common_os_UnixDynamicLinkerImpl_dlerror__(JNIEnv *env, jclass _unused) { char * _res; _res = dlerror(); if (_res == NULL) return NULL; return (*env)->NewStringUTF(env, _res); @@ -36,12 +36,12 @@ Java_com_jogamp_common_os_UnixDynamicLinkerImpl_dlerror__(JNIEnv *env, jclass _u /* Java->C glue code: - * Java package: com.jogamp.common.os.UnixDynamicLinkerImpl + * Java package: jogamp.common.os.UnixDynamicLinkerImpl * Java method: long dlopen(java.lang.String arg0, int arg1) * C function: void * dlopen(const char * , int); */ JNIEXPORT jlong JNICALL -Java_com_jogamp_common_os_UnixDynamicLinkerImpl_dlopen__Ljava_lang_String_2I(JNIEnv *env, jclass _unused, jstring arg0, jint arg1) { +Java_jogamp_common_os_UnixDynamicLinkerImpl_dlopen__Ljava_lang_String_2I(JNIEnv *env, jclass _unused, jstring arg0, jint arg1) { const char* _UTF8arg0 = NULL; void * _res; if (arg0 != NULL) { @@ -63,12 +63,12 @@ Java_com_jogamp_common_os_UnixDynamicLinkerImpl_dlopen__Ljava_lang_String_2I(JNI /* Java->C glue code: - * Java package: com.jogamp.common.os.UnixDynamicLinkerImpl + * Java package: jogamp.common.os.UnixDynamicLinkerImpl * Java method: long dlsym(long arg0, java.lang.String arg1) * C function: void * dlsym(void * , const char * ); */ JNIEXPORT jlong JNICALL -Java_com_jogamp_common_os_UnixDynamicLinkerImpl_dlsym__JLjava_lang_String_2(JNIEnv *env, jclass _unused, jlong arg0, jstring arg1) { +Java_jogamp_common_os_UnixDynamicLinkerImpl_dlsym__JLjava_lang_String_2(JNIEnv *env, jclass _unused, jlong arg0, jstring arg1) { const char* _UTF8arg1 = NULL; void * _res; if (arg1 != NULL) { diff --git a/src/native/windows/WindowsDynamicLinkerImpl_JNI.c b/src/native/windows/WindowsDynamicLinkerImpl_JNI.c index b253c9c..9ddb9d0 100755 --- a/src/native/windows/WindowsDynamicLinkerImpl_JNI.c +++ b/src/native/windows/WindowsDynamicLinkerImpl_JNI.c @@ -5,7 +5,7 @@ #include -#include "com_jogamp_common_os_WindowsDynamicLinkerImpl.h" +#include "jogamp_common_os_WindowsDynamicLinkerImpl.h" #include /* This typedef is apparently needed for compilers before VC8, @@ -19,12 +19,12 @@ #endif /* Java->C glue code: - * Java package: com.jogamp.common.os.WindowsDynamicLinkerImpl + * Java package: jogamp.common.os.WindowsDynamicLinkerImpl * Java method: int FreeLibrary(long hLibModule) * C function: BOOL FreeLibrary(HANDLE hLibModule); */ JNIEXPORT jint JNICALL -Java_com_jogamp_common_os_WindowsDynamicLinkerImpl_FreeLibrary__J(JNIEnv *env, jclass _unused, jlong hLibModule) { +Java_jogamp_common_os_WindowsDynamicLinkerImpl_FreeLibrary__J(JNIEnv *env, jclass _unused, jlong hLibModule) { BOOL _res; _res = FreeLibrary((HANDLE) (intptr_t) hLibModule); return _res; @@ -32,12 +32,12 @@ Java_com_jogamp_common_os_WindowsDynamicLinkerImpl_FreeLibrary__J(JNIEnv *env, j /* Java->C glue code: - * Java package: com.jogamp.common.os.WindowsDynamicLinkerImpl + * Java package: jogamp.common.os.WindowsDynamicLinkerImpl * Java method: int GetLastError() * C function: DWORD GetLastError(void); */ JNIEXPORT jint JNICALL -Java_com_jogamp_common_os_WindowsDynamicLinkerImpl_GetLastError__(JNIEnv *env, jclass _unused) { +Java_jogamp_common_os_WindowsDynamicLinkerImpl_GetLastError__(JNIEnv *env, jclass _unused) { DWORD _res; _res = GetLastError(); return _res; @@ -45,12 +45,12 @@ Java_com_jogamp_common_os_WindowsDynamicLinkerImpl_GetLastError__(JNIEnv *env, j /* Java->C glue code: - * Java package: com.jogamp.common.os.WindowsDynamicLinkerImpl + * Java package: jogamp.common.os.WindowsDynamicLinkerImpl * Java method: long GetProcAddressA(long hModule, java.lang.String lpProcName) * C function: PROC GetProcAddressA(HANDLE hModule, LPCSTR lpProcName); */ JNIEXPORT jlong JNICALL -Java_com_jogamp_common_os_WindowsDynamicLinkerImpl_GetProcAddressA__JLjava_lang_String_2(JNIEnv *env, jclass _unused, jlong hModule, jstring lpProcName) { +Java_jogamp_common_os_WindowsDynamicLinkerImpl_GetProcAddressA__JLjava_lang_String_2(JNIEnv *env, jclass _unused, jlong hModule, jstring lpProcName) { const char* _strchars_lpProcName = NULL; PROC _res; if (lpProcName != NULL) { @@ -70,12 +70,12 @@ Java_com_jogamp_common_os_WindowsDynamicLinkerImpl_GetProcAddressA__JLjava_lang_ /* Java->C glue code: - * Java package: com.jogamp.common.os.WindowsDynamicLinkerImpl + * Java package: jogamp.common.os.WindowsDynamicLinkerImpl * Java method: long LoadLibraryW(java.lang.String lpLibFileName) * C function: HANDLE LoadLibraryW(LPCWSTR lpLibFileName); */ JNIEXPORT jlong JNICALL -Java_com_jogamp_common_os_WindowsDynamicLinkerImpl_LoadLibraryW__Ljava_lang_String_2(JNIEnv *env, jclass _unused, jstring lpLibFileName) { +Java_jogamp_common_os_WindowsDynamicLinkerImpl_LoadLibraryW__Ljava_lang_String_2(JNIEnv *env, jclass _unused, jstring lpLibFileName) { jchar* _strchars_lpLibFileName = NULL; HANDLE _res; if (lpLibFileName != NULL) { -- cgit v1.2.3