+ * 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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/src/share/classes/java/lang/management/PlatformManagedObject.java
--- a/jdk/src/share/classes/java/lang/management/PlatformManagedObject.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/src/share/classes/java/lang/management/PlatformManagedObject.java Thu Mar 31 22:07:32 2011 -0700
@@ -46,7 +46,7 @@
* 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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/src/share/classes/java/lang/management/package.html
--- a/jdk/src/share/classes/java/lang/management/package.html Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/src/share/classes/java/lang/management/package.html Thu Mar 31 22:07:32 2011 -0700
@@ -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 @@
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();
+1) Direct access to the Oracle-specific MXBean interface
+
+
+ List<com.sun.management.GarbageCollectorMXBean> mxbeans =
+ ManagementFactory.getPlatformMXBeans(com.sun.management.GarbageCollectorMXBean.class);
- // Get the standard attribute "VmVendor"
- String vendor = mxbean.getVmVendor();
+ for (com.sun.management.GarbageCollectorMXBean gc : mxbeans) {
+ // Get the standard attribute "CollectionCount"
+ String count = mxbean.getCollectionCount();
- // Get the platform-specific attribute "Bar"
- BarType bar = mxbean.getBar();
-
+ // 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 @@
// 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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/src/share/classes/java/nio/BufferPoolMXBean.java
--- a/jdk/src/share/classes/java/nio/BufferPoolMXBean.java Thu Mar 31 18:14:17 2011 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,94 +0,0 @@
-/*
- * Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.nio;
-
-import java.lang.management.PlatformManagedObject;
-
-/**
- * The management interface for a buffer pool.
- *
- *
A class implementing this interface is an MXBean. A Java
- * virtual machine has one or more implementations of this interface. The {@link
- * java.lang.management.ManagementFactory#getPlatformMXBeans getPlatformMXBeans}
- * method can be used to obtain the list of {@code BufferPoolMXBean} objects
- * representing the management interfaces for pools of buffers as follows:
- *
- * List<BufferPoolMXBean> pools = ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class);
- *
- *
- * The management interfaces are also registered with the platform {@link
- * javax.management.MBeanServer MBeanServer}. The {@link
- * javax.management.ObjectName ObjectName} that uniquely identifies the
- * management interface within the {@code MBeanServer} takes the form:
- *
- * java.nio:type=BufferPool,name=pool name
- *
- * where pool name is the {@link #getName name} of the buffer pool.
- *
- * @since 1.7
- */
-
-public interface BufferPoolMXBean extends PlatformManagedObject {
-
- /**
- * Returns the name representing this buffer pool.
- *
- * @return The name of this buffer pool.
- */
- String getName();
-
- /**
- * Returns an estimate of the number of buffers in the pool.
- *
- * @return An estimate of the number of buffers in this pool
- */
- long getCount();
-
- /**
- * Returns an estimate of the total capacity of the buffers in this pool.
- * A buffer's capacity is the number of elements it contains and the value
- * returned by this method is an estimate of the total capacity of buffers
- * in the pool in bytes.
- *
- * @return An estimate of the total capacity of the buffers in this pool
- * in bytes
- */
- long getTotalCapacity();
-
- /**
- * Returns an estimate of the memory that the Java virtual machine is using
- * for this buffer pool. The value returned by this method may differ
- * from the estimate of the total {@link #getTotalCapacity capacity} of
- * the buffers in this pool. This difference is explained by alignment,
- * memory allocator, and other implementation specific reasons.
- *
- * @return An estimate of the memory that the Java virtual machine is using
- * for this buffer pool in bytes, or {@code -1L} if an estimate of
- * the memory usage is not available
- */
- long getMemoryUsed();
-}
diff -r 3db1444f8ac8 -r 5cf29386a520 jdk/src/share/classes/java/util/Collections.java
--- a/jdk/src/share/classes/java/util/Collections.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/src/share/classes/java/util/Collections.java Thu Mar 31 22:07:32 2011 -0700
@@ -3533,20 +3533,20 @@
}
/**
- * 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 @@
/**
* 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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/src/share/classes/java/util/ComparableTimSort.java
--- a/jdk/src/share/classes/java/util/ComparableTimSort.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/src/share/classes/java/util/ComparableTimSort.java Thu Mar 31 22:07:32 2011 -0700
@@ -241,7 +241,7 @@
* 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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/src/share/classes/java/util/SortedMap.java
--- a/jdk/src/share/classes/java/util/SortedMap.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/src/share/classes/java/util/SortedMap.java Thu Mar 31 22:07:32 2011 -0700
@@ -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 @@
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 @@
* 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 @@
* 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 @@
* 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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/src/share/classes/java/util/TimSort.java
--- a/jdk/src/share/classes/java/util/TimSort.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/src/share/classes/java/util/TimSort.java Thu Mar 31 22:07:32 2011 -0700
@@ -274,7 +274,7 @@
* 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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/src/share/classes/java/util/jar/JarVerifier.java
--- a/jdk/src/share/classes/java/util/jar/JarVerifier.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/src/share/classes/java/util/jar/JarVerifier.java Thu Mar 31 22:07:32 2011 -0700
@@ -415,6 +415,12 @@
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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/src/share/classes/java/util/logging/LogManager.java
--- a/jdk/src/share/classes/java/util/logging/LogManager.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/src/share/classes/java/util/logging/LogManager.java Thu Mar 31 22:07:32 2011 -0700
@@ -1166,7 +1166,12 @@
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 @@
/**
* 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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/src/share/classes/java/util/logging/LoggingMXBean.java
--- a/jdk/src/share/classes/java/util/logging/LoggingMXBean.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/src/share/classes/java/util/logging/LoggingMXBean.java Thu Mar 31 22:07:32 2011 -0700
@@ -27,36 +27,41 @@
/**
- * 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 @@
*
* @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 @@
*
* @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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/src/share/classes/java/util/logging/LoggingProxyImpl.java
--- a/jdk/src/share/classes/java/util/logging/LoggingProxyImpl.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/src/share/classes/java/util/logging/LoggingProxyImpl.java Thu Mar 31 22:07:32 2011 -0700
@@ -99,4 +99,9 @@
public String getLevelName(Object level) {
return ((Level) level).getName();
}
+
+ @Override
+ public String getProperty(String key) {
+ return LogManager.getLogManager().getProperty(key);
+ }
}
diff -r 3db1444f8ac8 -r 5cf29386a520 jdk/src/share/classes/java/util/logging/PlatformLoggingMXBean.java
--- a/jdk/src/share/classes/java/util/logging/PlatformLoggingMXBean.java Thu Mar 31 18:14:17 2011 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/src/share/classes/java/util/logging/SimpleFormatter.java
--- a/jdk/src/share/classes/java/util/logging/SimpleFormatter.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/src/share/classes/java/util/logging/SimpleFormatter.java Thu Mar 31 22:07:32 2011 -0700
@@ -29,31 +29,108 @@
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 @@
* @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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/src/share/classes/javax/net/ssl/KeyStoreBuilderParameters.java
--- a/jdk/src/share/classes/javax/net/ssl/KeyStoreBuilderParameters.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/src/share/classes/javax/net/ssl/KeyStoreBuilderParameters.java Thu Mar 31 22:07:32 2011 -0700
@@ -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 @@
* @exception NullPointerException if builder is null
*/
public KeyStoreBuilderParameters(Builder builder) {
- parameters = Collections.singletonList(builder);
+ parameters = Collections.singletonList(Objects.requireNonNull(builder));
}
/**
@@ -64,11 +64,12 @@
* @exception IllegalArgumentException if parameters is an empty list
*/
public KeyStoreBuilderParameters(List parameters) {
+ if (parameters.isEmpty()) {
+ throw new IllegalArgumentException();
+ }
+
this.parameters = Collections.unmodifiableList(
new ArrayList(parameters));
- if (this.parameters.isEmpty()) {
- throw new IllegalArgumentException();
- }
}
/**
diff -r 3db1444f8ac8 -r 5cf29386a520 jdk/src/share/classes/sun/awt/HToolkit.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/sun/awt/HToolkit.java Thu Mar 31 22:07:32 2011 -0700
@@ -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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/src/share/classes/sun/management/ManagementFactoryHelper.java
--- a/jdk/src/share/classes/sun/management/ManagementFactoryHelper.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/src/share/classes/sun/management/ManagementFactoryHelper.java Thu Mar 31 22:07:32 2011 -0700
@@ -27,20 +27,18 @@
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 @@
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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/src/share/classes/sun/misc/Version.java.template
--- a/jdk/src/share/classes/sun/misc/Version.java.template Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/src/share/classes/sun/misc/Version.java.template Thu Mar 31 22:07:32 2011 -0700
@@ -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 @@
"@@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 @@
* 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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/src/share/classes/sun/security/krb5/Realm.java
--- a/jdk/src/share/classes/sun/security/krb5/Realm.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/src/share/classes/sun/security/krb5/Realm.java Thu Mar 31 22:07:32 2011 -0700
@@ -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 @@
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 @@
}
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 @@
} 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 @@
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 @@
}
}
+ /* 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 @@
* 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 @@
}
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 @@
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 @@
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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/src/share/classes/sun/security/tools/JarSigner.java
--- a/jdk/src/share/classes/sun/security/tools/JarSigner.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/src/share/classes/sun/security/tools/JarSigner.java Thu Mar 31 22:07:32 2011 -0700
@@ -1238,10 +1238,11 @@
// 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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/src/share/classes/sun/security/tools/JarSignerResources.java
--- a/jdk/src/share/classes/sun/security/tools/JarSignerResources.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/src/share/classes/sun/security/tools/JarSignerResources.java Thu Mar 31 22:07:32 2011 -0700
@@ -181,11 +181,10 @@
{"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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/src/share/classes/sun/security/tools/KeyTool.java
--- a/jdk/src/share/classes/sun/security/tools/KeyTool.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/src/share/classes/sun/security/tools/KeyTool.java Thu Mar 31 22:07:32 2011 -0700
@@ -1740,16 +1740,19 @@
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));
}
@@ -1837,10 +1840,6 @@
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();
}
@@ -3187,10 +3186,6 @@
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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/src/share/classes/sun/security/tools/TimestampedSigner.java
--- a/jdk/src/share/classes/sun/security/tools/TimestampedSigner.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/src/share/classes/sun/security/tools/TimestampedSigner.java Thu Mar 31 22:07:32 2011 -0700
@@ -250,10 +250,10 @@
* (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 @@
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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/src/share/classes/sun/security/util/AuthResources.java
--- a/jdk/src/share/classes/sun/security/util/AuthResources.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/src/share/classes/sun/security/util/AuthResources.java Thu Mar 31 22:07:32 2011 -0700
@@ -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 @@
// 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 @@
{"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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/src/share/classes/sun/security/util/ManifestEntryVerifier.java
--- a/jdk/src/share/classes/sun/security/util/ManifestEntryVerifier.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/src/share/classes/sun/security/util/ManifestEntryVerifier.java Thu Mar 31 22:07:32 2011 -0700
@@ -195,8 +195,7 @@
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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/src/share/classes/sun/security/util/Resources.java
--- a/jdk/src/share/classes/sun/security/util/Resources.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/src/share/classes/sun/security/util/Resources.java Thu Mar 31 22:07:32 2011 -0700
@@ -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 @@
{"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 @@
{"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 your keystore *\n" +
+ "* has NOT been verified! In order to verify its integrity, *\n" +
+ "* you must provide your keystore password. *"},
{".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.",
- "* you must provide your keystore password. *"},
- {".you.must.provide.the.srckeystore.password.",
+ "* 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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/src/share/classes/sun/text/bidi/BidiBase.java
--- a/jdk/src/share/classes/sun/text/bidi/BidiBase.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/src/share/classes/sun/text/bidi/BidiBase.java Thu Mar 31 22:07:32 2011 -0700
@@ -3457,13 +3457,18 @@
*/
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 @@
}
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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/src/share/classes/sun/util/logging/LoggingProxy.java
--- a/jdk/src/share/classes/sun/util/logging/LoggingProxy.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/src/share/classes/sun/util/logging/LoggingProxy.java Thu Mar 31 22:07:32 2011 -0700
@@ -60,4 +60,7 @@
public Object parseLevel(String levelName);
public String getLevelName(Object level);
+
+ // return the logging property
+ public String getProperty(String key);
}
diff -r 3db1444f8ac8 -r 5cf29386a520 jdk/src/share/classes/sun/util/logging/LoggingSupport.java
--- a/jdk/src/share/classes/sun/util/logging/LoggingSupport.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/src/share/classes/sun/util/logging/LoggingSupport.java Thu Mar 31 22:07:32 2011 -0700
@@ -29,6 +29,7 @@
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 @@
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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/src/share/classes/sun/util/logging/PlatformLogger.java
--- a/jdk/src/share/classes/sun/util/logging/PlatformLogger.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/src/share/classes/sun/util/logging/PlatformLogger.java Thu Mar 31 22:07:32 2011 -0700
@@ -316,12 +316,6 @@
*/
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 @@
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 @@
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 @@
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 @@
}
}
+ 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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/src/share/lib/logging.properties
--- a/jdk/src/share/lib/logging.properties Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/src/share/lib/logging.properties Thu Mar 31 22:07:32 2011 -0700
@@ -43,6 +43,11 @@
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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/src/solaris/bin/arm/jvm.cfg
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/solaris/bin/arm/jvm.cfg Thu Mar 31 22:07:32 2011 -0700
@@ -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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/src/solaris/bin/ppc/jvm.cfg
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/solaris/bin/ppc/jvm.cfg Thu Mar 31 22:07:32 2011 -0700
@@ -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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/src/solaris/classes/sun/awt/X11/XToolkit.java
--- a/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java Thu Mar 31 22:07:32 2011 -0700
@@ -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 @@
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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/src/solaris/classes/sun/awt/X11/XTrayIconPeer.java
--- a/jdk/src/solaris/classes/sun/awt/X11/XTrayIconPeer.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/src/solaris/classes/sun/awt/X11/XTrayIconPeer.java Thu Mar 31 22:07:32 2011 -0700
@@ -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 @@
// 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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/src/solaris/native/java/lang/java_props_md.c
--- a/jdk/src/solaris/native/java/lang/java_props_md.c Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/src/solaris/native/java/lang/java_props_md.c Thu Mar 31 22:07:32 2011 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 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
@@ -55,6 +55,11 @@
#endif
#endif
+#ifdef JAVASE_EMBEDDED
+#include
+#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 @@
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 @@
/* 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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/src/solaris/native/sun/awt/jawt.c
--- a/jdk/src/solaris/native/sun/awt/jawt.c Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/src/solaris/native/sun/awt/jawt.c Thu Mar 31 22:07:32 2011 -0700
@@ -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 @@
}
return JNI_TRUE;
+#endif
}
diff -r 3db1444f8ac8 -r 5cf29386a520 jdk/src/solaris/native/sun/xawt/XToolkit.c
--- a/jdk/src/solaris/native/sun/xawt/XToolkit.c Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/src/solaris/native/sun/xawt/XToolkit.c Thu Mar 31 22:07:32 2011 -0700
@@ -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
@@ -112,6 +112,21 @@
/*
* 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
* Signature: ()J
*/
@@ -340,15 +355,34 @@
#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 @@
*/
static void readEnv() {
char * value;
+ int tmp_poll_alg;
static Boolean env_read = False;
if (env_read) return;
@@ -451,6 +486,23 @@
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 @@
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 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);
- 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;
- // Adjust timeout to flush_time and task_time
- return min(flushTimeout, min(taskTimeout, timeout));
-} /* awt_get_poll_timeout() */
+ case AWT_POLL_FALSE:
+ ret_timeout = (nextTaskTime > curTime) ?
+ (nextTaskTime - curTime) :
+ ((nextTaskTime == -1) ? -1 : 0);
+ break;
+ }
+
+ return ret_timeout;
+
+} /* get_poll_timeout() */
/*
* Waits for X/Xt events to appear on the pipe. Returns only when
@@ -598,6 +686,8 @@
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 @@
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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/src/windows/native/java/net/Inet6AddressImpl.c
--- a/jdk/src/windows/native/java/net/Inet6AddressImpl.c Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/src/windows/native/java/net/Inet6AddressImpl.c Thu Mar 31 22:07:32 2011 -0700
@@ -90,6 +90,7 @@
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 @@
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) {
- JNU_ReleaseStringPlatformChars(env, host, hostname);
- return NULL;
- }
+ if (ia_preferIPv6AddressID == NULL) {
+ jclass c = (*env)->FindClass(env,"java/net/InetAddress");
+ if (c) {
+ ia_preferIPv6AddressID =
+ (*env)->GetStaticFieldID(env, c, "preferIPv6Address", "Z");
}
- /* 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;
-
- error = (*getaddrinfo_ptr)(hostname, NULL, &hints, &res);
-
- if (error) {
- /* report error */
- JNU_ThrowByName(env, JNU_JAVANETPKG "UnknownHostException",
- (char *)hostname);
+ if (ia_preferIPv6AddressID == NULL) {
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;
+ }
+ }
+ /* 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;
+
+ error = getaddrinfo(hostname, NULL, &hints, &res);
- 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;
+ 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;
}
}
- } 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;
- }
-
- if (!skip) {
- struct addrinfo *next
- = (struct addrinfo*) malloc(sizeof(struct addrinfo));
- if (!next) {
- JNU_ThrowOutOfMemoryError(env, "heap allocation failed");
- ret = NULL;
- goto cleanupAndReturn;
+ if (t < 16) {
+ itr = itr->ai_next;
+ continue;
+ } else {
+ skip = 1;
+ break;
+ }
}
- 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 ++;
- }
+ } else if (iterator->ai_family != AF_INET &&
+ iterator->ai_family != AF_INET6) {
+ /* we can't handle other family types */
+ skip = 1;
+ break;
}
- 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 @@
JNU_ReleaseStringPlatformChars(env, host, hostname);
}
- if (NET_addrtransAvailable())
- (*freeaddrinfo_ptr)(res);
+ freeaddrinfo(res);
return ret;
}
@@ -312,44 +309,41 @@
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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/src/windows/native/java/net/NetworkInterface.c
--- a/jdk/src/windows/native/java/net/NetworkInterface.c Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/src/windows/native/java/net/NetworkInterface.c Thu Mar 31 22:07:32 2011 -0700
@@ -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 @@
*/
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 @@
/*
* 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 @@
* 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 @@
*/
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 @@
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 @@
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 @@
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 @@
* 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 @@
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 @@
* 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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
(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 @@
* 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 @@
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_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 @@
* 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 @@
* 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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/src/windows/native/java/net/NetworkInterface.h
--- a/jdk/src/windows/native/java/net/NetworkInterface.h Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/src/windows/native/java/net/NetworkInterface.h Thu Mar 31 22:07:32 2011 -0700
@@ -87,338 +87,6 @@
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;
+int enumInterfaces(JNIEnv *env, netif **netifPP);
#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
-
-#endif
diff -r 3db1444f8ac8 -r 5cf29386a520 jdk/src/windows/native/java/net/NetworkInterface_win9x.c
--- a/jdk/src/windows/native/java/net/NetworkInterface_win9x.c Thu Mar 31 18:14:17 2011 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/src/windows/native/java/net/NetworkInterface_winXP.c
--- a/jdk/src/windows/native/java/net/NetworkInterface_winXP.c Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/src/windows/native/java/net/NetworkInterface_winXP.c Thu Mar 31 22:07:32 2011 -0700
@@ -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 @@
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 @@
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 @@
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 @@
* 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 @@
* (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 @@
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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/src/windows/native/java/net/net_util_md.c
--- a/jdk/src/windows/native/java/net/net_util_md.c Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/src/windows/native/java/net/net_util_md.c Thu Mar 31 22:07:32 2011 -0700
@@ -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 @@
jint IPv6_supported()
{
- HMODULE lib;
- int fd = socket(AF_INET6, SOCK_STREAM, 0) ;
- if (fd < 0) {
- return JNI_FALSE;
- }
- closesocket (fd);
-
- if ((lib = LoadLibrary ("ws2_32.dll")) == NULL) {
+ SOCKET s = socket(AF_INET6, SOCK_STREAM, 0) ;
+ if (s == INVALID_SOCKET) {
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
(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 @@
}
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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/src/windows/native/java/net/net_util_md.h
--- a/jdk/src/windows/native/java/net/net_util_md.h Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/src/windows/native/java/net/net_util_md.h Thu Mar 31 22:07:32 2011 -0700
@@ -209,10 +209,6 @@
);
#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_ThrowSocketException(JNIEnv *env, char* msg);
-jboolean NET_addrtransAvailable();
-
/*
* differs from NET_Timeout() as follows:
*
diff -r 3db1444f8ac8 -r 5cf29386a520 jdk/src/windows/native/sun/net/dns/ResolverConfigurationImpl.c
--- a/jdk/src/windows/native/sun/net/dns/ResolverConfigurationImpl.c Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/src/windows/native/sun/net/dns/ResolverConfigurationImpl.c Thu Mar 31 22:07:32 2011 -0700
@@ -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 @@
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 @@
* 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 @@
*/
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 @@
/*
- * 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 @@
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 @@
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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/src/windows/native/sun/net/www/protocol/http/ntlm/NTLMAuthSequence.c
--- a/jdk/src/windows/native/sun/net/www/protocol/http/ntlm/NTLMAuthSequence.c Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/src/windows/native/sun/net/www/protocol/http/ntlm/NTLMAuthSequence.c Thu Mar 31 22:07:32 2011 -0700
@@ -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 @@
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 @@
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 @@
pAuthId = NULL;
}
- ss = pAcquireCredentialsHandle(
+ ss = AcquireCredentialsHandleA(
NULL, "NTLM", SECPKG_CRED_OUTBOUND,
NULL, pAuthId, NULL, NULL,
pCred, <ime
@@ -258,7 +206,7 @@
* 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 @@
}
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 @@
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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/test/Makefile
--- a/jdk/test/Makefile Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/test/Makefile Thu Mar 31 22:07:32 2011 -0700
@@ -261,6 +261,7 @@
# 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 @@
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 @@
# 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 @@
($(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 @@
# 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 @@
# 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 @@
################################################################
-# perftest to collect statistics
+# perftest to collect statistics
# Expect JPRT to set JPRT_PACKTEST_HOME.
PERFTEST_HOME = $(TEST_ROOT)/perf
@@ -706,7 +709,7 @@
# 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 @@
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 @@
# 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
+
+# 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
+
+# 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
-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
+# 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)
-jck7runtime: JCK7_HOME=$(JCK7RUNTIME_HOME)
-jck7runtime: JCK_BUNDLE_NAME=runtime
-jck7runtime: jck7_tests
-
-jck7runtime_lang: JCK_BUNDLE_TESTDIRS=lang
-jck7runtime_lang: jck7runtime
+# JCK7 compiler tests
+jck7compiler:
+ $(MAKE) UNIQUE_DIR=$@ \
+ JCK_HOME=$(JCK7COMPILER_HOME) \
+ TESTDIRS="$(JCK_COMPILER_TESTS)" \
+ _generic_jck_tests
-jck7devtools: JCK7_HOME=$(JCK7DEVTOOLS_HOME)
-jck7devtools: JCK_BUNDLE_NAME=devtools
-jck7devtools: jck7_tests
+# JCK7 runtime tests
+jck7runtime:
+ $(MAKE) UNIQUE_DIR=$@ \
+ JCK_HOME=$(JCK7RUNTIME_HOME) \
+ TESTDIRS="$(JCK_RUNTIME_TESTS)" \
+ _generic_jck_tests
-jck7devtools_lang: JCK_BUNDLE_TESTDIRS=lang
-jck7devtools_lang: jck7devtools
+# JCK7 devtools tests
+jck7devtools:
+ $(MAKE) UNIQUE_DIR=$@ \
+ JCK_HOME=$(JCK7DEVTOOLS_HOME) \
+ TESTDIRS="$(JCK_DEVTOOLS_TESTS)" \
+ _generic_jck_tests
-PHONY_LIST += jck7compiler jck7runtime jck7devtools jck7_tests \
- jck7compiler_lang jck7runtime_lang jck7devtools_lang
+# Run all 3 sets of JCK7 tests
+jck_all: jck7runtime jck7devtools jck7compiler
+
+PHONY_LIST += jck_all _generic_jck_tests \
+ jck7compiler jck7runtime jck7devtools
################################################################
diff -r 3db1444f8ac8 -r 5cf29386a520 jdk/test/ProblemList.txt
--- a/jdk/test/ProblemList.txt Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/test/ProblemList.txt Thu Mar 31 22:07:32 2011 -0700
@@ -690,6 +690,9 @@
# jdk_util
+# Filed 7027061
+java/util/Locale/Bug6989440.java windows-all
+
# Filed 6933803
java/util/concurrent/ThreadPoolExecutor/CoreThreadTimeOut.java generic-all
diff -r 3db1444f8ac8 -r 5cf29386a520 jdk/test/com/sun/jdi/PrivateTransportTest.sh
--- a/jdk/test/com/sun/jdi/PrivateTransportTest.sh Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/test/com/sun/jdi/PrivateTransportTest.sh Thu Mar 31 22:07:32 2011 -0700
@@ -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 @@
libdir=${TESTCLASSES}
+is_windows=false
+is_cygwin=false
case `uname -s` in
SunOS)
libarch=`uname -p`
@@ -126,10 +128,13 @@
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 @@
#
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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/test/java/lang/Throwable/SuppressedExceptions.java
--- a/jdk/test/java/lang/Throwable/SuppressedExceptions.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/test/java/lang/Throwable/SuppressedExceptions.java Thu Mar 31 22:07:32 2011 -0700
@@ -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 @@
/*
* @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 @@
} 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 @@
(byte)0x02, (byte)0x00, (byte)0x00, (byte)0x78, (byte)0x70,
};
- ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
- ObjectInputStream ois = new ObjectInputStream(bais);
+ try(ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+ ObjectInputStream ois = new ObjectInputStream(bais)) {
+ Object o = ois.readObject();
+ Throwable throwable = (Throwable) o;
- 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 @@
}
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 @@
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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/test/java/lang/annotation/PackageMain.java
--- a/jdk/test/java/lang/annotation/PackageMain.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/test/java/lang/annotation/PackageMain.java Thu Mar 31 22:07:32 2011 -0700
@@ -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 @@
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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/test/java/lang/annotation/package-info.java
--- a/jdk/test/java/lang/annotation/package-info.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/test/java/lang/annotation/package-info.java Thu Mar 31 22:07:32 2011 -0700
@@ -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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/test/java/lang/management/BufferPoolMXBean/Basic.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/management/BufferPoolMXBean/Basic.java Thu Mar 31 22:07:32 2011 -0700
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+ * @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.file.Path;
+import java.nio.file.Files;
+import static java.nio.file.StandardOpenOption.*;
+import java.nio.channels.FileChannel;
+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 {
+
+ // static fields to ensure buffers aren't GC'ed
+ static List buffers;
+ static MappedByteBuffer mbb;
+
+ // check counters
+ static void check(List pools,
+ int minBufferCount,
+ long minTotalCapacity)
+ {
+ int bufferCount = 0;
+ long totalCap = 0;
+ long totalMem = 0;
+ for (BufferPoolMXBean pool: pools) {
+ bufferCount += pool.getCount();
+ totalCap += pool.getTotalCapacity();
+ totalMem += pool.getMemoryUsed();
+ }
+ if (bufferCount < minBufferCount)
+ throw new RuntimeException("Count less than expected");
+ if (totalMem < minTotalCapacity)
+ throw new RuntimeException("Memory usage less than expected");
+ if (totalCap < minTotalCapacity)
+ throw new RuntimeException("Total capacity less than expected");
+ }
+
+ public static void main(String[] args) throws Exception {
+ Random rand = new Random();
+
+ // allocate a few direct buffers
+ int bufferCount = 5 + rand.nextInt(20);
+ buffers = new ArrayList(bufferCount);
+ long totalCapacity = 0L;
+ for (int i=0; i pools =
+ ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class);
+ check(pools, bufferCount, totalCapacity);
+
+ // use MBeanServer
+ MBeanServer server = ManagementFactory.getPlatformMBeanServer();
+ Set mbeans = server.queryNames(
+ new ObjectName("java.nio:type=BufferPool,*"), null);
+ pools = new ArrayList();
+ for (ObjectName name: mbeans) {
+ BufferPoolMXBean pool = ManagementFactory
+ .newPlatformMXBeanProxy(server, name.toString(), BufferPoolMXBean.class);
+ 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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/test/java/lang/management/ManagementFactory/GetPlatformMXBeans.java
--- a/jdk/test/java/lang/management/ManagementFactory/GetPlatformMXBeans.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/test/java/lang/management/ManagementFactory/GetPlatformMXBeans.java Thu Mar 31 22:07:32 2011 -0700
@@ -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 @@
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 @@
}
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
+ 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");
}
- // verify platform MXBeans in the platform MBeanServer
- mxbeans = getPlatformMXBeans(platformMBeanServer, mxbeanInterface);
+ 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 @@
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 @@
+ 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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/test/java/lang/management/PlatformLoggingMXBean/LoggingMXBeanTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/management/PlatformLoggingMXBean/LoggingMXBeanTest.java Thu Mar 31 22:07:32 2011 -0700
@@ -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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/test/java/lang/management/PlatformLoggingMXBean/PlatformLoggingMXBeanTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/management/PlatformLoggingMXBean/PlatformLoggingMXBeanTest.java Thu Mar 31 22:07:32 2011 -0700
@@ -0,0 +1,276 @@
+/*
+ * Copyright (c) 2003, 2004, 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 6876135 7024172
+ *
+ * @summary Test PlatformLoggingMXBean
+ * This test performs similar testing as
+ * java/util/logging/LoggingMXBeanTest.
+ *
+ * @build PlatformLoggingMXBeanTest
+ * @run main PlatformLoggingMXBeanTest
+ */
+
+import javax.management.*;
+import java.lang.management.ManagementFactory;
+import java.lang.management.PlatformLoggingMXBean;
+import java.util.logging.*;
+import java.util.List;
+
+public class PlatformLoggingMXBeanTest
+{
+
+ ObjectName objectName = null;
+ static String LOGGER_NAME_1 = "com.sun.management.Logger1";
+ static String LOGGER_NAME_2 = "com.sun.management.Logger2";
+
+ public PlatformLoggingMXBeanTest() throws Exception {
+ }
+
+ private void runTest(PlatformLoggingMXBean mBean) throws Exception {
+
+ /*
+ * Create the MBeanServeri, register the PlatformLoggingMXBean
+ */
+ System.out.println( "***************************************************" );
+ System.out.println( "********** PlatformLoggingMXBean Unit Test **********" );
+ System.out.println( "***************************************************" );
+ System.out.println( "" );
+ System.out.println( "*******************************" );
+ System.out.println( "*********** Phase 1 ***********" );
+ System.out.println( "*******************************" );
+ System.out.println( " Creating MBeanServer " );
+ System.out.print( " Register PlatformLoggingMXBean: " );
+ MBeanServer mbs = MBeanServerFactory.createMBeanServer();
+ String[] list = new String[0];
+
+ try {
+ objectName = new ObjectName(LogManager.LOGGING_MXBEAN_NAME);
+ mbs.registerMBean( mBean, objectName );
+ }
+ catch ( Exception e ) {
+ System.out.println( "FAILED" );
+ throw e;
+ }
+ System.out.println( "PASSED" );
+ System.out.println("");
+
+ /*
+ * Access our MBean to get the current list of Loggers
+ */
+ System.out.println( "*******************************" );
+ System.out.println( "*********** Phase 2 ***********" );
+ System.out.println( "*******************************" );
+ System.out.println( " Test Logger Name retrieval (getLoggerNames) " );
+ // check that Level object are returned properly
+ try {
+ list = (String[]) mbs.getAttribute( objectName, "LoggerNames" );
+ }
+ catch ( Exception e ) {
+ System.out.println(" : FAILED" );
+ throw e;
+ }
+
+ /*
+ * Dump the list of Loggers already present, if any
+ */
+ Object[] params = new Object[1];
+ String[] signature = new String[1];
+ Level l;
+
+ if ( list == null ) {
+ System.out.println(" : PASSED. No Standard Loggers Present" );
+ System.out.println("");
+ }
+ else {
+ System.out.println(" : PASSED. There are " + list.length + " Loggers Present" );
+ System.out.println("");
+ System.out.println( "*******************************" );
+ System.out.println( "*********** Phase 2B **********" );
+ System.out.println( "*******************************" );
+ System.out.println( " Examine Existing Loggers" );
+ for ( int i = 0; i < list.length; i++ ) {
+ try {
+ params[0] = list[i];
+ signature[0] = "java.lang.String";
+ String levelName = (String) mbs.invoke( objectName, "getLoggerLevel", params, signature );
+ System.out.println(" : Logger #" + i + " = " + list[i] );
+ System.out.println(" : Level = " + levelName );
+ }
+ catch ( Exception e ) {
+ System.out.println(" : FAILED" );
+ throw e;
+ }
+ }
+ System.out.println(" : PASSED" );
+ }
+
+ /*
+ * Create two new loggers to the list of Loggers already present
+ */
+ System.out.println("");
+ System.out.println( "*******************************" );
+ System.out.println( "*********** Phase 3 ***********" );
+ System.out.println( "*******************************" );
+ System.out.println( " Create and test new Loggers" );
+ Logger logger1 = Logger.getLogger( LOGGER_NAME_1 );
+ Logger logger2 = Logger.getLogger( LOGGER_NAME_2 );
+
+ // check that Level object are returned properly
+ try {
+ list = (String[]) mbs.getAttribute( objectName, "LoggerNames" );
+ }
+ catch ( Exception e ) {
+ System.out.println(" : FAILED" );
+ throw e;
+ }
+
+ /*
+ * Check for the existence of our new Loggers
+ */
+ boolean log1 = false, log2 = false;
+
+ if ( list == null || list.length < 2 ) {
+ System.out.println(" : FAILED. Could not Detect the presense of the new Loggers" );
+ throw new RuntimeException(
+ "Could not Detect the presense of the new Loggers");
+ }
+ else {
+ for ( int i = 0; i < list.length; i++ ) {
+ if ( list[i].equals( LOGGER_NAME_1 ) ) {
+ log1 = true;
+ System.out.println( " : Found new Logger : " + list[i] );
+ }
+ if ( list[i].equals( LOGGER_NAME_2 ) ) {
+ log2 = true;
+ System.out.println( " : Found new Logger : " + list[i] );
+ }
+ }
+ 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");
+ }
+ }
+
+ /*
+ * Set a new Logging levels and check that it succeeded
+ */
+ System.out.println("");
+ System.out.println( "*******************************" );
+ System.out.println( "*********** Phase 4 ***********" );
+ System.out.println( "*******************************" );
+ System.out.println( " Set and Check the Logger Level" );
+ log1 = false;
+ log2 = false;
+ try {
+ // Set the level of logger1 to ALL
+ params = new Object[2];
+ signature = new String[2];
+ params[0] = LOGGER_NAME_1;
+ params[1] = Level.ALL.getName();
+ signature[0] = "java.lang.String";
+ signature[1] = "java.lang.String";
+ mbs.invoke( objectName, "setLoggerLevel", params, signature );
+
+ // Set the level of logger2 to FINER
+ params[0] = LOGGER_NAME_2;
+ params[1] = Level.FINER.getName();
+ mbs.invoke( objectName, "setLoggerLevel", params, signature );
+
+ // Okay read back the Level from Logger1. Should be ALL
+ params = new Object[1];
+ signature = new String[1];
+ params[0] = LOGGER_NAME_1;
+ signature[0] = "java.lang.String";
+ String levelName = (String) mbs.invoke( objectName, "getLoggerLevel", params, signature );
+ l = Level.parse(levelName);
+ System.out.print(" Logger1: " );
+ if ( l.equals( l.ALL ) ) {
+ System.out.println("Level Set to ALL: PASSED" );
+ log1 = true;
+ }
+ else {
+ System.out.println("Level Set to ALL: FAILED" );
+ throw new RuntimeException(
+ "Level Set to ALL but returned " + l.toString());
+ }
+
+ // Okay read back the Level from Logger2. Should be FINER
+ params = new Object[1];
+ signature = new String[1];
+ params[0] = LOGGER_NAME_2;
+ signature[0] = "java.lang.String";
+ levelName = (String) mbs.invoke( objectName, "getLoggerLevel", params, signature );
+ l = Level.parse(levelName);
+ System.out.print(" Logger2: " );
+ if ( l.equals( l.FINER ) ) {
+ System.out.println("Level Set to FINER: PASSED" );
+ log2 = true;
+ }
+ else {
+ System.out.println("Level Set to FINER: FAILED" );
+ throw new RuntimeException(
+ "Level Set to FINER but returned " + l.toString());
+ }
+ }
+ catch ( Exception e ) {
+ throw e;
+ }
+
+ System.out.println( "" );
+ System.out.println( "***************************************************" );
+ System.out.println( "***************** All Tests Passed ****************" );
+ System.out.println( "***************************************************" );
+ }
+
+ public static void main(String[] argv) throws Exception {
+ 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);
+ }
+
+ // 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.lang.management.PlatformLoggingMXBean") ||
+ !platformMBS.isInstanceOf(objName, "java.util.logging.LoggingMXBean")) {
+ throw new RuntimeException(objName + " is of unexpected type");
+ }
+
+ // test if PlatformLoggingMXBean works properly in a MBeanServer
+ PlatformLoggingMXBeanTest test = new PlatformLoggingMXBeanTest();
+ test.runTest(mbean);
+ }
+}
diff -r 3db1444f8ac8 -r 5cf29386a520 jdk/test/java/nio/BufferPoolMXBean/Basic.java
--- a/jdk/test/java/nio/BufferPoolMXBean/Basic.java Thu Mar 31 18:14:17 2011 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,107 +0,0 @@
-/*
- * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/* @test
- * @bug 6606598
- * @summary Unit test for java.nio.BufferPoolMXBean
- * @run main/othervm Basic
- */
-
-import java.nio.ByteBuffer;
-import java.nio.MappedByteBuffer;
-import java.nio.BufferPoolMXBean;
-import java.nio.channels.FileChannel;
-import java.io.File;
-import java.io.RandomAccessFile;
-import java.lang.management.ManagementFactory;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import java.util.*;
-
-public class Basic {
-
- // static fields to ensure buffers aren't GC'ed
- static List buffers;
- static MappedByteBuffer mbb;
-
- // check counters
- static void check(List pools,
- int minBufferCount,
- long minTotalCapacity)
- {
- int bufferCount = 0;
- long totalCap = 0;
- long totalMem = 0;
- for (BufferPoolMXBean pool: pools) {
- bufferCount += pool.getCount();
- totalCap += pool.getTotalCapacity();
- totalMem += pool.getMemoryUsed();
- }
- if (bufferCount < minBufferCount)
- throw new RuntimeException("Count less than expected");
- if (totalMem < minTotalCapacity)
- throw new RuntimeException("Memory usage less than expected");
- if (totalCap < minTotalCapacity)
- throw new RuntimeException("Total capacity less than expected");
- }
-
- public static void main(String[] args) throws Exception {
- Random rand = new Random();
-
- // allocate a few direct buffers
- int bufferCount = 5 + rand.nextInt(20);
- buffers = new ArrayList(bufferCount);
- long totalCapacity = 0L;
- for (int i=0; i pools =
- ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class);
- check(pools, bufferCount, totalCapacity);
-
- // using MBeanServer
- MBeanServer server = ManagementFactory.getPlatformMBeanServer();
- Set mbeans = server.queryNames(
- new ObjectName("java.nio:type=BufferPool,*"), null);
- pools = new ArrayList();
- for (ObjectName name: mbeans) {
- BufferPoolMXBean pool = ManagementFactory
- .newPlatformMXBeanProxy(server, name.toString(), BufferPoolMXBean.class);
- pools.add(pool);
- }
- check(pools, bufferCount, totalCapacity);
- }
-}
diff -r 3db1444f8ac8 -r 5cf29386a520 jdk/test/java/nio/channels/AsynchronousSocketChannel/Leaky.java
--- a/jdk/test/java/nio/channels/AsynchronousSocketChannel/Leaky.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/test/java/nio/channels/AsynchronousSocketChannel/Leaky.java Thu Mar 31 22:07:32 2011 -0700
@@ -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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/test/java/util/jar/JarFile/MevNPE.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/jar/JarFile/MevNPE.java Thu Mar 31 22:07:32 2011 -0700
@@ -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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/test/java/util/logging/PlatformLoggingMXBean/PlatformLoggingMXBeanTest.java
--- a/jdk/test/java/util/logging/PlatformLoggingMXBean/PlatformLoggingMXBeanTest.java Thu Mar 31 18:14:17 2011 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,279 +0,0 @@
-/*
- * Copyright (c) 2003, 2004, 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 6876135
- *
- * @summary Test PlatformLoggingMXBean
- * This test performs similar testing as LoggingMXBeanTest.
- *
- * @build PlatformLoggingMXBeanTest
- * @run main PlatformLoggingMXBeanTest
- */
-
-import javax.management.*;
-import java.lang.management.ManagementFactory;
-import java.util.logging.*;
-import java.util.List;
-
-public class PlatformLoggingMXBeanTest
-{
-
- ObjectName objectName = null;
- static String LOGGER_NAME_1 = "com.sun.management.Logger1";
- static String LOGGER_NAME_2 = "com.sun.management.Logger2";
-
- public PlatformLoggingMXBeanTest() throws Exception {
- }
-
- private void runTest(PlatformLoggingMXBean mBean) throws Exception {
-
- /*
- * Create the MBeanServeri, register the PlatformLoggingMXBean
- */
- System.out.println( "***************************************************" );
- System.out.println( "********** PlatformLoggingMXBean Unit Test **********" );
- System.out.println( "***************************************************" );
- System.out.println( "" );
- System.out.println( "*******************************" );
- System.out.println( "*********** Phase 1 ***********" );
- System.out.println( "*******************************" );
- System.out.println( " Creating MBeanServer " );
- System.out.print( " Register PlatformLoggingMXBean: " );
- MBeanServer mbs = MBeanServerFactory.createMBeanServer();
- String[] list = new String[0];
-
- try {
- objectName = new ObjectName(LogManager.LOGGING_MXBEAN_NAME);
- mbs.registerMBean( mBean, objectName );
- }
- catch ( Exception e ) {
- System.out.println( "FAILED" );
- throw e;
- }
- System.out.println( "PASSED" );
- System.out.println("");
-
- /*
- * Access our MBean to get the current list of Loggers
- */
- System.out.println( "*******************************" );
- System.out.println( "*********** Phase 2 ***********" );
- System.out.println( "*******************************" );
- System.out.println( " Test Logger Name retrieval (getLoggerNames) " );
- // check that Level object are returned properly
- try {
- list = (String[]) mbs.getAttribute( objectName, "LoggerNames" );
- }
- catch ( Exception e ) {
- System.out.println(" : FAILED" );
- throw e;
- }
-
- /*
- * Dump the list of Loggers already present, if any
- */
- Object[] params = new Object[1];
- String[] signature = new String[1];
- Level l;
-
- if ( list == null ) {
- System.out.println(" : PASSED. No Standard Loggers Present" );
- System.out.println("");
- }
- else {
- System.out.println(" : PASSED. There are " + list.length + " Loggers Present" );
- System.out.println("");
- System.out.println( "*******************************" );
- System.out.println( "*********** Phase 2B **********" );
- System.out.println( "*******************************" );
- System.out.println( " Examine Existing Loggers" );
- for ( int i = 0; i < list.length; i++ ) {
- try {
- params[0] = list[i];
- signature[0] = "java.lang.String";
- String levelName = (String) mbs.invoke( objectName, "getLoggerLevel", params, signature );
- System.out.println(" : Logger #" + i + " = " + list[i] );
- System.out.println(" : Level = " + levelName );
- }
- catch ( Exception e ) {
- System.out.println(" : FAILED" );
- throw e;
- }
- }
- System.out.println(" : PASSED" );
- }
-
- /*
- * Create two new loggers to the list of Loggers already present
- */
- System.out.println("");
- System.out.println( "*******************************" );
- System.out.println( "*********** Phase 3 ***********" );
- System.out.println( "*******************************" );
- System.out.println( " Create and test new Loggers" );
- Logger logger1 = Logger.getLogger( LOGGER_NAME_1 );
- Logger logger2 = Logger.getLogger( LOGGER_NAME_2 );
-
- // check that Level object are returned properly
- try {
- list = (String[]) mbs.getAttribute( objectName, "LoggerNames" );
- }
- catch ( Exception e ) {
- System.out.println(" : FAILED" );
- throw e;
- }
-
- /*
- * Check for the existence of our new Loggers
- */
- boolean log1 = false, log2 = false;
-
- if ( list == null || list.length < 2 ) {
- System.out.println(" : FAILED. Could not Detect the presense of the new Loggers" );
- throw new RuntimeException(
- "Could not Detect the presense of the new Loggers");
- }
- else {
- for ( int i = 0; i < list.length; i++ ) {
- if ( list[i].equals( LOGGER_NAME_1 ) ) {
- log1 = true;
- System.out.println( " : Found new Logger : " + list[i] );
- }
- if ( list[i].equals( LOGGER_NAME_2 ) ) {
- log2 = true;
- System.out.println( " : Found new Logger : " + list[i] );
- }
- }
- 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");
- }
- }
-
- /*
- * Set a new Logging levels and check that it succeeded
- */
- System.out.println("");
- System.out.println( "*******************************" );
- System.out.println( "*********** Phase 4 ***********" );
- System.out.println( "*******************************" );
- System.out.println( " Set and Check the Logger Level" );
- log1 = false;
- log2 = false;
- try {
- // Set the level of logger1 to ALL
- params = new Object[2];
- signature = new String[2];
- params[0] = LOGGER_NAME_1;
- params[1] = Level.ALL.getName();
- signature[0] = "java.lang.String";
- signature[1] = "java.lang.String";
- mbs.invoke( objectName, "setLoggerLevel", params, signature );
-
- // Set the level of logger2 to FINER
- params[0] = LOGGER_NAME_2;
- params[1] = Level.FINER.getName();
- mbs.invoke( objectName, "setLoggerLevel", params, signature );
-
- // Okay read back the Level from Logger1. Should be ALL
- params = new Object[1];
- signature = new String[1];
- params[0] = LOGGER_NAME_1;
- signature[0] = "java.lang.String";
- String levelName = (String) mbs.invoke( objectName, "getLoggerLevel", params, signature );
- l = Level.parse(levelName);
- System.out.print(" Logger1: " );
- if ( l.equals( l.ALL ) ) {
- System.out.println("Level Set to ALL: PASSED" );
- log1 = true;
- }
- else {
- System.out.println("Level Set to ALL: FAILED" );
- throw new RuntimeException(
- "Level Set to ALL but returned " + l.toString());
- }
-
- // Okay read back the Level from Logger2. Should be FINER
- params = new Object[1];
- signature = new String[1];
- params[0] = LOGGER_NAME_2;
- signature[0] = "java.lang.String";
- levelName = (String) mbs.invoke( objectName, "getLoggerLevel", params, signature );
- l = Level.parse(levelName);
- System.out.print(" Logger2: " );
- if ( l.equals( l.FINER ) ) {
- System.out.println("Level Set to FINER: PASSED" );
- log2 = true;
- }
- else {
- System.out.println("Level Set to FINER: FAILED" );
- throw new RuntimeException(
- "Level Set to FINER but returned " + l.toString());
- }
- }
- catch ( Exception e ) {
- throw e;
- }
-
- System.out.println( "" );
- System.out.println( "***************************************************" );
- System.out.println( "***************** All Tests Passed ****************" );
- System.out.println( "***************************************************" );
- }
-
- 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);
- ObjectName objname = mbean.getObjectName();
- if (!objname.equals(new ObjectName(LogManager.LOGGING_MXBEAN_NAME))) {
- throw new RuntimeException("Invalid ObjectName " + objname);
- }
-
- // 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") ||
- !platformMBS.isInstanceOf(objName, "java.util.logging.LoggingMXBean")) {
- throw new RuntimeException(objName + " is of unexpected type");
- }
-
- // test if PlatformLoggingMXBean works properly in a MBeanServer
- PlatformLoggingMXBeanTest test = new PlatformLoggingMXBeanTest();
- test.runTest(mbean);
- }
-}
diff -r 3db1444f8ac8 -r 5cf29386a520 jdk/test/java/util/logging/SimpleFormatterFormat.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/logging/SimpleFormatterFormat.java Thu Mar 31 22:07:32 2011 -0700
@@ -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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/test/sun/misc/Version/Version.java
--- a/jdk/test/sun/misc/Version/Version.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/test/sun/misc/Version/Version.java Thu Mar 31 22:07:32 2011 -0700
@@ -142,15 +142,21 @@
// 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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/test/sun/security/ec/TestEC.java
--- a/jdk/test/sun/security/ec/TestEC.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/test/sun/security/ec/TestEC.java Thu Mar 31 22:07:32 2011 -0700
@@ -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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/test/sun/security/jgss/GssNPE.java
--- a/jdk/test/sun/security/jgss/GssNPE.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/test/sun/security/jgss/GssNPE.java Thu Mar 31 22:07:32 2011 -0700
@@ -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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/test/sun/security/jgss/spnego/NoSpnegoAsDefMech.java
--- a/jdk/test/sun/security/jgss/spnego/NoSpnegoAsDefMech.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/test/sun/security/jgss/spnego/NoSpnegoAsDefMech.java Thu Mar 31 22:07:32 2011 -0700
@@ -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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/test/sun/security/krb5/ConfPlusProp.java
--- a/jdk/test/sun/security/krb5/ConfPlusProp.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/test/sun/security/krb5/ConfPlusProp.java Thu Mar 31 22:07:32 2011 -0700
@@ -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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/test/sun/security/krb5/ConfigWithQuotations.java
--- a/jdk/test/sun/security/krb5/ConfigWithQuotations.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/test/sun/security/krb5/ConfigWithQuotations.java Thu Mar 31 22:07:32 2011 -0700
@@ -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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/test/sun/security/krb5/DnsFallback.java
--- a/jdk/test/sun/security/krb5/DnsFallback.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/test/sun/security/krb5/DnsFallback.java Thu Mar 31 22:07:32 2011 -0700
@@ -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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/test/sun/security/krb5/IPv6.java
--- a/jdk/test/sun/security/krb5/IPv6.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/test/sun/security/krb5/IPv6.java Thu Mar 31 22:07:32 2011 -0700
@@ -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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/test/sun/security/krb5/ParseCAPaths.java
--- a/jdk/test/sun/security/krb5/ParseCAPaths.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/test/sun/security/krb5/ParseCAPaths.java Thu Mar 31 22:07:32 2011 -0700
@@ -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 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 @@
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 @@
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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/test/sun/security/krb5/ParseConfig.java
--- a/jdk/test/sun/security/krb5/ParseConfig.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/test/sun/security/krb5/ParseConfig.java Thu Mar 31 22:07:32 2011 -0700
@@ -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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/test/sun/security/krb5/RFC396xTest.java
--- a/jdk/test/sun/security/krb5/RFC396xTest.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/test/sun/security/krb5/RFC396xTest.java Thu Mar 31 22:07:32 2011 -0700
@@ -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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/test/sun/security/krb5/TimeInCCache.java
--- a/jdk/test/sun/security/krb5/TimeInCCache.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/test/sun/security/krb5/TimeInCCache.java Thu Mar 31 22:07:32 2011 -0700
@@ -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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/test/sun/security/krb5/auto/HttpNegotiateServer.java
--- a/jdk/test/sun/security/krb5/auto/HttpNegotiateServer.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/test/sun/security/krb5/auto/HttpNegotiateServer.java Thu Mar 31 22:07:32 2011 -0700
@@ -74,11 +74,10 @@
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 @@
// 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 @@
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 @@
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 @@
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 @@
* @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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/test/sun/security/krb5/etype/ETypeOrder.java
--- a/jdk/test/sun/security/krb5/etype/ETypeOrder.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/test/sun/security/krb5/etype/ETypeOrder.java Thu Mar 31 22:07:32 2011 -0700
@@ -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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/test/sun/security/krb5/krb5-capaths.conf
--- a/jdk/test/sun/security/krb5/krb5-capaths.conf Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/test/sun/security/krb5/krb5-capaths.conf Thu Mar 31 22:07:32 2011 -0700
@@ -85,3 +85,13 @@
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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/test/sun/security/krb5/ktab/HighestKvno.java
--- a/jdk/test/sun/security/krb5/ktab/HighestKvno.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/test/sun/security/krb5/ktab/HighestKvno.java Thu Mar 31 22:07:32 2011 -0700
@@ -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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/test/sun/security/pkcs11/fips/CipherTest.java
--- a/jdk/test/sun/security/pkcs11/fips/CipherTest.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/test/sun/security/pkcs11/fips/CipherTest.java Thu Mar 31 22:07:32 2011 -0700
@@ -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 @@
}
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 @@
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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/test/sun/security/pkcs11/sslecc/CipherTest.java
--- a/jdk/test/sun/security/pkcs11/sslecc/CipherTest.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/test/sun/security/pkcs11/sslecc/CipherTest.java Thu Mar 31 22:07:32 2011 -0700
@@ -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 @@
}
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 @@
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 @@
// no client with anonymous ciphersuites
continue;
}
+
tests.add(new TestParameters(cipherSuite, protocol,
clientAuth));
}
}
}
+
testIterator = tests.iterator();
}
diff -r 3db1444f8ac8 -r 5cf29386a520 jdk/test/sun/security/ssl/sanity/interop/CipherTest.java
--- a/jdk/test/sun/security/ssl/sanity/interop/CipherTest.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/test/sun/security/ssl/sanity/interop/CipherTest.java Thu Mar 31 22:07:32 2011 -0700
@@ -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 @@
}
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 @@
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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/test/sun/security/ssl/sanity/interop/ClientJSSEServerJSSE.java
--- a/jdk/test/sun/security/ssl/sanity/interop/ClientJSSEServerJSSE.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/test/sun/security/ssl/sanity/interop/ClientJSSEServerJSSE.java Thu Mar 31 22:07:32 2011 -0700
@@ -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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/test/sun/util/logging/PlatformLoggerTest.java
--- a/jdk/test/sun/util/logging/PlatformLoggerTest.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/test/sun/util/logging/PlatformLoggerTest.java Thu Mar 31 22:07:32 2011 -0700
@@ -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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/test/tools/pack200/CommandLineTests.java
--- a/jdk/test/tools/pack200/CommandLineTests.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/test/tools/pack200/CommandLineTests.java Thu Mar 31 22:07:32 2011 -0700
@@ -120,9 +120,9 @@
// 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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/test/tools/pack200/TimeStamp.java
--- a/jdk/test/tools/pack200/TimeStamp.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/test/tools/pack200/TimeStamp.java Thu Mar 31 22:07:32 2011 -0700
@@ -56,7 +56,7 @@
// 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 -r 3db1444f8ac8 -r 5cf29386a520 jdk/test/tools/pack200/Utils.java
--- a/jdk/test/tools/pack200/Utils.java Thu Mar 31 18:14:17 2011 -0700
+++ b/jdk/test/tools/pack200/Utils.java Thu Mar 31 22:07:32 2011 -0700
@@ -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.zip.ZipEntry;
import java.util.zip.ZipFile;
+import static java.nio.file.StandardCopyOption.*;
+
/**
*
* @author ksrini
@@ -180,45 +182,12 @@
}
};
- 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();
- }
+ Path parent = dst.toPath().getParent();
+ if (parent != null) {
+ Files.createDirectories(parent);
}
- 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);
- }
- setFileAttributes(src, dst);
+ Files.copy(src.toPath(), dst.toPath(), COPY_ATTRIBUTES, REPLACE_EXISTING);
}
static String baseName(File file, String extension) {