mirror of
https://github.com/openjdk/jdk.git
synced 2026-03-05 13:40:18 +00:00
Merge
This commit is contained in:
commit
8b14c7551d
@ -62,7 +62,8 @@ EXCLUDE_PROPWARN_PKGS += sun.dyn
|
||||
# This is an interim solution until the ct.sym is replaced
|
||||
# with a new module system (being discussed for JDK 7).
|
||||
#
|
||||
EXPORTED_PRIVATE_PKGS = com.sun.servicetag
|
||||
EXPORTED_PRIVATE_PKGS = com.sun.servicetag \
|
||||
com.oracle.net
|
||||
|
||||
# 64-bit solaris has a few special cases. We define the variable
|
||||
# SOLARIS64 for use in this Makefile to easily test those cases
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2007, 2011, 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
|
||||
@ -45,7 +45,7 @@ else
|
||||
JAVA_MEM_FLAGS += -Xms$(MIN_VM_MEMORY)m -XX:PermSize=32m -XX:MaxPermSize=160m
|
||||
endif
|
||||
|
||||
#
|
||||
#
|
||||
# All java tools (javac, javah, and javadoc) run faster with certain java
|
||||
# options, this macro should be used with all these tools.
|
||||
# In particular, the client VM makes these tools run faster when
|
||||
@ -122,6 +122,17 @@ ifeq ($(JAVAC_WARNINGS_FATAL), true)
|
||||
JAVACFLAGS += -Werror
|
||||
endif
|
||||
|
||||
#
|
||||
# Some licensees do not get the Security Source bundles. We will
|
||||
# fall back on the prebuilt jce.jar so that we can do a best
|
||||
# attempt at building. If sources exist, we always want to
|
||||
# build/use the most recent source instead of an older jce.jar, whether
|
||||
# built implicitly/explicitly.
|
||||
#
|
||||
ifeq ($(wildcard $(SHARE_SRC)/classes/javax/crypto/Cipher.java),)
|
||||
JCEFLAGS = $(CLASSPATH_SEPARATOR)$(LIBDIR)/jce.jar
|
||||
endif
|
||||
|
||||
# Add the source level
|
||||
SOURCE_LANGUAGE_VERSION = 7
|
||||
LANGUAGE_VERSION = -source $(SOURCE_LANGUAGE_VERSION)
|
||||
@ -132,11 +143,11 @@ TARGET_CLASS_VERSION = 7
|
||||
CLASS_VERSION = -target $(TARGET_CLASS_VERSION)
|
||||
JAVACFLAGS += $(CLASS_VERSION)
|
||||
JAVACFLAGS += -encoding ascii
|
||||
JAVACFLAGS += "-Xbootclasspath:$(CLASSBINDIR)"
|
||||
JAVACFLAGS += "-Xbootclasspath:$(CLASSBINDIR)$(JCEFLAGS)"
|
||||
JAVACFLAGS += $(OTHER_JAVACFLAGS)
|
||||
|
||||
# Needed for javah
|
||||
JAVAHFLAGS += -bootclasspath $(CLASSBINDIR)
|
||||
JAVAHFLAGS += -bootclasspath "$(CLASSBINDIR)$(JCEFLAGS)"
|
||||
|
||||
# Needed for javadoc to ensure it builds documentation
|
||||
# against the newly built classes
|
||||
|
||||
@ -91,8 +91,6 @@ SCTPAPI_PKGS = com.sun.nio.sctp
|
||||
TRACING_PKGS = com.sun.tracing \
|
||||
com.sun.tracing.dtrace
|
||||
|
||||
ORACLENET_PKGS = com.oracle.net
|
||||
|
||||
# non-core packages in rt.jar
|
||||
NON_CORE_PKGS = $(DOMAPI_PKGS) \
|
||||
$(MGMT_PKGS) \
|
||||
@ -103,6 +101,5 @@ NON_CORE_PKGS = $(DOMAPI_PKGS) \
|
||||
$(HTTPSERVER_PKGS) \
|
||||
$(SMARTCARDIO_PKGS) \
|
||||
$(TRACING_PKGS) \
|
||||
$(SCTPAPI_PKGS) \
|
||||
$(ORACLENET_PKGS)
|
||||
$(SCTPAPI_PKGS)
|
||||
|
||||
|
||||
@ -466,7 +466,6 @@ JAVA_JAVA_java = \
|
||||
java/security/ProtectionDomain.java \
|
||||
java/net/URLClassLoader.java \
|
||||
java/net/URLConnection.java \
|
||||
sun/misc/BootClassLoaderHook.java \
|
||||
sun/misc/Launcher.java \
|
||||
sun/misc/MetaIndex.java \
|
||||
sun/misc/URLClassPath.java \
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2011, 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
|
||||
@ -26,9 +26,7 @@
|
||||
package com.sun.jarsigner;
|
||||
|
||||
import java.net.URI;
|
||||
import java.security.cert.X509CRL;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.Set;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
/**
|
||||
@ -82,13 +80,6 @@ public interface ContentSignerParameters {
|
||||
*/
|
||||
public X509Certificate[] getSignerCertificateChain();
|
||||
|
||||
/**
|
||||
* Retrieves the signer's X.509 CRLs.
|
||||
*
|
||||
* @return An unmodifiable set of X.509 CRLs (never <code>null</code>)
|
||||
*/
|
||||
public Set<X509CRL> getCRLs();
|
||||
|
||||
/**
|
||||
* Retrieves the content that was signed.
|
||||
* The content is the JAR file's signature file.
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 2011, 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
|
||||
@ -1011,7 +1011,7 @@ class PackageReader extends BandStructure {
|
||||
return -1;
|
||||
}
|
||||
|
||||
Comparator<Entry> entryOutputOrder = new Comparator<>() {
|
||||
Comparator<Entry> entryOutputOrder = new Comparator<Entry>() {
|
||||
public int compare(Entry e0, Entry e1) {
|
||||
int k0 = getOutputIndex(e0);
|
||||
int k1 = getOutputIndex(e1);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 2011, 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
|
||||
@ -785,7 +785,7 @@ class PackageWriter extends BandStructure {
|
||||
defMap.entrySet().toArray(layoutsAndCounts);
|
||||
// Sort by count, most frequent first.
|
||||
// Predefs. participate in this sort, though it does not matter.
|
||||
Arrays.sort(layoutsAndCounts, new Comparator<>() {
|
||||
Arrays.sort(layoutsAndCounts, new Comparator<Object>() {
|
||||
public int compare(Object o0, Object o1) {
|
||||
Map.Entry e0 = (Map.Entry) o0;
|
||||
Map.Entry e1 = (Map.Entry) o1;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2011, 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
|
||||
@ -380,13 +380,19 @@ public final class Connection implements Runnable {
|
||||
}
|
||||
|
||||
LdapRequest writeRequest(BerEncoder ber, int msgId) throws IOException {
|
||||
return writeRequest(ber, msgId, false /* pauseAfterReceipt */);
|
||||
return writeRequest(ber, msgId, false /* pauseAfterReceipt */, -1);
|
||||
}
|
||||
|
||||
LdapRequest writeRequest(BerEncoder ber, int msgId, boolean pauseAfterReceipt)
|
||||
throws IOException {
|
||||
LdapRequest writeRequest(BerEncoder ber, int msgId,
|
||||
boolean pauseAfterReceipt) throws IOException {
|
||||
return writeRequest(ber, msgId, pauseAfterReceipt, -1);
|
||||
}
|
||||
|
||||
LdapRequest req = new LdapRequest(msgId, pauseAfterReceipt);
|
||||
LdapRequest writeRequest(BerEncoder ber, int msgId,
|
||||
boolean pauseAfterReceipt, int replyQueueCapacity) throws IOException {
|
||||
|
||||
LdapRequest req =
|
||||
new LdapRequest(msgId, pauseAfterReceipt, replyQueueCapacity);
|
||||
addRequest(req);
|
||||
|
||||
if (traceFile != null) {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2011, 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
|
||||
@ -516,7 +516,8 @@ public final class LdapClient implements PooledConnection {
|
||||
LdapResult search(String dn, int scope, int deref, int sizeLimit,
|
||||
int timeLimit, boolean attrsOnly, String attrs[],
|
||||
String filter, int batchSize, Control[] reqCtls,
|
||||
Hashtable binaryAttrs, boolean waitFirstReply)
|
||||
Hashtable binaryAttrs, boolean waitFirstReply,
|
||||
int replyQueueCapacity)
|
||||
throws IOException, NamingException {
|
||||
|
||||
ensureOpen();
|
||||
@ -543,7 +544,8 @@ public final class LdapClient implements PooledConnection {
|
||||
if (isLdapv3) encodeControls(ber, reqCtls);
|
||||
ber.endSeq();
|
||||
|
||||
LdapRequest req = conn.writeRequest(ber, curMsgId);
|
||||
LdapRequest req =
|
||||
conn.writeRequest(ber, curMsgId, false, replyQueueCapacity);
|
||||
|
||||
res.msgId = curMsgId;
|
||||
res.status = LdapClient.LDAP_SUCCESS; //optimistic
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2011, 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
|
||||
@ -191,6 +191,14 @@ final public class LdapCtx extends ComponentDirContext
|
||||
// Environment property for the domain name (derived from this context's DN)
|
||||
private static final String DOMAIN_NAME = "com.sun.jndi.ldap.domainname";
|
||||
|
||||
// Block until the first search reply is received
|
||||
private static final String WAIT_FOR_REPLY =
|
||||
"com.sun.jndi.ldap.search.waitForReply";
|
||||
|
||||
// Size of the queue of unprocessed search replies
|
||||
private static final String REPLY_QUEUE_SIZE =
|
||||
"com.sun.jndi.ldap.search.replyQueueSize";
|
||||
|
||||
// ----------------- Fields that don't change -----------------------
|
||||
private static final NameParser parser = new LdapNameParser();
|
||||
|
||||
@ -246,6 +254,8 @@ final public class LdapCtx extends ComponentDirContext
|
||||
private Hashtable binaryAttrs = null; // attr values returned as byte[]
|
||||
private int connectTimeout = -1; // no timeout value
|
||||
private int readTimeout = -1; // no timeout value
|
||||
private boolean waitForReply = true; // wait for search response
|
||||
private int replyQueueSize = -1; // unlimited queue size
|
||||
private boolean useSsl = false; // true if SSL protocol is active
|
||||
private boolean useDefaultPortNumber = false; // no port number was supplied
|
||||
|
||||
@ -1759,8 +1769,8 @@ final public class LdapCtx extends ComponentDirContext
|
||||
SearchControls cons,
|
||||
Continuation cont)
|
||||
throws NamingException {
|
||||
return searchAux(name, filter, cloneSearchControls(cons), true, true,
|
||||
cont);
|
||||
return searchAux(name, filter, cloneSearchControls(cons), true,
|
||||
waitForReply, cont);
|
||||
}
|
||||
|
||||
protected NamingEnumeration c_search(Name name,
|
||||
@ -1928,7 +1938,7 @@ final public class LdapCtx extends ComponentDirContext
|
||||
}
|
||||
|
||||
private LdapResult doSearch(Name name, String filter, SearchControls cons,
|
||||
boolean relative, boolean waitFirstReply) throws NamingException {
|
||||
boolean relative, boolean waitForReply) throws NamingException {
|
||||
ensureOpen();
|
||||
try {
|
||||
int scope;
|
||||
@ -1984,7 +1994,8 @@ final public class LdapCtx extends ComponentDirContext
|
||||
batchSize,
|
||||
reqCtls,
|
||||
binaryAttrs,
|
||||
waitFirstReply);
|
||||
waitForReply,
|
||||
replyQueueSize);
|
||||
respCtls = answer.resControls; // retrieve response controls
|
||||
return answer;
|
||||
|
||||
@ -2170,6 +2181,10 @@ final public class LdapCtx extends ComponentDirContext
|
||||
connectTimeout = -1;
|
||||
} else if (propName.equals(READ_TIMEOUT)) {
|
||||
readTimeout = -1;
|
||||
} else if (propName.equals(WAIT_FOR_REPLY)) {
|
||||
waitForReply = true;
|
||||
} else if (propName.equals(REPLY_QUEUE_SIZE)) {
|
||||
replyQueueSize = -1;
|
||||
|
||||
// The following properties affect the connection
|
||||
|
||||
@ -2225,6 +2240,11 @@ final public class LdapCtx extends ComponentDirContext
|
||||
setConnectTimeout((String)propVal);
|
||||
} else if (propName.equals(READ_TIMEOUT)) {
|
||||
setReadTimeout((String)propVal);
|
||||
} else if (propName.equals(WAIT_FOR_REPLY)) {
|
||||
setWaitForReply((String)propVal);
|
||||
} else if (propName.equals(REPLY_QUEUE_SIZE)) {
|
||||
setReplyQueueSize((String)propVal);
|
||||
|
||||
// The following properties affect the connection
|
||||
|
||||
} else if (propName.equals(Context.SECURITY_PROTOCOL)) {
|
||||
@ -2312,6 +2332,13 @@ final public class LdapCtx extends ComponentDirContext
|
||||
// Set the read timeout
|
||||
setReadTimeout((String)envprops.get(READ_TIMEOUT));
|
||||
|
||||
// Set the flag that controls whether to block until the first reply
|
||||
// is received
|
||||
setWaitForReply((String)envprops.get(WAIT_FOR_REPLY));
|
||||
|
||||
// Set the size of the queue of unprocessed search replies
|
||||
setReplyQueueSize((String)envprops.get(REPLY_QUEUE_SIZE));
|
||||
|
||||
// When connection is created, it will use these and other
|
||||
// properties from the environment
|
||||
}
|
||||
@ -2441,6 +2468,34 @@ final public class LdapCtx extends ComponentDirContext
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the size of the queue of unprocessed search replies
|
||||
*/
|
||||
private void setReplyQueueSize(String replyQueueSizeProp) {
|
||||
if (replyQueueSizeProp != null) {
|
||||
replyQueueSize = Integer.parseInt(replyQueueSizeProp);
|
||||
// disallow an empty queue
|
||||
if (replyQueueSize <= 0) {
|
||||
replyQueueSize = -1; // unlimited
|
||||
}
|
||||
} else {
|
||||
replyQueueSize = -1; // unlimited
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the flag that controls whether to block until the first search
|
||||
* reply is received
|
||||
*/
|
||||
private void setWaitForReply(String waitForReplyProp) {
|
||||
if (waitForReplyProp != null &&
|
||||
(waitForReplyProp.equalsIgnoreCase("false"))) {
|
||||
waitForReply = false;
|
||||
} else {
|
||||
waitForReply = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the read timeout value
|
||||
*/
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2002, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2011, 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
|
||||
@ -26,7 +26,8 @@
|
||||
package com.sun.jndi.ldap;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Vector;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import javax.naming.CommunicationException;
|
||||
|
||||
final class LdapRequest {
|
||||
@ -35,14 +36,26 @@ final class LdapRequest {
|
||||
int msgId; // read-only
|
||||
|
||||
private int gotten = 0;
|
||||
private Vector replies = new Vector(3);
|
||||
private BlockingQueue<BerDecoder> replies;
|
||||
private int highWatermark = -1;
|
||||
private boolean cancelled = false;
|
||||
private boolean pauseAfterReceipt = false;
|
||||
private boolean completed = false;
|
||||
|
||||
LdapRequest(int msgId, boolean pause) {
|
||||
this(msgId, pause, -1);
|
||||
}
|
||||
|
||||
LdapRequest(int msgId, boolean pause, int replyQueueCapacity) {
|
||||
this.msgId = msgId;
|
||||
this.pauseAfterReceipt = pause;
|
||||
if (replyQueueCapacity == -1) {
|
||||
this.replies = new LinkedBlockingQueue<BerDecoder>();
|
||||
} else {
|
||||
this.replies =
|
||||
new LinkedBlockingQueue<BerDecoder>(replyQueueCapacity);
|
||||
highWatermark = (replyQueueCapacity * 80) / 100; // 80% capacity
|
||||
}
|
||||
}
|
||||
|
||||
synchronized void cancel() {
|
||||
@ -57,7 +70,13 @@ final class LdapRequest {
|
||||
if (cancelled) {
|
||||
return false;
|
||||
}
|
||||
replies.addElement(ber);
|
||||
|
||||
// Add a new reply to the queue of unprocessed replies.
|
||||
try {
|
||||
replies.put(ber);
|
||||
} catch (InterruptedException e) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
// peek at the BER buffer to check if it is a SearchResultDone PDU
|
||||
try {
|
||||
@ -70,6 +89,14 @@ final class LdapRequest {
|
||||
ber.reset();
|
||||
|
||||
notify(); // notify anyone waiting for reply
|
||||
/*
|
||||
* If a queue capacity has been set then trigger a pause when the
|
||||
* queue has filled to 80% capacity. Later, when the queue has drained
|
||||
* then the reader gets unpaused.
|
||||
*/
|
||||
if (highWatermark != -1 && replies.size() >= highWatermark) {
|
||||
return true; // trigger the pause
|
||||
}
|
||||
return pauseAfterReceipt;
|
||||
}
|
||||
|
||||
@ -79,14 +106,12 @@ final class LdapRequest {
|
||||
" cancelled");
|
||||
}
|
||||
|
||||
if (gotten < replies.size()) {
|
||||
BerDecoder answer = (BerDecoder)replies.elementAt(gotten);
|
||||
replies.setElementAt(null, gotten); // remove reference
|
||||
++gotten; // skip to next
|
||||
return answer;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
/*
|
||||
* Remove a reply if the queue is not empty.
|
||||
* poll returns null if queue is empty.
|
||||
*/
|
||||
BerDecoder reply = replies.poll();
|
||||
return reply;
|
||||
}
|
||||
|
||||
synchronized boolean hasSearchCompleted() {
|
||||
|
||||
@ -58,7 +58,6 @@ import java.util.StringTokenizer;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
|
||||
import sun.misc.BootClassLoaderHook;
|
||||
|
||||
/**
|
||||
* A representation of color profile data for device independent and
|
||||
@ -865,8 +864,7 @@ public class ICC_Profile implements Serializable {
|
||||
case ColorSpace.CS_PYCC:
|
||||
synchronized(ICC_Profile.class) {
|
||||
if (PYCCprofile == null) {
|
||||
if (BootClassLoaderHook.getHook() != null ||
|
||||
standardProfileExists("PYCC.pf"))
|
||||
if (standardProfileExists("PYCC.pf"))
|
||||
{
|
||||
ProfileDeferralInfo pInfo =
|
||||
new ProfileDeferralInfo("PYCC.pf",
|
||||
|
||||
@ -2055,7 +2055,7 @@ public class File
|
||||
*
|
||||
* @return a {@code Path} constructed from this abstract path
|
||||
*
|
||||
* @throws InvalidPathException
|
||||
* @throws java.nio.file.InvalidPathException
|
||||
* if a {@code Path} object cannot be constructed from the abstract
|
||||
* path (see {@link java.nio.file.FileSystem#getPath FileSystem.getPath})
|
||||
*
|
||||
|
||||
@ -51,7 +51,6 @@ import java.util.Vector;
|
||||
import java.util.Hashtable;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import sun.misc.BootClassLoaderHook;
|
||||
import sun.misc.ClassFileTransformer;
|
||||
import sun.misc.CompoundEnumeration;
|
||||
import sun.misc.Resource;
|
||||
@ -1300,7 +1299,6 @@ public abstract class ClassLoader {
|
||||
* Find resources from the VM's built-in classloader.
|
||||
*/
|
||||
private static URL getBootstrapResource(String name) {
|
||||
BootClassLoaderHook.preLoadResource(name);
|
||||
URLClassPath ucp = getBootstrapClassPath();
|
||||
Resource res = ucp.getResource(name);
|
||||
return res != null ? res.getURL() : null;
|
||||
@ -1814,7 +1812,6 @@ public abstract class ClassLoader {
|
||||
// Invoked in the java.lang.Runtime class to implement load and loadLibrary.
|
||||
static void loadLibrary(Class fromClass, String name,
|
||||
boolean isAbsolute) {
|
||||
BootClassLoaderHook.preLoadLibrary(name);
|
||||
ClassLoader loader =
|
||||
(fromClass == null) ? null : fromClass.getClassLoader();
|
||||
if (sys_paths == null) {
|
||||
|
||||
@ -576,12 +576,10 @@ public class Package implements java.lang.reflect.AnnotatedElement {
|
||||
* Returns the Manifest for the specified JAR file name.
|
||||
*/
|
||||
private static Manifest loadManifest(String fn) {
|
||||
try {
|
||||
FileInputStream fis = new FileInputStream(fn);
|
||||
JarInputStream jis = new JarInputStream(fis, false);
|
||||
Manifest man = jis.getManifest();
|
||||
jis.close();
|
||||
return man;
|
||||
try (FileInputStream fis = new FileInputStream(fn);
|
||||
JarInputStream jis = new JarInputStream(fis, false))
|
||||
{
|
||||
return jis.getManifest();
|
||||
} catch (IOException e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -400,7 +400,8 @@ abstract public class HttpURLConnection extends URLConnection {
|
||||
* @exception ProtocolException if the method cannot be reset or if
|
||||
* the requested method isn't valid for HTTP.
|
||||
* @exception SecurityException if a security manager is set and the
|
||||
* "allowHttpTrace" NetPermission is not granted.
|
||||
* method is "TRACE", but the "allowHttpTrace"
|
||||
* NetPermission is not granted.
|
||||
* @see #getRequestMethod()
|
||||
*/
|
||||
public void setRequestMethod(String method) throws ProtocolException {
|
||||
|
||||
@ -73,6 +73,13 @@ import java.util.StringTokenizer;
|
||||
* </tr>
|
||||
*
|
||||
* <tr>
|
||||
* <td>getNetworkInformation</td>
|
||||
* <td>The ability to retrieve all information about local network interfaces.</td>
|
||||
* <td>Malicious code can read information about network hardware such as
|
||||
* MAC addresses, which could be used to construct local IPv6 addresses.</td>
|
||||
* </tr>
|
||||
*
|
||||
* <tr>
|
||||
* <td>getProxySelector</td>
|
||||
* <td>The ability to get the proxy selector used to make decisions
|
||||
* on which proxies to use when making network connections.</td>
|
||||
|
||||
@ -991,7 +991,7 @@ public final class URI
|
||||
* authority and path are taken from the given URI. </p></li>
|
||||
*
|
||||
* <li><p> Otherwise the new URI's authority component is copied from
|
||||
* this URI, and its path is computed as follows: </p></li>
|
||||
* this URI, and its path is computed as follows: </p>
|
||||
*
|
||||
* <ol type=a>
|
||||
*
|
||||
@ -1005,7 +1005,7 @@ public final class URI
|
||||
* path and then normalizing the result as if by invoking the {@link
|
||||
* #normalize() normalize} method. </p></li>
|
||||
*
|
||||
* </ol>
|
||||
* </ol></li>
|
||||
*
|
||||
* </ol>
|
||||
*
|
||||
@ -1511,7 +1511,7 @@ public final class URI
|
||||
* fragments. </p></li>
|
||||
*
|
||||
* <li><p> Two hierarchical URIs with identical schemes are ordered
|
||||
* according to the ordering of their authority components: </p></li>
|
||||
* according to the ordering of their authority components: </p>
|
||||
*
|
||||
* <ul type=disc>
|
||||
*
|
||||
@ -1526,7 +1526,7 @@ public final class URI
|
||||
* the URIs are ordered according to the ordering of their authority
|
||||
* components. </p></li>
|
||||
*
|
||||
* </ul>
|
||||
* </ul></li>
|
||||
*
|
||||
* <li><p> Finally, two hierarchical URIs with identical schemes and
|
||||
* authority components are ordered according to the ordering of their
|
||||
|
||||
@ -31,18 +31,18 @@ Provides the classes for implementing networking applications.
|
||||
|
||||
<p> The java.net package can be roughly divided in two sections:</p>
|
||||
<ul>
|
||||
<li> <p><i>A Low Level API</i>, which deals with the following abstractions:</p></li>
|
||||
<li> <p><i>A Low Level API</i>, which deals with the following abstractions:</p>
|
||||
<ul>
|
||||
<li><p><i>Addresses</i>, which are networking identifiers, like IP addresses.</p></li>
|
||||
<li><p><i>Sockets</i>, which are basic bidirectional data communication mechanisms.</p></li>
|
||||
<li><p><i>Interfaces</i>, which describe network interfaces. </p></li>
|
||||
</ul>
|
||||
<li> <p><i>A High Level API</i>, which deals with the following abstractions:</p></li>
|
||||
</ul></li>
|
||||
<li> <p><i>A High Level API</i>, which deals with the following abstractions:</p>
|
||||
<ul>
|
||||
<li><p><i>URIs</i>, which represent Universal Resource Identifiers.</p></li>
|
||||
<li><p><i>URLs</i>, which represent Universal Resource Locators.</p></li>
|
||||
<li><p><i>Connections</i>, which represents connections to the resource pointed to by <i>URLs</i>.</p></li>
|
||||
</ul>
|
||||
</ul></li>
|
||||
</ul>
|
||||
<h2>Addresses</h2>
|
||||
<p>Addresses are used throughout the java.net APIs as either host identifiers, or socket endpoint identifiers.</p>
|
||||
|
||||
@ -48,12 +48,12 @@ import java.util.Collections;
|
||||
*
|
||||
* <p> An asynchronous file channel does not have a <i>current position</i>
|
||||
* within the file. Instead, the file position is specified to each read and
|
||||
* write methd that initiate asynchronous operations. A {@link CompletionHandler}
|
||||
* write method that initiates asynchronous operations. A {@link CompletionHandler}
|
||||
* is specified as a parameter and is invoked to consume the result of the I/O
|
||||
* operation. This class also defines read and write methods that initiate
|
||||
* asynchronous operations, returning a {@link Future} to represent the pending
|
||||
* result of the operation. The {@code Future} may be used to check if the
|
||||
* operation has completed, to wait for its completion.
|
||||
* operation has completed, wait for its completion, and retrieve the result.
|
||||
*
|
||||
* <p> In addition to read and write operations, this class defines the
|
||||
* following operations: </p>
|
||||
@ -73,13 +73,13 @@ import java.util.Collections;
|
||||
* which tasks are submitted to handle I/O events and dispatch to completion
|
||||
* handlers that consume the results of I/O operations on the channel. The
|
||||
* completion handler for an I/O operation initiated on a channel is guaranteed
|
||||
* to be invoked by one threads in the thread pool (This ensures that the
|
||||
* to be invoked by one of the threads in the thread pool (This ensures that the
|
||||
* completion handler is run by a thread with the expected <em>identity</em>).
|
||||
* Where an I/O operation completes immediately, and the initiating thread is
|
||||
* itself a thread in the thread pool, then the completion handler may be invoked
|
||||
* directly by the initiating thread. When an {@code AsynchronousFileChannel} is
|
||||
* created without specifying a thread pool then the channel is associated with
|
||||
* a system-dependent and default thread pool that may be shared with other
|
||||
* a system-dependent default thread pool that may be shared with other
|
||||
* channels. The default thread pool is configured by the system properties
|
||||
* defined by the {@link AsynchronousChannelGroup} class.
|
||||
*
|
||||
|
||||
@ -182,10 +182,13 @@ public abstract class SocketChannel
|
||||
SocketChannel sc = open();
|
||||
try {
|
||||
sc.connect(remote);
|
||||
} finally {
|
||||
if (!sc.isConnected()) {
|
||||
try { sc.close(); } catch (IOException x) { }
|
||||
} catch (Throwable x) {
|
||||
try {
|
||||
sc.close();
|
||||
} catch (Throwable suppressed) {
|
||||
x.addSuppressed(suppressed);
|
||||
}
|
||||
throw x;
|
||||
}
|
||||
assert sc.isConnected();
|
||||
return sc;
|
||||
|
||||
@ -135,11 +135,13 @@ class CopyMoveHelper {
|
||||
view.setTimes(attrs.lastModifiedTime(),
|
||||
attrs.lastAccessTime(),
|
||||
attrs.creationTime());
|
||||
} catch (IOException x) {
|
||||
} catch (Throwable x) {
|
||||
// rollback
|
||||
try {
|
||||
Files.delete(target);
|
||||
} catch (IOException ignore) { }
|
||||
} catch (Throwable suppressed) {
|
||||
x.addSuppressed(suppressed);
|
||||
}
|
||||
throw x;
|
||||
}
|
||||
}
|
||||
|
||||
@ -129,17 +129,18 @@ public final class Files {
|
||||
* <pre>
|
||||
* Path path = ...
|
||||
*
|
||||
* // replace an existing file or create the file if it doesn't initially exist
|
||||
* // truncate and overwrite an existing file, or create the file if
|
||||
* // it doesn't initially exist
|
||||
* OutputStream out = Files.newOutputStream(path);
|
||||
*
|
||||
* // append to an existing file, fail if the file does not exist
|
||||
* out = Files.newOutputStream(path, APPEND);
|
||||
*
|
||||
* // append to an existing file, create file if it doesn't initially exist
|
||||
* out = Files.newOutputStream(CREATE, APPEND);
|
||||
* out = Files.newOutputStream(path, CREATE, APPEND);
|
||||
*
|
||||
* // always create new file, failing if it already exists
|
||||
* out = Files.newOutputStream(CREATE_NEW);
|
||||
* out = Files.newOutputStream(path, CREATE_NEW);
|
||||
* </pre>
|
||||
*
|
||||
* @param path
|
||||
@ -793,7 +794,8 @@ public final class Files {
|
||||
FileAttribute<?>... attrs)
|
||||
throws IOException
|
||||
{
|
||||
return TempFileHelper.createTempFile(dir, prefix, suffix, attrs);
|
||||
return TempFileHelper.createTempFile(Objects.requireNonNull(dir),
|
||||
prefix, suffix, attrs);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -890,13 +892,14 @@ public final class Files {
|
||||
FileAttribute<?>... attrs)
|
||||
throws IOException
|
||||
{
|
||||
return TempFileHelper.createTempDirectory(dir, prefix, attrs);
|
||||
return TempFileHelper.createTempDirectory(Objects.requireNonNull(dir),
|
||||
prefix, attrs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new directory in the default temporary-file directory, using
|
||||
* the given prefix and suffix to generate its name. The resulting {@code
|
||||
* Path} is associated with the default {@code FileSystem}.
|
||||
* the given prefix to generate its name. The resulting {@code Path} is
|
||||
* associated with the default {@code FileSystem}.
|
||||
*
|
||||
* <p> This method works in exactly the manner specified by {@link
|
||||
* #createTempDirectory(Path,String,FileAttribute[])} method for the case
|
||||
@ -2583,7 +2586,7 @@ public final class Files {
|
||||
* walkFileTree(start, EnumSet.noneOf(FileVisitOption.class), Integer.MAX_VALUE, visitor)
|
||||
* </pre></blockquote>
|
||||
* In other words, it does not follow symbolic links, and visits all levels
|
||||
* of the file level.
|
||||
* of the file tree.
|
||||
*
|
||||
* @param start
|
||||
* the starting file
|
||||
@ -3005,7 +3008,7 @@ public final class Files {
|
||||
* or after some bytes have been written to the file.
|
||||
*
|
||||
* <p> <b>Usage example</b>: By default the method creates a new file or
|
||||
* overrides an existing file. Suppose you instead want to append bytes
|
||||
* overwrites an existing file. Suppose you instead want to append bytes
|
||||
* to an existing file:
|
||||
* <pre>
|
||||
* Path path = ...
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2011, 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
|
||||
@ -26,10 +26,7 @@
|
||||
package java.security;
|
||||
|
||||
import java.io.*;
|
||||
import java.security.cert.CRL;
|
||||
import java.security.cert.CertPath;
|
||||
import sun.misc.JavaSecurityCodeSignerAccess;
|
||||
import sun.misc.SharedSecrets;
|
||||
|
||||
/**
|
||||
* This class encapsulates information about a code signer.
|
||||
@ -167,44 +164,6 @@ public final class CodeSigner implements Serializable {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
// A private attribute attached to this CodeSigner object. Can be accessed
|
||||
// through SharedSecrets.getJavaSecurityCodeSignerAccess().[g|s]etCRLs
|
||||
//
|
||||
// Currently called in SignatureFileVerifier.getSigners
|
||||
private transient CRL[] crls;
|
||||
|
||||
/**
|
||||
* Sets the CRLs attached
|
||||
* @param crls, null to clear
|
||||
*/
|
||||
void setCRLs(CRL[] crls) {
|
||||
this.crls = crls;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the CRLs attached
|
||||
* @return the crls, initially null
|
||||
*/
|
||||
CRL[] getCRLs() {
|
||||
return crls;
|
||||
}
|
||||
|
||||
// Set up JavaSecurityCodeSignerAccess in SharedSecrets
|
||||
static {
|
||||
SharedSecrets.setJavaSecurityCodeSignerAccess(
|
||||
new JavaSecurityCodeSignerAccess() {
|
||||
@Override
|
||||
public void setCRLs(CodeSigner signer, CRL[] crls) {
|
||||
signer.setCRLs(crls);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CRL[] getCRLs(CodeSigner signer) {
|
||||
return signer.getCRLs();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Explicitly reset hash code value to -1
|
||||
private void readObject(ObjectInputStream ois)
|
||||
throws IOException, ClassNotFoundException {
|
||||
|
||||
@ -233,7 +233,9 @@ public final class Currency implements Serializable {
|
||||
"currency.properties");
|
||||
if (propFile.exists()) {
|
||||
Properties props = new Properties();
|
||||
props.load(new FileReader(propFile));
|
||||
try (FileReader fr = new FileReader(propFile)) {
|
||||
props.load(fr);
|
||||
}
|
||||
Set<String> keys = props.stringPropertyNames();
|
||||
Pattern propertiesPattern =
|
||||
Pattern.compile("([A-Z]{3})\\s*,\\s*(\\d{3})\\s*,\\s*([0-3])");
|
||||
|
||||
@ -272,13 +272,6 @@ public class ConcurrentLinkedDeque<E>
|
||||
|
||||
private static final Node<Object> PREV_TERMINATOR, NEXT_TERMINATOR;
|
||||
|
||||
static {
|
||||
PREV_TERMINATOR = new Node<Object>(null);
|
||||
PREV_TERMINATOR.next = PREV_TERMINATOR;
|
||||
NEXT_TERMINATOR = new Node<Object>(null);
|
||||
NEXT_TERMINATOR.prev = NEXT_TERMINATOR;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Node<E> prevTerminator() {
|
||||
return (Node<E>) PREV_TERMINATOR;
|
||||
@ -294,6 +287,9 @@ public class ConcurrentLinkedDeque<E>
|
||||
volatile E item;
|
||||
volatile Node<E> next;
|
||||
|
||||
Node() { // default constructor for NEXT_TERMINATOR, PREV_TERMINATOR
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new node. Uses relaxed write because item can
|
||||
* only be seen after publication via casNext or casPrev.
|
||||
@ -324,14 +320,25 @@ public class ConcurrentLinkedDeque<E>
|
||||
|
||||
// Unsafe mechanics
|
||||
|
||||
private static final sun.misc.Unsafe UNSAFE =
|
||||
sun.misc.Unsafe.getUnsafe();
|
||||
private static final long prevOffset =
|
||||
objectFieldOffset(UNSAFE, "prev", Node.class);
|
||||
private static final long itemOffset =
|
||||
objectFieldOffset(UNSAFE, "item", Node.class);
|
||||
private static final long nextOffset =
|
||||
objectFieldOffset(UNSAFE, "next", Node.class);
|
||||
private static final sun.misc.Unsafe UNSAFE;
|
||||
private static final long prevOffset;
|
||||
private static final long itemOffset;
|
||||
private static final long nextOffset;
|
||||
|
||||
static {
|
||||
try {
|
||||
UNSAFE = sun.misc.Unsafe.getUnsafe();
|
||||
Class k = Node.class;
|
||||
prevOffset = UNSAFE.objectFieldOffset
|
||||
(k.getDeclaredField("prev"));
|
||||
itemOffset = UNSAFE.objectFieldOffset
|
||||
(k.getDeclaredField("item"));
|
||||
nextOffset = UNSAFE.objectFieldOffset
|
||||
(k.getDeclaredField("next"));
|
||||
} catch (Exception e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1422,14 +1429,6 @@ public class ConcurrentLinkedDeque<E>
|
||||
initHeadTail(h, t);
|
||||
}
|
||||
|
||||
// Unsafe mechanics
|
||||
|
||||
private static final sun.misc.Unsafe UNSAFE =
|
||||
sun.misc.Unsafe.getUnsafe();
|
||||
private static final long headOffset =
|
||||
objectFieldOffset(UNSAFE, "head", ConcurrentLinkedDeque.class);
|
||||
private static final long tailOffset =
|
||||
objectFieldOffset(UNSAFE, "tail", ConcurrentLinkedDeque.class);
|
||||
|
||||
private boolean casHead(Node<E> cmp, Node<E> val) {
|
||||
return UNSAFE.compareAndSwapObject(this, headOffset, cmp, val);
|
||||
@ -1439,15 +1438,25 @@ public class ConcurrentLinkedDeque<E>
|
||||
return UNSAFE.compareAndSwapObject(this, tailOffset, cmp, val);
|
||||
}
|
||||
|
||||
static long objectFieldOffset(sun.misc.Unsafe UNSAFE,
|
||||
String field, Class<?> klazz) {
|
||||
// Unsafe mechanics
|
||||
|
||||
private static final sun.misc.Unsafe UNSAFE;
|
||||
private static final long headOffset;
|
||||
private static final long tailOffset;
|
||||
static {
|
||||
PREV_TERMINATOR = new Node<Object>();
|
||||
PREV_TERMINATOR.next = PREV_TERMINATOR;
|
||||
NEXT_TERMINATOR = new Node<Object>();
|
||||
NEXT_TERMINATOR.prev = NEXT_TERMINATOR;
|
||||
try {
|
||||
return UNSAFE.objectFieldOffset(klazz.getDeclaredField(field));
|
||||
} catch (NoSuchFieldException e) {
|
||||
// Convert Exception to corresponding Error
|
||||
NoSuchFieldError error = new NoSuchFieldError(field);
|
||||
error.initCause(e);
|
||||
throw error;
|
||||
UNSAFE = sun.misc.Unsafe.getUnsafe();
|
||||
Class k = ConcurrentLinkedDeque.class;
|
||||
headOffset = UNSAFE.objectFieldOffset
|
||||
(k.getDeclaredField("head"));
|
||||
tailOffset = UNSAFE.objectFieldOffset
|
||||
(k.getDeclaredField("tail"));
|
||||
} catch (Exception e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -194,12 +194,22 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
|
||||
|
||||
// Unsafe mechanics
|
||||
|
||||
private static final sun.misc.Unsafe UNSAFE =
|
||||
sun.misc.Unsafe.getUnsafe();
|
||||
private static final long nextOffset =
|
||||
objectFieldOffset(UNSAFE, "next", Node.class);
|
||||
private static final long itemOffset =
|
||||
objectFieldOffset(UNSAFE, "item", Node.class);
|
||||
private static final sun.misc.Unsafe UNSAFE;
|
||||
private static final long itemOffset;
|
||||
private static final long nextOffset;
|
||||
|
||||
static {
|
||||
try {
|
||||
UNSAFE = sun.misc.Unsafe.getUnsafe();
|
||||
Class k = Node.class;
|
||||
itemOffset = UNSAFE.objectFieldOffset
|
||||
(k.getDeclaredField("item"));
|
||||
nextOffset = UNSAFE.objectFieldOffset
|
||||
(k.getDeclaredField("next"));
|
||||
} catch (Exception e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -790,14 +800,6 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
|
||||
throw new NullPointerException();
|
||||
}
|
||||
|
||||
// Unsafe mechanics
|
||||
|
||||
private static final sun.misc.Unsafe UNSAFE = sun.misc.Unsafe.getUnsafe();
|
||||
private static final long headOffset =
|
||||
objectFieldOffset(UNSAFE, "head", ConcurrentLinkedQueue.class);
|
||||
private static final long tailOffset =
|
||||
objectFieldOffset(UNSAFE, "tail", ConcurrentLinkedQueue.class);
|
||||
|
||||
private boolean casTail(Node<E> cmp, Node<E> val) {
|
||||
return UNSAFE.compareAndSwapObject(this, tailOffset, cmp, val);
|
||||
}
|
||||
@ -806,15 +808,21 @@ public class ConcurrentLinkedQueue<E> extends AbstractQueue<E>
|
||||
return UNSAFE.compareAndSwapObject(this, headOffset, cmp, val);
|
||||
}
|
||||
|
||||
static long objectFieldOffset(sun.misc.Unsafe UNSAFE,
|
||||
String field, Class<?> klazz) {
|
||||
// Unsafe mechanics
|
||||
|
||||
private static final sun.misc.Unsafe UNSAFE;
|
||||
private static final long headOffset;
|
||||
private static final long tailOffset;
|
||||
static {
|
||||
try {
|
||||
return UNSAFE.objectFieldOffset(klazz.getDeclaredField(field));
|
||||
} catch (NoSuchFieldException e) {
|
||||
// Convert Exception to corresponding Error
|
||||
NoSuchFieldError error = new NoSuchFieldError(field);
|
||||
error.initCause(e);
|
||||
throw error;
|
||||
UNSAFE = sun.misc.Unsafe.getUnsafe();
|
||||
Class k = ConcurrentLinkedQueue.class;
|
||||
headOffset = UNSAFE.objectFieldOffset
|
||||
(k.getDeclaredField("head"));
|
||||
tailOffset = UNSAFE.objectFieldOffset
|
||||
(k.getDeclaredField("tail"));
|
||||
} catch (Exception e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -507,13 +507,24 @@ public class ConcurrentSkipListMap<K,V> extends AbstractMap<K,V>
|
||||
return new AbstractMap.SimpleImmutableEntry<K,V>(key, v);
|
||||
}
|
||||
|
||||
// Unsafe mechanics
|
||||
private static final sun.misc.Unsafe UNSAFE = sun.misc.Unsafe.getUnsafe();
|
||||
private static final long valueOffset =
|
||||
objectFieldOffset(UNSAFE, "value", Node.class);
|
||||
private static final long nextOffset =
|
||||
objectFieldOffset(UNSAFE, "next", Node.class);
|
||||
// UNSAFE mechanics
|
||||
|
||||
private static final sun.misc.Unsafe UNSAFE;
|
||||
private static final long valueOffset;
|
||||
private static final long nextOffset;
|
||||
|
||||
static {
|
||||
try {
|
||||
UNSAFE = sun.misc.Unsafe.getUnsafe();
|
||||
Class k = Node.class;
|
||||
valueOffset = UNSAFE.objectFieldOffset
|
||||
(k.getDeclaredField("value"));
|
||||
nextOffset = UNSAFE.objectFieldOffset
|
||||
(k.getDeclaredField("next"));
|
||||
} catch (Exception e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------- Indexing -------------- */
|
||||
@ -580,10 +591,18 @@ public class ConcurrentSkipListMap<K,V> extends AbstractMap<K,V>
|
||||
}
|
||||
|
||||
// Unsafe mechanics
|
||||
private static final sun.misc.Unsafe UNSAFE = sun.misc.Unsafe.getUnsafe();
|
||||
private static final long rightOffset =
|
||||
objectFieldOffset(UNSAFE, "right", Index.class);
|
||||
|
||||
private static final sun.misc.Unsafe UNSAFE;
|
||||
private static final long rightOffset;
|
||||
static {
|
||||
try {
|
||||
UNSAFE = sun.misc.Unsafe.getUnsafe();
|
||||
Class k = Index.class;
|
||||
rightOffset = UNSAFE.objectFieldOffset
|
||||
(k.getDeclaredField("right"));
|
||||
} catch (Exception e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------- Head nodes -------------- */
|
||||
@ -3082,20 +3101,16 @@ public class ConcurrentSkipListMap<K,V> extends AbstractMap<K,V>
|
||||
}
|
||||
|
||||
// Unsafe mechanics
|
||||
private static final sun.misc.Unsafe UNSAFE = sun.misc.Unsafe.getUnsafe();
|
||||
private static final long headOffset =
|
||||
objectFieldOffset(UNSAFE, "head", ConcurrentSkipListMap.class);
|
||||
|
||||
static long objectFieldOffset(sun.misc.Unsafe UNSAFE,
|
||||
String field, Class<?> klazz) {
|
||||
private static final sun.misc.Unsafe UNSAFE;
|
||||
private static final long headOffset;
|
||||
static {
|
||||
try {
|
||||
return UNSAFE.objectFieldOffset(klazz.getDeclaredField(field));
|
||||
} catch (NoSuchFieldException e) {
|
||||
// Convert Exception to corresponding Error
|
||||
NoSuchFieldError error = new NoSuchFieldError(field);
|
||||
error.initCause(e);
|
||||
throw error;
|
||||
UNSAFE = sun.misc.Unsafe.getUnsafe();
|
||||
Class k = ConcurrentSkipListMap.class;
|
||||
headOffset = UNSAFE.objectFieldOffset
|
||||
(k.getDeclaredField("head"));
|
||||
} catch (Exception e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -470,16 +470,20 @@ public class ConcurrentSkipListSet<E>
|
||||
}
|
||||
|
||||
// Support for resetting map in clone
|
||||
private static final Unsafe unsafe = Unsafe.getUnsafe();
|
||||
private void setMap(ConcurrentNavigableMap<E,Object> map) {
|
||||
UNSAFE.putObjectVolatile(this, mapOffset, map);
|
||||
}
|
||||
|
||||
private static final sun.misc.Unsafe UNSAFE;
|
||||
private static final long mapOffset;
|
||||
static {
|
||||
try {
|
||||
mapOffset = unsafe.objectFieldOffset
|
||||
(ConcurrentSkipListSet.class.getDeclaredField("m"));
|
||||
} catch (Exception ex) { throw new Error(ex); }
|
||||
UNSAFE = sun.misc.Unsafe.getUnsafe();
|
||||
Class k = ConcurrentSkipListSet.class;
|
||||
mapOffset = UNSAFE.objectFieldOffset
|
||||
(k.getDeclaredField("m"));
|
||||
} catch (Exception e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
private void setMap(ConcurrentNavigableMap<E,Object> map) {
|
||||
unsafe.putObjectVolatile(this, mapOffset, map);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1318,16 +1318,19 @@ public class CopyOnWriteArrayList<E>
|
||||
}
|
||||
|
||||
// Support for resetting lock while deserializing
|
||||
private static final Unsafe unsafe = Unsafe.getUnsafe();
|
||||
private void resetLock() {
|
||||
UNSAFE.putObjectVolatile(this, lockOffset, new ReentrantLock());
|
||||
}
|
||||
private static final sun.misc.Unsafe UNSAFE;
|
||||
private static final long lockOffset;
|
||||
static {
|
||||
try {
|
||||
lockOffset = unsafe.objectFieldOffset
|
||||
(CopyOnWriteArrayList.class.getDeclaredField("lock"));
|
||||
} catch (Exception ex) { throw new Error(ex); }
|
||||
UNSAFE = sun.misc.Unsafe.getUnsafe();
|
||||
Class k = CopyOnWriteArrayList.class;
|
||||
lockOffset = UNSAFE.objectFieldOffset
|
||||
(k.getDeclaredField("lock"));
|
||||
} catch (Exception e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
private void resetLock() {
|
||||
unsafe.putObjectVolatile(this, lockOffset, new ReentrantLock());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -525,16 +525,27 @@ public class LinkedTransferQueue<E> extends AbstractQueue<E>
|
||||
return false;
|
||||
}
|
||||
|
||||
// Unsafe mechanics
|
||||
private static final sun.misc.Unsafe UNSAFE = sun.misc.Unsafe.getUnsafe();
|
||||
private static final long nextOffset =
|
||||
objectFieldOffset(UNSAFE, "next", Node.class);
|
||||
private static final long itemOffset =
|
||||
objectFieldOffset(UNSAFE, "item", Node.class);
|
||||
private static final long waiterOffset =
|
||||
objectFieldOffset(UNSAFE, "waiter", Node.class);
|
||||
|
||||
private static final long serialVersionUID = -3375979862319811754L;
|
||||
|
||||
// Unsafe mechanics
|
||||
private static final sun.misc.Unsafe UNSAFE;
|
||||
private static final long itemOffset;
|
||||
private static final long nextOffset;
|
||||
private static final long waiterOffset;
|
||||
static {
|
||||
try {
|
||||
UNSAFE = sun.misc.Unsafe.getUnsafe();
|
||||
Class k = Node.class;
|
||||
itemOffset = UNSAFE.objectFieldOffset
|
||||
(k.getDeclaredField("item"));
|
||||
nextOffset = UNSAFE.objectFieldOffset
|
||||
(k.getDeclaredField("next"));
|
||||
waiterOffset = UNSAFE.objectFieldOffset
|
||||
(k.getDeclaredField("waiter"));
|
||||
} catch (Exception e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** head of the queue; null until first enqueue */
|
||||
@ -1312,23 +1323,22 @@ public class LinkedTransferQueue<E> extends AbstractQueue<E>
|
||||
|
||||
// Unsafe mechanics
|
||||
|
||||
private static final sun.misc.Unsafe UNSAFE = sun.misc.Unsafe.getUnsafe();
|
||||
private static final long headOffset =
|
||||
objectFieldOffset(UNSAFE, "head", LinkedTransferQueue.class);
|
||||
private static final long tailOffset =
|
||||
objectFieldOffset(UNSAFE, "tail", LinkedTransferQueue.class);
|
||||
private static final long sweepVotesOffset =
|
||||
objectFieldOffset(UNSAFE, "sweepVotes", LinkedTransferQueue.class);
|
||||
|
||||
static long objectFieldOffset(sun.misc.Unsafe UNSAFE,
|
||||
String field, Class<?> klazz) {
|
||||
private static final sun.misc.Unsafe UNSAFE;
|
||||
private static final long headOffset;
|
||||
private static final long tailOffset;
|
||||
private static final long sweepVotesOffset;
|
||||
static {
|
||||
try {
|
||||
return UNSAFE.objectFieldOffset(klazz.getDeclaredField(field));
|
||||
} catch (NoSuchFieldException e) {
|
||||
// Convert Exception to corresponding Error
|
||||
NoSuchFieldError error = new NoSuchFieldError(field);
|
||||
error.initCause(e);
|
||||
throw error;
|
||||
UNSAFE = sun.misc.Unsafe.getUnsafe();
|
||||
Class k = LinkedTransferQueue.class;
|
||||
headOffset = UNSAFE.objectFieldOffset
|
||||
(k.getDeclaredField("head"));
|
||||
tailOffset = UNSAFE.objectFieldOffset
|
||||
(k.getDeclaredField("tail"));
|
||||
sweepVotesOffset = UNSAFE.objectFieldOffset
|
||||
(k.getDeclaredField("sweepVotes"));
|
||||
} catch (Exception e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1137,18 +1137,16 @@ public class Phaser {
|
||||
|
||||
// Unsafe mechanics
|
||||
|
||||
private static final sun.misc.Unsafe UNSAFE = sun.misc.Unsafe.getUnsafe();
|
||||
private static final long stateOffset =
|
||||
objectFieldOffset("state", Phaser.class);
|
||||
|
||||
private static long objectFieldOffset(String field, Class<?> klazz) {
|
||||
private static final sun.misc.Unsafe UNSAFE;
|
||||
private static final long stateOffset;
|
||||
static {
|
||||
try {
|
||||
return UNSAFE.objectFieldOffset(klazz.getDeclaredField(field));
|
||||
} catch (NoSuchFieldException e) {
|
||||
// Convert Exception to corresponding Error
|
||||
NoSuchFieldError error = new NoSuchFieldError(field);
|
||||
error.initCause(e);
|
||||
throw error;
|
||||
UNSAFE = sun.misc.Unsafe.getUnsafe();
|
||||
Class k = Phaser.class;
|
||||
stateOffset = UNSAFE.objectFieldOffset
|
||||
(k.getDeclaredField("state"));
|
||||
} catch (Exception e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -963,21 +963,16 @@ public class PriorityBlockingQueue<E> extends AbstractQueue<E>
|
||||
}
|
||||
|
||||
// Unsafe mechanics
|
||||
private static final sun.misc.Unsafe UNSAFE = sun.misc.Unsafe.getUnsafe();
|
||||
private static final long allocationSpinLockOffset =
|
||||
objectFieldOffset(UNSAFE, "allocationSpinLock",
|
||||
PriorityBlockingQueue.class);
|
||||
|
||||
static long objectFieldOffset(sun.misc.Unsafe UNSAFE,
|
||||
String field, Class<?> klazz) {
|
||||
private static final sun.misc.Unsafe UNSAFE;
|
||||
private static final long allocationSpinLockOffset;
|
||||
static {
|
||||
try {
|
||||
return UNSAFE.objectFieldOffset(klazz.getDeclaredField(field));
|
||||
} catch (NoSuchFieldException e) {
|
||||
// Convert Exception to corresponding Error
|
||||
NoSuchFieldError error = new NoSuchFieldError(field);
|
||||
error.initCause(e);
|
||||
throw error;
|
||||
UNSAFE = sun.misc.Unsafe.getUnsafe();
|
||||
Class k = PriorityBlockingQueue.class;
|
||||
allocationSpinLockOffset = UNSAFE.objectFieldOffset
|
||||
(k.getDeclaredField("allocationSpinLock"));
|
||||
} catch (Exception e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -279,12 +279,22 @@ public class SynchronousQueue<E> extends AbstractQueue<E>
|
||||
}
|
||||
|
||||
// Unsafe mechanics
|
||||
private static final sun.misc.Unsafe UNSAFE = sun.misc.Unsafe.getUnsafe();
|
||||
private static final long nextOffset =
|
||||
objectFieldOffset(UNSAFE, "next", SNode.class);
|
||||
private static final long matchOffset =
|
||||
objectFieldOffset(UNSAFE, "match", SNode.class);
|
||||
private static final sun.misc.Unsafe UNSAFE;
|
||||
private static final long matchOffset;
|
||||
private static final long nextOffset;
|
||||
|
||||
static {
|
||||
try {
|
||||
UNSAFE = sun.misc.Unsafe.getUnsafe();
|
||||
Class k = SNode.class;
|
||||
matchOffset = UNSAFE.objectFieldOffset
|
||||
(k.getDeclaredField("match"));
|
||||
nextOffset = UNSAFE.objectFieldOffset
|
||||
(k.getDeclaredField("next"));
|
||||
} catch (Exception e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** The head (top) of the stack */
|
||||
@ -498,10 +508,18 @@ public class SynchronousQueue<E> extends AbstractQueue<E>
|
||||
}
|
||||
|
||||
// Unsafe mechanics
|
||||
private static final sun.misc.Unsafe UNSAFE = sun.misc.Unsafe.getUnsafe();
|
||||
private static final long headOffset =
|
||||
objectFieldOffset(UNSAFE, "head", TransferStack.class);
|
||||
|
||||
private static final sun.misc.Unsafe UNSAFE;
|
||||
private static final long headOffset;
|
||||
static {
|
||||
try {
|
||||
UNSAFE = sun.misc.Unsafe.getUnsafe();
|
||||
Class k = TransferStack.class;
|
||||
headOffset = UNSAFE.objectFieldOffset
|
||||
(k.getDeclaredField("head"));
|
||||
} catch (Exception e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Dual Queue */
|
||||
@ -558,11 +576,22 @@ public class SynchronousQueue<E> extends AbstractQueue<E>
|
||||
}
|
||||
|
||||
// Unsafe mechanics
|
||||
private static final sun.misc.Unsafe UNSAFE = sun.misc.Unsafe.getUnsafe();
|
||||
private static final long nextOffset =
|
||||
objectFieldOffset(UNSAFE, "next", QNode.class);
|
||||
private static final long itemOffset =
|
||||
objectFieldOffset(UNSAFE, "item", QNode.class);
|
||||
private static final sun.misc.Unsafe UNSAFE;
|
||||
private static final long itemOffset;
|
||||
private static final long nextOffset;
|
||||
|
||||
static {
|
||||
try {
|
||||
UNSAFE = sun.misc.Unsafe.getUnsafe();
|
||||
Class k = QNode.class;
|
||||
itemOffset = UNSAFE.objectFieldOffset
|
||||
(k.getDeclaredField("item"));
|
||||
nextOffset = UNSAFE.objectFieldOffset
|
||||
(k.getDeclaredField("next"));
|
||||
} catch (Exception e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Head of queue */
|
||||
@ -791,15 +820,24 @@ public class SynchronousQueue<E> extends AbstractQueue<E>
|
||||
}
|
||||
}
|
||||
|
||||
// unsafe mechanics
|
||||
private static final sun.misc.Unsafe UNSAFE = sun.misc.Unsafe.getUnsafe();
|
||||
private static final long headOffset =
|
||||
objectFieldOffset(UNSAFE, "head", TransferQueue.class);
|
||||
private static final long tailOffset =
|
||||
objectFieldOffset(UNSAFE, "tail", TransferQueue.class);
|
||||
private static final long cleanMeOffset =
|
||||
objectFieldOffset(UNSAFE, "cleanMe", TransferQueue.class);
|
||||
|
||||
private static final sun.misc.Unsafe UNSAFE;
|
||||
private static final long headOffset;
|
||||
private static final long tailOffset;
|
||||
private static final long cleanMeOffset;
|
||||
static {
|
||||
try {
|
||||
UNSAFE = sun.misc.Unsafe.getUnsafe();
|
||||
Class k = TransferQueue.class;
|
||||
headOffset = UNSAFE.objectFieldOffset
|
||||
(k.getDeclaredField("head"));
|
||||
tailOffset = UNSAFE.objectFieldOffset
|
||||
(k.getDeclaredField("tail"));
|
||||
cleanMeOffset = UNSAFE.objectFieldOffset
|
||||
(k.getDeclaredField("cleanMe"));
|
||||
} catch (Exception e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -376,9 +376,9 @@ class JarFile extends ZipFile {
|
||||
*/
|
||||
private byte[] getBytes(ZipEntry ze) throws IOException {
|
||||
byte[] b = new byte[(int)ze.getSize()];
|
||||
DataInputStream is = new DataInputStream(super.getInputStream(ze));
|
||||
is.readFully(b, 0, b.length);
|
||||
is.close();
|
||||
try (DataInputStream is = new DataInputStream(super.getInputStream(ze))) {
|
||||
is.readFully(b, 0, b.length);
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
@ -480,10 +480,10 @@ class JarFile extends ZipFile {
|
||||
JarEntry manEntry = getManEntry();
|
||||
if (manEntry != null) {
|
||||
byte[] b = new byte[(int)manEntry.getSize()];
|
||||
DataInputStream dis = new DataInputStream(
|
||||
super.getInputStream(manEntry));
|
||||
dis.readFully(b, 0, b.length);
|
||||
dis.close();
|
||||
try (DataInputStream dis = new DataInputStream(
|
||||
super.getInputStream(manEntry))) {
|
||||
dis.readFully(b, 0, b.length);
|
||||
}
|
||||
|
||||
int last = b.length - src.length;
|
||||
int i = 0;
|
||||
|
||||
@ -26,7 +26,6 @@
|
||||
package java.util.zip;
|
||||
|
||||
import java.util.Date;
|
||||
import sun.misc.BootClassLoaderHook;
|
||||
|
||||
/**
|
||||
* This class is used to represent a ZIP file entry.
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2011, 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
|
||||
@ -61,7 +61,6 @@ import sun.security.jca.GetInstance.Instance;
|
||||
* <p> Every implementation of the Java platform is required to support the
|
||||
* following standard <code>SecretKeyFactory</code> algorithms:
|
||||
* <ul>
|
||||
* <li><tt>AES</tt></li>
|
||||
* <li><tt>DES</tt></li>
|
||||
* <li><tt>DESede</tt></li>
|
||||
* </ul>
|
||||
|
||||
@ -1,141 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 2010, 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.misc;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URLStreamHandlerFactory;
|
||||
import sun.misc.URLClassPath;
|
||||
|
||||
/**
|
||||
* BootClassLoaderHook defines an interface for a hook to inject
|
||||
* into the bootstrap class loader.
|
||||
*
|
||||
* With jkernel now removed, no hook is set
|
||||
*/
|
||||
public abstract class BootClassLoaderHook {
|
||||
private static BootClassLoaderHook bootLoaderHook = null;
|
||||
public static synchronized BootClassLoaderHook getHook() {
|
||||
return bootLoaderHook;
|
||||
}
|
||||
|
||||
public static synchronized void setHook(BootClassLoaderHook hook) {
|
||||
if (!VM.isBooted()) {
|
||||
throw new InternalError("hook can only be set after VM is booted");
|
||||
}
|
||||
if (bootLoaderHook != null) {
|
||||
throw new InternalError("hook should not be reinitialized");
|
||||
}
|
||||
bootLoaderHook = hook;
|
||||
}
|
||||
|
||||
protected BootClassLoaderHook() {
|
||||
}
|
||||
|
||||
/**
|
||||
* A method to be invoked before a class loader loads
|
||||
* a bootstrap class.
|
||||
*
|
||||
* @param classname the binary name of the class
|
||||
*/
|
||||
public static void preLoadClass(String classname) {
|
||||
BootClassLoaderHook hook = getHook();
|
||||
if (hook != null) {
|
||||
hook.loadBootstrapClass(classname);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A method to be invoked before a class loader loads
|
||||
* a resource.
|
||||
*
|
||||
* @param resourcename the resource name
|
||||
*/
|
||||
public static void preLoadResource(String resourcename) {
|
||||
BootClassLoaderHook hook = getHook();
|
||||
if (hook != null) {
|
||||
hook.getBootstrapResource(resourcename);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A method to be invoked before a library is loaded.
|
||||
*
|
||||
* @param libname the name of the library
|
||||
*/
|
||||
public static void preLoadLibrary(String libname) {
|
||||
BootClassLoaderHook hook = getHook();
|
||||
if (hook != null) {
|
||||
hook.loadLibrary(libname);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a pathname of a JAR or class that the hook loads
|
||||
* per this loadClass request; or null.
|
||||
*
|
||||
* @param classname the binary name of the class
|
||||
*/
|
||||
public abstract String loadBootstrapClass(String className);
|
||||
|
||||
/**
|
||||
* Returns a pathname of a resource file that the hook loads
|
||||
* per this getResource request; or null.
|
||||
*
|
||||
* @param resourceName the resource name
|
||||
*/
|
||||
public abstract String getBootstrapResource(String resourceName);
|
||||
|
||||
/**
|
||||
* Returns true if the hook successfully performs an operation per
|
||||
* this loadLibrary request; or false if it fails.
|
||||
*
|
||||
* @param libname the name of the library
|
||||
*/
|
||||
public abstract boolean loadLibrary(String libname);
|
||||
|
||||
/**
|
||||
* Returns a bootstrap class path constructed by the hook.
|
||||
*
|
||||
* @param bcp VM's bootstrap class path
|
||||
* @param factory Launcher's URL stream handler
|
||||
*/
|
||||
public abstract URLClassPath getBootstrapClassPath(URLClassPath bcp,
|
||||
URLStreamHandlerFactory factory);
|
||||
|
||||
/**
|
||||
* Returns true if the current thread is in the process of doing
|
||||
* a prefetching operation.
|
||||
*/
|
||||
public abstract boolean isCurrentThreadPrefetching();
|
||||
|
||||
/**
|
||||
* Returns true if the hook successfully prefetches the specified file.
|
||||
*
|
||||
* @param name a platform independent pathname
|
||||
*/
|
||||
public abstract boolean prefetchFile(String name);
|
||||
}
|
||||
@ -38,7 +38,6 @@ import java.util.StringTokenizer;
|
||||
import java.util.Set;
|
||||
import java.util.Vector;
|
||||
import java.security.AccessController;
|
||||
import java.security.AllPermission;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
import java.security.AccessControlContext;
|
||||
@ -117,18 +116,6 @@ public class Launcher {
|
||||
return loader;
|
||||
}
|
||||
|
||||
public static void addURLToAppClassLoader(URL u) {
|
||||
AccessController.checkPermission(new AllPermission());
|
||||
ClassLoader loader = Launcher.getLauncher().getClassLoader();
|
||||
((Launcher.AppClassLoader) loader).addAppURL(u);
|
||||
}
|
||||
|
||||
public static void addURLToExtClassLoader(URL u) {
|
||||
AccessController.checkPermission(new AllPermission());
|
||||
ClassLoader loader = Launcher.getLauncher().getClassLoader();
|
||||
((Launcher.ExtClassLoader) loader.getParent()).addExtURL(u);
|
||||
}
|
||||
|
||||
/*
|
||||
* The class loader used for loading installed extensions.
|
||||
*/
|
||||
@ -247,11 +234,6 @@ public class Launcher {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected Class findClass(String name) throws ClassNotFoundException {
|
||||
BootClassLoaderHook.preLoadClass(name);
|
||||
return super.findClass(name);
|
||||
}
|
||||
|
||||
private static AccessControlContext getContext(File[] dirs)
|
||||
throws IOException
|
||||
{
|
||||
@ -316,7 +298,6 @@ public class Launcher {
|
||||
public Class loadClass(String name, boolean resolve)
|
||||
throws ClassNotFoundException
|
||||
{
|
||||
BootClassLoaderHook.preLoadClass(name);
|
||||
int i = name.lastIndexOf('.');
|
||||
if (i != -1) {
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
@ -373,10 +354,6 @@ public class Launcher {
|
||||
|
||||
return acc;
|
||||
}
|
||||
|
||||
void addAppURL(URL url) {
|
||||
super.addURL(url);
|
||||
}
|
||||
}
|
||||
|
||||
private static class BootClassPathHolder {
|
||||
@ -413,11 +390,7 @@ public class Launcher {
|
||||
}
|
||||
|
||||
public static URLClassPath getBootstrapClassPath() {
|
||||
URLClassPath bcp = BootClassPathHolder.bcp;
|
||||
// if DownloadManager is installed, return the bootstrap class path
|
||||
// maintained by the Java kernel
|
||||
BootClassLoaderHook hook = BootClassLoaderHook.getHook();
|
||||
return hook == null ? bcp : hook.getBootstrapClassPath(bcp, factory);
|
||||
return BootClassPathHolder.bcp;
|
||||
}
|
||||
|
||||
private static URL[] pathToURLs(File[] path) {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -28,7 +28,6 @@ package sun.misc;
|
||||
import java.util.jar.JarFile;
|
||||
import java.io.Console;
|
||||
import java.io.FileDescriptor;
|
||||
import java.security.CodeSigner;
|
||||
import java.security.ProtectionDomain;
|
||||
|
||||
/** A repository of "shared secrets", which are a mechanism for
|
||||
@ -49,7 +48,6 @@ public class SharedSecrets {
|
||||
private static JavaNioAccess javaNioAccess;
|
||||
private static JavaIOFileDescriptorAccess javaIOFileDescriptorAccess;
|
||||
private static JavaSecurityProtectionDomainAccess javaSecurityProtectionDomainAccess;
|
||||
private static JavaSecurityCodeSignerAccess javaSecurityCodeSignerAccess;
|
||||
|
||||
public static JavaUtilJarAccess javaUtilJarAccess() {
|
||||
if (javaUtilJarAccess == null) {
|
||||
@ -127,16 +125,4 @@ public class SharedSecrets {
|
||||
unsafe.ensureClassInitialized(ProtectionDomain.class);
|
||||
return javaSecurityProtectionDomainAccess;
|
||||
}
|
||||
|
||||
public static void setJavaSecurityCodeSignerAccess
|
||||
(JavaSecurityCodeSignerAccess jscsa) {
|
||||
javaSecurityCodeSignerAccess = jscsa;
|
||||
}
|
||||
|
||||
public static JavaSecurityCodeSignerAccess
|
||||
getJavaSecurityCodeSignerAccess() {
|
||||
if (javaSecurityCodeSignerAccess == null)
|
||||
unsafe.ensureClassInitialized(CodeSigner.class);
|
||||
return javaSecurityCodeSignerAccess;
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,32 +69,33 @@ class ChunkedInputStream extends LeftOverInputStream {
|
||||
*/
|
||||
private int readChunkHeader () throws IOException {
|
||||
boolean gotCR = false;
|
||||
char c;
|
||||
int c;
|
||||
char[] len_arr = new char [16];
|
||||
int len_size = 0;
|
||||
boolean end_of_len = false;
|
||||
|
||||
while ((c=(char)in.read())!= -1) {
|
||||
while ((c=in.read())!= -1) {
|
||||
char ch = (char) c;
|
||||
if (len_size == len_arr.length -1) {
|
||||
throw new IOException ("invalid chunk header");
|
||||
}
|
||||
if (gotCR) {
|
||||
if (c == LF) {
|
||||
if (ch == LF) {
|
||||
int l = numeric (len_arr, len_size);
|
||||
return l;
|
||||
} else {
|
||||
gotCR = false;
|
||||
}
|
||||
if (!end_of_len) {
|
||||
len_arr[len_size++] = c;
|
||||
len_arr[len_size++] = ch;
|
||||
}
|
||||
} else {
|
||||
if (c == CR) {
|
||||
if (ch == CR) {
|
||||
gotCR = true;
|
||||
} else if (c == ';') {
|
||||
} else if (ch == ';') {
|
||||
end_of_len = true;
|
||||
} else if (!end_of_len) {
|
||||
len_arr[len_size++] = c;
|
||||
len_arr[len_size++] = ch;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -475,8 +475,8 @@ public class FileChannelImpl
|
||||
assert !target.isOpen();
|
||||
try {
|
||||
close();
|
||||
} catch (IOException ignore) {
|
||||
// nothing we can do
|
||||
} catch (Throwable suppressed) {
|
||||
e.addSuppressed(suppressed);
|
||||
}
|
||||
throw e;
|
||||
} catch (IOException ioe) {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -42,14 +42,12 @@ import static sun.security.pkcs11.wrapper.PKCS11Constants.*;
|
||||
* Cipher implementation class. This class currently supports
|
||||
* DES, DESede, AES, ARCFOUR, and Blowfish.
|
||||
*
|
||||
* This class is designed to support ECB and CBC with NoPadding and
|
||||
* PKCS5Padding for both. It will use its own padding impl if the
|
||||
* native mechanism does not support padding.
|
||||
* This class is designed to support ECB, CBC, CTR with NoPadding
|
||||
* and ECB, CBC with PKCS5Padding. It will use its own padding impl
|
||||
* if the native mechanism does not support padding.
|
||||
*
|
||||
* Note that PKCS#11 current only supports ECB and CBC. There are no
|
||||
* provisions for other modes such as CFB, OFB, PCBC, or CTR mode.
|
||||
* However, CTR could be implemented relatively easily (and efficiently)
|
||||
* on top of ECB mode in this class, if need be.
|
||||
* Note that PKCS#11 currently only supports ECB, CBC, and CTR.
|
||||
* There are no provisions for other modes such as CFB, OFB, and PCBC.
|
||||
*
|
||||
* @author Andreas Sterbenz
|
||||
* @since 1.5
|
||||
@ -60,6 +58,8 @@ final class P11Cipher extends CipherSpi {
|
||||
private final static int MODE_ECB = 3;
|
||||
// mode constant for CBC mode
|
||||
private final static int MODE_CBC = 4;
|
||||
// mode constant for CTR mode
|
||||
private final static int MODE_CTR = 5;
|
||||
|
||||
// padding constant for NoPadding
|
||||
private final static int PAD_NONE = 5;
|
||||
@ -157,7 +157,7 @@ final class P11Cipher extends CipherSpi {
|
||||
private byte[] padBuffer;
|
||||
private int padBufferLen;
|
||||
|
||||
// original IV, if in MODE_CBC
|
||||
// original IV, if in MODE_CBC or MODE_CTR
|
||||
private byte[] iv;
|
||||
|
||||
// number of bytes buffered internally by the native mechanism and padBuffer
|
||||
@ -213,6 +213,8 @@ final class P11Cipher extends CipherSpi {
|
||||
("CBC mode not supported with stream ciphers");
|
||||
}
|
||||
result = MODE_CBC;
|
||||
} else if (mode.equals("CTR")) {
|
||||
result = MODE_CTR;
|
||||
} else {
|
||||
throw new NoSuchAlgorithmException("Unsupported mode " + mode);
|
||||
}
|
||||
@ -228,6 +230,10 @@ final class P11Cipher extends CipherSpi {
|
||||
if (padding.equals("NOPADDING")) {
|
||||
paddingType = PAD_NONE;
|
||||
} else if (padding.equals("PKCS5PADDING")) {
|
||||
if (this.blockMode == MODE_CTR) {
|
||||
throw new NoSuchPaddingException
|
||||
("PKCS#5 padding not supported with CTR mode");
|
||||
}
|
||||
paddingType = PAD_PKCS5;
|
||||
if (mechanism != CKM_DES_CBC_PAD && mechanism != CKM_DES3_CBC_PAD &&
|
||||
mechanism != CKM_AES_CBC_PAD) {
|
||||
@ -348,11 +354,14 @@ final class P11Cipher extends CipherSpi {
|
||||
("IV not used in ECB mode");
|
||||
}
|
||||
}
|
||||
} else { // MODE_CBC
|
||||
} else { // MODE_CBC or MODE_CTR
|
||||
if (iv == null) {
|
||||
if (encrypt == false) {
|
||||
throw new InvalidAlgorithmParameterException
|
||||
("IV must be specified for decryption in CBC mode");
|
||||
String exMsg =
|
||||
(blockMode == MODE_CBC ?
|
||||
"IV must be specified for decryption in CBC mode" :
|
||||
"IV must be specified for decryption in CTR mode");
|
||||
throw new InvalidAlgorithmParameterException(exMsg);
|
||||
}
|
||||
// generate random IV
|
||||
if (random == null) {
|
||||
@ -410,13 +419,15 @@ final class P11Cipher extends CipherSpi {
|
||||
if (session == null) {
|
||||
session = token.getOpSession();
|
||||
}
|
||||
CK_MECHANISM mechParams = (blockMode == MODE_CTR?
|
||||
new CK_MECHANISM(mechanism, new CK_AES_CTR_PARAMS(iv)) :
|
||||
new CK_MECHANISM(mechanism, iv));
|
||||
|
||||
try {
|
||||
if (encrypt) {
|
||||
token.p11.C_EncryptInit(session.id(),
|
||||
new CK_MECHANISM(mechanism, iv), p11Key.keyID);
|
||||
token.p11.C_EncryptInit(session.id(), mechParams, p11Key.keyID);
|
||||
} else {
|
||||
token.p11.C_DecryptInit(session.id(),
|
||||
new CK_MECHANISM(mechanism, iv), p11Key.keyID);
|
||||
token.p11.C_DecryptInit(session.id(), mechParams, p11Key.keyID);
|
||||
}
|
||||
} catch (PKCS11Exception ex) {
|
||||
// release session when initialization failed
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2011, 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
|
||||
@ -62,6 +62,11 @@ final class P11RSACipher extends CipherSpi {
|
||||
// mode constant for public key decryption (verifying)
|
||||
private final static int MODE_VERIFY = 4;
|
||||
|
||||
// padding type constant for NoPadding
|
||||
private final static int PAD_NONE = 1;
|
||||
// padding type constant for PKCS1Padding
|
||||
private final static int PAD_PKCS1 = 2;
|
||||
|
||||
// token instance
|
||||
private final Token token;
|
||||
|
||||
@ -77,6 +82,9 @@ final class P11RSACipher extends CipherSpi {
|
||||
// mode, one of MODE_* above
|
||||
private int mode;
|
||||
|
||||
// padding, one of PAD_* above
|
||||
private int padType;
|
||||
|
||||
private byte[] buffer;
|
||||
private int bufOfs;
|
||||
|
||||
@ -113,8 +121,10 @@ final class P11RSACipher extends CipherSpi {
|
||||
protected void engineSetPadding(String padding)
|
||||
throws NoSuchPaddingException {
|
||||
String lowerPadding = padding.toLowerCase(Locale.ENGLISH);
|
||||
if (lowerPadding.equals("pkcs1Padding")) {
|
||||
// empty
|
||||
if (lowerPadding.equals("pkcs1padding")) {
|
||||
padType = PAD_PKCS1;
|
||||
} else if (lowerPadding.equals("nopadding")) {
|
||||
padType = PAD_NONE;
|
||||
} else {
|
||||
throw new NoSuchPaddingException("Unsupported padding " + padding);
|
||||
}
|
||||
@ -209,7 +219,8 @@ final class P11RSACipher extends CipherSpi {
|
||||
int n = (p11Key.keyLength() + 7) >> 3;
|
||||
outputSize = n;
|
||||
buffer = new byte[n];
|
||||
maxInputSize = encrypt ? (n - PKCS1_MIN_PADDING_LENGTH) : n;
|
||||
maxInputSize = ((padType == PAD_PKCS1 && encrypt) ?
|
||||
(n - PKCS1_MIN_PADDING_LENGTH) : n);
|
||||
try {
|
||||
initialize();
|
||||
} catch (PKCS11Exception e) {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2011, 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
|
||||
@ -621,12 +621,16 @@ public final class SunPKCS11 extends AuthProvider {
|
||||
m(CKM_AES_CBC_PAD, CKM_AES_CBC));
|
||||
d(CIP, "AES/ECB", P11Cipher, s("AES"),
|
||||
m(CKM_AES_ECB));
|
||||
d(CIP, "AES/CTR/NoPadding", P11Cipher,
|
||||
m(CKM_AES_CTR));
|
||||
d(CIP, "Blowfish/CBC", P11Cipher,
|
||||
m(CKM_BLOWFISH_CBC));
|
||||
|
||||
// XXX RSA_X_509, RSA_OAEP not yet supported
|
||||
d(CIP, "RSA/ECB/PKCS1Padding", P11RSACipher,
|
||||
d(CIP, "RSA/ECB/PKCS1Padding", P11RSACipher, s("RSA"),
|
||||
m(CKM_RSA_PKCS));
|
||||
d(CIP, "RSA/ECB/NoPadding", P11RSACipher,
|
||||
m(CKM_RSA_X_509));
|
||||
|
||||
d(SIG, "RawDSA", P11Signature, s("NONEwithDSA"),
|
||||
m(CKM_DSA));
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 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
|
||||
@ -22,12 +22,45 @@
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package sun.misc;
|
||||
|
||||
import java.security.CodeSigner;
|
||||
import java.security.cert.CRL;
|
||||
package sun.security.pkcs11.wrapper;
|
||||
|
||||
public interface JavaSecurityCodeSignerAccess {
|
||||
void setCRLs(CodeSigner signer, CRL[] crls);
|
||||
CRL[] getCRLs(CodeSigner signer);
|
||||
/**
|
||||
* This class represents the necessary parameters required by
|
||||
* the CKM_AES_CTR mechanism as defined in CK_AES_CTR_PARAMS structure.<p>
|
||||
* <B>PKCS#11 structure:</B>
|
||||
* <PRE>
|
||||
* typedef struct CK_AES_CTR_PARAMS {
|
||||
* CK_ULONG ulCounterBits;
|
||||
* CK_BYTE cb[16];
|
||||
* } CK_AES_CTR_PARAMS;
|
||||
* </PRE>
|
||||
*
|
||||
* @author Yu-Ching Valerie Peng
|
||||
* @since 1.7
|
||||
*/
|
||||
public class CK_AES_CTR_PARAMS {
|
||||
|
||||
private final long ulCounterBits;
|
||||
private final byte cb[];
|
||||
|
||||
public CK_AES_CTR_PARAMS(byte[] cb) {
|
||||
ulCounterBits = 128;
|
||||
this.cb = cb.clone();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
|
||||
buffer.append(Constants.INDENT);
|
||||
buffer.append("ulCounterBits: ");
|
||||
buffer.append(ulCounterBits);
|
||||
buffer.append(Constants.NEWLINE);
|
||||
|
||||
buffer.append(Constants.INDENT);
|
||||
buffer.append("cb: ");
|
||||
buffer.append(Functions.toHexString(cb));
|
||||
|
||||
return buffer.toString();
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
|
||||
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
|
||||
@ -48,6 +48,7 @@
|
||||
package sun.security.pkcs11.wrapper;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import static sun.security.pkcs11.wrapper.PKCS11Constants.*;
|
||||
|
||||
/**
|
||||
* class CK_MECHANISM specifies a particular mechanism and any parameters it
|
||||
@ -127,6 +128,10 @@ public class CK_MECHANISM {
|
||||
init(mechanism, params);
|
||||
}
|
||||
|
||||
public CK_MECHANISM(long mechanism, CK_AES_CTR_PARAMS params) {
|
||||
init(mechanism, params);
|
||||
}
|
||||
|
||||
private void init(long mechanism, Object pParameter) {
|
||||
this.mechanism = mechanism;
|
||||
this.pParameter = pParameter;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
|
||||
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
|
||||
@ -47,8 +47,6 @@
|
||||
|
||||
package sun.security.pkcs11.wrapper;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This interface holds constants of the PKCS#11 v2.11 standard.
|
||||
* This is mainly the content of the 'pkcs11t.h' header file.
|
||||
@ -306,6 +304,10 @@ public interface PKCS11Constants {
|
||||
|
||||
public static final long CKK_VENDOR_DEFINED = 0x80000000L;
|
||||
|
||||
// new for v2.20 amendment 3
|
||||
//public static final long CKK_CAMELLIA = 0x00000025L;
|
||||
//public static final long CKK_ARIA = 0x00000026L;
|
||||
|
||||
// pseudo key type ANY (for template manager)
|
||||
public static final long PCKK_ANY = 0x7FFFFF22L;
|
||||
|
||||
@ -690,6 +692,34 @@ public interface PKCS11Constants {
|
||||
|
||||
public static final long CKM_VENDOR_DEFINED = 0x80000000L;
|
||||
|
||||
// new for v2.20 amendment 3
|
||||
public static final long CKM_SHA224 = 0x00000255L;
|
||||
public static final long CKM_SHA224_HMAC = 0x00000256L;
|
||||
public static final long CKM_SHA224_HMAC_GENERAL = 0x00000257L;
|
||||
public static final long CKM_SHA224_KEY_DERIVATION = 0x00000396L;
|
||||
public static final long CKM_SHA224_RSA_PKCS = 0x00000046L;
|
||||
public static final long CKM_SHA224_RSA_PKCS_PSS = 0x00000047L;
|
||||
public static final long CKM_AES_CTR = 0x00001086L;
|
||||
/*
|
||||
public static final long CKM_CAMELLIA_KEY_GEN = 0x00000550L;
|
||||
public static final long CKM_CAMELLIA_ECB = 0x00000551L;
|
||||
public static final long CKM_CAMELLIA_CBC = 0x00000552L;
|
||||
public static final long CKM_CAMELLIA_MAC = 0x00000553L;
|
||||
public static final long CKM_CAMELLIA_MAC_GENERAL = 0x00000554L;
|
||||
public static final long CKM_CAMELLIA_CBC_PAD = 0x00000555L;
|
||||
public static final long CKM_CAMELLIA_ECB_ENCRYPT_DATA = 0x00000556L;
|
||||
public static final long CKM_CAMELLIA_CBC_ENCRYPT_DATA = 0x00000557L;
|
||||
public static final long CKM_CAMELLIA_CTR = 0x00000558L;
|
||||
public static final long CKM_ARIA_KEY_GEN = 0x00000560L;
|
||||
public static final long CKM_ARIA_ECB = 0x00000561L;
|
||||
public static final long CKM_ARIA_CBC = 0x00000562L;
|
||||
public static final long CKM_ARIA_MAC = 0x00000563L;
|
||||
public static final long CKM_ARIA_MAC_GENERAL = 0x00000564L;
|
||||
public static final long CKM_ARIA_CBC_PAD = 0x00000565L;
|
||||
public static final long CKM_ARIA_ECB_ENCRYPT_DATA = 0x00000566L;
|
||||
public static final long CKM_ARIA_CBC_ENCRYPT_DATA = 0x00000567L;
|
||||
*/
|
||||
|
||||
// NSS private
|
||||
public static final long CKM_NSS_TLS_PRF_GENERAL = 0x80000373L;
|
||||
|
||||
@ -881,7 +911,8 @@ public interface PKCS11Constants {
|
||||
|
||||
/* The following MGFs are defined */
|
||||
public static final long CKG_MGF1_SHA1 = 0x00000001L;
|
||||
|
||||
// new for v2.20 amendment 3
|
||||
public static final long CKG_MGF1_SHA224 = 0x00000005L;
|
||||
|
||||
/* The following encoding parameter sources are defined */
|
||||
public static final long CKZ_DATA_SPECIFIED = 0x00000001L;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2011, 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
|
||||
@ -26,7 +26,6 @@
|
||||
package sun.security.tools;
|
||||
|
||||
import java.io.*;
|
||||
import java.security.cert.X509CRL;
|
||||
import java.util.*;
|
||||
import java.util.zip.*;
|
||||
import java.util.jar.*;
|
||||
@ -36,7 +35,6 @@ import java.net.URISyntaxException;
|
||||
import java.text.Collator;
|
||||
import java.text.MessageFormat;
|
||||
import java.security.cert.Certificate;
|
||||
import java.security.cert.CRL;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.*;
|
||||
@ -58,7 +56,6 @@ import java.util.Map.Entry;
|
||||
import sun.security.x509.*;
|
||||
import sun.security.util.*;
|
||||
import sun.misc.BASE64Encoder;
|
||||
import sun.misc.SharedSecrets;
|
||||
|
||||
|
||||
/**
|
||||
@ -117,13 +114,11 @@ public class JarSigner {
|
||||
static final int SIGNED_BY_ALIAS = 0x08; // signer is in alias list
|
||||
|
||||
X509Certificate[] certChain; // signer's cert chain (when composing)
|
||||
Set<X509CRL> crls; // signer provided CRLs
|
||||
PrivateKey privateKey; // private key
|
||||
KeyStore store; // the keystore specified by -keystore
|
||||
// or the default keystore, never null
|
||||
|
||||
String keystore; // key store file
|
||||
List<String> crlfiles = new ArrayList<>(); // CRL files to add
|
||||
boolean nullStream = false; // null keystore input stream (NONE)
|
||||
boolean token = false; // token-based keystore
|
||||
String jarfile; // jar files to sign or verify
|
||||
@ -151,7 +146,6 @@ public class JarSigner {
|
||||
boolean signManifest = true; // "sign" the whole manifest
|
||||
boolean externalSF = true; // leave the .SF out of the PKCS7 block
|
||||
boolean strict = false; // treat warnings as error
|
||||
boolean autoCRL = false; // Automatcially add CRL defined in cert
|
||||
|
||||
// read zip entry raw bytes
|
||||
private ByteArrayOutputStream baos = new ByteArrayOutputStream(2048);
|
||||
@ -232,29 +226,6 @@ public class JarSigner {
|
||||
} else {
|
||||
loadKeyStore(keystore, true);
|
||||
getAliasInfo(alias);
|
||||
crls = new HashSet<X509CRL>();
|
||||
if (crlfiles.size() > 0 || autoCRL) {
|
||||
CertificateFactory fac =
|
||||
CertificateFactory.getInstance("X509");
|
||||
List<CRL> list = new ArrayList<>();
|
||||
for (String file: crlfiles) {
|
||||
Collection<? extends CRL> tmp = KeyTool.loadCRLs(file);
|
||||
for (CRL crl: tmp) {
|
||||
if (crl instanceof X509CRL) {
|
||||
crls.add((X509CRL)crl);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (autoCRL) {
|
||||
List<CRL> crlsFromCert =
|
||||
KeyTool.readCRLsFromCert(certChain[0]);
|
||||
for (CRL crl: crlsFromCert) {
|
||||
if (crl instanceof X509CRL) {
|
||||
crls.add((X509CRL)crl);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// load the alternative signing mechanism
|
||||
if (altSignerClass != null) {
|
||||
@ -396,13 +367,6 @@ public class JarSigner {
|
||||
} else if (collator.compare(flags, "-digestalg") ==0) {
|
||||
if (++n == args.length) usageNoArg();
|
||||
digestalg = args[n];
|
||||
} else if (collator.compare(flags, "-crl") ==0) {
|
||||
if ("auto".equals(modifier)) {
|
||||
autoCRL = true;
|
||||
} else {
|
||||
if (++n == args.length) usageNoArg();
|
||||
crlfiles.add(args[n]);
|
||||
}
|
||||
} else if (collator.compare(flags, "-certs") ==0) {
|
||||
showcerts = true;
|
||||
} else if (collator.compare(flags, "-strict") ==0) {
|
||||
@ -548,9 +512,6 @@ public class JarSigner {
|
||||
System.out.println(rb.getString
|
||||
(".sigalg.algorithm.name.of.signature.algorithm"));
|
||||
System.out.println();
|
||||
System.out.println(rb.getString
|
||||
(".crl.auto.file.include.CRL.in.signed.jar"));
|
||||
System.out.println();
|
||||
System.out.println(rb.getString
|
||||
(".verify.verify.a.signed.JAR.file"));
|
||||
System.out.println();
|
||||
@ -691,20 +652,6 @@ public class JarSigner {
|
||||
if (showcerts) {
|
||||
sb.append(si);
|
||||
sb.append('\n');
|
||||
CRL[] crls = SharedSecrets
|
||||
.getJavaSecurityCodeSignerAccess()
|
||||
.getCRLs(signer);
|
||||
if (crls != null) {
|
||||
for (CRL crl: crls) {
|
||||
if (crl instanceof X509CRLImpl) {
|
||||
sb.append(tab).append("[");
|
||||
sb.append(String.format(
|
||||
rb.getString("with.a.CRL.including.d.entries"),
|
||||
((X509CRLImpl)crl).getRevokedCertificates().size()))
|
||||
.append("]\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (showcerts && !verbose.equals("all")) {
|
||||
@ -1284,7 +1231,7 @@ public class JarSigner {
|
||||
|
||||
try {
|
||||
block =
|
||||
sf.generateBlock(privateKey, sigalg, certChain, crls,
|
||||
sf.generateBlock(privateKey, sigalg, certChain,
|
||||
externalSF, tsaUrl, tsaCert, signingMechanism, args,
|
||||
zipFile);
|
||||
} catch (SocketTimeoutException e) {
|
||||
@ -2249,7 +2196,6 @@ class SignatureFile {
|
||||
public Block generateBlock(PrivateKey privateKey,
|
||||
String sigalg,
|
||||
X509Certificate[] certChain,
|
||||
Set<X509CRL> crls,
|
||||
boolean externalSF, String tsaUrl,
|
||||
X509Certificate tsaCert,
|
||||
ContentSigner signingMechanism,
|
||||
@ -2257,7 +2203,7 @@ class SignatureFile {
|
||||
throws NoSuchAlgorithmException, InvalidKeyException, IOException,
|
||||
SignatureException, CertificateException
|
||||
{
|
||||
return new Block(this, privateKey, sigalg, certChain, crls, externalSF,
|
||||
return new Block(this, privateKey, sigalg, certChain, externalSF,
|
||||
tsaUrl, tsaCert, signingMechanism, args, zipFile);
|
||||
}
|
||||
|
||||
@ -2271,8 +2217,7 @@ class SignatureFile {
|
||||
* Construct a new signature block.
|
||||
*/
|
||||
Block(SignatureFile sfg, PrivateKey privateKey, String sigalg,
|
||||
X509Certificate[] certChain, Set<X509CRL> crls,
|
||||
boolean externalSF, String tsaUrl,
|
||||
X509Certificate[] certChain, boolean externalSF, String tsaUrl,
|
||||
X509Certificate tsaCert, ContentSigner signingMechanism,
|
||||
String[] args, ZipFile zipFile)
|
||||
throws NoSuchAlgorithmException, InvalidKeyException, IOException,
|
||||
@ -2359,7 +2304,7 @@ class SignatureFile {
|
||||
// Assemble parameters for the signing mechanism
|
||||
ContentSignerParameters params =
|
||||
new JarSignerParameters(args, tsaUri, tsaCert, signature,
|
||||
signatureAlgorithm, certChain, crls, content, zipFile);
|
||||
signatureAlgorithm, certChain, content, zipFile);
|
||||
|
||||
// Generate the signature block
|
||||
block = signingMechanism.generateSignedData(
|
||||
@ -2400,7 +2345,6 @@ class JarSignerParameters implements ContentSignerParameters {
|
||||
private byte[] signature;
|
||||
private String signatureAlgorithm;
|
||||
private X509Certificate[] signerCertificateChain;
|
||||
private Set<X509CRL> crls;
|
||||
private byte[] content;
|
||||
private ZipFile source;
|
||||
|
||||
@ -2409,8 +2353,7 @@ class JarSignerParameters implements ContentSignerParameters {
|
||||
*/
|
||||
JarSignerParameters(String[] args, URI tsa, X509Certificate tsaCertificate,
|
||||
byte[] signature, String signatureAlgorithm,
|
||||
X509Certificate[] signerCertificateChain, Set<X509CRL> crls,
|
||||
byte[] content,
|
||||
X509Certificate[] signerCertificateChain, byte[] content,
|
||||
ZipFile source) {
|
||||
|
||||
if (signature == null || signatureAlgorithm == null ||
|
||||
@ -2423,7 +2366,6 @@ class JarSignerParameters implements ContentSignerParameters {
|
||||
this.signature = signature;
|
||||
this.signatureAlgorithm = signatureAlgorithm;
|
||||
this.signerCertificateChain = signerCertificateChain;
|
||||
this.crls = crls;
|
||||
this.content = content;
|
||||
this.source = source;
|
||||
}
|
||||
@ -2499,13 +2441,4 @@ class JarSignerParameters implements ContentSignerParameters {
|
||||
public ZipFile getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<X509CRL> getCRLs() {
|
||||
if (crls == null) {
|
||||
return Collections.emptySet();
|
||||
} else {
|
||||
return Collections.unmodifiableSet(crls);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2011, 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
|
||||
@ -74,8 +74,6 @@ public class JarSignerResources extends java.util.ListResourceBundle {
|
||||
"[-digestalg <algorithm>] name of digest algorithm"},
|
||||
{".sigalg.algorithm.name.of.signature.algorithm",
|
||||
"[-sigalg <algorithm>] name of signature algorithm"},
|
||||
{".crl.auto.file.include.CRL.in.signed.jar",
|
||||
"[-crl[:auto| <file>] include CRL in signed jar"},
|
||||
{".verify.verify.a.signed.JAR.file",
|
||||
"[-verify] verify a signed JAR file"},
|
||||
{".verbose.suboptions.verbose.output.when.signing.verifying.",
|
||||
@ -193,7 +191,6 @@ public class JarSignerResources extends java.util.ListResourceBundle {
|
||||
{"using.an.alternative.signing.mechanism",
|
||||
"using an alternative signing mechanism"},
|
||||
{"entry.was.signed.on", "entry was signed on {0}"},
|
||||
{"with.a.CRL.including.d.entries", "with a CRL including %d entries"},
|
||||
{"Warning.", "Warning: "},
|
||||
{"This.jar.contains.unsigned.entries.which.have.not.been.integrity.checked.",
|
||||
"This jar contains unsigned entries which have not been integrity-checked. "},
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2011, 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
|
||||
@ -25,7 +25,6 @@
|
||||
|
||||
package sun.security.tools;
|
||||
|
||||
import sun.misc.SharedSecrets;
|
||||
import java.io.*;
|
||||
import java.security.CodeSigner;
|
||||
import java.security.KeyStore;
|
||||
@ -2311,16 +2310,6 @@ public final class KeyTool {
|
||||
out.println();
|
||||
}
|
||||
}
|
||||
CRL[] crls = SharedSecrets
|
||||
.getJavaSecurityCodeSignerAccess()
|
||||
.getCRLs(signer);
|
||||
if (crls != null) {
|
||||
out.println(rb.getString("CRLs."));
|
||||
out.println();
|
||||
for (CRL crl: crls) {
|
||||
printCRL(crl, out);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2007, 2011, 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
|
||||
@ -38,7 +38,6 @@ import java.security.cert.X509Certificate;
|
||||
import java.util.List;
|
||||
|
||||
import com.sun.jarsigner.*;
|
||||
import java.security.cert.X509CRL;
|
||||
import java.util.Arrays;
|
||||
import sun.security.pkcs.*;
|
||||
import sun.security.timestamp.*;
|
||||
@ -238,9 +237,8 @@ public final class TimestampedSigner extends ContentSigner {
|
||||
AlgorithmId[] algorithms = {digestAlgorithmId};
|
||||
|
||||
// Create the PKCS #7 signed data message
|
||||
PKCS7 p7 =
|
||||
new PKCS7(algorithms, contentInfo, signerCertificateChain,
|
||||
parameters.getCRLs().toArray(new X509CRL[parameters.getCRLs().size()]), signerInfos);
|
||||
PKCS7 p7 = new PKCS7(algorithms, contentInfo, signerCertificateChain,
|
||||
null, signerInfos);
|
||||
ByteArrayOutputStream p7out = new ByteArrayOutputStream();
|
||||
p7.encodeSignedData(p7out);
|
||||
|
||||
|
||||
@ -37,7 +37,6 @@ import java.util.jar.*;
|
||||
import sun.security.pkcs.*;
|
||||
import sun.security.timestamp.TimestampToken;
|
||||
import sun.misc.BASE64Decoder;
|
||||
import sun.misc.SharedSecrets;
|
||||
|
||||
import sun.security.jca.Providers;
|
||||
|
||||
@ -486,12 +485,7 @@ public class SignatureFileVerifier {
|
||||
signers = new ArrayList<CodeSigner>();
|
||||
}
|
||||
// Append the new code signer
|
||||
CodeSigner signer = new CodeSigner(certChain, getTimestamp(info));
|
||||
if (block.getCRLs() != null) {
|
||||
SharedSecrets.getJavaSecurityCodeSignerAccess().setCRLs(
|
||||
signer, block.getCRLs());
|
||||
}
|
||||
signers.add(signer);
|
||||
signers.add(new CodeSigner(certChain, getTimestamp(info)));
|
||||
|
||||
if (debug != null) {
|
||||
debug.println("Signature Block Certificate: " +
|
||||
|
||||
@ -94,7 +94,7 @@ public class Main {
|
||||
* Run the converter
|
||||
*/
|
||||
public synchronized boolean convert(String argv[]){
|
||||
Vector v = new Vector(2);
|
||||
List<String> v = new ArrayList<>(2);
|
||||
File outputFile = null;
|
||||
boolean createOutputFile = false;
|
||||
|
||||
@ -115,7 +115,7 @@ public class Main {
|
||||
usage();
|
||||
return false;
|
||||
}
|
||||
v.addElement(argv[i]);
|
||||
v.add(argv[i]);
|
||||
}
|
||||
}
|
||||
if (encodingString == null)
|
||||
@ -126,11 +126,11 @@ public class Main {
|
||||
initializeConverter();
|
||||
|
||||
if (v.size() == 1)
|
||||
inputFileName = (String)v.elementAt(0);
|
||||
inputFileName = v.get(0);
|
||||
|
||||
if (v.size() == 2) {
|
||||
inputFileName = (String)v.elementAt(0);
|
||||
outputFileName = (String)v.elementAt(1);
|
||||
inputFileName = v.get(0);
|
||||
outputFileName = v.get(1);
|
||||
createOutputFile = true;
|
||||
}
|
||||
|
||||
@ -363,9 +363,7 @@ public class Main {
|
||||
|
||||
private String formatMsg(String key, String arg) {
|
||||
String msg = getMsg(key);
|
||||
String[] args = new String[1];
|
||||
args[0] = arg;
|
||||
return MessageFormat.format(msg, (Object)args);
|
||||
return MessageFormat.format(msg, arg);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -127,7 +127,9 @@ public class LocalGregorianCalendar extends BaseCalendar {
|
||||
calendarProps = (Properties) AccessController.doPrivileged(new PrivilegedExceptionAction() {
|
||||
public Object run() throws IOException {
|
||||
Properties props = new Properties();
|
||||
props.load(new FileInputStream(fname));
|
||||
try (FileInputStream fis = new FileInputStream(fname)) {
|
||||
props.load(fis);
|
||||
}
|
||||
return props;
|
||||
}
|
||||
});
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@ -76,7 +76,7 @@ public class ZipDirectoryStream implements DirectoryStream<Path> {
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
return new Iterator<>() {
|
||||
return new Iterator<Path>() {
|
||||
private Path next;
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
|
||||
@ -112,11 +112,8 @@ public class ZipFileSystem extends FileSystem {
|
||||
}
|
||||
// sm and existence check
|
||||
zfpath.getFileSystem().provider().checkAccess(zfpath, AccessMode.READ);
|
||||
try {
|
||||
zfpath.getFileSystem().provider().checkAccess(zfpath, AccessMode.WRITE);
|
||||
} catch (AccessDeniedException x) {
|
||||
if (!Files.isWritable(zfpath))
|
||||
this.readOnly = true;
|
||||
}
|
||||
this.zc = ZipCoder.get(nameEncoding);
|
||||
this.defaultdir = new ZipPath(this, getBytes(defaultDir));
|
||||
this.ch = Files.newByteChannel(zfpath, READ);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@ -590,7 +590,7 @@ public class ZipPath implements Path {
|
||||
|
||||
@Override
|
||||
public Iterator<Path> iterator() {
|
||||
return new Iterator<>() {
|
||||
return new Iterator<Path>() {
|
||||
private int i = 0;
|
||||
|
||||
@Override
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2009, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
|
||||
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
|
||||
@ -694,6 +694,46 @@ CK_SSL3_KEY_MAT_PARAMS jSsl3KeyMatParamToCKSsl3KeyMatParam(JNIEnv *env, jobject
|
||||
return ckParam ;
|
||||
}
|
||||
|
||||
/*
|
||||
* converts the Java CK_AES_CTR_PARAMS object to a CK_AES_CTR_PARAMS structure
|
||||
*
|
||||
* @param env - used to call JNI funktions to get the Java classes and objects
|
||||
* @param jParam - the Java CK_AES_CTR_PARAMS object to convert
|
||||
* @param ckpParam - pointer to the new CK_AES_CTR_PARAMS structure
|
||||
*/
|
||||
void jAesCtrParamsToCKAesCtrParam(JNIEnv *env, jobject jParam,
|
||||
CK_AES_CTR_PARAMS_PTR ckpParam) {
|
||||
jclass jAesCtrParamsClass;
|
||||
jfieldID fieldID;
|
||||
jlong jCounterBits;
|
||||
jobject jCb;
|
||||
CK_BYTE_PTR ckBytes;
|
||||
CK_ULONG ckTemp;
|
||||
|
||||
/* get ulCounterBits */
|
||||
jAesCtrParamsClass = (*env)->FindClass(env, CLASS_AES_CTR_PARAMS);
|
||||
if (jAesCtrParamsClass == NULL) { return; }
|
||||
fieldID = (*env)->GetFieldID(env, jAesCtrParamsClass, "ulCounterBits", "J");
|
||||
if (fieldID == NULL) { return; }
|
||||
jCounterBits = (*env)->GetLongField(env, jParam, fieldID);
|
||||
|
||||
/* get cb */
|
||||
fieldID = (*env)->GetFieldID(env, jAesCtrParamsClass, "cb", "[B");
|
||||
if (fieldID == NULL) { return; }
|
||||
jCb = (*env)->GetObjectField(env, jParam, fieldID);
|
||||
|
||||
/* populate java values */
|
||||
ckpParam->ulCounterBits = jLongToCKULong(jCounterBits);
|
||||
jByteArrayToCKByteArray(env, jCb, &ckBytes, &ckTemp);
|
||||
if ((*env)->ExceptionCheck(env)) { return; }
|
||||
if (ckTemp != 16) {
|
||||
TRACE1("ERROR: WRONG CTR IV LENGTH %d", ckTemp);
|
||||
} else {
|
||||
memcpy(ckpParam->cb, ckBytes, ckTemp);
|
||||
free(ckBytes);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* converts a Java CK_MECHANISM object into a CK_MECHANISM structure
|
||||
*
|
||||
@ -937,12 +977,10 @@ void jMechanismParameterToCKMechanismParameterSlow(JNIEnv *env, jobject jParam,
|
||||
{
|
||||
/* get all Java mechanism parameter classes */
|
||||
jclass jVersionClass, jSsl3MasterKeyDeriveParamsClass, jSsl3KeyMatParamsClass;
|
||||
jclass jTlsPrfParamsClass, jRsaPkcsOaepParamsClass, jPbeParamsClass;
|
||||
jclass jPkcs5Pbkd2ParamsClass, jRsaPkcsPssParamsClass;
|
||||
jclass jTlsPrfParamsClass, jAesCtrParamsClass, jRsaPkcsOaepParamsClass;
|
||||
jclass jPbeParamsClass, jPkcs5Pbkd2ParamsClass, jRsaPkcsPssParamsClass;
|
||||
jclass jEcdh1DeriveParamsClass, jEcdh2DeriveParamsClass;
|
||||
jclass jX942Dh1DeriveParamsClass, jX942Dh2DeriveParamsClass;
|
||||
|
||||
/* get all Java mechanism parameter classes */
|
||||
TRACE0("\nDEBUG: jMechanismParameterToCKMechanismParameter");
|
||||
|
||||
/* most common cases, i.e. NULL/byte[]/long, are already handled by
|
||||
@ -1046,6 +1084,33 @@ void jMechanismParameterToCKMechanismParameterSlow(JNIEnv *env, jobject jParam,
|
||||
return;
|
||||
}
|
||||
|
||||
jAesCtrParamsClass = (*env)->FindClass(env, CLASS_AES_CTR_PARAMS);
|
||||
if (jAesCtrParamsClass == NULL) { return; }
|
||||
if ((*env)->IsInstanceOf(env, jParam, jAesCtrParamsClass)) {
|
||||
/*
|
||||
* CK_AES_CTR_PARAMS
|
||||
*/
|
||||
CK_AES_CTR_PARAMS_PTR ckpParam;
|
||||
|
||||
ckpParam = (CK_AES_CTR_PARAMS_PTR) malloc(sizeof(CK_AES_CTR_PARAMS));
|
||||
if (ckpParam == NULL) {
|
||||
JNU_ThrowOutOfMemoryError(env, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
/* convert jParameter to CKParameter */
|
||||
jAesCtrParamsToCKAesCtrParam(env, jParam, ckpParam);
|
||||
if ((*env)->ExceptionCheck(env)) {
|
||||
free(ckpParam);
|
||||
return;
|
||||
}
|
||||
|
||||
/* get length and pointer of parameter */
|
||||
*ckpLength = sizeof(CK_AES_CTR_PARAMS);
|
||||
*ckpParamPtr = ckpParam;
|
||||
return;
|
||||
}
|
||||
|
||||
jRsaPkcsOaepParamsClass = (*env)->FindClass(env, CLASS_RSA_PKCS_OAEP_PARAMS);
|
||||
if (jRsaPkcsOaepParamsClass == NULL) { return; }
|
||||
if ((*env)->IsInstanceOf(env, jParam, jRsaPkcsOaepParamsClass)) {
|
||||
|
||||
@ -0,0 +1,124 @@
|
||||
/* pkcs-11v2-20a3.h include file for the PKCS #11 Version 2.20 Amendment 3
|
||||
document. */
|
||||
|
||||
/* $Revision: 1.4 $ */
|
||||
|
||||
/* License to copy and use this software is granted provided that it is
|
||||
* identified as "RSA Security Inc. PKCS #11 Cryptographic Token Interface
|
||||
* (Cryptoki) Version 2.20 Amendment 3" in all material mentioning or
|
||||
* referencing this software.
|
||||
|
||||
* RSA Security Inc. makes no representations concerning either the
|
||||
* merchantability of this software or the suitability of this software for
|
||||
* any particular purpose. It is provided "as is" without express or implied
|
||||
* warranty of any kind.
|
||||
*/
|
||||
|
||||
/* This file is preferably included after inclusion of pkcs11.h */
|
||||
|
||||
#ifndef _PKCS_11V2_20A3_H_
|
||||
#define _PKCS_11V2_20A3_H_ 1
|
||||
|
||||
/* Are the definitions of this file already included in pkcs11t.h ? */
|
||||
#ifndef CKK_CAMELLIA
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Key types */
|
||||
|
||||
/* Camellia is new for PKCS #11 v2.20 amendment 3 */
|
||||
#define CKK_CAMELLIA 0x00000025
|
||||
/* ARIA is new for PKCS #11 v2.20 amendment 3 */
|
||||
#define CKK_ARIA 0x00000026
|
||||
|
||||
|
||||
/* Mask-generating functions */
|
||||
|
||||
/* SHA-224 is new for PKCS #11 v2.20 amendment 3 */
|
||||
#define CKG_MGF1_SHA224 0x00000005
|
||||
|
||||
|
||||
/* Mechanism Identifiers */
|
||||
|
||||
/* SHA-224 is new for PKCS #11 v2.20 amendment 3 */
|
||||
#define CKM_SHA224 0x00000255
|
||||
#define CKM_SHA224_HMAC 0x00000256
|
||||
#define CKM_SHA224_HMAC_GENERAL 0x00000257
|
||||
|
||||
/* SHA-224 key derivation is new for PKCS #11 v2.20 amendment 3 */
|
||||
#define CKM_SHA224_KEY_DERIVATION 0x00000396
|
||||
|
||||
/* SHA-224 RSA mechanisms are new for PKCS #11 v2.20 amendment 3 */
|
||||
#define CKM_SHA224_RSA_PKCS 0x00000046
|
||||
#define CKM_SHA224_RSA_PKCS_PSS 0x00000047
|
||||
|
||||
/* AES counter mode is new for PKCS #11 v2.20 amendment 3 */
|
||||
#define CKM_AES_CTR 0x00001086
|
||||
|
||||
/* Camellia is new for PKCS #11 v2.20 amendment 3 */
|
||||
#define CKM_CAMELLIA_KEY_GEN 0x00000550
|
||||
#define CKM_CAMELLIA_ECB 0x00000551
|
||||
#define CKM_CAMELLIA_CBC 0x00000552
|
||||
#define CKM_CAMELLIA_MAC 0x00000553
|
||||
#define CKM_CAMELLIA_MAC_GENERAL 0x00000554
|
||||
#define CKM_CAMELLIA_CBC_PAD 0x00000555
|
||||
#define CKM_CAMELLIA_ECB_ENCRYPT_DATA 0x00000556
|
||||
#define CKM_CAMELLIA_CBC_ENCRYPT_DATA 0x00000557
|
||||
#define CKM_CAMELLIA_CTR 0x00000558
|
||||
|
||||
/* ARIA is new for PKCS #11 v2.20 amendment 3 */
|
||||
#define CKM_ARIA_KEY_GEN 0x00000560
|
||||
#define CKM_ARIA_ECB 0x00000561
|
||||
#define CKM_ARIA_CBC 0x00000562
|
||||
#define CKM_ARIA_MAC 0x00000563
|
||||
#define CKM_ARIA_MAC_GENERAL 0x00000564
|
||||
#define CKM_ARIA_CBC_PAD 0x00000565
|
||||
#define CKM_ARIA_ECB_ENCRYPT_DATA 0x00000566
|
||||
#define CKM_ARIA_CBC_ENCRYPT_DATA 0x00000567
|
||||
|
||||
|
||||
/* Mechanism parameters */
|
||||
|
||||
/* CK_AES_CTR_PARAMS is new for PKCS #11 v2.20 amendment 3 */
|
||||
typedef struct CK_AES_CTR_PARAMS {
|
||||
CK_ULONG ulCounterBits;
|
||||
CK_BYTE cb[16];
|
||||
} CK_AES_CTR_PARAMS;
|
||||
|
||||
typedef CK_AES_CTR_PARAMS CK_PTR CK_AES_CTR_PARAMS_PTR;
|
||||
|
||||
/* CK_CAMELLIA_CTR_PARAMS is new for PKCS #11 v2.20 amendment 3 */
|
||||
typedef struct CK_CAMELLIA_CTR_PARAMS {
|
||||
CK_ULONG ulCounterBits;
|
||||
CK_BYTE cb[16];
|
||||
} CK_CAMELLIA_CTR_PARAMS;
|
||||
|
||||
typedef CK_CAMELLIA_CTR_PARAMS CK_PTR CK_CAMELLIA_CTR_PARAMS_PTR;
|
||||
|
||||
/* CK_CAMELLIA_CBC_ENCRYPT_DATA_PARAMS is new for PKCS #11 v2.20 amendment 3 */
|
||||
typedef struct CK_CAMELLIA_CBC_ENCRYPT_DATA_PARAMS {
|
||||
CK_BYTE iv[16];
|
||||
CK_BYTE_PTR pData;
|
||||
CK_ULONG length;
|
||||
} CK_CAMELLIA_CBC_ENCRYPT_DATA_PARAMS;
|
||||
|
||||
typedef CK_CAMELLIA_CBC_ENCRYPT_DATA_PARAMS CK_PTR CK_CAMELLIA_CBC_ENCRYPT_DATA_PARAMS_PTR;
|
||||
|
||||
/* CK_ARIA_CBC_ENCRYPT_DATA_PARAMS is new for PKCS #11 v2.20 amendment 3 */
|
||||
typedef struct CK_ARIA_CBC_ENCRYPT_DATA_PARAMS {
|
||||
CK_BYTE iv[16];
|
||||
CK_BYTE_PTR pData;
|
||||
CK_ULONG length;
|
||||
} CK_ARIA_CBC_ENCRYPT_DATA_PARAMS;
|
||||
|
||||
typedef CK_ARIA_CBC_ENCRYPT_DATA_PARAMS CK_PTR CK_ARIA_CBC_ENCRYPT_DATA_PARAMS_PTR;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2009, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
|
||||
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
|
||||
@ -153,6 +153,7 @@
|
||||
#include "p11_md.h"
|
||||
|
||||
#include "pkcs11.h"
|
||||
#include "pkcs-11v2-20a3.h"
|
||||
#include <jni.h>
|
||||
#include <jni_util.h>
|
||||
|
||||
@ -272,6 +273,7 @@
|
||||
#define CLASS_SSL3_MASTER_KEY_DERIVE_PARAMS "sun/security/pkcs11/wrapper/CK_SSL3_MASTER_KEY_DERIVE_PARAMS"
|
||||
#define CLASS_SSL3_KEY_MAT_PARAMS "sun/security/pkcs11/wrapper/CK_SSL3_KEY_MAT_PARAMS"
|
||||
#define CLASS_TLS_PRF_PARAMS "sun/security/pkcs11/wrapper/CK_TLS_PRF_PARAMS"
|
||||
#define CLASS_AES_CTR_PARAMS "sun/security/pkcs11/wrapper/CK_AES_CTR_PARAMS"
|
||||
|
||||
/* function to convert a PKCS#11 return value other than CK_OK into a Java Exception
|
||||
* or to throw a PKCS11RuntimeException
|
||||
|
||||
@ -571,9 +571,9 @@ class FileSystemPreferences extends AbstractPreferences {
|
||||
long newLastSyncTime = 0;
|
||||
try {
|
||||
newLastSyncTime = prefsFile.lastModified();
|
||||
FileInputStream fis = new FileInputStream(prefsFile);
|
||||
XmlSupport.importMap(fis, m);
|
||||
fis.close();
|
||||
try (FileInputStream fis = new FileInputStream(prefsFile)) {
|
||||
XmlSupport.importMap(fis, m);
|
||||
}
|
||||
} catch(Exception e) {
|
||||
if (e instanceof InvalidPreferencesFormatException) {
|
||||
getLogger().warning("Invalid preferences format in "
|
||||
@ -618,9 +618,9 @@ class FileSystemPreferences extends AbstractPreferences {
|
||||
if (!dir.exists() && !dir.mkdirs())
|
||||
throw new BackingStoreException(dir +
|
||||
" create failed.");
|
||||
FileOutputStream fos = new FileOutputStream(tmpFile);
|
||||
XmlSupport.exportMap(fos, prefsCache);
|
||||
fos.close();
|
||||
try (FileOutputStream fos = new FileOutputStream(tmpFile)) {
|
||||
XmlSupport.exportMap(fos, prefsCache);
|
||||
}
|
||||
if (!tmpFile.renameTo(prefsFile))
|
||||
throw new BackingStoreException("Can't rename " +
|
||||
tmpFile + " to " + prefsFile);
|
||||
|
||||
@ -236,7 +236,9 @@ class UnixAsynchronousServerSocketChannelImpl
|
||||
} catch (SecurityException x) {
|
||||
try {
|
||||
ch.close();
|
||||
} catch (IOException ignore) { }
|
||||
} catch (Throwable suppressed) {
|
||||
x.addSuppressed(suppressed);
|
||||
}
|
||||
throw x;
|
||||
}
|
||||
return ch;
|
||||
|
||||
@ -137,7 +137,7 @@ class UnixAsynchronousSocketChannelImpl
|
||||
return port;
|
||||
}
|
||||
|
||||
// register for events if there are outstanding I/O operations
|
||||
// register events for outstanding I/O operations, caller already owns updateLock
|
||||
private void updateEvents() {
|
||||
assert Thread.holdsLock(updateLock);
|
||||
int events = 0;
|
||||
@ -149,6 +149,13 @@ class UnixAsynchronousSocketChannelImpl
|
||||
port.startPoll(fdVal, events);
|
||||
}
|
||||
|
||||
// register events for outstanding I/O operations
|
||||
private void lockAndUpdateEvents() {
|
||||
synchronized (updateLock) {
|
||||
updateEvents();
|
||||
}
|
||||
}
|
||||
|
||||
// invoke to finish read and/or write operations
|
||||
private void finish(boolean mayInvokeDirect,
|
||||
boolean readable,
|
||||
@ -255,10 +262,11 @@ class UnixAsynchronousSocketChannelImpl
|
||||
// close channel if connection cannot be established
|
||||
try {
|
||||
close();
|
||||
} catch (IOException ignore) { }
|
||||
} catch (Throwable suppressed) {
|
||||
e.addSuppressed(suppressed);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// invoke handler and set result
|
||||
CompletionHandler<Void,Object> handler = connectHandler;
|
||||
Object att = connectAttachment;
|
||||
@ -345,7 +353,9 @@ class UnixAsynchronousSocketChannelImpl
|
||||
if (e != null) {
|
||||
try {
|
||||
close();
|
||||
} catch (IOException ignore) { }
|
||||
} catch (Throwable suppressed) {
|
||||
e.addSuppressed(suppressed);
|
||||
}
|
||||
}
|
||||
if (handler == null) {
|
||||
return CompletedFuture.withResult(null, e);
|
||||
@ -399,9 +409,8 @@ class UnixAsynchronousSocketChannelImpl
|
||||
exc = x;
|
||||
} finally {
|
||||
// restart poll in case of concurrent write
|
||||
synchronized (updateLock) {
|
||||
updateEvents();
|
||||
}
|
||||
if (!(exc instanceof AsynchronousCloseException))
|
||||
lockAndUpdateEvents();
|
||||
end();
|
||||
}
|
||||
|
||||
@ -595,9 +604,8 @@ class UnixAsynchronousSocketChannelImpl
|
||||
exc = x;
|
||||
} finally {
|
||||
// restart poll in case of concurrent write
|
||||
synchronized (updateLock) {
|
||||
updateEvents();
|
||||
}
|
||||
if (!(exc instanceof AsynchronousCloseException))
|
||||
lockAndUpdateEvents();
|
||||
end();
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2011, 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
|
||||
@ -77,22 +77,24 @@ Java_java_net_Inet4AddressImpl_getLocalHostName(JNIEnv *env, jobject this) {
|
||||
*/
|
||||
#endif /* __linux__ */
|
||||
struct hostent res, res2, *hp;
|
||||
char buf[HENT_BUF_SIZE];
|
||||
char buf2[HENT_BUF_SIZE];
|
||||
// these buffers must be pointer-aligned so they are declared
|
||||
// with pointer type
|
||||
char *buf[HENT_BUF_SIZE/(sizeof (char *))];
|
||||
char *buf2[HENT_BUF_SIZE/(sizeof (char *))];
|
||||
int h_error=0;
|
||||
|
||||
#ifdef __GLIBC__
|
||||
gethostbyname_r(hostname, &res, buf, sizeof(buf), &hp, &h_error);
|
||||
gethostbyname_r(hostname, &res, (char*)buf, sizeof(buf), &hp, &h_error);
|
||||
#else
|
||||
hp = gethostbyname_r(hostname, &res, buf, sizeof(buf), &h_error);
|
||||
hp = gethostbyname_r(hostname, &res, (char*)buf, sizeof(buf), &h_error);
|
||||
#endif
|
||||
if (hp) {
|
||||
#ifdef __GLIBC__
|
||||
gethostbyaddr_r(hp->h_addr, hp->h_length, AF_INET,
|
||||
&res2, buf2, sizeof(buf2), &hp, &h_error);
|
||||
&res2, (char*)buf2, sizeof(buf2), &hp, &h_error);
|
||||
#else
|
||||
hp = gethostbyaddr_r(hp->h_addr, hp->h_length, AF_INET,
|
||||
&res2, buf2, sizeof(buf2), &h_error);
|
||||
&res2, (char*)buf2, sizeof(buf2), &h_error);
|
||||
#endif
|
||||
if (hp) {
|
||||
/*
|
||||
@ -136,7 +138,9 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
|
||||
const char *hostname;
|
||||
jobjectArray ret = 0;
|
||||
struct hostent res, *hp = 0;
|
||||
char buf[HENT_BUF_SIZE];
|
||||
// this buffer must be pointer-aligned so is declared
|
||||
// with pointer type
|
||||
char *buf[HENT_BUF_SIZE/(sizeof (char *))];
|
||||
|
||||
/* temporary buffer, on the off chance we need to expand */
|
||||
char *tmp = NULL;
|
||||
@ -176,9 +180,9 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
|
||||
|
||||
/* Try once, with our static buffer. */
|
||||
#ifdef __GLIBC__
|
||||
gethostbyname_r(hostname, &res, buf, sizeof(buf), &hp, &h_error);
|
||||
gethostbyname_r(hostname, &res, (char*)buf, sizeof(buf), &hp, &h_error);
|
||||
#else
|
||||
hp = gethostbyname_r(hostname, &res, buf, sizeof(buf), &h_error);
|
||||
hp = gethostbyname_r(hostname, &res, (char*)buf, sizeof(buf), &h_error);
|
||||
#endif
|
||||
|
||||
/* With the re-entrant system calls, it's possible that the buffer
|
||||
@ -251,7 +255,9 @@ Java_java_net_Inet4AddressImpl_getHostByAddr(JNIEnv *env, jobject this,
|
||||
jstring ret = NULL;
|
||||
jint addr;
|
||||
struct hostent hent, *hp = 0;
|
||||
char buf[HENT_BUF_SIZE];
|
||||
// this buffer must be pointer-aligned so is declared
|
||||
// with pointer type
|
||||
char *buf[HENT_BUF_SIZE/(sizeof (char *))];
|
||||
int h_error = 0;
|
||||
char *tmp = NULL;
|
||||
|
||||
@ -273,10 +279,10 @@ Java_java_net_Inet4AddressImpl_getHostByAddr(JNIEnv *env, jobject this,
|
||||
addr = htonl(addr);
|
||||
#ifdef __GLIBC__
|
||||
gethostbyaddr_r((char *)&addr, sizeof(addr), AF_INET, &hent,
|
||||
buf, sizeof(buf), &hp, &h_error);
|
||||
(char*)buf, sizeof(buf), &hp, &h_error);
|
||||
#else
|
||||
hp = gethostbyaddr_r((char *)&addr, sizeof(addr), AF_INET, &hent,
|
||||
buf, sizeof(buf), &h_error);
|
||||
(char*)buf, sizeof(buf), &h_error);
|
||||
#endif
|
||||
/* With the re-entrant system calls, it's possible that the buffer
|
||||
* we pass to it is not large enough to hold an exceptionally
|
||||
|
||||
@ -45,7 +45,6 @@
|
||||
#ifdef __linux__
|
||||
#include <sys/ioctl.h>
|
||||
#include <bits/ioctls.h>
|
||||
#include <linux/sockios.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
@ -1100,7 +1099,7 @@ static netif *enumIPv4Interfaces(JNIEnv *env, int sock, netif *ifs) {
|
||||
#ifdef AF_INET6
|
||||
static netif *enumIPv6Interfaces(JNIEnv *env, int sock, netif *ifs) {
|
||||
FILE *f;
|
||||
char addr6[40], devname[20];
|
||||
char addr6[40], devname[21];
|
||||
char addr6p[8][5];
|
||||
int plen, scope, dad_status, if_idx;
|
||||
uint8_t ipv6addr[16];
|
||||
|
||||
@ -34,8 +34,8 @@
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
#ifdef __linux__
|
||||
#include <linux/unistd.h>
|
||||
#include <linux/sysctl.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <netinet/ip.h>
|
||||
|
||||
|
||||
@ -42,8 +42,8 @@
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
#ifdef __linux__
|
||||
#include <linux/unistd.h>
|
||||
#include <linux/sysctl.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
|
||||
#include "jvm.h"
|
||||
|
||||
@ -112,7 +112,7 @@ static void __attribute((constructor)) init() {
|
||||
*/
|
||||
static inline fdEntry_t *getFdEntry(int fd)
|
||||
{
|
||||
if (fd < 0 || fd > fdCount) {
|
||||
if (fd < 0 || fd >= fdCount) {
|
||||
return NULL;
|
||||
}
|
||||
return &fdTable[fd];
|
||||
|
||||
@ -608,7 +608,7 @@ static void initLoopbackRoutes() {
|
||||
{
|
||||
/* now find the scope_id for "lo" */
|
||||
|
||||
char devname[20];
|
||||
char devname[21];
|
||||
char addr6p[8][5];
|
||||
int plen, scope, dad_status, if_idx;
|
||||
|
||||
@ -651,7 +651,7 @@ static int nifs = 0; /* number of entries used in array */
|
||||
static void initLocalIfs () {
|
||||
FILE *f;
|
||||
unsigned char staddr [16];
|
||||
char ifname [32];
|
||||
char ifname [33];
|
||||
struct localinterface *lif=0;
|
||||
int index, x1, x2, x3;
|
||||
unsigned int u0,u1,u2,u3,u4,u5,u6,u7,u8,u9,ua,ub,uc,ud,ue,uf;
|
||||
@ -660,7 +660,7 @@ static void initLocalIfs () {
|
||||
return ;
|
||||
}
|
||||
while (fscanf (f, "%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x%2x "
|
||||
"%d %x %x %x %s",&u0,&u1,&u2,&u3,&u4,&u5,&u6,&u7,
|
||||
"%d %x %x %x %32s",&u0,&u1,&u2,&u3,&u4,&u5,&u6,&u7,
|
||||
&u8,&u9,&ua,&ub,&uc,&ud,&ue,&uf,
|
||||
&index, &x1, &x2, &x3, ifname) == 21) {
|
||||
staddr[0] = (unsigned char)u0;
|
||||
@ -1102,7 +1102,7 @@ int getDefaultIPv6Interface(struct in6_addr *target_addr) {
|
||||
* index.
|
||||
*/
|
||||
if (match) {
|
||||
char devname[20];
|
||||
char devname[21];
|
||||
char addr6p[8][5];
|
||||
int plen, scope, dad_status, if_idx;
|
||||
|
||||
|
||||
@ -110,8 +110,7 @@ class PendingIoCache {
|
||||
if (closed)
|
||||
return;
|
||||
|
||||
// handle the case that where there are I/O operations that have
|
||||
// not completed.
|
||||
// handle case where I/O operations that have not completed.
|
||||
if (!pendingIoMap.isEmpty())
|
||||
clearPendingIoMap();
|
||||
|
||||
@ -132,7 +131,9 @@ class PendingIoCache {
|
||||
closePending = true;
|
||||
try {
|
||||
this.wait(50);
|
||||
} catch (InterruptedException x) { }
|
||||
} catch (InterruptedException x) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
closePending = false;
|
||||
if (pendingIoMap.isEmpty())
|
||||
return;
|
||||
|
||||
@ -439,6 +439,7 @@ public class WindowsAsynchronousFileChannelImpl
|
||||
address = ((DirectBuffer)buf).address();
|
||||
}
|
||||
|
||||
boolean pending = false;
|
||||
try {
|
||||
begin();
|
||||
|
||||
@ -449,6 +450,7 @@ public class WindowsAsynchronousFileChannelImpl
|
||||
n = readFile(handle, address, rem, position, overlapped);
|
||||
if (n == IOStatus.UNAVAILABLE) {
|
||||
// I/O is pending
|
||||
pending = true;
|
||||
return;
|
||||
} else if (n == IOStatus.EOF) {
|
||||
result.setResult(n);
|
||||
@ -460,14 +462,15 @@ public class WindowsAsynchronousFileChannelImpl
|
||||
// failed to initiate read
|
||||
result.setFailure(toIOException(x));
|
||||
} finally {
|
||||
if (!pending) {
|
||||
// release resources
|
||||
if (overlapped != 0L)
|
||||
ioCache.remove(overlapped);
|
||||
releaseBufferIfSubstituted();
|
||||
}
|
||||
end();
|
||||
}
|
||||
|
||||
// release resources
|
||||
if (overlapped != 0L)
|
||||
ioCache.remove(overlapped);
|
||||
releaseBufferIfSubstituted();
|
||||
|
||||
// invoke completion handler
|
||||
Invoker.invoke(result);
|
||||
}
|
||||
|
||||
@ -239,14 +239,14 @@ class WindowsAsynchronousSocketChannelImpl
|
||||
result.setResult(null);
|
||||
}
|
||||
} catch (Throwable x) {
|
||||
if (overlapped != 0L)
|
||||
ioCache.remove(overlapped);
|
||||
exc = x;
|
||||
} finally {
|
||||
end();
|
||||
}
|
||||
|
||||
if (exc != null) {
|
||||
if (overlapped != 0L)
|
||||
ioCache.remove(overlapped);
|
||||
closeChannel();
|
||||
result.setFailure(toIOException(exc));
|
||||
}
|
||||
|
||||
@ -201,13 +201,12 @@ class WindowsFileStore
|
||||
if (!(ob instanceof WindowsFileStore))
|
||||
return false;
|
||||
WindowsFileStore other = (WindowsFileStore)ob;
|
||||
return this.volInfo.volumeSerialNumber() == other.volInfo.volumeSerialNumber();
|
||||
return root.equals(other.root);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
// reveals VSN without permission check - okay?
|
||||
return volInfo.volumeSerialNumber();
|
||||
return root.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -380,30 +380,9 @@ java/io/File/MaxPathLength.java windows-all
|
||||
|
||||
# jdk_nio
|
||||
|
||||
# 6944810
|
||||
java/nio/channels/FileChannel/ReleaseOnCloseDeadlock.java windows-all
|
||||
|
||||
# 6963118
|
||||
java/nio/channels/Selector/Wakeup.java windows-all
|
||||
|
||||
# The asynchronous I/O implementation on Windows requires Windows XP or newer.
|
||||
# We can remove the following once all Windows 2000 machines have been
|
||||
# decommissioned.
|
||||
java/nio/channels/AsynchronousChannelGroup/Basic.java windows-5.0
|
||||
java/nio/channels/AsynchronousChannelGroup/GroupOfOne.java windows-5.0
|
||||
java/nio/channels/AsynchronousChannelGroup/Identity.java windows-5.0
|
||||
java/nio/channels/AsynchronousChannelGroup/Restart.java windows-5.0
|
||||
java/nio/channels/AsynchronousChannelGroup/Unbounded.java windows-5.0
|
||||
java/nio/channels/AsynchronousDatagramChannel/Basic.java windows-5.0
|
||||
java/nio/channels/AsynchronousFileChannel/Lock.java windows-5.0
|
||||
java/nio/channels/AsynchronousServerSocketChannel/Basic.java windows-5.0
|
||||
java/nio/channels/AsynchronousServerSocketChannel/WithSecurityManager.java windows-5.0
|
||||
java/nio/channels/AsynchronousSocketChannel/Basic.java windows-5.0
|
||||
java/nio/channels/AsynchronousSocketChannel/DieBeforeComplete.java windows-5.0
|
||||
java/nio/channels/AsynchronousSocketChannel/Leaky.java windows-5.0
|
||||
java/nio/channels/AsynchronousSocketChannel/StressLoopback.java windows-5.0
|
||||
java/nio/channels/Channels/Basic2.java windows-5.0
|
||||
|
||||
# 6959891
|
||||
com/sun/nio/sctp/SctpChannel/SocketOptionTests.java
|
||||
|
||||
@ -625,9 +604,6 @@ sun/security/tools/keytool/emptysubject.sh generic-all
|
||||
# Timeout on solaris-sparcv9 or exception thrown
|
||||
com/sun/crypto/provider/Cipher/RSA/TestOAEP_KAT.java solaris-all
|
||||
|
||||
# File 6535697.test input stream left open? windows samevm
|
||||
java/security/cert/CertificateFactory/openssl/OpenSSLCert.java generic-all
|
||||
|
||||
# Leaving file open: SerialVersion.current, windows samevm
|
||||
java/security/BasicPermission/SerialVersion.java generic-all
|
||||
|
||||
@ -717,6 +693,7 @@ sun/tools/jconsole/ResourceCheckTest.sh generic-all
|
||||
# Filed 6933803
|
||||
java/util/concurrent/ThreadPoolExecutor/CoreThreadTimeOut.java generic-all
|
||||
|
||||
# Filed 7022325
|
||||
# Fails with assertion error on windows
|
||||
# 11 separate stacktraces created... file reuse problem?
|
||||
java/util/zip/ZipFile/ReadLongZipFileName.java generic-all
|
||||
|
||||
131
jdk/test/com/sun/jndi/ldap/NoWaitForReplyTest.java
Normal file
131
jdk/test/com/sun/jndi/ldap/NoWaitForReplyTest.java
Normal file
@ -0,0 +1,131 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 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 6748156
|
||||
* @summary add an new JNDI property to control the boolean flag WaitForReply
|
||||
*/
|
||||
|
||||
import java.net.Socket;
|
||||
import java.net.ServerSocket;
|
||||
import java.io.*;
|
||||
import javax.naming.*;
|
||||
import javax.naming.directory.*;
|
||||
import java.util.Hashtable;
|
||||
|
||||
public class NoWaitForReplyTest {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
boolean passed = false;
|
||||
|
||||
// start the LDAP server
|
||||
DummyServer ldapServer = new DummyServer();
|
||||
ldapServer.start();
|
||||
|
||||
// Set up the environment for creating the initial context
|
||||
Hashtable env = new Hashtable(11);
|
||||
env.put(Context.PROVIDER_URL, "ldap://localhost:" +
|
||||
ldapServer.getPortNumber());
|
||||
env.put(Context.INITIAL_CONTEXT_FACTORY,
|
||||
"com.sun.jndi.ldap.LdapCtxFactory");
|
||||
|
||||
// Wait up to 10 seconds for a response from the LDAP server
|
||||
env.put("com.sun.jndi.ldap.read.timeout", "10000");
|
||||
|
||||
// Don't wait until the first search reply is received
|
||||
env.put("com.sun.jndi.ldap.search.waitForReply", "false");
|
||||
|
||||
// Send the LDAP search request without first authenticating (no bind)
|
||||
env.put("java.naming.ldap.version", "3");
|
||||
|
||||
|
||||
try {
|
||||
|
||||
// Create initial context
|
||||
System.out.println("Client: connecting to the server");
|
||||
DirContext ctx = new InitialDirContext(env);
|
||||
|
||||
SearchControls scl = new SearchControls();
|
||||
scl.setSearchScope(SearchControls.SUBTREE_SCOPE);
|
||||
System.out.println("Client: performing search");
|
||||
NamingEnumeration answer =
|
||||
ctx.search("ou=People,o=JNDITutorial", "(objectClass=*)", scl);
|
||||
|
||||
// Server will never reply: either we waited in the call above until
|
||||
// the timeout (fail) or we did not wait and reached here (pass).
|
||||
passed = true;
|
||||
System.out.println("Client: did not wait until first reply");
|
||||
|
||||
// Close the context when we're done
|
||||
ctx.close();
|
||||
|
||||
} catch (NamingException e) {
|
||||
// timeout (ignore)
|
||||
}
|
||||
ldapServer.interrupt();
|
||||
|
||||
if (!passed) {
|
||||
throw new Exception(
|
||||
"Test FAILED: should not have waited until first search reply");
|
||||
}
|
||||
System.out.println("Test PASSED");
|
||||
}
|
||||
|
||||
static class DummyServer extends Thread {
|
||||
|
||||
private final ServerSocket serverSocket;
|
||||
|
||||
DummyServer() throws IOException {
|
||||
this.serverSocket = new ServerSocket(0);
|
||||
System.out.println("Server: listening on port " + serverSocket.getLocalPort());
|
||||
}
|
||||
|
||||
public int getPortNumber() {
|
||||
return serverSocket.getLocalPort();
|
||||
}
|
||||
|
||||
public void run() {
|
||||
try (Socket socket = serverSocket.accept()) {
|
||||
System.out.println("Server: accepted a connection");
|
||||
InputStream in = socket.getInputStream();
|
||||
|
||||
while (!isInterrupted()) {
|
||||
in.skip(in.available());
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
|
||||
} finally {
|
||||
System.out.println("Server: shutting down");
|
||||
try {
|
||||
serverSocket.close();
|
||||
} catch (IOException e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -105,9 +105,9 @@ public class SetLastModified {
|
||||
System.getProperty("os.name").startsWith("Windows") ? 0L : 3L*G;
|
||||
long pos = 0L;
|
||||
while (pos <= MAX_POSITION) {
|
||||
FileChannel fc = new FileOutputStream(f).getChannel();
|
||||
fc.position(pos).write(ByteBuffer.wrap("x".getBytes()));
|
||||
fc.close();
|
||||
try (FileChannel fc = new FileOutputStream(f).getChannel()) {
|
||||
fc.position(pos).write(ByteBuffer.wrap("x".getBytes()));
|
||||
}
|
||||
ot = f.lastModified();
|
||||
System.out.format("check with file size: %d\n", f.length());
|
||||
if (!f.setLastModified(nt))
|
||||
|
||||
@ -47,12 +47,12 @@ public class AtomicAppend {
|
||||
for (int i = 0; i < nThreads; i++)
|
||||
es.execute(new Runnable() { public void run() {
|
||||
try {
|
||||
FileOutputStream s = new FileOutputStream(file, true);
|
||||
for (int j = 0; j < 1000; j++) {
|
||||
s.write((int) 'x');
|
||||
s.flush();
|
||||
try (FileOutputStream s = new FileOutputStream(file, true)) {
|
||||
for (int j = 0; j < 1000; j++) {
|
||||
s.write((int) 'x');
|
||||
s.flush();
|
||||
}
|
||||
}
|
||||
s.close();
|
||||
} catch (Throwable t) { unexpected(t); }}});
|
||||
es.shutdown();
|
||||
es.awaitTermination(10L, TimeUnit.MINUTES);
|
||||
|
||||
@ -35,8 +35,9 @@ public class Encode implements Runnable {
|
||||
new Encode();
|
||||
}
|
||||
|
||||
final ServerSocket ss = new ServerSocket(0);
|
||||
|
||||
Encode() throws Exception {
|
||||
ss = new ServerSocket(0);
|
||||
(new Thread(this)).start();
|
||||
String toEncode = "\uD800\uDC00 \uD801\uDC01 ";
|
||||
String enc1 = URLEncoder.encode(toEncode, "UTF-8");
|
||||
@ -47,27 +48,31 @@ public class Encode implements Runnable {
|
||||
"/missing.nothtml";
|
||||
HttpURLConnection uc = (HttpURLConnection)new URL(url).openConnection();
|
||||
uc.connect();
|
||||
String enc2 = URLEncoder.encode(toEncode, "UTF-8");
|
||||
if (!enc1.equals(enc2))
|
||||
throw new RuntimeException("test failed");
|
||||
uc.disconnect();
|
||||
try {
|
||||
String enc2 = URLEncoder.encode(toEncode, "UTF-8");
|
||||
if (!enc1.equals(enc2)) {
|
||||
System.out.println("test failed");
|
||||
throw new RuntimeException("test failed");
|
||||
}
|
||||
} finally {
|
||||
uc.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
ServerSocket ss;
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
Socket s = ss.accept();
|
||||
BufferedReader in = new BufferedReader(
|
||||
new InputStreamReader(s.getInputStream()));
|
||||
try (ServerSocket serv = ss;
|
||||
Socket s = serv.accept();
|
||||
BufferedReader in =
|
||||
new BufferedReader(new InputStreamReader(s.getInputStream())))
|
||||
{
|
||||
String req = in.readLine();
|
||||
PrintStream out = new PrintStream(new BufferedOutputStream(
|
||||
s.getOutputStream()));
|
||||
out.print("HTTP/1.1 403 Forbidden\r\n");
|
||||
out.print("\r\n");
|
||||
out.flush();
|
||||
s.close();
|
||||
ss.close();
|
||||
try (OutputStream os = s.getOutputStream();
|
||||
BufferedOutputStream bos = new BufferedOutputStream(os);
|
||||
PrintStream out = new PrintStream(bos))
|
||||
{
|
||||
out.print("HTTP/1.1 403 Forbidden\r\n");
|
||||
out.print("\r\n");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@ -34,11 +34,11 @@ public class EncodingConstructor {
|
||||
|
||||
public static void main(String args[]) throws Exception {
|
||||
ByteArrayOutputStream bo = new ByteArrayOutputStream();
|
||||
PrintStream ps = new PrintStream(bo, false, "UTF-8");
|
||||
String s = "xyzzy";
|
||||
int n = s.length();
|
||||
ps.print(s);
|
||||
ps.close();
|
||||
try (PrintStream ps = new PrintStream(bo, false, "UTF-8")) {
|
||||
ps.print(s);
|
||||
}
|
||||
byte[] ba = bo.toByteArray();
|
||||
if (ba.length != n)
|
||||
throw new Exception("Length mismatch: " + n + " " + ba.length);
|
||||
|
||||
@ -35,6 +35,8 @@ import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class FailingConstructors {
|
||||
static final String fileName = "FailingConstructorsTest";
|
||||
@ -45,14 +47,13 @@ public class FailingConstructors {
|
||||
test(false, new File(fileName));
|
||||
|
||||
/* create the file and write its contents */
|
||||
File file = File.createTempFile(fileName, null);
|
||||
file.deleteOnExit();
|
||||
FileOutputStream fos = new FileOutputStream(file);
|
||||
fos.write(FILE_CONTENTS.getBytes());
|
||||
fos.close();
|
||||
|
||||
test(true, file);
|
||||
file.delete();
|
||||
Path path = Files.createTempFile(fileName, null);
|
||||
try {
|
||||
Files.write(path, FILE_CONTENTS.getBytes());
|
||||
test(true, path.toFile());
|
||||
} finally {
|
||||
Files.delete(path);
|
||||
}
|
||||
}
|
||||
|
||||
private static void test(boolean exists, File file) throws Throwable {
|
||||
|
||||
@ -27,7 +27,7 @@
|
||||
* @build install/SerialDriver.java test/SerialDriver.java extension/ExtendedObjectInputStream.java
|
||||
* @summary Enable resolveClass() to accommodate package renaming.
|
||||
* This fix enables one to implement a resolveClass method that maps a
|
||||
* Serialiazable class within a serialization stream to the same class
|
||||
* Serializable class within a serialization stream to the same class
|
||||
* in a different package within the JVM runtime. See run shell script
|
||||
* for instructions on how to run this test.
|
||||
*/
|
||||
@ -86,16 +86,15 @@ public class SerialDriver implements Serializable {
|
||||
File f = new File("stream.ser");
|
||||
if (serialize) {
|
||||
// Serialize the subclass
|
||||
try {
|
||||
FileOutputStream fo = new FileOutputStream(f);
|
||||
ObjectOutputStream so = new ObjectOutputStream(fo);
|
||||
try (FileOutputStream fo = new FileOutputStream(f);
|
||||
ObjectOutputStream so = new ObjectOutputStream(fo))
|
||||
{
|
||||
so.writeObject(obj);
|
||||
/* Skip arrays since they do not work with rename yet.
|
||||
The serialVersionUID changes due to the name change
|
||||
and there is no way to set the serialVersionUID for an
|
||||
array. */
|
||||
so.writeObject(array);
|
||||
so.flush();
|
||||
} catch (Exception e) {
|
||||
System.out.println(e);
|
||||
throw e;
|
||||
@ -103,16 +102,14 @@ public class SerialDriver implements Serializable {
|
||||
}
|
||||
if (deserialize) {
|
||||
// Deserialize the subclass
|
||||
try {
|
||||
FileInputStream fi = new FileInputStream(f);
|
||||
ExtendedObjectInputStream si =
|
||||
new ExtendedObjectInputStream(fi);
|
||||
try (FileInputStream fi = new FileInputStream(f);
|
||||
ExtendedObjectInputStream si = new ExtendedObjectInputStream(fi))
|
||||
{
|
||||
si.addRenamedClassName("test.SerialDriver", "install.SerialDriver");
|
||||
si.addRenamedClassName("[Ltest.SerialDriver;",
|
||||
"[Linstall.SerialDriver");
|
||||
obj = (SerialDriver) si.readObject();
|
||||
array = (SerialDriver[]) si.readObject();
|
||||
si.close();
|
||||
} catch (Exception e) {
|
||||
System.out.println(e);
|
||||
throw e;
|
||||
|
||||
@ -27,7 +27,7 @@
|
||||
* @build install/SerialDriver.java test/SerialDriver.java extension/ExtendedObjectInputStream.java
|
||||
* @summary Enable resolveClass() to accommodate package renaming.
|
||||
* This fix enables one to implement a resolveClass method that maps a
|
||||
* Serialiazable class within a serialization stream to the same class
|
||||
* Serializable class within a serialization stream to the same class
|
||||
* in a different package within the JVM runtime. See run shell script
|
||||
* for instructions on how to run this test.
|
||||
*/
|
||||
@ -83,14 +83,13 @@ public class SerialDriver implements Serializable {
|
||||
File f = new File("stream.ser");
|
||||
if (serialize) {
|
||||
// Serialize the subclass
|
||||
try {
|
||||
FileOutputStream fo = new FileOutputStream(f);
|
||||
ObjectOutputStream so = new ObjectOutputStream(fo);
|
||||
try (FileOutputStream fo = new FileOutputStream(f);
|
||||
ObjectOutputStream so = new ObjectOutputStream(fo))
|
||||
{
|
||||
so.writeObject(obj);
|
||||
/* Comment out since renaming arrays does not work
|
||||
since it changes the serialVersionUID. */
|
||||
so.writeObject(array);
|
||||
so.flush();
|
||||
} catch (Exception e) {
|
||||
System.out.println(e);
|
||||
throw e;
|
||||
@ -98,16 +97,15 @@ public class SerialDriver implements Serializable {
|
||||
}
|
||||
if (deserialize) {
|
||||
// Deserialize the subclass
|
||||
try {
|
||||
FileInputStream fi = new FileInputStream(f);
|
||||
ExtendedObjectInputStream si = new ExtendedObjectInputStream(fi);
|
||||
try (FileInputStream fi = new FileInputStream(f);
|
||||
ExtendedObjectInputStream si = new ExtendedObjectInputStream(fi))
|
||||
{
|
||||
si.addRenamedClassName("install.SerialDriver",
|
||||
"test.SerialDriver");
|
||||
si.addRenamedClassName("[Linstall.SerialDriver;",
|
||||
"[Ltest.SerialDriver");
|
||||
obj = (SerialDriver) si.readObject();
|
||||
array = (SerialDriver[]) si.readObject();
|
||||
si.close();
|
||||
} catch (Exception e) {
|
||||
System.out.println(e);
|
||||
throw e;
|
||||
|
||||
@ -12,40 +12,43 @@ import java.lang.Character.UnicodeScript;
|
||||
|
||||
public class CheckScript {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
BufferedReader sbfr = null;
|
||||
static BufferedReader open(String[] args) throws FileNotFoundException {
|
||||
if (args.length == 0) {
|
||||
sbfr = new BufferedReader(new FileReader(new File(System.getProperty("test.src", "."), "Scripts.txt")));
|
||||
return new BufferedReader(new FileReader(new File(System.getProperty("test.src", "."), "Scripts.txt")));
|
||||
} else if (args.length == 1) {
|
||||
sbfr = new BufferedReader(new FileReader(args[0]));
|
||||
return new BufferedReader(new FileReader(args[0]));
|
||||
} else {
|
||||
System.out.println("java CharacterScript Scripts.txt");
|
||||
throw new RuntimeException("Datafile name should be specified.");
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
Matcher m = Pattern.compile("(\\p{XDigit}+)(?:\\.{2}(\\p{XDigit}+))?\\s+;\\s+(\\w+)\\s+#.*").matcher("");
|
||||
String line = null;
|
||||
HashMap<String,ArrayList<Integer>> scripts = new HashMap<>();
|
||||
while ((line = sbfr.readLine()) != null) {
|
||||
if (line.length() <= 1 || line.charAt(0) == '#') {
|
||||
continue;
|
||||
}
|
||||
m.reset(line);
|
||||
if (m.matches()) {
|
||||
int start = Integer.parseInt(m.group(1), 16);
|
||||
int end = (m.group(2)==null)?start
|
||||
:Integer.parseInt(m.group(2), 16);
|
||||
String name = m.group(3).toLowerCase(Locale.ENGLISH);
|
||||
ArrayList<Integer> ranges = scripts.get(name);
|
||||
if (ranges == null) {
|
||||
ranges = new ArrayList<Integer>();
|
||||
scripts.put(name, ranges);
|
||||
try (BufferedReader sbfr = open(args)) {
|
||||
while ((line = sbfr.readLine()) != null) {
|
||||
if (line.length() <= 1 || line.charAt(0) == '#') {
|
||||
continue;
|
||||
}
|
||||
m.reset(line);
|
||||
if (m.matches()) {
|
||||
int start = Integer.parseInt(m.group(1), 16);
|
||||
int end = (m.group(2)==null)?start
|
||||
:Integer.parseInt(m.group(2), 16);
|
||||
String name = m.group(3).toLowerCase(Locale.ENGLISH);
|
||||
ArrayList<Integer> ranges = scripts.get(name);
|
||||
if (ranges == null) {
|
||||
ranges = new ArrayList<Integer>();
|
||||
scripts.put(name, ranges);
|
||||
}
|
||||
ranges.add(start);
|
||||
ranges.add(end);
|
||||
}
|
||||
ranges.add(start);
|
||||
ranges.add(end);
|
||||
}
|
||||
}
|
||||
sbfr.close();
|
||||
// check all defined ranges
|
||||
Integer[] ZEROSIZEARRAY = new Integer[0];
|
||||
for (String name : scripts.keySet()) {
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
* @bug 4199068 4738465 4937983 4930681 4926230 4931433 4932663 4986689
|
||||
* 5026830 5023243 5070673 4052517 4811767 6192449 6397034 6413313
|
||||
* 6464154 6523983 6206031 4960438 6631352 6631966 6850957 6850958
|
||||
* 4947220
|
||||
* 4947220 7018606
|
||||
* @summary Basic tests for Process and Environment Variable code
|
||||
* @run main/othervm/timeout=300 Basic
|
||||
* @author Martin Buchholz
|
||||
@ -47,6 +47,9 @@ import static java.util.AbstractMap.SimpleImmutableEntry;
|
||||
|
||||
public class Basic {
|
||||
|
||||
/* used for Windows only */
|
||||
static final String systemRoot = System.getenv("SystemRoot");
|
||||
|
||||
private static String commandOutput(Reader r) throws Throwable {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int c;
|
||||
@ -1073,7 +1076,11 @@ public class Basic {
|
||||
try {
|
||||
ProcessBuilder pb = new ProcessBuilder();
|
||||
pb.environment().clear();
|
||||
equal(getenvInChild(pb), "");
|
||||
String expected = Windows.is() ? "SystemRoot="+systemRoot+",": "";
|
||||
if (Windows.is()) {
|
||||
pb.environment().put("SystemRoot", systemRoot);
|
||||
}
|
||||
equal(getenvInChild(pb), expected);
|
||||
} catch (Throwable t) { unexpected(t); }
|
||||
|
||||
//----------------------------------------------------------------
|
||||
@ -1561,13 +1568,21 @@ public class Basic {
|
||||
List<String> childArgs = new ArrayList<String>(javaChildArgs);
|
||||
childArgs.add("System.getenv()");
|
||||
String[] cmdp = childArgs.toArray(new String[childArgs.size()]);
|
||||
String[] envp = {"=ExitValue=3", "=C:=\\"};
|
||||
String[] envp;
|
||||
String[] envpWin = {"=ExitValue=3", "=C:=\\", "SystemRoot="+systemRoot};
|
||||
String[] envpOth = {"=ExitValue=3", "=C:=\\"};
|
||||
if (Windows.is()) {
|
||||
envp = envpWin;
|
||||
} else {
|
||||
envp = envpOth;
|
||||
}
|
||||
Process p = Runtime.getRuntime().exec(cmdp, envp);
|
||||
String expected = Windows.is() ? "=C:=\\,=ExitValue=3," : "=C:=\\,";
|
||||
String expected = Windows.is() ? "=C:=\\,SystemRoot="+systemRoot+",=ExitValue=3," : "=C:=\\,";
|
||||
equal(commandOutput(p), expected);
|
||||
if (Windows.is()) {
|
||||
ProcessBuilder pb = new ProcessBuilder(childArgs);
|
||||
pb.environment().clear();
|
||||
pb.environment().put("SystemRoot", systemRoot);
|
||||
pb.environment().put("=ExitValue", "3");
|
||||
pb.environment().put("=C:", "\\");
|
||||
equal(commandOutput(pb), expected);
|
||||
@ -1591,10 +1606,18 @@ public class Basic {
|
||||
List<String> childArgs = new ArrayList<String>(javaChildArgs);
|
||||
childArgs.add("System.getenv()");
|
||||
String[] cmdp = childArgs.toArray(new String[childArgs.size()]);
|
||||
String[] envp = {"LC_ALL=C\u0000\u0000", // Yuck!
|
||||
String[] envpWin = {"SystemRoot="+systemRoot, "LC_ALL=C\u0000\u0000", // Yuck!
|
||||
"FO\u0000=B\u0000R"};
|
||||
String[] envpOth = {"LC_ALL=C\u0000\u0000", // Yuck!
|
||||
"FO\u0000=B\u0000R"};
|
||||
String[] envp;
|
||||
if (Windows.is()) {
|
||||
envp = envpWin;
|
||||
} else {
|
||||
envp = envpOth;
|
||||
}
|
||||
Process p = Runtime.getRuntime().exec(cmdp, envp);
|
||||
check(commandOutput(p).equals("LC_ALL=C,"),
|
||||
check(commandOutput(p).equals(Windows.is() ? "SystemRoot="+systemRoot+",LC_ALL=C," : "LC_ALL=C,"),
|
||||
"Incorrect handling of envstrings containing NULs");
|
||||
} catch (Throwable t) { unexpected(t); }
|
||||
|
||||
@ -2144,6 +2167,7 @@ public class Basic {
|
||||
static void equal(Object x, Object y) {
|
||||
if (x == null ? y == null : x.equals(y)) pass();
|
||||
else fail(x + " not equal to " + y);}
|
||||
|
||||
public static void main(String[] args) throws Throwable {
|
||||
try {realMain(args);} catch (Throwable t) {unexpected(t);}
|
||||
System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
|
||||
|
||||
@ -43,9 +43,9 @@ public class ShutdownHooks {
|
||||
file = new File(dir, args[1]);
|
||||
// write to file
|
||||
System.out.println("writing to "+ file);
|
||||
PrintWriter pw = new PrintWriter(file);
|
||||
pw.println("Shutdown begins");
|
||||
pw.close();
|
||||
try (PrintWriter pw = new PrintWriter(file)) {
|
||||
pw.println("Shutdown begins");
|
||||
}
|
||||
}
|
||||
|
||||
public static class Cleaner extends Thread {
|
||||
@ -56,10 +56,8 @@ public class ShutdownHooks {
|
||||
// register the DeleteOnExitHook while the application
|
||||
// shutdown hook is running
|
||||
file.deleteOnExit();
|
||||
try {
|
||||
PrintWriter pw = new PrintWriter(file);
|
||||
try (PrintWriter pw = new PrintWriter(file)) {
|
||||
pw.println("file is being deleted");
|
||||
pw.close();
|
||||
} catch (FileNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
@ -22,11 +22,14 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6379235
|
||||
* @ignore until 6721694 is fixed
|
||||
* @run main/othervm -server -Xmx32m -Xms32m -Xss256m StartOOMTest
|
||||
* @summary ThreadGroup accounting mistake possible with failure of Thread.start()
|
||||
* This test is relatively useful for verifying 6379235, but
|
||||
* is too resource intensive, especially on 64 bit systems,
|
||||
* to be run automatically, see 6721694.
|
||||
*
|
||||
* When run it should be typically be run with the server vm
|
||||
* and a relatively small java heap, and a large stack size
|
||||
* ( to provoke the OOM quicker ).
|
||||
* java -server -Xmx32m -Xms32m -Xss256m StartOOMTest
|
||||
*/
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@ -62,31 +62,33 @@ public class Setup {
|
||||
* Create manifest file with Boot-Class-Path encoding the
|
||||
* sub-directory name.
|
||||
*/
|
||||
FileOutputStream out = new FileOutputStream(manifestFile);
|
||||
out.write("Manifest-Version: 1.0\n".getBytes("UTF-8"));
|
||||
try (FileOutputStream out = new FileOutputStream(manifestFile)) {
|
||||
out.write("Manifest-Version: 1.0\n".getBytes("UTF-8"));
|
||||
|
||||
byte[] premainBytes = ("Premain-Class: " + premainClass + "\n").getBytes("UTF-8");
|
||||
out.write(premainBytes);
|
||||
byte[] premainBytes =
|
||||
("Premain-Class: " + premainClass + "\n").getBytes("UTF-8");
|
||||
out.write(premainBytes);
|
||||
|
||||
out.write( "Boot-Class-Path: ".getBytes("UTF-8") );
|
||||
out.write( "Boot-Class-Path: ".getBytes("UTF-8") );
|
||||
|
||||
byte[] value = bootClassPath.getBytes("UTF-8");
|
||||
for (int i=0; i<value.length; i++) {
|
||||
int v = (int)value[i];
|
||||
if (v < 0) v += 256;
|
||||
byte[] escaped = ("%" + Integer.toHexString(v)).getBytes("UTF-8");
|
||||
out.write(escaped);
|
||||
byte[] value = bootClassPath.getBytes("UTF-8");
|
||||
for (int i=0; i<value.length; i++) {
|
||||
int v = (int)value[i];
|
||||
if (v < 0) v += 256;
|
||||
byte[] escaped =
|
||||
("%" + Integer.toHexString(v)).getBytes("UTF-8");
|
||||
out.write(escaped);
|
||||
}
|
||||
out.write( "\n\n".getBytes("UTF-8") );
|
||||
}
|
||||
out.write( "\n\n".getBytes("UTF-8") );
|
||||
out.close();
|
||||
|
||||
/*
|
||||
* Write the name of the boot dir to "boot.dir"
|
||||
*/
|
||||
f = new File(workDir + fileSeparator + "boot.dir");
|
||||
out = new FileOutputStream(f);
|
||||
out.write(bootDir.getBytes(defaultEncoding));
|
||||
out.close();
|
||||
try (FileOutputStream out = new FileOutputStream(f)) {
|
||||
out.write(bootDir.getBytes(defaultEncoding));
|
||||
}
|
||||
}
|
||||
|
||||
/* ported from test/sun/tools/launcher/UnicodeTest.java */
|
||||
|
||||
@ -118,23 +118,24 @@ public class Inject implements RuntimeConstants {
|
||||
}
|
||||
|
||||
void dump(File outDir, String filename) throws IOException {
|
||||
FileOutputStream fileOut = new FileOutputStream(new File(outDir, filename));
|
||||
DataOutputStream dataOut = new DataOutputStream(fileOut);
|
||||
try (FileOutputStream fileOut =
|
||||
new FileOutputStream(new File(outDir, filename));
|
||||
DataOutputStream dataOut = new DataOutputStream(fileOut))
|
||||
{
|
||||
String currentClassName = null;
|
||||
|
||||
String currentClassName = null;
|
||||
|
||||
dataOut.writeInt(infoList.size());
|
||||
for (Iterator<Info> it = infoList.iterator(); it.hasNext(); ) {
|
||||
Info info = it.next();
|
||||
if (!info.className.equals(currentClassName)) {
|
||||
dataOut.writeInt(123456); // class name marker
|
||||
currentClassName = info.className;
|
||||
dataOut.writeUTF(currentClassName);
|
||||
dataOut.writeInt(infoList.size());
|
||||
for (Iterator<Info> it = infoList.iterator(); it.hasNext(); ) {
|
||||
Info info = it.next();
|
||||
if (!info.className.equals(currentClassName)) {
|
||||
dataOut.writeInt(123456); // class name marker
|
||||
currentClassName = info.className;
|
||||
dataOut.writeUTF(currentClassName);
|
||||
}
|
||||
dataOut.writeInt(info.location);
|
||||
dataOut.writeUTF(info.methodName);
|
||||
}
|
||||
dataOut.writeInt(info.location);
|
||||
dataOut.writeUTF(info.methodName);
|
||||
}
|
||||
dataOut.close();
|
||||
}
|
||||
|
||||
public byte[] bytecodes(String className, String methodName, int location) {
|
||||
|
||||
@ -645,26 +645,17 @@ public class BigIntegerTest {
|
||||
BigInteger b2 = null;
|
||||
|
||||
File f = new File("serialtest");
|
||||
FileOutputStream fos = new FileOutputStream(f);
|
||||
try {
|
||||
ObjectOutputStream oos = new ObjectOutputStream(fos);
|
||||
try {
|
||||
|
||||
try (FileOutputStream fos = new FileOutputStream(f)) {
|
||||
try (ObjectOutputStream oos = new ObjectOutputStream(fos)) {
|
||||
oos.writeObject(b1);
|
||||
oos.flush();
|
||||
} finally {
|
||||
oos.close();
|
||||
}
|
||||
|
||||
FileInputStream fis = new FileInputStream(f);
|
||||
try {
|
||||
ObjectInputStream ois = new ObjectInputStream(fis);
|
||||
try {
|
||||
b2 = (BigInteger)ois.readObject();
|
||||
} finally {
|
||||
ois.close();
|
||||
}
|
||||
} finally {
|
||||
fis.close();
|
||||
try (FileInputStream fis = new FileInputStream(f);
|
||||
ObjectInputStream ois = new ObjectInputStream(fis))
|
||||
{
|
||||
b2 = (BigInteger)ois.readObject();
|
||||
}
|
||||
|
||||
if (!b1.equals(b2) ||
|
||||
@ -673,8 +664,6 @@ public class BigIntegerTest {
|
||||
System.err.println("Serialized failed for hex " +
|
||||
b1.toString(16));
|
||||
}
|
||||
} finally {
|
||||
fos.close();
|
||||
}
|
||||
f.delete();
|
||||
}
|
||||
@ -683,29 +672,17 @@ public class BigIntegerTest {
|
||||
BigInteger b1 = fetchNumber(rnd.nextInt(100));
|
||||
BigInteger b2 = null;
|
||||
File f = new File("serialtest");
|
||||
FileOutputStream fos = new FileOutputStream(f);
|
||||
try {
|
||||
ObjectOutputStream oos = new ObjectOutputStream(fos);
|
||||
try {
|
||||
try (FileOutputStream fos = new FileOutputStream(f)) {
|
||||
try (ObjectOutputStream oos = new ObjectOutputStream(fos)) {
|
||||
oos.writeObject(b1);
|
||||
oos.flush();
|
||||
} finally {
|
||||
oos.close();
|
||||
}
|
||||
|
||||
FileInputStream fis = new FileInputStream(f);
|
||||
try {
|
||||
ObjectInputStream ois = new ObjectInputStream(fis);
|
||||
try {
|
||||
b2 = (BigInteger)ois.readObject();
|
||||
} finally {
|
||||
ois.close();
|
||||
}
|
||||
} finally {
|
||||
fis.close();
|
||||
try (FileInputStream fis = new FileInputStream(f);
|
||||
ObjectInputStream ois = new ObjectInputStream(fis))
|
||||
{
|
||||
b2 = (BigInteger)ois.readObject();
|
||||
}
|
||||
} finally {
|
||||
fos.close();
|
||||
}
|
||||
|
||||
if (!b1.equals(b2) ||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 2011, 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
|
||||
@ -36,105 +36,81 @@ import java.io.*;
|
||||
import java.net.*;
|
||||
|
||||
class RedirLimitServer extends Thread {
|
||||
static final int TIMEOUT = 10 * 1000;
|
||||
static final int NUM_REDIRECTS = 9;
|
||||
|
||||
ServerSocket s;
|
||||
Socket s1;
|
||||
InputStream is;
|
||||
OutputStream os;
|
||||
int port;
|
||||
int nredirects = 9;
|
||||
|
||||
String reply1 = "HTTP/1.1 307 Temporary Redirect\r\n" +
|
||||
static final String reply1 = "HTTP/1.1 307 Temporary Redirect\r\n" +
|
||||
"Date: Mon, 15 Jan 2001 12:18:21 GMT\r\n" +
|
||||
"Server: Apache/1.3.14 (Unix)\r\n" +
|
||||
"Location: http://localhost:";
|
||||
String reply2 = ".html\r\n" +
|
||||
static final String reply2 = ".html\r\n" +
|
||||
"Connection: close\r\n" +
|
||||
"Content-Type: text/html; charset=iso-8859-1\r\n\r\n" +
|
||||
"<html>Hello</html>";
|
||||
|
||||
RedirLimitServer (ServerSocket y) {
|
||||
s = y;
|
||||
port = s.getLocalPort();
|
||||
}
|
||||
|
||||
String reply3 = "HTTP/1.1 200 Ok\r\n" +
|
||||
static final String reply3 = "HTTP/1.1 200 Ok\r\n" +
|
||||
"Date: Mon, 15 Jan 2001 12:18:21 GMT\r\n" +
|
||||
"Server: Apache/1.3.14 (Unix)\r\n" +
|
||||
"Connection: close\r\n" +
|
||||
"Content-Type: text/html; charset=iso-8859-1\r\n\r\n" +
|
||||
"World";
|
||||
|
||||
public void run () {
|
||||
final ServerSocket ss;
|
||||
final int port;
|
||||
|
||||
RedirLimitServer(ServerSocket ss) {
|
||||
this.ss = ss;
|
||||
port = ss.getLocalPort();
|
||||
}
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
s.setSoTimeout (2000);
|
||||
for (int i=0; i<nredirects; i++) {
|
||||
s1 = s.accept ();
|
||||
s1.setSoTimeout (2000);
|
||||
is = s1.getInputStream ();
|
||||
os = s1.getOutputStream ();
|
||||
is.read ();
|
||||
String reply = reply1 + port + "/redirect" + i + reply2;
|
||||
os.write (reply.getBytes());
|
||||
os.close();
|
||||
ss.setSoTimeout(TIMEOUT);
|
||||
for (int i=0; i<NUM_REDIRECTS; i++) {
|
||||
try (Socket s = ss.accept()) {
|
||||
s.setSoTimeout(TIMEOUT);
|
||||
InputStream is = s.getInputStream();
|
||||
OutputStream os = s.getOutputStream();
|
||||
is.read();
|
||||
String reply = reply1 + port + "/redirect" + i + reply2;
|
||||
os.write(reply.getBytes());
|
||||
}
|
||||
}
|
||||
s1 = s.accept ();
|
||||
is = s1.getInputStream ();
|
||||
os = s1.getOutputStream ();
|
||||
is.read ();
|
||||
os.write (reply3.getBytes());
|
||||
os.close();
|
||||
}
|
||||
catch (Exception e) {
|
||||
/* Just need thread to terminate */
|
||||
try (Socket s = ss.accept()) {
|
||||
InputStream is = s.getInputStream();
|
||||
OutputStream os = s.getOutputStream();
|
||||
is.read();
|
||||
os.write(reply3.getBytes());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try { s.close(); } catch (IOException unused) {}
|
||||
try { ss.close(); } catch (IOException unused) {}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
public class RedirectLimit {
|
||||
|
||||
public static final int DELAY = 10;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
int nLoops = 1;
|
||||
int nSize = 10;
|
||||
int port, n =0;
|
||||
byte b[] = new byte[nSize];
|
||||
RedirLimitServer server;
|
||||
ServerSocket sock;
|
||||
ServerSocket ss = new ServerSocket (0);
|
||||
int port = ss.getLocalPort();
|
||||
RedirLimitServer server = new RedirLimitServer(ss);
|
||||
server.start();
|
||||
|
||||
InputStream in = null;
|
||||
try {
|
||||
sock = new ServerSocket (0);
|
||||
port = sock.getLocalPort ();
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.out.println ("Exception: " + e);
|
||||
return;
|
||||
}
|
||||
|
||||
server = new RedirLimitServer(sock);
|
||||
server.start ();
|
||||
|
||||
try {
|
||||
|
||||
String s = "http://localhost:" + port;
|
||||
URL url = new URL(s);
|
||||
URL url = new URL("http://localhost:" + port);
|
||||
URLConnection conURL = url.openConnection();
|
||||
|
||||
conURL.setDoInput(true);
|
||||
conURL.setAllowUserInteraction(false);
|
||||
conURL.setUseCaches(false);
|
||||
|
||||
InputStream in = conURL.getInputStream();
|
||||
in = conURL.getInputStream();
|
||||
if ((in.read() != (int)'W') || (in.read()!=(int)'o')) {
|
||||
throw new RuntimeException ("Unexpected string read");
|
||||
throw new RuntimeException("Unexpected string read");
|
||||
}
|
||||
}
|
||||
catch(IOException e) {
|
||||
throw new RuntimeException ("Exception caught " + e);
|
||||
} finally {
|
||||
if ( in != null ) { in.close(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
*/
|
||||
|
||||
/* @test
|
||||
* @bug 4607272 6842687 6878369
|
||||
* @bug 4607272 6842687 6878369 6944810 7023403
|
||||
* @summary Unit test for AsynchronousSocketChannel
|
||||
* @run main/timeout=600 Basic
|
||||
*/
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
*/
|
||||
|
||||
/* @test
|
||||
* @bug 4313887 6873621 6979526 7006126
|
||||
* @bug 4313887 6873621 6979526 7006126 7020517
|
||||
* @summary Unit test for java.nio.file.FileStore
|
||||
* @library ..
|
||||
*/
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
*/
|
||||
|
||||
/* @test
|
||||
* @bug 4313887 6838333 7006126
|
||||
* @bug 4313887 6838333 7006126 7023034
|
||||
* @summary Unit test for Files.createTempXXX
|
||||
* @library ..
|
||||
*/
|
||||
@ -167,5 +167,31 @@ public class TemporaryFiles {
|
||||
testInvalidFileTemp("../blah", null);
|
||||
testInvalidFileTemp("dir/blah", null);
|
||||
testInvalidFileTemp("blah", ".dat/foo");
|
||||
|
||||
// nulls
|
||||
try {
|
||||
Files.createTempFile("blah", ".tmp", (FileAttribute<?>[])null);
|
||||
throw new RuntimeException("NullPointerException expected");
|
||||
} catch (NullPointerException ignore) { }
|
||||
try {
|
||||
Files.createTempFile("blah", ".tmp", new FileAttribute<?>[] { null });
|
||||
throw new RuntimeException("NullPointerException expected");
|
||||
} catch (NullPointerException ignore) { }
|
||||
try {
|
||||
Files.createTempDirectory("blah", (FileAttribute<?>[])null);
|
||||
throw new RuntimeException("NullPointerException expected");
|
||||
} catch (NullPointerException ignore) { }
|
||||
try {
|
||||
Files.createTempDirectory("blah", new FileAttribute<?>[] { null });
|
||||
throw new RuntimeException("NullPointerException expected");
|
||||
} catch (NullPointerException ignore) { }
|
||||
try {
|
||||
Files.createTempFile((Path)null, "blah", ".tmp");
|
||||
throw new RuntimeException("NullPointerException expected");
|
||||
} catch (NullPointerException ignore) { }
|
||||
try {
|
||||
Files.createTempDirectory((Path)null, "blah");
|
||||
throw new RuntimeException("NullPointerException expected");
|
||||
} catch (NullPointerException ignore) { }
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -28,6 +28,8 @@
|
||||
*/
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
import java.security.cert.CertificateFactory;
|
||||
|
||||
@ -46,24 +48,20 @@ public class OpenSSLCert {
|
||||
}
|
||||
|
||||
static void test(String... files) throws Exception {
|
||||
FileOutputStream fout = new FileOutputStream(OUTFILE);
|
||||
for (String file: files) {
|
||||
FileInputStream fin = new FileInputStream(
|
||||
new File(System.getProperty("test.src", "."), file));
|
||||
byte[] buffer = new byte[4096];
|
||||
while (true) {
|
||||
int len = fin.read(buffer);
|
||||
if (len < 0) break;
|
||||
fout.write(buffer, 0, len);
|
||||
try (FileOutputStream fout = new FileOutputStream(OUTFILE)) {
|
||||
String here = System.getProperty("test.src", "");
|
||||
for (String file: files) {
|
||||
Files.copy(Paths.get(here, file), fout);
|
||||
}
|
||||
fin.close();
|
||||
}
|
||||
fout.close();
|
||||
System.out.println("Testing " + Arrays.toString(files) + "...");
|
||||
if (CertificateFactory.getInstance("X509")
|
||||
.generateCertificates(new FileInputStream(OUTFILE))
|
||||
.size() != files.length) {
|
||||
throw new Exception("Not same number");
|
||||
try (FileInputStream fin = new FileInputStream(OUTFILE)) {
|
||||
System.out.println("Testing " + Arrays.toString(files) + "...");
|
||||
if (CertificateFactory.getInstance("X509")
|
||||
.generateCertificates(fin)
|
||||
.size() != files.length) {
|
||||
throw new Exception("Not same number");
|
||||
}
|
||||
}
|
||||
Files.delete(Paths.get(OUTFILE));
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,6 +28,8 @@
|
||||
* 6431845 4802633 6570566 6570575 6570631 6570924 6691185 6691215
|
||||
* @summary Run many tests on many Collection and Map implementations
|
||||
* @author Martin Buchholz
|
||||
* @run main MOAT
|
||||
* @run main/othervm -XX:+AggressiveOpts MOAT
|
||||
*/
|
||||
|
||||
/* Mother Of All (Collection) Tests
|
||||
|
||||
@ -111,57 +111,58 @@ public class ValidateISO4217 {
|
||||
|
||||
static void test1() throws Exception {
|
||||
|
||||
FileReader fr = new FileReader(new File(System.getProperty("test.src", "."), datafile));
|
||||
BufferedReader in = new BufferedReader(fr);
|
||||
String line;
|
||||
SimpleDateFormat format = null;
|
||||
try (FileReader fr = new FileReader(new File(System.getProperty("test.src", "."), datafile));
|
||||
BufferedReader in = new BufferedReader(fr))
|
||||
{
|
||||
String line;
|
||||
SimpleDateFormat format = null;
|
||||
|
||||
while ((line = in.readLine()) != null) {
|
||||
if (line.length() == 0 || line.charAt(0) == '#') {
|
||||
continue;
|
||||
}
|
||||
while ((line = in.readLine()) != null) {
|
||||
if (line.length() == 0 || line.charAt(0) == '#') {
|
||||
continue;
|
||||
}
|
||||
|
||||
StringTokenizer tokens = new StringTokenizer(line, "\t");
|
||||
String country = tokens.nextToken();
|
||||
if (country.length() != 2) {
|
||||
continue;
|
||||
}
|
||||
StringTokenizer tokens = new StringTokenizer(line, "\t");
|
||||
String country = tokens.nextToken();
|
||||
if (country.length() != 2) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String currency;
|
||||
String numeric;
|
||||
String minorUnit;
|
||||
int tokensCount = tokens.countTokens();
|
||||
if (tokensCount < 3) {
|
||||
currency = "";
|
||||
numeric = "0";
|
||||
minorUnit = "0";
|
||||
} else {
|
||||
currency = tokens.nextToken();
|
||||
numeric = tokens.nextToken();
|
||||
minorUnit = tokens.nextToken();
|
||||
testCurrencies.add(Currency.getInstance(currency));
|
||||
String currency;
|
||||
String numeric;
|
||||
String minorUnit;
|
||||
int tokensCount = tokens.countTokens();
|
||||
if (tokensCount < 3) {
|
||||
currency = "";
|
||||
numeric = "0";
|
||||
minorUnit = "0";
|
||||
} else {
|
||||
currency = tokens.nextToken();
|
||||
numeric = tokens.nextToken();
|
||||
minorUnit = tokens.nextToken();
|
||||
testCurrencies.add(Currency.getInstance(currency));
|
||||
|
||||
// check for the cutover
|
||||
if (tokensCount > 3) {
|
||||
if (format == null) {
|
||||
format = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss", Locale.US);
|
||||
format.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
format.setLenient(false);
|
||||
}
|
||||
if (format.parse(tokens.nextToken()).getTime() <
|
||||
System.currentTimeMillis()) {
|
||||
currency = tokens.nextToken();
|
||||
numeric = tokens.nextToken();
|
||||
minorUnit = tokens.nextToken();
|
||||
testCurrencies.add(Currency.getInstance(currency));
|
||||
// check for the cutover
|
||||
if (tokensCount > 3) {
|
||||
if (format == null) {
|
||||
format = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss", Locale.US);
|
||||
format.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
format.setLenient(false);
|
||||
}
|
||||
if (format.parse(tokens.nextToken()).getTime() <
|
||||
System.currentTimeMillis()) {
|
||||
currency = tokens.nextToken();
|
||||
numeric = tokens.nextToken();
|
||||
minorUnit = tokens.nextToken();
|
||||
testCurrencies.add(Currency.getInstance(currency));
|
||||
}
|
||||
}
|
||||
}
|
||||
int index = toIndex(country);
|
||||
testCountryCurrency(country, currency, Integer.parseInt(numeric),
|
||||
Integer.parseInt(minorUnit), index);
|
||||
}
|
||||
int index = toIndex(country);
|
||||
testCountryCurrency(country, currency, Integer.parseInt(numeric),
|
||||
Integer.parseInt(minorUnit), index);
|
||||
}
|
||||
in.close();
|
||||
|
||||
for (int i = 0; i < additionalCodes.length; i++) {
|
||||
int index = toIndex(additionalCodes[i][0]);
|
||||
|
||||
@ -34,6 +34,7 @@ import java.io.FileOutputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Formatter;
|
||||
|
||||
public class FailingConstructors {
|
||||
@ -47,9 +48,7 @@ public class FailingConstructors {
|
||||
/* create the file and write its contents */
|
||||
File file = File.createTempFile(fileName, null);
|
||||
file.deleteOnExit();
|
||||
FileOutputStream fos = new FileOutputStream(file);
|
||||
fos.write(FILE_CONTENTS.getBytes());
|
||||
fos.close();
|
||||
Files.write(file.toPath(), FILE_CONTENTS.getBytes());
|
||||
|
||||
test(true, file);
|
||||
file.delete();
|
||||
|
||||
@ -1204,14 +1204,12 @@ public class LocaleEnhanceTest extends LocaleTestFmwk {
|
||||
locale = new Locale(lang, country, variant);
|
||||
}
|
||||
|
||||
// desrialize
|
||||
try {
|
||||
FileInputStream fis = new FileInputStream(testfile);
|
||||
ObjectInputStream ois = new ObjectInputStream(fis);
|
||||
|
||||
// deserialize
|
||||
try (FileInputStream fis = new FileInputStream(testfile);
|
||||
ObjectInputStream ois = new ObjectInputStream(fis))
|
||||
{
|
||||
Object o = ois.readObject();
|
||||
assertEquals("Deserialize Java 6 Locale " + locale, o, locale);
|
||||
ois.close();
|
||||
} catch (Exception e) {
|
||||
errln("Exception while reading " + testfile.getAbsolutePath() + " - " + e.getMessage());
|
||||
}
|
||||
|
||||
@ -39,24 +39,19 @@ import java.util.PropertyResourceBundle;
|
||||
public final class Bug6204853 {
|
||||
|
||||
public Bug6204853() {
|
||||
try {
|
||||
String srcDir = System.getProperty("test.src", ".");
|
||||
FileInputStream fis8859_1 =
|
||||
new FileInputStream(new File(srcDir, "Bug6204853.properties"));
|
||||
FileInputStream fisUtf8 =
|
||||
new FileInputStream(new File(srcDir, "Bug6204853_Utf8.properties"));
|
||||
InputStreamReader isrUtf8 = new InputStreamReader(fisUtf8, "UTF-8");
|
||||
|
||||
String srcDir = System.getProperty("test.src", ".");
|
||||
try (FileInputStream fis8859_1 =
|
||||
new FileInputStream(new File(srcDir, "Bug6204853.properties"));
|
||||
FileInputStream fisUtf8 =
|
||||
new FileInputStream(new File(srcDir, "Bug6204853_Utf8.properties"));
|
||||
InputStreamReader isrUtf8 = new InputStreamReader(fisUtf8, "UTF-8"))
|
||||
{
|
||||
PropertyResourceBundle bundleUtf8 = new PropertyResourceBundle(isrUtf8);
|
||||
PropertyResourceBundle bundle = new PropertyResourceBundle(fis8859_1);
|
||||
|
||||
String[] arrayUtf8 = createKeyValueArray(bundleUtf8);
|
||||
String[] array = createKeyValueArray(bundle);
|
||||
|
||||
isrUtf8.close();
|
||||
fisUtf8.close();
|
||||
fis8859_1.close();
|
||||
|
||||
if (!Arrays.equals(arrayUtf8, array)) {
|
||||
throw new RuntimeException("PropertyResourceBundle constructed from a UTF-8 encoded property file is not equal to the one constructed from ISO-8859-1 encoded property file.");
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user