Merge
This commit is contained in:
commit
fded3474ec
@ -79,9 +79,6 @@ $(eval $(call SetupNativeCompilation,BUILD_UNPACKEXE, \
|
||||
CFLAGS_linux := -fPIC, \
|
||||
CFLAGS_solaris := -KPIC, \
|
||||
CFLAGS_macosx := -fPIC, \
|
||||
DISABLED_WARNINGS_gcc := sign-compare unused-result format-nonliteral \
|
||||
format-security parentheses, \
|
||||
DISABLED_WARNINGS_microsoft := 4267 4018, \
|
||||
MAPFILE := $(UNPACK_MAPFILE),\
|
||||
LDFLAGS := $(UNPACKEXE_ZIPOBJS) \
|
||||
$(LDFLAGS_JDKEXE) $(LDFLAGS_CXX_JDK) \
|
||||
|
@ -40,11 +40,6 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBUNPACK, \
|
||||
-I$(JDK_TOPDIR)/src/jdk.pack200/share/native/common-unpack \
|
||||
$(LIBJAVA_HEADER_FLAGS), \
|
||||
CFLAGS_release := -DPRODUCT, \
|
||||
DISABLED_WARNINGS_gcc := conversion-null sign-compare format-security \
|
||||
format-nonliteral parentheses, \
|
||||
DISABLED_WARNINGS_clang := bool-conversion format-security, \
|
||||
DISABLED_WARNINGS_solstudio := truncwarn, \
|
||||
DISABLED_WARNINGS_microsoft := 4267 4018, \
|
||||
MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libunpack/mapfile-vers, \
|
||||
LDFLAGS := $(LDFLAGS_JDKLIB) $(LDFLAGS_CXX_JDK) \
|
||||
$(call SET_SHARED_LIBRARY_ORIGIN), \
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2015, 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
|
||||
@ -32,10 +32,10 @@ package com.sun.net.ssl;
|
||||
import java.net.URL;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.io.IOException;
|
||||
import java.security.cert.Certificate;
|
||||
import javax.net.SocketFactory;
|
||||
import javax.net.ssl.SSLSocketFactory;
|
||||
|
||||
import javax.security.cert.X509Certificate;
|
||||
import javax.net.ssl.SSLPeerUnverifiedException;
|
||||
|
||||
/**
|
||||
* HTTP URL connection with support for HTTPS-specific features. See
|
||||
@ -70,7 +70,8 @@ class HttpsURLConnection extends HttpURLConnection
|
||||
* the server did not authenticate.
|
||||
* @return the server certificate chain
|
||||
*/
|
||||
public abstract X509Certificate [] getServerCertificateChain();
|
||||
public abstract Certificate[] getServerCertificates()
|
||||
throws SSLPeerUnverifiedException;
|
||||
|
||||
/**
|
||||
* HostnameVerifier provides a callback mechanism so that
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2015, 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
|
||||
@ -187,25 +187,6 @@ public class HttpsURLConnectionOldImpl
|
||||
return delegate.getServerCertificates();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the server's X.509 certificate chain, or null if
|
||||
* the server did not authenticate.
|
||||
*
|
||||
* NOTE: This method is not necessary for the version of this class
|
||||
* implementing javax.net.ssl.HttpsURLConnection, but provided for
|
||||
* compatibility with the com.sun.net.ssl.HttpsURLConnection version.
|
||||
*/
|
||||
public javax.security.cert.X509Certificate[] getServerCertificateChain() {
|
||||
try {
|
||||
return delegate.getServerCertificateChain();
|
||||
} catch (SSLPeerUnverifiedException e) {
|
||||
// this method does not throw an exception as declared in
|
||||
// com.sun.net.ssl.HttpsURLConnection.
|
||||
// Return null for compatibility.
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Allowable input/output sequences:
|
||||
* [interpreted as POST/PUT]
|
||||
|
@ -82,7 +82,7 @@ import java.util.Map;
|
||||
* <li><a name="redirect-output">a destination for <i>standard output</i>
|
||||
* and <i>standard error</i></a>. By default, the subprocess writes standard
|
||||
* output and standard error to pipes. Java code can access these pipes
|
||||
* via the input streams returned by {@link Process#getInputStream()} and
|
||||
* via the input streams returned by {@link Process#getOutputStream()} and
|
||||
* {@link Process#getErrorStream()}. However, standard output and
|
||||
* standard error may be redirected to other destinations using
|
||||
* {@link #redirectOutput(Redirect) redirectOutput} and
|
||||
@ -988,14 +988,14 @@ public final class ProcessBuilder
|
||||
* <li>the standard input to the subprocess was
|
||||
* {@linkplain #redirectInput redirected from a file}
|
||||
* and the security manager's
|
||||
* {@link SecurityManager#checkRead checkRead} method
|
||||
* {@link SecurityManager#checkRead(String) checkRead} method
|
||||
* denies read access to the file, or
|
||||
*
|
||||
* <li>the standard output or standard error of the
|
||||
* subprocess was
|
||||
* {@linkplain #redirectOutput redirected to a file}
|
||||
* and the security manager's
|
||||
* {@link SecurityManager#checkWrite checkWrite} method
|
||||
* {@link SecurityManager#checkWrite(String) checkWrite} method
|
||||
* denies write access to the file
|
||||
*
|
||||
* </ul>
|
||||
|
@ -1317,6 +1317,7 @@ public class Date
|
||||
private void writeObject(ObjectOutputStream s)
|
||||
throws IOException
|
||||
{
|
||||
s.defaultWriteObject();
|
||||
s.writeLong(getTimeImpl());
|
||||
}
|
||||
|
||||
@ -1326,6 +1327,7 @@ public class Date
|
||||
private void readObject(ObjectInputStream s)
|
||||
throws IOException, ClassNotFoundException
|
||||
{
|
||||
s.defaultReadObject();
|
||||
fastTime = s.readLong();
|
||||
}
|
||||
|
||||
|
@ -346,7 +346,7 @@ public final class Optional<T> {
|
||||
* </ul>
|
||||
*
|
||||
* @param obj an object to be tested for equality
|
||||
* @return {code true} if the other object is "equal to" this object
|
||||
* @return {@code true} if the other object is "equal to" this object
|
||||
* otherwise {@code false}
|
||||
*/
|
||||
@Override
|
||||
|
@ -244,7 +244,7 @@ public final class OptionalDouble {
|
||||
* </ul>
|
||||
*
|
||||
* @param obj an object to be tested for equality
|
||||
* @return {code true} if the other object is "equal to" this object
|
||||
* @return {@code true} if the other object is "equal to" this object
|
||||
* otherwise {@code false}
|
||||
*/
|
||||
@Override
|
||||
|
@ -244,7 +244,7 @@ public final class OptionalInt {
|
||||
* </ul>
|
||||
*
|
||||
* @param obj an object to be tested for equality
|
||||
* @return {code true} if the other object is "equal to" this object
|
||||
* @return {@code true} if the other object is "equal to" this object
|
||||
* otherwise {@code false}
|
||||
*/
|
||||
@Override
|
||||
|
@ -244,7 +244,7 @@ public final class OptionalLong {
|
||||
* </ul>
|
||||
*
|
||||
* @param obj an object to be tested for equality
|
||||
* @return {code true} if the other object is "equal to" this object
|
||||
* @return {@code true} if the other object is "equal to" this object
|
||||
* otherwise {@code false}
|
||||
*/
|
||||
@Override
|
||||
|
@ -309,7 +309,7 @@ class Properties extends Hashtable<Object,Object> {
|
||||
* input stream.
|
||||
* @throws IllegalArgumentException if a malformed Unicode escape
|
||||
* appears in the input.
|
||||
* @throws NullPointerException if {@code reader} is null.
|
||||
* @throws NullPointerException if {@code reader} is null.
|
||||
* @since 1.6
|
||||
*/
|
||||
public synchronized void load(Reader reader) throws IOException {
|
||||
@ -335,7 +335,7 @@ class Properties extends Hashtable<Object,Object> {
|
||||
* input stream.
|
||||
* @throws IllegalArgumentException if the input stream contains a
|
||||
* malformed Unicode escape sequence.
|
||||
* @throws NullPointerException if {@code inStream} is null.
|
||||
* @throws NullPointerException if {@code inStream} is null.
|
||||
* @since 1.2
|
||||
*/
|
||||
public synchronized void load(InputStream inStream) throws IOException {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2015, 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
|
||||
@ -379,60 +379,6 @@ abstract class AbstractPipeline<E_IN, E_OUT, S extends BaseStream<E_OUT, S>>
|
||||
return StreamOpFlag.toStreamFlags(combinedFlags);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the pipeline for a parallel execution. As the pipeline is built,
|
||||
* the flags and depth indicators are set up for a sequential execution.
|
||||
* If the execution is parallel, and there are any stateful operations, then
|
||||
* some of these need to be adjusted, as well as adjusting for flags from
|
||||
* the terminal operation (such as back-propagating UNORDERED).
|
||||
* Need not be called for a sequential execution.
|
||||
*
|
||||
* @param terminalFlags Operation flags for the terminal operation
|
||||
*/
|
||||
private void parallelPrepare(int terminalFlags) {
|
||||
@SuppressWarnings("rawtypes")
|
||||
AbstractPipeline backPropagationHead = sourceStage;
|
||||
if (sourceStage.sourceAnyStateful) {
|
||||
int depth = 1;
|
||||
for ( @SuppressWarnings("rawtypes") AbstractPipeline u = sourceStage, p = sourceStage.nextStage;
|
||||
p != null;
|
||||
u = p, p = p.nextStage) {
|
||||
int thisOpFlags = p.sourceOrOpFlags;
|
||||
if (p.opIsStateful()) {
|
||||
// If the stateful operation is a short-circuit operation
|
||||
// then move the back propagation head forwards
|
||||
// NOTE: there are no size-injecting ops
|
||||
if (StreamOpFlag.SHORT_CIRCUIT.isKnown(thisOpFlags)) {
|
||||
backPropagationHead = p;
|
||||
// Clear the short circuit flag for next pipeline stage
|
||||
// This stage encapsulates short-circuiting, the next
|
||||
// stage may not have any short-circuit operations, and
|
||||
// if so spliterator.forEachRemaining should be used
|
||||
// for traversal
|
||||
thisOpFlags = thisOpFlags & ~StreamOpFlag.IS_SHORT_CIRCUIT;
|
||||
}
|
||||
|
||||
depth = 0;
|
||||
// The following injects size, it is equivalent to:
|
||||
// StreamOpFlag.combineOpFlags(StreamOpFlag.IS_SIZED, p.combinedFlags);
|
||||
thisOpFlags = (thisOpFlags & ~StreamOpFlag.NOT_SIZED) | StreamOpFlag.IS_SIZED;
|
||||
}
|
||||
p.depth = depth++;
|
||||
p.combinedFlags = StreamOpFlag.combineOpFlags(thisOpFlags, u.combinedFlags);
|
||||
}
|
||||
}
|
||||
|
||||
// Apply the upstream terminal flags
|
||||
if (terminalFlags != 0) {
|
||||
int upstreamTerminalFlags = terminalFlags & StreamOpFlag.UPSTREAM_TERMINAL_OP_MASK;
|
||||
for ( @SuppressWarnings("rawtypes") AbstractPipeline p = backPropagationHead; p.nextStage != null; p = p.nextStage) {
|
||||
p.combinedFlags = StreamOpFlag.combineOpFlags(upstreamTerminalFlags, p.combinedFlags);
|
||||
}
|
||||
|
||||
combinedFlags = StreamOpFlag.combineOpFlags(terminalFlags, combinedFlags);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the source spliterator for this pipeline stage. For a sequential or
|
||||
* stateless parallel pipeline, this is the source spliterator. For a
|
||||
@ -456,24 +402,70 @@ abstract class AbstractPipeline<E_IN, E_OUT, S extends BaseStream<E_OUT, S>>
|
||||
throw new IllegalStateException(MSG_CONSUMED);
|
||||
}
|
||||
|
||||
if (isParallel()) {
|
||||
// @@@ Merge parallelPrepare with the loop below and use the
|
||||
// spliterator characteristics to determine if SIZED
|
||||
// should be injected
|
||||
parallelPrepare(terminalFlags);
|
||||
boolean hasTerminalFlags = terminalFlags != 0;
|
||||
if (isParallel() && sourceStage.sourceAnyStateful) {
|
||||
// Adjust pipeline stages if there are stateful ops,
|
||||
// and find the last short circuiting op, if any, that
|
||||
// defines the head stage for back-propagation of terminal flags
|
||||
@SuppressWarnings("rawtypes")
|
||||
AbstractPipeline backPropagationHead = sourceStage;
|
||||
int depth = 1;
|
||||
for (@SuppressWarnings("rawtypes") AbstractPipeline p = sourceStage.nextStage;
|
||||
p != null;
|
||||
p = p.nextStage) {
|
||||
if (p.opIsStateful()) {
|
||||
if (StreamOpFlag.SHORT_CIRCUIT.isKnown(p.sourceOrOpFlags)) {
|
||||
// If the stateful operation is a short-circuit operation
|
||||
// then move the back propagation head forwards
|
||||
// NOTE: there are no size-injecting ops
|
||||
backPropagationHead = p;
|
||||
}
|
||||
|
||||
depth = 0;
|
||||
}
|
||||
p.depth = depth++;
|
||||
}
|
||||
|
||||
// Adapt the source spliterator, evaluating each stateful op
|
||||
// in the pipeline up to and including this pipeline stage
|
||||
for ( @SuppressWarnings("rawtypes") AbstractPipeline u = sourceStage, p = sourceStage.nextStage, e = this;
|
||||
// Flags for each pipeline stage are adjusted accordingly
|
||||
boolean backPropagate = false;
|
||||
int upstreamTerminalFlags = terminalFlags & StreamOpFlag.UPSTREAM_TERMINAL_OP_MASK;
|
||||
for (@SuppressWarnings("rawtypes") AbstractPipeline u = sourceStage, p = sourceStage.nextStage, e = this;
|
||||
u != e;
|
||||
u = p, p = p.nextStage) {
|
||||
|
||||
if (p.opIsStateful()) {
|
||||
spliterator = p.opEvaluateParallelLazy(u, spliterator);
|
||||
if (hasTerminalFlags &&
|
||||
(backPropagate || (backPropagate = (u == backPropagationHead)))) {
|
||||
// Back-propagate flags from the terminal operation
|
||||
u.combinedFlags = StreamOpFlag.combineOpFlags(upstreamTerminalFlags, u.combinedFlags);
|
||||
}
|
||||
|
||||
int thisOpFlags = p.sourceOrOpFlags;
|
||||
if (p.opIsStateful()) {
|
||||
if (StreamOpFlag.SHORT_CIRCUIT.isKnown(thisOpFlags)) {
|
||||
// Clear the short circuit flag for next pipeline stage
|
||||
// This stage encapsulates short-circuiting, the next
|
||||
// stage may not have any short-circuit operations, and
|
||||
// if so spliterator.forEachRemaining should be used
|
||||
// for traversal
|
||||
thisOpFlags = thisOpFlags & ~StreamOpFlag.IS_SHORT_CIRCUIT;
|
||||
}
|
||||
|
||||
spliterator = p.opEvaluateParallelLazy(u, spliterator);
|
||||
|
||||
// Inject or clear SIZED on the source pipeline stage
|
||||
// based on the stage's spliterator
|
||||
thisOpFlags = spliterator.hasCharacteristics(Spliterator.SIZED)
|
||||
? (thisOpFlags & ~StreamOpFlag.NOT_SIZED) | StreamOpFlag.IS_SIZED
|
||||
: (thisOpFlags & ~StreamOpFlag.IS_SIZED) | StreamOpFlag.NOT_SIZED;
|
||||
}
|
||||
p.combinedFlags = StreamOpFlag.combineOpFlags(thisOpFlags, u.combinedFlags);
|
||||
}
|
||||
}
|
||||
else if (terminalFlags != 0) {
|
||||
|
||||
if (hasTerminalFlags) {
|
||||
// Apply flags from the terminal operation to last pipeline stage
|
||||
combinedFlags = StreamOpFlag.combineOpFlags(terminalFlags, combinedFlags);
|
||||
}
|
||||
|
||||
|
@ -264,6 +264,11 @@ final class ReduceOps {
|
||||
return spliterator.getExactSizeIfKnown();
|
||||
return super.evaluateParallel(helper, spliterator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpFlags() {
|
||||
return StreamOpFlag.NOT_ORDERED;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -433,6 +438,11 @@ final class ReduceOps {
|
||||
return spliterator.getExactSizeIfKnown();
|
||||
return super.evaluateParallel(helper, spliterator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpFlags() {
|
||||
return StreamOpFlag.NOT_ORDERED;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -602,6 +612,11 @@ final class ReduceOps {
|
||||
return spliterator.getExactSizeIfKnown();
|
||||
return super.evaluateParallel(helper, spliterator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpFlags() {
|
||||
return StreamOpFlag.NOT_ORDERED;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -771,6 +786,11 @@ final class ReduceOps {
|
||||
return spliterator.getExactSizeIfKnown();
|
||||
return super.evaluateParallel(helper, spliterator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpFlags() {
|
||||
return StreamOpFlag.NOT_ORDERED;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -261,27 +261,6 @@ public abstract class AbstractDelegateHttpsURLConnection extends
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the server's X.509 certificate chain, or null if
|
||||
* the server did not authenticate.
|
||||
*
|
||||
* @deprecated This method returns the deprecated
|
||||
* {@code javax.security.cert.X509Certificate} type.
|
||||
* Use {@code getServerCertificates()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public javax.security.cert.X509Certificate[] getServerCertificateChain()
|
||||
throws SSLPeerUnverifiedException {
|
||||
if (cachedResponse != null) {
|
||||
throw new UnsupportedOperationException("this method is not supported when using cache");
|
||||
}
|
||||
if (http == null) {
|
||||
throw new IllegalStateException("connection not yet open");
|
||||
} else {
|
||||
return ((HttpsClient)http).getServerCertificateChain();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the server's principal, or throws SSLPeerUnverifiedException
|
||||
* if the server did not authenticate.
|
||||
|
@ -696,21 +696,6 @@ final class HttpsClient extends HttpClient
|
||||
return session.getPeerCertificates();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the X.509 certificate chain with which the server
|
||||
* authenticated itself, or null if the server did not authenticate.
|
||||
*
|
||||
* @deprecated This method returns the deprecated
|
||||
* {@code javax.security.cert.X509Certificate} type.
|
||||
* Use {@code getServerCertificates()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
javax.security.cert.X509Certificate [] getServerCertificateChain()
|
||||
throws SSLPeerUnverifiedException
|
||||
{
|
||||
return session.getPeerCertificateChain();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the principal with which the server authenticated
|
||||
* itself, or throw a SSLPeerUnverifiedException if the
|
||||
|
@ -197,30 +197,6 @@ public class HttpsURLConnectionImpl
|
||||
return delegate.getServerCertificates();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the server's X.509 certificate chain, or null if
|
||||
* the server did not authenticate.
|
||||
*
|
||||
* NOTE: This method is not necessary for the version of this class
|
||||
* implementing javax.net.ssl.HttpsURLConnection, but provided for
|
||||
* compatibility with the com.sun.net.ssl.HttpsURLConnection version.
|
||||
*
|
||||
* @deprecated This method returns the deprecated
|
||||
* {@code javax.security.cert.X509Certificate} type.
|
||||
* Use {@code getServerCertificates()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public javax.security.cert.X509Certificate[] getServerCertificateChain() {
|
||||
try {
|
||||
return delegate.getServerCertificateChain();
|
||||
} catch (SSLPeerUnverifiedException e) {
|
||||
// this method does not throw an exception as declared in
|
||||
// com.sun.net.ssl.HttpsURLConnection.
|
||||
// Return null for compatibility.
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the principal with which the server authenticated itself,
|
||||
* or throw a SSLPeerUnverifiedException if the server did not authenticate.
|
||||
|
@ -290,8 +290,9 @@ public class PKCS10 {
|
||||
throw new SignatureException("Cert request was not signed");
|
||||
|
||||
|
||||
byte[] CRLF = new byte[] {'\r', '\n'};
|
||||
out.println("-----BEGIN NEW CERTIFICATE REQUEST-----");
|
||||
out.println(Base64.getMimeEncoder().encodeToString(encoded));
|
||||
out.println(Base64.getMimeEncoder(64, CRLF).encodeToString(encoded));
|
||||
out.println("-----END NEW CERTIFICATE REQUEST-----");
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,8 @@ package sun.security.provider;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.security.cert.*;
|
||||
|
||||
import sun.security.util.Pem;
|
||||
import sun.security.x509.X509CertImpl;
|
||||
import sun.security.x509.X509CRLImpl;
|
||||
import sun.security.pkcs.PKCS7;
|
||||
@ -633,7 +635,7 @@ public class X509Factory extends CertificateFactorySpi {
|
||||
|
||||
checkHeaderFooter(header.toString(), footer.toString());
|
||||
|
||||
return Base64.getMimeDecoder().decode(new String(data, 0, pos));
|
||||
return Pem.decode(new String(data, 0, pos));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,6 +80,7 @@ import sun.security.pkcs.PKCS9Attribute;
|
||||
import sun.security.tools.KeyStoreUtil;
|
||||
import sun.security.tools.PathList;
|
||||
import sun.security.util.DerValue;
|
||||
import sun.security.util.Pem;
|
||||
import sun.security.x509.*;
|
||||
|
||||
import static java.security.KeyStore.*;
|
||||
@ -100,6 +101,8 @@ import static sun.security.tools.keytool.Main.Option.*;
|
||||
*/
|
||||
public final class Main {
|
||||
|
||||
private static final byte[] CRLF = new byte[] {'\r', '\n'};
|
||||
|
||||
private boolean debug = false;
|
||||
private Command command = null;
|
||||
private String sigAlgName = null;
|
||||
@ -1266,7 +1269,7 @@ public final class Main {
|
||||
sb.append(s);
|
||||
}
|
||||
}
|
||||
byte[] rawReq = Base64.getMimeDecoder().decode(new String(sb));
|
||||
byte[] rawReq = Pem.decode(new String(sb));
|
||||
PKCS10 req = new PKCS10(rawReq);
|
||||
|
||||
info.set(X509CertInfo.KEY, new CertificateX509Key(req.getSubjectPublicKeyInfo()));
|
||||
@ -1343,7 +1346,7 @@ public final class Main {
|
||||
crl.sign(privateKey, sigAlgName);
|
||||
if (rfc) {
|
||||
out.println("-----BEGIN X509 CRL-----");
|
||||
out.println(Base64.getMimeEncoder().encodeToString(crl.getEncodedInternal()));
|
||||
out.println(Base64.getMimeEncoder(64, CRLF).encodeToString(crl.getEncodedInternal()));
|
||||
out.println("-----END X509 CRL-----");
|
||||
} else {
|
||||
out.write(crl.getEncodedInternal());
|
||||
@ -2304,7 +2307,7 @@ public final class Main {
|
||||
if (rfc) {
|
||||
X509CRL xcrl = (X509CRL)crl;
|
||||
out.println("-----BEGIN X509 CRL-----");
|
||||
out.println(Base64.getMimeEncoder().encodeToString(xcrl.getEncoded()));
|
||||
out.println(Base64.getMimeEncoder(64, CRLF).encodeToString(xcrl.getEncoded()));
|
||||
out.println("-----END X509 CRL-----");
|
||||
} else {
|
||||
out.println(crl.toString());
|
||||
@ -2331,7 +2334,7 @@ public final class Main {
|
||||
sb.append(s);
|
||||
}
|
||||
}
|
||||
PKCS10 req = new PKCS10(Base64.getMimeDecoder().decode(new String(sb)));
|
||||
PKCS10 req = new PKCS10(Pem.decode(new String(sb)));
|
||||
|
||||
PublicKey pkey = req.getSubjectPublicKeyInfo();
|
||||
out.printf(rb.getString("PKCS.10.Certificate.Request.Version.1.0.Subject.s.Public.Key.s.format.s.key."),
|
||||
@ -3115,7 +3118,7 @@ public final class Main {
|
||||
{
|
||||
if (rfc) {
|
||||
out.println(X509Factory.BEGIN_CERT);
|
||||
out.println(Base64.getMimeEncoder().encodeToString(cert.getEncoded()));
|
||||
out.println(Base64.getMimeEncoder(64, CRLF).encodeToString(cert.getEncoded()));
|
||||
out.println(X509Factory.END_CERT);
|
||||
} else {
|
||||
out.write(cert.getEncoded()); // binary
|
||||
|
52
jdk/src/java.base/share/classes/sun/security/util/Pem.java
Normal file
52
jdk/src/java.base/share/classes/sun/security/util/Pem.java
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 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. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package sun.security.util;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Base64;
|
||||
|
||||
/**
|
||||
* The Length interface defines the length of an object
|
||||
*/
|
||||
public class Pem {
|
||||
|
||||
/**
|
||||
* Decodes a PEM-encoded block.
|
||||
*
|
||||
* @param input the input string, according to RFC 1421, can only contain
|
||||
* characters in the base-64 alphabet and whitespaces.
|
||||
* @return the decoded bytes
|
||||
* @throws java.io.IOException if input is invalid
|
||||
*/
|
||||
public static byte[] decode(String input) throws IOException {
|
||||
byte[] src = input.replaceAll("\\s+", "").getBytes();
|
||||
try {
|
||||
return Base64.getDecoder().decode(src);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
}
|
||||
}
|
@ -271,7 +271,7 @@ public class X509CertImpl extends X509Certificate implements DerEncoder {
|
||||
der = new DerValue(decstream.toByteArray());
|
||||
break;
|
||||
} else {
|
||||
decstream.write(Base64.getMimeDecoder().decode(line));
|
||||
decstream.write(Pem.decode(line));
|
||||
}
|
||||
}
|
||||
} catch (IOException ioe2) {
|
||||
|
@ -496,12 +496,11 @@ final class ProcessImpl extends Process {
|
||||
public synchronized boolean waitFor(long timeout, TimeUnit unit)
|
||||
throws InterruptedException
|
||||
{
|
||||
long remainingNanos = unit.toNanos(timeout); // throw NPE before other conditions
|
||||
if (hasExited) return true;
|
||||
if (timeout <= 0) return false;
|
||||
|
||||
long remainingNanos = unit.toNanos(timeout);
|
||||
long deadline = System.nanoTime() + remainingNanos;
|
||||
|
||||
do {
|
||||
// Round up to next millisecond
|
||||
wait(TimeUnit.NANOSECONDS.toMillis(remainingNanos + 999_999L));
|
||||
|
@ -458,12 +458,11 @@ final class ProcessImpl extends Process {
|
||||
public boolean waitFor(long timeout, TimeUnit unit)
|
||||
throws InterruptedException
|
||||
{
|
||||
long remainingNanos = unit.toNanos(timeout); // throw NPE before other conditions
|
||||
if (getExitCodeProcess(handle) != STILL_ACTIVE) return true;
|
||||
if (timeout <= 0) return false;
|
||||
|
||||
long remainingNanos = unit.toNanos(timeout);
|
||||
long deadline = System.nanoTime() + remainingNanos ;
|
||||
|
||||
do {
|
||||
// Round up to next millisecond
|
||||
long msTimeout = TimeUnit.NANOSECONDS.toMillis(remainingNanos + 999_999L);
|
||||
|
@ -31,7 +31,7 @@ import javax.management.DynamicMBean;
|
||||
/**
|
||||
* Management interface for the diagnostic commands for the HotSpot Virtual Machine.
|
||||
*
|
||||
* <p>The {code DiagnosticCommandMBean} is registered to the
|
||||
* <p>The {@code DiagnosticCommandMBean} is registered to the
|
||||
* {@linkplain java.lang.management.ManagementFactory#getPlatformMBeanServer
|
||||
* platform MBeanServer} as are other platform MBeans.
|
||||
*
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
#include "jni.h"
|
||||
#include "jni_util.h"
|
||||
#include "jvm.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -184,15 +185,26 @@ JNIEXPORT void JNICALL Java_sun_tools_attach_VirtualMachineImpl_checkPermissions
|
||||
res = errno;
|
||||
}
|
||||
|
||||
/* release p here before we throw an I/O exception */
|
||||
if (isCopy) {
|
||||
JNU_ReleaseStringPlatformChars(env, path, p);
|
||||
}
|
||||
|
||||
if (res == 0) {
|
||||
if ( (sb.st_uid != uid) || (sb.st_gid != gid) ||
|
||||
((sb.st_mode & (S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)) != 0) ) {
|
||||
JNU_ThrowIOException(env, "well-known file is not secure");
|
||||
char msg[100];
|
||||
jboolean isError = JNI_FALSE;
|
||||
if (sb.st_uid != uid) {
|
||||
jio_snprintf(msg, sizeof(msg)-1,
|
||||
"file should be owned by the current user (which is %d) but is owned by %d", uid, sb.st_uid);
|
||||
isError = JNI_TRUE;
|
||||
} else if (sb.st_gid != gid) {
|
||||
jio_snprintf(msg, sizeof(msg)-1,
|
||||
"file's group should be the current group (which is %d) but the group is %d", gid, sb.st_gid);
|
||||
isError = JNI_TRUE;
|
||||
} else if ((sb.st_mode & (S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)) != 0) {
|
||||
jio_snprintf(msg, sizeof(msg)-1,
|
||||
"file should only be readable and writable by the owner but has 0%03o access", sb.st_mode & 0777);
|
||||
isError = JNI_TRUE;
|
||||
}
|
||||
if (isError) {
|
||||
char buf[256];
|
||||
jio_snprintf(buf, sizeof(buf)-1, "well-known file %s is not secure: %s", p, msg);
|
||||
JNU_ThrowIOException(env, buf);
|
||||
}
|
||||
} else {
|
||||
char* msg = strdup(strerror(res));
|
||||
@ -201,6 +213,10 @@ JNIEXPORT void JNICALL Java_sun_tools_attach_VirtualMachineImpl_checkPermissions
|
||||
free(msg);
|
||||
}
|
||||
}
|
||||
|
||||
if (isCopy) {
|
||||
JNU_ReleaseStringPlatformChars(env, path, p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#include "jni.h"
|
||||
#include "jni_util.h"
|
||||
#include "jvm.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -369,15 +370,26 @@ JNIEXPORT void JNICALL Java_sun_tools_attach_VirtualMachineImpl_checkPermissions
|
||||
res = errno;
|
||||
}
|
||||
|
||||
/* release p here before we throw an I/O exception */
|
||||
if (isCopy) {
|
||||
JNU_ReleaseStringPlatformChars(env, path, p);
|
||||
}
|
||||
|
||||
if (res == 0) {
|
||||
if ( (sb.st_uid != uid) || (sb.st_gid != gid) ||
|
||||
((sb.st_mode & (S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)) != 0) ) {
|
||||
JNU_ThrowIOException(env, "well-known file is not secure");
|
||||
char msg[100];
|
||||
jboolean isError = JNI_FALSE;
|
||||
if (sb.st_uid != uid) {
|
||||
jio_snprintf(msg, sizeof(msg)-1,
|
||||
"file should be owned by the current user (which is %d) but is owned by %d", uid, sb.st_uid);
|
||||
isError = JNI_TRUE;
|
||||
} else if (sb.st_gid != gid) {
|
||||
jio_snprintf(msg, sizeof(msg)-1,
|
||||
"file's group should be the current group (which is %d) but the group is %d", gid, sb.st_gid);
|
||||
isError = JNI_TRUE;
|
||||
} else if ((sb.st_mode & (S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)) != 0) {
|
||||
jio_snprintf(msg, sizeof(msg)-1,
|
||||
"file should only be readable and writable by the owner but has 0%03o access", sb.st_mode & 0777);
|
||||
isError = JNI_TRUE;
|
||||
}
|
||||
if (isError) {
|
||||
char buf[256];
|
||||
jio_snprintf(buf, sizeof(buf)-1, "well-known file %s is not secure: %s", p, msg);
|
||||
JNU_ThrowIOException(env, buf);
|
||||
}
|
||||
} else {
|
||||
char* msg = strdup(strerror(res));
|
||||
@ -386,6 +398,10 @@ JNIEXPORT void JNICALL Java_sun_tools_attach_VirtualMachineImpl_checkPermissions
|
||||
free(msg);
|
||||
}
|
||||
}
|
||||
|
||||
if (isCopy) {
|
||||
JNU_ReleaseStringPlatformChars(env, path, p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#include "jni.h"
|
||||
#include "jni_util.h"
|
||||
#include "jvm.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -151,15 +152,26 @@ JNIEXPORT void JNICALL Java_sun_tools_attach_VirtualMachineImpl_checkPermissions
|
||||
res = errno;
|
||||
}
|
||||
|
||||
/* release p here before we throw an I/O exception */
|
||||
if (isCopy) {
|
||||
JNU_ReleaseStringPlatformChars(env, path, p);
|
||||
}
|
||||
|
||||
if (res == 0) {
|
||||
if ( (sb.st_uid != uid) || (sb.st_gid != gid) ||
|
||||
((sb.st_mode & (S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)) != 0) ) {
|
||||
JNU_ThrowIOException(env, "well-known file is not secure");
|
||||
char msg[100];
|
||||
jboolean isError = JNI_FALSE;
|
||||
if (sb.st_uid != uid) {
|
||||
jio_snprintf(msg, sizeof(msg)-1,
|
||||
"file should be owned by the current user (which is %d) but is owned by %d", uid, sb.st_uid);
|
||||
isError = JNI_TRUE;
|
||||
} else if (sb.st_gid != gid) {
|
||||
jio_snprintf(msg, sizeof(msg)-1,
|
||||
"file's group should be the current group (which is %d) but the group is %d", gid, sb.st_gid);
|
||||
isError = JNI_TRUE;
|
||||
} else if ((sb.st_mode & (S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)) != 0) {
|
||||
jio_snprintf(msg, sizeof(msg)-1,
|
||||
"file should only be readable and writable by the owner but has 0%03o access", sb.st_mode & 0777);
|
||||
isError = JNI_TRUE;
|
||||
}
|
||||
if (isError) {
|
||||
char buf[256];
|
||||
jio_snprintf(buf, sizeof(buf)-1, "well-known file %s is not secure: %s", p, msg);
|
||||
JNU_ThrowIOException(env, buf);
|
||||
}
|
||||
} else {
|
||||
char* msg = strdup(strerror(res));
|
||||
@ -168,6 +180,10 @@ JNIEXPORT void JNICALL Java_sun_tools_attach_VirtualMachineImpl_checkPermissions
|
||||
free(msg);
|
||||
}
|
||||
}
|
||||
|
||||
if (isCopy) {
|
||||
JNU_ReleaseStringPlatformChars(env, path, p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,7 @@
|
||||
|
||||
#include "jni.h"
|
||||
#include "jni_util.h"
|
||||
#include "jvm.h"
|
||||
|
||||
#include "sun_tools_attach_VirtualMachineImpl.h"
|
||||
|
||||
@ -112,15 +113,26 @@ JNIEXPORT void JNICALL Java_sun_tools_attach_VirtualMachineImpl_checkPermissions
|
||||
res = errno;
|
||||
}
|
||||
|
||||
/* release p here before we throw an I/O exception */
|
||||
if (isCopy) {
|
||||
JNU_ReleaseStringPlatformChars(env, path, p);
|
||||
}
|
||||
|
||||
if (res == 0) {
|
||||
if ( (sb.st_uid != uid) || (sb.st_gid != gid) ||
|
||||
((sb.st_mode & (S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)) != 0) ) {
|
||||
JNU_ThrowIOException(env, "well-known file is not secure");
|
||||
char msg[100];
|
||||
jboolean isError = JNI_FALSE;
|
||||
if (sb.st_uid != uid) {
|
||||
jio_snprintf(msg, sizeof(msg)-1,
|
||||
"file should be owned by the current user (which is %d) but is owned by %d", uid, sb.st_uid);
|
||||
isError = JNI_TRUE;
|
||||
} else if (sb.st_gid != gid) {
|
||||
jio_snprintf(msg, sizeof(msg)-1,
|
||||
"file's group should be the current group (which is %d) but the group is %d", gid, sb.st_gid);
|
||||
isError = JNI_TRUE;
|
||||
} else if ((sb.st_mode & (S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)) != 0) {
|
||||
jio_snprintf(msg, sizeof(msg)-1,
|
||||
"file should only be readable and writable by the owner but has 0%03o access", sb.st_mode & 0777);
|
||||
isError = JNI_TRUE;
|
||||
}
|
||||
if (isError) {
|
||||
char buf[256];
|
||||
jio_snprintf(buf, sizeof(buf)-1, "well-known file %s is not secure: %s", p, msg);
|
||||
JNU_ThrowIOException(env, buf);
|
||||
}
|
||||
} else {
|
||||
char* msg = strdup(strerror(res));
|
||||
@ -129,6 +141,10 @@ JNIEXPORT void JNICALL Java_sun_tools_attach_VirtualMachineImpl_checkPermissions
|
||||
free(msg);
|
||||
}
|
||||
}
|
||||
|
||||
if (isCopy) {
|
||||
JNU_ReleaseStringPlatformChars(env, path, p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2015, 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
|
||||
@ -142,7 +142,7 @@ public class FormatData_de extends ParallelListResourceBundle {
|
||||
new String[] {
|
||||
"Jan", // abb january
|
||||
"Feb", // abb february
|
||||
"Mrz", // abb march
|
||||
"M\u00e4r", // abb march
|
||||
"Apr", // abb april
|
||||
"Mai", // abb may
|
||||
"Jun", // abb june
|
||||
|
@ -63,7 +63,7 @@ struct bytes {
|
||||
bytes res;
|
||||
res.ptr = ptr + beg;
|
||||
res.len = end - beg;
|
||||
assert(res.len == 0 || inBounds(res.ptr) && inBounds(res.limit()-1));
|
||||
assert(res.len == 0 || (inBounds(res.ptr) && inBounds(res.limit()-1)));
|
||||
return res;
|
||||
}
|
||||
// building C strings inside byte buffers:
|
||||
|
@ -225,9 +225,9 @@ struct entry {
|
||||
}
|
||||
|
||||
#ifdef PRODUCT
|
||||
char* string() { return 0; }
|
||||
const char* string() { return NULL; }
|
||||
#else
|
||||
char* string(); // see far below
|
||||
const char* string(); // see far below
|
||||
#endif
|
||||
};
|
||||
|
||||
@ -718,13 +718,13 @@ void unpacker::read_file_header() {
|
||||
// Now we can size the whole archive.
|
||||
// Read everything else into a mega-buffer.
|
||||
rp = hdr.rp;
|
||||
int header_size_0 = (int)(rp - input.base()); // used-up header (4byte + 3int)
|
||||
int header_size_1 = (int)(rplimit - rp); // buffered unused initial fragment
|
||||
int header_size = header_size_0+header_size_1;
|
||||
size_t header_size_0 = (rp - input.base()); // used-up header (4byte + 3int)
|
||||
size_t header_size_1 = (rplimit - rp); // buffered unused initial fragment
|
||||
size_t header_size = header_size_0 + header_size_1;
|
||||
unsized_bytes_read = header_size_0;
|
||||
CHECK;
|
||||
if (foreign_buf) {
|
||||
if (archive_size > (size_t)header_size_1) {
|
||||
if (archive_size > header_size_1) {
|
||||
abort("EOF reading fixed input buffer");
|
||||
return;
|
||||
}
|
||||
@ -738,7 +738,7 @@ void unpacker::read_file_header() {
|
||||
return;
|
||||
}
|
||||
input.set(U_NEW(byte, add_size(header_size_0, archive_size, C_SLOP)),
|
||||
(size_t) header_size_0 + archive_size);
|
||||
header_size_0 + archive_size);
|
||||
CHECK;
|
||||
assert(input.limit()[0] == 0);
|
||||
// Move all the bytes we read initially into the real buffer.
|
||||
@ -961,13 +961,13 @@ void cpool::init(unpacker* u_, int counts[CONSTANT_Limit]) {
|
||||
nentries = next_entry;
|
||||
|
||||
// place a limit on future CP growth:
|
||||
int generous = 0;
|
||||
size_t generous = 0;
|
||||
generous = add_size(generous, u->ic_count); // implicit name
|
||||
generous = add_size(generous, u->ic_count); // outer
|
||||
generous = add_size(generous, u->ic_count); // outer.utf8
|
||||
generous = add_size(generous, 40); // WKUs, misc
|
||||
generous = add_size(generous, u->class_count); // implicit SourceFile strings
|
||||
maxentries = add_size(nentries, generous);
|
||||
maxentries = (uint)add_size(nentries, generous);
|
||||
|
||||
// Note that this CP does not include "empty" entries
|
||||
// for longs and doubles. Those are introduced when
|
||||
@ -985,8 +985,9 @@ void cpool::init(unpacker* u_, int counts[CONSTANT_Limit]) {
|
||||
}
|
||||
|
||||
// Initialize *all* our entries once
|
||||
for (int i = 0 ; i < maxentries ; i++)
|
||||
for (uint i = 0 ; i < maxentries ; i++) {
|
||||
entries[i].outputIndex = REQUESTED_NONE;
|
||||
}
|
||||
|
||||
initGroupIndexes();
|
||||
// Initialize hashTab to a generous power-of-two size.
|
||||
@ -3680,21 +3681,22 @@ void cpool::computeOutputIndexes() {
|
||||
|
||||
unpacker* debug_u;
|
||||
|
||||
static bytes& getbuf(int len) { // for debugging only!
|
||||
static bytes& getbuf(size_t len) { // for debugging only!
|
||||
static int bn = 0;
|
||||
static bytes bufs[8];
|
||||
bytes& buf = bufs[bn++ & 7];
|
||||
while ((int)buf.len < len+10)
|
||||
while (buf.len < len + 10) {
|
||||
buf.realloc(buf.len ? buf.len * 2 : 1000);
|
||||
}
|
||||
buf.ptr[0] = 0; // for the sake of strcat
|
||||
return buf;
|
||||
}
|
||||
|
||||
char* entry::string() {
|
||||
const char* entry::string() {
|
||||
bytes buf;
|
||||
switch (tag) {
|
||||
case CONSTANT_None:
|
||||
return (char*)"<empty>";
|
||||
return "<empty>";
|
||||
case CONSTANT_Signature:
|
||||
if (value.b.ptr == null)
|
||||
return ref(0)->string();
|
||||
@ -3714,26 +3716,28 @@ char* entry::string() {
|
||||
break;
|
||||
default:
|
||||
if (nrefs == 0) {
|
||||
buf = getbuf(20);
|
||||
sprintf((char*)buf.ptr, TAG_NAME[tag]);
|
||||
return TAG_NAME[tag];
|
||||
} else if (nrefs == 1) {
|
||||
return refs[0]->string();
|
||||
} else {
|
||||
char* s1 = refs[0]->string();
|
||||
char* s2 = refs[1]->string();
|
||||
buf = getbuf((int)strlen(s1) + 1 + (int)strlen(s2) + 4 + 1);
|
||||
const char* s1 = refs[0]->string();
|
||||
const char* s2 = refs[1]->string();
|
||||
buf = getbuf(strlen(s1) + 1 + strlen(s2) + 4 + 1);
|
||||
buf.strcat(s1).strcat(" ").strcat(s2);
|
||||
if (nrefs > 2) buf.strcat(" ...");
|
||||
}
|
||||
}
|
||||
return (char*)buf.ptr;
|
||||
return (const char*)buf.ptr;
|
||||
}
|
||||
|
||||
void print_cp_entry(int i) {
|
||||
entry& e = debug_u->cp.entries[i];
|
||||
char buf[30];
|
||||
sprintf(buf, ((uint)e.tag < CONSTANT_Limit)? TAG_NAME[e.tag]: "%d", e.tag);
|
||||
printf(" %d\t%s %s\n", i, buf, e.string());
|
||||
|
||||
if ((uint)e.tag < CONSTANT_Limit) {
|
||||
printf(" %d\t%s %s\n", i, TAG_NAME[e.tag], e.string());
|
||||
} else {
|
||||
printf(" %d\t%d %s\n", i, e.tag, e.string());
|
||||
}
|
||||
}
|
||||
|
||||
void print_cp_entries(int beg, int end) {
|
||||
|
@ -210,7 +210,7 @@ struct unpacker {
|
||||
byte* rp; // read pointer (< rplimit <= input.limit())
|
||||
byte* rplimit; // how much of the input block has been read?
|
||||
julong bytes_read;
|
||||
int unsized_bytes_read;
|
||||
size_t unsized_bytes_read;
|
||||
|
||||
// callback to read at least one byte, up to available input
|
||||
typedef jlong (*read_input_fn_t)(unpacker* self, void* buf, jlong minlen, jlong maxlen);
|
||||
|
@ -81,7 +81,7 @@ void breakpoint() { } // hook for debugger
|
||||
int assert_failed(const char* p) {
|
||||
char message[1<<12];
|
||||
sprintf(message, "@assert failed: %s\n", p);
|
||||
fprintf(stdout, 1+message);
|
||||
fprintf(stdout, "%s", 1+message);
|
||||
breakpoint();
|
||||
unpack_abort(message);
|
||||
return 0;
|
||||
|
@ -84,7 +84,7 @@ void jar::init(unpacker* u_) {
|
||||
}
|
||||
|
||||
// Write data to the ZIP output stream.
|
||||
void jar::write_data(void* buff, int len) {
|
||||
void jar::write_data(void* buff, size_t len) {
|
||||
while (len > 0) {
|
||||
int rc = (int)fwrite(buff, 1, len, jarfp);
|
||||
if (rc <= 0) {
|
||||
@ -323,12 +323,12 @@ void jar::write_central_directory() {
|
||||
// Total number of disks (int)
|
||||
header64[36] = (ushort)SWAP_BYTES(1);
|
||||
header64[37] = 0;
|
||||
write_data(header64, (int)sizeof(header64));
|
||||
write_data(header64, sizeof(header64));
|
||||
}
|
||||
|
||||
// Write the End of Central Directory structure.
|
||||
PRINTCR((2, "end-of-directory at %d\n", output_file_offset));
|
||||
write_data(header, (int)sizeof(header));
|
||||
write_data(header, sizeof(header));
|
||||
|
||||
PRINTCR((2, "writing zip comment\n"));
|
||||
// Write the comment.
|
||||
@ -590,7 +590,7 @@ void gunzip::init(unpacker* u_) {
|
||||
zstream = NEW(z_stream, 1);
|
||||
u->gzin = this;
|
||||
u->read_input_fn = read_input_via_gzip;
|
||||
u->gzcrc = crc32(0L, Z_NULL, 0);
|
||||
u->gzcrc = crc32(0, Z_NULL, 0);
|
||||
}
|
||||
|
||||
void gunzip::start(int magic) {
|
||||
|
@ -68,8 +68,8 @@ struct jar {
|
||||
}
|
||||
|
||||
// Private Methods
|
||||
void write_data(void* ptr, int len);
|
||||
void write_data(bytes& b) { write_data(b.ptr, (int)b.len); }
|
||||
void write_data(void* ptr, size_t len);
|
||||
void write_data(bytes& b) { write_data(b.ptr, b.len); }
|
||||
void add_to_jar_directory(const char* fname, bool store, int modtime,
|
||||
int len, int clen, uLong crc);
|
||||
void write_jar_header(const char* fname, bool store, int modtime,
|
||||
|
@ -292,7 +292,7 @@ Java_com_sun_java_util_jar_pack_NativeUnpack_getUnusedInput(JNIEnv *env, jobject
|
||||
|
||||
if (uPtr->aborting()) {
|
||||
THROW_IOE(uPtr->get_abort_message());
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
// We have fetched all the files.
|
||||
@ -310,7 +310,7 @@ Java_com_sun_java_util_jar_pack_NativeUnpack_getUnusedInput(JNIEnv *env, jobject
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_com_sun_java_util_jar_pack_NativeUnpack_finish(JNIEnv *env, jobject pObj) {
|
||||
unpacker* uPtr = get_unpacker(env, pObj, false);
|
||||
CHECK_EXCEPTION_RETURN_VALUE(uPtr, NULL);
|
||||
CHECK_EXCEPTION_RETURN_VALUE(uPtr, 0);
|
||||
size_t consumed = uPtr->input_consumed();
|
||||
free_unpacker(env, pObj, uPtr);
|
||||
return consumed;
|
||||
@ -320,6 +320,7 @@ JNIEXPORT jboolean JNICALL
|
||||
Java_com_sun_java_util_jar_pack_NativeUnpack_setOption(JNIEnv *env, jobject pObj,
|
||||
jstring pProp, jstring pValue) {
|
||||
unpacker* uPtr = get_unpacker(env, pObj);
|
||||
CHECK_EXCEPTION_RETURN_VALUE(uPtr, false);
|
||||
const char* prop = env->GetStringUTFChars(pProp, JNI_FALSE);
|
||||
CHECK_EXCEPTION_RETURN_VALUE(prop, false);
|
||||
const char* value = env->GetStringUTFChars(pValue, JNI_FALSE);
|
||||
|
@ -149,31 +149,28 @@ static const char* nbasename(const char* progname) {
|
||||
return progname;
|
||||
}
|
||||
|
||||
static const char* usage_lines[] = {
|
||||
"Usage: %s [-opt... | --option=value]... x.pack[.gz] y.jar\n",
|
||||
"\n",
|
||||
"Unpacking Options\n",
|
||||
" -H{h}, --deflate-hint={h} override transmitted deflate hint: true, false, or keep (default)\n",
|
||||
" -r, --remove-pack-file remove input file after unpacking\n",
|
||||
" -v, --verbose increase program verbosity\n",
|
||||
" -q, --quiet set verbosity to lowest level\n",
|
||||
" -l{F}, --log-file={F} output to the given log file, or '-' for standard output (default)\n",
|
||||
" -?, -h, --help print this message\n",
|
||||
" -V, --version print program version\n",
|
||||
" -J{X} Java VM argument (ignored)\n",
|
||||
null
|
||||
};
|
||||
#define USAGE_HEADER "Usage: %s [-opt... | --option=value]... x.pack[.gz] y.jar\n"
|
||||
#define USAGE_OPTIONS \
|
||||
"\n" \
|
||||
"Unpacking Options\n" \
|
||||
" -H{h}, --deflate-hint={h} override transmitted deflate hint: true, false, or keep (default)\n" \
|
||||
" -r, --remove-pack-file remove input file after unpacking\n" \
|
||||
" -v, --verbose increase program verbosity\n" \
|
||||
" -q, --quiet set verbosity to lowest level\n" \
|
||||
" -l{F}, --log-file={F} output to the given log file, or '-' for standard output (default)\n" \
|
||||
" -?, -h, --help print this message\n" \
|
||||
" -V, --version print program version\n" \
|
||||
" -J{X} Java VM argument (ignored)\n"
|
||||
|
||||
static void usage(unpacker* u, const char* progname, bool full = false) {
|
||||
// WinMain does not set argv[0] to the progrname
|
||||
progname = (progname != null) ? nbasename(progname) : "unpack200";
|
||||
for (int i = 0; usage_lines[i] != null; i++) {
|
||||
fprintf(u->errstrm, usage_lines[i], progname);
|
||||
if (!full) {
|
||||
fprintf(u->errstrm,
|
||||
"(For more information, run %s --help .)\n", progname);
|
||||
break;
|
||||
}
|
||||
|
||||
fprintf(u->errstrm, USAGE_HEADER, progname);
|
||||
if (full) {
|
||||
fprintf(u->errstrm, USAGE_OPTIONS);
|
||||
} else {
|
||||
fprintf(u->errstrm, "(For more information, run %s --help .)\n", progname);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -283,9 +283,6 @@ tools/launcher/FXLauncherTest.java linux-all
|
||||
|
||||
# jdk_jdi
|
||||
|
||||
# 6983531
|
||||
com/sun/jdi/BadHandshakeTest.java linux-all,windows-all
|
||||
|
||||
# 8004127
|
||||
com/sun/jdi/RedefineImplementor.sh generic-all
|
||||
|
||||
|
@ -38,7 +38,9 @@ tier2 = \
|
||||
:jdk_time \
|
||||
:jdk_security \
|
||||
:jdk_text \
|
||||
:core_tools
|
||||
:core_tools \
|
||||
:jdk_other \
|
||||
:jdk_svc
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
|
@ -21,22 +21,15 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/* @test
|
||||
* @bug 6306165 6432567
|
||||
* @summary Check that a bad handshake doesn't cause a debuggee to abort
|
||||
* @library /lib/testlibrary
|
||||
*
|
||||
* @build jdk.testlibrary.* VMConnection BadHandshakeTest Exit0
|
||||
* @run driver BadHandshakeTest
|
||||
*
|
||||
*/
|
||||
import java.net.Socket;
|
||||
import java.net.InetAddress;
|
||||
|
||||
import com.sun.jdi.Bootstrap;
|
||||
import com.sun.jdi.VirtualMachine;
|
||||
import com.sun.jdi.event.*;
|
||||
import com.sun.jdi.connect.Connector;
|
||||
import com.sun.jdi.connect.AttachingConnector;
|
||||
import com.sun.jdi.connect.Connector.Argument;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.util.Iterator;
|
||||
@ -46,13 +39,22 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import jdk.testlibrary.Utils;
|
||||
import jdk.testlibrary.ProcessTools;
|
||||
|
||||
/* @test
|
||||
* @bug 6306165 6432567
|
||||
* @summary Check that a bad handshake doesn't cause a debuggee to abort
|
||||
* @library /lib/testlibrary
|
||||
*
|
||||
* @build jdk.testlibrary.* VMConnection BadHandshakeTest Exit0
|
||||
* @run driver BadHandshakeTest
|
||||
*/
|
||||
public class BadHandshakeTest {
|
||||
|
||||
/*
|
||||
* Find a connector by name
|
||||
*/
|
||||
private static Connector findConnector(String name) {
|
||||
List connectors = Bootstrap.virtualMachineManager().allConnectors();
|
||||
Iterator iter = connectors.iterator();
|
||||
List<Connector> connectors = Bootstrap.virtualMachineManager().allConnectors();
|
||||
Iterator<Connector> iter = connectors.iterator();
|
||||
while (iter.hasNext()) {
|
||||
Connector connector = (Connector)iter.next();
|
||||
if (connector.name().equals(name)) {
|
||||
@ -65,7 +67,7 @@ public class BadHandshakeTest {
|
||||
/*
|
||||
* Launch a server debuggee with the given address
|
||||
*/
|
||||
private static Process launch(String address, String class_name) throws Exception {
|
||||
private static LaunchResult launch(String address, String class_name) throws Exception {
|
||||
String[] args = VMConnection.insertDebuggeeVMOptions(new String[] {
|
||||
"-agentlib:jdwp=transport=dt_socket" +
|
||||
",server=y" + ",suspend=y" + ",address=" + address,
|
||||
@ -75,6 +77,7 @@ public class BadHandshakeTest {
|
||||
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args);
|
||||
|
||||
final AtomicBoolean success = new AtomicBoolean();
|
||||
final AtomicBoolean bindFailed = new AtomicBoolean();
|
||||
Process p = ProcessTools.startProcess(
|
||||
class_name,
|
||||
pb,
|
||||
@ -83,13 +86,17 @@ public class BadHandshakeTest {
|
||||
// Listening for transport dt_socket at address: xxxxx
|
||||
// which shows the debuggee is ready to accept connections.
|
||||
success.set(line.contains("Listening for transport dt_socket at address:"));
|
||||
// If the first line contains 'Address already in use'
|
||||
// that means the debuggee has failed to start due to busy port
|
||||
bindFailed.set(line.contains("Address already in use"));
|
||||
return true;
|
||||
},
|
||||
Integer.MAX_VALUE,
|
||||
TimeUnit.MILLISECONDS
|
||||
);
|
||||
|
||||
return success.get() ? p : null;
|
||||
return new LaunchResult(success.get() ? p : null,
|
||||
bindFailed.get());
|
||||
}
|
||||
|
||||
/*
|
||||
@ -99,14 +106,20 @@ public class BadHandshakeTest {
|
||||
* - verify we saw no error
|
||||
*/
|
||||
public static void main(String args[]) throws Exception {
|
||||
int port = Utils.getFreePort();
|
||||
|
||||
String address = String.valueOf(port);
|
||||
|
||||
// launch the server debuggee
|
||||
Process process = launch(address, "Exit0");
|
||||
if (process == null) {
|
||||
throw new RuntimeException("Unable to start debugee");
|
||||
// Launch the server debuggee
|
||||
int port = 0;
|
||||
Process process = null;
|
||||
while (process == null) {
|
||||
port = Utils.getFreePort();
|
||||
String address = String.valueOf(port);
|
||||
LaunchResult launchResult = launch(address, "Exit0");
|
||||
process = launchResult.getProcess();
|
||||
if (launchResult.isBindFailed()) {
|
||||
System.out.println("Port " + port + " already in use. Trying to restart debuggee with a new one...");
|
||||
Thread.sleep(100);
|
||||
} else if (process == null ) {
|
||||
throw new RuntimeException("Unable to start debugee");
|
||||
}
|
||||
}
|
||||
|
||||
// Connect to the debuggee and handshake with garbage
|
||||
@ -119,9 +132,9 @@ public class BadHandshakeTest {
|
||||
s.getOutputStream().write("JDWP-".getBytes("UTF-8"));
|
||||
|
||||
|
||||
// attach to server debuggee and resume it so it can exit
|
||||
// Attach to server debuggee and resume it so it can exit
|
||||
AttachingConnector conn = (AttachingConnector)findConnector("com.sun.jdi.SocketAttach");
|
||||
Map conn_args = conn.defaultArguments();
|
||||
Map<String, Argument> conn_args = conn.defaultArguments();
|
||||
Connector.IntegerArgument port_arg =
|
||||
(Connector.IntegerArgument)conn_args.get("port");
|
||||
port_arg.setValue(port);
|
||||
@ -143,4 +156,24 @@ public class BadHandshakeTest {
|
||||
process.waitFor();
|
||||
}
|
||||
|
||||
private static class LaunchResult {
|
||||
|
||||
private final Process p;
|
||||
private final boolean bindFailed;
|
||||
|
||||
public LaunchResult(Process p, boolean bindFailed) {
|
||||
this.p = p;
|
||||
this.bindFailed = bindFailed;
|
||||
}
|
||||
|
||||
public Process getProcess() {
|
||||
return p;
|
||||
}
|
||||
|
||||
public boolean isBindFailed() {
|
||||
return bindFailed;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -43,11 +43,16 @@ public class SendFailed {
|
||||
|
||||
void test(String[] args) throws IOException {
|
||||
SocketAddress address = null;
|
||||
String os = System.getProperty("os.name").toLowerCase();
|
||||
|
||||
if (!Util.isSCTPSupported()) {
|
||||
out.println("SCTP protocol is not supported");
|
||||
out.println("Test cannot be run");
|
||||
return;
|
||||
} else if (os.startsWith("sunos")) {
|
||||
out.println("Test not supported on Solaris");
|
||||
out.println("Test cannot be run");
|
||||
return;
|
||||
}
|
||||
|
||||
System.out.println("remote address: " + remoteAddress);
|
||||
|
@ -27,6 +27,7 @@
|
||||
* 5026830 5023243 5070673 4052517 4811767 6192449 6397034 6413313
|
||||
* 6464154 6523983 6206031 4960438 6631352 6631966 6850957 6850958
|
||||
* 4947220 7018606 7034570 4244896 5049299 8003488 8054494 8058464
|
||||
* 8067796
|
||||
* @summary Basic tests for Process and Environment Variable code
|
||||
* @run main/othervm/timeout=300 Basic
|
||||
* @run main/othervm/timeout=300 -Djdk.lang.Process.launchMechanism=fork Basic
|
||||
@ -2386,6 +2387,56 @@ public class Basic {
|
||||
p.destroy();
|
||||
} catch (Throwable t) { unexpected(t); }
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// Check that Process.waitFor(timeout, null) throws NPE.
|
||||
//----------------------------------------------------------------
|
||||
try {
|
||||
List<String> childArgs = new ArrayList<String>(javaChildArgs);
|
||||
childArgs.add("sleep");
|
||||
final Process p = new ProcessBuilder(childArgs).start();
|
||||
THROWS(NullPointerException.class,
|
||||
() -> p.waitFor(10L, null));
|
||||
THROWS(NullPointerException.class,
|
||||
() -> p.waitFor(0L, null));
|
||||
THROWS(NullPointerException.class,
|
||||
() -> p.waitFor(-1L, null));
|
||||
// Terminate process and recheck after it exits
|
||||
p.destroy();
|
||||
p.waitFor();
|
||||
THROWS(NullPointerException.class,
|
||||
() -> p.waitFor(10L, null));
|
||||
THROWS(NullPointerException.class,
|
||||
() -> p.waitFor(0L, null));
|
||||
THROWS(NullPointerException.class,
|
||||
() -> p.waitFor(-1L, null));
|
||||
} catch (Throwable t) { unexpected(t); }
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// Check that default implementation of Process.waitFor(timeout, null) throws NPE.
|
||||
//----------------------------------------------------------------
|
||||
try {
|
||||
List<String> childArgs = new ArrayList<String>(javaChildArgs);
|
||||
childArgs.add("sleep");
|
||||
final Process proc = new ProcessBuilder(childArgs).start();
|
||||
final DelegatingProcess p = new DelegatingProcess(proc);
|
||||
|
||||
THROWS(NullPointerException.class,
|
||||
() -> p.waitFor(10L, null));
|
||||
THROWS(NullPointerException.class,
|
||||
() -> p.waitFor(0L, null));
|
||||
THROWS(NullPointerException.class,
|
||||
() -> p.waitFor(-1L, null));
|
||||
// Terminate process and recheck after it exits
|
||||
p.destroy();
|
||||
p.waitFor();
|
||||
THROWS(NullPointerException.class,
|
||||
() -> p.waitFor(10L, null));
|
||||
THROWS(NullPointerException.class,
|
||||
() -> p.waitFor(0L, null));
|
||||
THROWS(NullPointerException.class,
|
||||
() -> p.waitFor(-1L, null));
|
||||
} catch (Throwable t) { unexpected(t); }
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// Check the default implementation for
|
||||
// Process.waitFor(long, TimeUnit)
|
||||
|
@ -1,7 +1,7 @@
|
||||
#! /bin/sh
|
||||
|
||||
#
|
||||
# Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2000, 2015, 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 @@
|
||||
# questions.
|
||||
#
|
||||
|
||||
javac -d . ../../../../make/tools/src/build/tools/spp/Spp.java
|
||||
javac -d . ../../../../make/src/classes/build/tools/spp/Spp.java
|
||||
|
||||
gen() {
|
||||
java build.tools.spp.Spp -K$1 -Dtype=$1 -DType=$2 -DFulltype=$3 <Basic-X.java.template >Basic$2.java
|
||||
|
@ -1,7 +1,7 @@
|
||||
#! /bin/sh
|
||||
|
||||
#
|
||||
# Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2002, 2015, 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 @@
|
||||
# questions.
|
||||
#
|
||||
|
||||
javac -d . ../../../../make/tools/src/build/tools/spp/Spp.java > Spp.java
|
||||
javac -d . ../../../../make/src/classes/build/tools/spp/Spp.java > Spp.java
|
||||
|
||||
gen() {
|
||||
java build.tools.spp.Spp -K$1 -Dtype=$1 -DType=$2 -DFulltype=$3<CopyDirect-X-Memory.java.template >CopyDirect$2Memory.java
|
||||
|
@ -25,7 +25,6 @@
|
||||
* @bug 4607272 6842687 6878369 6944810 7023403
|
||||
* @summary Unit test for AsynchronousSocketChannel
|
||||
* @run main Basic -skipSlowConnectTest
|
||||
* @key intermittent
|
||||
*/
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -25,7 +25,6 @@
|
||||
* @bug 6405995
|
||||
* @summary Unit test for selector wakeup and interruption
|
||||
* @library ..
|
||||
* @key intermittent
|
||||
*/
|
||||
|
||||
import java.io.*;
|
||||
|
@ -25,7 +25,6 @@
|
||||
* @bug 4313887 6993267
|
||||
* @summary Unit test for Sun-specific ExtendedCopyOption.INTERRUPTIBLE option
|
||||
* @library ..
|
||||
* @key intermittent
|
||||
*/
|
||||
|
||||
import java.nio.file.*;
|
||||
|
371
jdk/test/java/security/KeyStore/PKCS12/WriteP12Test.java
Normal file
371
jdk/test/java/security/KeyStore/PKCS12/WriteP12Test.java
Normal file
@ -0,0 +1,371 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2015, 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 static java.lang.System.out;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.security.Key;
|
||||
import java.security.KeyStore;
|
||||
import java.security.KeyStoreException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.NoSuchProviderException;
|
||||
import java.security.UnrecoverableKeyException;
|
||||
import java.security.cert.Certificate;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.CertificateFactory;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.Arrays;
|
||||
import java.util.Base64;
|
||||
import java.util.Enumeration;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8048618
|
||||
* @summary Write different types p12 key store to Check the write related
|
||||
* APIs.
|
||||
* @run main WriteP12Test
|
||||
*/
|
||||
|
||||
public class WriteP12Test {
|
||||
|
||||
private static final String IN_KEYSTORE_TYPE = "jks";
|
||||
private static final String IN_KEYSTORE_PRV = "SUN";
|
||||
|
||||
private static final String IN_KEYSTORE_ENDUSER = "keystoreEU.jks.data";
|
||||
private static final String IN_KEYSTORE_CA = "keystoreCA.jks.data";
|
||||
private static final String OUT_KEYSTORE = "outKeyStore.p12";
|
||||
|
||||
private static final String IN_STORE_PASS = "storepass";
|
||||
private static final String IN_KEY_PASS = "keypass";
|
||||
|
||||
private static final String CERT_PATH = System.getProperty("test.src", ".")
|
||||
+ File.separator + "certs" + File.separator + "writeP12"
|
||||
+ File.separator;
|
||||
|
||||
private static final String CA_CERT_STR = "-----BEGIN CERTIFICATE-----\n"
|
||||
+ "MIIDFzCCAf8CBD8+0nAwDQYJKoZIhvcNAQEFBQAwUDELMAkGA1UEBh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qe3lviMZPkkSXepTJI8m0AiXCji+eXj97jVLeH+RxeBchBY+uELrqUr\n"
|
||||
+ "sVOVWh7IBCqC/V7FqUTkmD1IFlzkkinatpl42s1MbhJId2yQkzaeBRc\n"
|
||||
+ "suE63bDEtuRWp9ynMO3QA4Yu85uBRWGzQ1Di\n"
|
||||
+ "-----END CERTIFICATE-----";
|
||||
private static final String LEAD_CERT = "-----BEGIN CERTIFICATE-----\n"
|
||||
+ "MIICwDCCAaigAwIBAgIEPz7S1jANBgkqhkiG9w0BAQQFADBQMQswCQYDV\n"
|
||||
+ "QQGEwJVUzERMA8GA1UEChMISmF2YVNvZnQxFTATBgNVBAsTDFNlY3VyaX\n"
|
||||
+ "R5IFNRRTEXMBUGA1UEAxMOUEtDUzEyIFRlc3QgQ0EwHhcNMDAwODA5MDc\n"
|
||||
+ "wMDAwWhcNMTAwODA3MDcwMDAwWjBSMQswCQYDVQQGEwJVUzERMA8GA1UE\n"
|
||||
+ "ChMISmF2YVNvZnQxFTATBgNVBAsTDFNlY3VyaXR5IFNRRTEZMBcGA1UEA\n"
|
||||
+ "xMQUEtDUzEyIFRlc3QgTGVhZDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgY\n"
|
||||
+ "kCgYEAzq9X2USz/WjDhT+jUyZWqB5h4A33tS11YqH5qYvqjTXjcUI6gOp\n"
|
||||
+ "moXMafDG9RHRlIccvp51xLp7Ap3WMrv411lWBttqtZi5c1/DEC1cEM/Sl\n"
|
||||
+ "PCk1r2zFbkJu7QKieXeMcrjZEo6LcBHMwQjIpI+up9cr3VjuyqG/olQkU\n"
|
||||
+ "mXVuS0CAwEAAaMkMCIwDwYDVR0PAQH/BAUDAweAADAPBgNVHRMBAf8EBT\n"
|
||||
+ "ADAQH/MA0GCSqGSIb3DQEBBAUAA4IBAQBhbuim98TWmtv9vSldRE7RvQ8\n"
|
||||
+ "FlS0TyZVO7kcSNtfCUE4R76J1ElN74Koc5pQnUtduLeQJs2ao/mEcCZsE\n"
|
||||
+ "zVcwI3mSZrSzPhc8s7w5gOQA4TUwVLSSjKgBCaZ7R3+qJ3QeqPJ5O6sFz\n"
|
||||
+ "pvBYkgSa4MWptK41jbmT8cwZQJXFCi8WxFFJ+p97F1Ppm3LgmYmtiUP4M\n"
|
||||
+ "ZQwOBvpTZWXU0WrqFXpzWQx0mg4SX19fZm4nLcJAerCEUphf8ILagtpQM\n"
|
||||
+ "EErT3/jg6mfCdT3Rj055QXPfF4OiRFevPF5a1fZgrCePCukRQZcd7s8K5\n"
|
||||
+ "OBIaryuM0MdFtlzxi6XWeUNpVFFHURcy\n"
|
||||
+ "-----END CERTIFICATE-----";
|
||||
private static final String END_CERT = "-----BEGIN CERTIFICATE-----\n"
|
||||
+ "MIICNjCCAZ+gAwIBAgIEPz7WtzANBgkqhkiG9w0BAQQFADBSMQswCQYDV\n"
|
||||
+ "QQGEwJVUzERMA8GA1UEChMISmF2YVNvZnQxFTATBgNVBAsTDFNlY3VyaX\n"
|
||||
+ "R5IFNRRTEZMBcGA1UEAxMQUEtDUzEyIFRlc3QgTGVhZDAeFw0wMDA4MDk\n"
|
||||
+ "wNzAwMDBaFw0xMDA4MDcwNzAwMDBaMFgxCzAJBgNVBAYTAlVTMREwDwYD\n"
|
||||
+ "VQQKEwhKYXZhU29mdDEVMBMGA1UECxMMU2VjdXJpdHkgU1FFMR8wHQYDV\n"
|
||||
+ "QQDExZQS0NTMTIgVGVzdCBFbmQgVXNlciAxMIGfMA0GCSqGSIb3DQEBAQ\n"
|
||||
+ "UAA4GNADCBiQKBgQDIKomSYomDzH/V63eDQEG7od0DLcnnVZ81pbWhDss\n"
|
||||
+ "8gHV2m8pADdRqdihBmnSQEaMW4D3uZ4sFE1LtkQls6hjd7SdOsG5Y24L8\n"
|
||||
+ "15jot9a2JcB73H8H0VKirrObL5BZdt7BtASPDnYtW4Spt++YjDoJFxyF0\n"
|
||||
+ "HchkavzXaVTlexakwIDAQABoxMwETAPBgNVHQ8BAf8EBQMDB4AAMA0GCS\n"
|
||||
+ "qGSIb3DQEBBAUAA4GBAIFA3JXEmb9AXn3RD7t+Mn6DoyVDIy5jsn6xOKT\n"
|
||||
+ "JV25I0obpDUzgw4QaAMmM0ZvusOmZ2wZNS8MtyTUgdANyakbzn5SdxbTy\n"
|
||||
+ "TLEqQsFbX8UVC38fx5ZM6ExA5YSAvgmXudZpOVC0ATccoZS3JFU8CxSfW\n"
|
||||
+ "+Q3IC2MLh+QTg3hUJ5b\n-----END CERTIFICATE-----";
|
||||
|
||||
private final Certificate testerCert;
|
||||
private final Certificate testLeadCert;
|
||||
private final Certificate caCert;
|
||||
|
||||
WriteP12Test() throws CertificateException {
|
||||
CertificateFactory cf = CertificateFactory.getInstance("X.509");
|
||||
caCert = cf.generateCertificate(new ByteArrayInputStream(CA_CERT_STR
|
||||
.getBytes()));
|
||||
testLeadCert = cf.generateCertificate(new ByteArrayInputStream(
|
||||
LEAD_CERT.getBytes()));
|
||||
testerCert = cf.generateCertificate(new ByteArrayInputStream(END_CERT
|
||||
.getBytes()));
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws CertificateException,
|
||||
UnrecoverableKeyException, KeyStoreException,
|
||||
NoSuchProviderException, NoSuchAlgorithmException, IOException {
|
||||
WriteP12Test jstest = new WriteP12Test();
|
||||
out.println("test WriteP12CertChain");
|
||||
/*
|
||||
* WriteP12CertChain: This test creates a p12 keystore contains one
|
||||
* entry with private key and a certificate chains contains three
|
||||
* certificates in the order of user->lead->ca. This case expects to
|
||||
* pass.
|
||||
*/
|
||||
jstest.test(new Certificate[] { jstest.testerCert, jstest.testLeadCert,
|
||||
jstest.caCert }, IN_KEYSTORE_ENDUSER, "pkcs12testenduser1",
|
||||
"pass", "pass");
|
||||
|
||||
/*
|
||||
* WriteP12CertChainBad: same as WriteP12CertChain but chains order is
|
||||
* user-ca-lead, the order is wrong so expects to fail.
|
||||
*/
|
||||
out.println("test WriteP12CertChainBad");
|
||||
try {
|
||||
jstest.test(new Certificate[] { jstest.testerCert, jstest.caCert,
|
||||
jstest.testLeadCert }, IN_KEYSTORE_ENDUSER,
|
||||
"pkcs12testenduser1", "pass", "pass");
|
||||
throw new RuntimeException(
|
||||
" Certificate chain is not valid, test should not pass."
|
||||
+ " Test failed.");
|
||||
} catch (KeyStoreException e) {
|
||||
e.printStackTrace();
|
||||
out.println(" Certificate chain is not valid,exception is"
|
||||
+ " expected. Test passed.");
|
||||
}
|
||||
/*
|
||||
* WriteP12PrivateKey:This test creates a p12 contains a self-signed
|
||||
* cert and private key,expects no exception
|
||||
*/
|
||||
out.println("test WriteP12PrivateKey");
|
||||
jstest.test(null, IN_KEYSTORE_ENDUSER, "pkcs12testenduser1", "pass",
|
||||
"pass");
|
||||
|
||||
/*
|
||||
* WriteP12TwoEntry: This test creates a p12 keystore with different
|
||||
* storepass and keypass, and contains two entries.
|
||||
*/
|
||||
out.println("test WriteP12TwoEntry");
|
||||
jstest.testTwoEntry(IN_KEYSTORE_ENDUSER, IN_KEYSTORE_CA,
|
||||
"pkcs12testenduser1", "pass", "pass");
|
||||
/*
|
||||
* WriteP12TwoPass: This test creates a p12 keystore with different
|
||||
* storepass and keypass, and contains one entry with private key and a
|
||||
* certificate
|
||||
*/
|
||||
out.println("test WriteP12TwoPass");
|
||||
jstest.test(null, IN_KEYSTORE_CA, "pkcs12testCA", "storepass",
|
||||
"keypass");
|
||||
}
|
||||
|
||||
private void test(Certificate certs[], String inKeyStorePath,
|
||||
String userAlias, String outStorePass, String outKeyPass)
|
||||
throws KeyStoreException, NoSuchProviderException, IOException,
|
||||
CertificateException, UnrecoverableKeyException,
|
||||
NoSuchAlgorithmException {
|
||||
// init output key store
|
||||
KeyStore outputKeyStore = KeyStore.getInstance("pkcs12", "SunJSSE");
|
||||
outputKeyStore.load(null, null);
|
||||
try (FileOutputStream fout = new FileOutputStream(OUT_KEYSTORE)) {
|
||||
// KeyStore have encoded by Base64.getMimeEncoder().encode(),need
|
||||
// decode first.
|
||||
byte[] input = Files.readAllBytes(Paths.get(CERT_PATH,
|
||||
inKeyStorePath));
|
||||
ByteArrayInputStream arrayIn = new ByteArrayInputStream(Base64
|
||||
.getMimeDecoder().decode(input));
|
||||
// input key store
|
||||
KeyStore inputKeyStore = KeyStore.getInstance(IN_KEYSTORE_TYPE,
|
||||
IN_KEYSTORE_PRV);
|
||||
inputKeyStore.load(arrayIn, IN_STORE_PASS.toCharArray());
|
||||
// add key/certificate to output key store
|
||||
Key key = inputKeyStore
|
||||
.getKey(userAlias, IN_KEY_PASS.toCharArray());
|
||||
out.println("Input Key Algorithm " + key.getAlgorithm());
|
||||
out.println("====Input Certs=====");
|
||||
if (certs == null) {
|
||||
certs = new Certificate[] { inputKeyStore
|
||||
.getCertificate(userAlias) };
|
||||
}
|
||||
for (Certificate cert : certs) {
|
||||
out.println(((X509Certificate) cert).getSubjectDN());
|
||||
}
|
||||
outputKeyStore.setKeyEntry(userAlias, key,
|
||||
outKeyPass.toCharArray(), certs);
|
||||
Certificate retCerts[] = outputKeyStore
|
||||
.getCertificateChain(userAlias);
|
||||
out.println("====Output Certs=====");
|
||||
for (Certificate retCert : retCerts) {
|
||||
out.println(((X509Certificate) retCert).getSubjectDN());
|
||||
}
|
||||
out.println("====Output Key Algorithm=====");
|
||||
Key outKey = outputKeyStore.getKey(userAlias,
|
||||
outKeyPass.toCharArray());
|
||||
out.println(outKey.getAlgorithm());
|
||||
|
||||
if (!key.equals(outKey)) {
|
||||
throw new RuntimeException("key don't match");
|
||||
}
|
||||
if (!Arrays.equals(certs, retCerts)) {
|
||||
throw new RuntimeException("certs don't match");
|
||||
}
|
||||
// save output
|
||||
outputKeyStore.store(fout, outStorePass.toCharArray());
|
||||
// test output
|
||||
testKeyStore(outputKeyStore, outKeyPass.toCharArray());
|
||||
}
|
||||
}
|
||||
|
||||
private void testTwoEntry(String inKeyStoreOnePath,
|
||||
String inKeyStoreTwoPath, String userAlias, String outStorePass,
|
||||
String outKeyPass) throws KeyStoreException,
|
||||
NoSuchProviderException, NoSuchAlgorithmException,
|
||||
CertificateException, IOException, UnrecoverableKeyException {
|
||||
// initial KeyStore
|
||||
KeyStore outputKeyStore = KeyStore.getInstance("pkcs12", "SunJSSE");
|
||||
try (FileOutputStream fout = new FileOutputStream(OUT_KEYSTORE);) {
|
||||
outputKeyStore.load(null, null);
|
||||
KeyStore inputKeyStoreOne, inputKeyStoreTwo;
|
||||
inputKeyStoreOne = KeyStore.getInstance(IN_KEYSTORE_TYPE,
|
||||
IN_KEYSTORE_PRV);
|
||||
// KeyStore have encoded by Base64.getMimeEncoder().encode(),need
|
||||
// decode first.
|
||||
byte[] inputBytes = Files.readAllBytes(Paths.get(CERT_PATH,
|
||||
inKeyStoreOnePath));
|
||||
ByteArrayInputStream arrayIn = new ByteArrayInputStream(Base64
|
||||
.getMimeDecoder().decode(inputBytes));
|
||||
// input key store
|
||||
inputKeyStoreOne.load(arrayIn, IN_STORE_PASS.toCharArray());
|
||||
|
||||
inputBytes = Files.readAllBytes(Paths.get(CERT_PATH,
|
||||
inKeyStoreTwoPath));
|
||||
arrayIn = new ByteArrayInputStream(Base64.getMimeDecoder().decode(
|
||||
inputBytes));
|
||||
inputKeyStoreTwo = KeyStore.getInstance(IN_KEYSTORE_TYPE,
|
||||
IN_KEYSTORE_PRV);
|
||||
inputKeyStoreTwo.load(arrayIn, IN_STORE_PASS.toCharArray());
|
||||
|
||||
// add key/certificate to output key store
|
||||
out.println("====First Entry=====");
|
||||
Key inputKey = inputKeyStoreOne.getKey(userAlias,
|
||||
IN_KEY_PASS.toCharArray());
|
||||
Certificate cert = inputKeyStoreOne.getCertificate(userAlias);
|
||||
Certificate certs[] = new Certificate[1];
|
||||
certs[0] = cert;
|
||||
|
||||
out.println("====Input1 Key=====");
|
||||
out.println(inputKey.getAlgorithm());
|
||||
out.println("====Input1 Certs=====");
|
||||
out.println("Certificate :");
|
||||
out.println(((X509Certificate) cert).getSubjectDN());
|
||||
outputKeyStore.setKeyEntry("USER", inputKey,
|
||||
outKeyPass.toCharArray(), certs);
|
||||
out.println("====Second Entry=====");
|
||||
String caAlias = "pkcs12testca";
|
||||
inputKey = inputKeyStoreTwo.getKey(caAlias,
|
||||
IN_KEY_PASS.toCharArray());
|
||||
cert = inputKeyStoreTwo.getCertificate(caAlias);
|
||||
certs[0] = cert;
|
||||
out.println("====Input2 Key=====");
|
||||
out.println(inputKey.getAlgorithm());
|
||||
out.println("====Input2 Certs=====");
|
||||
out.println("Certificate :");
|
||||
out.println(((X509Certificate) cert).getSubjectDN());
|
||||
outputKeyStore.setKeyEntry("CA", inputKey,
|
||||
outKeyPass.toCharArray(), certs);
|
||||
// save output
|
||||
outputKeyStore.store(fout, outStorePass.toCharArray());
|
||||
// test output
|
||||
testKeyStore(outputKeyStore, outKeyPass.toCharArray());
|
||||
}
|
||||
}
|
||||
|
||||
private void testKeyStore(KeyStore inputKeyStore, char[] keypass)
|
||||
throws KeyStoreException, UnrecoverableKeyException,
|
||||
NoSuchAlgorithmException {
|
||||
out.println("========== Key Store ==========");
|
||||
out.println("getProvider : " + inputKeyStore.getProvider());
|
||||
out.println("getType : " + inputKeyStore.getType());
|
||||
out.println("getDefaultType : " + KeyStore.getDefaultType());
|
||||
|
||||
int idx = 0;
|
||||
Enumeration<String> e = inputKeyStore.aliases();
|
||||
String alias;
|
||||
while (e.hasMoreElements()) {
|
||||
alias = e.nextElement();
|
||||
if (!inputKeyStore.containsAlias(alias)) {
|
||||
throw new RuntimeException("Alias not found");
|
||||
}
|
||||
out.println("Alias " + idx + " : " + alias);
|
||||
out.println("getCreationDate : "
|
||||
+ inputKeyStore.getCreationDate(alias));
|
||||
X509Certificate cert = (X509Certificate) inputKeyStore
|
||||
.getCertificate(alias);
|
||||
out.println("getCertificate : " + cert.getSubjectDN());
|
||||
String retAlias = inputKeyStore.getCertificateAlias(cert);
|
||||
if (!retAlias.equals(alias)) {
|
||||
throw new RuntimeException("Alias mismatch, actually "
|
||||
+ retAlias + ", expected " + alias);
|
||||
}
|
||||
out.println("getCertificateAlias : " + retAlias);
|
||||
Certificate[] certs = inputKeyStore.getCertificateChain(alias);
|
||||
int i = 0;
|
||||
for (Certificate certification : certs) {
|
||||
out.println("getCertificateChain " + i
|
||||
+ ((X509Certificate) certification).getSubjectDN());
|
||||
i++;
|
||||
}
|
||||
if (inputKeyStore.isCertificateEntry(alias)) {
|
||||
throw new RuntimeException(
|
||||
"inputKeystore should not be certEntry because this"
|
||||
+ " keystore only contain key pair entries.");
|
||||
}
|
||||
if (!inputKeyStore.isKeyEntry(alias)) {
|
||||
throw new RuntimeException("Entry type unknown.");
|
||||
}
|
||||
idx++;
|
||||
}
|
||||
int size = inputKeyStore.size();
|
||||
if (idx != size) {
|
||||
throw new RuntimeException("Size not match, actually " + idx
|
||||
+ ", expected " + size);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
/u3+7QAAAAIAAAABAAAAAQAMcGtjczEydGVzdGNhAAAA9w1mDAMAAAUCMIIE/jAOBgorBgEEASoC
|
||||
EQEBBQAEggTqFhceJz85XyVsicsfonXYx+vvFXkb9Jmr11eh9n570ZdiFZ1hv4XRk/x/1C1spy5X
|
||||
J2wv4lABGAOA5gV0aTKij+82NLoEz9zDW5fwAnrBKVjAq/NxdwEi9lvipiSVx1qglx/mQAHeEi4i
|
||||
6vDoai3hVNQqVmd/TG2deyk/fQ9MZ7U2fmWcJDH4YbP39psQ+7rp9cDJ0P7GWoLXwbWs1vftbN0R
|
||||
4fWitH1+6hBbIbVT9o0cM9ilAjpkNFr10pBEsfrikaE8IsN562soWfNxGwwrsjExEFeKlMrtNtWM
|
||||
Wc4+YZ1ybVi/6krK/kFfOa+R3mtjBoD7zM4TSG9dptuvBLVgey8RXh3BQ8pU7uN5q+9Omqo1SsRN
|
||||
wHYKjTrfWMozt+37ZlyCZ70Kb/2jJYWFuo9+wqXQU+MYnpZZB+cLt3PIFMakhIu1vpMpJCcoceaS
|
||||
bjDWxCG8HHZjjFJPxAE3HEbCzaj4BevxQfxtp57llmtI2I0NJvua8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c2LPWBDLYTTxoFEazWmYLv1k/J
|
||||
T7Nta1qu1quvxXJ4uV1XHbd9NFAJWKwtFQEpfv4o6I7qWUPoxnfA+jyqKXxv27z25tzt+Y4xOEhq
|
||||
vO03G0QimhkiNt9MF7L69y2U0/U73+uFNGzdAEDiI9EibvICiOnr1TeQ5GekK3Ybk5qe3lviMZPk
|
||||
kSXepTJI8m0AiXCji+eXj97jVLeH+RxeBchBY+uELrqUrsVOVWh7IBCqC/V7FqUTkmD1IFlzkkin
|
||||
atpl42s1MbhJId2yQkzaeBRcsuE63bDEtuRWp9ynMO3QA4Yu85uBRWGzQ1Di7p2dz0wNRNimbVP4
|
||||
VL+NWQOgtME=
|
@ -24,22 +24,63 @@
|
||||
/*
|
||||
* @test
|
||||
* @bug 8072909
|
||||
* @run main/othervm -Xms385m TimSortStackSize2 67108864
|
||||
* @library /lib/testlibrary /../../test/lib
|
||||
* @build jdk.testlibrary.*
|
||||
* @build TimSortStackSize2
|
||||
* @run main ClassFileInstaller sun.hotspot.WhiteBox
|
||||
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
|
||||
* -XX:+WhiteBoxAPI TimSortStackSize2
|
||||
* @summary Test TimSort stack size on big arrays
|
||||
* big tests not for regular execution on all platforms:
|
||||
* run main/othervm -Xmx8g TimSortStackSize2 1073741824
|
||||
* run main/othervm -Xmx16g TimSortStackSize2 2147483644
|
||||
*/
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import jdk.testlibrary.OutputAnalyzer;
|
||||
import jdk.testlibrary.ProcessTools;
|
||||
import jdk.testlibrary.Utils;
|
||||
import sun.hotspot.WhiteBox;
|
||||
|
||||
public class TimSortStackSize2 {
|
||||
|
||||
public static void main(String[] args) {
|
||||
int lengthOfTest = Integer.parseInt(args[0]);
|
||||
if ( args == null || args.length == 0 ){
|
||||
startMeWithArgs();
|
||||
} else {
|
||||
doTestOfTwoTimSorts(Integer.parseInt(args[0]));
|
||||
}
|
||||
}
|
||||
|
||||
private static void startMeWithArgs(){
|
||||
/*
|
||||
* big tests not for regular execution on all platforms:
|
||||
* run main/othervm -Xmx8g TimSortStackSize2 1073741824
|
||||
* run main/othervm -Xmx16g TimSortStackSize2 2147483644
|
||||
*/
|
||||
try {
|
||||
Boolean compressedOops = WhiteBox.getWhiteBox()
|
||||
.getBooleanVMFlag("UseCompressedOops");
|
||||
final String xmsValue = "-Xms" +
|
||||
((compressedOops == null || compressedOops) ? "385" : "770")
|
||||
+ "m";
|
||||
System.out.println( "compressedOops: " + compressedOops
|
||||
+ "; Test will be started with \"" + xmsValue + "\"");
|
||||
ProcessBuilder processBuilder = ProcessTools
|
||||
.createJavaProcessBuilder(Utils.addTestJavaOpts(xmsValue,
|
||||
"TimSortStackSize2", "67108864"
|
||||
)
|
||||
);
|
||||
OutputAnalyzer output = ProcessTools.executeProcess(processBuilder);
|
||||
System.out.println(output.getOutput());
|
||||
output.shouldHaveExitValue(0);
|
||||
} catch( Exception e ){
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static void doTestOfTwoTimSorts(final int lengthOfTest){
|
||||
boolean passed = doTest("TimSort", lengthOfTest,
|
||||
(Integer [] a) -> Arrays.sort(a));
|
||||
passed = doTest("ComparableTimSort", lengthOfTest, (Integer [] a) ->
|
||||
|
@ -28,10 +28,10 @@ import java.util.Properties;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8073214
|
||||
* @summary Basic tests of Properties methods.
|
||||
* @bug 8073214 8075362
|
||||
* @summary Tests to verify that load() and store() throw NPEs as advertised.
|
||||
*/
|
||||
public class Basic
|
||||
public class LoadAndStoreNPE
|
||||
{
|
||||
public static void main(String[] args) throws Exception
|
||||
{
|
||||
@ -68,7 +68,7 @@ public class Basic
|
||||
}
|
||||
|
||||
if (failures != 0) {
|
||||
throw new RuntimeException("Basic failed with "
|
||||
throw new RuntimeException("LoadAndStoreNPE failed with "
|
||||
+ failures + " errors!");
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2015, 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
|
||||
@ -251,7 +251,7 @@ public class UnorderedTest extends OpTestCase {
|
||||
|
||||
final int lastLimitIndex = l;
|
||||
return s -> {
|
||||
if (lastLimitIndex == -1)
|
||||
if (lastLimitIndex == -1 && fs.size() > 0)
|
||||
s = fi.apply(s);
|
||||
for (int i = 0; i < fs.size(); i++) {
|
||||
s = fs.get(i).apply(s);
|
||||
|
@ -24,11 +24,12 @@
|
||||
/**
|
||||
* @test
|
||||
* @summary Tests counting of streams
|
||||
* @bug 8031187 8067969
|
||||
* @bug 8031187 8067969 8075307
|
||||
*/
|
||||
|
||||
package org.openjdk.tests.java.util.stream;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.DoubleStream;
|
||||
import java.util.stream.DoubleStreamTestDataProvider;
|
||||
@ -59,6 +60,19 @@ public class CountTest extends OpTestCase {
|
||||
terminal(s -> s.filter(e -> true), Stream::count).
|
||||
expectedResult(expectedCount).
|
||||
exercise();
|
||||
|
||||
// Test with stateful distinct op that is a barrier or lazy
|
||||
// depending if source is not already distinct and encounter order is
|
||||
// preserved or not
|
||||
expectedCount = data.into(new HashSet<>()).size();
|
||||
withData(data).
|
||||
terminal(Stream::distinct, Stream::count).
|
||||
expectedResult(expectedCount).
|
||||
exercise();
|
||||
withData(data).
|
||||
terminal(s -> s.unordered().distinct(), Stream::count).
|
||||
expectedResult(expectedCount).
|
||||
exercise();
|
||||
}
|
||||
|
||||
@Test(dataProvider = "IntStreamTestData", dataProviderClass = IntStreamTestDataProvider.class)
|
||||
@ -74,6 +88,16 @@ public class CountTest extends OpTestCase {
|
||||
terminal(s -> s.filter(e -> true), IntStream::count).
|
||||
expectedResult(expectedCount).
|
||||
exercise();
|
||||
|
||||
expectedCount = data.into(new HashSet<>()).size();
|
||||
withData(data).
|
||||
terminal(IntStream::distinct, IntStream::count).
|
||||
expectedResult(expectedCount).
|
||||
exercise();
|
||||
withData(data).
|
||||
terminal(s -> s.unordered().distinct(), IntStream::count).
|
||||
expectedResult(expectedCount).
|
||||
exercise();
|
||||
}
|
||||
|
||||
@Test(dataProvider = "LongStreamTestData", dataProviderClass = LongStreamTestDataProvider.class)
|
||||
@ -89,6 +113,16 @@ public class CountTest extends OpTestCase {
|
||||
terminal(s -> s.filter(e -> true), LongStream::count).
|
||||
expectedResult(expectedCount).
|
||||
exercise();
|
||||
|
||||
expectedCount = data.into(new HashSet<>()).size();
|
||||
withData(data).
|
||||
terminal(LongStream::distinct, LongStream::count).
|
||||
expectedResult(expectedCount).
|
||||
exercise();
|
||||
withData(data).
|
||||
terminal(s -> s.unordered().distinct(), LongStream::count).
|
||||
expectedResult(expectedCount).
|
||||
exercise();
|
||||
}
|
||||
|
||||
@Test(dataProvider = "DoubleStreamTestData", dataProviderClass = DoubleStreamTestDataProvider.class)
|
||||
@ -104,6 +138,16 @@ public class CountTest extends OpTestCase {
|
||||
terminal(s -> s.filter(e -> true), DoubleStream::count).
|
||||
expectedResult(expectedCount).
|
||||
exercise();
|
||||
|
||||
expectedCount = data.into(new HashSet<>()).size();
|
||||
withData(data).
|
||||
terminal(DoubleStream::distinct, DoubleStream::count).
|
||||
expectedResult(expectedCount).
|
||||
exercise();
|
||||
withData(data).
|
||||
terminal(s -> s.unordered().distinct(), DoubleStream::count).
|
||||
expectedResult(expectedCount).
|
||||
exercise();
|
||||
}
|
||||
|
||||
public void testNoEvaluationForSizedStream() {
|
||||
@ -111,24 +155,36 @@ public class CountTest extends OpTestCase {
|
||||
AtomicInteger ai = new AtomicInteger();
|
||||
Stream.of(1, 2, 3, 4).peek(e -> ai.getAndIncrement()).count();
|
||||
assertEquals(ai.get(), 0);
|
||||
|
||||
Stream.of(1, 2, 3, 4).peek(e -> ai.getAndIncrement()).parallel().count();
|
||||
assertEquals(ai.get(), 0);
|
||||
}
|
||||
|
||||
{
|
||||
AtomicInteger ai = new AtomicInteger();
|
||||
IntStream.of(1, 2, 3, 4).peek(e -> ai.getAndIncrement()).count();
|
||||
assertEquals(ai.get(), 0);
|
||||
|
||||
IntStream.of(1, 2, 3, 4).peek(e -> ai.getAndIncrement()).parallel().count();
|
||||
assertEquals(ai.get(), 0);
|
||||
}
|
||||
|
||||
{
|
||||
AtomicInteger ai = new AtomicInteger();
|
||||
LongStream.of(1, 2, 3, 4).peek(e -> ai.getAndIncrement()).count();
|
||||
assertEquals(ai.get(), 0);
|
||||
|
||||
LongStream.of(1, 2, 3, 4).peek(e -> ai.getAndIncrement()).parallel().count();
|
||||
assertEquals(ai.get(), 0);
|
||||
}
|
||||
|
||||
{
|
||||
AtomicInteger ai = new AtomicInteger();
|
||||
DoubleStream.of(1, 2, 3, 4).peek(e -> ai.getAndIncrement()).count();
|
||||
assertEquals(ai.get(), 0);
|
||||
|
||||
DoubleStream.of(1, 2, 3, 4).peek(e -> ai.getAndIncrement()).parallel().count();
|
||||
assertEquals(ai.get(), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2015, 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
|
||||
@ -128,7 +128,7 @@ public class DistinctOpTest extends OpTestCase {
|
||||
@Test(dataProvider = "StreamTestData<Integer>", dataProviderClass = StreamTestDataProvider.class)
|
||||
public void testDistinctDistinct(String name, TestData.OfRef<Integer> data) {
|
||||
Collection<Integer> result = withData(data)
|
||||
.stream(s -> s.distinct().distinct(), new CollectorOps.TestParallelSizedOp<>())
|
||||
.stream(s -> s.distinct().distinct())
|
||||
.exercise();
|
||||
assertUnique(result);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 2015, 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
|
||||
@ -80,7 +80,7 @@ public class ComURLNulls {
|
||||
}
|
||||
|
||||
try {
|
||||
urlc.getServerCertificateChain();
|
||||
urlc.getServerCertificates();
|
||||
} catch (IllegalStateException e) {
|
||||
System.out.print("Caught proper exception: ");
|
||||
System.out.println(e.getMessage());
|
||||
|
@ -24,6 +24,8 @@
|
||||
package jdk.testlibrary;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.management.RuntimeMXBean;
|
||||
@ -34,6 +36,7 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
@ -188,8 +191,8 @@ public final class ProcessTools {
|
||||
} else {
|
||||
latch.countDown();
|
||||
}
|
||||
Future<Void> stdoutTask = stdout.process();
|
||||
Future<Void> stderrTask = stderr.process();
|
||||
final Future<Void> stdoutTask = stdout.process();
|
||||
final Future<Void> stderrTask = stderr.process();
|
||||
|
||||
try {
|
||||
if (timeout > -1) {
|
||||
@ -216,7 +219,7 @@ public final class ProcessTools {
|
||||
throw e;
|
||||
}
|
||||
|
||||
return p;
|
||||
return new ProcessImpl(p, stdoutTask, stderrTask);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -436,4 +439,84 @@ public final class ProcessTools {
|
||||
System.out.println(analyzer.getOutput());
|
||||
return analyzer;
|
||||
}
|
||||
|
||||
private static class ProcessImpl extends Process {
|
||||
|
||||
private final Process p;
|
||||
private final Future<Void> stdoutTask;
|
||||
private final Future<Void> stderrTask;
|
||||
|
||||
public ProcessImpl(Process p, Future<Void> stdoutTask, Future<Void> stderrTask) {
|
||||
this.p = p;
|
||||
this.stdoutTask = stdoutTask;
|
||||
this.stderrTask = stderrTask;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OutputStream getOutputStream() {
|
||||
return p.getOutputStream();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getInputStream() {
|
||||
return p.getInputStream();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getErrorStream() {
|
||||
return p.getErrorStream();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int waitFor() throws InterruptedException {
|
||||
int rslt = p.waitFor();
|
||||
waitForStreams();
|
||||
return rslt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int exitValue() {
|
||||
return p.exitValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
p.destroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getPid() {
|
||||
return p.getPid();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAlive() {
|
||||
return p.isAlive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Process destroyForcibly() {
|
||||
return p.destroyForcibly();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean waitFor(long timeout, TimeUnit unit) throws InterruptedException {
|
||||
boolean rslt = p.waitFor(timeout, unit);
|
||||
if (rslt) {
|
||||
waitForStreams();
|
||||
}
|
||||
return rslt;
|
||||
}
|
||||
|
||||
private void waitForStreams() throws InterruptedException {
|
||||
try {
|
||||
stdoutTask.get();
|
||||
} catch (ExecutionException e) {
|
||||
}
|
||||
try {
|
||||
stderrTask.get();
|
||||
} catch (ExecutionException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -90,7 +90,6 @@ public class JMXStartStopTest {
|
||||
}
|
||||
}
|
||||
}
|
||||
System.err.println("*** port = " + port);
|
||||
ports[i] = port;
|
||||
}
|
||||
return ports;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 2015, 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
|
||||
@ -34,8 +34,8 @@
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.security.cert.Certificate;
|
||||
import javax.net.ssl.*;
|
||||
import javax.security.cert.*;
|
||||
import com.sun.net.ssl.HostnameVerifier;
|
||||
import com.sun.net.ssl.HttpsURLConnection;
|
||||
|
||||
@ -240,8 +240,8 @@ public class ComHTTPSConnection {
|
||||
|
||||
System.out.println("Cipher Suite: " +
|
||||
((HttpsURLConnection)urlc).getCipherSuite());
|
||||
X509Certificate[] certs =
|
||||
((HttpsURLConnection)urlc).getServerCertificateChain();
|
||||
Certificate[] certs =
|
||||
((HttpsURLConnection)urlc).getServerCertificates();
|
||||
for (int i = 0; i < certs.length; i++) {
|
||||
System.out.println(certs[0]);
|
||||
}
|
||||
|
@ -30,6 +30,7 @@
|
||||
# @run shell ShortRSAKey1024.sh 1024
|
||||
# @run shell ShortRSAKey1024.sh 768
|
||||
# @run shell ShortRSAKey1024.sh 512
|
||||
# @key intermittent
|
||||
|
||||
# set a few environment variables so that the shell-script can run stand-alone
|
||||
# in the source directory
|
||||
|
@ -28,6 +28,7 @@
|
||||
# @bug 6578658
|
||||
# @run shell SignUsingNONEwithRSA.sh
|
||||
# @summary Sign using the NONEwithRSA signature algorithm from SunMSCAPI
|
||||
# @key intermittent
|
||||
|
||||
# set a few environment variables so that the shell-script can run stand-alone
|
||||
# in the source directory
|
||||
|
76
jdk/test/sun/security/provider/X509Factory/BadPem.java
Normal file
76
jdk/test/sun/security/provider/X509Factory/BadPem.java
Normal file
@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 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 8074935
|
||||
* @summary jdk8 keytool doesn't validate pem files for RFC 1421 correctness, as jdk7 did
|
||||
*/
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.security.KeyStore;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Base64;
|
||||
|
||||
import sun.security.provider.X509Factory;
|
||||
import java.security.cert.CertificateFactory;
|
||||
import java.io.ByteArrayInputStream;
|
||||
|
||||
public class BadPem {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
String ks = System.getProperty("test.src", ".")
|
||||
+ "/../../../../javax/net/ssl/etc/keystore";
|
||||
String pass = "passphrase";
|
||||
String alias = "dummy";
|
||||
|
||||
KeyStore keyStore = KeyStore.getInstance("JKS");
|
||||
keyStore.load(new FileInputStream(ks), pass.toCharArray());
|
||||
byte[] cert = keyStore.getCertificate(alias).getEncoded();
|
||||
|
||||
ByteArrayOutputStream bout = new ByteArrayOutputStream();
|
||||
PrintStream pout = new PrintStream(bout);
|
||||
byte[] CRLF = new byte[] {'\r', '\n'};
|
||||
pout.println(X509Factory.BEGIN_CERT);
|
||||
for (int i=0; i<cert.length; i += 48) {
|
||||
int blockLen = (cert.length > i + 48) ? 48 : (cert.length - i);
|
||||
pout.println("!" + Base64.getEncoder()
|
||||
.encodeToString(Arrays.copyOfRange(cert, i, i + blockLen)));
|
||||
}
|
||||
pout.println(X509Factory.END_CERT);
|
||||
|
||||
CertificateFactory cf = CertificateFactory.getInstance("X.509");
|
||||
|
||||
try {
|
||||
cf.generateCertificate(new ByteArrayInputStream(bout.toByteArray()));
|
||||
throw new Exception("Should fail");
|
||||
} catch (CertificateException e) {
|
||||
// Good
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -56,6 +56,8 @@
|
||||
* NSS PKCS11 config file are changed, DSA not supported now.
|
||||
*/
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.security.KeyStore;
|
||||
import sun.security.x509.*;
|
||||
import java.io.*;
|
||||
@ -1222,6 +1224,24 @@ public class KeyToolTest {
|
||||
remove("mykey.cert");
|
||||
}
|
||||
|
||||
// 8074935: jdk8 keytool doesn't validate pem files for RFC 1421 correctness
|
||||
static void checkPem(String file) throws Exception {
|
||||
boolean maybeLast = false;
|
||||
for (String s: Files.readAllLines(Paths.get(file))) {
|
||||
if (s.isEmpty()) continue;
|
||||
if (s.startsWith("---")) continue;
|
||||
if (maybeLast) {
|
||||
throw new Exception("Last line already seen");
|
||||
}
|
||||
if (s.length() > 64) {
|
||||
throw new Exception(s);
|
||||
}
|
||||
if (s.length() < 64) {
|
||||
maybeLast = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void v3extTest(String keyAlg) throws Exception {
|
||||
KeyStore ks;
|
||||
remove("x.jks");
|
||||
@ -1588,12 +1608,14 @@ public class KeyToolTest {
|
||||
"-rfc -file test.req");
|
||||
// printcertreq
|
||||
testOK("", "-printcertreq -file test.req");
|
||||
checkPem("test.req");
|
||||
// issue: deny KU, change criticality of 1.2.3 and 1.2.4,
|
||||
// change content of BC, add 2.3.4
|
||||
testOK("", simple+"-gencert -alias ca -infile test.req -ext " +
|
||||
"honored=all,-KU,1.2.3:critical,1.2.4:non-critical " +
|
||||
"-ext BC=2 -ext 2.3.4=01020304 " +
|
||||
"-debug -rfc -outfile test.cert");
|
||||
checkPem("test.cert");
|
||||
testOK("", simple+"-importcert -file test.cert -alias a");
|
||||
ks = loadStore("x.jks", "changeit", "JKS");
|
||||
X509CertImpl a = (X509CertImpl)ks.getCertificate("a");
|
||||
|
@ -8279,3 +8279,6 @@ FormatData/fi/DatePatterns/0=d. MMMM yyyy
|
||||
FormatData/fi/DatePatterns/1=d. MMMM yyyy
|
||||
FormatData/fi/DatePatterns/2=d.M.yyyy
|
||||
FormatData/fi/DatePatterns/3=d.M.yyyy
|
||||
|
||||
# bug #8075173
|
||||
FormatData/de/standalone.MonthAbbreviations/2=M\u00e4r
|
||||
|
@ -36,7 +36,7 @@
|
||||
* 6919624 6998391 7019267 7020960 7025837 7020583 7036905 7066203 7101495
|
||||
* 7003124 7085757 7028073 7171028 7189611 8000983 7195759 8004489 8006509
|
||||
* 7114053 7074882 7040556 8013836 8021121 6192407 6931564 8027695 8017142
|
||||
* 8037343 8055222 8042126 8074791
|
||||
* 8037343 8055222 8042126 8074791 8075173
|
||||
* @summary Verify locale data
|
||||
*
|
||||
*/
|
||||
|
@ -417,7 +417,9 @@ public class LingeredApp {
|
||||
setLastModified(theLockFileName, epoch());
|
||||
Thread.sleep(spinDelay);
|
||||
}
|
||||
|
||||
} catch (NoSuchFileException ex) {
|
||||
// Lock deleted while we are setting last modified time.
|
||||
// Ignore error and lets the app exits
|
||||
} catch (Exception ex) {
|
||||
System.err.println("LingeredApp ERROR: " + ex);
|
||||
// Leave exit_code = 1 to Java launcher
|
||||
|
Loading…
x
Reference in New Issue
Block a user