public static void main(String[] args) { Package pckgs[]; pckgs = Package.getPackages(); for (Package pckg : pckgs) { System.out.println( pckg.getName() + " " + pckg.getImplementationTitle() + " " + pckg.getImplementationVendor() + " " + pckg.getImplementationVersion()); } }
static String productVersion(Class<?> clazz) { String title = null; String version = null; String vendor = null; Package pkg = clazz.getPackage(); if (pkg != null) { title = pkg.getImplementationTitle(); version = pkg.getImplementationVersion(); vendor = pkg.getImplementationVendor(); } StringBuilder builder = new StringBuilder("Product Version: "); builder.append((title != null) ? title : clazz.getSimpleName()); builder.append(" "); builder.append((version != null) ? version : "(unknown version)"); if (vendor != null) { builder.append(", ").append(vendor); } return builder.toString(); }
static void pkgInfo(ClassLoader classLoader, String pkgName, String className) { try { classLoader.loadClass(pkgName + "." + className); Package p = Package.getPackage(pkgName); if (p == null) { System.err.println("WARNING: Package.getPackage(" + pkgName + ") is null"); } else { if (devPhase && debug) { System.err.println(p); System.err.println("Specification Title = " + p.getSpecificationTitle()); System.err.println("Specification Vendor = " + p.getSpecificationVendor()); System.err.println("Specification Version = " + p.getSpecificationVersion()); System.err.println("Implementation Vendor = " + p.getImplementationVendor()); System.err.println("Implementation Version = " + p.getImplementationVersion()); } else if (devPhase) System.err.println(", Java 3D " + p.getImplementationVersion() + "."); } } catch (ClassNotFoundException e) { System.err.println("Unable to load " + pkgName); } // System.err.println(); }
/** * @tests java.lang.Package#getImplementationVendor() * @tests java.lang.Package#getImplementationVersion() * @tests java.lang.Package#getSpecificationTitle() * @tests java.lang.Package#getSpecificationVendor() * @tests java.lang.Package#getSpecificationVersion() * @tests java.lang.Package#getImplementationTitle() */ public void test_helper_Attributes() throws Exception { Package p = getTestPackage("hyts_all_attributes.jar", "p.C"); assertEquals( "Package getImplementationTitle returns a wrong string (1)", "p Implementation-Title", p.getImplementationTitle()); assertEquals( "Package getImplementationVendor returns a wrong string (1)", "p Implementation-Vendor", p.getImplementationVendor()); assertEquals( "Package getImplementationVersion returns a wrong string (1)", "2.2.2", p.getImplementationVersion()); assertEquals( "Package getSpecificationTitle returns a wrong string (1)", "p Specification-Title", p.getSpecificationTitle()); assertEquals( "Package getSpecificationVendor returns a wrong string (1)", "p Specification-Vendor", p.getSpecificationVendor()); assertEquals( "Package getSpecificationVersion returns a wrong string (1)", "2.2.2", p.getSpecificationVersion()); // No entry for the package Package p2 = getTestPackage("hyts_no_entry.jar", "p.C"); assertEquals( "Package getImplementationTitle returns a wrong string (2)", "MF Implementation-Title", p2.getImplementationTitle()); assertEquals( "Package getImplementationVendor returns a wrong string (2)", "MF Implementation-Vendor", p2.getImplementationVendor()); assertEquals( "Package getImplementationVersion returns a wrong string (2)", "5.3.b1", p2.getImplementationVersion()); assertEquals( "Package getSpecificationTitle returns a wrong string (2)", "MF Specification-Title", p2.getSpecificationTitle()); assertEquals( "Package getSpecificationVendor returns a wrong string (2)", "MF Specification-Vendor", p2.getSpecificationVendor()); assertEquals( "Package getSpecificationVersion returns a wrong string (2)", "1.2.3", p2.getSpecificationVersion()); // No attributes in the package entry Package p3 = getTestPackage("hyts_no_attributes.jar", "p.C"); assertEquals( "Package getImplementationTitle returns a wrong string (3)", "MF Implementation-Title", p3.getImplementationTitle()); assertEquals( "Package getImplementationVendor returns a wrong string (3)", "MF Implementation-Vendor", p3.getImplementationVendor()); assertEquals( "Package getImplementationVersion returns a wrong string (3)", "5.3.b1", p3.getImplementationVersion()); assertEquals( "Package getSpecificationTitle returns a wrong string (3)", "MF Specification-Title", p3.getSpecificationTitle()); assertEquals( "Package getSpecificationVendor returns a wrong string (3)", "MF Specification-Vendor", p3.getSpecificationVendor()); assertEquals( "Package getSpecificationVersion returns a wrong string (3)", "1.2.3", p3.getSpecificationVersion()); // Some attributes in the package entry Package p4 = getTestPackage("hyts_some_attributes.jar", "p.C"); assertEquals( "Package getImplementationTitle returns a wrong string (4)", "p Implementation-Title", p4.getImplementationTitle()); assertEquals( "Package getImplementationVendor returns a wrong string (4)", "MF Implementation-Vendor", p4.getImplementationVendor()); assertEquals( "Package getImplementationVersion returns a wrong string (4)", "2.2.2", p4.getImplementationVersion()); assertEquals( "Package getSpecificationTitle returns a wrong string (4)", "MF Specification-Title", p4.getSpecificationTitle()); assertEquals( "Package getSpecificationVendor returns a wrong string (4)", "p Specification-Vendor", p4.getSpecificationVendor()); assertEquals( "Package getSpecificationVersion returns a wrong string (4)", "2.2.2", p4.getSpecificationVersion()); // subdirectory Package Package p5 = getTestPackage("hyts_pq.jar", "p.q.C"); assertEquals( "Package getImplementationTitle returns a wrong string (5)", "p Implementation-Title", p5.getImplementationTitle()); assertEquals( "Package getImplementationVendor returns a wrong string (5)", "p Implementation-Vendor", p5.getImplementationVendor()); assertEquals( "Package getImplementationVersion returns a wrong string (5)", "1.1.3", p5.getImplementationVersion()); assertEquals( "Package getSpecificationTitle returns a wrong string (5)", "p Specification-Title", p5.getSpecificationTitle()); assertEquals( "Package getSpecificationVendor returns a wrong string (5)", "p Specification-Vendor", p5.getSpecificationVendor()); assertEquals( "Package getSpecificationVersion returns a wrong string (5)", "2.2.0.0.0.0.0.0.0.0.0", p5.getSpecificationVersion()); }
@TestTargetNew( level = TestLevel.COMPLETE, notes = "", method = "definePackage", args = { java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.net.URL.class }) public void test_definePackage() { PackageClassLoader pcl = new PackageClassLoader(getClass().getClassLoader()); String[] packageProperties = { "test.package", "title", "1.0", "Vendor", "Title", "1.1", "implementation vendor" }; URL url = null; try { url = new URL("file:"); } catch (MalformedURLException e) { fail("MalformedURLException was thrown."); } pcl.definePackage( packageProperties[0], packageProperties[1], packageProperties[2], packageProperties[3], packageProperties[4], packageProperties[5], packageProperties[6], url); Package pack = pcl.getPackage(packageProperties[0]); assertEquals(packageProperties[1], pack.getSpecificationTitle()); assertEquals(packageProperties[2], pack.getSpecificationVersion()); assertEquals(packageProperties[3], pack.getSpecificationVendor()); assertEquals(packageProperties[4], pack.getImplementationTitle()); assertEquals(packageProperties[5], pack.getImplementationVersion()); assertEquals(packageProperties[6], pack.getImplementationVendor()); assertTrue(pack.isSealed(url)); assertTrue(pack.isSealed()); try { pcl.definePackage( packageProperties[0], packageProperties[1], packageProperties[2], packageProperties[3], packageProperties[4], packageProperties[5], packageProperties[6], null); fail("IllegalArgumentException was not thrown."); } catch (IllegalArgumentException iae) { // expected } pcl.definePackage("test.package.test", null, null, null, null, null, null, null); pack = pcl.getPackage("test.package.test"); assertNull(pack.getSpecificationTitle()); assertNull(pack.getSpecificationVersion()); assertNull(pack.getSpecificationVendor()); assertNull(pack.getImplementationTitle()); assertNull(pack.getImplementationVersion()); assertNull(pack.getImplementationVendor()); assertFalse(pack.isSealed()); }
public void init(GLAutoDrawable glAutoDrawable) { StringBuilder sb = new StringBuilder(); sb.append(gov.nasa.worldwind.Version.getVersion() + "\n"); sb.append("\nSystem Properties\n"); sb.append("Processors: " + Runtime.getRuntime().availableProcessors() + "\n"); sb.append("Free memory: " + Runtime.getRuntime().freeMemory() + " bytes\n"); sb.append("Max memory: " + Runtime.getRuntime().maxMemory() + " bytes\n"); sb.append("Total memory: " + Runtime.getRuntime().totalMemory() + " bytes\n"); for (Map.Entry prop : System.getProperties().entrySet()) { sb.append(prop.getKey() + " = " + prop.getValue() + "\n"); } GL gl = glAutoDrawable.getGL(); sb.append("\nOpenGL Values\n"); String oglVersion = gl.glGetString(GL.GL_VERSION); sb.append("OpenGL version: " + oglVersion + "\n"); String oglVendor = gl.glGetString(GL.GL_VENDOR); sb.append("OpenGL vendor: " + oglVendor + "\n"); String oglRenderer = gl.glGetString(GL.GL_RENDERER); sb.append("OpenGL renderer: " + oglRenderer + "\n"); int[] intVals = new int[2]; for (Attr attr : attrs) { sb.append(attr.name).append(": "); if (attr.attr instanceof Integer) { gl.glGetIntegerv((Integer) attr.attr, intVals, 0); sb.append(intVals[0]).append(intVals[1] > 0 ? ", " + intVals[1] : ""); } sb.append("\n"); } String extensionString = gl.glGetString(GL.GL_EXTENSIONS); String[] extensions = extensionString.split(" "); sb.append("Extensions\n"); for (String ext : extensions) { sb.append(" " + ext + "\n"); } sb.append("\nJOGL Values\n"); String pkgName = "javax.media.opengl"; try { getClass().getClassLoader().loadClass(pkgName + ".GL"); Package p = Package.getPackage(pkgName); if (p == null) { sb.append("WARNING: Package.getPackage(" + pkgName + ") is null\n"); } else { sb.append(p + "\n"); sb.append("Specification Title = " + p.getSpecificationTitle() + "\n"); sb.append("Specification Vendor = " + p.getSpecificationVendor() + "\n"); sb.append("Specification Version = " + p.getSpecificationVersion() + "\n"); sb.append("Implementation Vendor = " + p.getImplementationVendor() + "\n"); sb.append("Implementation Version = " + p.getImplementationVersion() + "\n"); } } catch (ClassNotFoundException e) { sb.append("Unable to load " + pkgName + "\n"); } this.outputArea.setText(sb.toString()); }
/** @return Hazelcast's implementation vendor */ public String getAdapterVendorName() { return HZ_PACKAGE.getImplementationVendor(); }