From 3711e80a6191e5adca5e3ef027882912746ed064 Mon Sep 17 00:00:00 2001 From: Kevin Rushforth Date: Tue, 9 Oct 2007 18:29:40 +0000 Subject: Fixed issue 534: ClassNotFoundException when running applet if Java 3D installed into JRE git-svn-id: https://svn.java.net/svn/j3d-core~svn/trunk@870 ba19aa83-45c5-6ac9-afd3-db810772062c --- .../share/javax/media/j3d/NativePipeline.java | 32 ++++++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/classes/share/javax/media/j3d/NativePipeline.java b/src/classes/share/javax/media/j3d/NativePipeline.java index dcdf8a5..2df39c2 100644 --- a/src/classes/share/javax/media/j3d/NativePipeline.java +++ b/src/classes/share/javax/media/j3d/NativePipeline.java @@ -15,6 +15,7 @@ package javax.media.j3d; import java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; import java.io.File; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.security.AccessController; import java.util.ArrayList; @@ -180,16 +181,35 @@ class NativePipeline extends Pipeline { AccessController.doPrivileged( new java.security.PrivilegedAction() { public Object run() { - try { - if (useAppletLauncher) { + boolean loaded = false; + if (useAppletLauncher) { + try { Class jnlpAppletLauncherClass = Class.forName("org.jdesktop.applet.util.JNLPAppletLauncher"); Method loadLibraryMethod = jnlpAppletLauncherClass.getDeclaredMethod("loadLibrary", String.class); loadLibraryMethod.invoke(null, libName); - } else { - System.loadLibrary(libName); + loaded = true; + } catch (ClassNotFoundException ex) { + System.err.println("Java 3D: loadLibrary(" + libName + ")"); + System.err.println(ex); + System.err.println("Attempting to use System.loadLibrary instead"); + } catch (Exception ex) { + Throwable t = ex; + if (t instanceof InvocationTargetException) { + t = ((InvocationTargetException) t).getTargetException(); + } + if (t instanceof Error) { + throw (Error) t; + } + if (t instanceof RuntimeException) { + throw (RuntimeException) t; + } + // Throw UnsatisfiedLinkError for best compatibility with System.loadLibrary() + throw (UnsatisfiedLinkError) new UnsatisfiedLinkError().initCause(ex); } - } catch (Exception ex) { - throw new RuntimeException(ex); + } + + if (!loaded) { + System.loadLibrary(libName); } return null; } -- cgit v1.2.3