8194534: Manifest better support

Reviewed-by: mchung, igerasim
This commit is contained in:
Weijun Wang 2018-04-17 15:55:49 +08:00
parent cd8e70a35c
commit a58b68027b
8 changed files with 105 additions and 18 deletions

View file

@ -535,13 +535,13 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
* @spec JPMS
*/
protected Package definePackage(String name, Manifest man, URL url) {
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);
Attributes attr = SharedSecrets.javaUtilJarAccess()
.getTrustedAttributes(man, name.replace('.', '/').concat("/"));
if (attr != null) {
specTitle = attr.getValue(Name.SPECIFICATION_TITLE);
specVersion = attr.getValue(Name.SPECIFICATION_VERSION);
@ -585,10 +585,12 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
/*
* Returns true if the specified package name is sealed according to the
* given manifest.
*
* @throws SecurityException if the package name is untrusted in the manifest
*/
private boolean isSealed(String name, Manifest man) {
String path = name.replace('.', '/').concat("/");
Attributes attr = man.getAttributes(path);
Attributes attr = SharedSecrets.javaUtilJarAccess()
.getTrustedAttributes(man, name.replace('.', '/').concat("/"));
String sealed = null;
if (attr != null) {
sealed = attr.getValue(Name.SEALED);