From 32f09a5894ce3b157d5439df83703fa6f5336ff4 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 18 Aug 2015 02:50:49 +0200 Subject: Bug 1145: Fix cc2: Null versions reported using the fat-jar (JogampVersion) In case we run fat-jar file, the package name is 'com.jogamp' and all entries are based upon GlueGen. JogampVersion will fall back trying to find a fat-jar Manifest in case a null Manifest is being passed. --- src/java/com/jogamp/common/util/JogampVersion.java | 24 +++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'src/java/com') diff --git a/src/java/com/jogamp/common/util/JogampVersion.java b/src/java/com/jogamp/common/util/JogampVersion.java index e9becc6..e06ce1f 100644 --- a/src/java/com/jogamp/common/util/JogampVersion.java +++ b/src/java/com/jogamp/common/util/JogampVersion.java @@ -46,6 +46,9 @@ public class JogampVersion { /** See {@link #getImplementationCommit()} */ public static final Attributes.Name IMPLEMENTATION_COMMIT = new Attributes.Name("Implementation-Commit"); + /** For FAT JogAmp jar files */ + private static final String packageNameFAT = "com.jogamp"; + private final String packageName; private final Manifest mf; private final int hash; @@ -55,12 +58,27 @@ public class JogampVersion { private final String androidPackageVersionName; protected JogampVersion(final String packageName, final Manifest mf) { - this.packageName = packageName; - this.mf = ( null != mf ) ? mf : new Manifest(); + if( null != mf ) { + // use provided valid data + this.mf = mf; + this.packageName = packageName; + } else { + // try FAT jar file + final Manifest fatMF = VersionUtil.getManifest(JogampVersion.class.getClassLoader(), packageNameFAT); + if( null != fatMF ) { + // use FAT jar file + this.mf = fatMF; + this.packageName = packageNameFAT; + } else { + // use faulty data, unresolvable .. + this.mf = new Manifest(); + this.packageName = packageName; + } + } this.hash = this.mf.hashCode(); mainAttributes = this.mf.getMainAttributes(); mainAttributeNames = mainAttributes.keySet(); - androidPackageVersionName = AndroidUtils.getPackageInfoVersionName(packageName); // null if !Android + androidPackageVersionName = AndroidUtils.getPackageInfoVersionName(this.packageName); // null if !Android } @Override -- cgit v1.2.3