GlueGen v2.6.0-rc-20250712
GlueGen, Native Binding Generator for Java™ (public API).
GlueGenVersion.java
Go to the documentation of this file.
1/**
2 * Copyright 2010 JogAmp Community. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without modification, are
5 * permitted provided that the following conditions are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright notice, this list of
8 * conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11 * of conditions and the following disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 *
24 * The views and conclusions contained in the software and documentation are those of the
25 * authors and should not be interpreted as representing official policies, either expressed
26 * or implied, of JogAmp Community.
27 */
28
29package com.jogamp.common;
30
31import com.jogamp.common.util.JogampVersion;
32import com.jogamp.common.util.SHASum;
33import com.jogamp.common.util.VersionUtil;
34
35import java.io.IOException;
36import java.net.URISyntaxException;
37import java.security.MessageDigest;
38import java.security.NoSuchAlgorithmException;
39import java.util.ArrayList;
40import java.util.List;
41import java.util.jar.Manifest;
42import java.util.regex.Pattern;
43
44public class GlueGenVersion extends JogampVersion {
45
46 protected static volatile GlueGenVersion jogampCommonVersionInfo;
47
48 protected GlueGenVersion(final String packageName, final Manifest mf) {
49 super(packageName, mf);
50 }
51
52 public static GlueGenVersion getInstance() {
53 if(null == jogampCommonVersionInfo) { // volatile: ok
54 synchronized(GlueGenVersion.class) {
55 if( null == jogampCommonVersionInfo ) {
56 final String packageNameCompileTime = "com.jogamp.gluegen";
57 final String packageNameRuntime = "com.jogamp.common";
58 Manifest mf = VersionUtil.getManifest(GlueGenVersion.class.getClassLoader(), packageNameRuntime);
59 if(null != mf) {
60 jogampCommonVersionInfo = new GlueGenVersion(packageNameRuntime, mf);
61 } else {
62 mf = VersionUtil.getManifest(GlueGenVersion.class.getClassLoader(), packageNameCompileTime);
63 jogampCommonVersionInfo = new GlueGenVersion(packageNameCompileTime, mf);
64 }
65 }
66 }
67 }
69 }
70
71 /**
72 * {@code gluegen-rt.jar} definition of {@link SHASum.TempJarSHASum}'s specialization of {@link SHASum}.
73 * <p>
74 * Implementation uses {@link com.jogamp.common.util.cache.TempJarCache}.
75 * </p>
76 * <p>
77 * Constructor defines the includes and excludes as used for {@code gluegen-rt.jar} {@link SHASum} computation.
78 * </p>
79 */
80 public static class GluGenRTJarSHASum extends SHASum.TempJarSHASum {
81 /**
82 * See {@link GluGenRTJarSHASum}
83 * @throws SecurityException
84 * @throws IllegalArgumentException
85 * @throws NoSuchAlgorithmException
86 * @throws IOException
87 * @throws URISyntaxException
88 */
90 throws SecurityException, IllegalArgumentException, NoSuchAlgorithmException, IOException, URISyntaxException
91 {
92 super(MessageDigest.getInstance("SHA-256"), GlueGenVersion.class, new ArrayList<Pattern>(), new ArrayList<Pattern>());
93 final List<Pattern> excludes = getExcludes();
94 final List<Pattern> includes = getIncludes();
95 final String origin = getOrigin();
96 excludes.add(Pattern.compile(origin+"/jogamp/android/launcher"));
97 excludes.add(Pattern.compile(origin+"/jogamp/common/os/android"));
98 excludes.add(Pattern.compile(origin+"/com/jogamp/gluegen/jcpp"));
99 includes.add(Pattern.compile(origin+"/com/jogamp/gluegen/runtime/.*\\.class"));
100 includes.add(Pattern.compile(origin+"/com/jogamp/common/.*"));
101 includes.add(Pattern.compile(origin+"/jogamp/common/.*"));
102 }
103 }
104
105 public static void main(final String args[]) {
106 System.err.println(VersionUtil.getPlatformInfo());
107 System.err.println(GlueGenVersion.getInstance());
108 }
109}
gluegen-rt.jar definition of SHASum.TempJarSHASum's specialization of SHASum.
GlueGenVersion(final String packageName, final Manifest mf)
static volatile GlueGenVersion jogampCommonVersionInfo
static void main(final String args[])
static GlueGenVersion getInstance()
SHASum specialization utilizing TempJarCache to access jar file content for SHA computation
Definition: SHASum.java:213
Utility class to produce secure hash (SHA) sums over diverse input sources.
Definition: SHASum.java:73
final List< Pattern > getIncludes()
Definition: SHASum.java:208
final List< Pattern > getExcludes()
Definition: SHASum.java:207
static StringBuilder getPlatformInfo(StringBuilder sb)
Appends environment information like OS, JVM and CPU architecture properties to the StringBuilder.
static Manifest getManifest(final ClassLoader cl, final String extension)
Returns the manifest of the jar which contains the specified extension.