+ * If the {@code Level} of the specified logger is {@code null},
+ * which means that this logger's effective level is inherited
+ * from its parent, an empty string will be returned.
+ *
+ * @param loggerName The name of the {@code Logger} to be retrieved.
+ *
+ * @return The name of the log level of the specified logger; or
+ * an empty string if the log level of the specified logger
+ * is {@code null}. If the specified logger does not
+ * exist, {@code null} is returned.
+ *
+ * @see java.util.logging.Logger#getLevel
+ */
+ String getLoggerLevel(String loggerName);
+
+ /**
+ * Sets the specified logger to the specified new
+ * {@linkplain java.util.logging.Logger#setLevel level}.
+ * If the {@code levelName} is not {@code null}, the level
+ * of the specified logger is set to the parsed
+ * {@link java.util.logging.Level Level}
+ * matching the {@code levelName}.
+ * If the {@code levelName} is {@code null}, the level
+ * of the specified logger is set to {@code null} and
+ * the effective level of the logger is inherited from
+ * its nearest ancestor with a specific (non-null) level value.
+ *
+ * @param loggerName The name of the {@code Logger} to be set.
+ * Must be non-null.
+ * @param levelName The name of the level to set on the specified logger,
+ * or {@code null} if setting the level to inherit
+ * from its nearest ancestor.
+ *
+ * @throws IllegalArgumentException if the specified logger
+ * does not exist, or {@code levelName} is not a valid level name.
+ *
+ * @throws SecurityException if a security manager exists and if
+ * the caller does not have LoggingPermission("control").
+ *
+ * @see java.util.logging.Logger#setLevel
+ */
+ void setLoggerLevel(String loggerName, String levelName);
+
+ /**
+ * Returns the name of the
+ * {@linkplain java.util.logging.Logger#getParent parent}
+ * for the specified logger.
+ * If the specified logger does not exist, {@code null} is returned.
+ * If the specified logger is the root {@code Logger} in the namespace,
+ * the result will be an empty string.
+ *
+ * @param loggerName The name of a {@code Logger}.
+ *
+ * @return the name of the nearest existing parent logger;
+ * an empty string if the specified logger is the root logger.
+ * If the specified logger does not exist, {@code null}
+ * is returned.
+ */
+ String getParentLoggerName(String loggerName);
+}
diff --git a/src/share/classes/java/lang/management/PlatformManagedObject.java b/src/share/classes/java/lang/management/PlatformManagedObject.java
index b12dc268347b56146b1d283e84e01470d294c925..b87825732635b0fae8b0043eddef794c1792744f 100644
--- a/src/share/classes/java/lang/management/PlatformManagedObject.java
+++ b/src/share/classes/java/lang/management/PlatformManagedObject.java
@@ -46,7 +46,7 @@ import javax.management.ObjectName;
* intended for the management interfaces for the platform to extend but
* not for applications.
*
- * @see Platform MXBeans
+ * @see ManagementFactory
* @since 1.7
*/
public interface PlatformManagedObject {
diff --git a/src/share/classes/java/lang/management/package.html b/src/share/classes/java/lang/management/package.html
index 7ae6fbefc1eeeb8c416cb741a31e509f541a068d..eb01e37a2d80ec7af15c08e0c6abf72b4ceb9d7b 100644
--- a/src/share/classes/java/lang/management/package.html
+++ b/src/share/classes/java/lang/management/package.html
@@ -27,160 +27,124 @@
-Provides the management interface for monitoring and management of the
-Java virtual machine as well as the operating system on which the
-Java virtual machine is running. It allows both local and remote
-monitoring and management of the running Java virtual machine.
-
-An application can monitor the instrumentation of the
-Java virtual machine and manage certain characteristics in
-the following ways:
-
The {@link java.lang.management.ManagementFactory} class is the management
+factory class for the Java platform. This class provides a set of
static factory methods to obtain the MXBeans for the Java platform
to allow an application to access the MXBeans directly.
A management application and a platform MBeanServer of a running
+virtual machine can interoperate
without requiring classes used by the platform MXBean interfaces.
The data types being transmitted between the JMX connector
server and the connector client are JMX
-{@link javax.management.openmbean.OpenType open types} and
+{@linkplain javax.management.openmbean.OpenType open types} and
this allows interoperation across versions.
-
-
A data type used by the MXBean interfaces are mapped to
-an open type when being accessed via MBeanServer interface.
-The data type mapping is specified in the
-{@link java.lang.management.ManagementFactory ManagementFactory} class.
+A data type used by the MXBean interfaces are mapped to an
+open type when being accessed via MBeanServer interface.
+See the
+MXBean specification for details.
An application can monitor the instrumentation of the
+Java virtual machine and the runtime in the following ways:
A Java virtual machine implementation may add its platform extension to
the management interface by defining platform-dependent
interfaces that extend the standard management interfaces to include
-platform-specific metrics and management operations.
+platform-specific metrics and management operations.
The static factory methods in the ManagementFactory class will
-return the MBeans with the platform extension.
+return the MXBeans with the platform extension.
It is recommended to name the platform-specific attributes with
@@ -240,26 +187,30 @@ is happened to be same as some vendor-specific attribute's name,
the applications accessing that vendor-specific attribute would have
to be modified to cope with versioning and compatibility issues.
-
Below is an example showing how to access a platform-specific
-attribute from Sun's implementation of the RuntimeMXBean.
+
Below is an example showing how to access an attribute
+from the platform extension:
- com.sun.management.RuntimeMXBean mxbean =
- (com.sun.management.RuntimeMXBean) ManagementFactory.getRuntimeMXBean();
-
- // Get the standard attribute "VmVendor"
- String vendor = mxbean.getVmVendor();
+1) Direct access to the Oracle-specific MXBean interface
+
+
+ List<com.sun.management.GarbageCollectorMXBean> mxbeans =
+ ManagementFactory.getPlatformMXBeans(com.sun.management.GarbageCollectorMXBean.class);
- // Get the platform-specific attribute "Bar"
- BarType bar = mxbean.getBar();
+ for (com.sun.management.GarbageCollectorMXBean gc : mxbeans) {
+ // Get the standard attribute "CollectionCount"
+ String count = mxbean.getCollectionCount();
+ // Get the platform-specific attribute "LastGcInfo"
+ GcInfo gcinfo = gc.getLastGcInfo();
+ ...
+ }
-2) Access the Sun-specific MXBean interface via MBeanServer
+2) Access the Oracle-specific MXBean interface via MBeanServer
+ through proxy
MBeanServerConnection mbs;
@@ -268,24 +219,17 @@ attribute from Sun's implementation of the RuntimeMXBean.
// that has the JVM MXBeans registered in it
...
- try {
- // Assuming the RuntimeMXBean has been registered in mbs
- ObjectName oname = new ObjectName(ManagementFactory.RUNTIME_MXBEAN_NAME);
-
- // Get standard attribute "VmVendor"
- String vendor = (String) mbs.getAttribute(oname, "VmVendor");
+ List<com.sun.management.GarbageCollectorMXBean> mxbeans =
+ ManagementFactory.getPlatformMXBeans(mbs, com.sun.management.GarbageCollectorMXBean.class);
- // Check if this MXBean contains Sun's extension
- if (mbs.isInstanceOf(oname, "com.sun.management.RuntimeMXBean")) {
- // Get platform-specific attribute "Bar"
- BarType bar = (String) mbs.getAttribute(oname, "Bar");
- }
- } catch (....) {
- // Catch the exceptions thrown by ObjectName constructor
- // and MBeanServer methods
+ for (com.sun.management.GarbageCollectorMXBean gc : mxbeans) {
+ // Get the standard attribute "CollectionCount"
+ String count = mxbean.getCollectionCount();
+
+ // Get the platform-specific attribute "LastGcInfo"
+ GcInfo gcinfo = gc.getLastGcInfo();
...
}
-
Unless otherwise noted, passing a null argument to a constructor
diff --git a/src/share/classes/java/lang/reflect/AccessibleObject.java b/src/share/classes/java/lang/reflect/AccessibleObject.java
index c324add6957cfcc2162446774d5de8b8efadb08d..69b08ebe720d5b2539f850f10b4b2d2e4eb6ff61 100644
--- a/src/share/classes/java/lang/reflect/AccessibleObject.java
+++ b/src/share/classes/java/lang/reflect/AccessibleObject.java
@@ -26,6 +26,7 @@
package java.lang.reflect;
import java.security.AccessController;
+import sun.reflect.Reflection;
import sun.reflect.ReflectionFactory;
import java.lang.annotation.Annotation;
@@ -201,4 +202,73 @@ public class AccessibleObject implements AnnotatedElement {
public Annotation[] getDeclaredAnnotations() {
throw new AssertionError("All subclasses should override this method");
}
+
+
+ // Shared access checking logic.
+
+ // For non-public members or members in package-private classes,
+ // it is necessary to perform somewhat expensive security checks.
+ // If the security check succeeds for a given class, it will
+ // always succeed (it is not affected by the granting or revoking
+ // of permissions); we speed up the check in the common case by
+ // remembering the last Class for which the check succeeded.
+ //
+ // The simple security check for Constructor is to see if
+ // the caller has already been seen, verified, and cached.
+ // (See also Class.newInstance(), which uses a similar method.)
+ //
+ // A more complicated security check cache is needed for Method and Field
+ // The cache can be either null (empty cache), a 2-array of {caller,target},
+ // or a caller (with target implicitly equal to this.clazz).
+ // In the 2-array case, the target is always different from the clazz.
+ volatile Object securityCheckCache;
+
+ void checkAccess(Class> caller, Class> clazz, Object obj, int modifiers)
+ throws IllegalAccessException
+ {
+ if (caller == clazz) { // quick check
+ return; // ACCESS IS OK
+ }
+ Object cache = securityCheckCache; // read volatile
+ Class> targetClass = clazz;
+ if (obj != null
+ && Modifier.isProtected(modifiers)
+ && ((targetClass = obj.getClass()) != clazz)) {
+ // Must match a 2-list of { caller, targetClass }.
+ if (cache instanceof Class[]) {
+ Class>[] cache2 = (Class>[]) cache;
+ if (cache2[1] == targetClass &&
+ cache2[0] == caller) {
+ return; // ACCESS IS OK
+ }
+ // (Test cache[1] first since range check for [1]
+ // subsumes range check for [0].)
+ }
+ } else if (cache == caller) {
+ // Non-protected case (or obj.class == this.clazz).
+ return; // ACCESS IS OK
+ }
+
+ // If no return, fall through to the slow path.
+ slowCheckMemberAccess(caller, clazz, obj, modifiers, targetClass);
+ }
+
+ // Keep all this slow stuff out of line:
+ void slowCheckMemberAccess(Class> caller, Class> clazz, Object obj, int modifiers,
+ Class> targetClass)
+ throws IllegalAccessException
+ {
+ Reflection.ensureMemberAccess(caller, clazz, obj, modifiers);
+
+ // Success: Update the cache.
+ Object cache = ((targetClass == clazz)
+ ? caller
+ : new Class>[] { caller, targetClass });
+
+ // Note: The two cache elements are not volatile,
+ // but they are effectively final. The Java memory model
+ // guarantees that the initializing stores for the cache
+ // elements will occur before the volatile write.
+ securityCheckCache = cache; // write volatile
+ }
}
diff --git a/src/share/classes/java/lang/reflect/Constructor.java b/src/share/classes/java/lang/reflect/Constructor.java
index 601eafe066dfd7077640518e4e597923189a3802..2451c54e82d65c63fdbb9896ace7dece24934e5e 100644
--- a/src/share/classes/java/lang/reflect/Constructor.java
+++ b/src/share/classes/java/lang/reflect/Constructor.java
@@ -74,14 +74,6 @@ public final
private byte[] annotations;
private byte[] parameterAnnotations;
- // For non-public members or members in package-private classes,
- // it is necessary to perform somewhat expensive security checks.
- // If the security check succeeds for a given class, it will
- // always succeed (it is not affected by the granting or revoking
- // of permissions); we speed up the check in the common case by
- // remembering the last Class for which the check succeeded.
- private volatile Class> securityCheckCache;
-
// Generics infrastructure
// Accessor for factory
private GenericsFactory getFactory() {
@@ -495,7 +487,7 @@ public final
* this object represents
*
* @exception IllegalAccessException if this {@code Constructor} object
- * enforces Java language access control and the underlying
+ * is enforcing Java language access control and the underlying
* constructor is inaccessible.
* @exception IllegalArgumentException if the number of actual
* and formal parameters differ; if an unwrapping
@@ -518,16 +510,17 @@ public final
if (!override) {
if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
Class> caller = Reflection.getCallerClass(2);
- if (securityCheckCache != caller) {
- Reflection.ensureMemberAccess(caller, clazz, null, modifiers);
- securityCheckCache = caller;
- }
+
+ checkAccess(caller, clazz, null, modifiers);
}
}
if ((clazz.getModifiers() & Modifier.ENUM) != 0)
throw new IllegalArgumentException("Cannot reflectively create enum objects");
- if (constructorAccessor == null) acquireConstructorAccessor();
- return (T) constructorAccessor.newInstance(initargs);
+ ConstructorAccessor ca = constructorAccessor; // read volatile
+ if (ca == null) {
+ ca = acquireConstructorAccessor();
+ }
+ return (T) ca.newInstance(initargs);
}
/**
@@ -560,18 +553,20 @@ public final
// ConstructorAccessor for a given Constructor. However, avoiding
// synchronization will probably make the implementation more
// scalable.
- private void acquireConstructorAccessor() {
+ private ConstructorAccessor acquireConstructorAccessor() {
// First check to see if one has been created yet, and take it
// if so.
ConstructorAccessor tmp = null;
if (root != null) tmp = root.getConstructorAccessor();
if (tmp != null) {
constructorAccessor = tmp;
- return;
+ } else {
+ // Otherwise fabricate one and propagate it up to the root
+ tmp = reflectionFactory.newConstructorAccessor(this);
+ setConstructorAccessor(tmp);
}
- // Otherwise fabricate one and propagate it up to the root
- tmp = reflectionFactory.newConstructorAccessor(this);
- setConstructorAccessor(tmp);
+
+ return tmp;
}
// Returns ConstructorAccessor for this Constructor object, not
diff --git a/src/share/classes/java/lang/reflect/Field.java b/src/share/classes/java/lang/reflect/Field.java
index 77884d46bbe6c4f45d89feeacb47244c686ff898..f7647d6dc8faa999cc8eae1b42f7e53eb0b3bbf9 100644
--- a/src/share/classes/java/lang/reflect/Field.java
+++ b/src/share/classes/java/lang/reflect/Field.java
@@ -79,11 +79,6 @@ class Field extends AccessibleObject implements Member {
// potentially many Field objects pointing to it.)
private Field root;
- // More complicated security check cache needed here than for
- // Class.newInstance() and Constructor.newInstance()
- private Class> securityCheckCache;
- private Class> securityCheckTargetClassCache;
-
// Generics infrastructure
private String getGenericSignature() {return signature;}
@@ -340,7 +335,7 @@ class Field extends AccessibleObject implements Member {
* instance of the class or interface declaring the underlying
* field, the method throws an {@code IllegalArgumentException}.
*
- *
If this {@code Field} object enforces Java language access control, and
+ *
If this {@code Field} object is enforcing Java language access control, and
* the underlying field is inaccessible, the method throws an
* {@code IllegalAccessException}.
* If the underlying field is static, the class that declared the
@@ -360,8 +355,9 @@ class Field extends AccessibleObject implements Member {
* {@code obj}; primitive values are wrapped in an appropriate
* object before being returned
*
- * @exception IllegalAccessException if the underlying field
- * is inaccessible.
+ * @exception IllegalAccessException if this {@code Field} object
+ * is enforcing Java language access control and the underlying
+ * field is inaccessible.
* @exception IllegalArgumentException if the specified object is not an
* instance of the class or interface declaring the underlying
* field (or a subclass or implementor thereof).
@@ -383,8 +379,9 @@ class Field extends AccessibleObject implements Member {
* from
* @return the value of the {@code boolean} field
*
- * @exception IllegalAccessException if the underlying field
- * is inaccessible.
+ * @exception IllegalAccessException if this {@code Field} object
+ * is enforcing Java language access control and the underlying
+ * field is inaccessible.
* @exception IllegalArgumentException if the specified object is not
* an instance of the class or interface declaring the
* underlying field (or a subclass or implementor
@@ -410,8 +407,9 @@ class Field extends AccessibleObject implements Member {
* from
* @return the value of the {@code byte} field
*
- * @exception IllegalAccessException if the underlying field
- * is inaccessible.
+ * @exception IllegalAccessException if this {@code Field} object
+ * is enforcing Java language access control and the underlying
+ * field is inaccessible.
* @exception IllegalArgumentException if the specified object is not
* an instance of the class or interface declaring the
* underlying field (or a subclass or implementor
@@ -439,8 +437,9 @@ class Field extends AccessibleObject implements Member {
* from
* @return the value of the field converted to type {@code char}
*
- * @exception IllegalAccessException if the underlying field
- * is inaccessible.
+ * @exception IllegalAccessException if this {@code Field} object
+ * is enforcing Java language access control and the underlying
+ * field is inaccessible.
* @exception IllegalArgumentException if the specified object is not
* an instance of the class or interface declaring the
* underlying field (or a subclass or implementor
@@ -468,8 +467,9 @@ class Field extends AccessibleObject implements Member {
* from
* @return the value of the field converted to type {@code short}
*
- * @exception IllegalAccessException if the underlying field
- * is inaccessible.
+ * @exception IllegalAccessException if this {@code Field} object
+ * is enforcing Java language access control and the underlying
+ * field is inaccessible.
* @exception IllegalArgumentException if the specified object is not
* an instance of the class or interface declaring the
* underlying field (or a subclass or implementor
@@ -497,8 +497,9 @@ class Field extends AccessibleObject implements Member {
* from
* @return the value of the field converted to type {@code int}
*
- * @exception IllegalAccessException if the underlying field
- * is inaccessible.
+ * @exception IllegalAccessException if this {@code Field} object
+ * is enforcing Java language access control and the underlying
+ * field is inaccessible.
* @exception IllegalArgumentException if the specified object is not
* an instance of the class or interface declaring the
* underlying field (or a subclass or implementor
@@ -526,8 +527,9 @@ class Field extends AccessibleObject implements Member {
* from
* @return the value of the field converted to type {@code long}
*
- * @exception IllegalAccessException if the underlying field
- * is inaccessible.
+ * @exception IllegalAccessException if this {@code Field} object
+ * is enforcing Java language access control and the underlying
+ * field is inaccessible.
* @exception IllegalArgumentException if the specified object is not
* an instance of the class or interface declaring the
* underlying field (or a subclass or implementor
@@ -555,8 +557,9 @@ class Field extends AccessibleObject implements Member {
* from
* @return the value of the field converted to type {@code float}
*
- * @exception IllegalAccessException if the underlying field
- * is inaccessible.
+ * @exception IllegalAccessException if this {@code Field} object
+ * is enforcing Java language access control and the underlying
+ * field is inaccessible.
* @exception IllegalArgumentException if the specified object is not
* an instance of the class or interface declaring the
* underlying field (or a subclass or implementor
@@ -584,8 +587,9 @@ class Field extends AccessibleObject implements Member {
* from
* @return the value of the field converted to type {@code double}
*
- * @exception IllegalAccessException if the underlying field
- * is inaccessible.
+ * @exception IllegalAccessException if this {@code Field} object
+ * is enforcing Java language access control and the underlying
+ * field is inaccessible.
* @exception IllegalArgumentException if the specified object is not
* an instance of the class or interface declaring the
* underlying field (or a subclass or implementor
@@ -621,14 +625,14 @@ class Field extends AccessibleObject implements Member {
* an instance of the class or interface declaring the underlying
* field, the method throws an {@code IllegalArgumentException}.
*
- *
If this {@code Field} object enforces Java language access control, and
+ *
If this {@code Field} object is enforcing Java language access control, and
* the underlying field is inaccessible, the method throws an
* {@code IllegalAccessException}.
*
*
If the underlying field is final, the method throws an
- * {@code IllegalAccessException} unless
- * {@code setAccessible(true)} has succeeded for this field
- * and this field is non-static. Setting a final field in this way
+ * {@code IllegalAccessException} unless {@code setAccessible(true)}
+ * has succeeded for this {@code Field} object
+ * and the field is non-static. Setting a final field in this way
* is meaningful only during deserialization or reconstruction of
* instances of classes with blank final fields, before they are
* made available for access by other parts of a program. Use in
@@ -658,8 +662,9 @@ class Field extends AccessibleObject implements Member {
* @param value the new value for the field of {@code obj}
* being modified
*
- * @exception IllegalAccessException if the underlying field
- * is inaccessible.
+ * @exception IllegalAccessException if this {@code Field} object
+ * is enforcing Java language access control and the underlying
+ * field is either inaccessible or final.
* @exception IllegalArgumentException if the specified object is not an
* instance of the class or interface declaring the underlying
* field (or a subclass or implementor thereof),
@@ -686,8 +691,9 @@ class Field extends AccessibleObject implements Member {
* @param z the new value for the field of {@code obj}
* being modified
*
- * @exception IllegalAccessException if the underlying field
- * is inaccessible.
+ * @exception IllegalAccessException if this {@code Field} object
+ * is enforcing Java language access control and the underlying
+ * field is either inaccessible or final.
* @exception IllegalArgumentException if the specified object is not an
* instance of the class or interface declaring the underlying
* field (or a subclass or implementor thereof),
@@ -715,8 +721,9 @@ class Field extends AccessibleObject implements Member {
* @param b the new value for the field of {@code obj}
* being modified
*
- * @exception IllegalAccessException if the underlying field
- * is inaccessible.
+ * @exception IllegalAccessException if this {@code Field} object
+ * is enforcing Java language access control and the underlying
+ * field is either inaccessible or final.
* @exception IllegalArgumentException if the specified object is not an
* instance of the class or interface declaring the underlying
* field (or a subclass or implementor thereof),
@@ -744,8 +751,9 @@ class Field extends AccessibleObject implements Member {
* @param c the new value for the field of {@code obj}
* being modified
*
- * @exception IllegalAccessException if the underlying field
- * is inaccessible.
+ * @exception IllegalAccessException if this {@code Field} object
+ * is enforcing Java language access control and the underlying
+ * field is either inaccessible or final.
* @exception IllegalArgumentException if the specified object is not an
* instance of the class or interface declaring the underlying
* field (or a subclass or implementor thereof),
@@ -773,8 +781,9 @@ class Field extends AccessibleObject implements Member {
* @param s the new value for the field of {@code obj}
* being modified
*
- * @exception IllegalAccessException if the underlying field
- * is inaccessible.
+ * @exception IllegalAccessException if this {@code Field} object
+ * is enforcing Java language access control and the underlying
+ * field is either inaccessible or final.
* @exception IllegalArgumentException if the specified object is not an
* instance of the class or interface declaring the underlying
* field (or a subclass or implementor thereof),
@@ -802,8 +811,9 @@ class Field extends AccessibleObject implements Member {
* @param i the new value for the field of {@code obj}
* being modified
*
- * @exception IllegalAccessException if the underlying field
- * is inaccessible.
+ * @exception IllegalAccessException if this {@code Field} object
+ * is enforcing Java language access control and the underlying
+ * field is either inaccessible or final.
* @exception IllegalArgumentException if the specified object is not an
* instance of the class or interface declaring the underlying
* field (or a subclass or implementor thereof),
@@ -831,8 +841,9 @@ class Field extends AccessibleObject implements Member {
* @param l the new value for the field of {@code obj}
* being modified
*
- * @exception IllegalAccessException if the underlying field
- * is inaccessible.
+ * @exception IllegalAccessException if this {@code Field} object
+ * is enforcing Java language access control and the underlying
+ * field is either inaccessible or final.
* @exception IllegalArgumentException if the specified object is not an
* instance of the class or interface declaring the underlying
* field (or a subclass or implementor thereof),
@@ -860,8 +871,9 @@ class Field extends AccessibleObject implements Member {
* @param f the new value for the field of {@code obj}
* being modified
*
- * @exception IllegalAccessException if the underlying field
- * is inaccessible.
+ * @exception IllegalAccessException if this {@code Field} object
+ * is enforcing Java language access control and the underlying
+ * field is either inaccessible or final.
* @exception IllegalArgumentException if the specified object is not an
* instance of the class or interface declaring the underlying
* field (or a subclass or implementor thereof),
@@ -889,8 +901,9 @@ class Field extends AccessibleObject implements Member {
* @param d the new value for the field of {@code obj}
* being modified
*
- * @exception IllegalAccessException if the underlying field
- * is inaccessible.
+ * @exception IllegalAccessException if this {@code Field} object
+ * is enforcing Java language access control and the underlying
+ * field is either inaccessible or final.
* @exception IllegalArgumentException if the specified object is not an
* instance of the class or interface declaring the underlying
* field (or a subclass or implementor thereof),
@@ -936,6 +949,7 @@ class Field extends AccessibleObject implements Member {
tmp = reflectionFactory.newFieldAccessor(this, overrideFinalCheck);
setFieldAccessor(tmp, overrideFinalCheck);
}
+
return tmp;
}
@@ -965,21 +979,8 @@ class Field extends AccessibleObject implements Member {
if (!override) {
if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
Class> caller = Reflection.getCallerClass(4);
- Class> targetClass = ((obj == null || !Modifier.isProtected(modifiers))
- ? clazz
- : obj.getClass());
- synchronized (this) {
- if ((securityCheckCache == caller)
- && (securityCheckTargetClassCache == targetClass)) {
- return;
- }
- }
- Reflection.ensureMemberAccess(caller, clazz, obj, modifiers);
- synchronized (this) {
- securityCheckCache = caller;
- securityCheckTargetClassCache = targetClass;
- }
+ checkAccess(caller, clazz, obj, modifiers);
}
}
}
diff --git a/src/share/classes/java/lang/reflect/Method.java b/src/share/classes/java/lang/reflect/Method.java
index 51eaf2dff5095bb6935dafae5f9929beba0ffbd4..1de1557051159d2ddcc795af0933c41975a9f9fe 100644
--- a/src/share/classes/java/lang/reflect/Method.java
+++ b/src/share/classes/java/lang/reflect/Method.java
@@ -83,11 +83,6 @@ public final
// potentially many Method objects pointing to it.)
private Method root;
- // More complicated security check cache needed here than for
- // Class.newInstance() and Constructor.newInstance()
- private Class> securityCheckCache;
- private Class> securityCheckTargetClassCache;
-
// Generics infrastructure
private String getGenericSignature() {return signature;}
@@ -402,28 +397,28 @@ public final
*/
public String toString() {
try {
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
int mod = getModifiers() & Modifier.methodModifiers();
if (mod != 0) {
- sb.append(Modifier.toString(mod) + " ");
+ sb.append(Modifier.toString(mod)).append(' ');
}
- sb.append(Field.getTypeName(getReturnType()) + " ");
- sb.append(Field.getTypeName(getDeclaringClass()) + ".");
- sb.append(getName() + "(");
+ sb.append(Field.getTypeName(getReturnType())).append(' ');
+ sb.append(Field.getTypeName(getDeclaringClass())).append('.');
+ sb.append(getName()).append('(');
Class>[] params = parameterTypes; // avoid clone
for (int j = 0; j < params.length; j++) {
sb.append(Field.getTypeName(params[j]));
if (j < (params.length - 1))
- sb.append(",");
+ sb.append(',');
}
- sb.append(")");
+ sb.append(')');
Class>[] exceptions = exceptionTypes; // avoid clone
if (exceptions.length > 0) {
sb.append(" throws ");
for (int k = 0; k < exceptions.length; k++) {
sb.append(exceptions[k].getName());
if (k < (exceptions.length - 1))
- sb.append(",");
+ sb.append(',');
}
}
return sb.toString();
@@ -475,15 +470,15 @@ public final
StringBuilder sb = new StringBuilder();
int mod = getModifiers() & Modifier.methodModifiers();
if (mod != 0) {
- sb.append(Modifier.toString(mod) + " ");
+ sb.append(Modifier.toString(mod)).append(' ');
}
TypeVariable>[] typeparms = getTypeParameters();
if (typeparms.length > 0) {
boolean first = true;
- sb.append("<");
+ sb.append('<');
for(TypeVariable> typeparm: typeparms) {
if (!first)
- sb.append(",");
+ sb.append(',');
// Class objects can't occur here; no need to test
// and call Class.getName().
sb.append(typeparm.toString());
@@ -494,10 +489,11 @@ public final
Type genRetType = getGenericReturnType();
sb.append( ((genRetType instanceof Class>)?
- Field.getTypeName((Class>)genRetType):genRetType.toString()) + " ");
+ Field.getTypeName((Class>)genRetType):genRetType.toString()))
+ .append(' ');
- sb.append(Field.getTypeName(getDeclaringClass()) + ".");
- sb.append(getName() + "(");
+ sb.append(Field.getTypeName(getDeclaringClass())).append('.');
+ sb.append(getName()).append('(');
Type[] params = getGenericParameterTypes();
for (int j = 0; j < params.length; j++) {
String param = (params[j] instanceof Class)?
@@ -507,9 +503,9 @@ public final
param = param.replaceFirst("\\[\\]$", "...");
sb.append(param);
if (j < (params.length - 1))
- sb.append(",");
+ sb.append(',');
}
- sb.append(")");
+ sb.append(')');
Type[] exceptions = getGenericExceptionTypes();
if (exceptions.length > 0) {
sb.append(" throws ");
@@ -518,7 +514,7 @@ public final
((Class)exceptions[k]).getName():
exceptions[k].toString());
if (k < (exceptions.length - 1))
- sb.append(",");
+ sb.append(',');
}
}
return sb.toString();
@@ -565,7 +561,7 @@ public final
* {@code args}
*
* @exception IllegalAccessException if this {@code Method} object
- * enforces Java language access control and the underlying
+ * is enforcing Java language access control and the underlying
* method is inaccessible.
* @exception IllegalArgumentException if the method is an
* instance method and the specified object argument
@@ -591,26 +587,15 @@ public final
if (!override) {
if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
Class> caller = Reflection.getCallerClass(1);
- Class> targetClass = ((obj == null || !Modifier.isProtected(modifiers))
- ? clazz
- : obj.getClass());
-
- boolean cached;
- synchronized (this) {
- cached = (securityCheckCache == caller)
- && (securityCheckTargetClassCache == targetClass);
- }
- if (!cached) {
- Reflection.ensureMemberAccess(caller, clazz, obj, modifiers);
- synchronized (this) {
- securityCheckCache = caller;
- securityCheckTargetClassCache = targetClass;
- }
- }
+
+ checkAccess(caller, clazz, obj, modifiers);
}
}
- if (methodAccessor == null) acquireMethodAccessor();
- return methodAccessor.invoke(obj, args);
+ MethodAccessor ma = methodAccessor; // read volatile
+ if (ma == null) {
+ ma = acquireMethodAccessor();
+ }
+ return ma.invoke(obj, args);
}
/**
@@ -654,18 +639,20 @@ public final
// (though not efficient) to generate more than one MethodAccessor
// for a given Method. However, avoiding synchronization will
// probably make the implementation more scalable.
- private void acquireMethodAccessor() {
+ private MethodAccessor acquireMethodAccessor() {
// First check to see if one has been created yet, and take it
// if so
MethodAccessor tmp = null;
if (root != null) tmp = root.getMethodAccessor();
if (tmp != null) {
methodAccessor = tmp;
- return;
+ } else {
+ // Otherwise fabricate one and propagate it up to the root
+ tmp = reflectionFactory.newMethodAccessor(this);
+ setMethodAccessor(tmp);
}
- // Otherwise fabricate one and propagate it up to the root
- tmp = reflectionFactory.newMethodAccessor(this);
- setMethodAccessor(tmp);
+
+ return tmp;
}
// Returns MethodAccessor for this Method object, not looking up
diff --git a/src/share/classes/java/nio/file/Files.java b/src/share/classes/java/nio/file/Files.java
index 8b7af13544ce6f9914c873215e636f9aa901ea8c..77847e7fcc17a7ccbe8480d74057be8e52c544eb 100644
--- a/src/share/classes/java/nio/file/Files.java
+++ b/src/share/classes/java/nio/file/Files.java
@@ -2067,7 +2067,7 @@ public final class Files {
*
* @return {@code true} if the file is a symbolic link; {@code false} if
* the file does not exist, is not a symbolic link, or it cannot
- * be determined if the file is symbolic link or not.
+ * be determined if the file is a symbolic link or not.
*
* @throws SecurityException
* In the case of the default provider, and a security manager is
@@ -2106,7 +2106,7 @@ public final class Files {
*
* @return {@code true} if the file is a directory; {@code false} if
* the file does not exist, is not a directory, or it cannot
- * be determined if the file is directory or not.
+ * be determined if the file is a directory or not.
*
* @throws SecurityException
* In the case of the default provider, and a security manager is
@@ -2142,8 +2142,8 @@ public final class Files {
* options indicating how symbolic links are handled
*
* @return {@code true} if the file is a regular file; {@code false} if
- * the file does not exist, is not a direcregular filetory, or it
- * cannot be determined if the file is regular file or not.
+ * the file does not exist, is not a regular file, or it
+ * cannot be determined if the file is a regular file or not.
*
* @throws SecurityException
* In the case of the default provider, and a security manager is
diff --git a/src/share/classes/java/nio/file/Path.java b/src/share/classes/java/nio/file/Path.java
index 618f0226363a530da3e20d809e8c3527048b6544..cefd2d2fd04d29e685f91dd4e462323846bbb3d9 100644
--- a/src/share/classes/java/nio/file/Path.java
+++ b/src/share/classes/java/nio/file/Path.java
@@ -550,18 +550,21 @@ public interface Path
*
If this path is relative then its absolute path is first obtained,
* as if by invoking the {@link #toAbsolutePath toAbsolutePath} method.
*
- *
The {@code resolveLinks} parameter specifies if symbolic links
- * should be resolved. This parameter is ignored when symbolic links are
- * not supported. Where supported, and the parameter has the value {@code
- * true} then symbolic links are resolved to their final target. Where the
- * parameter has the value {@code false} then this method does not resolve
- * symbolic links. Some implementations allow special names such as
- * "{@code ..}" to refer to the parent directory. When deriving the real
- * path, and a "{@code ..}" (or equivalent) is preceded by a
- * non-"{@code ..}" name then an implementation will typically causes both
- * names to be removed. When not resolving symbolic links and the preceding
- * name is a symbolic link then the names are only removed if it guaranteed
- * that the resulting path will locate the same file as this path.
+ *
The {@code options} array may be used to indicate how symbolic links
+ * are handled. By default, symbolic links are resolved to their final
+ * target. If the option {@link LinkOption#NOFOLLOW_LINKS NOFOLLOW_LINKS} is
+ * present then this method does not resolve symbolic links.
+ *
+ * Some implementations allow special names such as "{@code ..}" to refer to
+ * the parent directory. When deriving the real path, and a
+ * "{@code ..}" (or equivalent) is preceded by a non-"{@code ..}" name then
+ * an implementation will typically cause both names to be removed. When
+ * not resolving symbolic links and the preceding name is a symbolic link
+ * then the names are only removed if it guaranteed that the resulting path
+ * will locate the same file as this path.
+ *
+ * @param options
+ * options indicating how symbolic links are handled
*
* @return an absolute path represent the real path of the file
* located by this object
@@ -576,7 +579,7 @@ public interface Path
* checkPropertyAccess} method is invoked to check access to the
* system property {@code user.dir}
*/
- Path toRealPath(boolean resolveLinks) throws IOException;
+ Path toRealPath(LinkOption... options) throws IOException;
/**
* Returns a {@link File} object representing this path. Where this {@code
diff --git a/src/share/classes/java/util/Collections.java b/src/share/classes/java/util/Collections.java
index 1ea0ecb04c008fb24e78e865280cc78acd770e0e..826cbe759c92b99fad35a50e13f35b68e3f3ec4f 100644
--- a/src/share/classes/java/util/Collections.java
+++ b/src/share/classes/java/util/Collections.java
@@ -3533,20 +3533,20 @@ public class Collections {
}
/**
- * Returns a comparator that imposes the reverse of the natural
- * ordering on a collection of objects that implement the
- * Comparable interface. (The natural ordering is the ordering
- * imposed by the objects' own compareTo method.) This enables a
+ * Returns a comparator that imposes the reverse of the natural
+ * ordering on a collection of objects that implement the
+ * {@code Comparable} interface. (The natural ordering is the ordering
+ * imposed by the objects' own {@code compareTo} method.) This enables a
* simple idiom for sorting (or maintaining) collections (or arrays) of
- * objects that implement the Comparable interface in
- * reverse-natural-order. For example, suppose a is an array of
+ * objects that implement the {@code Comparable} interface in
+ * reverse-natural-order. For example, suppose {@code a} is an array of
* strings. Then:
* Arrays.sort(a, Collections.reverseOrder());
* sorts the array in reverse-lexicographic (alphabetical) order.
*
* The returned comparator is serializable.
*
- * @return a comparator that imposes the reverse of the natural
+ * @return A comparator that imposes the reverse of the natural
* ordering on a collection of objects that implement
* the Comparable interface.
* @see Comparable
@@ -3575,16 +3575,18 @@ public class Collections {
/**
* Returns a comparator that imposes the reverse ordering of the specified
- * comparator. If the specified comparator is null, this method is
+ * comparator. If the specified comparator is {@code null}, this method is
* equivalent to {@link #reverseOrder()} (in other words, it returns a
- * comparator that imposes the reverse of the natural ordering on a
- * collection of objects that implement the Comparable interface).
+ * comparator that imposes the reverse of the natural ordering on
+ * a collection of objects that implement the Comparable interface).
*
*
The returned comparator is serializable (assuming the specified
- * comparator is also serializable or null).
+ * comparator is also serializable or {@code null}).
*
- * @return a comparator that imposes the reverse ordering of the
- * specified comparator
+ * @param cmp a comparator who's ordering is to be reversed by the returned
+ * comparator or {@code null}
+ * @return A comparator that imposes the reverse ordering of the
+ * specified comparator.
* @since 1.5
*/
public static Comparator reverseOrder(Comparator cmp) {
diff --git a/src/share/classes/java/util/ComparableTimSort.java b/src/share/classes/java/util/ComparableTimSort.java
index f78ee9a2efc711bf0e1dde89eed9a5fe38976548..22427a2d353cba980b6a23d36d3f4b895cdbccd1 100644
--- a/src/share/classes/java/util/ComparableTimSort.java
+++ b/src/share/classes/java/util/ComparableTimSort.java
@@ -241,7 +241,7 @@ class ComparableTimSort {
* pivot < all in [left, start), so pivot belongs at left. Note
* that if there are elements equal to pivot, left points to the
* first slot after them -- that's why this sort is stable.
- * Slide elements over to make room to make room for pivot.
+ * Slide elements over to make room for pivot.
*/
int n = start - left; // The number of elements to move
// Switch is just an optimization for arraycopy in default case
diff --git a/src/share/classes/java/util/SortedMap.java b/src/share/classes/java/util/SortedMap.java
index 601b3f5de2af3afcbbbc150a52da9c2d4f625bb9..b71b5faa1a6eaf0e81b31fc3950af9941dcd45cf 100644
--- a/src/share/classes/java/util/SortedMap.java
+++ b/src/share/classes/java/util/SortedMap.java
@@ -26,69 +26,70 @@
package java.util;
/**
- * A {@link Map} that further provides a total ordering on its keys.
+ * A {@link Map} that further provides a total ordering on its keys.
* The map is ordered according to the {@linkplain Comparable natural
* ordering} of its keys, or by a {@link Comparator} typically
* provided at sorted map creation time. This order is reflected when
* iterating over the sorted map's collection views (returned by the
- * entrySet, keySet and values methods).
+ * {@code entrySet}, {@code keySet} and {@code values} methods).
* Several additional operations are provided to take advantage of the
- * ordering. (This interface is the map analogue of {@link
- * SortedSet}.)
+ * ordering. (This interface is the map analogue of {@link SortedSet}.)
*
- * All keys inserted into a sorted map must implement the Comparable
+ *
All keys inserted into a sorted map must implement the {@code Comparable}
* interface (or be accepted by the specified comparator). Furthermore, all
- * such keys must be mutually comparable: k1.compareTo(k2) (or
- * comparator.compare(k1, k2)) must not throw a
- * ClassCastException for any keys k1 and k2 in
+ * such keys must be mutually comparable: {@code k1.compareTo(k2)} (or
+ * {@code comparator.compare(k1, k2)}) must not throw a
+ * {@code ClassCastException} for any keys {@code k1} and {@code k2} in
* the sorted map. Attempts to violate this restriction will cause the
* offending method or constructor invocation to throw a
- * ClassCastException.
+ * {@code ClassCastException}.
*
*
Note that the ordering maintained by a sorted map (whether or not an
- * explicit comparator is provided) must be consistent with equals if
- * the sorted map is to correctly implement the Map interface. (See
- * the Comparable interface or Comparator interface for a
- * precise definition of consistent with equals.) This is so because
- * the Map interface is defined in terms of the equals
+ * explicit comparator is provided) must be consistent with equals if
+ * the sorted map is to correctly implement the {@code Map} interface. (See
+ * the {@code Comparable} interface or {@code Comparator} interface for a
+ * precise definition of consistent with equals.) This is so because
+ * the {@code Map} interface is defined in terms of the {@code equals}
* operation, but a sorted map performs all key comparisons using its
- * compareTo (or compare) method, so two keys that are
+ * {@code compareTo} (or {@code compare}) method, so two keys that are
* deemed equal by this method are, from the standpoint of the sorted map,
- * equal. The behavior of a tree map is well-defined even if its
+ * equal. The behavior of a tree map is well-defined even if its
* ordering is inconsistent with equals; it just fails to obey the general
- * contract of the Map interface.
+ * contract of the {@code Map} interface.
*
- *
All general-purpose sorted map implementation classes should
- * provide four "standard" constructors: 1) A void (no arguments)
- * constructor, which creates an empty sorted map sorted according to
- * the natural ordering of its keys. 2) A constructor with a
- * single argument of type Comparator, which creates an empty
- * sorted map sorted according to the specified comparator. 3) A
- * constructor with a single argument of type Map, which
- * creates a new map with the same key-value mappings as its argument,
- * sorted according to the keys' natural ordering. 4) A constructor
- * with a single argument of type SortedMap,
- * which creates a new sorted map with the same key-value mappings and
- * the same ordering as the input sorted map. There is no way to
- * enforce this recommendation, as interfaces cannot contain
- * constructors.
+ *
All general-purpose sorted map implementation classes should provide four
+ * "standard" constructors. It is not possible to enforce this recommendation
+ * though as required constructors cannot be specified by interfaces. The
+ * expected "standard" constructors for all sorted map implementations are:
+ *
+ * - A void (no arguments) constructor, which creates an empty sorted map
+ * sorted according to the natural ordering of its keys.
+ * - A constructor with a single argument of type {@code Comparator}, which
+ * creates an empty sorted map sorted according to the specified comparator.
+ * - A constructor with a single argument of type {@code Map}, which creates
+ * a new map with the same key-value mappings as its argument, sorted
+ * according to the keys' natural ordering.
+ * - A constructor with a single argument of type {@code SortedMap}, which
+ * creates a new sorted map with the same key-value mappings and the same
+ * ordering as the input sorted map.
+ *
*
- * Note: several methods return submaps with restricted key ranges.
- * Such ranges are half-open, that is, they include their low
+ *
Note: several methods return submaps with restricted key
+ * ranges. Such ranges are half-open, that is, they include their low
* endpoint but not their high endpoint (where applicable). If you need a
- * closed range (which includes both endpoints), and the key type
+ * closed range (which includes both endpoints), and the key type
* allows for calculation of the successor of a given key, merely request
- * the subrange from lowEndpoint to
- * successor(highEndpoint). For example, suppose that m
+ * the subrange from {@code lowEndpoint} to
+ * {@code successor(highEndpoint)}. For example, suppose that {@code m}
* is a map whose keys are strings. The following idiom obtains a view
- * containing all of the key-value mappings in m whose keys are
- * between low and high, inclusive:
+ * containing all of the key-value mappings in {@code m} whose keys are
+ * between {@code low} and {@code high}, inclusive:
* SortedMap<String, V> sub = m.subMap(low, high+"\0");
*
- * A similar technique can be used to generate an open range
+ * A similar technique can be used to generate an open range
* (which contains neither endpoint). The following idiom obtains a
- * view containing all of the key-value mappings in m whose keys
- * are between low and high, exclusive:
+ * view containing all of the key-value mappings in {@code m} whose keys
+ * are between {@code low} and {@code high}, exclusive:
* SortedMap<String, V> sub = m.subMap(low+"\0", high);
*
* This interface is a member of the
@@ -112,96 +113,96 @@ package java.util;
public interface SortedMap extends Map {
/**
* Returns the comparator used to order the keys in this map, or
- * null if this map uses the {@linkplain Comparable
+ * {@code null} if this map uses the {@linkplain Comparable
* natural ordering} of its keys.
*
* @return the comparator used to order the keys in this map,
- * or null if this map uses the natural ordering
+ * or {@code null} if this map uses the natural ordering
* of its keys
*/
Comparator super K> comparator();
/**
* Returns a view of the portion of this map whose keys range from
- * fromKey, inclusive, to toKey, exclusive. (If
- * fromKey and toKey are equal, the returned map
+ * {@code fromKey}, inclusive, to {@code toKey}, exclusive. (If
+ * {@code fromKey} and {@code toKey} are equal, the returned map
* is empty.) The returned map is backed by this map, so changes
* in the returned map are reflected in this map, and vice-versa.
* The returned map supports all optional map operations that this
* map supports.
*
- * The returned map will throw an IllegalArgumentException
+ *
The returned map will throw an {@code IllegalArgumentException}
* on an attempt to insert a key outside its range.
*
* @param fromKey low endpoint (inclusive) of the keys in the returned map
* @param toKey high endpoint (exclusive) of the keys in the returned map
* @return a view of the portion of this map whose keys range from
- * fromKey, inclusive, to toKey, exclusive
- * @throws ClassCastException if fromKey and toKey
+ * {@code fromKey}, inclusive, to {@code toKey}, exclusive
+ * @throws ClassCastException if {@code fromKey} and {@code toKey}
* cannot be compared to one another using this map's comparator
* (or, if the map has no comparator, using natural ordering).
* Implementations may, but are not required to, throw this
- * exception if fromKey or toKey
+ * exception if {@code fromKey} or {@code toKey}
* cannot be compared to keys currently in the map.
- * @throws NullPointerException if fromKey or toKey
+ * @throws NullPointerException if {@code fromKey} or {@code toKey}
* is null and this map does not permit null keys
- * @throws IllegalArgumentException if fromKey is greater than
- * toKey; or if this map itself has a restricted
- * range, and fromKey or toKey lies
+ * @throws IllegalArgumentException if {@code fromKey} is greater than
+ * {@code toKey}; or if this map itself has a restricted
+ * range, and {@code fromKey} or {@code toKey} lies
* outside the bounds of the range
*/
SortedMap subMap(K fromKey, K toKey);
/**
* Returns a view of the portion of this map whose keys are
- * strictly less than toKey. The returned map is backed
+ * strictly less than {@code toKey}. The returned map is backed
* by this map, so changes in the returned map are reflected in
* this map, and vice-versa. The returned map supports all
* optional map operations that this map supports.
*
- * The returned map will throw an IllegalArgumentException
+ *
The returned map will throw an {@code IllegalArgumentException}
* on an attempt to insert a key outside its range.
*
* @param toKey high endpoint (exclusive) of the keys in the returned map
* @return a view of the portion of this map whose keys are strictly
- * less than toKey
- * @throws ClassCastException if toKey is not compatible
+ * less than {@code toKey}
+ * @throws ClassCastException if {@code toKey} is not compatible
* with this map's comparator (or, if the map has no comparator,
- * if toKey does not implement {@link Comparable}).
+ * if {@code toKey} does not implement {@link Comparable}).
* Implementations may, but are not required to, throw this
- * exception if toKey cannot be compared to keys
+ * exception if {@code toKey} cannot be compared to keys
* currently in the map.
- * @throws NullPointerException if toKey is null and
+ * @throws NullPointerException if {@code toKey} is null and
* this map does not permit null keys
* @throws IllegalArgumentException if this map itself has a
- * restricted range, and toKey lies outside the
+ * restricted range, and {@code toKey} lies outside the
* bounds of the range
*/
SortedMap headMap(K toKey);
/**
* Returns a view of the portion of this map whose keys are
- * greater than or equal to fromKey. The returned map is
+ * greater than or equal to {@code fromKey}. The returned map is
* backed by this map, so changes in the returned map are
* reflected in this map, and vice-versa. The returned map
* supports all optional map operations that this map supports.
*
- * The returned map will throw an IllegalArgumentException
+ *
The returned map will throw an {@code IllegalArgumentException}
* on an attempt to insert a key outside its range.
*
* @param fromKey low endpoint (inclusive) of the keys in the returned map
* @return a view of the portion of this map whose keys are greater
- * than or equal to fromKey
- * @throws ClassCastException if fromKey is not compatible
+ * than or equal to {@code fromKey}
+ * @throws ClassCastException if {@code fromKey} is not compatible
* with this map's comparator (or, if the map has no comparator,
- * if fromKey does not implement {@link Comparable}).
+ * if {@code fromKey} does not implement {@link Comparable}).
* Implementations may, but are not required to, throw this
- * exception if fromKey cannot be compared to keys
+ * exception if {@code fromKey} cannot be compared to keys
* currently in the map.
- * @throws NullPointerException if fromKey is null and
+ * @throws NullPointerException if {@code fromKey} is null and
* this map does not permit null keys
* @throws IllegalArgumentException if this map itself has a
- * restricted range, and fromKey lies outside the
+ * restricted range, and {@code fromKey} lies outside the
* bounds of the range
*/
SortedMap tailMap(K fromKey);
@@ -228,12 +229,12 @@ public interface SortedMap extends Map {
* The set is backed by the map, so changes to the map are
* reflected in the set, and vice-versa. If the map is modified
* while an iteration over the set is in progress (except through
- * the iterator's own remove operation), the results of
+ * the iterator's own {@code remove} operation), the results of
* the iteration are undefined. The set supports element removal,
* which removes the corresponding mapping from the map, via the
- * Iterator.remove, Set.remove,
- * removeAll, retainAll, and clear
- * operations. It does not support the add or addAll
+ * {@code Iterator.remove}, {@code Set.remove},
+ * {@code removeAll}, {@code retainAll}, and {@code clear}
+ * operations. It does not support the {@code add} or {@code addAll}
* operations.
*
* @return a set view of the keys contained in this map, sorted in
@@ -248,13 +249,13 @@ public interface SortedMap extends Map {
* The collection is backed by the map, so changes to the map are
* reflected in the collection, and vice-versa. If the map is
* modified while an iteration over the collection is in progress
- * (except through the iterator's own remove operation),
+ * (except through the iterator's own {@code remove} operation),
* the results of the iteration are undefined. The collection
* supports element removal, which removes the corresponding
- * mapping from the map, via the Iterator.remove,
- * Collection.remove, removeAll,
- * retainAll and clear operations. It does not
- * support the add or addAll operations.
+ * mapping from the map, via the {@code Iterator.remove},
+ * {@code Collection.remove}, {@code removeAll},
+ * {@code retainAll} and {@code clear} operations. It does not
+ * support the {@code add} or {@code addAll} operations.
*
* @return a collection view of the values contained in this map,
* sorted in ascending key order
@@ -267,14 +268,14 @@ public interface SortedMap extends Map {
* The set is backed by the map, so changes to the map are
* reflected in the set, and vice-versa. If the map is modified
* while an iteration over the set is in progress (except through
- * the iterator's own remove operation, or through the
- * setValue operation on a map entry returned by the
+ * the iterator's own {@code remove} operation, or through the
+ * {@code setValue} operation on a map entry returned by the
* iterator) the results of the iteration are undefined. The set
* supports element removal, which removes the corresponding
- * mapping from the map, via the Iterator.remove,
- * Set.remove, removeAll, retainAll and
- * clear operations. It does not support the
- * add or addAll operations.
+ * mapping from the map, via the {@code Iterator.remove},
+ * {@code Set.remove}, {@code removeAll}, {@code retainAll} and
+ * {@code clear} operations. It does not support the
+ * {@code add} or {@code addAll} operations.
*
* @return a set view of the mappings contained in this map,
* sorted in ascending key order
diff --git a/src/share/classes/java/util/TimSort.java b/src/share/classes/java/util/TimSort.java
index f55a6b2136a70216934fb9eb6c42f2cf712271ae..0c2e1ec25c46d9a3a5443b61819dbed489049b92 100644
--- a/src/share/classes/java/util/TimSort.java
+++ b/src/share/classes/java/util/TimSort.java
@@ -274,7 +274,7 @@ class TimSort {
* pivot < all in [left, start), so pivot belongs at left. Note
* that if there are elements equal to pivot, left points to the
* first slot after them -- that's why this sort is stable.
- * Slide elements over to make room to make room for pivot.
+ * Slide elements over to make room for pivot.
*/
int n = start - left; // The number of elements to move
// Switch is just an optimization for arraycopy in default case
diff --git a/src/share/classes/java/util/jar/JarVerifier.java b/src/share/classes/java/util/jar/JarVerifier.java
index abbb85e3768862c8bf9e00a2820260a7fa1d49ca..4f84ac28effd82e57f9cbcacf4dc917bb3261ea1 100644
--- a/src/share/classes/java/util/jar/JarVerifier.java
+++ b/src/share/classes/java/util/jar/JarVerifier.java
@@ -415,6 +415,12 @@ class JarVerifier {
pendingBlocks = null;
signerCache = null;
manDig = null;
+ // MANIFEST.MF is always treated as signed and verified,
+ // move its signers from sigFileSigners to verifiedSigners.
+ if (sigFileSigners.containsKey(JarFile.MANIFEST_NAME)) {
+ verifiedSigners.put(JarFile.MANIFEST_NAME,
+ sigFileSigners.remove(JarFile.MANIFEST_NAME));
+ }
}
static class VerifierStream extends java.io.InputStream {
diff --git a/src/share/classes/java/util/logging/LogManager.java b/src/share/classes/java/util/logging/LogManager.java
index fb074721ab5f3ca2b34ea89e458717ccea99eb50..cf49a0a69b71e462199984d3f0d6c2359a3de85c 100644
--- a/src/share/classes/java/util/logging/LogManager.java
+++ b/src/share/classes/java/util/logging/LogManager.java
@@ -1166,7 +1166,12 @@ public class LogManager {
private static LoggingMXBean loggingMXBean = null;
/**
* String representation of the
- * {@link javax.management.ObjectName} for {@link LoggingMXBean}.
+ * {@link javax.management.ObjectName} for the management interface
+ * for the logging facility.
+ *
+ * @see java.lang.management.PlatformLoggingMXBean
+ * @see java.util.logging.LoggingMXBean
+ *
* @since 1.5
*/
public final static String LOGGING_MXBEAN_NAME
@@ -1174,20 +1179,20 @@ public class LogManager {
/**
* Returns LoggingMXBean for managing loggers.
- * An alternative way to manage loggers is using
- * the {@link java.lang.management.ManagementFactory#getPlatformMXBeans(Class)
- * ManagementFactory.getPlatformMXBeans} method as follows:
+ * An alternative way to manage loggers is through the
+ * {@link java.lang.management.PlatformLoggingMXBean} interface
+ * that can be obtained by calling:
*
- * List<{@link PlatformLoggingMXBean}> result = ManagementFactory.getPlatformMXBeans(PlatformLoggingMXBean.class);
+ * PlatformLoggingMXBean logging = {@link java.lang.management.ManagementFactory#getPlatformMXBean(Class)
+ * ManagementFactory.getPlatformMXBean}(PlatformLoggingMXBean.class);
*
*
* @return a {@link LoggingMXBean} object.
*
- * @see PlatformLoggingMXBean
- * @see java.lang.management.ManagementFactory
+ * @see java.lang.management.PlatformLoggingMXBean
* @since 1.5
*/
- public static synchronized LoggingMXBean getLoggingMXBean() {
+ public static synchronized LoggingMXBean getLoggingMXBean() {
if (loggingMXBean == null) {
loggingMXBean = new Logging();
}
diff --git a/src/share/classes/java/util/logging/LoggingMXBean.java b/src/share/classes/java/util/logging/LoggingMXBean.java
index d6700e098bc57c1f0700f8ddd3ce685aa76a94a0..2c9bad2feb80df8da460c8866dcf70ce031dd92c 100644
--- a/src/share/classes/java/util/logging/LoggingMXBean.java
+++ b/src/share/classes/java/util/logging/LoggingMXBean.java
@@ -27,36 +27,41 @@ package java.util.logging;
/**
- * The management interface for the logging facility.
+ * The management interface for the logging facility. It is recommended
+ * to use the {@link java.lang.management.PlatformLoggingMXBean} management
+ * interface that implements all attributes defined in this
+ * {@code LoggingMXBean}. The
+ * {@link java.lang.management.ManagementFactory#getPlatformMXBean(Class)
+ * ManagementFactory.getPlatformMXBean} method can be used to obtain
+ * the {@code PlatformLoggingMXBean} object representing the management
+ * interface for logging.
*
* There is a single global instance of the LoggingMXBean.
- * This instance is an
- * MXBean
- * can be obtained by calling
- * the {@link LogManager#getLoggingMXBean} method or from the
+ * This instance is an {@link javax.management.MXBean MXBean} that
+ * can be obtained by calling the {@link LogManager#getLoggingMXBean}
+ * method or from the
* {@linkplain java.lang.management.ManagementFactory#getPlatformMBeanServer
* platform MBeanServer}.
- *
- * The {@link javax.management.ObjectName ObjectName} for uniquely
- * identifying the LoggingMXBean within an MBeanServer is:
- *
- * {@link LogManager#LOGGING_MXBEAN_NAME
- * java.util.logging:type=Logging}
- *
- *
- * The instance registered in the platform MBeanServer with
- * this {@code ObjectName} is also a {@link PlatformLoggingMXBean}.
+ *
+ * The {@link javax.management.ObjectName ObjectName} that uniquely identifies
+ * the management interface for logging within the {@code MBeanServer} is:
+ *
+ * {@link LogManager#LOGGING_MXBEAN_NAME java.util.logging:type=Logging}
+ *
+ *
+ * The instance registered in the platform {@code MBeanServer}
+ * is also a {@link java.lang.management.PlatformLoggingMXBean}.
*
* @author Ron Mann
* @author Mandy Chung
* @since 1.5
*
- * @see PlatformLoggingMXBean
+ * @see java.lang.management.PlatformLoggingMXBean
*/
public interface LoggingMXBean {
/**
- * Returns the list of currently registered loggers. This method
+ * Returns the list of currently registered logger names. This method
* calls {@link LogManager#getLoggerNames} and returns a list
* of the logger names.
*
@@ -89,7 +94,7 @@ public interface LoggingMXBean {
*
* @see Logger#getLevel
*/
- public String getLoggerLevel( String loggerName );
+ public String getLoggerLevel(String loggerName);
/**
* Sets the specified logger to the specified new level.
@@ -115,7 +120,7 @@ public interface LoggingMXBean {
*
* @see Logger#setLevel
*/
- public void setLoggerLevel( String loggerName, String levelName );
+ public void setLoggerLevel(String loggerName, String levelName);
/**
* Returns the name of the parent for the specified logger.
diff --git a/src/share/classes/java/util/logging/LoggingProxyImpl.java b/src/share/classes/java/util/logging/LoggingProxyImpl.java
index 61e56db406bb2c5b8e3c78377b924eafa84cb896..8e027d66a47a8727be913fc0a13be581269276f1 100644
--- a/src/share/classes/java/util/logging/LoggingProxyImpl.java
+++ b/src/share/classes/java/util/logging/LoggingProxyImpl.java
@@ -99,4 +99,9 @@ class LoggingProxyImpl implements LoggingProxy {
public String getLevelName(Object level) {
return ((Level) level).getName();
}
+
+ @Override
+ public String getProperty(String key) {
+ return LogManager.getLogManager().getProperty(key);
+ }
}
diff --git a/src/share/classes/java/util/logging/PlatformLoggingMXBean.java b/src/share/classes/java/util/logging/PlatformLoggingMXBean.java
deleted file mode 100644
index 72297490ee409491bb9c218c096df38b4f6f2b59..0000000000000000000000000000000000000000
--- a/src/share/classes/java/util/logging/PlatformLoggingMXBean.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 2009, 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 java.util.logging;
-
-import java.lang.management.PlatformManagedObject;
-
-/**
- * The {@linkplain PlatformManagedObject platform managed object} for the
- * logging facility. This interface simply unifies {@link LoggingMXBean}
- * {@link PlatformManagedObject};
- * and it does not specify any new operations.
- *
- *
The {@link java.lang.management.ManagementFactory#getPlatformMXBeans(Class)
- * ManagementFactory.getPlatformMXBeans} method can be used to obtain
- * the {@code PlatformLoggingMXBean} object as follows:
- *
- * ManagementFactory.getPlatformMXBeans(PlatformLoggingMXBean.class);
- *
- * or from the {@linkplain java.lang.management.ManagementFactory#getPlatformMBeanServer
- * platform MBeanServer}.
- *
- * The {@link javax.management.ObjectName ObjectName} for uniquely
- * identifying the LoggingMXBean within an MBeanServer is:
- *
- * java.util.logging:type=Logging
- *
- *
- * The {@link PlatformManagedObject#getObjectName} method
- * can be used to obtain its {@code ObjectName}.
- *
- * @see java.lang.management.PlatformManagedObject
- *
- * @author Mandy Chung
- * @since 1.7
- */
-public interface PlatformLoggingMXBean extends LoggingMXBean, PlatformManagedObject {
-}
diff --git a/src/share/classes/java/util/logging/SimpleFormatter.java b/src/share/classes/java/util/logging/SimpleFormatter.java
index e318a047f2bb5f56cd6f4c21fa53c3e7078afc14..87f2c7eeba6b70af0e99a7a483e899ffa6df0785 100644
--- a/src/share/classes/java/util/logging/SimpleFormatter.java
+++ b/src/share/classes/java/util/logging/SimpleFormatter.java
@@ -29,31 +29,108 @@ package java.util.logging;
import java.io.*;
import java.text.*;
import java.util.Date;
+import sun.util.logging.LoggingSupport;
/**
- * Print a brief summary of the LogRecord in a human readable
+ * Print a brief summary of the {@code LogRecord} in a human readable
* format. The summary will typically be 1 or 2 lines.
*
+ *
+ *
+ * Configuration:
+ * The {@code SimpleFormatter} is initialized with the
+ * format string
+ * specified in the {@code java.util.logging.SimpleFormatter.format}
+ * property to {@linkplain #format format} the log messages.
+ * This property can be defined
+ * in the {@linkplain LogManager#getProperty logging properties}
+ * configuration file
+ * or as a system property. If this property is set in both
+ * the logging properties and system properties,
+ * the format string specified in the system property will be used.
+ * If this property is not defined or the given format string
+ * is {@linkplain java.util.IllegalFormatException illegal},
+ * the default format is implementation-specific.
+ *
* @since 1.4
+ * @see java.util.Formatter
*/
public class SimpleFormatter extends Formatter {
- Date dat = new Date();
- private final static String format = "{0,date} {0,time}";
- private MessageFormat formatter;
-
- private Object args[] = new Object[1];
-
- // Line separator string. This is the value of the line.separator
- // property at the moment that the SimpleFormatter was created.
- private String lineSeparator = java.security.AccessController.doPrivileged(
- new sun.security.action.GetPropertyAction("line.separator"));
+ // format string for printing the log record
+ private static final String format = LoggingSupport.getSimpleFormat();
+ private final Date dat = new Date();
/**
* Format the given LogRecord.
*
- * This method can be overridden in a subclass.
+ * The formatting can be customized by specifying the
+ * format string
+ * in the
+ * {@code java.util.logging.SimpleFormatter.format} property.
+ * The given {@code LogRecord} will be formatted as if by calling:
+ *
+ * {@link String#format String.format}(format, date, source, logger, level, message, thrown);
+ *
+ * where the arguments are:
+ *
+ * - {@code format} - the {@link java.util.Formatter
+ * java.util.Formatter} format string specified in the
+ * {@code java.util.logging.SimpleFormatter.format} property
+ * or the default format.
+ * - {@code date} - a {@link Date} object representing
+ * {@linkplain LogRecord#getMillis event time} of the log record.
+ * - {@code source} - a string representing the caller, if available;
+ * otherwise, the logger's name.
+ * - {@code logger} - the logger's name.
+ * - {@code level} - the {@linkplain Level#getLocalizedName
+ * log level}.
+ * - {@code message} - the formatted log message
+ * returned from the {@link Formatter#formatMessage(LogRecord)}
+ * method. It uses {@link java.text.MessageFormat java.text}
+ * formatting and does not use the {@code java.util.Formatter
+ * format} argument.
+ * - {@code thrown} - a string representing
+ * the {@linkplain LogRecord#getThrown throwable}
+ * associated with the log record and its backtrace
+ * beginning with a newline character, if any;
+ * otherwise, an empty string.
+ *
+ *
+ * Some example formats:
+ *
+ * - {@code java.util.logging.SimpleFormatter.format="%4$s: %5$s [%1$tc]%n"}
+ *
This prints 1 line with the log level ({@code 4$}),
+ * the log message ({@code 5$}) and the timestamp ({@code 1$}) in
+ * a square bracket.
+ *
+ * WARNING: warning message [Tue Mar 22 13:11:31 PDT 2011]
+ *
+ * - {@code java.util.logging.SimpleFormatter.format="%1$tc %2$s%n%4$s: %5$s%6$s%n"}
+ *
This prints 2 lines where the first line includes
+ * the timestamp ({@code 1$}) and the source ({@code 2$});
+ * the second line includes the log level ({@code 4$}) and
+ * the log message ({@code 5$}) followed with the throwable
+ * and its backtrace ({@code 6$}), if any:
+ *
+ * Tue Mar 22 13:11:31 PDT 2011 MyClass fatal
+ * SEVERE: several message with an exception
+ * java.lang.IllegalArgumentException: invalid argument
+ * at MyClass.mash(MyClass.java:9)
+ * at MyClass.crunch(MyClass.java:6)
+ * at MyClass.main(MyClass.java:3)
+ *
+ * - {@code java.util.logging.SimpleFormatter.format="%1$tb %1$td, %1$tY %1$tl:%1$tM:%1$tS %1$Tp %2$s%n%4$s: %5$s%n"}
+ *
This prints 2 lines similar to the example above
+ * with a different date/time formatting and does not print
+ * the throwable and its backtrace:
+ *
+ * Mar 22, 2011 1:11:31 PM MyClass fatal
+ * SEVERE: several message with an exception
+ *
+ *
+ * This method can also be overridden in a subclass.
* It is recommended to use the {@link Formatter#formatMessage}
* convenience method to localize and format the message field.
*
@@ -61,42 +138,32 @@ public class SimpleFormatter extends Formatter {
* @return a formatted log record
*/
public synchronized String format(LogRecord record) {
- StringBuffer sb = new StringBuffer();
- // Minimize memory allocations here.
dat.setTime(record.getMillis());
- args[0] = dat;
- StringBuffer text = new StringBuffer();
- if (formatter == null) {
- formatter = new MessageFormat(format);
- }
- formatter.format(args, text, null);
- sb.append(text);
- sb.append(" ");
+ String source;
if (record.getSourceClassName() != null) {
- sb.append(record.getSourceClassName());
+ source = record.getSourceClassName();
+ if (record.getSourceMethodName() != null) {
+ source += " " + record.getSourceMethodName();
+ }
} else {
- sb.append(record.getLoggerName());
+ source = record.getLoggerName();
}
- if (record.getSourceMethodName() != null) {
- sb.append(" ");
- sb.append(record.getSourceMethodName());
- }
- sb.append(lineSeparator);
String message = formatMessage(record);
- sb.append(record.getLevel().getLocalizedName());
- sb.append(": ");
- sb.append(message);
- sb.append(lineSeparator);
+ String throwable = "";
if (record.getThrown() != null) {
- try {
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- record.getThrown().printStackTrace(pw);
- pw.close();
- sb.append(sw.toString());
- } catch (Exception ex) {
- }
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ pw.println();
+ record.getThrown().printStackTrace(pw);
+ pw.close();
+ throwable = sw.toString();
}
- return sb.toString();
+ return String.format(format,
+ dat,
+ source,
+ record.getLoggerName(),
+ record.getLevel().getLocalizedName(),
+ message,
+ throwable);
}
}
diff --git a/src/share/classes/java/util/zip/DeflaterOutputStream.java b/src/share/classes/java/util/zip/DeflaterOutputStream.java
index e7a78cb5ce18855fa6efa399018159ca68cf54d1..96ade216719c4baa121de7bb89df353210b860ed 100644
--- a/src/share/classes/java/util/zip/DeflaterOutputStream.java
+++ b/src/share/classes/java/util/zip/DeflaterOutputStream.java
@@ -206,14 +206,9 @@ class DeflaterOutputStream extends FilterOutputStream {
return;
}
if (!def.finished()) {
- // Deflate no more than stride bytes at a time. This avoids
- // excess copying in deflateBytes (see Deflater.c)
- int stride = buf.length;
- for (int i = 0; i < len; i+= stride) {
- def.setInput(b, off + i, Math.min(stride, len - i));
- while (!def.needsInput()) {
- deflate();
- }
+ def.setInput(b, off, len);
+ while (!def.needsInput()) {
+ deflate();
}
}
}
diff --git a/src/share/classes/javax/net/ssl/KeyStoreBuilderParameters.java b/src/share/classes/javax/net/ssl/KeyStoreBuilderParameters.java
index 87b582fed305692d41632ef7b7ced18b928ad0ee..678b0a2ff6dfa7f96717bc84949e33df1da8d8ff 100644
--- a/src/share/classes/javax/net/ssl/KeyStoreBuilderParameters.java
+++ b/src/share/classes/javax/net/ssl/KeyStoreBuilderParameters.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -51,7 +51,7 @@ public class KeyStoreBuilderParameters implements ManagerFactoryParameters {
* @exception NullPointerException if builder is null
*/
public KeyStoreBuilderParameters(Builder builder) {
- parameters = Collections.singletonList(builder);
+ parameters = Collections.singletonList(Objects.requireNonNull(builder));
}
/**
@@ -64,11 +64,12 @@ public class KeyStoreBuilderParameters implements ManagerFactoryParameters {
* @exception IllegalArgumentException if parameters is an empty list
*/
public KeyStoreBuilderParameters(List parameters) {
- this.parameters = Collections.unmodifiableList(
- new ArrayList(parameters));
- if (this.parameters.isEmpty()) {
+ if (parameters.isEmpty()) {
throw new IllegalArgumentException();
}
+
+ this.parameters = Collections.unmodifiableList(
+ new ArrayList(parameters));
}
/**
diff --git a/src/share/classes/sun/awt/HToolkit.java b/src/share/classes/sun/awt/HToolkit.java
new file mode 100644
index 0000000000000000000000000000000000000000..edadb84f397dc2f0f76ce8663a6a4c6aacc9acec
--- /dev/null
+++ b/src/share/classes/sun/awt/HToolkit.java
@@ -0,0 +1,378 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. 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.awt;
+
+import java.awt.*;
+import java.awt.dnd.*;
+import java.awt.dnd.peer.DragSourceContextPeer;
+import java.awt.im.InputMethodHighlight;
+import java.awt.im.spi.InputMethodDescriptor;
+import java.awt.image.*;
+import java.awt.datatransfer.Clipboard;
+import java.awt.peer.*;
+import java.util.Map;
+import java.util.Properties;
+
+/*
+ * HToolkit is a platform independent Toolkit used
+ * with the HeadlessToolkit. It is primarily used
+ * in embedded JRE's that do not have sun/awt/X11 classes.
+ */
+public class HToolkit extends SunToolkit
+ implements ComponentFactory {
+
+ public HToolkit() {
+ }
+
+ /*
+ * Component peer objects - unsupported.
+ */
+
+ public WindowPeer createWindow(Window target)
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public FramePeer createFrame(Frame target)
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public DialogPeer createDialog(Dialog target)
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public ButtonPeer createButton(Button target)
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public TextFieldPeer createTextField(TextField target)
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public ChoicePeer createChoice(Choice target)
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public LabelPeer createLabel(Label target)
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public ListPeer createList(List target)
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public CheckboxPeer createCheckbox(Checkbox target)
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public ScrollbarPeer createScrollbar(Scrollbar target)
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public ScrollPanePeer createScrollPane(ScrollPane target)
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public TextAreaPeer createTextArea(TextArea target)
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public FileDialogPeer createFileDialog(FileDialog target)
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public MenuBarPeer createMenuBar(MenuBar target)
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public MenuPeer createMenu(Menu target)
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public PopupMenuPeer createPopupMenu(PopupMenu target)
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public MenuItemPeer createMenuItem(MenuItem target)
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public CheckboxMenuItemPeer createCheckboxMenuItem(CheckboxMenuItem target)
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public DragSourceContextPeer createDragSourceContextPeer(
+ DragGestureEvent dge)
+ throws InvalidDnDOperationException {
+ throw new InvalidDnDOperationException("Headless environment");
+ }
+
+ public RobotPeer createRobot(Robot target, GraphicsDevice screen)
+ throws AWTException, HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public KeyboardFocusManagerPeer createKeyboardFocusManagerPeer(KeyboardFocusManager manager) {
+ // See 6833019.
+ return
+ new KeyboardFocusManagerPeer() {
+ public Window getCurrentFocusedWindow() { return null; }
+ public void setCurrentFocusOwner(Component comp) {}
+ public Component getCurrentFocusOwner() { return null; }
+ public void clearGlobalFocusOwner(Window activeWindow) {}
+ };
+ }
+
+ public TrayIconPeer createTrayIcon(TrayIcon target)
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public SystemTrayPeer createSystemTray(SystemTray target)
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public boolean isTraySupported() {
+ return false;
+ }
+
+ public GlobalCursorManager getGlobalCursorManager()
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ /*
+ * Headless toolkit - unsupported.
+ */
+ protected void loadSystemColors(int[] systemColors)
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public ColorModel getColorModel()
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public int getScreenResolution()
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public Map mapInputMethodHighlight(InputMethodHighlight highlight)
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public int getMenuShortcutKeyMask()
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public boolean getLockingKeyState(int keyCode)
+ throws UnsupportedOperationException {
+ throw new HeadlessException();
+ }
+
+ public void setLockingKeyState(int keyCode, boolean on)
+ throws UnsupportedOperationException {
+ throw new HeadlessException();
+ }
+
+ public Cursor createCustomCursor(Image cursor, Point hotSpot, String name)
+ throws IndexOutOfBoundsException, HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public Dimension getBestCursorSize(int preferredWidth, int preferredHeight)
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public int getMaximumCursorColors()
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public T
+ createDragGestureRecognizer(Class abstractRecognizerClass,
+ DragSource ds, Component c,
+ int srcActions, DragGestureListener dgl)
+ {
+ return null;
+ }
+
+ public int getScreenHeight()
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public int getScreenWidth()
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public Dimension getScreenSize()
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public Insets getScreenInsets(GraphicsConfiguration gc)
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public void setDynamicLayout(boolean dynamic)
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ protected boolean isDynamicLayoutSet()
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public boolean isDynamicLayoutActive()
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ public Clipboard getSystemClipboard()
+ throws HeadlessException {
+ throw new HeadlessException();
+ }
+
+ /*
+ * Printing
+ */
+ public PrintJob getPrintJob(Frame frame, String jobtitle,
+ JobAttributes jobAttributes,
+ PageAttributes pageAttributes) {
+ if (frame != null) {
+ // Should never happen
+ throw new HeadlessException();
+ }
+ throw new IllegalArgumentException(
+ "PrintJob not supported in a headless environment");
+ }
+
+ public PrintJob getPrintJob(Frame frame, String doctitle, Properties props)
+ {
+ if (frame != null) {
+ // Should never happen
+ throw new HeadlessException();
+ }
+ throw new IllegalArgumentException(
+ "PrintJob not supported in a headless environment");
+ }
+
+ /*
+ * Headless toolkit - supported.
+ */
+
+ public void sync() {
+ // Do nothing
+ }
+
+ protected boolean syncNativeQueue(final long timeout) {
+ return false;
+ }
+
+ public void beep() {
+ // Send alert character
+ System.out.write(0x07);
+ }
+
+
+ /*
+ * Fonts
+ */
+ public FontPeer getFontPeer(String name, int style) {
+ return (FontPeer)null;
+ }
+
+ /*
+ * Modality
+ */
+ public boolean isModalityTypeSupported(Dialog.ModalityType modalityType) {
+ return false;
+ }
+
+ public boolean isModalExclusionTypeSupported(Dialog.ModalExclusionType exclusionType) {
+ return false;
+ }
+
+ public boolean isDesktopSupported() {
+ return false;
+ }
+
+ public DesktopPeer createDesktopPeer(Desktop target)
+ throws HeadlessException{
+ throw new HeadlessException();
+ }
+
+ public boolean isWindowOpacityControlSupported() {
+ return false;
+ }
+
+ public boolean isWindowShapingSupported() {
+ return false;
+ }
+
+ public boolean isWindowTranslucencySupported() {
+ return false;
+ }
+
+ public void grab(Window w) { }
+
+ public void ungrab(Window w) { }
+
+ protected boolean syncNativeQueue() { return false; }
+
+ public InputMethodDescriptor getInputMethodAdapterDescriptor()
+ throws AWTException
+ {
+ return (InputMethodDescriptor)null;
+ }
+}
diff --git a/src/share/classes/sun/management/ManagementFactoryHelper.java b/src/share/classes/sun/management/ManagementFactoryHelper.java
index 19aa6d7195444a3db0df81ff8f49036e60a30a6d..64ac47f9c4495a135eb15e45db5df1801ac51869 100644
--- a/src/share/classes/sun/management/ManagementFactoryHelper.java
+++ b/src/share/classes/sun/management/ManagementFactoryHelper.java
@@ -27,20 +27,18 @@ package sun.management;
import java.lang.management.*;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
import javax.management.InstanceAlreadyExistsException;
import javax.management.InstanceNotFoundException;
+import javax.management.MBeanServer;
import javax.management.MBeanRegistrationException;
import javax.management.NotCompliantMBeanException;
+import javax.management.ObjectName;
import javax.management.RuntimeOperationsException;
-import java.nio.BufferPoolMXBean;
import java.security.AccessController;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import sun.security.action.LoadLibraryAction;
-import java.util.logging.PlatformLoggingMXBean;
import sun.util.logging.LoggingSupport;
import java.util.ArrayList;
@@ -139,61 +137,80 @@ public class ManagementFactoryHelper {
return result;
}
- public static List getLoggingMXBean() {
+ public static PlatformLoggingMXBean getPlatformLoggingMXBean() {
if (LoggingSupport.isAvailable()) {
- return Collections.singletonList(createPlatformLoggingMXBean());
+ return PlatformLoggingImpl.instance;
} else {
- return Collections.emptyList();
+ return null;
}
}
- private final static String LOGGING_MXBEAN_NAME = "java.util.logging:type=Logging";
- private static PlatformLoggingMXBean createPlatformLoggingMXBean() {
- return new PlatformLoggingMXBean() {
- private volatile ObjectName objname; // created lazily
- @Override
- public ObjectName getObjectName() {
- ObjectName result = objname;
- if (result == null) {
- synchronized (this) {
- if (objname == null) {
- result = Util.newObjectName(LOGGING_MXBEAN_NAME);
- objname = result;
- }
+ // The logging MXBean object is an instance of
+ // PlatformLoggingMXBean and java.util.logging.LoggingMXBean
+ // but it can't directly implement two MXBean interfaces
+ // as a compliant MXBean implements exactly one MXBean interface,
+ // or if it implements one interface that is a subinterface of
+ // all the others; otherwise, it is a non-compliant MXBean
+ // and MBeanServer will throw NotCompliantMBeanException.
+ // See the Definition of an MXBean section in javax.management.MXBean spec.
+ //
+ // To create a compliant logging MXBean, define a LoggingMXBean interface
+ // that extend PlatformLoggingMXBean and j.u.l.LoggingMXBean
+ interface LoggingMXBean
+ extends PlatformLoggingMXBean, java.util.logging.LoggingMXBean {
+ }
+
+ static class PlatformLoggingImpl implements LoggingMXBean
+ {
+ final static PlatformLoggingMXBean instance = new PlatformLoggingImpl();
+ final static String LOGGING_MXBEAN_NAME = "java.util.logging:type=Logging";
+
+ private volatile ObjectName objname; // created lazily
+ @Override
+ public ObjectName getObjectName() {
+ ObjectName result = objname;
+ if (result == null) {
+ synchronized (this) {
+ if (objname == null) {
+ result = Util.newObjectName(LOGGING_MXBEAN_NAME);
+ objname = result;
}
}
- return result;
}
+ return result;
+ }
- @Override
- public java.util.List getLoggerNames() {
- return LoggingSupport.getLoggerNames();
- }
+ @Override
+ public java.util.List getLoggerNames() {
+ return LoggingSupport.getLoggerNames();
+ }
- @Override
- public String getLoggerLevel(String loggerName) {
- return LoggingSupport.getLoggerLevel(loggerName);
- }
+ @Override
+ public String getLoggerLevel(String loggerName) {
+ return LoggingSupport.getLoggerLevel(loggerName);
+ }
- @Override
- public void setLoggerLevel(String loggerName, String levelName) {
- LoggingSupport.setLoggerLevel(loggerName, levelName);
- }
+ @Override
+ public void setLoggerLevel(String loggerName, String levelName) {
+ LoggingSupport.setLoggerLevel(loggerName, levelName);
+ }
- @Override
- public String getParentLoggerName(String loggerName) {
- return LoggingSupport.getParentLoggerName(loggerName);
- }
- };
+ @Override
+ public String getParentLoggerName(String loggerName) {
+ return LoggingSupport.getParentLoggerName(loggerName);
+ }
}
- public static List getBufferPoolMXBeans() {
- List pools = new ArrayList(2);
- pools.add(createBufferPoolMXBean(sun.misc.SharedSecrets.getJavaNioAccess()
- .getDirectBufferPool()));
- pools.add(createBufferPoolMXBean(sun.nio.ch.FileChannelImpl
- .getMappedBufferPool()));
- return pools;
+ private static List bufferPools = null;
+ public static synchronized List getBufferPoolMXBeans() {
+ if (bufferPools == null) {
+ bufferPools = new ArrayList<>(2);
+ bufferPools.add(createBufferPoolMXBean(sun.misc.SharedSecrets.getJavaNioAccess()
+ .getDirectBufferPool()));
+ bufferPools.add(createBufferPoolMXBean(sun.nio.ch.FileChannelImpl
+ .getMappedBufferPool()));
+ }
+ return bufferPools;
}
private final static String BUFFER_POOL_MXBEAN_NAME = "java.nio:type=BufferPool";
diff --git a/src/share/classes/sun/misc/Version.java.template b/src/share/classes/sun/misc/Version.java.template
index 974526a915e1cc902560f8e5f43f717c1b11b0b9..62babae10084843abe769e62c062e93849cee8f5 100644
--- a/src/share/classes/sun/misc/Version.java.template
+++ b/src/share/classes/sun/misc/Version.java.template
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -36,8 +36,8 @@ public class Version {
"@@java_version@@";
private static final String java_runtime_name =
- "@@java_runtime_name@@";
-
+ "@@java_runtime_name@@";
+
private static final String java_runtime_version =
"@@java_runtime_version@@";
@@ -87,12 +87,26 @@ public class Version {
* Give a stream, it will print version info on it.
*/
public static void print(PrintStream ps) {
+ boolean isHeadless = false;
+
+ /* Report that we're running headless if the property is true */
+ String headless = System.getProperty("java.awt.headless");
+ if ( (headless != null) && (headless.equalsIgnoreCase("true")) ) {
+ isHeadless = true;
+ }
+
/* First line: platform version. */
ps.println(launcher_name + " version \"" + java_version + "\"");
/* Second line: runtime version (ie, libraries). */
- ps.println(java_runtime_name + " (build " +
- java_runtime_version + ")");
+
+ ps.print(java_runtime_name + " (build " + java_runtime_version);
+
+ if (java_runtime_name.indexOf("Embedded") != -1 && isHeadless) {
+ // embedded builds report headless state
+ ps.print(", headless");
+ }
+ ps.println(')');
/* Third line: JVM information. */
String java_vm_name = System.getProperty("java.vm.name");
diff --git a/src/share/classes/sun/nio/fs/Util.java b/src/share/classes/sun/nio/fs/Util.java
index 7628701116964fdd8980eb4ee9acfdfd53111bfb..6c94710dd8d68482f05b3ba99849831cbaed9fad 100644
--- a/src/share/classes/sun/nio/fs/Util.java
+++ b/src/share/classes/sun/nio/fs/Util.java
@@ -26,6 +26,7 @@
package sun.nio.fs;
import java.util.*;
+import java.nio.file.*;
/**
* Utility methods
@@ -80,4 +81,21 @@ class Util {
}
return set;
}
+
+ /**
+ * Returns {@code true} if symbolic links should be followed
+ */
+ static boolean followLinks(LinkOption... options) {
+ boolean followLinks = true;
+ for (LinkOption option: options) {
+ if (option == LinkOption.NOFOLLOW_LINKS) {
+ followLinks = false;
+ } else if (option == null) {
+ throw new NullPointerException();
+ } else {
+ throw new AssertionError("Should not get here");
+ }
+ }
+ return followLinks;
+ }
}
diff --git a/src/share/classes/sun/security/krb5/Realm.java b/src/share/classes/sun/security/krb5/Realm.java
index f7b450ec6be87b3ccfecd33e90be8f1b8da3a6e4..f148f868049a35b06b689f0a9f2249242f989394 100644
--- a/src/share/classes/sun/security/krb5/Realm.java
+++ b/src/share/classes/sun/security/krb5/Realm.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -362,19 +362,15 @@ public class Realm implements Cloneable {
Stack iStack = new Stack<>();
/*
- * I don't expect any more than a handful of intermediaries.
+ * The half-established reversed-path, starting from the final target
+ * (sRealm), each item can be connected to by the next one.
+ * Might contains wrong item, if found, a bad track is performed
*/
Vector tempList = new Vector<>(8, 8);
-
- /*
- * The initiator at first location.
- */
- tempList.add(cRealm);
+ tempList.add(sRealm);
int count = 0; // For debug only
- if (DEBUG) {
- tempTarget = sRealm;
- }
+ tempTarget = sRealm;
out: do {
if (DEBUG) {
@@ -384,8 +380,8 @@ public class Realm implements Cloneable {
}
if (intermediaries != null &&
- !intermediaries.equals(PrincipalName.REALM_COMPONENT_SEPARATOR_STR))
- {
+ !intermediaries.equals(".") &&
+ !intermediaries.equals(cRealm)) {
if (DEBUG) {
System.out.println(">>> Realm parseCapaths: loop " +
count + ": intermediaries=[" +
@@ -466,11 +462,15 @@ public class Realm implements Cloneable {
} while (true);
+ if (tempList.isEmpty()) {
+ return null;
+ }
+
+ // From (SREALM, T1, T2) to (CREALM, T2, T1)
retList = new String[tempList.size()];
- try {
- retList = tempList.toArray(retList);
- } catch (ArrayStoreException exc) {
- retList = null;
+ retList[0] = cRealm;
+ for (int i=1; i> 8));
- sig.update((byte)(tmp & 0x0ff));
- sig.update(dh_p);
-
- tmp = dh_g.length;
- sig.update((byte)(tmp >> 8));
- sig.update((byte)(tmp & 0x0ff));
- sig.update(dh_g);
-
- tmp = dh_Ys.length;
- sig.update((byte)(tmp >> 8));
- sig.update((byte)(tmp & 0x0ff));
- sig.update(dh_Ys);
- }
-
/*
* Construct from initialized DH key object, for DH_anon
* key exchange.
@@ -779,12 +738,6 @@ class DH_ServerKeyExchange extends ServerKeyExchange
signature = sig.sign();
}
- private void setValues(DHCrypt obj) {
- dh_p = toByteArray(obj.getModulus());
- dh_g = toByteArray(obj.getBase());
- dh_Ys = toByteArray(obj.getPublicKey());
- }
-
/*
* Construct a DH_ServerKeyExchange message from an input
* stream, as if sent from server to client for use with
@@ -875,6 +828,53 @@ class DH_ServerKeyExchange extends ServerKeyExchange
}
}
+ /* Return the Diffie-Hellman modulus */
+ BigInteger getModulus() {
+ return new BigInteger(1, dh_p);
+ }
+
+ /* Return the Diffie-Hellman base/generator */
+ BigInteger getBase() {
+ return new BigInteger(1, dh_g);
+ }
+
+ /* Return the server's Diffie-Hellman public key */
+ BigInteger getServerPublicKey() {
+ return new BigInteger(1, dh_Ys);
+ }
+
+ /*
+ * Update sig with nonces and Diffie-Hellman public key.
+ */
+ private void updateSignature(Signature sig, byte clntNonce[],
+ byte svrNonce[]) throws SignatureException {
+ int tmp;
+
+ sig.update(clntNonce);
+ sig.update(svrNonce);
+
+ tmp = dh_p.length;
+ sig.update((byte)(tmp >> 8));
+ sig.update((byte)(tmp & 0x0ff));
+ sig.update(dh_p);
+
+ tmp = dh_g.length;
+ sig.update((byte)(tmp >> 8));
+ sig.update((byte)(tmp & 0x0ff));
+ sig.update(dh_g);
+
+ tmp = dh_Ys.length;
+ sig.update((byte)(tmp >> 8));
+ sig.update((byte)(tmp & 0x0ff));
+ sig.update(dh_Ys);
+ }
+
+ private void setValues(DHCrypt obj) {
+ dh_p = toByteArray(obj.getModulus());
+ dh_g = toByteArray(obj.getBase());
+ dh_Ys = toByteArray(obj.getPublicKey());
+ }
+
int messageLength() {
int temp = 6; // overhead for p, g, y(s) values.
@@ -945,8 +945,7 @@ class DH_ServerKeyExchange extends ServerKeyExchange
* We support named curves only, no explicitly encoded curves.
*/
static final
-class ECDH_ServerKeyExchange extends ServerKeyExchange
-{
+class ECDH_ServerKeyExchange extends ServerKeyExchange {
// constants for ECCurveType
private final static int CURVE_EXPLICIT_PRIME = 1;
@@ -1120,10 +1119,12 @@ class ECDH_ServerKeyExchange extends ServerKeyExchange
}
int messageLength() {
- int sigLen = (signatureBytes == null) ? 0 : 2 + signatureBytes.length;
-
- if (protocolVersion.v >= ProtocolVersion.TLS12.v) {
- sigLen += SignatureAndHashAlgorithm.sizeInRecord();
+ int sigLen = 0;
+ if (signatureBytes != null) {
+ sigLen = 2 + signatureBytes.length;
+ if (protocolVersion.v >= ProtocolVersion.TLS12.v) {
+ sigLen += SignatureAndHashAlgorithm.sizeInRecord();
+ }
}
return 4 + pointBytes.length + sigLen;
@@ -1133,12 +1134,13 @@ class ECDH_ServerKeyExchange extends ServerKeyExchange
s.putInt8(CURVE_NAMED_CURVE);
s.putInt16(curveId);
s.putBytes8(pointBytes);
- if (protocolVersion.v >= ProtocolVersion.TLS12.v) {
- s.putInt8(preferableSignatureAlgorithm.getHashValue());
- s.putInt8(preferableSignatureAlgorithm.getSignatureValue());
- }
if (signatureBytes != null) {
+ if (protocolVersion.v >= ProtocolVersion.TLS12.v) {
+ s.putInt8(preferableSignatureAlgorithm.getHashValue());
+ s.putInt8(preferableSignatureAlgorithm.getSignatureValue());
+ }
+
s.putBytes16(signatureBytes);
}
}
@@ -1147,9 +1149,13 @@ class ECDH_ServerKeyExchange extends ServerKeyExchange
s.println("*** ECDH ServerKeyExchange");
if (debug != null && Debug.isOn("verbose")) {
- if (protocolVersion.v >= ProtocolVersion.TLS12.v) {
- s.println("Signature Algorithm " +
- preferableSignatureAlgorithm.getAlgorithmName());
+ if (signatureBytes == null) {
+ s.println("Anonymous");
+ } else {
+ if (protocolVersion.v >= ProtocolVersion.TLS12.v) {
+ s.println("Signature Algorithm " +
+ preferableSignatureAlgorithm.getAlgorithmName());
+ }
}
s.println("Server key: " + publicKey);
diff --git a/src/share/classes/sun/security/tools/JarSigner.java b/src/share/classes/sun/security/tools/JarSigner.java
index 4d0e032819e8b59c107c64bab7dccb2a600bb0bb..ca1006a840ee9879415472d0c9986586842e2191 100644
--- a/src/share/classes/sun/security/tools/JarSigner.java
+++ b/src/share/classes/sun/security/tools/JarSigner.java
@@ -1238,10 +1238,11 @@ public class JarSigner {
// Provide a helpful message when TSA is beyond a firewall
error(rb.getString("unable.to.sign.jar.") +
rb.getString("no.response.from.the.Timestamping.Authority.") +
- rb.getString("When.connecting.from.behind.a.firewall.then.an.HTTP.proxy.may.need.to.be.specified.") +
- rb.getString("Supply.the.following.options.to.jarsigner.") +
- "\n -J-Dhttp.proxyHost= " +
- "\n -J-Dhttp.proxyPort= ", e);
+ "\n -J-Dhttp.proxyHost=" +
+ "\n -J-Dhttp.proxyPort=\n" +
+ rb.getString("or") +
+ "\n -J-Dhttps.proxyHost= " +
+ "\n -J-Dhttps.proxyPort= ", e);
}
sfFilename = sf.getMetaName();
diff --git a/src/share/classes/sun/security/tools/JarSignerResources.java b/src/share/classes/sun/security/tools/JarSignerResources.java
index c3d8a6e38ec0ad0e99c0936edde23864fb0d2b45..cea8b253927887f4f6ce94107aacfb98c27270f7 100644
--- a/src/share/classes/sun/security/tools/JarSignerResources.java
+++ b/src/share/classes/sun/security/tools/JarSignerResources.java
@@ -181,11 +181,10 @@ public class JarSignerResources extends java.util.ListResourceBundle {
{"TSA.location.", "TSA location: "},
{"TSA.certificate.", "TSA certificate: "},
{"no.response.from.the.Timestamping.Authority.",
- "no response from the Timestamping Authority. "},
- {"When.connecting.from.behind.a.firewall.then.an.HTTP.proxy.may.need.to.be.specified.",
- "When connecting from behind a firewall then an HTTP proxy may need to be specified. "},
- {"Supply.the.following.options.to.jarsigner.",
- "Supply the following options to jarsigner: "},
+ "no response from the Timestamping Authority. When connecting"
+ + " from behind a firewall an HTTP or HTTPS proxy may need to"
+ + " be specified. Supply the following options to jarsigner:"},
+ {"or", "or"},
{"Certificate.not.found.for.alias.alias.must.reference.a.valid.KeyStore.entry.containing.an.X.509.public.key.certificate.for.the",
"Certificate not found for: {0}. {1} must reference a valid KeyStore entry containing an X.509 public key certificate for the Timestamping Authority."},
{"using.an.alternative.signing.mechanism",
diff --git a/src/share/classes/sun/security/tools/KeyTool.java b/src/share/classes/sun/security/tools/KeyTool.java
index 50349173a4166e08e3c4f2de2652ceb1534aaeab..d2749f5f8b2685edbf1d2d12cfa5abd71f8acb33 100644
--- a/src/share/classes/sun/security/tools/KeyTool.java
+++ b/src/share/classes/sun/security/tools/KeyTool.java
@@ -1740,16 +1740,19 @@ public final class KeyTool {
KeyStore.TrustedCertificateEntry.class)) {
// We have a trusted certificate entry
Certificate cert = keyStore.getCertificate(alias);
+ Object[] source = {"trustedCertEntry"};
+ String mf = new MessageFormat(
+ rb.getString("Entry.type.type.")).format(source) + "\n";
if (verbose && (cert instanceof X509Certificate)) {
- out.println(rb.getString("Entry.type.trustedCertEntry."));
+ out.println(mf);
printX509Cert((X509Certificate)cert, out);
} else if (rfc) {
- out.println(rb.getString("Entry.type.trustedCertEntry."));
+ out.println(mf);
dumpCert(cert, out);
} else if (debug) {
out.println(cert.toString());
} else {
- out.println(rb.getString("trustedCertEntry."));
+ out.println("trustedCertEntry, ");
out.println(rb.getString("Certificate.fingerprint.SHA1.")
+ getCertFingerPrint("SHA1", cert));
}
@@ -1836,10 +1839,6 @@ public final class KeyTool {
(".WARNING.WARNING.WARNING."));
System.err.println(rb.getString
(".The.integrity.of.the.information.stored.in.the.srckeystore."));
- System.err.println(rb.getString
- (".has.NOT.been.verified.In.order.to.verify.its.integrity."));
- System.err.println(rb.getString
- (".you.must.provide.the.srckeystore.password."));
System.err.println(rb.getString
(".WARNING.WARNING.WARNING."));
System.err.println();
@@ -3186,10 +3185,6 @@ public final class KeyTool {
(".WARNING.WARNING.WARNING."));
System.err.println(rb.getString
(".The.integrity.of.the.information.stored.in.your.keystore."));
- System.err.println(rb.getString
- (".has.NOT.been.verified.In.order.to.verify.its.integrity."));
- System.err.println(rb.getString
- (".you.must.provide.your.keystore.password."));
System.err.println(rb.getString
(".WARNING.WARNING.WARNING."));
System.err.println();
diff --git a/src/share/classes/sun/security/tools/TimestampedSigner.java b/src/share/classes/sun/security/tools/TimestampedSigner.java
index 6d5eb63b7fddec4d94c832042723967ec45f3e59..349607af7202bdf7d42216fca95d26d9c68c4bb4 100644
--- a/src/share/classes/sun/security/tools/TimestampedSigner.java
+++ b/src/share/classes/sun/security/tools/TimestampedSigner.java
@@ -250,10 +250,10 @@ public final class TimestampedSigner extends ContentSigner {
* (RFC 3280).
* The extension's accessMethod field should contain the object
* identifier defined for timestamping: 1.3.6.1.5.5.7.48.3 and its
- * accessLocation field should contain an HTTP URL.
+ * accessLocation field should contain an HTTP or HTTPS URL.
*
* @param tsaCertificate An X.509 certificate for the TSA.
- * @return An HTTP URL or null if none was found.
+ * @return An HTTP or HTTPS URL or null if none was found.
*/
public static String getTimestampingUrl(X509Certificate tsaCertificate) {
@@ -279,7 +279,8 @@ public final class TimestampedSigner extends ContentSigner {
location = description.getAccessLocation();
if (location.getType() == GeneralNameInterface.NAME_URI) {
uri = (URIName) location.getName();
- if (uri.getScheme().equalsIgnoreCase("http")) {
+ if (uri.getScheme().equalsIgnoreCase("http") ||
+ uri.getScheme().equalsIgnoreCase("https")) {
return uri.getName();
}
}
diff --git a/src/share/classes/sun/security/util/AuthResources.java b/src/share/classes/sun/security/util/AuthResources.java
index 68d8d9edbe247d3bb95c363797803e951c3c9260..8821b87988ae78bf2b3399978d92183431eb7b35 100644
--- a/src/share/classes/sun/security/util/AuthResources.java
+++ b/src/share/classes/sun/security/util/AuthResources.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -111,17 +111,15 @@ public class AuthResources extends java.util.ListResourceBundle {
// com.sun.security.auth.PolicyParser
{"expected.keystore.type", "expected keystore type"},
- {"can.not.specify.Principal.with.a.",
- "can not specify Principal with a "},
- {"wildcard.class.without.a.wildcard.name",
- "wildcard class without a wildcard name"},
+ {"can.not.specify.Principal.with.a.wildcard.class.without.a.wildcard.name",
+ "can not specify Principal with a wildcard class without a wildcard name"},
{"expected.codeBase.or.SignedBy", "expected codeBase or SignedBy"},
{"only.Principal.based.grant.entries.permitted",
"only Principal-based grant entries permitted"},
{"expected.permission.entry", "expected permission entry"},
{"number.", "number "},
- {"expected.", "expected "},
- {".read.end.of.file", ", read end of file"},
+ {"expected.expect.read.end.of.file.",
+ "expected {0}, read end of file"},
{"expected.read.end.of.file", "expected ';', read end of file"},
{"line.", "line "},
{".expected.", ": expected '"},
@@ -136,6 +134,9 @@ public class AuthResources extends java.util.ListResourceBundle {
{"SolarisNumericUserPrincipal.",
"SolarisNumericUserPrincipal: "},
{"SolarisPrincipal.", "SolarisPrincipal: "},
+ // provided.null.name is the NullPointerException message when a
+ // developer incorrectly passes a null name to the constructor of
+ // subclasses of java.security.Principal
{"provided.null.name", "provided null name"}
};
diff --git a/src/share/classes/sun/security/util/ManifestEntryVerifier.java b/src/share/classes/sun/security/util/ManifestEntryVerifier.java
index 3bcc18a7456cb94f9a5965c8e361b17c417d8c48..9eee5421da549ced050806101e1af6faad3e1e00 100644
--- a/src/share/classes/sun/security/util/ManifestEntryVerifier.java
+++ b/src/share/classes/sun/security/util/ManifestEntryVerifier.java
@@ -195,8 +195,7 @@ public class ManifestEntryVerifier {
Hashtable sigFileSigners)
throws JarException
{
- // MANIFEST.MF should not be skipped. It has signers.
- if (skip && !entry.getName().equals(JarFile.MANIFEST_NAME)) {
+ if (skip) {
return null;
}
diff --git a/src/share/classes/sun/security/util/Resources.java b/src/share/classes/sun/security/util/Resources.java
index 5489c3d9eaa86e3a4ea1239a6577cc2027e6a3a8..299facc668ad512bd4c2ed6bd0c2d61fc5c3a887 100644
--- a/src/share/classes/sun/security/util/Resources.java
+++ b/src/share/classes/sun/security/util/Resources.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -304,8 +304,6 @@ public class Resources extends java.util.ListResourceBundle {
{"Certificate.chain.length.", "Certificate chain length: "},
{"Certificate.i.1.", "Certificate[{0,number,integer}]:"},
{"Certificate.fingerprint.SHA1.", "Certificate fingerprint (SHA1): "},
- {"Entry.type.trustedCertEntry.", "Entry type: trustedCertEntry\n"},
- {"trustedCertEntry.", "trustedCertEntry,"},
{"Keystore.type.", "Keystore type: "},
{"Keystore.provider.", "Keystore provider: "},
{"Your.keystore.contains.keyStore.size.entry",
@@ -378,21 +376,15 @@ public class Resources extends java.util.ListResourceBundle {
{"No.certificate.from.the.SSL.server",
"No certificate from the SSL server"},
- // Translators of the following 5 pairs, ATTENTION:
- // the next 5 string pairs are meant to be combined into 2 paragraphs,
- // 1+3+4 and 2+3+5. make sure your translation also does.
{".The.integrity.of.the.information.stored.in.your.keystore.",
- "* The integrity of the information stored in your keystore *"},
- {".The.integrity.of.the.information.stored.in.the.srckeystore.",
- "* The integrity of the information stored in the srckeystore*"},
- {".has.NOT.been.verified.In.order.to.verify.its.integrity.",
- "* has NOT been verified! In order to verify its integrity, *"},
- {".you.must.provide.your.keystore.password.",
+ "* The integrity of the information stored in your keystore *\n" +
+ "* has NOT been verified! In order to verify its integrity, *\n" +
"* you must provide your keystore password. *"},
- {".you.must.provide.the.srckeystore.password.",
+ {".The.integrity.of.the.information.stored.in.the.srckeystore.",
+ "* The integrity of the information stored in the srckeystore*\n" +
+ "* has NOT been verified! In order to verify its integrity, *\n" +
"* you must provide the srckeystore password. *"},
-
{"Certificate.reply.does.not.contain.public.key.for.alias.",
"Certificate reply does not contain public key for <{0}>"},
{"Incomplete.certificate.chain.in.reply",
diff --git a/src/share/classes/sun/text/bidi/BidiBase.java b/src/share/classes/sun/text/bidi/BidiBase.java
index d3457dd5c61050cd78421f173d6e87bae4488413..8be648e931c794fc49bc0f9925030b1dbb69f407 100644
--- a/src/share/classes/sun/text/bidi/BidiBase.java
+++ b/src/share/classes/sun/text/bidi/BidiBase.java
@@ -3457,13 +3457,18 @@ public class BidiBase {
*/
static final AttributedCharacterIterator.Attribute RUN_DIRECTION =
getTextAttribute("RUN_DIRECTION");
- static final Boolean RUN_DIRECTION_LTR =
- (Boolean)getStaticField(clazz, "RUN_DIRECTION_LTR");
static final AttributedCharacterIterator.Attribute NUMERIC_SHAPING =
getTextAttribute("NUMERIC_SHAPING");
static final AttributedCharacterIterator.Attribute BIDI_EMBEDDING =
getTextAttribute("BIDI_EMBEDDING");
+ /**
+ * TextAttribute.RUN_DIRECTION_LTR
+ */
+ static final Boolean RUN_DIRECTION_LTR = (clazz == null) ?
+ Boolean.FALSE : (Boolean)getStaticField(clazz, "RUN_DIRECTION_LTR");
+
+
private static Class> getClass(String name) {
try {
return Class.forName(name, true, null);
@@ -3473,25 +3478,23 @@ public class BidiBase {
}
private static Object getStaticField(Class> clazz, String name) {
- if (clazz == null) {
- // fake attribute
- return new AttributedCharacterIterator.Attribute(name) { };
- } else {
- try {
- Field f = clazz.getField(name);
- return f.get(null);
- } catch (NoSuchFieldException x) {
- throw new AssertionError(x);
- } catch (IllegalAccessException x) {
- throw new AssertionError(x);
- }
+ try {
+ Field f = clazz.getField(name);
+ return f.get(null);
+ } catch (NoSuchFieldException | IllegalAccessException x) {
+ throw new AssertionError(x);
}
}
private static AttributedCharacterIterator.Attribute
getTextAttribute(String name)
{
- return (AttributedCharacterIterator.Attribute)getStaticField(clazz, name);
+ if (clazz == null) {
+ // fake attribute
+ return new AttributedCharacterIterator.Attribute(name) { };
+ } else {
+ return (AttributedCharacterIterator.Attribute)getStaticField(clazz, name);
+ }
}
}
diff --git a/src/share/classes/sun/util/calendar/ZoneInfoFile.java b/src/share/classes/sun/util/calendar/ZoneInfoFile.java
index c6251ade5122e4bb6675e26a5ef3f0a33fcb8d29..891817776aaeb72d435b5dcd94ff068f541aae85 100644
--- a/src/share/classes/sun/util/calendar/ZoneInfoFile.java
+++ b/src/share/classes/sun/util/calendar/ZoneInfoFile.java
@@ -479,7 +479,7 @@ public class ZoneInfoFile {
String zi = System.getProperty("java.home") +
File.separator + "lib" + File.separator + "zi";
try {
- zi = FileSystems.getDefault().getPath(zi).toRealPath(true).toString();
+ zi = FileSystems.getDefault().getPath(zi).toRealPath().toString();
} catch(Exception e) {
}
return zi;
diff --git a/src/share/classes/sun/util/logging/LoggingProxy.java b/src/share/classes/sun/util/logging/LoggingProxy.java
index bb3fc78066e0d8b5a3823a16b4f4686fcb5fbe91..c3cbfd614fc1d8181fb8bf0233573148ca2b398d 100644
--- a/src/share/classes/sun/util/logging/LoggingProxy.java
+++ b/src/share/classes/sun/util/logging/LoggingProxy.java
@@ -60,4 +60,7 @@ public interface LoggingProxy {
public Object parseLevel(String levelName);
public String getLevelName(Object level);
+
+ // return the logging property
+ public String getProperty(String key);
}
diff --git a/src/share/classes/sun/util/logging/LoggingSupport.java b/src/share/classes/sun/util/logging/LoggingSupport.java
index 1c1b140d50ee04c0c06742ec76ddd973a50879f6..c5a2200c5e7610ad193c95bb541e3c09b41d8b20 100644
--- a/src/share/classes/sun/util/logging/LoggingSupport.java
+++ b/src/share/classes/sun/util/logging/LoggingSupport.java
@@ -29,6 +29,7 @@ package sun.util.logging;
import java.lang.reflect.Field;
import java.security.AccessController;
import java.security.PrivilegedAction;
+import java.util.Date;
/**
* Internal API to support JRE implementation to detect if the java.util.logging
@@ -138,4 +139,42 @@ public class LoggingSupport {
ensureAvailable();
return proxy.getLevelName(level);
}
+
+ private static final String DEFAULT_FORMAT =
+ "%1$tb %1$td, %1$tY %1$tl:%1$tM:%1$tS %1$Tp %2$s%n%4$s: %5$s%6$s%n";
+
+ private static final String FORMAT_PROP_KEY = "java.util.logging.SimpleFormatter.format";
+ public static String getSimpleFormat() {
+ return getSimpleFormat(true);
+ }
+
+ // useProxy if true will cause initialization of
+ // java.util.logging and read its configuration
+ static String getSimpleFormat(boolean useProxy) {
+ String format =
+ AccessController.doPrivileged(
+ new PrivilegedAction() {
+ public String run() {
+ return System.getProperty(FORMAT_PROP_KEY);
+ }
+ });
+
+ if (useProxy && proxy != null && format == null) {
+ format = proxy.getProperty(FORMAT_PROP_KEY);
+ }
+
+ if (format != null) {
+ try {
+ // validate the user-defined format string
+ String.format(format, new Date(), "", "", "", "", "");
+ } catch (IllegalArgumentException e) {
+ // illegal syntax; fall back to the default format
+ format = DEFAULT_FORMAT;
+ }
+ } else {
+ format = DEFAULT_FORMAT;
+ }
+ return format;
+ }
+
}
diff --git a/src/share/classes/sun/util/logging/PlatformLogger.java b/src/share/classes/sun/util/logging/PlatformLogger.java
index 98fd0196746b457839d9e7fd02a911f995552bfe..c1420c8f278bc82ef38540ec3c3ec2be52277331 100644
--- a/src/share/classes/sun/util/logging/PlatformLogger.java
+++ b/src/share/classes/sun/util/logging/PlatformLogger.java
@@ -316,12 +316,6 @@ public class PlatformLogger {
*/
static class LoggerProxy {
private static final PrintStream defaultStream = System.err;
- private static final String lineSeparator = AccessController.doPrivileged(
- new PrivilegedAction() {
- public String run() {
- return System.getProperty("line.separator");
- }
- });
final String name;
volatile int levelValue;
@@ -353,14 +347,14 @@ public class PlatformLogger {
if (level < levelValue || levelValue == OFF) {
return;
}
- defaultStream.println(format(level, msg, null));
+ defaultStream.print(format(level, msg, null));
}
void doLog(int level, String msg, Throwable thrown) {
if (level < levelValue || levelValue == OFF) {
return;
}
- defaultStream.println(format(level, msg, thrown));
+ defaultStream.print(format(level, msg, thrown));
}
void doLog(int level, String msg, Object... params) {
@@ -368,7 +362,7 @@ public class PlatformLogger {
return;
}
String newMsg = formatMessage(msg, params);
- defaultStream.println(format(level, newMsg, null));
+ defaultStream.print(format(level, newMsg, null));
}
public boolean isLoggable(int level) {
@@ -378,12 +372,6 @@ public class PlatformLogger {
return true;
}
- private static final String format = "{0,date} {0,time}";
-
- private Object args[] = new Object[1];
- private MessageFormat formatter;
- private Date dat;
-
// Copied from java.util.logging.Formatter.formatMessage
private String formatMessage(String format, Object... parameters) {
// Do the formatting.
@@ -408,37 +396,30 @@ public class PlatformLogger {
}
}
+ private static final String formatString =
+ LoggingSupport.getSimpleFormat(false); // don't check logging.properties
+
+ // minimize memory allocation
+ private Date date = new Date();
private synchronized String format(int level, String msg, Throwable thrown) {
- StringBuffer sb = new StringBuffer();
- // Minimize memory allocations here.
- if (dat == null) {
- dat = new Date();
- formatter = new MessageFormat(format);
- }
- dat.setTime(System.currentTimeMillis());
- args[0] = dat;
- StringBuffer text = new StringBuffer();
- formatter.format(args, text, null);
- sb.append(text);
- sb.append(" ");
- sb.append(getCallerInfo());
- sb.append(lineSeparator);
- sb.append(PlatformLogger.getLevelName(level));
- sb.append(": ");
- sb.append(msg);
+ date.setTime(System.currentTimeMillis());
+ String throwable = "";
if (thrown != null) {
- try {
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- thrown.printStackTrace(pw);
- pw.close();
- sb.append(sw.toString());
- } catch (Exception ex) {
- throw new AssertionError(ex);
- }
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ pw.println();
+ thrown.printStackTrace(pw);
+ pw.close();
+ throwable = sw.toString();
}
- return sb.toString();
+ return String.format(formatString,
+ date,
+ getCallerInfo(),
+ name,
+ PlatformLogger.getLevelName(level),
+ msg,
+ throwable);
}
// Returns the caller's class and method's name; best effort
diff --git a/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileSystemProvider.java b/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileSystemProvider.java
index d8aa305d29b1ab1be0913966f75656406d3a6a54..530c8864ba61d02ecd6370ef42d53fc9577cf1ae 100644
--- a/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileSystemProvider.java
+++ b/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileSystemProvider.java
@@ -99,7 +99,7 @@ public class ZipFileSystemProvider extends FileSystemProvider {
synchronized(filesystems) {
Path realPath = null;
if (ensureFile(path)) {
- realPath = path.toRealPath(true);
+ realPath = path.toRealPath();
if (filesystems.containsKey(realPath))
throw new FileSystemAlreadyExistsException();
}
@@ -154,7 +154,7 @@ public class ZipFileSystemProvider extends FileSystemProvider {
synchronized (filesystems) {
ZipFileSystem zipfs = null;
try {
- zipfs = filesystems.get(uriToPath(uri).toRealPath(true));
+ zipfs = filesystems.get(uriToPath(uri).toRealPath());
} catch (IOException x) {
// ignore the ioe from toRealPath(), return FSNFE
}
@@ -310,7 +310,7 @@ public class ZipFileSystemProvider extends FileSystemProvider {
//////////////////////////////////////////////////////////////
void removeFileSystem(Path zfpath, ZipFileSystem zfs) throws IOException {
synchronized (filesystems) {
- zfpath = zfpath.toRealPath(true);
+ zfpath = zfpath.toRealPath();
if (filesystems.get(zfpath) == zfs)
filesystems.remove(zfpath);
}
diff --git a/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipPath.java b/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipPath.java
index 1232a27ff1f0b2c1f0d1cb9d6307854a5e22e630..8c97818b24482f3fde4f129a7f46185054d041e7 100644
--- a/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipPath.java
+++ b/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipPath.java
@@ -150,7 +150,7 @@ public class ZipPath implements Path {
}
@Override
- public ZipPath toRealPath(boolean resolveLinks) throws IOException {
+ public ZipPath toRealPath(LinkOption... options) throws IOException {
ZipPath realPath = new ZipPath(zfs, getResolvedPath()).toAbsolutePath();
realPath.checkAccess();
return realPath;
diff --git a/src/share/lib/logging.properties b/src/share/lib/logging.properties
index 4f7f6dcfd416d3e0b6b1c45ab8cd985ed3e6ea49..65cf1b1b7dc9700ada1f3412ca2605ac7bb6b226 100644
--- a/src/share/lib/logging.properties
+++ b/src/share/lib/logging.properties
@@ -43,6 +43,11 @@ java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter
java.util.logging.ConsoleHandler.level = INFO
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
+# Example to customize the SimpleFormatter output format
+# to print one-line log message like this:
+# : []
+#
+# java.util.logging.SimpleFormatter.format=%4$s: %5$s [%1$tc]%n
############################################################
# Facility specific properties.
diff --git a/src/share/native/java/util/zip/Deflater.c b/src/share/native/java/util/zip/Deflater.c
index 3b32750a2985fd42ee8f01464de3a90616841ae7..6cad24e480a82b99573841a00f787603433950fb 100644
--- a/src/share/native/java/util/zip/Deflater.c
+++ b/src/share/native/java/util/zip/Deflater.c
@@ -129,34 +129,28 @@ Java_java_util_zip_Deflater_deflateBytes(JNIEnv *env, jobject this, jlong addr,
if ((*env)->GetBooleanField(env, this, setParamsID)) {
int level = (*env)->GetIntField(env, this, levelID);
int strategy = (*env)->GetIntField(env, this, strategyID);
-
- in_buf = (jbyte *) malloc(this_len);
- if (in_buf == 0) {
+ in_buf = (*env)->GetPrimitiveArrayCritical(env, this_buf, 0);
+ if (in_buf == NULL) {
// Throw OOME only when length is not zero
if (this_len != 0)
JNU_ThrowOutOfMemoryError(env, 0);
return 0;
}
- (*env)->GetByteArrayRegion(env, this_buf, this_off, this_len, in_buf);
- out_buf = (jbyte *) malloc(len);
- if (out_buf == 0) {
- free(in_buf);
+ out_buf = (*env)->GetPrimitiveArrayCritical(env, b, 0);
+ if (out_buf == NULL) {
+ (*env)->ReleasePrimitiveArrayCritical(env, this_buf, in_buf, 0);
if (len != 0)
JNU_ThrowOutOfMemoryError(env, 0);
return 0;
}
- strm->next_in = (Bytef *) in_buf;
- strm->next_out = (Bytef *) out_buf;
+ strm->next_in = (Bytef *) (in_buf + this_off);
+ strm->next_out = (Bytef *) (out_buf + off);
strm->avail_in = this_len;
strm->avail_out = len;
res = deflateParams(strm, level, strategy);
-
- if (res == Z_OK) {
- (*env)->SetByteArrayRegion(env, b, off, len - strm->avail_out, out_buf);
- }
- free(out_buf);
- free(in_buf);
+ (*env)->ReleasePrimitiveArrayCritical(env, b, out_buf, 0);
+ (*env)->ReleasePrimitiveArrayCritical(env, this_buf, in_buf, 0);
switch (res) {
case Z_OK:
@@ -174,33 +168,28 @@ Java_java_util_zip_Deflater_deflateBytes(JNIEnv *env, jobject this, jlong addr,
}
} else {
jboolean finish = (*env)->GetBooleanField(env, this, finishID);
- in_buf = (jbyte *) malloc(this_len);
- if (in_buf == 0) {
+ in_buf = (*env)->GetPrimitiveArrayCritical(env, this_buf, 0);
+ if (in_buf == NULL) {
if (this_len != 0)
JNU_ThrowOutOfMemoryError(env, 0);
return 0;
}
- (*env)->GetByteArrayRegion(env, this_buf, this_off, this_len, in_buf);
-
- out_buf = (jbyte *) malloc(len);
- if (out_buf == 0) {
- free(in_buf);
+ out_buf = (*env)->GetPrimitiveArrayCritical(env, b, 0);
+ if (out_buf == NULL) {
+ (*env)->ReleasePrimitiveArrayCritical(env, this_buf, in_buf, 0);
if (len != 0)
JNU_ThrowOutOfMemoryError(env, 0);
+
return 0;
}
- strm->next_in = (Bytef *) in_buf;
- strm->next_out = (Bytef *) out_buf;
+ strm->next_in = (Bytef *) (in_buf + this_off);
+ strm->next_out = (Bytef *) (out_buf + off);
strm->avail_in = this_len;
strm->avail_out = len;
res = deflate(strm, finish ? Z_FINISH : flush);
-
- if (res == Z_STREAM_END || res == Z_OK) {
- (*env)->SetByteArrayRegion(env, b, off, len - strm->avail_out, out_buf);
- }
- free(out_buf);
- free(in_buf);
+ (*env)->ReleasePrimitiveArrayCritical(env, b, out_buf, 0);
+ (*env)->ReleasePrimitiveArrayCritical(env, this_buf, in_buf, 0);
switch (res) {
case Z_STREAM_END:
diff --git a/src/share/native/java/util/zip/Inflater.c b/src/share/native/java/util/zip/Inflater.c
index dbf9a1357aecad5388a29ed598c4714023b8113b..e5296fcf4c6db6c126bea37849e1f2582517de40 100644
--- a/src/share/native/java/util/zip/Inflater.c
+++ b/src/share/native/java/util/zip/Inflater.c
@@ -38,8 +38,6 @@
#include "zlib.h"
#include "java_util_zip_Inflater.h"
-#define MIN2(x, y) ((x) < (y) ? (x) : (y))
-
#define ThrowDataFormatException(env, msg) \
JNU_ThrowByName(env, "java/util/zip/DataFormatException", msg)
@@ -111,71 +109,50 @@ Java_java_util_zip_Inflater_inflateBytes(JNIEnv *env, jobject this, jlong addr,
jarray b, jint off, jint len)
{
z_stream *strm = jlong_to_ptr(addr);
-
jarray this_buf = (jarray)(*env)->GetObjectField(env, this, bufID);
jint this_off = (*env)->GetIntField(env, this, offID);
jint this_len = (*env)->GetIntField(env, this, lenID);
+
jbyte *in_buf;
jbyte *out_buf;
int ret;
- /*
- * Avoid excess copying.
- * zlib stream usually has a few bytes of overhead for header info
- * (depends on the underlying data)
- *
- * (a) 5 bytes per 16KB
- * (b) 6 bytes for entire stream
- * (c) 4 bytes for gzip header
- * (d) 2 bytes for crc
- *
- * Use 20 bytes as the "safe cutoff" number.
- */
- jint in_len = MIN2(this_len, len + 20);
- jint consumed;
-
- in_buf = (jbyte *) malloc(in_len);
- if (in_buf == 0) {
- if (in_len != 0)
+
+ in_buf = (*env)->GetPrimitiveArrayCritical(env, this_buf, 0);
+ if (in_buf == NULL) {
+ if (this_len != 0)
JNU_ThrowOutOfMemoryError(env, 0);
return 0;
}
- (*env)->GetByteArrayRegion(env, this_buf, this_off, in_len, in_buf);
-
- out_buf = (jbyte *) malloc(len);
- if (out_buf == 0) {
- free(in_buf);
+ out_buf = (*env)->GetPrimitiveArrayCritical(env, b, 0);
+ if (out_buf == NULL) {
+ (*env)->ReleasePrimitiveArrayCritical(env, this_buf, in_buf, 0);
if (len != 0)
JNU_ThrowOutOfMemoryError(env, 0);
return 0;
}
-
- strm->next_in = (Bytef *) in_buf;
- strm->next_out = (Bytef *) out_buf;
- strm->avail_in = in_len;
+ strm->next_in = (Bytef *) (in_buf + this_off);
+ strm->next_out = (Bytef *) (out_buf + off);
+ strm->avail_in = this_len;
strm->avail_out = len;
ret = inflate(strm, Z_PARTIAL_FLUSH);
-
- if (ret == Z_STREAM_END || ret == Z_OK) {
- (*env)->SetByteArrayRegion(env, b, off, len - strm->avail_out, out_buf);
- }
- free(out_buf);
- free(in_buf);
+ (*env)->ReleasePrimitiveArrayCritical(env, b, out_buf, 0);
+ (*env)->ReleasePrimitiveArrayCritical(env, this_buf, in_buf, 0);
switch (ret) {
case Z_STREAM_END:
(*env)->SetBooleanField(env, this, finishedID, JNI_TRUE);
/* fall through */
case Z_OK:
- consumed = in_len - strm->avail_in;
- (*env)->SetIntField(env, this, offID, this_off + consumed);
- (*env)->SetIntField(env, this, lenID, this_len - consumed);
+ this_off += this_len - strm->avail_in;
+ (*env)->SetIntField(env, this, offID, this_off);
+ (*env)->SetIntField(env, this, lenID, strm->avail_in);
return len - strm->avail_out;
case Z_NEED_DICT:
(*env)->SetBooleanField(env, this, needDictID, JNI_TRUE);
/* Might have consumed some input here! */
- consumed = in_len - strm->avail_in;
- (*env)->SetIntField(env, this, offID, this_off + consumed);
- (*env)->SetIntField(env, this, lenID, this_len - consumed);
+ this_off += this_len - strm->avail_in;
+ (*env)->SetIntField(env, this, offID, this_off);
+ (*env)->SetIntField(env, this, lenID, strm->avail_in);
return 0;
case Z_BUF_ERROR:
return 0;
diff --git a/src/solaris/bin/arm/jvm.cfg b/src/solaris/bin/arm/jvm.cfg
new file mode 100644
index 0000000000000000000000000000000000000000..0262ebda2e37fad7d9f0cce3711f8ada20e15176
--- /dev/null
+++ b/src/solaris/bin/arm/jvm.cfg
@@ -0,0 +1,38 @@
+# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation. 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.
+#
+# List of JVMs that can be used as an option to java, javac, etc.
+# Order is important -- first in this list is the default JVM.
+# NOTE that this both this file and its format are UNSUPPORTED and
+# WILL GO AWAY in a future release.
+#
+# You may also select a JVM in an arbitrary location with the
+# "-XXaltjvm=" option, but that too is unsupported
+# and may not be available in a future release.
+#
+-client KNOWN
+-server KNOWN
+-hotspot ERROR
+-classic WARN
+-native ERROR
+-green ERROR
diff --git a/src/solaris/bin/ppc/jvm.cfg b/src/solaris/bin/ppc/jvm.cfg
new file mode 100644
index 0000000000000000000000000000000000000000..0262ebda2e37fad7d9f0cce3711f8ada20e15176
--- /dev/null
+++ b/src/solaris/bin/ppc/jvm.cfg
@@ -0,0 +1,38 @@
+# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation. 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.
+#
+# List of JVMs that can be used as an option to java, javac, etc.
+# Order is important -- first in this list is the default JVM.
+# NOTE that this both this file and its format are UNSUPPORTED and
+# WILL GO AWAY in a future release.
+#
+# You may also select a JVM in an arbitrary location with the
+# "-XXaltjvm=" option, but that too is unsupported
+# and may not be available in a future release.
+#
+-client KNOWN
+-server KNOWN
+-hotspot ERROR
+-classic WARN
+-native ERROR
+-green ERROR
diff --git a/src/solaris/classes/sun/awt/X11/XToolkit.java b/src/solaris/classes/sun/awt/X11/XToolkit.java
index 8bde71a79747d5dc76d2b40926d67a72ffd79a5d..641d82180a905406e592d86de0a4dead4ebf9943 100644
--- a/src/solaris/classes/sun/awt/X11/XToolkit.java
+++ b/src/solaris/classes/sun/awt/X11/XToolkit.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -135,6 +135,12 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
noisyAwtHandler = AccessController.doPrivileged(new GetBooleanAction("sun.awt.noisyerrorhandler"));
}
+ /*
+ * Return (potentially) platform specific display timeout for the
+ * tray icon
+ */
+ static native long getTrayIconDisplayTimeout();
+
//---- ERROR HANDLER CODE ----//
/*
diff --git a/src/solaris/classes/sun/awt/X11/XTrayIconPeer.java b/src/solaris/classes/sun/awt/X11/XTrayIconPeer.java
index ff7b78e2c1396886b79c68e247345594ee08d0de..7bc452c968eb8203bd1c2fd362f32fbfc811b74c 100644
--- a/src/solaris/classes/sun/awt/X11/XTrayIconPeer.java
+++ b/src/solaris/classes/sun/awt/X11/XTrayIconPeer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -230,7 +230,7 @@ public class XTrayIconPeer implements TrayIconPeer,
// Wait till the EmbeddedFrame is reparented
long start = System.currentTimeMillis();
- final long PERIOD = 2000L;
+ final long PERIOD = XToolkit.getTrayIconDisplayTimeout();
XToolkit.awtLock();
try {
while (!isTrayIconDisplayed) {
diff --git a/src/solaris/classes/sun/nio/fs/LinuxFileSystemProvider.java b/src/solaris/classes/sun/nio/fs/LinuxFileSystemProvider.java
index 6659ff5ede48f5871524e7697db056d53b87df54..0b8aa14e1882b1a57f43561dc716c9e16c59a795 100644
--- a/src/solaris/classes/sun/nio/fs/LinuxFileSystemProvider.java
+++ b/src/solaris/classes/sun/nio/fs/LinuxFileSystemProvider.java
@@ -56,11 +56,11 @@ public class LinuxFileSystemProvider extends UnixFileSystemProvider {
{
if (type == DosFileAttributeView.class) {
return (V) new LinuxDosFileAttributeView(UnixPath.toUnixPath(obj),
- followLinks(options));
+ Util.followLinks(options));
}
if (type == UserDefinedFileAttributeView.class) {
return (V) new LinuxUserDefinedFileAttributeView(UnixPath.toUnixPath(obj),
- followLinks(options));
+ Util.followLinks(options));
}
return super.getFileAttributeView(obj, type, options);
}
@@ -72,11 +72,11 @@ public class LinuxFileSystemProvider extends UnixFileSystemProvider {
{
if (name.equals("dos")) {
return new LinuxDosFileAttributeView(UnixPath.toUnixPath(obj),
- followLinks(options));
+ Util.followLinks(options));
}
if (name.equals("user")) {
return new LinuxUserDefinedFileAttributeView(UnixPath.toUnixPath(obj),
- followLinks(options));
+ Util.followLinks(options));
}
return super.getFileAttributeView(obj, name, options);
}
diff --git a/src/solaris/classes/sun/nio/fs/SolarisFileSystemProvider.java b/src/solaris/classes/sun/nio/fs/SolarisFileSystemProvider.java
index 98c3ae8699ca580bf37a26b26a7e763f649be1e9..eca619be1d0dfbe21cdd84aa674eda8d58b05361 100644
--- a/src/solaris/classes/sun/nio/fs/SolarisFileSystemProvider.java
+++ b/src/solaris/classes/sun/nio/fs/SolarisFileSystemProvider.java
@@ -57,11 +57,11 @@ public class SolarisFileSystemProvider extends UnixFileSystemProvider {
{
if (type == AclFileAttributeView.class) {
return (V) new SolarisAclFileAttributeView(UnixPath.toUnixPath(obj),
- followLinks(options));
+ Util.followLinks(options));
}
if (type == UserDefinedFileAttributeView.class) {
return(V) new SolarisUserDefinedFileAttributeView(UnixPath.toUnixPath(obj),
- followLinks(options));
+ Util.followLinks(options));
}
return super.getFileAttributeView(obj, type, options);
}
@@ -73,10 +73,10 @@ public class SolarisFileSystemProvider extends UnixFileSystemProvider {
{
if (name.equals("acl"))
return new SolarisAclFileAttributeView(UnixPath.toUnixPath(obj),
- followLinks(options));
+ Util.followLinks(options));
if (name.equals("user"))
return new SolarisUserDefinedFileAttributeView(UnixPath.toUnixPath(obj),
- followLinks(options));
+ Util.followLinks(options));
return super.getFileAttributeView(obj, name, options);
}
}
diff --git a/src/solaris/classes/sun/nio/fs/UnixFileSystemProvider.java b/src/solaris/classes/sun/nio/fs/UnixFileSystemProvider.java
index 8ec672a306bbca65911ae715730de5aa6effeff5..1bee2d0b3860e3d60477ef52b9427c1bb5d0630b 100644
--- a/src/solaris/classes/sun/nio/fs/UnixFileSystemProvider.java
+++ b/src/solaris/classes/sun/nio/fs/UnixFileSystemProvider.java
@@ -105,20 +105,6 @@ public abstract class UnixFileSystemProvider
return (UnixPath)obj;
}
- boolean followLinks(LinkOption... options) {
- boolean followLinks = true;
- for (LinkOption option: options) {
- if (option == LinkOption.NOFOLLOW_LINKS) {
- followLinks = false;
- continue;
- }
- if (option == null)
- throw new NullPointerException();
- throw new AssertionError("Should not get here");
- }
- return followLinks;
- }
-
@Override
@SuppressWarnings("unchecked")
public V getFileAttributeView(Path obj,
@@ -126,7 +112,7 @@ public abstract class UnixFileSystemProvider
LinkOption... options)
{
UnixPath file = UnixPath.toUnixPath(obj);
- boolean followLinks = followLinks(options);
+ boolean followLinks = Util.followLinks(options);
if (type == BasicFileAttributeView.class)
return (V) UnixFileAttributeViews.createBasicView(file, followLinks);
if (type == PosixFileAttributeView.class)
@@ -163,7 +149,7 @@ public abstract class UnixFileSystemProvider
LinkOption... options)
{
UnixPath file = UnixPath.toUnixPath(obj);
- boolean followLinks = followLinks(options);
+ boolean followLinks = Util.followLinks(options);
if (name.equals("basic"))
return UnixFileAttributeViews.createBasicView(file, followLinks);
if (name.equals("posix"))
diff --git a/src/solaris/classes/sun/nio/fs/UnixPath.java b/src/solaris/classes/sun/nio/fs/UnixPath.java
index b392b56b7e92c2c3839baec5c7184548ab4e5255..dfa1e0f0d7e6894eb68afea19df3abc9cd60f7ca 100644
--- a/src/solaris/classes/sun/nio/fs/UnixPath.java
+++ b/src/solaris/classes/sun/nio/fs/UnixPath.java
@@ -819,13 +819,13 @@ class UnixPath
}
@Override
- public Path toRealPath(boolean resolveLinks) throws IOException {
+ public Path toRealPath(LinkOption... options) throws IOException {
checkRead();
UnixPath absolute = toAbsolutePath();
- // if resolveLinks is true then use realpath
- if (resolveLinks) {
+ // if resolving links then use realpath
+ if (Util.followLinks(options)) {
try {
byte[] rp = realpath(absolute);
return new UnixPath(getFileSystem(), rp);
@@ -834,7 +834,7 @@ class UnixPath
}
}
- // if resolveLinks is false then eliminate "." and also ".."
+ // if not resolving links then eliminate "." and also ".."
// where the previous element is not a link.
UnixPath result = fs.rootDirectory();
for (int i=0; i
+#include
+#endif
+
/* Take an array of string pairs (map of key->value) and a string (key).
* Examine each pair in the map to see if the first string (key) matches the
* string. If so, store the second string of the pair (value) in the value and
@@ -304,6 +309,36 @@ static int ParseLocale(int cat, char ** std_language, char ** std_script,
return 1;
}
+#ifdef JAVASE_EMBEDDED
+/* Determine the default embedded toolkit based on whether lib/xawt/
+ * exists in the JRE. This can still be overridden by -Dawt.toolkit=XXX
+ */
+static char* getEmbeddedToolkit() {
+ Dl_info dlinfo;
+ char buf[MAXPATHLEN];
+ int32_t len;
+ char *p;
+ struct stat statbuf;
+
+ /* Get address of this library and the directory containing it. */
+ dladdr((void *)getEmbeddedToolkit, &dlinfo);
+ realpath((char *)dlinfo.dli_fname, buf);
+ len = strlen(buf);
+ p = strrchr(buf, '/');
+ /* Default AWT Toolkit on Linux and Solaris is XAWT. */
+ strncpy(p, "/xawt/", MAXPATHLEN-len-1);
+ /* Check if it exists */
+ if (stat(buf, &statbuf) == -1 && errno == ENOENT) {
+ /* No - this is a reduced-headless-jre so use special HToolkit */
+ return "sun.awt.HToolkit";
+ }
+ else {
+ /* Yes - this is a headful JRE so fallback to SE defaults */
+ return NULL;
+ }
+}
+#endif
+
/* This function gets called very early, before VM_CALLS are setup.
* Do not use any of the VM_CALLS entries!!!
*/
@@ -328,7 +363,12 @@ GetJavaProperties(JNIEnv *env)
/* Java 2D properties */
sprops.graphics_env = "sun.awt.X11GraphicsEnvironment";
- sprops.awt_toolkit = NULL;
+
+#ifdef JAVASE_EMBEDDED
+ sprops.awt_toolkit = getEmbeddedToolkit();
+ if (sprops.awt_toolkit == NULL) // default as below
+#endif
+ sprops.awt_toolkit = "sun.awt.X11.XToolkit";
/* This is used only for debugging of font problems. */
v = getenv("JAVA2D_FONTPATH");
diff --git a/src/solaris/native/sun/awt/jawt.c b/src/solaris/native/sun/awt/jawt.c
index b682edaf45d7a8b5464f3a32b7f3024a00ad8d37..f6f8530cb9ac6f13bae0971bcace233d90ea3f6c 100644
--- a/src/solaris/native/sun/awt/jawt.c
+++ b/src/solaris/native/sun/awt/jawt.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2001, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -33,6 +33,10 @@
*/
JNIEXPORT jboolean JNICALL JAWT_GetAWT(JNIEnv* env, JAWT* awt)
{
+#if defined(JAVASE_EMBEDDED) && defined(HEADLESS)
+ /* there are no AWT libs available at all */
+ return JNI_FALSE;
+#else
if (awt == NULL) {
return JNI_FALSE;
}
@@ -51,4 +55,5 @@ JNIEXPORT jboolean JNICALL JAWT_GetAWT(JNIEnv* env, JAWT* awt)
}
return JNI_TRUE;
+#endif
}
diff --git a/src/solaris/native/sun/xawt/XToolkit.c b/src/solaris/native/sun/xawt/XToolkit.c
index 4ea63143c701d91f1b8952f062e0d0e9a18de687..69620ffc1e641c1245ca2ea8cb9a846cd9ffcbc3 100644
--- a/src/solaris/native/sun/xawt/XToolkit.c
+++ b/src/solaris/native/sun/xawt/XToolkit.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -110,6 +110,21 @@ Java_sun_awt_X11_XToolkit_initIDs
awt_ModLockIsShiftLock = (*env)->GetStaticIntField(env, clazz, fid) != 0 ? True : False;
}
+/*
+ * Class: sun_awt_X11_XToolkit
+ * Method: getTrayIconDisplayTimeout
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_sun_awt_X11_XToolkit_getTrayIconDisplayTimeout
+ (JNIEnv *env, jclass clazz)
+{
+#ifndef JAVASE_EMBEDDED
+ return (jlong) 2000;
+#else
+ return (jlong) 10000;
+#endif
+}
+
/*
* Class: sun_awt_X11_XToolkit
* Method: getDefaultXColormap
@@ -340,15 +355,34 @@ static uint32_t get_poll_timeout(jlong nextTaskTime);
#define AWT_READPIPE (awt_pipe_fds[0])
#define AWT_WRITEPIPE (awt_pipe_fds[1])
-#define DEF_AWT_MAX_POLL_TIMEOUT ((uint32_t)500) /* milliseconds */
+#ifdef JAVASE_EMBEDDED
+ #define DEF_AWT_MAX_POLL_TIMEOUT ((uint32_t)4000000000) /* milliseconds */
+#else
+ #define DEF_AWT_MAX_POLL_TIMEOUT ((uint32_t)500) /* milliseconds */
+#endif
+
#define DEF_AWT_FLUSH_TIMEOUT ((uint32_t)100) /* milliseconds */
#define AWT_MIN_POLL_TIMEOUT ((uint32_t)0) /* milliseconds */
#define TIMEOUT_TIMEDOUT 0
#define TIMEOUT_EVENTS 1
+/* awt_poll_alg - AWT Poll Events Aging Algorithms */
+#define AWT_POLL_FALSE 1
+#define AWT_POLL_AGING_SLOW 2
+#define AWT_POLL_AGING_FAST 3
+
+#define AWT_POLL_THRESHOLD 1000 // msec, Block if delay is larger
+#define AWT_POLL_BLOCK -1 // cause poll() block
+
// Static fields
+#ifdef JAVASE_EMBEDDED
+ static int awt_poll_alg = AWT_POLL_AGING_FAST;
+#else
+ static int awt_poll_alg = AWT_POLL_AGING_SLOW;
+#endif
+
static uint32_t AWT_FLUSH_TIMEOUT = DEF_AWT_FLUSH_TIMEOUT; /* milliseconds */
static uint32_t AWT_MAX_POLL_TIMEOUT = DEF_AWT_MAX_POLL_TIMEOUT; /* milliseconds */
static pthread_t awt_MainThread = 0;
@@ -417,6 +451,7 @@ awt_pipe_init() {
*/
static void readEnv() {
char * value;
+ int tmp_poll_alg;
static Boolean env_read = False;
if (env_read) return;
@@ -451,6 +486,23 @@ static void readEnv() {
if (static_poll_timeout != 0) {
curPollTimeout = static_poll_timeout;
}
+
+ // non-blocking poll()
+ value = getenv("_AWT_POLL_ALG");
+ if (value != NULL) {
+ tmp_poll_alg = atoi(value);
+ switch(tmp_poll_alg) {
+ case AWT_POLL_FALSE:
+ case AWT_POLL_AGING_SLOW:
+ case AWT_POLL_AGING_FAST:
+ awt_poll_alg = tmp_poll_alg;
+ break;
+ default:
+ PRINT("Unknown value of _AWT_POLL_ALG, assuming Slow Aging Algorithm by default");
+ awt_poll_alg = AWT_POLL_AGING_SLOW;
+ break;
+ }
+ }
}
/**
@@ -478,14 +530,29 @@ static void update_poll_timeout(int timeout_control) {
if (static_poll_timeout != 0) return;
// Update it otherwise
- if (timeout_control == TIMEOUT_TIMEDOUT) {
- /* add 1/4 (plus 1, in case the division truncates to 0) */
- curPollTimeout += ((curPollTimeout>>2) + 1);
- curPollTimeout = min(AWT_MAX_POLL_TIMEOUT, curPollTimeout);
- } else if (timeout_control == TIMEOUT_EVENTS) {
- /* subtract 1/4 (plus 1, in case the division truncates to 0) */
- curPollTimeout -= ((curPollTimeout>>2) + 1);
- curPollTimeout = max(AWT_MIN_POLL_TIMEOUT, curPollTimeout);
+
+ switch(awt_poll_alg) {
+ case AWT_POLL_AGING_SLOW:
+ if (timeout_control == TIMEOUT_TIMEDOUT) {
+ /* add 1/4 (plus 1, in case the division truncates to 0) */
+ curPollTimeout += ((curPollTimeout>>2) + 1);
+ curPollTimeout = min(AWT_MAX_POLL_TIMEOUT, curPollTimeout);
+ } else if (timeout_control == TIMEOUT_EVENTS) {
+ /* subtract 1/4 (plus 1, in case the division truncates to 0) */
+ curPollTimeout -= ((curPollTimeout>>2) + 1);
+ curPollTimeout = max(AWT_MIN_POLL_TIMEOUT, curPollTimeout);
+ }
+ break;
+ case AWT_POLL_AGING_FAST:
+ if (timeout_control == TIMEOUT_TIMEDOUT) {
+ curPollTimeout += ((curPollTimeout>>2) + 1);
+ curPollTimeout = min(AWT_MAX_POLL_TIMEOUT, curPollTimeout);
+ if((int)curPollTimeout > AWT_POLL_THRESHOLD || (int)curPollTimeout == AWT_POLL_BLOCK)
+ curPollTimeout = AWT_POLL_BLOCK;
+ } else if (timeout_control == TIMEOUT_EVENTS) {
+ curPollTimeout = max(AWT_MIN_POLL_TIMEOUT, 1);
+ }
+ break;
}
}
@@ -497,16 +564,37 @@ static void update_poll_timeout(int timeout_control) {
*/
static uint32_t get_poll_timeout(jlong nextTaskTime)
{
+ uint32_t ret_timeout;
+ uint32_t timeout;
+ uint32_t taskTimeout;
+ uint32_t flushTimeout;
+
jlong curTime = awtJNI_TimeMillis();
- uint32_t timeout = curPollTimeout;
- uint32_t taskTimeout = (nextTaskTime == -1) ? AWT_MAX_POLL_TIMEOUT : (uint32_t)max(0, (int32_t)(nextTaskTime - curTime));
- uint32_t flushTimeout = (awt_next_flush_time > 0) ? (uint32_t)max(0, (int32_t)(awt_next_flush_time - curTime)) : AWT_MAX_POLL_TIMEOUT;
+ timeout = curPollTimeout;
+ switch(awt_poll_alg) {
+ case AWT_POLL_AGING_SLOW:
+ case AWT_POLL_AGING_FAST:
+ taskTimeout = (nextTaskTime == -1) ? AWT_MAX_POLL_TIMEOUT : (uint32_t)max(0, (int32_t)(nextTaskTime - curTime));
+ flushTimeout = (awt_next_flush_time > 0) ? (uint32_t)max(0, (int32_t)(awt_next_flush_time - curTime)) : AWT_MAX_POLL_TIMEOUT;
+
+ PRINT2("to: %d, ft: %d, to: %d, tt: %d, mil: %d\n", taskTimeout, flushTimeout, timeout, (int)nextTaskTime, (int)curTime);
+
+ // Adjust timeout to flush_time and task_time
+ ret_timeout = min(flushTimeout, min(taskTimeout, timeout));
+ if((int)curPollTimeout == AWT_POLL_BLOCK)
+ ret_timeout = AWT_POLL_BLOCK;
+ break;
+
+ case AWT_POLL_FALSE:
+ ret_timeout = (nextTaskTime > curTime) ?
+ (nextTaskTime - curTime) :
+ ((nextTaskTime == -1) ? -1 : 0);
+ break;
+ }
- PRINT2("to: %d, ft: %d, to: %d, tt: %d, mil: %d\n", taskTimeout, flushTimeout, timeout, (int)nextTaskTime, (int)curTime);
+ return ret_timeout;
- // Adjust timeout to flush_time and task_time
- return min(flushTimeout, min(taskTimeout, timeout));
-} /* awt_get_poll_timeout() */
+} /* get_poll_timeout() */
/*
* Waits for X/Xt events to appear on the pipe. Returns only when
@@ -598,6 +686,8 @@ performPoll(JNIEnv *env, jlong nextTaskTime) {
if (result == 0) {
/* poll() timed out -- update timeout value */
update_poll_timeout(TIMEOUT_TIMEDOUT);
+ PRINT2("%s(): TIMEOUT_TIMEDOUT curPollTimeout = %d \n",
+ performPoll, curPollTimeout);
}
if (pollFds[1].revents) {
int count;
@@ -606,10 +696,14 @@ performPoll(JNIEnv *env, jlong nextTaskTime) {
do {
count = read(AWT_READPIPE, read_buf, AWT_POLL_BUFSIZE );
} while (count == AWT_POLL_BUFSIZE );
+ PRINT2("%s(): data on the AWT pipe: curPollTimeout = %d \n",
+ performPoll, curPollTimeout);
}
if (pollFds[0].revents) {
// Events in X pipe
update_poll_timeout(TIMEOUT_EVENTS);
+ PRINT2("%s(): TIMEOUT_EVENTS curPollTimeout = %ld \n",
+ performPoll, curPollTimeout);
}
return;
diff --git a/src/windows/classes/sun/nio/fs/WindowsFileSystemProvider.java b/src/windows/classes/sun/nio/fs/WindowsFileSystemProvider.java
index 6d6a4db89b2286c38b0db6df09d1db8811b2c007..b55efa03025d29f19838b03a6a506dbe90ea93fe 100644
--- a/src/windows/classes/sun/nio/fs/WindowsFileSystemProvider.java
+++ b/src/windows/classes/sun/nio/fs/WindowsFileSystemProvider.java
@@ -150,20 +150,6 @@ public class WindowsFileSystemProvider
}
}
- private boolean followLinks(LinkOption... options) {
- boolean followLinks = true;
- for (LinkOption option: options) {
- if (option == LinkOption.NOFOLLOW_LINKS) {
- followLinks = false;
- continue;
- }
- if (option == null)
- throw new NullPointerException();
- throw new AssertionError("Should not get here");
- }
- return followLinks;
- }
-
@Override
@SuppressWarnings("unchecked")
public V
@@ -172,7 +158,7 @@ public class WindowsFileSystemProvider
WindowsPath file = WindowsPath.toWindowsPath(obj);
if (view == null)
throw new NullPointerException();
- boolean followLinks = followLinks(options);
+ boolean followLinks = Util.followLinks(options);
if (view == BasicFileAttributeView.class)
return (V) WindowsFileAttributeViews.createBasicView(file, followLinks);
if (view == DosFileAttributeView.class)
@@ -209,7 +195,7 @@ public class WindowsFileSystemProvider
@Override
public DynamicFileAttributeView getFileAttributeView(Path obj, String name, LinkOption... options) {
WindowsPath file = WindowsPath.toWindowsPath(obj);
- boolean followLinks = followLinks(options);
+ boolean followLinks = Util.followLinks(options);
if (name.equals("basic"))
return WindowsFileAttributeViews.createBasicView(file, followLinks);
if (name.equals("dos"))
diff --git a/src/windows/classes/sun/nio/fs/WindowsPath.java b/src/windows/classes/sun/nio/fs/WindowsPath.java
index eb35de8167e554d3dbc649bf1c84395fd2497ff3..0f6d5f8c242e5e40e695f08fb05e1ab5332816ce 100644
--- a/src/windows/classes/sun/nio/fs/WindowsPath.java
+++ b/src/windows/classes/sun/nio/fs/WindowsPath.java
@@ -831,9 +831,9 @@ class WindowsPath extends AbstractPath {
}
@Override
- public WindowsPath toRealPath(boolean resolveLinks) throws IOException {
+ public WindowsPath toRealPath(LinkOption... options) throws IOException {
checkRead();
- String rp = WindowsLinkSupport.getRealPath(this, resolveLinks);
+ String rp = WindowsLinkSupport.getRealPath(this, Util.followLinks(options));
return createFromNormalizedPath(getFileSystem(), rp);
}
diff --git a/src/windows/native/com/sun/management/OperatingSystem_md.c b/src/windows/native/com/sun/management/OperatingSystem_md.c
index c8e72bf73a71fe07e1bb3943d389a93262765058..9422ee2dc86708d0755648246ff7b304ce39603d 100644
--- a/src/windows/native/com/sun/management/OperatingSystem_md.c
+++ b/src/windows/native/com/sun/management/OperatingSystem_md.c
@@ -30,6 +30,7 @@
#include "management.h"
#include "com_sun_management_OperatingSystem.h"
+#include
#include
#include
@@ -53,41 +54,12 @@ static jlong jlong_from(jint h, jint l) {
return result;
}
-// From psapi.h
-typedef struct _PROCESS_MEMORY_COUNTERS {
- DWORD cb;
- DWORD PageFaultCount;
- SIZE_T PeakWorkingSetSize;
- SIZE_T WorkingSetSize;
- SIZE_T QuotaPeakPagedPoolUsage;
- SIZE_T QuotaPagedPoolUsage;
- SIZE_T QuotaPeakNonPagedPoolUsage;
- SIZE_T QuotaNonPagedPoolUsage;
- SIZE_T PagefileUsage;
- SIZE_T PeakPagefileUsage;
-} PROCESS_MEMORY_COUNTERS;
-
-static HINSTANCE hInstPsapi = NULL;
-typedef BOOL (WINAPI *LPFNGETPROCESSMEMORYINFO)(HANDLE, PROCESS_MEMORY_COUNTERS*, DWORD);
-
-static jboolean is_nt = JNI_FALSE;
static HANDLE main_process;
JNIEXPORT void JNICALL
Java_com_sun_management_OperatingSystem_initialize
(JNIEnv *env, jclass cls)
{
- OSVERSIONINFO oi;
- oi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
- GetVersionEx(&oi);
- switch(oi.dwPlatformId) {
- case VER_PLATFORM_WIN32_WINDOWS: is_nt = JNI_FALSE; break;
- case VER_PLATFORM_WIN32_NT: is_nt = JNI_TRUE; break;
- default:
- throw_internal_error(env, "Unsupported Platform");
- return;
- }
-
main_process = GetCurrentProcess();
}
@@ -95,31 +67,12 @@ JNIEXPORT jlong JNICALL
Java_com_sun_management_OperatingSystem_getCommittedVirtualMemorySize0
(JNIEnv *env, jobject mbean)
{
-
- /*
- * In bytes. NT/2000/XP only - using GetProcessMemoryInfo from psapi.dll
- */
- static LPFNGETPROCESSMEMORYINFO lpfnGetProcessMemoryInfo = NULL;
- static volatile jboolean psapi_inited = JNI_FALSE;
PROCESS_MEMORY_COUNTERS pmc;
-
- if (!is_nt) return -1;
-
- if (!psapi_inited) {
- psapi_inited = JNI_TRUE;
- if ((hInstPsapi = LoadLibrary("PSAPI.DLL")) == NULL) return -1;
- if ((lpfnGetProcessMemoryInfo = (LPFNGETPROCESSMEMORYINFO)
- GetProcAddress( hInstPsapi, "GetProcessMemoryInfo")) == NULL) {
- FreeLibrary(hInstPsapi);
- return -1;
- }
+ if (GetProcessMemoryInfo(main_process, &pmc, sizeof(PROCESS_MEMORY_COUNTERS)) == 0) {
+ return (jlong)-1L;
+ } else {
+ return (jlong) pmc.PagefileUsage;
}
-
- if (lpfnGetProcessMemoryInfo == NULL) return -1;
-
- lpfnGetProcessMemoryInfo(main_process, &pmc,
- sizeof(PROCESS_MEMORY_COUNTERS));
- return (jlong) pmc.PagefileUsage;
}
JNIEXPORT jlong JNICALL
@@ -148,20 +101,15 @@ Java_com_sun_management_OperatingSystem_getProcessCpuTime
FILETIME process_creation_time, process_exit_time,
process_user_time, process_kernel_time;
- // Windows NT only
- if (is_nt) {
- // Using static variables declared above
- // Units are 100-ns intervals. Convert to ns.
- GetProcessTimes(main_process, &process_creation_time,
- &process_exit_time,
- &process_kernel_time, &process_user_time);
- return (jlong_from(process_user_time.dwHighDateTime,
- process_user_time.dwLowDateTime) +
- jlong_from(process_kernel_time.dwHighDateTime,
- process_kernel_time.dwLowDateTime)) * 100;
- } else {
- return -1;
- }
+ // Using static variables declared above
+ // Units are 100-ns intervals. Convert to ns.
+ GetProcessTimes(main_process, &process_creation_time,
+ &process_exit_time,
+ &process_kernel_time, &process_user_time);
+ return (jlong_from(process_user_time.dwHighDateTime,
+ process_user_time.dwLowDateTime) +
+ jlong_from(process_kernel_time.dwHighDateTime,
+ process_kernel_time.dwLowDateTime)) * 100;
}
JNIEXPORT jlong JNICALL
diff --git a/src/windows/native/java/io/WinNTFileSystem_md.c b/src/windows/native/java/io/WinNTFileSystem_md.c
index 566b697eb8f7065bbbf2da33ff6f39a055e201ab..6e377b2e67f8ef8b3d4d635e89b8517353f894b3 100644
--- a/src/windows/native/java/io/WinNTFileSystem_md.c
+++ b/src/windows/native/java/io/WinNTFileSystem_md.c
@@ -23,9 +23,9 @@
* questions.
*/
-/* Access APIs for Win2K and above */
+/* Access APIs for WinXP and above */
#ifndef _WIN32_WINNT
-#define _WIN32_WINNT 0x0500
+#define _WIN32_WINNT 0x0501
#endif
#include
@@ -60,13 +60,17 @@ static GetFinalPathNameByHandleProc GetFinalPathNameByHandle_func;
JNIEXPORT void JNICALL
Java_java_io_WinNTFileSystem_initIDs(JNIEnv *env, jclass cls)
{
- HANDLE handle;
+ HMODULE handle;
jclass fileClass = (*env)->FindClass(env, "java/io/File");
if (!fileClass) return;
ids.path =
(*env)->GetFieldID(env, fileClass, "path", "Ljava/lang/String;");
- handle = LoadLibrary("kernel32");
- if (handle != NULL) {
+
+ // GetFinalPathNameByHandle requires Windows Vista or newer
+ if (GetModuleHandleExW((GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
+ GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT),
+ (LPCWSTR)&CreateFileW, &handle) != 0)
+ {
GetFinalPathNameByHandle_func = (GetFinalPathNameByHandleProc)
GetProcAddress(handle, "GetFinalPathNameByHandleW");
}
@@ -824,8 +828,6 @@ Java_java_io_WinNTFileSystem_getDriveDirectory(JNIEnv *env, jobject this,
return ret;
}
-typedef BOOL (WINAPI* GetVolumePathNameProc) (LPCWSTR, LPWSTR, DWORD);
-
JNIEXPORT jlong JNICALL
Java_java_io_WinNTFileSystem_getSpace0(JNIEnv *env, jobject this,
jobject file, jint t)
@@ -834,14 +836,7 @@ Java_java_io_WinNTFileSystem_getSpace0(JNIEnv *env, jobject this,
jlong rv = 0L;
WCHAR *pathbuf = fileToNTPath(env, file, ids.path);
- HMODULE h = LoadLibrary("kernel32");
- GetVolumePathNameProc getVolumePathNameW = NULL;
- if (h) {
- getVolumePathNameW
- = (GetVolumePathNameProc)GetProcAddress(h, "GetVolumePathNameW");
- }
-
- if (getVolumePathNameW(pathbuf, volname, MAX_PATH_LENGTH)) {
+ if (GetVolumePathNameW(pathbuf, volname, MAX_PATH_LENGTH)) {
ULARGE_INTEGER totalSpace, freeSpace, usableSpace;
if (GetDiskFreeSpaceExW(volname, &usableSpace, &totalSpace, &freeSpace)) {
switch(t) {
@@ -860,9 +855,6 @@ Java_java_io_WinNTFileSystem_getSpace0(JNIEnv *env, jobject this,
}
}
- if (h) {
- FreeLibrary(h);
- }
free(pathbuf);
return rv;
}
diff --git a/src/windows/native/java/lang/java_props_md.c b/src/windows/native/java/lang/java_props_md.c
index 5b9332fb11181797211eacce65ea690fb5c29bd6..c66efbaf2fbdddce73b40b429be26d561add9f3a 100644
--- a/src/windows/native/java/lang/java_props_md.c
+++ b/src/windows/native/java/lang/java_props_md.c
@@ -196,42 +196,23 @@ getHomeFromRegistry()
/*
* Code to figure out the user's home directory using shell32.dll
*/
-typedef HRESULT (WINAPI *GetSpecialFolderType)(HWND, int, LPITEMIDLIST *);
-typedef BOOL (WINAPI *GetPathFromIDListType)(LPCITEMIDLIST, LPSTR);
-
WCHAR*
getHomeFromShell32()
{
- HMODULE lib = LoadLibraryW(L"SHELL32.DLL");
- GetSpecialFolderType do_get_folder;
- GetPathFromIDListType do_get_path;
HRESULT rc;
LPITEMIDLIST item_list = 0;
WCHAR *p;
WCHAR path[MAX_PATH+1];
int size = MAX_PATH+1;
- if (lib == 0) {
- // We can't load the library !!??
- return NULL;
- }
-
- do_get_folder = (GetSpecialFolderType)GetProcAddress(lib, "SHGetSpecialFolderLocation");
- do_get_path = (GetPathFromIDListType)GetProcAddress(lib, "SHGetPathFromIDListW");
-
- if (do_get_folder == 0 || do_get_path == 0) {
- // the library doesn't hold the right functions !!??
- return NULL;
- }
-
- rc = (*do_get_folder)(NULL, CSIDL_DESKTOPDIRECTORY, &item_list);
+ rc = SHGetSpecialFolderLocation(NULL, CSIDL_DESKTOPDIRECTORY, &item_list);
if (!SUCCEEDED(rc)) {
// we can't find the shell folder.
return NULL;
}
path[0] = 0;
- (*do_get_path)(item_list, (LPSTR)path);
+ SHGetPathFromIDListW(item_list, (LPWSTR)path);
/* Get the parent of Desktop directory */
p = wcsrchr(path, L'\\');
@@ -253,17 +234,7 @@ getHomeFromShell32()
static boolean
haveMMX(void)
{
- boolean mmx = 0;
- HMODULE lib = LoadLibrary("KERNEL32");
- if (lib != NULL) {
- BOOL (WINAPI *isProcessorFeaturePresent)(DWORD) =
- (BOOL (WINAPI *)(DWORD))
- GetProcAddress(lib, "IsProcessorFeaturePresent");
- if (isProcessorFeaturePresent != NULL)
- mmx = isProcessorFeaturePresent(PF_MMX_INSTRUCTIONS_AVAILABLE);
- FreeLibrary(lib);
- }
- return mmx;
+ return IsProcessorFeaturePresent(PF_MMX_INSTRUCTIONS_AVAILABLE);
}
static const char *
@@ -532,10 +503,19 @@ GetJavaProperties(JNIEnv* env)
if (uname != NULL && wcslen(uname) > 0) {
sprops.user_name = _wcsdup(uname);
} else {
- WCHAR buf[100];
- int buflen = sizeof(buf);
- sprops.user_name =
- GetUserNameW(buf, &buflen) ? _wcsdup(buf) : L"unknown";
+ DWORD buflen = 0;
+ if (GetUserNameW(NULL, &buflen) == 0 &&
+ GetLastError() == ERROR_INSUFFICIENT_BUFFER)
+ {
+ uname = (WCHAR*)malloc(buflen * sizeof(WCHAR));
+ if (uname != NULL && GetUserNameW(uname, &buflen) == 0) {
+ free(uname);
+ uname = NULL;
+ }
+ } else {
+ uname = NULL;
+ }
+ sprops.user_name = (uname != NULL) ? uname : L"unknown";
}
}
@@ -633,8 +613,8 @@ GetJavaProperties(JNIEnv* env)
/* Current directory */
{
WCHAR buf[MAX_PATH];
- GetCurrentDirectoryW(sizeof(buf), buf);
- sprops.user_dir = _wcsdup(buf);
+ if (GetCurrentDirectoryW(sizeof(buf)/sizeof(WCHAR), buf) != 0)
+ sprops.user_dir = _wcsdup(buf);
}
sprops.file_separator = "\\";
diff --git a/src/windows/native/java/net/Inet6AddressImpl.c b/src/windows/native/java/net/Inet6AddressImpl.c
index 1f9a6779e6ebfc98e36eaddf4371b2117a5d9110..1e4373355e3cbab6e0721adabecee08435cf5ef8 100644
--- a/src/windows/native/java/net/Inet6AddressImpl.c
+++ b/src/windows/native/java/net/Inet6AddressImpl.c
@@ -90,6 +90,7 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
jobjectArray ret = 0;
int retLen = 0;
jboolean preferIPv6Address;
+ static jfieldID ia_preferIPv6AddressID;
int error=0;
struct addrinfo hints, *res, *resNew = NULL;
@@ -116,166 +117,163 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
hostname = JNU_GetStringPlatformChars(env, host, JNI_FALSE);
CHECK_NULL_RETURN(hostname, NULL);
- if (NET_addrtransAvailable()) {
- static jfieldID ia_preferIPv6AddressID;
+ if (ia_preferIPv6AddressID == NULL) {
+ jclass c = (*env)->FindClass(env,"java/net/InetAddress");
+ if (c) {
+ ia_preferIPv6AddressID =
+ (*env)->GetStaticFieldID(env, c, "preferIPv6Address", "Z");
+ }
if (ia_preferIPv6AddressID == NULL) {
- jclass c = (*env)->FindClass(env,"java/net/InetAddress");
- if (c) {
- ia_preferIPv6AddressID =
- (*env)->GetStaticFieldID(env, c, "preferIPv6Address", "Z");
- }
- if (ia_preferIPv6AddressID == NULL) {
- JNU_ReleaseStringPlatformChars(env, host, hostname);
- return NULL;
- }
+ JNU_ReleaseStringPlatformChars(env, host, hostname);
+ return NULL;
}
- /* get the address preference */
- preferIPv6Address
- = (*env)->GetStaticBooleanField(env, ia_class, ia_preferIPv6AddressID);
+ }
+ /* get the address preference */
+ preferIPv6Address
+ = (*env)->GetStaticBooleanField(env, ia_class, ia_preferIPv6AddressID);
- /* Try once, with our static buffer. */
- memset(&hints, 0, sizeof(hints));
- hints.ai_flags = AI_CANONNAME;
- hints.ai_family = AF_UNSPEC;
+ /* Try once, with our static buffer. */
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_flags = AI_CANONNAME;
+ hints.ai_family = AF_UNSPEC;
- error = (*getaddrinfo_ptr)(hostname, NULL, &hints, &res);
+ error = getaddrinfo(hostname, NULL, &hints, &res);
- if (error) {
- /* report error */
- JNU_ThrowByName(env, JNU_JAVANETPKG "UnknownHostException",
- (char *)hostname);
- JNU_ReleaseStringPlatformChars(env, host, hostname);
- return NULL;
- } else {
- int i = 0;
- int inetCount = 0, inet6Count = 0, inetIndex, inet6Index;
- struct addrinfo *itr, *last, *iterator = res;
- while (iterator != NULL) {
- int skip = 0;
- itr = resNew;
- while (itr != NULL) {
- if (iterator->ai_family == itr->ai_family &&
- iterator->ai_addrlen == itr->ai_addrlen) {
- if (itr->ai_family == AF_INET) { /* AF_INET */
- struct sockaddr_in *addr1, *addr2;
- addr1 = (struct sockaddr_in *)iterator->ai_addr;
- addr2 = (struct sockaddr_in *)itr->ai_addr;
- if (addr1->sin_addr.s_addr ==
- addr2->sin_addr.s_addr) {
- skip = 1;
+ if (error) {
+ /* report error */
+ JNU_ThrowByName(env, JNU_JAVANETPKG "UnknownHostException",
+ (char *)hostname);
+ JNU_ReleaseStringPlatformChars(env, host, hostname);
+ return NULL;
+ } else {
+ int i = 0;
+ int inetCount = 0, inet6Count = 0, inetIndex, inet6Index;
+ struct addrinfo *itr, *last, *iterator = res;
+ while (iterator != NULL) {
+ int skip = 0;
+ itr = resNew;
+ while (itr != NULL) {
+ if (iterator->ai_family == itr->ai_family &&
+ iterator->ai_addrlen == itr->ai_addrlen) {
+ if (itr->ai_family == AF_INET) { /* AF_INET */
+ struct sockaddr_in *addr1, *addr2;
+ addr1 = (struct sockaddr_in *)iterator->ai_addr;
+ addr2 = (struct sockaddr_in *)itr->ai_addr;
+ if (addr1->sin_addr.s_addr ==
+ addr2->sin_addr.s_addr) {
+ skip = 1;
+ break;
+ }
+ } else {
+ int t;
+ struct sockaddr_in6 *addr1, *addr2;
+ addr1 = (struct sockaddr_in6 *)iterator->ai_addr;
+ addr2 = (struct sockaddr_in6 *)itr->ai_addr;
+
+ for (t = 0; t < 16; t++) {
+ if (addr1->sin6_addr.s6_addr[t] !=
+ addr2->sin6_addr.s6_addr[t]) {
break;
}
+ }
+ if (t < 16) {
+ itr = itr->ai_next;
+ continue;
} else {
- int t;
- struct sockaddr_in6 *addr1, *addr2;
- addr1 = (struct sockaddr_in6 *)iterator->ai_addr;
- addr2 = (struct sockaddr_in6 *)itr->ai_addr;
-
- for (t = 0; t < 16; t++) {
- if (addr1->sin6_addr.s6_addr[t] !=
- addr2->sin6_addr.s6_addr[t]) {
- break;
- }
- }
- if (t < 16) {
- itr = itr->ai_next;
- continue;
- } else {
- skip = 1;
- break;
- }
+ skip = 1;
+ break;
}
- } else if (iterator->ai_family != AF_INET &&
- iterator->ai_family != AF_INET6) {
- /* we can't handle other family types */
- skip = 1;
- break;
}
- itr = itr->ai_next;
+ } else if (iterator->ai_family != AF_INET &&
+ iterator->ai_family != AF_INET6) {
+ /* we can't handle other family types */
+ skip = 1;
+ break;
}
-
- if (!skip) {
- struct addrinfo *next
- = (struct addrinfo*) malloc(sizeof(struct addrinfo));
- if (!next) {
- JNU_ThrowOutOfMemoryError(env, "heap allocation failed");
- ret = NULL;
- goto cleanupAndReturn;
- }
- memcpy(next, iterator, sizeof(struct addrinfo));
- next->ai_next = NULL;
- if (resNew == NULL) {
- resNew = next;
- } else {
- last->ai_next = next;
- }
- last = next;
- i++;
- if (iterator->ai_family == AF_INET) {
- inetCount ++;
- } else if (iterator->ai_family == AF_INET6) {
- inet6Count ++;
- }
- }
- iterator = iterator->ai_next;
- }
- retLen = i;
- iterator = resNew;
- i = 0;
- ret = (*env)->NewObjectArray(env, retLen, ni_iacls, NULL);
-
- if (IS_NULL(ret)) {
- /* we may have memory to free at the end of this */
- goto cleanupAndReturn;
+ itr = itr->ai_next;
}
- if (preferIPv6Address) {
- inetIndex = inet6Count;
- inet6Index = 0;
- } else {
- inetIndex = 0;
- inet6Index = inetCount;
- }
-
- while (iterator != NULL) {
- if (iterator->ai_family == AF_INET) {
- jobject iaObj = (*env)->NewObject(env, ni_ia4cls, ni_ia4ctrID);
- if (IS_NULL(iaObj)) {
+ if (!skip) {
+ struct addrinfo *next
+ = (struct addrinfo*) malloc(sizeof(struct addrinfo));
+ if (!next) {
+ JNU_ThrowOutOfMemoryError(env, "heap allocation failed");
ret = NULL;
goto cleanupAndReturn;
- }
- (*env)->SetIntField(env, iaObj, ni_iaaddressID,
- ntohl(((struct sockaddr_in*)iterator->ai_addr)->sin_addr.s_addr));
- (*env)->SetObjectField(env, iaObj, ni_iahostID, host);
- (*env)->SetObjectArrayElement(env, ret, inetIndex, iaObj);
- inetIndex ++;
+ }
+ memcpy(next, iterator, sizeof(struct addrinfo));
+ next->ai_next = NULL;
+ if (resNew == NULL) {
+ resNew = next;
+ } else {
+ last->ai_next = next;
+ }
+ last = next;
+ i++;
+ if (iterator->ai_family == AF_INET) {
+ inetCount ++;
} else if (iterator->ai_family == AF_INET6) {
- jint scope = 0;
- jbyteArray ipaddress;
- jobject iaObj = (*env)->NewObject(env, ni_ia6cls, ni_ia6ctrID);
- if (IS_NULL(iaObj)) {
- ret = NULL;
- goto cleanupAndReturn;
- }
- ipaddress = (*env)->NewByteArray(env, 16);
- if (IS_NULL(ipaddress)) {
- ret = NULL;
- goto cleanupAndReturn;
- }
- (*env)->SetByteArrayRegion(env, ipaddress, 0, 16,
- (jbyte *)&(((struct sockaddr_in6*)iterator->ai_addr)->sin6_addr));
- scope = ((struct sockaddr_in6*)iterator->ai_addr)->sin6_scope_id;
- if (scope != 0) { /* zero is default value, no need to set */
- (*env)->SetIntField(env, iaObj, ia6_scopeidID, scope);
- (*env)->SetBooleanField(env, iaObj, ia6_scopeidsetID, JNI_TRUE);
- }
- (*env)->SetObjectField(env, iaObj, ni_ia6ipaddressID, ipaddress);
- (*env)->SetObjectField(env, iaObj, ni_iahostID, host);
- (*env)->SetObjectArrayElement(env, ret, inet6Index, iaObj);
- inet6Index ++;
+ inet6Count ++;
}
- iterator = iterator->ai_next;
}
+ iterator = iterator->ai_next;
+ }
+ retLen = i;
+ iterator = resNew;
+ i = 0;
+ ret = (*env)->NewObjectArray(env, retLen, ni_iacls, NULL);
+
+ if (IS_NULL(ret)) {
+ /* we may have memory to free at the end of this */
+ goto cleanupAndReturn;
+ }
+
+ if (preferIPv6Address) {
+ inetIndex = inet6Count;
+ inet6Index = 0;
+ } else {
+ inetIndex = 0;
+ inet6Index = inetCount;
+ }
+
+ while (iterator != NULL) {
+ if (iterator->ai_family == AF_INET) {
+ jobject iaObj = (*env)->NewObject(env, ni_ia4cls, ni_ia4ctrID);
+ if (IS_NULL(iaObj)) {
+ ret = NULL;
+ goto cleanupAndReturn;
+ }
+ (*env)->SetIntField(env, iaObj, ni_iaaddressID,
+ ntohl(((struct sockaddr_in*)iterator->ai_addr)->sin_addr.s_addr));
+ (*env)->SetObjectField(env, iaObj, ni_iahostID, host);
+ (*env)->SetObjectArrayElement(env, ret, inetIndex, iaObj);
+ inetIndex ++;
+ } else if (iterator->ai_family == AF_INET6) {
+ jint scope = 0;
+ jbyteArray ipaddress;
+ jobject iaObj = (*env)->NewObject(env, ni_ia6cls, ni_ia6ctrID);
+ if (IS_NULL(iaObj)) {
+ ret = NULL;
+ goto cleanupAndReturn;
+ }
+ ipaddress = (*env)->NewByteArray(env, 16);
+ if (IS_NULL(ipaddress)) {
+ ret = NULL;
+ goto cleanupAndReturn;
+ }
+ (*env)->SetByteArrayRegion(env, ipaddress, 0, 16,
+ (jbyte *)&(((struct sockaddr_in6*)iterator->ai_addr)->sin6_addr));
+ scope = ((struct sockaddr_in6*)iterator->ai_addr)->sin6_scope_id;
+ if (scope != 0) { /* zero is default value, no need to set */
+ (*env)->SetIntField(env, iaObj, ia6_scopeidID, scope);
+ (*env)->SetBooleanField(env, iaObj, ia6_scopeidsetID, JNI_TRUE);
+ }
+ (*env)->SetObjectField(env, iaObj, ni_ia6ipaddressID, ipaddress);
+ (*env)->SetObjectField(env, iaObj, ni_iahostID, host);
+ (*env)->SetObjectArrayElement(env, ret, inet6Index, iaObj);
+ inet6Index ++;
+ }
+ iterator = iterator->ai_next;
}
}
@@ -291,8 +289,7 @@ cleanupAndReturn:
JNU_ReleaseStringPlatformChars(env, host, hostname);
}
- if (NET_addrtransAvailable())
- (*freeaddrinfo_ptr)(res);
+ freeaddrinfo(res);
return ret;
}
@@ -312,44 +309,41 @@ Java_java_net_Inet6AddressImpl_getHostByAddr(JNIEnv *env, jobject this,
int len = 0;
jbyte caddr[16];
- if (NET_addrtransAvailable()) {
- struct sockaddr_in him4;
- struct sockaddr_in6 him6;
- struct sockaddr *sa;
+ struct sockaddr_in him4;
+ struct sockaddr_in6 him6;
+ struct sockaddr *sa;
+ /*
+ * For IPv4 addresses construct a sockaddr_in structure.
+ */
+ if ((*env)->GetArrayLength(env, addrArray) == 4) {
+ jint addr;
+ (*env)->GetByteArrayRegion(env, addrArray, 0, 4, caddr);
+ addr = ((caddr[0]<<24) & 0xff000000);
+ addr |= ((caddr[1] <<16) & 0xff0000);
+ addr |= ((caddr[2] <<8) & 0xff00);
+ addr |= (caddr[3] & 0xff);
+ memset((char *) &him4, 0, sizeof(him4));
+ him4.sin_addr.s_addr = (uint32_t) htonl(addr);
+ him4.sin_family = AF_INET;
+ sa = (struct sockaddr *) &him4;
+ len = sizeof(him4);
+ } else {
/*
- * For IPv4 addresses construct a sockaddr_in structure.
+ * For IPv6 address construct a sockaddr_in6 structure.
*/
- if ((*env)->GetArrayLength(env, addrArray) == 4) {
- jint addr;
- (*env)->GetByteArrayRegion(env, addrArray, 0, 4, caddr);
- addr = ((caddr[0]<<24) & 0xff000000);
- addr |= ((caddr[1] <<16) & 0xff0000);
- addr |= ((caddr[2] <<8) & 0xff00);
- addr |= (caddr[3] & 0xff);
- memset((char *) &him4, 0, sizeof(him4));
- him4.sin_addr.s_addr = (uint32_t) htonl(addr);
- him4.sin_family = AF_INET;
- sa = (struct sockaddr *) &him4;
- len = sizeof(him4);
- } else {
- /*
- * For IPv6 address construct a sockaddr_in6 structure.
- */
- (*env)->GetByteArrayRegion(env, addrArray, 0, 16, caddr);
- memset((char *) &him6, 0, sizeof(him6));
- memcpy((void *)&(him6.sin6_addr), caddr, sizeof(struct in6_addr) );
- him6.sin6_family = AF_INET6;
- sa = (struct sockaddr *) &him6 ;
- len = sizeof(him6) ;
- }
+ (*env)->GetByteArrayRegion(env, addrArray, 0, 16, caddr);
+ memset((char *) &him6, 0, sizeof(him6));
+ memcpy((void *)&(him6.sin6_addr), caddr, sizeof(struct in6_addr) );
+ him6.sin6_family = AF_INET6;
+ sa = (struct sockaddr *) &him6 ;
+ len = sizeof(him6) ;
+ }
- error = (*getnameinfo_ptr)(sa, len, host, NI_MAXHOST, NULL, 0,
- NI_NAMEREQD);
+ error = getnameinfo(sa, len, host, NI_MAXHOST, NULL, 0, NI_NAMEREQD);
- if (!error) {
- ret = (*env)->NewStringUTF(env, host);
- }
+ if (!error) {
+ ret = (*env)->NewStringUTF(env, host);
}
if (ret == NULL) {
diff --git a/src/windows/native/java/net/NetworkInterface.c b/src/windows/native/java/net/NetworkInterface.c
index 6a318722414a0fb8dbbfedd4d7ba4016de6069f6..fa5dfc13f611178b4ee6a1c4b51aef3839275186 100644
--- a/src/windows/native/java/net/NetworkInterface.c
+++ b/src/windows/native/java/net/NetworkInterface.c
@@ -53,36 +53,6 @@
* order and this ensures consistent device number across invocations.
*/
-
-/* IP helper library routines */
-int (PASCAL FAR *GetIpAddrTable_fn)();
-int (PASCAL FAR *GetIfTable_fn)();
-int (PASCAL FAR *GetFriendlyIfIndex_fn)();
-int (PASCAL FAR *GetAdaptersAddresses_fn)();
-int (PASCAL FAR *GetAdaptersInfo_fn)();
-int (PASCAL FAR *GetNumberOfInterfaces_fn)();
-
-/* Enumeration routines */
-typedef int (*EnumerateNetInterfaces)(JNIEnv *, netif **);
-typedef int(*EnumerateNetAddresses)(JNIEnv *, netif *, netaddr **);
-
-static EnumerateNetInterfaces enumInterfaces_fn;
-static EnumerateNetAddresses enumAddresses_fn;
-
-/* Windows 9x routines are external (not needed on 64-bit) */
-#ifndef _WIN64
-extern int enumInterfaces_win9x(JNIEnv *, netif **);
-extern int enumAddresses_win9x(JNIEnv *, netif *, netaddr **);
-extern int init_win9x(void);
-#endif
-
-
-/* Windows 95/98/ME running */
-static jboolean isW9x;
-
-/* Windows version supports */
-static jboolean os_supports_ipv6;
-
/* various JNI ids */
jclass ni_class; /* NetworkInterface */
@@ -154,10 +124,10 @@ MIB_IFROW *getIF(jint index) {
*/
size = sizeof(MIB_IFTABLE);
tableP = (MIB_IFTABLE *)malloc(size);
- count = (*GetIfTable_fn)(tableP, &size, TRUE);
+ count = GetIfTable(tableP, &size, TRUE);
if (count == ERROR_INSUFFICIENT_BUFFER || count == ERROR_BUFFER_OVERFLOW) {
tableP = (MIB_IFTABLE *)realloc(tableP, size);
- count = (*GetIfTable_fn)(tableP, &size, TRUE);
+ count = GetIfTable(tableP, &size, TRUE);
}
if (count != NO_ERROR) {
@@ -172,7 +142,7 @@ MIB_IFROW *getIF(jint index) {
/*
* Warning the real index is obtained by GetFriendlyIfIndex()
*/
- ifindex = (*GetFriendlyIfIndex_fn)(ifrowP->dwIndex);
+ ifindex = GetFriendlyIfIndex(ifrowP->dwIndex);
if (ifindex == index) {
/*
* Create a copy of the entry so that we can free the table.
@@ -199,7 +169,7 @@ MIB_IFROW *getIF(jint index) {
* occurs then netifPP be returned as list of netif structures or NULL
* if no interfaces are found.
*/
-int enumInterfaces_win(JNIEnv *env, netif **netifPP)
+int enumInterfaces(JNIEnv *env, netif **netifPP)
{
MIB_IFTABLE *tableP;
MIB_IFROW *ifrowP;
@@ -215,32 +185,16 @@ int enumInterfaces_win(JNIEnv *env, netif **netifPP)
*/
size = sizeof(MIB_IFTABLE);
tableP = (MIB_IFTABLE *)malloc(size);
- ret = (*GetIfTable_fn)(tableP, &size, TRUE);
+ ret = GetIfTable(tableP, &size, TRUE);
if (ret == ERROR_INSUFFICIENT_BUFFER || ret == ERROR_BUFFER_OVERFLOW) {
tableP = (MIB_IFTABLE *)realloc(tableP, size);
- ret = (*GetIfTable_fn)(tableP, &size, TRUE);
+ ret = GetIfTable(tableP, &size, TRUE);
}
if (ret != NO_ERROR) {
if (tableP != NULL)
free(tableP);
-#ifndef _WIN64
- if (isW9x && ret == ERROR_NOT_SUPPORTED) {
- /*
- * If ERROR_NOT_SUPPORTED is returned on Windows 98 it means that
- * IE5.0 has been installed. In this case we revert to the Windows 95
- * approach and avoid using the IP Helper Library.
- * See: http://support.microsoft.com/support/kb/articles/q234/5/73.asp
- */
- enumInterfaces_fn = enumInterfaces_win9x;
- enumAddresses_fn = enumAddresses_win9x;
- init_win9x();
-
- return (*enumInterfaces_fn)(env, netifPP);
- }
-#endif
-
JNU_ThrowByName(env, "java/lang/Error",
"IP Helper Library GetIfTable function failed");
@@ -328,7 +282,7 @@ int enumInterfaces_win(JNIEnv *env, netif **netifPP)
curr->displayName[ifrowP->dwDescrLen] = '\0';
curr->dwIndex = ifrowP->dwIndex;
curr->ifType = ifrowP->dwType;
- curr->index = (*GetFriendlyIfIndex_fn)(ifrowP->dwIndex);
+ curr->index = GetFriendlyIfIndex(ifrowP->dwIndex);
/*
* Put the interface at tail of list as GetIfTable(,,TRUE) is
@@ -384,10 +338,10 @@ int enumAddresses_win(JNIEnv *env, netif *netifP, netaddr **netaddrPP)
size = sizeof(MIB_IPADDRTABLE);
tableP = (MIB_IPADDRTABLE *)malloc(size);
- ret = (*GetIpAddrTable_fn)(&tableP, &size, FALSE);
+ ret = GetIpAddrTable(tableP, &size, FALSE);
if (ret == ERROR_INSUFFICIENT_BUFFER || ret == ERROR_BUFFER_OVERFLOW) {
tableP = (MIB_IPADDRTABLE *)realloc(tableP, size);
- ret = (*GetIpAddrTable_fn)(tableP, &size, FALSE);
+ ret = GetIpAddrTable(tableP, &size, FALSE);
}
if (ret != NO_ERROR) {
if (tableP) {
@@ -477,71 +431,6 @@ int enumAddresses_win(JNIEnv *env, netif *netifP, netaddr **netaddrPP)
JNIEXPORT void JNICALL
Java_java_net_NetworkInterface_init(JNIEnv *env, jclass cls)
{
- OSVERSIONINFO ver;
- HANDLE h;
-
- /*
- * First check if this is a Windows 9x machine.
- */
- ver.dwOSVersionInfoSize = sizeof(ver);
- GetVersionEx(&ver);
- if (ver.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS && ver.dwMajorVersion == 4) {
- isW9x = JNI_TRUE;
- }
-
- /*
- * Try to load the IP Helper Library and obtain the entry points we
- * require. This will succeed on 98, NT SP4+, 2000 & XP. It will
- * fail on Windows 95 (if IE hasn't been updated) and old versions
- * of NT (IP helper library only appeared at SP4). If it fails on
- * Windows 9x we will use the registry approach, otherwise if it
- * fails we throw an Error indicating that we have an incompatible
- * IP helper library.
- */
- h = LoadLibrary("iphlpapi.dll");
- if (h != NULL) {
- GetIpAddrTable_fn =
- (int (PASCAL FAR *)())GetProcAddress(h, "GetIpAddrTable");
- GetIfTable_fn =
- (int (PASCAL FAR *)())GetProcAddress(h, "GetIfTable");
- GetFriendlyIfIndex_fn =
- (int (PASCAL FAR *)())GetProcAddress(h, "GetFriendlyIfIndex");
- GetNumberOfInterfaces_fn =
- (int (PASCAL FAR *)())GetProcAddress(h, "GetNumberOfInterfaces");
- GetAdaptersAddresses_fn =
- (int (PASCAL FAR *)())GetProcAddress(h, "GetAdaptersAddresses");
- GetAdaptersInfo_fn =
- (int (PASCAL FAR *)())GetProcAddress(h, "GetAdaptersInfo");
- }
-
- /* IPv6 is supported on Windows versions if the following APIs avail */
-
- os_supports_ipv6 = (GetAdaptersAddresses_fn != NULL) &&
- (GetNumberOfInterfaces_fn != NULL) &&
- (GetAdaptersInfo_fn != NULL);
-
- if (GetIpAddrTable_fn == NULL ||
- GetIfTable_fn == NULL ||
- GetFriendlyIfIndex_fn == NULL) {
-
-#ifndef _WIN64
- if (isW9x) {
- /* Use Windows 9x registry approach which requires initialization */
- enumInterfaces_fn = enumInterfaces_win9x;
- enumAddresses_fn = enumAddresses_win9x;
- init_win9x();
- } else
-#endif
- {
- JNU_ThrowByName(env, "java/lang/Error",
- "Incompatible IP helper library (iphlpapi.dll)");
- return;
- }
- } else {
- enumInterfaces_fn = enumInterfaces_win;
- enumAddresses_fn = enumAddresses_win;
- }
-
/*
* Get the various JNI ids that we require
*/
@@ -581,7 +470,8 @@ Java_java_net_NetworkInterface_init(JNIEnv *env, jclass cls)
* populate the InetAddress array based on the IP addresses for this
* interface.
*/
-jobject createNetworkInterface(JNIEnv *env, netif *ifs, int netaddrCount, netaddr *netaddrP)
+jobject createNetworkInterface
+ (JNIEnv *env, netif *ifs, int netaddrCount, netaddr *netaddrP)
{
jobject netifObj;
jobject name, displayName;
@@ -596,7 +486,8 @@ jobject createNetworkInterface(JNIEnv *env, netif *ifs, int netaddrCount, netadd
netifObj = (*env)->NewObject(env, ni_class, ni_ctor);
name = (*env)->NewStringUTF(env, ifs->name);
if (ifs->dNameIsUnicode) {
- displayName = (*env)->NewString(env, (PWCHAR)ifs->displayName, wcslen ((PWCHAR)ifs->displayName));
+ displayName = (*env)->NewString(env, (PWCHAR)ifs->displayName,
+ (jsize)wcslen ((PWCHAR)ifs->displayName));
} else {
displayName = (*env)->NewStringUTF(env, ifs->displayName);
}
@@ -612,7 +503,7 @@ jobject createNetworkInterface(JNIEnv *env, netif *ifs, int netaddrCount, netadd
* Note that 0 is a valid number of addresses.
*/
if (netaddrCount < 0) {
- netaddrCount = (*enumAddresses_fn)(env, ifs, &netaddrP);
+ netaddrCount = enumAddresses_win(env, ifs, &netaddrP);
if ((*env)->ExceptionOccurred(env)) {
free_netaddr(netaddrP);
return NULL;
@@ -725,12 +616,13 @@ JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByName0
const char *name_utf;
jobject netifObj = NULL;
- if (os_supports_ipv6 && ipv6_available()) {
+ // Retained for now to support IPv4 only stack, java.net.preferIPv4Stack
+ if (ipv6_available()) {
return Java_java_net_NetworkInterface_getByName0_XP (env, cls, name);
}
/* get the list of interfaces */
- if ((*enumInterfaces_fn)(env, &ifList) < 0) {
+ if (enumInterfaces(env, &ifList) < 0) {
return NULL;
}
@@ -771,12 +663,13 @@ JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByIndex0
netif *ifList, *curr;
jobject netifObj = NULL;
- if (os_supports_ipv6 && ipv6_available()) {
+ // Retained for now to support IPv4 only stack, java.net.preferIPv4Stack
+ if (ipv6_available()) {
return Java_java_net_NetworkInterface_getByIndex0_XP (env, cls, index);
}
/* get the list of interfaces */
- if ((*enumInterfaces_fn)(env, &ifList) < 0) {
+ if (enumInterfaces(env, &ifList) < 0) {
return NULL;
}
@@ -812,12 +705,13 @@ JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByInetAddress0
jint addr = (*env)->GetIntField(env, iaObj, ni_iaAddr);
jobject netifObj = NULL;
- if (os_supports_ipv6 && ipv6_available()) {
+ // Retained for now to support IPv4 only stack, java.net.preferIPv4Stack
+ if (ipv6_available()) {
return Java_java_net_NetworkInterface_getByInetAddress0_XP (env, cls, iaObj);
}
/* get the list of interfaces */
- if ((*enumInterfaces_fn)(env, &ifList) < 0) {
+ if (enumInterfaces(env, &ifList) < 0) {
return NULL;
}
@@ -832,7 +726,7 @@ JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByInetAddress0
netaddr *addrP;
/* enumerate the addresses on this interface */
- count = (*enumAddresses_fn)(env, curr, &addrList);
+ count = enumAddresses_win(env, curr, &addrList);
if (count < 0) {
free_netif(ifList);
return NULL;
@@ -881,14 +775,15 @@ JNIEXPORT jobjectArray JNICALL Java_java_net_NetworkInterface_getAll
jobjectArray netIFArr;
jint arr_index;
- if (os_supports_ipv6 && ipv6_available()) {
+ // Retained for now to support IPv4 only stack, java.net.preferIPv4Stack
+ if (ipv6_available()) {
return Java_java_net_NetworkInterface_getAll_XP (env, cls);
}
/*
* Get list of interfaces
*/
- count = (*enumInterfaces_fn)(env, &ifList);
+ count = enumInterfaces(env, &ifList);
if (count < 0) {
return NULL;
}
@@ -934,13 +829,16 @@ JNIEXPORT jboolean JNICALL Java_java_net_NetworkInterface_isUp0
(JNIEnv *env, jclass cls, jstring name, jint index) {
jboolean ret = JNI_FALSE;
- if (os_supports_ipv6 && ipv6_available()) {
+ // Retained for now to support IPv4 only stack, java.net.preferIPv4Stack
+ if (ipv6_available()) {
return Java_java_net_NetworkInterface_isUp0_XP(env, cls, name, index);
} else {
MIB_IFROW *ifRowP;
ifRowP = getIF(index);
if (ifRowP != NULL) {
- ret = ifRowP->dwAdminStatus == 1 && (ifRowP->dwOperStatus == MIB_IF_OPER_STATUS_OPERATIONAL || ifRowP->dwOperStatus == MIB_IF_OPER_STATUS_CONNECTED);
+ ret = ifRowP->dwAdminStatus == 1 &&
+ (ifRowP->dwOperStatus == MIB_IF_OPER_STATUS_OPERATIONAL ||
+ ifRowP->dwOperStatus == MIB_IF_OPER_STATUS_CONNECTED);
free(ifRowP);
}
}
@@ -952,11 +850,13 @@ JNIEXPORT jboolean JNICALL Java_java_net_NetworkInterface_isUp0
* Method: isP2P0
* Signature: (Ljava/lang/String;I)Z
*/
-JNIEXPORT jboolean JNICALL Java_java_net_NetworkInterface_isP2P0(JNIEnv *env, jclass cls, jstring name, jint index) {
+JNIEXPORT jboolean JNICALL Java_java_net_NetworkInterface_isP2P0
+ (JNIEnv *env, jclass cls, jstring name, jint index) {
MIB_IFROW *ifRowP;
jboolean ret = JNI_FALSE;
- if (os_supports_ipv6 && ipv6_available()) {
+ // Retained for now to support IPv4 only stack, java.net.preferIPv4Stack
+ if (ipv6_available()) {
return Java_java_net_NetworkInterface_isP2P0_XP(env, cls, name, index);
} else {
ifRowP = getIF(index);
@@ -983,7 +883,8 @@ JNIEXPORT jboolean JNICALL Java_java_net_NetworkInterface_isLoopback0
MIB_IFROW *ifRowP;
jboolean ret = JNI_FALSE;
- if (os_supports_ipv6 && ipv6_available()) {
+ // Retained for now to support IPv4 only stack, java.net.preferIPv4Stack
+ if (ipv6_available()) {
return Java_java_net_NetworkInterface_isLoopback0_XP(env, cls, name, index);
} else {
ifRowP = getIF(index);
@@ -1003,22 +904,8 @@ JNIEXPORT jboolean JNICALL Java_java_net_NetworkInterface_isLoopback0
*/
JNIEXPORT jboolean JNICALL Java_java_net_NetworkInterface_supportsMulticast0
(JNIEnv *env, jclass cls, jstring name, jint index) {
- MIB_IFROW *ifRowP;
- jboolean ret = JNI_TRUE;
-
- // Let's try to use the newer API (XP & 2003 only)
- if (GetAdaptersAddresses_fn != NULL) {
- ret = Java_java_net_NetworkInterface_supportsMulticast0_XP(env, cls,
+ return Java_java_net_NetworkInterface_supportsMulticast0_XP(env, cls,
name, index);
- return ret;
- }
- ifRowP = getIF(index);
- if (ifRowP != NULL) {
- if (ifRowP->dwType == MIB_IF_TYPE_LOOPBACK)
- ret = JNI_FALSE;
- free(ifRowP);
- }
- return ret;
}
/*
@@ -1026,12 +913,14 @@ JNIEXPORT jboolean JNICALL Java_java_net_NetworkInterface_supportsMulticast0
* Method: getMacAddr0
* Signature: ([bLjava/lang/String;I)[b
*/
-JNIEXPORT jbyteArray JNICALL Java_java_net_NetworkInterface_getMacAddr0(JNIEnv *env, jclass class, jbyteArray addrArray, jstring name, jint index) {
+JNIEXPORT jbyteArray JNICALL Java_java_net_NetworkInterface_getMacAddr0
+ (JNIEnv *env, jclass class, jbyteArray addrArray, jstring name, jint index) {
jbyteArray ret = NULL;
int len;
MIB_IFROW *ifRowP;
- if (os_supports_ipv6 && ipv6_available()) {
+ // Retained for now to support IPv4 only stack, java.net.preferIPv4Stack
+ if (ipv6_available()) {
return Java_java_net_NetworkInterface_getMacAddr0_XP(env, class, name, index);
} else {
ifRowP = getIF(index);
@@ -1058,11 +947,13 @@ JNIEXPORT jbyteArray JNICALL Java_java_net_NetworkInterface_getMacAddr0(JNIEnv *
* Method: getMTU0
* Signature: ([bLjava/lang/String;I)I
*/
-JNIEXPORT jint JNICALL Java_java_net_NetworkInterface_getMTU0(JNIEnv *env, jclass class, jstring name, jint index) {
+JNIEXPORT jint JNICALL Java_java_net_NetworkInterface_getMTU0
+ (JNIEnv *env, jclass class, jstring name, jint index) {
jint ret = -1;
MIB_IFROW *ifRowP;
- if (os_supports_ipv6 && ipv6_available()) {
+ // Retained for now to support IPv4 only stack, java.net.preferIPv4Stack
+ if (ipv6_available()) {
return Java_java_net_NetworkInterface_getMTU0_XP(env, class, name, index);
} else {
ifRowP = getIF(index);
diff --git a/src/windows/native/java/net/NetworkInterface.h b/src/windows/native/java/net/NetworkInterface.h
index 6d3e1c1a95771a366172dbb8affa63a1b5a806fa..262e15a0db0960492ecf709986e235cbe98016eb 100644
--- a/src/windows/native/java/net/NetworkInterface.h
+++ b/src/windows/native/java/net/NetworkInterface.h
@@ -87,338 +87,6 @@ extern jfieldID ni_ibaddressID; /* InterfaceAddress.address */
extern jfieldID ni_ibbroadcastID; /* InterfaceAddress.broadcast */
extern jfieldID ni_ibmaskID; /* InterfaceAddress.maskLength */
-int enumInterfaces_win(JNIEnv *env, netif **netifPP);
-
-/* We have included iphlpapi.h which includes iptypes.h which has the definition
- * for MAX_ADAPTER_DESCRIPTION_LENGTH (along with the other definitions in this
- * ifndef block). Therefore if MAX_ADAPTER_DESCRIPTION_LENGTH is defined we can
- * be sure that the other definitions are also defined */
-#ifndef MAX_ADAPTER_DESCRIPTION_LENGTH
-
-/*
- * Following includes come from iptypes.h
- */
-
-#pragma warning(push)
-#pragma warning(disable:4201)
-
-#include
-
-// Definitions and structures used by getnetworkparams and getadaptersinfo apis
-
-#define MAX_ADAPTER_DESCRIPTION_LENGTH 128 // arb.
-#define MAX_ADAPTER_NAME_LENGTH 256 // arb.
-#define MAX_ADAPTER_ADDRESS_LENGTH 8 // arb.
-#define DEFAULT_MINIMUM_ENTITIES 32 // arb.
-#define MAX_HOSTNAME_LEN 128 // arb.
-#define MAX_DOMAIN_NAME_LEN 128 // arb.
-#define MAX_SCOPE_ID_LEN 256 // arb.
-
-//
-// types
-//
-
-// Node Type
-
-#define BROADCAST_NODETYPE 1
-#define PEER_TO_PEER_NODETYPE 2
-#define MIXED_NODETYPE 4
-#define HYBRID_NODETYPE 8
-
-//
-// IP_ADDRESS_STRING - store an IP address as a dotted decimal string
-//
-
-typedef struct {
- char String[4 * 4];
-} IP_ADDRESS_STRING, *PIP_ADDRESS_STRING, IP_MASK_STRING, *PIP_MASK_STRING;
-
-//
-// IP_ADDR_STRING - store an IP address with its corresponding subnet mask,
-// both as dotted decimal strings
-//
-
-typedef struct _IP_ADDR_STRING {
- struct _IP_ADDR_STRING* Next;
- IP_ADDRESS_STRING IpAddress;
- IP_MASK_STRING IpMask;
- DWORD Context;
-} IP_ADDR_STRING, *PIP_ADDR_STRING;
-
-//
-// ADAPTER_INFO - per-adapter information. All IP addresses are stored as
-// strings
-//
-
-typedef struct _IP_ADAPTER_INFO {
- struct _IP_ADAPTER_INFO* Next;
- DWORD ComboIndex;
- char AdapterName[MAX_ADAPTER_NAME_LENGTH + 4];
- char Description[MAX_ADAPTER_DESCRIPTION_LENGTH + 4];
- UINT AddressLength;
- BYTE Address[MAX_ADAPTER_ADDRESS_LENGTH];
- DWORD Index;
- UINT Type;
- UINT DhcpEnabled;
- PIP_ADDR_STRING CurrentIpAddress;
- IP_ADDR_STRING IpAddressList;
- IP_ADDR_STRING GatewayList;
- IP_ADDR_STRING DhcpServer;
- BOOL HaveWins;
- IP_ADDR_STRING PrimaryWinsServer;
- IP_ADDR_STRING SecondaryWinsServer;
- time_t LeaseObtained;
- time_t LeaseExpires;
-} IP_ADAPTER_INFO, *PIP_ADAPTER_INFO;
-
-#ifdef _WINSOCK2API_
-
-//
-// The following types require Winsock2.
-//
-
-typedef enum {
- IpPrefixOriginOther = 0,
- IpPrefixOriginManual,
- IpPrefixOriginWellKnown,
- IpPrefixOriginDhcp,
- IpPrefixOriginRouterAdvertisement,
-} IP_PREFIX_ORIGIN;
-
-typedef enum {
- IpSuffixOriginOther = 0,
- IpSuffixOriginManual,
- IpSuffixOriginWellKnown,
- IpSuffixOriginDhcp,
- IpSuffixOriginLinkLayerAddress,
- IpSuffixOriginRandom,
-} IP_SUFFIX_ORIGIN;
-
-typedef enum {
- IpDadStateInvalid = 0,
- IpDadStateTentative,
- IpDadStateDuplicate,
- IpDadStateDeprecated,
- IpDadStatePreferred,
-} IP_DAD_STATE;
-
-typedef struct _IP_ADAPTER_UNICAST_ADDRESS {
- union {
- ULONGLONG Alignment;
- struct {
- ULONG Length;
- DWORD Flags;
- };
- };
- struct _IP_ADAPTER_UNICAST_ADDRESS *Next;
- SOCKET_ADDRESS Address;
-
- IP_PREFIX_ORIGIN PrefixOrigin;
- IP_SUFFIX_ORIGIN SuffixOrigin;
- IP_DAD_STATE DadState;
-
- ULONG ValidLifetime;
- ULONG PreferredLifetime;
- ULONG LeaseLifetime;
-} IP_ADAPTER_UNICAST_ADDRESS, *PIP_ADAPTER_UNICAST_ADDRESS;
-
-typedef struct _IP_ADAPTER_ANYCAST_ADDRESS {
- union {
- ULONGLONG Alignment;
- struct {
- ULONG Length;
- DWORD Flags;
- };
- };
- struct _IP_ADAPTER_ANYCAST_ADDRESS *Next;
- SOCKET_ADDRESS Address;
-} IP_ADAPTER_ANYCAST_ADDRESS, *PIP_ADAPTER_ANYCAST_ADDRESS;
-
-typedef struct _IP_ADAPTER_MULTICAST_ADDRESS {
- union {
- ULONGLONG Alignment;
- struct {
- ULONG Length;
- DWORD Flags;
- };
- };
- struct _IP_ADAPTER_MULTICAST_ADDRESS *Next;
- SOCKET_ADDRESS Address;
-} IP_ADAPTER_MULTICAST_ADDRESS, *PIP_ADAPTER_MULTICAST_ADDRESS;
-
-//
-// Per-address Flags
-//
-#define IP_ADAPTER_ADDRESS_DNS_ELIGIBLE 0x01
-#define IP_ADAPTER_ADDRESS_TRANSIENT 0x02
-
-typedef struct _IP_ADAPTER_DNS_SERVER_ADDRESS {
- union {
- ULONGLONG Alignment;
- struct {
- ULONG Length;
- DWORD Reserved;
- };
- };
- struct _IP_ADAPTER_DNS_SERVER_ADDRESS *Next;
- SOCKET_ADDRESS Address;
-} IP_ADAPTER_DNS_SERVER_ADDRESS, *PIP_ADAPTER_DNS_SERVER_ADDRESS;
-
-typedef struct _IP_ADAPTER_PREFIX {
- union {
- ULONGLONG Alignment;
- struct {
- ULONG Length;
- DWORD Flags;
- };
- };
- struct _IP_ADAPTER_PREFIX *Next;
- SOCKET_ADDRESS Address;
- ULONG PrefixLength;
-} IP_ADAPTER_PREFIX, *PIP_ADAPTER_PREFIX;
-
-//
-// Per-adapter Flags
-//
-#define IP_ADAPTER_DDNS_ENABLED 0x01
-#define IP_ADAPTER_REGISTER_ADAPTER_SUFFIX 0x02
-#define IP_ADAPTER_DHCP_ENABLED 0x04
-#define IP_ADAPTER_RECEIVE_ONLY 0x08
-#define IP_ADAPTER_NO_MULTICAST 0x10
-#define IP_ADAPTER_IPV6_OTHER_STATEFUL_CONFIG 0x20
-
-//
-// OperStatus values from RFC 2863
-//
-typedef enum {
- IfOperStatusUp = 1,
- IfOperStatusDown,
- IfOperStatusTesting,
- IfOperStatusUnknown,
- IfOperStatusDormant,
- IfOperStatusNotPresent,
- IfOperStatusLowerLayerDown
-} IF_OPER_STATUS;
-
-//
-// Scope levels from RFC 2373 used with ZoneIndices array.
-//
-typedef enum {
- ScopeLevelInterface = 1,
- ScopeLevelLink = 2,
- ScopeLevelSubnet = 3,
- ScopeLevelAdmin = 4,
- ScopeLevelSite = 5,
- ScopeLevelOrganization = 8,
- ScopeLevelGlobal = 14
-} SCOPE_LEVEL;
-
-typedef struct _IP_ADAPTER_ADDRESSES {
- union {
- ULONGLONG Alignment;
- struct {
- ULONG Length;
- DWORD IfIndex;
- };
- };
- struct _IP_ADAPTER_ADDRESSES *Next;
- PCHAR AdapterName;
- PIP_ADAPTER_UNICAST_ADDRESS FirstUnicastAddress;
- PIP_ADAPTER_ANYCAST_ADDRESS FirstAnycastAddress;
- PIP_ADAPTER_MULTICAST_ADDRESS FirstMulticastAddress;
- PIP_ADAPTER_DNS_SERVER_ADDRESS FirstDnsServerAddress;
- PWCHAR DnsSuffix;
- PWCHAR Description;
- PWCHAR FriendlyName;
- BYTE PhysicalAddress[MAX_ADAPTER_ADDRESS_LENGTH];
- DWORD PhysicalAddressLength;
- DWORD Flags;
- DWORD Mtu;
- DWORD IfType;
- IF_OPER_STATUS OperStatus;
- DWORD Ipv6IfIndex;
- DWORD ZoneIndices[16];
- PIP_ADAPTER_PREFIX FirstPrefix;
-} IP_ADAPTER_ADDRESSES, *PIP_ADAPTER_ADDRESSES;
-
-//
-// Flags used as argument to GetAdaptersAddresses().
-// "SKIP" flags are added when the default is to include the information.
-// "INCLUDE" flags are added when the default is to skip the information.
-//
-#define GAA_FLAG_SKIP_UNICAST 0x0001
-#define GAA_FLAG_SKIP_ANYCAST 0x0002
-#define GAA_FLAG_SKIP_MULTICAST 0x0004
-#define GAA_FLAG_SKIP_DNS_SERVER 0x0008
-#define GAA_FLAG_INCLUDE_PREFIX 0x0010
-#define GAA_FLAG_SKIP_FRIENDLY_NAME 0x0020
-
-#endif /* _WINSOCK2API_ */
-
-//
-// IP_PER_ADAPTER_INFO - per-adapter IP information such as DNS server list.
-//
-
-typedef struct _IP_PER_ADAPTER_INFO {
- UINT AutoconfigEnabled;
- UINT AutoconfigActive;
- PIP_ADDR_STRING CurrentDnsServer;
- IP_ADDR_STRING DnsServerList;
-} IP_PER_ADAPTER_INFO, *PIP_PER_ADAPTER_INFO;
-
-//
-// FIXED_INFO - the set of IP-related information which does not depend on DHCP
-//
-
-typedef struct {
- char HostName[MAX_HOSTNAME_LEN + 4] ;
- char DomainName[MAX_DOMAIN_NAME_LEN + 4];
- PIP_ADDR_STRING CurrentDnsServer;
- IP_ADDR_STRING DnsServerList;
- UINT NodeType;
- char ScopeId[MAX_SCOPE_ID_LEN + 4];
- UINT EnableRouting;
- UINT EnableProxy;
- UINT EnableDns;
-} FIXED_INFO, *PFIXED_INFO;
-
-#pragma warning(pop)
-
-#endif /*!MAX_ADAPTER_DESCRIPTION_LENGTH*/
-
-#ifndef IP_INTERFACE_NAME_INFO_DEFINED
-#define IP_INTERFACE_NAME_INFO_DEFINED
-
-typedef struct ip_interface_name_info {
- ULONG Index; // Interface Index
- ULONG MediaType; // Interface Types - see ipifcons.h
- UCHAR ConnectionType;
- UCHAR AccessType;
- GUID DeviceGuid; // Device GUID is the guid of the device
- // that IP exposes
- GUID InterfaceGuid; // Interface GUID, if not GUID_NULL is the
- // GUID for the interface mapped to the device.
-} IP_INTERFACE_NAME_INFO, *PIP_INTERFACE_NAME_INFO;
-
-#endif
-
-
-/* from ipifcons.h */
-
-#ifndef IF_TYPE_PPP
-#define IF_TYPE_PPP 23
-#endif
-
-#ifndef IF_TYPE_SOFTWARE_LOOPBACK
-#define IF_TYPE_SOFTWARE_LOOPBACK 24
-#endif
-
-#ifndef IF_TYPE_SLIP
-#define IF_TYPE_SLIP 28
-#endif
-
-#ifndef IF_TYPE_TUNNEL
-#define IF_TYPE_TUNNEL 131
-#endif
+int enumInterfaces(JNIEnv *env, netif **netifPP);
#endif
diff --git a/src/windows/native/java/net/NetworkInterface_win9x.c b/src/windows/native/java/net/NetworkInterface_win9x.c
deleted file mode 100644
index deac1eb7f3da8efb26a4b58945cb3085ac869440..0000000000000000000000000000000000000000
--- a/src/windows/native/java/net/NetworkInterface_win9x.c
+++ /dev/null
@@ -1,1141 +0,0 @@
-/*
- * Copyright (c) 2002, 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.
- */
-
-#include
-#include
-#include
-
-#include "jni_util.h"
-
-#include "NetworkInterface.h"
-
-/*
- * Windows 9x specific routines to enumerate network interfaces and the
- * IP addresses bound to those interfaces.
- *
- * Windows 95 does not include IP helper library support by default.
- * Additionally Windows 98 can have its IP helper library support
- * trashed by certain IE installations. For these environments we
- * combine information from the registry with the list of IP addresses
- * obtained via SIO_GET_INTERFACE_LIST.
- */
-
-/*
- * Header files are missing these
- */
-#if !defined(SIO_GET_INTERFACE_LIST)
-#define SIO_GET_INTERFACE_LIST _IOR('t', 127, u_long)
-
-struct in_addr6 {
- u_char s6_addr[16];
-};
-
-struct sockaddr_in6 {
- short sin6_family;
- u_short sin6_port;
- u_long sin6_flowinfo;
- struct in_addr6 sin6_addr;
-};
-
-typedef union sockaddr_gen{
- struct sockaddr Address;
- struct sockaddr_in AddressIn;
- struct sockaddr_in6 AddressIn6;
-} sockaddr_gen;
-
-typedef struct _INTERFACE_INFO
-{
- u_long iiFlags;
- sockaddr_gen iiAddress;
- sockaddr_gen iiBroadcastAddress;
- sockaddr_gen iiNetmask;
-} INTERFACE_INFO;
-
-#define IFF_UP 0x00000001
-#endif
-
-
-#define MAX_STR_LEN 256
-
-
-/*
- * A network adapter (similiar to the netif structure except contains
- * Windows 9x specific fields).
- */
-typedef struct _adapter {
- char *name;
- char *displayName;
- int index;
- char *reg_key;
- int is_wan_driver;
- netaddr *addrs;
- struct _adapter *next;
-} adapter;
-
-
-/*
- * Cached adapter list.
- */
-static CRITICAL_SECTION cacheLock;
-static adapter *cachedAdapterList;
-
-/*
- * Initialize cache
- */
-void init_win9x() {
- InitializeCriticalSection(&cacheLock);
-}
-
-
-/*
- * Free adapter list and any addresses bound to the adpater.
- */
-static void free_adapters(adapter *adapterP) {
- adapter *curr = adapterP;
- while (curr != NULL) {
- if (curr->name != NULL)
- free(curr->name);
-
- if (curr->displayName != NULL)
- free(curr->displayName);
-
- if (curr->reg_key != NULL)
- free(curr->reg_key);
-
- if (curr->addrs != NULL)
- free_netaddr(curr->addrs);
-
- adapterP = adapterP->next;
- free(curr);
- curr = adapterP;
- }
-}
-
-
-/*
- * Returns the SIO_GET_INTERFACE_LIST output
- */
-static int getInterfaceList(JNIEnv *env, INTERFACE_INFO *infoP, DWORD dwSize) {
- SOCKET sock;
- DWORD ret;
-
- /* create a socket and do the ioctl */
- sock = socket(AF_INET, SOCK_DGRAM, 0);
- if (sock == INVALID_SOCKET) {
- JNU_ThrowByName(env, "java/lang/Error", "socket failed");
- return -1;
- }
- ret = WSAIoctl(sock, SIO_GET_INTERFACE_LIST, NULL, 0,
- infoP, dwSize, &dwSize, NULL, NULL);
- closesocket(sock);
- if (ret == SOCKET_ERROR) {
- JNU_ThrowByName(env, "java/lang/Error", "WSAIoctl failed");
- return -1;
- }
- return dwSize;
-}
-
-
-/*
- * Gross, ugly, and crude way of guessing if this is a WAN (dial-up) driver.
- * Returns 1 if it's the normal PPCMAC VxD, otherwise 0.
- */
-static int isWanDriver(char *driver) {
- LONG ret;
- HKEY hKey;
- DWORD dwLen;
- ULONG ulType;
- char key[MAX_STR_LEN];
- char vxd[MAX_STR_LEN];
-
- sprintf(key, "System\\CurrentControlSet\\Services\\Class\\%s", driver);
- ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE, key, 0, KEY_READ, (PHKEY)&hKey);
- if (ret != ERROR_SUCCESS) {
- return 0;
- }
- dwLen = sizeof(vxd);
- ret = RegQueryValueEx(hKey, "DeviceVxDs", NULL, &ulType,
- (LPBYTE)vxd, &dwLen);
- RegCloseKey(hKey);
- if (ret != ERROR_SUCCESS) {
- return 0;
- }
- return (strcmp(vxd, "pppmac.vxd") == 0);
-}
-
-/*
- * Windows 9x routine to get the network adapters using the registry.
- * We enumerate HKEY_LOCAL_MACHINE\Enum and iterate through the tree
- * looking for devices of class "Net". As these devices may not have a
- * unique name we assign them a generated name.
- *
- * Returns a list of adapters without IP addresses (addrs member is NULL).
- */
-static int getAdapters(JNIEnv *env, adapter **adapterPP)
-{
- LONG ret;
- HKEY enumKey;
- DWORD dwLen;
- DWORD dwEnumKeys;
- DWORD enumIndex;
- ULONG ulType;
- int adapterCount = 0;
- adapter *adapterP = NULL;
- adapter *curr;
-
- /*
- * Start at HKEY_LOCAL_MACHINE\Enum
- */
- ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Enum", 0, KEY_READ, (PHKEY)&enumKey);
- if (ret != ERROR_SUCCESS) {
- return -1;
- }
- ret = RegQueryInfoKey(enumKey, NULL, NULL, NULL, &dwEnumKeys,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL);
- if (ret != ERROR_SUCCESS) {
- RegCloseKey(enumKey);
- return -1;
- }
-
- /*
- * Iterate through the sub-keys (PCI, Root, ...)
- */
- for(enumIndex = 0; enumIndexis_wan_driver = wan_device;
- curr->name = (char *)malloc(strlen(ps_name) + 1);
- if (curr->name) {
- curr->displayName = (char *)malloc(strlen(deviceDesc) + 1);
- if (curr->displayName) {
- curr->reg_key = (char *)malloc(strlen(key_name)+1);
- if (curr->reg_key == NULL) {
- free(curr->displayName);
- free(curr->name);
- free(curr);
- curr = NULL;
- }
- } else {
- free(curr->name);
- free(curr);
- curr = NULL;
- }
- } else {
- free(curr);
- curr = NULL;
- }
- }
-
- /* At OutOfMemory occurred */
- if (curr == NULL) {
- JNU_ThrowOutOfMemoryError(env, "heap allocation failure");
- free_adapters(adapterP);
- RegCloseKey(clsKey);
- RegCloseKey(nameKey);
- RegCloseKey(deviceKey);
- RegCloseKey(enumKey);
- return -1;
- }
-
- /* index starts at 1 (not 0) */
- curr->index = ++adapterCount;
-
- strcpy(curr->name, ps_name);
- strcpy(curr->displayName, deviceDesc);
- strcpy(curr->reg_key, key_name);
-
- /*
- * Put the adapter at the end of the list.
- */
- if (adapterP == NULL) {
- adapterP = curr;
- } else {
- adapter *tail = adapterP;
- while (tail->next != NULL) {
- tail = tail->next;
- }
- tail->next = curr;
- }
- }
- }
- }
- }
- RegCloseKey(clsKey);
- }
- RegCloseKey(nameKey);
- }
- RegCloseKey(deviceKey);
- }
- RegCloseKey(enumKey);
-
- /*
- * Insert an entry for the loopback interface
- */
- curr = (adapter *)calloc(1, sizeof(adapter));
- if (curr == NULL) {
- JNU_ThrowOutOfMemoryError(env, "heap allocation failure");
- free_adapters(adapterP);
- return -1;
- }
- curr->index = ++adapterCount;
- curr->name = _strdup("lo");
- curr->displayName = _strdup("TCP Loopback interface");
- curr->next = adapterP;
- *adapterPP = curr;
-
- return adapterCount;
-}
-
-/*
- * Windows 9x routine to obtain any static addresses for a specified
- * TCP/IP binding.
- *
- * We first open Enum\Network\${binding} and check that the driver
- * is TCP/IP. If so we pick up the driver and check for any IP addresses
- * in System\\CurrentControlSet\\Services\\Class\\${driver}
- *
- * Returns 0 if found, otherwise -1.
- */
-static int getStaticAddressEntry(char *binding, char *addresses) {
- LONG ret;
- HKEY hKey;
- char name[255];
- char desc[255];
- char driver[255];
- char ipaddr[255];
- DWORD dwName;
- ULONG ulType;
-
- /* assume nothing will be returned */
- strcpy(addresses, "");
-
- /*
- * Open the binding and check that it's TCP/IP
- */
- sprintf(name, "Enum\\Network\\%s", binding);
- ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE, name, 0, KEY_READ, (PHKEY)&hKey);
- if (ret != ERROR_SUCCESS) {
- return -1;
- }
- dwName = sizeof(desc);
- ret = RegQueryValueEx(hKey, "DeviceDesc", NULL, &ulType,
- (LPBYTE)desc, &dwName);
- if (ret != ERROR_SUCCESS) {
- RegCloseKey(hKey);
- return -1;
- }
- if (strcmp(desc, "TCP/IP") != 0) {
- /* ignore non-TCP/IP bindings */
- RegCloseKey(hKey);
- return -1;
- }
-
- /*
- * Get the driver for this TCP/IP binding
- */
- dwName = sizeof(driver);
- ret = RegQueryValueEx(hKey, "Driver", NULL, &ulType,
- (LPBYTE)driver, &dwName);
- RegCloseKey(hKey);
- if (ret != ERROR_SUCCESS) {
- return -1;
- }
-
- /*
- * Finally check if there is an IPAddress value for this driver.
- */
- sprintf(name, "System\\CurrentControlSet\\Services\\Class\\%s", driver);
- ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE, name, 0, KEY_READ, (PHKEY)&hKey);
- if (ret != ERROR_SUCCESS) {
- return -1;
- }
- dwName = sizeof(ipaddr);
- ret = RegQueryValueEx(hKey, "IPAddress", NULL, &ulType,
- (LPBYTE)ipaddr, &dwName);
- RegCloseKey(hKey);
- if (ret != ERROR_SUCCESS) {
- return -1;
- }
-
- /* Return the address(es) */
- strcpy( addresses, ipaddr );
- return 0;
-}
-
-/*
- * Windows 9x routine to enumerate the static IP addresses on a
- * particular interface using the registry.
- *
- * Returns a count of the number of addresses found.
- */
-static int getStaticAddresses(JNIEnv *env, char *reg_key, netaddr **netaddrPP)
-{
- LONG ret;
- HKEY enumKey, bindingKey;
- DWORD dwLen;
- ULONG ulType;
- char addresses[MAX_STR_LEN];
- unsigned long addr; /* IPv4 address */
- unsigned char byte;
- netaddr *netaddrP, *curr;
- int i, addrCount;
-
- /*
- * Open the HKEY_LOCAL_MACHINE\Enum\%s\%s\%s key
- */
- ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE, reg_key, 0, KEY_READ,
- (PHKEY)&enumKey);
- if (ret != ERROR_SUCCESS) {
- /* interface has been removed */
- *netaddrPP = NULL;
- return 0;
- }
-
- /*
- * Iterate through each of the bindings to find any TCP/IP bindings
- * and any static address assoicated with the binding.
- */
- strcpy(addresses, "");
- addrCount = 0;
- netaddrP = NULL;
-
- ret = RegOpenKeyEx(enumKey, "Bindings", 0, KEY_READ, (PHKEY)&bindingKey);
- if (ret == ERROR_SUCCESS) {
- DWORD dwBindingKeys;
- DWORD dwBindingIndex;
-
- ret = RegQueryInfoKey(bindingKey, NULL, NULL, NULL, NULL, NULL, NULL, &dwBindingKeys,
- NULL, NULL, NULL, NULL);
- if (ret == ERROR_SUCCESS) {
- TCHAR binding[MAX_STR_LEN];
-
- dwBindingIndex=0;
- while (dwBindingIndexaddr.him4.sin_family = AF_INET;
- curr->addr.him4.sin_addr.s_addr = htonl(addr);
- curr->next = netaddrP;
-
- netaddrP = curr;
- addrCount++;
-
- /* reset the address for the next iteration */
- addr = 0;
- }
- byte = 0;
- } else {
- if (addresses[i] == '.') {
- addr = (addr << 8) | byte;
- byte = 0;
- } else {
- byte = (byte * 10) + (addresses[i] - '0');
- }
- }
- i++;
- }
- }
- }
- if (addrCount > 0) {
- break;
- }
- dwBindingIndex++;
- }
- }
- RegCloseKey(bindingKey);
- }
-
- /* close the registry */
- RegCloseKey(enumKey);
-
-
- /* return the list */
- *netaddrPP = netaddrP;
- return addrCount;
-}
-
-/*
- * Windows 9x routine to probe the registry for a DHCP allocated address.
- * This routine is only useful if we know that only one interface has its
- * address allocated using DHCP. Returns 0.0.0.0 if none or multiple
- * addresses found.0
- */
-static DWORD getDHCPAddress()
-{
- LONG ret;
- HKEY hKey;
- DWORD dwLen;
- ULONG ulType;
- char key[MAX_STR_LEN];
- int index;
- DWORD dhcp_addr = 0;
-
- index = 0;
- while (index < 99) {
- DWORD addr;
-
- sprintf(key, "SYSTEM\\CurrentControlSet\\Services\\VxD\\DHCP\\DhcpInfo%02d", index);
-
- ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE, key, 0, KEY_READ, (PHKEY)&hKey);
- if (ret != ERROR_SUCCESS) {
- return dhcp_addr;
- }
-
- /*
- * On Windows 9x the DHCP address is in the DhcpIPAddress key. We
- * are assuming here that this is Windows Socket 2. If Windows
- * Sockets is the original 1.1 release then this doesn't work because
- * the IP address if in the DhcpInfo key (a blob with the first 4
- * bytes set to the IP address).
- */
- dwLen = sizeof(addr);
- ret = RegQueryValueEx(hKey, "DhcpIPAddress", NULL, &ulType,
- (LPBYTE)&addr, &dwLen);
- RegCloseKey(hKey);
-
- if (ret == ERROR_SUCCESS) {
- if (addr) {
- /* more than 1 DHCP address in registry */
- if (dhcp_addr) {
- return 0;
- }
- dhcp_addr = htonl(addr);
- }
- }
- index++;
- }
-
- /* if we get here it means we've examined 100 registry entries */
- return 0;
-}
-
-
-/*
- * Attempt to allocate the remaining addresses on addrList to the adpaters
- * on adapterList. Returns the number of address remaining.
- */
-int allocateRemaining(adapter *adapterList, int address_count, netaddr *addrList) {
- adapter *adapterP = adapterList;
- adapter *nobindingsP = NULL;
-
- /*
- * If all addresses have been assigned there's nothing to do.
- */
- if (address_count == 0) {
- return 0;
- }
-
- /*
- * Determine if there is only one adapter without an address
- */
- while (adapterP != NULL) {
- if (adapterP->addrs == NULL) {
- if (nobindingsP == NULL) {
- nobindingsP = adapterP;
- } else {
- nobindingsP = NULL;
- break;
- }
- }
- adapterP = adapterP->next;
- }
-
- /*
- * Found (only one)
- */
- if (nobindingsP) {
- nobindingsP->addrs = addrList;
- address_count = 0;
- }
-
- return address_count;
-}
-
-
-/*
- * 1. Network adapters are enumerated by traversing through the
- * HKEY_LOCAL_MACHINE\Enum tree and picking out class "Net" devices.
- *
- * 2. Address enumeration starts with the list of IP addresses returned
- * by SIO_GET_INTERFACE_LIST and then we "allocate" the addresses to
- * the network adapters enumerated in step 1. Allocation works as
- * follows :-
- *
- * i. Loopback address is assigned to the loopback interface. If there
- * is one network adapter then all other addresses must be bound
- * to that adapter.
- *
- * ii. Enumerate all static IP addresses using the registry. This allows
- * us to allocate all static IP address to the corresponding adapter.
- *
- * iii. After step ii. if there is one network adapter that has not been
- * allocated an IP address then we know that the remaining IP addresses
- * must be bound to this adapter.
- *
- * iv. If we get to this step it means we are dealing with a complex
- * configuration whereby multiple network adapters have their address
- * configured dynamically (eg: NIC using DHCP plus modem using PPP).
- * We employ a gross hack based on a crude determination done in step 1.
- * If there is a DHCP address configured and if one remaining
- * network adapter that is not a WAN adapter then the DHCP address
- * must be bound to it.
- */
-static adapter *loadConfig(JNIEnv *env) {
- adapter *adapterList;
- int adapter_count;
- INTERFACE_INFO interfaceInfo[8];
- DWORD dwSize;
- int address_count, i;
- netaddr *addrList;
-
- /*
- * Enumerate the network adapters
- */
- adapter_count = getAdapters(env, &adapterList);
- if (adapter_count < 0) {
- return NULL;
- }
- /* minimum of loopback interface */
- assert(adapter_count >= 1);
-
- /*
- * Enumerate all IP addresses as known to winsock
- */
- dwSize = getInterfaceList(env, interfaceInfo, sizeof(interfaceInfo));
- if (dwSize < 0) {
- free_adapters(adapterList);
- return NULL;
- }
- address_count = dwSize/sizeof(INTERFACE_INFO);
-
- /* minimum of loopback address */
- assert(address_count >= 1);
-
- /*
- * Create an address list (addrList) from the INTERFACE_INFO
- * structure.
- */
- addrList = NULL;
- for (i=0; iaddr.him4.sin_family = AF_INET;
- addrP->addr.him4.sin_addr.s_addr =
- ((SOCKADDR_IN *)&(interfaceInfo[i].iiAddress))->sin_addr.S_un.S_addr;
-
- addrP->next = addrList;
- addrList = addrP;
- }
-
-
- /*
- * First we assign the loopback address to the lo adapter.
- * If lo is the only adapter then we are done.
- */
- {
- adapter *loopbackAdapter;
- netaddr *addrP, *prevP;
-
- /* find the loopback adapter */
- loopbackAdapter = adapterList;
- while (strcmp(loopbackAdapter->name, "lo") != 0) {
- loopbackAdapter = loopbackAdapter->next;
- }
- assert(loopbackAdapter != NULL);
-
- /* find the loopback address and move it to the loopback adapter */
- addrP = addrList;
- prevP = NULL;
- while (addrP != NULL) {
- if (addrP->addr.him4.sin_addr.s_addr == htonl(0x7f000001)) {
- loopbackAdapter->addrs = addrP;
- if (prevP == NULL) {
- addrList = addrP->next;
- } else {
- prevP->next = addrP->next;
- }
- loopbackAdapter->addrs->next = NULL;
- address_count--;
- break;
- }
- prevP = addrP;
- addrP = addrP->next;
- }
- }
-
-
- /*
- * Special case. If there's only one network adapter then all remaining
- * IP addresses must be bound to that adapter.
- */
- address_count = allocateRemaining(adapterList, address_count, addrList);
- if (address_count == 0) {
- return adapterList;
- }
-
- /*
- * Locate any static IP addresses defined in the registry. Validate the
- * addresses against the SIO_GET_INTERFACE_LIST (as registry may have
- * stale settings). If valid we move the addresses from addrList to
- * the adapter.
- */
- {
- adapter *adapterP;
-
- adapterP = adapterList;
- while (adapterP != NULL) {
- int cnt;
- netaddr *static_addrP;
-
- /*
- * Skip loopback
- */
- if (strcmp(adapterP->name, "lo") == 0) {
- adapterP = adapterP->next;
- continue;
- }
-
- /*
- * Get the static addresses for this adapter.
- */
- cnt = getStaticAddresses(env, adapterP->reg_key, &static_addrP);
- if (cnt < 0) {
- free_netaddr(addrList);
- free(adapterList);
- return NULL;
- }
-
- /*
- * Validate against the SIO_GET_INTERFACE_LIST.
- * (avoids stale registry settings).
- */
- while (static_addrP != NULL) {
- netaddr *addrP = addrList;
- netaddr *prev = NULL;
-
- while (addrP != NULL) {
- if (addrP->addr.him4.sin_addr.s_addr == static_addrP->addr.him4.sin_addr.s_addr)
- break;
-
- prev = addrP;
- addrP = addrP->next;
- }
-
- /*
- * if addrP is not NULL it means we have a match
- * (ie: address from the registry is valid).
- */
- if (addrP != NULL) {
- /* remove from addrList */
- if (prev == NULL) {
- addrList = addrP->next;
- } else {
- prev->next = addrP->next;
- }
- address_count--;
-
- /* add to adapter list */
- addrP->next = adapterP->addrs;
- adapterP->addrs = addrP;
- }
-
- /*
- * On the next static address.
- */
- static_addrP = static_addrP->next;
- }
-
- /* not needed */
- free_netaddr(static_addrP);
-
- adapterP = adapterP->next;
- }
- }
-
-
- /*
- * Static addresses are now assigned so try again to allocate the
- * remaining addresses. This will succeed if there is one adapter
- * with a dynamically assigned address (DHCP or PPP).
- */
- address_count = allocateRemaining(adapterList, address_count, addrList);
- if (address_count == 0) {
- return adapterList;
- }
-
- /*
- * Next we see if there is a DHCP address in the registry. If there is
- * an address (and it's valid) then we know it must be bound to a LAN
- * adapter. Additionally, when we enumerate the network adapters
- * we made a crude determination on if an adapter is dial-up. Thus if
- * we know there is one remaining LAN adapter without an IP address
- * then the DHCP address must be bound to it.
- */
- {
- long dhcp_addr = getDHCPAddress(); /* returns in network order */
- if (dhcp_addr) {
- netaddr *addrP, *prevP;
-
- /*
- * Check that the DHCP address is valid
- */
- addrP = addrList;
- prevP = NULL;
- while (addrP != NULL) {
- if (addrP->addr.him4.sin_addr.s_addr == dhcp_addr) {
- break;
- }
- prevP = addrP;
- addrP = addrP->next;
- }
-
- /*
- * Address is valid - now check how many non-WAN adapters
- * don't have addresses yet.
- */
- if (addrP != NULL) {
- adapter *adapterP = adapterList;
- adapter *nobindingsP = NULL;
-
- while (adapterP != NULL) {
- if (adapterP->addrs == NULL && !adapterP->is_wan_driver) {
- if (nobindingsP == NULL) {
- nobindingsP = adapterP;
- } else {
- /* already found one */
- nobindingsP = NULL;
- break;
- }
- }
- adapterP = adapterP->next;
- }
-
- /*
- * One non-WAN adapter remaining
- */
- if (nobindingsP != NULL) {
- nobindingsP->addrs = addrP;
-
- /* remove from addrList */
- if (prevP == NULL) {
- addrList = addrP->next;
- } else {
- prevP->next = addrP->next;
- }
- addrP->next = NULL;
- address_count--;
- }
- }
- }
- }
-
- /*
- * Finally we do one final attempt to re-assign any remaining
- * addresses. This catches the case of 2 adapters that have their
- * addresses dynamically assigned (specifically NIC with DHCP, and
- * Modem using RAS/PPP).
- */
- address_count = allocateRemaining(adapterList, address_count, addrList);
- if (address_count == 0) {
- return adapterList;
- }
-
- /*
- * Free any unallocated addresses
- */
- if (address_count > 0) {
- free_netaddr(addrList);
- }
-
- /*
- * Return the adapter List.
- */
- return adapterList;
-
-}
-
-
-/*
- * Enumerate network interfaces. If successful returns the number of
- * network interfaces and netifPP returning a list of netif structures.
- * Returns -1 with exception thrown if error.
- */
-int enumInterfaces_win9x(JNIEnv *env, netif **netifPP) {
- adapter *adapters, *adapterP;
- int cnt = 0;
- netif *netifP = NULL;
-
- /* enumerate network configuration */
- adapters = loadConfig(env);
- if (adapters == NULL) {
- return -1;
- }
-
- /*
- * loadConfig returns an adapter list - we need to create a corresponding
- * list of netif structures.
- */
- adapterP = adapters;
- while (adapterP != NULL) {
- netif *ifs = (netif *)calloc(1, sizeof(netif));
-
- if (ifs == NULL) {
- JNU_ThrowOutOfMemoryError(env, "heap allocation failure");
- free_adapters(adapters);
- free_netif(netifP);
- return -1;
- }
-
- ifs->name = _strdup(adapterP->name);
- ifs->displayName = _strdup(adapterP->displayName);
- ifs->dwIndex = adapterP->index;
- ifs->index = adapterP->index;
- ifs->next = netifP;
- netifP = ifs;
-
- if (ifs->name == NULL || ifs->displayName == NULL) {
- JNU_ThrowOutOfMemoryError(env, "heap allocation failure");
- free_adapters(adapters);
- free_netif(netifP);
- return -1;
- }
-
- cnt++;
- adapterP = adapterP->next;
- }
-
- /*
- * Put the adapter list in the cache
- */
- EnterCriticalSection(&cacheLock);
- {
- if (cachedAdapterList != NULL) {
- free_adapters(cachedAdapterList);
- }
- cachedAdapterList = adapters;
- }
- LeaveCriticalSection(&cacheLock);
-
- /*
- * Return the netif list
- */
- *netifPP = netifP;
- return cnt;
-}
-
-/*
- * Enumerate the addresses for the specified network interface. If successful
- * returns the number of addresses bound to the interface and sets netaddrPP
- * to be a list of netaddr structures. Returns -1 if error.
- */
-int enumAddresses_win9x(JNIEnv *env, netif *netifP, netaddr **netaddrPP) {
-
- EnterCriticalSection(&cacheLock);
- {
- adapter *adapterP = cachedAdapterList;
- while (adapterP != NULL) {
- if (strcmp(adapterP->name, netifP->name) == 0) {
-
- netaddr *newlist = NULL;
- netaddr *curr = adapterP->addrs;
- int cnt = 0;
-
- while (curr != NULL) {
- /*
- * Clone the netaddr and add it to newlist.
- */
- netaddr *tmp = (netaddr *)calloc(1, sizeof(netaddr));
- if (tmp == NULL) {
- LeaveCriticalSection(&cacheLock);
- JNU_ThrowOutOfMemoryError(env, "heap allocation failure");
- free_netaddr(newlist);
- return -1;
- }
- tmp->addr = curr->addr;
- tmp->next = newlist;
- newlist = tmp;
-
- cnt++;
- curr = curr->next;
- }
-
- *netaddrPP = newlist;
- LeaveCriticalSection(&cacheLock);
- return cnt;
- }
- adapterP = adapterP->next;
- }
- }
- LeaveCriticalSection(&cacheLock);
-
- *netaddrPP = NULL;
- return 0;
-}
diff --git a/src/windows/native/java/net/NetworkInterface_winXP.c b/src/windows/native/java/net/NetworkInterface_winXP.c
index 283be81b89ae7a54ef4d8763cb1b036dd3f970e6..ecfab4967db5cb2fbd1c9a55aa24d2d28c750d79 100644
--- a/src/windows/native/java/net/NetworkInterface_winXP.c
+++ b/src/windows/native/java/net/NetworkInterface_winXP.c
@@ -43,14 +43,6 @@
extern int enumAddresses_win(JNIEnv *env, netif *netifP, netaddr **netaddrPP);
int getAddrsFromAdapter(IP_ADAPTER_ADDRESSES *ptr, netaddr **netaddrPP);
-/* IP helper library routines */
-int (PASCAL FAR *GetIpAddrTable_fn)();
-int (PASCAL FAR *GetIfTable_fn)();
-int (PASCAL FAR *GetFriendlyIfIndex_fn)();
-int (PASCAL FAR *GetAdaptersAddresses_fn)();
-int (PASCAL FAR *GetAdaptersInfo_fn)();
-int (PASCAL FAR *GetNumberOfInterfaces_fn)();
-
#ifdef DEBUG
void printnif (netif *nif) {
#ifdef _WIN64
@@ -96,14 +88,14 @@ static int getAdapters (JNIEnv *env, IP_ADAPTER_ADDRESSES **adapters) {
flags = GAA_FLAG_SKIP_DNS_SERVER;
flags |= GAA_FLAG_SKIP_MULTICAST;
flags |= GAA_FLAG_INCLUDE_PREFIX;
- ret = (*GetAdaptersAddresses_fn) (AF_UNSPEC, flags, NULL, adapterInfo, &len);
+ ret = GetAdaptersAddresses(AF_UNSPEC, flags, NULL, adapterInfo, &len);
if (ret == ERROR_BUFFER_OVERFLOW) {
adapterInfo = (IP_ADAPTER_ADDRESSES *) realloc (adapterInfo, len);
if (adapterInfo == 0) {
return -1;
}
bufsize = len;
- ret = (*GetAdaptersAddresses_fn) (AF_UNSPEC, flags, NULL, adapterInfo, &len);
+ ret = GetAdaptersAddresses(AF_UNSPEC, flags, NULL, adapterInfo, &len);
}
if (ret != ERROR_SUCCESS) {
free (adapterInfo);
@@ -133,7 +125,7 @@ IP_ADAPTER_ADDRESSES *getAdapter (JNIEnv *env, jint index) {
flags = GAA_FLAG_SKIP_DNS_SERVER;
flags |= GAA_FLAG_SKIP_MULTICAST;
flags |= GAA_FLAG_INCLUDE_PREFIX;
- val = (*GetAdaptersAddresses_fn) (AF_UNSPEC, flags, NULL, adapterInfo, &len);
+ val = GetAdaptersAddresses(AF_UNSPEC, flags, NULL, adapterInfo, &len);
if (val == ERROR_BUFFER_OVERFLOW) {
adapterInfo = (IP_ADAPTER_ADDRESSES *) realloc (adapterInfo, len);
if (adapterInfo == 0) {
@@ -141,7 +133,7 @@ IP_ADAPTER_ADDRESSES *getAdapter (JNIEnv *env, jint index) {
return NULL;
}
bufsize = len;
- val = (*GetAdaptersAddresses_fn) (AF_UNSPEC, flags, NULL, adapterInfo, &len);
+ val = GetAdaptersAddresses(AF_UNSPEC, flags, NULL, adapterInfo, &len);
}
if (val != ERROR_SUCCESS) {
free (adapterInfo);
@@ -182,7 +174,7 @@ int getAllInterfacesAndAddresses (JNIEnv *env, netif **netifPP)
* as what previous JDK versions would return.
*/
- ret = enumInterfaces_win (env, netifPP);
+ ret = enumInterfaces(env, netifPP);
if (ret == -1) {
return -1;
} else {
@@ -221,7 +213,7 @@ int getAllInterfacesAndAddresses (JNIEnv *env, netif **netifPP)
* (b) IPv6 information for IPv6 only interfaces (probably tunnels)
*
* For compatibility with previous releases we use the naming
- * information gotten from enumInterfaces_win() for (a) entries
+ * information gotten from enumInterfaces() for (a) entries
* However, the index numbers are taken from the new API.
*
* The procedure is to go through the list of adapters returned
@@ -439,7 +431,8 @@ static jobject createNetworkInterfaceXP(JNIEnv *env, netif *ifs)
netifObj = (*env)->NewObject(env, ni_class, ni_ctor);
name = (*env)->NewStringUTF(env, ifs->name);
if (ifs->dNameIsUnicode) {
- displayName = (*env)->NewString(env, (PWCHAR)ifs->displayName, wcslen ((PWCHAR)ifs->displayName));
+ displayName = (*env)->NewString(env, (PWCHAR)ifs->displayName,
+ (jsize)wcslen ((PWCHAR)ifs->displayName));
} else {
displayName = (*env)->NewStringUTF(env, ifs->displayName);
}
diff --git a/src/windows/native/java/net/net_util_md.c b/src/windows/native/java/net/net_util_md.c
index ffaf52078aa4589672ef4ce4238e9985dc3936df..4cf522e786a908212da1c425774b4b33dba06a60 100644
--- a/src/windows/native/java/net/net_util_md.c
+++ b/src/windows/native/java/net/net_util_md.c
@@ -39,10 +39,6 @@
/* true if SO_RCVTIMEO is supported */
jboolean isRcvTimeoutSupported = JNI_TRUE;
-LPFN_GETADDRINFO getaddrinfo_ptr = NULL;
-LPFN_FREEADDRINFO freaddrinfo_ptr = NULL;
-LPFN_GETNAMEINFO getnameinfo_ptr = NULL;
-
/*
* Table of Windows Sockets errors, the specific exception we
* throw for the error, and the error text.
@@ -233,38 +229,15 @@ NET_GetFileDescriptorID(JNIEnv *env)
jint IPv6_supported()
{
- HMODULE lib;
- int fd = socket(AF_INET6, SOCK_STREAM, 0) ;
- if (fd < 0) {
+ SOCKET s = socket(AF_INET6, SOCK_STREAM, 0) ;
+ if (s == INVALID_SOCKET) {
return JNI_FALSE;
}
- closesocket (fd);
-
- if ((lib = LoadLibrary ("ws2_32.dll")) == NULL) {
- return JNI_FALSE;
- }
- if ((getaddrinfo_ptr = (LPFN_GETADDRINFO)GetProcAddress (lib, "getaddrinfo")) == NULL) {
- FreeLibrary (lib);
- return JNI_FALSE;
- }
- if ((freeaddrinfo_ptr = (LPFN_FREEADDRINFO)GetProcAddress (lib, "freeaddrinfo")) == NULL) {
- FreeLibrary (lib);
- return JNI_FALSE;
- }
- if ((getnameinfo_ptr = (LPFN_GETNAMEINFO)GetProcAddress (lib, "getnameinfo")) == NULL) {
- FreeLibrary (lib);
- return JNI_FALSE;
- }
- FreeLibrary(lib);
+ closesocket(s);
return JNI_TRUE;
}
-jboolean NET_addrtransAvailable() {
- return (jboolean)(getaddrinfo_ptr != NULL);
-}
-
-
/*
* Return the default TOS value
*/
@@ -664,7 +637,7 @@ NET_BindV6(struct ipv6bind* b) {
if (family == AF_INET && (b->addr->him4.sin_addr.s_addr != INADDR_ANY)) {
/* bind to v4 only */
int ret;
- ret = NET_Bind (b->ipv4_fd, (struct sockaddr *)b->addr,
+ ret = NET_Bind ((int)b->ipv4_fd, (struct sockaddr *)b->addr,
sizeof (struct sockaddr_in));
if (ret == SOCKET_ERROR) {
CLOSE_SOCKETS_AND_RETURN;
@@ -676,7 +649,7 @@ NET_BindV6(struct ipv6bind* b) {
if (family == AF_INET6 && (!IN6_IS_ADDR_ANY(&b->addr->him6.sin6_addr))) {
/* bind to v6 only */
int ret;
- ret = NET_Bind (b->ipv6_fd, (struct sockaddr *)b->addr,
+ ret = NET_Bind ((int)b->ipv6_fd, (struct sockaddr *)b->addr,
sizeof (struct SOCKADDR_IN6));
if (ret == SOCKET_ERROR) {
CLOSE_SOCKETS_AND_RETURN;
@@ -691,15 +664,15 @@ NET_BindV6(struct ipv6bind* b) {
memset (&oaddr, 0, sizeof(oaddr));
if (family == AF_INET) {
ofamily = AF_INET6;
- fd = b->ipv4_fd;
- ofd = b->ipv6_fd;
+ fd = (int)b->ipv4_fd;
+ ofd = (int)b->ipv6_fd;
port = (u_short)GET_PORT (b->addr);
IN6ADDR_SETANY (&oaddr.him6);
oaddr.him6.sin6_port = port;
} else {
ofamily = AF_INET;
- ofd = b->ipv4_fd;
- fd = b->ipv6_fd;
+ ofd = (int)b->ipv4_fd;
+ fd = (int)b->ipv6_fd;
port = (u_short)GET_PORT (b->addr);
oaddr.him4.sin_family = AF_INET;
oaddr.him4.sin_port = port;
@@ -744,11 +717,11 @@ NET_BindV6(struct ipv6bind* b) {
b->ipv6_fd = SOCKET_ERROR;
/* create two new sockets */
- fd = socket (family, sotype, 0);
+ fd = (int)socket (family, sotype, 0);
if (fd == SOCKET_ERROR) {
CLOSE_SOCKETS_AND_RETURN;
}
- ofd = socket (ofamily, sotype, 0);
+ ofd = (int)socket (ofamily, sotype, 0);
if (ofd == SOCKET_ERROR) {
CLOSE_SOCKETS_AND_RETURN;
}
@@ -802,7 +775,7 @@ jint getDefaultIPv6Interface(JNIEnv *env, struct SOCKADDR_IN6 *target_addr)
DWORD b;
struct sockaddr_in6 route;
SOCKET fd = socket(AF_INET6, SOCK_STREAM, 0);
- if (fd < 0) {
+ if (fd == INVALID_SOCKET) {
return 0;
}
@@ -810,7 +783,7 @@ jint getDefaultIPv6Interface(JNIEnv *env, struct SOCKADDR_IN6 *target_addr)
(void *)target_addr, sizeof(struct sockaddr_in6),
(void *)&route, sizeof(struct sockaddr_in6),
&b, 0, 0);
- if (ret < 0) {
+ if (ret == SOCKET_ERROR) {
// error
closesocket(fd);
return 0;
@@ -1001,10 +974,10 @@ NET_Wait(JNIEnv *env, jint fd, jint flags, jint timeout)
}
int NET_Socket (int domain, int type, int protocol) {
- int sock;
+ SOCKET sock;
sock = socket (domain, type, protocol);
if (sock != INVALID_SOCKET) {
SetHandleInformation((HANDLE)(uintptr_t)sock, HANDLE_FLAG_INHERIT, FALSE);
}
- return sock;
+ return (int)sock;
}
diff --git a/src/windows/native/java/net/net_util_md.h b/src/windows/native/java/net/net_util_md.h
index b1a37e9b8260aa9af52696d8b6e7dd8d8aa38e10..e764260bb24a861e929fd998464ed98a0aa87146 100644
--- a/src/windows/native/java/net/net_util_md.h
+++ b/src/windows/native/java/net/net_util_md.h
@@ -209,10 +209,6 @@ int
);
#endif
-LPFN_GETADDRINFO getaddrinfo_ptr;
-LPFN_FREEADDRINFO freeaddrinfo_ptr;
-LPFN_GETNAMEINFO getnameinfo_ptr;
-
/* used to disable connection reset messages on Windows XP */
#ifndef SIO_UDP_CONNRESET
#define SIO_UDP_CONNRESET _WSAIOW(IOC_VENDOR,12)
@@ -302,8 +298,6 @@ void NET_ThrowByNameWithLastError(JNIEnv *env, const char *name,
void NET_ThrowSocketException(JNIEnv *env, char* msg);
-jboolean NET_addrtransAvailable();
-
/*
* differs from NET_Timeout() as follows:
*
diff --git a/src/windows/native/sun/management/FileSystemImpl.c b/src/windows/native/sun/management/FileSystemImpl.c
index 57abea98541f07ba501fed3057061960da04417a..0747121d35a7b8d47dfc37a17caba9fb089ae6dd 100644
--- a/src/windows/native/sun/management/FileSystemImpl.c
+++ b/src/windows/native/sun/management/FileSystemImpl.c
@@ -36,45 +36,6 @@
*/
#define ANY_ACCESS (FILE_GENERIC_READ | FILE_GENERIC_WRITE | FILE_GENERIC_EXECUTE)
-/*
- * Function prototypes for security functions - we can't statically
- * link because these functions aren't on Windows 9x.
- */
-typedef BOOL (WINAPI *GetFileSecurityFunc)
- (LPCTSTR lpFileName, SECURITY_INFORMATION RequestedInformation,
- PSECURITY_DESCRIPTOR pSecurityDescriptor, DWORD nLength,
- LPDWORD lpnLengthNeeded);
-
-typedef BOOL (WINAPI *GetSecurityDescriptorOwnerFunc)
- (PSECURITY_DESCRIPTOR pSecurityDescriptor, PSID *pOwner,
- LPBOOL lpbOwnerDefaulted);
-
-typedef BOOL (WINAPI *GetSecurityDescriptorDaclFunc)
- (PSECURITY_DESCRIPTOR pSecurityDescriptor, LPBOOL lpbDaclPresent,
- PACL *pDacl, LPBOOL lpbDaclDefaulted);
-
-typedef BOOL (WINAPI *GetAclInformationFunc)
- (PACL pAcl, LPVOID pAclInformation, DWORD nAclInformationLength,
- ACL_INFORMATION_CLASS dwAclInformationClass);
-
-typedef BOOL (WINAPI *GetAceFunc)
- (PACL pAcl, DWORD dwAceIndex, LPVOID *pAce);
-
-typedef BOOL (WINAPI *EqualSidFunc)(PSID pSid1, PSID pSid2);
-
-
-/* Addresses of the security functions */
-static GetFileSecurityFunc GetFileSecurity_func;
-static GetSecurityDescriptorOwnerFunc GetSecurityDescriptorOwner_func;
-static GetSecurityDescriptorDaclFunc GetSecurityDescriptorDacl_func;
-static GetAclInformationFunc GetAclInformation_func;
-static GetAceFunc GetAce_func;
-static EqualSidFunc EqualSid_func;
-
-/* True if this OS is NT kernel based (NT/2000/XP) */
-static int isNT;
-
-
/*
* Returns JNI_TRUE if the specified file is on a file system that supports
* persistent ACLs (On NTFS file systems returns true, on FAT32 file systems
@@ -165,7 +126,7 @@ static SECURITY_DESCRIPTOR* getFileSecurityDescriptor(JNIEnv* env, const char* p
SECURITY_INFORMATION info =
OWNER_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION;
- (*GetFileSecurity_func)(path, info , 0, 0, &len);
+ GetFileSecurityA(path, info , 0, 0, &len);
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
JNU_ThrowIOExceptionWithLastError(env, "GetFileSecurity failed");
return NULL;
@@ -174,7 +135,7 @@ static SECURITY_DESCRIPTOR* getFileSecurityDescriptor(JNIEnv* env, const char* p
if (sd == NULL) {
JNU_ThrowOutOfMemoryError(env, 0);
} else {
- if (!(*GetFileSecurity_func)(path, info, sd, len, &len)) {
+ if (!(*GetFileSecurityA)(path, info, sd, len, &len)) {
JNU_ThrowIOExceptionWithLastError(env, "GetFileSecurity failed");
free(sd);
return NULL;
@@ -191,7 +152,7 @@ static SID* getFileOwner(JNIEnv* env, SECURITY_DESCRIPTOR* sd) {
SID* owner;
BOOL defaulted;
- if (!(*GetSecurityDescriptorOwner_func)(sd, &owner, &defaulted)) {
+ if (!GetSecurityDescriptorOwner(sd, &owner, &defaulted)) {
JNU_ThrowIOExceptionWithLastError(env, "GetSecurityDescriptorOwner failed");
return NULL;
}
@@ -206,7 +167,7 @@ static ACL* getFileDACL(JNIEnv* env, SECURITY_DESCRIPTOR* sd) {
ACL *acl;
int defaulted, present;
- if (!(*GetSecurityDescriptorDacl_func)(sd, &present, &acl, &defaulted)) {
+ if (!GetSecurityDescriptorDacl(sd, &present, &acl, &defaulted)) {
JNU_ThrowIOExceptionWithLastError(env, "GetSecurityDescriptorDacl failed");
return NULL;
}
@@ -235,8 +196,8 @@ static jboolean isAccessUserOnly(JNIEnv* env, SID* owner, ACL* acl) {
/*
* Get the ACE count
*/
- if (!(*GetAclInformation_func)(acl, (void *) &acl_size_info, sizeof(acl_size_info),
- AclSizeInformation)) {
+ if (!GetAclInformation(acl, (void *) &acl_size_info, sizeof(acl_size_info),
+ AclSizeInformation)) {
JNU_ThrowIOExceptionWithLastError(env, "GetAclInformation failed");
return JNI_FALSE;
}
@@ -250,7 +211,7 @@ static jboolean isAccessUserOnly(JNIEnv* env, SID* owner, ACL* acl) {
ACCESS_ALLOWED_ACE *access;
SID* sid;
- if (!(*GetAce_func)(acl, i, &ace)) {
+ if (!GetAce(acl, i, &ace)) {
JNU_ThrowIOExceptionWithLastError(env, "GetAce failed");
return -1;
}
@@ -280,51 +241,7 @@ static jboolean isAccessUserOnly(JNIEnv* env, SID* owner, ACL* acl) {
JNIEXPORT void JNICALL Java_sun_management_FileSystemImpl_init0
(JNIEnv *env, jclass ignored)
{
- OSVERSIONINFO ver;
- HINSTANCE hInst;
-
- /*
- * Get the OS version. If dwPlatformId is VER_PLATFORM_WIN32_NT
- * it means we're running on a Windows NT, 2000, or XP machine.
- */
- ver.dwOSVersionInfoSize = sizeof(ver);
- GetVersionEx(&ver);
- isNT = (ver.dwPlatformId == VER_PLATFORM_WIN32_NT);
- if (!isNT) {
- return;
- }
-
- /*
- * On NT/2000/XP we need the addresses of the security functions
- */
- hInst = LoadLibrary("ADVAPI32.DLL");
- if (hInst == NULL) {
- JNU_ThrowIOExceptionWithLastError(env, "Unable to load ADVAPI32.DLL");
- return;
- }
-
-
- GetFileSecurity_func = (GetFileSecurityFunc)GetProcAddress(hInst, "GetFileSecurityA");
- GetSecurityDescriptorOwner_func =
- (GetSecurityDescriptorOwnerFunc)GetProcAddress(hInst, "GetSecurityDescriptorOwner");
- GetSecurityDescriptorDacl_func =
- (GetSecurityDescriptorDaclFunc)GetProcAddress(hInst, "GetSecurityDescriptorDacl");
- GetAclInformation_func =
- (GetAclInformationFunc)GetProcAddress(hInst, "GetAclInformation");
- GetAce_func = (GetAceFunc)GetProcAddress(hInst, "GetAce");
- EqualSid_func = (EqualSidFunc)GetProcAddress(hInst, "EqualSid");
-
- if (GetFileSecurity_func == NULL ||
- GetSecurityDescriptorDacl_func == NULL ||
- GetSecurityDescriptorDacl_func == NULL ||
- GetAclInformation_func == NULL ||
- GetAce_func == NULL ||
- EqualSid_func == NULL)
- {
- JNU_ThrowIOExceptionWithLastError(env,
- "Unable to get address of security functions");
- return;
- }
+ /* nothing to do */
}
/*
@@ -339,10 +256,6 @@ JNIEXPORT jboolean JNICALL Java_sun_management_FileSystemImpl_isSecuritySupporte
jboolean isCopy;
const char* path;
- if (!isNT) {
- return JNI_FALSE;
- }
-
path = JNU_GetStringPlatformChars(env, str, &isCopy);
if (path != NULL) {
res = isSecuritySupported(env, path);
diff --git a/src/windows/native/sun/net/dns/ResolverConfigurationImpl.c b/src/windows/native/sun/net/dns/ResolverConfigurationImpl.c
index 21a87afa25ecf2f3ddef3d7a5ac3dd203db1b206..8885bdc79020423fd434d470a1690aaf0ab5c49c 100644
--- a/src/windows/native/sun/net/dns/ResolverConfigurationImpl.c
+++ b/src/windows/native/sun/net/dns/ResolverConfigurationImpl.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -30,6 +30,7 @@
#include
#include
#include
+#include
#include "jni_util.h"
@@ -42,93 +43,17 @@
#define IS_SL_FOUND(sts) (sts & STS_SL_FOUND)
#define IS_NS_FOUND(sts) (sts & STS_NS_FOUND)
-/*
- * Visual C++ SP3 (as required by J2SE 1.4.0) is missing some of
- * the definitions required for the IP helper library routines that
- * were added in Windows 98 & Windows 2000.
- */
-#ifndef MAX_ADAPTER_NAME_LENGTH
-
-#define MAX_ADAPTER_ADDRESS_LENGTH 8
-#define MAX_ADAPTER_DESCRIPTION_LENGTH 128
-#define MAX_ADAPTER_NAME_LENGTH 256
-#define MAX_HOSTNAME_LEN 128
-#define MAX_DOMAIN_NAME_LEN 128
-#define MAX_SCOPE_ID_LEN 256
-
-typedef struct {
- char String[4 * 4];
-} IP_ADDRESS_STRING, *PIP_ADDRESS_STRING, IP_MASK_STRING, *PIP_MASK_STRING;
-
-typedef struct _IP_ADDR_STRING {
- struct _IP_ADDR_STRING* Next;
- IP_ADDRESS_STRING IpAddress;
- IP_MASK_STRING IpMask;
- DWORD Context;
-} IP_ADDR_STRING, *PIP_ADDR_STRING;
-
-typedef struct _IP_ADAPTER_INFO {
- struct _IP_ADAPTER_INFO* Next;
- DWORD ComboIndex;
- char AdapterName[MAX_ADAPTER_NAME_LENGTH + 4];
- char Description[MAX_ADAPTER_DESCRIPTION_LENGTH + 4];
- UINT AddressLength;
- BYTE Address[MAX_ADAPTER_ADDRESS_LENGTH];
- DWORD Index;
- UINT Type;
- UINT DhcpEnabled;
- PIP_ADDR_STRING CurrentIpAddress;
- IP_ADDR_STRING IpAddressList;
- IP_ADDR_STRING GatewayList;
- IP_ADDR_STRING DhcpServer;
- BOOL HaveWins;
- IP_ADDR_STRING PrimaryWinsServer;
- IP_ADDR_STRING SecondaryWinsServer;
- time_t LeaseObtained;
- time_t LeaseExpires;
-} IP_ADAPTER_INFO, *PIP_ADAPTER_INFO;
-
-typedef struct _FIXED_INFO {
- char HostName[MAX_HOSTNAME_LEN + 4] ;
- char DomainName[MAX_DOMAIN_NAME_LEN + 4];
- PIP_ADDR_STRING CurrentDnsServer;
- IP_ADDR_STRING DnsServerList;
- UINT NodeType;
- char ScopeId[MAX_SCOPE_ID_LEN + 4];
- UINT EnableRouting;
- UINT EnableProxy;
- UINT EnableDns;
-} FIXED_INFO, *PFIXED_INFO;
-
-#endif
-
-
-/* IP helper library routine used on 98/2000/XP */
-static int (PASCAL FAR *GetNetworkParams_fn)();
-static int (PASCAL FAR *GetAdaptersInfo_fn)();
-static int (PASCAL FAR *NotifyAddrChange_fn)();
-
-/*
- * Routines to obtain domain name and name servers are OS specific
- */
-typedef int (*LoadConfig)(char *sl, char *ns);
-static LoadConfig loadconfig_fn;
-
-
-/*
- * JNI ids
- */
+/* JNI ids */
static jfieldID searchlistID;
static jfieldID nameserversID;
-
/*
* Utility routine to append s2 to s1 with a space delimiter.
* strappend(s1="abc", "def") => "abc def"
* strappend(s1="", "def") => "def
*/
void strappend(char *s1, char *s2) {
- int len;
+ size_t len;
if (s2[0] == '\0') /* nothing to append */
return;
@@ -145,356 +70,6 @@ void strappend(char *s1, char *s2) {
strcat(s1, s2);
}
-
-/*
- * Windows 95/98/ME for static TCP/IP configuration.
- *
- * Use registry approach for statically configured TCP/IP settings.
- * Registry entries described in "MS TCP/IP and Windows 95 Networking"
- * (Microsoft TechNet site).
- */
-static int loadStaticConfig9x(char *sl, char *ns) {
- LONG ret;
- HANDLE hKey;
- DWORD dwLen;
- ULONG ulType;
- char result[MAX_STR_LEN];
- int sts = STS_NO_CONFIG;
-
- ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
- "SYSTEM\\CurrentControlSet\\Services\\VxD\\MSTCP",
- 0,
- KEY_READ,
- (PHKEY)&hKey);
- if (ret == ERROR_SUCCESS) {
- /*
- * Determine suffix list
- */
- result[0] = '\0';
- dwLen = sizeof(result);
- ret = RegQueryValueEx(hKey, "SearchList", NULL, &ulType,
- (LPBYTE)&result, &dwLen);
- if ((ret != ERROR_SUCCESS) || (strlen(result) == 0)) {
- dwLen = sizeof(result);
- ret = RegQueryValueEx(hKey, "Domain", NULL, &ulType,
- (LPBYTE)&result, &dwLen);
- }
- if (ret == ERROR_SUCCESS) {
- assert(ulType == REG_SZ);
- if (strlen(result) > 0) {
- strappend(sl, result);
- sts |= STS_SL_FOUND;
- }
- }
-
- /*
- * Determine DNS name server(s)
- */
- result[0] = '\0';
- dwLen = sizeof(result);
- ret = RegQueryValueEx(hKey, "NameServer", NULL, &ulType,
- (LPBYTE)&result, &dwLen);
- if (ret == ERROR_SUCCESS) {
- assert(ulType == REG_SZ);
- if (strlen(result) > 0) {
- strappend(ns, result);
- sts |= STS_NS_FOUND;
- }
- }
-
- RegCloseKey(hKey);
- }
-
- return sts;
-}
-
-
-/*
- * Windows 95
- *
- * Use registry approach for statically configured TCP/IP settings
- * (see loadStaticConfig9x).
- *
- * If DHCP is used we examine the DHCP vendor specific extensions. We parse
- * this based on format described in RFC 2132.
- *
- * If Dial-up Networking (DUN) is used then this TCP/IP settings cannot
- * be determined here.
- */
-static int loadConfig95(char *sl, char *ns) {
- int sts;
- int index;
- LONG ret;
- HANDLE hKey;
- DWORD dwLen;
- ULONG ulType;
- char optionInfo[MAX_STR_LEN];
-
- /*
- * First try static configuration - if found we are done.
- */
- sts = loadStaticConfig9x(sl, ns);
- if (IS_SL_FOUND(sts) && IS_NS_FOUND(sts)) {
- return sts;
- }
-
- /*
- * Try DHCP. DHCP information is stored in :-
- * SYSTEM\CurrentControlSet\Services\VxD\DHCP\DhcpInfoXX
- *
- * The key is normally DhcpInfo00\OptionInfo (see Article Q255245 on
- * Microsoft site). However when multiple cards are added & removed we
- * have observed that it can be located in DhcpInfo{01,02, ...}.
- * As a hack we search all DhcpInfoXX keys until we find OptionInfo.
- */
- for (index=0; index<99; index++) {
- char key[MAX_STR_LEN];
- sprintf(key, "SYSTEM\\CurrentControlSet\\Services\\VxD\\DHCP\\DhcpInfo%02d",
- index);
-
- ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE, key, 0, KEY_READ, (PHKEY)&hKey);
- if (ret != ERROR_SUCCESS) {
- /* end of DhcpInfoXX entries */
- break;
- }
-
- dwLen = sizeof(optionInfo);
- ret = RegQueryValueEx(hKey, "OptionInfo", NULL, &ulType,
- (LPBYTE)optionInfo, &dwLen);
- RegCloseKey(hKey);
-
- if (ret == ERROR_SUCCESS) {
- /* OptionInfo found */
- break;
- }
- }
-
- /*
- * If OptionInfo was found then we parse (as the 'options' field of
- * the DHCP packet - see RFC 2132).
- */
- if (ret == ERROR_SUCCESS) {
- unsigned int pos = 0;
-
- while (pos < dwLen) {
- int code, len;
-
- code = optionInfo[pos];
- pos++;
- if (pos >= dwLen) break; /* bad packet */
-
- len = optionInfo[pos];
- pos++;
-
- if (pos+len > dwLen) break; /* bad packet */
-
- /*
- * Domain Name - see RFC 2132 section 3.17
- */
- if (!IS_SL_FOUND(sts)) {
- if (code == 0xf) {
- char domain[MAX_STR_LEN];
-
- assert(len < MAX_STR_LEN);
-
- memcpy((void *)domain, (void *)&(optionInfo[pos]), (size_t)len);
- domain[len] = '\0';
-
- strappend(sl, domain);
- sts |= STS_SL_FOUND;
- }
- }
-
- /*
- * DNS Option - see RFC 2132 section 3.8
- */
- if (!IS_NS_FOUND(sts)) {
- if (code == 6 && (len % 4) == 0) {
- while (len > 0 && pos < dwLen) {
- char addr[32];
- sprintf(addr, "%d.%d.%d.%d",
- (unsigned char)optionInfo[pos],
- (unsigned char)optionInfo[pos+1],
- (unsigned char)optionInfo[pos+2],
- (unsigned char)optionInfo[pos+3]);
- pos += 4;
- len -= 4;
-
- /*
- * Append to list of name servers
- */
- strappend(ns, addr);
- sts |= STS_NS_FOUND;
- }
- }
- }
-
- /*
- * Onto the next options
- */
- pos += len;
- }
- }
-
- return sts;
-}
-
-/*
- * Windows 98/ME
- *
- * Use registry approach for statically configured TCP/IP settings
- * (see loadStaticConfig9x).
- *
- * If configuration is not static then use IP helper library routine
- * GetNetworkParams to obtain the network settings which include the
- * domain name and the DNS servers. Note that we use the registry in
- * preference to GetNetworkParams as the domain name is not populated
- * by GetNetworkParams if the configuration is static.
- */
-static int loadConfig98(char *sl, char *ns) {
- FIXED_INFO *infoP;
- ULONG size;
- DWORD ret;
- int sts;
-
- /*
- * Use registry approach to pick up static configuation.
- */
- sts = loadStaticConfig9x(sl, ns);
- if (IS_SL_FOUND(sts) && IS_NS_FOUND(sts)) {
- return sts;
- }
-
- /*
- * Use IP helper library to obtain dynamic configuration (DHCP and
- * DUN).
- */
- size = sizeof(FIXED_INFO);
- infoP = (FIXED_INFO *)malloc(size);
- if (infoP) {
- ret = (*GetNetworkParams_fn)(infoP, &size);
- if (ret == ERROR_BUFFER_OVERFLOW) {
- infoP = (FIXED_INFO *)realloc(infoP, size);
- if (infoP != NULL)
- ret = (*GetNetworkParams_fn)(infoP, &size);
- }
- }
- if (infoP == NULL) {
- return sts;
- }
- if (ret == ERROR_SUCCESS) {
- /*
- * Use DomainName if search-list not specified.
- */
- if (!IS_SL_FOUND(sts)) {
- strappend(sl, infoP->DomainName);
- sts |= STS_SL_FOUND;
- }
-
- /*
- * Use DnsServerList if not statically configured.
- */
- if (!IS_NS_FOUND(sts)) {
- PIP_ADDR_STRING dnsP = &(infoP->DnsServerList);
- do {
- strappend(ns, (char *)&(dnsP->IpAddress));
- dnsP = dnsP->Next;
- } while (dnsP != NULL);
- sts |= STS_NS_FOUND;
- }
- }
-
- free(infoP);
-
- return sts;
-}
-
-
-/*
- * Windows NT
- *
- * Use registry approach based on settings described in "TCP/IP and
- * NBT Configuration Parameters for Windows" - Article Q12062 on
- * Microsoft site.
- *
- * All non-RAS TCP/IP settings are stored in HKEY_LOCAL_MACHINE in
- * the SYSTEM\CurrentControlSet\Services\Tcpip\Parameters key.
- *
- * If SearchList if not provided then return Domain or DhcpDomain.
- * If Domain is specified it overrides DhcpDomain even if DHCP is
- * enabled.
- *
- * DNS name servers based on NameServer or DhcpNameServer settings.
- * NameServer overrides DhcpNameServer even if DHCP is enabled.
- */
-static int loadConfigNT(char *sl, char *ns) {
- LONG ret;
- HANDLE hKey;
- DWORD dwLen;
- ULONG ulType;
- char result[MAX_STR_LEN];
- int sts = STS_NO_CONFIG;
-
- ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
- "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters",
- 0,
- KEY_READ,
- (PHKEY)&hKey);
- if (ret != ERROR_SUCCESS) {
- return sts;
- }
-
- /*
- * Determine search list
- */
- result[0] = '\0';
- dwLen = sizeof(result);
- ret = RegQueryValueEx(hKey, "SearchList", NULL, &ulType,
- (LPBYTE)&result, &dwLen);
- if ((ret != ERROR_SUCCESS) || (strlen(result) == 0)) {
- dwLen = sizeof(result);
- ret = RegQueryValueEx(hKey, "Domain", NULL, &ulType,
- (LPBYTE)&result, &dwLen);
- if ((ret != ERROR_SUCCESS) || (strlen(result) == 0)) {
- dwLen = sizeof(result);
- ret = RegQueryValueEx(hKey, "DhcpDomain", NULL, &ulType,
- (LPBYTE)&result, &dwLen);
- }
- }
- if (ret == ERROR_SUCCESS) {
- assert(ulType == REG_SZ);
- if (strlen(result) > 0) {
- strappend(sl, result);
- sts |= STS_SL_FOUND;
- }
- }
-
- /*
- * Determine DNS name server(s)
- */
- result[0] = '\0';
- dwLen = sizeof(result);
- ret = RegQueryValueEx(hKey, "NameServer", NULL, &ulType,
- (LPBYTE)&result, &dwLen);
- if ((ret != ERROR_SUCCESS) || (strlen(result) == 0)) {
- dwLen = sizeof(result);
- ret = RegQueryValueEx(hKey, "DhcpNameServer", NULL, &ulType,
- (LPBYTE)&result, &dwLen);
- }
- if (ret == ERROR_SUCCESS) {
- assert(ulType == REG_SZ);
- if (strlen(result) > 0) {
- strappend(ns, result);
- sts |= STS_NS_FOUND;
- }
- }
-
- RegCloseKey(hKey);
-
- return sts;
-}
-
-
/*
* Windows 2000/XP
*
@@ -510,7 +85,7 @@ static int loadConfigNT(char *sl, char *ns) {
* names of each adapter and then query the corresponding registry
* settings to obtain NameServer/DhcpNameServer and Domain/DhcpDomain.
*/
-static int loadConfig2000(char *sl, char *ns) {
+static int loadConfig(char *sl, char *ns) {
IP_ADAPTER_INFO *adapterP;
ULONG size;
DWORD ret;
@@ -547,10 +122,10 @@ static int loadConfig2000(char *sl, char *ns) {
*/
size = sizeof(IP_ADAPTER_INFO);
adapterP = (IP_ADAPTER_INFO *)malloc(size);
- ret = (*GetAdaptersInfo_fn)(adapterP, &size);
+ ret = GetAdaptersInfo(adapterP, &size);
if (ret == ERROR_BUFFER_OVERFLOW) {
adapterP = (IP_ADAPTER_INFO *)realloc(adapterP, size);
- ret = (*GetAdaptersInfo_fn)(adapterP, &size);
+ ret = GetAdaptersInfo(adapterP, &size);
}
/*
@@ -648,87 +223,15 @@ static int loadConfig2000(char *sl, char *ns) {
/*
- * Initialization :-
- *
- * 1. Based on OS version set the function pointer for OS specific load
- * configuration routine.
- *
- * 2. On 98/2000/XP load the IP helper library.
- *
- * 3. Initialize JNI field IDs.
- *
+ * Initialize JNI field IDs.
*/
JNIEXPORT void JNICALL
Java_sun_net_dns_ResolverConfigurationImpl_init0(JNIEnv *env, jclass cls)
{
- OSVERSIONINFO ver;
- jboolean loadHelperLibrary = JNI_TRUE;
-
- /*
- * First we figure out which OS is running
- */
- ver.dwOSVersionInfoSize = sizeof(ver);
- GetVersionEx(&ver);
-
- if (ver.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {
- if ((ver.dwMajorVersion == 4) && (ver.dwMinorVersion == 0)) {
- /*
- * Windows 95
- */
- loadHelperLibrary = JNI_FALSE;
- loadconfig_fn = loadConfig95;
- } else {
- /*
- * Windows 98/ME
- */
- loadHelperLibrary = JNI_TRUE;
- loadconfig_fn = loadConfig98;
- }
- }
-
- if (ver.dwPlatformId == VER_PLATFORM_WIN32_NT) {
- if (ver.dwMajorVersion <= 4) {
- /*
- * Windows NT
- */
- loadHelperLibrary = JNI_FALSE;
- loadconfig_fn = loadConfigNT;
- } else {
- /*
- * Windows 2000/XP
- */
- loadHelperLibrary = JNI_TRUE;
- loadconfig_fn = loadConfig2000;
- }
- }
-
- /*
- * On 98/2000/XP we load the IP Helper Library.
- */
- if (loadHelperLibrary) {
- HANDLE h = LoadLibrary("iphlpapi.dll");
-
- if (h != NULL) {
- GetNetworkParams_fn = (int (PASCAL FAR *)())GetProcAddress(h, "GetNetworkParams");
- GetAdaptersInfo_fn = (int (PASCAL FAR *)())GetProcAddress(h, "GetAdaptersInfo");
-
- NotifyAddrChange_fn = (int (PASCAL FAR *)())GetProcAddress(h, "NotifyAddrChange");
- }
-
- if (GetNetworkParams_fn == NULL || GetAdaptersInfo_fn == NULL) {
- JNU_ThrowByName(env, "java/lang/UnsatisfiedLinkError", "iphlpapi.dll");
- return;
- }
- }
-
- /*
- * Get JNI ids
- */
searchlistID = (*env)->GetStaticFieldID(env, cls, "os_searchlist",
"Ljava/lang/String;");
nameserversID = (*env)->GetStaticFieldID(env, cls, "os_nameservers",
"Ljava/lang/String;");
-
}
/*
@@ -746,8 +249,7 @@ Java_sun_net_dns_ResolverConfigurationImpl_loadDNSconfig0(JNIEnv *env, jclass cl
searchlist[0] = '\0';
nameservers[0] = '\0';
- /* call OS specific routine */
- (void)(*loadconfig_fn)(searchlist, nameservers);
+ loadConfig(searchlist, nameservers);
/*
* Populate static fields in sun.net.DefaultResolverConfiguration
@@ -772,17 +274,15 @@ Java_sun_net_dns_ResolverConfigurationImpl_notifyAddrChange0(JNIEnv *env, jclass
HANDLE h;
DWORD rc, xfer;
- if (NotifyAddrChange_fn != NULL) {
- ol.hEvent = (HANDLE)0;
- rc = (*NotifyAddrChange_fn)(&h, &ol);
- if (rc == ERROR_IO_PENDING) {
- rc = GetOverlappedResult(h, &ol, &xfer, TRUE);
- if (rc != 0) {
- return 0; /* address changed */
- }
+ ol.hEvent = (HANDLE)0;
+ rc = NotifyAddrChange(&h, &ol);
+ if (rc == ERROR_IO_PENDING) {
+ rc = GetOverlappedResult(h, &ol, &xfer, TRUE);
+ if (rc != 0) {
+ return 0; /* address changed */
}
}
- /* NotifyAddrChange not support or error */
+ /* error */
return -1;
}
diff --git a/src/windows/native/sun/net/www/protocol/http/ntlm/NTLMAuthSequence.c b/src/windows/native/sun/net/www/protocol/http/ntlm/NTLMAuthSequence.c
index fca399d3206972bec16e9d372e4f55c0b735fc33..86af0a877a1590bd1c4a79c1f3d83e2c8d2638f6 100644
--- a/src/windows/native/sun/net/www/protocol/http/ntlm/NTLMAuthSequence.c
+++ b/src/windows/native/sun/net/www/protocol/http/ntlm/NTLMAuthSequence.c
@@ -41,18 +41,6 @@
#define SECURITY_WIN32
#include "sspi.h"
-
-/*
- * OS calls loaded from DLL on intialization
- */
-
-static FREE_CREDENTIALS_HANDLE_FN pFreeCredentialsHandle;
-static ACQUIRE_CREDENTIALS_HANDLE_FN pAcquireCredentialsHandle;
-static FREE_CONTEXT_BUFFER_FN pFreeContextBuffer;
-static INITIALIZE_SECURITY_CONTEXT_FN pInitializeSecurityContext;
-static COMPLETE_AUTH_TOKEN_FN pCompleteAuthToken;
-static DELETE_SECURITY_CONTEXT_FN pDeleteSecurityContext;
-
static void endSequence (PCredHandle credHand, PCtxtHandle ctxHandle);
static jfieldID ntlm_ctxHandleID;
@@ -63,48 +51,8 @@ static HINSTANCE lib = NULL;
JNIEXPORT void JNICALL Java_sun_net_www_protocol_http_ntlm_NTLMAuthSequence_initFirst
(JNIEnv *env, jclass clazz)
{
- OSVERSIONINFO version;
- UCHAR libName[MAX_PATH];
-
ntlm_ctxHandleID = (*env)->GetFieldID(env, clazz, "ctxHandle", "J");
ntlm_crdHandleID = (*env)->GetFieldID(env, clazz, "crdHandle", "J");
-
- version.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
- GetVersionEx (&version);
-
- if (version.dwPlatformId == VER_PLATFORM_WIN32_NT) {
- strcpy (libName, "security.dll" );
- }
- else if (version.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {
- strcpy (libName, "secur32.dll" );
- }
-
- lib = LoadLibrary (libName);
-
- pFreeCredentialsHandle
- = (FREE_CREDENTIALS_HANDLE_FN) GetProcAddress(
- lib, "FreeCredentialsHandle" );
-
- pAcquireCredentialsHandle
- = (ACQUIRE_CREDENTIALS_HANDLE_FN) GetProcAddress(
- lib, "AcquireCredentialsHandleA" );
-
- pFreeContextBuffer
- = (FREE_CONTEXT_BUFFER_FN) GetProcAddress(
- lib, "FreeContextBuffer" );
-
- pInitializeSecurityContext
- = (INITIALIZE_SECURITY_CONTEXT_FN) GetProcAddress(
- lib, "InitializeSecurityContextA" );
-
- pCompleteAuthToken
- = (COMPLETE_AUTH_TOKEN_FN) GetProcAddress(
- lib, "CompleteAuthToken" );
-
- pDeleteSecurityContext
- = (DELETE_SECURITY_CONTEXT_FN) GetProcAddress(
- lib, "DeleteSecurityContext" );
-
}
/*
@@ -158,17 +106,17 @@ JNIEXPORT jlong JNICALL Java_sun_net_www_protocol_http_ntlm_NTLMAuthSequence_get
if ( pUser != NULL ) {
AuthId.User = (unsigned char *) pUser;
- AuthId.UserLength = strlen( pUser );
+ AuthId.UserLength = (unsigned long) strlen( pUser );
}
if ( pPassword != NULL ) {
AuthId.Password = (unsigned char *) pPassword;
- AuthId.PasswordLength = strlen( pPassword );
+ AuthId.PasswordLength = (unsigned long) strlen( pPassword );
}
if ( pDomain != NULL ) {
AuthId.Domain = (unsigned char *) pDomain;
- AuthId.DomainLength = strlen( pDomain );
+ AuthId.DomainLength = (unsigned long) strlen( pDomain );
}
AuthId.Flags = SEC_WINNT_AUTH_IDENTITY_ANSI;
@@ -176,7 +124,7 @@ JNIEXPORT jlong JNICALL Java_sun_net_www_protocol_http_ntlm_NTLMAuthSequence_get
pAuthId = NULL;
}
- ss = pAcquireCredentialsHandle(
+ ss = AcquireCredentialsHandleA(
NULL, "NTLM", SECPKG_CRED_OUTBOUND,
NULL, pAuthId, NULL, NULL,
pCred, <ime
@@ -258,7 +206,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_net_www_protocol_http_ntlm_NTLMAuthSequenc
* need to send the out buffer if there are bytes to send
*/
- ss = pInitializeSecurityContext(
+ ss = InitializeSecurityContextA(
pCred, pCtx, NULL, 0, 0, SECURITY_NATIVE_DREP,
lastToken ? &InBuffDesc : NULL, 0, newContext, &OutBuffDesc,
&ContextAttributes, <ime
@@ -274,7 +222,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_net_www_protocol_http_ntlm_NTLMAuthSequenc
}
if ((ss == SEC_I_COMPLETE_NEEDED) || (ss == SEC_I_COMPLETE_AND_CONTINUE) ) {
- ss = pCompleteAuthToken( pCtx, &OutBuffDesc );
+ ss = CompleteAuthToken( pCtx, &OutBuffDesc );
if (ss < 0) {
endSequence (pCred, pCtx);
@@ -300,12 +248,12 @@ JNIEXPORT jbyteArray JNICALL Java_sun_net_www_protocol_http_ntlm_NTLMAuthSequenc
static void endSequence (PCredHandle credHand, PCtxtHandle ctxHandle) {
if (credHand != 0) {
- pFreeCredentialsHandle (credHand);
- free (credHand);
+ FreeCredentialsHandle(credHand);
+ free(credHand);
}
if (ctxHandle != 0) {
- pDeleteSecurityContext(ctxHandle);
- free (ctxHandle);
+ DeleteSecurityContext(ctxHandle);
+ free(ctxHandle);
}
}
diff --git a/src/windows/native/sun/nio/fs/WindowsNativeDispatcher.c b/src/windows/native/sun/nio/fs/WindowsNativeDispatcher.c
index d9d8a9d7cb254e80716c3bf5172ee0883baf61da..7324950e9ef87b2cc424d9a5ae39734a6101ed3e 100644
--- a/src/windows/native/sun/nio/fs/WindowsNativeDispatcher.c
+++ b/src/windows/native/sun/nio/fs/WindowsNativeDispatcher.c
@@ -24,7 +24,7 @@
*/
#ifndef _WIN32_WINNT
-#define _WIN32_WINNT 0x0500
+#define _WIN32_WINNT 0x0501
#endif
#include
@@ -36,6 +36,7 @@
#include
#include
#include
+#include
#include "jni.h"
#include "jni_util.h"
@@ -77,40 +78,20 @@ static jfieldID backupResult_context;
/**
- * Win32 APIs not defined in Visual Studio 2003 header files
+ * Win32 APIs not available in Windows XP
*/
-
-typedef enum {
- FindStreamInfoStandard
-} MY_STREAM_INFO_LEVELS;
-
-typedef struct _MY_WIN32_FIND_STREAM_DATA {
- LARGE_INTEGER StreamSize;
- WCHAR cStreamName[MAX_PATH + 36];
-} MY_WIN32_FIND_STREAM_DATA;
-
-typedef HANDLE (WINAPI* FindFirstStream_Proc)(LPCWSTR, MY_STREAM_INFO_LEVELS, LPVOID, DWORD);
+typedef HANDLE (WINAPI* FindFirstStream_Proc)(LPCWSTR, STREAM_INFO_LEVELS, LPVOID, DWORD);
typedef BOOL (WINAPI* FindNextStream_Proc)(HANDLE, LPVOID);
typedef BOOLEAN (WINAPI* CreateSymbolicLinkProc) (LPCWSTR, LPCWSTR, DWORD);
-typedef BOOL (WINAPI* CreateHardLinkProc) (LPCWSTR, LPCWSTR, LPSECURITY_ATTRIBUTES);
typedef BOOL (WINAPI* GetFinalPathNameByHandleProc) (HANDLE, LPWSTR, DWORD, DWORD);
-typedef BOOL (WINAPI* ConvertSidToStringSidProc) (PSID, LPWSTR*);
-typedef BOOL (WINAPI* ConvertStringSidToSidProc) (LPWSTR, PSID*);
-typedef DWORD (WINAPI* GetLengthSidProc) (PSID);
-
static FindFirstStream_Proc FindFirstStream_func;
static FindNextStream_Proc FindNextStream_func;
static CreateSymbolicLinkProc CreateSymbolicLink_func;
-static CreateHardLinkProc CreateHardLink_func;
static GetFinalPathNameByHandleProc GetFinalPathNameByHandle_func;
-static ConvertSidToStringSidProc ConvertSidToStringSid_func;
-static ConvertStringSidToSidProc ConvertStringSidToSid_func;
-static GetLengthSidProc GetLengthSid_func;
-
static void throwWindowsException(JNIEnv* env, DWORD lastError) {
jobject x = JNU_NewObjectByName(env, "sun/nio/fs/WindowsException",
"(I)V", lastError);
@@ -190,33 +171,23 @@ Java_sun_nio_fs_WindowsNativeDispatcher_initIDs(JNIEnv* env, jclass this)
backupResult_bytesTransferred = (*env)->GetFieldID(env, clazz, "bytesTransferred", "I");
backupResult_context = (*env)->GetFieldID(env, clazz, "context", "J");
-
- h = LoadLibrary("kernel32");
- if (h != INVALID_HANDLE_VALUE) {
+ // get handle to kernel32
+ if (GetModuleHandleExW((GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
+ GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT),
+ (LPCWSTR)&CreateFileW, &h) != 0)
+ {
+ // requires Windows Server 2003 or newer
FindFirstStream_func =
(FindFirstStream_Proc)GetProcAddress(h, "FindFirstStreamW");
FindNextStream_func =
(FindNextStream_Proc)GetProcAddress(h, "FindNextStreamW");
+
+ // requires Windows Vista or newer
CreateSymbolicLink_func =
(CreateSymbolicLinkProc)GetProcAddress(h, "CreateSymbolicLinkW");
- CreateHardLink_func =
- (CreateHardLinkProc)GetProcAddress(h, "CreateHardLinkW");
GetFinalPathNameByHandle_func =
(GetFinalPathNameByHandleProc)GetProcAddress(h, "GetFinalPathNameByHandleW");
- FreeLibrary(h);
- }
-
- h = LoadLibrary("advapi32");
- if (h != INVALID_HANDLE_VALUE) {
- ConvertSidToStringSid_func =
- (ConvertSidToStringSidProc)GetProcAddress(h, "ConvertSidToStringSidW");
- ConvertStringSidToSid_func =
- (ConvertStringSidToSidProc)GetProcAddress(h, "ConvertStringSidToSidW");
- GetLengthSid_func =
- (GetLengthSidProc)GetProcAddress(h, "GetLengthSid");
- FreeLibrary(h);
}
-
}
JNIEXPORT jstring JNICALL
@@ -413,7 +384,7 @@ JNIEXPORT void JNICALL
Java_sun_nio_fs_WindowsNativeDispatcher_FindFirstStream0(JNIEnv* env, jclass this,
jlong address, jobject obj)
{
- MY_WIN32_FIND_STREAM_DATA data;
+ WIN32_FIND_STREAM_DATA data;
LPCWSTR lpFileName = jlong_to_ptr(address);
HANDLE handle;
@@ -443,7 +414,7 @@ JNIEXPORT jstring JNICALL
Java_sun_nio_fs_WindowsNativeDispatcher_FindNextStream(JNIEnv* env, jclass this,
jlong handle)
{
- MY_WIN32_FIND_STREAM_DATA data;
+ WIN32_FIND_STREAM_DATA data;
HANDLE h = (HANDLE)jlong_to_ptr(handle);
if (FindNextStream_func == NULL) {
@@ -909,12 +880,7 @@ Java_sun_nio_fs_WindowsNativeDispatcher_GetLengthSid(JNIEnv* env,
jclass this, jlong address)
{
PSID sid = jlong_to_ptr(address);
-
- if (GetLengthSid_func == NULL) {
- JNU_ThrowInternalError(env, "Should not get here");
- return 0;
- }
- return (jint)(*GetLengthSid_func)(sid);
+ return (jint)GetLengthSid(sid);
}
@@ -924,13 +890,7 @@ Java_sun_nio_fs_WindowsNativeDispatcher_ConvertSidToStringSid(JNIEnv* env,
{
PSID sid = jlong_to_ptr(address);
LPWSTR string;
-
- if (ConvertSidToStringSid_func == NULL) {
- JNU_ThrowInternalError(env, "Should not get here");
- return NULL;
- }
-
- if ((*ConvertSidToStringSid_func)(sid, &string) == 0) {
+ if (ConvertSidToStringSidW(sid, &string) == 0) {
throwWindowsException(env, GetLastError());
return NULL;
} else {
@@ -947,15 +907,8 @@ Java_sun_nio_fs_WindowsNativeDispatcher_ConvertStringSidToSid0(JNIEnv* env,
{
LPWSTR lpStringSid = jlong_to_ptr(address);
PSID pSid;
-
- if (ConvertStringSidToSid_func == NULL) {
- JNU_ThrowInternalError(env, "Should not get here");
- return (jlong)0;
- }
-
- if ((*ConvertStringSidToSid_func)(lpStringSid, &pSid) == 0)
+ if (ConvertStringSidToSidW(lpStringSid, &pSid) == 0)
throwWindowsException(env, GetLastError());
-
return ptr_to_jlong(pSid);
}
@@ -1137,11 +1090,7 @@ Java_sun_nio_fs_WindowsNativeDispatcher_CreateHardLink0(JNIEnv* env,
LPCWSTR newFile = jlong_to_ptr(newFileAddress);
LPCWSTR existingFile = jlong_to_ptr(existingFileAddress);
- if (CreateHardLink_func == NULL) {
- JNU_ThrowInternalError(env, "Should not get here");
- return;
- }
- if ((*CreateHardLink_func)(newFile, existingFile, NULL) == 0)
+ if (CreateHardLinkW(newFile, existingFile, NULL) == 0)
throwWindowsException(env, GetLastError());
}
diff --git a/src/windows/native/sun/security/provider/WinCAPISeedGenerator.c b/src/windows/native/sun/security/provider/WinCAPISeedGenerator.c
index d9d91080ddbb3635387846ca3b16c89bf8251b72..968650da591852ae3a1f40cbb2b417f750471e9d 100644
--- a/src/windows/native/sun/security/provider/WinCAPISeedGenerator.c
+++ b/src/windows/native/sun/security/provider/WinCAPISeedGenerator.c
@@ -33,11 +33,6 @@
#include
#include "sun_security_provider_NativeSeedGenerator.h"
-/* Typedefs for runtime linking. */
-typedef BOOL (WINAPI *CryptAcquireContextType)(HCRYPTPROV*, LPCTSTR, LPCTSTR, DWORD, DWORD);
-typedef BOOL (WINAPI *CryptGenRandomType)(HCRYPTPROV, DWORD, BYTE*);
-typedef BOOL (WINAPI *CryptReleaseContextType)(HCRYPTPROV, DWORD);
-
/*
* Get a random seed from the MS CryptoAPI. Return true if successful, false
* otherwise.
@@ -49,48 +44,27 @@ typedef BOOL (WINAPI *CryptReleaseContextType)(HCRYPTPROV, DWORD);
JNIEXPORT jboolean JNICALL Java_sun_security_provider_NativeSeedGenerator_nativeGenerateSeed
(JNIEnv *env, jclass clazz, jbyteArray randArray)
{
- HMODULE lib;
- CryptAcquireContextType acquireContext;
- CryptGenRandomType genRandom;
- CryptReleaseContextType releaseContext;
-
HCRYPTPROV hCryptProv;
jboolean result = JNI_FALSE;
jsize numBytes;
jbyte* randBytes;
- lib = LoadLibrary("ADVAPI32.DLL");
- if (lib == NULL) {
- return result;
- }
-
- acquireContext = (CryptAcquireContextType)GetProcAddress(lib, "CryptAcquireContextA");
- genRandom = (CryptGenRandomType)GetProcAddress(lib, "CryptGenRandom");
- releaseContext = (CryptReleaseContextType)GetProcAddress(lib, "CryptReleaseContext");
-
- if (acquireContext == NULL || genRandom == NULL || releaseContext == NULL) {
- FreeLibrary(lib);
- return result;
- }
-
- if (acquireContext(&hCryptProv, "J2SE", NULL, PROV_RSA_FULL, 0) == FALSE) {
+ if (CryptAcquireContextA(&hCryptProv, "J2SE", NULL, PROV_RSA_FULL, 0) == FALSE) {
/* If CSP context hasn't been created, create one. */
- if (acquireContext(&hCryptProv, "J2SE", NULL, PROV_RSA_FULL,
+ if (CryptAcquireContextA(&hCryptProv, "J2SE", NULL, PROV_RSA_FULL,
CRYPT_NEWKEYSET) == FALSE) {
- FreeLibrary(lib);
return result;
}
}
numBytes = (*env)->GetArrayLength(env, randArray);
randBytes = (*env)->GetByteArrayElements(env, randArray, NULL);
- if (genRandom(hCryptProv, numBytes, randBytes)) {
+ if (CryptGenRandom(hCryptProv, numBytes, randBytes)) {
result = JNI_TRUE;
}
(*env)->ReleaseByteArrayElements(env, randArray, randBytes, 0);
- releaseContext(hCryptProv, 0);
- FreeLibrary(lib);
+ CryptReleaseContext(hCryptProv, 0);
return result;
}
diff --git a/test/Makefile b/test/Makefile
index d1171b9602759a2ca3bca891d3cc85141e849e37..26bd7e5e2c8dd161d502735af355411e729aefd5 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -261,6 +261,7 @@ endif
# Follow command with ";$(BUNDLE_UP_AND_EXIT)", so it always gets executed.
ZIP_UP_RESULTS = ( $(MKDIR) -p `$(DIRNAME) $(ARCHIVE_BUNDLE)` \
&& $(CD) $(ABS_TEST_OUTPUT_DIR) \
+ && $(CHMOD) -R a+r . \
&& $(ZIP) -q -r $(ARCHIVE_BUNDLE) . )
SUMMARY_TXT = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)")/JTreport/text/summary.txt
STATS_TXT_NAME = Stats.txt
@@ -312,7 +313,9 @@ BUNDLE_UP_AND_EXIT = \
else \
$(ECHO) "Missing file: $${_summary}" >> $(STATS_TXT); \
fi; \
- $(CAT) $(STATS_TXT); \
+ if [ -f $(STATS_TXT) ] ; then \
+ $(CAT) $(STATS_TXT); \
+ fi; \
$(ZIP_UP_RESULTS) ; \
$(TESTEXIT) \
)
@@ -370,10 +373,10 @@ EXCLUDELIST=$(ABS_TEST_OUTPUT_DIR)/excludelist.txt
# Create exclude list for this platform and arch
ifdef NO_EXCLUDES
-$(EXCLUDELIST): $(PROBLEM_LISTS) $(TESTDIRS)
+$(EXCLUDELIST): $(PROBLEM_LISTS) $(TEST_DEPENDENCIES)
@$(ECHO) "NOTHING_EXCLUDED" > $@
else
-$(EXCLUDELIST): $(PROBLEM_LISTS) $(TESTDIRS)
+$(EXCLUDELIST): $(PROBLEM_LISTS) $(TEST_DEPENDENCIES)
@$(RM) $@ $@.temp1 $@.temp2
@(($(CAT) $(PROBLEM_LISTS) | $(EGREP) -- '$(OS_NAME)-all' ) ;\
($(CAT) $(PROBLEM_LISTS) | $(EGREP) -- '$(PLATFORM_OS)' ) ;\
@@ -385,7 +388,7 @@ $(EXCLUDELIST): $(PROBLEM_LISTS) $(TESTDIRS)
($(ECHO) "#") ;\
) | $(SED) -e 's@^[\ ]*@@' \
| $(EGREP) -v '^#' > $@.temp1
- @for tdir in $(TESTDIRS) ; do \
+ for tdir in $(TESTDIRS) SOLARIS_10_SH_BUG_NO_EMPTY_FORS ; do \
( ( $(CAT) $@.temp1 | $(EGREP) "^$${tdir}" ) ; $(ECHO) "#" ) >> $@.temp2 ; \
done
@$(ECHO) "# at least one line" >> $@.temp2
@@ -400,11 +403,11 @@ endef
# Running batches of tests with or without samevm
define RunSamevmBatch
$(ECHO) "Running tests in samevm mode: $?"
-$(MAKE) TESTDIRS="$?" USE_JTREG_SAMEVM=true UNIQUE_DIR=$@ jtreg_tests
+$(MAKE) TEST_DEPENDENCIES="$?" TESTDIRS="$?" USE_JTREG_SAMEVM=true UNIQUE_DIR=$@ jtreg_tests
endef
define RunOthervmBatch
$(ECHO) "Running tests in othervm mode: $?"
-$(MAKE) TESTDIRS="$?" USE_JTREG_SAMEVM=false UNIQUE_DIR=$@ jtreg_tests
+$(MAKE) TEST_DEPENDENCIES="$?" TESTDIRS="$?" USE_JTREG_SAMEVM=false UNIQUE_DIR=$@ jtreg_tests
endef
define SummaryInfo
$(ECHO) "########################################################"
@@ -501,7 +504,7 @@ jdk_nio1: $(call TestDirs, java/nio/file)
# Stable samevm testruns (minus items from PROBLEM_LIST)
JDK_ALL_TARGETS += jdk_nio2
jdk_nio2: $(call TestDirs, java/nio/Buffer java/nio/ByteOrder \
- java/nio/channels java/nio/BufferPoolMXBean java/nio/MappedByteBuffer)
+ java/nio/channels java/nio/MappedByteBuffer)
$(call SharedLibraryPermissions,java/nio/channels)
$(call RunSamevmBatch)
@@ -684,7 +687,7 @@ PHONY_LIST += packtest packtest_stress
################################################################
-# perftest to collect statistics
+# perftest to collect statistics
# Expect JPRT to set JPRT_PACKTEST_HOME.
PERFTEST_HOME = $(TEST_ROOT)/perf
@@ -706,7 +709,7 @@ PHONY_LIST += perftest
# vmsqe tests
# Expect JPRT to set JPRT_VMSQE_HOME.
-VMSQE_HOME = /java/sqe/comp/vm/testbase/sqe/vm/current/build/latest/vm
+VMSQE_HOME = $(SLASH_JAVA)/sqe/comp/vm/testbase/sqe/vm/current/build/latest/vm
ifdef JPRT_VMSQE_HOME
VMSQE_HOME = $(JPRT_VMSQE_HOME)
endif
@@ -718,7 +721,7 @@ ifdef JPRT_RUNVMSQE_HOME
endif
# Expect JPRT to set JPRT_TONGA3_HOME.
-TONGA3_HOME = /java/sqe//tools/gtee/harness/tonga
+TONGA3_HOME = $(SLASH_JAVA)/sqe/tools/gtee/harness/tonga
ifdef JPRT_TONGA3_HOME
TONGA3_HOME = $(JPRT_TONGA3_HOME)
endif
@@ -771,148 +774,84 @@ PHONY_LIST += vmsqe_jdwp vmsqe_jdi vmsqe_jdb vmsqe_quick-jdi vmsqe_sajdi \
# jck tests
-JCK_WORK_DIR = $(ABS_TEST_OUTPUT_DIR)/JCKwork
-JCK_REPORT_DIR = $(ABS_TEST_OUTPUT_DIR)/JCKreport
-JCK_PROPERTIES = $(ABS_TEST_OUTPUT_DIR)/jck.properties
-JCK_CONFIG = $(ABS_TEST_OUTPUT_DIR)/jck.config
-
-JCK_JAVA_EXE = $(PRODUCT_HOME)/bin/java$(EXESUFFIX)
-
-JCK_JAVATEST_JAR = $(JCK_HOME)/lib/javatest.jar
-JCK_JAVATEST = $(ALT_BOOTDIR)/bin/java -jar $(JCK_JAVATEST_JAR)
-
-$(JCK_CONFIG): $(TEST_ROOT)/JCK-$(JCK_BUNDLE_NAME)-$(JCK_RELEASE)-base.jti
- $(RM) $@
- $(MKDIR) -p $(@D)
- $(CP) $< $@
-
-$(JCK_PROPERTIES): $(PRODUCT_HOME) $(JCK_JAVA_EXE)
- $(RM) $@
- $(MKDIR) -p $(@D)
- $(ECHO) "jck.env.compiler.compRefExecute.cmdAsFile=$(JCK_JAVA_EXE)" >> $@
- $(ECHO) "jck.env.compiler.compRefExecute.systemRoot=$(SYSTEMROOT)" >> $@
- $(ECHO) "jck.env.compiler.testCompile.testCompileAPImultiJVM.cmdAsFile=$(JCK_JAVA_EXE)" >> $@
- $(ECHO) "jck.tests.tests=$(JCK_BUNDLE_TESTDIRS)" >> $@
-
-jck_tests: prep $(JCK_HOME) $(JCK_PROPERTIES) $(JCK_CONFIG) $(JCK_JAVATEST_JAR)
- $(MKDIR) -p $(JCK_WORK_DIR)
- ( $(JCK_JAVATEST) \
- -verbose:commands,non-pass \
- -testSuite $(JCK_HOME) \
- -workDir $(JCK_WORK_DIR) \
- -config $(JCK_CONFIG) \
- -set -file $(JCK_PROPERTIES) \
- -runtests \
- -writeReport $(JCK_REPORT_DIR) \
- ) ; $(BUNDLE_UP_AND_EXIT)
-
-PHONY_LIST += jck_tests
-
-################################################################
-
-# jck6 tests
-
-JCK6_RELEASE = 6b
-JCK6_DEFAULT_HOME = $(SLASH_JAVA)/re/jck/$(JCK6_RELEASE)/archive/fcs/binaries
-
-# Expect JPRT to set JPRT_JCK6COMPILER_HOME.
-JCK6COMPILER_HOME = $(JCK6_DEFAULT_HOME)/JCK-compiler-$(JCK6_RELEASE)
-ifdef JPRT_JCK6COMPILER_HOME
- JCK6COMPILER_HOME = $(JPRT_JCK6COMPILER_HOME)
-endif
-
-# Expect JPRT to set JPRT_JCK6RUNTIME_HOME.
-JCK6RUNTIME_HOME = $(JCK6_DEFAULT_HOME)/JCK-runtime-$(JCK6_RELEASE)
-ifdef JPRT_JCK6RUNTIME_HOME
- JCK6RUNTIME_HOME = $(JPRT_JCK6RUNTIME_HOME)
-endif
-
-# Expect JPRT to set JPRT_JCK6DEVTOOLS_HOME.
-JCK6DEVTOOLS_HOME = $(JCK6_DEFAULT_HOME)/JCK-devtools-$(JCK6_RELEASE)
-ifdef JPRT_JCK6DEVTOOLS_HOME
- JCK6DEVTOOLS_HOME = $(JPRT_JCK6DEVTOOLS_HOME)
-endif
-
-jck6_tests: JCK_HOME=$(JCK6_HOME)
-jck6_tests: JCK_RELEASE=$(JCK6_RELEASE)
-jck6_tests: jck_tests
-
-jck6compiler: JCK6_HOME=$(JCK6COMPILER_HOME)
-jck6compiler: JCK_BUNDLE_NAME=compiler
-jck6compiler: jck6_tests
-
-jck6compiler_lang: JCK_BUNDLE_TESTDIRS=lang
-jck6compiler_lang: jck6compiler
-
-jck6runtime: JCK6_HOME=$(JCK6RUNTIME_HOME)
-jck6runtime: JCK_BUNDLE_NAME=runtime
-jck6runtime: jck6_tests
-
-jck6runtime_lang: JCK_BUNDLE_TESTDIRS=lang
-jck6runtime_lang: jck6runtime
-
-jck6devtools: JCK6_HOME=$(JCK6DEVTOOLS_HOME)
-jck6devtools: JCK_BUNDLE_NAME=devtools
-jck6devtools: jck6_tests
-
-jck6devtools_lang: JCK_BUNDLE_TESTDIRS=lang
-jck6devtools_lang: jck6devtools
-
-PHONY_LIST += jck6compiler jck6runtime jck6devtools jck6_tests \
- jck6compiler_lang jck6runtime_lang jck6devtools_lang
-
-################################################################
-
-# jck7 tests
-
-JCK7_RELEASE = 7
-JCK7_DEFAULT_HOME = $(SLASH_JAVA)/re/jck/$(JCK7_RELEASE)/archive/fcs/binaries
+# Default is to use jck 7 from /java/re
+JCK7_DEFAULT_HOME = $(SLASH_JAVA)/re/jck/7/promoted/latest/binaries
# Expect JPRT to set JPRT_JCK7COMPILER_HOME.
-JCK7COMPILER_HOME = $(JCK7_DEFAULT_HOME)/JCK-compiler-$(JCK7_RELEASE)
+JCK7COMPILER_HOME = $(JCK7_DEFAULT_HOME)/JCK-compiler-7
ifdef JPRT_JCK7COMPILER_HOME
- JCK7COMPILER_HOME = $(JPRT_JCK7COMPILER_HOME)
+ JCK7COMPILER_HOME = $(JPRT_JCK7COMPILER_HOME)/JCK-compiler-7
endif
# Expect JPRT to set JPRT_JCK7RUNTIME_HOME.
-JCK7RUNTIME_HOME = $(JCK7_DEFAULT_HOME)/JCK-runtime-$(JCK7_RELEASE)
+JCK7RUNTIME_HOME = $(JCK7_DEFAULT_HOME)/JCK-runtime-7
ifdef JPRT_JCK7RUNTIME_HOME
- JCK7RUNTIME_HOME = $(JPRT_JCK7RUNTIME_HOME)
+ JCK7RUNTIME_HOME = $(JPRT_JCK7RUNTIME_HOME)/JCK-runtime-7
endif
# Expect JPRT to set JPRT_JCK7DEVTOOLS_HOME.
-JCK7DEVTOOLS_HOME = $(JCK7_DEFAULT_HOME)/JCK-devtools-$(JCK7_RELEASE)
+JCK7DEVTOOLS_HOME = $(JCK7_DEFAULT_HOME)/JCK-devtools-7
ifdef JPRT_JCK7DEVTOOLS_HOME
- JCK7DEVTOOLS_HOME = $(JPRT_JCK7DEVTOOLS_HOME)
+ JCK7DEVTOOLS_HOME = $(JPRT_JCK7DEVTOOLS_HOME)/JCK-devtools-7
endif
-jck7_tests: JCK_HOME=$(JCK7_HOME)
-jck7_tests: JCK_RELEASE=$(JCK7_RELEASE)
-jck7_tests: jck_tests
-
-jck7compiler: JCK7_HOME=$(JCK7COMPILER_HOME)
-jck7compiler: JCK_BUNDLE_NAME=compiler
-jck7compiler: jck7_tests
-
-jck7compiler_lang: JCK_BUNDLE_TESTDIRS=lang
-jck7compiler_lang: jck7compiler
+# The jtjck.jar utility to use to run the tests
+JTJCK_JAR = $(JCK_HOME)/lib/jtjck.jar
+JTJCK_JAVA_ARGS = -XX:MaxPermSize=256m -Xmx512m
+JTJCK_OPTIONS = -headless -v
-jck7runtime: JCK7_HOME=$(JCK7RUNTIME_HOME)
-jck7runtime: JCK_BUNDLE_NAME=runtime
-jck7runtime: jck7_tests
-
-jck7runtime_lang: JCK_BUNDLE_TESTDIRS=lang
-jck7runtime_lang: jck7runtime
-
-jck7devtools: JCK7_HOME=$(JCK7DEVTOOLS_HOME)
-jck7devtools: JCK_BUNDLE_NAME=devtools
-jck7devtools: jck7_tests
+# Default tests to run
+ifndef JCK_COMPILER_TESTS
+ JCK_COMPILER_TESTS =
+endif
+ifndef JCK_RUNTIME_TESTS
+ JCK_RUNTIME_TESTS =
+endif
+ifndef JCK_DEVTOOLS_TESTS
+ JCK_DEVTOOLS_TESTS =
+endif
-jck7devtools_lang: JCK_BUNDLE_TESTDIRS=lang
-jck7devtools_lang: jck7devtools
+# Generic rule used to run jck tests
+_generic_jck_tests: prep $(PRODUCT_HOME) $(EXCLUDELIST)
+ @$(EXPAND) $(EXCLUDELIST) \
+ | $(CUT) -d' ' -f1 \
+ | $(SED) -e 's@^@Excluding: @'
+ ( $(CD) $(ABS_TEST_OUTPUT_DIR) && \
+ $(PRODUCT_HOME)/bin/java $(JTJCK_JAVA_ARGS) \
+ -jar "$(JTJCK_JAR)" \
+ $(JTJCK_OPTIONS) \
+ -r:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)")/JTreport \
+ -w:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)")/JTwork \
+ -jdk:$(shell $(GETMIXEDPATH) "$(PRODUCT_HOME)") \
+ $(TESTDIRS) \
+ ) ; $(BUNDLE_UP_AND_EXIT)
-PHONY_LIST += jck7compiler jck7runtime jck7devtools jck7_tests \
- jck7compiler_lang jck7runtime_lang jck7devtools_lang
+# JCK7 compiler tests
+jck7compiler:
+ $(MAKE) UNIQUE_DIR=$@ \
+ JCK_HOME=$(JCK7COMPILER_HOME) \
+ TESTDIRS="$(JCK_COMPILER_TESTS)" \
+ _generic_jck_tests
+
+# JCK7 runtime tests
+jck7runtime:
+ $(MAKE) UNIQUE_DIR=$@ \
+ JCK_HOME=$(JCK7RUNTIME_HOME) \
+ TESTDIRS="$(JCK_RUNTIME_TESTS)" \
+ _generic_jck_tests
+
+# JCK7 devtools tests
+jck7devtools:
+ $(MAKE) UNIQUE_DIR=$@ \
+ JCK_HOME=$(JCK7DEVTOOLS_HOME) \
+ TESTDIRS="$(JCK_DEVTOOLS_TESTS)" \
+ _generic_jck_tests
+
+# Run all 3 sets of JCK7 tests
+jck_all: jck7runtime jck7devtools jck7compiler
+
+PHONY_LIST += jck_all _generic_jck_tests \
+ jck7compiler jck7runtime jck7devtools
################################################################
diff --git a/test/ProblemList.txt b/test/ProblemList.txt
index 27518785b070b0fa0887c82c86838aed19560e01..d0336f9b6a1704d77aed923e797c53901bdcefba 100644
--- a/test/ProblemList.txt
+++ b/test/ProblemList.txt
@@ -690,6 +690,9 @@ sun/tools/jconsole/ResourceCheckTest.sh generic-all
# jdk_util
+# Filed 7027061
+java/util/Locale/Bug6989440.java windows-all
+
# Filed 6933803
java/util/concurrent/ThreadPoolExecutor/CoreThreadTimeOut.java generic-all
diff --git a/test/com/sun/jdi/PrivateTransportTest.sh b/test/com/sun/jdi/PrivateTransportTest.sh
index 75e666fdb5edea358fe888b2106837e6d5e5c058..89a306c9ee99c3441ec16a15a5996c58a20f1279 100644
--- a/test/com/sun/jdi/PrivateTransportTest.sh
+++ b/test/com/sun/jdi/PrivateTransportTest.sh
@@ -1,7 +1,7 @@
#!/bin/ksh -p
#
-# Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2005, 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
@@ -99,6 +99,8 @@ fi
libdir=${TESTCLASSES}
+is_windows=false
+is_cygwin=false
case `uname -s` in
SunOS)
libarch=`uname -p`
@@ -126,10 +128,13 @@ case `uname -s` in
libloc=`dirname ${xx}`
;;
Windows*)
+ is_windows=true
libloc=${jreloc}/bin
sep=';'
;;
CYGWIN*)
+ is_windows=true
+ is_cygwin=true
libloc=${jreloc}/bin
sep=':'
@@ -176,7 +181,18 @@ fi
#
CP="-classpath \"${TESTCLASSES}\""
#
-DEBUGGEEFLAGS="$DEBUGGEEFLAGS -agentlib:jdwp=transport=${private_transport},server=y,suspend=n"
+if [ "$is_windows" = "true" ]; then
+ if [ "$is_cygwin" = "true" ]; then
+ win_fullpath=`cygpath -m "$fullpath" \
+ | sed -e 's#/#\\\\\\\\#g' -e 's/\.dll//'`
+ else
+ win_fullpath=`echo "$fullpath" \
+ | sed -e 's#/#\\\\\\\\#g' -e 's/\.dll//'`
+ fi
+ DEBUGGEEFLAGS="$DEBUGGEEFLAGS -agentlib:jdwp=transport=${win_fullpath},server=y,suspend=n"
+else
+ DEBUGGEEFLAGS="$DEBUGGEEFLAGS -agentlib:jdwp=transport=${private_transport},server=y,suspend=n"
+fi
echo ${TESTJAVA}/bin/java ${DEBUGGEEFLAGS} ${CP} ${TARGETCLASS}
eval ${TESTJAVA}/bin/java ${DEBUGGEEFLAGS} ${CP} ${TARGETCLASS}
diff --git a/test/java/lang/Throwable/SuppressedExceptions.java b/test/java/lang/Throwable/SuppressedExceptions.java
index f1c30b358adfc972beda6bacfb9481f3ec89b7dd..b987600dca39e45133752007cf94f6f4b879303e 100644
--- a/test/java/lang/Throwable/SuppressedExceptions.java
+++ b/test/java/lang/Throwable/SuppressedExceptions.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,7 @@ import java.util.*;
/*
* @test
- * @bug 6911258 6962571 6963622 6991528
+ * @bug 6911258 6962571 6963622 6991528 7005628
* @summary Basic tests of suppressed exceptions
* @author Joseph D. Darcy
*/
@@ -50,14 +50,6 @@ public class SuppressedExceptions {
} catch (IllegalArgumentException iae) {
; // Expected
}
-
- throwable.addSuppressed(null); // Immutable suppression list
- try {
- throwable.addSuppressed(throwable);
- throw new RuntimeException("IllegalArgumentException for self-suppresion not thrown.");
- } catch (IllegalArgumentException iae) {
- ; // Expected
- }
}
private static void basicSupressionTest() {
@@ -153,19 +145,19 @@ public class SuppressedExceptions {
(byte)0x02, (byte)0x00, (byte)0x00, (byte)0x78, (byte)0x70,
};
- ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
- ObjectInputStream ois = new ObjectInputStream(bais);
-
- Object o = ois.readObject();
- Throwable throwable = (Throwable) o;
+ try(ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+ ObjectInputStream ois = new ObjectInputStream(bais)) {
+ Object o = ois.readObject();
+ Throwable throwable = (Throwable) o;
- System.err.println("TESTING SERIALIZED EXCEPTION");
+ System.err.println("TESTING SERIALIZED EXCEPTION");
- Throwable[] t0 = throwable.getSuppressed();
- if (t0.length != 0) { // Will fail if t0 is null.
- throw new RuntimeException(message);
+ Throwable[] t0 = throwable.getSuppressed();
+ if (t0.length != 0) { // Will fail if t0 is null.
+ throw new RuntimeException(message);
+ }
+ throwable.printStackTrace();
}
- throwable.printStackTrace();
}
private static void selfReference() {
@@ -183,8 +175,7 @@ public class SuppressedExceptions {
}
private static void noModification() {
- Throwable t = new Throwable();
- t.addSuppressed(null);
+ Throwable t = new NoSuppression(false);
Throwable[] t0 = t.getSuppressed();
if (t0.length != 0)
@@ -196,5 +187,24 @@ public class SuppressedExceptions {
t0 = t.getSuppressed();
if (t0.length != 0)
throw new RuntimeException("Bad nonzero length of suppressed exceptions.");
+
+ Throwable suppressed = new ArithmeticException();
+ t = new NoSuppression(true); // Suppression enabled
+ // Make sure addSuppressed(null) throws an NPE
+ try {
+ t.addSuppressed(null);
+ } catch(NullPointerException e) {
+ ; // Expected
+ }
+ t.addSuppressed(suppressed);
+ t0 = t.getSuppressed();
+ if (t0.length != 1 || t0[0] != suppressed)
+ throw new RuntimeException("Expected suppression did not occur.");
+ }
+
+ private static class NoSuppression extends Throwable {
+ public NoSuppression(boolean enableSuppression) {
+ super("The medium.", null, enableSuppression);
+ }
}
}
diff --git a/test/java/lang/annotation/PackageMain.java b/test/java/lang/annotation/PackageMain.java
index 8b3f727d8c72a99a9830e124eff2177bf496c364..5c73a9ebb255eb0cbfa0618ac6f75d72418a642d 100644
--- a/test/java/lang/annotation/PackageMain.java
+++ b/test/java/lang/annotation/PackageMain.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 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
@@ -21,8 +21,6 @@
* questions.
*/
-import java.lang.annotation.Documented;
-
public class PackageMain {
public static void main(String[] args) throws Exception {
Class> c = Class.forName("foo.bar.Baz");
@@ -30,7 +28,7 @@ public class PackageMain {
System.out.println("cl=" + c.getClassLoader());
Package p = c.getPackage();
System.out.println("p=" + p);
- Documented d = p.getAnnotation(Documented.class);
+ Deprecated d = p.getAnnotation(Deprecated.class);
if (d == null) throw new Error();
}
}
diff --git a/test/java/lang/annotation/package-info.java b/test/java/lang/annotation/package-info.java
index f5463672c5c7aacdc1c911ccd78cac09c7e3ff14..8b057d87a3d8f2667954ecfde61c31850b52b30f 100644
--- a/test/java/lang/annotation/package-info.java
+++ b/test/java/lang/annotation/package-info.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 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
@@ -31,7 +31,7 @@
* @run main PackageMain
*/
-@java.lang.annotation.Documented
+@Deprecated
package foo.bar;
class Baz {}
diff --git a/test/java/nio/BufferPoolMXBean/Basic.java b/test/java/lang/management/BufferPoolMXBean/Basic.java
similarity index 78%
rename from test/java/nio/BufferPoolMXBean/Basic.java
rename to test/java/lang/management/BufferPoolMXBean/Basic.java
index 255edae0c8b2511422523329c340c60584a36da5..a55f50ef0eff779040e512f796867082edbc28a6 100644
--- a/test/java/nio/BufferPoolMXBean/Basic.java
+++ b/test/java/lang/management/BufferPoolMXBean/Basic.java
@@ -22,20 +22,22 @@
*/
/* @test
- * @bug 6606598
- * @summary Unit test for java.nio.BufferPoolMXBean
+ * @bug 6606598 7024172
+ * @summary Unit test for java.lang.management.BufferPoolMXBean
* @run main/othervm Basic
*/
import java.nio.ByteBuffer;
import java.nio.MappedByteBuffer;
-import java.nio.BufferPoolMXBean;
+import java.nio.file.Path;
+import java.nio.file.Files;
+import static java.nio.file.StandardOpenOption.*;
import java.nio.channels.FileChannel;
-import java.io.File;
-import java.io.RandomAccessFile;
+import java.lang.management.BufferPoolMXBean;
import java.lang.management.ManagementFactory;
import javax.management.MBeanServer;
import javax.management.ObjectName;
+import java.lang.ref.WeakReference;
import java.util.*;
public class Basic {
@@ -78,21 +80,21 @@ public class Basic {
totalCapacity += cap;
}
- // map a file
- File f = File.createTempFile("blah", null);
- f.deleteOnExit();
- RandomAccessFile raf = new RandomAccessFile(f, "rw");
- FileChannel fc = raf.getChannel();
- mbb = fc.map(FileChannel.MapMode.READ_WRITE, 10, 100);
- bufferCount++;
- totalCapacity += mbb.capacity();
+ // create a mapped buffer
+ Path tmpfile = Files.createTempFile("blah", null);
+ tmpfile.toFile().deleteOnExit();
+ try (FileChannel fc = FileChannel.open(tmpfile, READ, WRITE)) {
+ mbb = fc.map(FileChannel.MapMode.READ_WRITE, 10, 100);
+ bufferCount++;
+ totalCapacity += mbb.capacity();
+ }
- // direct
+ // use platform MXBeans directly
List pools =
ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class);
check(pools, bufferCount, totalCapacity);
- // using MBeanServer
+ // use MBeanServer
MBeanServer server = ManagementFactory.getPlatformMBeanServer();
Set mbeans = server.queryNames(
new ObjectName("java.nio:type=BufferPool,*"), null);
@@ -103,5 +105,13 @@ public class Basic {
pools.add(pool);
}
check(pools, bufferCount, totalCapacity);
+
+ // attempt to unmap mapped buffer
+ WeakReference ref = new WeakReference<>(mbb);
+ mbb = null;
+ do {
+ System.gc();
+ Thread.sleep(250);
+ } while (ref.get() != null);
}
}
diff --git a/test/java/lang/management/ManagementFactory/GetPlatformMXBeans.java b/test/java/lang/management/ManagementFactory/GetPlatformMXBeans.java
index 86acdb95dfd219929e8b19008a3be9a65d938e0b..5e88b469e50c5c20730e0b1eb3c344268496c5ef 100644
--- a/test/java/lang/management/ManagementFactory/GetPlatformMXBeans.java
+++ b/test/java/lang/management/ManagementFactory/GetPlatformMXBeans.java
@@ -23,23 +23,26 @@
/*
* @test
- * @bug 6610094
- * @summary Basic unit test of ManagementFactory.getPlatformMXBeans()
- * and also PlatformManagedObject.getObjectName()
+ * @bug 6610094 7024172
+ * @summary Basic unit test of ManagementFactory.getPlatformMXBean(s)
+ * methods and PlatformManagedObject.getObjectName()
* @author Mandy Chung
*
* @run main GetPlatformMXBeans
*/
import java.lang.management.*;
-import static java.lang.management.ManagementFactory.*;
+import java.io.IOException;
import java.util.*;
import javax.management.*;
+import static java.lang.management.ManagementFactory.*;
+
public class GetPlatformMXBeans {
private static MBeanServer platformMBeanServer =
getPlatformMBeanServer();
public static void main(String[] argv) throws Exception {
+ // singleton platform MXBean
checkPlatformMXBean(getClassLoadingMXBean(),
ClassLoadingMXBean.class,
CLASS_LOADING_MXBEAN_NAME);
@@ -58,17 +61,28 @@ public class GetPlatformMXBeans {
checkPlatformMXBean(getThreadMXBean(),
ThreadMXBean.class,
THREAD_MXBEAN_NAME);
+
+ // the following MXBean can have more than one instances
checkGarbageCollectorMXBeans(getGarbageCollectorMXBeans());
checkMemoryManagerMXBeans(getMemoryManagerMXBeans());
checkMemoryPoolMXBeans(getMemoryPoolMXBeans());
+
+ // check invalid platform MXBean
+ checkInvalidPlatformMXBean();
}
private static
- void checkPlatformMXBean(T obj, Class mxbeanInterface,
- String mxbeanName) throws Exception
+ void checkPlatformMXBean(T obj, Class mxbeanInterface,
+ String mxbeanName)
+ throws Exception
{
- int numElements = (obj != null ? 1 : 0);
- // verify local list of platform MXBeans
+ // getPlatformMXBean may return null if the mxbean is not implemented
+ PlatformManagedObject mxbean = getPlatformMXBean(mxbeanInterface);
+ if (obj != mxbean) {
+ throw new RuntimeException("Singleton MXBean returned not matched");
+ }
+
+ int numElements = obj == null ? 0 : 1;
List extends PlatformManagedObject> mxbeans =
getPlatformMXBeans(mxbeanInterface);
if (mxbeans.size() != numElements) {
@@ -77,24 +91,46 @@ public class GetPlatformMXBeans {
}
if (obj != null) {
- PlatformManagedObject pmo = mxbeans.get(0);
- if (obj != pmo) {
+ if (obj != mxbeans.get(0)) {
throw new RuntimeException("The list returned by getPlatformMXBeans"
+ " not matched");
}
ObjectName on = new ObjectName(mxbeanName);
- if (!on.equals(pmo.getObjectName())) {
+ if (!on.equals(mxbean.getObjectName())) {
throw new RuntimeException("Unmatched ObjectName " +
- pmo.getObjectName() + " Expected = " + on);
+ mxbean.getObjectName() + " Expected = " + on);
}
+ checkRemotePlatformMXBean(obj, platformMBeanServer,
+ mxbeanInterface, mxbeanName);
}
+ }
- // verify platform MXBeans in the platform MBeanServer
- mxbeans = getPlatformMXBeans(platformMBeanServer, mxbeanInterface);
+ // verify platform MXBeans in the platform MBeanServer
+ private static
+ void checkRemotePlatformMXBean(T obj,
+ MBeanServerConnection mbs,
+ Class mxbeanInterface,
+ String mxbeanName)
+ throws Exception
+ {
+ PlatformManagedObject mxbean = getPlatformMXBean(mbs, mxbeanInterface);
+ if ((obj == null && mxbean != null) || (obj != null && mxbean == null)) {
+ throw new RuntimeException("Singleton MXBean returned not matched");
+ }
+
+ int numElements = obj == null ? 0 : 1;
+ List extends PlatformManagedObject> mxbeans =
+ getPlatformMXBeans(mbs, mxbeanInterface);
if (mxbeans.size() != numElements) {
throw new RuntimeException("Unmatched number of platform MXBeans "
+ mxbeans.size() + ". Expected = " + numElements);
}
+
+ ObjectName on = new ObjectName(mxbeanName);
+ if (!on.equals(mxbean.getObjectName())) {
+ throw new RuntimeException("Unmatched ObjectName " +
+ mxbean.getObjectName() + " Expected = " + on);
+ }
}
private static void checkMemoryManagerMXBeans(List objs)
@@ -148,6 +184,14 @@ public class GetPlatformMXBeans {
void checkPlatformMXBeans(List objs, Class mxbeanInterface)
throws Exception
{
+ try {
+ getPlatformMXBean(mxbeanInterface);
+ // mxbeanInterface is not a singleton
+ throw new RuntimeException(mxbeanInterface + ": not a singleton MXBean");
+ } catch (IllegalArgumentException e) {
+ // expect IAE
+ }
+
// verify local list of platform MXBeans
List extends PlatformManagedObject> mxbeans =
getPlatformMXBeans(mxbeanInterface);
@@ -177,4 +221,40 @@ public class GetPlatformMXBeans {
+ mxbeans.size() + ". Expected = " + objs.size());
}
}
+
+ interface FakeMXBean extends PlatformManagedObject {};
+
+ private static void checkInvalidPlatformMXBean() throws IOException {
+ try {
+ getPlatformMXBean(FakeMXBean.class);
+ // mxbeanInterface is not a singleton
+ throw new RuntimeException("Expect IllegalArgumentException but not thrown");
+ } catch (IllegalArgumentException e) {
+ // expect IAE
+ }
+
+ try {
+ getPlatformMXBeans(FakeMXBean.class);
+ // mxbeanInterface is not a singleton
+ throw new RuntimeException("Expect IllegalArgumentException but not thrown");
+ } catch (IllegalArgumentException e) {
+ // expect IAE
+ }
+
+ try {
+ getPlatformMXBean(platformMBeanServer, FakeMXBean.class);
+ // mxbeanInterface is not a singleton
+ throw new RuntimeException("Expect IllegalArgumentException but not thrown");
+ } catch (IllegalArgumentException e) {
+ // expect IAE
+ }
+
+ try {
+ getPlatformMXBeans(platformMBeanServer, FakeMXBean.class);
+ // mxbeanInterface is not a singleton
+ throw new RuntimeException("Expect IllegalArgumentException but not thrown");
+ } catch (IllegalArgumentException e) {
+ // expect IAE
+ }
+ }
}
diff --git a/test/java/lang/management/PlatformLoggingMXBean/LoggingMXBeanTest.java b/test/java/lang/management/PlatformLoggingMXBean/LoggingMXBeanTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..17569b4cec1d010ac45db98cd859d73e1d86eb80
--- /dev/null
+++ b/test/java/lang/management/PlatformLoggingMXBean/LoggingMXBeanTest.java
@@ -0,0 +1,229 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7024172
+ * @summary Test if proxy for PlatformLoggingMXBean is equivalent
+ * to proxy for LoggingMXBean
+ *
+ * @build LoggingMXBeanTest
+ * @run main LoggingMXBeanTest
+ */
+
+import java.lang.management.*;
+import javax.management.MBeanServer;
+import java.util.logging.*;
+import java.util.ArrayList;
+import java.util.List;
+
+public class LoggingMXBeanTest
+{
+ static String LOGGER_NAME_1 = "com.sun.management.Logger";
+ static String LOGGER_NAME_2 = "com.sun.management.Logger.Logger2";
+ static String UNKNOWN_LOGGER_NAME = "com.sun.management.Unknown";
+
+ public static void main(String[] argv) throws Exception {
+ MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
+ LoggingMXBean proxy =
+ ManagementFactory.newPlatformMXBeanProxy(mbs,
+ LogManager.LOGGING_MXBEAN_NAME,
+ LoggingMXBean.class);
+
+ // test LoggingMXBean proxy
+ LoggingMXBeanTest p = new LoggingMXBeanTest(proxy);
+
+ // check if the attributes implemented by PlatformLoggingMXBean
+ // and LoggingMXBean return the same value
+ PlatformLoggingMXBean mxbean =
+ ManagementFactory.getPlatformMXBean(mbs, PlatformLoggingMXBean.class);
+
+ checkAttributes(proxy, mxbean);
+ }
+
+ // same verification as in java/util/logging/LoggingMXBeanTest2
+ public LoggingMXBeanTest(LoggingMXBean mbean) throws Exception {
+
+ Logger logger1 = Logger.getLogger( LOGGER_NAME_1 );
+ logger1.setLevel(Level.FINE);
+ Logger logger2 = Logger.getLogger( LOGGER_NAME_2 );
+ logger2.setLevel(null);
+
+ /*
+ * Check for the existence of our new Loggers
+ */
+ System.out.println("Test Logger Name retrieval (getLoggerNames)");
+ boolean log1 = false, log2 = false;
+ List loggers = mbean.getLoggerNames();
+ if (loggers == null || loggers.size() < 2) {
+ throw new RuntimeException(
+ "Could not Detect the presense of the new Loggers");
+ }
+
+ for (String logger : loggers) {
+ if (logger.equals(LOGGER_NAME_1)) {
+ log1 = true;
+ System.out.println(" : Found new Logger : " + logger);
+ }
+ if (logger.equals(LOGGER_NAME_2)) {
+ log2 = true;
+ System.out.println(" : Found new Logger : " + logger);
+ }
+ }
+ if ( log1 && log2 )
+ System.out.println(" : PASSED." );
+ else {
+ System.out.println(" : FAILED. Could not Detect the new Loggers." );
+ throw new RuntimeException(
+ "Could not Detect the presense of the new Loggers");
+ }
+
+ System.out.println("Test getLoggerLevel");
+ String l1 = mbean.getLoggerLevel(LOGGER_NAME_1);
+ System.out.println(" : Level for Logger " + LOGGER_NAME_1 + " : " + l1);
+ if (!l1.equals(Level.FINE.getName())) {
+ throw new RuntimeException(
+ "Expected level for " + LOGGER_NAME_1 + " = " +
+ Level.FINE.getName() + " but got " + l1);
+ }
+ String l2 = mbean.getLoggerLevel(LOGGER_NAME_2);
+ System.out.println(" : Level for Logger " + LOGGER_NAME_2 + " : " + l2);
+ if (!l2.equals("")) {
+ throw new RuntimeException(
+ "Expected level for " + LOGGER_NAME_2 + " = \"\"" +
+ " but got " + l2);
+ }
+ String l3 = mbean.getLoggerLevel(UNKNOWN_LOGGER_NAME);
+ System.out.println(" : Level for unknown logger : " + l3);
+ if (l3 != null) {
+ throw new RuntimeException(
+ "Expected level for " + UNKNOWN_LOGGER_NAME + " = null" +
+ " but got " + l3);
+ }
+
+ System.out.println("Test setLoggerLevel");
+ mbean.setLoggerLevel(LOGGER_NAME_1, "INFO");
+ System.out.println(" : Set Level for Logger " + LOGGER_NAME_1 + " to: INFO");
+ Level l = logger1.getLevel();
+ if (l != Level.INFO) {
+ throw new RuntimeException(
+ "Expected level for " + LOGGER_NAME_1 + " = " +
+ Level.INFO + " but got " + l);
+ }
+
+ mbean.setLoggerLevel(LOGGER_NAME_2, "SEVERE");
+ System.out.println(" : Set Level for Logger " + LOGGER_NAME_2 + " to: SERVER");
+ l = logger2.getLevel();
+ if (l != Level.SEVERE) {
+ throw new RuntimeException(
+ "Expected level for " + LOGGER_NAME_2 + " = " +
+ Level.SEVERE+ " but got " + l);
+ }
+
+ mbean.setLoggerLevel(LOGGER_NAME_1, null);
+ System.out.println(" : Set Level for Logger " + LOGGER_NAME_1 + " to: null");
+ l = logger1.getLevel();
+ if (l != null) {
+ throw new RuntimeException(
+ "Expected level for " + LOGGER_NAME_1 + " = null " +
+ " but got " + l);
+ }
+
+ boolean iaeCaught = false;
+ System.out.println(" : Set Level for unknown Logger to: FINE");
+ try {
+ mbean.setLoggerLevel(UNKNOWN_LOGGER_NAME, "FINE");
+ } catch (IllegalArgumentException e) {
+ // expected
+ iaeCaught = true;
+ System.out.println(" : IllegalArgumentException caught as expected");
+ }
+ if (!iaeCaught) {
+ throw new RuntimeException(
+ "Expected IllegalArgumentException for setting level for " +
+ UNKNOWN_LOGGER_NAME + " not thrown");
+ }
+ iaeCaught = false;
+ System.out.println(" : Set Level for Logger " + LOGGER_NAME_1 + " to: DUMMY");
+ try {
+ mbean.setLoggerLevel(LOGGER_NAME_1, "DUMMY");
+ } catch (IllegalArgumentException e) {
+ // expected
+ iaeCaught = true;
+ System.out.println(" : IllegalArgumentException caught as expected");
+ }
+ if (!iaeCaught) {
+ throw new RuntimeException(
+ "Expected IllegalArgumentException for invalid level.");
+ }
+
+
+ System.out.println("Test getParentLoggerName");
+ String p1 = mbean.getParentLoggerName(LOGGER_NAME_2);
+ System.out.println(" : Parent Logger for " + LOGGER_NAME_2 + " : " + p1);
+ if (!p1.equals(LOGGER_NAME_1)) {
+ throw new RuntimeException(
+ "Expected parent for " + LOGGER_NAME_2 + " = " +
+ LOGGER_NAME_1 + " but got " + p1);
+ }
+ String p2 = mbean.getParentLoggerName("");
+ System.out.println(" : Parent Logger for \"\" : " + p2);
+ if (!p2.equals("")) {
+ throw new RuntimeException(
+ "Expected parent for root logger \"\" = \"\"" +
+ " but got " + p2);
+ }
+ String p3 = mbean.getParentLoggerName(UNKNOWN_LOGGER_NAME);
+ System.out.println(" : Parent Logger for unknown logger : " + p3);
+ if (p3 != null) {
+ throw new RuntimeException(
+ "Expected level for " + UNKNOWN_LOGGER_NAME + " = null" +
+ " but got " + p3);
+ }
+ }
+
+ private static void checkAttributes(LoggingMXBean mxbean1,
+ PlatformLoggingMXBean mxbean2) {
+ // verify logger names
+ List loggers1 = mxbean1.getLoggerNames();
+ List loggers2 = mxbean2.getLoggerNames();
+ if (loggers1.size() != loggers2.size())
+ throw new RuntimeException("LoggerNames: unmatched number of entries");
+ List loggers3 = new ArrayList<>(loggers1);
+ loggers3.removeAll(loggers2);
+ if (loggers3.size() != 0)
+ throw new RuntimeException("LoggerNames: unmatched loggers");
+
+ // verify logger's level and parent
+ for (String logger : loggers1) {
+ if (!mxbean1.getLoggerLevel(logger)
+ .equals(mxbean2.getLoggerLevel(logger)))
+ throw new RuntimeException(
+ "LoggerLevel: unmatched level for " + logger);
+ if (!mxbean1.getParentLoggerName(logger)
+ .equals(mxbean2.getParentLoggerName(logger)))
+ throw new RuntimeException(
+ "ParentLoggerName: unmatched parent logger's name for " + logger);
+ }
+ }
+}
diff --git a/test/java/util/logging/PlatformLoggingMXBean/PlatformLoggingMXBeanTest.java b/test/java/lang/management/PlatformLoggingMXBean/PlatformLoggingMXBeanTest.java
similarity index 95%
rename from test/java/util/logging/PlatformLoggingMXBean/PlatformLoggingMXBeanTest.java
rename to test/java/lang/management/PlatformLoggingMXBean/PlatformLoggingMXBeanTest.java
index f76a3d3ff1021112ec50adcfab3029c37db05cf4..3694641351dc8adeef742b52520c5253e7c8817d 100644
--- a/test/java/util/logging/PlatformLoggingMXBean/PlatformLoggingMXBeanTest.java
+++ b/test/java/lang/management/PlatformLoggingMXBean/PlatformLoggingMXBeanTest.java
@@ -23,10 +23,11 @@
/*
* @test
- * @bug 6876135
+ * @bug 6876135 7024172
*
* @summary Test PlatformLoggingMXBean
- * This test performs similar testing as LoggingMXBeanTest.
+ * This test performs similar testing as
+ * java/util/logging/LoggingMXBeanTest.
*
* @build PlatformLoggingMXBeanTest
* @run main PlatformLoggingMXBeanTest
@@ -34,6 +35,7 @@
import javax.management.*;
import java.lang.management.ManagementFactory;
+import java.lang.management.PlatformLoggingMXBean;
import java.util.logging.*;
import java.util.List;
@@ -247,14 +249,8 @@ public class PlatformLoggingMXBeanTest
}
public static void main(String[] argv) throws Exception {
- List result =
- ManagementFactory.getPlatformMXBeans(PlatformLoggingMXBean.class);
- if (result.size() != 1) {
- throw new RuntimeException("Unexpected number of PlatformLoggingMXBean instances: " +
- result.size());
- }
-
- PlatformLoggingMXBean mbean = result.get(0);
+ PlatformLoggingMXBean mbean =
+ ManagementFactory.getPlatformMXBean(PlatformLoggingMXBean.class);
ObjectName objname = mbean.getObjectName();
if (!objname.equals(new ObjectName(LogManager.LOGGING_MXBEAN_NAME))) {
throw new RuntimeException("Invalid ObjectName " + objname);
@@ -263,11 +259,12 @@ public class PlatformLoggingMXBeanTest
// check if the PlatformLoggingMXBean is registered in the platform MBeanServer
MBeanServer platformMBS = ManagementFactory.getPlatformMBeanServer();
ObjectName objName = new ObjectName(LogManager.LOGGING_MXBEAN_NAME);
+
// We could call mbs.isRegistered(objName) here.
// Calling getMBeanInfo will throw exception if not found.
platformMBS.getMBeanInfo(objName);
- if (!platformMBS.isInstanceOf(objName, "java.util.logging.PlatformLoggingMXBean") ||
+ if (!platformMBS.isInstanceOf(objName, "java.lang.management.PlatformLoggingMXBean") ||
!platformMBS.isInstanceOf(objName, "java.util.logging.LoggingMXBean")) {
throw new RuntimeException(objName + " is of unexpected type");
}
diff --git a/test/java/nio/channels/AsynchronousSocketChannel/Leaky.java b/test/java/nio/channels/AsynchronousSocketChannel/Leaky.java
index 2606627446d2fcf64de70a3a0bc8933b291c1e96..39b50187242f865f92d0784a4870dec7bb02a303 100644
--- a/test/java/nio/channels/AsynchronousSocketChannel/Leaky.java
+++ b/test/java/nio/channels/AsynchronousSocketChannel/Leaky.java
@@ -28,12 +28,12 @@
*/
import java.nio.ByteBuffer;
-import java.nio.BufferPoolMXBean;
import java.nio.channels.*;
import java.net.*;
import java.util.List;
import java.util.concurrent.Future;
import java.util.concurrent.ThreadFactory;
+import java.lang.management.BufferPoolMXBean;
import java.lang.management.ManagementFactory;
/**
diff --git a/test/java/nio/file/Files/CheckPermissions.java b/test/java/nio/file/Files/CheckPermissions.java
index 8137a358d42cd07a56478c52089a3b99bf5c7c19..4c9dcca85f3131cd2e6dda508dead71b587f15dc 100644
--- a/test/java/nio/file/Files/CheckPermissions.java
+++ b/test/java/nio/file/Files/CheckPermissions.java
@@ -521,19 +521,19 @@ public class CheckPermissions {
// -- toRealPath --
prepare();
- file.toRealPath(true);
+ file.toRealPath();
assertCheckRead(file);
prepare();
- file.toRealPath(false);
+ file.toRealPath(LinkOption.NOFOLLOW_LINKS);
assertCheckRead(file);
prepare();
- Paths.get(".").toRealPath(true);
+ Paths.get(".").toRealPath();
assertCheckPropertyAccess("user.dir");
prepare();
- Paths.get(".").toRealPath(false);
+ Paths.get(".").toRealPath(LinkOption.NOFOLLOW_LINKS);
assertCheckPropertyAccess("user.dir");
// -- register --
diff --git a/test/java/nio/file/Files/PassThroughFileSystem.java b/test/java/nio/file/Files/PassThroughFileSystem.java
index 31345a8bf36d124d0574b7ca27a6ec74d94709e0..e460e358265928953c7ad3e8f8002eb059c82b24 100644
--- a/test/java/nio/file/Files/PassThroughFileSystem.java
+++ b/test/java/nio/file/Files/PassThroughFileSystem.java
@@ -486,8 +486,8 @@ class PassThroughFileSystem extends FileSystem {
}
@Override
- public Path toRealPath(boolean resolveLinks) throws IOException {
- return wrap(delegate.toRealPath(resolveLinks));
+ public Path toRealPath(LinkOption... options) throws IOException {
+ return wrap(delegate.toRealPath(options));
}
@Override
diff --git a/test/java/nio/file/Path/Misc.java b/test/java/nio/file/Path/Misc.java
index b2bf03e3510b15e2cc8c2694e916b14fe85b273d..3f997d1752e7a7a5ec120a0b60bf5f105eaf3659 100644
--- a/test/java/nio/file/Path/Misc.java
+++ b/test/java/nio/file/Path/Misc.java
@@ -22,12 +22,13 @@
*/
/* @test
- * @bug 4313887 6838333
+ * @bug 4313887 6838333 7029979
* @summary Unit test for miscellenous java.nio.file.Path methods
* @library ..
*/
import java.nio.file.*;
+import static java.nio.file.LinkOption.*;
import java.io.*;
public class Misc {
@@ -96,65 +97,65 @@ public class Misc {
final Path link = dir.resolve("link");
/**
- * Test: totRealPath(true) will access same file as toRealPath(false)
+ * Test: totRealPath() will access same file as toRealPath(NOFOLLOW_LINKS)
*/
- assertTrue(Files.isSameFile(file.toRealPath(true), file.toRealPath(false)));
+ assertTrue(Files.isSameFile(file.toRealPath(), file.toRealPath(NOFOLLOW_LINKS)));
/**
* Test: toRealPath should fail if file does not exist
*/
Path doesNotExist = dir.resolve("DoesNotExist");
try {
- doesNotExist.toRealPath(true);
+ doesNotExist.toRealPath();
throw new RuntimeException("IOException expected");
} catch (IOException expected) {
}
try {
- doesNotExist.toRealPath(false);
+ doesNotExist.toRealPath(NOFOLLOW_LINKS);
throw new RuntimeException("IOException expected");
} catch (IOException expected) {
}
/**
- * Test: toRealPath(true) should resolve links
+ * Test: toRealPath() should resolve links
*/
if (supportsLinks) {
Files.createSymbolicLink(link, file.toAbsolutePath());
- assertTrue(link.toRealPath(true).equals(file.toRealPath(true)));
+ assertTrue(link.toRealPath().equals(file.toRealPath()));
Files.delete(link);
}
/**
- * Test: toRealPath(false) should not resolve links
+ * Test: toRealPath(NOFOLLOW_LINKS) should not resolve links
*/
if (supportsLinks) {
Files.createSymbolicLink(link, file.toAbsolutePath());
- assertTrue(link.toRealPath(false).getFileName().equals(link.getFileName()));
+ assertTrue(link.toRealPath(NOFOLLOW_LINKS).getFileName().equals(link.getFileName()));
Files.delete(link);
}
/**
- * Test: toRealPath(false) with broken link
+ * Test: toRealPath(NOFOLLOW_LINKS) with broken link
*/
if (supportsLinks) {
Path broken = Files.createSymbolicLink(link, doesNotExist);
- assertTrue(link.toRealPath(false).getFileName().equals(link.getFileName()));
+ assertTrue(link.toRealPath(NOFOLLOW_LINKS).getFileName().equals(link.getFileName()));
Files.delete(link);
}
/**
* Test: toRealPath should eliminate "."
*/
- assertTrue(dir.resolve(".").toRealPath(true).equals(dir.toRealPath(true)));
- assertTrue(dir.resolve(".").toRealPath(false).equals(dir.toRealPath(false)));
+ assertTrue(dir.resolve(".").toRealPath().equals(dir.toRealPath()));
+ assertTrue(dir.resolve(".").toRealPath(NOFOLLOW_LINKS).equals(dir.toRealPath(NOFOLLOW_LINKS)));
/**
* Test: toRealPath should eliminate ".." when it doesn't follow a
* symbolic link
*/
Path subdir = Files.createDirectory(dir.resolve("subdir"));
- assertTrue(subdir.resolve("..").toRealPath(true).equals(dir.toRealPath(true)));
- assertTrue(subdir.resolve("..").toRealPath(false).equals(dir.toRealPath(false)));
+ assertTrue(subdir.resolve("..").toRealPath().equals(dir.toRealPath()));
+ assertTrue(subdir.resolve("..").toRealPath(NOFOLLOW_LINKS).equals(dir.toRealPath(NOFOLLOW_LINKS)));
Files.delete(subdir);
// clean-up
diff --git a/test/java/util/jar/JarFile/MevNPE.java b/test/java/util/jar/JarFile/MevNPE.java
new file mode 100644
index 0000000000000000000000000000000000000000..f8627d333248bbcb9e7c1a2b7fe993fe67e4044d
--- /dev/null
+++ b/test/java/util/jar/JarFile/MevNPE.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+ * @bug 7023056
+ * @summary NPE from sun.security.util.ManifestEntryVerifier.verify during Maven build
+ */
+import java.io.*;
+import java.util.jar.*;
+
+public class MevNPE {
+ public static void main(String[] args) throws Exception {
+ File f = new File(System.getProperty("test.src", "."), "Signed.jar");
+ try (JarFile jf = new JarFile(f, true)) {
+ try (InputStream s1 = jf.getInputStream(
+ jf.getJarEntry(JarFile.MANIFEST_NAME))) {
+ s1.read(new byte[10000]);
+ };
+ try (InputStream s2 = jf.getInputStream(
+ jf.getJarEntry(JarFile.MANIFEST_NAME))) {
+ s2.read(new byte[10000]);
+ };
+ }
+ }
+}
diff --git a/test/java/util/logging/SimpleFormatterFormat.java b/test/java/util/logging/SimpleFormatterFormat.java
new file mode 100644
index 0000000000000000000000000000000000000000..fc786a0f092d7a7972e2ed68e8f96e05794d62b2
--- /dev/null
+++ b/test/java/util/logging/SimpleFormatterFormat.java
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6381464
+ * @summary Test the custom simple formatter output
+ *
+ * @run main/othervm SimpleFormatterFormat
+ */
+
+import java.io.*;
+import java.util.logging.*;
+import java.util.regex.*;
+
+public class SimpleFormatterFormat {
+ private static final String key = "java.util.logging.SimpleFormatter.format";
+ private static final String origFormat = System.getProperty(key);
+ private static final PrintStream err = System.err;
+ public static void main(String[] args) throws Exception {
+ try {
+ File dir = new File(System.getProperty("user.dir", "."));
+ File log = new File(dir, "simpleformat.txt");
+ java.nio.file.Files.deleteIfExists(log.toPath());
+ PrintStream logps = new PrintStream(log);
+ System.setProperty(key, "%3$s:%4$s: %5$s [%1$tc] source: %2$s%6$s%n");
+ writeLogRecords(logps);
+ checkLogRecords(log);
+ } finally {
+ if (origFormat == null) {
+ System.clearProperty(key);
+ } else {
+ System.setProperty(key, origFormat);
+ }
+ System.setErr(err);
+ }
+ }
+
+ private static String[] loggers = new String[] {
+ "test.foo",
+ "test.foo",
+ "test.bar",
+ "test.bar"
+ };
+ private static String[] messages = new String[] {
+ "severe hello world",
+ "warning lost connection",
+ "info welcome",
+ "warning exception thrown",
+ };
+ private static void writeLogRecords(PrintStream logps) throws Exception {
+ try {
+ System.setErr(logps);
+
+ Logger foo = Logger.getLogger("test.foo");
+ foo.log(Level.SEVERE, "{0} {1} {2}", new Object[] {"severe", "hello", "world"});
+ foo.warning(messages[1]);
+
+ Logger bar = Logger.getLogger("test.bar");
+ bar.finest("Dummy message");
+ bar.info(messages[2]);
+ bar.log(Level.WARNING, messages[3], new IllegalArgumentException());
+
+ } finally {
+ logps.flush();
+ logps.close();
+ System.setErr(err);
+ }
+ }
+
+ private static void checkLogRecords(File log) throws Exception {
+ System.out.println("Checking log records in file: " + log);
+ Pattern p = Pattern.compile("([\\.a-zA-Z:]+) (.*) \\[.*\\] source: (.*)");
+
+ try (FileInputStream in = new FileInputStream(log)) {
+ BufferedReader reader = new BufferedReader(new InputStreamReader(in));
+ String line;
+ int i = 0;
+ while (i < messages.length &&
+ (line = reader.readLine()) != null) {
+ String expectedLogger = loggers[i];
+ String expectedMsg = messages[i];
+ i++;
+
+ line = line.trim();
+ System.out.println(line);
+
+ Matcher m = p.matcher(line);
+ if (!m.matches()) {
+ throw new RuntimeException("Unexpected output format");
+ }
+ if (m.groupCount() != 3) {
+ throw new RuntimeException("Unexpected group count = " +
+ m.groupCount());
+ }
+ // verify logger name and level
+ String[] ss = m.group(1).split(":");
+ int len = ss.length;
+ if (len != 2) {
+ throw new RuntimeException("Unexpected logger name and level" +
+ m.group(1));
+ }
+
+ verify(expectedLogger, expectedMsg, ss[0], ss[1], m.group(2), m.group(3));
+ }
+
+ // expect IllegalArgumentException following it
+ line = reader.readLine().trim();
+ if (!line.equals("java.lang.IllegalArgumentException")) {
+ throw new RuntimeException("Invalid line: " + line);
+ }
+ }
+ }
+
+ private static void verify(String expectedLogger, String expectedMsg,
+ String logger, String level,
+ String msg, String source) {
+ if (!logger.equals(expectedLogger)) {
+ throw new RuntimeException("Unexpected logger: " + logger);
+ }
+ if (!msg.equals(expectedMsg)) {
+ throw new RuntimeException("Unexpected message: " + msg);
+ }
+
+ String[] ss = expectedMsg.split("\\s+");
+ String expectedLevel = ss[0].toUpperCase();
+ if (!level.equals(expectedLevel)) {
+ throw new RuntimeException("Unexpected level: " + level);
+ }
+
+ ss = source.split("\\s+");
+ int len = ss.length;
+ if (!(len == 2 &&
+ ss[0].equals("SimpleFormatterFormat") &&
+ ss[1].equals("writeLogRecords"))) {
+ throw new RuntimeException("Unexpected source: " + source);
+ }
+ }
+}
diff --git a/test/java/util/zip/FlaterCriticalArray.java b/test/java/util/zip/FlaterCriticalArray.java
new file mode 100644
index 0000000000000000000000000000000000000000..3d90195dea2ca27b34f34275e2df5313425f28c6
--- /dev/null
+++ b/test/java/util/zip/FlaterCriticalArray.java
@@ -0,0 +1,295 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * ZIP inflater/deflater performance.
+ */
+
+/*
+ * Run this test on JDK 6 and on later
+ * JDKs to compare results:
+ * java -server -Xms1024M -Xmx1024M -Ddebug=true FlaterCriticalArray
+ *
+ * The performance issues can be readily seen on JDK 6, and so this code is
+ * written to compile on that platform: it does *not* use any JDK 7 - specific
+ * features.
+ */
+
+import java.io.*;
+import java.nio.*;
+import java.util.*;
+import java.util.zip.*;
+
+public class FlaterCriticalArray {
+ // If true, print information about performance
+ private static final boolean debug = System.getProperty("debug") != null;
+
+ private static void debug(String s) {
+ if (debug) System.out.println(s);
+ }
+
+ private static void debug(String name, String inOut, long time, int length) {
+ debug(name + ": Duration of " + inOut + "(in ms): " + time);
+ debug(name + ": " + inOut + "d data length: " + length + " bytes");
+ }
+
+ private static byte[] grow(byte[] a, int capacity) {
+ while (a.length < capacity) {
+ byte[] a2 = new byte[a.length * 2];
+ System.arraycopy(a, 0, a2, 0, a.length);
+ a = a2;
+ }
+ return a;
+ }
+
+ private static byte[] trim(byte[] a, int length) {
+ byte[] res = new byte[length];
+ System.arraycopy(a, 0, res, 0, length);
+ return res;
+ }
+
+ /*
+ * Base class for individual test cases
+ */
+ abstract static private class TestCase {
+ protected String name; // For information in debug messages
+ protected byte data[]; // Data to be deflated and subsequently inflated
+ protected int level; // Compression level for deflater
+
+ protected TestCase(String name, byte data[]) {
+ this(name, data, -1);
+ }
+
+ protected TestCase(String name, byte data[], int level) {
+ this.name = name;
+ this.data = data;
+ this.level = level;
+ }
+
+ public void runTest() throws Throwable {
+ long time0, time1;
+ byte deflated[], inflated[];
+
+ debug("");
+
+ time0 = System.currentTimeMillis();
+ deflated = deflate(data, level);
+ time1 = System.currentTimeMillis();
+ inform("Deflate", time1 - time0, deflated.length);
+
+ time0 = System.currentTimeMillis();
+ inflated = inflate(deflated);
+ time1 = System.currentTimeMillis();
+ inform("Inflate", time1 - time0, inflated.length);
+
+ check(Arrays.equals(data, inflated),
+ name + ": Inflated and deflated arrays do not match");
+ }
+
+ private void inform(String inOut, long duration, int length) {
+ debug(name, inOut, duration, length);
+ }
+
+ abstract protected byte[] deflate(byte data[], int level) throws Throwable;
+
+ abstract protected byte[] inflate(byte deflated[]) throws Throwable;
+ }
+
+ /*
+ * Following are the individual test cases
+ */
+
+ private static class StrideTest extends TestCase {
+ static final int STRIDE = 1024;
+
+ public StrideTest(byte data[], int level) {
+ super("STRIDE", data, level);
+ }
+
+ protected byte[] deflate(byte in[], int level) throws Throwable {
+ final int len = in.length;
+ final Deflater deflater = new Deflater(level);
+ final byte[] smallBuffer = new byte[32];
+ byte[] flated = new byte[32];
+ int count = 0;
+ for (int i = 0; i 0);
+ return trim(flated, count);
+ }
+
+ protected byte[] inflate(byte in[]) throws Throwable {
+ final int len = in.length;
+ final Inflater inflater = new Inflater();
+ final byte[] smallBuffer = new byte[3200];
+
+ byte[] flated = new byte[32];
+ int count = 0;
+
+ for (int i = 0; i 0) {
+ flated = grow(flated, count + n);
+ System.arraycopy(smallBuffer, 0, flated, count, n);
+ count += n;
+ }
+ }
+ }
+ return trim(flated, count);
+ }
+ }
+
+ private static class NoStrideTest extends TestCase {
+ public NoStrideTest(byte data[], int level) {
+ super("NO STRIDE", data, level);
+ }
+
+ public byte[] deflate(byte in[], int level) throws Throwable {
+ final Deflater flater = new Deflater(level);
+ flater.setInput(in);
+ flater.finish();
+ final byte[] smallBuffer = new byte[32];
+ byte[] flated = new byte[32];
+ int count = 0;
+ int n;
+ while ((n = flater.deflate(smallBuffer)) > 0) {
+ flated = grow(flated, count + n);
+ System.arraycopy(smallBuffer, 0, flated, count, n);
+ count += n;
+ }
+ return trim(flated, count);
+ }
+
+ public byte[] inflate(byte in[]) throws Throwable {
+ final Inflater flater = new Inflater();
+ flater.setInput(in);
+ final byte[] smallBuffer = new byte[32];
+ byte[] flated = new byte[32];
+ int count = 0;
+ int n;
+ while ((n = flater.inflate(smallBuffer)) > 0) {
+ flated = grow(flated, count + n);
+ System.arraycopy(smallBuffer, 0, flated, count, n);
+ count += n;
+ }
+ return trim(flated, count);
+ }
+ }
+
+ /**
+ * Check Deflater{In,Out}putStream by way of GZIP{In,Out}putStream
+ */
+ private static class GZIPTest extends TestCase {
+ public GZIPTest(byte data[]) {
+ super("GZIP", data);
+ }
+
+ public byte[] deflate(byte data[], int ignored) throws Throwable {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ OutputStream gzos = new GZIPOutputStream(baos);
+ gzos.write(data, 0, data.length);
+ gzos.close();
+ return baos.toByteArray();
+ }
+
+ public byte[] inflate(byte deflated[]) throws Throwable {
+ InputStream bais = new ByteArrayInputStream(deflated);
+ GZIPInputStream gzis = new GZIPInputStream(bais);
+ byte[] inflated = new byte[data.length];
+ int numRead = 0;
+ int count = 0;
+ while ((numRead = gzis.read(inflated, count, data.length - count)) > 0) {
+ count += numRead;
+ }
+ check(count == data.length, name + ": Read " + count + "; expected " + data.length);
+ return inflated;
+ }
+ }
+
+ public static void realMain(String[] args) throws Throwable {
+ byte data[];
+ int level = -1;
+ if (args.length > 0) {
+ level = Integer.parseInt(args[0]);
+ }
+ debug("Using level " + level);
+
+ if (args.length > 1) {
+ FileInputStream fis = new FileInputStream(args[1]);
+ int len = fis.available();
+ data = new byte[len];
+ check(fis.read(data, 0, len) == len, "Did not read complete file");
+ debug("Original data from " + args[1]);
+ fis.close();
+ } else {
+ ByteBuffer bb = ByteBuffer.allocate(8);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ for (int i = 0; i < 1024 * 64; i++) { // data length
+ bb.putDouble(0, Math.random());
+ baos.write(bb.array(), 0, 8);
+ }
+ data = baos.toByteArray();
+ debug("Original data from random byte array");
+ }
+ debug("Original data length: " + data.length + " bytes");
+
+ new StrideTest(data, level).runTest();
+ new NoStrideTest(data, level).runTest();
+ new GZIPTest(data).runTest();
+ }
+
+ //--------------------- Infrastructure ---------------------------
+ static volatile int passed = 0, failed = 0;
+ static void pass() {passed++;}
+ static void pass(String msg) {System.out.println(msg); passed++;}
+ static void fail() {failed++; Thread.dumpStack();}
+ static void fail(String msg) {System.out.println(msg); fail();}
+ static void unexpected(Throwable t) {failed++; t.printStackTrace();}
+ static void unexpected(Throwable t, String msg) {
+ System.out.println(msg); failed++; t.printStackTrace();}
+ static boolean check(boolean cond) {if (cond) pass(); else fail(); return cond;}
+ static boolean check(boolean cond, String msg) {if (cond) pass(); else fail(msg); return cond;}
+ static void equal(Object x, Object y) {
+ if (x == null ? y == null : x.equals(y)) pass();
+ else fail(x + " not equal to " + y);}
+ public static void main(String[] args) throws Throwable {
+ try {realMain(args);} catch (Throwable t) {unexpected(t);}
+ System.out.println("\nPassed = " + passed + " failed = " + failed);
+ if (failed > 0) throw new AssertionError("Some tests failed");}
+}
diff --git a/test/java/util/zip/InflaterBufferSize.java b/test/java/util/zip/InflaterBufferSize.java
new file mode 100644
index 0000000000000000000000000000000000000000..cf5363fca3e904c08559cb0367c4bac0b439a233
--- /dev/null
+++ b/test/java/util/zip/InflaterBufferSize.java
@@ -0,0 +1,163 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 6571338
+ * @summary Inflater should not require a buffer to the inflate() methods
+ * larger than 1 byte.
+ */
+
+import java.io.*;
+import java.nio.*;
+import java.util.*;
+import java.util.zip.*;
+
+public class InflaterBufferSize {
+ private static final int DATA_LEN = 1024 *64;
+ private static byte[] data;
+
+ // If true, print extra info.
+ private static final boolean debug = System.getProperty("debug") != null;
+
+ private static void debug(String s) {
+ if (debug) System.out.println(s);
+ }
+
+ private static void createData() {
+ ByteBuffer bb = ByteBuffer.allocate(8);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ for (int i = 0; i < DATA_LEN; i++) {
+ bb.putDouble(0, Math.random());
+ baos.write(bb.array(), 0, 8);
+ }
+ data = baos.toByteArray();
+ }
+
+ private static byte[] grow(byte[] a, int capacity) {
+ while (a.length < capacity) {
+ byte[] a2 = new byte[a.length * 2];
+ System.arraycopy(a, 0, a2, 0, a.length);
+ a = a2;
+ }
+ return a;
+ }
+
+ private static byte[] trim(byte[] a, int length) {
+ byte[] res = new byte[length];
+ System.arraycopy(a, 0, res, 0, length);
+ return res;
+ }
+
+ private static byte[] deflate(byte[] in, int level) throws Throwable {
+ final Deflater flater = new Deflater(level);
+ flater.setInput(in);
+ flater.finish();
+ final byte[] smallBuffer = new byte[32];
+ byte[] flated = new byte[32];
+ int count = 0;
+ int n;
+ while ((n = flater.deflate(smallBuffer)) > 0) {
+ flated = grow(flated, count + n);
+ System.arraycopy(smallBuffer, 0, flated, count, n);
+ count += n;
+ }
+ return trim(flated, count);
+ }
+
+ private static byte[] inflate(byte[] in) throws Throwable {
+ final Inflater flater = new Inflater();
+ flater.setInput(in);
+ // This is the buffer of interest. It should be possible to use any
+ // non-zero size.
+ final byte[] smallBuffer = new byte[1];
+ byte[] flated = new byte[32];
+ int count = 0;
+ int n;
+ while ((n = flater.inflate(smallBuffer)) > 0) {
+ flated = grow(flated, count + n);
+ System.arraycopy(smallBuffer, 0, flated, count, n);
+ count += n;
+ }
+ return trim(flated, count);
+ }
+
+ public static void realMain(String[] args) throws Throwable {
+ byte deflated[], inflated[];
+
+ int level = -1;
+ if (args.length > 0) {
+ level = Integer.parseInt(args[0]);
+ }
+ debug("Using level " + level);
+
+ if (args.length > 1) {
+ FileInputStream fis = new FileInputStream(args[1]);
+ int len = fis.available();
+ data = new byte[len];
+ check(fis.read(data, 0, len) == len, "Did not read complete file");
+ debug("Original data from " + args[1]);
+ fis.close();
+ } else {
+ createData();
+ debug("Original data from random byte array");
+ }
+ debug("Original data length: " + data.length + " bytes");
+
+ debug("");
+ deflated = deflate(data, level);
+ debug("Deflated data length: " + deflated.length + " bytes");
+
+ inflated = inflate(deflated);
+ debug("Inflated data length: "+ inflated.length + " bytes" );
+
+ if (!check(Arrays.equals(data, inflated),
+ "Inflated and deflated arrays do not match")) {
+ OutputStream os = new BufferedOutputStream(new FileOutputStream("deflated.zip"));
+ try {
+ os.write(deflated);
+ } finally {
+ os.close();
+ }
+ }
+ }
+
+ //--------------------- Infrastructure ---------------------------
+ static volatile int passed = 0, failed = 0;
+ static void pass() {passed++;}
+ static void pass(String msg) {System.out.println(msg); passed++;}
+ static void fail() {failed++; Thread.dumpStack();}
+ static void fail(String msg) {System.out.println(msg); fail();}
+ static void unexpected(Throwable t) {failed++; t.printStackTrace();}
+ static void unexpected(Throwable t, String msg) {
+ System.out.println(msg); failed++; t.printStackTrace();}
+ static boolean check(boolean cond) {if (cond) pass(); else fail(); return cond;}
+ static boolean check(boolean cond, String msg) {if (cond) pass(); else fail(msg); return cond;}
+ static void equal(Object x, Object y) {
+ if (x == null ? y == null : x.equals(y)) pass();
+ else fail(x + " not equal to " + y);}
+ public static void main(String[] args) throws Throwable {
+ try {realMain(args);} catch (Throwable t) {unexpected(t);}
+ System.out.println("\nPassed = " + passed + " failed = " + failed);
+ if (failed > 0) throw new AssertionError("Some tests failed");}
+}
diff --git a/test/sun/misc/Version/Version.java b/test/sun/misc/Version/Version.java
index 6e7d3626d9febb2df39f3ed4fe5c2fd65c659cf7..16ecd1ea9c840792d294f3a957da6fbb1771248a 100644
--- a/test/sun/misc/Version/Version.java
+++ b/test/sun/misc/Version/Version.java
@@ -142,15 +142,21 @@ public class Version {
// non-product VM will have -debug|-release appended
cs = cs.subSequence(1, cs.length());
String[] res = cs.toString().split("-");
- for (String s : res) {
+ for (int i = res.length - 1; i >= 0; i--) {
+ String s = res[i];
if (s.charAt(0) == 'b') {
- build =
- Integer.valueOf(s.substring(1, s.length())).intValue();
- break;
+ try {
+ build = Integer.parseInt(s.substring(1, s.length()));
+ break;
+ } catch (NumberFormatException nfe) {
+ // ignore
+ }
}
}
}
}
- return new VersionInfo(major, minor, micro, update, special, build);
+ VersionInfo vi = new VersionInfo(major, minor, micro, update, special, build);
+ System.out.printf("newVersionInfo: input=%s output=%s\n", version, vi);
+ return vi;
}
}
diff --git a/test/sun/security/ec/TestEC.java b/test/sun/security/ec/TestEC.java
index fe075cd3f0a4c0d66108e3b6ea3e263ea7240eb2..3c4a89506270f963b26b3ca15a4d4369f29b5ef1 100644
--- a/test/sun/security/ec/TestEC.java
+++ b/test/sun/security/ec/TestEC.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
* 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,8 +25,6 @@
* @test
* @bug 6840752
* @summary Provide out-of-the-box support for ECC algorithms
- * @ignore JSSE supported cipher suites are changed with CR 6916074,
- * need to update this test case in JDK 7 soon
* @library ../pkcs11
* @library ../pkcs11/ec
* @library ../pkcs11/sslecc
diff --git a/test/sun/security/jgss/GssNPE.java b/test/sun/security/jgss/GssNPE.java
index bacf60c5f346fa3a06d2ed921f696458db7e90cb..d2723ba625c57269819c2d09107fa96cbc78e957 100644
--- a/test/sun/security/jgss/GssNPE.java
+++ b/test/sun/security/jgss/GssNPE.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -24,6 +24,7 @@
/*
* @test
* @bug 6345338
+ * @run main/othervm GssNPE
* @summary GSS throws NPE when the JAAS config file does not exist
*/
diff --git a/test/sun/security/jgss/spnego/NoSpnegoAsDefMech.java b/test/sun/security/jgss/spnego/NoSpnegoAsDefMech.java
index 13b9ee9d47bbd93c6fdbb768af34aeb8e0865067..998f50d339f99b49890a82c899d025d271b76c91 100644
--- a/test/sun/security/jgss/spnego/NoSpnegoAsDefMech.java
+++ b/test/sun/security/jgss/spnego/NoSpnegoAsDefMech.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,7 @@
/*
* @test
* @bug 6770883
+ * @run main/othervm NoSpnegoAsDefMech
* @summary Infinite loop if SPNEGO specified as sun.security.jgss.mechanism
*/
diff --git a/test/sun/security/krb5/ConfPlusProp.java b/test/sun/security/krb5/ConfPlusProp.java
index e29637b1b154289da5c0230daf482278b69cf8b6..9fe1adcf455beb894fe76061fdf1a39fd73b15f0 100644
--- a/test/sun/security/krb5/ConfPlusProp.java
+++ b/test/sun/security/krb5/ConfPlusProp.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
* 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,6 +25,7 @@
* @bug 6857795
* @bug 6858589
* @bug 6972005
+ * @run main/othervm ConfPlusProp
* @summary krb5.conf ignored if system properties on realm and kdc are provided
*/
diff --git a/test/sun/security/krb5/ConfigWithQuotations.java b/test/sun/security/krb5/ConfigWithQuotations.java
index adf3919b9a02c02393800a97408378600b2e9cfe..c1286f8cb3acb979f3ef94dd0f511a1d609869fc 100644
--- a/test/sun/security/krb5/ConfigWithQuotations.java
+++ b/test/sun/security/krb5/ConfigWithQuotations.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@
/*
* @test
* @bug 6714845
+ * @run main/othervm ConfigWithQuotations
* @summary Quotes in Kerberos configuration file are included in the values
*/
diff --git a/test/sun/security/krb5/DnsFallback.java b/test/sun/security/krb5/DnsFallback.java
index e305ac85699325b9bead37d1fdb8084c9c4f9be2..3a48b05d83763ec4304b584d4f22f5e2fb75e9a8 100644
--- a/test/sun/security/krb5/DnsFallback.java
+++ b/test/sun/security/krb5/DnsFallback.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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
@@ -24,6 +24,7 @@
* @test
* @bug 6673164
* @bug 6552334
+ * @run main/othervm DnsFallback
* @summary fix dns_fallback parse error, and use dns by default
*/
diff --git a/test/sun/security/krb5/IPv6.java b/test/sun/security/krb5/IPv6.java
index 4b4f2a88767623db4780f07f93cb4fdf60c828ad..d1a8bf260bce93a22bc98d94fb8de3976603d4f5 100644
--- a/test/sun/security/krb5/IPv6.java
+++ b/test/sun/security/krb5/IPv6.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,7 @@
/*
* @test
* @bug 6877357 6885166
+ * @run main/othervm IPv6
* @summary IPv6 address does not work
*/
diff --git a/test/sun/security/krb5/ParseCAPaths.java b/test/sun/security/krb5/ParseCAPaths.java
index ec6f73257fb8054c57e7944b65a2327ec9df0321..f8c30bd7b7d3e16578318e6c4c73eca5bb912eb8 100644
--- a/test/sun/security/krb5/ParseCAPaths.java
+++ b/test/sun/security/krb5/ParseCAPaths.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@
/*
* @test
* @bug 6789935
+ * @run main/othervm ParseCAPaths
* @summary cross-realm capath search error
*/
@@ -30,9 +31,10 @@ import java.util.Arrays;
import sun.security.krb5.Realm;
public class ParseCAPaths {
- static boolean failed = false;
+ static Exception failed = null;
public static void main(String[] args) throws Exception {
- System.setProperty("java.security.krb5.conf", System.getProperty("test.src", ".") +"/krb5-capaths.conf");
+ System.setProperty("java.security.krb5.conf",
+ System.getProperty("test.src", ".") +"/krb5-capaths.conf");
//System.setProperty("sun.security.krb5.debug", "true");
// Standard example
@@ -59,9 +61,13 @@ public class ParseCAPaths {
check("G1.COM", "G3.COM", "G1.COM", "COM");
check("H1.COM", "H3.COM", "H1.COM");
check("I1.COM", "I4.COM", "I1.COM", "I5.COM");
-
- if (failed) {
- throw new Exception("Failed somewhere.");
+ // J2=J1 is the same as J2=.
+ check("J1.COM", "J2.COM", "J1.COM");
+ // 7019384
+ check("A9.PRAGUE.XXX.CZ", "SERVIS.XXX.CZ",
+ "A9.PRAGUE.XXX.CZ", "PRAGUE.XXX.CZ", "ROOT.XXX.CZ");
+ if (failed != null) {
+ throw failed;
}
}
@@ -69,10 +75,10 @@ public class ParseCAPaths {
try {
check2(from, to, paths);
} catch (Exception e) {
- failed = true;
- e.printStackTrace();
+ failed = e;
}
}
+
static void check2(String from, String to, String... paths)
throws Exception {
System.out.println(from + " -> " + to);
diff --git a/test/sun/security/krb5/ParseConfig.java b/test/sun/security/krb5/ParseConfig.java
index d4aa590eb2a29b3903ebf1a48f8edae768c7bb48..43c5ce39f3ae5467623ee4a96051fff7e6c0ee95 100644
--- a/test/sun/security/krb5/ParseConfig.java
+++ b/test/sun/security/krb5/ParseConfig.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@
/*
* @test
* @bug 6319046
+ * @run main/othervm ParseConfig
* @summary Problem with parsing krb5.conf
*/
diff --git a/test/sun/security/krb5/RFC396xTest.java b/test/sun/security/krb5/RFC396xTest.java
index 2bd3f235a9f15bdd61ca07382cbfd3cc6a688cd2..76016c38817d1d96250aadf74434720223f63f77 100644
--- a/test/sun/security/krb5/RFC396xTest.java
+++ b/test/sun/security/krb5/RFC396xTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@
/*
* @test
* @bug 6862679
+ * @run main/othervm RFC396xTest
* @summary ESC: AD Authentication with user with umlauts fails
*/
diff --git a/test/sun/security/krb5/TimeInCCache.java b/test/sun/security/krb5/TimeInCCache.java
index e0e420f33e03fe50816539ea7396b436d0d089c2..6c33d2eae3fed8b8856262d2eaa3cc077ccaa116 100644
--- a/test/sun/security/krb5/TimeInCCache.java
+++ b/test/sun/security/krb5/TimeInCCache.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@
/*
* @test
* @bug 6590930
+ * @run main/othervm TimeInCCache
* @summary read/write does not match for ccache
*/
diff --git a/test/sun/security/krb5/auto/HttpNegotiateServer.java b/test/sun/security/krb5/auto/HttpNegotiateServer.java
index 423ef0d853d5df91443e25c08c0276534f9156d2..aab6b92137ee3d53a22b60cf84be971aa0356671 100644
--- a/test/sun/security/krb5/auto/HttpNegotiateServer.java
+++ b/test/sun/security/krb5/auto/HttpNegotiateServer.java
@@ -74,11 +74,10 @@ public class HttpNegotiateServer {
final static char[] WEB_PASS = "webby".toCharArray();
final static String PROXY_USER = "pro";
final static char[] PROXY_PASS = "proxy".toCharArray();
- final static int WEB_PORT = 17840;
+
final static String WEB_HOST = "host.web.domain";
final static String PROXY_HOST = "host.proxy.domain";
- final static int PROXY_PORT = 17841;
// web page content
final static String CONTENT = "Hello, World!";
@@ -86,18 +85,11 @@ public class HttpNegotiateServer {
// For 6829283, count how many times the Authenticator is called.
static int count = 0;
+ static int webPort, proxyPort;
+
// URLs for web test, proxy test. The proxy server is not a real proxy
// since it fakes the same content for any URL. :)
- final static URL webUrl, proxyUrl;
- static {
- URL u1 = null, u2 = null;
- try {
- u1 = new URL("http://" + WEB_HOST +":" + WEB_PORT + "/a/b/c");
- u2 = new URL("http://nosuchplace/a/b/c");
- } catch (Exception e) {
- }
- webUrl = u1; proxyUrl = u2;
- }
+ static URL webUrl, proxyUrl;
/**
* This Authenticator checks everything:
@@ -127,7 +119,7 @@ public class HttpNegotiateServer {
if (!this.getRequestingHost().equalsIgnoreCase(PROXY_HOST)) {
throw new RuntimeException("Bad host");
}
- if (this.getRequestingPort() != PROXY_PORT) {
+ if (this.getRequestingPort() != proxyPort) {
throw new RuntimeException("Bad port");
}
if (!this.getRequestingURL().equals(proxyUrl)) {
@@ -188,10 +180,15 @@ public class HttpNegotiateServer {
fos.close();
f.deleteOnExit();
- HttpServer h1 = httpd(WEB_PORT, "Negotiate", false,
+ HttpServer h1 = httpd("Negotiate", false,
"HTTP/" + WEB_HOST + "@" + REALM_WEB, KRB5_TAB);
- HttpServer h2 = httpd(PROXY_PORT, "Negotiate", true,
+ webPort = h1.getAddress().getPort();
+ HttpServer h2 = httpd("Negotiate", true,
"HTTP/" + PROXY_HOST + "@" + REALM_PROXY, KRB5_TAB);
+ proxyPort = h2.getAddress().getPort();
+
+ webUrl = new URL("http://" + WEB_HOST +":" + webPort + "/a/b/c");
+ proxyUrl = new URL("http://nosuchplace/a/b/c");
try {
Exception e1 = null, e2 = null;
@@ -230,7 +227,7 @@ public class HttpNegotiateServer {
reader = new BufferedReader(new InputStreamReader(
proxyUrl.openConnection(
new Proxy(Proxy.Type.HTTP,
- new InetSocketAddress(PROXY_HOST, PROXY_PORT)))
+ new InetSocketAddress(PROXY_HOST, proxyPort)))
.getInputStream()));
if (!reader.readLine().equals(CONTENT)) {
throw new RuntimeException("Bad content");
@@ -258,10 +255,10 @@ public class HttpNegotiateServer {
* @param principal the krb5 service principal the server runs with
* @return the server
*/
- public static HttpServer httpd(int port, String scheme, boolean proxy,
+ public static HttpServer httpd(String scheme, boolean proxy,
String principal, String ktab) throws Exception {
MyHttpHandler h = new MyHttpHandler();
- HttpServer server = HttpServer.create(new InetSocketAddress(port), 0);
+ HttpServer server = HttpServer.create(new InetSocketAddress(0), 0);
HttpContext hc = server.createContext("/", h);
hc.setAuthenticator(new MyServerAuthenticator(
proxy, scheme, principal, ktab));
diff --git a/test/sun/security/krb5/etype/ETypeOrder.java b/test/sun/security/krb5/etype/ETypeOrder.java
index cb854acf7f58fae34f9807976ad0b1bee4f4038c..9437b16ed05795b357fd3e435985bdad90052b4d 100644
--- a/test/sun/security/krb5/etype/ETypeOrder.java
+++ b/test/sun/security/krb5/etype/ETypeOrder.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -23,6 +23,7 @@
/*
* @test
* @bug 6844907
+ * @run main/othervm ETypeOrder
* @summary krb5 etype order should be from strong to weak
*/
diff --git a/test/sun/security/krb5/krb5-capaths.conf b/test/sun/security/krb5/krb5-capaths.conf
index db672820b7d84841ae07dc188c3766d1ed115800..eead02c0b348ada5e6c2c0af9eeeddaf16768b1d 100644
--- a/test/sun/security/krb5/krb5-capaths.conf
+++ b/test/sun/security/krb5/krb5-capaths.conf
@@ -85,3 +85,13 @@ I1.COM = {
I3.COM = I2.COM
I4.COM = I2.COM I5.COM
}
+
+J1.COM = {
+ J2.COM=J1.COM
+}
+
+A9.PRAGUE.XXX.CZ = {
+ PRAGUE.XXX.CZ = .
+ ROOT.XXX.CZ = PRAGUE.XXX.CZ
+ SERVIS.XXX.CZ = ROOT.XXX.CZ
+}
diff --git a/test/sun/security/krb5/ktab/HighestKvno.java b/test/sun/security/krb5/ktab/HighestKvno.java
index 9636bb1b576fe30445e72921fa99e0d897d1f841..92e3aebd630ffff99a2084dd2e3cb565d3bcb1e8 100644
--- a/test/sun/security/krb5/ktab/HighestKvno.java
+++ b/test/sun/security/krb5/ktab/HighestKvno.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,7 @@
* @test
* @bug 6867665
* @bug 6875033
+ * @run main/othervm HighestKvno
* @summary Problem with keytabs with multiple kvno's (key versions)
*/
diff --git a/test/sun/security/pkcs11/fips/CipherTest.java b/test/sun/security/pkcs11/fips/CipherTest.java
index 3736aa07d08460b23c6dd1a9e55c61dfef428cc8..8dad4a76dcc3f23455ba74910d8d984c3ab40a83 100644
--- a/test/sun/security/pkcs11/fips/CipherTest.java
+++ b/test/sun/security/pkcs11/fips/CipherTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -114,19 +114,7 @@ public class CipherTest {
}
boolean isEnabled() {
- // ignore SCSV
- if (cipherSuite.equals("TLS_EMPTY_RENEGOTIATION_INFO_SCSV")) {
- return false;
- }
-
- // ignore exportable cipher suite for TLSv1.1
- if (protocol.equals("TLSv1.1")) {
- if(cipherSuite.indexOf("_EXPORT_") != -1) {
- return false;
- }
- }
-
- return true;
+ return TLSCipherStatus.isEnabled(cipherSuite, protocol);
}
public String toString() {
@@ -137,6 +125,114 @@ public class CipherTest {
return s;
}
+ static enum TLSCipherStatus {
+ // cipher suites supported since TLS 1.2
+ CS_01("TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384", 0x0303, 0xFFFF),
+ CS_02("TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384", 0x0303, 0xFFFF),
+ CS_03("TLS_RSA_WITH_AES_256_CBC_SHA256", 0x0303, 0xFFFF),
+ CS_04("TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384", 0x0303, 0xFFFF),
+ CS_05("TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384", 0x0303, 0xFFFF),
+ CS_06("TLS_DHE_RSA_WITH_AES_256_CBC_SHA256", 0x0303, 0xFFFF),
+ CS_07("TLS_DHE_DSS_WITH_AES_256_CBC_SHA256", 0x0303, 0xFFFF),
+
+ CS_08("TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256", 0x0303, 0xFFFF),
+ CS_09("TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256", 0x0303, 0xFFFF),
+ CS_10("TLS_RSA_WITH_AES_128_CBC_SHA256", 0x0303, 0xFFFF),
+ CS_11("TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256", 0x0303, 0xFFFF),
+ CS_12("TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256", 0x0303, 0xFFFF),
+ CS_13("TLS_DHE_RSA_WITH_AES_128_CBC_SHA256", 0x0303, 0xFFFF),
+ CS_14("TLS_DHE_DSS_WITH_AES_128_CBC_SHA256", 0x0303, 0xFFFF),
+
+ CS_15("TLS_DH_anon_WITH_AES_256_CBC_SHA256", 0x0303, 0xFFFF),
+ CS_16("TLS_DH_anon_WITH_AES_128_CBC_SHA256", 0x0303, 0xFFFF),
+ CS_17("TLS_RSA_WITH_NULL_SHA256", 0x0303, 0xFFFF),
+
+ // cipher suites obsoleted since TLS 1.2
+ CS_50("SSL_RSA_WITH_DES_CBC_SHA", 0x0000, 0x0303),
+ CS_51("SSL_DHE_RSA_WITH_DES_CBC_SHA", 0x0000, 0x0303),
+ CS_52("SSL_DHE_DSS_WITH_DES_CBC_SHA", 0x0000, 0x0303),
+ CS_53("SSL_DH_anon_WITH_DES_CBC_SHA", 0x0000, 0x0303),
+ CS_54("TLS_KRB5_WITH_DES_CBC_SHA", 0x0000, 0x0303),
+ CS_55("TLS_KRB5_WITH_DES_CBC_MD5", 0x0000, 0x0303),
+
+ // cipher suites obsoleted since TLS 1.1
+ CS_60("SSL_RSA_EXPORT_WITH_RC4_40_MD5", 0x0000, 0x0302),
+ CS_61("SSL_DH_anon_EXPORT_WITH_RC4_40_MD5", 0x0000, 0x0302),
+ CS_62("SSL_RSA_EXPORT_WITH_DES40_CBC_SHA", 0x0000, 0x0302),
+ CS_63("SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA", 0x0000, 0x0302),
+ CS_64("SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA", 0x0000, 0x0302),
+ CS_65("SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA", 0x0000, 0x0302),
+ CS_66("TLS_KRB5_EXPORT_WITH_RC4_40_SHA", 0x0000, 0x0302),
+ CS_67("TLS_KRB5_EXPORT_WITH_RC4_40_MD5", 0x0000, 0x0302),
+ CS_68("TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA", 0x0000, 0x0302),
+ CS_69("TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5", 0x0000, 0x0302),
+
+ // ignore TLS_EMPTY_RENEGOTIATION_INFO_SCSV always
+ CS_99("TLS_EMPTY_RENEGOTIATION_INFO_SCSV", 0xFFFF, 0x0000);
+
+ // the cipher suite name
+ final String cipherSuite;
+
+ // supported since protocol version
+ final int supportedSince;
+
+ // obsoleted since protocol version
+ final int obsoletedSince;
+
+ TLSCipherStatus(String cipherSuite,
+ int supportedSince, int obsoletedSince) {
+ this.cipherSuite = cipherSuite;
+ this.supportedSince = supportedSince;
+ this.obsoletedSince = obsoletedSince;
+ }
+
+ static boolean isEnabled(String cipherSuite, String protocol) {
+ int versionNumber = toVersionNumber(protocol);
+
+ if (versionNumber < 0) {
+ return true; // unlikely to happen
+ }
+
+ for (TLSCipherStatus status : TLSCipherStatus.values()) {
+ if (cipherSuite.equals(status.cipherSuite)) {
+ if ((versionNumber < status.supportedSince) ||
+ (versionNumber >= status.obsoletedSince)) {
+ return false;
+ }
+
+ return true;
+ }
+ }
+
+ return true;
+ }
+
+ private static int toVersionNumber(String protocol) {
+ int versionNumber = -1;
+
+ switch (protocol) {
+ case "SSLv2Hello":
+ versionNumber = 0x0002;
+ break;
+ case "SSLv3":
+ versionNumber = 0x0300;
+ break;
+ case "TLSv1":
+ versionNumber = 0x0301;
+ break;
+ case "TLSv1.1":
+ versionNumber = 0x0302;
+ break;
+ case "TLSv1.2":
+ versionNumber = 0x0303;
+ break;
+ default:
+ // unlikely to happen
+ }
+
+ return versionNumber;
+ }
+ }
}
private List tests;
diff --git a/test/sun/security/pkcs11/sslecc/CipherTest.java b/test/sun/security/pkcs11/sslecc/CipherTest.java
index 09ab1c66ffbcf5fc1999fb0747047ee2ce264719..64153f58d20653e68a7c84cda37e7304e1976f77 100644
--- a/test/sun/security/pkcs11/sslecc/CipherTest.java
+++ b/test/sun/security/pkcs11/sslecc/CipherTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -114,19 +114,7 @@ public class CipherTest {
}
boolean isEnabled() {
- // ignore SCSV
- if (cipherSuite.equals("TLS_EMPTY_RENEGOTIATION_INFO_SCSV")) {
- return false;
- }
-
- // ignore exportable cipher suite for TLSv1.1
- if (protocol.equals("TLSv1.1")) {
- if(cipherSuite.indexOf("_EXPORT_") != -1) {
- return false;
- }
- }
-
- return true;
+ return TLSCipherStatus.isEnabled(cipherSuite, protocol);
}
public String toString() {
@@ -137,6 +125,114 @@ public class CipherTest {
return s;
}
+ static enum TLSCipherStatus {
+ // cipher suites supported since TLS 1.2
+ CS_01("TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384", 0x0303, 0xFFFF),
+ CS_02("TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384", 0x0303, 0xFFFF),
+ CS_03("TLS_RSA_WITH_AES_256_CBC_SHA256", 0x0303, 0xFFFF),
+ CS_04("TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384", 0x0303, 0xFFFF),
+ CS_05("TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384", 0x0303, 0xFFFF),
+ CS_06("TLS_DHE_RSA_WITH_AES_256_CBC_SHA256", 0x0303, 0xFFFF),
+ CS_07("TLS_DHE_DSS_WITH_AES_256_CBC_SHA256", 0x0303, 0xFFFF),
+
+ CS_08("TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256", 0x0303, 0xFFFF),
+ CS_09("TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256", 0x0303, 0xFFFF),
+ CS_10("TLS_RSA_WITH_AES_128_CBC_SHA256", 0x0303, 0xFFFF),
+ CS_11("TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256", 0x0303, 0xFFFF),
+ CS_12("TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256", 0x0303, 0xFFFF),
+ CS_13("TLS_DHE_RSA_WITH_AES_128_CBC_SHA256", 0x0303, 0xFFFF),
+ CS_14("TLS_DHE_DSS_WITH_AES_128_CBC_SHA256", 0x0303, 0xFFFF),
+
+ CS_15("TLS_DH_anon_WITH_AES_256_CBC_SHA256", 0x0303, 0xFFFF),
+ CS_16("TLS_DH_anon_WITH_AES_128_CBC_SHA256", 0x0303, 0xFFFF),
+ CS_17("TLS_RSA_WITH_NULL_SHA256", 0x0303, 0xFFFF),
+
+ // cipher suites obsoleted since TLS 1.2
+ CS_50("SSL_RSA_WITH_DES_CBC_SHA", 0x0000, 0x0303),
+ CS_51("SSL_DHE_RSA_WITH_DES_CBC_SHA", 0x0000, 0x0303),
+ CS_52("SSL_DHE_DSS_WITH_DES_CBC_SHA", 0x0000, 0x0303),
+ CS_53("SSL_DH_anon_WITH_DES_CBC_SHA", 0x0000, 0x0303),
+ CS_54("TLS_KRB5_WITH_DES_CBC_SHA", 0x0000, 0x0303),
+ CS_55("TLS_KRB5_WITH_DES_CBC_MD5", 0x0000, 0x0303),
+
+ // cipher suites obsoleted since TLS 1.1
+ CS_60("SSL_RSA_EXPORT_WITH_RC4_40_MD5", 0x0000, 0x0302),
+ CS_61("SSL_DH_anon_EXPORT_WITH_RC4_40_MD5", 0x0000, 0x0302),
+ CS_62("SSL_RSA_EXPORT_WITH_DES40_CBC_SHA", 0x0000, 0x0302),
+ CS_63("SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA", 0x0000, 0x0302),
+ CS_64("SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA", 0x0000, 0x0302),
+ CS_65("SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA", 0x0000, 0x0302),
+ CS_66("TLS_KRB5_EXPORT_WITH_RC4_40_SHA", 0x0000, 0x0302),
+ CS_67("TLS_KRB5_EXPORT_WITH_RC4_40_MD5", 0x0000, 0x0302),
+ CS_68("TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA", 0x0000, 0x0302),
+ CS_69("TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5", 0x0000, 0x0302),
+
+ // ignore TLS_EMPTY_RENEGOTIATION_INFO_SCSV always
+ CS_99("TLS_EMPTY_RENEGOTIATION_INFO_SCSV", 0xFFFF, 0x0000);
+
+ // the cipher suite name
+ final String cipherSuite;
+
+ // supported since protocol version
+ final int supportedSince;
+
+ // obsoleted since protocol version
+ final int obsoletedSince;
+
+ TLSCipherStatus(String cipherSuite,
+ int supportedSince, int obsoletedSince) {
+ this.cipherSuite = cipherSuite;
+ this.supportedSince = supportedSince;
+ this.obsoletedSince = obsoletedSince;
+ }
+
+ static boolean isEnabled(String cipherSuite, String protocol) {
+ int versionNumber = toVersionNumber(protocol);
+
+ if (versionNumber < 0) {
+ return true; // unlikely to happen
+ }
+
+ for (TLSCipherStatus status : TLSCipherStatus.values()) {
+ if (cipherSuite.equals(status.cipherSuite)) {
+ if ((versionNumber < status.supportedSince) ||
+ (versionNumber >= status.obsoletedSince)) {
+ return false;
+ }
+
+ return true;
+ }
+ }
+
+ return true;
+ }
+
+ private static int toVersionNumber(String protocol) {
+ int versionNumber = -1;
+
+ switch (protocol) {
+ case "SSLv2Hello":
+ versionNumber = 0x0002;
+ break;
+ case "SSLv3":
+ versionNumber = 0x0300;
+ break;
+ case "TLSv1":
+ versionNumber = 0x0301;
+ break;
+ case "TLSv1.1":
+ versionNumber = 0x0302;
+ break;
+ case "TLSv1.2":
+ versionNumber = 0x0303;
+ break;
+ default:
+ // unlikely to happen
+ }
+
+ return versionNumber;
+ }
+ }
}
private List tests;
@@ -170,11 +266,13 @@ public class CipherTest {
// no client with anonymous ciphersuites
continue;
}
+
tests.add(new TestParameters(cipherSuite, protocol,
clientAuth));
}
}
}
+
testIterator = tests.iterator();
}
diff --git a/test/sun/security/ssl/sanity/interop/CipherTest.java b/test/sun/security/ssl/sanity/interop/CipherTest.java
index c7b544260ae061aa880f2c2c234156b8a2b13c4a..9c5af7eda4afb029a9fa4e1bcb044429dd93051e 100644
--- a/test/sun/security/ssl/sanity/interop/CipherTest.java
+++ b/test/sun/security/ssl/sanity/interop/CipherTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -115,19 +115,7 @@ public class CipherTest {
}
boolean isEnabled() {
- // ignore SCSV
- if (cipherSuite.equals("TLS_EMPTY_RENEGOTIATION_INFO_SCSV")) {
- return false;
- }
-
- // ignore exportable cipher suite for TLSv1.1
- if (protocol.equals("TLSv1.1")) {
- if(cipherSuite.indexOf("_EXPORT_") != -1) {
- return false;
- }
- }
-
- return true;
+ return TLSCipherStatus.isEnabled(cipherSuite, protocol);
}
public String toString() {
@@ -138,6 +126,114 @@ public class CipherTest {
return s;
}
+ static enum TLSCipherStatus {
+ // cipher suites supported since TLS 1.2
+ CS_01("TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384", 0x0303, 0xFFFF),
+ CS_02("TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384", 0x0303, 0xFFFF),
+ CS_03("TLS_RSA_WITH_AES_256_CBC_SHA256", 0x0303, 0xFFFF),
+ CS_04("TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384", 0x0303, 0xFFFF),
+ CS_05("TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384", 0x0303, 0xFFFF),
+ CS_06("TLS_DHE_RSA_WITH_AES_256_CBC_SHA256", 0x0303, 0xFFFF),
+ CS_07("TLS_DHE_DSS_WITH_AES_256_CBC_SHA256", 0x0303, 0xFFFF),
+
+ CS_08("TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256", 0x0303, 0xFFFF),
+ CS_09("TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256", 0x0303, 0xFFFF),
+ CS_10("TLS_RSA_WITH_AES_128_CBC_SHA256", 0x0303, 0xFFFF),
+ CS_11("TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256", 0x0303, 0xFFFF),
+ CS_12("TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256", 0x0303, 0xFFFF),
+ CS_13("TLS_DHE_RSA_WITH_AES_128_CBC_SHA256", 0x0303, 0xFFFF),
+ CS_14("TLS_DHE_DSS_WITH_AES_128_CBC_SHA256", 0x0303, 0xFFFF),
+
+ CS_15("TLS_DH_anon_WITH_AES_256_CBC_SHA256", 0x0303, 0xFFFF),
+ CS_16("TLS_DH_anon_WITH_AES_128_CBC_SHA256", 0x0303, 0xFFFF),
+ CS_17("TLS_RSA_WITH_NULL_SHA256", 0x0303, 0xFFFF),
+
+ // cipher suites obsoleted since TLS 1.2
+ CS_50("SSL_RSA_WITH_DES_CBC_SHA", 0x0000, 0x0303),
+ CS_51("SSL_DHE_RSA_WITH_DES_CBC_SHA", 0x0000, 0x0303),
+ CS_52("SSL_DHE_DSS_WITH_DES_CBC_SHA", 0x0000, 0x0303),
+ CS_53("SSL_DH_anon_WITH_DES_CBC_SHA", 0x0000, 0x0303),
+ CS_54("TLS_KRB5_WITH_DES_CBC_SHA", 0x0000, 0x0303),
+ CS_55("TLS_KRB5_WITH_DES_CBC_MD5", 0x0000, 0x0303),
+
+ // cipher suites obsoleted since TLS 1.1
+ CS_60("SSL_RSA_EXPORT_WITH_RC4_40_MD5", 0x0000, 0x0302),
+ CS_61("SSL_DH_anon_EXPORT_WITH_RC4_40_MD5", 0x0000, 0x0302),
+ CS_62("SSL_RSA_EXPORT_WITH_DES40_CBC_SHA", 0x0000, 0x0302),
+ CS_63("SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA", 0x0000, 0x0302),
+ CS_64("SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA", 0x0000, 0x0302),
+ CS_65("SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA", 0x0000, 0x0302),
+ CS_66("TLS_KRB5_EXPORT_WITH_RC4_40_SHA", 0x0000, 0x0302),
+ CS_67("TLS_KRB5_EXPORT_WITH_RC4_40_MD5", 0x0000, 0x0302),
+ CS_68("TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA", 0x0000, 0x0302),
+ CS_69("TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5", 0x0000, 0x0302),
+
+ // ignore TLS_EMPTY_RENEGOTIATION_INFO_SCSV always
+ CS_99("TLS_EMPTY_RENEGOTIATION_INFO_SCSV", 0xFFFF, 0x0000);
+
+ // the cipher suite name
+ final String cipherSuite;
+
+ // supported since protocol version
+ final int supportedSince;
+
+ // obsoleted since protocol version
+ final int obsoletedSince;
+
+ TLSCipherStatus(String cipherSuite,
+ int supportedSince, int obsoletedSince) {
+ this.cipherSuite = cipherSuite;
+ this.supportedSince = supportedSince;
+ this.obsoletedSince = obsoletedSince;
+ }
+
+ static boolean isEnabled(String cipherSuite, String protocol) {
+ int versionNumber = toVersionNumber(protocol);
+
+ if (versionNumber < 0) {
+ return true; // unlikely to happen
+ }
+
+ for (TLSCipherStatus status : TLSCipherStatus.values()) {
+ if (cipherSuite.equals(status.cipherSuite)) {
+ if ((versionNumber < status.supportedSince) ||
+ (versionNumber >= status.obsoletedSince)) {
+ return false;
+ }
+
+ return true;
+ }
+ }
+
+ return true;
+ }
+
+ private static int toVersionNumber(String protocol) {
+ int versionNumber = -1;
+
+ switch (protocol) {
+ case "SSLv2Hello":
+ versionNumber = 0x0002;
+ break;
+ case "SSLv3":
+ versionNumber = 0x0300;
+ break;
+ case "TLSv1":
+ versionNumber = 0x0301;
+ break;
+ case "TLSv1.1":
+ versionNumber = 0x0302;
+ break;
+ case "TLSv1.2":
+ versionNumber = 0x0303;
+ break;
+ default:
+ // unlikely to happen
+ }
+
+ return versionNumber;
+ }
+ }
}
private List tests;
diff --git a/test/sun/security/ssl/sanity/interop/ClientJSSEServerJSSE.java b/test/sun/security/ssl/sanity/interop/ClientJSSEServerJSSE.java
index 74564602d007a9527943bd75fbdd08d7a4ba41aa..953d2ea8e5f40886ba139b447836ec060f435ee4 100644
--- a/test/sun/security/ssl/sanity/interop/ClientJSSEServerJSSE.java
+++ b/test/sun/security/ssl/sanity/interop/ClientJSSEServerJSSE.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,8 +25,6 @@
* @test
* @bug 4496785
* @summary Verify that all ciphersuites work in all configurations
- * @ignore JSSE supported cipher suites are changed with CR 6916074,
- * need to update this test case in JDK 7 soon
* @author Andreas Sterbenz
* @run main/othervm/timeout=300 ClientJSSEServerJSSE
*/
diff --git a/test/sun/util/logging/PlatformLoggerTest.java b/test/sun/util/logging/PlatformLoggerTest.java
index 35fccfc00e6e960086e21fac4a2a7828db838863..9e7435d404551fd8d0bf3d67353f80a380bd1d5a 100644
--- a/test/sun/util/logging/PlatformLoggerTest.java
+++ b/test/sun/util/logging/PlatformLoggerTest.java
@@ -26,10 +26,11 @@
* @bug 6882376 6985460
* @summary Test if java.util.logging.Logger is created before and after
* logging is enabled. Also validate some basic PlatformLogger
- * operations.
+ * operations. othervm mode to make sure java.util.logging
+ * is not initialized.
*
* @compile -XDignore.symbol.file PlatformLoggerTest.java
- * @run main PlatformLoggerTest
+ * @run main/othervm PlatformLoggerTest
*/
import java.util.logging.*;
diff --git a/test/tools/pack200/CommandLineTests.java b/test/tools/pack200/CommandLineTests.java
index fefefd2a8608e84c6e3903c9ece418b85030d6c3..74a1524fa39a631f54947333527084b4b9b040eb 100644
--- a/test/tools/pack200/CommandLineTests.java
+++ b/test/tools/pack200/CommandLineTests.java
@@ -120,9 +120,9 @@ public class CommandLineTests {
// make a backup copy for re-use
File bakFile = new File(f.getName() + ".bak");
if (!bakFile.exists()) { // backup
- Utils.copyFile(f.getAbsoluteFile(), bakFile.getAbsoluteFile());
+ Utils.copyFile(f, bakFile);
} else { // restore
- Utils.copyFile(bakFile.getAbsoluteFile(), f.getAbsoluteFile());
+ Utils.copyFile(bakFile, f);
}
cmdsList.clear();
cmdsList.add(Utils.getPack200Cmd());
diff --git a/test/tools/pack200/TimeStamp.java b/test/tools/pack200/TimeStamp.java
index 3d099e2141c74b4ada6a10114aeb46342d4b1e25..aa82fbb4e16b5a99501fd4312263956de3b853bc 100644
--- a/test/tools/pack200/TimeStamp.java
+++ b/test/tools/pack200/TimeStamp.java
@@ -56,7 +56,7 @@ public class TimeStamp {
// make a local copy of our test file
File srcFile = Utils.locateJar("golden.jar");
File goldenFile = new File("golden.jar");
- Utils.copyFile(srcFile, goldenFile.getAbsoluteFile());
+ Utils.copyFile(srcFile, goldenFile);
JarFile goldenJarFile = new JarFile(goldenFile);
File packFile = new File("golden.pack");
diff --git a/test/tools/pack200/Utils.java b/test/tools/pack200/Utils.java
index 5cf7663d201a2bdd53ad57ad5c0058c0f4e2114a..53c1a1baa0b9ccb7c0e52d16cc3465edc288deb4 100644
--- a/test/tools/pack200/Utils.java
+++ b/test/tools/pack200/Utils.java
@@ -21,18 +21,18 @@
* questions.
*/
+import java.nio.file.Path;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.Closeable;
import java.io.File;
import java.io.FileFilter;
-import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
-import java.nio.channels.FileChannel;
+import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -44,6 +44,8 @@ import java.util.jar.Pack200;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
+import static java.nio.file.StandardCopyOption.*;
+
/**
*
* @author ksrini
@@ -180,45 +182,12 @@ class Utils {
}
};
- private static void setFileAttributes(File src, File dst) throws IOException {
- dst.setExecutable(src.canExecute());
- dst.setReadable(src.canRead());
- dst.setWritable(src.canWrite());
- dst.setLastModified(src.lastModified());
- }
-
static void copyFile(File src, File dst) throws IOException {
- if (src.isDirectory()) {
- dst.mkdirs();
- setFileAttributes(src, dst);
- return;
- } else {
- File baseDirFile = dst.getParentFile();
- if (!baseDirFile.exists()) {
- baseDirFile.mkdirs();
- }
- }
- FileInputStream in = null;
- FileOutputStream out = null;
- FileChannel srcChannel = null;
- FileChannel dstChannel = null;
- try {
- in = new FileInputStream(src);
- out = new FileOutputStream(dst);
- srcChannel = in.getChannel();
- dstChannel = out.getChannel();
-
- long retval = srcChannel.transferTo(0, src.length(), dstChannel);
- if (src.length() != dst.length()) {
- throw new IOException("file copy failed for " + src);
- }
- } finally {
- close(srcChannel);
- close(dstChannel);
- close(in);
- close(out);
+ Path parent = dst.toPath().getParent();
+ if (parent != null) {
+ Files.createDirectories(parent);
}
- setFileAttributes(src, dst);
+ Files.copy(src.toPath(), dst.toPath(), COPY_ATTRIBUTES, REPLACE_EXISTING);
}
static String baseName(File file, String extension) {