Merge
This commit is contained in:
commit
15bdd03998
@ -883,7 +883,7 @@ class PackageWriter extends BandStructure {
|
||||
avHiBits &= (1L<<attrIndexLimit[i])-1;
|
||||
int nextLoBit = 0;
|
||||
Map<Attribute.Layout, int[]> defMap = allLayouts.get(i);
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
Map.Entry<Attribute.Layout, int[]>[] layoutsAndCounts =
|
||||
new Map.Entry[defMap.size()];
|
||||
defMap.entrySet().toArray(layoutsAndCounts);
|
||||
|
@ -32,14 +32,15 @@ import static javax.management.openmbean.SimpleType.*;
|
||||
|
||||
import com.sun.jmx.remote.util.EnvHelp;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.io.InvalidObjectException;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.GenericArrayType;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
@ -1129,14 +1130,56 @@ public class DefaultMXBeanMappingFactory extends MXBeanMappingFactory {
|
||||
to getters. */
|
||||
private static final class CompositeBuilderViaConstructor
|
||||
extends CompositeBuilder {
|
||||
static class AnnotationHelper {
|
||||
private static Class<? extends Annotation> constructorPropertiesClass;
|
||||
private static Method valueMethod;
|
||||
static {
|
||||
findConstructorPropertiesClass();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static void findConstructorPropertiesClass() {
|
||||
try {
|
||||
constructorPropertiesClass = (Class<? extends Annotation>)
|
||||
Class.forName("java.beans.ConstructorProperties", false,
|
||||
DefaultMXBeanMappingFactory.class.getClassLoader());
|
||||
valueMethod = constructorPropertiesClass.getMethod("value");
|
||||
} catch (ClassNotFoundException cnf) {
|
||||
// java.beans not present
|
||||
} catch (NoSuchMethodException e) {
|
||||
// should not reach here
|
||||
throw new InternalError(e);
|
||||
}
|
||||
}
|
||||
|
||||
static boolean isAvailable() {
|
||||
return constructorPropertiesClass != null;
|
||||
}
|
||||
|
||||
static String[] getPropertyNames(Constructor<?> constr) {
|
||||
if (!isAvailable())
|
||||
return null;
|
||||
|
||||
Annotation a = constr.getAnnotation(constructorPropertiesClass);
|
||||
if (a == null) return null;
|
||||
|
||||
try {
|
||||
return (String[]) valueMethod.invoke(a);
|
||||
} catch (InvocationTargetException e) {
|
||||
throw new InternalError(e);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new InternalError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CompositeBuilderViaConstructor(Class<?> targetClass, String[] itemNames) {
|
||||
super(targetClass, itemNames);
|
||||
}
|
||||
|
||||
String applicable(Method[] getters) throws InvalidObjectException {
|
||||
|
||||
final Class<ConstructorProperties> propertyNamesClass = ConstructorProperties.class;
|
||||
if (!AnnotationHelper.isAvailable())
|
||||
return "@ConstructorProperties annotation not available";
|
||||
|
||||
Class<?> targetClass = getTargetClass();
|
||||
Constructor<?>[] constrs = targetClass.getConstructors();
|
||||
@ -1145,7 +1188,7 @@ public class DefaultMXBeanMappingFactory extends MXBeanMappingFactory {
|
||||
List<Constructor<?>> annotatedConstrList = newList();
|
||||
for (Constructor<?> constr : constrs) {
|
||||
if (Modifier.isPublic(constr.getModifiers())
|
||||
&& constr.getAnnotation(propertyNamesClass) != null)
|
||||
&& AnnotationHelper.getPropertyNames(constr) != null)
|
||||
annotatedConstrList.add(constr);
|
||||
}
|
||||
|
||||
@ -1174,8 +1217,7 @@ public class DefaultMXBeanMappingFactory extends MXBeanMappingFactory {
|
||||
// so we can test unambiguity.
|
||||
Set<BitSet> getterIndexSets = newSet();
|
||||
for (Constructor<?> constr : annotatedConstrList) {
|
||||
String[] propertyNames =
|
||||
constr.getAnnotation(propertyNamesClass).value();
|
||||
String[] propertyNames = AnnotationHelper.getPropertyNames(constr);
|
||||
|
||||
Type[] paramTypes = constr.getGenericParameterTypes();
|
||||
if (paramTypes.length != propertyNames.length) {
|
||||
|
@ -178,7 +178,7 @@ public class VMOption {
|
||||
return "VM option: " + getName() +
|
||||
" value: " + value + " " +
|
||||
" origin: " + origin + " " +
|
||||
(writeable ? "(read-only)" : "(read-write)");
|
||||
(writeable ? "(read-write)" : "(read-only)");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -153,8 +153,8 @@ public final class Init {
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (Node el=config.getFirstChild();el!=null;el=el.getNextSibling()) {
|
||||
if (!(el instanceof Element)) {
|
||||
for (Node el=config.getFirstChild();el!=null;el=el.getNextSibling()) {
|
||||
if (el.getNodeType() != Node.ELEMENT_NODE) {
|
||||
continue;
|
||||
}
|
||||
String tag=el.getLocalName();
|
||||
|
@ -205,7 +205,7 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
|
||||
try {
|
||||
NameSpaceSymbTable ns=new NameSpaceSymbTable();
|
||||
int nodeLevel=NODE_BEFORE_DOCUMENT_ELEMENT;
|
||||
if (rootNode instanceof Element) {
|
||||
if (rootNode != null && rootNode.getNodeType() == Node.ELEMENT_NODE) {
|
||||
//Fills the nssymbtable with the definitions of the parent of the root subnode
|
||||
getParentNameSpaces((Element)rootNode,ns);
|
||||
nodeLevel=NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT;
|
||||
@ -335,7 +335,7 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
|
||||
return;
|
||||
sibling=parentNode.getNextSibling();
|
||||
parentNode=parentNode.getParentNode();
|
||||
if (!(parentNode instanceof Element)) {
|
||||
if (parentNode !=null && parentNode.getNodeType() != Node.ELEMENT_NODE) {
|
||||
documentLevel=NODE_AFTER_DOCUMENT_ELEMENT;
|
||||
parentNode=null;
|
||||
}
|
||||
@ -391,7 +391,7 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
|
||||
return;
|
||||
boolean currentNodeIsVisible = false;
|
||||
NameSpaceSymbTable ns=new NameSpaceSymbTable();
|
||||
if (currentNode instanceof Element)
|
||||
if (currentNode != null && currentNode.getNodeType() == Node.ELEMENT_NODE)
|
||||
getParentNameSpaces((Element)currentNode,ns);
|
||||
Node sibling=null;
|
||||
Node parentNode=null;
|
||||
@ -512,7 +512,7 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
|
||||
return;
|
||||
sibling=parentNode.getNextSibling();
|
||||
parentNode=parentNode.getParentNode();
|
||||
if (!(parentNode instanceof Element)) {
|
||||
if (parentNode != null && parentNode.getNodeType() != Node.ELEMENT_NODE) {
|
||||
parentNode=null;
|
||||
documentLevel=NODE_AFTER_DOCUMENT_ELEMENT;
|
||||
}
|
||||
@ -594,18 +594,14 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
|
||||
final void getParentNameSpaces(Element el,NameSpaceSymbTable ns) {
|
||||
List<Element> parents=new ArrayList<Element>(10);
|
||||
Node n1=el.getParentNode();
|
||||
if (!(n1 instanceof Element)) {
|
||||
if (n1 == null || n1.getNodeType() != Node.ELEMENT_NODE) {
|
||||
return;
|
||||
}
|
||||
//Obtain all the parents of the elemnt
|
||||
Element parent=(Element) n1;
|
||||
while (parent!=null) {
|
||||
parents.add(parent);
|
||||
Node n=parent.getParentNode();
|
||||
if (!(n instanceof Element )) {
|
||||
break;
|
||||
}
|
||||
parent=(Element)n;
|
||||
Node parent = n1;
|
||||
while (parent!=null && parent.getNodeType() == Node.ELEMENT_NODE) {
|
||||
parents.add((Element)parent);
|
||||
parent = parent.getParentNode();
|
||||
}
|
||||
//Visit them in reverse order.
|
||||
ListIterator<Element> it=parents.listIterator(parents.size());
|
||||
|
@ -1445,7 +1445,7 @@ public class XMLCipher {
|
||||
// The de-serialiser returns a fragment whose children we need to
|
||||
// take on.
|
||||
|
||||
if (sourceParent instanceof Document) {
|
||||
if (sourceParent != null && sourceParent.getNodeType() == Node.DOCUMENT_NODE) {
|
||||
|
||||
// If this is a content decryption, this may have problems
|
||||
|
||||
|
@ -283,7 +283,7 @@ public class RetrievalMethodResolver extends KeyResolverSpi {
|
||||
Element e=null;
|
||||
while (it.hasNext()) {
|
||||
Node currentNode=it.next();
|
||||
if (currentNode instanceof Element) {
|
||||
if (currentNode != null && currentNode.getNodeType() == Node.ELEMENT_NODE) {
|
||||
e=(Element)currentNode;
|
||||
break;
|
||||
}
|
||||
@ -292,14 +292,14 @@ public class RetrievalMethodResolver extends KeyResolverSpi {
|
||||
List<Element> parents=new ArrayList<Element>(10);
|
||||
|
||||
//Obtain all the parents of the elemnt
|
||||
do {
|
||||
while (e != null) {
|
||||
parents.add(e);
|
||||
Node n=e.getParentNode();
|
||||
if (!(n instanceof Element )) {
|
||||
if (n == null || n.getNodeType() != Node.ELEMENT_NODE) {
|
||||
break;
|
||||
}
|
||||
e=(Element)n;
|
||||
} while (e!=null);
|
||||
}
|
||||
//Visit them in reverse order.
|
||||
ListIterator<Element> it2=parents.listIterator(parents.size()-1);
|
||||
Element ele=null;
|
||||
|
@ -225,7 +225,7 @@ public class IdResolver {
|
||||
} while (sibling==null && parentNode!=null) {
|
||||
sibling=parentNode.getNextSibling();
|
||||
parentNode=parentNode.getParentNode();
|
||||
if (!(parentNode instanceof Element)) {
|
||||
if (parentNode != null && parentNode.getNodeType() != Node.ELEMENT_NODE) {
|
||||
parentNode=null;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2012, 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
|
||||
@ -31,7 +31,6 @@ import javax.naming.*;
|
||||
import java.io.*;
|
||||
import java.math.*;
|
||||
import java.util.*;
|
||||
import java.beans.*;
|
||||
|
||||
import javax.sql.rowset.*;
|
||||
|
||||
@ -83,12 +82,6 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
|
||||
*/
|
||||
private ResultSetMetaData resMD;
|
||||
|
||||
/**
|
||||
* The property that helps to fire the property changed event when certain
|
||||
* properties are changed in the <code>JdbcRowSet</code> object. This property
|
||||
* is being added to satisfy Rave requirements.
|
||||
*/
|
||||
private PropertyChangeSupport propertyChangeSupport;
|
||||
|
||||
/**
|
||||
* The Vector holding the Match Columns
|
||||
@ -145,7 +138,6 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
|
||||
throw new RuntimeException(ioe);
|
||||
}
|
||||
|
||||
propertyChangeSupport = new PropertyChangeSupport(this);
|
||||
|
||||
initParams();
|
||||
|
||||
@ -268,7 +260,6 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
|
||||
throw new RuntimeException(ioe);
|
||||
}
|
||||
|
||||
propertyChangeSupport = new PropertyChangeSupport(this);
|
||||
|
||||
initParams();
|
||||
// set the defaults
|
||||
@ -343,7 +334,6 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
|
||||
throw new RuntimeException(ioe);
|
||||
}
|
||||
|
||||
propertyChangeSupport = new PropertyChangeSupport(this);
|
||||
|
||||
initParams();
|
||||
|
||||
@ -360,10 +350,6 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
|
||||
setMaxRows(0);
|
||||
setMaxFieldSize(0);
|
||||
|
||||
// to ensure connection to a db call connect now
|
||||
// and associate a conn with "this" object
|
||||
// in this case.
|
||||
conn = connect();
|
||||
setParams();
|
||||
|
||||
setReadOnly(true);
|
||||
@ -435,7 +421,6 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
|
||||
throw new RuntimeException(ioe);
|
||||
}
|
||||
|
||||
propertyChangeSupport = new PropertyChangeSupport(this);
|
||||
|
||||
initParams();
|
||||
|
||||
@ -620,12 +605,7 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
|
||||
|
||||
}
|
||||
|
||||
// An alternate solution is required instead of having the
|
||||
// connect method as protected.
|
||||
// This is a work around to assist Rave Team
|
||||
// :ah
|
||||
|
||||
protected Connection connect() throws SQLException {
|
||||
private Connection connect() throws SQLException {
|
||||
|
||||
// Get a JDBC connection.
|
||||
|
||||
@ -4056,9 +4036,7 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
|
||||
// Added as per Rave requirements
|
||||
|
||||
if( conn.getHoldability() != HOLD_CURSORS_OVER_COMMIT) {
|
||||
ResultSet oldVal = rs;
|
||||
rs = null;
|
||||
// propertyChangeSupport.firePropertyChange("ResultSet",oldVal,rs);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4119,9 +4097,7 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
|
||||
// Makes the result ste handle null after rollback
|
||||
// Added as per Rave requirements
|
||||
|
||||
ResultSet oldVal = rs;
|
||||
rs = null;
|
||||
// propertyChangeSupport.firePropertyChange("ResultSet", oldVal,rs);
|
||||
}
|
||||
|
||||
|
||||
@ -4247,12 +4223,6 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
|
||||
rs = resultSet;
|
||||
}
|
||||
|
||||
|
||||
// Over riding the setCommand from BaseRowSet for
|
||||
// firing the propertyChangeSupport Event for
|
||||
// Rave requirements when this property's value
|
||||
// changes.
|
||||
|
||||
/**
|
||||
* Sets this <code>JdbcRowSet</code> object's <code>command</code> property to
|
||||
* the given <code>String</code> object and clears the parameters, if any,
|
||||
@ -4277,28 +4247,19 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
|
||||
* @see #getCommand
|
||||
*/
|
||||
public void setCommand(String command) throws SQLException {
|
||||
String oldVal;
|
||||
|
||||
if (getCommand() != null) {
|
||||
if(!getCommand().equals(command)) {
|
||||
oldVal = getCommand();
|
||||
super.setCommand(command);
|
||||
ps = null;
|
||||
rs = null;
|
||||
propertyChangeSupport.firePropertyChange("command", oldVal,command);
|
||||
}
|
||||
}
|
||||
else {
|
||||
super.setCommand(command);
|
||||
propertyChangeSupport.firePropertyChange("command", null,command);
|
||||
}
|
||||
}
|
||||
|
||||
// Over riding the setDataSourceName from BaseRowSet for
|
||||
// firing the propertyChangeSupport Event for
|
||||
// Rave requirements when this property's values
|
||||
// changes.
|
||||
|
||||
/**
|
||||
* Sets the <code>dataSourceName</code> property for this <code>JdbcRowSet</code>
|
||||
* object to the given logical name and sets this <code>JdbcRowSet</code> object's
|
||||
@ -4329,28 +4290,20 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
|
||||
* @see #getDataSourceName
|
||||
*/
|
||||
public void setDataSourceName(String dsName) throws SQLException{
|
||||
String oldVal;
|
||||
|
||||
if(getDataSourceName() != null) {
|
||||
if(!getDataSourceName().equals(dsName)) {
|
||||
oldVal = getDataSourceName();
|
||||
super.setDataSourceName(dsName);
|
||||
conn = null;
|
||||
ps = null;
|
||||
rs = null;
|
||||
propertyChangeSupport.firePropertyChange("dataSourceName",oldVal,dsName);
|
||||
}
|
||||
}
|
||||
else {
|
||||
super.setDataSourceName(dsName);
|
||||
propertyChangeSupport.firePropertyChange("dataSourceName",null,dsName);
|
||||
}
|
||||
}
|
||||
|
||||
// Over riding the setUrl from BaseRowSet for
|
||||
// firing the propertyChangeSupport Event for
|
||||
// Rave requirements when this property's values
|
||||
// changes.
|
||||
|
||||
/**
|
||||
* Sets the Url property for this <code>JdbcRowSet</code> object
|
||||
@ -4394,29 +4347,20 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
|
||||
*/
|
||||
|
||||
public void setUrl(String url) throws SQLException {
|
||||
String oldVal;
|
||||
|
||||
if(getUrl() != null) {
|
||||
if(!getUrl().equals(url)) {
|
||||
oldVal = getUrl();
|
||||
super.setUrl(url);
|
||||
conn = null;
|
||||
ps = null;
|
||||
rs = null;
|
||||
propertyChangeSupport.firePropertyChange("url", oldVal, url);
|
||||
}
|
||||
}
|
||||
else {
|
||||
super.setUrl(url);
|
||||
propertyChangeSupport.firePropertyChange("url", null, url);
|
||||
}
|
||||
}
|
||||
|
||||
// Over riding the setUsername from BaseRowSet for
|
||||
// firing the propertyChangeSupport Event for
|
||||
// Rave requirements when this property's values
|
||||
// changes.
|
||||
|
||||
/**
|
||||
* Sets the username property for this <code>JdbcRowSet</code> object
|
||||
* to the given user name. Because it
|
||||
@ -4438,29 +4382,20 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
|
||||
* @see #getUsername
|
||||
*/
|
||||
public void setUsername(String uname) {
|
||||
String oldVal;
|
||||
|
||||
if( getUsername() != null) {
|
||||
if(!getUsername().equals(uname)) {
|
||||
oldVal = getUsername();
|
||||
super.setUsername(uname);
|
||||
conn = null;
|
||||
ps = null;
|
||||
rs = null;
|
||||
propertyChangeSupport.firePropertyChange("username",oldVal,uname);
|
||||
}
|
||||
}
|
||||
else{
|
||||
super.setUsername(uname);
|
||||
propertyChangeSupport.firePropertyChange("username",null,uname);
|
||||
}
|
||||
}
|
||||
|
||||
// Over riding the setPassword from BaseRowSet for
|
||||
// firing the propertyChangeSupport Event for
|
||||
// Rave requirements when this property's values
|
||||
// changes.
|
||||
|
||||
/**
|
||||
* Sets the password property for this <code>JdbcRowSet</code> object
|
||||
* to the given <code>String</code> object. Because it
|
||||
@ -4481,21 +4416,17 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
|
||||
* that must be supplied to the database to create a connection
|
||||
*/
|
||||
public void setPassword(String password) {
|
||||
String oldVal;
|
||||
|
||||
if ( getPassword() != null) {
|
||||
if(!getPassword().equals(password)) {
|
||||
oldVal = getPassword();
|
||||
super.setPassword(password);
|
||||
conn = null;
|
||||
ps = null;
|
||||
rs = null;
|
||||
propertyChangeSupport.firePropertyChange("password",oldVal,password);
|
||||
}
|
||||
}
|
||||
else{
|
||||
super.setPassword(password);
|
||||
propertyChangeSupport.firePropertyChange("password",null,password);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4528,7 +4459,6 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
|
||||
|
||||
if(oldVal != type) {
|
||||
super.setType(type);
|
||||
propertyChangeSupport.firePropertyChange("type",oldVal,type);
|
||||
}
|
||||
|
||||
}
|
||||
@ -4561,78 +4491,6 @@ public class JdbcRowSetImpl extends BaseRowSet implements JdbcRowSet, Joinable {
|
||||
|
||||
if(oldVal != concur) {
|
||||
super.setConcurrency(concur);
|
||||
propertyChangeSupport.firePropertyChange("concurrency",oldVal,concur);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the transaction isolation property for this JDBC <code>RowSet</code> object to the given
|
||||
* constant. The DBMS will use this transaction isolation level for
|
||||
* transactions if it can.
|
||||
* <p>
|
||||
* For <code>RowSet</code> implementations such as
|
||||
* the <code>CachedRowSet</code> that operate in a disconnected environment,
|
||||
* the <code>SyncProvider</code> object being used
|
||||
* offers complementary locking and data integrity options. The
|
||||
* options described below are pertinent only to connected <code>RowSet</code>
|
||||
* objects (<code>JdbcRowSet</code> objects).
|
||||
*
|
||||
* @param transIso one of the following constants, listed in ascending order:
|
||||
* <code>Connection.TRANSACTION_NONE</code>,
|
||||
* <code>Connection.TRANSACTION_READ_UNCOMMITTED</code>,
|
||||
* <code>Connection.TRANSACTION_READ_COMMITTED</code>,
|
||||
* <code>Connection.TRANSACTION_REPEATABLE_READ</code>, or
|
||||
* <code>Connection.TRANSACTION_SERIALIZABLE</code>
|
||||
* @throws SQLException if the given parameter is not one of the Connection
|
||||
* constants
|
||||
* @see javax.sql.rowset.spi.SyncFactory
|
||||
* @see javax.sql.rowset.spi.SyncProvider
|
||||
* @see #getTransactionIsolation
|
||||
*/
|
||||
public void setTransactionIsolation(int transIso) throws SQLException {
|
||||
|
||||
int oldVal;
|
||||
|
||||
try {
|
||||
oldVal = getTransactionIsolation();
|
||||
}catch(NullPointerException ex) {
|
||||
oldVal = 0;
|
||||
}
|
||||
|
||||
if(oldVal != transIso) {
|
||||
super.setTransactionIsolation(transIso);
|
||||
propertyChangeSupport.firePropertyChange("transactionIsolation",oldVal,transIso);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the maximum number of rows that this <code>RowSet</code> object may contain to
|
||||
* the given number. If this limit is exceeded, the excess rows are
|
||||
* silently dropped.
|
||||
*
|
||||
* @param mRows an <code>int</code> indicating the current maximum number
|
||||
* of rows; zero means that there is no limit
|
||||
* @throws SQLException if an error occurs internally setting the
|
||||
* maximum limit on the number of rows that a JDBC <code>RowSet</code> object
|
||||
* can contain; or if <i>max</i> is less than <code>0</code>; or
|
||||
* if <i>max</i> is less than the <code>fetchSize</code> of the
|
||||
* <code>RowSet</code>
|
||||
*/
|
||||
public void setMaxRows(int mRows) throws SQLException {
|
||||
|
||||
int oldVal;
|
||||
|
||||
try {
|
||||
oldVal = getMaxRows();
|
||||
}catch(NullPointerException ex) {
|
||||
oldVal = 0;
|
||||
}
|
||||
|
||||
if(oldVal != mRows) {
|
||||
super.setMaxRows(mRows);
|
||||
propertyChangeSupport.firePropertyChange("maxRows",oldVal,mRows);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -52,7 +52,9 @@ import javax.swing.JTextField;
|
||||
* This can be used by a JAAS application to instantiate a
|
||||
* CallbackHandler
|
||||
* @see javax.security.auth.callback
|
||||
* @deprecated This class will be removed in a future release.
|
||||
*/
|
||||
@Deprecated
|
||||
public class DialogCallbackHandler implements CallbackHandler {
|
||||
|
||||
/* -- Fields -- */
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2012, 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
|
||||
@ -31,10 +31,6 @@ import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Vector;
|
||||
import java.util.Collections;
|
||||
import java.io.ObjectStreamField;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.IOException;
|
||||
import sun.security.util.SecurityConstants;
|
||||
|
||||
/**
|
||||
@ -424,7 +420,7 @@ public final class FilePermission extends Permission implements Serializable {
|
||||
/**
|
||||
* Converts an actions String to an actions mask.
|
||||
*
|
||||
* @param action the action string.
|
||||
* @param actions the action string.
|
||||
* @return the actions mask.
|
||||
*/
|
||||
private static int getMask(String actions) {
|
||||
@ -435,7 +431,9 @@ public final class FilePermission extends Permission implements Serializable {
|
||||
if (actions == null) {
|
||||
return mask;
|
||||
}
|
||||
// Check against use of constants (used heavily within the JDK)
|
||||
|
||||
// Use object identity comparison against known-interned strings for
|
||||
// performance benefit (these values are used heavily within the JDK).
|
||||
if (actions == SecurityConstants.FILE_READ_ACTION) {
|
||||
return READ;
|
||||
} else if (actions == SecurityConstants.FILE_WRITE_ACTION) {
|
||||
@ -531,7 +529,7 @@ public final class FilePermission extends Permission implements Serializable {
|
||||
switch(a[i-matchlen]) {
|
||||
case ',':
|
||||
seencomma = true;
|
||||
/*FALLTHROUGH*/
|
||||
break;
|
||||
case ' ': case '\r': case '\n':
|
||||
case '\f': case '\t':
|
||||
break;
|
||||
@ -798,7 +796,7 @@ implements Serializable {
|
||||
* @return an enumeration of all the FilePermission objects.
|
||||
*/
|
||||
|
||||
public Enumeration elements() {
|
||||
public Enumeration<Permission> elements() {
|
||||
// Convert Iterator into Enumeration
|
||||
synchronized (this) {
|
||||
return Collections.enumeration(perms);
|
||||
@ -843,7 +841,6 @@ implements Serializable {
|
||||
/*
|
||||
* Reads in a Vector of FilePermissions and saves them in the perms field.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private void readObject(ObjectInputStream in) throws IOException,
|
||||
ClassNotFoundException {
|
||||
// Don't call defaultReadObject()
|
||||
@ -852,6 +849,7 @@ implements Serializable {
|
||||
ObjectInputStream.GetField gfields = in.readFields();
|
||||
|
||||
// Get the one we want
|
||||
@SuppressWarnings("unchecked")
|
||||
Vector<Permission> permissions = (Vector<Permission>)gfields.get("permissions", null);
|
||||
perms = new ArrayList<>(permissions.size());
|
||||
perms.addAll(permissions);
|
||||
|
@ -96,6 +96,8 @@ abstract class AbstractStringBuilder implements Appendable, CharSequence {
|
||||
* </ul>
|
||||
* If the {@code minimumCapacity} argument is nonpositive, this
|
||||
* method takes no action and simply returns.
|
||||
* Note that subsequent operations on this object can reduce the
|
||||
* actual capacity below that requested here.
|
||||
*
|
||||
* @param minimumCapacity the minimum desired capacity.
|
||||
*/
|
||||
|
@ -27,7 +27,7 @@ package java.lang.management;
|
||||
|
||||
import javax.management.openmbean.CompositeData;
|
||||
import java.util.concurrent.locks.*;
|
||||
import java.beans.ConstructorProperties;
|
||||
import sun.management.LockInfoCompositeData;
|
||||
|
||||
/**
|
||||
* Information about a <em>lock</em>. A lock can be a built-in object monitor,
|
||||
@ -44,8 +44,7 @@ import java.beans.ConstructorProperties;
|
||||
*
|
||||
* <h4><a name="MappedType">MXBean Mapping</a></h4>
|
||||
* <tt>LockInfo</tt> is mapped to a {@link CompositeData CompositeData}
|
||||
* as specified in the <a href="../../../javax/management/MXBean.html#mapping-rules">
|
||||
* type mapping rules</a> of {@linkplain javax.management.MXBean MXBeans}.
|
||||
* as specified in the {@link #from from} method.
|
||||
*
|
||||
* @see java.util.concurrent.locks.AbstractOwnableSynchronizer
|
||||
* @see java.util.concurrent.locks.Condition
|
||||
@ -66,7 +65,6 @@ public class LockInfo {
|
||||
* @param identityHashCode the {@link System#identityHashCode
|
||||
* identity hash code} of the lock object.
|
||||
*/
|
||||
@ConstructorProperties({"className", "identityHashCode"})
|
||||
public LockInfo(String className, int identityHashCode) {
|
||||
if (className == null) {
|
||||
throw new NullPointerException("Parameter className cannot be null");
|
||||
@ -102,6 +100,50 @@ public class LockInfo {
|
||||
return identityHashCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@code LockInfo} object represented by the
|
||||
* given {@code CompositeData}.
|
||||
* The given {@code CompositeData} must contain the following attributes:
|
||||
* <blockquote>
|
||||
* <table border>
|
||||
* <tr>
|
||||
* <th align=left>Attribute Name</th>
|
||||
* <th align=left>Type</th>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>className</td>
|
||||
* <td><tt>java.lang.String</tt></td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>identityHashCode</td>
|
||||
* <td><tt>java.lang.Integer</tt></td>
|
||||
* </tr>
|
||||
* </table>
|
||||
* </blockquote>
|
||||
*
|
||||
* @param cd {@code CompositeData} representing a {@code LockInfo}
|
||||
*
|
||||
* @throws IllegalArgumentException if {@code cd} does not
|
||||
* represent a {@code LockInfo} with the attributes described
|
||||
* above.
|
||||
* @return a {@code LockInfo} object represented
|
||||
* by {@code cd} if {@code cd} is not {@code null};
|
||||
* {@code null} otherwise.
|
||||
*
|
||||
* @since 1.8
|
||||
*/
|
||||
public static LockInfo from(CompositeData cd) {
|
||||
if (cd == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (cd instanceof LockInfoCompositeData) {
|
||||
return ((LockInfoCompositeData) cd).getLockInfo();
|
||||
} else {
|
||||
return LockInfoCompositeData.toLockInfo(cd);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of a lock. The returned
|
||||
* string representation consists of the name of the class of the
|
||||
|
@ -696,9 +696,7 @@ public class ThreadInfo {
|
||||
* <td>lockInfo</td>
|
||||
* <td><tt>javax.management.openmbean.CompositeData</tt>
|
||||
* - the mapped type for {@link LockInfo} as specified in the
|
||||
* <a href="../../../javax/management/MXBean.html#mapping-rules">
|
||||
* type mapping rules</a> of
|
||||
* {@linkplain javax.management.MXBean MXBeans}.
|
||||
* {@link LockInfo#from} method.
|
||||
* <p>
|
||||
* If <tt>cd</tt> does not contain this attribute,
|
||||
* the <tt>LockInfo</tt> object will be constructed from
|
||||
@ -766,10 +764,7 @@ public class ThreadInfo {
|
||||
* <td>lockedSynchronizers</td>
|
||||
* <td><tt>javax.management.openmbean.CompositeData[]</tt>
|
||||
* whose element type is the mapped type for
|
||||
* {@link LockInfo} as specified in the
|
||||
* <a href="../../../javax/management/MXBean.html#mapping-rules">
|
||||
* type mapping rules</a> of
|
||||
* {@linkplain javax.management.MXBean MXBeans}.
|
||||
* {@link LockInfo} as specified in the {@link LockInfo#from} method.
|
||||
* <p>
|
||||
* If <tt>cd</tt> does not contain this attribute,
|
||||
* this attribute will be set to an empty array. </td>
|
||||
@ -830,7 +825,6 @@ public class ThreadInfo {
|
||||
* @since 1.6
|
||||
*/
|
||||
public LockInfo[] getLockedSynchronizers() {
|
||||
// represents an <a href="LockInfo.html#OwnableSynchronizer">
|
||||
return lockedSynchronizers;
|
||||
}
|
||||
|
||||
|
@ -182,7 +182,7 @@ public final class Constructor<T> extends Executable {
|
||||
* @since 1.5
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
public TypeVariable<Constructor<T>>[] getTypeParameters() {
|
||||
if (getSignature() != null) {
|
||||
return (TypeVariable<Constructor<T>>[])getGenericInfo().getTypeParameters();
|
||||
|
@ -194,7 +194,7 @@ public final class Method extends Executable {
|
||||
* @since 1.5
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
public TypeVariable<Method>[] getTypeParameters() {
|
||||
if (getGenericSignature() != null)
|
||||
return (TypeVariable<Method>[])getGenericInfo().getTypeParameters();
|
||||
|
@ -467,7 +467,6 @@ implements java.io.Serializable
|
||||
* @param action the action string
|
||||
* @return the action mask
|
||||
*/
|
||||
@SuppressWarnings("fallthrough")
|
||||
private static int getMask(String action) {
|
||||
|
||||
if (action == null) {
|
||||
@ -480,7 +479,8 @@ implements java.io.Serializable
|
||||
|
||||
int mask = NONE;
|
||||
|
||||
// Check against use of constants (used heavily within the JDK)
|
||||
// Use object identity comparison against known-interned strings for
|
||||
// performance benefit (these values are used heavily within the JDK).
|
||||
if (action == SecurityConstants.SOCKET_RESOLVE_ACTION) {
|
||||
return RESOLVE;
|
||||
} else if (action == SecurityConstants.SOCKET_CONNECT_ACTION) {
|
||||
@ -568,7 +568,7 @@ implements java.io.Serializable
|
||||
switch(a[i-matchlen]) {
|
||||
case ',':
|
||||
seencomma = true;
|
||||
/*FALLTHROUGH*/
|
||||
break;
|
||||
case ' ': case '\r': case '\n':
|
||||
case '\f': case '\t':
|
||||
break;
|
||||
|
@ -248,7 +248,7 @@ public abstract class AsynchronousFileChannel
|
||||
return provider.newAsynchronousFileChannel(file, options, executor, attrs);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" }) // generic array construction
|
||||
@SuppressWarnings({"unchecked", "rawtypes"}) // generic array construction
|
||||
private static final FileAttribute<?>[] NO_ATTRIBUTES = new FileAttribute[0];
|
||||
|
||||
/**
|
||||
|
@ -287,7 +287,7 @@ public abstract class FileChannel
|
||||
return provider.newFileChannel(path, options, attrs);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" }) // generic array construction
|
||||
@SuppressWarnings({"unchecked", "rawtypes"}) // generic array construction
|
||||
private static final FileAttribute<?>[] NO_ATTRIBUTES = new FileAttribute[0];
|
||||
|
||||
/**
|
||||
|
@ -121,6 +121,7 @@ public class ArrayDeque<E> extends AbstractCollection<E>
|
||||
*
|
||||
* @param numElements the number of elements to hold
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private void allocateElements(int numElements) {
|
||||
int initialCapacity = MIN_INITIAL_CAPACITY;
|
||||
// Find the best power of two to hold elements.
|
||||
@ -152,10 +153,11 @@ public class ArrayDeque<E> extends AbstractCollection<E>
|
||||
int newCapacity = n << 1;
|
||||
if (newCapacity < 0)
|
||||
throw new IllegalStateException("Sorry, deque too big");
|
||||
Object[] a = new Object[newCapacity];
|
||||
@SuppressWarnings("unchecked")
|
||||
E[] a = (E[]) new Object[newCapacity];
|
||||
System.arraycopy(elements, p, a, 0, r);
|
||||
System.arraycopy(elements, 0, a, r, p);
|
||||
elements = (E[])a;
|
||||
elements = a;
|
||||
head = 0;
|
||||
tail = n;
|
||||
}
|
||||
@ -182,6 +184,7 @@ public class ArrayDeque<E> extends AbstractCollection<E>
|
||||
* Constructs an empty array deque with an initial capacity
|
||||
* sufficient to hold 16 elements.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayDeque() {
|
||||
elements = (E[]) new Object[16];
|
||||
}
|
||||
@ -793,6 +796,7 @@ public class ArrayDeque<E> extends AbstractCollection<E>
|
||||
* this deque
|
||||
* @throws NullPointerException if the specified array is null
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T[] toArray(T[] a) {
|
||||
int size = size();
|
||||
if (a.length < size)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2012, 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
|
||||
@ -560,7 +560,7 @@ public class Arrays {
|
||||
* off is the offset to generate corresponding low, high in src
|
||||
* To be removed in a future release.
|
||||
*/
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
private static void mergeSort(Object[] src,
|
||||
Object[] dest,
|
||||
int low,
|
||||
@ -747,7 +747,7 @@ public class Arrays {
|
||||
* off is the offset into src corresponding to low in dest
|
||||
* To be removed in a future release.
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
private static void mergeSort(Object[] src,
|
||||
Object[] dest,
|
||||
int low, int high, int off,
|
||||
@ -2832,6 +2832,7 @@ public class Arrays {
|
||||
* @return a list view of the specified array
|
||||
*/
|
||||
@SafeVarargs
|
||||
@SuppressWarnings("varargs")
|
||||
public static <T> List<T> asList(T... a) {
|
||||
return new ArrayList<>(a);
|
||||
}
|
||||
|
@ -213,7 +213,7 @@ public class Collections {
|
||||
* @throws IllegalArgumentException (optional) if the comparator is
|
||||
* found to violate the {@link Comparator} contract
|
||||
*/
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public static <T> void sort(List<T> list, Comparator<? super T> c) {
|
||||
Object[] a = list.toArray();
|
||||
Arrays.sort(a, (Comparator)c);
|
||||
@ -418,7 +418,7 @@ public class Collections {
|
||||
* @throws UnsupportedOperationException if the specified list or
|
||||
* its list-iterator does not support the <tt>set</tt> operation.
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
public static void reverse(List<?> list) {
|
||||
int size = list.size();
|
||||
if (size < REVERSE_THRESHOLD || list instanceof RandomAccess) {
|
||||
@ -497,7 +497,7 @@ public class Collections {
|
||||
* @throws UnsupportedOperationException if the specified list or its
|
||||
* list-iterator does not support the <tt>set</tt> operation.
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
public static void shuffle(List<?> list, Random rnd) {
|
||||
int size = list.size();
|
||||
if (size < SHUFFLE_THRESHOLD || list instanceof RandomAccess) {
|
||||
@ -535,7 +535,7 @@ public class Collections {
|
||||
* || j < 0 || j >= list.size()).
|
||||
* @since 1.4
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
public static void swap(List<?> list, int i, int j) {
|
||||
// instead of using a raw type here, it's possible to capture
|
||||
// the wildcard but it will require a call to a supplementary
|
||||
@ -669,7 +669,7 @@ public class Collections {
|
||||
* @throws NoSuchElementException if the collection is empty.
|
||||
* @see Comparable
|
||||
*/
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public static <T> T min(Collection<? extends T> coll, Comparator<? super T> comp) {
|
||||
if (comp==null)
|
||||
return (T)min((Collection) coll);
|
||||
@ -740,7 +740,7 @@ public class Collections {
|
||||
* @throws NoSuchElementException if the collection is empty.
|
||||
* @see Comparable
|
||||
*/
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public static <T> T max(Collection<? extends T> coll, Comparator<? super T> comp) {
|
||||
if (comp==null)
|
||||
return (T)max((Collection) coll);
|
||||
@ -1403,7 +1403,7 @@ public class Collections {
|
||||
extends UnmodifiableSet<Map.Entry<K,V>> {
|
||||
private static final long serialVersionUID = 7854390611657943733L;
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
UnmodifiableEntrySet(Set<? extends Map.Entry<? extends K, ? extends V>> s) {
|
||||
// Need to cast to raw in order to work around a limitation in the type system
|
||||
super((Set)s);
|
||||
@ -3172,7 +3172,7 @@ public class Collections {
|
||||
*
|
||||
* @see #emptySet()
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static final Set EMPTY_SET = new EmptySet<>();
|
||||
|
||||
/**
|
||||
@ -3271,10 +3271,13 @@ public class Collections {
|
||||
return new EmptySortedSet<>();
|
||||
}
|
||||
|
||||
public Comparator comparator() {
|
||||
@Override
|
||||
public Comparator<? super E> comparator() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public SortedSet<E> subSet(Object fromElement, Object toElement) {
|
||||
Objects.requireNonNull(fromElement);
|
||||
Objects.requireNonNull(toElement);
|
||||
@ -3294,6 +3297,7 @@ public class Collections {
|
||||
return emptySortedSet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortedSet<E> headSet(Object toElement) {
|
||||
Objects.requireNonNull(toElement);
|
||||
|
||||
@ -3304,6 +3308,7 @@ public class Collections {
|
||||
return emptySortedSet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortedSet<E> tailSet(Object fromElement) {
|
||||
Objects.requireNonNull(fromElement);
|
||||
|
||||
@ -3314,10 +3319,12 @@ public class Collections {
|
||||
return emptySortedSet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public E first() {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public E last() {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
@ -3328,7 +3335,7 @@ public class Collections {
|
||||
*
|
||||
* @see #emptyList()
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static final List EMPTY_LIST = new EmptyList<>();
|
||||
|
||||
/**
|
||||
@ -3402,7 +3409,7 @@ public class Collections {
|
||||
* @see #emptyMap()
|
||||
* @since 1.3
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static final Map EMPTY_MAP = new EmptyMap<>();
|
||||
|
||||
/**
|
||||
@ -3685,6 +3692,7 @@ public class Collections {
|
||||
return a;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T[] toArray(T[] a) {
|
||||
final int n = this.n;
|
||||
if (a.length < n) {
|
||||
@ -3731,6 +3739,7 @@ public class Collections {
|
||||
* the <tt>Comparable</tt> interface.
|
||||
* @see Comparable
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> Comparator<T> reverseOrder() {
|
||||
return (Comparator<T>) ReverseComparator.REVERSE_ORDER;
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ class ComparableTimSort {
|
||||
* @param start the index of the first element in the range that is
|
||||
* not already known to be sorted ({@code lo <= start <= hi})
|
||||
*/
|
||||
@SuppressWarnings({ "fallthrough", "rawtypes", "unchecked" })
|
||||
@SuppressWarnings({"fallthrough", "rawtypes", "unchecked"})
|
||||
private static void binarySort(Object[] a, int lo, int hi, int start) {
|
||||
assert lo <= start && start <= hi;
|
||||
if (start == lo)
|
||||
@ -277,7 +277,7 @@ class ComparableTimSort {
|
||||
* @return the length of the run beginning at the specified position in
|
||||
* the specified array
|
||||
*/
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
private static int countRunAndMakeAscending(Object[] a, int lo, int hi) {
|
||||
assert lo < hi;
|
||||
int runHi = lo + 1;
|
||||
@ -612,7 +612,7 @@ class ComparableTimSort {
|
||||
* (must be aBase + aLen)
|
||||
* @param len2 length of second run to be merged (must be > 0)
|
||||
*/
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
private void mergeLo(int base1, int len1, int base2, int len2) {
|
||||
assert len1 > 0 && len2 > 0 && base1 + len1 == base2;
|
||||
|
||||
@ -729,7 +729,7 @@ class ComparableTimSort {
|
||||
* (must be aBase + aLen)
|
||||
* @param len2 length of second run to be merged (must be > 0)
|
||||
*/
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
private void mergeHi(int base1, int len1, int base2, int len2) {
|
||||
assert len1 > 0 && len2 > 0 && base1 + len1 == base2;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -34,6 +34,8 @@ import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.regex.Pattern;
|
||||
@ -60,7 +62,14 @@ import sun.util.logging.PlatformLogger;
|
||||
* and the ISO 4217 currency data respectively. The value part consists of
|
||||
* three ISO 4217 values of a currency, i.e., an alphabetic code, a numeric
|
||||
* code, and a minor unit. Those three ISO 4217 values are separated by commas.
|
||||
* The lines which start with '#'s are considered comment lines. For example,
|
||||
* The lines which start with '#'s are considered comment lines. An optional UTC
|
||||
* timestamp may be specified per currency entry if users need to specify a
|
||||
* cutover date indicating when the new data comes into effect. The timestamp is
|
||||
* appended to the end of the currency properties and uses a comma as a separator.
|
||||
* If a UTC datestamp is present and valid, the JRE will only use the new currency
|
||||
* properties if the current UTC date is later than the date specified at class
|
||||
* loading time. The format of the timestamp must be of ISO 8601 format :
|
||||
* {@code 'yyyy-MM-dd'T'HH:mm:ss'}. For example,
|
||||
* <p>
|
||||
* <code>
|
||||
* #Sample currency properties<br>
|
||||
@ -69,6 +78,20 @@ import sun.util.logging.PlatformLogger;
|
||||
* <p>
|
||||
* will supersede the currency data for Japan.
|
||||
*
|
||||
* <p>
|
||||
* <code>
|
||||
* #Sample currency properties with cutover date<br>
|
||||
* JP=JPZ,999,0,2014-01-01T00:00:00
|
||||
* </code>
|
||||
* <p>
|
||||
* will supersede the currency data for Japan if {@code Currency} class is loaded after
|
||||
* 1st January 2014 00:00:00 GMT.
|
||||
* <p>
|
||||
* Where syntactically malformed entries are encountered, the entry is ignored
|
||||
* and the remainder of entries in file are processed. For instances where duplicate
|
||||
* country code entries exist, the behavior of the Currency information for that
|
||||
* {@code Currency} is undefined and the remainder of entries in file are processed.
|
||||
*
|
||||
* @since 1.4
|
||||
*/
|
||||
public final class Currency implements Serializable {
|
||||
@ -100,7 +123,6 @@ public final class Currency implements Serializable {
|
||||
private static ConcurrentMap<String, Currency> instances = new ConcurrentHashMap<>(7);
|
||||
private static HashSet<Currency> available;
|
||||
|
||||
|
||||
// Class data: currency data obtained from currency.data file.
|
||||
// Purpose:
|
||||
// - determine valid country codes
|
||||
@ -235,7 +257,9 @@ public final class Currency implements Serializable {
|
||||
}
|
||||
Set<String> keys = props.stringPropertyNames();
|
||||
Pattern propertiesPattern =
|
||||
Pattern.compile("([A-Z]{3})\\s*,\\s*(\\d{3})\\s*,\\s*([0-3])");
|
||||
Pattern.compile("([A-Z]{3})\\s*,\\s*(\\d{3})\\s*,\\s*" +
|
||||
"([0-3])\\s*,?\\s*(\\d{4}-\\d{2}-\\d{2}T\\d{2}:" +
|
||||
"\\d{2}:\\d{2})?");
|
||||
for (String key : keys) {
|
||||
replaceCurrencyData(propertiesPattern,
|
||||
key.toUpperCase(Locale.ROOT),
|
||||
@ -645,29 +669,38 @@ public final class Currency implements Serializable {
|
||||
* consists of "three-letter alphabet code", "three-digit numeric code",
|
||||
* and "one-digit (0,1,2, or 3) default fraction digit".
|
||||
* For example, "JPZ,392,0".
|
||||
* @throws
|
||||
* An optional UTC date can be appended to the string (comma separated)
|
||||
* to allow a currency change take effect after date specified.
|
||||
* For example, "JP=JPZ,999,0,2014-01-01T00:00:00" has no effect unless
|
||||
* UTC time is past 1st January 2014 00:00:00 GMT.
|
||||
*/
|
||||
private static void replaceCurrencyData(Pattern pattern, String ctry, String curdata) {
|
||||
|
||||
if (ctry.length() != 2) {
|
||||
// ignore invalid country code
|
||||
String message = new StringBuilder()
|
||||
.append("The entry in currency.properties for ")
|
||||
.append(ctry).append(" is ignored because of the invalid country code.")
|
||||
.toString();
|
||||
info(message, null);
|
||||
info("currency.properties entry for " + ctry +
|
||||
" is ignored because of the invalid country code.", null);
|
||||
return;
|
||||
}
|
||||
|
||||
Matcher m = pattern.matcher(curdata);
|
||||
if (!m.find()) {
|
||||
if (!m.find() || (m.group(4) == null && countOccurrences(curdata, ',') >= 3)) {
|
||||
// format is not recognized. ignore the data
|
||||
String message = new StringBuilder()
|
||||
.append("The entry in currency.properties for ")
|
||||
.append(ctry)
|
||||
.append(" is ignored because the value format is not recognized.")
|
||||
.toString();
|
||||
info(message, null);
|
||||
// if group(4) date string is null and we've 4 values, bad date value
|
||||
info("currency.properties entry for " + ctry +
|
||||
" ignored because the value format is not recognized.", null);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if (m.group(4) != null && !isPastCutoverDate(m.group(4))) {
|
||||
info("currency.properties entry for " + ctry +
|
||||
" ignored since cutover date has not passed :" + curdata, null);
|
||||
return;
|
||||
}
|
||||
} catch (IndexOutOfBoundsException | NullPointerException | ParseException ex) {
|
||||
info("currency.properties entry for " + ctry +
|
||||
" ignored since exception encountered :" + ex.getMessage(), null);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -695,6 +728,26 @@ public final class Currency implements Serializable {
|
||||
setMainTableEntry(ctry.charAt(0), ctry.charAt(1), entry);
|
||||
}
|
||||
|
||||
private static boolean isPastCutoverDate(String s)
|
||||
throws IndexOutOfBoundsException, NullPointerException, ParseException {
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.ROOT);
|
||||
format.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
format.setLenient(false);
|
||||
long time = format.parse(s.trim()).getTime();
|
||||
return System.currentTimeMillis() > time;
|
||||
|
||||
}
|
||||
|
||||
private static int countOccurrences(String value, char match) {
|
||||
int count = 0;
|
||||
for (char c : value.toCharArray()) {
|
||||
if (c == match) {
|
||||
++count;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
private static void info(String message, Throwable t) {
|
||||
PlatformLogger logger = PlatformLogger.getLogger("java.util.Currency");
|
||||
if (logger.isLoggable(PlatformLogger.INFO)) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2012, 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
|
||||
@ -230,7 +230,7 @@ public class HashMap<K,V>
|
||||
|
||||
this.loadFactor = loadFactor;
|
||||
threshold = (int)Math.min(capacity * loadFactor, MAXIMUM_CAPACITY + 1);
|
||||
table = new Entry[capacity];
|
||||
table = new Entry<?,?>[capacity];
|
||||
init();
|
||||
}
|
||||
|
||||
@ -1078,7 +1078,7 @@ public class HashMap<K,V>
|
||||
capacity <<= 1;
|
||||
}
|
||||
|
||||
table = new Entry[capacity];
|
||||
table = new Entry<?,?>[capacity];
|
||||
threshold = (int) Math.min(capacity * loadFactor, MAXIMUM_CAPACITY + 1);
|
||||
init(); // Give subclass a chance to do its thing.
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2012, 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
|
||||
@ -121,6 +121,7 @@ class JumboEnumSet<E extends Enum<E>> extends EnumSet<E> {
|
||||
unseen = elements[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
while (unseen == 0 && unseenIndex < elements.length - 1)
|
||||
unseen = elements[++unseenIndex];
|
||||
@ -128,6 +129,7 @@ class JumboEnumSet<E extends Enum<E>> extends EnumSet<E> {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public E next() {
|
||||
if (!hasNext())
|
||||
throw new NoSuchElementException();
|
||||
@ -138,6 +140,7 @@ class JumboEnumSet<E extends Enum<E>> extends EnumSet<E> {
|
||||
+ Long.numberOfTrailingZeros(lastReturned)];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
if (lastReturned == 0)
|
||||
throw new IllegalStateException();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2012, 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
|
||||
@ -330,6 +330,7 @@ public class PriorityQueue<E> extends AbstractQueue<E>
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public E peek() {
|
||||
if (size == 0)
|
||||
return null;
|
||||
|
@ -246,7 +246,8 @@ public final class PropertyPermission extends BasicPermission {
|
||||
return mask;
|
||||
}
|
||||
|
||||
// Check against use of constants (used heavily within the JDK)
|
||||
// Use object identity comparison against known-interned strings for
|
||||
// performance benefit (these values are used heavily within the JDK).
|
||||
if (actions == SecurityConstants.PROPERTY_READ_ACTION) {
|
||||
return READ;
|
||||
} if (actions == SecurityConstants.PROPERTY_WRITE_ACTION) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2012, 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
|
||||
@ -125,6 +125,7 @@ public class PropertyResourceBundle extends ResourceBundle {
|
||||
* @throws IOException if an I/O error occurs
|
||||
* @throws NullPointerException if <code>stream</code> is null
|
||||
*/
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public PropertyResourceBundle (InputStream stream) throws IOException {
|
||||
Properties properties = new Properties();
|
||||
properties.load(stream);
|
||||
@ -143,6 +144,7 @@ public class PropertyResourceBundle extends ResourceBundle {
|
||||
* @throws NullPointerException if <code>reader</code> is null
|
||||
* @since 1.6
|
||||
*/
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public PropertyResourceBundle (Reader reader) throws IOException {
|
||||
Properties properties = new Properties();
|
||||
properties.load(reader);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2012, 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
|
||||
@ -325,6 +325,7 @@ class JarVerifier {
|
||||
* the given file in the jar.
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public java.security.cert.Certificate[] getCerts(String name)
|
||||
{
|
||||
return mapSignersToCertArray(getCodeSigners(name));
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003,2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003,2012, 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
|
||||
@ -726,13 +726,13 @@ public abstract class Pack200 {
|
||||
private static final String PACK_PROVIDER = "java.util.jar.Pack200.Packer";
|
||||
private static final String UNPACK_PROVIDER = "java.util.jar.Pack200.Unpacker";
|
||||
|
||||
private static Class packerImpl;
|
||||
private static Class unpackerImpl;
|
||||
private static Class<?> packerImpl;
|
||||
private static Class<?> unpackerImpl;
|
||||
|
||||
private synchronized static Object newInstance(String prop) {
|
||||
String implName = "(unknown)";
|
||||
try {
|
||||
Class impl = (PACK_PROVIDER.equals(prop))? packerImpl: unpackerImpl;
|
||||
Class<?> impl = (PACK_PROVIDER.equals(prop))? packerImpl: unpackerImpl;
|
||||
if (impl == null) {
|
||||
// The first time, we must decide which class to use.
|
||||
implName = java.security.AccessController.doPrivileged(
|
||||
|
@ -2,7 +2,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<!--
|
||||
Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
|
||||
This code is free software; you can redistribute it and/or modify it
|
||||
@ -41,7 +41,7 @@ input streams.
|
||||
|
||||
</a>
|
||||
<ul>
|
||||
<li><a href="ftp://ftp.uu.net/pub/archiving/zip/doc/appnote-970311-iz.zip">
|
||||
<li><a href="http://www.info-zip.org/doc/appnote-19970311-iz.zip">
|
||||
Info-ZIP Application Note 970311
|
||||
</a> - a detailed description of the Info-ZIP format upon which
|
||||
the <code>java.util.zip</code> classes are based.
|
||||
|
@ -1,111 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2008, 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.management;
|
||||
|
||||
import java.lang.management.LockInfo;
|
||||
import java.lang.management.ThreadInfo;
|
||||
import javax.management.Attribute;
|
||||
import javax.management.StandardMBean;
|
||||
import javax.management.openmbean.CompositeData;
|
||||
|
||||
/**
|
||||
* This MXBean is used for data conversion from LockInfo
|
||||
* to CompositeData (its mapped type) or vice versa.
|
||||
*/
|
||||
class LockDataConverter extends StandardMBean
|
||||
implements LockDataConverterMXBean {
|
||||
private LockInfo lockInfo;
|
||||
private LockInfo[] lockedSyncs;
|
||||
|
||||
LockDataConverter() {
|
||||
super(LockDataConverterMXBean.class, true);
|
||||
this.lockInfo = null;
|
||||
this.lockedSyncs = null;
|
||||
}
|
||||
|
||||
LockDataConverter(ThreadInfo ti) {
|
||||
super(LockDataConverterMXBean.class, true);
|
||||
this.lockInfo = ti.getLockInfo();
|
||||
this.lockedSyncs = ti.getLockedSynchronizers();
|
||||
}
|
||||
|
||||
public void setLockInfo(LockInfo l) {
|
||||
this.lockInfo = l;
|
||||
}
|
||||
|
||||
public LockInfo getLockInfo() {
|
||||
return this.lockInfo;
|
||||
}
|
||||
|
||||
public void setLockedSynchronizers(LockInfo[] l) {
|
||||
this.lockedSyncs = l;
|
||||
}
|
||||
|
||||
public LockInfo[] getLockedSynchronizers() {
|
||||
return this.lockedSyncs;
|
||||
}
|
||||
|
||||
// helper methods
|
||||
CompositeData toLockInfoCompositeData() {
|
||||
try {
|
||||
return (CompositeData) getAttribute("LockInfo");
|
||||
} catch (Exception e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
CompositeData[] toLockedSynchronizersCompositeData() {
|
||||
try {
|
||||
return (CompositeData[]) getAttribute("LockedSynchronizers");
|
||||
} catch (Exception e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
LockInfo toLockInfo(CompositeData cd) {
|
||||
try {
|
||||
setAttribute(new Attribute("LockInfo", cd));
|
||||
} catch (Exception e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
return getLockInfo();
|
||||
}
|
||||
|
||||
LockInfo[] toLockedSynchronizers(CompositeData[] cd) {
|
||||
try {
|
||||
setAttribute(new Attribute("LockedSynchronizers", cd));
|
||||
} catch (Exception e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
return getLockedSynchronizers();
|
||||
}
|
||||
|
||||
static CompositeData toLockInfoCompositeData(LockInfo l) {
|
||||
LockDataConverter ldc = new LockDataConverter();
|
||||
ldc.setLockInfo(l);
|
||||
return ldc.toLockInfoCompositeData();
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 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.management;
|
||||
|
||||
import java.lang.management.LockInfo;
|
||||
|
||||
/**
|
||||
* This interface is used for data conversion from LockInfo
|
||||
* to CompositeData (its mapped type) or vice versa.
|
||||
*/
|
||||
public interface LockDataConverterMXBean {
|
||||
public void setLockInfo(LockInfo l);
|
||||
public LockInfo getLockInfo();
|
||||
|
||||
public void setLockedSynchronizers(LockInfo[] l);
|
||||
public LockInfo[] getLockedSynchronizers();
|
||||
}
|
118
jdk/src/share/classes/sun/management/LockInfoCompositeData.java
Normal file
118
jdk/src/share/classes/sun/management/LockInfoCompositeData.java
Normal file
@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 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.management;
|
||||
|
||||
import java.lang.management.LockInfo;
|
||||
import javax.management.openmbean.CompositeType;
|
||||
import javax.management.openmbean.CompositeData;
|
||||
import javax.management.openmbean.CompositeDataSupport;
|
||||
import javax.management.openmbean.OpenDataException;
|
||||
|
||||
/**
|
||||
* A CompositeData for LockInfo for the local management support.
|
||||
* This class avoids the performance penalty paid to the
|
||||
* construction of a CompositeData use in the local case.
|
||||
*/
|
||||
public class LockInfoCompositeData extends LazyCompositeData {
|
||||
private final LockInfo lock;
|
||||
|
||||
private LockInfoCompositeData(LockInfo li) {
|
||||
this.lock = li;
|
||||
}
|
||||
|
||||
public LockInfo getLockInfo() {
|
||||
return lock;
|
||||
}
|
||||
|
||||
public static CompositeData toCompositeData(LockInfo li) {
|
||||
if (li == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
LockInfoCompositeData licd = new LockInfoCompositeData(li);
|
||||
return licd.getCompositeData();
|
||||
}
|
||||
|
||||
protected CompositeData getCompositeData() {
|
||||
// CONTENTS OF THIS ARRAY MUST BE SYNCHRONIZED WITH
|
||||
// lockInfoItemNames!
|
||||
final Object[] lockInfoItemValues = {
|
||||
new String(lock.getClassName()),
|
||||
new Integer(lock.getIdentityHashCode()),
|
||||
};
|
||||
|
||||
try {
|
||||
return new CompositeDataSupport(lockInfoCompositeType,
|
||||
lockInfoItemNames,
|
||||
lockInfoItemValues);
|
||||
} catch (OpenDataException e) {
|
||||
// Should never reach here
|
||||
throw Util.newException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static final CompositeType lockInfoCompositeType;
|
||||
static {
|
||||
try {
|
||||
lockInfoCompositeType = (CompositeType)
|
||||
MappedMXBeanType.toOpenType(LockInfo.class);
|
||||
} catch (OpenDataException e) {
|
||||
// Should never reach here
|
||||
throw Util.newException(e);
|
||||
}
|
||||
}
|
||||
|
||||
static CompositeType getLockInfoCompositeType() {
|
||||
return lockInfoCompositeType;
|
||||
}
|
||||
|
||||
private static final String CLASS_NAME = "className";
|
||||
private static final String IDENTITY_HASH_CODE = "identityHashCode";
|
||||
private static final String[] lockInfoItemNames = {
|
||||
CLASS_NAME,
|
||||
IDENTITY_HASH_CODE,
|
||||
};
|
||||
|
||||
/*
|
||||
* Returns a LockInfo object mapped from the given CompositeData.
|
||||
*/
|
||||
public static LockInfo toLockInfo(CompositeData cd) {
|
||||
if (cd == null) {
|
||||
throw new NullPointerException("Null CompositeData");
|
||||
}
|
||||
|
||||
if (!isTypeMatched(lockInfoCompositeType, cd.getCompositeType())) {
|
||||
throw new IllegalArgumentException(
|
||||
"Unexpected composite type for LockInfo");
|
||||
}
|
||||
|
||||
String className = getString(cd, CLASS_NAME);
|
||||
int identityHashCode = getInt(cd, IDENTITY_HASH_CODE);
|
||||
return new LockInfo(className, identityHashCode);
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = -6374759159749014052L;
|
||||
}
|
@ -703,7 +703,7 @@ public abstract class MappedMXBeanType {
|
||||
if (data instanceof java.lang.management.MonitorInfo) {
|
||||
return MonitorInfoCompositeData.toCompositeData((MonitorInfo) data);
|
||||
}
|
||||
return LockDataConverter.toLockInfoCompositeData((LockInfo) data);
|
||||
return LockInfoCompositeData.toCompositeData((LockInfo) data);
|
||||
}
|
||||
|
||||
if (data instanceof MemoryNotificationInfo) {
|
||||
|
@ -59,7 +59,7 @@ public class MonitorInfoCompositeData extends LazyCompositeData {
|
||||
|
||||
int len = monitorInfoItemNames.length;
|
||||
Object[] values = new Object[len];
|
||||
CompositeData li = LockDataConverter.toLockInfoCompositeData(lock);
|
||||
CompositeData li = LockInfoCompositeData.toCompositeData(lock);
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
String item = monitorInfoItemNames[i];
|
||||
|
@ -85,11 +85,18 @@ public class ThreadInfoCompositeData extends LazyCompositeData {
|
||||
}
|
||||
|
||||
// Convert MonitorInfo[] and LockInfo[] to CompositeData[]
|
||||
LockDataConverter converter = new LockDataConverter(threadInfo);
|
||||
CompositeData lockInfoData = converter.toLockInfoCompositeData();
|
||||
CompositeData[] lockedSyncsData = converter.toLockedSynchronizersCompositeData();
|
||||
CompositeData lockInfoData =
|
||||
LockInfoCompositeData.toCompositeData(threadInfo.getLockInfo());
|
||||
|
||||
// Convert LockInfo[] and MonitorInfo[] to CompositeData[]
|
||||
LockInfo[] lockedSyncs = threadInfo.getLockedSynchronizers();
|
||||
CompositeData[] lockedSyncsData =
|
||||
new CompositeData[lockedSyncs.length];
|
||||
for (int i = 0; i < lockedSyncs.length; i++) {
|
||||
LockInfo li = lockedSyncs[i];
|
||||
lockedSyncsData[i] = LockInfoCompositeData.toCompositeData(li);
|
||||
}
|
||||
|
||||
// Convert MonitorInfo[] to CompositeData[]
|
||||
MonitorInfo[] lockedMonitors = threadInfo.getLockedMonitors();
|
||||
CompositeData[] lockedMonitorsData =
|
||||
new CompositeData[lockedMonitors.length];
|
||||
@ -98,7 +105,6 @@ public class ThreadInfoCompositeData extends LazyCompositeData {
|
||||
lockedMonitorsData[i] = MonitorInfoCompositeData.toCompositeData(mi);
|
||||
}
|
||||
|
||||
|
||||
// CONTENTS OF THIS ARRAY MUST BE SYNCHRONIZED WITH
|
||||
// threadInfoItemNames!
|
||||
final Object[] threadInfoItemValues = {
|
||||
@ -216,11 +222,11 @@ public class ThreadInfoCompositeData extends LazyCompositeData {
|
||||
// with it. So we can get the CompositeType representing LockInfo
|
||||
// from a mapped CompositeData for any LockInfo object.
|
||||
// Thus we construct a random LockInfo object and pass it
|
||||
// to LockDataConverter to do the conversion.
|
||||
// to LockInfoCompositeData to do the conversion.
|
||||
Object o = new Object();
|
||||
LockInfo li = new LockInfo(o.getClass().getName(),
|
||||
System.identityHashCode(o));
|
||||
CompositeData cd = LockDataConverter.toLockInfoCompositeData(li);
|
||||
CompositeData cd = LockInfoCompositeData.toCompositeData(li);
|
||||
lockInfoCompositeType = cd.getCompositeType();
|
||||
}
|
||||
|
||||
@ -315,9 +321,8 @@ public class ThreadInfoCompositeData extends LazyCompositeData {
|
||||
|
||||
// 6.0 new attributes
|
||||
public LockInfo lockInfo() {
|
||||
LockDataConverter converter = new LockDataConverter();
|
||||
CompositeData lockInfoData = (CompositeData) cdata.get(LOCK_INFO);
|
||||
return converter.toLockInfo(lockInfoData);
|
||||
return LockInfo.from(lockInfoData);
|
||||
}
|
||||
|
||||
public MonitorInfo[] lockedMonitors() {
|
||||
@ -336,13 +341,17 @@ public class ThreadInfoCompositeData extends LazyCompositeData {
|
||||
}
|
||||
|
||||
public LockInfo[] lockedSynchronizers() {
|
||||
LockDataConverter converter = new LockDataConverter();
|
||||
CompositeData[] lockedSyncsData =
|
||||
(CompositeData[]) cdata.get(LOCKED_SYNCS);
|
||||
|
||||
// The LockedSynchronizers item cannot be null, but if it is we will
|
||||
// get a NullPointerException when we ask for its length.
|
||||
return converter.toLockedSynchronizers(lockedSyncsData);
|
||||
LockInfo[] locks = new LockInfo[lockedSyncsData.length];
|
||||
for (int i = 0; i < lockedSyncsData.length; i++) {
|
||||
CompositeData cdi = lockedSyncsData[i];
|
||||
locks[i] = LockInfo.from(cdi);
|
||||
}
|
||||
return locks;
|
||||
}
|
||||
|
||||
/** Validate if the input CompositeData has the expected
|
||||
|
@ -87,8 +87,10 @@ public final class ECParameters extends AlgorithmParametersSpi {
|
||||
if ((data.length == 0) || (data[0] != 4)) {
|
||||
throw new IOException("Only uncompressed point format supported");
|
||||
}
|
||||
int n = data.length / 2;
|
||||
if (n > ((curve.getField().getFieldSize() + 7 ) >> 3)) {
|
||||
// Per ANSI X9.62, an encoded point is a 1 byte type followed by
|
||||
// ceiling(log base 2 field-size / 8) bytes of x and the same of y.
|
||||
int n = (data.length - 1) / 2;
|
||||
if (n != ((curve.getField().getFieldSize() + 7 ) >> 3)) {
|
||||
throw new IOException("Point does not match field size");
|
||||
}
|
||||
byte[] xb = new byte[n];
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2009, 2012, 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
|
||||
@ -259,8 +259,7 @@ final public class AlgorithmChecker extends PKIXCertPathChecker {
|
||||
}
|
||||
|
||||
// Inherit key parameters from previous key
|
||||
if (currPubKey instanceof DSAPublicKey &&
|
||||
((DSAPublicKey)currPubKey).getParams() == null) {
|
||||
if (PKIX.isDSAPublicKeyWithoutParams(currPubKey)) {
|
||||
// Inherit DSA parameters from previous key
|
||||
if (!(prevPubKey instanceof DSAPublicKey)) {
|
||||
throw new CertPathValidatorException("Input key is not " +
|
||||
|
@ -101,9 +101,7 @@ class BasicChecker extends PKIXCertPathChecker {
|
||||
public void init(boolean forward) throws CertPathValidatorException {
|
||||
if (!forward) {
|
||||
prevPubKey = trustedPubKey;
|
||||
if (prevPubKey instanceof DSAPublicKey &&
|
||||
((DSAPublicKey)prevPubKey).getParams() == null)
|
||||
{
|
||||
if (PKIX.isDSAPublicKeyWithoutParams(prevPubKey)) {
|
||||
// If TrustAnchor is a DSA public key and it has no params, it
|
||||
// cannot be used to verify the signature of the first cert,
|
||||
// so throw exception
|
||||
@ -248,8 +246,7 @@ class BasicChecker extends PKIXCertPathChecker {
|
||||
currCert.getSubjectX500Principal() + "; serial#: " +
|
||||
currCert.getSerialNumber().toString());
|
||||
}
|
||||
if (cKey instanceof DSAPublicKey &&
|
||||
((DSAPublicKey)cKey).getParams() == null) {
|
||||
if (PKIX.isDSAPublicKeyWithoutParams(cKey)) {
|
||||
// cKey needs to inherit DSA parameters from prev key
|
||||
cKey = makeInheritedParamsKey(cKey, prevPubKey);
|
||||
if (debug != null) debug.println("BasicChecker.updateState Made " +
|
||||
|
@ -35,6 +35,7 @@ import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.PrivilegedActionException;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
import java.security.cert.CertStore;
|
||||
import java.security.cert.CertStoreException;
|
||||
import java.security.cert.X509CertSelector;
|
||||
import java.security.cert.X509CRLSelector;
|
||||
import javax.security.auth.x500.X500Principal;
|
||||
@ -96,6 +97,25 @@ public abstract class CertStoreHelper {
|
||||
}
|
||||
}
|
||||
|
||||
static boolean isCausedByNetworkIssue(String type, CertStoreException cse) {
|
||||
switch (type) {
|
||||
case "LDAP":
|
||||
case "SSLServer":
|
||||
try {
|
||||
CertStoreHelper csh = CertStoreHelper.getInstance(type);
|
||||
return csh.isCausedByNetworkIssue(cse);
|
||||
} catch (NoSuchAlgorithmException nsae) {
|
||||
return false;
|
||||
}
|
||||
case "URI":
|
||||
Throwable t = cse.getCause();
|
||||
return (t != null && t instanceof IOException);
|
||||
default:
|
||||
// we don't know about any other remote CertStore types
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a CertStore using the given URI as parameters.
|
||||
*/
|
||||
@ -119,4 +139,10 @@ public abstract class CertStoreHelper {
|
||||
Collection<X500Principal> certIssuers,
|
||||
String dn)
|
||||
throws IOException;
|
||||
|
||||
/**
|
||||
* Returns true if the cause of the CertStoreException is a network
|
||||
* related issue.
|
||||
*/
|
||||
public abstract boolean isCausedByNetworkIssue(CertStoreException e);
|
||||
}
|
||||
|
@ -116,12 +116,17 @@ class DistributionPointFetcher {
|
||||
/**
|
||||
* Download CRLs from the given distribution point, verify and return them.
|
||||
* See the top of the class for current limitations.
|
||||
*
|
||||
* @throws CertStoreException if there is an error retrieving the CRLs
|
||||
* from one of the GeneralNames and no other CRLs are retrieved from
|
||||
* the other GeneralNames. If more than one GeneralName throws an
|
||||
* exception then the one from the last GeneralName is thrown.
|
||||
*/
|
||||
private static Collection<X509CRL> getCRLs(X509CRLSelector selector,
|
||||
X509CertImpl certImpl, DistributionPoint point, boolean[] reasonsMask,
|
||||
boolean signFlag, PublicKey prevKey, String provider,
|
||||
List<CertStore> certStores, Set<TrustAnchor> trustAnchors,
|
||||
Date validity) {
|
||||
Date validity) throws CertStoreException {
|
||||
|
||||
// check for full name
|
||||
GeneralNames fullName = point.getFullName();
|
||||
@ -149,24 +154,33 @@ class DistributionPointFetcher {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
}
|
||||
Collection<X509CRL> possibleCRLs = new ArrayList<X509CRL>();
|
||||
Collection<X509CRL> crls = new ArrayList<X509CRL>(2);
|
||||
Collection<X509CRL> possibleCRLs = new ArrayList<>();
|
||||
CertStoreException savedCSE = null;
|
||||
for (Iterator<GeneralName> t = fullName.iterator(); t.hasNext(); ) {
|
||||
GeneralName name = t.next();
|
||||
if (name.getType() == GeneralNameInterface.NAME_DIRECTORY) {
|
||||
X500Name x500Name = (X500Name) name.getName();
|
||||
possibleCRLs.addAll(
|
||||
getCRLs(x500Name, certImpl.getIssuerX500Principal(),
|
||||
certStores));
|
||||
} else if (name.getType() == GeneralNameInterface.NAME_URI) {
|
||||
URIName uriName = (URIName)name.getName();
|
||||
X509CRL crl = getCRL(uriName);
|
||||
if (crl != null) {
|
||||
possibleCRLs.add(crl);
|
||||
try {
|
||||
GeneralName name = t.next();
|
||||
if (name.getType() == GeneralNameInterface.NAME_DIRECTORY) {
|
||||
X500Name x500Name = (X500Name) name.getName();
|
||||
possibleCRLs.addAll(
|
||||
getCRLs(x500Name, certImpl.getIssuerX500Principal(),
|
||||
certStores));
|
||||
} else if (name.getType() == GeneralNameInterface.NAME_URI) {
|
||||
URIName uriName = (URIName)name.getName();
|
||||
X509CRL crl = getCRL(uriName);
|
||||
if (crl != null) {
|
||||
possibleCRLs.add(crl);
|
||||
}
|
||||
}
|
||||
} catch (CertStoreException cse) {
|
||||
savedCSE = cse;
|
||||
}
|
||||
}
|
||||
// only throw CertStoreException if no CRLs are retrieved
|
||||
if (possibleCRLs.isEmpty() && savedCSE != null) {
|
||||
throw savedCSE;
|
||||
}
|
||||
|
||||
Collection<X509CRL> crls = new ArrayList<>(2);
|
||||
for (X509CRL crl : possibleCRLs) {
|
||||
try {
|
||||
// make sure issuer is not set
|
||||
@ -191,34 +205,43 @@ class DistributionPointFetcher {
|
||||
/**
|
||||
* Download CRL from given URI.
|
||||
*/
|
||||
private static X509CRL getCRL(URIName name) {
|
||||
private static X509CRL getCRL(URIName name) throws CertStoreException {
|
||||
URI uri = name.getURI();
|
||||
if (debug != null) {
|
||||
debug.println("Trying to fetch CRL from DP " + uri);
|
||||
}
|
||||
CertStore ucs = null;
|
||||
try {
|
||||
CertStore ucs = URICertStore.getInstance
|
||||
ucs = URICertStore.getInstance
|
||||
(new URICertStore.URICertStoreParameters(uri));
|
||||
Collection<? extends CRL> crls = ucs.getCRLs(null);
|
||||
if (crls.isEmpty()) {
|
||||
return null;
|
||||
} else {
|
||||
return (X509CRL) crls.iterator().next();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
} catch (InvalidAlgorithmParameterException |
|
||||
NoSuchAlgorithmException e) {
|
||||
if (debug != null) {
|
||||
debug.println("Exception getting CRL from CertStore: " + e);
|
||||
e.printStackTrace();
|
||||
debug.println("Can't create URICertStore: " + e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Collection<? extends CRL> crls = ucs.getCRLs(null);
|
||||
if (crls.isEmpty()) {
|
||||
return null;
|
||||
} else {
|
||||
return (X509CRL) crls.iterator().next();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch CRLs from certStores.
|
||||
*
|
||||
* @throws CertStoreException if there is an error retrieving the CRLs from
|
||||
* one of the CertStores and no other CRLs are retrieved from
|
||||
* the other CertStores. If more than one CertStore throws an
|
||||
* exception then the one from the last CertStore is thrown.
|
||||
*/
|
||||
private static Collection<X509CRL> getCRLs(X500Name name,
|
||||
X500Principal certIssuer, List<CertStore> certStores)
|
||||
X500Principal certIssuer,
|
||||
List<CertStore> certStores)
|
||||
throws CertStoreException
|
||||
{
|
||||
if (debug != null) {
|
||||
debug.println("Trying to fetch CRL from DP " + name);
|
||||
@ -227,21 +250,27 @@ class DistributionPointFetcher {
|
||||
xcs.addIssuer(name.asX500Principal());
|
||||
xcs.addIssuer(certIssuer);
|
||||
Collection<X509CRL> crls = new ArrayList<>();
|
||||
CertStoreException savedCSE = null;
|
||||
for (CertStore store : certStores) {
|
||||
try {
|
||||
for (CRL crl : store.getCRLs(xcs)) {
|
||||
crls.add((X509CRL)crl);
|
||||
}
|
||||
} catch (CertStoreException cse) {
|
||||
// don't add the CRL
|
||||
if (debug != null) {
|
||||
debug.println("Non-fatal exception while retrieving " +
|
||||
debug.println("Exception while retrieving " +
|
||||
"CRLs: " + cse);
|
||||
cse.printStackTrace();
|
||||
}
|
||||
savedCSE = new PKIX.CertStoreTypeException(store.getType(),cse);
|
||||
}
|
||||
}
|
||||
return crls;
|
||||
// only throw CertStoreException if no CRLs are retrieved
|
||||
if (crls.isEmpty() && savedCSE != null) {
|
||||
throw savedCSE;
|
||||
} else {
|
||||
return crls;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -369,20 +369,21 @@ class ForwardBuilder extends Builder {
|
||||
boolean add = false;
|
||||
for (AccessDescription ad : adList) {
|
||||
CertStore cs = URICertStore.getInstance(ad);
|
||||
try {
|
||||
if (certs.addAll((Collection<X509Certificate>)
|
||||
cs.getCertificates(caSelector))) {
|
||||
add = true;
|
||||
if (!searchAllCertStores) {
|
||||
return true;
|
||||
if (cs != null) {
|
||||
try {
|
||||
if (certs.addAll((Collection<X509Certificate>)
|
||||
cs.getCertificates(caSelector))) {
|
||||
add = true;
|
||||
if (!searchAllCertStores) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch (CertStoreException cse) {
|
||||
if (debug != null) {
|
||||
debug.println("exception getting certs from CertStore:");
|
||||
cse.printStackTrace();
|
||||
}
|
||||
}
|
||||
} catch (CertStoreException cse) {
|
||||
if (debug != null) {
|
||||
debug.println("exception getting certs from CertStore:");
|
||||
cse.printStackTrace();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return add;
|
||||
@ -816,36 +817,36 @@ class ForwardBuilder extends Builder {
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
X500Principal principal = anchor.getCA();
|
||||
PublicKey publicKey = anchor.getCAPublicKey();
|
||||
}
|
||||
X500Principal principal = anchor.getCA();
|
||||
PublicKey publicKey = anchor.getCAPublicKey();
|
||||
|
||||
if (principal != null && publicKey != null &&
|
||||
principal.equals(cert.getSubjectX500Principal())) {
|
||||
if (publicKey.equals(cert.getPublicKey())) {
|
||||
// the cert itself is a trust anchor
|
||||
this.trustAnchor = anchor;
|
||||
return true;
|
||||
}
|
||||
// else, it is a self-issued certificate of the anchor
|
||||
if (principal != null && publicKey != null &&
|
||||
principal.equals(cert.getSubjectX500Principal())) {
|
||||
if (publicKey.equals(cert.getPublicKey())) {
|
||||
// the cert itself is a trust anchor
|
||||
this.trustAnchor = anchor;
|
||||
return true;
|
||||
}
|
||||
// else, it is a self-issued certificate of the anchor
|
||||
}
|
||||
|
||||
// Check subject/issuer name chaining
|
||||
if (principal == null ||
|
||||
!principal.equals(cert.getIssuerX500Principal())) {
|
||||
continue;
|
||||
}
|
||||
// Check subject/issuer name chaining
|
||||
if (principal == null ||
|
||||
!principal.equals(cert.getIssuerX500Principal())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// skip anchor if it contains a DSA key with no DSA params
|
||||
if (PKIX.isDSAPublicKeyWithoutParams(publicKey)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check signature
|
||||
*/
|
||||
try {
|
||||
// NOTE: the DSA public key in the buildParams may lack
|
||||
// parameters, yet there is no key to inherit the parameters
|
||||
// from. This is probably such a rare case that it is not worth
|
||||
// trying to detect the situation earlier.
|
||||
cert.verify(anchor.getCAPublicKey(), buildParams.sigProvider());
|
||||
cert.verify(publicKey, buildParams.sigProvider());
|
||||
} catch (InvalidKeyException ike) {
|
||||
if (debug != null) {
|
||||
debug.println("ForwardBuilder.isPathCompleted() invalid "
|
||||
|
@ -26,12 +26,10 @@
|
||||
package sun.security.provider.certpath;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.PublicKey;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.CertPathValidatorException;
|
||||
import java.security.cert.PKIXCertPathChecker;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.security.interfaces.DSAPublicKey;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@ -169,9 +167,7 @@ class ForwardState implements State {
|
||||
X509CertImpl icert = X509CertImpl.toImpl(cert);
|
||||
|
||||
/* see if certificate key has null parameters */
|
||||
PublicKey newKey = icert.getPublicKey();
|
||||
if (newKey instanceof DSAPublicKey &&
|
||||
((DSAPublicKey)newKey).getParams() == null) {
|
||||
if (PKIX.isDSAPublicKeyWithoutParams(icert.getPublicKey())) {
|
||||
keyParamsNeededFlag = true;
|
||||
}
|
||||
|
||||
|
@ -335,8 +335,8 @@ public final class OCSP {
|
||||
static class NetworkFailureException extends CertPathValidatorException {
|
||||
private static final long serialVersionUID = 0l;
|
||||
|
||||
private NetworkFailureException(IOException ioe) {
|
||||
super(ioe);
|
||||
NetworkFailureException(Throwable t) {
|
||||
super(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -26,7 +26,9 @@ package sun.security.provider.certpath;
|
||||
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.KeyStore;
|
||||
import java.security.PublicKey;
|
||||
import java.security.cert.*;
|
||||
import java.security.interfaces.DSAPublicKey;
|
||||
import java.util.*;
|
||||
import javax.security.auth.x500.X500Principal;
|
||||
|
||||
@ -42,6 +44,11 @@ class PKIX {
|
||||
|
||||
private PKIX() { }
|
||||
|
||||
static boolean isDSAPublicKeyWithoutParams(PublicKey publicKey) {
|
||||
return (publicKey instanceof DSAPublicKey &&
|
||||
((DSAPublicKey)publicKey).getParams() == null);
|
||||
}
|
||||
|
||||
static ValidatorParams checkParams(CertPath cp, CertPathParameters params)
|
||||
throws InvalidAlgorithmParameterException
|
||||
{
|
||||
@ -270,6 +277,24 @@ class PKIX {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A CertStoreException with additional information about the type of
|
||||
* CertStore that generated the exception.
|
||||
*/
|
||||
static class CertStoreTypeException extends CertStoreException {
|
||||
private static final long serialVersionUID = 7463352639238322556L;
|
||||
|
||||
private final String type;
|
||||
|
||||
CertStoreTypeException(String type, CertStoreException cse) {
|
||||
super(cse.getMessage(), cse.getCause());
|
||||
this.type = type;
|
||||
}
|
||||
String getType() {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Comparator that orders CertStores so that local CertStores come before
|
||||
* remote CertStores.
|
||||
|
@ -32,7 +32,6 @@ import java.security.cert.CertPathValidatorException;
|
||||
import java.security.cert.PKIXCertPathChecker;
|
||||
import java.security.cert.TrustAnchor;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.security.interfaces.DSAPublicKey;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@ -287,8 +286,7 @@ class ReverseState implements State {
|
||||
/* check for key needing to inherit alg parameters */
|
||||
X509CertImpl icert = X509CertImpl.toImpl(cert);
|
||||
PublicKey newKey = cert.getPublicKey();
|
||||
if (newKey instanceof DSAPublicKey &&
|
||||
(((DSAPublicKey)newKey).getParams() == null)) {
|
||||
if (PKIX.isDSAPublicKeyWithoutParams(newKey)) {
|
||||
newKey = BasicChecker.makeInheritedParamsKey(newKey, pubKey);
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,6 @@ import java.security.Security;
|
||||
import java.security.cert.CertPathValidatorException.BasicReason;
|
||||
import java.security.cert.Extension;
|
||||
import java.security.cert.*;
|
||||
import java.security.interfaces.DSAPublicKey;
|
||||
import java.util.Arrays;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@ -50,7 +49,7 @@ import java.util.Set;
|
||||
import javax.security.auth.x500.X500Principal;
|
||||
|
||||
import static sun.security.provider.certpath.OCSP.*;
|
||||
import sun.security.provider.certpath.PKIX.ValidatorParams;
|
||||
import static sun.security.provider.certpath.PKIX.*;
|
||||
import sun.security.action.GetPropertyAction;
|
||||
import sun.security.x509.*;
|
||||
import static sun.security.x509.PKIXExtensions.*;
|
||||
@ -406,8 +405,7 @@ class RevocationChecker extends PKIXRevocationChecker {
|
||||
|
||||
// Make new public key if parameters are missing
|
||||
PublicKey pubKey = cert.getPublicKey();
|
||||
if (pubKey instanceof DSAPublicKey &&
|
||||
((DSAPublicKey)pubKey).getParams() == null) {
|
||||
if (PKIX.isDSAPublicKeyWithoutParams(pubKey)) {
|
||||
// pubKey needs to inherit DSA parameters from prev key
|
||||
pubKey = BasicChecker.makeInheritedParamsKey(pubKey, prevPubKey);
|
||||
}
|
||||
@ -458,14 +456,23 @@ class RevocationChecker extends PKIXRevocationChecker {
|
||||
sel.setCertificateChecking(cert);
|
||||
CertPathHelper.setDateAndTime(sel, params.date(), MAX_CLOCK_SKEW);
|
||||
|
||||
// First, check cached CRLs
|
||||
// First, check user-specified CertStores
|
||||
NetworkFailureException nfe = null;
|
||||
for (CertStore store : certStores) {
|
||||
try {
|
||||
for (CRL crl : store.getCRLs(sel)) {
|
||||
possibleCRLs.add((X509CRL)crl);
|
||||
}
|
||||
} catch (CertStoreException e) {
|
||||
// XXX ignore?
|
||||
if (debug != null) {
|
||||
debug.println("RevocationChecker.checkCRLs() " +
|
||||
"CertStoreException: " + e.getMessage());
|
||||
}
|
||||
if (softFail && nfe == null &&
|
||||
CertStoreHelper.isCausedByNetworkIssue(store.getType(),e)) {
|
||||
// save this exception, we may need to throw it later
|
||||
nfe = new NetworkFailureException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -504,9 +511,12 @@ class RevocationChecker extends PKIXRevocationChecker {
|
||||
reasonsMask, anchors, params.date()));
|
||||
}
|
||||
} catch (CertStoreException e) {
|
||||
if (debug != null) {
|
||||
debug.println("RevocationChecker.checkCRLs() " +
|
||||
"unexpected exception: " + e.getMessage());
|
||||
if (softFail && e instanceof CertStoreTypeException) {
|
||||
CertStoreTypeException cste = (CertStoreTypeException)e;
|
||||
if (CertStoreHelper.isCausedByNetworkIssue(cste.getType(),
|
||||
e)) {
|
||||
throw new NetworkFailureException(e);
|
||||
}
|
||||
}
|
||||
throw new CertPathValidatorException(e);
|
||||
}
|
||||
@ -516,10 +526,28 @@ class RevocationChecker extends PKIXRevocationChecker {
|
||||
checkApprovedCRLs(cert, approvedCRLs);
|
||||
} else {
|
||||
if (allowSeparateKey) {
|
||||
verifyWithSeparateSigningKey(cert, prevKey, signFlag,
|
||||
stackedCerts);
|
||||
return;
|
||||
try {
|
||||
verifyWithSeparateSigningKey(cert, prevKey, signFlag,
|
||||
stackedCerts);
|
||||
return;
|
||||
} catch (CertPathValidatorException cpve) {
|
||||
if (nfe != null) {
|
||||
// if a network issue previously prevented us from
|
||||
// retrieving a CRL from one of the user-specified
|
||||
// CertStores and SOFT_FAIL is enabled, throw it now
|
||||
// so it can be handled appropriately
|
||||
throw nfe;
|
||||
}
|
||||
throw cpve;
|
||||
}
|
||||
} else {
|
||||
if (nfe != null) {
|
||||
// if a network issue previously prevented us from
|
||||
// retrieving a CRL from one of the user-specified
|
||||
// CertStores and SOFT_FAIL is enabled, throw it now
|
||||
// so it can be handled appropriately
|
||||
throw nfe;
|
||||
}
|
||||
throw new CertPathValidatorException
|
||||
("Could not determine revocation status", null, null, -1,
|
||||
BasicReason.UNDETERMINED_REVOCATION_STATUS);
|
||||
|
@ -31,7 +31,6 @@ import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.PublicKey;
|
||||
import java.security.cert.*;
|
||||
import java.security.cert.PKIXReason;
|
||||
import java.security.interfaces.DSAPublicKey;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@ -242,6 +241,15 @@ public final class SunCertPathBuilder extends CertPathBuilderSpi {
|
||||
break;
|
||||
}
|
||||
|
||||
// skip anchor if it contains a DSA key with no DSA params
|
||||
X509Certificate trustedCert = anchor.getTrustedCert();
|
||||
PublicKey pubKey = trustedCert != null ? trustedCert.getPublicKey()
|
||||
: anchor.getCAPublicKey();
|
||||
|
||||
if (PKIX.isDSAPublicKeyWithoutParams(pubKey)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Initialize current state */
|
||||
currentState.initState(buildParams);
|
||||
currentState.updateState(anchor, buildParams);
|
||||
@ -705,9 +713,7 @@ public final class SunCertPathBuilder extends CertPathBuilderSpi {
|
||||
* Extract and save the final target public key
|
||||
*/
|
||||
finalPublicKey = cert.getPublicKey();
|
||||
if (finalPublicKey instanceof DSAPublicKey &&
|
||||
((DSAPublicKey)finalPublicKey).getParams() == null)
|
||||
{
|
||||
if (PKIX.isDSAPublicKeyWithoutParams(finalPublicKey)) {
|
||||
finalPublicKey =
|
||||
BasicChecker.makeInheritedParamsKey
|
||||
(finalPublicKey, currentState.pubKey);
|
||||
|
@ -340,7 +340,11 @@ class URICertStore extends CertStoreSpi {
|
||||
// Fetch the CRLs via LDAP. LDAPCertStore has its own
|
||||
// caching mechanism, see the class description for more info.
|
||||
// Safe cast since xsel is an X509 certificate selector.
|
||||
return (Collection<X509CRL>) ldapCertStore.getCRLs(xsel);
|
||||
try {
|
||||
return (Collection<X509CRL>) ldapCertStore.getCRLs(xsel);
|
||||
} catch (CertStoreException cse) {
|
||||
throw new PKIX.CertStoreTypeException("LDAP", cse);
|
||||
}
|
||||
}
|
||||
|
||||
// Return the CRLs for this entry. It returns the cached value
|
||||
@ -391,11 +395,12 @@ class URICertStore extends CertStoreSpi {
|
||||
debug.println("Exception fetching CRL:");
|
||||
e.printStackTrace();
|
||||
}
|
||||
// exception, forget previous values
|
||||
lastModified = 0;
|
||||
crl = null;
|
||||
throw new PKIX.CertStoreTypeException("URI",
|
||||
new CertStoreException(e));
|
||||
}
|
||||
// exception, forget previous values
|
||||
lastModified = 0;
|
||||
crl = null;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2009, 2012, 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,15 +25,18 @@
|
||||
|
||||
package sun.security.provider.certpath.ldap;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.Collection;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.cert.CertStore;
|
||||
import java.security.cert.CertStoreException;
|
||||
import java.security.cert.X509CertSelector;
|
||||
import java.security.cert.X509CRLSelector;
|
||||
import javax.naming.CommunicationException;
|
||||
import javax.naming.ServiceUnavailableException;
|
||||
import javax.security.auth.x500.X500Principal;
|
||||
import java.io.IOException;
|
||||
|
||||
import sun.security.provider.certpath.CertStoreHelper;
|
||||
|
||||
@ -68,4 +71,11 @@ public final class LDAPCertStoreHelper
|
||||
{
|
||||
return new LDAPCertStore.LDAPCRLSelector(selector, certIssuers, ldapDN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCausedByNetworkIssue(CertStoreException e) {
|
||||
Throwable t = e.getCause();
|
||||
return (t != null && (t instanceof ServiceUnavailableException ||
|
||||
t instanceof CommunicationException));
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2012, 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,15 +25,16 @@
|
||||
|
||||
package sun.security.provider.certpath.ssl;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.Collection;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.cert.CertStore;
|
||||
import java.security.cert.CertStoreException;
|
||||
import java.security.cert.X509CertSelector;
|
||||
import java.security.cert.X509CRLSelector;
|
||||
import java.util.Collection;
|
||||
import javax.security.auth.x500.X500Principal;
|
||||
import java.io.IOException;
|
||||
|
||||
import sun.security.provider.certpath.CertStoreHelper;
|
||||
|
||||
@ -66,4 +67,10 @@ public final class SSLServerCertStoreHelper extends CertStoreHelper {
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCausedByNetworkIssue(CertStoreException e) {
|
||||
Throwable t = e.getCause();
|
||||
return (t != null && t instanceof IOException);
|
||||
}
|
||||
}
|
||||
|
@ -266,7 +266,7 @@ public abstract class SSLContextImpl extends SSLContextSpi {
|
||||
}
|
||||
|
||||
// Get suported CipherSuiteList.
|
||||
CipherSuiteList getSuportedCipherSuiteList() {
|
||||
CipherSuiteList getSupportedCipherSuiteList() {
|
||||
// The maintenance of cipher suites needs to be synchronized.
|
||||
synchronized (this) {
|
||||
// Clear cache of available ciphersuites.
|
||||
|
@ -1978,7 +1978,7 @@ final public class SSLEngineImpl extends SSLEngine {
|
||||
* @return an array of cipher suite names
|
||||
*/
|
||||
public String[] getSupportedCipherSuites() {
|
||||
return sslContext.getSuportedCipherSuiteList().toStringArray();
|
||||
return sslContext.getSupportedCipherSuiteList().toStringArray();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2012, 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
|
||||
@ -113,7 +113,7 @@ public class SSLServerSocketFactoryImpl extends SSLServerSocketFactory
|
||||
* @return an array of cipher suite names
|
||||
*/
|
||||
public String[] getSupportedCipherSuites() {
|
||||
return context.getSuportedCipherSuiteList().toStringArray();
|
||||
return context.getSupportedCipherSuiteList().toStringArray();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2012, 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
|
||||
@ -168,7 +168,7 @@ class SSLServerSocketImpl extends SSLServerSocket
|
||||
* @return an array of cipher suite names
|
||||
*/
|
||||
public String[] getSupportedCipherSuites() {
|
||||
return sslContext.getSuportedCipherSuiteList().toStringArray();
|
||||
return sslContext.getSupportedCipherSuiteList().toStringArray();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2012, 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
|
||||
@ -177,6 +177,6 @@ final public class SSLSocketFactoryImpl extends SSLSocketFactory {
|
||||
* certain kinds of certificates to use certain cipher suites.
|
||||
*/
|
||||
public String[] getSupportedCipherSuites() {
|
||||
return context.getSuportedCipherSuiteList().toStringArray();
|
||||
return context.getSupportedCipherSuiteList().toStringArray();
|
||||
}
|
||||
}
|
||||
|
@ -2353,7 +2353,7 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
|
||||
* @return an array of cipher suite names
|
||||
*/
|
||||
public String[] getSupportedCipherSuites() {
|
||||
return sslContext.getSuportedCipherSuiteList().toStringArray();
|
||||
return sslContext.getSupportedCipherSuiteList().toStringArray();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -70,15 +70,22 @@ public class Debug {
|
||||
System.err.println();
|
||||
System.err.println("all turn on all debugging");
|
||||
System.err.println("access print all checkPermission results");
|
||||
System.err.println("certpath PKIX CertPathBuilder and");
|
||||
System.err.println(" CertPathValidator debugging");
|
||||
System.err.println("combiner SubjectDomainCombiner debugging");
|
||||
System.err.println("gssloginconfig");
|
||||
System.err.println(" GSS LoginConfigImpl debugging");
|
||||
System.err.println("configfile JAAS ConfigFile loading");
|
||||
System.err.println("configparser JAAS ConfigFile parsing");
|
||||
System.err.println(" GSS LoginConfigImpl debugging");
|
||||
System.err.println("jar jar verification");
|
||||
System.err.println("logincontext login context results");
|
||||
System.err.println("jca JCA engine class debugging");
|
||||
System.err.println("policy loading and granting");
|
||||
System.err.println("provider security provider debugging");
|
||||
System.err.println("pkcs11 PKCS11 session manager debugging");
|
||||
System.err.println("pkcs11keystore");
|
||||
System.err.println(" PKCS11 KeyStore debugging");
|
||||
System.err.println("sunpkcs11 SunPKCS11 provider debugging");
|
||||
System.err.println("scl permissions SecureClassLoader assigns");
|
||||
System.err.println("ts timestamping");
|
||||
System.err.println();
|
||||
|
@ -1,177 +0,0 @@
|
||||
/*
|
||||
* 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.security.x509;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Enumeration;
|
||||
|
||||
import sun.security.util.*;
|
||||
|
||||
/**
|
||||
* This class defines the subject/issuer unique identity attribute
|
||||
* for the Certificate.
|
||||
*
|
||||
* @author Amit Kapoor
|
||||
* @author Hemma Prafullchandra
|
||||
* @see CertAttrSet
|
||||
*/
|
||||
public class CertificateIssuerUniqueIdentity implements CertAttrSet<String> {
|
||||
private UniqueIdentity id;
|
||||
|
||||
/**
|
||||
* Identifier for this attribute, to be used with the
|
||||
* get, set, delete methods of Certificate, x509 type.
|
||||
*/
|
||||
public static final String IDENT = "x509.info.issuerID";
|
||||
/**
|
||||
* Sub attributes name for this CertAttrSet.
|
||||
*/
|
||||
public static final String NAME = "issuerID";
|
||||
public static final String ID = "id";
|
||||
|
||||
/**
|
||||
* Default constructor for the certificate attribute.
|
||||
*
|
||||
* @param key the UniqueIdentity
|
||||
*/
|
||||
public CertificateIssuerUniqueIdentity(UniqueIdentity id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the object, decoding the values from the passed DER stream.
|
||||
*
|
||||
* @param in the DerInputStream to read the UniqueIdentity from.
|
||||
* @exception IOException on decoding errors.
|
||||
*/
|
||||
public CertificateIssuerUniqueIdentity(DerInputStream in)
|
||||
throws IOException {
|
||||
id = new UniqueIdentity(in);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the object, decoding the values from the passed stream.
|
||||
*
|
||||
* @param in the InputStream to read the UniqueIdentity from.
|
||||
* @exception IOException on decoding errors.
|
||||
*/
|
||||
public CertificateIssuerUniqueIdentity(InputStream in)
|
||||
throws IOException {
|
||||
DerValue val = new DerValue(in);
|
||||
id = new UniqueIdentity(val);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the object, decoding the values from the passed DER value.
|
||||
*
|
||||
* @param in the DerValue to read the UniqueIdentity from.
|
||||
* @exception IOException on decoding errors.
|
||||
*/
|
||||
public CertificateIssuerUniqueIdentity(DerValue val)
|
||||
throws IOException {
|
||||
id = new UniqueIdentity(val);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the identity as user readable string.
|
||||
*/
|
||||
public String toString() {
|
||||
if (id == null) return "";
|
||||
return (id.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode the identity in DER form to the stream.
|
||||
*
|
||||
* @param out the DerOutputStream to marshal the contents to.
|
||||
* @exception IOException on errors.
|
||||
*/
|
||||
public void encode(OutputStream out) throws IOException {
|
||||
DerOutputStream tmp = new DerOutputStream();
|
||||
id.encode(tmp,DerValue.createTag(DerValue.TAG_CONTEXT,false,(byte)1));
|
||||
|
||||
out.write(tmp.toByteArray());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the attribute value.
|
||||
*/
|
||||
public void set(String name, Object obj) throws IOException {
|
||||
if (!(obj instanceof UniqueIdentity)) {
|
||||
throw new IOException("Attribute must be of type UniqueIdentity.");
|
||||
}
|
||||
if (name.equalsIgnoreCase(ID)) {
|
||||
id = (UniqueIdentity)obj;
|
||||
} else {
|
||||
throw new IOException("Attribute name not recognized by " +
|
||||
"CertAttrSet: CertificateIssuerUniqueIdentity.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attribute value.
|
||||
*/
|
||||
public UniqueIdentity get(String name) throws IOException {
|
||||
if (name.equalsIgnoreCase(ID)) {
|
||||
return (id);
|
||||
} else {
|
||||
throw new IOException("Attribute name not recognized by " +
|
||||
"CertAttrSet: CertificateIssuerUniqueIdentity.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the attribute value.
|
||||
*/
|
||||
public void delete(String name) throws IOException {
|
||||
if (name.equalsIgnoreCase(ID)) {
|
||||
id = null;
|
||||
} else {
|
||||
throw new IOException("Attribute name not recognized by " +
|
||||
"CertAttrSet: CertificateIssuerUniqueIdentity.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an enumeration of names of attributes existing within this
|
||||
* attribute.
|
||||
*/
|
||||
public Enumeration<String> getElements() {
|
||||
AttributeNameEnumeration elements = new AttributeNameEnumeration();
|
||||
elements.addElement(ID);
|
||||
|
||||
return (elements.elements());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of this attribute.
|
||||
*/
|
||||
public String getName() {
|
||||
return (NAME);
|
||||
}
|
||||
}
|
@ -1,176 +0,0 @@
|
||||
/*
|
||||
* 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
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package sun.security.x509;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Enumeration;
|
||||
|
||||
import sun.security.util.*;
|
||||
|
||||
/**
|
||||
* This class defines the subject/issuer unique identity attribute
|
||||
* for the Certificate.
|
||||
*
|
||||
* @author Amit Kapoor
|
||||
* @author Hemma Prafullchandra
|
||||
* @see CertAttrSet
|
||||
*/
|
||||
public class CertificateSubjectUniqueIdentity implements CertAttrSet<String> {
|
||||
/**
|
||||
* Identifier for this attribute, to be used with the
|
||||
* get, set, delete methods of Certificate, x509 type.
|
||||
*/
|
||||
public static final String IDENT = "x509.info.subjectID";
|
||||
/**
|
||||
* Sub attributes name for this CertAttrSet.
|
||||
*/
|
||||
public static final String NAME = "subjectID";
|
||||
public static final String ID = "id";
|
||||
|
||||
private UniqueIdentity id;
|
||||
|
||||
/**
|
||||
* Default constructor for the certificate attribute.
|
||||
*
|
||||
* @param key the UniqueIdentity
|
||||
*/
|
||||
public CertificateSubjectUniqueIdentity(UniqueIdentity id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the object, decoding the values from the passed DER stream.
|
||||
*
|
||||
* @param in the DerInputStream to read the UniqueIdentity from.
|
||||
* @exception IOException on decoding errors.
|
||||
*/
|
||||
public CertificateSubjectUniqueIdentity(DerInputStream in)
|
||||
throws IOException {
|
||||
id = new UniqueIdentity(in);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the object, decoding the values from the passed stream.
|
||||
*
|
||||
* @param in the InputStream to read the UniqueIdentity from.
|
||||
* @exception IOException on decoding errors.
|
||||
*/
|
||||
public CertificateSubjectUniqueIdentity(InputStream in)
|
||||
throws IOException {
|
||||
DerValue val = new DerValue(in);
|
||||
id = new UniqueIdentity(val);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the object, decoding the values from the passed DER value.
|
||||
*
|
||||
* @param in the DerValue to read the UniqueIdentity from.
|
||||
* @exception IOException on decoding errors.
|
||||
*/
|
||||
public CertificateSubjectUniqueIdentity(DerValue val)
|
||||
throws IOException {
|
||||
id = new UniqueIdentity(val);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the identity as user readable string.
|
||||
*/
|
||||
public String toString() {
|
||||
if (id == null) return "";
|
||||
return(id.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode the identity in DER form to the stream.
|
||||
*
|
||||
* @param out the DerOutputStream to marshal the contents to.
|
||||
* @exception IOException on errors.
|
||||
*/
|
||||
public void encode(OutputStream out) throws IOException {
|
||||
DerOutputStream tmp = new DerOutputStream();
|
||||
id.encode(tmp,DerValue.createTag(DerValue.TAG_CONTEXT,false,(byte)2));
|
||||
|
||||
out.write(tmp.toByteArray());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the attribute value.
|
||||
*/
|
||||
public void set(String name, Object obj) throws IOException {
|
||||
if (!(obj instanceof UniqueIdentity)) {
|
||||
throw new IOException("Attribute must be of type UniqueIdentity.");
|
||||
}
|
||||
if (name.equalsIgnoreCase(ID)) {
|
||||
id = (UniqueIdentity)obj;
|
||||
} else {
|
||||
throw new IOException("Attribute name not recognized by " +
|
||||
"CertAttrSet: CertificateSubjectUniqueIdentity.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attribute value.
|
||||
*/
|
||||
public UniqueIdentity get(String name) throws IOException {
|
||||
if (name.equalsIgnoreCase(ID)) {
|
||||
return(id);
|
||||
} else {
|
||||
throw new IOException("Attribute name not recognized by " +
|
||||
"CertAttrSet: CertificateSubjectUniqueIdentity.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the attribute value.
|
||||
*/
|
||||
public void delete(String name) throws IOException {
|
||||
if (name.equalsIgnoreCase(ID)) {
|
||||
id = null;
|
||||
} else {
|
||||
throw new IOException("Attribute name not recognized by " +
|
||||
"CertAttrSet: CertificateSubjectUniqueIdentity.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an enumeration of names of attributes existing within this
|
||||
* attribute.
|
||||
*/
|
||||
public Enumeration<String> getElements() {
|
||||
AttributeNameEnumeration elements = new AttributeNameEnumeration();
|
||||
elements.addElement(ID);
|
||||
|
||||
return (elements.elements());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of this attribute.
|
||||
*/
|
||||
public String getName() {
|
||||
return (NAME);
|
||||
}
|
||||
}
|
@ -1070,8 +1070,7 @@ public class X509CertImpl extends X509Certificate implements DerEncoder {
|
||||
return null;
|
||||
try {
|
||||
UniqueIdentity id = (UniqueIdentity)info.get(
|
||||
CertificateIssuerUniqueIdentity.NAME
|
||||
+ DOT + CertificateIssuerUniqueIdentity.ID);
|
||||
X509CertInfo.ISSUER_ID);
|
||||
if (id == null)
|
||||
return null;
|
||||
else
|
||||
@ -1091,8 +1090,7 @@ public class X509CertImpl extends X509Certificate implements DerEncoder {
|
||||
return null;
|
||||
try {
|
||||
UniqueIdentity id = (UniqueIdentity)info.get(
|
||||
CertificateSubjectUniqueIdentity.NAME
|
||||
+ DOT + CertificateSubjectUniqueIdentity.ID);
|
||||
X509CertInfo.SUBJECT_ID);
|
||||
if (id == null)
|
||||
return null;
|
||||
else
|
||||
|
@ -75,8 +75,8 @@ public class X509CertInfo implements CertAttrSet<String> {
|
||||
public static final String VALIDITY = CertificateValidity.NAME;
|
||||
public static final String SUBJECT = CertificateSubjectName.NAME;
|
||||
public static final String KEY = CertificateX509Key.NAME;
|
||||
public static final String ISSUER_ID = CertificateIssuerUniqueIdentity.NAME;
|
||||
public static final String SUBJECT_ID = CertificateSubjectUniqueIdentity.NAME;
|
||||
public static final String ISSUER_ID = "issuerID";
|
||||
public static final String SUBJECT_ID = "subjectID";
|
||||
public static final String EXTENSIONS = CertificateExtensions.NAME;
|
||||
|
||||
// X509.v1 data
|
||||
@ -89,8 +89,8 @@ public class X509CertInfo implements CertAttrSet<String> {
|
||||
protected CertificateX509Key pubKey = null;
|
||||
|
||||
// X509.v2 & v3 extensions
|
||||
protected CertificateIssuerUniqueIdentity issuerUniqueId = null;
|
||||
protected CertificateSubjectUniqueIdentity subjectUniqueId = null;
|
||||
protected UniqueIdentity issuerUniqueId = null;
|
||||
protected UniqueIdentity subjectUniqueId = null;
|
||||
|
||||
// X509.v3 extensions
|
||||
protected CertificateExtensions extensions = null;
|
||||
@ -431,19 +431,11 @@ public class X509CertInfo implements CertAttrSet<String> {
|
||||
break;
|
||||
|
||||
case ATTR_ISSUER_ID:
|
||||
if (suffix == null) {
|
||||
setIssuerUniqueId(val);
|
||||
} else {
|
||||
issuerUniqueId.set(suffix, val);
|
||||
}
|
||||
setIssuerUniqueId(val);
|
||||
break;
|
||||
|
||||
case ATTR_SUBJECT_ID:
|
||||
if (suffix == null) {
|
||||
setSubjectUniqueId(val);
|
||||
} else {
|
||||
subjectUniqueId.set(suffix, val);
|
||||
}
|
||||
setSubjectUniqueId(val);
|
||||
break;
|
||||
|
||||
case ATTR_EXTENSIONS:
|
||||
@ -529,18 +521,10 @@ public class X509CertInfo implements CertAttrSet<String> {
|
||||
}
|
||||
break;
|
||||
case (ATTR_ISSUER_ID):
|
||||
if (suffix == null) {
|
||||
issuerUniqueId = null;
|
||||
} else {
|
||||
issuerUniqueId.delete(suffix);
|
||||
}
|
||||
issuerUniqueId = null;
|
||||
break;
|
||||
case (ATTR_SUBJECT_ID):
|
||||
if (suffix == null) {
|
||||
subjectUniqueId = null;
|
||||
} else {
|
||||
subjectUniqueId.delete(suffix);
|
||||
}
|
||||
subjectUniqueId = null;
|
||||
break;
|
||||
case (ATTR_EXTENSIONS):
|
||||
if (suffix == null) {
|
||||
@ -626,23 +610,9 @@ public class X509CertInfo implements CertAttrSet<String> {
|
||||
return(serialNum.get(suffix));
|
||||
}
|
||||
case (ATTR_ISSUER_ID):
|
||||
if (suffix == null) {
|
||||
return(issuerUniqueId);
|
||||
} else {
|
||||
if (issuerUniqueId == null)
|
||||
return null;
|
||||
else
|
||||
return(issuerUniqueId.get(suffix));
|
||||
}
|
||||
return(issuerUniqueId);
|
||||
case (ATTR_SUBJECT_ID):
|
||||
if (suffix == null) {
|
||||
return(subjectUniqueId);
|
||||
} else {
|
||||
if (subjectUniqueId == null)
|
||||
return null;
|
||||
else
|
||||
return(subjectUniqueId.get(suffix));
|
||||
}
|
||||
return(subjectUniqueId);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -711,7 +681,7 @@ public class X509CertInfo implements CertAttrSet<String> {
|
||||
// Get the issuerUniqueId if present
|
||||
tmp = in.getDerValue();
|
||||
if (tmp.isContextSpecific((byte)1)) {
|
||||
issuerUniqueId = new CertificateIssuerUniqueIdentity(tmp);
|
||||
issuerUniqueId = new UniqueIdentity(tmp);
|
||||
if (in.available() == 0)
|
||||
return;
|
||||
tmp = in.getDerValue();
|
||||
@ -719,7 +689,7 @@ public class X509CertInfo implements CertAttrSet<String> {
|
||||
|
||||
// Get the subjectUniqueId if present.
|
||||
if (tmp.isContextSpecific((byte)2)) {
|
||||
subjectUniqueId = new CertificateSubjectUniqueIdentity(tmp);
|
||||
subjectUniqueId = new UniqueIdentity(tmp);
|
||||
if (in.available() == 0)
|
||||
return;
|
||||
tmp = in.getDerValue();
|
||||
@ -814,10 +784,12 @@ public class X509CertInfo implements CertAttrSet<String> {
|
||||
|
||||
// Encode issuerUniqueId & subjectUniqueId.
|
||||
if (issuerUniqueId != null) {
|
||||
issuerUniqueId.encode(tmp);
|
||||
issuerUniqueId.encode(tmp, DerValue.createTag(DerValue.TAG_CONTEXT,
|
||||
false,(byte)1));
|
||||
}
|
||||
if (subjectUniqueId != null) {
|
||||
subjectUniqueId.encode(tmp);
|
||||
subjectUniqueId.encode(tmp, DerValue.createTag(DerValue.TAG_CONTEXT,
|
||||
false,(byte)2));
|
||||
}
|
||||
|
||||
// Write all the extensions.
|
||||
@ -946,11 +918,11 @@ public class X509CertInfo implements CertAttrSet<String> {
|
||||
if (version.compare(CertificateVersion.V2) < 0) {
|
||||
throw new CertificateException("Invalid version");
|
||||
}
|
||||
if (!(val instanceof CertificateIssuerUniqueIdentity)) {
|
||||
if (!(val instanceof UniqueIdentity)) {
|
||||
throw new CertificateException(
|
||||
"IssuerUniqueId class type invalid.");
|
||||
}
|
||||
issuerUniqueId = (CertificateIssuerUniqueIdentity)val;
|
||||
issuerUniqueId = (UniqueIdentity)val;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -963,11 +935,11 @@ public class X509CertInfo implements CertAttrSet<String> {
|
||||
if (version.compare(CertificateVersion.V2) < 0) {
|
||||
throw new CertificateException("Invalid version");
|
||||
}
|
||||
if (!(val instanceof CertificateSubjectUniqueIdentity)) {
|
||||
if (!(val instanceof UniqueIdentity)) {
|
||||
throw new CertificateException(
|
||||
"SubjectUniqueId class type invalid.");
|
||||
}
|
||||
subjectUniqueId = (CertificateSubjectUniqueIdentity)val;
|
||||
subjectUniqueId = (UniqueIdentity)val;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -126,7 +126,7 @@ public abstract class PreHashedMap<V>
|
||||
*/
|
||||
protected abstract void init(Object[] ht);
|
||||
|
||||
// @SuppressWarnings("unchecked")
|
||||
@SuppressWarnings("unchecked")
|
||||
private V toV(Object x) {
|
||||
return (V)x;
|
||||
}
|
||||
@ -259,8 +259,7 @@ public abstract class PreHashedMap<V>
|
||||
return true;
|
||||
if (!(ob instanceof Map.Entry))
|
||||
return false;
|
||||
Map.Entry<String,V> that
|
||||
= (Map.Entry<String,V>)ob;
|
||||
Map.Entry<?,?> that = (Map.Entry<?,?>)ob;
|
||||
return ((this.getKey() == null
|
||||
? that.getKey() == null
|
||||
: this.getKey()
|
||||
|
@ -40,6 +40,22 @@ public class DefaultAsynchronousChannelProvider {
|
||||
*/
|
||||
private DefaultAsynchronousChannelProvider() { }
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static AsynchronousChannelProvider createProvider(String cn) {
|
||||
Class<AsynchronousChannelProvider> c;
|
||||
try {
|
||||
c = (Class<AsynchronousChannelProvider>)Class.forName(cn);
|
||||
} catch (ClassNotFoundException x) {
|
||||
throw new AssertionError(x);
|
||||
}
|
||||
try {
|
||||
return c.newInstance();
|
||||
} catch (IllegalAccessException | InstantiationException x) {
|
||||
throw new AssertionError(x);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default AsynchronousChannelProvider.
|
||||
*/
|
||||
@ -47,12 +63,11 @@ public class DefaultAsynchronousChannelProvider {
|
||||
String osname = AccessController
|
||||
.doPrivileged(new GetPropertyAction("os.name"));
|
||||
if (osname.equals("SunOS"))
|
||||
return new SolarisAsynchronousChannelProvider();
|
||||
return createProvider("sun.nio.ch.SolarisAsynchronousChannelProvider");
|
||||
if (osname.equals("Linux"))
|
||||
return new LinuxAsynchronousChannelProvider();
|
||||
return createProvider("sun.nio.ch.LinuxAsynchronousChannelProvider");
|
||||
if (osname.contains("OS X"))
|
||||
return new BsdAsynchronousChannelProvider();
|
||||
return createProvider("sun.nio.ch.BsdAsynchronousChannelProvider");
|
||||
throw new InternalError("platform not recognized");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -27,7 +27,6 @@ package sun.nio.ch;
|
||||
|
||||
import java.nio.channels.spi.SelectorProvider;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import sun.security.action.GetPropertyAction;
|
||||
|
||||
/**
|
||||
@ -41,34 +40,32 @@ public class DefaultSelectorProvider {
|
||||
*/
|
||||
private DefaultSelectorProvider() { }
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static SelectorProvider createProvider(String cn) {
|
||||
Class<SelectorProvider> c;
|
||||
try {
|
||||
c = (Class<SelectorProvider>)Class.forName(cn);
|
||||
} catch (ClassNotFoundException x) {
|
||||
throw new AssertionError(x);
|
||||
}
|
||||
try {
|
||||
return c.newInstance();
|
||||
} catch (IllegalAccessException | InstantiationException x) {
|
||||
throw new AssertionError(x);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default SelectorProvider.
|
||||
*/
|
||||
public static SelectorProvider create() {
|
||||
String osname = AccessController.doPrivileged(
|
||||
new GetPropertyAction("os.name"));
|
||||
if ("SunOS".equals(osname)) {
|
||||
return new sun.nio.ch.DevPollSelectorProvider();
|
||||
}
|
||||
|
||||
// use EPollSelectorProvider for Linux kernels >= 2.6
|
||||
if ("Linux".equals(osname)) {
|
||||
String osversion = AccessController.doPrivileged(
|
||||
new GetPropertyAction("os.version"));
|
||||
String[] vers = osversion.split("\\.", 0);
|
||||
if (vers.length >= 2) {
|
||||
try {
|
||||
int major = Integer.parseInt(vers[0]);
|
||||
int minor = Integer.parseInt(vers[1]);
|
||||
if (major > 2 || (major == 2 && minor >= 6)) {
|
||||
return new sun.nio.ch.EPollSelectorProvider();
|
||||
}
|
||||
} catch (NumberFormatException x) {
|
||||
// format not recognized
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String osname = AccessController
|
||||
.doPrivileged(new GetPropertyAction("os.name"));
|
||||
if (osname.equals("SunOS"))
|
||||
return createProvider("sun.nio.ch.DevPollSelectorProvider");
|
||||
if (osname.equals("Linux"))
|
||||
return createProvider("sun.nio.ch.EPollSelectorProvider");
|
||||
return new sun.nio.ch.PollSelectorProvider();
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,6 @@ package sun.nio.fs;
|
||||
|
||||
import java.nio.file.spi.FileSystemProvider;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import sun.security.action.GetPropertyAction;
|
||||
|
||||
/**
|
||||
@ -38,24 +37,18 @@ public class DefaultFileSystemProvider {
|
||||
private DefaultFileSystemProvider() { }
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static FileSystemProvider createProvider(final String cn) {
|
||||
return AccessController
|
||||
.doPrivileged(new PrivilegedAction<FileSystemProvider>() {
|
||||
public FileSystemProvider run() {
|
||||
Class<FileSystemProvider> c;
|
||||
try {
|
||||
c = (Class<FileSystemProvider>)Class.forName(cn, true, null);
|
||||
} catch (ClassNotFoundException x) {
|
||||
throw new AssertionError(x);
|
||||
}
|
||||
try {
|
||||
return c.newInstance();
|
||||
} catch (IllegalAccessException x) {
|
||||
throw new AssertionError(x);
|
||||
} catch (InstantiationException x) {
|
||||
throw new AssertionError(x);
|
||||
}
|
||||
}});
|
||||
private static FileSystemProvider createProvider(String cn) {
|
||||
Class<FileSystemProvider> c;
|
||||
try {
|
||||
c = (Class<FileSystemProvider>)Class.forName(cn);
|
||||
} catch (ClassNotFoundException x) {
|
||||
throw new AssertionError(x);
|
||||
}
|
||||
try {
|
||||
return c.newInstance();
|
||||
} catch (IllegalAccessException | InstantiationException x) {
|
||||
throw new AssertionError(x);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -68,7 +61,7 @@ public class DefaultFileSystemProvider {
|
||||
return createProvider("sun.nio.fs.SolarisFileSystemProvider");
|
||||
if (osname.equals("Linux"))
|
||||
return createProvider("sun.nio.fs.LinuxFileSystemProvider");
|
||||
if (osname.equals("Darwin") || osname.contains("OS X"))
|
||||
if (osname.contains("OS X"))
|
||||
return createProvider("sun.nio.fs.MacOSXFileSystemProvider");
|
||||
throw new AssertionError("Platform not recognized");
|
||||
}
|
||||
|
@ -147,6 +147,9 @@ javax/management/remote/mandatory/connection/ReconnectTest.java generic-all
|
||||
# 7158614, locks up Windows machines at least
|
||||
sun/management/jmxremote/startstop/JMXStartStopTest.sh windows-all
|
||||
|
||||
# 7120365
|
||||
javax/management/remote/mandatory/notif/DiffHBTest.java generic-all
|
||||
|
||||
############################################################################
|
||||
|
||||
# jdk_math
|
||||
@ -216,11 +219,6 @@ java/net/DatagramSocket/SendDatagramToBadAddress.java macosx-all
|
||||
sun/net/www/protocol/http/B6299712.java macosx-all
|
||||
java/net/CookieHandler/CookieManagerTest.java macosx-all
|
||||
|
||||
# 7164518
|
||||
sun/security/krb5/auto/Unreachable.java macosx-all
|
||||
|
||||
# JPRT needs to set 127.0.0.1 in proxy bypass list
|
||||
java/net/URLClassLoader/closetest/CloseTest.java macosx-all
|
||||
############################################################################
|
||||
|
||||
# jdk_io
|
||||
@ -251,9 +249,6 @@ java/nio/channels/DatagramChannel/ChangingAddress.java macosx-all
|
||||
# 7132677
|
||||
java/nio/channels/Selector/OutOfBand.java macosx-all
|
||||
|
||||
# 7142919
|
||||
java/nio/channels/AsyncCloseAndInterrupt.java solaris-all
|
||||
|
||||
############################################################################
|
||||
|
||||
# jdk_rmi
|
||||
@ -277,6 +272,9 @@ sun/rmi/transport/proxy/EagerHttpFallback.java linux-all
|
||||
|
||||
# jdk_security
|
||||
|
||||
# 7164518: no PortUnreachableException on Mac
|
||||
sun/security/krb5/auto/Unreachable.java macosx-all
|
||||
|
||||
# 7193792
|
||||
sun/security/pkcs11/ec/TestECDSA.java solaris-all
|
||||
sun/security/pkcs11/ec/TestECDSA.java linux-all
|
||||
@ -284,47 +282,17 @@ sun/security/pkcs11/ec/TestECDSA.java linux-all
|
||||
# 7193793
|
||||
sun/security/pkcs11/ec/TestECDH.java linux-all
|
||||
|
||||
# 7198198: the test also fails on SuSE Linux
|
||||
sun/security/pkcs11/ec/ReadCertificates.java linux-all
|
||||
|
||||
# 7147060
|
||||
com/sun/org/apache/xml/internal/security/transforms/ClassLoaderTest.java generic-all
|
||||
|
||||
# Failing on Solaris i586, 3/9/2010, not a -samevm issue (jdk_security3)
|
||||
sun/security/pkcs11/Secmod/AddPrivateKey.java solaris-i586
|
||||
sun/security/pkcs11/ec/ReadCertificates.java generic-all
|
||||
sun/security/pkcs11/ec/ReadPKCS12.java generic-all
|
||||
sun/security/pkcs11/ec/TestCurves.java solaris-i586
|
||||
#sun/security/pkcs11/ec/TestECGenSpec.java solaris-i586
|
||||
#sun/security/pkcs11/ec/TestKeyFactory.java solaris-i586
|
||||
sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java generic-all
|
||||
|
||||
# Fails on Fedora 9/Ubuntu 10.04 64bit, PKCS11Exception: CKR_DEVICE_ERROR
|
||||
sun/security/pkcs11/KeyAgreement/TestDH.java generic-all
|
||||
|
||||
# Run too slow on Solaris 10 sparc
|
||||
sun/security/ssl/com/sun/net/ssl/internal/ssl/InputRecord/SSLSocketTimeoutNulls.java solaris-sparc
|
||||
sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/ClientTimeout.java solaris-sparc
|
||||
sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/ServerTimeout.java solaris-sparc
|
||||
sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/ReadTimeout.java solaris-sparc
|
||||
sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/NotifyHandshakeTest.sh solaris-sparc
|
||||
|
||||
# Solaris 10 sparc, passed/failed confusion? java.security.ProviderException: update() failed
|
||||
sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/AsyncSSLSocketClose.java generic-all
|
||||
|
||||
# Othervm, sparc, NoRouteToHostException: Cannot assign requested address
|
||||
sun/security/ssl/javax/net/ssl/NewAPIs/SessionCacheSizeTests.java generic-all
|
||||
|
||||
# Times out on windows X64, othervm mode
|
||||
# Solaris sparc and sparcv9 -server, timeout
|
||||
sun/security/ssl/javax/net/ssl/NewAPIs/SessionTimeOutTests.java generic-all
|
||||
|
||||
# Various failures on Linux Fedora 9 X64, othervm mode
|
||||
sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/TestAllSuites.java generic-all
|
||||
sun/security/ssl/sanity/ciphersuites/CheckCipherSuites.java generic-all
|
||||
|
||||
# Various failures on Linux Fedora 9 X64, othervm mode
|
||||
sun/security/ssl/sanity/interop/ClientJSSEServerJSSE.java generic-all
|
||||
|
||||
# 7079203 sun/security/tools/keytool/printssl.sh fails on solaris with timeout
|
||||
sun/security/tools/keytool/printssl.sh solaris-all
|
||||
# 6988842: 4 tests failing on Solaris 5.10
|
||||
sun/security/pkcs11/Secmod/AddPrivateKey.java solaris-all
|
||||
sun/security/pkcs11/ec/ReadCertificates.java solaris-all
|
||||
sun/security/pkcs11/ec/ReadPKCS12.java solaris-all
|
||||
sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java solaris-all
|
||||
|
||||
# 7041639, Solaris DSA keypair generation bug (Note: jdk_util also affected)
|
||||
java/security/KeyPairGenerator/SolarisShortDSA.java solaris-all
|
||||
@ -348,6 +316,8 @@ sun/security/tools/keytool/standard.sh solaris-all
|
||||
|
||||
# jdk_text
|
||||
|
||||
# 7196199
|
||||
java/text/Bidi/Bug6665028.java generic-all
|
||||
############################################################################
|
||||
|
||||
# jdk_tools
|
||||
|
@ -195,7 +195,7 @@ public class PaddingTest {
|
||||
|
||||
private static void diff(String fname1, String fname2) throws Exception {
|
||||
if (!Arrays.equals(Files.readAllBytes(Paths.get(fname1)),
|
||||
Files.readAllBytes(Paths.get(fname1)))) {
|
||||
Files.readAllBytes(Paths.get(fname2)))) {
|
||||
throw new Exception(
|
||||
"files " + fname1 + " and " + fname2 + " differ");
|
||||
}
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 5086470 6358247
|
||||
* @bug 5086470 6358247 7193302
|
||||
* @summary Test type conversion when invoking ThreadMXBean.dumpAllThreads
|
||||
* through proxy.
|
||||
*
|
||||
@ -173,6 +173,10 @@ public class ThreadMXBeanProxy {
|
||||
throw new RuntimeException("LockInfo: " + syncs[0] +
|
||||
" IdentityHashCode not matched. Expected: " + hcode);
|
||||
}
|
||||
LockInfo li = info.getLockInfo();
|
||||
if (li == null) {
|
||||
throw new RuntimeException("Expected non-null LockInfo");
|
||||
}
|
||||
}
|
||||
}
|
||||
static class Mutex implements Lock, java.io.Serializable {
|
||||
|
@ -48,7 +48,7 @@ public class CollectionUsageThreshold {
|
||||
private static Map<String, PoolRecord> result = new HashMap<>();
|
||||
private static boolean trace = false;
|
||||
private static boolean testFailed = false;
|
||||
private static final int EXPECTED_NUM_POOLS = 2;
|
||||
private static int numMemoryPools = 1;
|
||||
private static final int NUM_GCS = 3;
|
||||
private static final int THRESHOLD = 10;
|
||||
private static Checker checker;
|
||||
@ -129,14 +129,19 @@ public class CollectionUsageThreshold {
|
||||
for (MemoryPoolMXBean p : pools) {
|
||||
MemoryUsage u = p.getUsage();
|
||||
if (p.isUsageThresholdSupported() && p.isCollectionUsageThresholdSupported()) {
|
||||
if (p.getName().toLowerCase().contains("perm")) {
|
||||
// if we have a "perm gen" pool increase the number of expected
|
||||
// memory pools by one.
|
||||
numMemoryPools++;
|
||||
}
|
||||
PoolRecord pr = new PoolRecord(p);
|
||||
result.put(p.getName(), pr);
|
||||
if (result.size() == EXPECTED_NUM_POOLS) {
|
||||
if (result.size() == numMemoryPools) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (result.size() != EXPECTED_NUM_POOLS) {
|
||||
if (result.size() != numMemoryPools) {
|
||||
throw new RuntimeException("Unexpected number of selected pools");
|
||||
}
|
||||
|
||||
@ -209,7 +214,7 @@ public class CollectionUsageThreshold {
|
||||
public void run() {
|
||||
while (true) {
|
||||
try {
|
||||
signals.acquire(EXPECTED_NUM_POOLS);
|
||||
signals.acquire(numMemoryPools);
|
||||
checkResult();
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
|
@ -58,8 +58,11 @@ public class MemoryTest {
|
||||
// They are: Copy/Scavenger + MSC + CodeCache manager
|
||||
// (or equivalent for other collectors)
|
||||
// Number of GC memory managers = 2
|
||||
private static int[] expectedMinNumPools = {3, 2};
|
||||
private static int[] expectedMaxNumPools = {3, 4};
|
||||
|
||||
// Hotspot VM 1.8+ after perm gen removal is expected to have only
|
||||
// one non-heap memory pool
|
||||
private static int[] expectedMinNumPools = {3, 1};
|
||||
private static int[] expectedMaxNumPools = {3, 1};
|
||||
private static int expectedNumGCMgrs = 2;
|
||||
private static int expectedNumMgrs = expectedNumGCMgrs + 1;
|
||||
private static String[] types = { "heap", "non-heap" };
|
||||
@ -80,6 +83,7 @@ public class MemoryTest {
|
||||
|
||||
private static void checkMemoryPools() throws Exception {
|
||||
List pools = ManagementFactory.getMemoryPoolMXBeans();
|
||||
boolean hasPerm = false;
|
||||
|
||||
int[] numPools = new int[NUM_TYPES];
|
||||
for (ListIterator iter = pools.listIterator(); iter.hasNext();) {
|
||||
@ -90,6 +94,16 @@ public class MemoryTest {
|
||||
if (pool.getType() == MemoryType.NON_HEAP) {
|
||||
numPools[NONHEAP]++;
|
||||
}
|
||||
if (pool.getName().toLowerCase().contains("perm")) {
|
||||
hasPerm = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasPerm) {
|
||||
// If the VM has perm gen there will be between 2 and 4 non heap
|
||||
// pools (4 if class data sharing is used)
|
||||
expectedMinNumPools[NONHEAP] = 2;
|
||||
expectedMaxNumPools[NONHEAP] = 4;
|
||||
}
|
||||
|
||||
// Check the number of Memory pools
|
||||
|
@ -25,7 +25,7 @@
|
||||
* @test
|
||||
* @bug 4678055
|
||||
* @library ../../../sun/net/www/httptest/
|
||||
* @build HttpCallback HttpServer ClosedChannelList HttpTransaction
|
||||
* @build HttpCallback TestHttpServer ClosedChannelList HttpTransaction
|
||||
* @run main B4678055
|
||||
* @summary Basic Authentication fails with multiple realms
|
||||
*/
|
||||
@ -119,13 +119,13 @@ public class B4678055 implements HttpCallback {
|
||||
is.close();
|
||||
}
|
||||
|
||||
static HttpServer server;
|
||||
static TestHttpServer server;
|
||||
|
||||
public static void main (String[] args) throws Exception {
|
||||
MyAuthenticator auth = new MyAuthenticator ();
|
||||
Authenticator.setDefault (auth);
|
||||
try {
|
||||
server = new HttpServer (new B4678055(), 1, 10, 0);
|
||||
server = new TestHttpServer (new B4678055(), 1, 10, 0);
|
||||
System.out.println ("Server: listening on port: " + server.getLocalPort());
|
||||
client ("http://localhost:"+server.getLocalPort()+"/d1/foo.html");
|
||||
client ("http://localhost:"+server.getLocalPort()+"/d2/foo.html");
|
||||
|
@ -25,7 +25,7 @@
|
||||
* @test
|
||||
* @bug 4722333
|
||||
* @library ../../../sun/net/www/httptest/
|
||||
* @build HttpCallback HttpServer ClosedChannelList HttpTransaction
|
||||
* @build HttpCallback TestHttpServer ClosedChannelList HttpTransaction
|
||||
* @run main B4722333
|
||||
* @summary JRE Proxy Authentication Not Working with ISA2000
|
||||
*/
|
||||
@ -114,13 +114,13 @@ public class B4722333 implements HttpCallback {
|
||||
is.close();
|
||||
}
|
||||
|
||||
static HttpServer server;
|
||||
static TestHttpServer server;
|
||||
|
||||
public static void main (String[] args) throws Exception {
|
||||
MyAuthenticator auth = new MyAuthenticator ();
|
||||
Authenticator.setDefault (auth);
|
||||
try {
|
||||
server = new HttpServer (new B4722333(), 1, 10, 0);
|
||||
server = new TestHttpServer (new B4722333(), 1, 10, 0);
|
||||
System.out.println ("Server started: listening on port: " + server.getLocalPort());
|
||||
client ("http://localhost:"+server.getLocalPort()+"/d1/d2/d3/foo.html");
|
||||
client ("http://localhost:"+server.getLocalPort()+"/ASD/d3/x.html");
|
||||
|
@ -25,7 +25,7 @@
|
||||
* @test
|
||||
* @bug 4759514
|
||||
* @library ../../../sun/net/www/httptest/
|
||||
* @build HttpCallback HttpServer ClosedChannelList HttpTransaction
|
||||
* @build HttpCallback TestHttpServer ClosedChannelList HttpTransaction
|
||||
* @run main B4759514
|
||||
* @summary Digest Authentication is erroniously quoting the nc value, contrary to RFC 2617
|
||||
*/
|
||||
@ -91,13 +91,13 @@ public class B4759514 implements HttpCallback {
|
||||
is.close();
|
||||
}
|
||||
|
||||
static HttpServer server;
|
||||
static TestHttpServer server;
|
||||
|
||||
public static void main (String[] args) throws Exception {
|
||||
MyAuthenticator auth = new MyAuthenticator ();
|
||||
Authenticator.setDefault (auth);
|
||||
try {
|
||||
server = new HttpServer (new B4759514(), 1, 10, 0);
|
||||
server = new TestHttpServer (new B4759514(), 1, 10, 0);
|
||||
System.out.println ("Server: listening on port: " + server.getLocalPort());
|
||||
client ("http://localhost:"+server.getLocalPort()+"/d1/foo.html");
|
||||
} catch (Exception e) {
|
||||
|
@ -25,7 +25,7 @@
|
||||
* @test
|
||||
* @bug 4769350
|
||||
* @library ../../../sun/net/www/httptest/
|
||||
* @build HttpCallback HttpServer ClosedChannelList HttpTransaction AbstractCallback
|
||||
* @build HttpCallback TestHttpServer ClosedChannelList HttpTransaction AbstractCallback
|
||||
* @run main/othervm B4769350 server
|
||||
* @run main/othervm B4769350 proxy
|
||||
* @summary proxy authentication username and password caching only works in serial case
|
||||
@ -142,10 +142,10 @@ public class B4769350 {
|
||||
switch (count) {
|
||||
case 0:
|
||||
errorReply (req, "Basic realm=\"realm1\"");
|
||||
HttpServer.rendezvous ("one", 2);
|
||||
TestHttpServer.rendezvous ("one", 2);
|
||||
break;
|
||||
case 1:
|
||||
HttpServer.waitForCondition ("cond2");
|
||||
TestHttpServer.waitForCondition ("cond2");
|
||||
okReply (req);
|
||||
break;
|
||||
default:
|
||||
@ -158,11 +158,11 @@ public class B4769350 {
|
||||
switch (count) {
|
||||
case 0:
|
||||
errorReply (req, "Basic realm=\"realm2\"");
|
||||
HttpServer.rendezvous ("one", 2);
|
||||
HttpServer.setCondition ("cond1");
|
||||
TestHttpServer.rendezvous ("one", 2);
|
||||
TestHttpServer.setCondition ("cond1");
|
||||
break;
|
||||
case 1:
|
||||
HttpServer.waitForCondition ("cond2");
|
||||
TestHttpServer.waitForCondition ("cond2");
|
||||
okReply (req);
|
||||
break;
|
||||
default:
|
||||
@ -174,7 +174,7 @@ public class B4769350 {
|
||||
switch (count) {
|
||||
case 0:
|
||||
errorReply (req, "Basic realm=\"realm1\"");
|
||||
HttpServer.rendezvous ("two", 2);
|
||||
TestHttpServer.rendezvous ("two", 2);
|
||||
break;
|
||||
case 1:
|
||||
okReply (req);
|
||||
@ -188,8 +188,8 @@ public class B4769350 {
|
||||
switch (count) {
|
||||
case 0:
|
||||
errorReply (req, "Basic realm=\"realm2\"");
|
||||
HttpServer.rendezvous ("two", 2);
|
||||
HttpServer.setCondition ("cond2");
|
||||
TestHttpServer.rendezvous ("two", 2);
|
||||
TestHttpServer.setCondition ("cond2");
|
||||
break;
|
||||
case 1:
|
||||
okReply (req);
|
||||
@ -207,7 +207,7 @@ public class B4769350 {
|
||||
void doT2a (HttpTransaction req, int count) throws IOException {
|
||||
/* This will be called several times */
|
||||
if (count == 1) {
|
||||
HttpServer.setCondition ("T2cond1");
|
||||
TestHttpServer.setCondition ("T2cond1");
|
||||
}
|
||||
errorReply (req, "Basic realm=\"realm3\"");
|
||||
}
|
||||
@ -233,7 +233,7 @@ public class B4769350 {
|
||||
switch (count) {
|
||||
case 0:
|
||||
proxyReply (req, "Basic realm=\"proxy\"");
|
||||
HttpServer.setCondition ("T3cond1");
|
||||
TestHttpServer.setCondition ("T3cond1");
|
||||
break;
|
||||
case 1:
|
||||
errorReply (req, "Basic realm=\"realm4\"");
|
||||
@ -260,7 +260,7 @@ public class B4769350 {
|
||||
}
|
||||
};
|
||||
|
||||
static HttpServer server;
|
||||
static TestHttpServer server;
|
||||
static MyAuthenticator auth = new MyAuthenticator ();
|
||||
|
||||
static int redirects = 4;
|
||||
@ -276,7 +276,7 @@ public class B4769350 {
|
||||
c4 = new Client (authority, "/test/realm2/t1d", false);
|
||||
|
||||
c1.start(); c2.start();
|
||||
HttpServer.waitForCondition ("cond1");
|
||||
TestHttpServer.waitForCondition ("cond1");
|
||||
c3.start(); c4.start();
|
||||
c1.join(); c2.join(); c3.join(); c4.join();
|
||||
|
||||
@ -294,7 +294,7 @@ public class B4769350 {
|
||||
c5 = new Client (authority, "/test/realm3/t2a", true);
|
||||
c6 = new Client (authority, "/test/realm3/t2b", false);
|
||||
c5.start ();
|
||||
HttpServer.waitForCondition ("T2cond1");
|
||||
TestHttpServer.waitForCondition ("T2cond1");
|
||||
c6.start ();
|
||||
c5.join(); c6.join();
|
||||
|
||||
@ -313,7 +313,7 @@ public class B4769350 {
|
||||
c8 = new Client (authority, "/test/realm4/t3b", false);
|
||||
c9 = new Client (authority, "/test/realm4/t3c", false);
|
||||
c7.start ();
|
||||
HttpServer.waitForCondition ("T3cond1");
|
||||
TestHttpServer.waitForCondition ("T3cond1");
|
||||
c8.start ();
|
||||
c9.start ();
|
||||
c7.join(); c8.join(); c9.join();
|
||||
@ -333,7 +333,7 @@ public class B4769350 {
|
||||
Authenticator.setDefault (auth);
|
||||
boolean proxy = args[0].equals ("proxy");
|
||||
try {
|
||||
server = new HttpServer (new CallBack(), 10, 1, 0);
|
||||
server = new TestHttpServer (new CallBack(), 10, 1, 0);
|
||||
System.out.println ("Server: listening on port: " + server.getLocalPort());
|
||||
if (proxy) {
|
||||
System.setProperty ("http.proxyHost", "localhost");
|
||||
|
@ -25,7 +25,7 @@
|
||||
* @test
|
||||
* @bug 4921848
|
||||
* @library ../../../sun/net/www/httptest/
|
||||
* @build HttpCallback HttpServer ClosedChannelList HttpTransaction
|
||||
* @build HttpCallback TestHttpServer ClosedChannelList HttpTransaction
|
||||
* @run main/othervm -Dhttp.auth.preference=basic B4921848
|
||||
* @summary Allow user control over authentication schemes
|
||||
*/
|
||||
@ -82,13 +82,13 @@ public class B4921848 implements HttpCallback {
|
||||
is.close();
|
||||
}
|
||||
|
||||
static HttpServer server;
|
||||
static TestHttpServer server;
|
||||
|
||||
public static void main (String[] args) throws Exception {
|
||||
MyAuthenticator auth = new MyAuthenticator ();
|
||||
Authenticator.setDefault (auth);
|
||||
try {
|
||||
server = new HttpServer (new B4921848(), 1, 10, 0);
|
||||
server = new TestHttpServer (new B4921848(), 1, 10, 0);
|
||||
System.out.println ("Server started: listening on port: " + server.getLocalPort());
|
||||
client ("http://localhost:"+server.getLocalPort()+"/d1/d2/d3/foo.html");
|
||||
} catch (Exception e) {
|
||||
|
@ -119,7 +119,7 @@ public class B4933582 implements HttpCallback {
|
||||
is.close();
|
||||
}
|
||||
|
||||
static HttpServer server;
|
||||
static TestHttpServer server;
|
||||
|
||||
public static void main (String[] args) throws Exception {
|
||||
firstTime = args[0].equals ("first");
|
||||
@ -128,11 +128,11 @@ public class B4933582 implements HttpCallback {
|
||||
CacheImpl cache;
|
||||
try {
|
||||
if (firstTime) {
|
||||
server = new HttpServer (new B4933582(), 1, 10, 0);
|
||||
server = new TestHttpServer (new B4933582(), 1, 10, 0);
|
||||
cache = new CacheImpl (server.getLocalPort());
|
||||
} else {
|
||||
cache = new CacheImpl ();
|
||||
server = new HttpServer(new B4933582(), 1, 10, cache.getPort());
|
||||
server = new TestHttpServer(new B4933582(), 1, 10, cache.getPort());
|
||||
}
|
||||
AuthCacheValue.setAuthCache (cache);
|
||||
System.out.println ("Server: listening on port: " + server.getLocalPort());
|
||||
|
@ -25,7 +25,7 @@
|
||||
* @test
|
||||
* @bug 4962064
|
||||
* @library ../../../sun/net/www/httptest/
|
||||
* @build HttpCallback HttpServer ClosedChannelList HttpTransaction
|
||||
* @build HttpCallback TestHttpServer ClosedChannelList HttpTransaction
|
||||
* @run main/othervm B4962064
|
||||
* @summary Extend Authenticator to provide access to request URI and server/proxy
|
||||
*/
|
||||
@ -85,12 +85,12 @@ public class B4962064 implements HttpCallback {
|
||||
is.close();
|
||||
}
|
||||
|
||||
static HttpServer server;
|
||||
static TestHttpServer server;
|
||||
static URL urlsave;
|
||||
|
||||
public static void main (String[] args) throws Exception {
|
||||
try {
|
||||
server = new HttpServer (new B4962064(), 1, 10, 0);
|
||||
server = new TestHttpServer (new B4962064(), 1, 10, 0);
|
||||
int port = server.getLocalPort();
|
||||
System.setProperty ("http.proxyHost", "localhost");
|
||||
System.setProperty ("http.proxyPort", Integer.toString (port));
|
||||
|
@ -26,7 +26,7 @@
|
||||
* @summary Unit test for java.net.CookieManager
|
||||
* @bug 6244040
|
||||
* @library ../../../sun/net/www/httptest/
|
||||
* @build HttpCallback HttpServer ClosedChannelList HttpTransaction
|
||||
* @build HttpCallback TestHttpServer ClosedChannelList HttpTransaction
|
||||
* @run main/othervm -ea CookieManagerTest
|
||||
* @author Edward Wang
|
||||
*/
|
||||
@ -38,7 +38,7 @@ import sun.net.www.MessageHeader;
|
||||
|
||||
public class CookieManagerTest {
|
||||
static CookieHttpTransaction httpTrans;
|
||||
static HttpServer server;
|
||||
static TestHttpServer server;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
startHttpServer();
|
||||
@ -52,7 +52,7 @@ public class CookieManagerTest {
|
||||
public static void startHttpServer() {
|
||||
try {
|
||||
httpTrans = new CookieHttpTransaction();
|
||||
server = new HttpServer(httpTrans, 1, 1, 0);
|
||||
server = new TestHttpServer(httpTrans, 1, 1, 0);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -41,14 +41,13 @@ public class GetLocalHostWithSM {
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
// try setting the local hostname
|
||||
try {
|
||||
System.setProperty("host.name", InetAddress.
|
||||
getLocalHost().
|
||||
getHostName());
|
||||
} catch (UnknownHostException e) {
|
||||
System.out.println("Cannot find the local hostname, " +
|
||||
"no nameserver entry found");
|
||||
InetAddress localHost = InetAddress.getLocalHost();
|
||||
if (localHost.isLoopbackAddress()) {
|
||||
System.err.println("Local host name is resolved into a loopback address. Quit now!");
|
||||
return;
|
||||
}
|
||||
System.setProperty("host.name", localHost.
|
||||
getHostName());
|
||||
String policyFileName = System.getProperty("test.src", ".") +
|
||||
"/" + "policy.file";
|
||||
System.setProperty("java.security.policy", policyFileName);
|
||||
@ -66,6 +65,7 @@ public class GetLocalHostWithSM {
|
||||
new MyAction(), null);
|
||||
|
||||
if (localHost1.equals(localHost2)) {
|
||||
System.out.println("localHost1 = " + localHost1);
|
||||
throw new RuntimeException("InetAddress.getLocalHost() test " +
|
||||
" fails. localHost2 should be " +
|
||||
" the real address instead of " +
|
||||
|
@ -25,7 +25,7 @@
|
||||
* @bug 4924226
|
||||
* @summary PIT: Can no launch jnlp application via 127.0.0.1 address on the web server
|
||||
* @library ../../../sun/net/www/httptest/
|
||||
* @build ClosedChannelList HttpServer HttpTransaction HttpCallback
|
||||
* @build ClosedChannelList TestHttpServer HttpTransaction HttpCallback
|
||||
* @compile LoopbackAddresses.java
|
||||
* @run main/othervm LoopbackAddresses
|
||||
*/
|
||||
@ -39,7 +39,7 @@ import java.io.*;
|
||||
*/
|
||||
|
||||
public class LoopbackAddresses implements HttpCallback {
|
||||
static HttpServer server;
|
||||
static TestHttpServer server;
|
||||
|
||||
public void request (HttpTransaction req) {
|
||||
req.setResponseEntityBody ("Hello .");
|
||||
@ -52,7 +52,7 @@ public class LoopbackAddresses implements HttpCallback {
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
server = new HttpServer (new LoopbackAddresses(), 1, 10, 0);
|
||||
server = new TestHttpServer (new LoopbackAddresses(), 1, 10, 0);
|
||||
ProxyServer pserver = new ProxyServer(InetAddress.getByName("localhost"), server.getLocalPort());
|
||||
// start proxy server
|
||||
new Thread(pserver).start();
|
||||
|
@ -26,7 +26,7 @@
|
||||
* @bug 4696512
|
||||
* @summary HTTP client: Improve proxy server configuration and selection
|
||||
* @library ../../../sun/net/www/httptest/
|
||||
* @build ClosedChannelList HttpServer HttpTransaction HttpCallback
|
||||
* @build ClosedChannelList TestHttpServer HttpTransaction HttpCallback
|
||||
* @compile ProxyTest.java
|
||||
* @run main/othervm -Dhttp.proxyHost=inexistant -Dhttp.proxyPort=8080 ProxyTest
|
||||
*/
|
||||
@ -36,7 +36,7 @@ import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ProxyTest implements HttpCallback {
|
||||
static HttpServer server;
|
||||
static TestHttpServer server;
|
||||
|
||||
public ProxyTest() {
|
||||
}
|
||||
@ -74,7 +74,7 @@ public class ProxyTest implements HttpCallback {
|
||||
throw new RuntimeException("Default ProxySelector is null");
|
||||
ProxySelector.setDefault(new MyProxySelector());
|
||||
try {
|
||||
server = new HttpServer (new ProxyTest(), 1, 10, 0);
|
||||
server = new TestHttpServer (new ProxyTest(), 1, 10, 0);
|
||||
URL url = new URL("http://localhost:"+server.getLocalPort());
|
||||
System.out.println ("client opening connection to: " + url);
|
||||
HttpURLConnection urlc = (HttpURLConnection)url.openConnection ();
|
||||
|
@ -25,7 +25,7 @@
|
||||
* @bug 4920526
|
||||
* @summary Needs per connection proxy support for URLs
|
||||
* @library ../../../sun/net/www/httptest/
|
||||
* @build ClosedChannelList HttpServer HttpTransaction HttpCallback
|
||||
* @build ClosedChannelList TestHttpServer HttpTransaction HttpCallback
|
||||
* @compile PerConnectionProxy.java
|
||||
* @run main/othervm -Dhttp.proxyHost=inexistant -Dhttp.proxyPort=8080 PerConnectionProxy
|
||||
*/
|
||||
@ -35,7 +35,7 @@ import java.io.*;
|
||||
import sun.net.www.*;
|
||||
|
||||
public class PerConnectionProxy implements HttpCallback {
|
||||
static HttpServer server;
|
||||
static TestHttpServer server;
|
||||
|
||||
public void request (HttpTransaction req) {
|
||||
req.setResponseEntityBody ("Hello .");
|
||||
@ -48,7 +48,7 @@ public class PerConnectionProxy implements HttpCallback {
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
server = new HttpServer (new PerConnectionProxy(), 1, 10, 0);
|
||||
server = new TestHttpServer (new PerConnectionProxy(), 1, 10, 0);
|
||||
ProxyServer pserver = new ProxyServer(InetAddress.getByName("localhost"), server.getLocalPort());
|
||||
// start proxy server
|
||||
new Thread(pserver).start();
|
||||
|
@ -128,7 +128,7 @@ public class CloseTest extends Common {
|
||||
// load tests
|
||||
loadClass ("com.foo.TestClass1", loader, false);
|
||||
loadClass ("com.foo.TestClass", loader, true);
|
||||
loadClass ("java.awt.Button", loader, true);
|
||||
loadClass ("java.sql.Array", loader, true);
|
||||
|
||||
// now check we can delete the path
|
||||
rm_minus_rf (new File(name));
|
||||
|
@ -25,7 +25,7 @@
|
||||
* @test
|
||||
* @bug 5052093
|
||||
* @library ../../../sun/net/www/httptest/
|
||||
* @build HttpCallback HttpServer ClosedChannelList HttpTransaction
|
||||
* @build HttpCallback TestHttpServer ClosedChannelList HttpTransaction
|
||||
* @run main B5052093
|
||||
* @summary URLConnection doesn't support large files
|
||||
*/
|
||||
@ -34,7 +34,7 @@ import java.io.*;
|
||||
import sun.net.www.protocol.file.FileURLConnection;
|
||||
|
||||
public class B5052093 implements HttpCallback {
|
||||
private static HttpServer server;
|
||||
private static TestHttpServer server;
|
||||
private static long testSize = ((long) (Integer.MAX_VALUE)) + 2;
|
||||
|
||||
public static class LargeFile extends File {
|
||||
@ -63,7 +63,7 @@ public class B5052093 implements HttpCallback {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
server = new HttpServer(new B5052093(), 1, 10, 0);
|
||||
server = new TestHttpServer(new B5052093(), 1, 10, 0);
|
||||
try {
|
||||
URL url = new URL("http://localhost:"+server.getLocalPort()+"/foo");
|
||||
URLConnection conn = url.openConnection();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 2012, 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,17 +22,24 @@
|
||||
*/
|
||||
|
||||
/* @test
|
||||
* @bug 4460583 4470470 4840199 6419424 6710579 6596323 6824135 6395224
|
||||
* @bug 4460583 4470470 4840199 6419424 6710579 6596323 6824135 6395224 7142919
|
||||
* @run main/othervm AsyncCloseAndInterrupt
|
||||
* @summary Comprehensive test of asynchronous closing and interruption
|
||||
* @author Mark Reinhold
|
||||
*/
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.nio.*;
|
||||
import java.nio.channels.*;
|
||||
import java.util.*;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class AsyncCloseAndInterrupt {
|
||||
|
||||
@ -79,45 +86,12 @@ public class AsyncCloseAndInterrupt {
|
||||
// Server socket that refuses all connections
|
||||
|
||||
static ServerSocketChannel refuser;
|
||||
static List refuserClients = new ArrayList();
|
||||
|
||||
private static void initRefuser() throws IOException {
|
||||
refuser = ServerSocketChannel.open();
|
||||
refuser.socket().bind(wildcardAddress);
|
||||
pumpRefuser("Initializing refuser...");
|
||||
}
|
||||
|
||||
private static void pumpRefuser(String msg) throws IOException {
|
||||
// Can't reliably saturate connection backlog on Windows Server editions
|
||||
assert !TestUtil.onWindows();
|
||||
|
||||
log.print(msg);
|
||||
int n = refuserClients.size();
|
||||
|
||||
// Saturate the refuser's connection backlog so that further connection
|
||||
// attempts will block
|
||||
//
|
||||
outer:
|
||||
for (;;) {
|
||||
SocketChannel sc = SocketChannel.open();
|
||||
sc.configureBlocking(false);
|
||||
if (!sc.connect(refuser.socket().getLocalSocketAddress())) {
|
||||
for (int i = 0; i < 20; i++) {
|
||||
Thread.yield();
|
||||
if (sc.finishConnect())
|
||||
break;
|
||||
if (i >= 19)
|
||||
break outer;
|
||||
}
|
||||
}
|
||||
// Retain so that finalizer doesn't close
|
||||
refuserClients.add(sc);
|
||||
}
|
||||
|
||||
log.println(" " + (refuserClients.size() - n) + " connections");
|
||||
}
|
||||
|
||||
|
||||
// Dead pipe source and sink
|
||||
|
||||
static Pipe.SourceChannel deadSource;
|
||||
@ -374,8 +348,8 @@ public class AsyncCloseAndInterrupt {
|
||||
};
|
||||
|
||||
static final Op CONNECT = new Op("connect") {
|
||||
void setup() throws IOException {
|
||||
pumpRefuser("Pumping refuser ...");
|
||||
void setup() {
|
||||
waitPump("connect wait for pumping refuser ...");
|
||||
}
|
||||
void doIO(InterruptibleChannel ich) throws IOException {
|
||||
SocketChannel sc = (SocketChannel)ich;
|
||||
@ -386,8 +360,8 @@ public class AsyncCloseAndInterrupt {
|
||||
};
|
||||
|
||||
static final Op FINISH_CONNECT = new Op("finishConnect") {
|
||||
void setup() throws IOException {
|
||||
pumpRefuser("Pumping refuser ...");
|
||||
void setup() {
|
||||
waitPump("finishConnect wait for pumping refuser ...");
|
||||
}
|
||||
void doIO(InterruptibleChannel ich) throws IOException {
|
||||
SocketChannel sc = (SocketChannel)ich;
|
||||
@ -462,6 +436,7 @@ public class AsyncCloseAndInterrupt {
|
||||
this.test = test;
|
||||
}
|
||||
|
||||
@SuppressWarnings("fallthrough")
|
||||
private void caught(Channel ch, IOException x) {
|
||||
String xn = x.getClass().getName();
|
||||
switch (test) {
|
||||
@ -519,9 +494,63 @@ public class AsyncCloseAndInterrupt {
|
||||
|
||||
}
|
||||
|
||||
private static volatile boolean pumpDone = false;
|
||||
private static volatile boolean pumpReady = false;
|
||||
|
||||
// Tests
|
||||
private static void waitPump(String msg){
|
||||
pumpReady = false;
|
||||
log.println(msg);
|
||||
|
||||
while (!pumpReady){
|
||||
sleep(200);
|
||||
}
|
||||
}
|
||||
|
||||
// Create a pump thread dedicated to saturate refuser's connection backlog
|
||||
private static Future<Integer> pumpRefuser(ExecutorService pumperExecutor) {
|
||||
|
||||
Callable<Integer> pumpTask = new Callable<Integer>() {
|
||||
|
||||
@Override
|
||||
public Integer call() throws IOException {
|
||||
// Can't reliably saturate connection backlog on Windows Server editions
|
||||
assert !TestUtil.onWindows();
|
||||
log.println("Start pumping refuser ...");
|
||||
List<SocketChannel> refuserClients = new ArrayList<>();
|
||||
|
||||
// Saturate the refuser's connection backlog so that further connection
|
||||
// attempts will be blocked
|
||||
while (!pumpDone) {
|
||||
SocketChannel sc = SocketChannel.open();
|
||||
sc.configureBlocking(false);
|
||||
boolean connected = sc.connect(refuser.socket().getLocalSocketAddress());
|
||||
|
||||
// Assume that the connection backlog is saturated if a
|
||||
// client cannot connect to the refuser within 50 miliseconds
|
||||
long start = System.currentTimeMillis();
|
||||
while (!connected && (System.currentTimeMillis() - start < 50)) {
|
||||
connected = sc.finishConnect();
|
||||
}
|
||||
|
||||
if (connected) {
|
||||
// Retain so that finalizer doesn't close
|
||||
refuserClients.add(sc);
|
||||
pumpReady = false;
|
||||
} else {
|
||||
sc.close();
|
||||
pumpReady = true;
|
||||
}
|
||||
}
|
||||
|
||||
log.println("Stop pumping refuser ...");
|
||||
return refuserClients.size();
|
||||
}
|
||||
};
|
||||
|
||||
return pumperExecutor.submit(pumpTask);
|
||||
}
|
||||
|
||||
// Test
|
||||
static void test(ChannelFactory cf, Op op, int test)
|
||||
throws Exception
|
||||
{
|
||||
@ -667,15 +696,40 @@ public class AsyncCloseAndInterrupt {
|
||||
log.println("WARNING Cannot reliably test connect/finishConnect"
|
||||
+ " operations on Windows");
|
||||
} else {
|
||||
test(socketChannelFactory, CONNECT);
|
||||
test(socketChannelFactory, FINISH_CONNECT);
|
||||
// Only the following tests need refuser's connection backlog
|
||||
// to be saturated
|
||||
ExecutorService pumperExecutor =
|
||||
Executors.newSingleThreadExecutor(
|
||||
new ThreadFactory() {
|
||||
|
||||
@Override
|
||||
public Thread newThread(Runnable r) {
|
||||
Thread t = new Thread(r);
|
||||
t.setDaemon(true);
|
||||
t.setName("Pumper");
|
||||
return t;
|
||||
}
|
||||
});
|
||||
|
||||
pumpDone = false;
|
||||
try {
|
||||
Future<Integer> pumpFuture = pumpRefuser(pumperExecutor);
|
||||
waitPump("\nWait for initial Pump");
|
||||
|
||||
test(socketChannelFactory, CONNECT);
|
||||
test(socketChannelFactory, FINISH_CONNECT);
|
||||
|
||||
pumpDone = true;
|
||||
Integer newConn = pumpFuture.get(30, TimeUnit.SECONDS);
|
||||
log.println("Pump " + newConn + " connections.");
|
||||
} finally {
|
||||
pumperExecutor.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
test(serverSocketChannelFactory, ACCEPT);
|
||||
test(datagramChannelFactory);
|
||||
test(pipeSourceChannelFactory);
|
||||
test(pipeSinkChannelFactory);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2007, 2012, 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,11 +22,12 @@
|
||||
*/
|
||||
|
||||
import java.io.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
public class PropertiesTest {
|
||||
public static void main(String[] s) {
|
||||
public static void main(String[] s) throws Exception {
|
||||
for (int i = 0; i < s.length; i ++) {
|
||||
if ("-d".equals(s[i])) {
|
||||
i++;
|
||||
@ -76,7 +77,7 @@ public class PropertiesTest {
|
||||
pw.close();
|
||||
}
|
||||
|
||||
private static void compare(String beforeFile, String afterFile) {
|
||||
private static void compare(String beforeFile, String afterFile) throws Exception {
|
||||
// load file contents
|
||||
Properties before = new Properties();
|
||||
Properties after = new Properties();
|
||||
@ -114,11 +115,23 @@ public class PropertiesTest {
|
||||
// test each replacements
|
||||
keys = p.stringPropertyNames();
|
||||
Pattern propertiesPattern =
|
||||
Pattern.compile("([A-Z]{3})\\s*,\\s*(\\d{3})\\s*,\\s*([0-3])");
|
||||
Pattern.compile("([A-Z]{3})\\s*,\\s*(\\d{3})\\s*,\\s*" +
|
||||
"([0-3])\\s*,?\\s*(\\d{4}-\\d{2}-\\d{2}T\\d{2}:" +
|
||||
"\\d{2}:\\d{2})?");
|
||||
for (String key: keys) {
|
||||
String val = p.getProperty(key);
|
||||
try {
|
||||
if (countOccurrences(val, ',') == 3 && !isPastCutoverDate(val)) {
|
||||
System.out.println("Skipping since date is in future");
|
||||
continue; // skip since date in future (no effect)
|
||||
}
|
||||
} catch (ParseException pe) {
|
||||
// swallow - currency class should not honour this value
|
||||
continue;
|
||||
}
|
||||
String afterVal = after.getProperty(key);
|
||||
System.out.printf("Testing key: %s, val: %s... ", key, val);
|
||||
System.out.println("AfterVal is : " + afterVal);
|
||||
|
||||
Matcher m = propertiesPattern.matcher(val.toUpperCase(Locale.ROOT));
|
||||
if (!m.find()) {
|
||||
@ -131,7 +144,6 @@ public class PropertiesTest {
|
||||
// ignore this
|
||||
continue;
|
||||
}
|
||||
|
||||
Matcher mAfter = propertiesPattern.matcher(afterVal);
|
||||
mAfter.find();
|
||||
|
||||
@ -164,4 +176,29 @@ public class PropertiesTest {
|
||||
throw new RuntimeException(sb.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isPastCutoverDate(String s)
|
||||
throws IndexOutOfBoundsException, NullPointerException, ParseException {
|
||||
String dateString = s.substring(s.lastIndexOf(',')+1, s.length()).trim();
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.ROOT);
|
||||
format.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
format.setLenient(false);
|
||||
|
||||
long time = format.parse(dateString).getTime();
|
||||
if (System.currentTimeMillis() - time >= 0L) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static int countOccurrences(String value, char match) {
|
||||
int count = 0;
|
||||
for (char c : value.toCharArray()) {
|
||||
if (c == match) {
|
||||
++count;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# @test
|
||||
# @bug 6332666
|
||||
# @bug 6332666 7180362
|
||||
# @summary tests the capability of replacing the currency data with user
|
||||
# specified currency properties file
|
||||
# @build PropertiesTest
|
||||
|
@ -2,9 +2,19 @@
|
||||
# Test data for replacing the currency data
|
||||
#
|
||||
JP=JPZ,123,2
|
||||
US=euR,978,2
|
||||
ES=ESD,877,2
|
||||
US=euR,978,2,2001-01-01T00:00:00
|
||||
CM=IED,111,2, 2004-01-01T00:70:00
|
||||
SB=EUR,111,2, 2099-01-01T00:00:00
|
||||
ZZ = ZZZ , 999 , 3
|
||||
NO=EUR ,978 ,2, 2099-01-01T00:00:00
|
||||
|
||||
# invalid entries
|
||||
GB=123
|
||||
FR=zzzzz.123
|
||||
DE=2009-01-01T00:00:00,EUR,111,2
|
||||
IE=euR,111,2,#testcomment
|
||||
=euR,111,2, 2099-01-01-00-00-00
|
||||
FM=DED,194,2,eeee-01-01T00:00:00
|
||||
PE=EUR ,978 ,2, 20399-01-01T00:00:00
|
||||
MX=SSS,493,2,2001-01-01-00-00-00
|
||||
|
@ -24,6 +24,8 @@
|
||||
/*
|
||||
* @test
|
||||
* @bug 7126277
|
||||
* @run main Collisions -shortrun
|
||||
* @run main/othervm -Djdk.map.althashing.threshold=0 Collisions -shortrun
|
||||
* @summary Ensure Maps behave well with lots of hashCode() collisions.
|
||||
* @author Mike Duigou
|
||||
*/
|
||||
@ -33,6 +35,11 @@ import java.util.concurrent.ConcurrentSkipListMap;
|
||||
|
||||
public class Collisions {
|
||||
|
||||
/**
|
||||
* Number of elements per map.
|
||||
*/
|
||||
private static final int TEST_SIZE = 5000;
|
||||
|
||||
final static class HashableInteger implements Comparable<HashableInteger> {
|
||||
|
||||
final int value;
|
||||
@ -64,20 +71,19 @@ public class Collisions {
|
||||
return value - o.value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Integer.toString(value);
|
||||
}
|
||||
}
|
||||
private static final int ITEMS = 5000;
|
||||
private static final Object KEYS[][];
|
||||
|
||||
static {
|
||||
HashableInteger UNIQUE_OBJECTS[] = new HashableInteger[ITEMS];
|
||||
HashableInteger COLLIDING_OBJECTS[] = new HashableInteger[ITEMS];
|
||||
String UNIQUE_STRINGS[] = new String[ITEMS];
|
||||
String COLLIDING_STRINGS[] = new String[ITEMS];
|
||||
private static Object[][] makeTestData(int size) {
|
||||
HashableInteger UNIQUE_OBJECTS[] = new HashableInteger[size];
|
||||
HashableInteger COLLIDING_OBJECTS[] = new HashableInteger[size];
|
||||
String UNIQUE_STRINGS[] = new String[size];
|
||||
String COLLIDING_STRINGS[] = new String[size];
|
||||
|
||||
for (int i = 0; i < ITEMS; i++) {
|
||||
for (int i = 0; i < size; i++) {
|
||||
UNIQUE_OBJECTS[i] = new HashableInteger(i, Integer.MAX_VALUE);
|
||||
COLLIDING_OBJECTS[i] = new HashableInteger(i, 10);
|
||||
UNIQUE_STRINGS[i] = unhash(i);
|
||||
@ -86,7 +92,7 @@ public class Collisions {
|
||||
: "\u0000\u0000\u0000\u0000\u0000" + COLLIDING_STRINGS[i - 1];
|
||||
}
|
||||
|
||||
KEYS = new Object[][] {
|
||||
return new Object[][] {
|
||||
new Object[]{"Unique Objects", UNIQUE_OBJECTS},
|
||||
new Object[]{"Colliding Objects", COLLIDING_OBJECTS},
|
||||
new Object[]{"Unique Strings", UNIQUE_STRINGS},
|
||||
@ -132,23 +138,29 @@ public class Collisions {
|
||||
}
|
||||
|
||||
private static void realMain(String[] args) throws Throwable {
|
||||
for (Object[] keys_desc : KEYS) {
|
||||
Map<Object, Object>[] MAPS = (Map<Object, Object>[]) new Map[]{
|
||||
new Hashtable<>(),
|
||||
boolean shortRun = args.length > 0 && args[0].equals("-shortrun");
|
||||
|
||||
Object[][] mapKeys = makeTestData(shortRun ? (TEST_SIZE / 2) : TEST_SIZE);
|
||||
|
||||
// loop through data sets
|
||||
for (Object[] keys_desc : mapKeys) {
|
||||
Map<Object, Object>[] maps = (Map<Object, Object>[]) new Map[]{
|
||||
new HashMap<>(),
|
||||
new Hashtable<>(),
|
||||
new IdentityHashMap<>(),
|
||||
new LinkedHashMap<>(),
|
||||
new ConcurrentHashMap<>(),
|
||||
new WeakHashMap<>(),
|
||||
new TreeMap<>(),
|
||||
new WeakHashMap<>(),
|
||||
new ConcurrentHashMap<>(),
|
||||
new ConcurrentSkipListMap<>()
|
||||
};
|
||||
|
||||
for (Map<Object, Object> map : MAPS) {
|
||||
// for each map type.
|
||||
for (Map<Object, Object> map : maps) {
|
||||
String desc = (String) keys_desc[0];
|
||||
Object[] keys = (Object[]) keys_desc[1];
|
||||
try {
|
||||
testMap(map, desc, keys);
|
||||
testMap(map, desc, keys);
|
||||
} catch(Exception all) {
|
||||
unexpected("Failed for " + map.getClass().getName() + " with " + desc, all);
|
||||
}
|
||||
@ -397,7 +409,7 @@ public class Collisions {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Throwable {
|
||||
Thread.currentThread().setName("Collisions");
|
||||
Thread.currentThread().setName(Collisions.class.getName());
|
||||
// Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
|
||||
try {
|
||||
realMain(args);
|
||||
|
@ -45,7 +45,7 @@
|
||||
*
|
||||
* As usual with timing-sensitive tests, we could potentially get
|
||||
* sporadic failures. We fail if the ratio of the time with many
|
||||
* MBeans to the time with just one MBean is more than 100. With the
|
||||
* MBeans to the time with just one MBean is more than 500. With the
|
||||
* fix in place, it is usually less than 1, presumably because some
|
||||
* code was being interpreted during the first measurement but had
|
||||
* been compiled by the second.
|
||||
@ -176,7 +176,7 @@ public class ListenerScaleTest {
|
||||
long manyMBeansTime = timeNotif(mbs);
|
||||
System.out.println("Time with many MBeans: " + manyMBeansTime + "ns");
|
||||
double ratio = (double) manyMBeansTime / singleMBeanTime;
|
||||
if (ratio > 100.0)
|
||||
if (ratio > 500.0)
|
||||
throw new Exception("Failed: ratio=" + ratio);
|
||||
System.out.println("Test passed: ratio=" + ratio);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 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
|
||||
@ -21,75 +21,97 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* See ClassnameCharTest.sh for details.
|
||||
/* @test
|
||||
* @bug 4957669 5017871
|
||||
* @compile -XDignore.symbol.file=true ClassnameCharTest.java
|
||||
* @run main ClassnameCharTest
|
||||
* @summary cannot load class names containing some JSR 202 characters;
|
||||
* plugin does not escape unicode character in http request
|
||||
*/
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.security.*;
|
||||
import java.util.jar.*;
|
||||
import com.sun.net.httpserver.*;
|
||||
import sun.applet.AppletClassLoader;
|
||||
|
||||
public class ClassnameCharTest implements HttpCallback {
|
||||
private static String FNPrefix;
|
||||
private String[] respBody = new String[52];
|
||||
private byte[][] bufs = new byte[52][8*1024];
|
||||
private static MessageDigest md5;
|
||||
private static byte[] file1Mac, file2Mac;
|
||||
public void request (HttpTransaction req) {
|
||||
try {
|
||||
String filename = req.getRequestURI().getPath();
|
||||
System.out.println("getRequestURI = "+req.getRequestURI());
|
||||
System.out.println("filename = "+filename);
|
||||
FileInputStream fis = new FileInputStream(FNPrefix+filename);
|
||||
req.setResponseEntityBody(fis);
|
||||
req.sendResponse(200, "OK");
|
||||
req.orderlyClose();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public class ClassnameCharTest {
|
||||
static String FNPrefix = System.getProperty("test.src", ".") + File.separator;
|
||||
static File classesJar = new File(FNPrefix + "testclasses.jar");
|
||||
static HttpServer server;
|
||||
|
||||
public static void test () throws Exception {
|
||||
public static void realMain(String[] args) throws Exception {
|
||||
server = HttpServer.create(new InetSocketAddress(0), 0);
|
||||
server.createContext("/", new HttpHandler() {
|
||||
@Override
|
||||
public void handle(HttpExchange exchange) {
|
||||
try {
|
||||
String filename = exchange.getRequestURI().getPath();
|
||||
System.out.println("getRequestURI = " + exchange.getRequestURI());
|
||||
System.out.println("filename = " + filename);
|
||||
try (FileInputStream fis = new FileInputStream(classesJar);
|
||||
JarInputStream jis = new JarInputStream(fis)) {
|
||||
JarEntry entry;
|
||||
while ((entry = jis.getNextJarEntry()) != null) {
|
||||
if (filename.endsWith(entry.getName())) {
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
byte[] buf = new byte[8092];
|
||||
int count = 0;
|
||||
while ((count = jis.read(buf)) != -1)
|
||||
baos.write(buf, 0, count);
|
||||
exchange.sendResponseHeaders(200, baos.size());
|
||||
try (OutputStream os = exchange.getResponseBody()) {
|
||||
baos.writeTo(os);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
fail("Failed to find " + filename);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
unexpected(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
server.start();
|
||||
try {
|
||||
|
||||
FNPrefix = System.getProperty("test.classes", ".")+"/";
|
||||
server = new HttpServer (new ClassnameCharTest(), 1, 10, 0);
|
||||
System.out.println ("Server: listening on port: " + server.getLocalPort());
|
||||
URL base = new URL("http://localhost:"+server.getLocalPort());
|
||||
URL base = new URL("http://localhost:" + server.getAddress().getPort());
|
||||
System.out.println ("Server: listening on " + base);
|
||||
MyAppletClassLoader acl = new MyAppletClassLoader(base);
|
||||
Class class1 = acl.findClass("fo o");
|
||||
System.out.println("class1 = "+class1);
|
||||
Class<?> class1 = acl.findClass("fo o");
|
||||
System.out.println("class1 = " + class1);
|
||||
pass();
|
||||
// can't test the following class unless platform in unicode locale
|
||||
// Class class2 = acl.findClass("\u624b\u518c");
|
||||
// System.out.println("class2 = "+class2);
|
||||
} catch (Exception e) {
|
||||
if (server != null) {
|
||||
server.terminate();
|
||||
}
|
||||
throw e;
|
||||
} finally {
|
||||
server.stop(0);
|
||||
}
|
||||
}
|
||||
|
||||
static class MyAppletClassLoader extends AppletClassLoader {
|
||||
MyAppletClassLoader(URL base) {
|
||||
super(base);
|
||||
}
|
||||
|
||||
server.terminate();
|
||||
@Override
|
||||
public Class<?> findClass(String name) throws ClassNotFoundException {
|
||||
return super.findClass(name);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
test();
|
||||
}
|
||||
|
||||
public static void except (String s) {
|
||||
server.terminate();
|
||||
throw new RuntimeException (s);
|
||||
}
|
||||
}
|
||||
|
||||
class MyAppletClassLoader extends AppletClassLoader {
|
||||
MyAppletClassLoader(URL base) {
|
||||
super(base);
|
||||
}
|
||||
|
||||
public Class findClass(String name) throws ClassNotFoundException {
|
||||
return super.findClass(name);
|
||||
}
|
||||
//--------------------- Infrastructure ---------------------------
|
||||
static volatile int passed = 0, failed = 0;
|
||||
static boolean pass() {passed++; return true;}
|
||||
static boolean fail() {failed++; server.stop(0); Thread.dumpStack(); return false;}
|
||||
static boolean fail(String msg) {System.out.println(msg); return fail();}
|
||||
static void unexpected(Throwable t) {failed++; server.stop(0); t.printStackTrace();}
|
||||
static boolean check(boolean cond) {if (cond) pass(); else fail(); return cond;}
|
||||
static boolean equal(Object x, Object y) {
|
||||
if (x == null ? y == null : x.equals(y)) return pass();
|
||||
else return fail(x + " not equal to " + y);}
|
||||
public static void main(String[] args) throws Throwable {
|
||||
try {realMain(args);} catch (Throwable t) {unexpected(t);}
|
||||
System.out.println("\nPassed = " + passed + " failed = " + failed);
|
||||
if (failed > 0) throw new AssertionError("Some tests failed");}
|
||||
}
|
||||
|
@ -1,60 +0,0 @@
|
||||
#! /bin/sh
|
||||
|
||||
#
|
||||
# Copyright (c) 2004, 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.
|
||||
#
|
||||
# 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
|
||||
# @author Yingxian Wang
|
||||
# @bug 4957669 5017871
|
||||
# @library ../../../sun/net/www/httptest/
|
||||
# @build HttpCallback HttpServer ClosedChannelList HttpTransaction
|
||||
# @run shell/timeout=300 ClassnameCharTest.sh
|
||||
# @summary ; cannot load class names containing some JSR 202 characters;
|
||||
# plugin does not escape unicode character in http request
|
||||
#
|
||||
# set platform-dependent variables
|
||||
|
||||
OS=`uname -s`
|
||||
case "$OS" in
|
||||
SunOS | Linux | Darwin )
|
||||
PS=":"
|
||||
FS="/"
|
||||
;;
|
||||
Windows* | CYGWIN* )
|
||||
PS=";"
|
||||
FS="\\"
|
||||
;;
|
||||
* )
|
||||
echo "Unrecognized system!"
|
||||
exit 1;
|
||||
;;
|
||||
esac
|
||||
|
||||
cp ${TESTSRC}${FS}testclasses.jar ${TESTCLASSES}
|
||||
cd ${TESTCLASSES}
|
||||
${TESTJAVA}${FS}bin${FS}jar xvf testclasses.jar "fo o.class"
|
||||
${TESTJAVA}${FS}bin${FS}javac -d ${TESTCLASSES} ${TESTSRC}${FS}ClassnameCharTest.java
|
||||
|
||||
${TESTJAVA}${FS}bin${FS}java -classpath "${TESTCLASSES}${PS}${TESTCLASSES}${FS}sun${FS}misc${FS}URLClassPath" ClassnameCharTest
|
||||
|
||||
rm -rf "fo o.class" testclasses.jar
|
@ -25,7 +25,7 @@
|
||||
* @test
|
||||
* @bug 4804309
|
||||
* @library ../../../sun/net/www/httptest/
|
||||
* @build HttpCallback HttpServer ClosedChannelList HttpTransaction
|
||||
* @build HttpCallback TestHttpServer ClosedChannelList HttpTransaction
|
||||
* @run main AuthHeaderTest
|
||||
* @summary AuthHeaderTest bug
|
||||
*/
|
||||
@ -90,13 +90,13 @@ public class AuthHeaderTest implements HttpCallback {
|
||||
is.close();
|
||||
}
|
||||
|
||||
static HttpServer server;
|
||||
static TestHttpServer server;
|
||||
|
||||
public static void main (String[] args) throws Exception {
|
||||
MyAuthenticator auth = new MyAuthenticator ();
|
||||
Authenticator.setDefault (auth);
|
||||
try {
|
||||
server = new HttpServer (new AuthHeaderTest(), 1, 10, 0);
|
||||
server = new TestHttpServer (new AuthHeaderTest(), 1, 10, 0);
|
||||
System.out.println ("Server: listening on port: " + server.getLocalPort());
|
||||
client ("http://localhost:"+server.getLocalPort()+"/d1/foo.html");
|
||||
} catch (Exception e) {
|
||||
|
@ -24,8 +24,6 @@
|
||||
/**
|
||||
* @test
|
||||
* @bug 4333920 4994372
|
||||
* @library ../../../../../sun/net/www/httptest/
|
||||
* @build HttpCallback HttpServer ClosedChannelList HttpTransaction
|
||||
* @run main ChunkedEncodingWithProgressMonitorTest
|
||||
* @summary ChunkedEncoding unit test; MeteredStream/ProgressData problem
|
||||
*/
|
||||
|
@ -25,7 +25,7 @@
|
||||
* @test
|
||||
* @bug 5045306 6356004 6993490
|
||||
* @library ../../httptest/
|
||||
* @build HttpCallback HttpServer HttpTransaction
|
||||
* @build HttpCallback TestHttpServer HttpTransaction
|
||||
* @run main/othervm B5045306
|
||||
* @summary Http keep-alive implementation is not efficient
|
||||
*/
|
||||
@ -50,7 +50,7 @@ import java.lang.management.*;
|
||||
public class B5045306
|
||||
{
|
||||
static SimpleHttpTransaction httpTrans;
|
||||
static HttpServer server;
|
||||
static TestHttpServer server;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
startHttpServer();
|
||||
@ -60,7 +60,7 @@ public class B5045306
|
||||
public static void startHttpServer() {
|
||||
try {
|
||||
httpTrans = new SimpleHttpTransaction();
|
||||
server = new HttpServer(httpTrans, 1, 10, 0);
|
||||
server = new TestHttpServer(httpTrans, 1, 10, 0);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ public class HttpTransaction {
|
||||
|
||||
String command;
|
||||
URI requesturi;
|
||||
HttpServer.Server server;
|
||||
TestHttpServer.Server server;
|
||||
MessageHeader reqheaders, reqtrailers;
|
||||
String reqbody;
|
||||
byte[] rspbody;
|
||||
@ -46,7 +46,7 @@ public class HttpTransaction {
|
||||
int rspbodylen;
|
||||
boolean rspchunked;
|
||||
|
||||
HttpTransaction (HttpServer.Server server, String command,
|
||||
HttpTransaction (TestHttpServer.Server server, String command,
|
||||
URI requesturi, MessageHeader headers,
|
||||
String body, MessageHeader trailers, SelectionKey key) {
|
||||
this.command = command;
|
||||
@ -290,7 +290,7 @@ public class HttpTransaction {
|
||||
* @param rTag the response string to send with the response code
|
||||
*/
|
||||
public void sendResponse (int rCode, String rTag) throws IOException {
|
||||
OutputStream os = new HttpServer.NioOutputStream(channel());
|
||||
OutputStream os = new TestHttpServer.NioOutputStream(channel());
|
||||
PrintStream ps = new PrintStream (os);
|
||||
ps.print ("HTTP/1.1 " + rCode + " " + rTag + "\r\n");
|
||||
if (rspheaders != null) {
|
||||
@ -314,7 +314,7 @@ public class HttpTransaction {
|
||||
/* sends one byte less than intended */
|
||||
|
||||
public void sendPartialResponse (int rCode, String rTag)throws IOException {
|
||||
OutputStream os = new HttpServer.NioOutputStream(channel());
|
||||
OutputStream os = new TestHttpServer.NioOutputStream(channel());
|
||||
PrintStream ps = new PrintStream (os);
|
||||
ps.print ("HTTP/1.1 " + rCode + " " + rTag + "\r\n");
|
||||
ps.flush();
|
||||
|
@ -48,7 +48,7 @@ import java.util.*;
|
||||
* NOTE NOTE NOTE NOTE NOTE NOTE NOTE
|
||||
*/
|
||||
|
||||
public class HttpServer {
|
||||
public class TestHttpServer {
|
||||
|
||||
ServerSocketChannel schan;
|
||||
int threads;
|
||||
@ -57,19 +57,19 @@ public class HttpServer {
|
||||
Server[] servers;
|
||||
|
||||
/**
|
||||
* Create a <code>HttpServer<code> instance with the specified callback object
|
||||
* Create a <code>TestHttpServer<code> instance with the specified callback object
|
||||
* for handling requests. One thread is created to handle requests,
|
||||
* and up to ten TCP connections will be handled simultaneously.
|
||||
* @param cb the callback object which is invoked to handle each
|
||||
* incoming request
|
||||
*/
|
||||
|
||||
public HttpServer (HttpCallback cb) throws IOException {
|
||||
public TestHttpServer (HttpCallback cb) throws IOException {
|
||||
this (cb, 1, 10, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a <code>HttpServer<code> instance with the specified number of
|
||||
* Create a <code>TestHttpServer<code> instance with the specified number of
|
||||
* threads and maximum number of connections per thread. This functions
|
||||
* the same as the 4 arg constructor, where the port argument is set to zero.
|
||||
* @param cb the callback object which is invoked to handle each
|
||||
@ -80,13 +80,13 @@ public class HttpServer {
|
||||
* handle per thread
|
||||
*/
|
||||
|
||||
public HttpServer (HttpCallback cb, int threads, int cperthread)
|
||||
public TestHttpServer (HttpCallback cb, int threads, int cperthread)
|
||||
throws IOException {
|
||||
this (cb, threads, cperthread, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a <code>HttpServer<code> instance with the specified number
|
||||
* Create a <code>TestHttpServer<code> instance with the specified number
|
||||
* of threads and maximum number of connections per thread and running on
|
||||
* the specified port. The specified number of threads are created to
|
||||
* handle incoming requests, and each thread is allowed
|
||||
@ -101,7 +101,7 @@ public class HttpServer {
|
||||
* means choose any free port.
|
||||
*/
|
||||
|
||||
public HttpServer (HttpCallback cb, int threads, int cperthread, int port)
|
||||
public TestHttpServer (HttpCallback cb, int threads, int cperthread, int port)
|
||||
throws IOException {
|
||||
schan = ServerSocketChannel.open ();
|
||||
InetSocketAddress addr = new InetSocketAddress (port);
|
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