/** * Init the native binding to the underlying system library. * @return <code>true</code> if the link is effective and <code>false</code> otherwise. */ public static void init() throws UnsatisfiedLinkError { Native.unregister(JOpenVRLibrary.class); String path = System.getProperty(JNA_OPENVR_LIBRARY_PATH); if (path != null){ JNA_LIBRARY_NAME = path; logger.config("Using OpenVR implementation located at "+JNA_LIBRARY_NAME); JNA_NATIVE_LIB = NativeLibrary.getInstance(JOpenVRLibrary.JNA_LIBRARY_NAME); Native.register(JOpenVRLibrary.class, JOpenVRLibrary.JNA_NATIVE_LIB); } else { JNA_LIBRARY_NAME = "openvr_api"; logger.config("Using embedded OpenVR implementation "+JOpenVRLibrary.JNA_LIBRARY_NAME); JNA_NATIVE_LIB = NativeLibrary.getInstance(JOpenVRLibrary.JNA_LIBRARY_NAME); Native.register(JOpenVRLibrary.class, JOpenVRLibrary.JNA_NATIVE_LIB); } }
private static void unregisterAll() { synchronized(registeredClasses) { for (Map.Entry<Class<?>, long[]> e : registeredClasses.entrySet()) { unregister(e.getKey(), e.getValue()); } registeredClasses.clear(); } }
/** Remove all native mappings for the given class. Should only be called if the class is no longer referenced and about to be garbage collected. */ public static void unregister(Class<?> cls) { synchronized(registeredClasses) { long[] handles = registeredClasses.get(cls); if (handles != null) { unregister(cls, handles); registeredClasses.remove(cls); registeredLibraries.remove(cls); } } }
/** Remove all native mappings for the calling class. Should only be called if the class is no longer referenced and about to be garbage collected. */ public static void unregister() { unregister(findDirectMappedClass(getCallingClass())); }
private static void unregisterAll() { synchronized(registeredClasses) { for (Map.Entry<Class<?>, long[]> e : registeredClasses.entrySet()) { unregister(e.getKey(), e.getValue()); } registeredClasses.clear(); } }
/** Remove all native mappings for the given class. Should only be called if the class is no longer referenced and about to be garbage collected. */ public static void unregister(Class<?> cls) { synchronized(registeredClasses) { long[] handles = registeredClasses.get(cls); if (handles != null) { unregister(cls, handles); registeredClasses.remove(cls); registeredLibraries.remove(cls); } } }
/** Remove all native mappings for the calling class. Should only be called if the class is no longer referenced and about to be garbage collected. */ public static void unregister() { unregister(findDirectMappedClass(getCallingClass())); }