From ad554ae820ca353a1796bd750b669c1a00546341 Mon Sep 17 00:00:00 2001 From: Michael Bien Date: Fri, 4 Feb 2011 22:32:53 +0100 Subject: initialize JOCLVersion as privileged action to be able to find trusted libraries when launched via webstart. --- src/com/jogamp/opencl/util/JOCLVersion.java | 50 +++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 10 deletions(-) (limited to 'src/com/jogamp/opencl') diff --git a/src/com/jogamp/opencl/util/JOCLVersion.java b/src/com/jogamp/opencl/util/JOCLVersion.java index 181df3f5..44f32c57 100644 --- a/src/com/jogamp/opencl/util/JOCLVersion.java +++ b/src/com/jogamp/opencl/util/JOCLVersion.java @@ -35,12 +35,15 @@ import com.jogamp.common.GlueGenVersion; import com.jogamp.common.os.Platform; import com.jogamp.common.util.JogampVersion; import com.jogamp.common.util.VersionUtil; +import com.jogamp.opencl.CL; +import java.security.PrivilegedAction; import java.util.jar.Manifest; +import static java.security.AccessController.*; import static com.jogamp.common.util.VersionUtil.*; /** - * + * Utility for querying module versions and environment properties. * @author Michael Bien */ public class JOCLVersion extends JogampVersion { @@ -51,9 +54,16 @@ public class JOCLVersion extends JogampVersion { super(PACKAGE, mf); } - private static JOCLVersion createInstance(){ - Manifest manifest = VersionUtil.getManifest(JOCLVersion.class.getClassLoader(), PACKAGE); - return new JOCLVersion(manifest); + private static JOCLVersion createInstance() { + return doPrivileged(new PrivilegedAction() { + public JOCLVersion run() { + Manifest manifest = VersionUtil.getManifest(CL.class.getClassLoader(), PACKAGE); + if(manifest == null) { + manifest = new Manifest(); + } + return new JOCLVersion(manifest); + } + }); } public static String getVersion() { @@ -62,15 +72,35 @@ public class JOCLVersion extends JogampVersion { public static String getAllVersions() { - StringBuilder sb = new StringBuilder(); + final StringBuilder sb = new StringBuilder(); - sb.append(SEPERATOR).append(Platform.getNewline()); - sb.append(getPlatformInfo(null)); - sb.append(SEPERATOR).append(Platform.getNewline()); + try{ + sb.append(SEPERATOR).append(Platform.getNewline()); + sb.append(getPlatformInfo(null)); + sb.append(SEPERATOR).append(Platform.getNewline()); + }catch(Exception e) { + sb.append(e.getMessage()); + e.printStackTrace(); + } - createInstance().toString(sb); + try{ + createInstance().toString(sb); + }catch(Exception e) { + sb.append(e.getMessage()); + e.printStackTrace(); + } - sb.append(GlueGenVersion.getInstance().toString()); + try{ + doPrivileged(new PrivilegedAction() { + public Object run() { + sb.append(GlueGenVersion.getInstance().toString()); + return null; + } + }); + }catch(Exception e) { + sb.append(e.getMessage()); + e.printStackTrace(); + } return sb.toString(); } -- cgit v1.2.3