java.util.jar.Manifest#getAttributes ( )源码实例Demo

下面列出了java.util.jar.Manifest#getAttributes ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: consulo   文件: JarUtil.java
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;
}
 
源代码2 项目: testcontainers-java   文件: SeleniumUtils.java
/**
 * 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;
}
 
源代码3 项目: sarl   文件: SARLRuntime.java
/** 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;
	}
}
 
源代码4 项目: Tomcat7.0.67   文件: WebappClassLoaderBase.java
/**
 * 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);

}
 
源代码5 项目: jdk1.8-source-analysis   文件: URLClassLoader.java
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);
}
 
源代码6 项目: openjdk-jdk9   文件: BuiltinClassLoader.java
/**
 * 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);
}
 
源代码7 项目: pentaho-reporting   文件: VersionHelper.java
/**
 * 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;
}
 
源代码8 项目: openjdk-jdk9   文件: BuiltinClassLoader.java
/**
 * 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);
}
 
源代码9 项目: jdk-1.7-annotated   文件: Package.java
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;
}
 
源代码10 项目: AndroidComponentPlugin   文件: Package.java
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;
}
 
源代码11 项目: jdk8u_jdk   文件: Package.java
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;
}
 
源代码12 项目: TencentKona-8   文件: Package.java
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;
}
 
源代码13 项目: jdk8u-dev-jdk   文件: Package.java
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;
}
 
源代码14 项目: jdk8u60   文件: URLClassLoader.java
/**
 * 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);
}
 
源代码15 项目: openjdk-jdk9   文件: JarSigner.java
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;
}
 
源代码16 项目: jdk8u-dev-jdk   文件: URLClassLoader.java
/**
 * 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);
}
 
源代码17 项目: sofa-ark   文件: JarEntry.java
@Override
public Attributes getAttributes() throws IOException {
    Manifest manifest = this.jarFile.getManifest();
    return (manifest == null ? null : manifest.getAttributes(getName()));
}
 
源代码18 项目: jdk8u-jdk   文件: Package.java
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;
}
 
源代码19 项目: Java8CN   文件: URLClassLoader.java
/**
 * 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);
}
 
源代码20 项目: openjdk-jdk8u-backup   文件: Package.java
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;
}