aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/com/jogamp/common/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/com/jogamp/common/util')
-rw-r--r--src/java/com/jogamp/common/util/JogampVersion.java75
-rw-r--r--src/java/com/jogamp/common/util/VersionUtil.java50
2 files changed, 66 insertions, 59 deletions
diff --git a/src/java/com/jogamp/common/util/JogampVersion.java b/src/java/com/jogamp/common/util/JogampVersion.java
index 914da3d..aae6d77 100644
--- a/src/java/com/jogamp/common/util/JogampVersion.java
+++ b/src/java/com/jogamp/common/util/JogampVersion.java
@@ -39,6 +39,8 @@ public class JogampVersion {
public static Attributes.Name IMPLEMENTATION_BRANCH = new Attributes.Name("Implementation-Branch");
public static Attributes.Name IMPLEMENTATION_COMMIT = new Attributes.Name("Implementation-Commit");
+
+ protected static final String SEPERATOR = "-----------------------------------------------------------------------------------------------------";
private String packageName;
private Manifest mf;
@@ -59,8 +61,8 @@ public class JogampVersion {
}
public final boolean equals(Object o) {
- if (o instanceof GlueGenVersion) {
- return mf.equals(((GlueGenVersion) o).getManifest());
+ if (o instanceof JogampVersion) {
+ return mf.equals(((JogampVersion) o).getManifest());
}
return false;
}
@@ -119,6 +121,10 @@ public class JogampVersion {
return this.getAttribute(Attributes.Name.IMPLEMENTATION_VENDOR_ID);
}
+ public final String getImplementationURL() {
+ return this.getAttribute(Attributes.Name.IMPLEMENTATION_URL);
+ }
+
public final String getImplementationVersion() {
return this.getAttribute(Attributes.Name.IMPLEMENTATION_VERSION);
}
@@ -139,63 +145,44 @@ public class JogampVersion {
return VersionUtil.getFullManifestInfo(getManifest(), sb);
}
+ public StringBuffer getPlatformInfo(StringBuffer sb) {
+ return VersionUtil.getPlatformInfo(sb);
+ }
+
public StringBuffer getManifestInfo(StringBuffer sb) {
if(null==sb) {
sb = new StringBuffer();
}
- sb.append("Package: ");
- sb.append(getPackageName());
- sb.append(Platform.getNewline());
- sb.append("Extension Name: ");
- sb.append(getExtensionName());
- sb.append(Platform.getNewline());
- sb.append("Specification Title: ");
- sb.append(getSpecificationTitle());
- sb.append(Platform.getNewline());
- sb.append("Specification Vendor: ");
- sb.append(getSpecificationVendor());
- sb.append(Platform.getNewline());
- sb.append("Specification Version: ");
- sb.append(getSpecificationVersion());
- sb.append(Platform.getNewline());
- sb.append("Implementation Title: ");
- sb.append(getImplementationTitle());
- sb.append(Platform.getNewline());
- sb.append("Implementation Vendor: ");
- sb.append(getImplementationVendor());
- sb.append(Platform.getNewline());
- sb.append("Implementation Vendor ID: ");
- sb.append(getImplementationVendorID());
- sb.append(Platform.getNewline());
- sb.append("Implementation Version: ");
- sb.append(getImplementationVersion());
- sb.append(Platform.getNewline());
- sb.append("Implementation Branch: ");
- sb.append(getImplementationBranch());
- sb.append(Platform.getNewline());
- sb.append("Implementation Commit: ");
- sb.append(getImplementationCommit());
- sb.append(Platform.getNewline());
+ String nl = Platform.getNewline();
+ sb.append("Package: ").append(getPackageName()).append(nl);
+ sb.append("Extension Name: ").append(getExtensionName()).append(nl);
+ sb.append("Specification Title: ").append(getSpecificationTitle()).append(nl);
+ sb.append("Specification Vendor: ").append(getSpecificationVendor()).append(nl);
+ sb.append("Specification Version: ").append(getSpecificationVersion()).append(nl);
+ sb.append("Implementation Title: ").append(getImplementationTitle()).append(nl);
+ sb.append("Implementation Vendor: ").append(getImplementationVendor()).append(nl);
+ sb.append("Implementation Vendor ID: ").append(getImplementationVendorID()).append(nl);
+ sb.append("Implementation URL: ").append(getImplementationURL()).append(nl);
+ sb.append("Implementation Version: ").append(getImplementationVersion()).append(nl);
+ sb.append("Implementation Branch: ").append(getImplementationBranch()).append(nl);
+ sb.append("Implementation Commit: ").append(getImplementationCommit()).append(nl);
return sb;
}
- public StringBuffer toStringBuffer(StringBuffer sb) {
+ public StringBuffer toString(StringBuffer sb) {
if(null==sb) {
sb = new StringBuffer();
}
- sb.append(Platform.getNewline());
- sb.append("-----------------------------------------------------------------------------------------------------");
- sb.append(Platform.getNewline());
- VersionUtil.getPlatformInfo(sb);
- sb.append(Platform.getNewline());
+ String nl = Platform.getNewline();
+ sb.append(SEPERATOR).append(nl);
getManifestInfo(sb);
- sb.append("-----------------------------------------------------------------------------------------------------");
- sb.append(Platform.getNewline());
+ sb.append(SEPERATOR).append(nl);
return sb;
}
+
public String toString() {
- return toStringBuffer(null).toString();
+ return toString(null).toString();
}
}
diff --git a/src/java/com/jogamp/common/util/VersionUtil.java b/src/java/com/jogamp/common/util/VersionUtil.java
index a4e625e..ac4d0b8 100644
--- a/src/java/com/jogamp/common/util/VersionUtil.java
+++ b/src/java/com/jogamp/common/util/VersionUtil.java
@@ -31,9 +31,8 @@ package com.jogamp.common.util;
import com.jogamp.common.os.Platform;
import java.io.IOException;
-import java.net.JarURLConnection;
import java.net.URL;
-import java.net.URLConnection;
+import java.util.Enumeration;
import java.util.Iterator;
import java.util.Set;
import java.util.jar.Attributes;
@@ -41,32 +40,53 @@ import java.util.jar.Manifest;
public class VersionUtil {
+ /**
+ * Appends environment information like OS, JVM and CPU architecture properties to the StringBuffer.
+ */
public static StringBuffer getPlatformInfo(StringBuffer sb) {
- if(null==sb) {
+ if(null == sb) {
sb = new StringBuffer();
}
- sb.append("Platform: ").append(Platform.getOS()).append(" ").append(Platform.getOSVersion()).append(" (os), ").append(Platform.getArch()).append(" (arch)");
+ // environment
+ sb.append("Platform: ").append(Platform.getOS()).append(' ').append(Platform.getOSVersion()).append(" (os), ");
+ sb.append(Platform.getArch()).append(" (arch) ").append(Runtime.getRuntime().availableProcessors()).append(" cores");
sb.append(Platform.getNewline());
- sb.append("Platform: littleEndian ").append(Platform.isLittleEndian()).append(", 32Bit ").append(Platform.is32Bit()).append(", a-ptr bit-size ").append(Platform.getPointerSizeInBits());
+
+ // arch
+ sb.append("Platform: littleEndian ").append(Platform.isLittleEndian()).append(", 32Bit ");
+ sb.append(Platform.is32Bit()).append(", a-ptr bit-size ").append(Platform.getPointerSizeInBits());
sb.append(Platform.getNewline());
- sb.append("Platform: Java ").append(Platform.getJavaVersion()).append(", ").append(Platform.getJavaVendor()).append(", ").append(Platform.getJavaVendorURL()).append(", is JavaSE: ").append(Platform.isJavaSE());
+
+ // JVM/JRE
+ sb.append("Platform: Java ").append(Platform.getJavaVersion()).append(", ").append(System.getProperty("java.vm.name")).append(", ");
+ sb.append(Platform.getJavaVendor()).append(", ").append(Platform.getJavaVendorURL()).append(", is JavaSE: ").append(Platform.isJavaSE());
sb.append(Platform.getNewline());
return sb;
}
- public static Manifest getManifest(ClassLoader cl, String fullClazzName) {
- String fullClazzFileName = "/" + fullClazzName.replace('.', '/') + ".class" ;
- URL url = cl.getClass().getResource(fullClazzFileName);
- Manifest mf = null;
+ /**
+ * Returns the manifest of the jar which contains the specified extension.
+ * The provided ClassLoader is used for resource loading.
+ * @param cl A ClassLoader which should find the manifest.
+ * @param extension The value of the 'Extension-Name' jar-manifest attribute; used to identify the manifest.
+ * @return the requested manifest or null when not found.
+ */
+ public static Manifest getManifest(ClassLoader cl, String extension) {
try {
- URLConnection urlConn = url.openConnection();
- if(urlConn instanceof JarURLConnection) {
- mf = ((JarURLConnection)urlConn).getManifest();
+ Enumeration resources = cl.getResources("META-INF/MANIFEST.MF");
+ while (resources.hasMoreElements()) {
+ Manifest manifest = new Manifest(((URL)resources.nextElement()).openStream());
+ Attributes attributes = manifest.getMainAttributes();
+ if(attributes != null && extension.equals(attributes.getValue(Attributes.Name.EXTENSION_NAME))) {
+ return manifest;
+ }
}
- } catch (IOException ex) { }
- return mf;
+ } catch (IOException ex) {
+ throw new RuntimeException("Unable to read manifest.", ex);
+ }
+ return null;
}
public static StringBuffer getFullManifestInfo(Manifest mf, StringBuffer sb) {