Merge
This commit is contained in:
commit
e5583eb15a
jdk
make/src/classes/build/tools/cldrconverter
src
java.base
share
classes
java
lang
net
util
jdk/internal/loader
sun
net/www/protocol/jar
security/tools
text/resources
conf/security
native/libjli
windows/native/libjli
java.logging/share/classes/java/util/logging
java.naming/share/classes/com/sun/jndi/ldap
AbstractLdapNamingEnumeration.javaLdapBindingEnumeration.javaLdapNamingEnumeration.javaLdapSearchEnumeration.java
jdk.crypto.ucrypto/solaris/classes/com/oracle/security/ucrypto
jdk.jartool/share/classes/sun/security/tools/jarsigner
jdk.jlink/share/classes/jdk/tools/jlink
internal
plugin
jdk.localedata/share/classes/sun/text/resources/ext
JavaTimeSupplementary_ar.javaJavaTimeSupplementary_be.javaJavaTimeSupplementary_bg.javaJavaTimeSupplementary_cs.javaJavaTimeSupplementary_da.javaJavaTimeSupplementary_et.javaJavaTimeSupplementary_fi.javaJavaTimeSupplementary_fr.javaJavaTimeSupplementary_ga.javaJavaTimeSupplementary_hr.javaJavaTimeSupplementary_in.javaJavaTimeSupplementary_iw.javaJavaTimeSupplementary_lt.javaJavaTimeSupplementary_no.javaJavaTimeSupplementary_sl.javaJavaTimeSupplementary_sq.javaJavaTimeSupplementary_sr.javaJavaTimeSupplementary_sv.java
jdk.policytool/share/classes/sun/security/tools/policytool
test
ProblemList.txt
java
lang
Runtime/Version
System
Logger/default
LoggerFinder
DefaultLoggerFinderTest
jdk
DefaultLoggerBridgeTest
DefaultPlatformLoggerTest
ThreadGroup
nio/channels/FileChannel
rmi
activation
Activatable/restartService
ActivationGroup/downloadActivationGroup
server/RMISocketFactory/useSocketFactory/activatable
util
Locale
jar/JarFile/mrjar
MultiReleaseJarAPI.javaMultiReleaseJarHttpProperties.javaMultiReleaseJarIterators.javaMultiReleaseJarProperties.javaMultiReleaseJarSecurity.java
logging
zip/InflaterInputStream
sun
net/www/protocol/jar
security
pkcs11/fips
tools
jarsigner
keytool
text/resources
tools
@ -693,6 +693,8 @@ public class CLDRConverter {
|
||||
"field.weekday",
|
||||
"field.dayperiod",
|
||||
"field.hour",
|
||||
"timezone.hourFormat",
|
||||
"timezone.gmtFormat",
|
||||
"field.minute",
|
||||
"field.second",
|
||||
"field.zone",
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2016, 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
|
||||
@ -41,12 +41,12 @@ class CopyrightHeaders {
|
||||
" * Copyright (c) 2012, %d, Oracle and/or its affiliates. All rights reserved.\n" +
|
||||
" */\n";
|
||||
|
||||
// Last updated: - 1/16/2015, 1:42:31 PM
|
||||
// Last updated: - 6/06/2016, 1:42:31 PM
|
||||
private static final String UNICODE =
|
||||
"/*\n" +
|
||||
" * COPYRIGHT AND PERMISSION NOTICE\n" +
|
||||
" *\n" +
|
||||
" * Copyright (C) 1991-2015 Unicode, Inc. All rights reserved.\n" +
|
||||
" * Copyright (C) 1991-2016 Unicode, Inc. All rights reserved.\n" +
|
||||
" * Distributed under the Terms of Use in \n" +
|
||||
" * http://www.unicode.org/copyright.html.\n" +
|
||||
" *\n" +
|
||||
|
@ -417,6 +417,12 @@ class LDMLParseHandler extends AbstractLDMLHandler<Object> {
|
||||
case "timeZoneNames":
|
||||
pushContainer(qName, attributes);
|
||||
break;
|
||||
case "hourFormat":
|
||||
pushStringEntry(qName, attributes, "timezone.hourFormat");
|
||||
break;
|
||||
case "gmtFormat":
|
||||
pushStringEntry(qName, attributes, "timezone.gmtFormat");
|
||||
break;
|
||||
case "zone":
|
||||
{
|
||||
String tzid = attributes.getValue("type"); // Olson tz id
|
||||
|
@ -67,19 +67,35 @@ class VersionProps {
|
||||
System.setProperty("java.runtime.name", java_runtime_name);
|
||||
}
|
||||
|
||||
static List<Integer> versionNumbers() {
|
||||
List<Integer> versionNumbers = new ArrayList<>(4);
|
||||
private static int parseVersionNumber(String version, int prevIndex, int index) {
|
||||
if (index - prevIndex > 1 &&
|
||||
Character.digit(version.charAt(prevIndex), 10) <= 0)
|
||||
throw new IllegalArgumentException("Leading zeros not supported (" +
|
||||
version.substring(prevIndex, index) + ")");
|
||||
return Integer.parseInt(version, prevIndex, index, 10);
|
||||
}
|
||||
|
||||
// This method is reflectively used by regression tests.
|
||||
static List<Integer> parseVersionNumbers(String version) {
|
||||
List<Integer> verNumbers = new ArrayList<>(4);
|
||||
int prevIndex = 0;
|
||||
int index = VERSION_NUMBER.indexOf('.');
|
||||
int index = version.indexOf('.');
|
||||
while (index > 0) {
|
||||
versionNumbers.add(
|
||||
Integer.parseInt(VERSION_NUMBER, prevIndex, index, 10));
|
||||
verNumbers.add(parseVersionNumber(version, prevIndex, index));
|
||||
prevIndex = index + 1; // Skip the period
|
||||
index = VERSION_NUMBER.indexOf('.', prevIndex);
|
||||
index = version.indexOf('.', prevIndex);
|
||||
}
|
||||
versionNumbers.add(Integer.parseInt(VERSION_NUMBER,
|
||||
prevIndex, VERSION_NUMBER.length(), 10));
|
||||
return versionNumbers;
|
||||
verNumbers.add(parseVersionNumber(version, prevIndex, version.length()));
|
||||
|
||||
if (verNumbers.get(0) == 0 || verNumbers.get(verNumbers.size() - 1) == 0)
|
||||
throw new IllegalArgumentException("Leading/trailing zeros not supported (" +
|
||||
verNumbers + ")");
|
||||
|
||||
return verNumbers;
|
||||
}
|
||||
|
||||
static List<Integer> versionNumbers() {
|
||||
return parseVersionNumbers(VERSION_NUMBER);
|
||||
}
|
||||
|
||||
static Optional<String> pre() {
|
||||
|
@ -523,7 +523,7 @@ class ModulePath implements ConfigurableModuleFinder {
|
||||
try (JarFile jf = new JarFile(file.toFile(),
|
||||
true, // verify
|
||||
ZipFile.OPEN_READ,
|
||||
JarFile.Release.RUNTIME))
|
||||
JarFile.runtimeVersion()))
|
||||
{
|
||||
ModuleDescriptor md;
|
||||
JarEntry entry = jf.getJarEntry(MODULE_INFO);
|
||||
|
@ -201,7 +201,7 @@ class ModuleReferences {
|
||||
return new JarFile(path.toFile(),
|
||||
true, // verify
|
||||
ZipFile.OPEN_READ,
|
||||
JarFile.Release.RUNTIME);
|
||||
JarFile.runtimeVersion());
|
||||
} catch (IOException ioe) {
|
||||
throw new UncheckedIOException(ioe);
|
||||
}
|
||||
|
@ -59,9 +59,11 @@ import sun.security.util.SecurityConstants;
|
||||
|
||||
/**
|
||||
* This class loader is used to load classes and resources from a search
|
||||
* path of URLs referring to both JAR files and directories. Any URL that
|
||||
* ends with a '/' is assumed to refer to a directory. Otherwise, the URL
|
||||
* is assumed to refer to a JAR file which will be opened as needed.
|
||||
* path of URLs referring to both JAR files and directories. Any {@code jar:}
|
||||
* scheme URL (see {@link java.net.JarURLConnection}) is assumed to refer to a
|
||||
* JAR file. Any {@code file:} scheme URL that ends with a '/' is assumed to
|
||||
* refer to a directory. Otherwise, the URL is assumed to refer to a JAR file
|
||||
* which will be opened as needed.
|
||||
* <p>
|
||||
* The AccessControlContext of the thread that created the instance of
|
||||
* URLClassLoader will be used when subsequently loading classes and
|
||||
@ -83,9 +85,11 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
||||
/**
|
||||
* Constructs a new URLClassLoader for the given URLs. The URLs will be
|
||||
* searched in the order specified for classes and resources after first
|
||||
* searching in the specified parent class loader. Any URL that ends with
|
||||
* a '/' is assumed to refer to a directory. Otherwise, the URL is assumed
|
||||
* to refer to a JAR file which will be downloaded and opened as needed.
|
||||
* searching in the specified parent class loader. Any {@code jar:}
|
||||
* scheme URL is assumed to refer to a JAR file. Any {@code file:} scheme
|
||||
* URL that ends with a '/' is assumed to refer to a directory. Otherwise,
|
||||
* the URL is assumed to refer to a JAR file which will be downloaded and
|
||||
* opened as needed.
|
||||
*
|
||||
* <p>If there is a security manager, this method first
|
||||
* calls the security manager's {@code checkCreateClassLoader} method
|
||||
|
@ -64,8 +64,8 @@ import sun.security.util.SignatureFileVerifier;
|
||||
* file, and as such an entry name is associated with at most one base entry.
|
||||
* The {@code JarFile} may be configured to process a multi-release jar file by
|
||||
* creating the {@code JarFile} with the
|
||||
* {@link JarFile#JarFile(File, boolean, int, Release)} constructor. The
|
||||
* {@code Release} object sets a maximum version used when searching for
|
||||
* {@link JarFile#JarFile(File, boolean, int, Runtime.Version)} constructor. The
|
||||
* {@code Runtime.Version} object sets a maximum version used when searching for
|
||||
* versioned entries. When so configured, an entry name
|
||||
* can correspond with at most one base entry and zero or more versioned
|
||||
* entries. A search is required to associate the entry name with the latest
|
||||
@ -74,8 +74,8 @@ import sun.security.util.SignatureFileVerifier;
|
||||
*
|
||||
* <p>Class loaders that utilize {@code JarFile} to load classes from the
|
||||
* contents of {@code JarFile} entries should construct the {@code JarFile}
|
||||
* by invoking the {@link JarFile#JarFile(File, boolean, int, Release)}
|
||||
* constructor with the value {@code Release.RUNTIME} assigned to the last
|
||||
* by invoking the {@link JarFile#JarFile(File, boolean, int, Runtime.Version)}
|
||||
* constructor with the value {@code Runtime.version()} assigned to the last
|
||||
* argument. This assures that classes compatible with the major
|
||||
* version of the running JVM are loaded from multi-release jar files.
|
||||
*
|
||||
@ -99,12 +99,12 @@ import sun.security.util.SignatureFileVerifier;
|
||||
* <li>
|
||||
* {@code jdk.util.jar.version} can be assigned a value that is the
|
||||
* {@code String} representation of a non-negative integer
|
||||
* {@code <= Version.current().major()}. The value is used to set the effective
|
||||
* {@code <= Runtime.version().major()}. The value is used to set the effective
|
||||
* runtime version to something other than the default value obtained by
|
||||
* evaluating {@code Version.current().major()}. The effective runtime version
|
||||
* is the version that the {@link JarFile#JarFile(File, boolean, int, Release)}
|
||||
* evaluating {@code Runtime.version().major()}. The effective runtime version
|
||||
* is the version that the {@link JarFile#JarFile(File, boolean, int, Runtime.Version)}
|
||||
* constructor uses when the value of the last argument is
|
||||
* {@code Release.RUNTIME}.
|
||||
* {@code JarFile.runtimeVersion()}.
|
||||
* </li>
|
||||
* <li>
|
||||
* {@code jdk.util.jar.enableMultiRelease} can be assigned one of the three
|
||||
@ -116,7 +116,7 @@ import sun.security.util.SignatureFileVerifier;
|
||||
* the method {@link JarFile#isMultiRelease()} returns <em>false</em>. The value
|
||||
* <em>force</em> causes the {@code JarFile} to be initialized to runtime
|
||||
* versioning after construction. It effectively does the same as this code:
|
||||
* {@code (new JarFile(File, boolean, int, Release.RUNTIME)}.
|
||||
* {@code (new JarFile(File, boolean, int, JarFile.runtimeVersion())}.
|
||||
* </li>
|
||||
* </ul>
|
||||
* </div>
|
||||
@ -129,8 +129,9 @@ import sun.security.util.SignatureFileVerifier;
|
||||
*/
|
||||
public
|
||||
class JarFile extends ZipFile {
|
||||
private final static int BASE_VERSION;
|
||||
private final static int RUNTIME_VERSION;
|
||||
private final static Runtime.Version BASE_VERSION;
|
||||
private final static int BASE_VERSION_MAJOR;
|
||||
private final static Runtime.Version RUNTIME_VERSION;
|
||||
private final static boolean MULTI_RELEASE_ENABLED;
|
||||
private final static boolean MULTI_RELEASE_FORCED;
|
||||
private SoftReference<Manifest> manRef;
|
||||
@ -138,10 +139,10 @@ class JarFile extends ZipFile {
|
||||
private JarVerifier jv;
|
||||
private boolean jvInitialized;
|
||||
private boolean verify;
|
||||
private final int version;
|
||||
private boolean notVersioned;
|
||||
private final boolean runtimeVersioned;
|
||||
private boolean isMultiRelease; // is jar multi-release?
|
||||
private final Runtime.Version version; // current version
|
||||
private final int versionMajor; // version.major()
|
||||
private boolean notVersioned; // legacy constructor called
|
||||
private boolean isMultiRelease; // is jar multi-release?
|
||||
|
||||
// indicates if Class-Path attribute present
|
||||
private boolean hasClassPathAttribute;
|
||||
@ -151,17 +152,18 @@ class JarFile extends ZipFile {
|
||||
static {
|
||||
// Set up JavaUtilJarAccess in SharedSecrets
|
||||
SharedSecrets.setJavaUtilJarAccess(new JavaUtilJarAccessImpl());
|
||||
|
||||
BASE_VERSION = 8; // one less than lowest version for versioned entries
|
||||
// multi-release jar file versions >= 9
|
||||
BASE_VERSION = Runtime.Version.parse(Integer.toString(8));
|
||||
BASE_VERSION_MAJOR = BASE_VERSION.major();
|
||||
String jarVersion = GetPropertyAction.privilegedGetProperty("jdk.util.jar.version");
|
||||
int runtimeVersion = Runtime.version().major();
|
||||
String jarVersion =
|
||||
GetPropertyAction.privilegedGetProperty("jdk.util.jar.version");
|
||||
if (jarVersion != null) {
|
||||
int jarVer = Integer.parseInt(jarVersion);
|
||||
runtimeVersion = (jarVer > runtimeVersion)
|
||||
? runtimeVersion : Math.max(jarVer, 0);
|
||||
? runtimeVersion
|
||||
: Math.max(jarVer, BASE_VERSION_MAJOR);
|
||||
}
|
||||
RUNTIME_VERSION = runtimeVersion;
|
||||
RUNTIME_VERSION = Runtime.Version.parse(Integer.toString(runtimeVersion));
|
||||
String enableMultiRelease = GetPropertyAction
|
||||
.privilegedGetProperty("jdk.util.jar.enableMultiRelease", "true");
|
||||
switch (enableMultiRelease) {
|
||||
@ -181,61 +183,6 @@ class JarFile extends ZipFile {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A set of constants that represent the entries in either the base directory
|
||||
* or one of the versioned directories in a multi-release jar file. It's
|
||||
* possible for a multi-release jar file to contain versioned directories
|
||||
* that are not represented by the constants of the {@code Release} enum.
|
||||
* In those cases, the entries will not be located by this {@code JarFile}
|
||||
* through the aliasing mechanism, but they can be directly accessed by
|
||||
* specifying the full path name of the entry.
|
||||
*
|
||||
* @since 9
|
||||
*/
|
||||
public enum Release {
|
||||
/**
|
||||
* Represents unversioned entries, or entries in "regular", as opposed
|
||||
* to multi-release jar files.
|
||||
*/
|
||||
BASE(BASE_VERSION),
|
||||
|
||||
/**
|
||||
* Represents entries found in the META-INF/versions/9 directory of a
|
||||
* multi-release jar file.
|
||||
*/
|
||||
VERSION_9(9),
|
||||
|
||||
// fill in the "blanks" for future releases
|
||||
|
||||
/**
|
||||
* Represents entries found in the META-INF/versions/{n} directory of a
|
||||
* multi-release jar file, where {@code n} is the effective runtime
|
||||
* version of the jar file.
|
||||
*
|
||||
* @implNote
|
||||
* <div class="block">
|
||||
* The effective runtime version is determined
|
||||
* by evaluating {@code Version.current().major()} or by using the value
|
||||
* of the {@code jdk.util.jar.version} System property if it exists.
|
||||
* </div>
|
||||
*/
|
||||
RUNTIME(RUNTIME_VERSION);
|
||||
|
||||
Release(int version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
private static Release valueOf(int version) {
|
||||
return version <= BASE.value() ? BASE : valueOf("VERSION_" + version);
|
||||
}
|
||||
|
||||
private final int version;
|
||||
|
||||
private int value() {
|
||||
return this.version;
|
||||
}
|
||||
}
|
||||
|
||||
private static final String META_INF = "META-INF/";
|
||||
|
||||
private static final String META_INF_VERSIONS = META_INF + "versions/";
|
||||
@ -245,6 +192,32 @@ class JarFile extends ZipFile {
|
||||
*/
|
||||
public static final String MANIFEST_NAME = META_INF + "MANIFEST.MF";
|
||||
|
||||
/**
|
||||
* The version that represents the unversioned configuration of a multi-release jar file.
|
||||
*
|
||||
* @return Runtime.Version that represents the unversioned configuration
|
||||
*
|
||||
* @since 9
|
||||
*/
|
||||
public static Runtime.Version baseVersion() {
|
||||
return BASE_VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
* The version that represents the effective runtime versioned configuration of a
|
||||
* multi-release jar file. In most cases, {@code runtimeVersion()} is equal to
|
||||
* {@code Runtime.version()}. However, if the {@code jdk.util.jar.version} property is set,
|
||||
* {@code runtimeVersion()} is derived from that property and may not be equal to
|
||||
* {@code Runtime.version()}.
|
||||
*
|
||||
* @return Runtime.Version that represents the runtime versioned configuration
|
||||
*
|
||||
* @since 9
|
||||
*/
|
||||
public static Runtime.Version runtimeVersion() {
|
||||
return RUNTIME_VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@code JarFile} to read from the specified
|
||||
* file {@code name}. The {@code JarFile} will be verified if
|
||||
@ -316,7 +289,7 @@ class JarFile extends ZipFile {
|
||||
* @since 1.3
|
||||
*/
|
||||
public JarFile(File file, boolean verify, int mode) throws IOException {
|
||||
this(file, verify, mode, Release.BASE);
|
||||
this(file, verify, mode, BASE_VERSION);
|
||||
this.notVersioned = true;
|
||||
}
|
||||
|
||||
@ -324,8 +297,13 @@ class JarFile extends ZipFile {
|
||||
* Creates a new {@code JarFile} to read from the specified
|
||||
* {@code File} object in the specified mode. The mode argument
|
||||
* must be either {@code OPEN_READ} or {@code OPEN_READ | OPEN_DELETE}.
|
||||
* The version argument configures the {@code JarFile} for processing
|
||||
* The version argument, after being converted to a canonical form, is
|
||||
* used to configure the {@code JarFile} for processing
|
||||
* multi-release jar files.
|
||||
* <p>
|
||||
* The canonical form derived from the version parameter is
|
||||
* {@code Runtime.Version.parse(Integer.toString(n))} where {@code n} is
|
||||
* {@code Math.max(version.major(), JarFile.baseVersion().major())}.
|
||||
*
|
||||
* @param file the jar file to be opened for reading
|
||||
* @param verify whether or not to verify the jar file if
|
||||
@ -340,47 +318,31 @@ class JarFile extends ZipFile {
|
||||
* @throws NullPointerException if {@code version} is {@code null}
|
||||
* @since 9
|
||||
*/
|
||||
public JarFile(File file, boolean verify, int mode, Release version) throws IOException {
|
||||
public JarFile(File file, boolean verify, int mode, Runtime.Version version) throws IOException {
|
||||
super(file, mode);
|
||||
Objects.requireNonNull(version);
|
||||
this.verify = verify;
|
||||
// version applies to multi-release jar files, ignored for regular jar files
|
||||
if (MULTI_RELEASE_FORCED) {
|
||||
Objects.requireNonNull(version);
|
||||
if (MULTI_RELEASE_FORCED || version.major() == RUNTIME_VERSION.major()) {
|
||||
// This deals with the common case where the value from JarFile.runtimeVersion() is passed
|
||||
this.version = RUNTIME_VERSION;
|
||||
version = Release.RUNTIME;
|
||||
} else if (version.major() <= BASE_VERSION_MAJOR) {
|
||||
// This also deals with the common case where the value from JarFile.baseVersion() is passed
|
||||
this.version = BASE_VERSION;
|
||||
} else {
|
||||
this.version = version.value();
|
||||
}
|
||||
this.runtimeVersioned = version == Release.RUNTIME;
|
||||
|
||||
assert runtimeVersionExists();
|
||||
}
|
||||
|
||||
private boolean runtimeVersionExists() {
|
||||
int version = Runtime.version().major();
|
||||
try {
|
||||
Release.valueOf(version);
|
||||
return true;
|
||||
} catch (IllegalArgumentException x) {
|
||||
System.err.println("No JarFile.Release object for release " + version);
|
||||
return false;
|
||||
// Canonicalize
|
||||
this.version = Runtime.Version.parse(Integer.toString(version.major()));
|
||||
}
|
||||
this.versionMajor = this.version.major();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum version used when searching for versioned entries.
|
||||
*
|
||||
* @return the maximum version, or {@code Release.BASE} if this jar file is
|
||||
* processed as if it is an unversioned jar file or is not a
|
||||
* multi-release jar file
|
||||
* @return the maximum version
|
||||
* @since 9
|
||||
*/
|
||||
public final Release getVersion() {
|
||||
if (isMultiRelease()) {
|
||||
return runtimeVersioned ? Release.RUNTIME : Release.valueOf(version);
|
||||
} else {
|
||||
return Release.BASE;
|
||||
}
|
||||
public final Runtime.Version getVersion() {
|
||||
return isMultiRelease() ? this.version : BASE_VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -393,7 +355,7 @@ class JarFile extends ZipFile {
|
||||
if (isMultiRelease) {
|
||||
return true;
|
||||
}
|
||||
if (MULTI_RELEASE_ENABLED && version != BASE_VERSION) {
|
||||
if (MULTI_RELEASE_ENABLED && versionMajor != BASE_VERSION_MAJOR) {
|
||||
try {
|
||||
checkForSpecialAttributes();
|
||||
} catch (IOException io) {
|
||||
@ -639,7 +601,7 @@ class JarFile extends ZipFile {
|
||||
ZipEntry vze = null;
|
||||
String sname = "/" + name;
|
||||
int i = version;
|
||||
while (i > BASE_VERSION) {
|
||||
while (i > BASE_VERSION_MAJOR) {
|
||||
vze = super.getEntry(META_INF_VERSIONS + i + sname);
|
||||
if (vze != null) break;
|
||||
i--;
|
||||
@ -649,10 +611,10 @@ class JarFile extends ZipFile {
|
||||
|
||||
private ZipEntry getVersionedEntry(ZipEntry ze) {
|
||||
ZipEntry vze = null;
|
||||
if (version > BASE_VERSION && !ze.isDirectory()) {
|
||||
if (BASE_VERSION_MAJOR < versionMajor && !ze.isDirectory()) {
|
||||
String name = ze.getName();
|
||||
if (!name.startsWith(META_INF)) {
|
||||
vze = searchForVersionedEntry(version, name);
|
||||
vze = searchForVersionedEntry(versionMajor, name);
|
||||
}
|
||||
}
|
||||
return vze == null ? ze : vze;
|
||||
@ -1038,7 +1000,7 @@ class JarFile extends ZipFile {
|
||||
hasClassPathAttribute = match(CLASSPATH_CHARS, b,
|
||||
CLASSPATH_LASTOCC) != -1;
|
||||
// is this a multi-release jar file
|
||||
if (MULTI_RELEASE_ENABLED && version != BASE_VERSION) {
|
||||
if (MULTI_RELEASE_ENABLED && versionMajor != BASE_VERSION_MAJOR) {
|
||||
int i = match(MULTIRELEASE_CHARS, b, MULTIRELEASE_LASTOCC);
|
||||
if (i != -1) {
|
||||
i += MULTIRELEASE_CHARS.length;
|
||||
|
@ -179,6 +179,10 @@ class InflaterInputStream extends FilterInputStream {
|
||||
ensureOpen();
|
||||
if (reachEOF) {
|
||||
return 0;
|
||||
} else if (inf.finished()) {
|
||||
// the end of the compressed data stream has been reached
|
||||
reachEOF = true;
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
|
@ -695,7 +695,7 @@ public class URLClassPath {
|
||||
throw new FileNotFoundException(p.getPath());
|
||||
}
|
||||
return checkJar(new JarFile(new File(p.getPath()), true, ZipFile.OPEN_READ,
|
||||
JarFile.Release.RUNTIME));
|
||||
JarFile.runtimeVersion()));
|
||||
}
|
||||
URLConnection uc = (new URL(getBaseURL(), "#runtime")).openConnection();
|
||||
uc.setRequestProperty(USER_AGENT_JAVA_VERSION, JAVA_VERSION);
|
||||
|
@ -66,7 +66,9 @@ public class URLJarFile extends JarFile {
|
||||
|
||||
static JarFile getJarFile(URL url, URLJarFileCloseController closeController) throws IOException {
|
||||
if (isFileURL(url)) {
|
||||
Release version = "runtime".equals(url.getRef()) ? Release.RUNTIME : Release.BASE;
|
||||
Runtime.Version version = "runtime".equals(url.getRef())
|
||||
? JarFile.runtimeVersion()
|
||||
: JarFile.baseVersion();
|
||||
return new URLJarFile(url, closeController, version);
|
||||
} else {
|
||||
return retrieve(url, closeController);
|
||||
@ -90,12 +92,14 @@ public class URLJarFile extends JarFile {
|
||||
this.closeController = closeController;
|
||||
}
|
||||
|
||||
private URLJarFile(File file, URLJarFileCloseController closeController, Release version) throws IOException {
|
||||
private URLJarFile(File file, URLJarFileCloseController closeController, Runtime.Version version)
|
||||
throws IOException {
|
||||
super(file, true, ZipFile.OPEN_READ | ZipFile.OPEN_DELETE, version);
|
||||
this.closeController = closeController;
|
||||
}
|
||||
|
||||
private URLJarFile(URL url, URLJarFileCloseController closeController, Release version) throws IOException {
|
||||
private URLJarFile(URL url, URLJarFileCloseController closeController, Runtime.Version version)
|
||||
throws IOException {
|
||||
super(new File(ParseUtil.decode(url.getFile())), true, ZipFile.OPEN_READ, version);
|
||||
this.closeController = closeController;
|
||||
}
|
||||
@ -200,7 +204,9 @@ public class URLJarFile extends JarFile {
|
||||
{
|
||||
|
||||
JarFile result = null;
|
||||
Release version = "runtime".equals(url.getRef()) ? Release.RUNTIME : Release.BASE;
|
||||
Runtime.Version version = "runtime".equals(url.getRef())
|
||||
? JarFile.runtimeVersion()
|
||||
: JarFile.baseVersion();
|
||||
|
||||
/* get the stream before asserting privileges */
|
||||
try (final InputStream in = url.openConnection().getInputStream()) {
|
||||
|
@ -38,6 +38,8 @@ import java.net.URL;
|
||||
|
||||
import java.security.KeyStore;
|
||||
|
||||
import java.security.Provider;
|
||||
import java.security.Security;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.text.Collator;
|
||||
|
||||
@ -46,6 +48,7 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Properties;
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
import sun.security.util.PropertyExpander;
|
||||
|
||||
@ -209,6 +212,7 @@ public class KeyStoreUtil {
|
||||
|
||||
/**
|
||||
* Prepends matched options from a pre-configured options file.
|
||||
*
|
||||
* @param tool the name of the tool, can be "keytool" or "jarsigner"
|
||||
* @param file the pre-configured options file
|
||||
* @param c1 the name of the command, with the "-" prefix,
|
||||
@ -259,4 +263,68 @@ public class KeyStoreUtil {
|
||||
return result.toArray(new String[result.size()]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a security provider as a service.
|
||||
*
|
||||
* @param provName the name
|
||||
* @param arg optional arg
|
||||
* @throws IllegalArgumentException if no provider matches the name
|
||||
*/
|
||||
public static void loadProviderByName(String provName, String arg) {
|
||||
Provider loaded = Security.getProvider(provName);
|
||||
if (loaded != null) {
|
||||
if (arg != null) {
|
||||
loaded = loaded.configure(arg);
|
||||
Security.addProvider(loaded);
|
||||
}
|
||||
return;
|
||||
}
|
||||
for (Provider p : ServiceLoader.load(Provider.class,
|
||||
ClassLoader.getSystemClassLoader())) {
|
||||
if (p.getName().equals(provName)) {
|
||||
if (arg != null) {
|
||||
p = p.configure(arg);
|
||||
}
|
||||
Security.addProvider(p);
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("No provider found");
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a security provider by a fully-qualified class name.
|
||||
*
|
||||
* @param provClass the class name
|
||||
* @param arg optional arg
|
||||
* @param cl optional class loader
|
||||
* @throws IllegalArgumentException if no provider matches the class name
|
||||
* @throws ClassCastException if the class has not extended Provider
|
||||
*/
|
||||
public static void loadProviderByClass(
|
||||
String provClass, String arg, ClassLoader cl) {
|
||||
|
||||
// For compatibility, SunPKCS11 and OracleUcrypto can still be
|
||||
// loadable with -providerClass.
|
||||
if (provClass.equals("sun.security.pkcs11.SunPKCS11")) {
|
||||
loadProviderByName("SunPKCS11", arg);
|
||||
return;
|
||||
} else if (provClass.equals("com.oracle.security.crypto.UcryptoProvider")) {
|
||||
loadProviderByName("OracleUcrypto", arg);
|
||||
return;
|
||||
}
|
||||
|
||||
Provider prov;
|
||||
try {
|
||||
Class<?> clazz = Class.forName(provClass, false, cl);
|
||||
prov = (Provider) clazz.getConstructor().newInstance();
|
||||
} catch (ReflectiveOperationException e) {
|
||||
throw new IllegalArgumentException(e);
|
||||
}
|
||||
if (arg != null) {
|
||||
prov = prov.configure(arg);
|
||||
}
|
||||
Security.addProvider(prov);
|
||||
}
|
||||
}
|
||||
|
@ -33,13 +33,11 @@ import java.security.MessageDigest;
|
||||
import java.security.Key;
|
||||
import java.security.PublicKey;
|
||||
import java.security.PrivateKey;
|
||||
import java.security.Security;
|
||||
import java.security.Signature;
|
||||
import java.security.Timestamp;
|
||||
import java.security.UnrecoverableEntryException;
|
||||
import java.security.UnrecoverableKeyException;
|
||||
import java.security.Principal;
|
||||
import java.security.Provider;
|
||||
import java.security.cert.Certificate;
|
||||
import java.security.cert.CertificateFactory;
|
||||
import java.security.cert.CertStoreException;
|
||||
@ -128,6 +126,7 @@ public final class Main {
|
||||
// them through the command line.
|
||||
|
||||
private Set<Pair <String, String>> providers = null;
|
||||
private Set<Pair <String, String>> providerClasses = null;
|
||||
private String storetype = null;
|
||||
private boolean hasStoretypeOption = false;
|
||||
private String srcProviderName = null;
|
||||
@ -166,57 +165,57 @@ public final class Main {
|
||||
enum Command {
|
||||
CERTREQ("Generates.a.certificate.request",
|
||||
ALIAS, SIGALG, FILEOUT, KEYPASS, KEYSTORE, DNAME,
|
||||
STOREPASS, STORETYPE, PROVIDERNAME, PROVIDERCLASS,
|
||||
PROVIDERARG, PROVIDERPATH, V, PROTECTED),
|
||||
STOREPASS, STORETYPE, PROVIDERNAME, ADDPROVIDER,
|
||||
PROVIDERCLASS, PROVIDERPATH, V, PROTECTED),
|
||||
CHANGEALIAS("Changes.an.entry.s.alias",
|
||||
ALIAS, DESTALIAS, KEYPASS, KEYSTORE, STOREPASS,
|
||||
STORETYPE, PROVIDERNAME, PROVIDERCLASS, PROVIDERARG,
|
||||
STORETYPE, PROVIDERNAME, ADDPROVIDER, PROVIDERCLASS,
|
||||
PROVIDERPATH, V, PROTECTED),
|
||||
DELETE("Deletes.an.entry",
|
||||
ALIAS, KEYSTORE, STOREPASS, STORETYPE,
|
||||
PROVIDERNAME, PROVIDERCLASS, PROVIDERARG,
|
||||
PROVIDERNAME, ADDPROVIDER, PROVIDERCLASS,
|
||||
PROVIDERPATH, V, PROTECTED),
|
||||
EXPORTCERT("Exports.certificate",
|
||||
RFC, ALIAS, FILEOUT, KEYSTORE, STOREPASS,
|
||||
STORETYPE, PROVIDERNAME, PROVIDERCLASS, PROVIDERARG,
|
||||
STORETYPE, PROVIDERNAME, ADDPROVIDER, PROVIDERCLASS,
|
||||
PROVIDERPATH, V, PROTECTED),
|
||||
GENKEYPAIR("Generates.a.key.pair",
|
||||
ALIAS, KEYALG, KEYSIZE, SIGALG, DESTALIAS, DNAME,
|
||||
STARTDATE, EXT, VALIDITY, KEYPASS, KEYSTORE,
|
||||
STOREPASS, STORETYPE, PROVIDERNAME, PROVIDERCLASS,
|
||||
PROVIDERARG, PROVIDERPATH, V, PROTECTED),
|
||||
STOREPASS, STORETYPE, PROVIDERNAME, ADDPROVIDER,
|
||||
PROVIDERCLASS, PROVIDERPATH, V, PROTECTED),
|
||||
GENSECKEY("Generates.a.secret.key",
|
||||
ALIAS, KEYPASS, KEYALG, KEYSIZE, KEYSTORE,
|
||||
STOREPASS, STORETYPE, PROVIDERNAME, PROVIDERCLASS,
|
||||
PROVIDERARG, PROVIDERPATH, V, PROTECTED),
|
||||
STOREPASS, STORETYPE, PROVIDERNAME, ADDPROVIDER,
|
||||
PROVIDERCLASS, PROVIDERPATH, V, PROTECTED),
|
||||
GENCERT("Generates.certificate.from.a.certificate.request",
|
||||
RFC, INFILE, OUTFILE, ALIAS, SIGALG, DNAME,
|
||||
STARTDATE, EXT, VALIDITY, KEYPASS, KEYSTORE,
|
||||
STOREPASS, STORETYPE, PROVIDERNAME, PROVIDERCLASS,
|
||||
PROVIDERARG, PROVIDERPATH, V, PROTECTED),
|
||||
STOREPASS, STORETYPE, PROVIDERNAME, ADDPROVIDER,
|
||||
PROVIDERCLASS, PROVIDERPATH, V, PROTECTED),
|
||||
IMPORTCERT("Imports.a.certificate.or.a.certificate.chain",
|
||||
NOPROMPT, TRUSTCACERTS, PROTECTED, ALIAS, FILEIN,
|
||||
KEYPASS, KEYSTORE, STOREPASS, STORETYPE,
|
||||
PROVIDERNAME, PROVIDERCLASS, PROVIDERARG,
|
||||
PROVIDERNAME, ADDPROVIDER, PROVIDERCLASS,
|
||||
PROVIDERPATH, V),
|
||||
IMPORTPASS("Imports.a.password",
|
||||
ALIAS, KEYPASS, KEYALG, KEYSIZE, KEYSTORE,
|
||||
STOREPASS, STORETYPE, PROVIDERNAME, PROVIDERCLASS,
|
||||
PROVIDERARG, PROVIDERPATH, V, PROTECTED),
|
||||
STOREPASS, STORETYPE, PROVIDERNAME, ADDPROVIDER,
|
||||
PROVIDERCLASS, PROVIDERPATH, V, PROTECTED),
|
||||
IMPORTKEYSTORE("Imports.one.or.all.entries.from.another.keystore",
|
||||
SRCKEYSTORE, DESTKEYSTORE, SRCSTORETYPE,
|
||||
DESTSTORETYPE, SRCSTOREPASS, DESTSTOREPASS,
|
||||
SRCPROTECTED, DESTPROTECTED, SRCPROVIDERNAME, DESTPROVIDERNAME,
|
||||
SRCALIAS, DESTALIAS, SRCKEYPASS, DESTKEYPASS,
|
||||
NOPROMPT, PROVIDERCLASS, PROVIDERARG, PROVIDERPATH,
|
||||
NOPROMPT, ADDPROVIDER, PROVIDERCLASS, PROVIDERPATH,
|
||||
V),
|
||||
KEYPASSWD("Changes.the.key.password.of.an.entry",
|
||||
ALIAS, KEYPASS, NEW, KEYSTORE, STOREPASS,
|
||||
STORETYPE, PROVIDERNAME, PROVIDERCLASS, PROVIDERARG,
|
||||
STORETYPE, PROVIDERNAME, ADDPROVIDER, PROVIDERCLASS,
|
||||
PROVIDERPATH, V),
|
||||
LIST("Lists.entries.in.a.keystore",
|
||||
RFC, ALIAS, KEYSTORE, STOREPASS, STORETYPE,
|
||||
PROVIDERNAME, PROVIDERCLASS, PROVIDERARG,
|
||||
PROVIDERNAME, ADDPROVIDER, PROVIDERCLASS,
|
||||
PROVIDERPATH, V, PROTECTED),
|
||||
PRINTCERT("Prints.the.content.of.a.certificate",
|
||||
RFC, FILEIN, SSLSERVER, JARFILE, V),
|
||||
@ -226,26 +225,26 @@ public final class Main {
|
||||
FILEIN, V),
|
||||
STOREPASSWD("Changes.the.store.password.of.a.keystore",
|
||||
NEW, KEYSTORE, STOREPASS, STORETYPE, PROVIDERNAME,
|
||||
PROVIDERCLASS, PROVIDERARG, PROVIDERPATH, V),
|
||||
ADDPROVIDER, PROVIDERCLASS, PROVIDERPATH, V),
|
||||
|
||||
// Undocumented start here, KEYCLONE is used a marker in -help;
|
||||
|
||||
KEYCLONE("Clones.a.key.entry",
|
||||
ALIAS, DESTALIAS, KEYPASS, NEW, STORETYPE,
|
||||
KEYSTORE, STOREPASS, PROVIDERNAME, PROVIDERCLASS,
|
||||
PROVIDERARG, PROVIDERPATH, V),
|
||||
KEYSTORE, STOREPASS, PROVIDERNAME, ADDPROVIDER,
|
||||
PROVIDERCLASS, PROVIDERPATH, V),
|
||||
SELFCERT("Generates.a.self.signed.certificate",
|
||||
ALIAS, SIGALG, DNAME, STARTDATE, VALIDITY, KEYPASS,
|
||||
STORETYPE, KEYSTORE, STOREPASS, PROVIDERNAME,
|
||||
PROVIDERCLASS, PROVIDERARG, PROVIDERPATH, V),
|
||||
ADDPROVIDER, PROVIDERCLASS, PROVIDERPATH, V),
|
||||
GENCRL("Generates.CRL",
|
||||
RFC, FILEOUT, ID,
|
||||
ALIAS, SIGALG, EXT, KEYPASS, KEYSTORE,
|
||||
STOREPASS, STORETYPE, PROVIDERNAME, PROVIDERCLASS,
|
||||
PROVIDERARG, PROVIDERPATH, V, PROTECTED),
|
||||
STOREPASS, STORETYPE, PROVIDERNAME, ADDPROVIDER,
|
||||
PROVIDERCLASS, PROVIDERPATH, V, PROTECTED),
|
||||
IDENTITYDB("Imports.entries.from.a.JDK.1.1.x.style.identity.database",
|
||||
FILEIN, STORETYPE, KEYSTORE, STOREPASS, PROVIDERNAME,
|
||||
PROVIDERCLASS, PROVIDERARG, PROVIDERPATH, V);
|
||||
ADDPROVIDER, PROVIDERCLASS, PROVIDERPATH, V);
|
||||
|
||||
final String description;
|
||||
final Option[] options;
|
||||
@ -289,48 +288,48 @@ public final class Main {
|
||||
|
||||
enum Option {
|
||||
ALIAS("alias", "<alias>", "alias.name.of.the.entry.to.process"),
|
||||
DESTALIAS("destalias", "<destalias>", "destination.alias"),
|
||||
DESTALIAS("destalias", "<alias>", "destination.alias"),
|
||||
DESTKEYPASS("destkeypass", "<arg>", "destination.key.password"),
|
||||
DESTKEYSTORE("destkeystore", "<destkeystore>", "destination.keystore.name"),
|
||||
DESTKEYSTORE("destkeystore", "<keystore>", "destination.keystore.name"),
|
||||
DESTPROTECTED("destprotected", null, "destination.keystore.password.protected"),
|
||||
DESTPROVIDERNAME("destprovidername", "<destprovidername>", "destination.keystore.provider.name"),
|
||||
DESTPROVIDERNAME("destprovidername", "<name>", "destination.keystore.provider.name"),
|
||||
DESTSTOREPASS("deststorepass", "<arg>", "destination.keystore.password"),
|
||||
DESTSTORETYPE("deststoretype", "<deststoretype>", "destination.keystore.type"),
|
||||
DNAME("dname", "<dname>", "distinguished.name"),
|
||||
DESTSTORETYPE("deststoretype", "<type>", "destination.keystore.type"),
|
||||
DNAME("dname", "<name>", "distinguished.name"),
|
||||
EXT("ext", "<value>", "X.509.extension"),
|
||||
FILEOUT("file", "<filename>", "output.file.name"),
|
||||
FILEIN("file", "<filename>", "input.file.name"),
|
||||
FILEOUT("file", "<file>", "output.file.name"),
|
||||
FILEIN("file", "<file>", "input.file.name"),
|
||||
ID("id", "<id:reason>", "Serial.ID.of.cert.to.revoke"),
|
||||
INFILE("infile", "<filename>", "input.file.name"),
|
||||
KEYALG("keyalg", "<keyalg>", "key.algorithm.name"),
|
||||
INFILE("infile", "<file>", "input.file.name"),
|
||||
KEYALG("keyalg", "<alg>", "key.algorithm.name"),
|
||||
KEYPASS("keypass", "<arg>", "key.password"),
|
||||
KEYSIZE("keysize", "<keysize>", "key.bit.size"),
|
||||
KEYSIZE("keysize", "<size>", "key.bit.size"),
|
||||
KEYSTORE("keystore", "<keystore>", "keystore.name"),
|
||||
NEW("new", "<arg>", "new.password"),
|
||||
NOPROMPT("noprompt", null, "do.not.prompt"),
|
||||
OUTFILE("outfile", "<filename>", "output.file.name"),
|
||||
OUTFILE("outfile", "<file>", "output.file.name"),
|
||||
PROTECTED("protected", null, "password.through.protected.mechanism"),
|
||||
PROVIDERARG("providerarg", "<arg>", "provider.argument"),
|
||||
PROVIDERCLASS("providerclass", "<providerclass>", "provider.class.name"),
|
||||
PROVIDERNAME("providername", "<providername>", "provider.name"),
|
||||
PROVIDERPATH("providerpath", "<pathlist>", "provider.classpath"),
|
||||
PROVIDERCLASS("providerclass", "<class>\n[-providerarg <arg>]", "provider.class.option"),
|
||||
ADDPROVIDER("addprovider", "<name>\n[-providerarg <arg>]", "addprovider.option"),
|
||||
PROVIDERNAME("providername", "<name>", "provider.name"),
|
||||
PROVIDERPATH("providerpath", "<list>", "provider.classpath"),
|
||||
RFC("rfc", null, "output.in.RFC.style"),
|
||||
SIGALG("sigalg", "<sigalg>", "signature.algorithm.name"),
|
||||
SRCALIAS("srcalias", "<srcalias>", "source.alias"),
|
||||
SIGALG("sigalg", "<alg>", "signature.algorithm.name"),
|
||||
SRCALIAS("srcalias", "<alias>", "source.alias"),
|
||||
SRCKEYPASS("srckeypass", "<arg>", "source.key.password"),
|
||||
SRCKEYSTORE("srckeystore", "<srckeystore>", "source.keystore.name"),
|
||||
SRCKEYSTORE("srckeystore", "<keystore>", "source.keystore.name"),
|
||||
SRCPROTECTED("srcprotected", null, "source.keystore.password.protected"),
|
||||
SRCPROVIDERNAME("srcprovidername", "<srcprovidername>", "source.keystore.provider.name"),
|
||||
SRCPROVIDERNAME("srcprovidername", "<name>", "source.keystore.provider.name"),
|
||||
SRCSTOREPASS("srcstorepass", "<arg>", "source.keystore.password"),
|
||||
SRCSTORETYPE("srcstoretype", "<srcstoretype>", "source.keystore.type"),
|
||||
SRCSTORETYPE("srcstoretype", "<type>", "source.keystore.type"),
|
||||
SSLSERVER("sslserver", "<server[:port]>", "SSL.server.host.and.port"),
|
||||
JARFILE("jarfile", "<filename>", "signed.jar.file"),
|
||||
STARTDATE("startdate", "<startdate>", "certificate.validity.start.date.time"),
|
||||
JARFILE("jarfile", "<file>", "signed.jar.file"),
|
||||
STARTDATE("startdate", "<date>", "certificate.validity.start.date.time"),
|
||||
STOREPASS("storepass", "<arg>", "keystore.password"),
|
||||
STORETYPE("storetype", "<storetype>", "keystore.type"),
|
||||
STORETYPE("storetype", "<type>", "keystore.type"),
|
||||
TRUSTCACERTS("trustcacerts", null, "trust.certificates.from.cacerts"),
|
||||
V("v", null, "verbose.output"),
|
||||
VALIDITY("validity", "<valDays>", "validity.number.of.days");
|
||||
VALIDITY("validity", "<days>", "validity.number.of.days");
|
||||
|
||||
final String name, arg, description;
|
||||
Option(String name, String arg, String description) {
|
||||
@ -344,8 +343,6 @@ public final class Main {
|
||||
}
|
||||
};
|
||||
|
||||
private static final Class<?>[] PARAM_STRING = { String.class };
|
||||
|
||||
private static final String NONE = "NONE";
|
||||
private static final String P11KEYSTORE = "PKCS11";
|
||||
private static final String P12KEYSTORE = "PKCS12";
|
||||
@ -549,10 +546,10 @@ public final class Main {
|
||||
jarfile = args[++i];
|
||||
} else if (collator.compare(flags, "-srckeystore") == 0) {
|
||||
srcksfname = args[++i];
|
||||
} else if ((collator.compare(flags, "-provider") == 0) ||
|
||||
(collator.compare(flags, "-providerclass") == 0)) {
|
||||
if (providers == null) {
|
||||
providers = new HashSet<Pair <String, String>> (3);
|
||||
} else if (collator.compare(flags, "-provider") == 0 ||
|
||||
collator.compare(flags, "-providerclass") == 0) {
|
||||
if (providerClasses == null) {
|
||||
providerClasses = new HashSet<Pair <String, String>> (3);
|
||||
}
|
||||
String providerClass = args[++i];
|
||||
String providerArg = null;
|
||||
@ -565,8 +562,25 @@ public final class Main {
|
||||
i += 2;
|
||||
}
|
||||
}
|
||||
providers.add(
|
||||
providerClasses.add(
|
||||
Pair.of(providerClass, providerArg));
|
||||
} else if (collator.compare(flags, "-addprovider") == 0) {
|
||||
if (providers == null) {
|
||||
providers = new HashSet<Pair <String, String>> (3);
|
||||
}
|
||||
String provider = args[++i];
|
||||
String providerArg = null;
|
||||
|
||||
if (args.length > (i+1)) {
|
||||
flags = args[i+1];
|
||||
if (collator.compare(flags, "-providerarg") == 0) {
|
||||
if (args.length == (i+2)) errorNeedArgument(flags);
|
||||
providerArg = args[i+2];
|
||||
i += 2;
|
||||
}
|
||||
}
|
||||
providers.add(
|
||||
Pair.of(provider, providerArg));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -617,7 +631,6 @@ public final class Main {
|
||||
return cmd != PRINTCERT && cmd != PRINTCERTREQ;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Execute the commands.
|
||||
*/
|
||||
@ -703,6 +716,20 @@ public final class Main {
|
||||
|
||||
// Try to load and install specified provider
|
||||
if (providers != null) {
|
||||
for (Pair<String, String> provider : providers) {
|
||||
try {
|
||||
KeyStoreUtil.loadProviderByName(
|
||||
provider.fst, provider.snd);
|
||||
if (debug) {
|
||||
System.out.println("loadProviderByName: " + provider.fst);
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new Exception(String.format(rb.getString(
|
||||
"provider.name.not.found"), provider.fst));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (providerClasses != null) {
|
||||
ClassLoader cl = null;
|
||||
if (pathlist != null) {
|
||||
String path = null;
|
||||
@ -717,30 +744,20 @@ public final class Main {
|
||||
} else {
|
||||
cl = ClassLoader.getSystemClassLoader();
|
||||
}
|
||||
|
||||
for (Pair <String, String> provider: providers) {
|
||||
String provName = provider.fst;
|
||||
Class<?> provClass;
|
||||
if (cl != null) {
|
||||
provClass = cl.loadClass(provName);
|
||||
} else {
|
||||
provClass = Class.forName(provName);
|
||||
for (Pair<String, String> provider : providerClasses) {
|
||||
try {
|
||||
KeyStoreUtil.loadProviderByClass(
|
||||
provider.fst, provider.snd, cl);
|
||||
if (debug) {
|
||||
System.out.println("loadProviderByClass: " + provider.fst);
|
||||
}
|
||||
} catch (ClassCastException cce) {
|
||||
throw new Exception(String.format(rb.getString(
|
||||
"provclass.not.a.provider"), provider.fst));
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new Exception(String.format(rb.getString(
|
||||
"provider.class.not.found"), provider.fst), e.getCause());
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
Object obj = provClass.newInstance();
|
||||
if (!(obj instanceof Provider)) {
|
||||
MessageFormat form = new MessageFormat
|
||||
(rb.getString("provName.not.a.provider"));
|
||||
Object[] source = {provName};
|
||||
throw new Exception(form.format(source));
|
||||
}
|
||||
Provider p = (Provider) obj;
|
||||
String provArg = provider.snd;
|
||||
if (provArg != null) {
|
||||
p = p.configure(provArg);
|
||||
}
|
||||
Security.addProvider(p);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4132,27 +4149,40 @@ public final class Main {
|
||||
System.err.println(rb.getString("Options."));
|
||||
System.err.println();
|
||||
|
||||
// Left and right sides of the options list
|
||||
// Left and right sides of the options list. Both might
|
||||
// contain "\n" and span multiple lines
|
||||
String[] left = new String[command.options.length];
|
||||
String[] right = new String[command.options.length];
|
||||
|
||||
// Check if there's an unknown option
|
||||
boolean found = false;
|
||||
|
||||
// Length of left side of options list
|
||||
int lenLeft = 0;
|
||||
for (int j=0; j<left.length; j++) {
|
||||
|
||||
for (int j = 0; j < command.options.length; j++) {
|
||||
Option opt = command.options[j];
|
||||
left[j] = opt.toString();
|
||||
if (opt.arg != null) left[j] += " " + opt.arg;
|
||||
if (left[j].length() > lenLeft) {
|
||||
lenLeft = left[j].length();
|
||||
if (opt.arg != null) {
|
||||
left[j] += " " + opt.arg;
|
||||
}
|
||||
String[] lefts = left[j].split("\n");
|
||||
for (String s : lefts) {
|
||||
if (s.length() > lenLeft) {
|
||||
lenLeft = s.length();
|
||||
}
|
||||
}
|
||||
right[j] = rb.getString(opt.description);
|
||||
}
|
||||
for (int j=0; j<left.length; j++) {
|
||||
System.err.printf(" %-" + lenLeft + "s %s\n",
|
||||
left[j], right[j]);
|
||||
for (int j = 0; j < left.length; j++) {
|
||||
String[] lefts = left[j].split("\n");
|
||||
String[] rights = right[j].split("\n");
|
||||
for (int i = 0; i < lefts.length && i < rights.length; i++) {
|
||||
String s1 = i < lefts.length ? lefts[i] : "";
|
||||
String s2 = i < rights.length ? rights[i] : "";
|
||||
if (i == 0) {
|
||||
System.err.printf(" %-" + lenLeft + "s %s\n", s1, s2);
|
||||
} else {
|
||||
System.err.printf(" %-" + lenLeft + "s %s\n", s1, s2);
|
||||
}
|
||||
}
|
||||
}
|
||||
System.err.println();
|
||||
System.err.println(rb.getString(
|
||||
|
@ -133,10 +133,16 @@ public class Resources extends java.util.ListResourceBundle {
|
||||
"do not prompt"}, //-noprompt
|
||||
{"password.through.protected.mechanism",
|
||||
"password through protected mechanism"}, //-protected
|
||||
{"provider.argument",
|
||||
"provider argument"}, //-providerarg
|
||||
{"provider.class.name",
|
||||
"provider class name"}, //-providerclass
|
||||
|
||||
// The following 2 values should span 2 lines, the first for the
|
||||
// option itself, the second for its -providerArg value.
|
||||
{"addprovider.option",
|
||||
"add security provider by name (e.g. SunPKCS11)\n" +
|
||||
"configure argument for -addprovider"}, //-addprovider
|
||||
{"provider.class.option",
|
||||
"add security provider by fully-qualified class name\n" +
|
||||
"configure argument for -providerclass"}, //-providerclass
|
||||
|
||||
{"provider.name",
|
||||
"provider name"}, //-providername
|
||||
{"provider.classpath",
|
||||
@ -209,7 +215,9 @@ public class Resources extends java.util.ListResourceBundle {
|
||||
{"Illegal.startdate.value", "Illegal startdate value"},
|
||||
{"Validity.must.be.greater.than.zero",
|
||||
"Validity must be greater than zero"},
|
||||
{"provName.not.a.provider", "{0} not a provider"},
|
||||
{"provclass.not.a.provider", "%s not a provider"},
|
||||
{"provider.name.not.found", "Provider named \"%s\" not found"},
|
||||
{"provider.class.not.found", "Provider \"%s\" not found"},
|
||||
{"Usage.error.no.command.provided", "Usage error: no command provided"},
|
||||
{"Source.keystore.file.exists.but.is.empty.", "Source keystore file exists, but is empty: "},
|
||||
{"Please.specify.srckeystore", "Please specify -srckeystore"},
|
||||
|
@ -343,6 +343,10 @@ public class JavaTimeSupplementary extends OpenListResourceBundle {
|
||||
sharedShortEras },
|
||||
{ "roc.short.Eras",
|
||||
sharedShortEras },
|
||||
{ "timezone.gmtFormat",
|
||||
"GMT{0}" },
|
||||
{ "timezone.hourFormat",
|
||||
"+HH:mm;-HH:mm" },
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,8 @@ grant codeBase "jrt:/jdk.crypto.ucrypto" {
|
||||
permission java.security.SecurityPermission "putProviderProperty.OracleUcrypto";
|
||||
permission java.security.SecurityPermission "clearProviderProperties.OracleUcrypto";
|
||||
permission java.security.SecurityPermission "removeProviderProperty.OracleUcrypto";
|
||||
permission java.io.FilePermission "${java.home}/conf/security/ucrypto-solaris.cfg", "read";
|
||||
// Needed for reading Ucrypto config file
|
||||
permission java.io.FilePermission "<<ALL FILES>>", "read";
|
||||
};
|
||||
|
||||
grant codeBase "jrt:/java.sql" {
|
||||
|
@ -130,7 +130,7 @@ static void checkArg(const char *arg) {
|
||||
expectingNoDashArg = JNI_FALSE;
|
||||
}
|
||||
// only update on java mode and not yet found main class
|
||||
if (firstAppArgIndex == -1 && idx != 0) {
|
||||
if (firstAppArgIndex == NOT_FOUND && idx != 0) {
|
||||
firstAppArgIndex = (int) idx;
|
||||
}
|
||||
}
|
||||
|
@ -943,26 +943,6 @@ ProcessPlatformOption(const char *arg)
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
int
|
||||
filterArgs(StdArg *stdargs, const int nargc, StdArg **pargv) {
|
||||
StdArg* argv = NULL;
|
||||
int nargs = 0;
|
||||
int i;
|
||||
|
||||
/* Copy the non-vm args */
|
||||
for (i = 0; i < nargc ; i++) {
|
||||
const char *arg = stdargs[i].arg;
|
||||
if (arg[0] == '-' && arg[1] == 'J')
|
||||
continue;
|
||||
argv = (StdArg*) JLI_MemRealloc(argv, (nargs+1) * sizeof(StdArg));
|
||||
argv[nargs].arg = JLI_StringDup(arg);
|
||||
argv[nargs].has_wildcard = stdargs[i].has_wildcard;
|
||||
nargs++;
|
||||
}
|
||||
*pargv = argv;
|
||||
return nargs;
|
||||
}
|
||||
|
||||
/*
|
||||
* At this point we have the arguments to the application, and we need to
|
||||
* check with original stdargs in order to compare which of these truly
|
||||
@ -975,12 +955,13 @@ CreateApplicationArgs(JNIEnv *env, char **strv, int argc)
|
||||
int i, j, idx;
|
||||
size_t tlen;
|
||||
jobjectArray outArray, inArray;
|
||||
char *ostart, *astart, **nargv;
|
||||
char *arg, **nargv;
|
||||
jboolean needs_expansion = JNI_FALSE;
|
||||
jmethodID mid;
|
||||
int filteredargc, stdargc;
|
||||
int stdargc;
|
||||
StdArg *stdargs;
|
||||
StdArg *filteredargs;
|
||||
int *appArgIdx;
|
||||
int isTool;
|
||||
jclass cls = GetLauncherHelperClass(env);
|
||||
NULL_CHECK0(cls);
|
||||
|
||||
@ -991,8 +972,6 @@ CreateApplicationArgs(JNIEnv *env, char **strv, int argc)
|
||||
stdargs = JLI_GetStdArgs();
|
||||
stdargc = JLI_GetStdArgc();
|
||||
|
||||
filteredargc = filterArgs(stdargs, stdargc, &filteredargs);
|
||||
|
||||
// sanity check, this should never happen
|
||||
if (argc > stdargc) {
|
||||
JLI_TraceLauncher("Warning: app args is larger than the original, %d %d\n", argc, stdargc);
|
||||
@ -1001,22 +980,35 @@ CreateApplicationArgs(JNIEnv *env, char **strv, int argc)
|
||||
}
|
||||
|
||||
// sanity check, match the args we have, to the holy grail
|
||||
idx = filteredargc - argc;
|
||||
ostart = filteredargs[idx].arg;
|
||||
astart = strv[0];
|
||||
// sanity check, ensure that the first argument of the arrays are the same
|
||||
if (JLI_StrCmp(ostart, astart) != 0) {
|
||||
// some thing is amiss the args don't match
|
||||
JLI_TraceLauncher("Warning: app args parsing error\n");
|
||||
JLI_TraceLauncher("passing arguments as-is\n");
|
||||
idx = JLI_GetAppArgIndex();
|
||||
isTool = (idx == 0);
|
||||
if (isTool) { idx++; } // skip tool name
|
||||
JLI_TraceLauncher("AppArgIndex: %d points to %s\n", idx, stdargs[idx].arg);
|
||||
|
||||
appArgIdx = calloc(argc, sizeof(int));
|
||||
for (i = idx, j = 0; i < stdargc; i++) {
|
||||
if (isTool) { // filter -J used by tools to pass JVM options
|
||||
arg = stdargs[i].arg;
|
||||
if (arg[0] == '-' && arg[1] == 'J') {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
appArgIdx[j++] = i;
|
||||
}
|
||||
// sanity check, ensure same number of arguments for application
|
||||
if (j != argc) {
|
||||
JLI_TraceLauncher("Warning: app args count doesn't match, %d %d\n", j, argc);
|
||||
JLI_TraceLauncher("passing arguments as-is.\n");
|
||||
JLI_MemFree(appArgIdx);
|
||||
return NewPlatformStringArray(env, strv, argc);
|
||||
}
|
||||
|
||||
// make a copy of the args which will be expanded in java if required.
|
||||
nargv = (char **)JLI_MemAlloc(argc * sizeof(char*));
|
||||
for (i = 0, j = idx; i < argc; i++, j++) {
|
||||
jboolean arg_expand = (JLI_StrCmp(filteredargs[j].arg, strv[i]) == 0)
|
||||
? filteredargs[j].has_wildcard
|
||||
for (i = 0; i < argc; i++) {
|
||||
j = appArgIdx[i];
|
||||
jboolean arg_expand = (JLI_StrCmp(stdargs[j].arg, strv[i]) == 0)
|
||||
? stdargs[j].has_wildcard
|
||||
: JNI_FALSE;
|
||||
if (needs_expansion == JNI_FALSE)
|
||||
needs_expansion = arg_expand;
|
||||
@ -1039,6 +1031,7 @@ CreateApplicationArgs(JNIEnv *env, char **strv, int argc)
|
||||
JLI_MemFree(nargv[i]);
|
||||
}
|
||||
JLI_MemFree(nargv);
|
||||
JLI_MemFree(appArgIdx);
|
||||
return NewPlatformStringArray(env, strv, argc);
|
||||
}
|
||||
NULL_CHECK0(mid = (*env)->GetStaticMethodID(env, cls,
|
||||
@ -1053,6 +1046,6 @@ CreateApplicationArgs(JNIEnv *env, char **strv, int argc)
|
||||
JLI_MemFree(nargv[i]);
|
||||
}
|
||||
JLI_MemFree(nargv);
|
||||
JLI_MemFree(filteredargs);
|
||||
JLI_MemFree(appArgIdx);
|
||||
return outArray;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2016, 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
|
||||
@ -387,11 +387,15 @@ public class LogManager {
|
||||
assert rootLogger == null;
|
||||
assert initializedCalled && !initializationDone;
|
||||
|
||||
// create root logger before reading primordial
|
||||
// configuration - to ensure that it will be added
|
||||
// before the global logger, and not after.
|
||||
owner.rootLogger = owner.new RootLogger();
|
||||
|
||||
// Read configuration.
|
||||
owner.readPrimordialConfiguration();
|
||||
|
||||
// Create and retain Logger for the root of the namespace.
|
||||
owner.rootLogger = owner.new RootLogger();
|
||||
owner.addLogger(owner.rootLogger);
|
||||
if (!owner.rootLogger.isLevelInitialized()) {
|
||||
owner.rootLogger.setLevel(defaultLevel);
|
||||
@ -516,7 +520,7 @@ public class LogManager {
|
||||
if (result == null) {
|
||||
// only allocate the new logger once
|
||||
Logger newLogger = new Logger(name, resourceBundleName,
|
||||
module == null ? null : module, this, false);
|
||||
module, this, false);
|
||||
do {
|
||||
if (addLogger(newLogger)) {
|
||||
// We successfully added the new Logger that we
|
||||
@ -569,15 +573,13 @@ public class LogManager {
|
||||
} while (logger == null);
|
||||
|
||||
// LogManager will set the sysLogger's handlers via LogManager.addLogger method.
|
||||
if (logger != sysLogger && sysLogger.accessCheckedHandlers().length == 0) {
|
||||
// if logger already exists but handlers not set
|
||||
if (logger != sysLogger) {
|
||||
// if logger already exists we merge the two logger configurations.
|
||||
final Logger l = logger;
|
||||
AccessController.doPrivileged(new PrivilegedAction<Void>() {
|
||||
@Override
|
||||
public Void run() {
|
||||
for (Handler hdl : l.accessCheckedHandlers()) {
|
||||
sysLogger.addHandler(hdl);
|
||||
}
|
||||
l.mergeWithSystemLogger(sysLogger);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
@ -259,13 +259,185 @@ public class Logger {
|
||||
private static final RuntimePermission GET_CLASS_LOADER_PERMISSION =
|
||||
new RuntimePermission("getClassLoader");
|
||||
|
||||
// A value class that holds the logger configuration data.
|
||||
// This configuration can be shared between an application logger
|
||||
// and a system logger of the same name.
|
||||
private static final class ConfigurationData {
|
||||
|
||||
// The delegate field is used to avoid races while
|
||||
// merging configuration. This will ensure that any pending
|
||||
// configuration action on an application logger will either
|
||||
// be finished before the merge happens, or will be forwarded
|
||||
// to the system logger configuration after the merge is completed.
|
||||
// By default delegate=this.
|
||||
private volatile ConfigurationData delegate;
|
||||
|
||||
volatile boolean useParentHandlers;
|
||||
volatile Filter filter;
|
||||
volatile Level levelObject;
|
||||
volatile int levelValue; // current effective level value
|
||||
final CopyOnWriteArrayList<Handler> handlers =
|
||||
new CopyOnWriteArrayList<>();
|
||||
|
||||
ConfigurationData() {
|
||||
delegate = this;
|
||||
useParentHandlers = true;
|
||||
levelValue = Level.INFO.intValue();
|
||||
}
|
||||
|
||||
void setUseParentHandlers(boolean flag) {
|
||||
useParentHandlers = flag;
|
||||
if (delegate != this) {
|
||||
// merge in progress - propagate value to system peer.
|
||||
final ConfigurationData system = delegate;
|
||||
synchronized (system) {
|
||||
system.useParentHandlers = useParentHandlers;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setFilter(Filter f) {
|
||||
filter = f;
|
||||
if (delegate != this) {
|
||||
// merge in progress - propagate value to system peer.
|
||||
final ConfigurationData system = delegate;
|
||||
synchronized (system) {
|
||||
system.filter = filter;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setLevelObject(Level l) {
|
||||
levelObject = l;
|
||||
if (delegate != this) {
|
||||
// merge in progress - propagate value to system peer.
|
||||
final ConfigurationData system = delegate;
|
||||
synchronized (system) {
|
||||
system.levelObject = levelObject;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setLevelValue(int v) {
|
||||
levelValue = v;
|
||||
if (delegate != this) {
|
||||
// merge in progress - propagate value to system peer.
|
||||
final ConfigurationData system = delegate;
|
||||
synchronized (system) {
|
||||
system.levelValue = levelValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void addHandler(Handler h) {
|
||||
if (handlers.add(h)) {
|
||||
if (delegate != this) {
|
||||
// merge in progress - propagate value to system peer.
|
||||
final ConfigurationData system = delegate;
|
||||
synchronized (system) {
|
||||
system.handlers.addIfAbsent(h);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void removeHandler(Handler h) {
|
||||
if (handlers.remove(h)) {
|
||||
if (delegate != this) {
|
||||
// merge in progress - propagate value to system peer.
|
||||
final ConfigurationData system = delegate;
|
||||
synchronized (system) {
|
||||
system.handlers.remove(h);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ConfigurationData merge(Logger systemPeer) {
|
||||
if (!systemPeer.isSystemLogger) {
|
||||
// should never come here
|
||||
throw new InternalError("not a system logger");
|
||||
}
|
||||
|
||||
ConfigurationData system = systemPeer.config;
|
||||
|
||||
if (system == this) {
|
||||
// nothing to do
|
||||
return system;
|
||||
}
|
||||
|
||||
synchronized (system) {
|
||||
// synchronize before checking on delegate to counter
|
||||
// race conditions where two threads might attempt to
|
||||
// merge concurrently
|
||||
if (delegate == system) {
|
||||
// merge already performed;
|
||||
return system;
|
||||
}
|
||||
|
||||
// publish system as the temporary delegate configuration.
|
||||
// This should take care of potential race conditions where
|
||||
// an other thread might attempt to call e.g. setlevel on
|
||||
// the application logger while merge is in progress.
|
||||
// (see implementation of ConfigurationData::setLevel)
|
||||
delegate = system;
|
||||
|
||||
// merge this config object data into the system config
|
||||
system.useParentHandlers = useParentHandlers;
|
||||
system.filter = filter;
|
||||
system.levelObject = levelObject;
|
||||
system.levelValue = levelValue;
|
||||
|
||||
// Prevent race condition in case two threads attempt to merge
|
||||
// configuration and add handlers at the same time. We don't want
|
||||
// to add the same handlers twice.
|
||||
//
|
||||
// Handlers are created and loaded by LogManager.addLogger. If we
|
||||
// reach here, then it means that the application logger has
|
||||
// been created first and added with LogManager.addLogger, and the
|
||||
// system logger was created after - and no handler has been added
|
||||
// to it by LogManager.addLogger. Therefore, system.handlers
|
||||
// should be empty.
|
||||
//
|
||||
// A non empty cfg.handlers list indicates a race condition
|
||||
// where two threads might attempt to merge the configuration
|
||||
// or add handlers concurrently. Though of no consequence for
|
||||
// the other data (level etc...) this would be an issue if we
|
||||
// added the same handlers twice.
|
||||
//
|
||||
for (Handler h : handlers) {
|
||||
if (!system.handlers.contains(h)) {
|
||||
systemPeer.addHandler(h);
|
||||
}
|
||||
}
|
||||
system.handlers.retainAll(handlers);
|
||||
system.handlers.addAllAbsent(handlers);
|
||||
}
|
||||
|
||||
// sanity: update effective level after merging
|
||||
synchronized(treeLock) {
|
||||
systemPeer.updateEffectiveLevel();
|
||||
}
|
||||
|
||||
return system;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// The logger configuration data. Ideally, this should be final
|
||||
// for system loggers, and replace-once for application loggers.
|
||||
// When an application requests a logger by name, we do not know a-priori
|
||||
// whether that corresponds to a system logger name or not.
|
||||
// So if no system logger by that name already exists, we simply return an
|
||||
// application logger.
|
||||
// If a system class later requests a system logger of the same name, then
|
||||
// the application logger and system logger configurations will be merged
|
||||
// in a single instance of ConfigurationData that both loggers will share.
|
||||
private volatile ConfigurationData config;
|
||||
|
||||
private volatile LogManager manager;
|
||||
private String name;
|
||||
private final CopyOnWriteArrayList<Handler> handlers =
|
||||
new CopyOnWriteArrayList<>();
|
||||
private volatile LoggerBundle loggerBundle = NO_RESOURCE_BUNDLE;
|
||||
private volatile boolean useParentHandlers = true;
|
||||
private volatile Filter filter;
|
||||
private boolean anonymous;
|
||||
|
||||
// Cache to speed up behavior of findResourceBundle:
|
||||
@ -280,8 +452,6 @@ public class Logger {
|
||||
// references from children to parents.
|
||||
private volatile Logger parent; // our nearest parent.
|
||||
private ArrayList<LogManager.LoggerWeakRef> kids; // WeakReferences to loggers that have us as parent
|
||||
private volatile Level levelObject;
|
||||
private volatile int levelValue; // current effective level value
|
||||
private WeakReference<Module> callerModuleRef;
|
||||
private final boolean isSystemLogger;
|
||||
|
||||
@ -384,9 +554,29 @@ public class Logger {
|
||||
LogManager manager, boolean isSystemLogger) {
|
||||
this.manager = manager;
|
||||
this.isSystemLogger = isSystemLogger;
|
||||
setupResourceInfo(resourceBundleName, caller);
|
||||
this.config = new ConfigurationData();
|
||||
this.name = name;
|
||||
levelValue = Level.INFO.intValue();
|
||||
setupResourceInfo(resourceBundleName, caller);
|
||||
}
|
||||
|
||||
// Called by LogManager when a system logger is created
|
||||
// after a user logger of the same name.
|
||||
// Ensure that both loggers will share the same
|
||||
// configuration.
|
||||
final void mergeWithSystemLogger(Logger system) {
|
||||
// sanity checks
|
||||
if (!system.isSystemLogger
|
||||
|| anonymous
|
||||
|| name == null
|
||||
|| !name.equals(system.name)) {
|
||||
// should never come here
|
||||
throw new InternalError("invalid logger merge");
|
||||
}
|
||||
checkPermission();
|
||||
final ConfigurationData cfg = config;
|
||||
if (cfg != system.config) {
|
||||
config = cfg.merge(system);
|
||||
}
|
||||
}
|
||||
|
||||
private void setCallerModuleRef(Module callerModule) {
|
||||
@ -408,7 +598,7 @@ public class Logger {
|
||||
// The manager field is not initialized here.
|
||||
this.name = name;
|
||||
this.isSystemLogger = true;
|
||||
levelValue = Level.INFO.intValue();
|
||||
config = new ConfigurationData();
|
||||
}
|
||||
|
||||
// It is called from LoggerContext.addLocalLogger() when the logger
|
||||
@ -451,7 +641,7 @@ public class Logger {
|
||||
private static Logger demandLogger(String name, String resourceBundleName, Class<?> caller) {
|
||||
LogManager manager = LogManager.getLogManager();
|
||||
if (!SystemLoggerHelper.disableCallerCheck) {
|
||||
if (caller.getClassLoader() == null) {
|
||||
if (isSystem(caller.getModule())) {
|
||||
return manager.demandSystemLogger(name, resourceBundleName, caller);
|
||||
}
|
||||
}
|
||||
@ -740,7 +930,7 @@ public class Logger {
|
||||
*/
|
||||
public void setFilter(Filter newFilter) throws SecurityException {
|
||||
checkPermission();
|
||||
filter = newFilter;
|
||||
config.setFilter(newFilter);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -749,7 +939,7 @@ public class Logger {
|
||||
* @return a filter object (may be null)
|
||||
*/
|
||||
public Filter getFilter() {
|
||||
return filter;
|
||||
return config.filter;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -765,7 +955,7 @@ public class Logger {
|
||||
if (!isLoggable(record.getLevel())) {
|
||||
return;
|
||||
}
|
||||
Filter theFilter = filter;
|
||||
Filter theFilter = config.filter;
|
||||
if (theFilter != null && !theFilter.isLoggable(record)) {
|
||||
return;
|
||||
}
|
||||
@ -784,7 +974,7 @@ public class Logger {
|
||||
}
|
||||
|
||||
final boolean useParentHdls = isSystemLogger
|
||||
? logger.useParentHandlers
|
||||
? logger.config.useParentHandlers
|
||||
: logger.getUseParentHandlers();
|
||||
|
||||
if (!useParentHdls) {
|
||||
@ -1804,13 +1994,13 @@ public class Logger {
|
||||
public void setLevel(Level newLevel) throws SecurityException {
|
||||
checkPermission();
|
||||
synchronized (treeLock) {
|
||||
levelObject = newLevel;
|
||||
config.setLevelObject(newLevel);
|
||||
updateEffectiveLevel();
|
||||
}
|
||||
}
|
||||
|
||||
final boolean isLevelInitialized() {
|
||||
return levelObject != null;
|
||||
return config.levelObject != null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1821,7 +2011,7 @@ public class Logger {
|
||||
* @return this Logger's level
|
||||
*/
|
||||
public Level getLevel() {
|
||||
return levelObject;
|
||||
return config.levelObject;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1833,6 +2023,7 @@ public class Logger {
|
||||
* @return true if the given message level is currently being logged.
|
||||
*/
|
||||
public boolean isLoggable(Level level) {
|
||||
int levelValue = config.levelValue;
|
||||
if (level.intValue() < levelValue || levelValue == offValue) {
|
||||
return false;
|
||||
}
|
||||
@ -1862,7 +2053,7 @@ public class Logger {
|
||||
public void addHandler(Handler handler) throws SecurityException {
|
||||
Objects.requireNonNull(handler);
|
||||
checkPermission();
|
||||
handlers.add(handler);
|
||||
config.addHandler(handler);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1880,7 +2071,7 @@ public class Logger {
|
||||
if (handler == null) {
|
||||
return;
|
||||
}
|
||||
handlers.remove(handler);
|
||||
config.removeHandler(handler);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1895,7 +2086,7 @@ public class Logger {
|
||||
// This method should ideally be marked final - but unfortunately
|
||||
// it needs to be overridden by LogManager.RootLogger
|
||||
Handler[] accessCheckedHandlers() {
|
||||
return handlers.toArray(emptyHandlers);
|
||||
return config.handlers.toArray(emptyHandlers);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1912,7 +2103,7 @@ public class Logger {
|
||||
*/
|
||||
public void setUseParentHandlers(boolean useParentHandlers) {
|
||||
checkPermission();
|
||||
this.useParentHandlers = useParentHandlers;
|
||||
config.setUseParentHandlers(useParentHandlers);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1922,7 +2113,7 @@ public class Logger {
|
||||
* @return true if output is to be sent to the logger's parent
|
||||
*/
|
||||
public boolean getUseParentHandlers() {
|
||||
return useParentHandlers;
|
||||
return config.useParentHandlers;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2256,11 +2447,13 @@ public class Logger {
|
||||
|
||||
// Figure out our current effective level.
|
||||
int newLevelValue;
|
||||
final ConfigurationData cfg = config;
|
||||
final Level levelObject = cfg.levelObject;
|
||||
if (levelObject != null) {
|
||||
newLevelValue = levelObject.intValue();
|
||||
} else {
|
||||
if (parent != null) {
|
||||
newLevelValue = parent.levelValue;
|
||||
newLevelValue = parent.config.levelValue;
|
||||
} else {
|
||||
// This may happen during initialization.
|
||||
newLevelValue = Level.INFO.intValue();
|
||||
@ -2268,11 +2461,11 @@ public class Logger {
|
||||
}
|
||||
|
||||
// If our effective value hasn't changed, we're done.
|
||||
if (levelValue == newLevelValue) {
|
||||
if (cfg.levelValue == newLevelValue) {
|
||||
return;
|
||||
}
|
||||
|
||||
levelValue = newLevelValue;
|
||||
cfg.setLevelValue(newLevelValue);
|
||||
|
||||
// System.err.println("effective level: \"" + getName() + "\" := " + level);
|
||||
|
||||
|
@ -300,7 +300,7 @@ abstract class AbstractLdapNamingEnumeration<T extends NameClassPair>
|
||||
errEx = e;
|
||||
}
|
||||
|
||||
protected abstract AbstractLdapNamingEnumeration<T> getReferredResults(
|
||||
protected abstract AbstractLdapNamingEnumeration<? extends NameClassPair> getReferredResults(
|
||||
LdapReferralContext refCtx) throws NamingException;
|
||||
|
||||
/*
|
||||
@ -360,7 +360,7 @@ abstract class AbstractLdapNamingEnumeration<T extends NameClassPair>
|
||||
* Merge the entries and/or referrals from the supplied enumeration
|
||||
* with those of the current enumeration.
|
||||
*/
|
||||
protected void update(AbstractLdapNamingEnumeration<T> ne) {
|
||||
protected void update(AbstractLdapNamingEnumeration<? extends NameClassPair> ne) {
|
||||
// Cleanup previous context first
|
||||
homeCtx.decEnumCount();
|
||||
|
||||
|
@ -104,9 +104,9 @@ final class LdapBindingEnumeration
|
||||
}
|
||||
|
||||
@Override
|
||||
protected LdapBindingEnumeration getReferredResults(
|
||||
protected AbstractLdapNamingEnumeration<? extends NameClassPair> getReferredResults(
|
||||
LdapReferralContext refCtx) throws NamingException{
|
||||
// repeat the original operation at the new context
|
||||
return (LdapBindingEnumeration)refCtx.listBindings(listArg);
|
||||
return (AbstractLdapNamingEnumeration<? extends NameClassPair>)refCtx.listBindings(listArg);
|
||||
}
|
||||
}
|
||||
|
@ -72,9 +72,9 @@ final class LdapNamingEnumeration
|
||||
}
|
||||
|
||||
@Override
|
||||
protected LdapNamingEnumeration getReferredResults(
|
||||
protected AbstractLdapNamingEnumeration<? extends NameClassPair> getReferredResults(
|
||||
LdapReferralContext refCtx) throws NamingException {
|
||||
// repeat the original operation at the new context
|
||||
return (LdapNamingEnumeration)refCtx.list(listArg);
|
||||
return (AbstractLdapNamingEnumeration<? extends NameClassPair>)refCtx.list(listArg);
|
||||
}
|
||||
}
|
||||
|
@ -199,15 +199,15 @@ final class LdapSearchEnumeration
|
||||
}
|
||||
|
||||
@Override
|
||||
protected LdapSearchEnumeration getReferredResults(
|
||||
protected AbstractLdapNamingEnumeration<? extends NameClassPair> getReferredResults(
|
||||
LdapReferralContext refCtx) throws NamingException {
|
||||
// repeat the original operation at the new context
|
||||
return (LdapSearchEnumeration)refCtx.search(
|
||||
return (AbstractLdapNamingEnumeration<? extends NameClassPair>)refCtx.search(
|
||||
searchArgs.name, searchArgs.filter, searchArgs.cons);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void update(AbstractLdapNamingEnumeration<SearchResult> ne) {
|
||||
protected void update(AbstractLdapNamingEnumeration<? extends NameClassPair> ne) {
|
||||
super.update(ne);
|
||||
|
||||
// Update search-specific variables
|
||||
|
@ -235,13 +235,14 @@ public final class UcryptoProvider extends Provider {
|
||||
|
||||
@Override
|
||||
public Provider configure(String configArg) throws InvalidParameterException {
|
||||
// default policy entry only grants read access to default config
|
||||
if (!defConfigName.equals(configArg)) {
|
||||
throw new InvalidParameterException("Ucrypto provider can only be " +
|
||||
"configured with default configuration file");
|
||||
try {
|
||||
init(configArg);
|
||||
} catch (UcryptoException ue) {
|
||||
InvalidParameterException ipe =
|
||||
new InvalidParameterException("Error using " + configArg);
|
||||
ipe.initCause(ue.getCause());
|
||||
throw ipe;
|
||||
}
|
||||
// re-read the config
|
||||
init(defConfigName);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -118,7 +118,8 @@ public class Main {
|
||||
boolean protectedPath; // protected authentication path
|
||||
String storetype; // keystore type
|
||||
String providerName; // provider name
|
||||
Vector<String> providers = null; // list of providers
|
||||
List<String> providers = null; // list of provider names
|
||||
List<String> providerClasses = null; // list of provider classes
|
||||
// arguments for provider constructors
|
||||
HashMap<String,String> providerArgs = new HashMap<>();
|
||||
char[] keypass; // private key password
|
||||
@ -174,30 +175,36 @@ public class Main {
|
||||
|
||||
// Try to load and install the specified providers
|
||||
if (providers != null) {
|
||||
ClassLoader cl = ClassLoader.getSystemClassLoader();
|
||||
Enumeration<String> e = providers.elements();
|
||||
while (e.hasMoreElements()) {
|
||||
String provName = e.nextElement();
|
||||
Class<?> provClass;
|
||||
if (cl != null) {
|
||||
provClass = cl.loadClass(provName);
|
||||
} else {
|
||||
provClass = Class.forName(provName);
|
||||
for (String provName: providers) {
|
||||
try {
|
||||
KeyStoreUtil.loadProviderByName(provName,
|
||||
providerArgs.get(provName));
|
||||
if (debug) {
|
||||
System.out.println("loadProviderByName: " + provName);
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new Exception(String.format(rb.getString(
|
||||
"provider.name.not.found"), provName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Object obj = provClass.newInstance();
|
||||
if (!(obj instanceof Provider)) {
|
||||
MessageFormat form = new MessageFormat(rb.getString
|
||||
("provName.not.a.provider"));
|
||||
Object[] source = {provName};
|
||||
throw new Exception(form.format(source));
|
||||
if (providerClasses != null) {
|
||||
ClassLoader cl = ClassLoader.getSystemClassLoader();
|
||||
for (String provClass: providerClasses) {
|
||||
try {
|
||||
KeyStoreUtil.loadProviderByClass(provClass,
|
||||
providerArgs.get(provClass), cl);
|
||||
if (debug) {
|
||||
System.out.println("loadProviderByClass: " + provClass);
|
||||
}
|
||||
} catch (ClassCastException cce) {
|
||||
throw new Exception(String.format(rb.getString(
|
||||
"provclass.not.a.provider"), provClass));
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new Exception(String.format(rb.getString(
|
||||
"provider.class.not.found"), provClass), e.getCause());
|
||||
}
|
||||
Provider p = (Provider) obj;
|
||||
String provArg = providerArgs.get(provName);
|
||||
if (provArg != null) {
|
||||
p = p.configure(provArg);
|
||||
}
|
||||
Security.addProvider(p);
|
||||
}
|
||||
}
|
||||
|
||||
@ -335,11 +342,26 @@ public class Main {
|
||||
} else if (collator.compare(flags, "-providerName") ==0) {
|
||||
if (++n == args.length) usageNoArg();
|
||||
providerName = args[n];
|
||||
} else if ((collator.compare(flags, "-provider") == 0) ||
|
||||
(collator.compare(flags, "-providerClass") == 0)) {
|
||||
} else if (collator.compare(flags, "-provider") == 0 ||
|
||||
collator.compare(flags, "-providerClass") == 0) {
|
||||
if (++n == args.length) usageNoArg();
|
||||
if (providerClasses == null) {
|
||||
providerClasses = new ArrayList<>(3);
|
||||
}
|
||||
providerClasses.add(args[n]);
|
||||
|
||||
if (args.length > (n+1)) {
|
||||
flags = args[n+1];
|
||||
if (collator.compare(flags, "-providerArg") == 0) {
|
||||
if (args.length == (n+2)) usageNoArg();
|
||||
providerArgs.put(args[n], args[n+2]);
|
||||
n += 2;
|
||||
}
|
||||
}
|
||||
} else if (collator.compare(flags, "-addprovider") == 0) {
|
||||
if (++n == args.length) usageNoArg();
|
||||
if (providers == null) {
|
||||
providers = new Vector<String>(3);
|
||||
providers = new ArrayList<>(3);
|
||||
}
|
||||
providers.add(args[n]);
|
||||
|
||||
@ -584,9 +606,14 @@ public class Main {
|
||||
(".providerName.name.provider.name"));
|
||||
System.out.println();
|
||||
System.out.println(rb.getString
|
||||
(".providerClass.class.name.of.cryptographic.service.provider.s"));
|
||||
(".add.provider.option"));
|
||||
System.out.println(rb.getString
|
||||
(".providerArg.arg.master.class.file.and.constructor.argument"));
|
||||
(".providerArg.option.1"));
|
||||
System.out.println();
|
||||
System.out.println(rb.getString
|
||||
(".providerClass.option"));
|
||||
System.out.println(rb.getString
|
||||
(".providerArg.option.2"));
|
||||
System.out.println();
|
||||
System.out.println(rb.getString
|
||||
(".strict.treat.warnings.as.errors"));
|
||||
|
@ -40,8 +40,9 @@ public class Resources extends java.util.ListResourceBundle {
|
||||
{"6SPACE", " "},
|
||||
{"COMMA", ", "},
|
||||
|
||||
{"provName.not.a.provider", "{0} not a provider"},
|
||||
{"signerClass.is.not.a.signing.mechanism", "{0} is not a signing mechanism"},
|
||||
{"provclass.not.a.provider", "%s not a provider"},
|
||||
{"provider.name.not.found", "Provider named \"%s\" not found"},
|
||||
{"provider.class.not.found", "Provider \"%s\" not found"},
|
||||
{"jarsigner.error.", "jarsigner error: "},
|
||||
{"Illegal.option.", "Illegal option: "},
|
||||
{"This.option.is.deprecated", "This option is deprecated: "},
|
||||
@ -105,10 +106,14 @@ public class Resources extends java.util.ListResourceBundle {
|
||||
"[-protected] keystore has protected authentication path"},
|
||||
{".providerName.name.provider.name",
|
||||
"[-providerName <name>] provider name"},
|
||||
{".providerClass.class.name.of.cryptographic.service.provider.s",
|
||||
"[-providerClass <class> name of cryptographic service provider's"},
|
||||
{".providerArg.arg.master.class.file.and.constructor.argument",
|
||||
" [-providerArg <arg>]] ... master class file and constructor argument"},
|
||||
{".add.provider.option",
|
||||
"[-addprovider <name> add security provider by name (e.g. SunPKCS11)"},
|
||||
{".providerArg.option.1",
|
||||
" [-providerArg <arg>]] ... configure argument for -addprovider"},
|
||||
{".providerClass.option",
|
||||
"[-providerClass <class> add security provider by fully-qualified class name"},
|
||||
{".providerArg.option.2",
|
||||
" [-providerArg <arg>]] ... configure argument for -providerClass"},
|
||||
{".strict.treat.warnings.as.errors",
|
||||
"[-strict] treat warnings as errors"},
|
||||
{".conf.url.specify.a.pre.configured.options.file",
|
||||
|
@ -399,6 +399,14 @@ public final class ImagePluginStack {
|
||||
return res.isPresent()? Optional.of(getUncompressed(res.get())) : Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<ModuleEntry> findEntryInContext(String path, ModuleEntry context) {
|
||||
Objects.requireNonNull(path);
|
||||
Objects.requireNonNull(context);
|
||||
Optional<ModuleEntry> res = pool.findEntryInContext(path, context);
|
||||
return res.map(this::getUncompressed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(ModuleEntry res) {
|
||||
return pool.contains(res);
|
||||
|
@ -51,16 +51,32 @@ public final class ModuleEntryFactory {
|
||||
original.getPath(), original.getType(), file);
|
||||
}
|
||||
|
||||
private static String moduleFrom(String path) {
|
||||
static String moduleFrom(String path) {
|
||||
Objects.requireNonNull(path);
|
||||
if (path.isEmpty() || path.charAt(0) != '/') {
|
||||
throw new IllegalArgumentException(path + " must start with /");
|
||||
}
|
||||
String noRoot = path.substring(1);
|
||||
int idx = noRoot.indexOf('/');
|
||||
int idx = path.indexOf('/', 1);
|
||||
if (idx == -1) {
|
||||
throw new IllegalArgumentException("/ missing after module: " + path);
|
||||
}
|
||||
return noRoot.substring(0, idx);
|
||||
return path.substring(1, idx);
|
||||
}
|
||||
|
||||
static String packageFrom(String path) {
|
||||
Objects.requireNonNull(path);
|
||||
int idx = path.lastIndexOf('/');
|
||||
if (idx == -1) {
|
||||
throw new IllegalArgumentException("/ missing from path: " + path);
|
||||
}
|
||||
if (path.startsWith("/")) {
|
||||
int jdx = path.indexOf('/', 1);
|
||||
if (jdx == -1) {
|
||||
throw new IllegalArgumentException("/ missing after module: " + path);
|
||||
}
|
||||
return path.substring(jdx + 1, idx);
|
||||
} else {
|
||||
return path.substring(0, idx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -264,6 +264,25 @@ public class ModulePoolImpl implements ModulePool {
|
||||
return Optional.ofNullable(resources.get(path));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ModuleEntry for the passed path restricted to supplied context.
|
||||
*
|
||||
* @param path A data path
|
||||
* @param context A context of the search
|
||||
* @return A ModuleEntry instance or null if the data is not found
|
||||
*/
|
||||
@Override
|
||||
public Optional<ModuleEntry> findEntryInContext(String path, ModuleEntry context) {
|
||||
Objects.requireNonNull(path);
|
||||
Objects.requireNonNull(context);
|
||||
LinkModule module = modules.get(context.getModule());
|
||||
Objects.requireNonNull(module);
|
||||
Optional<ModuleEntry> entry = module.findEntry(path);
|
||||
// Navigating other modules via requires and exports is problematic
|
||||
// since we cannot construct the runtime model of loaders and layers.
|
||||
return entry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the ModulePool contains the given ModuleEntry.
|
||||
*
|
||||
|
@ -28,7 +28,7 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.Optional;
|
||||
import jdk.tools.jlink.plugin.ModulePool;
|
||||
import jdk.tools.jlink.plugin.Plugin.Category;
|
||||
import jdk.internal.org.objectweb.asm.ClassReader;
|
||||
@ -67,7 +67,7 @@ public final class ClassForNamePlugin implements Plugin {
|
||||
return index == -1 ? "" : binaryName.substring(0, index);
|
||||
}
|
||||
|
||||
private ModuleEntry transform(ModuleEntry resource, Map<String, ModuleEntry> classes) {
|
||||
private ModuleEntry transform(ModuleEntry resource, ModulePool pool) {
|
||||
byte[] inBytes = resource.getBytes();
|
||||
ClassReader cr = new ClassReader(inBytes);
|
||||
ClassNode cn = new ClassNode();
|
||||
@ -96,10 +96,11 @@ public final class ClassForNamePlugin implements Plugin {
|
||||
min.desc.equals("(Ljava/lang/String;)Ljava/lang/Class;")) {
|
||||
String ldcClassName = ldc.cst.toString();
|
||||
String thatClassName = ldcClassName.replaceAll("\\.", "/");
|
||||
ModuleEntry thatClass = classes.get(thatClassName);
|
||||
Optional<ModuleEntry> thatClass =
|
||||
pool.findEntryInContext(thatClassName + ".class", resource);
|
||||
|
||||
if (thatClass != null) {
|
||||
int thatAccess = getAccess(thatClass);
|
||||
if (thatClass.isPresent()) {
|
||||
int thatAccess = getAccess(thatClass.get());
|
||||
String thatPackage = getPackage(thatClassName);
|
||||
|
||||
if ((thatAccess & Opcodes.ACC_PRIVATE) != Opcodes.ACC_PRIVATE &&
|
||||
@ -142,19 +143,13 @@ public final class ClassForNamePlugin implements Plugin {
|
||||
public void visit(ModulePool in, ModulePool out) {
|
||||
Objects.requireNonNull(in);
|
||||
Objects.requireNonNull(out);
|
||||
Map<String, ModuleEntry> classes = in.entries()
|
||||
.filter(resource -> resource != null &&
|
||||
resource.getPath().endsWith(".class") &&
|
||||
!resource.getPath().endsWith("/module-info.class"))
|
||||
.collect(Collectors.toMap(resource -> binaryClassName(resource.getPath()),
|
||||
resource -> resource));
|
||||
|
||||
in.entries()
|
||||
.filter(resource -> resource != null)
|
||||
.forEach(resource -> {
|
||||
String path = resource.getPath();
|
||||
|
||||
if (path.endsWith(".class") && !path.endsWith("/module-info.class")) {
|
||||
out.add(transform(resource, classes));
|
||||
out.add(transform(resource, in));
|
||||
} else {
|
||||
out.add(resource);
|
||||
}
|
||||
|
@ -89,7 +89,16 @@ public interface ModulePool {
|
||||
* @param path A data path
|
||||
* @return A ModuleEntry instance or null if the data is not found
|
||||
*/
|
||||
public Optional<ModuleEntry> findEntry(String path);
|
||||
public Optional<ModuleEntry> findEntry(String path);
|
||||
|
||||
/**
|
||||
* Get the ModuleEntry for the passed path restricted to supplied context.
|
||||
*
|
||||
* @param path A data path
|
||||
* @param context A context of the search
|
||||
* @return A ModuleEntry instance or null if the data is not found
|
||||
*/
|
||||
public Optional<ModuleEntry> findEntryInContext(String path, ModuleEntry context);
|
||||
|
||||
/**
|
||||
* Check if the ModulePool contains the given ModuleEntry.
|
||||
|
@ -371,6 +371,8 @@ public class JavaTimeSupplementary_ar extends OpenListResourceBundle {
|
||||
sharedShortEras },
|
||||
{ "roc.short.Eras",
|
||||
sharedShortEras },
|
||||
{ "timezone.gmtFormat",
|
||||
"\u062c\u0631\u064a\u0646\u062a\u0634{0}" },
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -308,6 +308,8 @@ public class JavaTimeSupplementary_be extends OpenListResourceBundle {
|
||||
sharedAbbreviatedAmPmMarkers },
|
||||
{ "roc.narrow.AmPmMarkers",
|
||||
sharedNarrowAmPmMarkers },
|
||||
{ "timezone.hourFormat",
|
||||
"+HH.mm;-HH.mm" },
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -309,6 +309,8 @@ public class JavaTimeSupplementary_bg extends OpenListResourceBundle {
|
||||
sharedAmPmMarkers },
|
||||
{ "roc.narrow.AmPmMarkers",
|
||||
sharedAmPmMarkers },
|
||||
{ "timezone.gmtFormat",
|
||||
"\u0413\u0440\u0438\u043d\u0443\u0438\u0447{0}" },
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -298,6 +298,8 @@ public class JavaTimeSupplementary_cs extends OpenListResourceBundle {
|
||||
sharedEras },
|
||||
{ "roc.short.Eras",
|
||||
sharedEras },
|
||||
{ "timezone.hourFormat",
|
||||
"+H:mm;-H:mm" },
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -308,6 +308,8 @@ public class JavaTimeSupplementary_da extends OpenListResourceBundle {
|
||||
sharedEras },
|
||||
{ "roc.short.Eras",
|
||||
sharedEras },
|
||||
{ "timezone.hourFormat",
|
||||
"+HH.mm;-HH.mm" },
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -280,6 +280,8 @@ public class JavaTimeSupplementary_et extends OpenListResourceBundle {
|
||||
sharedTimePatterns },
|
||||
{ "roc.narrow.AmPmMarkers",
|
||||
sharedNarrowAmPmMarkers },
|
||||
{ "timezone.hourFormat",
|
||||
"+HH:mm;\u2212HH:mm" },
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -324,6 +324,10 @@ public class JavaTimeSupplementary_fi extends OpenListResourceBundle {
|
||||
sharedEras },
|
||||
{ "roc.short.Eras",
|
||||
sharedEras },
|
||||
{ "timezone.gmtFormat",
|
||||
"UTC{0}" },
|
||||
{ "timezone.hourFormat",
|
||||
"+H.mm;-H.mm" },
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -329,6 +329,10 @@ public class JavaTimeSupplementary_fr extends OpenListResourceBundle {
|
||||
sharedEras },
|
||||
{ "roc.short.Eras",
|
||||
sharedEras },
|
||||
{ "timezone.gmtFormat",
|
||||
"UTC{0}" },
|
||||
{ "timezone.hourFormat",
|
||||
"+HH:mm;\u2212HH:mm" },
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -284,6 +284,8 @@ public class JavaTimeSupplementary_ga extends OpenListResourceBundle {
|
||||
sharedAmPmMarkers },
|
||||
{ "roc.narrow.AmPmMarkers",
|
||||
sharedNarrowAmPmMarkers },
|
||||
{ "timezone.gmtFormat",
|
||||
"MAG{0}" },
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -335,6 +335,8 @@ public class JavaTimeSupplementary_hr extends OpenListResourceBundle {
|
||||
sharedEras },
|
||||
{ "roc.short.Eras",
|
||||
sharedEras },
|
||||
{ "timezone.hourFormat",
|
||||
"+HH:mm; -HH:mm" },
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -347,6 +347,8 @@ public class JavaTimeSupplementary_in extends OpenListResourceBundle {
|
||||
sharedEras },
|
||||
{ "roc.short.Eras",
|
||||
sharedEras },
|
||||
{ "timezone.hourFormat",
|
||||
"+HH.mm;-HH.mm" },
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -324,6 +324,10 @@ public class JavaTimeSupplementary_iw extends OpenListResourceBundle {
|
||||
sharedAmPmMarkers },
|
||||
{ "roc.narrow.AmPmMarkers",
|
||||
sharedAmPmMarkers },
|
||||
{ "timezone.gmtFormat",
|
||||
"GMT{0}\u200e" },
|
||||
{ "timezone.hourFormat",
|
||||
"\u200e+HH:mm;-HH:mm\u200e" },
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -325,6 +325,8 @@ public class JavaTimeSupplementary_lt extends OpenListResourceBundle {
|
||||
sharedEras },
|
||||
{ "roc.short.Eras",
|
||||
sharedEras },
|
||||
{ "timezone.hourFormat",
|
||||
"+HH:mm;\u2212HH:mm" },
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -389,6 +389,8 @@ public class JavaTimeSupplementary_no extends OpenListResourceBundle {
|
||||
sharedEras },
|
||||
{ "roc.short.Eras",
|
||||
sharedEras },
|
||||
{ "timezone.hourFormat",
|
||||
"+HH.mm;-HH.mm" },
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -286,6 +286,8 @@ public class JavaTimeSupplementary_sl extends OpenListResourceBundle {
|
||||
sharedAmPmMarkers },
|
||||
{ "roc.narrow.AmPmMarkers",
|
||||
sharedNarrowAmPmMarkers },
|
||||
{ "timezone.hourFormat",
|
||||
"+HH.mm;-HH.mm" },
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -294,6 +294,8 @@ public class JavaTimeSupplementary_sq extends OpenListResourceBundle {
|
||||
sharedAmPmMarkers },
|
||||
{ "roc.narrow.AmPmMarkers",
|
||||
sharedAmPmMarkers },
|
||||
{ "timezone.gmtFormat",
|
||||
"Ora e Grenui\u00e7it: {0}" },
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -386,6 +386,8 @@ public class JavaTimeSupplementary_sr extends OpenListResourceBundle {
|
||||
sharedShortEras },
|
||||
{ "roc.short.Eras",
|
||||
sharedShortEras },
|
||||
{ "timezone.hourFormat",
|
||||
"+HHmm;-HHmm" },
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -345,6 +345,8 @@ public class JavaTimeSupplementary_sv extends OpenListResourceBundle {
|
||||
sharedEras },
|
||||
{ "roc.short.Eras",
|
||||
sharedEras },
|
||||
{ "timezone.hourFormat",
|
||||
"+HH:mm;\u2212HH:mm" },
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1376,10 +1376,6 @@ class ToolWindow extends JFrame {
|
||||
ToolDialog ed = new ToolDialog
|
||||
(PolicyTool.getMessage("Error"), tool, this, true);
|
||||
|
||||
// find where the PolicyTool gui is
|
||||
Point location = ((w == null) ?
|
||||
getLocationOnScreen() : w.getLocationOnScreen());
|
||||
//ed.setBounds(location.x + 50, location.y + 50, 600, 100);
|
||||
ed.setLayout(new GridBagLayout());
|
||||
|
||||
JLabel label = new JLabel(error);
|
||||
|
@ -215,7 +215,7 @@ java/rmi/transport/dgcDeadLock/DGCDeadLock.java 8029360 macosx-a
|
||||
|
||||
sun/security/pkcs11/ec/TestKeyFactory.java 7157786 generic-all
|
||||
|
||||
sun/security/krb5/auto/Unreachable.java 7164518 macosx-all no PortUnreachableException on Mac
|
||||
sun/security/krb5/auto/Unreachable.java 7164518 macosx-all
|
||||
|
||||
sun/security/tools/keytool/ListKeychainStore.sh 8156889 macosx-all
|
||||
|
||||
@ -284,6 +284,7 @@ sun/security/pkcs11/tls/TestPremaster.java 8077138,8023434
|
||||
sun/security/krb5/auto/HttpNegotiateServer.java 8038079 generic-all
|
||||
|
||||
sun/security/tools/keytool/autotest.sh 8130302 generic-all
|
||||
sun/security/ssl/SSLSocketImpl/AsyncSSLSocketClose.java 8161232 macosx-all
|
||||
|
||||
############################################################################
|
||||
|
||||
|
102
jdk/test/java/lang/Runtime/Version/VersionProps.java
Normal file
102
jdk/test/java/lang/Runtime/Version/VersionProps.java
Normal file
@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2016 SAP SE. 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8160564
|
||||
* @summary check the implementation of VersionProps.versionNumbers()
|
||||
* @run main VersionProps
|
||||
* @author Volker Simonis
|
||||
*/
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class VersionProps {
|
||||
|
||||
final static String[] validVersions = {
|
||||
"1", "1.2", "1.2.3", "1.2.3.4", "1.0.0.1",
|
||||
"1.10000.1", "1.0.2.0.0.3.0.0.0.4.5.0.0.6",
|
||||
"1000001", "1.2.3.4.5.6.7.8.9.0.9.8.7.6.5.4.3.2.1" };
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
final static List[] validLists = {
|
||||
Arrays.asList(1),
|
||||
Arrays.asList(1, 2),
|
||||
Arrays.asList(1, 2, 3),
|
||||
Arrays.asList(1, 2, 3, 4),
|
||||
Arrays.asList(1, 0, 0, 1),
|
||||
Arrays.asList(1, 10000, 1),
|
||||
Arrays.asList(1, 0, 2, 0, 0, 3, 0, 0, 0, 4, 5, 0, 0, 6),
|
||||
Arrays.asList(1000001),
|
||||
Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1) };
|
||||
|
||||
final static String[] invalidVersions = {
|
||||
"01", "0.1.2", "1.02.3", "1.2.03.4", "1.0.0.1.0",
|
||||
"1.0.1.0.0", "1.00.1", "1.0.1.00", "1.10000." };
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Class<?> versionProps = Class.forName("java.lang.VersionProps");
|
||||
Method parseVersionNumbers =
|
||||
versionProps.getDeclaredMethod("parseVersionNumbers", String.class);
|
||||
parseVersionNumbers.setAccessible(true);
|
||||
|
||||
for (int i = 0; i < validVersions.length; i++) {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Integer> li =
|
||||
(List<Integer>)parseVersionNumbers.invoke(null, validVersions[i]);
|
||||
System.out.println(li);
|
||||
if (!validLists[i].equals(li))
|
||||
throw new Exception(li + " != " + validLists[i]);
|
||||
li = Runtime.Version.parse(validVersions[i]).version();
|
||||
if (!validLists[i].equals(li))
|
||||
throw new Exception(li + " != " + validLists[i]);
|
||||
}
|
||||
|
||||
for (int i = 0; i < invalidVersions.length; i++) {
|
||||
try {
|
||||
List<Integer> li =
|
||||
(List<Integer>)parseVersionNumbers.invoke(null, invalidVersions[i]);
|
||||
throw new Exception(invalidVersions[i] +
|
||||
" not recognized as invalid by VersionProps.parseVersionNumbers()");
|
||||
} catch (InvocationTargetException ex) {
|
||||
if (ex.getCause() instanceof IllegalArgumentException) {
|
||||
System.out.println("OK - caught bad version string " +
|
||||
invalidVersions[i]);
|
||||
} else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
List<Integer> li = Runtime.Version.parse(invalidVersions[i]).version();
|
||||
throw new Exception(invalidVersions[i] +
|
||||
" not recognized as invalid by Runtime.Version.parse()");
|
||||
} catch (IllegalArgumentException ex) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -539,6 +539,7 @@ public class DefaultLoggerTest {
|
||||
throw new RuntimeException("identical loggers");
|
||||
}
|
||||
|
||||
final java.util.logging.Logger sink;
|
||||
final java.util.logging.Logger appSink;
|
||||
final java.util.logging.Logger sysSink;
|
||||
final java.util.logging.Handler appHandler;
|
||||
@ -548,10 +549,9 @@ public class DefaultLoggerTest {
|
||||
try {
|
||||
appSink = java.util.logging.Logger.getLogger("foo");
|
||||
sysSink = accessSystemLogger.demandSystemLogger("foo");
|
||||
appSink.addHandler(appHandler = new MyHandler());
|
||||
sysSink.addHandler(sysHandler = new MyHandler());
|
||||
appSink.setUseParentHandlers(false);
|
||||
sysSink.setUseParentHandlers(false);
|
||||
sink = java.util.logging.Logger.getLogger("foo");
|
||||
sink.addHandler(appHandler = sysHandler = new MyHandler());
|
||||
sink.setUseParentHandlers(false);
|
||||
provider = LoggerFinder.getLoggerFinder();
|
||||
} finally {
|
||||
allowAll.get().set(false);
|
||||
|
@ -299,10 +299,9 @@ public class DefaultLoggerFinderTest {
|
||||
|
||||
final java.util.logging.Logger appSink = java.util.logging.Logger.getLogger("foo");
|
||||
final java.util.logging.Logger sysSink = accessSystemLogger.demandSystemLogger("foo");
|
||||
appSink.addHandler(new MyHandler());
|
||||
sysSink.addHandler(new MyHandler());
|
||||
appSink.setUseParentHandlers(VERBOSE);
|
||||
sysSink.setUseParentHandlers(VERBOSE);
|
||||
final java.util.logging.Logger sink = java.util.logging.Logger.getLogger("foo");
|
||||
sink.addHandler(new MyHandler());
|
||||
sink.setUseParentHandlers(VERBOSE);
|
||||
|
||||
Stream.of(args).map(TestCases::valueOf).forEach((testCase) -> {
|
||||
LoggerFinder provider;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 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
|
||||
@ -390,6 +390,7 @@ public class DefaultLoggerBridgeTest {
|
||||
throw new RuntimeException("identical loggers");
|
||||
}
|
||||
|
||||
final java.util.logging.Logger sink;
|
||||
final java.util.logging.Logger appSink;
|
||||
final java.util.logging.Logger sysSink;
|
||||
final MyHandler appHandler;
|
||||
@ -404,10 +405,13 @@ public class DefaultLoggerBridgeTest {
|
||||
if (appSink == sysSink) {
|
||||
throw new RuntimeException("identical backend loggers");
|
||||
}
|
||||
appSink.addHandler(appHandler = new MyHandler());
|
||||
sysSink.addHandler(sysHandler = new MyHandler());
|
||||
appSink.setUseParentHandlers(VERBOSE);
|
||||
sysSink.setUseParentHandlers(VERBOSE);
|
||||
sink = java.util.logging.Logger.getLogger("foo");
|
||||
if (appSink != sink) {
|
||||
throw new RuntimeException("expected same application logger");
|
||||
}
|
||||
|
||||
sink.addHandler(appHandler = sysHandler = new MyHandler());
|
||||
sink.setUseParentHandlers(VERBOSE);
|
||||
} finally {
|
||||
allowAll.get().set(old);
|
||||
}
|
||||
|
13
jdk/test/java/lang/System/LoggerFinder/jdk/DefaultPlatformLoggerTest/DefaultPlatformLoggerTest.java
13
jdk/test/java/lang/System/LoggerFinder/jdk/DefaultPlatformLoggerTest/DefaultPlatformLoggerTest.java
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, 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
|
||||
@ -42,9 +42,9 @@ import java.util.logging.Handler;
|
||||
import java.util.logging.LogManager;
|
||||
import java.util.logging.LogRecord;
|
||||
import java.lang.System.LoggerFinder;
|
||||
import java.util.logging.Logger;
|
||||
import sun.util.logging.PlatformLogger;
|
||||
import sun.util.logging.internal.LoggingProviderImpl;
|
||||
import java.lang.reflect.Module;
|
||||
|
||||
/**
|
||||
* @test
|
||||
@ -248,10 +248,9 @@ public class DefaultPlatformLoggerTest {
|
||||
DefaultPlatformLoggerTest.class.getModule());
|
||||
java.util.logging.Logger sysSink = LoggingProviderImpl.getLogManagerAccess()
|
||||
.demandLoggerFor(LogManager.getLogManager(),"foo", Thread.class.getModule());
|
||||
appSink.addHandler(new MyHandler());
|
||||
sysSink.addHandler(new MyHandler());
|
||||
appSink.setUseParentHandlers(VERBOSE);
|
||||
sysSink.setUseParentHandlers(VERBOSE);
|
||||
java.util.logging.Logger sink = Logger.getLogger("foo");
|
||||
sink.addHandler(new MyHandler());
|
||||
sink.setUseParentHandlers(VERBOSE);
|
||||
|
||||
System.out.println("\n*** Without Security Manager\n");
|
||||
test(provider, true, appSink, sysSink);
|
||||
@ -274,7 +273,7 @@ public class DefaultPlatformLoggerTest {
|
||||
public static void test(LoggerFinder provider, boolean hasRequiredPermissions,
|
||||
java.util.logging.Logger appSink, java.util.logging.Logger sysSink) throws Exception {
|
||||
|
||||
// No way to giva a resource bundle to a platform logger.
|
||||
// No way to give a resource bundle to a platform logger.
|
||||
// ResourceBundle loggerBundle = ResourceBundle.getBundle(MyLoggerBundle.class.getName());
|
||||
final Map<PlatformLogger, String> loggerDescMap = new HashMap<>();
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2016, 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
|
||||
@ -28,60 +28,41 @@
|
||||
* unpredictable results.
|
||||
*/
|
||||
|
||||
public class Stop implements Runnable {
|
||||
private static boolean groupStopped = false ;
|
||||
private static final Object lock = new Object();
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
private static final ThreadGroup group = new ThreadGroup("");
|
||||
private static final Thread first = new Thread(group, new Stop());
|
||||
private static final Thread second = new Thread(group, new Stop());
|
||||
|
||||
public void run() {
|
||||
while (true) {
|
||||
// Give the other thread a chance to start
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
|
||||
// When the first thread runs, it will stop the group.
|
||||
if (Thread.currentThread() == first) {
|
||||
synchronized (lock) {
|
||||
try {
|
||||
group.stop();
|
||||
} finally {
|
||||
// Signal the main thread it is time to check
|
||||
// that the stopped thread group was successful
|
||||
groupStopped = true;
|
||||
lock.notifyAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public class Stop {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
final CountDownLatch ready = new CountDownLatch(1);
|
||||
final ThreadGroup group = new ThreadGroup("");
|
||||
|
||||
final Thread second = new Thread(group, () -> {
|
||||
ready.countDown();
|
||||
while (true) {
|
||||
try {
|
||||
Thread.sleep(60000);
|
||||
} catch (InterruptedException shouldNotHappen) {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
final Thread first = new Thread(group, () -> {
|
||||
// Wait until "second" is started
|
||||
try {
|
||||
ready.await();
|
||||
} catch (InterruptedException shouldNotHappen) {
|
||||
}
|
||||
// Now stop the group
|
||||
group.stop();
|
||||
});
|
||||
|
||||
// Launch two threads as part of the same thread group
|
||||
first.start();
|
||||
second.start();
|
||||
|
||||
// Wait for the thread group stop to be issued
|
||||
synchronized(lock){
|
||||
while (!groupStopped) {
|
||||
lock.wait();
|
||||
// Give the other thread a chance to stop
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
}
|
||||
|
||||
// Check that the second thread is terminated when the
|
||||
// first thread terminates the thread group.
|
||||
boolean failed = second.isAlive();
|
||||
|
||||
// Clean up any threads that may have not been terminated
|
||||
first.stop();
|
||||
second.stop();
|
||||
if (failed)
|
||||
throw new RuntimeException("Failure.");
|
||||
second.join();
|
||||
// Test passed - if never get here the test times out and fails.
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 2016, 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
|
||||
@ -489,69 +489,72 @@ public class Transfers {
|
||||
debug = verbose = true;
|
||||
}
|
||||
|
||||
sourceFile = File.createTempFile("xfer.src.", "");
|
||||
File testDir = new File(System.getProperty("test.dir", "."));
|
||||
|
||||
sourceFile = File.createTempFile("xfer.src.", "", testDir);
|
||||
sourceFile.deleteOnExit();
|
||||
targetFile = File.createTempFile("xfer.tgt.", "");
|
||||
targetFile = File.createTempFile("xfer.tgt.", "", testDir);
|
||||
targetFile.deleteOnExit();
|
||||
|
||||
File fn = File.createTempFile("xfer.fch.", "");
|
||||
File fn = File.createTempFile("xfer.fch.", "", testDir);
|
||||
fn.deleteOnExit();
|
||||
FileChannel fc = new RandomAccessFile(fn, "rw").getChannel();
|
||||
|
||||
Random rnd = new Random();
|
||||
int failures = 0;
|
||||
|
||||
for (boolean to = false;; to = true) {
|
||||
for (boolean user = false;; user = true) {
|
||||
if (!verbose)
|
||||
out.print((to ? "To " : "From ") +
|
||||
(user ? "user channel" : "file channel")
|
||||
+ ":");
|
||||
IntGenerator offGen = new IntGenerator(MAX_XFER_SIZE + 2);
|
||||
while (offGen.hasNext()) {
|
||||
int off = offGen.next();
|
||||
if (!verbose) out.print(" " + off);
|
||||
IntGenerator lenGen = new IntGenerator(MAX_XFER_SIZE + 2);
|
||||
while (lenGen.hasNext()) {
|
||||
int len = lenGen.next();
|
||||
long s = rnd.nextLong();
|
||||
String chName = null;
|
||||
try {
|
||||
if (to) {
|
||||
Target tgt;
|
||||
if (user)
|
||||
tgt = new UserTarget(len, s);
|
||||
else
|
||||
tgt = new FileTarget(len, s);
|
||||
chName = tgt.name();
|
||||
testTo(s, fc, off, len, tgt);
|
||||
try (FileChannel fc = new RandomAccessFile(fn, "rw").getChannel()) {
|
||||
for (boolean to = false;; to = true) {
|
||||
for (boolean user = false;; user = true) {
|
||||
if (!verbose)
|
||||
out.print((to ? "To " : "From ") +
|
||||
(user ? "user channel" : "file channel")
|
||||
+ ":");
|
||||
IntGenerator offGen = new IntGenerator(MAX_XFER_SIZE + 2);
|
||||
while (offGen.hasNext()) {
|
||||
int off = offGen.next();
|
||||
if (!verbose) out.print(" " + off);
|
||||
IntGenerator lenGen = new IntGenerator(MAX_XFER_SIZE + 2);
|
||||
while (lenGen.hasNext()) {
|
||||
int len = lenGen.next();
|
||||
long s = rnd.nextLong();
|
||||
String chName = null;
|
||||
try {
|
||||
if (to) {
|
||||
Target tgt;
|
||||
if (user)
|
||||
tgt = new UserTarget(len, s);
|
||||
else
|
||||
tgt = new FileTarget(len, s);
|
||||
chName = tgt.name();
|
||||
testTo(s, fc, off, len, tgt);
|
||||
}
|
||||
else {
|
||||
Source src;
|
||||
if (user)
|
||||
src = new UserSource(len, s);
|
||||
else
|
||||
src = new FileSource(len, s);
|
||||
chName = src.name();
|
||||
testFrom(s, src, fc, off, len);
|
||||
}
|
||||
} catch (Failure x) {
|
||||
out.println();
|
||||
out.println("FAILURE: " + chName
|
||||
+ ", offset " + off
|
||||
+ ", length " + len);
|
||||
x.printStackTrace(out);
|
||||
failures++;
|
||||
}
|
||||
else {
|
||||
Source src;
|
||||
if (user)
|
||||
src = new UserSource(len, s);
|
||||
else
|
||||
src = new FileSource(len, s);
|
||||
chName = src.name();
|
||||
testFrom(s, src, fc, off, len);
|
||||
}
|
||||
} catch (Failure x) {
|
||||
out.println();
|
||||
out.println("FAILURE: " + chName
|
||||
+ ", offset " + off
|
||||
+ ", length " + len);
|
||||
x.printStackTrace(out);
|
||||
failures++;
|
||||
}
|
||||
}
|
||||
if (!verbose)
|
||||
out.println();
|
||||
if (user)
|
||||
break;
|
||||
}
|
||||
if (!verbose)
|
||||
out.println();
|
||||
if (user)
|
||||
if (to)
|
||||
break;
|
||||
}
|
||||
if (to)
|
||||
break;
|
||||
}
|
||||
|
||||
sourceFile.delete();
|
||||
@ -563,6 +566,6 @@ public class Transfers {
|
||||
throw new RuntimeException("Some tests failed");
|
||||
}
|
||||
|
||||
out.println("Test succeeded.");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2016, 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
|
||||
@ -23,6 +23,7 @@
|
||||
|
||||
/* @test
|
||||
* @bug 4095165 4321151
|
||||
* @key intermittent
|
||||
* @summary synopsis: activator should restart daemon services
|
||||
* @author Ann Wollrath
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 2016, 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
|
||||
@ -24,6 +24,7 @@
|
||||
/*
|
||||
* @test
|
||||
* @bug 4510355
|
||||
* @key intermittent
|
||||
* @summary ActivationGroup implementations cannot be downloaded by default;
|
||||
* Creates a custom activation group without setting a security manager
|
||||
* in activation group's descriptor. The custom activation group
|
||||
|
4
jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/UseCustomSocketFactory.java
4
jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/UseCustomSocketFactory.java
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2016, 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
|
||||
@ -23,7 +23,7 @@
|
||||
|
||||
/* @test
|
||||
* @bug 4115696
|
||||
|
||||
* @key intermittent
|
||||
* @summary synopsis: cannot use socket factories with Activatable objects
|
||||
* @author Ann Wollrath
|
||||
*
|
||||
|
99
jdk/test/java/util/Locale/Bug8154797.java
Normal file
99
jdk/test/java/util/Locale/Bug8154797.java
Normal file
@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8154797
|
||||
* @modules java.base/sun.util.locale.provider
|
||||
* java.base/sun.util.resources
|
||||
* jdk.localedata
|
||||
* @summary Test for checking HourFormat and GmtFormat resources are retrieved from
|
||||
* COMPAT and CLDR Providers.
|
||||
*/
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
import sun.util.locale.provider.LocaleProviderAdapter.Type;
|
||||
import sun.util.locale.provider.LocaleProviderAdapter;
|
||||
|
||||
public class Bug8154797 {
|
||||
static Map<String, String> expectedResourcesMap = new HashMap<>();
|
||||
static final String GMT_RESOURCE_KEY = "timezone.gmtFormat";
|
||||
static final String HMT_RESOURCE_KEY = "timezone.hourFormat";
|
||||
static final String GMT = "Gmt";
|
||||
static final String HMT = "Hmt";
|
||||
|
||||
static void generateExpectedValues() {
|
||||
expectedResourcesMap.put("FR" + GMT, "UTC{0}");
|
||||
expectedResourcesMap.put("FR" + HMT, "+HH:mm;\u2212HH:mm");
|
||||
expectedResourcesMap.put("FI" + HMT, "+H.mm;-H.mm");
|
||||
expectedResourcesMap.put("FI" + GMT, "UTC{0}");
|
||||
/* For root locale, en_US, de_DE, hi_IN, ja_JP,Root locale resources
|
||||
* should be returned.
|
||||
*/
|
||||
expectedResourcesMap.put(GMT, "GMT{0}"); //Root locale resource
|
||||
expectedResourcesMap.put(HMT, "+HH:mm;-HH:mm"); //Root locale resource
|
||||
}
|
||||
|
||||
static void compareResources(Locale loc) {
|
||||
String mapKeyHourFormat = HMT, mapKeyGmtFormat = GMT;
|
||||
ResourceBundle compatBundle, cldrBundle;
|
||||
compatBundle = LocaleProviderAdapter.forJRE().getLocaleResources(loc)
|
||||
.getJavaTimeFormatData();
|
||||
cldrBundle = LocaleProviderAdapter.forType(Type.CLDR)
|
||||
.getLocaleResources(loc).getJavaTimeFormatData();
|
||||
if (loc.getCountry() == "FR" || loc.getCountry() == "FI") {
|
||||
mapKeyHourFormat = loc.getCountry() + HMT;
|
||||
mapKeyGmtFormat = loc.getCountry() + GMT;
|
||||
}
|
||||
|
||||
if (!(expectedResourcesMap.get(mapKeyGmtFormat)
|
||||
.equals(compatBundle.getString(GMT_RESOURCE_KEY))
|
||||
&& expectedResourcesMap.get(mapKeyHourFormat)
|
||||
.equals(compatBundle.getString(HMT_RESOURCE_KEY))
|
||||
&& expectedResourcesMap.get(mapKeyGmtFormat)
|
||||
.equals(cldrBundle.getString(GMT_RESOURCE_KEY))
|
||||
&& expectedResourcesMap.get(mapKeyHourFormat)
|
||||
.equals(cldrBundle.getString(HMT_RESOURCE_KEY)))) {
|
||||
|
||||
throw new RuntimeException("Retrieved resource does not match with "
|
||||
+ " expected string for Locale " + compatBundle.getLocale());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void main(String args[]) {
|
||||
Bug8154797.generateExpectedValues();
|
||||
Locale[] locArr = {new Locale("hi", "IN"), Locale.UK, new Locale("fi", "FI"),
|
||||
Locale.ROOT, Locale.GERMAN, Locale.JAPANESE,
|
||||
Locale.ENGLISH, Locale.FRANCE};
|
||||
for (Locale loc : locArr) {
|
||||
Bug8154797.compareResources(loc);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -40,25 +40,19 @@ import java.util.jar.JarFile;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
import static java.util.jar.JarFile.Release;
|
||||
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
||||
public class MultiReleaseJarAPI {
|
||||
|
||||
static final int MAJOR_VERSION = Runtime.version().major();
|
||||
|
||||
String userdir = System.getProperty("user.dir",".");
|
||||
CreateMultiReleaseTestJars creator = new CreateMultiReleaseTestJars();
|
||||
File unversioned = new File(userdir, "unversioned.jar");
|
||||
File multirelease = new File(userdir, "multi-release.jar");
|
||||
File signedmultirelease = new File(userdir, "signed-multi-release.jar");
|
||||
Release[] values = JarFile.Release.values();
|
||||
|
||||
|
||||
@BeforeClass
|
||||
public void initialize() throws Exception {
|
||||
@ -81,7 +75,7 @@ public class MultiReleaseJarAPI {
|
||||
Assert.assertFalse(jf.isMultiRelease());
|
||||
}
|
||||
|
||||
try (JarFile jf = new JarFile(unversioned, true, ZipFile.OPEN_READ, Release.RUNTIME)) {
|
||||
try (JarFile jf = new JarFile(unversioned, true, ZipFile.OPEN_READ, Runtime.version())) {
|
||||
Assert.assertFalse(jf.isMultiRelease());
|
||||
}
|
||||
|
||||
@ -89,7 +83,7 @@ public class MultiReleaseJarAPI {
|
||||
Assert.assertFalse(jf.isMultiRelease());
|
||||
}
|
||||
|
||||
try (JarFile jf = new JarFile(multirelease, true, ZipFile.OPEN_READ, Release.RUNTIME)) {
|
||||
try (JarFile jf = new JarFile(multirelease, true, ZipFile.OPEN_READ, Runtime.version())) {
|
||||
Assert.assertTrue(jf.isMultiRelease());
|
||||
}
|
||||
|
||||
@ -110,68 +104,68 @@ public class MultiReleaseJarAPI {
|
||||
private void testCustomMultiReleaseValue(String value, boolean expected) throws Exception {
|
||||
creator.buildCustomMultiReleaseJar("custom-mr.jar", value);
|
||||
File custom = new File(userdir, "custom-mr.jar");
|
||||
try (JarFile jf = new JarFile(custom, true, ZipFile.OPEN_READ, Release.RUNTIME)) {
|
||||
try (JarFile jf = new JarFile(custom, true, ZipFile.OPEN_READ, Runtime.version())) {
|
||||
Assert.assertEquals(jf.isMultiRelease(), expected);
|
||||
}
|
||||
Files.delete(custom.toPath());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVersioning() throws Exception {
|
||||
// multi-release jar
|
||||
JarFile jar = new JarFile(multirelease);
|
||||
Assert.assertEquals(Release.BASE, jar.getVersion());
|
||||
jar.close();
|
||||
@DataProvider(name = "versions")
|
||||
public Object[][] createVersionData() throws Exception {
|
||||
return new Object[][]{
|
||||
{JarFile.baseVersion(), 8},
|
||||
{JarFile.runtimeVersion(), Runtime.version().major()},
|
||||
{Runtime.version(), Runtime.version().major()},
|
||||
{Runtime.Version.parse("7.1"), JarFile.baseVersion().major()},
|
||||
{Runtime.Version.parse("9"), 9},
|
||||
{Runtime.Version.parse("9.1.5-ea+200"), 9}
|
||||
};
|
||||
}
|
||||
|
||||
for (Release value : values) {
|
||||
System.err.println("test versioning for Release " + value);
|
||||
try (JarFile jf = new JarFile(multirelease, true, ZipFile.OPEN_READ, value)) {
|
||||
Assert.assertEquals(value, jf.getVersion());
|
||||
}
|
||||
@Test(dataProvider="versions")
|
||||
public void testVersioning(Runtime.Version value, int xpected) throws Exception {
|
||||
Runtime.Version expected = Runtime.Version.parse(String.valueOf(xpected));
|
||||
Runtime.Version base = JarFile.baseVersion();
|
||||
|
||||
// multi-release jar, opened as unversioned
|
||||
try (JarFile jar = new JarFile(multirelease)) {
|
||||
Assert.assertEquals(jar.getVersion(), base);
|
||||
}
|
||||
|
||||
System.err.println("test versioning for Release " + value);
|
||||
try (JarFile jf = new JarFile(multirelease, true, ZipFile.OPEN_READ, value)) {
|
||||
Assert.assertEquals(jf.getVersion(), expected);
|
||||
}
|
||||
|
||||
// regular, unversioned, jar
|
||||
for (Release value : values) {
|
||||
try (JarFile jf = new JarFile(unversioned, true, ZipFile.OPEN_READ, value)) {
|
||||
Assert.assertEquals(Release.BASE, jf.getVersion());
|
||||
}
|
||||
}
|
||||
|
||||
// assure that we have a Release object corresponding to the actual runtime version
|
||||
String version = "VERSION_" + MAJOR_VERSION;
|
||||
boolean runtimeVersionExists = false;
|
||||
for (Release value : values) {
|
||||
if (version.equals(value.name())) runtimeVersionExists = true;
|
||||
}
|
||||
Assert.assertTrue(runtimeVersionExists);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAliasing() throws Exception {
|
||||
for (Release value : values) {
|
||||
System.err.println("test aliasing for Release " + value);
|
||||
String name = value.name();
|
||||
String prefix;
|
||||
if (name.equals("BASE")) {
|
||||
prefix = "";
|
||||
} else if (name.equals("RUNTIME")) {
|
||||
prefix = "META-INF/versions/" + MAJOR_VERSION + "/";
|
||||
} else {
|
||||
prefix = "META-INF/versions/" + name.substring(8) + "/";
|
||||
}
|
||||
// test both multi-release jars
|
||||
readAndCompare(multirelease, value, "README", prefix + "README");
|
||||
readAndCompare(multirelease, value, "version/Version.class", prefix + "version/Version.class");
|
||||
// and signed multi-release jars
|
||||
readAndCompare(signedmultirelease, value, "README", prefix + "README");
|
||||
readAndCompare(signedmultirelease, value, "version/Version.class", prefix + "version/Version.class");
|
||||
try (JarFile jf = new JarFile(unversioned, true, ZipFile.OPEN_READ, value)) {
|
||||
Assert.assertEquals(jf.getVersion(), base);
|
||||
}
|
||||
}
|
||||
|
||||
private void readAndCompare(File jar, Release version, String name, String realName) throws Exception {
|
||||
@Test(dataProvider="versions")
|
||||
public void testAliasing(Runtime.Version version, int xpected) throws Exception {
|
||||
int n = Math.max(version.major(), JarFile.baseVersion().major());
|
||||
Runtime.Version value = Runtime.Version.parse(String.valueOf(n));
|
||||
System.err.println("test aliasing for Release " + version);
|
||||
String prefix;
|
||||
if (JarFile.baseVersion().equals(value)) {
|
||||
prefix = "";
|
||||
} else {
|
||||
prefix = "META-INF/versions/" + value.major() + "/";
|
||||
}
|
||||
// test both multi-release jars
|
||||
readAndCompare(multirelease, value, "README", prefix + "README");
|
||||
readAndCompare(multirelease, value, "version/Version.class", prefix + "version/Version.class");
|
||||
// and signed multi-release jars
|
||||
readAndCompare(signedmultirelease, value, "README", prefix + "README");
|
||||
readAndCompare(signedmultirelease, value, "version/Version.class", prefix + "version/Version.class");
|
||||
}
|
||||
|
||||
private void readAndCompare(File jar, Runtime.Version version, String name, String realName) throws Exception {
|
||||
byte[] baseBytes;
|
||||
byte[] versionedBytes;
|
||||
try (JarFile jf = new JarFile(jar, true, ZipFile.OPEN_READ, Release.BASE)) {
|
||||
try (JarFile jf = new JarFile(jar, true, ZipFile.OPEN_READ, JarFile.baseVersion())) {
|
||||
ZipEntry ze = jf.getEntry(realName);
|
||||
try (InputStream is = jf.getInputStream(ze)) {
|
||||
baseBytes = is.readAllBytes();
|
||||
@ -200,7 +194,7 @@ public class MultiReleaseJarAPI {
|
||||
ze1 = jf.getEntry(vname);
|
||||
}
|
||||
Assert.assertEquals(ze1.getName(), vname);
|
||||
try (JarFile jf = new JarFile(multirelease, true, ZipFile.OPEN_READ, Release.VERSION_9)) {
|
||||
try (JarFile jf = new JarFile(multirelease, true, ZipFile.OPEN_READ, Runtime.Version.parse("9"))) {
|
||||
ze2 = jf.getEntry(rname);
|
||||
}
|
||||
Assert.assertEquals(ze2.getName(), rname);
|
||||
|
@ -47,14 +47,8 @@
|
||||
*/
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.AfterClass;
|
||||
|
@ -43,8 +43,6 @@ import java.util.jar.JarFile;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
import static java.util.jar.JarFile.Release;
|
||||
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
@ -111,17 +109,17 @@ public class MultiReleaseJarIterators {
|
||||
testStream(jf, mrEntries);
|
||||
}
|
||||
|
||||
try (JarFile jf = new JarFile(multirelease, true, ZipFile.OPEN_READ, Release.BASE)) {
|
||||
try (JarFile jf = new JarFile(multirelease, true, ZipFile.OPEN_READ, JarFile.baseVersion())) {
|
||||
testEnumeration(jf, baseEntries);
|
||||
testStream(jf, baseEntries);
|
||||
}
|
||||
|
||||
try (JarFile jf = new JarFile(multirelease, true, ZipFile.OPEN_READ, Release.VERSION_9)) {
|
||||
try (JarFile jf = new JarFile(multirelease, true, ZipFile.OPEN_READ, Runtime.Version.parse("9"))) {
|
||||
testEnumeration(jf, v9Entries);
|
||||
testStream(jf, v9Entries);
|
||||
}
|
||||
|
||||
try (JarFile jf = new JarFile(multirelease, true, ZipFile.OPEN_READ, Release.RUNTIME)) {
|
||||
try (JarFile jf = new JarFile(multirelease, true, ZipFile.OPEN_READ, Runtime.version())) {
|
||||
Map<String,JarEntry> expectedEntries;
|
||||
switch (MAJOR_VERSION) {
|
||||
case 9:
|
||||
@ -147,17 +145,17 @@ public class MultiReleaseJarIterators {
|
||||
testStream(jf, uvEntries);
|
||||
}
|
||||
|
||||
try (JarFile jf = new JarFile(unversioned, true, ZipFile.OPEN_READ, Release.BASE)) {
|
||||
try (JarFile jf = new JarFile(unversioned, true, ZipFile.OPEN_READ, JarFile.baseVersion())) {
|
||||
testEnumeration(jf, uvEntries);
|
||||
testStream(jf, uvEntries);
|
||||
}
|
||||
|
||||
try (JarFile jf = new JarFile(unversioned, true, ZipFile.OPEN_READ, Release.VERSION_9)) {
|
||||
try (JarFile jf = new JarFile(unversioned, true, ZipFile.OPEN_READ, Runtime.Version.parse("9"))) {
|
||||
testEnumeration(jf, uvEntries);
|
||||
testStream(jf, uvEntries);
|
||||
}
|
||||
|
||||
try (JarFile jf = new JarFile(unversioned, true, ZipFile.OPEN_READ, Release.RUNTIME)) {
|
||||
try (JarFile jf = new JarFile(unversioned, true, ZipFile.OPEN_READ, Runtime.version())) {
|
||||
testEnumeration(jf, uvEntries);
|
||||
testStream(jf, uvEntries);
|
||||
}
|
||||
|
@ -60,11 +60,10 @@ import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
||||
public class MultiReleaseJarProperties {
|
||||
final static int BASE_VERSION = JarFile.baseVersion().major();
|
||||
|
||||
static final int MAJOR_VERSION = Runtime.version().major();
|
||||
|
||||
final static int ROOTVERSION = 8; // magic number from knowledge of internals
|
||||
final static String userdir = System.getProperty("user.dir", ".");
|
||||
final static File multirelease = new File(userdir, "multi-release.jar");
|
||||
protected int rtVersion;
|
||||
@ -77,15 +76,15 @@ public class MultiReleaseJarProperties {
|
||||
CreateMultiReleaseTestJars creator = new CreateMultiReleaseTestJars();
|
||||
creator.compileEntries();
|
||||
creator.buildMultiReleaseJar();
|
||||
|
||||
rtVersion = Integer.getInteger("jdk.util.jar.version", MAJOR_VERSION);
|
||||
int RUNTIME_VERSION = Runtime.version().major();
|
||||
rtVersion = Integer.getInteger("jdk.util.jar.version", RUNTIME_VERSION);
|
||||
String mrprop = System.getProperty("jdk.util.jar.enableMultiRelease", "");
|
||||
if (mrprop.equals("false")) {
|
||||
rtVersion = ROOTVERSION;
|
||||
} else if (rtVersion < ROOTVERSION) {
|
||||
rtVersion = ROOTVERSION;
|
||||
} else if (rtVersion > MAJOR_VERSION) {
|
||||
rtVersion = MAJOR_VERSION;
|
||||
rtVersion = BASE_VERSION;
|
||||
} else if (rtVersion < BASE_VERSION) {
|
||||
rtVersion = BASE_VERSION;
|
||||
} else if (rtVersion > RUNTIME_VERSION) {
|
||||
rtVersion = RUNTIME_VERSION;
|
||||
}
|
||||
force = mrprop.equals("force");
|
||||
|
||||
@ -135,7 +134,7 @@ public class MultiReleaseJarProperties {
|
||||
if (force) throw x;
|
||||
}
|
||||
}
|
||||
invokeMethod(vcls, force ? rtVersion : ROOTVERSION);
|
||||
invokeMethod(vcls, force ? rtVersion : BASE_VERSION);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ public class MultiReleaseJarSecurity {
|
||||
|
||||
@Test
|
||||
public void testCertsAndSigners() throws IOException {
|
||||
try (JarFile jf = new JarFile(signedmultirelease, true, ZipFile.OPEN_READ, JarFile.Release.RUNTIME)) {
|
||||
try (JarFile jf = new JarFile(signedmultirelease, true, ZipFile.OPEN_READ, Runtime.version())) {
|
||||
CertsAndSigners vcas = new CertsAndSigners(jf, jf.getJarEntry("version/Version.class"));
|
||||
CertsAndSigners rcas = new CertsAndSigners(jf, jf.getJarEntry("META-INF/versions/" + MAJOR_VERSION + "/version/Version.class"));
|
||||
Assert.assertTrue(Arrays.equals(rcas.getCertificates(), vcas.getCertificates()));
|
||||
|
423
jdk/test/java/util/logging/SystemLoggerConfigTest.java
Normal file
423
jdk/test/java/util/logging/SystemLoggerConfigTest.java
Normal file
@ -0,0 +1,423 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.lang.ref.Reference;
|
||||
import java.security.Permission;
|
||||
import java.security.Policy;
|
||||
import java.security.ProtectionDomain;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.logging.Handler;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogManager;
|
||||
import java.util.logging.LogRecord;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import sun.util.logging.PlatformLogger;
|
||||
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8159245
|
||||
* @summary Tests configuration of loggers.
|
||||
* @modules java.logging/sun.util.logging.internal java.base/sun.util.logging
|
||||
* @run main/othervm SystemLoggerConfigTest NOSECURITY
|
||||
* @run main/othervm SystemLoggerConfigTest WITHSECURITY
|
||||
*
|
||||
* @author danielfuchs
|
||||
*/
|
||||
public class SystemLoggerConfigTest {
|
||||
|
||||
static Logger createSystemLogger(String name) {
|
||||
return sun.util.logging.internal.LoggingProviderImpl.getLogManagerAccess()
|
||||
.demandLoggerFor(LogManager.getLogManager(), name,
|
||||
Thread.class.getModule());
|
||||
}
|
||||
|
||||
static PlatformLogger createPlatformLogger(String name) {
|
||||
return PlatformLogger.getLogger(name);
|
||||
}
|
||||
|
||||
private static void assertFalse(boolean value, String msg) {
|
||||
assertEquals(false, value, msg);
|
||||
}
|
||||
private static void assertEquals(boolean expected, boolean actual, String msg) {
|
||||
if (expected != actual) {
|
||||
throw new AssertionError(msg+": expected: " + expected + " actual: " + actual);
|
||||
}
|
||||
}
|
||||
private static void assertEquals(int expected, int actual, String msg) {
|
||||
if (expected != actual) {
|
||||
throw new AssertionError(msg+": expected: " + expected + " actual: " + actual);
|
||||
}
|
||||
}
|
||||
private static void assertEquals(long expected, long actual, String msg) {
|
||||
if (expected != actual) {
|
||||
throw new AssertionError(msg+": expected: " + expected + " actual: " + actual);
|
||||
}
|
||||
}
|
||||
private static void assertEquals(Object expected, Object actual, String msg) {
|
||||
if (!Objects.equals(expected, actual)) {
|
||||
throw new AssertionError(msg+": expected: " + expected + " actual: " + actual);
|
||||
}
|
||||
}
|
||||
|
||||
static class TestHandler extends Handler {
|
||||
private final List<LogRecord> records = new CopyOnWriteArrayList<>();
|
||||
public TestHandler() {
|
||||
super();
|
||||
setLevel(Level.ALL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void publish(LogRecord lr) {
|
||||
records.add(lr);
|
||||
}
|
||||
|
||||
public List<LogRecord> drain() {
|
||||
List<LogRecord> list = new ArrayList<>(records);
|
||||
records.clear();
|
||||
return list;
|
||||
}
|
||||
|
||||
public void close() {
|
||||
records.clear();
|
||||
}
|
||||
|
||||
public void flush() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class TestHandler1 extends TestHandler {
|
||||
final static AtomicLong COUNT = new AtomicLong();
|
||||
public TestHandler1() {
|
||||
COUNT.incrementAndGet();
|
||||
}
|
||||
}
|
||||
|
||||
public static class TestHandler2 extends TestHandler {
|
||||
final static AtomicLong COUNT = new AtomicLong();
|
||||
public TestHandler2() {
|
||||
COUNT.incrementAndGet();
|
||||
}
|
||||
}
|
||||
|
||||
static enum TestCase { WITHSECURITY, NOSECURITY }
|
||||
|
||||
public static void main(String[] args) {
|
||||
if (args == null || args.length == 0) {
|
||||
args = Stream.of(TestCase.values())
|
||||
.map(String::valueOf)
|
||||
.collect(Collectors.toList())
|
||||
.toArray(new String[0]);
|
||||
}
|
||||
Stream.of(args)
|
||||
.map(TestCase::valueOf)
|
||||
.forEach(SystemLoggerConfigTest::launch);
|
||||
}
|
||||
|
||||
public static void launch(TestCase test) {
|
||||
switch(test) {
|
||||
case WITHSECURITY:
|
||||
Policy.setPolicy(new Policy() {
|
||||
@Override
|
||||
public boolean implies(ProtectionDomain domain, Permission permission) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
System.setSecurityManager(new SecurityManager());
|
||||
break;
|
||||
case NOSECURITY:
|
||||
break;
|
||||
default:
|
||||
throw new InternalError("Unexpected enum: " + test);
|
||||
}
|
||||
try {
|
||||
test(test.name(), ".1", ".child");
|
||||
test(test.name(), ".2", "");
|
||||
testUpdateConfiguration(test.name(), ".3");
|
||||
testSetPlatformLevel(test.name(), ".4");
|
||||
} catch (IOException io) {
|
||||
throw new UncheckedIOException(io);
|
||||
}
|
||||
}
|
||||
|
||||
public static void test(String name, String step, String ext)
|
||||
throws IOException {
|
||||
|
||||
System.out.println("\n*** Testing " + name + step + ext);
|
||||
|
||||
final String systemName1a = "system.logger.one.a." + name + step + ext;
|
||||
final String systemName1b = "system.logger.one.b." + name + step + ext;
|
||||
final String appName1a = "system.logger.one.a." + name + step;
|
||||
final String appName1b = "system.logger.one.b." + name + step;
|
||||
final String msg1a = "logger name: " + systemName1a;
|
||||
final String msg1b = "logger name: " + systemName1b;
|
||||
final String systemName2 = "system.logger.two." + name + step + ext;
|
||||
final String appName2 = "system.logger.two." + name + step;
|
||||
final String msg2 = "logger name: " + systemName2;
|
||||
final String systemName3 = "system.logger.three." + name + step + ext;
|
||||
final String appName3 = "system.logger.three." + name + step;
|
||||
final String msg3 = "logger name: " + systemName3;
|
||||
List<LogRecord> records;
|
||||
|
||||
System.out.println("\n[Case #1] Creating platform logger: " + systemName1a);
|
||||
PlatformLogger system1a = createPlatformLogger(systemName1a);
|
||||
System.out.println(" Creating platform logger: " + systemName1b);
|
||||
PlatformLogger system1b = createPlatformLogger(systemName1b);
|
||||
System.out.println(" Adding handler on root logger...");
|
||||
TestHandler test1 = new TestHandler();
|
||||
Logger.getLogger("").addHandler(test1);
|
||||
|
||||
System.out.println(" Creating and configuring app logger: " + appName1a
|
||||
+ ", " + appName1b);
|
||||
Logger app1a = Logger.getLogger(appName1a);
|
||||
app1a.setLevel(Level.INFO);
|
||||
Logger app1b = Logger.getLogger(appName1b);
|
||||
app1b.setLevel(Level.INFO);
|
||||
assertFalse(system1a.isLoggable(PlatformLogger.Level.FINEST),
|
||||
"Unexpected level for " + system1a);
|
||||
System.out.println(" Configuring root logger...");
|
||||
Logger.getLogger("").setLevel(Level.FINEST);
|
||||
System.out.println(" Logging through system logger: " + systemName1a);
|
||||
system1a.finest(msg1a);
|
||||
Reference.reachabilityFence(app1a);
|
||||
records = test1.drain();
|
||||
assertEquals(0, records.size(), "Unexpected size for " + records.toString());
|
||||
System.out.println(" Logging through system logger: " + systemName1b);
|
||||
system1b.finest(msg1b);
|
||||
Reference.reachabilityFence(app1b);
|
||||
records = test1.drain();
|
||||
assertEquals(0, records.size(), "Unexpected size for " + records.toString());
|
||||
Logger.getLogger("system.logger.one.a").finest("system.logger.one.a");
|
||||
records = test1.drain();
|
||||
assertEquals("system.logger.one.a", records.get(0).getMessage(), "Unexpected message: ");
|
||||
Logger.getLogger("").setLevel(Level.INFO);
|
||||
Logger.getLogger("system.logger.one.a").finest("system.logger.one.a");
|
||||
records = test1.drain();
|
||||
assertEquals(0, records.size(), "Unexpected size for " + records.toString());
|
||||
|
||||
Reference.reachabilityFence(system1a);
|
||||
Reference.reachabilityFence(system1b);
|
||||
|
||||
System.out.println("\n[Case #2] Creating system logger: " + systemName2);
|
||||
Logger system2 = createSystemLogger(systemName2);
|
||||
System.out.println(" Creating app logger: " + appName2);
|
||||
Logger app2 = Logger.getLogger(appName2);
|
||||
System.out.println(" Configuring app logger...");
|
||||
TestHandler test2 = new TestHandler();
|
||||
app2.setLevel(Level.ALL);
|
||||
app2.setUseParentHandlers(false);
|
||||
app2.addHandler(test2);
|
||||
System.out.println(" Logging through system logger: " + systemName2);
|
||||
system2.finest(msg2);
|
||||
records = test2.drain();
|
||||
assertEquals(1, records.size(), "Unexpected size for " + records.toString());
|
||||
assertEquals(msg2, records.get(0).getMessage(), "Unexpected message: ");
|
||||
records = test1.drain();
|
||||
assertEquals(0, records.size(), "Unexpected size for " + records.toString());
|
||||
|
||||
Reference.reachabilityFence(app2);
|
||||
Reference.reachabilityFence(system2);
|
||||
|
||||
System.out.println("\n[Case #3] Creating app logger: " + appName3);
|
||||
Logger app3 = Logger.getLogger(appName3);
|
||||
System.out.println(" Configuring app logger...");
|
||||
TestHandler test3 = new TestHandler();
|
||||
app3.setLevel(Level.ALL);
|
||||
app3.setUseParentHandlers(false);
|
||||
app3.addHandler(test3);
|
||||
System.out.println(" Creating system logger: " + systemName3);
|
||||
Logger system3 = createSystemLogger(systemName3);
|
||||
System.out.println(" Logging through system logger: " + systemName3);
|
||||
system3.finest(msg3);
|
||||
records = test3.drain();
|
||||
assertEquals(1, records.size(), "Unexpected size for " + records.toString());
|
||||
assertEquals(msg3, records.get(0).getMessage(), "Unexpected message: ");
|
||||
records = test1.drain();
|
||||
assertEquals(0, records.size(), "Unexpected size for " + records.toString());
|
||||
|
||||
Reference.reachabilityFence(app3);
|
||||
Reference.reachabilityFence(system3);
|
||||
System.gc();
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecated")
|
||||
static void setPlatformLevel(PlatformLogger logger, PlatformLogger.Level level) {
|
||||
logger.setLevel(level);
|
||||
}
|
||||
|
||||
public static void testSetPlatformLevel(String name, String step) {
|
||||
System.out.println("\n*** Testing PlatformLogger.setLevel " + name + step);
|
||||
|
||||
System.out.println("\n[Case #5] Creating app logger: " + name + step);
|
||||
// this should return named logger in the global context
|
||||
Logger foo = Logger.getLogger(name + step);
|
||||
foo.setLevel(Level.FINE);
|
||||
|
||||
System.out.println(" Creating platform logger: " + name + step);
|
||||
PlatformLogger foo1 = PlatformLogger.getLogger(name + step);
|
||||
System.out.println(" Configuring platform logger...");
|
||||
setPlatformLevel(foo1, PlatformLogger.Level.INFO);
|
||||
|
||||
System.out.println(" Checking levels...");
|
||||
assertEquals(foo.getName(), foo1.getName(), "Bad logger names");
|
||||
// both logger share the same config
|
||||
assertEquals(foo.getLevel(), Level.INFO, "Bad level for user logger");
|
||||
assertEquals(foo1.level(), PlatformLogger.Level.INFO,
|
||||
"Bad level for platform logger");
|
||||
|
||||
}
|
||||
|
||||
static void updateConfiguration(Properties props) throws IOException {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
props.store(baos, "");
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
|
||||
LogManager.getLogManager().updateConfiguration(bais, (k) -> (o,n) -> n != null ? n : o);
|
||||
}
|
||||
|
||||
static void readConfiguration(Properties props) throws IOException {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
props.store(baos, "");
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
|
||||
LogManager.getLogManager().readConfiguration(bais);
|
||||
}
|
||||
|
||||
// Tests that though two loggers exist, only one handler is created for the
|
||||
// pair when reading configuration.
|
||||
//
|
||||
public static void testUpdateConfiguration(String name, String step) throws IOException {
|
||||
|
||||
System.out.println("\n*** Testing LogManager.updateConfiguration " + name + step);
|
||||
|
||||
final String name1a = "system.logger.one.a." + name + step;
|
||||
final String name1b = "system.logger.one.b." + name + step;
|
||||
final String msg1a = "logger name: " + name1a;
|
||||
final String msg1b = "logger name: " + name1b;
|
||||
List<LogRecord> records;
|
||||
|
||||
TestHandler1.COUNT.set(0);
|
||||
TestHandler2.COUNT.set(0);
|
||||
Properties props = new Properties();
|
||||
props.setProperty(name1a+".handlers", TestHandler1.class.getName());
|
||||
updateConfiguration(props);
|
||||
assertEquals(0, TestHandler1.COUNT.get(), "Bad instance count for "
|
||||
+ TestHandler1.class.getName());
|
||||
assertEquals(0, TestHandler2.COUNT.get(), "Bad instance count for "
|
||||
+ TestHandler2.class.getName());
|
||||
|
||||
System.out.println("\n[Case #4] Creating app logger: " + name1a);
|
||||
Logger app1a = Logger.getLogger(name1a);
|
||||
System.out.println(" Configuring app logger...");
|
||||
TestHandler test1 = new TestHandler();
|
||||
app1a.setLevel(Level.ALL);
|
||||
app1a.setUseParentHandlers(false);
|
||||
app1a.addHandler(test1);
|
||||
assertEquals(1, TestHandler1.COUNT.get(), "Bad instance count for "
|
||||
+ TestHandler1.class.getName());
|
||||
assertEquals(0, TestHandler2.COUNT.get(), "Bad instance count for "
|
||||
+ TestHandler2.class.getName());
|
||||
|
||||
System.out.println(" Creating system logger: " + name1a);
|
||||
Logger system1a = createSystemLogger(name1a);
|
||||
assertEquals(Level.ALL, system1a.getLevel(), "Bad level for system logger " + name1a);
|
||||
System.out.println(" Logging through system logger: " + name1a);
|
||||
system1a.finest(msg1a);
|
||||
records = test1.drain();
|
||||
assertEquals(1, records.size(), "Unexpected size for " + records.toString());
|
||||
assertEquals(msg1a, records.get(0).getMessage(), "Unexpected message: ");
|
||||
records = test1.drain();
|
||||
assertEquals(0, records.size(), "Unexpected size for " + records.toString());
|
||||
|
||||
assertEquals(1, TestHandler1.COUNT.get(), "Bad instance count for "
|
||||
+ TestHandler1.class.getName());
|
||||
assertEquals(0, TestHandler2.COUNT.get(), "Bad instance count for "
|
||||
+ TestHandler2.class.getName());
|
||||
|
||||
props.setProperty(name1a+".handlers", TestHandler2.class.getName());
|
||||
updateConfiguration(props);
|
||||
|
||||
assertEquals(1, TestHandler1.COUNT.get(), "Bad instance count for "
|
||||
+ TestHandler1.class.getName());
|
||||
assertEquals(1, TestHandler2.COUNT.get(), "Bad instance count for "
|
||||
+ TestHandler2.class.getName());
|
||||
|
||||
updateConfiguration(props);
|
||||
|
||||
assertEquals(1, TestHandler1.COUNT.get(), "Bad instance count for "
|
||||
+ TestHandler1.class.getName());
|
||||
assertEquals(1, TestHandler2.COUNT.get(), "Bad instance count for "
|
||||
+ TestHandler2.class.getName());
|
||||
|
||||
readConfiguration(props);
|
||||
|
||||
assertEquals(1, TestHandler1.COUNT.get(), "Bad instance count for "
|
||||
+ TestHandler1.class.getName());
|
||||
// readConfiguration reset handlers but does not recreate them
|
||||
assertEquals(1, TestHandler2.COUNT.get(), "Bad instance count for "
|
||||
+ TestHandler2.class.getName());
|
||||
|
||||
updateConfiguration(props);
|
||||
|
||||
assertEquals(1, TestHandler1.COUNT.get(), "Bad instance count for "
|
||||
+ TestHandler1.class.getName());
|
||||
assertEquals(1, TestHandler2.COUNT.get(), "Bad instance count for "
|
||||
+ TestHandler2.class.getName());
|
||||
|
||||
LogManager.getLogManager().reset();
|
||||
updateConfiguration(props);
|
||||
|
||||
assertEquals(1, TestHandler1.COUNT.get(), "Bad instance count for "
|
||||
+ TestHandler1.class.getName());
|
||||
assertEquals(2, TestHandler2.COUNT.get(), "Bad instance count for "
|
||||
+ TestHandler2.class.getName());
|
||||
|
||||
props.setProperty(name1a+".handlers",
|
||||
TestHandler2.class.getName() + "," + TestHandler1.class.getName());
|
||||
updateConfiguration(props);
|
||||
|
||||
assertEquals(2, TestHandler1.COUNT.get(), "Bad instance count for "
|
||||
+ TestHandler1.class.getName());
|
||||
assertEquals(3, TestHandler2.COUNT.get(), "Bad instance count for "
|
||||
+ TestHandler2.class.getName());
|
||||
|
||||
Reference.reachabilityFence(app1a);
|
||||
Reference.reachabilityFence(system1a);
|
||||
|
||||
LogManager.getLogManager().readConfiguration();
|
||||
System.gc();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/* @test
|
||||
* @library /lib/testlibrary/
|
||||
* @build jdk.testlibrary.*
|
||||
* @run main TestAvailable
|
||||
* @bug 7031075
|
||||
* @summary Make sure that available() method behaves as expected.
|
||||
* @key randomness
|
||||
*/
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Random;
|
||||
import java.util.zip.*;
|
||||
import jdk.testlibrary.RandomFactory;
|
||||
|
||||
public class TestAvailable {
|
||||
|
||||
public static void main(String args[]) throws Throwable {
|
||||
Random r = RandomFactory.getRandom();
|
||||
for (int n = 0; n < 10; n++) {
|
||||
byte[] src = new byte[r.nextInt(100)];
|
||||
r.nextBytes(src);
|
||||
|
||||
// test InflaterInputStream
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
try (DeflaterOutputStream dos = new DeflaterOutputStream(baos)) {
|
||||
dos.write(src);
|
||||
}
|
||||
try (InflaterInputStream iis = new InflaterInputStream(
|
||||
new ByteArrayInputStream(baos.toByteArray()))) {
|
||||
test(iis, src);
|
||||
}
|
||||
|
||||
// test GZIPInputStream
|
||||
baos = new ByteArrayOutputStream();
|
||||
try (GZIPOutputStream dos = new GZIPOutputStream(baos)) {
|
||||
dos.write(src);
|
||||
}
|
||||
try (GZIPInputStream gis = new GZIPInputStream(
|
||||
new ByteArrayInputStream(baos.toByteArray()))) {
|
||||
test(gis, src);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void test(InputStream is, byte[] expected) throws IOException {
|
||||
int cnt = 0;
|
||||
do {
|
||||
int available = is.available();
|
||||
if (available > 0) {
|
||||
int b = is.read();
|
||||
if (b == -1) {
|
||||
throw new RuntimeException("available() > 0, read() == -1 : failed!");
|
||||
}
|
||||
if (expected[cnt++] != (byte)b) {
|
||||
throw new RuntimeException("read() : failed!");
|
||||
}
|
||||
} else if (available == 0) {
|
||||
if (is.read() != -1) {
|
||||
throw new RuntimeException("available() == 0, read() != -1 : failed!");
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
throw new RuntimeException("available() < 0 : failed!");
|
||||
}
|
||||
} while (true);
|
||||
if (cnt != expected.length) {
|
||||
throw new RuntimeException("read : failed!");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -132,12 +132,12 @@ public class MultiReleaseJarURLConnection {
|
||||
URL rootUrl = new URL(urlFile);
|
||||
JarURLConnection juc = (JarURLConnection)rootUrl.openConnection();
|
||||
JarFile rootJar = juc.getJarFile();
|
||||
JarFile.Release root = rootJar.getVersion();
|
||||
Runtime.Version root = rootJar.getVersion();
|
||||
|
||||
URL runtimeUrl = new URL(urlFile + "#runtime");
|
||||
juc = (JarURLConnection)runtimeUrl.openConnection();
|
||||
JarFile runtimeJar = juc.getJarFile();
|
||||
JarFile.Release runtime = runtimeJar.getVersion();
|
||||
Runtime.Version runtime = runtimeJar.getVersion();
|
||||
if (style.equals("unversioned")) {
|
||||
Assert.assertEquals(root, runtime);
|
||||
} else {
|
||||
|
@ -37,7 +37,7 @@ setenv LD_LIBRARY_PATH $WS/test/sun/security/pkcs11/nss/lib/solaris-sparc
|
||||
modutil -create -dbdir .
|
||||
modutil -changepw "NSS Internal PKCS #11 Module" -dbdir .
|
||||
|
||||
$JHOME/bin/keytool -list -storetype PKCS11 -providerclass sun.security.pkcs11.SunPKCS11 -providerarg "--name=NSS\nnssSecmodDirectory=." -v -storepass test12
|
||||
$JHOME/bin/keytool -list -storetype PKCS11 -addprovider SunPKCS11 -providerarg "--name=NSS\nnssSecmodDirectory=." -v -storepass test12
|
||||
|
||||
modutil -fips true -dbdir .
|
||||
|
||||
|
161
jdk/test/sun/security/tools/jarsigner/AltProvider.java
Normal file
161
jdk/test/sun/security/tools/jarsigner/AltProvider.java
Normal file
@ -0,0 +1,161 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 4906940 8130302
|
||||
* @summary -providerPath, -providerClass, -addprovider, and -providerArg
|
||||
* @library /lib/testlibrary /test/lib/share/classes
|
||||
* @modules java.base/jdk.internal.misc
|
||||
*/
|
||||
|
||||
import jdk.test.lib.JDKToolLauncher;
|
||||
import jdk.test.lib.process.OutputAnalyzer;
|
||||
import jdk.test.lib.process.ProcessTools;
|
||||
import jdk.testlibrary.JarUtils;
|
||||
|
||||
import java.nio.file.*;
|
||||
|
||||
public class AltProvider {
|
||||
|
||||
private static final String TEST_SRC =
|
||||
Paths.get(System.getProperty("test.src")).toString();
|
||||
|
||||
private static final Path MOD_SRC_DIR = Paths.get(TEST_SRC, "alt");
|
||||
private static final Path MOD_DEST_DIR = Paths.get("mods");
|
||||
|
||||
private static final String ktCommand = "-keystore x.jks " +
|
||||
"-storepass changeit -storetype dummyks -list -debug";
|
||||
|
||||
private static final String jsCommand = "-keystore x.jks " +
|
||||
"-storepass changeit -storetype dummyks -debug x.jar x";
|
||||
|
||||
public static void main(String[] args) throws Throwable {
|
||||
|
||||
// Compile the provider
|
||||
CompilerUtils.compile(
|
||||
MOD_SRC_DIR, MOD_DEST_DIR,
|
||||
"-modulesourcepath",
|
||||
MOD_SRC_DIR.toString());
|
||||
|
||||
// Create a keystore
|
||||
tool("keytool", "-keystore x.jks -storetype jks -genkeypair" +
|
||||
" -storepass changeit -keypass changeit -alias x -dname CN=X")
|
||||
.shouldHaveExitValue(0);
|
||||
|
||||
// Create a jar file
|
||||
JarUtils.createJar("x.jar", "x.jks");
|
||||
|
||||
// Test starts here
|
||||
|
||||
// Without new provider
|
||||
testBoth("", 1, "DUMMYKS not found");
|
||||
|
||||
// legacy use (-providerPath only supported by keytool)
|
||||
testKeytool("-providerPath mods/test.dummy " +
|
||||
"-providerClass org.test.dummy.DummyProvider -providerArg full",
|
||||
0, "loadProviderByClass: org.test.dummy.DummyProvider");
|
||||
|
||||
// legacy, on classpath
|
||||
testBoth("-J-cp -Jmods/test.dummy " +
|
||||
"-providerClass org.test.dummy.DummyProvider -providerArg full",
|
||||
0, "loadProviderByClass: org.test.dummy.DummyProvider");
|
||||
|
||||
// Wrong name
|
||||
testBoth("-J-cp -Jmods/test.dummy " +
|
||||
"-providerClass org.test.dummy.Dummy -providerArg full",
|
||||
1, "Provider \"org.test.dummy.Dummy\" not found");
|
||||
|
||||
// Not a provider name
|
||||
testBoth("-J-cp -Jmods/test.dummy " +
|
||||
"-providerClass java.lang.Object -providerArg full",
|
||||
1, "java.lang.Object not a provider");
|
||||
|
||||
// without arg
|
||||
testBoth("-J-cp -Jmods/test.dummy " +
|
||||
"-providerClass org.test.dummy.DummyProvider",
|
||||
1, "DUMMYKS not found");
|
||||
|
||||
// old -provider still works
|
||||
testBoth("-J-cp -Jmods/test.dummy " +
|
||||
"-provider org.test.dummy.DummyProvider -providerArg full",
|
||||
0, "loadProviderByClass: org.test.dummy.DummyProvider");
|
||||
|
||||
// name in a module
|
||||
testBoth("-J-mp -Jmods " +
|
||||
"-addprovider Dummy -providerArg full",
|
||||
0, "loadProviderByName: Dummy");
|
||||
|
||||
// -providerClass does not work
|
||||
testBoth("-J-mp -Jmods " +
|
||||
"-providerClass org.test.dummy.DummyProvider -providerArg full",
|
||||
1, "Provider \"org.test.dummy.DummyProvider\" not found");
|
||||
|
||||
// -addprovider with class does not work
|
||||
testBoth("-J-mp -Jmods " +
|
||||
"-addprovider org.test.dummy.DummyProvider -providerArg full",
|
||||
1, "Provider named \"org.test.dummy.DummyProvider\" not found");
|
||||
|
||||
// -addprovider without arg does not work
|
||||
testBoth("-J-mp -Jmods " +
|
||||
"-addprovider Dummy",
|
||||
1, "DUMMYKS not found");
|
||||
}
|
||||
|
||||
// Test both tools with the same extra options
|
||||
private static void testBoth(String args, int exitValue, String contains)
|
||||
throws Throwable {
|
||||
testKeytool(args, exitValue, contains);
|
||||
testJarsigner(args, exitValue, contains);
|
||||
}
|
||||
|
||||
// Test keytool with extra options and check exitValue and output
|
||||
private static void testKeytool(String args, int exitValue, String contains)
|
||||
throws Throwable {
|
||||
tool("keytool", ktCommand + " " + args)
|
||||
.shouldHaveExitValue(exitValue)
|
||||
.shouldContain(contains);
|
||||
}
|
||||
|
||||
// Test jarsigner with extra options and check exitValue and output
|
||||
private static void testJarsigner(String args, int exitValue, String contains)
|
||||
throws Throwable {
|
||||
tool("jarsigner", jsCommand + " " + args)
|
||||
.shouldHaveExitValue(exitValue)
|
||||
.shouldContain(contains);
|
||||
}
|
||||
|
||||
// Launch a tool with args (space separated string)
|
||||
private static OutputAnalyzer tool(String tool, String args)
|
||||
throws Throwable {
|
||||
JDKToolLauncher l = JDKToolLauncher.createUsingTestJDK(tool);
|
||||
for (String a: args.split("\\s+")) {
|
||||
if (a.startsWith("-J")) {
|
||||
l.addVMArg(a.substring(2));
|
||||
} else {
|
||||
l.addToolArg(a);
|
||||
}
|
||||
}
|
||||
return ProcessTools.executeCommand(l.getCommand());
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
module test.dummy {
|
||||
provides java.security.Provider with org.test.dummy.DummyProvider;
|
||||
}
|
@ -21,22 +21,22 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
* @bug 4906490
|
||||
* @summary Dummy security service provider.
|
||||
* It is cited by the AltProviderPath.sh script.
|
||||
*/
|
||||
package org.test.dummy;
|
||||
|
||||
import java.util.*;
|
||||
import java.security.*;
|
||||
|
||||
public class DummyProvider extends Provider {
|
||||
public DummyProvider() {
|
||||
super("Dummy", 0.1, "Dummy Provider");
|
||||
super("Dummy", 0.1, "Dummy Provider with nothing");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Provider configure(String configArg) {
|
||||
return new DummyProvider(configArg);
|
||||
}
|
||||
|
||||
private DummyProvider(String arg) {
|
||||
super("Dummy", 0.2, "Dummy Provider with " + arg);
|
||||
//
|
||||
// KeyStore
|
||||
//
|
@ -1,122 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2004, 2013, 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
|
||||
# under the terms of the GNU General Public License version 2 only, as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
# version 2 for more details (a copy is included in the LICENSE file that
|
||||
# accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License version
|
||||
# 2 along with this work; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
# or visit www.oracle.com if you need additional information or have any
|
||||
# questions.
|
||||
#
|
||||
|
||||
# @test
|
||||
# @bug 4906940
|
||||
# @summary Add -providerPath option for keytool allowing one to specify
|
||||
# an additional classpath to search for providers.
|
||||
# @author Andrew Fan
|
||||
#
|
||||
# @run build DummyProvider
|
||||
# @run shell AltProviderPath.sh
|
||||
# set a few environment variables so that the shell-script can run stand-alone
|
||||
# in the source directory
|
||||
if [ "${TESTSRC}" = "" ] ; then
|
||||
TESTSRC="."
|
||||
fi
|
||||
if [ "${TESTCLASSES}" = "" ] ; then
|
||||
TESTCLASSES="."
|
||||
fi
|
||||
if [ "${TESTJAVA}" = "" ] ; then
|
||||
echo "TESTJAVA not set. Test cannot execute."
|
||||
echo "FAILED!!!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# set platform-dependent variables
|
||||
OS=`uname -s`
|
||||
case "$OS" in
|
||||
SunOS | Linux | Darwin | AIX )
|
||||
NULL=/dev/null
|
||||
PS=":"
|
||||
FS="/"
|
||||
;;
|
||||
CYGWIN* )
|
||||
NULL=/dev/null
|
||||
PS=";"
|
||||
FS="/"
|
||||
;;
|
||||
Windows_* )
|
||||
NULL=NUL
|
||||
PS=";"
|
||||
FS="\\"
|
||||
;;
|
||||
* )
|
||||
echo "Unrecognized operating system!"
|
||||
exit 1;
|
||||
;;
|
||||
esac
|
||||
|
||||
# the test code
|
||||
#genkey
|
||||
${TESTJAVA}${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -genkey -v -alias dummyTestCA \
|
||||
-keyalg "RSA" -keysize 1024 -sigalg "ShA1WithRSA" \
|
||||
-dname "cn=Dummy Test CA, ou=JSN, o=JavaSoft, c=US" -validity 3650 \
|
||||
-keypass storepass -keystore keystoreCA.dks -storepass storepass \
|
||||
-storetype "dummyks" -provider "org.test.dummy.DummyProvider" \
|
||||
-providerPath ${TESTCLASSES}
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#Change keystore password
|
||||
${TESTJAVA}${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -storepasswd -new storepass2 \
|
||||
-keystore keystoreCA.dks -storetype "dummyks" -storepass storepass \
|
||||
-provider "org.test.dummy.DummyProvider" -providerPath ${TESTCLASSES}
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
#Change keystore key password
|
||||
${TESTJAVA}${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -keypasswd -alias "dummyTestCA" \
|
||||
-keypass storepass -new keypass -keystore keystoreCA.dks \
|
||||
-storetype "dummyks" -storepass storepass2 \
|
||||
-provider "org.test.dummy.DummyProvider" -providerPath ${TESTCLASSES}
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#Export certificate
|
||||
${TESTJAVA}${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -v -export -rfc -alias "dummyTestCA" \
|
||||
-file "dummyTestCA.der" -keystore keystoreCA.dks -storetype "dummyks" \
|
||||
-storepass storepass2 -provider "org.test.dummy.DummyProvider" \
|
||||
-providerPath ${TESTCLASSES}
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#list keystore
|
||||
${TESTJAVA}${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -v -list -keystore keystoreCA.dks \
|
||||
-storetype "dummyks" -storepass storepass2 \
|
||||
-provider "org.test.dummy.DummyProvider" -providerPath ${TESTCLASSES}
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
@ -82,8 +82,9 @@ public class KeyToolTest {
|
||||
|
||||
static final String NSS_P11_ARG =
|
||||
"-keystore NONE -storetype PKCS11 -providerName SunPKCS11-nss " +
|
||||
"-providerClass sun.security.pkcs11.SunPKCS11 " +
|
||||
"-addprovider SunPKCS11 " +
|
||||
"-providerArg p11-nss.txt ";
|
||||
// Use -providerClass here, to confirm it still works for SunPKCS11.
|
||||
static final String NSS_SRC_P11_ARG =
|
||||
"-srckeystore NONE -srcstoretype PKCS11 " +
|
||||
"-srcproviderName SunPKCS11-nss " +
|
||||
@ -91,12 +92,12 @@ public class KeyToolTest {
|
||||
"-providerArg p11-nss.txt ";
|
||||
static final String NZZ_P11_ARG =
|
||||
"-keystore NONE -storetype PKCS11 -providerName SunPKCS11-nzz " +
|
||||
"-providerClass sun.security.pkcs11.SunPKCS11 " +
|
||||
"-addprovider SunPKCS11 " +
|
||||
"-providerArg p11-nzz.txt ";
|
||||
static final String NZZ_SRC_P11_ARG =
|
||||
"-srckeystore NONE -srcstoretype PKCS11 " +
|
||||
"-srcproviderName SunPKCS11-nzz " +
|
||||
"-providerClass sun.security.pkcs11.SunPKCS11 " +
|
||||
"-addprovider SunPKCS11 " +
|
||||
"-providerArg p11-nzz.txt ";
|
||||
static final String SUN_P11_ARG = "-keystore NONE -storetype PKCS11 ";
|
||||
static final String SUN_SRC_P11_ARG =
|
||||
@ -1715,9 +1716,9 @@ public class KeyToolTest {
|
||||
// 14. keytool -printcert -file cert
|
||||
testOK("", "-printcert -file cert -keystore x.jks -storetype JKS");
|
||||
remove("cert");
|
||||
// 15. keytool -list -storepass password -provider sun.security.provider.Sun
|
||||
// 15. keytool -list -storepass password -addprovider SUN
|
||||
testOK("", "-list -storepass password" +
|
||||
" -provider sun.security.provider.Sun" +
|
||||
" -addprovider SUN" +
|
||||
" -keystore x.jks -storetype JKS");
|
||||
|
||||
//Error tests
|
||||
|
@ -50,7 +50,7 @@ from keytool is correct (you can read everything in english fine).
|
||||
<li> keytool -import -v -file /tmp/cert -storepass password
|
||||
Check error (Certificate reply and cert are the same)
|
||||
<li> keytool -printcert -file /tmp/cert
|
||||
<li> keytool -list -storepass password -provider sun.security.provider.Sun
|
||||
<li> keytool -list -storepass password -addprovider SUN
|
||||
</ol>
|
||||
|
||||
Error tests
|
||||
@ -93,19 +93,19 @@ PKCS#11 tests
|
||||
<ol>
|
||||
<li> sccs edit cert8.db key3.db
|
||||
|
||||
<li> keytool -keystore NONE -storepass test12 -storetype PKCS11 -providerName SunPKCS11-nss -providerClass sun.security.pkcs11.SunPKCS11 -providerArg p11-nss.txt -genkey -alias genkey -dname cn=genkey -keysize 512 -keyalg rsa
|
||||
<li> keytool -keystore NONE -storepass test12 -storetype PKCS11 -providerName SunPKCS11-nss -providerClass sun.security.pkcs11.SunPKCS11 -providerArg p11-nss.txt -list
|
||||
<li> keytool -keystore NONE -storepass test12 -storetype PKCS11 -providerName SunPKCS11-nss -providerClass sun.security.pkcs11.SunPKCS11 -providerArg p11-nss.txt -list -alias genkey
|
||||
<li> keytool -keystore NONE -storepass test12 -storetype PKCS11 -providerName SunPKCS11-nss -providerClass sun.security.pkcs11.SunPKCS11 -providerArg p11-nss.txt -certreq -alias genkey -file genkey.certreq
|
||||
<li> keytool -keystore NONE -storepass test12 -storetype PKCS11 -providerName SunPKCS11-nss -providerClass sun.security.pkcs11.SunPKCS11 -providerArg p11-nss.txt -export -alias genkey -file genkey.cert
|
||||
<li> keytool -keystore NONE -storepass test12 -storetype PKCS11 -providerName SunPKCS11-nss -addprovider SunPKCS11 -providerArg p11-nss.txt -genkey -alias genkey -dname cn=genkey -keysize 512 -keyalg rsa
|
||||
<li> keytool -keystore NONE -storepass test12 -storetype PKCS11 -providerName SunPKCS11-nss -addprovider SunPKCS11 -providerArg p11-nss.txt -list
|
||||
<li> keytool -keystore NONE -storepass test12 -storetype PKCS11 -providerName SunPKCS11-nss -addprovider SunPKCS11 -providerArg p11-nss.txt -list -alias genkey
|
||||
<li> keytool -keystore NONE -storepass test12 -storetype PKCS11 -providerName SunPKCS11-nss -addprovider SunPKCS11 -providerArg p11-nss.txt -certreq -alias genkey -file genkey.certreq
|
||||
<li> keytool -keystore NONE -storepass test12 -storetype PKCS11 -providerName SunPKCS11-nss -addprovider SunPKCS11 -providerArg p11-nss.txt -export -alias genkey -file genkey.cert
|
||||
<li> keytool -printcert -file genkey.cert
|
||||
<li> keytool -keystore NONE -storepass test12 -storetype PKCS11 -providerName SunPKCS11-nss -providerClass sun.security.pkcs11.SunPKCS11 -providerArg p11-nss.txt -selfcert -alias genkey -dname cn=selfCert
|
||||
<li> keytool -keystore NONE -storepass test12 -storetype PKCS11 -providerName SunPKCS11-nss -addprovider SunPKCS11 -providerArg p11-nss.txt -selfcert -alias genkey -dname cn=selfCert
|
||||
|
||||
<li> keytool -keystore NONE -storepass test12 -storetype PKCS11 -providerName SunPKCS11-nss -providerClass sun.security.pkcs11.SunPKCS11 -providerArg p11-nss.txt -list -alias genkey -v
|
||||
<li> keytool -keystore NONE -storepass test12 -storetype PKCS11 -providerName SunPKCS11-nss -addprovider SunPKCS11 -providerArg p11-nss.txt -list -alias genkey -v
|
||||
(check that cert subject DN is [cn=selfCert])
|
||||
|
||||
<li> keytool -keystore NONE -storepass test12 -storetype PKCS11 -providerName SunPKCS11-nss -providerClass sun.security.pkcs11.SunPKCS11 -providerArg p11-nss.txt -delete -alias genkey
|
||||
<li> keytool -keystore NONE -storepass test12 -storetype PKCS11 -providerName SunPKCS11-nss -providerClass sun.security.pkcs11.SunPKCS11 -providerArg p11-nss.txt -list
|
||||
<li> keytool -keystore NONE -storepass test12 -storetype PKCS11 -providerName SunPKCS11-nss -addprovider SunPKCS11 -providerArg p11-nss.txt -delete -alias genkey
|
||||
<li> keytool -keystore NONE -storepass test12 -storetype PKCS11 -providerName SunPKCS11-nss -addprovider SunPKCS11 -providerArg p11-nss.txt -list
|
||||
(check for empty database listing)
|
||||
|
||||
<li> sccs unedit cert8.db key3.db
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8159943
|
||||
* @bug 8159943 8154797
|
||||
* @modules java.base/sun.util.locale.provider
|
||||
* java.base/sun.util.resources
|
||||
* jdk.localedata
|
||||
@ -65,6 +65,7 @@ public class JavaTimeSupplementaryTest {
|
||||
"field.",
|
||||
"islamic.",
|
||||
"roc.",
|
||||
"timezone."
|
||||
};
|
||||
|
||||
// All available locales for the COMPAT FormatData resource bundles
|
||||
|
@ -220,7 +220,7 @@ public class Basic {
|
||||
|
||||
private void checkMultiRelease(String jarFile, boolean expected) throws IOException {
|
||||
try (JarFile jf = new JarFile(new File(jarFile), true, ZipFile.OPEN_READ,
|
||||
JarFile.Release.RUNTIME)) {
|
||||
JarFile.runtimeVersion())) {
|
||||
assertEquals(jf.isMultiRelease(), expected);
|
||||
}
|
||||
}
|
||||
|
@ -75,5 +75,13 @@ public class JLinkPluginsTest {
|
||||
Path imageDir = helper.generateDefaultImage(userOptions, moduleName).assertSuccess();
|
||||
helper.checkImage(imageDir, moduleName, res, null);
|
||||
}
|
||||
{
|
||||
// Optimize Class.forName
|
||||
String[] userOptions = {"--class-for-name"};
|
||||
String moduleName = "classforname";
|
||||
helper.generateDefaultJModule(moduleName, "composite2");
|
||||
Path imageDir = helper.generateDefaultImage(userOptions, moduleName).assertSuccess();
|
||||
helper.checkImage(imageDir, moduleName, null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@
|
||||
/**
|
||||
* @test
|
||||
* @bug 5030233 6214916 6356475 6571029 6684582 6742159 4459600 6758881 6753938
|
||||
* 6894719 6968053 7151434 7146424 8007333 8077822 8143640
|
||||
* 6894719 6968053 7151434 7146424 8007333 8077822 8143640 8132379
|
||||
* @summary Argument parsing validation.
|
||||
* @compile -XDignore.symbol.file Arrrghs.java
|
||||
* @run main/othervm Arrrghs
|
||||
@ -383,6 +383,12 @@ public class Arrrghs extends TestHelper {
|
||||
checkArgumentWildcard("empty\\*?", "empty\\*?");
|
||||
checkArgumentWildcard("empty\\?*", "empty\\?*");
|
||||
|
||||
// 8132379: java should not filter out -J options for application
|
||||
String[] args = { "-J-one", "-Jtwo", "lib\\???.java", "-J-Dsomething",
|
||||
"a", "-J-Dlast.arg" };
|
||||
String[] expected = { "-J-one", "-Jtwo", "lib\\Fbo.java",
|
||||
"lib\\Foo.java", "-J-Dsomething", "a", "-J-Dlast.arg" };
|
||||
checkArgumentWildcard(args, expected);
|
||||
}
|
||||
|
||||
void doArgumentCheck(String inArgs, String... expArgs) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user