mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
Merge
This commit is contained in:
commit
42d9cdb7a0
40 changed files with 1035 additions and 471 deletions
|
@ -38,6 +38,7 @@ import java.security.CodeSource;
|
|||
import java.security.PrivilegedAction;
|
||||
import java.security.ProtectionDomain;
|
||||
import java.security.cert.Certificate;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Deque;
|
||||
|
@ -45,7 +46,6 @@ import java.util.Enumeration;
|
|||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Hashtable;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Objects;
|
||||
|
@ -2496,7 +2496,7 @@ public abstract class ClassLoader {
|
|||
}
|
||||
|
||||
// native libraries being loaded
|
||||
static Deque<NativeLibrary> nativeLibraryContext = new LinkedList<>();
|
||||
static Deque<NativeLibrary> nativeLibraryContext = new ArrayDeque<>(8);
|
||||
|
||||
/*
|
||||
* The run() method will be invoked when this class loader becomes
|
||||
|
|
|
@ -876,62 +876,6 @@ public class Runtime {
|
|||
ClassLoader.loadLibrary(fromClass, libname, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a localized version of an input stream. This method takes
|
||||
* an {@code InputStream} and returns an {@code InputStream}
|
||||
* equivalent to the argument in all respects except that it is
|
||||
* localized: as characters in the local character set are read from
|
||||
* the stream, they are automatically converted from the local
|
||||
* character set to Unicode.
|
||||
* <p>
|
||||
* If the argument is already a localized stream, it may be returned
|
||||
* as the result.
|
||||
*
|
||||
* @param in InputStream to localize
|
||||
* @return a localized input stream
|
||||
* @see java.io.InputStream
|
||||
* @see java.io.BufferedReader#BufferedReader(java.io.Reader)
|
||||
* @see java.io.InputStreamReader#InputStreamReader(java.io.InputStream)
|
||||
* @deprecated As of JDK 1.1, the preferred way to translate a byte
|
||||
* stream in the local encoding into a character stream in Unicode is via
|
||||
* the {@code InputStreamReader} and {@code BufferedReader}
|
||||
* classes.
|
||||
* This method is subject to removal in a future version of Java SE.
|
||||
*/
|
||||
@Deprecated(since="1.1", forRemoval=true)
|
||||
public InputStream getLocalizedInputStream(InputStream in) {
|
||||
return in;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a localized version of an output stream. This method
|
||||
* takes an {@code OutputStream} and returns an
|
||||
* {@code OutputStream} equivalent to the argument in all respects
|
||||
* except that it is localized: as Unicode characters are written to
|
||||
* the stream, they are automatically converted to the local
|
||||
* character set.
|
||||
* <p>
|
||||
* If the argument is already a localized stream, it may be returned
|
||||
* as the result.
|
||||
*
|
||||
* @deprecated As of JDK 1.1, the preferred way to translate a
|
||||
* Unicode character stream into a byte stream in the local encoding is via
|
||||
* the {@code OutputStreamWriter}, {@code BufferedWriter}, and
|
||||
* {@code PrintWriter} classes.
|
||||
* This method is subject to removal in a future version of Java SE.
|
||||
*
|
||||
* @param out OutputStream to localize
|
||||
* @return a localized output stream
|
||||
* @see java.io.OutputStream
|
||||
* @see java.io.BufferedWriter#BufferedWriter(java.io.Writer)
|
||||
* @see java.io.OutputStreamWriter#OutputStreamWriter(java.io.OutputStream)
|
||||
* @see java.io.PrintWriter#PrintWriter(java.io.OutputStream)
|
||||
*/
|
||||
@Deprecated(since="1.1", forRemoval=true)
|
||||
public OutputStream getLocalizedOutputStream(OutputStream out) {
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the version of the Java Runtime Environment as a {@link Version}.
|
||||
*
|
||||
|
|
|
@ -25,15 +25,13 @@
|
|||
|
||||
package java.security;
|
||||
|
||||
import java.lang.ref.Reference;
|
||||
import java.lang.ref.ReferenceQueue;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.WeakHashMap;
|
||||
import jdk.internal.misc.JavaSecurityAccess;
|
||||
import jdk.internal.misc.JavaSecurityProtectionDomainAccess;
|
||||
import static jdk.internal.misc.JavaSecurityProtectionDomainAccess.ProtectionDomainCache;
|
||||
|
@ -115,23 +113,10 @@ public class ProtectionDomain {
|
|||
}
|
||||
|
||||
static {
|
||||
// setup SharedSecrets to allow access to doIntersectionPrivilege
|
||||
// methods and ProtectionDomain cache
|
||||
// Set up JavaSecurityAccess in SharedSecrets
|
||||
SharedSecrets.setJavaSecurityAccess(new JavaSecurityAccessImpl());
|
||||
SharedSecrets.setJavaSecurityProtectionDomainAccess(
|
||||
new JavaSecurityProtectionDomainAccess() {
|
||||
@Override
|
||||
public ProtectionDomainCache getProtectionDomainCache() {
|
||||
return new PDCache();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Used for storing ProtectionDomains as keys in a Map.
|
||||
*/
|
||||
static final class Key {}
|
||||
|
||||
/* CodeSource */
|
||||
private CodeSource codesource ;
|
||||
|
||||
|
@ -571,117 +556,27 @@ public class ProtectionDomain {
|
|||
}
|
||||
|
||||
/**
|
||||
* A cache of ProtectionDomains and their Permissions.
|
||||
*
|
||||
* This class stores ProtectionDomains as weak keys in a ConcurrentHashMap
|
||||
* with additional support for checking and removing weak keys that are no
|
||||
* longer in use. There can be cases where the permission collection may
|
||||
* have a chain of strong references back to the ProtectionDomain, which
|
||||
* ordinarily would prevent the entry from being removed from the map. To
|
||||
* address that, we wrap the permission collection in a SoftReference so
|
||||
* that it can be reclaimed by the garbage collector due to memory demand.
|
||||
* Used for storing ProtectionDomains as keys in a Map.
|
||||
*/
|
||||
private static class PDCache implements ProtectionDomainCache {
|
||||
private final ConcurrentHashMap<WeakProtectionDomainKey,
|
||||
SoftReference<PermissionCollection>>
|
||||
pdMap = new ConcurrentHashMap<>();
|
||||
private final ReferenceQueue<Key> queue = new ReferenceQueue<>();
|
||||
final class Key {}
|
||||
|
||||
@Override
|
||||
public void put(ProtectionDomain pd, PermissionCollection pc) {
|
||||
processQueue(queue, pdMap);
|
||||
WeakProtectionDomainKey weakPd =
|
||||
new WeakProtectionDomainKey(pd, queue);
|
||||
pdMap.put(weakPd, new SoftReference<>(pc));
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermissionCollection get(ProtectionDomain pd) {
|
||||
processQueue(queue, pdMap);
|
||||
WeakProtectionDomainKey weakPd = new WeakProtectionDomainKey(pd);
|
||||
SoftReference<PermissionCollection> sr = pdMap.get(weakPd);
|
||||
return (sr == null) ? null : sr.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes weak keys from the map that have been enqueued
|
||||
* on the reference queue and are no longer in use.
|
||||
*/
|
||||
private static void processQueue(ReferenceQueue<Key> queue,
|
||||
ConcurrentHashMap<? extends
|
||||
WeakReference<Key>, ?> pdMap) {
|
||||
Reference<? extends Key> ref;
|
||||
while ((ref = queue.poll()) != null) {
|
||||
pdMap.remove(ref);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A weak key for a ProtectionDomain.
|
||||
*/
|
||||
private static class WeakProtectionDomainKey extends WeakReference<Key> {
|
||||
/**
|
||||
* Saved value of the referent's identity hash code, to maintain
|
||||
* a consistent hash code after the referent has been cleared
|
||||
*/
|
||||
private final int hash;
|
||||
|
||||
/**
|
||||
* A key representing a null ProtectionDomain.
|
||||
*/
|
||||
private static final Key NULL_KEY = new Key();
|
||||
|
||||
/**
|
||||
* Create a new WeakProtectionDomain with the specified domain and
|
||||
* registered with a queue.
|
||||
*/
|
||||
WeakProtectionDomainKey(ProtectionDomain pd, ReferenceQueue<Key> rq) {
|
||||
this((pd == null ? NULL_KEY : pd.key), rq);
|
||||
}
|
||||
|
||||
WeakProtectionDomainKey(ProtectionDomain pd) {
|
||||
this(pd == null ? NULL_KEY : pd.key);
|
||||
}
|
||||
|
||||
private WeakProtectionDomainKey(Key key, ReferenceQueue<Key> rq) {
|
||||
super(key, rq);
|
||||
hash = key.hashCode();
|
||||
}
|
||||
|
||||
private WeakProtectionDomainKey(Key key) {
|
||||
super(key);
|
||||
hash = key.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the identity hash code of the original referent.
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given object is an identical
|
||||
* WeakProtectionDomainKey instance, or, if this object's referent
|
||||
* has not been cleared and the given object is another
|
||||
* WeakProtectionDomainKey instance with an identical non-null
|
||||
* referent as this one.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (obj instanceof WeakProtectionDomainKey) {
|
||||
Object referent = get();
|
||||
return (referent != null) &&
|
||||
(referent == ((WeakProtectionDomainKey)obj).get());
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
static {
|
||||
SharedSecrets.setJavaSecurityProtectionDomainAccess(
|
||||
new JavaSecurityProtectionDomainAccess() {
|
||||
public ProtectionDomainCache getProtectionDomainCache() {
|
||||
return new ProtectionDomainCache() {
|
||||
private final Map<Key, PermissionCollection> map =
|
||||
Collections.synchronizedMap
|
||||
(new WeakHashMap<Key, PermissionCollection>());
|
||||
public void put(ProtectionDomain pd,
|
||||
PermissionCollection pc) {
|
||||
map.put((pd == null ? null : pd.key), pc);
|
||||
}
|
||||
public PermissionCollection get(ProtectionDomain pd) {
|
||||
return pd == null ? map.get(null) : map.get(pd.key);
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,6 +63,9 @@ import static jdk.internal.module.ClassFileConstants.*;
|
|||
|
||||
public final class ModuleInfo {
|
||||
|
||||
private final int JAVA_MIN_SUPPORTED_VERSION = 53;
|
||||
private final int JAVA_MAX_SUPPORTED_VERSION = 54;
|
||||
|
||||
private static final JavaLangModuleAccess JLMA
|
||||
= SharedSecrets.getJavaLangModuleAccess();
|
||||
|
||||
|
@ -188,8 +191,10 @@ public final class ModuleInfo {
|
|||
|
||||
int minor_version = in.readUnsignedShort();
|
||||
int major_version = in.readUnsignedShort();
|
||||
if (major_version < 53) {
|
||||
throw invalidModuleDescriptor("Must be >= 53.0");
|
||||
if (major_version < JAVA_MIN_SUPPORTED_VERSION ||
|
||||
major_version > JAVA_MAX_SUPPORTED_VERSION) {
|
||||
throw invalidModuleDescriptor("Unsupported major.minor version "
|
||||
+ major_version + "." + minor_version);
|
||||
}
|
||||
|
||||
ConstantPool cpool = new ConstantPool(in);
|
||||
|
@ -245,7 +250,7 @@ public final class ModuleInfo {
|
|||
switch (attribute_name) {
|
||||
|
||||
case MODULE :
|
||||
builder = readModuleAttribute(in, cpool);
|
||||
builder = readModuleAttribute(in, cpool, major_version);
|
||||
break;
|
||||
|
||||
case MODULE_PACKAGES :
|
||||
|
@ -334,7 +339,7 @@ public final class ModuleInfo {
|
|||
* Reads the Module attribute, returning the ModuleDescriptor.Builder to
|
||||
* build the corresponding ModuleDescriptor.
|
||||
*/
|
||||
private Builder readModuleAttribute(DataInput in, ConstantPool cpool)
|
||||
private Builder readModuleAttribute(DataInput in, ConstantPool cpool, int major)
|
||||
throws IOException
|
||||
{
|
||||
// module_name
|
||||
|
@ -390,8 +395,21 @@ public final class ModuleInfo {
|
|||
JLMA.requires(builder, mods, dn, vs);
|
||||
}
|
||||
|
||||
if (dn.equals("java.base"))
|
||||
if (dn.equals("java.base")) {
|
||||
if (major >= 54
|
||||
&& (mods.contains(Requires.Modifier.TRANSITIVE)
|
||||
|| mods.contains(Requires.Modifier.STATIC))) {
|
||||
String flagName;
|
||||
if (mods.contains(Requires.Modifier.TRANSITIVE)) {
|
||||
flagName = "ACC_TRANSITIVE";
|
||||
} else {
|
||||
flagName = "ACC_STATIC_PHASE";
|
||||
}
|
||||
throw invalidModuleDescriptor("The requires entry for java.base"
|
||||
+ " has " + flagName + " set");
|
||||
}
|
||||
requiresJavaBase = true;
|
||||
}
|
||||
}
|
||||
if (mn.equals("java.base")) {
|
||||
if (requires_count > 0) {
|
||||
|
|
|
@ -80,7 +80,7 @@ public final class ModuleInfoWriter {
|
|||
*/
|
||||
private static byte[] toModuleInfo(ModuleDescriptor md, ModuleTarget target) {
|
||||
ClassWriter cw = new ClassWriter(0);
|
||||
cw.visit(Opcodes.V9, ACC_MODULE, "module-info", null, null, null);
|
||||
cw.visit(Opcodes.V10, ACC_MODULE, "module-info", null, null, null);
|
||||
|
||||
int moduleFlags = md.modifiers().stream()
|
||||
.map(MODULE_MODS_TO_FLAGS::get)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -93,8 +93,9 @@ public class KeyStoreUtil {
|
|||
* MSCAPI KeyStores
|
||||
*/
|
||||
public static boolean isWindowsKeyStore(String storetype) {
|
||||
return storetype.equalsIgnoreCase("Windows-MY")
|
||||
|| storetype.equalsIgnoreCase("Windows-ROOT");
|
||||
return storetype != null
|
||||
&& (storetype.equalsIgnoreCase("Windows-MY")
|
||||
|| storetype.equalsIgnoreCase("Windows-ROOT"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -134,8 +134,6 @@ public final class Main {
|
|||
private Set<Pair <String, String>> providers = null;
|
||||
private Set<Pair <String, String>> providerClasses = null;
|
||||
private String storetype = null;
|
||||
private boolean hasStoretypeOption = false;
|
||||
private boolean hasSrcStoretypeOption = false;
|
||||
private String srcProviderName = null;
|
||||
private String providerName = null;
|
||||
private String pathlist = null;
|
||||
|
@ -549,14 +547,12 @@ public final class Main {
|
|||
passwords.add(storePass);
|
||||
} else if (collator.compare(flags, "-storetype") == 0 ||
|
||||
collator.compare(flags, "-deststoretype") == 0) {
|
||||
storetype = args[++i];
|
||||
hasStoretypeOption = true;
|
||||
storetype = KeyStoreUtil.niceStoreTypeName(args[++i]);
|
||||
} else if (collator.compare(flags, "-srcstorepass") == 0) {
|
||||
srcstorePass = getPass(modifier, args[++i]);
|
||||
passwords.add(srcstorePass);
|
||||
} else if (collator.compare(flags, "-srcstoretype") == 0) {
|
||||
srcstoretype = args[++i];
|
||||
hasSrcStoretypeOption = true;
|
||||
srcstoretype = KeyStoreUtil.niceStoreTypeName(args[++i]);
|
||||
} else if (collator.compare(flags, "-srckeypass") == 0) {
|
||||
srckeyPass = getPass(modifier, args[++i]);
|
||||
passwords.add(srckeyPass);
|
||||
|
@ -708,16 +704,6 @@ public final class Main {
|
|||
ksfname = KeyStoreUtil.getCacerts();
|
||||
}
|
||||
|
||||
if (storetype == null) {
|
||||
storetype = KeyStore.getDefaultType();
|
||||
}
|
||||
storetype = KeyStoreUtil.niceStoreTypeName(storetype);
|
||||
|
||||
if (srcstoretype == null) {
|
||||
srcstoretype = KeyStore.getDefaultType();
|
||||
}
|
||||
srcstoretype = KeyStoreUtil.niceStoreTypeName(srcstoretype);
|
||||
|
||||
if (P11KEYSTORE.equalsIgnoreCase(storetype) ||
|
||||
KeyStoreUtil.isWindowsKeyStore(storetype)) {
|
||||
token = true;
|
||||
|
@ -742,11 +728,6 @@ public final class Main {
|
|||
(".storepasswd.and.keypasswd.commands.not.supported.if.storetype.is.{0}"), storetype));
|
||||
}
|
||||
|
||||
if (P12KEYSTORE.equalsIgnoreCase(storetype) && command == KEYPASSWD) {
|
||||
throw new UnsupportedOperationException(rb.getString
|
||||
(".keypasswd.commands.not.supported.if.storetype.is.PKCS12"));
|
||||
}
|
||||
|
||||
if (token && (keyPass != null || newPass != null || destKeyPass != null)) {
|
||||
throw new IllegalArgumentException(MessageFormat.format(rb.getString
|
||||
(".keypass.and.new.can.not.be.specified.if.storetype.is.{0}"), storetype));
|
||||
|
@ -923,9 +904,13 @@ public final class Main {
|
|||
// Create new keystore
|
||||
// Probe for keystore type when filename is available
|
||||
if (ksfile != null && ksStream != null && providerName == null &&
|
||||
hasStoretypeOption == false && !inplaceImport) {
|
||||
storetype == null && !inplaceImport) {
|
||||
keyStore = KeyStore.getInstance(ksfile, storePass);
|
||||
storetype = keyStore.getType();
|
||||
} else {
|
||||
if (storetype == null) {
|
||||
storetype = KeyStore.getDefaultType();
|
||||
}
|
||||
if (providerName == null) {
|
||||
keyStore = KeyStore.getInstance(storetype);
|
||||
} else {
|
||||
|
@ -964,6 +949,11 @@ public final class Main {
|
|||
}
|
||||
}
|
||||
|
||||
if (P12KEYSTORE.equalsIgnoreCase(storetype) && command == KEYPASSWD) {
|
||||
throw new UnsupportedOperationException(rb.getString
|
||||
(".keypasswd.commands.not.supported.if.storetype.is.PKCS12"));
|
||||
}
|
||||
|
||||
// All commands that create or modify the keystore require a keystore
|
||||
// password.
|
||||
|
||||
|
@ -2123,9 +2113,13 @@ public final class Main {
|
|||
try {
|
||||
// Probe for keystore type when filename is available
|
||||
if (srcksfile != null && is != null && srcProviderName == null &&
|
||||
hasSrcStoretypeOption == false) {
|
||||
srcstoretype == null) {
|
||||
store = KeyStore.getInstance(srcksfile, srcstorePass);
|
||||
srcstoretype = store.getType();
|
||||
} else {
|
||||
if (srcstoretype == null) {
|
||||
srcstoretype = KeyStore.getDefaultType();
|
||||
}
|
||||
if (srcProviderName == null) {
|
||||
store = KeyStore.getInstance(srcstoretype);
|
||||
} else {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -476,10 +476,14 @@ static void prepAttributes(JNIEnv* env, struct stat64* buf, jobject attrs) {
|
|||
(*env)->SetLongField(env, attrs, attrs_st_birthtime_sec, (jlong)buf->st_birthtime);
|
||||
#endif
|
||||
|
||||
#if (_POSIX_C_SOURCE >= 200809L) || defined(__solaris__)
|
||||
#ifndef MACOSX
|
||||
(*env)->SetLongField(env, attrs, attrs_st_atime_nsec, (jlong)buf->st_atim.tv_nsec);
|
||||
(*env)->SetLongField(env, attrs, attrs_st_mtime_nsec, (jlong)buf->st_mtim.tv_nsec);
|
||||
(*env)->SetLongField(env, attrs, attrs_st_ctime_nsec, (jlong)buf->st_ctim.tv_nsec);
|
||||
#else
|
||||
(*env)->SetLongField(env, attrs, attrs_st_atime_nsec, (jlong)buf->st_atimespec.tv_nsec);
|
||||
(*env)->SetLongField(env, attrs, attrs_st_mtime_nsec, (jlong)buf->st_mtimespec.tv_nsec);
|
||||
(*env)->SetLongField(env, attrs, attrs_st_ctime_nsec, (jlong)buf->st_ctimespec.tv_nsec);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue