From 081ce00eaad7568f5a651a34d0940feb5c9f9124 Mon Sep 17 00:00:00 2001 From: Kenneth Russel Date: Mon, 17 Apr 2006 08:24:48 +0000 Subject: Fixed Issue 215: Enhancement for NativeLibLoader Incorporated patch largely unmodified from user s_koehler. Cleaned up Cg library loading based on this work. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@720 232f8b59-042b-4e1e-8c03-345bb8c30851 --- .../com/sun/opengl/impl/NativeLibLoader.java | 150 ++++++++++++--------- 1 file changed, 90 insertions(+), 60 deletions(-) (limited to 'src/classes/com') diff --git a/src/classes/com/sun/opengl/impl/NativeLibLoader.java b/src/classes/com/sun/opengl/impl/NativeLibLoader.java index 9331b2f72..25c52e594 100644 --- a/src/classes/com/sun/opengl/impl/NativeLibLoader.java +++ b/src/classes/com/sun/opengl/impl/NativeLibLoader.java @@ -40,87 +40,117 @@ package com.sun.opengl.impl; import java.awt.Toolkit; -import java.security.*; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.util.HashSet; public class NativeLibLoader { - private static volatile boolean doLoading = true; + public interface LoaderAction { + /** + * Loads the library specified by libname. Optionally preloads the libraries specified by + * preload. The implementation should ignore, if the preload-libraries have already been + * loaded. + * @param libname the library to load + * @param preload the libraries to load before loading the main library + * @param doPreload true, iff the preload-libraries should be loaded + * @param ignoreError true, iff errors during loading the preload-libraries should be ignored + */ + void loadLibrary(String libname, String[] preload, + boolean doPreload, boolean ignoreError); + } + + private static class DefaultAction implements LoaderAction { + public void loadLibrary(String libname, String[] preload, + boolean doPreload, boolean ignoreError) { + if (doPreload) { + for (int i=0; i