Java Code Examples for java.util.jar.Manifest#getAttributes()
The following examples show how to use
java.util.jar.Manifest#getAttributes() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JarUtil.java From consulo with Apache License 2.0 | 6 votes |
private static String getJarAttributeImpl(@Nonnull File file, @Nullable String entryName, @Nonnull Attributes.Name attribute) { if (file.canRead()) { try { JarFile jarFile = new JarFile(file); try { Manifest manifest = jarFile.getManifest(); if (manifest != null) { Attributes attributes = entryName != null ? manifest.getAttributes(entryName) : manifest.getMainAttributes(); return attributes.getValue(attribute); } } finally { jarFile.close(); } } catch (IOException e) { LOG.debug(e); } } return null; }
Example 2
Source File: WebappClassLoaderBase.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
/** * Returns true if the specified package name is sealed according to the * given manifest. */ protected boolean isPackageSealed(String name, Manifest man) { String path = name.replace('.', '/') + '/'; Attributes attr = man.getAttributes(path); String sealed = null; if (attr != null) { sealed = attr.getValue(Name.SEALED); } if (sealed == null) { if ((attr = man.getMainAttributes()) != null) { sealed = attr.getValue(Name.SEALED); } } return "true".equalsIgnoreCase(sealed); }
Example 3
Source File: SARLRuntime.java From sarl with Apache License 2.0 | 6 votes |
/** Replies if the given JAR file contains a SRE. * * <p>The SRE detection is based on the content of the manifest. * * @param jarFile the JAR file to test. * @return <code>true</code> if the given directory contains a SRE. Otherwise <code>false</code>. * @see #isUnpackedSRE(File) */ public static boolean isPackedSRE(File jarFile) { try (JarFile jFile = new JarFile(jarFile)) { final Manifest manifest = jFile.getManifest(); if (manifest == null) { return false; } final Attributes sarlSection = manifest.getAttributes(SREManifestPreferenceConstants.MANIFEST_SECTION_SRE); if (sarlSection == null) { return false; } final String sarlVersion = sarlSection.getValue(SREManifestPreferenceConstants.MANIFEST_SARL_SPEC_VERSION); if (sarlVersion == null || sarlVersion.isEmpty()) { return false; } final Version sarlVer = Version.parseVersion(sarlVersion); return sarlVer != null; } catch (IOException exception) { return false; } }
Example 4
Source File: SeleniumUtils.java From testcontainers-java with MIT License | 6 votes |
/** * Read Manifest to get Selenium Version. * @param manifest manifest * @return Selenium Version detected */ public static String getSeleniumVersionFromManifest(Manifest manifest) { String seleniumVersion = null; Attributes buildInfo = manifest.getAttributes("Build-Info"); if (buildInfo != null) { seleniumVersion = buildInfo.getValue("Selenium-Version"); } // Compatibility Selenium > 3.X if(seleniumVersion == null) { Attributes seleniumInfo = manifest.getAttributes("Selenium"); if (seleniumInfo != null) { seleniumVersion = seleniumInfo.getValue("Selenium-Version"); } } return seleniumVersion; }
Example 5
Source File: VersionHelper.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
/** * Looks up the attributes for the given module specified by <code>name</code> in the given Manifest. * * @param props the manifest where to search for the attributes. * @param name the name of the module. * @return the attributes for the module or the main attributes if the jar contains no such module. */ private Attributes getAttributes( final Manifest props, final String name ) { final Attributes attributes = props.getAttributes( name ); if ( attributes == null ) { return props.getMainAttributes(); } return attributes; }
Example 6
Source File: BuiltinClassLoader.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Returns {@code true} if the specified package name is sealed according to * the given manifest. */ private boolean isSealed(String pn, Manifest man) { String path = pn.replace('.', '/').concat("/"); Attributes attr = man.getAttributes(path); String sealed = null; if (attr != null) sealed = attr.getValue(Attributes.Name.SEALED); if (sealed == null && (attr = man.getMainAttributes()) != null) sealed = attr.getValue(Attributes.Name.SEALED); return "true".equalsIgnoreCase(sealed); }
Example 7
Source File: URLClassLoader.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
private boolean isSealed(String name, Manifest man) { String path = name.replace('.', '/').concat("/"); Attributes attr = man.getAttributes(path); String sealed = null; if (attr != null) { sealed = attr.getValue(Name.SEALED); } if (sealed == null) { if ((attr = man.getMainAttributes()) != null) { sealed = attr.getValue(Name.SEALED); } } return "true".equalsIgnoreCase(sealed); }
Example 8
Source File: Package.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
private Package(String name, Manifest man, URL url, ClassLoader loader) { String path = name.replace('.', '/').concat("/"); String sealed = null; String specTitle= null; String specVersion= null; String specVendor= null; String implTitle= null; String implVersion= null; String implVendor= null; URL sealBase= null; Attributes attr = man.getAttributes(path); if (attr != null) { specTitle = attr.getValue(Name.SPECIFICATION_TITLE); specVersion = attr.getValue(Name.SPECIFICATION_VERSION); specVendor = attr.getValue(Name.SPECIFICATION_VENDOR); implTitle = attr.getValue(Name.IMPLEMENTATION_TITLE); implVersion = attr.getValue(Name.IMPLEMENTATION_VERSION); implVendor = attr.getValue(Name.IMPLEMENTATION_VENDOR); sealed = attr.getValue(Name.SEALED); } attr = man.getMainAttributes(); if (attr != null) { if (specTitle == null) { specTitle = attr.getValue(Name.SPECIFICATION_TITLE); } if (specVersion == null) { specVersion = attr.getValue(Name.SPECIFICATION_VERSION); } if (specVendor == null) { specVendor = attr.getValue(Name.SPECIFICATION_VENDOR); } if (implTitle == null) { implTitle = attr.getValue(Name.IMPLEMENTATION_TITLE); } if (implVersion == null) { implVersion = attr.getValue(Name.IMPLEMENTATION_VERSION); } if (implVendor == null) { implVendor = attr.getValue(Name.IMPLEMENTATION_VENDOR); } if (sealed == null) { sealed = attr.getValue(Name.SEALED); } } if ("true".equalsIgnoreCase(sealed)) { sealBase = url; } pkgName = name; this.specTitle = specTitle; this.specVersion = specVersion; this.specVendor = specVendor; this.implTitle = implTitle; this.implVersion = implVersion; this.implVendor = implVendor; this.sealBase = sealBase; this.loader = loader; }
Example 9
Source File: Package.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
private Package(String name, Manifest man, URL url, ClassLoader loader) { String path = name.replace('.', '/').concat("/"); String sealed = null; String specTitle= null; String specVersion= null; String specVendor= null; String implTitle= null; String implVersion= null; String implVendor= null; URL sealBase= null; Attributes attr = man.getAttributes(path); if (attr != null) { specTitle = attr.getValue(Name.SPECIFICATION_TITLE); specVersion = attr.getValue(Name.SPECIFICATION_VERSION); specVendor = attr.getValue(Name.SPECIFICATION_VENDOR); implTitle = attr.getValue(Name.IMPLEMENTATION_TITLE); implVersion = attr.getValue(Name.IMPLEMENTATION_VERSION); implVendor = attr.getValue(Name.IMPLEMENTATION_VENDOR); sealed = attr.getValue(Name.SEALED); } attr = man.getMainAttributes(); if (attr != null) { if (specTitle == null) { specTitle = attr.getValue(Name.SPECIFICATION_TITLE); } if (specVersion == null) { specVersion = attr.getValue(Name.SPECIFICATION_VERSION); } if (specVendor == null) { specVendor = attr.getValue(Name.SPECIFICATION_VENDOR); } if (implTitle == null) { implTitle = attr.getValue(Name.IMPLEMENTATION_TITLE); } if (implVersion == null) { implVersion = attr.getValue(Name.IMPLEMENTATION_VERSION); } if (implVendor == null) { implVendor = attr.getValue(Name.IMPLEMENTATION_VENDOR); } if (sealed == null) { sealed = attr.getValue(Name.SEALED); } } if ("true".equalsIgnoreCase(sealed)) { sealBase = url; } pkgName = name; this.specTitle = specTitle; this.specVersion = specVersion; this.specVendor = specVendor; this.implTitle = implTitle; this.implVersion = implVersion; this.implVendor = implVendor; this.sealBase = sealBase; this.loader = loader; }
Example 10
Source File: Package.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
private Package(String name, Manifest man, URL url, ClassLoader loader) { String path = name.replace('.', '/').concat("/"); String sealed = null; String specTitle= null; String specVersion= null; String specVendor= null; String implTitle= null; String implVersion= null; String implVendor= null; URL sealBase= null; Attributes attr = man.getAttributes(path); if (attr != null) { specTitle = attr.getValue(Name.SPECIFICATION_TITLE); specVersion = attr.getValue(Name.SPECIFICATION_VERSION); specVendor = attr.getValue(Name.SPECIFICATION_VENDOR); implTitle = attr.getValue(Name.IMPLEMENTATION_TITLE); implVersion = attr.getValue(Name.IMPLEMENTATION_VERSION); implVendor = attr.getValue(Name.IMPLEMENTATION_VENDOR); sealed = attr.getValue(Name.SEALED); } attr = man.getMainAttributes(); if (attr != null) { if (specTitle == null) { specTitle = attr.getValue(Name.SPECIFICATION_TITLE); } if (specVersion == null) { specVersion = attr.getValue(Name.SPECIFICATION_VERSION); } if (specVendor == null) { specVendor = attr.getValue(Name.SPECIFICATION_VENDOR); } if (implTitle == null) { implTitle = attr.getValue(Name.IMPLEMENTATION_TITLE); } if (implVersion == null) { implVersion = attr.getValue(Name.IMPLEMENTATION_VERSION); } if (implVendor == null) { implVendor = attr.getValue(Name.IMPLEMENTATION_VENDOR); } if (sealed == null) { sealed = attr.getValue(Name.SEALED); } } if ("true".equalsIgnoreCase(sealed)) { sealBase = url; } pkgName = name; this.specTitle = specTitle; this.specVersion = specVersion; this.specVendor = specVendor; this.implTitle = implTitle; this.implVersion = implVersion; this.implVendor = implVendor; this.sealBase = sealBase; this.loader = loader; }
Example 11
Source File: URLClassLoader.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
/** * Defines a new package by name in this ClassLoader. The attributes * contained in the specified Manifest will be used to obtain package * version and sealing information. For sealed packages, the additional * URL specifies the code source URL from which the package was loaded. * * @param name the package name * @param man the Manifest containing package version and sealing * information * @param url the code source url for the package, or null if none * @exception IllegalArgumentException if the package name duplicates * an existing package either in this class loader or one * of its ancestors * @return the newly defined Package object */ protected Package definePackage(String name, Manifest man, URL url) throws IllegalArgumentException { String path = name.replace('.', '/').concat("/"); String specTitle = null, specVersion = null, specVendor = null; String implTitle = null, implVersion = null, implVendor = null; String sealed = null; URL sealBase = null; Attributes attr = man.getAttributes(path); if (attr != null) { specTitle = attr.getValue(Name.SPECIFICATION_TITLE); specVersion = attr.getValue(Name.SPECIFICATION_VERSION); specVendor = attr.getValue(Name.SPECIFICATION_VENDOR); implTitle = attr.getValue(Name.IMPLEMENTATION_TITLE); implVersion = attr.getValue(Name.IMPLEMENTATION_VERSION); implVendor = attr.getValue(Name.IMPLEMENTATION_VENDOR); sealed = attr.getValue(Name.SEALED); } attr = man.getMainAttributes(); if (attr != null) { if (specTitle == null) { specTitle = attr.getValue(Name.SPECIFICATION_TITLE); } if (specVersion == null) { specVersion = attr.getValue(Name.SPECIFICATION_VERSION); } if (specVendor == null) { specVendor = attr.getValue(Name.SPECIFICATION_VENDOR); } if (implTitle == null) { implTitle = attr.getValue(Name.IMPLEMENTATION_TITLE); } if (implVersion == null) { implVersion = attr.getValue(Name.IMPLEMENTATION_VERSION); } if (implVendor == null) { implVendor = attr.getValue(Name.IMPLEMENTATION_VENDOR); } if (sealed == null) { sealed = attr.getValue(Name.SEALED); } } if ("true".equalsIgnoreCase(sealed)) { sealBase = url; } return definePackage(name, specTitle, specVersion, specVendor, implTitle, implVersion, implVendor, sealBase); }
Example 12
Source File: JarSigner.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
private boolean updateDigests(ZipEntry ze, ZipFile zf, MessageDigest[] digests, Manifest mf) throws IOException { boolean update = false; Attributes attrs = mf.getAttributes(ze.getName()); String[] base64Digests = getDigests(ze, zf, digests); for (int i = 0; i < digests.length; i++) { // The entry name to be written into attrs String name = null; try { // Find if the digest already exists. An algorithm could have // different names. For example, last time it was SHA, and this // time it's SHA-1. AlgorithmId aid = AlgorithmId.get(digests[i].getAlgorithm()); for (Object key : attrs.keySet()) { if (key instanceof Attributes.Name) { String n = key.toString(); if (n.toUpperCase(Locale.ENGLISH).endsWith("-DIGEST")) { String tmp = n.substring(0, n.length() - 7); if (AlgorithmId.get(tmp).equals(aid)) { name = n; break; } } } } } catch (NoSuchAlgorithmException nsae) { // Ignored. Writing new digest entry. } if (name == null) { name = digests[i].getAlgorithm() + "-Digest"; attrs.putValue(name, base64Digests[i]); update = true; } else { // compare digests, and replace the one in the manifest // if they are different String mfDigest = attrs.getValue(name); if (!mfDigest.equalsIgnoreCase(base64Digests[i])) { attrs.putValue(name, base64Digests[i]); update = true; } } } return update; }
Example 13
Source File: URLClassLoader.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
/** * Defines a new package by name in this ClassLoader. The attributes * contained in the specified Manifest will be used to obtain package * version and sealing information. For sealed packages, the additional * URL specifies the code source URL from which the package was loaded. * * @param name the package name * @param man the Manifest containing package version and sealing * information * @param url the code source url for the package, or null if none * @exception IllegalArgumentException if the package name duplicates * an existing package either in this class loader or one * of its ancestors * @return the newly defined Package object */ protected Package definePackage(String name, Manifest man, URL url) throws IllegalArgumentException { String path = name.replace('.', '/').concat("/"); String specTitle = null, specVersion = null, specVendor = null; String implTitle = null, implVersion = null, implVendor = null; String sealed = null; URL sealBase = null; Attributes attr = man.getAttributes(path); if (attr != null) { specTitle = attr.getValue(Name.SPECIFICATION_TITLE); specVersion = attr.getValue(Name.SPECIFICATION_VERSION); specVendor = attr.getValue(Name.SPECIFICATION_VENDOR); implTitle = attr.getValue(Name.IMPLEMENTATION_TITLE); implVersion = attr.getValue(Name.IMPLEMENTATION_VERSION); implVendor = attr.getValue(Name.IMPLEMENTATION_VENDOR); sealed = attr.getValue(Name.SEALED); } attr = man.getMainAttributes(); if (attr != null) { if (specTitle == null) { specTitle = attr.getValue(Name.SPECIFICATION_TITLE); } if (specVersion == null) { specVersion = attr.getValue(Name.SPECIFICATION_VERSION); } if (specVendor == null) { specVendor = attr.getValue(Name.SPECIFICATION_VENDOR); } if (implTitle == null) { implTitle = attr.getValue(Name.IMPLEMENTATION_TITLE); } if (implVersion == null) { implVersion = attr.getValue(Name.IMPLEMENTATION_VERSION); } if (implVendor == null) { implVendor = attr.getValue(Name.IMPLEMENTATION_VENDOR); } if (sealed == null) { sealed = attr.getValue(Name.SEALED); } } if ("true".equalsIgnoreCase(sealed)) { sealBase = url; } return definePackage(name, specTitle, specVersion, specVendor, implTitle, implVersion, implVendor, sealBase); }
Example 14
Source File: JarEntry.java From sofa-ark with Apache License 2.0 | 4 votes |
@Override public Attributes getAttributes() throws IOException { Manifest manifest = this.jarFile.getManifest(); return (manifest == null ? null : manifest.getAttributes(getName())); }
Example 15
Source File: Package.java From AndroidComponentPlugin with Apache License 2.0 | 4 votes |
private Package(String name, Manifest man, URL url, ClassLoader loader) { String path = name.replace('.', '/').concat("/"); String sealed = null; String specTitle= null; String specVersion= null; String specVendor= null; String implTitle= null; String implVersion= null; String implVendor= null; URL sealBase= null; Attributes attr = man.getAttributes(path); if (attr != null) { specTitle = attr.getValue(Name.SPECIFICATION_TITLE); specVersion = attr.getValue(Name.SPECIFICATION_VERSION); specVendor = attr.getValue(Name.SPECIFICATION_VENDOR); implTitle = attr.getValue(Name.IMPLEMENTATION_TITLE); implVersion = attr.getValue(Name.IMPLEMENTATION_VERSION); implVendor = attr.getValue(Name.IMPLEMENTATION_VENDOR); sealed = attr.getValue(Name.SEALED); } attr = man.getMainAttributes(); if (attr != null) { if (specTitle == null) { specTitle = attr.getValue(Name.SPECIFICATION_TITLE); } if (specVersion == null) { specVersion = attr.getValue(Name.SPECIFICATION_VERSION); } if (specVendor == null) { specVendor = attr.getValue(Name.SPECIFICATION_VENDOR); } if (implTitle == null) { implTitle = attr.getValue(Name.IMPLEMENTATION_TITLE); } if (implVersion == null) { implVersion = attr.getValue(Name.IMPLEMENTATION_VERSION); } if (implVendor == null) { implVendor = attr.getValue(Name.IMPLEMENTATION_VENDOR); } if (sealed == null) { sealed = attr.getValue(Name.SEALED); } } if ("true".equalsIgnoreCase(sealed)) { sealBase = url; } pkgName = name; this.specTitle = specTitle; this.specVersion = specVersion; this.specVendor = specVendor; this.implTitle = implTitle; this.implVersion = implVersion; this.implVendor = implVendor; this.sealBase = sealBase; this.loader = loader; }
Example 16
Source File: Package.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
private Package(String name, Manifest man, URL url, ClassLoader loader) { String path = name.replace('.', '/').concat("/"); String sealed = null; String specTitle= null; String specVersion= null; String specVendor= null; String implTitle= null; String implVersion= null; String implVendor= null; URL sealBase= null; Attributes attr = man.getAttributes(path); if (attr != null) { specTitle = attr.getValue(Name.SPECIFICATION_TITLE); specVersion = attr.getValue(Name.SPECIFICATION_VERSION); specVendor = attr.getValue(Name.SPECIFICATION_VENDOR); implTitle = attr.getValue(Name.IMPLEMENTATION_TITLE); implVersion = attr.getValue(Name.IMPLEMENTATION_VERSION); implVendor = attr.getValue(Name.IMPLEMENTATION_VENDOR); sealed = attr.getValue(Name.SEALED); } attr = man.getMainAttributes(); if (attr != null) { if (specTitle == null) { specTitle = attr.getValue(Name.SPECIFICATION_TITLE); } if (specVersion == null) { specVersion = attr.getValue(Name.SPECIFICATION_VERSION); } if (specVendor == null) { specVendor = attr.getValue(Name.SPECIFICATION_VENDOR); } if (implTitle == null) { implTitle = attr.getValue(Name.IMPLEMENTATION_TITLE); } if (implVersion == null) { implVersion = attr.getValue(Name.IMPLEMENTATION_VERSION); } if (implVendor == null) { implVendor = attr.getValue(Name.IMPLEMENTATION_VENDOR); } if (sealed == null) { sealed = attr.getValue(Name.SEALED); } } if ("true".equalsIgnoreCase(sealed)) { sealBase = url; } pkgName = name; this.specTitle = specTitle; this.specVersion = specVersion; this.specVendor = specVendor; this.implTitle = implTitle; this.implVersion = implVersion; this.implVendor = implVendor; this.sealBase = sealBase; this.loader = loader; }
Example 17
Source File: URLClassLoader.java From Java8CN with Apache License 2.0 | 4 votes |
/** * Defines a new package by name in this ClassLoader. The attributes * contained in the specified Manifest will be used to obtain package * version and sealing information. For sealed packages, the additional * URL specifies the code source URL from which the package was loaded. * * @param name the package name * @param man the Manifest containing package version and sealing * information * @param url the code source url for the package, or null if none * @exception IllegalArgumentException if the package name duplicates * an existing package either in this class loader or one * of its ancestors * @return the newly defined Package object */ protected Package definePackage(String name, Manifest man, URL url) throws IllegalArgumentException { String path = name.replace('.', '/').concat("/"); String specTitle = null, specVersion = null, specVendor = null; String implTitle = null, implVersion = null, implVendor = null; String sealed = null; URL sealBase = null; Attributes attr = man.getAttributes(path); if (attr != null) { specTitle = attr.getValue(Name.SPECIFICATION_TITLE); specVersion = attr.getValue(Name.SPECIFICATION_VERSION); specVendor = attr.getValue(Name.SPECIFICATION_VENDOR); implTitle = attr.getValue(Name.IMPLEMENTATION_TITLE); implVersion = attr.getValue(Name.IMPLEMENTATION_VERSION); implVendor = attr.getValue(Name.IMPLEMENTATION_VENDOR); sealed = attr.getValue(Name.SEALED); } attr = man.getMainAttributes(); if (attr != null) { if (specTitle == null) { specTitle = attr.getValue(Name.SPECIFICATION_TITLE); } if (specVersion == null) { specVersion = attr.getValue(Name.SPECIFICATION_VERSION); } if (specVendor == null) { specVendor = attr.getValue(Name.SPECIFICATION_VENDOR); } if (implTitle == null) { implTitle = attr.getValue(Name.IMPLEMENTATION_TITLE); } if (implVersion == null) { implVersion = attr.getValue(Name.IMPLEMENTATION_VERSION); } if (implVendor == null) { implVendor = attr.getValue(Name.IMPLEMENTATION_VENDOR); } if (sealed == null) { sealed = attr.getValue(Name.SEALED); } } if ("true".equalsIgnoreCase(sealed)) { sealBase = url; } return definePackage(name, specTitle, specVersion, specVendor, implTitle, implVersion, implVendor, sealBase); }
Example 18
Source File: Package.java From jdk-1.7-annotated with Apache License 2.0 | 4 votes |
private Package(String name, Manifest man, URL url, ClassLoader loader) { String path = name.replace('.', '/').concat("/"); String sealed = null; String specTitle= null; String specVersion= null; String specVendor= null; String implTitle= null; String implVersion= null; String implVendor= null; URL sealBase= null; Attributes attr = man.getAttributes(path); if (attr != null) { specTitle = attr.getValue(Name.SPECIFICATION_TITLE); specVersion = attr.getValue(Name.SPECIFICATION_VERSION); specVendor = attr.getValue(Name.SPECIFICATION_VENDOR); implTitle = attr.getValue(Name.IMPLEMENTATION_TITLE); implVersion = attr.getValue(Name.IMPLEMENTATION_VERSION); implVendor = attr.getValue(Name.IMPLEMENTATION_VENDOR); sealed = attr.getValue(Name.SEALED); } attr = man.getMainAttributes(); if (attr != null) { if (specTitle == null) { specTitle = attr.getValue(Name.SPECIFICATION_TITLE); } if (specVersion == null) { specVersion = attr.getValue(Name.SPECIFICATION_VERSION); } if (specVendor == null) { specVendor = attr.getValue(Name.SPECIFICATION_VENDOR); } if (implTitle == null) { implTitle = attr.getValue(Name.IMPLEMENTATION_TITLE); } if (implVersion == null) { implVersion = attr.getValue(Name.IMPLEMENTATION_VERSION); } if (implVendor == null) { implVendor = attr.getValue(Name.IMPLEMENTATION_VENDOR); } if (sealed == null) { sealed = attr.getValue(Name.SEALED); } } if ("true".equalsIgnoreCase(sealed)) { sealBase = url; } pkgName = name; this.specTitle = specTitle; this.specVersion = specVersion; this.specVendor = specVendor; this.implTitle = implTitle; this.implVersion = implVersion; this.implVendor = implVendor; this.sealBase = sealBase; this.loader = loader; }
Example 19
Source File: Package.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
private Package(String name, Manifest man, URL url, ClassLoader loader) { String path = name.replace('.', '/').concat("/"); String sealed = null; String specTitle= null; String specVersion= null; String specVendor= null; String implTitle= null; String implVersion= null; String implVendor= null; URL sealBase= null; Attributes attr = man.getAttributes(path); if (attr != null) { specTitle = attr.getValue(Name.SPECIFICATION_TITLE); specVersion = attr.getValue(Name.SPECIFICATION_VERSION); specVendor = attr.getValue(Name.SPECIFICATION_VENDOR); implTitle = attr.getValue(Name.IMPLEMENTATION_TITLE); implVersion = attr.getValue(Name.IMPLEMENTATION_VERSION); implVendor = attr.getValue(Name.IMPLEMENTATION_VENDOR); sealed = attr.getValue(Name.SEALED); } attr = man.getMainAttributes(); if (attr != null) { if (specTitle == null) { specTitle = attr.getValue(Name.SPECIFICATION_TITLE); } if (specVersion == null) { specVersion = attr.getValue(Name.SPECIFICATION_VERSION); } if (specVendor == null) { specVendor = attr.getValue(Name.SPECIFICATION_VENDOR); } if (implTitle == null) { implTitle = attr.getValue(Name.IMPLEMENTATION_TITLE); } if (implVersion == null) { implVersion = attr.getValue(Name.IMPLEMENTATION_VERSION); } if (implVendor == null) { implVendor = attr.getValue(Name.IMPLEMENTATION_VENDOR); } if (sealed == null) { sealed = attr.getValue(Name.SEALED); } } if ("true".equalsIgnoreCase(sealed)) { sealBase = url; } pkgName = name; this.specTitle = specTitle; this.specVersion = specVersion; this.specVendor = specVendor; this.implTitle = implTitle; this.implVersion = implVersion; this.implVendor = implVendor; this.sealBase = sealBase; this.loader = loader; }
Example 20
Source File: BuiltinClassLoader.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
/** * Defines a new package in this ClassLoader. The attributes in the specified * Manifest are use to get the package version and sealing information. * * @throws IllegalArgumentException if the package name duplicates an * existing package either in this class loader or one of its ancestors */ private Package definePackage(String pn, Manifest man, URL url) { String specTitle = null; String specVersion = null; String specVendor = null; String implTitle = null; String implVersion = null; String implVendor = null; String sealed = null; URL sealBase = null; if (man != null) { Attributes attr = man.getAttributes(pn.replace('.', '/').concat("/")); if (attr != null) { specTitle = attr.getValue(Attributes.Name.SPECIFICATION_TITLE); specVersion = attr.getValue(Attributes.Name.SPECIFICATION_VERSION); specVendor = attr.getValue(Attributes.Name.SPECIFICATION_VENDOR); implTitle = attr.getValue(Attributes.Name.IMPLEMENTATION_TITLE); implVersion = attr.getValue(Attributes.Name.IMPLEMENTATION_VERSION); implVendor = attr.getValue(Attributes.Name.IMPLEMENTATION_VENDOR); sealed = attr.getValue(Attributes.Name.SEALED); } attr = man.getMainAttributes(); if (attr != null) { if (specTitle == null) specTitle = attr.getValue(Attributes.Name.SPECIFICATION_TITLE); if (specVersion == null) specVersion = attr.getValue(Attributes.Name.SPECIFICATION_VERSION); if (specVendor == null) specVendor = attr.getValue(Attributes.Name.SPECIFICATION_VENDOR); if (implTitle == null) implTitle = attr.getValue(Attributes.Name.IMPLEMENTATION_TITLE); if (implVersion == null) implVersion = attr.getValue(Attributes.Name.IMPLEMENTATION_VERSION); if (implVendor == null) implVendor = attr.getValue(Attributes.Name.IMPLEMENTATION_VENDOR); if (sealed == null) sealed = attr.getValue(Attributes.Name.SEALED); } // package is sealed if ("true".equalsIgnoreCase(sealed)) sealBase = url; } return definePackage(pn, specTitle, specVersion, specVendor, implTitle, implVersion, implVendor, sealBase); }