1.1 --- a/make/common/Release.gmk Fri Aug 06 12:52:07 2010 -0700
1.2 +++ b/make/common/Release.gmk Mon Aug 09 16:02:19 2010 -0700
1.3 @@ -571,6 +571,16 @@
1.4 $(ECHO) "META-INF/services/com.sun.tools.xjc.Plugin" >> $@
1.5 $(ECHO) "com/sun/tools/" >> $@
1.6 $(ECHO) "sun/jvmstat/" >> $@
1.7 + $(ECHO) "sun/nio/cs/ext/" >> $@
1.8 + $(ECHO) "sun/awt/HKSCS.class" >> $@
1.9 + $(ECHO) "sun/awt/motif/X11GB2312$Decoder.class" >> $@
1.10 + $(ECHO) "sun/awt/motif/X11GB2312$Encoder.class" >> $@
1.11 + $(ECHO) "sun/awt/motif/X11GB2312.class" >> $@
1.12 + $(ECHO) "sun/awt/motif/X11GBK$Encoder.class" >> $@
1.13 + $(ECHO) "sun/awt/motif/X11GBK.class" >> $@
1.14 + $(ECHO) "sun/awt/motif/X11KSC5601$Decoder.class" >> $@
1.15 + $(ECHO) "sun/awt/motif/X11KSC5601$Encoder.class" >> $@
1.16 + $(ECHO) "sun/awt/motif/X11KSC5601.class" >> $@
1.17 $(ECHO) "sun/rmi/rmic/" >> $@
1.18 $(ECHO) "sun/tools/asm/" >> $@
1.19 $(ECHO) "sun/tools/java/" >> $@
2.1 --- a/make/java/nio/mapfile-linux Fri Aug 06 12:52:07 2010 -0700
2.2 +++ b/make/java/nio/mapfile-linux Mon Aug 09 16:02:19 2010 -0700
2.3 @@ -119,6 +119,7 @@
2.4 Java_sun_nio_ch_ServerSocketChannelImpl_accept0;
2.5 Java_sun_nio_ch_ServerSocketChannelImpl_initIDs;
2.6 Java_sun_nio_ch_SocketChannelImpl_checkConnect;
2.7 + Java_sun_nio_ch_SocketChannelImpl_sendOutOfBandData;
2.8 Java_sun_nio_ch_UnixAsynchronousServerSocketChannelImpl_accept0;
2.9 Java_sun_nio_ch_UnixAsynchronousServerSocketChannelImpl_initIDs;
2.10 Java_sun_nio_ch_UnixAsynchronousSocketChannelImpl_checkConnect;
3.1 --- a/make/java/nio/mapfile-solaris Fri Aug 06 12:52:07 2010 -0700
3.2 +++ b/make/java/nio/mapfile-solaris Mon Aug 09 16:02:19 2010 -0700
3.3 @@ -106,6 +106,7 @@
3.4 Java_sun_nio_ch_ServerSocketChannelImpl_accept0;
3.5 Java_sun_nio_ch_ServerSocketChannelImpl_initIDs;
3.6 Java_sun_nio_ch_SocketChannelImpl_checkConnect;
3.7 + Java_sun_nio_ch_SocketChannelImpl_sendOutOfBandData;
3.8 Java_sun_nio_ch_UnixAsynchronousServerSocketChannelImpl_accept0;
3.9 Java_sun_nio_ch_UnixAsynchronousServerSocketChannelImpl_initIDs;
3.10 Java_sun_nio_ch_UnixAsynchronousSocketChannelImpl_checkConnect;
4.1 --- a/make/sun/nio/cs/Makefile Fri Aug 06 12:52:07 2010 -0700
4.2 +++ b/make/sun/nio/cs/Makefile Mon Aug 09 16:02:19 2010 -0700
4.3 @@ -58,6 +58,25 @@
4.4 FILES_genout_extcs = $(FILES_gen_extcs:%.java=$(GENSRCDIR)/%.java)
4.5
4.6 #
4.7 +# These sun.awt charsets use sun/nio/cs/ext charsets that only exist
4.8 +# in JDK7 charsets.jar, which causes problem when build the symbol
4.9 +# table for rt.jar in Release.gmk. They are now removed from the
4.10 +# rt.jar when building jdk/jre image (in Release.gmk), so add them
4.11 +# into charsets.jar here
4.12 +#
4.13 +ifeq ($(PLATFORM), windows)
4.14 +FILES_src += \
4.15 + sun/awt/HKSCS.java
4.16 +else
4.17 +# Solaris/Linux
4.18 +FILES_src += \
4.19 + sun/awt/HKSCS.java \
4.20 + sun/awt/motif/X11GB2312.java \
4.21 + sun/awt/motif/X11GBK.java \
4.22 + sun/awt/motif/X11KSC5601.java
4.23 +endif # PLATFORM
4.24 +
4.25 +#
4.26 # Rules
4.27 #
4.28 include $(BUILDDIR)/common/Classes.gmk
5.1 --- a/src/share/classes/com/sun/jndi/dns/DnsContextFactory.java Fri Aug 06 12:52:07 2010 -0700
5.2 +++ b/src/share/classes/com/sun/jndi/dns/DnsContextFactory.java Mon Aug 09 16:02:19 2010 -0700
5.3 @@ -1,5 +1,5 @@
5.4 /*
5.5 - * Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved.
5.6 + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
5.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5.8 *
5.9 * This code is free software; you can redistribute it and/or modify it
5.10 @@ -132,7 +132,7 @@
5.11 throw new ConfigurationException("DNS pseudo-URL required");
5.12 }
5.13
5.14 - List servers = new ArrayList();
5.15 + List<String> servers = new ArrayList<>();
5.16
5.17 for (int i = 0; i < urls.length; i++) {
5.18 String server = urls[i].getHost();
5.19 @@ -142,7 +142,7 @@
5.20 // No server or port given, so look to underlying platform.
5.21 // ResolverConfiguration does some limited caching, so the
5.22 // following is reasonably efficient even if called rapid-fire.
5.23 - List platformServers =
5.24 + List<String> platformServers =
5.25 ResolverConfiguration.open().nameservers();
5.26 if (!platformServers.isEmpty()) {
5.27 servers.addAll(platformServers);
5.28 @@ -157,8 +157,7 @@
5.29 ? server
5.30 : server + ":" + port);
5.31 }
5.32 - return (String[]) servers.toArray(
5.33 - new String[servers.size()]);
5.34 + return servers.toArray(new String[servers.size()]);
5.35 }
5.36
5.37 /*
6.1 --- a/src/share/classes/com/sun/jndi/ldap/Connection.java Fri Aug 06 12:52:07 2010 -0700
6.2 +++ b/src/share/classes/com/sun/jndi/ldap/Connection.java Mon Aug 09 16:02:19 2010 -0700
6.3 @@ -1,5 +1,5 @@
6.4 /*
6.5 - * Copyright (c) 1999, 2009, Oracle and/or its affiliates. All rights reserved.
6.6 + * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
6.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6.8 *
6.9 * This code is free software; you can redistribute it and/or modify it
6.10 @@ -658,6 +658,11 @@
6.11 }
6.12 }
6.13 if (nparent) {
6.14 + LdapRequest ldr = pendingRequests;
6.15 + while (ldr != null) {
6.16 + ldr.notify();
6.17 + ldr = ldr.next;
6.18 + }
6.19 parent.processConnectionClosure();
6.20 }
6.21 }
7.1 --- a/src/share/classes/com/sun/jndi/ldap/Filter.java Fri Aug 06 12:52:07 2010 -0700
7.2 +++ b/src/share/classes/com/sun/jndi/ldap/Filter.java Mon Aug 09 16:02:19 2010 -0700
7.3 @@ -803,8 +803,7 @@
7.4 //
7.5 ////////////////////////////////////////////////////////////////////////////
7.6
7.7 - // private static final boolean dbg = false;
7.8 - private static final boolean dbg = true;
7.9 + private static final boolean dbg = false;
7.10 private static int dbgIndent = 0;
7.11
7.12 private static void dprint(String msg) {
8.1 --- a/src/share/classes/com/sun/jndi/rmi/registry/RegistryContext.java Fri Aug 06 12:52:07 2010 -0700
8.2 +++ b/src/share/classes/com/sun/jndi/rmi/registry/RegistryContext.java Mon Aug 09 16:02:19 2010 -0700
8.3 @@ -81,7 +81,7 @@
8.4 }
8.5
8.6 RMIClientSocketFactory socketFactory =
8.7 - (RMIClientSocketFactory) env.get(SOCKET_FACTORY);
8.8 + (RMIClientSocketFactory) environment.get(SOCKET_FACTORY);
8.9 registry = getRegistry(host, port, socketFactory);
8.10 this.host = host;
8.11 this.port = port;
9.1 --- a/src/share/classes/java/lang/AutoCloseable.java Fri Aug 06 12:52:07 2010 -0700
9.2 +++ b/src/share/classes/java/lang/AutoCloseable.java Mon Aug 09 16:02:19 2010 -0700
9.3 @@ -41,6 +41,13 @@
9.4 * be declared to throw more specific exceptions (or no exception
9.5 * at all, if the close cannot fail).
9.6 *
9.7 + * <p>Note that unlike the {@link java.io.Closeable#close close}
9.8 + * method of {@link java.io.Closeable}, this {@code close} method
9.9 + * is <em>not</em> required to be idempotent. In other words,
9.10 + * calling this {@code close} method more than once may have some
9.11 + * visible side effect, unlike {@code Closeable.close} which is
9.12 + * required to have no effect if called more than once.
9.13 + *
9.14 * @throws Exception if this resource cannot be closed
9.15 */
9.16 void close() throws Exception;
10.1 --- a/src/share/classes/java/lang/Throwable.java Fri Aug 06 12:52:07 2010 -0700
10.2 +++ b/src/share/classes/java/lang/Throwable.java Mon Aug 09 16:02:19 2010 -0700
10.3 @@ -28,12 +28,12 @@
10.4 import java.util.*;
10.5
10.6 /**
10.7 - * The <code>Throwable</code> class is the superclass of all errors and
10.8 + * The {@code Throwable} class is the superclass of all errors and
10.9 * exceptions in the Java language. Only objects that are instances of this
10.10 * class (or one of its subclasses) are thrown by the Java Virtual Machine or
10.11 - * can be thrown by the Java <code>throw</code> statement. Similarly, only
10.12 + * can be thrown by the Java {@code throw} statement. Similarly, only
10.13 * this class or one of its subclasses can be the argument type in a
10.14 - * <code>catch</code> clause.
10.15 + * {@code catch} clause.
10.16 *
10.17 * For the purposes of compile-time checking of exceptions, {@code
10.18 * Throwable} and any subclass of {@code Throwable} that is not also a
10.19 @@ -73,11 +73,11 @@
10.20 * permit the method to throw the cause directly. For example, suppose
10.21 * a persistent collection conforms to the {@link java.util.Collection
10.22 * Collection} interface, and that its persistence is implemented atop
10.23 - * <tt>java.io</tt>. Suppose the internals of the <tt>add</tt> method
10.24 + * {@code java.io}. Suppose the internals of the {@code add} method
10.25 * can throw an {@link java.io.IOException IOException}. The implementation
10.26 - * can communicate the details of the <tt>IOException</tt> to its caller
10.27 - * while conforming to the <tt>Collection</tt> interface by wrapping the
10.28 - * <tt>IOException</tt> in an appropriate unchecked exception. (The
10.29 + * can communicate the details of the {@code IOException} to its caller
10.30 + * while conforming to the {@code Collection} interface by wrapping the
10.31 + * {@code IOException} in an appropriate unchecked exception. (The
10.32 * specification for the persistent collection should indicate that it is
10.33 * capable of throwing such exceptions.)
10.34 *
10.35 @@ -86,7 +86,7 @@
10.36 * {@link #initCause(Throwable)} method. New throwable classes that
10.37 * wish to allow causes to be associated with them should provide constructors
10.38 * that take a cause and delegate (perhaps indirectly) to one of the
10.39 - * <tt>Throwable</tt> constructors that takes a cause. For example:
10.40 + * {@code Throwable} constructors that takes a cause. For example:
10.41 * <pre>
10.42 * try {
10.43 * lowLevelOp();
10.44 @@ -94,10 +94,10 @@
10.45 * throw new HighLevelException(le); // Chaining-aware constructor
10.46 * }
10.47 * </pre>
10.48 - * Because the <tt>initCause</tt> method is public, it allows a cause to be
10.49 + * Because the {@code initCause} method is public, it allows a cause to be
10.50 * associated with any throwable, even a "legacy throwable" whose
10.51 * implementation predates the addition of the exception chaining mechanism to
10.52 - * <tt>Throwable</tt>. For example:
10.53 + * {@code Throwable}. For example:
10.54 * <pre>
10.55 * try {
10.56 * lowLevelOp();
10.57 @@ -121,28 +121,28 @@
10.58 * use the standard exception chaining mechanism, while continuing to
10.59 * implement their "legacy" chaining mechanisms for compatibility.
10.60 *
10.61 - * <p>Further, as of release 1.4, many general purpose <tt>Throwable</tt>
10.62 + * <p>Further, as of release 1.4, many general purpose {@code Throwable}
10.63 * classes (for example {@link Exception}, {@link RuntimeException},
10.64 * {@link Error}) have been retrofitted with constructors that take
10.65 * a cause. This was not strictly necessary, due to the existence of the
10.66 - * <tt>initCause</tt> method, but it is more convenient and expressive to
10.67 + * {@code initCause} method, but it is more convenient and expressive to
10.68 * delegate to a constructor that takes a cause.
10.69 *
10.70 - * <p>By convention, class <code>Throwable</code> and its subclasses have two
10.71 + * <p>By convention, class {@code Throwable} and its subclasses have two
10.72 * constructors, one that takes no arguments and one that takes a
10.73 - * <code>String</code> argument that can be used to produce a detail message.
10.74 + * {@code String} argument that can be used to produce a detail message.
10.75 * Further, those subclasses that might likely have a cause associated with
10.76 * them should have two more constructors, one that takes a
10.77 - * <code>Throwable</code> (the cause), and one that takes a
10.78 - * <code>String</code> (the detail message) and a <code>Throwable</code> (the
10.79 + * {@code Throwable} (the cause), and one that takes a
10.80 + * {@code String} (the detail message) and a {@code Throwable} (the
10.81 * cause).
10.82 *
10.83 * <p>Also introduced in release 1.4 is the {@link #getStackTrace()} method,
10.84 * which allows programmatic access to the stack trace information that was
10.85 * previously available only in text form, via the various forms of the
10.86 * {@link #printStackTrace()} method. This information has been added to the
10.87 - * <i>serialized representation</i> of this class so <tt>getStackTrace</tt>
10.88 - * and <tt>printStackTrace</tt> will operate properly on a throwable that
10.89 + * <i>serialized representation</i> of this class so {@code getStackTrace}
10.90 + * and {@code printStackTrace} will operate properly on a throwable that
10.91 * was obtained by deserialization.
10.92 *
10.93 * @author unascribed
10.94 @@ -162,7 +162,7 @@
10.95
10.96 /**
10.97 * Specific details about the Throwable. For example, for
10.98 - * <tt>FileNotFoundException</tt>, this contains the name of
10.99 + * {@code FileNotFoundException}, this contains the name of
10.100 * the file that could not be found.
10.101 *
10.102 * @serial
10.103 @@ -212,7 +212,7 @@
10.104 private static final String SUPPRESSED_CAPTION = "Suppressed: ";
10.105
10.106 /**
10.107 - * Constructs a new throwable with <code>null</code> as its detail message.
10.108 + * Constructs a new throwable with {@code null} as its detail message.
10.109 * The cause is not initialized, and may subsequently be initialized by a
10.110 * call to {@link #initCause}.
10.111 *
10.112 @@ -242,7 +242,7 @@
10.113 /**
10.114 * Constructs a new throwable with the specified detail message and
10.115 * cause. <p>Note that the detail message associated with
10.116 - * <code>cause</code> is <i>not</i> automatically incorporated in
10.117 + * {@code cause} is <i>not</i> automatically incorporated in
10.118 * this throwable's detail message.
10.119 *
10.120 * <p>The {@link #fillInStackTrace()} method is called to initialize
10.121 @@ -251,7 +251,7 @@
10.122 * @param message the detail message (which is saved for later retrieval
10.123 * by the {@link #getMessage()} method).
10.124 * @param cause the cause (which is saved for later retrieval by the
10.125 - * {@link #getCause()} method). (A <tt>null</tt> value is
10.126 + * {@link #getCause()} method). (A {@code null} value is
10.127 * permitted, and indicates that the cause is nonexistent or
10.128 * unknown.)
10.129 * @since 1.4
10.130 @@ -264,8 +264,8 @@
10.131
10.132 /**
10.133 * Constructs a new throwable with the specified cause and a detail
10.134 - * message of <tt>(cause==null ? null : cause.toString())</tt> (which
10.135 - * typically contains the class and detail message of <tt>cause</tt>).
10.136 + * message of {@code (cause==null ? null : cause.toString())} (which
10.137 + * typically contains the class and detail message of {@code cause}).
10.138 * This constructor is useful for throwables that are little more than
10.139 * wrappers for other throwables (for example, {@link
10.140 * java.security.PrivilegedActionException}).
10.141 @@ -274,7 +274,7 @@
10.142 * the stack trace data in the newly created throwable.
10.143 *
10.144 * @param cause the cause (which is saved for later retrieval by the
10.145 - * {@link #getCause()} method). (A <tt>null</tt> value is
10.146 + * {@link #getCause()} method). (A {@code null} value is
10.147 * permitted, and indicates that the cause is nonexistent or
10.148 * unknown.)
10.149 * @since 1.4
10.150 @@ -288,8 +288,8 @@
10.151 /**
10.152 * Returns the detail message string of this throwable.
10.153 *
10.154 - * @return the detail message string of this <tt>Throwable</tt> instance
10.155 - * (which may be <tt>null</tt>).
10.156 + * @return the detail message string of this {@code Throwable} instance
10.157 + * (which may be {@code null}).
10.158 */
10.159 public String getMessage() {
10.160 return detailMessage;
10.161 @@ -300,7 +300,7 @@
10.162 * Subclasses may override this method in order to produce a
10.163 * locale-specific message. For subclasses that do not override this
10.164 * method, the default implementation returns the same result as
10.165 - * <code>getMessage()</code>.
10.166 + * {@code getMessage()}.
10.167 *
10.168 * @return The localized description of this throwable.
10.169 * @since JDK1.1
10.170 @@ -310,22 +310,22 @@
10.171 }
10.172
10.173 /**
10.174 - * Returns the cause of this throwable or <code>null</code> if the
10.175 + * Returns the cause of this throwable or {@code null} if the
10.176 * cause is nonexistent or unknown. (The cause is the throwable that
10.177 * caused this throwable to get thrown.)
10.178 *
10.179 * <p>This implementation returns the cause that was supplied via one of
10.180 - * the constructors requiring a <tt>Throwable</tt>, or that was set after
10.181 + * the constructors requiring a {@code Throwable}, or that was set after
10.182 * creation with the {@link #initCause(Throwable)} method. While it is
10.183 * typically unnecessary to override this method, a subclass can override
10.184 * it to return a cause set by some other means. This is appropriate for
10.185 * a "legacy chained throwable" that predates the addition of chained
10.186 - * exceptions to <tt>Throwable</tt>. Note that it is <i>not</i>
10.187 - * necessary to override any of the <tt>PrintStackTrace</tt> methods,
10.188 - * all of which invoke the <tt>getCause</tt> method to determine the
10.189 + * exceptions to {@code Throwable}. Note that it is <i>not</i>
10.190 + * necessary to override any of the {@code PrintStackTrace} methods,
10.191 + * all of which invoke the {@code getCause} method to determine the
10.192 * cause of a throwable.
10.193 *
10.194 - * @return the cause of this throwable or <code>null</code> if the
10.195 + * @return the cause of this throwable or {@code null} if the
10.196 * cause is nonexistent or unknown.
10.197 * @since 1.4
10.198 */
10.199 @@ -345,11 +345,11 @@
10.200 * even once.
10.201 *
10.202 * @param cause the cause (which is saved for later retrieval by the
10.203 - * {@link #getCause()} method). (A <tt>null</tt> value is
10.204 + * {@link #getCause()} method). (A {@code null} value is
10.205 * permitted, and indicates that the cause is nonexistent or
10.206 * unknown.)
10.207 - * @return a reference to this <code>Throwable</code> instance.
10.208 - * @throws IllegalArgumentException if <code>cause</code> is this
10.209 + * @return a reference to this {@code Throwable} instance.
10.210 + * @throws IllegalArgumentException if {@code cause} is this
10.211 * throwable. (A throwable cannot be its own cause.)
10.212 * @throws IllegalStateException if this throwable was
10.213 * created with {@link #Throwable(Throwable)} or
10.214 @@ -375,7 +375,7 @@
10.215 * <li> the result of invoking this object's {@link #getLocalizedMessage}
10.216 * method
10.217 * </ul>
10.218 - * If <tt>getLocalizedMessage</tt> returns <tt>null</tt>, then just
10.219 + * If {@code getLocalizedMessage} returns {@code null}, then just
10.220 * the class name is returned.
10.221 *
10.222 * @return a string representation of this throwable.
10.223 @@ -389,8 +389,8 @@
10.224 /**
10.225 * Prints this throwable and its backtrace to the
10.226 * standard error stream. This method prints a stack trace for this
10.227 - * <code>Throwable</code> object on the error output stream that is
10.228 - * the value of the field <code>System.err</code>. The first line of
10.229 + * {@code Throwable} object on the error output stream that is
10.230 + * the value of the field {@code System.err}. The first line of
10.231 * output contains the result of the {@link #toString()} method for
10.232 * this object. Remaining lines represent data previously recorded by
10.233 * the method {@link #fillInStackTrace()}. The format of this
10.234 @@ -435,7 +435,7 @@
10.235 * at Junk.c(Junk.java:21)
10.236 * ... 3 more
10.237 * </pre>
10.238 - * Note the presence of lines containing the characters <tt>"..."</tt>.
10.239 + * Note the presence of lines containing the characters {@code "..."}.
10.240 * These lines indicate that the remainder of the stack trace for this
10.241 * exception matches the indicated number of frames from the bottom of the
10.242 * stack trace of the exception that was caused by this exception (the
10.243 @@ -542,14 +542,17 @@
10.244 /**
10.245 * Prints this throwable and its backtrace to the specified print stream.
10.246 *
10.247 - * @param s <code>PrintStream</code> to use for output
10.248 + * @param s {@code PrintStream} to use for output
10.249 */
10.250 public void printStackTrace(PrintStream s) {
10.251 printStackTrace(new WrappedPrintStream(s));
10.252 }
10.253
10.254 private void printStackTrace(PrintStreamOrWriter s) {
10.255 - Set<Throwable> dejaVu = new HashSet<Throwable>();
10.256 + // Guard against malicious overrides of Throwable.equals by
10.257 + // using a Set with identity equality semantics.
10.258 + Set<Throwable> dejaVu =
10.259 + Collections.newSetFromMap(new IdentityHashMap<Throwable, Boolean>());
10.260 dejaVu.add(this);
10.261
10.262 synchronized (s.lock()) {
10.263 @@ -616,7 +619,7 @@
10.264 * Prints this throwable and its backtrace to the specified
10.265 * print writer.
10.266 *
10.267 - * @param s <code>PrintWriter</code> to use for output
10.268 + * @param s {@code PrintWriter} to use for output
10.269 * @since JDK1.1
10.270 */
10.271 public void printStackTrace(PrintWriter s) {
10.272 @@ -669,10 +672,10 @@
10.273
10.274 /**
10.275 * Fills in the execution stack trace. This method records within this
10.276 - * <code>Throwable</code> object information about the current state of
10.277 + * {@code Throwable} object information about the current state of
10.278 * the stack frames for the current thread.
10.279 *
10.280 - * @return a reference to this <code>Throwable</code> instance.
10.281 + * @return a reference to this {@code Throwable} instance.
10.282 * @see java.lang.Throwable#printStackTrace()
10.283 */
10.284 public synchronized native Throwable fillInStackTrace();
10.285 @@ -694,7 +697,7 @@
10.286 * this throwable is permitted to return a zero-length array from this
10.287 * method. Generally speaking, the array returned by this method will
10.288 * contain one element for every frame that would be printed by
10.289 - * <tt>printStackTrace</tt>.
10.290 + * {@code printStackTrace}.
10.291 *
10.292 * @return an array of stack trace elements representing the stack trace
10.293 * pertaining to this throwable.
10.294 @@ -727,14 +730,14 @@
10.295 * read from a serialization stream.
10.296 *
10.297 * @param stackTrace the stack trace elements to be associated with
10.298 - * this <code>Throwable</code>. The specified array is copied by this
10.299 + * this {@code Throwable}. The specified array is copied by this
10.300 * call; changes in the specified array after the method invocation
10.301 - * returns will have no affect on this <code>Throwable</code>'s stack
10.302 + * returns will have no affect on this {@code Throwable}'s stack
10.303 * trace.
10.304 *
10.305 - * @throws NullPointerException if <code>stackTrace</code> is
10.306 - * <code>null</code>, or if any of the elements of
10.307 - * <code>stackTrace</code> are <code>null</code>
10.308 + * @throws NullPointerException if {@code stackTrace} is
10.309 + * {@code null}, or if any of the elements of
10.310 + * {@code stackTrace} are {@code null}
10.311 *
10.312 * @since 1.4
10.313 */
10.314 @@ -761,8 +764,8 @@
10.315 * package-protection for use by SharedSecrets.
10.316 *
10.317 * @param index index of the element to return.
10.318 - * @throws IndexOutOfBoundsException if <tt>index < 0 ||
10.319 - * index >= getStackTraceDepth() </tt>
10.320 + * @throws IndexOutOfBoundsException if {@code index < 0 ||
10.321 + * index >= getStackTraceDepth() }
10.322 */
10.323 native StackTraceElement getStackTraceElement(int index);
10.324
10.325 @@ -794,14 +797,27 @@
10.326 * were suppressed, typically by the automatic resource management
10.327 * statement, in order to deliver this exception.
10.328 *
10.329 + * <p>Note that when one exception {@linkplain
10.330 + * #initCause(Throwable) causes} another exception, the first
10.331 + * exception is usually caught and then the second exception is
10.332 + * thrown in response. In contrast, when one exception suppresses
10.333 + * another, two exceptions are thrown in sibling code blocks, such
10.334 + * as in a {@code try} block and in its {@code finally} block, and
10.335 + * control flow can only continue with one exception so the second
10.336 + * is recorded as a suppressed exception of the first.
10.337 + *
10.338 * @param exception the exception to be added to the list of
10.339 * suppressed exceptions
10.340 * @throws NullPointerException if {@code exception} is null
10.341 + * @throws IllegalArgumentException if {@code exception} is this
10.342 + * throwable; a throwable cannot suppress itself.
10.343 * @since 1.7
10.344 */
10.345 public synchronized void addSuppressedException(Throwable exception) {
10.346 if (exception == null)
10.347 throw new NullPointerException(NULL_CAUSE_MESSAGE);
10.348 + if (exception == this)
10.349 + throw new IllegalArgumentException("Self-suppression not permitted");
10.350
10.351 if (suppressedExceptions.size() == 0)
10.352 suppressedExceptions = new ArrayList<Throwable>();
11.1 --- a/src/share/classes/java/nio/Bits.java Fri Aug 06 12:52:07 2010 -0700
11.2 +++ b/src/share/classes/java/nio/Bits.java Mon Aug 09 16:02:19 2010 -0700
11.3 @@ -596,6 +596,9 @@
11.4 return pageSize;
11.5 }
11.6
11.7 + static int pageCount(long size) {
11.8 + return (int)(size + (long)pageSize() - 1L) / pageSize();
11.9 + }
11.10
11.11 private static boolean unaligned;
11.12 private static boolean unalignedKnown = false;
12.1 --- a/src/share/classes/java/nio/MappedByteBuffer.java Fri Aug 06 12:52:07 2010 -0700
12.2 +++ b/src/share/classes/java/nio/MappedByteBuffer.java Mon Aug 09 16:02:19 2010 -0700
12.3 @@ -25,6 +25,8 @@
12.4
12.5 package java.nio;
12.6
12.7 +import sun.misc.Unsafe;
12.8 +
12.9
12.10 /**
12.11 * A direct byte buffer whose content is a memory-mapped region of a file.
12.12 @@ -93,6 +95,22 @@
12.13 throw new UnsupportedOperationException();
12.14 }
12.15
12.16 + // Returns the distance (in bytes) of the buffer from the page aligned address
12.17 + // of the mapping. Computed each time to avoid storing in every direct buffer.
12.18 + private long mappingOffset() {
12.19 + int ps = Bits.pageSize();
12.20 + long offset = address % ps;
12.21 + return (offset >= 0) ? offset : (ps + offset);
12.22 + }
12.23 +
12.24 + private long mappingAddress(long mappingOffset) {
12.25 + return address - mappingOffset;
12.26 + }
12.27 +
12.28 + private long mappingLength(long mappingOffset) {
12.29 + return (long)capacity() + mappingOffset;
12.30 + }
12.31 +
12.32 /**
12.33 * Tells whether or not this buffer's content is resident in physical
12.34 * memory.
12.35 @@ -115,7 +133,9 @@
12.36 checkMapped();
12.37 if ((address == 0) || (capacity() == 0))
12.38 return true;
12.39 - return isLoaded0(((DirectByteBuffer)this).address(), capacity());
12.40 + long offset = mappingOffset();
12.41 + long length = mappingLength(offset);
12.42 + return isLoaded0(mappingAddress(offset), length, Bits.pageCount(length));
12.43 }
12.44
12.45 /**
12.46 @@ -132,7 +152,20 @@
12.47 checkMapped();
12.48 if ((address == 0) || (capacity() == 0))
12.49 return this;
12.50 - load0(((DirectByteBuffer)this).address(), capacity(), Bits.pageSize());
12.51 + long offset = mappingOffset();
12.52 + long length = mappingLength(offset);
12.53 + load0(mappingAddress(offset), length);
12.54 +
12.55 + // touch each page
12.56 + Unsafe unsafe = Unsafe.getUnsafe();
12.57 + int ps = Bits.pageSize();
12.58 + int count = Bits.pageCount(length);
12.59 + long a = mappingAddress(offset);
12.60 + for (int i=0; i<count; i++) {
12.61 + unsafe.getByte(a);
12.62 + a += ps;
12.63 + }
12.64 +
12.65 return this;
12.66 }
12.67
12.68 @@ -156,14 +189,15 @@
12.69 */
12.70 public final MappedByteBuffer force() {
12.71 checkMapped();
12.72 - if ((address == 0) || (capacity() == 0))
12.73 - return this;
12.74 - force0(((DirectByteBuffer)this).address(), capacity());
12.75 + if ((address != 0) && (capacity() != 0)) {
12.76 + long offset = mappingOffset();
12.77 + force0(mappingAddress(offset), mappingLength(offset));
12.78 + }
12.79 return this;
12.80 }
12.81
12.82 - private native boolean isLoaded0(long address, long length);
12.83 - private native int load0(long address, long length, int pageSize);
12.84 + private native boolean isLoaded0(long address, long length, int pageCount);
12.85 + private native void load0(long address, long length);
12.86 private native void force0(long address, long length);
12.87
12.88 }
13.1 --- a/src/share/classes/java/security/cert/X509CRL.java Fri Aug 06 12:52:07 2010 -0700
13.2 +++ b/src/share/classes/java/security/cert/X509CRL.java Mon Aug 09 16:02:19 2010 -0700
13.3 @@ -1,5 +1,5 @@
13.4 /*
13.5 - * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
13.6 + * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
13.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
13.8 *
13.9 * This code is free software; you can redistribute it and/or modify it
13.10 @@ -387,7 +387,7 @@
13.11
13.12 /**
13.13 * Gets the signature algorithm name for the CRL
13.14 - * signature algorithm. An example is the string "SHA-1/DSA".
13.15 + * signature algorithm. An example is the string "SHA256withRSA".
13.16 * The ASN.1 definition for this is:
13.17 * <pre>
13.18 * signatureAlgorithm AlgorithmIdentifier<p>
14.1 --- a/src/share/classes/java/security/cert/X509Certificate.java Fri Aug 06 12:52:07 2010 -0700
14.2 +++ b/src/share/classes/java/security/cert/X509Certificate.java Mon Aug 09 16:02:19 2010 -0700
14.3 @@ -1,5 +1,5 @@
14.4 /*
14.5 - * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
14.6 + * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
14.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
14.8 *
14.9 * This code is free software; you can redistribute it and/or modify it
14.10 @@ -352,7 +352,7 @@
14.11
14.12 /**
14.13 * Gets the signature algorithm name for the certificate
14.14 - * signature algorithm. An example is the string "SHA-1/DSA".
14.15 + * signature algorithm. An example is the string "SHA256withRSA".
14.16 * The ASN.1 definition for this is:
14.17 * <pre>
14.18 * signatureAlgorithm AlgorithmIdentifier<p>
15.1 --- a/src/share/classes/java/util/LinkedList.java Fri Aug 06 12:52:07 2010 -0700
15.2 +++ b/src/share/classes/java/util/LinkedList.java Mon Aug 09 16:02:19 2010 -0700
15.3 @@ -26,18 +26,9 @@
15.4 package java.util;
15.5
15.6 /**
15.7 - * Linked list implementation of the {@code List} interface. Implements all
15.8 - * optional list operations, and permits all elements (including
15.9 - * {@code null}). In addition to implementing the {@code List} interface,
15.10 - * the {@code LinkedList} class provides uniformly named methods to
15.11 - * {@code get}, {@code remove} and {@code insert} an element at the
15.12 - * beginning and end of the list. These operations allow linked lists to be
15.13 - * used as a stack, {@linkplain Queue queue}, or {@linkplain Deque
15.14 - * double-ended queue}.
15.15 - *
15.16 - * <p>The class implements the {@code Deque} interface, providing
15.17 - * first-in-first-out queue operations for {@code add},
15.18 - * {@code poll}, along with other stack and deque operations.
15.19 + * Linked list implementation of the {@link List} and {@link Deque} interfaces.
15.20 + * Implements all optional operations, and permits all elements (including
15.21 + * {@code null}).
15.22 *
15.23 * <p>All of the operations perform as could be expected for a doubly-linked
15.24 * list. Operations that index into the list will traverse the list from
16.1 --- a/src/share/classes/javax/swing/plaf/basic/BasicColorChooserUI.java Fri Aug 06 12:52:07 2010 -0700
16.2 +++ b/src/share/classes/javax/swing/plaf/basic/BasicColorChooserUI.java Mon Aug 09 16:02:19 2010 -0700
16.3 @@ -1,5 +1,5 @@
16.4 /*
16.5 - * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
16.6 + * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
16.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
16.8 *
16.9 * This code is free software; you can redistribute it and/or modify it
16.10 @@ -113,7 +113,6 @@
16.11 previewPanelHolder.setBorder(new TitledBorder(previewString));
16.12 }
16.13 previewPanelHolder.setInheritsPopupMenu(true);
16.14 - chooser.add(previewPanelHolder, BorderLayout.SOUTH);
16.15
16.16 installPreviewPanel();
16.17 chooser.applyComponentOrientation(c.getComponentOrientation());
16.18 @@ -126,13 +125,9 @@
16.19
16.20 uninstallDefaultChoosers();
16.21 uninstallListeners();
16.22 + uninstallPreviewPanel();
16.23 uninstallDefaults();
16.24
16.25 - previewPanelHolder.remove(previewPanel);
16.26 - if (previewPanel instanceof UIResource) {
16.27 - chooser.setPreviewPanel(null);
16.28 - }
16.29 -
16.30 previewPanelHolder = null;
16.31 previewPanel = null;
16.32 defaultChoosers = null;
16.33 @@ -143,29 +138,37 @@
16.34 }
16.35
16.36 protected void installPreviewPanel() {
16.37 - if (previewPanel != null) {
16.38 - previewPanelHolder.remove(previewPanel);
16.39 - previewPanel.removeMouseListener(getHandler());
16.40 + JComponent previewPanel = this.chooser.getPreviewPanel();
16.41 + if (previewPanel == null) {
16.42 + previewPanel = ColorChooserComponentFactory.getPreviewPanel();
16.43 }
16.44 -
16.45 - previewPanel = chooser.getPreviewPanel();
16.46 - Dimension layoutSize = new Dimension(); // fix for bug 4759306
16.47 - if (previewPanel != null) {
16.48 - layoutSize = new BorderLayout().minimumLayoutSize(previewPanel);
16.49 - if ((previewPanelHolder != null) && (chooser != null) &&
16.50 - (layoutSize.getWidth() + layoutSize.getHeight() == 0)) {
16.51 - chooser.remove(previewPanelHolder);
16.52 - return;
16.53 + else {
16.54 + Dimension size = new BorderLayout().minimumLayoutSize(previewPanel);
16.55 + if ((size.width == 0) && (size.height == 0)) {
16.56 + previewPanel = null;
16.57 }
16.58 }
16.59 - if (previewPanel == null || previewPanel instanceof UIResource) {
16.60 - previewPanel = ColorChooserComponentFactory.getPreviewPanel(); // get from table?
16.61 - chooser.setPreviewPanel(previewPanel);
16.62 + this.previewPanel = previewPanel;
16.63 + if (previewPanel != null) {
16.64 + chooser.add(previewPanelHolder, BorderLayout.SOUTH);
16.65 + previewPanel.setForeground(chooser.getColor());
16.66 + previewPanelHolder.add(previewPanel);
16.67 + previewPanel.addMouseListener(getHandler());
16.68 + previewPanel.setInheritsPopupMenu(true);
16.69 }
16.70 - previewPanel.setForeground(chooser.getColor());
16.71 - previewPanelHolder.add(previewPanel);
16.72 - previewPanel.addMouseListener(getHandler());
16.73 - previewPanel.setInheritsPopupMenu(true);
16.74 + }
16.75 +
16.76 + /**
16.77 + * Removes installed preview panel from the UI delegate.
16.78 + *
16.79 + * @since 1.7
16.80 + */
16.81 + protected void uninstallPreviewPanel() {
16.82 + if (this.previewPanel != null) {
16.83 + this.previewPanel.removeMouseListener(getHandler());
16.84 + this.previewPanelHolder.remove(this.previewPanel);
16.85 + }
16.86 + this.chooser.remove(this.previewPanelHolder);
16.87 }
16.88
16.89 protected void installDefaults() {
16.90 @@ -209,7 +212,6 @@
16.91 chooser.removePropertyChangeListener( propertyChangeListener );
16.92 chooser.getSelectionModel().removeChangeListener(previewListener);
16.93 previewListener = null;
16.94 - previewPanel.removeMouseListener(getHandler());
16.95 }
16.96
16.97 private void selectionChanged(ColorSelectionModel model) {
16.98 @@ -312,9 +314,8 @@
16.99 }
16.100 }
16.101 else if (prop == JColorChooser.PREVIEW_PANEL_PROPERTY) {
16.102 - if (evt.getNewValue() != previewPanel) {
16.103 - installPreviewPanel();
16.104 - }
16.105 + uninstallPreviewPanel();
16.106 + installPreviewPanel();
16.107 }
16.108 else if (prop == JColorChooser.SELECTION_MODEL_PROPERTY) {
16.109 ColorSelectionModel oldModel = (ColorSelectionModel) evt.getOldValue();
16.110 @@ -352,5 +353,4 @@
16.111 super("color");
16.112 }
16.113 }
16.114 -
16.115 }
17.1 --- a/src/share/classes/javax/swing/plaf/basic/BasicComboPopup.java Fri Aug 06 12:52:07 2010 -0700
17.2 +++ b/src/share/classes/javax/swing/plaf/basic/BasicComboPopup.java Mon Aug 09 16:02:19 2010 -0700
17.3 @@ -202,8 +202,8 @@
17.4 * Implementation of ComboPopup.show().
17.5 */
17.6 public void show() {
17.7 + comboBox.firePopupMenuWillBecomeVisible();
17.8 setListSelection(comboBox.getSelectedIndex());
17.9 -
17.10 Point location = getPopupLocation();
17.11 show( comboBox, location.x, location.y );
17.12 }
17.13 @@ -344,7 +344,8 @@
17.14
17.15 protected void firePopupMenuWillBecomeVisible() {
17.16 super.firePopupMenuWillBecomeVisible();
17.17 - comboBox.firePopupMenuWillBecomeVisible();
17.18 + // comboBox.firePopupMenuWillBecomeVisible() is called from BasicComboPopup.show() method
17.19 + // to let the user change the popup menu from the PopupMenuListener.popupMenuWillBecomeVisible()
17.20 }
17.21
17.22 protected void firePopupMenuWillBecomeInvisible() {
18.1 --- a/src/share/classes/javax/swing/text/DefaultFormatter.java Fri Aug 06 12:52:07 2010 -0700
18.2 +++ b/src/share/classes/javax/swing/text/DefaultFormatter.java Mon Aug 09 16:02:19 2010 -0700
18.3 @@ -570,7 +570,9 @@
18.4 direction = -1;
18.5 }
18.6
18.7 - if (getOverwriteMode() && rh.text != null) {
18.8 + if (getOverwriteMode() && rh.text != null &&
18.9 + getFormattedTextField().getSelectedText() == null)
18.10 + {
18.11 rh.length = Math.min(Math.max(rh.length, rh.text.length()),
18.12 rh.fb.getDocument().getLength() - rh.offset);
18.13 }
19.1 --- a/src/share/classes/javax/swing/text/InternationalFormatter.java Fri Aug 06 12:52:07 2010 -0700
19.2 +++ b/src/share/classes/javax/swing/text/InternationalFormatter.java Mon Aug 09 16:02:19 2010 -0700
19.3 @@ -622,18 +622,8 @@
19.4
19.5 /**
19.6 * Overriden in an attempt to honor the literals.
19.7 - * <p>
19.8 - * If we do
19.9 - * not allow invalid values and are in overwrite mode, this does the
19.10 - * following for each character in the replacement range:
19.11 - * <ol>
19.12 - * <li>If the character is a literal, add it to the string to replace
19.13 - * with. If there is text to insert and it doesn't match the
19.14 - * literal, then insert the literal in the the middle of the insert
19.15 - * text. This allows you to either paste in literals or not and
19.16 - * get the same behavior.
19.17 - * <li>If there is no text to insert, replace it with ' '.
19.18 - * </ol>
19.19 + * <p>If we do not allow invalid values and are in overwrite mode, this
19.20 + * {@code rh.length} is corrected as to preserve trailing literals.
19.21 * If not in overwrite mode, and there is text to insert it is
19.22 * inserted at the next non literal index going forward. If there
19.23 * is only text to remove, it is removed from the next non literal
19.24 @@ -643,61 +633,27 @@
19.25 if (!getAllowsInvalid()) {
19.26 String text = rh.text;
19.27 int tl = (text != null) ? text.length() : 0;
19.28 + JTextComponent c = getFormattedTextField();
19.29
19.30 - if (tl == 0 && rh.length == 1 && getFormattedTextField().
19.31 - getSelectionStart() != rh.offset) {
19.32 + if (tl == 0 && rh.length == 1 && c.getSelectionStart() != rh.offset) {
19.33 // Backspace, adjust to actually delete next non-literal.
19.34 rh.offset = getNextNonliteralIndex(rh.offset, -1);
19.35 - }
19.36 - if (getOverwriteMode()) {
19.37 - StringBuffer replace = null;
19.38 + } else if (getOverwriteMode()) {
19.39 + int pos = rh.offset;
19.40 + int textPos = pos;
19.41 + boolean overflown = false;
19.42
19.43 - for (int counter = 0, textIndex = 0,
19.44 - max = Math.max(tl, rh.length); counter < max;
19.45 - counter++) {
19.46 - if (isLiteral(rh.offset + counter)) {
19.47 - if (replace != null) {
19.48 - replace.append(getLiteral(rh.offset +
19.49 - counter));
19.50 - }
19.51 - if (textIndex < tl && text.charAt(textIndex) ==
19.52 - getLiteral(rh.offset + counter)) {
19.53 - textIndex++;
19.54 - }
19.55 - else if (textIndex == 0) {
19.56 - rh.offset++;
19.57 - rh.length--;
19.58 - counter--;
19.59 - max--;
19.60 - }
19.61 - else if (replace == null) {
19.62 - replace = new StringBuffer(max);
19.63 - replace.append(text.substring(0, textIndex));
19.64 - replace.append(getLiteral(rh.offset +
19.65 - counter));
19.66 - }
19.67 + for (int i = 0; i < rh.length; i++) {
19.68 + while (isLiteral(pos)) pos++;
19.69 + if (pos >= string.length()) {
19.70 + pos = textPos;
19.71 + overflown = true;
19.72 + break;
19.73 }
19.74 - else if (textIndex < tl) {
19.75 - if (replace != null) {
19.76 - replace.append(text.charAt(textIndex));
19.77 - }
19.78 - textIndex++;
19.79 - }
19.80 - else {
19.81 - // Nothing to replace it with, assume ' '
19.82 - if (replace == null) {
19.83 - replace = new StringBuffer(max);
19.84 - if (textIndex > 0) {
19.85 - replace.append(text.substring(0, textIndex));
19.86 - }
19.87 - }
19.88 - if (replace != null) {
19.89 - replace.append(' ');
19.90 - }
19.91 - }
19.92 + textPos = ++pos;
19.93 }
19.94 - if (replace != null) {
19.95 - rh.text = replace.toString();
19.96 + if (overflown || c.getSelectedText() == null) {
19.97 + rh.length = pos - rh.offset;
19.98 }
19.99 }
19.100 else if (tl > 0) {
20.1 --- a/src/share/classes/sun/net/dns/ResolverConfiguration.java Fri Aug 06 12:52:07 2010 -0700
20.2 +++ b/src/share/classes/sun/net/dns/ResolverConfiguration.java Mon Aug 09 16:02:19 2010 -0700
20.3 @@ -1,5 +1,5 @@
20.4 /*
20.5 - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
20.6 + * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
20.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
20.8 *
20.9 * This code is free software; you can redistribute it and/or modify it
20.10 @@ -26,7 +26,6 @@
20.11 package sun.net.dns;
20.12
20.13 import java.util.List;
20.14 -import java.io.IOException;
20.15
20.16 /**
20.17 * The configuration of the client resolver.
20.18 @@ -68,7 +67,7 @@
20.19 *
20.20 * @return list of domain names
20.21 */
20.22 - public abstract List searchlist();
20.23 + public abstract List<String> searchlist();
20.24
20.25 /**
20.26 * Returns a list of name servers used for host name lookup.
20.27 @@ -78,7 +77,7 @@
20.28 *
20.29 * @return list of the name servers
20.30 */
20.31 - public abstract List nameservers();
20.32 + public abstract List<String> nameservers();
20.33
20.34
20.35 /**
21.1 --- a/src/share/classes/sun/net/spi/nameservice/dns/DNSNameService.java Fri Aug 06 12:52:07 2010 -0700
21.2 +++ b/src/share/classes/sun/net/spi/nameservice/dns/DNSNameService.java Mon Aug 09 16:02:19 2010 -0700
21.3 @@ -1,5 +1,5 @@
21.4 /*
21.5 - * Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved.
21.6 + * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
21.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
21.8 *
21.9 * This code is free software; you can redistribute it and/or modify it
21.10 @@ -45,20 +45,21 @@
21.11 public final class DNSNameService implements NameService {
21.12
21.13 // List of domains specified by property
21.14 - private LinkedList domainList = null;
21.15 + private LinkedList<String> domainList = null;
21.16
21.17 // JNDI-DNS URL for name servers specified via property
21.18 private String nameProviderUrl = null;
21.19
21.20 // Per-thread soft cache of the last temporary context
21.21 - private static ThreadLocal contextRef = new ThreadLocal();
21.22 + private static ThreadLocal<SoftReference<ThreadContext>> contextRef =
21.23 + new ThreadLocal<>();
21.24
21.25 // Simple class to encapsulate the temporary context
21.26 private static class ThreadContext {
21.27 private DirContext dirCtxt;
21.28 - private List nsList;
21.29 + private List<String> nsList;
21.30
21.31 - public ThreadContext(DirContext dirCtxt, List nsList) {
21.32 + public ThreadContext(DirContext dirCtxt, List<String> nsList) {
21.33 this.dirCtxt = dirCtxt;
21.34 this.nsList = nsList;
21.35 }
21.36 @@ -67,16 +68,16 @@
21.37 return dirCtxt;
21.38 }
21.39
21.40 - public List nameservers() {
21.41 + public List<String> nameservers() {
21.42 return nsList;
21.43 }
21.44 }
21.45
21.46 // Returns a per-thread DirContext
21.47 private DirContext getTemporaryContext() throws NamingException {
21.48 - SoftReference ref = (SoftReference)contextRef.get();
21.49 + SoftReference<ThreadContext> ref = contextRef.get();
21.50 ThreadContext thrCtxt = null;
21.51 - List nsList = null;
21.52 + List<String> nsList = null;
21.53
21.54 // if no property specified we need to obtain the list of servers
21.55 //
21.56 @@ -87,7 +88,7 @@
21.57 // specified then we need to check if the DNS configuration
21.58 // has changed.
21.59 //
21.60 - if ((ref != null) && ((thrCtxt = (ThreadContext)ref.get()) != null)) {
21.61 + if ((ref != null) && ((thrCtxt = ref.get()) != null)) {
21.62 if (nameProviderUrl == null) {
21.63 if (!thrCtxt.nameservers().equals(nsList)) {
21.64 // DNS configuration has changed
21.65 @@ -98,7 +99,7 @@
21.66
21.67 // new thread context needs to be created
21.68 if (thrCtxt == null) {
21.69 - final Hashtable<String,Object> env = new Hashtable<String,Object>();
21.70 + final Hashtable<String,Object> env = new Hashtable<>();
21.71 env.put("java.naming.factory.initial",
21.72 "com.sun.jndi.dns.DnsContextFactory");
21.73
21.74 @@ -119,10 +120,9 @@
21.75 //
21.76 DirContext dirCtxt;
21.77 try {
21.78 - dirCtxt = (DirContext)
21.79 - java.security.AccessController.doPrivileged(
21.80 - new java.security.PrivilegedExceptionAction() {
21.81 - public Object run() throws NamingException {
21.82 + dirCtxt = java.security.AccessController.doPrivileged(
21.83 + new java.security.PrivilegedExceptionAction<DirContext>() {
21.84 + public DirContext run() throws NamingException {
21.85 // Create the DNS context using NamingManager rather than using
21.86 // the initial context constructor. This avoids having the initial
21.87 // context constructor call itself.
21.88 @@ -130,7 +130,7 @@
21.89 if (!(ctx instanceof DirContext)) {
21.90 return null; // cannot create a DNS context
21.91 }
21.92 - return ctx;
21.93 + return (DirContext)ctx;
21.94 }
21.95 });
21.96 } catch (java.security.PrivilegedActionException pae) {
21.97 @@ -161,18 +161,18 @@
21.98 *
21.99 * @throws UnknownHostException if lookup fails or other error.
21.100 */
21.101 - private ArrayList resolve(final DirContext ctx, final String name, final String[] ids,
21.102 - int depth) throws UnknownHostException
21.103 + private ArrayList<String> resolve(final DirContext ctx, final String name,
21.104 + final String[] ids, int depth)
21.105 + throws UnknownHostException
21.106 {
21.107 - ArrayList results = new ArrayList();
21.108 + ArrayList<String> results = new ArrayList<>();
21.109 Attributes attrs;
21.110
21.111 // do the query
21.112 try {
21.113 - attrs = (Attributes)
21.114 - java.security.AccessController.doPrivileged(
21.115 - new java.security.PrivilegedExceptionAction() {
21.116 - public Object run() throws NamingException {
21.117 + attrs = java.security.AccessController.doPrivileged(
21.118 + new java.security.PrivilegedExceptionAction<Attributes>() {
21.119 + public Attributes run() throws NamingException {
21.120 return ctx.getAttributes(name, ids);
21.121 }
21.122 });
21.123 @@ -181,7 +181,7 @@
21.124 }
21.125
21.126 // non-requested type returned so enumeration is empty
21.127 - NamingEnumeration ne = attrs.getAll();
21.128 + NamingEnumeration<? extends Attribute> ne = attrs.getAll();
21.129 if (!ne.hasMoreElements()) {
21.130 throw new UnknownHostException("DNS record not found");
21.131 }
21.132 @@ -190,7 +190,7 @@
21.133 UnknownHostException uhe = null;
21.134 try {
21.135 while (ne.hasMoreElements()) {
21.136 - Attribute attr = (Attribute)ne.next();
21.137 + Attribute attr = ne.next();
21.138 String attrID = attr.getID();
21.139
21.140 for (NamingEnumeration e = attr.getAll(); e.hasMoreElements();) {
21.141 @@ -251,13 +251,12 @@
21.142 // no property specified so check host DNS resolver configured
21.143 // with at least one nameserver in dotted notation.
21.144 //
21.145 - List nsList = ResolverConfiguration.open().nameservers();
21.146 - if (nsList.size() == 0)
21.147 + List<String> nsList = ResolverConfiguration.open().nameservers();
21.148 + if (nsList.isEmpty()) {
21.149 throw new RuntimeException("no nameservers provided");
21.150 + }
21.151 boolean found = false;
21.152 - Iterator i = nsList.iterator();
21.153 - while (i.hasNext()) {
21.154 - String addr = (String)i.next();
21.155 + for (String addr: nsList) {
21.156 if (IPAddressUtil.isIPv4LiteralAddress(addr) ||
21.157 IPAddressUtil.isIPv6LiteralAddress(addr)) {
21.158 found = true;
21.159 @@ -308,8 +307,8 @@
21.160 // suffix if the list has one entry.
21.161
21.162 if (results == null) {
21.163 - List searchList = null;
21.164 - Iterator i;
21.165 + List<String> searchList = null;
21.166 + Iterator<String> i;
21.167 boolean usingSearchList = false;
21.168
21.169 if (domainList != null) {
21.170 @@ -324,7 +323,7 @@
21.171
21.172 // iterator through each domain suffix
21.173 while (i.hasNext()) {
21.174 - String parentDomain = (String)i.next();
21.175 + String parentDomain = i.next();
21.176 int start = 0;
21.177 while ((start = parentDomain.indexOf(".")) != -1
21.178 && start < parentDomain.length() -1) {
21.179 @@ -407,7 +406,7 @@
21.180 String literalip = "";
21.181 String[] ids = { "PTR" };
21.182 DirContext ctx;
21.183 - ArrayList results = null;
21.184 + ArrayList<String> results = null;
21.185 try {
21.186 ctx = getTemporaryContext();
21.187 } catch (NamingException nx) {
21.188 @@ -420,7 +419,7 @@
21.189 literalip += "IN-ADDR.ARPA.";
21.190
21.191 results = resolve(ctx, literalip, ids, 0);
21.192 - host = (String)results.get(0);
21.193 + host = results.get(0);
21.194 } else if (addr.length == 16) { // IPv6 Address
21.195 /**
21.196 * Because RFC 3152 changed the root domain name for reverse
21.197 @@ -437,7 +436,7 @@
21.198
21.199 try {
21.200 results = resolve(ctx, ip6lit, ids, 0);
21.201 - host = (String)results.get(0);
21.202 + host = results.get(0);
21.203 } catch (UnknownHostException e) {
21.204 host = null;
21.205 }
21.206 @@ -445,7 +444,7 @@
21.207 // IP6.ARPA lookup failed, let's try the older IP6.INT
21.208 ip6lit = literalip + "IP6.INT.";
21.209 results = resolve(ctx, ip6lit, ids, 0);
21.210 - host = (String)results.get(0);
21.211 + host = results.get(0);
21.212 }
21.213 }
21.214 } catch (Exception e) {
21.215 @@ -478,11 +477,10 @@
21.216 * @return String containing the JNDI-DNS provider URL
21.217 * corresponding to the supplied List of nameservers.
21.218 */
21.219 - private static String createProviderURL(List nsList) {
21.220 - Iterator i = nsList.iterator();
21.221 + private static String createProviderURL(List<String> nsList) {
21.222 StringBuffer sb = new StringBuffer();
21.223 - while (i.hasNext()) {
21.224 - appendIfLiteralAddress((String)i.next(), sb);
21.225 + for (String s: nsList) {
21.226 + appendIfLiteralAddress(s, sb);
21.227 }
21.228 return sb.toString();
21.229 }
22.1 --- a/src/share/classes/sun/nio/ch/SocketAdaptor.java Fri Aug 06 12:52:07 2010 -0700
22.2 +++ b/src/share/classes/sun/nio/ch/SocketAdaptor.java Mon Aug 09 16:02:19 2010 -0700
22.3 @@ -336,7 +336,12 @@
22.4 }
22.5
22.6 public void sendUrgentData(int data) throws IOException {
22.7 - throw new SocketException("Urgent data not supported");
22.8 + synchronized (sc.blockingLock()) {
22.9 + if (!sc.isBlocking())
22.10 + throw new IllegalBlockingModeException();
22.11 + int n = sc.sendOutOfBandData((byte)data);
22.12 + assert n == 1;
22.13 + }
22.14 }
22.15
22.16 public void setOOBInline(boolean on) throws SocketException {
23.1 --- a/src/share/classes/sun/nio/ch/SocketChannelImpl.java Fri Aug 06 12:52:07 2010 -0700
23.2 +++ b/src/share/classes/sun/nio/ch/SocketChannelImpl.java Mon Aug 09 16:02:19 2010 -0700
23.3 @@ -498,6 +498,36 @@
23.4 return write0(Util.subsequence(srcs, offset, length));
23.5 }
23.6
23.7 + // package-private
23.8 + int sendOutOfBandData(byte b) throws IOException {
23.9 + synchronized (writeLock) {
23.10 + ensureWriteOpen();
23.11 + int n = 0;
23.12 + try {
23.13 + begin();
23.14 + synchronized (stateLock) {
23.15 + if (!isOpen())
23.16 + return 0;
23.17 + writerThread = NativeThread.current();
23.18 + }
23.19 + for (;;) {
23.20 + n = sendOutOfBandData(fd, b);
23.21 + if ((n == IOStatus.INTERRUPTED) && isOpen())
23.22 + continue;
23.23 + return IOStatus.normalize(n);
23.24 + }
23.25 + } finally {
23.26 + writerCleanup();
23.27 + end((n > 0) || (n == IOStatus.UNAVAILABLE));
23.28 + synchronized (stateLock) {
23.29 + if ((n <= 0) && (!isOutputOpen))
23.30 + throw new AsynchronousCloseException();
23.31 + }
23.32 + assert IOStatus.check(n);
23.33 + }
23.34 + }
23.35 + }
23.36 +
23.37 protected void implConfigureBlocking(boolean block) throws IOException {
23.38 IOUtil.configureBlocking(fd, block);
23.39 }
23.40 @@ -957,6 +987,9 @@
23.41 boolean block, boolean ready)
23.42 throws IOException;
23.43
23.44 + private static native int sendOutOfBandData(FileDescriptor fd, byte data)
23.45 + throws IOException;
23.46 +
23.47 static {
23.48 Util.load();
23.49 nd = new SocketDispatcher();
24.1 --- a/src/share/classes/sun/security/krb5/Config.java Fri Aug 06 12:52:07 2010 -0700
24.2 +++ b/src/share/classes/sun/security/krb5/Config.java Mon Aug 09 16:02:19 2010 -0700
24.3 @@ -42,6 +42,8 @@
24.4 import java.util.StringTokenizer;
24.5 import java.net.InetAddress;
24.6 import java.net.UnknownHostException;
24.7 +import java.util.List;
24.8 +import sun.net.dns.ResolverConfiguration;
24.9 import sun.security.krb5.internal.crypto.EType;
24.10 import sun.security.krb5.internal.ktab.*;
24.11 import sun.security.krb5.internal.Krb5;
24.12 @@ -1180,6 +1182,33 @@
24.13 }
24.14 // get the domain realm mapping from the configuration
24.15 String mapRealm = PrincipalName.mapHostToRealm(hostName);
24.16 + if (mapRealm == null) {
24.17 + // No match. Try search and/or domain in /etc/resolv.conf
24.18 + List<String> srchlist = ResolverConfiguration.open().searchlist();
24.19 + for (String domain: srchlist) {
24.20 + realm = checkRealm(domain);
24.21 + if (realm != null) {
24.22 + break;
24.23 + }
24.24 + }
24.25 + } else {
24.26 + realm = checkRealm(mapRealm);
24.27 + }
24.28 + if (realm == null) {
24.29 + throw new KrbException(Krb5.KRB_ERR_GENERIC,
24.30 + "Unable to locate Kerberos realm");
24.31 + }
24.32 + return realm;
24.33 + }
24.34 +
24.35 + /**
24.36 + * Check if the provided realm is the correct realm
24.37 + * @return the realm if correct, or null otherwise
24.38 + */
24.39 + private static String checkRealm(String mapRealm) {
24.40 + if (DEBUG) {
24.41 + System.out.println("getRealmFromDNS: trying " + mapRealm);
24.42 + }
24.43 String[] records = null;
24.44 String newRealm = mapRealm;
24.45 while ((records == null) && (newRealm != null)) {
24.46 @@ -1188,23 +1217,14 @@
24.47 newRealm = Realm.parseRealmComponent(newRealm);
24.48 // if no DNS TXT records found, try again using sub-realm
24.49 }
24.50 - if (records == null) {
24.51 - // no DNS TXT records
24.52 - throw new KrbException(Krb5.KRB_ERR_GENERIC,
24.53 - "Unable to locate Kerberos realm");
24.54 - }
24.55 - boolean found = false;
24.56 - for (int i = 0; i < records.length; i++) {
24.57 - if (records[i].equals(mapRealm)) {
24.58 - found = true;
24.59 - realm = records[i];
24.60 + if (records != null) {
24.61 + for (int i = 0; i < records.length; i++) {
24.62 + if (records[i].equalsIgnoreCase(mapRealm)) {
24.63 + return records[i];
24.64 + }
24.65 }
24.66 }
24.67 - if (found == false) {
24.68 - throw new KrbException(Krb5.KRB_ERR_GENERIC,
24.69 - "Unable to locate Kerberos realm");
24.70 - }
24.71 - return realm;
24.72 + return null;
24.73 }
24.74
24.75 /**
24.76 @@ -1218,10 +1238,16 @@
24.77 String kdcs = null;
24.78 String[] srvs = null;
24.79 // locate DNS SRV record using UDP
24.80 - srvs = KrbServiceLocator.getKerberosService(realm, "_udp.");
24.81 + if (DEBUG) {
24.82 + System.out.println("getKDCFromDNS using UDP");
24.83 + }
24.84 + srvs = KrbServiceLocator.getKerberosService(realm, "_udp");
24.85 if (srvs == null) {
24.86 // locate DNS SRV record using TCP
24.87 - srvs = KrbServiceLocator.getKerberosService(realm, "_tcp.");
24.88 + if (DEBUG) {
24.89 + System.out.println("getKDCFromDNS using UDP");
24.90 + }
24.91 + srvs = KrbServiceLocator.getKerberosService(realm, "_tcp");
24.92 }
24.93 if (srvs == null) {
24.94 // no DNS SRV records
25.1 --- a/src/share/classes/sun/security/krb5/Credentials.java Fri Aug 06 12:52:07 2010 -0700
25.2 +++ b/src/share/classes/sun/security/krb5/Credentials.java Mon Aug 09 16:02:19 2010 -0700
25.3 @@ -36,6 +36,7 @@
25.4 import sun.security.krb5.internal.crypto.EType;
25.5 import java.io.IOException;
25.6 import java.util.Date;
25.7 +import java.util.Locale;
25.8 import java.net.InetAddress;
25.9
25.10 /**
25.11 @@ -287,7 +288,7 @@
25.12 // The default ticket cache on Windows is not a file.
25.13 String os = java.security.AccessController.doPrivileged(
25.14 new sun.security.action.GetPropertyAction("os.name"));
25.15 - if (os.toUpperCase().startsWith("WINDOWS")) {
25.16 + if (os.toUpperCase(Locale.ENGLISH).startsWith("WINDOWS")) {
25.17 Credentials creds = acquireDefaultCreds();
25.18 if (creds == null) {
25.19 if (DEBUG) {
26.1 --- a/src/share/classes/sun/security/pkcs/PKCS9Attribute.java Fri Aug 06 12:52:07 2010 -0700
26.2 +++ b/src/share/classes/sun/security/pkcs/PKCS9Attribute.java Mon Aug 09 16:02:19 2010 -0700
26.3 @@ -1,5 +1,5 @@
26.4 /*
26.5 - * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
26.6 + * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
26.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
26.8 *
26.9 * This code is free software; you can redistribute it and/or modify it
26.10 @@ -28,6 +28,7 @@
26.11 import java.io.IOException;
26.12 import java.io.OutputStream;
26.13 import java.security.cert.CertificateException;
26.14 +import java.util.Locale;
26.15 import java.util.Date;
26.16 import java.util.Hashtable;
26.17 import sun.security.x509.CertificateExtensions;
26.18 @@ -742,7 +743,7 @@
26.19 * the name.
26.20 */
26.21 public static ObjectIdentifier getOID(String name) {
26.22 - return NAME_OID_TABLE.get(name.toLowerCase());
26.23 + return NAME_OID_TABLE.get(name.toLowerCase(Locale.ENGLISH));
26.24 }
26.25
26.26 /**
27.1 --- a/src/share/classes/sun/security/pkcs11/P11Cipher.java Fri Aug 06 12:52:07 2010 -0700
27.2 +++ b/src/share/classes/sun/security/pkcs11/P11Cipher.java Mon Aug 09 16:02:19 2010 -0700
27.3 @@ -26,6 +26,7 @@
27.4
27.5 import java.nio.ByteBuffer;
27.6 import java.util.Arrays;
27.7 +import java.util.Locale;
27.8
27.9 import java.security.*;
27.10 import java.security.spec.*;
27.11 @@ -201,7 +202,7 @@
27.12 }
27.13
27.14 private int parseMode(String mode) throws NoSuchAlgorithmException {
27.15 - mode = mode.toUpperCase();
27.16 + mode = mode.toUpperCase(Locale.ENGLISH);
27.17 int result;
27.18 if (mode.equals("ECB")) {
27.19 result = MODE_ECB;
27.20 @@ -222,7 +223,7 @@
27.21 throws NoSuchPaddingException {
27.22 paddingObj = null;
27.23 padBuffer = null;
27.24 - padding = padding.toUpperCase();
27.25 + padding = padding.toUpperCase(Locale.ENGLISH);
27.26 if (padding.equals("NOPADDING")) {
27.27 paddingType = PAD_NONE;
27.28 } else if (padding.equals("PKCS5PADDING")) {
28.1 --- a/src/share/classes/sun/security/pkcs11/P11RSACipher.java Fri Aug 06 12:52:07 2010 -0700
28.2 +++ b/src/share/classes/sun/security/pkcs11/P11RSACipher.java Mon Aug 09 16:02:19 2010 -0700
28.3 @@ -29,6 +29,8 @@
28.4 import java.security.spec.AlgorithmParameterSpec;
28.5 import java.security.spec.*;
28.6
28.7 +import java.util.Locale;
28.8 +
28.9 import javax.crypto.*;
28.10 import javax.crypto.spec.*;
28.11
28.12 @@ -110,7 +112,7 @@
28.13
28.14 protected void engineSetPadding(String padding)
28.15 throws NoSuchPaddingException {
28.16 - String lowerPadding = padding.toLowerCase();
28.17 + String lowerPadding = padding.toLowerCase(Locale.ENGLISH);
28.18 if (lowerPadding.equals("pkcs1Padding")) {
28.19 // empty
28.20 } else {
29.1 --- a/src/share/classes/sun/security/provider/certpath/URICertStore.java Fri Aug 06 12:52:07 2010 -0700
29.2 +++ b/src/share/classes/sun/security/provider/certpath/URICertStore.java Mon Aug 09 16:02:19 2010 -0700
29.3 @@ -1,5 +1,5 @@
29.4 /*
29.5 - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
29.6 + * Copyright (c) 2006, 2010 Oracle and/or its affiliates. All rights reserved.
29.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
29.8 *
29.9 * This code is free software; you can redistribute it and/or modify it
29.10 @@ -52,6 +52,7 @@
29.11 import java.util.Collection;
29.12 import java.util.Collections;
29.13 import java.util.List;
29.14 +import java.util.Locale;
29.15 import sun.security.x509.AccessDescription;
29.16 import sun.security.x509.GeneralNameInterface;
29.17 import sun.security.x509.URIName;
29.18 @@ -162,7 +163,7 @@
29.19 }
29.20 this.uri = ((URICertStoreParameters) params).uri;
29.21 // if ldap URI, use an LDAPCertStore to fetch certs and CRLs
29.22 - if (uri.getScheme().toLowerCase().equals("ldap")) {
29.23 + if (uri.getScheme().toLowerCase(Locale.ENGLISH).equals("ldap")) {
29.24 if (LDAP.helper() == null)
29.25 throw new NoSuchAlgorithmException("LDAP not present");
29.26 ldap = true;
30.1 --- a/src/share/classes/sun/security/util/Debug.java Fri Aug 06 12:52:07 2010 -0700
30.2 +++ b/src/share/classes/sun/security/util/Debug.java Mon Aug 09 16:02:19 2010 -0700
30.3 @@ -1,5 +1,5 @@
30.4 /*
30.5 - * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
30.6 + * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
30.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
30.8 *
30.9 * This code is free software; you can redistribute it and/or modify it
30.10 @@ -28,6 +28,7 @@
30.11 import java.math.BigInteger;
30.12 import java.util.regex.Pattern;
30.13 import java.util.regex.Matcher;
30.14 +import java.util.Locale;
30.15
30.16 /**
30.17 * A utility class for debuging.
30.18 @@ -262,7 +263,7 @@
30.19 source = left;
30.20
30.21 // convert the rest to lower-case characters
30.22 - target.append(source.toString().toLowerCase());
30.23 + target.append(source.toString().toLowerCase(Locale.ENGLISH));
30.24
30.25 return target.toString();
30.26 }
31.1 --- a/src/share/classes/sun/security/util/DerOutputStream.java Fri Aug 06 12:52:07 2010 -0700
31.2 +++ b/src/share/classes/sun/security/util/DerOutputStream.java Mon Aug 09 16:02:19 2010 -0700
31.3 @@ -1,5 +1,5 @@
31.4 /*
31.5 - * Copyright (c) 1996, 2009, Oracle and/or its affiliates. All rights reserved.
31.6 + * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
31.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
31.8 *
31.9 * This code is free software; you can redistribute it and/or modify it
31.10 @@ -25,17 +25,16 @@
31.11
31.12 package sun.security.util;
31.13
31.14 -import java.io.FilterOutputStream;
31.15 import java.io.ByteArrayOutputStream;
31.16 import java.io.OutputStream;
31.17 import java.io.IOException;
31.18 import java.text.SimpleDateFormat;
31.19 import java.util.Date;
31.20 import java.util.TimeZone;
31.21 -import java.util.Vector;
31.22 import java.util.Comparator;
31.23 import java.util.Arrays;
31.24 import java.math.BigInteger;
31.25 +import java.util.Locale;
31.26
31.27
31.28 /**
31.29 @@ -501,7 +500,7 @@
31.30 pattern = "yyyyMMddHHmmss'Z'";
31.31 }
31.32
31.33 - SimpleDateFormat sdf = new SimpleDateFormat(pattern);
31.34 + SimpleDateFormat sdf = new SimpleDateFormat(pattern, Locale.US);
31.35 sdf.setTimeZone(tz);
31.36 byte[] time = (sdf.format(d)).getBytes("ISO-8859-1");
31.37
32.1 --- a/src/share/classes/sun/security/x509/AVA.java Fri Aug 06 12:52:07 2010 -0700
32.2 +++ b/src/share/classes/sun/security/x509/AVA.java Mon Aug 09 16:02:19 2010 -0700
32.3 @@ -1,5 +1,5 @@
32.4 /*
32.5 - * Copyright (c) 1996, 2008, Oracle and/or its affiliates. All rights reserved.
32.6 + * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
32.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
32.8 *
32.9 * This code is free software; you can redistribute it and/or modify it
32.10 @@ -1227,7 +1227,7 @@
32.11 (String keyword, int standard, Map<String, String> extraKeywordMap)
32.12 throws IOException {
32.13
32.14 - keyword = keyword.toUpperCase();
32.15 + keyword = keyword.toUpperCase(Locale.ENGLISH);
32.16 if (standard == AVA.RFC2253) {
32.17 if (keyword.startsWith(" ") || keyword.endsWith(" ")) {
32.18 throw new IOException("Invalid leading or trailing space " +
33.1 --- a/src/share/classes/sun/security/x509/AlgorithmId.java Fri Aug 06 12:52:07 2010 -0700
33.2 +++ b/src/share/classes/sun/security/x509/AlgorithmId.java Mon Aug 09 16:02:19 2010 -0700
33.3 @@ -1,5 +1,5 @@
33.4 /*
33.5 - * Copyright (c) 1996, 2009, Oracle and/or its affiliates. All rights reserved.
33.6 + * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
33.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
33.8 *
33.9 * This code is free software; you can redistribute it and/or modify it
33.10 @@ -553,9 +553,10 @@
33.11 for (Enumeration<Object> enum_ = provs[i].keys();
33.12 enum_.hasMoreElements(); ) {
33.13 String alias = (String)enum_.nextElement();
33.14 + String upperCaseAlias = alias.toUpperCase(Locale.ENGLISH);
33.15 int index;
33.16 - if (alias.toUpperCase().startsWith("ALG.ALIAS") &&
33.17 - (index=alias.toUpperCase().indexOf("OID.", 0)) != -1) {
33.18 + if (upperCaseAlias.startsWith("ALG.ALIAS") &&
33.19 + (index=upperCaseAlias.indexOf("OID.", 0)) != -1) {
33.20 index += "OID.".length();
33.21 if (index == alias.length()) {
33.22 // invalid alias entry
33.23 @@ -565,19 +566,26 @@
33.24 oidTable = new HashMap<String,ObjectIdentifier>();
33.25 }
33.26 oidString = alias.substring(index);
33.27 - String stdAlgName
33.28 - = provs[i].getProperty(alias).toUpperCase();
33.29 - if (oidTable.get(stdAlgName) == null) {
33.30 + String stdAlgName = provs[i].getProperty(alias);
33.31 + if (stdAlgName != null) {
33.32 + stdAlgName = stdAlgName.toUpperCase(Locale.ENGLISH);
33.33 + }
33.34 + if (stdAlgName != null &&
33.35 + oidTable.get(stdAlgName) == null) {
33.36 oidTable.put(stdAlgName,
33.37 new ObjectIdentifier(oidString));
33.38 }
33.39 }
33.40 }
33.41 }
33.42 +
33.43 + if (oidTable == null) {
33.44 + oidTable = new HashMap<String,ObjectIdentifier>(1);
33.45 + }
33.46 initOidTable = true;
33.47 }
33.48
33.49 - return oidTable.get(name.toUpperCase());
33.50 + return oidTable.get(name.toUpperCase(Locale.ENGLISH));
33.51 }
33.52
33.53 private static ObjectIdentifier oid(int ... values) {
34.1 --- a/src/share/classes/sun/security/x509/DNSName.java Fri Aug 06 12:52:07 2010 -0700
34.2 +++ b/src/share/classes/sun/security/x509/DNSName.java Mon Aug 09 16:02:19 2010 -0700
34.3 @@ -1,5 +1,5 @@
34.4 /*
34.5 - * Copyright (c) 1997, 2000, Oracle and/or its affiliates. All rights reserved.
34.6 + * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
34.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
34.8 *
34.9 * This code is free software; you can redistribute it and/or modify it
34.10 @@ -26,6 +26,7 @@
34.11 package sun.security.x509;
34.12
34.13 import java.io.IOException;
34.14 +import java.util.Locale;
34.15
34.16 import sun.security.util.*;
34.17
34.18 @@ -198,8 +199,9 @@
34.19 else if (inputName.getType() != NAME_DNS)
34.20 constraintType = NAME_DIFF_TYPE;
34.21 else {
34.22 - String inName = (((DNSName)inputName).getName()).toLowerCase();
34.23 - String thisName = name.toLowerCase();
34.24 + String inName =
34.25 + (((DNSName)inputName).getName()).toLowerCase(Locale.ENGLISH);
34.26 + String thisName = name.toLowerCase(Locale.ENGLISH);
34.27 if (inName.equals(thisName))
34.28 constraintType = NAME_MATCH;
34.29 else if (thisName.endsWith(inName)) {
35.1 --- a/src/share/classes/sun/security/x509/RFC822Name.java Fri Aug 06 12:52:07 2010 -0700
35.2 +++ b/src/share/classes/sun/security/x509/RFC822Name.java Mon Aug 09 16:02:19 2010 -0700
35.3 @@ -1,5 +1,5 @@
35.4 /*
35.5 - * Copyright (c) 1997, 2000, Oracle and/or its affiliates. All rights reserved.
35.6 + * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
35.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
35.8 *
35.9 * This code is free software; you can redistribute it and/or modify it
35.10 @@ -26,6 +26,7 @@
35.11 package sun.security.x509;
35.12
35.13 import java.io.IOException;
35.14 +import java.util.Locale;
35.15
35.16 import sun.security.util.*;
35.17
35.18 @@ -187,8 +188,9 @@
35.19 constraintType = NAME_DIFF_TYPE;
35.20 } else {
35.21 //RFC2459 specifies that case is not significant in RFC822Names
35.22 - String inName = (((RFC822Name)inputName).getName()).toLowerCase();
35.23 - String thisName = name.toLowerCase();
35.24 + String inName =
35.25 + (((RFC822Name)inputName).getName()).toLowerCase(Locale.ENGLISH);
35.26 + String thisName = name.toLowerCase(Locale.ENGLISH);
35.27 if (inName.equals(thisName)) {
35.28 constraintType = NAME_MATCH;
35.29 } else if (thisName.endsWith(inName)) {
36.1 --- a/src/solaris/classes/sun/net/dns/ResolverConfigurationImpl.java Fri Aug 06 12:52:07 2010 -0700
36.2 +++ b/src/solaris/classes/sun/net/dns/ResolverConfigurationImpl.java Mon Aug 09 16:02:19 2010 -0700
36.3 @@ -1,5 +1,5 @@
36.4 /*
36.5 - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
36.6 + * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
36.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
36.8 *
36.9 * This code is free software; you can redistribute it and/or modify it
36.10 @@ -56,8 +56,11 @@
36.11 // Parse /etc/resolv.conf to get the values for a particular
36.12 // keyword.
36.13 //
36.14 - private LinkedList resolvconf(String keyword, int maxperkeyword, int maxkeywords) {
36.15 - LinkedList ll = new LinkedList();
36.16 + private LinkedList<String> resolvconf(String keyword,
36.17 + int maxperkeyword,
36.18 + int maxkeywords)
36.19 + {
36.20 + LinkedList<String> ll = new LinkedList<>();
36.21
36.22 try {
36.23 BufferedReader in =
36.24 @@ -99,8 +102,8 @@
36.25 return ll;
36.26 }
36.27
36.28 - private LinkedList searchlist;
36.29 - private LinkedList nameservers;
36.30 + private LinkedList<String> searchlist;
36.31 + private LinkedList<String> nameservers;
36.32
36.33
36.34 // Load DNS configuration from OS
36.35 @@ -118,9 +121,9 @@
36.36
36.37 // get the name servers from /etc/resolv.conf
36.38 nameservers =
36.39 - (LinkedList)java.security.AccessController.doPrivileged(
36.40 - new java.security.PrivilegedAction() {
36.41 - public Object run() {
36.42 + java.security.AccessController.doPrivileged(
36.43 + new java.security.PrivilegedAction<LinkedList<String>>() {
36.44 + public LinkedList<String> run() {
36.45 // typically MAXNS is 3 but we've picked 5 here
36.46 // to allow for additional servers if required.
36.47 return resolvconf("nameserver", 1, 5);
36.48 @@ -137,15 +140,15 @@
36.49
36.50 // obtain search list or local domain
36.51
36.52 - private LinkedList getSearchList() {
36.53 + private LinkedList<String> getSearchList() {
36.54
36.55 - LinkedList sl;
36.56 + LinkedList<String> sl;
36.57
36.58 // first try the search keyword in /etc/resolv.conf
36.59
36.60 - sl = (LinkedList)java.security.AccessController.doPrivileged(
36.61 - new java.security.PrivilegedAction() {
36.62 - public Object run() {
36.63 + sl = java.security.AccessController.doPrivileged(
36.64 + new java.security.PrivilegedAction<LinkedList<String>>() {
36.65 + public LinkedList<String> run() {
36.66 LinkedList ll;
36.67
36.68 // first try search keyword (max 6 domains)
36.69 @@ -177,10 +180,10 @@
36.70
36.71 // try domain keyword in /etc/resolv.conf
36.72
36.73 - sl = (LinkedList)java.security.AccessController.doPrivileged(
36.74 - new java.security.PrivilegedAction() {
36.75 - public Object run() {
36.76 - LinkedList ll;
36.77 + sl = java.security.AccessController.doPrivileged(
36.78 + new java.security.PrivilegedAction<LinkedList<String>>() {
36.79 + public LinkedList<String> run() {
36.80 + LinkedList<String> ll;
36.81
36.82 ll = resolvconf("domain", 1, 1);
36.83 if (ll.size() > 0) {
36.84 @@ -197,7 +200,7 @@
36.85 // no local domain so try fallback (RPC) domain or
36.86 // hostname
36.87
36.88 - sl = new LinkedList();
36.89 + sl = new LinkedList<>();
36.90 String domain = fallbackDomain0();
36.91 if (domain != null && domain.length() > 0) {
36.92 sl.add(domain);
36.93 @@ -213,7 +216,7 @@
36.94 opts = new OptionsImpl();
36.95 }
36.96
36.97 - public List searchlist() {
36.98 + public List<String> searchlist() {
36.99 synchronized (lock) {
36.100 loadConfig();
36.101
36.102 @@ -222,7 +225,7 @@
36.103 }
36.104 }
36.105
36.106 - public List nameservers() {
36.107 + public List<String> nameservers() {
36.108 synchronized (lock) {
36.109 loadConfig();
36.110
37.1 --- a/src/solaris/native/java/net/NetworkInterface.c Fri Aug 06 12:52:07 2010 -0700
37.2 +++ b/src/solaris/native/java/net/NetworkInterface.c Mon Aug 09 16:02:19 2010 -0700
37.3 @@ -131,7 +131,7 @@
37.4 static short getSubnet(JNIEnv *env, int sock, const char *ifname);
37.5 static int getIndex(int sock, const char *ifname);
37.6
37.7 -static int getFlags(JNIEnv *env, int sock, const char *ifname);
37.8 +static int getFlags(int sock, const char *ifname);
37.9 static int getMacAddress(JNIEnv *env, int sock, const char* ifname, const struct in_addr* addr, unsigned char *buf);
37.10 static int getMTU(JNIEnv *env, int sock, const char *ifname);
37.11
37.12 @@ -550,7 +550,7 @@
37.13
37.14 name_utf = (*env)->GetStringUTFChars(env, name, &isCopy);
37.15
37.16 - ret = getFlags(env, sock, name_utf);
37.17 + ret = getFlags(sock, name_utf);
37.18
37.19 close(sock);
37.20 (*env)->ReleaseStringUTFChars(env, name, name_utf);
37.21 @@ -753,19 +753,27 @@
37.22 * If IPv6 is available then enumerate IPv6 addresses.
37.23 */
37.24 #ifdef AF_INET6
37.25 - sock = openSocket(env, AF_INET6);
37.26 - if (sock < 0 && (*env)->ExceptionOccurred(env)) {
37.27 - freeif(ifs);
37.28 - return NULL;
37.29 - }
37.30
37.31 - ifs = enumIPv6Interfaces(env, sock, ifs);
37.32 - close(sock);
37.33 + /* User can disable ipv6 expicitly by -Djava.net.preferIPv4Stack=true,
37.34 + * so we have to call ipv6_available()
37.35 + */
37.36 + if (ipv6_available()) {
37.37
37.38 - if ((*env)->ExceptionOccurred(env)) {
37.39 - freeif(ifs);
37.40 - return NULL;
37.41 - }
37.42 + sock = openSocket(env, AF_INET6);
37.43 + if (sock < 0 && (*env)->ExceptionOccurred(env)) {
37.44 + freeif(ifs);
37.45 + return NULL;
37.46 + }
37.47 +
37.48 + ifs = enumIPv6Interfaces(env, sock, ifs);
37.49 + close(sock);
37.50 +
37.51 + if ((*env)->ExceptionOccurred(env)) {
37.52 + freeif(ifs);
37.53 + return NULL;
37.54 + }
37.55 +
37.56 + }
37.57 #endif
37.58
37.59 return ifs;
37.60 @@ -877,7 +885,7 @@
37.61 * the 'parent' interface with the new records.
37.62 */
37.63 *name_colonP = 0;
37.64 - if (getFlags(env,sock,name) < 0) {
37.65 + if (getFlags(sock, name) < 0) {
37.66 // failed to access parent interface do not create parent.
37.67 // We are a virtual interface with no parent.
37.68 isVirtual = 1;
37.69 @@ -1249,7 +1257,7 @@
37.70 return if2.ifr_mtu;
37.71 }
37.72
37.73 -static int getFlags(JNIEnv *env, int sock, const char *ifname) {
37.74 +static int getFlags(int sock, const char *ifname) {
37.75 struct ifreq if2;
37.76 int ret = -1;
37.77
37.78 @@ -1625,13 +1633,12 @@
37.79 }
37.80
37.81
37.82 -static int getFlags(JNIEnv *env, int sock, const char *ifname) {
37.83 +static int getFlags(int sock, const char *ifname) {
37.84 struct lifreq lifr;
37.85 memset((caddr_t)&lifr, 0, sizeof(lifr));
37.86 strcpy((caddr_t)&(lifr.lifr_name), ifname);
37.87
37.88 if (ioctl(sock, SIOCGLIFFLAGS, (char *)&lifr) < 0) {
37.89 - NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "IOCTL SIOCGLIFFLAGS failed");
37.90 return -1;
37.91 }
37.92
38.1 --- a/src/solaris/native/java/nio/MappedByteBuffer.c Fri Aug 06 12:52:07 2010 -0700
38.2 +++ b/src/solaris/native/java/nio/MappedByteBuffer.c Mon Aug 09 16:02:19 2010 -0700
38.3 @@ -32,14 +32,11 @@
38.4 #include <stddef.h>
38.5 #include <stdlib.h>
38.6
38.7 -
38.8 JNIEXPORT jboolean JNICALL
38.9 -Java_java_nio_MappedByteBuffer_isLoaded0(JNIEnv *env, jobject obj,
38.10 - jlong address, jlong len)
38.11 +Java_java_nio_MappedByteBuffer_isLoaded0(JNIEnv *env, jobject obj, jlong address,
38.12 + jlong len, jint numPages)
38.13 {
38.14 jboolean loaded = JNI_TRUE;
38.15 - jint pageSize = sysconf(_SC_PAGESIZE);
38.16 - jint numPages = (len + pageSize - 1) / pageSize;
38.17 int result = 0;
38.18 int i = 0;
38.19 void *a = (void *) jlong_to_ptr(address);
38.20 @@ -55,9 +52,9 @@
38.21 }
38.22
38.23 result = mincore(a, (size_t)len, vec);
38.24 - if (result != 0) {
38.25 + if (result == -1) {
38.26 + JNU_ThrowIOExceptionWithLastError(env, "mincore failed");
38.27 free(vec);
38.28 - JNU_ThrowIOExceptionWithLastError(env, "mincore failed");
38.29 return JNI_FALSE;
38.30 }
38.31
38.32 @@ -72,23 +69,15 @@
38.33 }
38.34
38.35
38.36 -JNIEXPORT jint JNICALL
38.37 +JNIEXPORT void JNICALL
38.38 Java_java_nio_MappedByteBuffer_load0(JNIEnv *env, jobject obj, jlong address,
38.39 - jlong len, jint pageSize)
38.40 + jlong len)
38.41 {
38.42 - int pageIncrement = pageSize / sizeof(int);
38.43 - int numPages = (len + pageSize - 1) / pageSize;
38.44 - int *ptr = (int *)jlong_to_ptr(address);
38.45 - int i = 0;
38.46 - int j = 0;
38.47 - int result = madvise((caddr_t)ptr, len, MADV_WILLNEED);
38.48 -
38.49 - /* touch every page */
38.50 - for (i=0; i<numPages; i++) {
38.51 - j += *((volatile int *)ptr);
38.52 - ptr += pageIncrement;
38.53 + char *a = (char *)jlong_to_ptr(address);
38.54 + int result = madvise((caddr_t)a, (size_t)len, MADV_WILLNEED);
38.55 + if (result == -1) {
38.56 + JNU_ThrowIOExceptionWithLastError(env, "madvise failed");
38.57 }
38.58 - return j;
38.59 }
38.60
38.61
38.62 @@ -96,13 +85,9 @@
38.63 Java_java_nio_MappedByteBuffer_force0(JNIEnv *env, jobject obj, jlong address,
38.64 jlong len)
38.65 {
38.66 - jlong pageSize = sysconf(_SC_PAGESIZE);
38.67 - unsigned long lAddress = address;
38.68 -
38.69 - jlong offset = lAddress % pageSize;
38.70 - void *a = (void *) jlong_to_ptr(lAddress - offset);
38.71 - int result = msync(a, (size_t)(len + offset), MS_SYNC);
38.72 - if (result != 0) {
38.73 + void* a = (void *)jlong_to_ptr(address);
38.74 + int result = msync(a, (size_t)len, MS_SYNC);
38.75 + if (result == -1) {
38.76 JNU_ThrowIOExceptionWithLastError(env, "msync failed");
38.77 }
38.78 }
39.1 --- a/src/solaris/native/sun/nio/ch/SocketChannelImpl.c Fri Aug 06 12:52:07 2010 -0700
39.2 +++ b/src/solaris/native/sun/nio/ch/SocketChannelImpl.c Mon Aug 09 16:02:19 2010 -0700
39.3 @@ -84,3 +84,11 @@
39.4 }
39.5 return 0;
39.6 }
39.7 +
39.8 +JNIEXPORT jint JNICALL
39.9 +Java_sun_nio_ch_SocketChannelImpl_sendOutOfBandData(JNIEnv* env, jclass this,
39.10 + jobject fdo, jbyte b)
39.11 +{
39.12 + int n = send(fdval(env, fdo), (const void*)&b, 1, MSG_OOB);
39.13 + return convertReturnVal(env, n, JNI_FALSE);
39.14 +}
40.1 --- a/src/windows/classes/sun/net/dns/ResolverConfigurationImpl.java Fri Aug 06 12:52:07 2010 -0700
40.2 +++ b/src/windows/classes/sun/net/dns/ResolverConfigurationImpl.java Mon Aug 09 16:02:19 2010 -0700
40.3 @@ -1,5 +1,5 @@
40.4 /*
40.5 - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
40.6 + * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
40.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
40.8 *
40.9 * This code is free software; you can redistribute it and/or modify it
40.10 @@ -28,7 +28,6 @@
40.11 import java.util.List;
40.12 import java.util.LinkedList;
40.13 import java.util.StringTokenizer;
40.14 -import java.io.IOException;
40.15
40.16 /*
40.17 * An implementation of sun.net.ResolverConfiguration for Windows.
40.18 @@ -63,8 +62,8 @@
40.19
40.20 // Parse string that consists of token delimited by space or commas
40.21 // and return LinkedHashMap
40.22 - private LinkedList stringToList(String str) {
40.23 - LinkedList ll = new LinkedList();
40.24 + private LinkedList<String> stringToList(String str) {
40.25 + LinkedList<String> ll = new LinkedList<>();
40.26
40.27 // comma and space are valid delimites
40.28 StringTokenizer st = new StringTokenizer(str, ", ");
40.29 @@ -112,7 +111,7 @@
40.30 opts = new OptionsImpl();
40.31 }
40.32
40.33 - public List searchlist() {
40.34 + public List<String> searchlist() {
40.35 synchronized (lock) {
40.36 loadConfig();
40.37
40.38 @@ -121,7 +120,7 @@
40.39 }
40.40 }
40.41
40.42 - public List nameservers() {
40.43 + public List<String> nameservers() {
40.44 synchronized (lock) {
40.45 loadConfig();
40.46
41.1 --- a/src/windows/native/java/nio/MappedByteBuffer.c Fri Aug 06 12:52:07 2010 -0700
41.2 +++ b/src/windows/native/java/nio/MappedByteBuffer.c Mon Aug 09 16:02:19 2010 -0700
41.3 @@ -31,8 +31,8 @@
41.4 #include <stdlib.h>
41.5
41.6 JNIEXPORT jboolean JNICALL
41.7 -Java_java_nio_MappedByteBuffer_isLoaded0(JNIEnv *env, jobject obj,
41.8 - jlong address, jlong len)
41.9 +Java_java_nio_MappedByteBuffer_isLoaded0(JNIEnv *env, jobject obj, jlong address,
41.10 + jlong len, jint numPages)
41.11 {
41.12 jboolean loaded = JNI_FALSE;
41.13 /* Information not available?
41.14 @@ -43,22 +43,11 @@
41.15 return loaded;
41.16 }
41.17
41.18 -JNIEXPORT jint JNICALL
41.19 +JNIEXPORT void JNICALL
41.20 Java_java_nio_MappedByteBuffer_load0(JNIEnv *env, jobject obj, jlong address,
41.21 - jlong len, jint pageSize)
41.22 + jlong len)
41.23 {
41.24 - int *ptr = (int *) jlong_to_ptr(address);
41.25 - int pageIncrement = pageSize / sizeof(int);
41.26 - jlong numPages = (len + pageSize - 1) / pageSize;
41.27 - int i = 0;
41.28 - int j = 0;
41.29 -
41.30 - /* touch every page */
41.31 - for (i=0; i<numPages; i++) {
41.32 - j += *((volatile int *)ptr);
41.33 - ptr += pageIncrement;
41.34 - }
41.35 - return j;
41.36 + // no madvise available
41.37 }
41.38
41.39 JNIEXPORT void JNICALL
42.1 --- a/src/windows/native/sun/nio/ch/SocketChannelImpl.c Fri Aug 06 12:52:07 2010 -0700
42.2 +++ b/src/windows/native/sun/nio/ch/SocketChannelImpl.c Mon Aug 09 16:02:19 2010 -0700
42.3 @@ -139,3 +139,16 @@
42.4
42.5 return 0;
42.6 }
42.7 +
42.8 +JNIEXPORT jint JNICALL
42.9 +Java_sun_nio_ch_SocketChannelImpl_sendOutOfBandData(JNIEnv* env, jclass this,
42.10 + jobject fdo, jbyte b)
42.11 +{
42.12 + int n = send(fdval(env, fdo), (const char*)&b, 1, MSG_OOB);
42.13 + if (n == SOCKET_ERROR) {
42.14 + handleSocketError(env, WSAGetLastError());
42.15 + return IOS_THROWN;
42.16 + } else {
42.17 + return n;
42.18 + }
42.19 +}
43.1 --- a/src/windows/native/sun/windows/awt.h Fri Aug 06 12:52:07 2010 -0700
43.2 +++ b/src/windows/native/sun/windows/awt.h Mon Aug 09 16:02:19 2010 -0700
43.3 @@ -310,24 +310,32 @@
43.4 * Class to encapsulate the extraction of the java string contents
43.5 * into a buffer and the cleanup of the buffer
43.6 */
43.7 - class JavaStringBuffer
43.8 +class JavaStringBuffer
43.9 {
43.10 protected:
43.11 LPWSTR m_pStr;
43.12 jsize m_dwSize;
43.13 + LPWSTR getNonEmptyString() {
43.14 + return (NULL==m_pStr)
43.15 + ? L""
43.16 + : m_pStr;
43.17 + }
43.18
43.19 public:
43.20 JavaStringBuffer(jsize cbTCharCount) {
43.21 m_dwSize = cbTCharCount;
43.22 - m_pStr = (LPWSTR)safe_Malloc( (m_dwSize+1)*sizeof(WCHAR) );
43.23 + m_pStr = (0 == m_dwSize)
43.24 + ? NULL
43.25 + : (LPWSTR)safe_Malloc( (m_dwSize+1)*sizeof(WCHAR) );
43.26 }
43.27
43.28 JavaStringBuffer(JNIEnv *env, jstring text) {
43.29 - if (NULL == text) {
43.30 - m_pStr = L"";
43.31 - m_dwSize = 0;
43.32 + m_dwSize = (NULL == text)
43.33 + ? 0
43.34 + : env->GetStringLength(text);
43.35 + if (0 == m_dwSize) {
43.36 + m_pStr = NULL;
43.37 } else {
43.38 - m_dwSize = env->GetStringLength(text);
43.39 m_pStr = (LPWSTR)safe_Malloc( (m_dwSize+1)*sizeof(WCHAR) );
43.40 env->GetStringRegion(text, 0, m_dwSize, reinterpret_cast<jchar *>(m_pStr));
43.41 m_pStr[m_dwSize] = 0;
43.42 @@ -341,12 +349,16 @@
43.43
43.44 void Resize(jsize cbTCharCount) {
43.45 m_dwSize = cbTCharCount;
43.46 + //It is ok to have non-null terminated string here.
43.47 + //The function is used only for space reservation in staff buffer for
43.48 + //followed data copying process. And that is the reason why we ignore
43.49 + //the special case m_dwSize==0 here.
43.50 m_pStr = (LPWSTR)safe_Realloc(m_pStr, (m_dwSize+1)*sizeof(WCHAR) );
43.51 }
43.52 //we are in UNICODE now, so LPWSTR:=:LPTSTR
43.53 - operator LPWSTR() { return m_pStr; }
43.54 - operator LPARAM() { return (LPARAM)m_pStr; }
43.55 - void *GetData() { return (void *)m_pStr; }
43.56 + operator LPWSTR() { return getNonEmptyString(); }
43.57 + operator LPARAM() { return (LPARAM)getNonEmptyString(); }
43.58 + void *GetData() { return (void *)getNonEmptyString(); }
43.59 jsize GetSize() { return m_dwSize; }
43.60 };
43.61
44.1 --- a/test/ProblemList.txt Fri Aug 06 12:52:07 2010 -0700
44.2 +++ b/test/ProblemList.txt Mon Aug 09 16:02:19 2010 -0700
44.3 @@ -366,139 +366,6 @@
44.4
44.5 # jdk_net
44.6
44.7 -# Suspect many of these tests auffer from using fixed ports, no concrete
44.8 -# evidence.
44.9 -
44.10 -# Times out on Windows X64
44.11 -sun/net/www/http/KeepAliveStream/KeepAliveStreamCloseWithWrongContentLength.java generic-all
44.12 -
44.13 -# Dies on Solaris 10 sparc and sparcv9, Linux -ea -esa with
44.14 -# Interrupted or IO exception, maybe writing to non-unique named file?
44.15 -com/sun/net/httpserver/bugs/B6373555.java generic-all
44.16 -
44.17 -# Fails on OpenSolaris, times out
44.18 -java/net/MulticastSocket/SetOutgoingIf.java generic-all
44.19 -
44.20 -# Timed out on Solaris 10 X86.
44.21 -com/sun/net/httpserver/Test3.java generic-all
44.22 -
44.23 -# Exception in test on windows
44.24 -com/sun/net/httpserver/bugs/B6373555.java windows-all
44.25 -
44.26 -# One of these pollutes the samevm on Linux, too many open files, kills jtreg
44.27 -com/sun/net/httpserver/bugs/B6339483.java generic-all
44.28 -com/sun/net/httpserver/bugs/B6341616.java generic-all
44.29 -
44.30 -# Suspects in cascading samevm problem, solaris 11 i586 (needs othervm?)
44.31 -# Suspect use of setHttps*()?
44.32 -com/sun/net/httpserver/SelCacheTest.java generic-all
44.33 -com/sun/net/httpserver/Test1.java generic-all
44.34 -com/sun/net/httpserver/Test12.java generic-all
44.35 -com/sun/net/httpserver/Test13.java generic-all
44.36 -com/sun/net/httpserver/Test6a.java generic-all
44.37 -com/sun/net/httpserver/Test7a.java generic-all
44.38 -com/sun/net/httpserver/Test8a.java generic-all
44.39 -com/sun/net/httpserver/Test9.java generic-all
44.40 -com/sun/net/httpserver/Test9a.java generic-all
44.41 -
44.42 -# 10,000 connections, fails on Linux and makes tests&jtreg fail with samevm
44.43 -com/sun/net/httpserver/bugs/B6361557.java generic-all
44.44 -
44.45 -# Address already in use with samevm? Always? Solaris sparc, probably ports
44.46 -java/net/Authenticator/B4933582.sh generic-all
44.47 -java/net/DatagramSocket/SendSize.java generic-all
44.48 -
44.49 -# Solaris 11: exception wrong address???
44.50 -java/net/Inet6Address/B6558853.java generic-all
44.51 -
44.52 -# Not closing stream on file i6a1, windows samevm problem
44.53 -java/net/Inet6Address/serialize/Serialize.java generic-all
44.54 -
44.55 -# Linux x64 fails "network unreachable"?
44.56 -java/net/ipv6tests/TcpTest.java generic-all
44.57 -
44.58 -# Linux i586, fails with unexpected output
44.59 -java/net/MulticastSocket/NoLoopbackPackets.java linux-i586
44.60 -
44.61 -# Address already in use
44.62 -java/net/DatagramSocket/DatagramTimeout.java generic-all
44.63 -
44.64 -# Fails on windows, takes too long and fails
44.65 -# Solaris 10 sparcv9, samevm, java.lang.Exception: Takes too long. Dead lock
44.66 -java/net/Socket/DeadlockTest.java generic-all
44.67 -
44.68 -# Linux i586 address already in use or connection error, samevm issues
44.69 -java/net/Socket/AccurateTimeout.java generic-all
44.70 -java/net/Socket/asyncClose/BrokenPipe.java generic-all
44.71 -java/net/Socket/CloseAvailable.java generic-all
44.72 -
44.73 -# Linux X64 address already in use, samevm issues
44.74 -java/net/Socket/LingerTest.java generic-all
44.75 -java/net/Socket/LinkLocal.java generic-all
44.76 -java/net/Socket/NullHost.java generic-all
44.77 -java/net/Socket/ProxyCons.java generic-all
44.78 -java/net/Socket/ReadTimeout.java generic-all
44.79 -
44.80 -# Linux X64 address already in use, samevm issues
44.81 -java/net/Socket/SetReceiveBufferSize.java generic-all
44.82 -
44.83 -# Linux i586 address already in use or connection error, samevm issues
44.84 -java/net/Socket/setReuseAddress/Basic.java generic-all
44.85 -java/net/Socket/setReuseAddress/Restart.java generic-all
44.86 -
44.87 -# Linux X64 address already in use, samevm issues
44.88 -java/net/Socket/SetSoLinger.java generic-all
44.89 -
44.90 -# Address already in use, windows samevm
44.91 -java/net/Socket/Timeout.java generic-all
44.92 -
44.93 -# Linux X64 address already in use, samevm issues
44.94 -java/net/Socket/ShutdownBoth.java generic-all
44.95 -java/net/Socket/SoTimeout.java generic-all
44.96 -java/net/Socket/TestClose.java generic-all
44.97 -java/net/Socket/UrgentDataTest.java generic-all
44.98 -java/net/SocketInputStream/SocketClosedException.java generic-all
44.99 -java/net/SocketInputStream/SocketTimeout.java generic-all
44.100 -
44.101 -# Linux i586, address already in use or timeout, samevm issues
44.102 -java/net/URLConnection/DisconnectAfterEOF.java generic-all
44.103 -java/net/URLConnection/HandleContentTypeWithAttrs.java generic-all
44.104 -java/net/URLConnection/Responses.java generic-all
44.105 -java/net/URLConnection/TimeoutTest.java generic-all
44.106 -java/net/URLConnection/ZeroContentLength.java generic-all
44.107 -
44.108 -# Solaris 11 i586 fails with samevm, not sure why
44.109 -java/net/ResponseCache/B6181108.java generic-all
44.110 -java/net/ResponseCache/ResponseCacheTest.java generic-all
44.111 -java/net/URL/GetContent.java generic-all
44.112 -java/net/URLConnection/HttpContinueStackOverflow.java generic-all
44.113 -java/net/URLConnection/Redirect307Test.java generic-all
44.114 -java/net/URLConnection/RedirectLimit.java generic-all
44.115 -java/net/URLConnection/ResendPostBody.java generic-all
44.116 -java/net/URL/OpenStream.java generic-all
44.117 -java/net/URLClassLoader/ClassLoad.java generic-all
44.118 -java/net/URLConnection/SetIfModifiedSince.java generic-all
44.119 -java/net/URLConnection/URLConnectionHeaders.java generic-all
44.120 -
44.121 -# Linux i586 Connection refused or address already in use, samevm issues
44.122 -sun/net/ftp/B6427768.java generic-all
44.123 -sun/net/ftp/FtpGetContent.java generic-all
44.124 -sun/net/ftp/FtpURL.java generic-all
44.125 -
44.126 -# Failed on solaris 10 i586, Exception: should have gotten HttpRetryException?
44.127 -sun/net/www/http/ChunkedOutputStream/Test.java generic-all
44.128 -
44.129 -# Trouble cleaning up threads in samevm mode on solaris 11 i586
44.130 -sun/net/www/http/HttpClient/ProxyTest.java generic-all
44.131 -sun/net/www/http/ChunkedInputStream/ChunkedEncodingTest.java generic-all
44.132 -sun/net/www/http/ChunkedInputStream/ChunkedEncodingWithProgressMonitorTest.java generic-all
44.133 -sun/net/www/http/HttpClient/B6726695.java generic-all
44.134 -sun/net/www/http/HttpClient/MultiThreadTest.java generic-all
44.135 -sun/net/www/http/KeepAliveCache/KeepAliveTimerThread.java generic-all
44.136 -
44.137 -# Connection refused, windows samevm
44.138 -sun/net/www/protocol/http/DigestTest.java generic-all
44.139 -
44.140 ############################################################################
44.141
44.142 # jdk_io
45.1 --- a/test/com/sun/jdi/ShellScaffold.sh Fri Aug 06 12:52:07 2010 -0700
45.2 +++ b/test/com/sun/jdi/ShellScaffold.sh Mon Aug 09 16:02:19 2010 -0700
45.3 @@ -1,7 +1,7 @@
45.4 #!/bin/sh
45.5
45.6 #
45.7 -# Copyright (c) 2002, 2009, Oracle and/or its affiliates. All rights reserved.
45.8 +# Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
45.9 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
45.10 #
45.11 # This code is free software; you can redistribute it and/or modify it
45.12 @@ -141,7 +141,10 @@
45.13 cleanup()
45.14 {
45.15 if [ -r "$failFile" ] ; then
45.16 - cat $failFile >& 2
45.17 + ls -l "$failFile" >&2
45.18 + echo "<cleanup:_begin_failFile_contents>" >&2
45.19 + cat "$failFile" >&2
45.20 + echo "<cleanup:_end_failFile_contents>" >&2
45.21 fi
45.22
45.23 # Kill all processes that have our special
45.24 @@ -337,6 +340,10 @@
45.25 failFile=$tmpFileDir/testFailed
45.26 debuggeepidFile=$tmpFileDir/debuggeepid
45.27 rm -f $failFile $debuggeepidFile
45.28 + if [ -f "$failFile" ]; then
45.29 + echo "ERROR: unable to delete existing failFile:" >&2
45.30 + ls -l "$failFile" >&2
45.31 + fi
45.32
45.33 if [ -z "$pkg" ] ; then
45.34 pkgSlash=
45.35 @@ -524,6 +531,10 @@
45.36 # See 6562090. Maybe there is a way that the exit
45.37 # can cause jdb to not get the quit.
45.38 sleep 5
45.39 +
45.40 + # The exit code value here doesn't matter since this function
45.41 + # is called as part of a pipeline and it is not the last command
45.42 + # in the pipeline.
45.43 exit 1
45.44 fi
45.45
45.46 @@ -938,6 +949,10 @@
45.47 done
45.48
45.49 if [ -r "$failFile" ] ; then
45.50 + ls -l "$failFile" >&2
45.51 + echo "<waitForFinish:_begin_failFile_contents>" >&2
45.52 + cat "$failFile" >&2
45.53 + echo "<waitForFinish:_end_failFile_contents>" >&2
45.54 exit 1
45.55 fi
45.56 }
45.57 @@ -946,33 +961,45 @@
45.58 # $3 is the number of lines to search (from the end)
45.59 grepForString()
45.60 {
45.61 - # See bug 6220903. Sometimes the jdb '> ' prompt chars
45.62 - # get inserted into the string we are searching for
45.63 - # so ignore those chars.
45.64 if [ -z "$3" ] ; then
45.65 theCmd=cat
45.66 else
45.67 theCmd="tail -$3"
45.68 fi
45.69 +
45.70 case "$2" in
45.71 - *\>*)
45.72 - # Target string contains a > so we better
45.73 - # not ignore it
45.74 + *\>*)
45.75 + # Target string contains a '>' so we better not ignore it
45.76 $theCmd $1 | $grep -s "$2" > $devnull 2>&1
45.77 - return $?
45.78 + stat="$?"
45.79 ;;
45.80 + *)
45.81 + # Target string does not contain a '>'.
45.82 + # NOTE: if $1 does not end with a new line, piping it to sed
45.83 + # doesn't include the chars on the last line. Detect this
45.84 + # case, and add a new line.
45.85 + theFile="$1"
45.86 + if [ `tail -1 "$theFile" | wc -l | sed -e 's@ @@g'` = 0 ] ; then
45.87 + # The target file doesn't end with a new line so we have
45.88 + # add one to a copy of the target file so the sed command
45.89 + # below can filter that last line.
45.90 + cp "$theFile" "$theFile.tmp"
45.91 + theFile="$theFile.tmp"
45.92 + echo >> "$theFile"
45.93 + fi
45.94 +
45.95 + # See bug 6220903. Sometimes the jdb prompt chars ('> ') can
45.96 + # get interleaved in the target file which can keep us from
45.97 + # matching the target string.
45.98 + $theCmd "$theFile" | sed -e 's@> @@g' -e 's@>@@g' \
45.99 + | $grep -s "$2" > $devnull 2>&1
45.100 + stat=$?
45.101 + if [ "$theFile" != "$1" ]; then
45.102 + # remove the copy of the target file
45.103 + rm -f "$theFile"
45.104 + fi
45.105 + unset theFile
45.106 esac
45.107 - # Target string does not contain a >.
45.108 - # Ignore > and '> ' in the file.
45.109 - # NOTE: if $1 does not end with a new line, piping it to sed doesn't include the
45.110 - # chars on the last line. Detect this case, and add a new line.
45.111 - cp $1 $1.tmp
45.112 - if [ `tail -1 $1.tmp | wc -l | sed -e 's@ @@g'` = 0 ] ; then
45.113 - echo >> $1.tmp
45.114 - fi
45.115 - $theCmd $1.tmp | sed -e 's@> @@g' -e 's@>@@g' | $grep -s "$2" > $devnull 2>&1
45.116 - stat=$?
45.117 - rm -f $1.tmp
45.118 return $stat
45.119 }
45.120
45.121 @@ -1037,6 +1064,11 @@
45.122 echo
45.123 echo "--Done: test passed"
45.124 exit 0
45.125 + else
45.126 + ls -l "$failFile" >&2
45.127 + echo "<pass:_begin_failFile_contents>" >&2
45.128 + cat "$failFile" >&2
45.129 + echo "<pass:_end_failFile_contents>" >&2
45.130 fi
45.131 }
45.132
46.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
46.2 +++ b/test/com/sun/jndi/rmi/registry/RegistryContext/ContextWithNullProperties.java Mon Aug 09 16:02:19 2010 -0700
46.3 @@ -0,0 +1,50 @@
46.4 +/*
46.5 + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
46.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
46.7 + *
46.8 + * This code is free software; you can redistribute it and/or modify it
46.9 + * under the terms of the GNU General Public License version 2 only, as
46.10 + * published by the Free Software Foundation.
46.11 + *
46.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
46.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
46.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
46.15 + * version 2 for more details (a copy is included in the LICENSE file that
46.16 + * accompanied this code).
46.17 + *
46.18 + * You should have received a copy of the GNU General Public License version
46.19 + * 2 along with this work; if not, write to the Free Software Foundation,
46.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
46.21 + *
46.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
46.23 + * or visit www.oracle.com if you need additional information or have any
46.24 + * questions.
46.25 + */
46.26 +
46.27 +/*
46.28 + * @test
46.29 + * @bug 6676075
46.30 + * @summary RegistryContext (com.sun.jndi.url.rmi.rmiURLContext) coding problem
46.31 + */
46.32 +
46.33 +import java.rmi.RemoteException;
46.34 +import java.rmi.registry.LocateRegistry;
46.35 +
46.36 +import com.sun.jndi.rmi.registry.*;
46.37 +
46.38 +public class ContextWithNullProperties {
46.39 +
46.40 + public static void main(String[] args) throws Exception {
46.41 +
46.42 + // Create registry on port 1099 if one is not already running.
46.43 + try {
46.44 + LocateRegistry.createRegistry(1099);
46.45 + } catch (RemoteException e) {
46.46 + }
46.47 +
46.48 + System.out.println("Connecting to the default Registry...");
46.49 + // Connect to the default Registry.
46.50 + // Pass null as the JNDI environment properties (see final argument)
46.51 + RegistryContext ctx = new RegistryContext(null, -1, null);
46.52 + }
46.53 +}
47.1 --- a/test/com/sun/net/httpserver/Test1.java Fri Aug 06 12:52:07 2010 -0700
47.2 +++ b/test/com/sun/net/httpserver/Test1.java Mon Aug 09 16:02:19 2010 -0700
47.3 @@ -24,17 +24,15 @@
47.4 /**
47.5 * @test
47.6 * @bug 6270015
47.7 + * @run main/othervm Test1
47.8 * @summary Light weight HTTP server
47.9 */
47.10
47.11 import com.sun.net.httpserver.*;
47.12
47.13 -import java.util.*;
47.14 import java.util.concurrent.*;
47.15 import java.io.*;
47.16 import java.net.*;
47.17 -import java.security.*;
47.18 -import java.security.cert.*;
47.19 import javax.net.ssl.*;
47.20
47.21 /* basic http/s connectivity test
48.1 --- a/test/com/sun/net/httpserver/Test11.java Fri Aug 06 12:52:07 2010 -0700
48.2 +++ b/test/com/sun/net/httpserver/Test11.java Mon Aug 09 16:02:19 2010 -0700
48.3 @@ -28,7 +28,6 @@
48.4 */
48.5
48.6 import java.net.*;
48.7 -import java.util.*;
48.8 import java.util.concurrent.*;
48.9 import java.io.*;
48.10 import com.sun.net.httpserver.*;
48.11 @@ -52,22 +51,25 @@
48.12
48.13 public static void main (String[] args) throws Exception {
48.14 System.out.print ("Test 11: ");
48.15 - HttpServer server = HttpServer.create (new InetSocketAddress(0), 0);
48.16 - HttpContext ctx = server.createContext (
48.17 - "/foo/bar/", new Handler ()
48.18 - );
48.19 - ExecutorService s = Executors.newCachedThreadPool();
48.20 - server.setExecutor (s);
48.21 - server.start ();
48.22 - URL url = new URL ("http://localhost:" + server.getAddress().getPort()+
48.23 - "/Foo/bar/test.html");
48.24 - HttpURLConnection urlc = (HttpURLConnection)url.openConnection();
48.25 - int r = urlc.getResponseCode();
48.26 - System.out.println ("OK");
48.27 - s.shutdown();
48.28 - server.stop(5);
48.29 - if (r == 200) {
48.30 - throw new RuntimeException ("wrong response received");
48.31 + HttpServer server = HttpServer.create(new InetSocketAddress(0), 0);
48.32 + ExecutorService s = Executors.newCachedThreadPool();
48.33 + try {
48.34 + HttpContext ctx = server.createContext (
48.35 + "/foo/bar/", new Handler ()
48.36 + );
48.37 + s = Executors.newCachedThreadPool();
48.38 + server.start ();
48.39 + URL url = new URL ("http://localhost:" + server.getAddress().getPort()+
48.40 + "/Foo/bar/test.html");
48.41 + HttpURLConnection urlc = (HttpURLConnection)url.openConnection();
48.42 + int r = urlc.getResponseCode();
48.43 + if (r == 200) {
48.44 + throw new RuntimeException ("wrong response received");
48.45 + }
48.46 + System.out.println ("OK");
48.47 + } finally {
48.48 + s.shutdown();
48.49 + server.stop(2);
48.50 }
48.51 }
48.52 }
49.1 --- a/test/com/sun/net/httpserver/Test12.java Fri Aug 06 12:52:07 2010 -0700
49.2 +++ b/test/com/sun/net/httpserver/Test12.java Mon Aug 09 16:02:19 2010 -0700
49.3 @@ -24,17 +24,15 @@
49.4 /**
49.5 * @test
49.6 * @bug 6270015
49.7 + * @run main/othervm Test12
49.8 * @summary Light weight HTTP server
49.9 */
49.10
49.11 import com.sun.net.httpserver.*;
49.12
49.13 -import java.util.*;
49.14 import java.util.concurrent.*;
49.15 import java.io.*;
49.16 import java.net.*;
49.17 -import java.security.*;
49.18 -import java.security.cert.*;
49.19 import javax.net.ssl.*;
49.20
49.21 /* basic http/s connectivity test
50.1 --- a/test/com/sun/net/httpserver/Test13.java Fri Aug 06 12:52:07 2010 -0700
50.2 +++ b/test/com/sun/net/httpserver/Test13.java Mon Aug 09 16:02:19 2010 -0700
50.3 @@ -24,17 +24,16 @@
50.4 /**
50.5 * @test
50.6 * @bug 6270015
50.7 + * @run main/othervm Test13
50.8 * @summary Light weight HTTP server
50.9 */
50.10
50.11 import com.sun.net.httpserver.*;
50.12
50.13 -import java.util.*;
50.14 import java.util.concurrent.*;
50.15 import java.io.*;
50.16 import java.net.*;
50.17 -import java.security.*;
50.18 -import java.security.cert.*;
50.19 +
50.20 import javax.net.ssl.*;
50.21
50.22 /* basic http/s connectivity test
51.1 --- a/test/com/sun/net/httpserver/Test6a.java Fri Aug 06 12:52:07 2010 -0700
51.2 +++ b/test/com/sun/net/httpserver/Test6a.java Mon Aug 09 16:02:19 2010 -0700
51.3 @@ -24,17 +24,15 @@
51.4 /**
51.5 * @test
51.6 * @bug 6270015
51.7 + * @run main/othervm Test6a
51.8 * @summary Light weight HTTP server
51.9 */
51.10
51.11 import com.sun.net.httpserver.*;
51.12
51.13 -import java.util.*;
51.14 import java.util.concurrent.*;
51.15 import java.io.*;
51.16 import java.net.*;
51.17 -import java.security.*;
51.18 -import javax.security.auth.callback.*;
51.19 import javax.net.ssl.*;
51.20
51.21 /**
52.1 --- a/test/com/sun/net/httpserver/Test7a.java Fri Aug 06 12:52:07 2010 -0700
52.2 +++ b/test/com/sun/net/httpserver/Test7a.java Mon Aug 09 16:02:19 2010 -0700
52.3 @@ -24,18 +24,15 @@
52.4 /**
52.5 * @test
52.6 * @bug 6270015
52.7 + * @run main/othervm Test7a
52.8 * @summary Light weight HTTP server
52.9 */
52.10
52.11 import com.sun.net.httpserver.*;
52.12
52.13 -import java.util.*;
52.14 import java.util.concurrent.*;
52.15 -import java.util.logging.*;
52.16 import java.io.*;
52.17 import java.net.*;
52.18 -import java.security.*;
52.19 -import javax.security.auth.callback.*;
52.20 import javax.net.ssl.*;
52.21
52.22 /**
53.1 --- a/test/com/sun/net/httpserver/Test8a.java Fri Aug 06 12:52:07 2010 -0700
53.2 +++ b/test/com/sun/net/httpserver/Test8a.java Mon Aug 09 16:02:19 2010 -0700
53.3 @@ -24,18 +24,15 @@
53.4 /**
53.5 * @test
53.6 * @bug 6270015
53.7 + * @run main/othervm Test8a
53.8 * @summary Light weight HTTP server
53.9 */
53.10
53.11 import com.sun.net.httpserver.*;
53.12
53.13 -import java.util.*;
53.14 import java.util.concurrent.*;
53.15 -import java.util.logging.*;
53.16 import java.io.*;
53.17 import java.net.*;
53.18 -import java.security.*;
53.19 -import javax.security.auth.callback.*;
53.20 import javax.net.ssl.*;
53.21
53.22 /**
53.23 @@ -50,46 +47,50 @@
53.24 //h.setLevel (Level.INFO);
53.25 //log.addHandler (h);
53.26 //log.setLevel (Level.INFO);
53.27 - Handler handler = new Handler();
53.28 - InetSocketAddress addr = new InetSocketAddress (0);
53.29 - HttpsServer server = HttpsServer.create (addr, 0);
53.30 - HttpContext ctx = server.createContext ("/test", handler);
53.31 - ExecutorService executor = Executors.newCachedThreadPool();
53.32 - SSLContext ssl = new SimpleSSLContext(System.getProperty("test.src")).get();
53.33 - server.setHttpsConfigurator(new HttpsConfigurator (ssl));
53.34 - server.setExecutor (executor);
53.35 - server.start ();
53.36 + HttpsServer server = null;
53.37 + ExecutorService executor = null;
53.38 + try {
53.39 + Handler handler = new Handler();
53.40 + InetSocketAddress addr = new InetSocketAddress (0);
53.41 + server = HttpsServer.create (addr, 0);
53.42 + HttpContext ctx = server.createContext ("/test", handler);
53.43 + executor = Executors.newCachedThreadPool();
53.44 + SSLContext ssl = new SimpleSSLContext(System.getProperty("test.src")).get();
53.45 + server.setHttpsConfigurator(new HttpsConfigurator (ssl));
53.46 + server.setExecutor (executor);
53.47 + server.start ();
53.48
53.49 - URL url = new URL ("https://localhost:"+server.getAddress().getPort()+"/test/foo.html");
53.50 - System.out.print ("Test8a: " );
53.51 - HttpsURLConnection urlc = (HttpsURLConnection)url.openConnection ();
53.52 - urlc.setDoOutput (true);
53.53 - urlc.setRequestMethod ("POST");
53.54 - urlc.setHostnameVerifier (new DummyVerifier());
53.55 - urlc.setSSLSocketFactory (ssl.getSocketFactory());
53.56 - OutputStream os = new BufferedOutputStream (urlc.getOutputStream(), 8000);
53.57 - for (int i=0; i<SIZE; i++) {
53.58 - os.write (i % 250);
53.59 + URL url = new URL ("https://localhost:"+server.getAddress().getPort()+"/test/foo.html");
53.60 + System.out.print ("Test8a: " );
53.61 + HttpsURLConnection urlc = (HttpsURLConnection)url.openConnection ();
53.62 + urlc.setDoOutput (true);
53.63 + urlc.setRequestMethod ("POST");
53.64 + urlc.setHostnameVerifier (new DummyVerifier());
53.65 + urlc.setSSLSocketFactory (ssl.getSocketFactory());
53.66 + OutputStream os = new BufferedOutputStream (urlc.getOutputStream(), 8000);
53.67 + for (int i=0; i<SIZE; i++) {
53.68 + os.write (i % 250);
53.69 + }
53.70 + os.close();
53.71 + int resp = urlc.getResponseCode();
53.72 + if (resp != 200) {
53.73 + throw new RuntimeException ("test failed response code");
53.74 + }
53.75 + InputStream is = urlc.getInputStream ();
53.76 + for (int i=0; i<SIZE; i++) {
53.77 + int f = is.read();
53.78 + if (f != (i % 250)) {
53.79 + System.out.println ("Setting error(" +f +")("+i+")" );
53.80 + error = true;
53.81 + break;
53.82 + }
53.83 + }
53.84 + is.close();
53.85 + } finally {
53.86 + delay();
53.87 + if (server != null) server.stop(2);
53.88 + if (executor != null) executor.shutdown();
53.89 }
53.90 - os.close();
53.91 - int resp = urlc.getResponseCode();
53.92 - if (resp != 200) {
53.93 - throw new RuntimeException ("test failed response code");
53.94 - }
53.95 - InputStream is = urlc.getInputStream ();
53.96 - for (int i=0; i<SIZE; i++) {
53.97 - int f = is.read();
53.98 - if (f != (i % 250)) {
53.99 - System.out.println ("Setting error(" +f +")("+i+")" );
53.100 - error = true;
53.101 - break;
53.102 - }
53.103 - }
53.104 - is.close();
53.105 -
53.106 - delay();
53.107 - server.stop(2);
53.108 - executor.shutdown();
53.109 if (error) {
53.110 throw new RuntimeException ("test failed error");
53.111 }
54.1 --- a/test/com/sun/net/httpserver/Test9.java Fri Aug 06 12:52:07 2010 -0700
54.2 +++ b/test/com/sun/net/httpserver/Test9.java Mon Aug 09 16:02:19 2010 -0700
54.3 @@ -24,17 +24,15 @@
54.4 /**
54.5 * @test
54.6 * @bug 6270015
54.7 + * @run main/othervm Test9
54.8 * @summary Light weight HTTP server
54.9 */
54.10
54.11 import com.sun.net.httpserver.*;
54.12
54.13 -import java.util.*;
54.14 import java.util.concurrent.*;
54.15 import java.io.*;
54.16 import java.net.*;
54.17 -import java.security.*;
54.18 -import java.security.cert.*;
54.19 import javax.net.ssl.*;
54.20
54.21 /* Same as Test1 but requests run in parallel.
55.1 --- a/test/com/sun/net/httpserver/Test9a.java Fri Aug 06 12:52:07 2010 -0700
55.2 +++ b/test/com/sun/net/httpserver/Test9a.java Mon Aug 09 16:02:19 2010 -0700
55.3 @@ -24,17 +24,15 @@
55.4 /**
55.5 * @test
55.6 * @bug 6270015
55.7 + * @run main/othervm Test9a
55.8 * @summary Light weight HTTP server
55.9 */
55.10
55.11 import com.sun.net.httpserver.*;
55.12
55.13 -import java.util.*;
55.14 import java.util.concurrent.*;
55.15 import java.io.*;
55.16 import java.net.*;
55.17 -import java.security.*;
55.18 -import java.security.cert.*;
55.19 import javax.net.ssl.*;
55.20
55.21 /* Same as Test1 but requests run in parallel.
56.1 --- a/test/com/sun/net/httpserver/bugs/B6361557.java Fri Aug 06 12:52:07 2010 -0700
56.2 +++ b/test/com/sun/net/httpserver/bugs/B6361557.java Mon Aug 09 16:02:19 2010 -0700
56.3 @@ -24,6 +24,7 @@
56.4 /**
56.5 * @test
56.6 * @bug 6361557
56.7 + * @run main/othervm B6361557
56.8 * @summary Lightweight HTTP server quickly runs out of file descriptors on Linux
56.9 */
56.10
56.11 @@ -35,12 +36,9 @@
56.12 import java.nio.*;
56.13 import java.nio.channels.*;
56.14 import java.net.*;
56.15 -import java.security.*;
56.16 -import java.security.cert.*;
56.17 -import javax.net.ssl.*;
56.18
56.19 /**
56.20 - * The test simply opens 10,000 separate connections
56.21 + * The test simply opens 1,000 separate connections
56.22 * and invokes one http request on each. The client does
56.23 * not close any sockets until after they are closed
56.24 * by the server. This verifies the basic ability
56.25 @@ -49,6 +47,7 @@
56.26 public class B6361557 {
56.27
56.28 public static boolean error = false;
56.29 + static final int NUM = 1000;
56.30
56.31 static class Handler implements HttpHandler {
56.32 int invocation = 1;
56.33 @@ -65,6 +64,9 @@
56.34 }
56.35 }
56.36
56.37 + final static String request = "GET /test/foo.html HTTP/1.1\r\nContent-length: 0\r\n\r\n";
56.38 + final static ByteBuffer requestBuf = ByteBuffer.allocate(64).put(request.getBytes());
56.39 +
56.40 public static void main (String[] args) throws Exception {
56.41 Handler handler = new Handler();
56.42 InetSocketAddress addr = new InetSocketAddress (0);
56.43 @@ -75,49 +77,72 @@
56.44 server.setExecutor (executor);
56.45 server.start ();
56.46
56.47 - final int NUM = 10000;
56.48 - ByteBuffer buf = ByteBuffer.allocate (4096);
56.49 InetSocketAddress destaddr = new InetSocketAddress (
56.50 "127.0.0.1", server.getAddress().getPort()
56.51 );
56.52 System.out.println ("destaddr " + destaddr);
56.53
56.54 Selector selector = Selector.open ();
56.55 - int i = 0;
56.56 + int requests = 0;
56.57 + int responses = 0;
56.58 while (true) {
56.59 - i ++;
56.60 int selres = selector.select (1);
56.61 Set<SelectionKey> selkeys = selector.selectedKeys();
56.62 for (SelectionKey key : selkeys) {
56.63 if (key.isReadable()) {
56.64 SocketChannel chan = (SocketChannel)key.channel();
56.65 - buf.clear();
56.66 + ByteBuffer buf = (ByteBuffer)key.attachment();
56.67 try {
56.68 - int x = chan.read (buf);
56.69 - if (x == -1) {
56.70 + int x = chan.read(buf);
56.71 + if (x == -1 || responseComplete(buf)) {
56.72 + key.attach(null);
56.73 chan.close();
56.74 + responses++;
56.75 }
56.76 } catch (IOException e) {}
56.77 }
56.78 }
56.79 - if (i< NUM) {
56.80 - SocketChannel schan = SocketChannel.open (destaddr);
56.81 - String cmd = "GET /test/foo.html HTTP/1.1\r\nContent-length: 0\r\n\r\n";
56.82 - buf.rewind ();
56.83 - buf.put (cmd.getBytes());
56.84 - buf.flip();
56.85 + if (requests < NUM) {
56.86 + SocketChannel schan = SocketChannel.open(destaddr);
56.87 + requestBuf.rewind();
56.88 int c = 0;
56.89 - while (buf.remaining() > 0) {
56.90 - c += schan.write (buf);
56.91 + while (requestBuf.remaining() > 0) {
56.92 + c += schan.write(requestBuf);
56.93 }
56.94 - schan.configureBlocking (false);
56.95 - schan.register (selector, SelectionKey.OP_READ, null);
56.96 - } else {
56.97 + schan.configureBlocking(false);
56.98 + schan.register(selector, SelectionKey.OP_READ, ByteBuffer.allocate(100));
56.99 + requests++;
56.100 + }
56.101 + if (responses == NUM) {
56.102 System.out.println ("Finished clients");
56.103 - server.stop (1);
56.104 - executor.shutdown ();
56.105 - return;
56.106 + break;
56.107 }
56.108 }
56.109 + server.stop (1);
56.110 + selector.close();
56.111 + executor.shutdown ();
56.112 +
56.113 + }
56.114 +
56.115 + /* Look for CR LF CR LF */
56.116 + static boolean responseComplete(ByteBuffer buf) {
56.117 + int pos = buf.position();
56.118 + buf.flip();
56.119 + byte[] lookingFor = new byte[] {'\r', '\n', '\r', '\n' };
56.120 + int lookingForCount = 0;
56.121 + while (buf.hasRemaining()) {
56.122 + byte b = buf.get();
56.123 + if (b == lookingFor[lookingForCount]) {
56.124 + lookingForCount++;
56.125 + if (lookingForCount == 4) {
56.126 + return true;
56.127 + }
56.128 + } else {
56.129 + lookingForCount = 0;
56.130 + }
56.131 + }
56.132 + buf.position(pos);
56.133 + buf.limit(buf.capacity());
56.134 + return false;
56.135 }
56.136 }
57.1 --- a/test/com/sun/net/httpserver/bugs/B6373555.java Fri Aug 06 12:52:07 2010 -0700
57.2 +++ b/test/com/sun/net/httpserver/bugs/B6373555.java Mon Aug 09 16:02:19 2010 -0700
57.3 @@ -46,7 +46,7 @@
57.4 private static Object lock;
57.5 static HttpServer httpServer;
57.6 static ExecutorService pool, execs;
57.7 - static int NUM = 4000;
57.8 + static int NUM = 1000;
57.9
57.10 public static void main(String[] args) throws Exception {
57.11 try {
57.12 @@ -125,7 +125,7 @@
57.13 }
57.14 }
57.15 catch(Exception e) {
57.16 - //e.printStackTrace();
57.17 + e.printStackTrace();
57.18 System.out.print (".");
57.19 error = true;
57.20 }
58.1 --- a/test/java/beans/XMLEncoder/Test4631471.java Fri Aug 06 12:52:07 2010 -0700
58.2 +++ b/test/java/beans/XMLEncoder/Test4631471.java Mon Aug 09 16:02:19 2010 -0700
58.3 @@ -1,5 +1,5 @@
58.4 /*
58.5 - * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
58.6 + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
58.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
58.8 *
58.9 * This code is free software; you can redistribute it and/or modify it
58.10 @@ -23,7 +23,7 @@
58.11
58.12 /*
58.13 * @test
58.14 - * @bug 4631471
58.15 + * @bug 4631471 6972468
58.16 * @summary Tests DefaultTreeModel encoding
58.17 * @author Sergey Malenkov, Mark Davidson
58.18 */
58.19 @@ -37,6 +37,12 @@
58.20
58.21 public abstract class Test4631471 extends AbstractTest {
58.22 public static void main(String[] args) throws Exception {
58.23 + main();
58.24 + System.setSecurityManager(new SecurityManager());
58.25 + main();
58.26 + }
58.27 +
58.28 + private static void main() throws Exception {
58.29 // the DefaultMutableTreeNode will archive correctly
58.30 new Test4631471() {
58.31 protected Object getObject() {
59.1 --- a/test/java/beans/XMLEncoder/Test4903007.java Fri Aug 06 12:52:07 2010 -0700
59.2 +++ b/test/java/beans/XMLEncoder/Test4903007.java Mon Aug 09 16:02:19 2010 -0700
59.3 @@ -1,5 +1,5 @@
59.4 /*
59.5 - * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved.
59.6 + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
59.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
59.8 *
59.9 * This code is free software; you can redistribute it and/or modify it
59.10 @@ -23,7 +23,7 @@
59.11
59.12 /*
59.13 * @test
59.14 - * @bug 4903007
59.15 + * @bug 4903007 6972468
59.16 * @summary Tests encoding of container with boxes and BoxLayout
59.17 * @author Sergey Malenkov, Mark Davidson
59.18 */
59.19 @@ -36,7 +36,7 @@
59.20
59.21 public class Test4903007 extends AbstractTest<JPanel> {
59.22 public static void main(String[] args) throws Exception {
59.23 - new Test4903007().test(false); // TODO: could not encode with security manager
59.24 + new Test4903007().test(true);
59.25 }
59.26
59.27 protected JPanel getObject() {
60.1 --- a/test/java/beans/XMLEncoder/javax_swing_JLayeredPane.java Fri Aug 06 12:52:07 2010 -0700
60.2 +++ b/test/java/beans/XMLEncoder/javax_swing_JLayeredPane.java Mon Aug 09 16:02:19 2010 -0700
60.3 @@ -1,5 +1,5 @@
60.4 /*
60.5 - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
60.6 + * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
60.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
60.8 *
60.9 * This code is free software; you can redistribute it and/or modify it
60.10 @@ -23,7 +23,7 @@
60.11
60.12 /*
60.13 * @test
60.14 - * @bug 5023552
60.15 + * @bug 5023552 6972468
60.16 * @summary Tests JLayeredPane encoding
60.17 * @author Sergey Malenkov
60.18 */
60.19 @@ -35,7 +35,7 @@
60.20
60.21 public final class javax_swing_JLayeredPane extends AbstractTest<JLayeredPane> {
60.22 public static void main(String[] args) {
60.23 - new javax_swing_JLayeredPane().test(false); // TODO: could not encode with security manager
60.24 + new javax_swing_JLayeredPane().test(true);
60.25 }
60.26
60.27 private static void init(JLayeredPane pane, int layer, int x, int y, int w, int h, Color color) {
61.1 --- a/test/java/lang/Throwable/SuppressedExceptions.java Fri Aug 06 12:52:07 2010 -0700
61.2 +++ b/test/java/lang/Throwable/SuppressedExceptions.java Mon Aug 09 16:02:19 2010 -0700
61.3 @@ -26,7 +26,7 @@
61.4
61.5 /*
61.6 * @test
61.7 - * @bug 6911258 6962571
61.8 + * @bug 6911258 6962571 6963622
61.9 * @summary Basic tests of suppressed exceptions
61.10 * @author Joseph D. Darcy
61.11 */
61.12 @@ -35,11 +35,22 @@
61.13 private static String message = "Bad suppressed exception information";
61.14
61.15 public static void main(String... args) throws Exception {
61.16 + noSelfSuppression();
61.17 basicSupressionTest();
61.18 serializationTest();
61.19 selfReference();
61.20 }
61.21
61.22 + private static void noSelfSuppression() {
61.23 + Throwable throwable = new Throwable();
61.24 + try {
61.25 + throwable.addSuppressedException(throwable);
61.26 + throw new RuntimeException("IllegalArgumentException for self-suppresion not thrown.");
61.27 + } catch (IllegalArgumentException iae) {
61.28 + ; // Expected
61.29 + }
61.30 + }
61.31 +
61.32 private static void basicSupressionTest() {
61.33 Throwable throwable = new Throwable();
61.34 RuntimeException suppressed = new RuntimeException("A suppressed exception.");
61.35 @@ -156,9 +167,8 @@
61.36
61.37 throwable1.printStackTrace();
61.38
61.39 -
61.40 - throwable1.addSuppressedException(throwable1);
61.41 throwable1.addSuppressedException(throwable2);
61.42 + throwable2.addSuppressedException(throwable1);
61.43
61.44 throwable1.printStackTrace();
61.45 }
62.1 --- a/test/java/net/DatagramSocket/DatagramTimeout.java Fri Aug 06 12:52:07 2010 -0700
62.2 +++ b/test/java/net/DatagramSocket/DatagramTimeout.java Mon Aug 09 16:02:19 2010 -0700
62.3 @@ -27,25 +27,25 @@
62.4 * @summary test to see if timeout hangs
62.5 * @run main/timeout=15 DatagramTimeout
62.6 */
62.7 -import java.net.*;
62.8 -import java.io.*;
62.9 +import java.net.DatagramPacket;
62.10 +import java.net.DatagramSocket;
62.11 +import java.net.SocketTimeoutException;
62.12
62.13 public class DatagramTimeout {
62.14 -
62.15 - public static ServerSocket sock;
62.16 -
62.17 public static void main(String[] args) throws Exception {
62.18 boolean success = false;
62.19 + DatagramSocket sock = new DatagramSocket();
62.20 +
62.21 try {
62.22 - DatagramSocket sock;
62.23 DatagramPacket p;
62.24 byte[] buffer = new byte[50];
62.25 p = new DatagramPacket(buffer, buffer.length);
62.26 - sock = new DatagramSocket(2333);
62.27 sock.setSoTimeout(2);
62.28 sock.receive(p);
62.29 } catch (SocketTimeoutException e) {
62.30 success = true;
62.31 + } finally {
62.32 + sock.close();
62.33 }
62.34 if (!success)
62.35 throw new RuntimeException("Socket timeout failure.");
63.1 --- a/test/java/net/DatagramSocket/SendSize.java Fri Aug 06 12:52:07 2010 -0700
63.2 +++ b/test/java/net/DatagramSocket/SendSize.java Mon Aug 09 16:02:19 2010 -0700
63.3 @@ -32,35 +32,26 @@
63.4 * @author Benjamin Renaud
63.5 */
63.6
63.7 -import java.io.*;
63.8 -import java.net.*;
63.9 -import java.util.*;
63.10 +import java.io.IOException;
63.11 +import java.net.DatagramPacket;
63.12 +import java.net.DatagramSocket;
63.13 +import java.net.InetAddress;
63.14
63.15 public class SendSize {
63.16 -
63.17 - static final int clientPort = 8989;
63.18 - static final int serverPort = 9999;
63.19 static final int bufferLength = 512;
63.20 static final int packetLength = 256;
63.21
63.22 public static void main(String[] args) throws Exception {
63.23 - new ServerThread().start();
63.24 - new ClientThread().start();
63.25 + DatagramSocket serverSocket = new DatagramSocket();
63.26 + new ServerThread(serverSocket).start();
63.27 + new ClientThread(serverSocket.getLocalPort()).start();
63.28 }
63.29
63.30 -
63.31 static class ServerThread extends Thread {
63.32 -
63.33 - int port;
63.34 DatagramSocket server;
63.35
63.36 - ServerThread(int port) throws IOException {
63.37 - this.port = port;
63.38 - this.server = new DatagramSocket(port);
63.39 - }
63.40 -
63.41 - ServerThread() throws IOException {
63.42 - this(SendSize.serverPort);
63.43 + ServerThread(DatagramSocket server) {
63.44 + this.server = server;
63.45 }
63.46
63.47 public void run() {
63.48 @@ -85,33 +76,22 @@
63.49 } catch (Exception e) {
63.50 e.printStackTrace();
63.51 throw new RuntimeException("caugth: " + e);
63.52 + } finally {
63.53 + if (server != null) { server.close(); }
63.54 }
63.55 }
63.56 }
63.57
63.58 static class ClientThread extends Thread {
63.59
63.60 - int port;
63.61 int serverPort;
63.62 - int bufferLength;
63.63 - int packetLength;
63.64 -
63.65 DatagramSocket client;
63.66 InetAddress host;
63.67
63.68 - ClientThread(int port, int serverPort,
63.69 - int bufferLength, int packetLength) throws IOException {
63.70 - this.port = port;
63.71 + ClientThread(int serverPort)throws IOException {
63.72 this.serverPort = serverPort;
63.73 this.host = InetAddress.getLocalHost();
63.74 - this.bufferLength = bufferLength;
63.75 - this.packetLength = packetLength;
63.76 - this.client = new DatagramSocket(port, host);
63.77 - }
63.78 -
63.79 - ClientThread() throws IOException {
63.80 - this(SendSize.clientPort, SendSize.serverPort,
63.81 - SendSize.bufferLength, SendSize.packetLength);
63.82 + this.client = new DatagramSocket();
63.83 }
63.84
63.85 public void run() {
63.86 @@ -129,6 +109,8 @@
63.87 } catch (Exception e) {
63.88 e.printStackTrace();
63.89 throw new RuntimeException("caught: " + e);
63.90 + } finally {
63.91 + if (client != null) { client.close(); }
63.92 }
63.93 }
63.94 }
64.1 --- a/test/java/net/Inet6Address/B6558853.java Fri Aug 06 12:52:07 2010 -0700
64.2 +++ b/test/java/net/Inet6Address/B6558853.java Mon Aug 09 16:02:19 2010 -0700
64.3 @@ -43,6 +43,9 @@
64.4 InetAddress dest = null;
64.5 while (l.hasMoreElements() && dest == null) {
64.6 NetworkInterface nif = l.nextElement();
64.7 + if (!nif.isUp())
64.8 + continue;
64.9 +
64.10 for (InterfaceAddress a : nif.getInterfaceAddresses()) {
64.11 if (a.getAddress() instanceof Inet6Address) {
64.12 Inet6Address a6 = (Inet6Address) a.getAddress();
64.13 @@ -53,6 +56,7 @@
64.14 }
64.15 }
64.16 }
64.17 + System.out.println("Using " + dest);
64.18 if (dest != null) {
64.19 B6558853 test = new B6558853(dest, port);
64.20 Thread thread = new Thread(test);
65.1 --- a/test/java/net/Inet6Address/serialize/Serialize.java Fri Aug 06 12:52:07 2010 -0700
65.2 +++ b/test/java/net/Inet6Address/serialize/Serialize.java Mon Aug 09 16:02:19 2010 -0700
65.3 @@ -72,6 +72,7 @@
65.4 File file = new File (System.getProperty("test.src"), "serial1.4.2.ser");
65.5 ois = new ObjectInputStream(new FileInputStream(file));
65.6 nobj = (Inet6Address) ois.readObject();
65.7 + ois.close();
65.8 if (!nobj.equals (InetAddress.getByName ("::1"))) {
65.9 throw new RuntimeException ("old ::1 not deserialized right");
65.10 }
65.11 @@ -90,6 +91,8 @@
65.12 nobj = (Inet6Address) ois.readObject();
65.13 } catch (NullPointerException e) {
65.14 throw new RuntimeException("6656849 Not fixed: NullPointer when deserializing");
65.15 + } finally {
65.16 + ois.close();
65.17 }
65.18 System.out.println(nobj);
65.19 System.out.println("All tests passed");
65.20 @@ -102,6 +105,7 @@
65.21
65.22 ObjectInputStream ois = new ObjectInputStream(new FileInputStream("i6a1.ser"));
65.23 Inet6Address nobj = (Inet6Address) ois.readObject();
65.24 + ois.close();
65.25
65.26 if (nobj.equals(obj)) {
65.27 return true;
66.1 --- a/test/java/net/InetAddress/CheckJNI.java Fri Aug 06 12:52:07 2010 -0700
66.2 +++ b/test/java/net/InetAddress/CheckJNI.java Mon Aug 09 16:02:19 2010 -0700
66.3 @@ -56,6 +56,8 @@
66.4
66.5 while (ifs.hasMoreElements()) {
66.6 NetworkInterface nif = (NetworkInterface)ifs.nextElement();
66.7 + if (!nif.isUp())
66.8 + continue;
66.9 Enumeration addrs = nif.getInetAddresses();
66.10 while (addrs.hasMoreElements()) {
66.11 InetAddress addr = (InetAddress) addrs.nextElement();
67.1 --- a/test/java/net/MulticastSocket/SetOutgoingIf.java Fri Aug 06 12:52:07 2010 -0700
67.2 +++ b/test/java/net/MulticastSocket/SetOutgoingIf.java Mon Aug 09 16:02:19 2010 -0700
67.3 @@ -76,6 +76,10 @@
67.4
67.5 // now determine what (if any) type of addresses are assigned to this interface
67.6 for (InetAddress addr : Collections.list(nic.getInetAddresses())) {
67.7 + if (addr.isAnyLocalAddress())
67.8 + continue;
67.9 +
67.10 + System.out.println(" addr " + addr);
67.11 if (addr instanceof Inet4Address) {
67.12 netIf.ipv4Address(true);
67.13 } else if (addr instanceof Inet6Address) {
68.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
68.2 +++ b/test/java/net/NetworkInterface/IPv4Only.java Mon Aug 09 16:02:19 2010 -0700
68.3 @@ -0,0 +1,51 @@
68.4 +/*
68.5 + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
68.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
68.7 + *
68.8 + * This code is free software; you can redistribute it and/or modify it
68.9 + * under the terms of the GNU General Public License version 2 only, as
68.10 + * published by the Free Software Foundation.
68.11 + *
68.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
68.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
68.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
68.15 + * version 2 for more details (a copy is included in the LICENSE file that
68.16 + * accompanied this code).
68.17 + *
68.18 + * You should have received a copy of the GNU General Public License version
68.19 + * 2 along with this work; if not, write to the Free Software Foundation,
68.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
68.21 + *
68.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
68.23 + * or visit www.oracle.com if you need additional information or have any
68.24 + * questions.
68.25 + */
68.26 +
68.27 +/* @test
68.28 + * @bug 6964714
68.29 + * @run main/othervm IPv4Only
68.30 + * @summary Test the networkinterface listing with java.net.preferIPv4Stack=true.
68.31 + */
68.32 +
68.33 +
68.34 +import java.net.*;
68.35 +import java.util.*;
68.36 +
68.37 +
68.38 +public class IPv4Only {
68.39 + public static void main(String[] args) throws Exception {
68.40 + System.setProperty("java.net.preferIPv4Stack","true");
68.41 +
68.42 + Enumeration<NetworkInterface> nifs = NetworkInterface.getNetworkInterfaces();
68.43 + while (nifs.hasMoreElements()) {
68.44 + NetworkInterface nif = nifs.nextElement();
68.45 + Enumeration<InetAddress> addrs = nif.getInetAddresses();
68.46 + while (addrs.hasMoreElements()) {
68.47 + InetAddress hostAddr = addrs.nextElement();
68.48 + if ( hostAddr instanceof Inet6Address ){
68.49 + throw new RuntimeException( "NetworkInterfaceV6List failed - found v6 address " + hostAddr.getHostAddress() );
68.50 + }
68.51 + }
68.52 + }
68.53 + }
68.54 +}
69.1 --- a/test/java/net/ResponseCache/B6181108.java Fri Aug 06 12:52:07 2010 -0700
69.2 +++ b/test/java/net/ResponseCache/B6181108.java Mon Aug 09 16:02:19 2010 -0700
69.3 @@ -67,9 +67,10 @@
69.4 out.flush();
69.5
69.6 s.close();
69.7 - ss.close();
69.8 } catch (Exception e) {
69.9 e.printStackTrace();
69.10 + } finally {
69.11 + try { ss.close(); } catch (IOException unused) {}
69.12 }
69.13 }
69.14
69.15 @@ -100,6 +101,7 @@
69.16 URLConnection urlc = url.openConnection();
69.17 int i = ((HttpURLConnection)(urlc)).getResponseCode();
69.18 System.out.println ("response code = " + i);
69.19 + ResponseCache.setDefault(null);
69.20 }
69.21
69.22 public static void main(String args[]) throws Exception {
70.1 --- a/test/java/net/ResponseCache/ResponseCacheTest.java Fri Aug 06 12:52:07 2010 -0700
70.2 +++ b/test/java/net/ResponseCache/ResponseCacheTest.java Mon Aug 09 16:02:19 2010 -0700
70.3 @@ -30,7 +30,6 @@
70.4 import java.net.*;
70.5 import java.util.*;
70.6 import java.io.*;
70.7 -import java.nio.*;
70.8 import sun.net.www.ParseUtil;
70.9 import javax.net.ssl.*;
70.10
70.11 @@ -43,11 +42,16 @@
70.12 static URL url1;
70.13 static URL url2;
70.14 static String FNPrefix, OutFNPrefix;
70.15 + static List<Closeable> streams = new ArrayList<>();
70.16 + static List<File> files = new ArrayList<>();
70.17 +
70.18 /*
70.19 * Our "http" server to return a 404 */
70.20 public void run() {
70.21 + Socket s = null;
70.22 + FileInputStream fis = null;
70.23 try {
70.24 - Socket s = ss.accept();
70.25 + s = ss.accept();
70.26
70.27 InputStream is = s.getInputStream ();
70.28 BufferedReader r = new BufferedReader(new InputStreamReader(is));
70.29 @@ -68,7 +72,7 @@
70.30 out.print("Content-Length: "+file2.length()+"\r\n");
70.31 out.print("Connection: close\r\n");
70.32 out.print("\r\n");
70.33 - FileInputStream fis = new FileInputStream(file2);
70.34 + fis = new FileInputStream(file2);
70.35 byte[] buf = new byte[(int)file2.length()];
70.36 int len;
70.37 while ((len = fis.read(buf)) != -1) {
70.38 @@ -81,6 +85,10 @@
70.39 ss.close();
70.40 } catch (Exception e) {
70.41 e.printStackTrace();
70.42 + } finally {
70.43 + try { ss.close(); } catch (IOException unused) {}
70.44 + try { s.close(); } catch (IOException unused) {}
70.45 + try { fis.close(); } catch (IOException unused) {}
70.46 }
70.47 }
70.48 static class NameVerifier implements HostnameVerifier {
70.49 @@ -144,11 +152,14 @@
70.50 // assert (headers1 == headers2 && file1 == file2.2)
70.51 File file1 = new File(OutFNPrefix+"file1");
70.52 File file2 = new File(OutFNPrefix+"file2.2");
70.53 + files.add(file1);
70.54 + files.add(file2);
70.55 System.out.println("headers1"+headers1+"\nheaders2="+headers2);
70.56 if (!headers1.equals(headers2) || file1.length() != file2.length()) {
70.57 throw new RuntimeException("test failed");
70.58 }
70.59 }
70.60 +
70.61 public static void main(String args[]) throws Exception {
70.62 try {
70.63 ResponseCache.setDefault(new MyResponseCache());
70.64 @@ -157,6 +168,12 @@
70.65 new ResponseCacheTest();
70.66 } finally{
70.67 ResponseCache.setDefault(null);
70.68 + for (Closeable c: streams) {
70.69 + try { c.close(); } catch (IOException unused) {}
70.70 + }
70.71 + for (File f: files) {
70.72 + f.delete();
70.73 + }
70.74 }
70.75 }
70.76
70.77 @@ -184,6 +201,7 @@
70.78 public MyCacheResponse(String filename) {
70.79 try {
70.80 fis = new FileInputStream(new File(filename));
70.81 + streams.add(fis);
70.82 ObjectInputStream ois = new ObjectInputStream(fis);
70.83 headers = (Map<String,List<String>>)ois.readObject();
70.84 } catch (Exception ex) {
70.85 @@ -206,6 +224,8 @@
70.86 try {
70.87 File file = new File(filename);
70.88 fos = new FileOutputStream(file);
70.89 + streams.add(fos);
70.90 + files.add(file);
70.91 ObjectOutputStream oos = new ObjectOutputStream(fos);
70.92 oos.writeObject(rspHeaders);
70.93 } catch (Exception ex) {
71.1 --- a/test/java/net/ResponseCache/getResponseCode.java Fri Aug 06 12:52:07 2010 -0700
71.2 +++ b/test/java/net/ResponseCache/getResponseCode.java Mon Aug 09 16:02:19 2010 -0700
71.3 @@ -39,6 +39,7 @@
71.4 public class getResponseCode {
71.5 static URL url;
71.6 static String FNPrefix;
71.7 + static List<Closeable> resources = new ArrayList<>();
71.8
71.9 getResponseCode() throws Exception {
71.10 url = new URL("http://localhost/file1.cache");
71.11 @@ -57,6 +58,9 @@
71.12 new getResponseCode();
71.13 } finally{
71.14 ResponseCache.setDefault(null);
71.15 + for (Closeable c : resources) {
71.16 + try { c.close(); } catch (IOException unused) {}
71.17 + }
71.18 }
71.19 }
71.20
71.21 @@ -77,6 +81,7 @@
71.22 public MyResponse(String filename) {
71.23 try {
71.24 fis = new FileInputStream(new File(filename));
71.25 + resources.add(fis);
71.26 headers = (Map<String,List<String>>)new ObjectInputStream(fis).readObject();
71.27 } catch (Exception ex) {
71.28 throw new RuntimeException(ex.getMessage());
72.1 --- a/test/java/net/Socket/AccurateTimeout.java Fri Aug 06 12:52:07 2010 -0700
72.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
72.3 @@ -1,144 +0,0 @@
72.4 -/*
72.5 - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
72.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
72.7 - *
72.8 - * This code is free software; you can redistribute it and/or modify it
72.9 - * under the terms of the GNU General Public License version 2 only, as
72.10 - * published by the Free Software Foundation.
72.11 - *
72.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
72.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
72.14 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
72.15 - * version 2 for more details (a copy is included in the LICENSE file that
72.16 - * accompanied this code).
72.17 - *
72.18 - * You should have received a copy of the GNU General Public License version
72.19 - * 2 along with this work; if not, write to the Free Software Foundation,
72.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
72.21 - *
72.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
72.23 - * or visit www.oracle.com if you need additional information or have any
72.24 - * questions.
72.25 - */
72.26 -
72.27 -/* @test
72.28 - * @bug 4512028
72.29 - * @summary Check the tolerance on read timeouts.
72.30 - */
72.31 -import java.net.*;
72.32 -import java.io.*;
72.33 -
72.34 -public class AccurateTimeout {
72.35 -
72.36 - static final int TOLERANCE = 100;
72.37 -
72.38 - static boolean skipTest() {
72.39 - String os = System.getProperty("os.name");
72.40 - if (os.equals("Windows 95") ||
72.41 - os.equals("Windows 98") ||
72.42 - os.equals("Windows Me")) {
72.43 -
72.44 - System.out.println("Due to an OS bug timeout tolerance cannot be tested on this OS");
72.45 - return true;
72.46 - }
72.47 - return false;
72.48 - }
72.49 -
72.50 - public static void main(String args[]) throws Exception {
72.51 -
72.52 - if (skipTest()) {
72.53 - return;
72.54 - }
72.55 -
72.56 - int failures = 0;
72.57 - int timeout;
72.58 -
72.59 - System.out.println("");
72.60 - System.out.println("Testing Socket.getInputStream().read() ...");
72.61 - System.out.println("");
72.62 -
72.63 - ServerSocket ss = new ServerSocket(0);
72.64 - Socket s1 = new Socket(InetAddress.getLocalHost(), ss.getLocalPort());
72.65 - Socket s2 = ss.accept();
72.66 -
72.67 - InputStream in = s1.getInputStream();
72.68 -
72.69 - timeout = 100;
72.70 - while (timeout < 2500) {
72.71 - s1.setSoTimeout(timeout);
72.72 -
72.73 - long startTime = System.currentTimeMillis();
72.74 - try {
72.75 - in.read();
72.76 - } catch (SocketTimeoutException e) {
72.77 - }
72.78 - long actual = System.currentTimeMillis() - startTime;
72.79 -
72.80 - System.out.print("excepted: " + timeout + " actual: " + actual);
72.81 -
72.82 - if (Math.abs(actual-timeout) > TOLERANCE) {
72.83 - System.out.print(" *** FAIL: outside tolerance");
72.84 - failures++;
72.85 - } else {
72.86 - System.out.print(" PASS.");
72.87 - }
72.88 -
72.89 - System.out.println("");
72.90 - timeout += 200;
72.91 - }
72.92 -
72.93 - s1.close();
72.94 - s2.close();
72.95 - ss.close();
72.96 -
72.97 -
72.98 - // ----------
72.99 -
72.100 -
72.101 - System.out.println("");
72.102 - System.out.println("Testing DatagramSocket.receive ...");
72.103 - System.out.println("");
72.104 -
72.105 - byte b[] = new byte[8];
72.106 - DatagramPacket p = new DatagramPacket(b, b.length);
72.107 -
72.108 - DatagramSocket ds = new DatagramSocket();
72.109 -
72.110 - timeout = 100;
72.111 - while (timeout < 2500) {
72.112 - ds.setSoTimeout(timeout);
72.113 -
72.114 - long startTime = System.currentTimeMillis();
72.115 - try {
72.116 - ds.receive(p);
72.117 - } catch (SocketTimeoutException e) {
72.118 - }
72.119 - long actual = System.currentTimeMillis() - startTime;
72.120 -
72.121 - System.out.print("excepted: " + timeout + " actual: " + actual);
72.122 -
72.123 - if (Math.abs(actual-timeout) > TOLERANCE) {
72.124 - System.out.print(" *** FAIL: outside tolerance");
72.125 - failures++;
72.126 - } else {
72.127 - System.out.print(" PASS.");
72.128 - }
72.129 -
72.130 - System.out.println("");
72.131 - timeout += 200;
72.132 - }
72.133 -
72.134 - ds.close();
72.135 -
72.136 - System.out.println("");
72.137 -
72.138 - // ---------
72.139 -
72.140 - if (failures > 0) {
72.141 - throw new Exception("Test failed: " + failures +
72.142 - " test(s) outside tolerance");
72.143 - }
72.144 -
72.145 - }
72.146 -
72.147 -}
73.1 --- a/test/java/net/Socket/CloseAvailable.java Fri Aug 06 12:52:07 2010 -0700
73.2 +++ b/test/java/net/Socket/CloseAvailable.java Mon Aug 09 16:02:19 2010 -0700
73.3 @@ -47,6 +47,7 @@
73.4 t.start();
73.5
73.6 Socket soc = ss.accept();
73.7 + ss.close();
73.8
73.9 DataInputStream is = new DataInputStream(soc.getInputStream());
73.10 is.close();
73.11 @@ -64,7 +65,7 @@
73.12 public void run() {
73.13 try {
73.14 Socket s = new Socket(addr, port);
73.15 -
73.16 + s.close();
73.17 } catch (Exception e) {
73.18 e.printStackTrace();
73.19 }
74.1 --- a/test/java/net/Socket/DeadlockTest.java Fri Aug 06 12:52:07 2010 -0700
74.2 +++ b/test/java/net/Socket/DeadlockTest.java Mon Aug 09 16:02:19 2010 -0700
74.3 @@ -33,29 +33,32 @@
74.4
74.5 public class DeadlockTest {
74.6 public static void main(String [] argv) throws Exception {
74.7 + ServerSocket ss = new ServerSocket(0);
74.8 + Socket clientSocket = new Socket();
74.9
74.10 - // Start the server thread
74.11 - Thread s1 = new Thread(new ServerThread());
74.12 - s1.start();
74.13 + try {
74.14 + // Start the server thread
74.15 + Thread s1 = new Thread(new ServerThread(ss));
74.16 + s1.start();
74.17
74.18 - // Sleep to make sure s1 has created a server socket
74.19 - Thread.sleep(1000);
74.20 + // Start the client thread
74.21 + ClientThread ct = new ClientThread(clientSocket, ss.getLocalPort());
74.22 + Thread c1 = new Thread(ct);
74.23 + c1.start();
74.24
74.25 - // Start the client thread
74.26 - ClientThread ct = new ClientThread();
74.27 - Thread c1 = new Thread(ct);
74.28 - c1.start();
74.29 + // Wait for the client thread to finish
74.30 + c1.join(20000);
74.31
74.32 - // Wait for the client thread to finish
74.33 - c1.join(40000);
74.34 -
74.35 - // If timeout, we assume there is a deadlock
74.36 - if (c1.isAlive() == true) {
74.37 - // Close the socket to force the server thread
74.38 - // terminate too
74.39 - s1.stop();
74.40 - ct.getSock().close();
74.41 - throw new Exception("Takes too long. Dead lock");
74.42 + // If timeout, we assume there is a deadlock
74.43 + if (c1.isAlive() == true) {
74.44 + // Close the socket to force the server thread
74.45 + // terminate too
74.46 + s1.stop();
74.47 + throw new Exception("Takes too long. Dead lock");
74.48 + }
74.49 + } finally {
74.50 + ss.close();
74.51 + clientSocket.close();
74.52 }
74.53 }
74.54 }
74.55 @@ -71,8 +74,8 @@
74.56
74.57 Socket sock;
74.58
74.59 - public ServerThread() throws Exception {
74.60 -
74.61 + public ServerThread(ServerSocket serverSocket) throws Exception {
74.62 + this.server = serverSocket;
74.63 }
74.64
74.65 public void ping(int cnt) {
74.66 @@ -85,7 +88,6 @@
74.67
74.68 try {
74.69 if (Thread.currentThread().getName().startsWith("child") == false) {
74.70 - server = new ServerSocket(4711);
74.71 sock = server.accept();
74.72
74.73 new Thread(this, "child").start();
74.74 @@ -107,6 +109,7 @@
74.75 }
74.76
74.77 } catch (Throwable e) {
74.78 + System.out.println(e);
74.79 // If anything goes wrong, just quit.
74.80 }
74.81
74.82 @@ -141,10 +144,11 @@
74.83
74.84 Socket sock;
74.85
74.86 - public ClientThread() throws Exception {
74.87 + public ClientThread(Socket sock, int serverPort) throws Exception {
74.88 try {
74.89 - System.out.println("About to create a socket");
74.90 - sock = new Socket(InetAddress.getLocalHost().getHostName(), 4711);
74.91 + System.out.println("About to connect the client socket");
74.92 + this.sock = sock;
74.93 + this.sock.connect(new InetSocketAddress("localhost", serverPort));
74.94 System.out.println("connected");
74.95
74.96 out = new ObjectOutputStream(sock.getOutputStream());
74.97 @@ -156,10 +160,6 @@
74.98 }
74.99 }
74.100
74.101 - public Socket getSock() {
74.102 - return sock;
74.103 - }
74.104 -
74.105 private int cnt = 1;
74.106
74.107 public void run() {
74.108 @@ -213,6 +213,7 @@
74.109 System.out.println("write message done " + cnt++);
74.110 } catch (IOException ioe) {
74.111 // Ignore the exception
74.112 + System.out.println(ioe);
74.113 }
74.114 }
74.115 }
75.1 --- a/test/java/net/Socket/LingerTest.java Fri Aug 06 12:52:07 2010 -0700
75.2 +++ b/test/java/net/Socket/LingerTest.java Mon Aug 09 16:02:19 2010 -0700
75.3 @@ -81,7 +81,7 @@
75.4 public void run() {
75.5 System.out.println ("Another starts");
75.6 try {
75.7 - Thread.currentThread().sleep(delay);
75.8 + Thread.sleep(delay);
75.9 Socket s = new Socket("localhost", port);
75.10 synchronized (this) {
75.11 connected = true;
75.12 @@ -105,7 +105,6 @@
75.13 Socket s1 = new Socket("localhost", ss.getLocalPort());
75.14 Socket s2 = ss.accept();
75.15
75.16 -
75.17 // setup conditions for untransmitted data and lengthy
75.18 // linger interval
75.19 s1.setSendBufferSize(128*1024);
75.20 @@ -122,14 +121,15 @@
75.21 thr.start();
75.22
75.23 // give sender time to queue the data
75.24 - Thread.currentThread().sleep(1000);
75.25 + Thread.sleep(1000);
75.26
75.27 // close the socket asynchronously
75.28 (new Thread(new Closer(s1))).start();
75.29
75.30 // give another time to run
75.31 - Thread.currentThread().sleep(10000);
75.32 + Thread.sleep(10000);
75.33
75.34 + ss.close();
75.35 // check that another is done
75.36 if (!another.connected()) {
75.37 throw new RuntimeException("Another thread is blocked");
76.1 --- a/test/java/net/Socket/LinkLocal.java Fri Aug 06 12:52:07 2010 -0700
76.2 +++ b/test/java/net/Socket/LinkLocal.java Mon Aug 09 16:02:19 2010 -0700
76.3 @@ -58,11 +58,10 @@
76.4 } catch (SocketException e) {
76.5 failed++;
76.6 System.out.println("Test failed: " + e);
76.7 + } finally {
76.8 + s.close();
76.9 + ss.close();
76.10 }
76.11 -
76.12 - // clean up
76.13 - s.close();
76.14 - ss.close();
76.15 }
76.16
76.17 static void UdpTest(InetAddress ia, boolean connected) throws Exception {
76.18 @@ -93,16 +92,16 @@
76.19 ds1.send(p);
76.20 System.out.println("Packet has been sent.");
76.21
76.22 - ds2.setSoTimeout(1000);
76.23 + ds2.setSoTimeout(5000);
76.24 ds2.receive(p);
76.25 System.out.println("Test passed - packet received.");
76.26 } catch (SocketException e) {
76.27 failed++;
76.28 System.out.println("Test failed: " + e);
76.29 + } finally {
76.30 + ds1.close();
76.31 + ds2.close();
76.32 }
76.33 -
76.34 - ds1.close();
76.35 - ds2.close();
76.36 }
76.37
76.38 static void TestAddress(InetAddress ia) throws Exception {
76.39 @@ -138,6 +137,9 @@
76.40 Enumeration nifs = NetworkInterface.getNetworkInterfaces();
76.41 while (nifs.hasMoreElements()) {
76.42 NetworkInterface ni = (NetworkInterface)nifs.nextElement();
76.43 + if (!ni.isUp())
76.44 + continue;
76.45 +
76.46 Enumeration addrs = ni.getInetAddresses();
76.47 while (addrs.hasMoreElements()) {
76.48 InetAddress addr = (InetAddress)addrs.nextElement();
77.1 --- a/test/java/net/Socket/ProxyCons.java Fri Aug 06 12:52:07 2010 -0700
77.2 +++ b/test/java/net/Socket/ProxyCons.java Mon Aug 09 16:02:19 2010 -0700
77.3 @@ -39,6 +39,7 @@
77.4 public void run () {
77.5 try {
77.6 Socket s = server.accept ();
77.7 + s.close();
77.8 while (!finished ()) {
77.9 Thread.sleep (500);
77.10 }
77.11 @@ -58,10 +59,9 @@
77.12 public ProxyCons() {
77.13 }
77.14
77.15 - void test() {
77.16 + void test() throws Exception {
77.17 + ServerSocket ss = new ServerSocket(0);
77.18 try {
77.19 - ServerSocket ss = new ServerSocket();
77.20 - ss.bind(new InetSocketAddress(0));
77.21 Server s = new Server(ss);
77.22 s.start();
77.23 Socket sock = new Socket(Proxy.NO_PROXY);
77.24 @@ -70,10 +70,12 @@
77.25 sock.close();
77.26 } catch (java.io.IOException e) {
77.27 throw new RuntimeException(e);
77.28 + } finally {
77.29 + ss.close();
77.30 }
77.31 }
77.32
77.33 - public static void main(String[] args) {
77.34 + public static void main(String[] args) throws Exception {
77.35 ProxyCons c = new ProxyCons();
77.36 c.test();
77.37 }
78.1 --- a/test/java/net/Socket/ReadTimeout.java Fri Aug 06 12:52:07 2010 -0700
78.2 +++ b/test/java/net/Socket/ReadTimeout.java Mon Aug 09 16:02:19 2010 -0700
78.3 @@ -44,7 +44,7 @@
78.4 sin = InetAddress.getLocalHost();
78.5 srv = new ServerSocket(port);
78.6 port = srv.getLocalPort();
78.7 - soc = new Socket(sin, port, true);
78.8 + soc = new Socket(sin, port);
78.9 soc1 = srv.accept();
78.10 soc.setSoTimeout(tout);
78.11
78.12 @@ -53,10 +53,10 @@
78.13 os = soc1.getOutputStream();
78.14 is.read();
78.15 } catch(InterruptedIOException e) {
78.16 + } finally {
78.17 + soc.close();
78.18 + soc1.close();
78.19 + srv.close();
78.20 }
78.21 -
78.22 - soc.close();
78.23 - soc1.close();
78.24 - srv.close();
78.25 }
78.26 }
79.1 --- a/test/java/net/Socket/SetReceiveBufferSize.java Fri Aug 06 12:52:07 2010 -0700
79.2 +++ b/test/java/net/Socket/SetReceiveBufferSize.java Mon Aug 09 16:02:19 2010 -0700
79.3 @@ -32,29 +32,14 @@
79.4 import java.net.ServerSocket;
79.5
79.6 public class SetReceiveBufferSize {
79.7 - class Server extends Thread {
79.8 - private ServerSocket ss;
79.9 - public Server(ServerSocket ss) {
79.10 - this.ss = ss;
79.11 - }
79.12 -
79.13 - public void run() {
79.14 - try {
79.15 - ss.accept();
79.16 - } catch (Exception e) {
79.17 - }
79.18 - }
79.19 - }
79.20 -
79.21 public static void main(String[] args) throws Exception {
79.22 SetReceiveBufferSize s = new SetReceiveBufferSize();
79.23 }
79.24
79.25 public SetReceiveBufferSize() throws Exception {
79.26 ServerSocket ss = new ServerSocket(0);
79.27 - Server serv = new Server(ss);
79.28 - serv.start();
79.29 Socket s = new Socket("localhost", ss.getLocalPort());
79.30 + Socket accepted = ss.accept();
79.31 try {
79.32 s.setReceiveBufferSize(0);
79.33 } catch (IllegalArgumentException e) {
79.34 @@ -62,6 +47,8 @@
79.35 } catch (Exception ex) {
79.36 } finally {
79.37 ss.close();
79.38 + s.close();
79.39 + accepted.close();
79.40 }
79.41 throw new RuntimeException("IllegalArgumentException not thrown!");
79.42 }
80.1 --- a/test/java/net/Socket/SetSoLinger.java Fri Aug 06 12:52:07 2010 -0700
80.2 +++ b/test/java/net/Socket/SetSoLinger.java Mon Aug 09 16:02:19 2010 -0700
80.3 @@ -30,36 +30,24 @@
80.4
80.5 import java.net.*;
80.6
80.7 -public class SetSoLinger implements Runnable {
80.8 - static ServerSocket ss;
80.9 - static InetAddress addr;
80.10 - static int port;
80.11 +public class SetSoLinger {
80.12 + static final int LINGER = 65546;
80.13
80.14 public static void main(String args[]) throws Exception {
80.15 - boolean error = true;
80.16 - int linger = 65546;
80.17 - int value = 0;
80.18 - addr = InetAddress.getLocalHost();
80.19 - ss = new ServerSocket(0);
80.20 - port = ss.getLocalPort();
80.21 + int value;
80.22 + InetAddress addr = InetAddress.getLocalHost();
80.23 + ServerSocket ss = new ServerSocket(0);
80.24 + int port = ss.getLocalPort();
80.25
80.26 - Thread t = new Thread(new SetSoLinger());
80.27 - t.start();
80.28 + Socket s = new Socket(addr, port);
80.29 Socket soc = ss.accept();
80.30 - soc.setSoLinger(true, linger);
80.31 + soc.setSoLinger(true, LINGER);
80.32 value = soc.getSoLinger();
80.33 soc.close();
80.34 + s.close();
80.35 + ss.close();
80.36
80.37 if(value != 65535)
80.38 throw new RuntimeException("Failed. Value not properly reduced.");
80.39 }
80.40 -
80.41 - public void run() {
80.42 - try {
80.43 - Socket s = new Socket(addr, port);
80.44 - } catch (Exception e) {
80.45 - e.printStackTrace();
80.46 - }
80.47 - }
80.48 -
80.49 }
81.1 --- a/test/java/net/Socket/ShutdownBoth.java Fri Aug 06 12:52:07 2010 -0700
81.2 +++ b/test/java/net/Socket/ShutdownBoth.java Mon Aug 09 16:02:19 2010 -0700
81.3 @@ -36,12 +36,14 @@
81.4 Socket s1 = new Socket(ss.getInetAddress(), ss.getLocalPort());
81.5 Socket s2 = ss.accept();
81.6
81.7 - s1.shutdownInput();
81.8 - s1.shutdownOutput(); // failed b55
81.9 -
81.10 - s1.close();
81.11 - s2.close();
81.12 - ss.close();
81.13 + try {
81.14 + s1.shutdownInput();
81.15 + s1.shutdownOutput(); // failed b55
81.16 + } finally {
81.17 + s1.close();
81.18 + s2.close();
81.19 + ss.close();
81.20 + }
81.21 }
81.22
81.23 }
82.1 --- a/test/java/net/Socket/SoTimeout.java Fri Aug 06 12:52:07 2010 -0700
82.2 +++ b/test/java/net/Socket/SoTimeout.java Mon Aug 09 16:02:19 2010 -0700
82.3 @@ -52,9 +52,10 @@
82.4 t.start();
82.5
82.6 Socket s = serverSocket.accept();
82.7 + serverSocket.close();
82.8
82.9 - // set a 1 second timeout on the socket
82.10 - s.setSoTimeout(1000);
82.11 + // set a 5 second timeout on the socket
82.12 + s.setSoTimeout(5000);
82.13
82.14 s.getInputStream().read(b, 0, b.length);
82.15 s.close();
82.16 @@ -64,7 +65,7 @@
82.17 // this sequence should complete fairly quickly and if it
82.18 // takes something resembling the the SoTimeout value then
82.19 // we are probably incorrectly blocking and not waking up
82.20 - if (waited > 500) {
82.21 + if (waited > 2000) {
82.22 throw new Exception("shouldn't take " + waited + " to complete");
82.23 }
82.24 }
83.1 --- a/test/java/net/Socket/Timeout.java Fri Aug 06 12:52:07 2010 -0700
83.2 +++ b/test/java/net/Socket/Timeout.java Mon Aug 09 16:02:19 2010 -0700
83.3 @@ -31,18 +31,16 @@
83.4 import java.io.*;
83.5
83.6 public class Timeout {
83.7 -
83.8 - public static ServerSocket sock;
83.9 -
83.10 public static void main(String[] args) throws Exception {
83.11 boolean success = false;
83.12 + ServerSocket sock = new ServerSocket(0);
83.13 try {
83.14 - ServerSocket sock;
83.15 - sock = new ServerSocket(2333);
83.16 sock.setSoTimeout(2);
83.17 sock.accept();
83.18 } catch (InterruptedIOException e) {
83.19 success = true;
83.20 + } finally {
83.21 + sock.close();
83.22 }
83.23 if (!success)
83.24 throw new RuntimeException("Socket timeout failure.");
84.1 --- a/test/java/net/Socket/UrgentDataTest.java Fri Aug 06 12:52:07 2010 -0700
84.2 +++ b/test/java/net/Socket/UrgentDataTest.java Mon Aug 09 16:02:19 2010 -0700
84.3 @@ -90,63 +90,64 @@
84.4 }
84.5
84.6 public void run () throws Exception {
84.7 - if (isClient) {
84.8 - client = new Socket (clHost, clPort);
84.9 - clis = client.getInputStream();
84.10 - clos = client.getOutputStream();
84.11 - client.setOOBInline (true);
84.12 - if (client.getOOBInline() != true) {
84.13 - throw new RuntimeException ("Setting OOBINLINE failed");
84.14 - }
84.15 - }
84.16 - if (isServer) {
84.17 - server = listener.accept ();
84.18 - sis = server.getInputStream();
84.19 - sos = server.getOutputStream();
84.20 - }
84.21 - if (isClient) {
84.22 - clos.write ("Hello".getBytes ());
84.23 - client.sendUrgentData (100);
84.24 - clos.write ("world".getBytes ());
84.25 - }
84.26 - // read Hello world from server (during which oob byte must have been dropped)
84.27 - String s = "Helloworld";
84.28 - if (isServer) {
84.29 - for (int y=0; y<s.length(); y++) {
84.30 - int c = sis.read ();
84.31 - if (c != (int)s.charAt (y)) {
84.32 - throw new RuntimeException ("Unexpected character read");
84.33 + try {
84.34 + if (isClient) {
84.35 + client = new Socket (clHost, clPort);
84.36 + clis = client.getInputStream();
84.37 + clos = client.getOutputStream();
84.38 + client.setOOBInline (true);
84.39 + if (client.getOOBInline() != true) {
84.40 + throw new RuntimeException ("Setting OOBINLINE failed");
84.41 }
84.42 }
84.43 - // Do the same from server to client
84.44 - sos.write ("Hello".getBytes ());
84.45 - server.sendUrgentData (101);
84.46 - sos.write ("World".getBytes ());
84.47 - }
84.48 - if (isClient) {
84.49 - // read Hello world from client (during which oob byte must have been read)
84.50 - s="Hello";
84.51 - for (int y=0; y<s.length(); y++) {
84.52 - int c = clis.read ();
84.53 - if (c != (int)s.charAt (y)) {
84.54 - throw new RuntimeException ("Unexpected character read");
84.55 + if (isServer) {
84.56 + server = listener.accept ();
84.57 + sis = server.getInputStream();
84.58 + sos = server.getOutputStream();
84.59 + }
84.60 + if (isClient) {
84.61 + clos.write ("Hello".getBytes ());
84.62 + client.sendUrgentData (100);
84.63 + clos.write ("world".getBytes ());
84.64 + }
84.65 + // read Hello world from server (during which oob byte must have been dropped)
84.66 + String s = "Helloworld";
84.67 + if (isServer) {
84.68 + for (int y=0; y<s.length(); y++) {
84.69 + int c = sis.read ();
84.70 + if (c != (int)s.charAt (y)) {
84.71 + throw new RuntimeException ("Unexpected character read");
84.72 + }
84.73 + }
84.74 + // Do the same from server to client
84.75 + sos.write ("Hello".getBytes ());
84.76 + server.sendUrgentData (101);
84.77 + sos.write ("World".getBytes ());
84.78 + }
84.79 + if (isClient) {
84.80 + // read Hello world from client (during which oob byte must have been read)
84.81 + s="Hello";
84.82 + for (int y=0; y<s.length(); y++) {
84.83 + int c = clis.read ();
84.84 + if (c != (int)s.charAt (y)) {
84.85 + throw new RuntimeException ("Unexpected character read");
84.86 + }
84.87 + }
84.88 + if (clis.read() != 101) {
84.89 + throw new RuntimeException ("OOB byte not received");
84.90 + }
84.91 + s="World";
84.92 + for (int y=0; y<s.length(); y++) {
84.93 + int c = clis.read ();
84.94 + if (c != (int)s.charAt (y)) {
84.95 + throw new RuntimeException ("Unexpected character read");
84.96 + }
84.97 }
84.98 }
84.99 - if (clis.read() != 101) {
84.100 - throw new RuntimeException ("OOB byte not received");
84.101 - }
84.102 - s="World";
84.103 - for (int y=0; y<s.length(); y++) {
84.104 - int c = clis.read ();
84.105 - if (c != (int)s.charAt (y)) {
84.106 - throw new RuntimeException ("Unexpected character read");
84.107 - }
84.108 - }
84.109 + } finally {
84.110 + if (listener != null) listener.close();
84.111 + if (client != null) client.close ();
84.112 + if (server != null) server.close ();
84.113 }
84.114 -
84.115 - if (isClient)
84.116 - client.close ();
84.117 - if (isServer)
84.118 - server.close ();
84.119 }
84.120 }
85.1 --- a/test/java/net/Socket/asyncClose/BrokenPipe.java Fri Aug 06 12:52:07 2010 -0700
85.2 +++ b/test/java/net/Socket/asyncClose/BrokenPipe.java Mon Aug 09 16:02:19 2010 -0700
85.3 @@ -61,7 +61,6 @@
85.4 try {
85.5 client.getOutputStream().write(new byte[1000000]);
85.6 } catch (IOException ioe) {
85.7 -
85.8 /*
85.9 * Check that the exception text doesn't indicate the
85.10 * socket is closed. In tiger we should be able to
85.11 @@ -71,8 +70,9 @@
85.12 if (text.toLowerCase().indexOf("closed") >= 0) {
85.13 throw ioe;
85.14 }
85.15 + } finally {
85.16 + server.close();
85.17 }
85.18 - server.close();
85.19 }
85.20
85.21 }
86.1 --- a/test/java/net/Socket/setReuseAddress/Restart.java Fri Aug 06 12:52:07 2010 -0700
86.2 +++ b/test/java/net/Socket/setReuseAddress/Restart.java Mon Aug 09 16:02:19 2010 -0700
86.3 @@ -39,27 +39,28 @@
86.4 */
86.5
86.6 public static void main(String args[]) throws Exception {
86.7 + ServerSocket ss = new ServerSocket(0);
86.8 + Socket s1 = null, s2 = null;
86.9 + try {
86.10 + int port = ss.getLocalPort();
86.11
86.12 - InetSocketAddress isa = new InetSocketAddress(0);
86.13 - ServerSocket ss = new ServerSocket();
86.14 - ss.bind(isa);
86.15 + s1 = new Socket(InetAddress.getLocalHost(), port);
86.16 + s2 = ss.accept();
86.17
86.18 - int port = ss.getLocalPort();
86.19 + // close server socket and the accepted connection
86.20 + ss.close();
86.21 + s2.close();
86.22
86.23 - Socket s1 = new Socket(InetAddress.getLocalHost(), port);
86.24 - Socket s2 = ss.accept();
86.25 + ss = new ServerSocket();
86.26 + ss.bind( new InetSocketAddress(port) );
86.27 + ss.close();
86.28
86.29 - // close server socket and the accepted connection
86.30 - ss.close();
86.31 - s2.close();
86.32 -
86.33 - boolean failed = false;
86.34 -
86.35 - ss = new ServerSocket();
86.36 - ss.bind( new InetSocketAddress(port) );
86.37 - ss.close();
86.38 -
86.39 - // close the client socket
86.40 - s1.close();
86.41 + // close the client socket
86.42 + s1.close();
86.43 + } finally {
86.44 + if (ss != null) ss.close();
86.45 + if (s1 != null) s1.close();
86.46 + if (s2 != null) s2.close();
86.47 + }
86.48 }
86.49 }
87.1 --- a/test/java/net/SocketInputStream/SocketClosedException.java Fri Aug 06 12:52:07 2010 -0700
87.2 +++ b/test/java/net/SocketInputStream/SocketClosedException.java Mon Aug 09 16:02:19 2010 -0700
87.3 @@ -32,68 +32,37 @@
87.4 import java.net.*;
87.5
87.6 public class SocketClosedException {
87.7 + static void doServerSide() throws Exception {
87.8 + try {
87.9 + Socket socket = serverSocket.accept();
87.10
87.11 - /*
87.12 - * Is the server ready to serve?
87.13 - */
87.14 - volatile static boolean serverReady = false;
87.15 + OutputStream os = socket.getOutputStream();
87.16
87.17 - /*
87.18 - * Define the server side of the test.
87.19 - *
87.20 - * If the server prematurely exits, serverReady will be set to true
87.21 - * to avoid infinite hangs.
87.22 - */
87.23 - static void doServerSide() throws Exception {
87.24 - ServerSocket serverSocket = new ServerSocket(serverPort);
87.25 - serverPort = serverSocket.getLocalPort();
87.26 -
87.27 - /*
87.28 - * Signal Client, we're ready for a connect.
87.29 - */
87.30 - serverReady = true;
87.31 -
87.32 - Socket socket = serverSocket.accept();
87.33 -
87.34 - InputStream is = socket.getInputStream();
87.35 - OutputStream os = socket.getOutputStream();
87.36 -
87.37 - os.write(85);
87.38 - os.flush();
87.39 - socket.close();
87.40 + os.write(85);
87.41 + os.flush();
87.42 + socket.close();
87.43 + } finally {
87.44 + serverSocket.close();
87.45 + }
87.46 }
87.47
87.48 - /*
87.49 - * Define the client side of the test.
87.50 - *
87.51 - * If the server prematurely exits, serverReady will be set to true
87.52 - * to avoid infinite hangs.
87.53 - */
87.54 - static void doClientSide() throws Exception {
87.55 + static void doClientSide(int port) throws Exception {
87.56 + Socket socket = new Socket("localhost", port);
87.57 + InputStream is = socket.getInputStream();
87.58
87.59 - /*
87.60 - * Wait for server to get started.
87.61 - */
87.62 - while (!serverReady) {
87.63 - Thread.sleep(5000);
87.64 - }
87.65 -
87.66 - Socket socket = new Socket("localhost", serverPort);
87.67 - InputStream is = socket.getInputStream();
87.68 - OutputStream os = socket.getOutputStream();
87.69 -
87.70 - int read = is.read();
87.71 + is.read();
87.72 socket.close();
87.73 - read = is.read();
87.74 + is.read();
87.75 }
87.76
87.77 - static int serverPort = 0;
87.78 + static ServerSocket serverSocket;
87.79 static Exception serverException = null;
87.80
87.81 public static void main(String[] args) throws Exception {
87.82 + serverSocket = new ServerSocket(0);
87.83 startServer();
87.84 try {
87.85 - doClientSide();
87.86 + doClientSide(serverSocket.getLocalPort());
87.87 } catch (SocketException e) {
87.88 if (!e.getMessage().equalsIgnoreCase("Socket closed")) {
87.89 throw new Exception("Received a wrong exception message: " +
87.90 @@ -108,21 +77,14 @@
87.91 }
87.92
87.93 static void startServer() {
87.94 - Thread serverThread = new Thread() {
87.95 + (new Thread() {
87.96 public void run() {
87.97 try {
87.98 doServerSide();
87.99 } catch (Exception e) {
87.100 - /*
87.101 - * server thread just died.
87.102 - * Release the client, if not active already...
87.103 - */
87.104 - System.err.println("Server died...");
87.105 - serverReady = true;
87.106 - serverException = e;
87.107 + e.printStackTrace();
87.108 }
87.109 }
87.110 - };
87.111 - serverThread.start();
87.112 + }).start();
87.113 }
87.114 }
88.1 --- a/test/java/net/SocketInputStream/SocketTimeout.java Fri Aug 06 12:52:07 2010 -0700
88.2 +++ b/test/java/net/SocketInputStream/SocketTimeout.java Mon Aug 09 16:02:19 2010 -0700
88.3 @@ -31,26 +31,24 @@
88.4 import java.io.*;
88.5
88.6 public class SocketTimeout {
88.7 + static final int TIMEOUT = 1000;
88.8 +
88.9 public static void main(String args[]) throws Exception {
88.10 - InetAddress sin = null;
88.11 + InetAddress sin = InetAddress.getLocalHost();
88.12 Socket soc = null,soc1 = null;
88.13 InputStream is = null;
88.14 - OutputStream os = null;
88.15 ServerSocket srv = null;
88.16 int port = 0;
88.17 - int tout = 1000;
88.18
88.19 - sin = InetAddress.getLocalHost();
88.20 - srv = new ServerSocket(port);
88.21 + srv = new ServerSocket(0);
88.22 port = srv.getLocalPort();
88.23 soc = new Socket(sin, port);
88.24 soc1 = srv.accept();
88.25 - soc.setSoTimeout(tout);
88.26 - srv.setSoTimeout(tout);
88.27 + soc.setSoTimeout(TIMEOUT);
88.28 + srv.setSoTimeout(TIMEOUT);
88.29
88.30 try {
88.31 is = soc.getInputStream();
88.32 - os = soc1.getOutputStream();
88.33 is.read();
88.34 } catch(InterruptedIOException e) {
88.35 try {
88.36 @@ -59,6 +57,9 @@
88.37 } catch(NoClassDefFoundError e1) {
88.38 throw new Exception ("SocketTimeoutException: not found");
88.39 }
88.40 + } finally {
88.41 + soc.close();
88.42 + soc1.close();
88.43 }
88.44
88.45 // now check accept
88.46 @@ -72,12 +73,14 @@
88.47 } catch(NoClassDefFoundError e1) {
88.48 throw new Exception ("SocketTimeoutException: not found");
88.49 }
88.50 + } finally {
88.51 + srv.close();
88.52 }
88.53
88.54 // Now check DatagramSocket.receive()
88.55
88.56 DatagramSocket dg = new DatagramSocket ();
88.57 - dg.setSoTimeout (tout);
88.58 + dg.setSoTimeout (TIMEOUT);
88.59
88.60 try {
88.61 dg.receive (new DatagramPacket (new byte [64], 64));
88.62 @@ -88,11 +91,8 @@
88.63 } catch(NoClassDefFoundError e1) {
88.64 throw new Exception ("SocketTimeoutException: not found");
88.65 }
88.66 + } finally {
88.67 + dg.close();
88.68 }
88.69 -
88.70 - soc.close();
88.71 - soc1.close();
88.72 - srv.close();
88.73 - dg.close();
88.74 }
88.75 }
89.1 --- a/test/java/net/URL/GetContent.java Fri Aug 06 12:52:07 2010 -0700
89.2 +++ b/test/java/net/URL/GetContent.java Mon Aug 09 16:02:19 2010 -0700
89.3 @@ -53,11 +53,13 @@
89.4
89.5 // wait for client to read response - otherwise http
89.6 // client get error and re-establish connection
89.7 - Thread.currentThread().sleep(2000);
89.8 + Thread.sleep(2000);
89.9
89.10 s.close();
89.11 } catch (Exception e) {
89.12 e.printStackTrace();
89.13 + } finally {
89.14 + try { ss.close(); } catch (IOException unused) {}
89.15 }
89.16 }
89.17
89.18 @@ -81,8 +83,6 @@
89.19 error = false;
89.20 }
89.21
89.22 - ss.close();
89.23 -
89.24 if (error)
89.25 throw new RuntimeException("No IOException generated.");
89.26 }
90.1 --- a/test/java/net/URLClassLoader/ClassLoad.java Fri Aug 06 12:52:07 2010 -0700
90.2 +++ b/test/java/net/URLClassLoader/ClassLoad.java Mon Aug 09 16:02:19 2010 -0700
90.3 @@ -27,20 +27,45 @@
90.4 * @summary Test for FileNotFoundException when loading bogus class
90.5 */
90.6
90.7 -import java.net.*;
90.8 -import java.io.*;
90.9 +import java.io.InputStream;
90.10 +import java.io.IOException;
90.11 +import java.net.InetSocketAddress;
90.12 +import java.net.URL;
90.13 +import java.net.URLClassLoader;
90.14 +import com.sun.net.httpserver.HttpExchange;
90.15 +import com.sun.net.httpserver.HttpHandler;
90.16 +import com.sun.net.httpserver.HttpServer;
90.17
90.18 public class ClassLoad {
90.19 public static void main(String[] args) throws Exception {
90.20 boolean error = true;
90.21 +
90.22 + // Start a dummy server to return 404
90.23 + HttpServer server = HttpServer.create(new InetSocketAddress(0), 0);
90.24 + HttpHandler handler = new HttpHandler() {
90.25 + public void handle(HttpExchange t) throws IOException {
90.26 + InputStream is = t.getRequestBody();
90.27 + while (is.read() != -1);
90.28 + t.sendResponseHeaders (404, -1);
90.29 + t.close();
90.30 + }
90.31 + };
90.32 + server.createContext("/", handler);
90.33 + server.start();
90.34 +
90.35 + // Client request
90.36 try {
90.37 - URL url = new URL(args.length >= 1 ? args[0] : "http://jini.east/");
90.38 + URL url = new URL("http://localhost:" + server.getAddress().getPort());
90.39 String name = args.length >= 2 ? args[1] : "foo.bar.Baz";
90.40 ClassLoader loader = new URLClassLoader(new URL[] { url });
90.41 + System.out.println(url);
90.42 Class c = loader.loadClass(name);
90.43 System.out.println("Loaded class \"" + c.getName() + "\".");
90.44 } catch (ClassNotFoundException ex) {
90.45 + System.out.println(ex);
90.46 error = false;
90.47 + } finally {
90.48 + server.stop(0);
90.49 }
90.50 if (error)
90.51 throw new RuntimeException("No ClassNotFoundException generated");
91.1 --- a/test/java/net/URLConnection/DisconnectAfterEOF.java Fri Aug 06 12:52:07 2010 -0700
91.2 +++ b/test/java/net/URLConnection/DisconnectAfterEOF.java Mon Aug 09 16:02:19 2010 -0700
91.3 @@ -56,7 +56,6 @@
91.4 int cl = -1;
91.5 int remaining = -1;
91.6 StringBuffer sb = new StringBuffer();
91.7 - Random r = new Random();
91.8 boolean close = false;
91.9
91.10 boolean inBody = false;
91.11 @@ -239,8 +238,6 @@
91.12 }
91.13
91.14 public static void main(String args[]) throws Exception {
91.15 - Random r = new Random();
91.16 -
91.17 // start server
91.18 ServerSocket ss = new ServerSocket(0);
91.19 Server svr = new Server(ss);
91.20 @@ -273,7 +270,7 @@
91.21 URLConnection uc1 = doRequest(uri);
91.22 doResponse(uc1);
91.23
91.24 - Thread.currentThread().sleep(2000);
91.25 + Thread.sleep(2000);
91.26
91.27 URLConnection uc2 = doRequest(uri);
91.28
92.1 --- a/test/java/net/URLConnection/HandleContentTypeWithAttrs.java Fri Aug 06 12:52:07 2010 -0700
92.2 +++ b/test/java/net/URLConnection/HandleContentTypeWithAttrs.java Mon Aug 09 16:02:19 2010 -0700
92.3 @@ -111,9 +111,8 @@
92.4 } catch(Exception e) {
92.5 System.out.print("Server failure\n");
92.6 e.printStackTrace();
92.7 - try {
92.8 - serverSocket.close();
92.9 - } catch(IOException e2) {}
92.10 + } finally {
92.11 + try { serverSocket.close(); } catch(IOException unused) {}
92.12 }
92.13 } else {
92.14 try {
92.15 @@ -127,10 +126,9 @@
92.16 } catch(Exception e) {
92.17 // System.out.print("Service handler failure\n");
92.18 // e.printStackTrace();
92.19 + } finally {
92.20 + try { close(); } catch(IOException unused) {}
92.21 }
92.22 - try {
92.23 - close();
92.24 - } catch(IOException e2) {}
92.25 }
92.26 }
92.27
93.1 --- a/test/java/net/URLConnection/HttpContinueStackOverflow.java Fri Aug 06 12:52:07 2010 -0700
93.2 +++ b/test/java/net/URLConnection/HttpContinueStackOverflow.java Mon Aug 09 16:02:19 2010 -0700
93.3 @@ -30,7 +30,7 @@
93.4 */
93.5 import java.io.BufferedReader;
93.6 import java.io.InputStreamReader;
93.7 -import java.io.OutputStreamWriter;
93.8 +import java.io.IOException;
93.9 import java.io.PrintStream;
93.10 import java.net.ServerSocket;
93.11 import java.net.Socket;
93.12 @@ -41,61 +41,56 @@
93.13
93.14 static class Server implements Runnable {
93.15 int port;
93.16 + ServerSocket serverSock ;
93.17
93.18 - Server(int port) {
93.19 - this.port = port;
93.20 + Server() throws IOException {
93.21 + serverSock = new ServerSocket(0);
93.22 + }
93.23 +
93.24 + int getLocalPort() {
93.25 + return serverSock.getLocalPort();
93.26 }
93.27
93.28 public void run() {
93.29 + Socket sock = null;
93.30 try {
93.31 - /* bind to port and wait for connection */
93.32 - ServerSocket serverSock = new ServerSocket( port );
93.33 serverSock.setSoTimeout(10000);
93.34 - Socket sock = serverSock.accept();
93.35 + sock = serverSock.accept();
93.36
93.37 /* setup streams and read http request */
93.38 BufferedReader in = new BufferedReader(
93.39 new InputStreamReader(sock.getInputStream()));
93.40 PrintStream out = new PrintStream( sock.getOutputStream() );
93.41 - String request = in.readLine();
93.42 + in.readLine();
93.43
93.44 /* send continue followed by invalid response */
93.45 out.println("HTTP/1.1 100 Continue\r");
93.46 out.println("\r");
93.47 out.println("junk junk junk");
93.48 out.flush();
93.49 -
93.50 - sock.close();
93.51 } catch (Exception e) {
93.52 e.printStackTrace();
93.53 + } finally {
93.54 + try { serverSock.close(); } catch (IOException unused) {}
93.55 + try { sock.close(); } catch (IOException unused) {}
93.56 }
93.57 }
93.58 }
93.59
93.60 - HttpContinueStackOverflow(int port) throws Exception {
93.61 + HttpContinueStackOverflow() throws Exception {
93.62 /* create the server */
93.63 - Server s = new Server(port);
93.64 - Thread thr = new Thread(s);
93.65 - thr.start();
93.66 -
93.67 - /* wait for server to bind to port */
93.68 - try {
93.69 - Thread.currentThread().sleep(2000);
93.70 - } catch (Exception e) { }
93.71 + Server s = new Server();
93.72 + (new Thread(s)).start();
93.73
93.74 /* connect to server, connect to server and get response code */
93.75 - URL url = new URL("http", "localhost", port, "anything.html");
93.76 + URL url = new URL("http", "localhost", s.getLocalPort(), "anything.html");
93.77 HttpURLConnection conn = (HttpURLConnection)url.openConnection();
93.78 - int respCode = conn.getResponseCode();
93.79 + conn.getResponseCode();
93.80 System.out.println("TEST PASSED");
93.81 }
93.82
93.83 public static void main(String args[]) throws Exception {
93.84 - int port = 4090;
93.85 - if (args.length > 0) {
93.86 - port = Integer.parseInt(args[0]);
93.87 - }
93.88 System.out.println("Testing 100-Continue");
93.89 - new HttpContinueStackOverflow(port);
93.90 + new HttpContinueStackOverflow();
93.91 }
93.92 }
94.1 --- a/test/java/net/URLConnection/Redirect307Test.java Fri Aug 06 12:52:07 2010 -0700
94.2 +++ b/test/java/net/URLConnection/Redirect307Test.java Mon Aug 09 16:02:19 2010 -0700
94.3 @@ -37,11 +37,11 @@
94.4 OutputStream os;
94.5 int port;
94.6
94.7 - String reply1 = "HTTP/1.1 307 Temporary Redirect\r\n" +
94.8 + String reply1Part1 = "HTTP/1.1 307 Temporary Redirect\r\n" +
94.9 "Date: Mon, 15 Jan 2001 12:18:21 GMT\r\n" +
94.10 "Server: Apache/1.3.14 (Unix)\r\n" +
94.11 "Location: http://localhost:";
94.12 - String reply2 = "/redirected.html\r\n" +
94.13 + String reply1Part2 = "/redirected.html\r\n" +
94.14 "Connection: close\r\n" +
94.15 "Content-Type: text/html; charset=iso-8859-1\r\n\r\n" +
94.16 "<html>Hello</html>";
94.17 @@ -49,9 +49,10 @@
94.18 RedirServer (ServerSocket y) {
94.19 s = y;
94.20 port = s.getLocalPort();
94.21 + System.out.println("Server created listening on " + port);
94.22 }
94.23
94.24 - String reply3 = "HTTP/1.1 200 Ok\r\n" +
94.25 + String reply2 = "HTTP/1.1 200 Ok\r\n" +
94.26 "Date: Mon, 15 Jan 2001 12:18:21 GMT\r\n" +
94.27 "Server: Apache/1.3.14 (Unix)\r\n" +
94.28 "Connection: close\r\n" +
94.29 @@ -64,16 +65,24 @@
94.30 is = s1.getInputStream ();
94.31 os = s1.getOutputStream ();
94.32 is.read ();
94.33 - String reply = reply1 + port + reply2;
94.34 + String reply = reply1Part1 + port + reply1Part2;
94.35 os.write (reply.getBytes());
94.36 + os.close();
94.37 /* wait for redirected connection */
94.38 s.setSoTimeout (5000);
94.39 s1 = s.accept ();
94.40 + is = s1.getInputStream ();
94.41 os = s1.getOutputStream ();
94.42 - os.write (reply3.getBytes());
94.43 + is.read();
94.44 + os.write (reply2.getBytes());
94.45 + os.close();
94.46 }
94.47 catch (Exception e) {
94.48 /* Just need thread to terminate */
94.49 + System.out.println("Server: caught " + e);
94.50 + e.printStackTrace();
94.51 + } finally {
94.52 + try { s.close(); } catch (IOException unused) {}
94.53 }
94.54 }
94.55 };
94.56 @@ -84,10 +93,7 @@
94.57 public static final int DELAY = 10;
94.58
94.59 public static void main(String[] args) throws Exception {
94.60 - int nLoops = 1;
94.61 - int nSize = 10;
94.62 - int port, n =0;
94.63 - byte b[] = new byte[nSize];
94.64 + int port;
94.65 RedirServer server;
94.66 ServerSocket sock;
94.67
94.68 @@ -119,7 +125,8 @@
94.69 }
94.70 }
94.71 catch(IOException e) {
94.72 - throw new RuntimeException ("Exception caught");
94.73 + e.printStackTrace();
94.74 + throw new RuntimeException ("Exception caught + " + e);
94.75 }
94.76 }
94.77 }
95.1 --- a/test/java/net/URLConnection/RedirectLimit.java Fri Aug 06 12:52:07 2010 -0700
95.2 +++ b/test/java/net/URLConnection/RedirectLimit.java Mon Aug 09 16:02:19 2010 -0700
95.3 @@ -76,15 +76,19 @@
95.4 is.read ();
95.5 String reply = reply1 + port + "/redirect" + i + reply2;
95.6 os.write (reply.getBytes());
95.7 + os.close();
95.8 }
95.9 s1 = s.accept ();
95.10 is = s1.getInputStream ();
95.11 os = s1.getOutputStream ();
95.12 is.read ();
95.13 os.write (reply3.getBytes());
95.14 + os.close();
95.15 }
95.16 catch (Exception e) {
95.17 /* Just need thread to terminate */
95.18 + } finally {
95.19 + try { s.close(); } catch (IOException unused) {}
95.20 }
95.21 }
95.22 };
96.1 --- a/test/java/net/URLConnection/ResendPostBody.java Fri Aug 06 12:52:07 2010 -0700
96.2 +++ b/test/java/net/URLConnection/ResendPostBody.java Mon Aug 09 16:02:19 2010 -0700
96.3 @@ -109,8 +109,11 @@
96.4 while (!finished()) {
96.5 Thread.sleep (1000);
96.6 }
96.7 + out.close();
96.8 } catch (Exception e) {
96.9 System.err.println ("Server Exception: " + e);
96.10 + } finally {
96.11 + try { server.close(); } catch (IOException unused) {}
96.12 }
96.13 }
96.14 }
96.15 @@ -134,7 +137,7 @@
96.16
96.17 public void execute () throws Exception {
96.18
96.19 - byte b[] = "X=ABCDEFGHZZZ".getBytes();
96.20 + byte b[] = "X=ABCDEFGHZZZ".getBytes();
96.21
96.22 ss = new ServerSocket (0);
96.23 server = new Server (ss);
96.24 @@ -163,8 +166,9 @@
96.25 /* Read the response */
96.26
96.27 int resp = conURL.getResponseCode ();
96.28 + server.setFinished (true);
96.29 +
96.30 if (resp != 200)
96.31 throw new RuntimeException ("Response code was not 200: " + resp);
96.32 - server.setFinished (true);
96.33 }
96.34 }
97.1 --- a/test/java/net/URLConnection/SetIfModifiedSince.java Fri Aug 06 12:52:07 2010 -0700
97.2 +++ b/test/java/net/URLConnection/SetIfModifiedSince.java Mon Aug 09 16:02:19 2010 -0700
97.3 @@ -23,7 +23,7 @@
97.4
97.5 /* @test
97.6 * @bug 4397096
97.7 - * @run main SetIfModifiedSince
97.8 + * @run main/othervm SetIfModifiedSince
97.9 * @summary setIfModifiedSince() of HttpURLConnection sets invalid date of default locale
97.10 */
97.11
98.1 --- a/test/java/net/URLConnection/TimeoutTest.java Fri Aug 06 12:52:07 2010 -0700
98.2 +++ b/test/java/net/URLConnection/TimeoutTest.java Mon Aug 09 16:02:19 2010 -0700
98.3 @@ -43,8 +43,9 @@
98.4 try {
98.5 Socket s = server.accept ();
98.6 while (!finished ()) {
98.7 - Thread.sleep (2000);
98.8 + Thread.sleep (1000);
98.9 }
98.10 + s.close();
98.11 } catch (Exception e) {
98.12 }
98.13 }
98.14 @@ -70,9 +71,12 @@
98.15 URL url = new URL ("http://127.0.0.1:"+ss.getLocalPort());
98.16 URLConnection urlc = url.openConnection ();
98.17 InputStream is = urlc.getInputStream ();
98.18 + throw new RuntimeException("Should have received timeout");
98.19 } catch (SocketTimeoutException e) {
98.20 - s.done ();
98.21 return;
98.22 + } finally {
98.23 + s.done();
98.24 + ss.close();
98.25 }
98.26 }
98.27 }
99.1 --- a/test/java/net/URLConnection/URLConnectionHeaders.java Fri Aug 06 12:52:07 2010 -0700
99.2 +++ b/test/java/net/URLConnection/URLConnectionHeaders.java Mon Aug 09 16:02:19 2010 -0700
99.3 @@ -70,8 +70,10 @@
99.4 w.newLine();
99.5 w.flush();
99.6 s.close ();
99.7 - srv.close (); // or else the HTTPURLConnection will retry
99.8 - } catch (IOException e) { e.printStackTrace();}
99.9 + } catch (IOException e) { e.printStackTrace();
99.10 + } finally {
99.11 + try { srv.close(); } catch (IOException unused) {}
99.12 + }
99.13 }
99.14 }
99.15
100.1 --- a/test/java/net/URLConnection/ZeroContentLength.java Fri Aug 06 12:52:07 2010 -0700
100.2 +++ b/test/java/net/URLConnection/ZeroContentLength.java Mon Aug 09 16:02:19 2010 -0700
100.3 @@ -58,6 +58,14 @@
100.4 contentLength = cl;
100.5 }
100.6
100.7 + static synchronized String getResponse() {
100.8 + return response;
100.9 + }
100.10 +
100.11 + static synchronized int getContentLength() {
100.12 + return contentLength;
100.13 + }
100.14 +
100.15 /*
100.16 * Worker thread to service single connection - can service
100.17 * multiple http requests on same connection.
100.18 @@ -71,25 +79,44 @@
100.19 this.id = id;
100.20 }
100.21
100.22 + final int CR = '\r';
100.23 + final int LF = '\n';
100.24 +
100.25 public void run() {
100.26 try {
100.27
100.28 s.setSoTimeout(2000);
100.29 - int max = 100;
100.30 + int max = 20; // there should only be 20 connections
100.31 + InputStream in = new BufferedInputStream(s.getInputStream());
100.32
100.33 for (;;) {
100.34 -
100.35 - // read entire request from client
100.36 - byte b[] = new byte[100];
100.37 - InputStream in = s.getInputStream();
100.38 - int n, total=0;
100.39 + // read entire request from client, until CR LF CR LF
100.40 + int c, total=0;
100.41
100.42 try {
100.43 - do {
100.44 - n = in.read(b);
100.45 - if (n > 0) total += n;
100.46 - } while (n > 0);
100.47 - } catch (SocketTimeoutException e) { }
100.48 + while ((c = in.read()) > 0) {
100.49 + total++;
100.50 + if (c == CR) {
100.51 + if ((c = in.read()) > 0) {
100.52 + total++;
100.53 + if (c == LF) {
100.54 + if ((c = in.read()) > 0) {
100.55 + total++;
100.56 + if (c == CR) {
100.57 + if ((c = in.read()) > 0) {
100.58 + total++;
100.59 + if (c == LF) {
100.60 + break;
100.61 + }
100.62 + }
100.63 + }
100.64 + }
100.65 + }
100.66 + }
100.67 + }
100.68 +
100.69 + }
100.70 + } catch (SocketTimeoutException e) {}
100.71
100.72 debug("worker " + id +
100.73 ": Read request from client " +
100.74 @@ -105,19 +132,20 @@
100.75 new BufferedOutputStream(
100.76 s.getOutputStream() ));
100.77
100.78 - out.print("HTTP/1.1 " + response + "\r\n");
100.79 - if (contentLength >= 0) {
100.80 - out.print("Content-Length: " + contentLength +
100.81 + out.print("HTTP/1.1 " + getResponse() + "\r\n");
100.82 + int clen = getContentLength();
100.83 + if (clen >= 0) {
100.84 + out.print("Content-Length: " + clen +
100.85 "\r\n");
100.86 }
100.87 out.print("\r\n");
100.88 - for (int i=0; i<contentLength; i++) {
100.89 + for (int i=0; i<clen; i++) {
100.90 out.write( (byte)'.' );
100.91 }
100.92 out.flush();
100.93
100.94 debug("worked " + id +
100.95 - ": Sent response to client, length: " + contentLength);
100.96 + ": Sent response to client, length: " + clen);
100.97
100.98 if (--max == 0) {
100.99 s.close();
101.1 --- a/test/java/net/ipv6tests/B6521014.java Fri Aug 06 12:52:07 2010 -0700
101.2 +++ b/test/java/net/ipv6tests/B6521014.java Mon Aug 09 16:02:19 2010 -0700
101.3 @@ -58,6 +58,8 @@
101.4 Enumeration e = NetworkInterface.getNetworkInterfaces();
101.5 while (e.hasMoreElements()) {
101.6 NetworkInterface ifc = (NetworkInterface) e.nextElement();
101.7 + if (!ifc.isUp())
101.8 + continue;
101.9 Enumeration addrs = ifc.getInetAddresses();
101.10 while (addrs.hasMoreElements()) {
101.11 InetAddress a = (InetAddress)addrs.nextElement();
102.1 --- a/test/java/net/ipv6tests/TcpTest.java Fri Aug 06 12:52:07 2010 -0700
102.2 +++ b/test/java/net/ipv6tests/TcpTest.java Mon Aug 09 16:02:19 2010 -0700
102.3 @@ -38,7 +38,6 @@
102.4 static InetAddress ia4any;
102.5 static InetAddress ia6any;
102.6 static Inet6Address ia6addr;
102.7 - static InetAddress ia6bad; /* a global 6to4 IPv6 address, which cant be connected to */
102.8 static Inet4Address ia4addr;
102.9
102.10 static {
102.11 @@ -47,14 +46,6 @@
102.12 try {
102.13 ia4any = InetAddress.getByName ("0.0.0.0");
102.14 ia6any = InetAddress.getByName ("::0");
102.15 - if (ia6addr != null) {
102.16 - int scope = ia6addr.getScopeId();
102.17 - if (scope != 0) {
102.18 - ia6bad = InetAddress.getByName ("fe80::1:2:3:4:5:6%"+scope);
102.19 - }
102.20 - } else {
102.21 - ia6bad = InetAddress.getByName ("fe80::1:2:3:4:5:6");
102.22 - }
102.23 } catch (Exception e) {
102.24 e.printStackTrace();
102.25 }
102.26 @@ -69,7 +60,6 @@
102.27 dprintln ("Local Addresses");
102.28 dprintln (ia4addr.toString());
102.29 dprintln (ia6addr.toString());
102.30 - dprintln ("Bad address: " + ia6bad);
102.31 test1 (0);
102.32 test1 (5100);
102.33 test2();
102.34 @@ -224,19 +214,6 @@
102.35 c1.close (); c2.close();
102.36 s1.close (); s2.close();
102.37
102.38 - /* check if connect() timesout when connecting to unknown dest. */
102.39 -
102.40 - c1 = new Socket();
102.41 - t1 = System.currentTimeMillis();
102.42 - InetSocketAddress ad1 = new InetSocketAddress (ia6bad, 2500);
102.43 - try {
102.44 - c1.connect (ad1, 5000);
102.45 - throw new RuntimeException ("timeout exception was expected");
102.46 - } catch (SocketTimeoutException e) {
102.47 - t1 = System.currentTimeMillis() - t1;
102.48 - checkTime (t1, 5000);
102.49 - } catch (NoRouteToHostException e1) {
102.50 - }
102.51 System.out.println ("Test3: OK");
102.52 }
102.53
103.1 --- a/test/java/net/ipv6tests/Tests.java Fri Aug 06 12:52:07 2010 -0700
103.2 +++ b/test/java/net/ipv6tests/Tests.java Mon Aug 09 16:02:19 2010 -0700
103.3 @@ -134,11 +134,11 @@
103.4 }
103.5 }
103.6
103.7 - /* check the time got is within 20% of the time expected */
103.8 + /* check the time got is within 50% of the time expected */
103.9 public static void checkTime (long got, long expected) {
103.10 dprintln ("checkTime: got " + got + " expected " + expected);
103.11 - long upper = expected + (expected / 5);
103.12 - long lower = expected - (expected / 5);
103.13 + long upper = expected + (expected / 2);
103.14 + long lower = expected - (expected / 2);
103.15 if (got > upper || got < lower) {
103.16 throw new RuntimeException ("checkTime failed: got " + got + " expected " + expected);
103.17 }
104.1 --- a/test/java/nio/MappedByteBuffer/Basic.java Fri Aug 06 12:52:07 2010 -0700
104.2 +++ b/test/java/nio/MappedByteBuffer/Basic.java Mon Aug 09 16:02:19 2010 -0700
104.3 @@ -22,7 +22,7 @@
104.4 */
104.5
104.6 /* @test
104.7 - * @bug 4462336
104.8 + * @bug 4462336 6799037
104.9 * @summary Simple MappedByteBuffer tests
104.10 * @run main/othervm Basic
104.11 */
104.12 @@ -52,6 +52,12 @@
104.13 mbb.force();
104.14 if (!mbb.isReadOnly())
104.15 throw new RuntimeException("Incorrect isReadOnly");
104.16 +
104.17 + // repeat with unaligned position in file
104.18 + mbb = fc.map(FileChannel.MapMode.READ_ONLY, 1, 10);
104.19 + mbb.load();
104.20 + mbb.isLoaded();
104.21 + mbb.force();
104.22 fc.close();
104.23 fis.close();
104.24
105.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
105.2 +++ b/test/java/nio/MappedByteBuffer/Truncate.java Mon Aug 09 16:02:19 2010 -0700
105.3 @@ -0,0 +1,94 @@
105.4 +/*
105.5 + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
105.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
105.7 + *
105.8 + * This code is free software; you can redistribute it and/or modify it
105.9 + * under the terms of the GNU General Public License version 2 only, as
105.10 + * published by the Free Software Foundation.
105.11 + *
105.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
105.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
105.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
105.15 + * version 2 for more details (a copy is included in the LICENSE file that
105.16 + * accompanied this code).
105.17 + *
105.18 + * You should have received a copy of the GNU General Public License version
105.19 + * 2 along with this work; if not, write to the Free Software Foundation,
105.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
105.21 + *
105.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
105.23 + * or visit www.oracle.com if you need additional information or have any
105.24 + * questions.
105.25 + */
105.26 +
105.27 +/* @test
105.28 + * @bug 6934977
105.29 + * @summary Test MappedByteBuffer operations after mapped bye buffer becomes
105.30 + * inaccessible
105.31 + * @run main/othervm Truncate
105.32 + */
105.33 +
105.34 +import java.io.*;
105.35 +import java.nio.*;
105.36 +import java.nio.channels.*;
105.37 +import java.util.concurrent.Callable;
105.38 +
105.39 +public class Truncate {
105.40 +
105.41 + static final long INITIAL_FILE_SIZE = 32000L;
105.42 + static final long TRUNCATED_FILE_SIZE = 512L;
105.43 +
105.44 + public static void main(String[] args) throws Exception {
105.45 + File blah = File.createTempFile("blah", null);
105.46 + blah.deleteOnExit();
105.47 +
105.48 + final FileChannel fc = new RandomAccessFile(blah, "rw").getChannel();
105.49 + fc.position(INITIAL_FILE_SIZE).write(ByteBuffer.wrap("THE END".getBytes()));
105.50 + final MappedByteBuffer mbb =
105.51 + fc.map(FileChannel.MapMode.READ_WRITE, 0, fc.size());
105.52 + boolean truncated;
105.53 + try {
105.54 + fc.truncate(TRUNCATED_FILE_SIZE);
105.55 + truncated = true;
105.56 + } catch (IOException ioe) {
105.57 + // probably on Windows where a file cannot be truncated when
105.58 + // there is a file mapping.
105.59 + truncated = false;
105.60 + }
105.61 + if (truncated) {
105.62 + // Test 1: access region that is no longer accessible
105.63 + execute(new Callable<Void>() {
105.64 + public Void call() {
105.65 + mbb.get((int)TRUNCATED_FILE_SIZE + 1);
105.66 + mbb.put((int)TRUNCATED_FILE_SIZE + 2, (byte)123);
105.67 + return null;
105.68 + }
105.69 + });
105.70 + // Test 2: load buffer into memory
105.71 + execute(new Callable<Void>() {
105.72 + public Void call() throws IOException {
105.73 + mbb.load();
105.74 + return null;
105.75 + }
105.76 + });
105.77 + }
105.78 + fc.close();
105.79 + }
105.80 +
105.81 + // Runs the given task in its own thread. If operating correcting the
105.82 + // the thread will terminate with an InternalError as the mapped buffer
105.83 + // is inaccessible.
105.84 + static void execute(final Callable<?> c) {
105.85 + Runnable r = new Runnable() {
105.86 + public void run() {
105.87 + try {
105.88 + Object ignore = c.call();
105.89 + } catch (Exception ignore) {
105.90 + }
105.91 + }
105.92 + };
105.93 + Thread t = new Thread(r);
105.94 + t.start();
105.95 + try { t.join(); } catch (InterruptedException ignore) { }
105.96 + }
105.97 +}
106.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
106.2 +++ b/test/java/nio/channels/SocketChannel/OutOfBand.java Mon Aug 09 16:02:19 2010 -0700
106.3 @@ -0,0 +1,191 @@
106.4 +/*
106.5 + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
106.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
106.7 + *
106.8 + * This code is free software; you can redistribute it and/or modify it
106.9 + * under the terms of the GNU General Public License version 2 only, as
106.10 + * published by the Free Software Foundation.
106.11 + *
106.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
106.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
106.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
106.15 + * version 2 for more details (a copy is included in the LICENSE file that
106.16 + * accompanied this code).
106.17 + *
106.18 + * You should have received a copy of the GNU General Public License version
106.19 + * 2 along with this work; if not, write to the Free Software Foundation,
106.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
106.21 + *
106.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
106.23 + * or visit www.oracle.com if you need additional information or have any
106.24 + * questions.
106.25 + */
106.26 +
106.27 +/* @test
106.28 + * @summary Test socket adapter sendUrgentData method
106.29 + * @bug 6963907
106.30 + */
106.31 +
106.32 +import java.net.*;
106.33 +import java.nio.ByteBuffer;
106.34 +import java.nio.channels.*;
106.35 +import java.io.IOException;
106.36 +import java.util.Random;
106.37 +
106.38 +public class OutOfBand {
106.39 +
106.40 + private static final Random rand = new Random();
106.41 +
106.42 + public static void main(String[] args) throws Exception {
106.43 + ServerSocketChannel ssc = null;
106.44 + SocketChannel sc1 = null;
106.45 + SocketChannel sc2 = null;
106.46 +
106.47 + try {
106.48 +
106.49 + // establish loopback connection
106.50 + ssc = ServerSocketChannel.open().bind(new InetSocketAddress(0));
106.51 + InetAddress lh = InetAddress.getLocalHost();
106.52 + SocketAddress remote =
106.53 + new InetSocketAddress(lh, ssc.socket().getLocalPort());
106.54 + sc1 = SocketChannel.open(remote);
106.55 + sc2 = ssc.accept();
106.56 +
106.57 + // enable SO_OOBLINE on server side
106.58 + sc2.socket().setOOBInline(true);
106.59 +
106.60 + // run tests
106.61 + test1(sc1, sc2);
106.62 + test2(sc1, sc2);
106.63 + test3(sc1, sc2);
106.64 + test4(sc1);
106.65 +
106.66 + } finally {
106.67 + if (sc1 != null) sc1.close();
106.68 + if (sc2 != null) sc2.close();
106.69 + if (ssc != null) ssc.close();
106.70 + }
106.71 + }
106.72 +
106.73 + /**
106.74 + * Basic test to check that OOB/TCP urgent byte is received.
106.75 + */
106.76 + static void test1(SocketChannel client, SocketChannel server)
106.77 + throws Exception
106.78 + {
106.79 + assert server.socket().getOOBInline();
106.80 + ByteBuffer bb = ByteBuffer.allocate(100);
106.81 + for (int i=0; i<1000; i++) {
106.82 + int b1 = -127 + rand.nextInt(384);
106.83 + client.socket().sendUrgentData(b1);
106.84 +
106.85 + bb.clear();
106.86 + if (server.read(bb) != 1)
106.87 + throw new RuntimeException("One byte expected");
106.88 + bb.flip();
106.89 + byte b2 = bb.get();
106.90 + if ((byte)b1 != b2)
106.91 + throw new RuntimeException("Unexpected byte");
106.92 + }
106.93 + }
106.94 +
106.95 + /**
106.96 + * Basic test to check that OOB/TCP urgent byte is received, maybe with
106.97 + * OOB mark changing.
106.98 + */
106.99 + static void test2(final SocketChannel client, SocketChannel server)
106.100 + throws Exception
106.101 + {
106.102 + assert server.socket().getOOBInline();
106.103 + Runnable sender = new Runnable() {
106.104 + public void run() {
106.105 + try {
106.106 + for (int i=0; i<256; i++)
106.107 + client.socket().sendUrgentData(i);
106.108 + } catch (IOException ioe) {
106.109 + ioe.printStackTrace();
106.110 + }
106.111 + }
106.112 + };
106.113 + Thread thr = new Thread(sender);
106.114 + thr.start();
106.115 +
106.116 + ByteBuffer bb = ByteBuffer.allocate(256);
106.117 + while (bb.hasRemaining()) {
106.118 + if (server.read(bb) < 0)
106.119 + throw new RuntimeException("Unexpected EOF");
106.120 + }
106.121 + bb.flip();
106.122 + byte expect = 0;
106.123 + while (bb.hasRemaining()) {
106.124 + if (bb.get() != expect)
106.125 + throw new RuntimeException("Unexpected byte");
106.126 + expect++;
106.127 + }
106.128 +
106.129 + thr.join();
106.130 + }
106.131 +
106.132 + /**
106.133 + * Test that is close to some real world examples where an urgent byte is
106.134 + * used to "cancel" a long running query or transaction on the server.
106.135 + */
106.136 + static void test3(SocketChannel client, final SocketChannel server)
106.137 + throws Exception
106.138 + {
106.139 + final int STOP = rand.nextInt(256);
106.140 +
106.141 + assert server.socket().getOOBInline();
106.142 + Runnable reader = new Runnable() {
106.143 + public void run() {
106.144 + ByteBuffer bb = ByteBuffer.allocate(100);
106.145 + try {
106.146 + int n = server.read(bb);
106.147 + if (n != 1) {
106.148 + String msg = (n < 0) ? "Unexpected EOF" :
106.149 + "One byte expected";
106.150 + throw new RuntimeException(msg);
106.151 + }
106.152 + bb.flip();
106.153 + if (bb.get() != (byte)STOP)
106.154 + throw new RuntimeException("Unexpected byte");
106.155 + bb.flip();
106.156 + server.write(bb);
106.157 + } catch (IOException ioe) {
106.158 + ioe.printStackTrace();
106.159 + }
106.160 +
106.161 + }
106.162 + };
106.163 +
106.164 + Thread thr = new Thread(reader);
106.165 + thr.start();
106.166 +
106.167 + // "stop" server
106.168 + client.socket().sendUrgentData(STOP);
106.169 +
106.170 + // wait for server reply
106.171 + ByteBuffer bb = ByteBuffer.allocate(100);
106.172 + int n = client.read(bb);
106.173 + if (n != 1)
106.174 + throw new RuntimeException("Unexpected number of bytes");
106.175 + bb.flip();
106.176 + if (bb.get() != (byte)STOP)
106.177 + throw new RuntimeException("Unexpected reply");
106.178 +
106.179 + thr.join();
106.180 + }
106.181 +
106.182 + static void test4(SocketChannel sc) throws IOException {
106.183 + boolean blocking = sc.isBlocking();
106.184 + sc.configureBlocking(false);
106.185 + try {
106.186 + sc.socket().sendUrgentData(0);
106.187 + throw new RuntimeException("IllegalBlockingModeException expected");
106.188 + } catch (IllegalBlockingModeException x) {
106.189 + // expected
106.190 + } finally {
106.191 + sc.configureBlocking(blocking);
106.192 + }
106.193 + }
106.194 +}
107.1 --- a/test/java/util/logging/AnonLoggerWeakRefLeak.java Fri Aug 06 12:52:07 2010 -0700
107.2 +++ b/test/java/util/logging/AnonLoggerWeakRefLeak.java Mon Aug 09 16:02:19 2010 -0700
107.3 @@ -23,24 +23,32 @@
107.4
107.5 import java.util.logging.*;
107.6
107.7 -public class AnonLoggerWeakRefLeak {
107.8 - public static int DEFAULT_LOOP_TIME = 60; // time is in seconds
107.9 +public class AnonLoggerWeakRefLeak extends SimpleApplication {
107.10 + // The test driver script will allow this program to run until we
107.11 + // reach DEFAULT_LOOP_TIME or a decrease in instance counts is
107.12 + // observed. For this particular WeakReference leak, the count
107.13 + // was always observed to be increasing so if we get a decreasing
107.14 + // count, then the leak is fixed in the bits being tested.
107.15 + // Two minutes has been enough time to observe a decrease in
107.16 + // fixed bits on overloaded systems, but the test will likely
107.17 + // finish more quickly.
107.18 + public static int DEFAULT_LOOP_TIME = 120; // time is in seconds
107.19
107.20 - public static void main(String[] args) {
107.21 + // execute the AnonLoggerWeakRefLeak app work
107.22 + public void doMyAppWork(String[] args) throws Exception {
107.23 int loop_time = 0;
107.24 int max_loop_time = DEFAULT_LOOP_TIME;
107.25
107.26 - if (args.length == 0) {
107.27 + // args[0] is the port-file
107.28 + if (args.length < 2) {
107.29 System.out.println("INFO: using default time of "
107.30 + max_loop_time + " seconds.");
107.31 } else {
107.32 try {
107.33 - max_loop_time = Integer.parseInt(args[0]);
107.34 + max_loop_time = Integer.parseInt(args[1]);
107.35 } catch (NumberFormatException nfe) {
107.36 - System.err.println("Error: '" + args[0]
107.37 + throw new RuntimeException("Error: '" + args[1]
107.38 + "': is not a valid seconds value.");
107.39 - System.err.println("Usage: AnonLoggerWeakRefLeak [seconds]");
107.40 - System.exit(1);
107.41 }
107.42 }
107.43
107.44 @@ -73,4 +81,12 @@
107.45
107.46 System.out.println("INFO: final loop count = " + count);
107.47 }
107.48 +
107.49 + public static void main(String[] args) throws Exception {
107.50 + AnonLoggerWeakRefLeak myApp = new AnonLoggerWeakRefLeak();
107.51 +
107.52 + SimpleApplication.setMyApp(myApp);
107.53 +
107.54 + SimpleApplication.main(args);
107.55 + }
107.56 }
108.1 --- a/test/java/util/logging/AnonLoggerWeakRefLeak.sh Fri Aug 06 12:52:07 2010 -0700
108.2 +++ b/test/java/util/logging/AnonLoggerWeakRefLeak.sh Mon Aug 09 16:02:19 2010 -0700
108.3 @@ -1,3 +1,5 @@
108.4 +#!/bin/sh
108.5 +
108.6 #
108.7 # Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
108.8 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
108.9 @@ -23,76 +25,24 @@
108.10
108.11 # @test
108.12 # @bug 6942989
108.13 -# @ignore until 6964018 is fixed
108.14 # @summary Check for WeakReference leak in anonymous Logger objects
108.15 # @author Daniel D. Daugherty
108.16 #
108.17 -# @run build AnonLoggerWeakRefLeak
108.18 -# @run shell/timeout=180 AnonLoggerWeakRefLeak.sh
108.19 +# @library ../../../sun/tools/common
108.20 +# @build SimpleApplication ShutdownSimpleApplication
108.21 +# @build AnonLoggerWeakRefLeak
108.22 +# @run shell/timeout=240 AnonLoggerWeakRefLeak.sh
108.23
108.24 -# The timeout is: 2 minutes for infrastructure and 1 minute for the test
108.25 +# The timeout is: 2 minutes for infrastructure and 2 minutes for the test
108.26 #
108.27
108.28 -if [ "${TESTJAVA}" = "" ]
108.29 -then
108.30 - echo "TESTJAVA not set. Test cannot execute. Failed."
108.31 - exit 1
108.32 -fi
108.33 +. ${TESTSRC}/../../../sun/tools/common/CommonSetup.sh
108.34 +. ${TESTSRC}/../../../sun/tools/common/ApplicationSetup.sh
108.35
108.36 -if [ "${TESTSRC}" = "" ]
108.37 -then
108.38 - echo "TESTSRC not set. Test cannot execute. Failed."
108.39 - exit 1
108.40 -fi
108.41 -
108.42 -if [ "${TESTCLASSES}" = "" ]
108.43 -then
108.44 - echo "TESTCLASSES not set. Test cannot execute. Failed."
108.45 - exit 1
108.46 -fi
108.47 -
108.48 -JAVA="${TESTJAVA}"/bin/java
108.49 -JMAP="${TESTJAVA}"/bin/jmap
108.50 -JPS="${TESTJAVA}"/bin/jps
108.51 -
108.52 -set -eu
108.53
108.54 TEST_NAME="AnonLoggerWeakRefLeak"
108.55 TARGET_CLASS="java\.lang\.ref\.WeakReference"
108.56
108.57 -is_cygwin=false
108.58 -is_mks=false
108.59 -is_windows=false
108.60 -
108.61 -case `uname -s` in
108.62 -CYGWIN*)
108.63 - is_cygwin=true
108.64 - is_windows=true
108.65 - ;;
108.66 -Windows_*)
108.67 - is_mks=true
108.68 - is_windows=true
108.69 - ;;
108.70 -*)
108.71 - ;;
108.72 -esac
108.73 -
108.74 -
108.75 -# wrapper for grep
108.76 -#
108.77 -grep_cmd() {
108.78 - set +e
108.79 - if $is_windows; then
108.80 - # need dos2unix to get rid of CTRL-M chars from java output
108.81 - dos2unix | grep "$@"
108.82 - status="$?"
108.83 - else
108.84 - grep "$@"
108.85 - status="$?"
108.86 - fi
108.87 - set -e
108.88 -}
108.89 -
108.90
108.91 # MAIN begins here
108.92 #
108.93 @@ -105,62 +55,64 @@
108.94 # see if this version of jmap supports the '-histo:live' option
108.95 jmap_option="-histo:live"
108.96 set +e
108.97 -"${JMAP}" "$jmap_option" 0 > "$TEST_NAME.jmap" 2>&1
108.98 -grep '^Usage: ' "$TEST_NAME.jmap" > /dev/null 2>&1
108.99 +"${JMAP}" 2>&1 | grep ':live' > /dev/null 2>&1
108.100 status="$?"
108.101 set -e
108.102 -if [ "$status" = 0 ]; then
108.103 - echo "INFO: switching jmap option from '$jmap_option'\c"
108.104 - jmap_option="-histo"
108.105 - echo " to '$jmap_option'."
108.106 +if [ "$status" != 0 ]; then
108.107 + # usage message doesn't show ':live' option
108.108 +
108.109 + if $isWindows; then
108.110 + # If SA isn't present, then jmap gives a different usage message
108.111 + # that doesn't show the ':live' option. However, that's a bug that
108.112 + # is covered by 6971851 so we try using the option just to be sure.
108.113 + # For some reason, this problem has only been seen on OpenJDK6 on
108.114 + # Windows. Not sure why.
108.115 + set +e
108.116 + # Note: Don't copy this code to try probing process 0 on Linux; it
108.117 + # will kill the process group in strange ways.
108.118 + "${JMAP}" "$jmap_option" 0 2>&1 | grep 'Usage' > /dev/null 2>&1
108.119 + status="$?"
108.120 + set -e
108.121 + if [ "$status" = 0 ]; then
108.122 + # Usage message generated so flag the problem.
108.123 + status=1
108.124 + else
108.125 + # No usage message so clear the flag.
108.126 + status=0
108.127 + fi
108.128 + fi
108.129 +
108.130 + if [ "$status" != 0 ]; then
108.131 + echo "ERROR: 'jmap $jmap_option' is not supported so this test"
108.132 + echo "ERROR: cannot work reliably. Aborting!"
108.133 + exit 2
108.134 + fi
108.135 fi
108.136
108.137 -"${JAVA}" ${TESTVMOPTS} -classpath "${TESTCLASSES}" \
108.138 - "$TEST_NAME" $seconds > "$TEST_NAME.log" 2>&1 &
108.139 -test_pid="$!"
108.140 -echo "INFO: starting $TEST_NAME as pid = $test_pid"
108.141 +# Start application and use TEST_NAME.port for coordination
108.142 +startApplication "$TEST_NAME" "$TEST_NAME.port" $seconds
108.143
108.144 -# wait for test program to get going
108.145 -count=0
108.146 -while [ "$count" -lt 30 ]; do
108.147 - sleep 2
108.148 - grep_cmd '^INFO: call count = 0$' < "$TEST_NAME.log" > /dev/null 2>&1
108.149 - if [ "$status" = 0 ]; then
108.150 - break
108.151 - fi
108.152 - count=`expr $count + 1`
108.153 -done
108.154 -
108.155 -if [ "$count" -ge 30 ]; then
108.156 - echo "ERROR: $TEST_NAME failed to get going." >&2
108.157 - echo "INFO: killing $test_pid"
108.158 - kill "$test_pid"
108.159 - exit 1
108.160 -elif [ "$count" -gt 1 ]; then
108.161 - echo "INFO: $TEST_NAME took $count loops to start."
108.162 -fi
108.163 -
108.164 -if $is_cygwin; then
108.165 - # We need the Windows pid for jmap and not the Cygwin pid.
108.166 - # Note: '\t' works on Cygwin, but doesn't seem to work on Solaris.
108.167 - jmap_pid=`"${JPS}"| grep_cmd "[ \t]$TEST_NAME$" | sed 's/[ \t].*//'`
108.168 - if [ -z "$jmap_pid" ]; then
108.169 - echo "FAIL: jps could not map Cygwin pid to Windows pid." >&2
108.170 - echo "INFO: killing $test_pid"
108.171 - kill "$test_pid"
108.172 - exit 2
108.173 - fi
108.174 - echo "INFO: pid = $test_pid maps to Windows pid = $jmap_pid"
108.175 -else
108.176 - jmap_pid="$test_pid"
108.177 -fi
108.178 +finished_early=false
108.179
108.180 decreasing_cnt=0
108.181 increasing_cnt=0
108.182 loop_cnt=0
108.183 prev_instance_cnt=0
108.184
108.185 +MAX_JMAP_TRY_CNT=10
108.186 +jmap_retry_cnt=0
108.187 +loop_cnt_on_retry=0
108.188 +
108.189 while true; do
108.190 + # see if the target process has finished its run and bail if it has
108.191 + set +e
108.192 + grep "^INFO: final loop count = " "$appOutput" > /dev/null 2>&1
108.193 + status="$?"
108.194 + set -e
108.195 + if [ "$status" = 0 ]; then
108.196 + break
108.197 + fi
108.198 +
108.199 # Output format for 'jmap -histo' in JDK1.5.0:
108.200 #
108.201 # <#bytes> <#instances> <class_name>
108.202 @@ -170,38 +122,70 @@
108.203 # <num>: <#instances> <#bytes> <class_name>
108.204 #
108.205 set +e
108.206 - "${JMAP}" "$jmap_option" "$jmap_pid" > "$TEST_NAME.jmap" 2>&1
108.207 + "${JMAP}" "$jmap_option" "$appJavaPid" > "$TEST_NAME.jmap" 2>&1
108.208 status="$?"
108.209 set -e
108.210
108.211 if [ "$status" != 0 ]; then
108.212 echo "INFO: jmap exited with exit code = $status"
108.213 - if [ "$loop_cnt" = 0 ]; then
108.214 - echo "INFO: on the first iteration so no samples were taken."
108.215 - echo "INFO: start of jmap output:"
108.216 - cat "$TEST_NAME.jmap"
108.217 - echo "INFO: end of jmap output."
108.218 +
108.219 + # There are intermittent jmap failures; see 6498448.
108.220 + #
108.221 + # So far the following have been observed in a jmap call
108.222 + # that was not in a race with target process termination:
108.223 + #
108.224 + # (Solaris specific, 2nd sample)
108.225 + # <pid>: Unable to open door: target process not responding or HotSpot VM not loaded
108.226 + # The -F option can be used when the target process is not responding
108.227 + #
108.228 + # (on Solaris so far)
108.229 + # java.io.IOException
108.230 + #
108.231 + # (on Solaris so far, 1st sample)
108.232 + # <pid>: Permission denied
108.233 + #
108.234 + sed 's/^/INFO: /' "$TEST_NAME.jmap"
108.235 +
108.236 + if [ "$loop_cnt" = "$loop_cnt_on_retry" ]; then
108.237 + # loop count hasn't changed
108.238 + jmap_retry_cnt=`expr $jmap_retry_cnt + 1`
108.239 + else
108.240 + # loop count has changed so remember it
108.241 + jmap_retry_cnt=1
108.242 + loop_cnt_on_retry="$loop_cnt"
108.243 + fi
108.244 +
108.245 + # This is '-ge' because we have the original attempt plus
108.246 + # MAX_JMAP_TRY_CNT - 1 retries.
108.247 + if [ "$jmap_retry_cnt" -ge "$MAX_JMAP_TRY_CNT" ]; then
108.248 + echo "INFO: jmap failed $MAX_JMAP_TRY_CNT times in a row" \
108.249 + "without making any progress."
108.250 echo "FAIL: jmap is unable to take any samples." >&2
108.251 - echo "INFO: killing $test_pid"
108.252 - kill "$test_pid"
108.253 + killApplication
108.254 exit 2
108.255 fi
108.256 - echo "INFO: The likely reason is that $TEST_NAME has finished running."
108.257 - break
108.258 +
108.259 + # short delay and try again
108.260 + # Note: sleep 1 didn't help with "<pid>: Permission denied"
108.261 + sleep 2
108.262 + echo "INFO: retrying jmap (retry=$jmap_retry_cnt, loop=$loop_cnt)."
108.263 + continue
108.264 fi
108.265
108.266 - instance_cnt=`grep_cmd "[ ]$TARGET_CLASS$" \
108.267 - < "$TEST_NAME.jmap" \
108.268 + set +e
108.269 + instance_cnt=`grep "${PATTERN_WS}${TARGET_CLASS}${PATTERN_EOL}" \
108.270 + "$TEST_NAME.jmap" \
108.271 | sed '
108.272 # strip leading whitespace; does nothing in JDK1.5.0
108.273 - s/^[ ][ ]*//
108.274 + s/^'"${PATTERN_WS}${PATTERN_WS}"'*//
108.275 # strip <#bytes> in JDK1.5.0; does nothing otherwise
108.276 - s/^[1-9][0-9]*[ ][ ]*//
108.277 + s/^[1-9][0-9]*'"${PATTERN_WS}${PATTERN_WS}"'*//
108.278 # strip <num>: field; does nothing in JDK1.5.0
108.279 - s/^[1-9][0-9]*:[ ][ ]*//
108.280 + s/^[1-9][0-9]*:'"${PATTERN_WS}${PATTERN_WS}"'*//
108.281 # strip <class_name> field
108.282 - s/[ ].*//
108.283 + s/'"${PATTERN_WS}"'.*//
108.284 '`
108.285 + set -e
108.286 if [ -z "$instance_cnt" ]; then
108.287 echo "INFO: instance count is unexpectedly empty"
108.288 if [ "$loop_cnt" = 0 ]; then
108.289 @@ -211,8 +195,7 @@
108.290 cat "$TEST_NAME.jmap"
108.291 echo "INFO: end of jmap output."
108.292 echo "FAIL: cannot find the instance count value." >&2
108.293 - echo "INFO: killing $test_pid"
108.294 - kill "$test_pid"
108.295 + killApplication
108.296 exit 2
108.297 fi
108.298 else
108.299 @@ -221,7 +204,17 @@
108.300 if [ "$instance_cnt" -gt "$prev_instance_cnt" ]; then
108.301 increasing_cnt=`expr $increasing_cnt + 1`
108.302 else
108.303 + # actually decreasing or the same
108.304 decreasing_cnt=`expr $decreasing_cnt + 1`
108.305 +
108.306 + # For this particular WeakReference leak, the count was
108.307 + # always observed to be increasing so if we get a decreasing
108.308 + # or the same count, then the leak is fixed in the bits
108.309 + # being tested.
108.310 + echo "INFO: finishing early due to non-increasing instance count."
108.311 + finished_early=true
108.312 + killApplication
108.313 + break
108.314 fi
108.315 prev_instance_cnt="$instance_cnt"
108.316 fi
108.317 @@ -232,8 +225,22 @@
108.318 loop_cnt=`expr $loop_cnt + 1`
108.319 done
108.320
108.321 +if [ $finished_early = false ]; then
108.322 + stopApplication "$TEST_NAME.port"
108.323 + waitForApplication
108.324 +fi
108.325 +
108.326 +echo "INFO: $TEST_NAME has finished running."
108.327 echo "INFO: increasing_cnt = $increasing_cnt"
108.328 echo "INFO: decreasing_cnt = $decreasing_cnt"
108.329 +if [ "$jmap_retry_cnt" -gt 0 ]; then
108.330 + echo "INFO: jmap_retry_cnt = $jmap_retry_cnt (in $loop_cnt iterations)"
108.331 +fi
108.332 +
108.333 +if [ "$loop_cnt" = 0 ]; then
108.334 + echo "FAIL: jmap is unable to take any samples." >&2
108.335 + exit 2
108.336 +fi
108.337
108.338 echo "INFO: The instance count of" `eval echo $TARGET_CLASS` "objects"
108.339 if [ "$decreasing_cnt" = 0 ]; then
108.340 @@ -242,6 +249,6 @@
108.341 exit 2
108.342 fi
108.343
108.344 -echo "INFO: is both increasing and decreasing."
108.345 +echo "INFO: is not always increasing."
108.346 echo "PASS: This indicates that there is not a memory leak."
108.347 exit 0
109.1 --- a/test/java/util/logging/LoggerWeakRefLeak.java Fri Aug 06 12:52:07 2010 -0700
109.2 +++ b/test/java/util/logging/LoggerWeakRefLeak.java Mon Aug 09 16:02:19 2010 -0700
109.3 @@ -23,27 +23,32 @@
109.4
109.5 import java.util.logging.*;
109.6
109.7 -public class LoggerWeakRefLeak {
109.8 - // AnonLoggerWeakRefLeak checks for one weak reference leak.
109.9 - // LoggerWeakRefLeak checks for two weak reference leaks so
109.10 - // this test runs twice as long, by default.
109.11 +public class LoggerWeakRefLeak extends SimpleApplication {
109.12 + // The test driver script will allow this program to run until we
109.13 + // reach DEFAULT_LOOP_TIME or a decrease in instance counts is
109.14 + // observed. For these particular WeakReference leaks, the count
109.15 + // was always observed to be increasing so if we get a decreasing
109.16 + // count, then the leaks are fixed in the bits being tested.
109.17 + // Two minutes has been enough time to observe a decrease in
109.18 + // fixed bits on overloaded systems, but the test will likely
109.19 + // finish more quickly.
109.20 public static int DEFAULT_LOOP_TIME = 120; // time is in seconds
109.21
109.22 - public static void main(String[] args) {
109.23 + // execute the LoggerWeakRefLeak app work
109.24 + public void doMyAppWork(String[] args) throws Exception {
109.25 int loop_time = 0;
109.26 int max_loop_time = DEFAULT_LOOP_TIME;
109.27
109.28 - if (args.length == 0) {
109.29 + // args[0] is the port-file
109.30 + if (args.length < 2) {
109.31 System.out.println("INFO: using default time of "
109.32 + max_loop_time + " seconds.");
109.33 } else {
109.34 try {
109.35 - max_loop_time = Integer.parseInt(args[0]);
109.36 + max_loop_time = Integer.parseInt(args[1]);
109.37 } catch (NumberFormatException nfe) {
109.38 - System.err.println("Error: '" + args[0]
109.39 + throw new RuntimeException("Error: '" + args[1]
109.40 + "': is not a valid seconds value.");
109.41 - System.err.println("Usage: LoggerWeakRefLeak [seconds]");
109.42 - System.exit(1);
109.43 }
109.44 }
109.45
109.46 @@ -86,4 +91,12 @@
109.47
109.48 System.out.println("INFO: final loop count = " + count);
109.49 }
109.50 +
109.51 + public static void main(String[] args) throws Exception {
109.52 + AnonLoggerWeakRefLeak myApp = new AnonLoggerWeakRefLeak();
109.53 +
109.54 + SimpleApplication.setMyApp(myApp);
109.55 +
109.56 + SimpleApplication.main(args);
109.57 + }
109.58 }
110.1 --- a/test/java/util/logging/LoggerWeakRefLeak.sh Fri Aug 06 12:52:07 2010 -0700
110.2 +++ b/test/java/util/logging/LoggerWeakRefLeak.sh Mon Aug 09 16:02:19 2010 -0700
110.3 @@ -1,3 +1,5 @@
110.4 +#!/bin/sh
110.5 +
110.6 #
110.7 # Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
110.8 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
110.9 @@ -23,76 +25,24 @@
110.10
110.11 # @test
110.12 # @bug 6942989
110.13 -# @ignore until 6964018 is fixed
110.14 # @summary Check for WeakReference leak in Logger objects
110.15 # @author Daniel D. Daugherty
110.16 #
110.17 -# @run build LoggerWeakRefLeak
110.18 +# @library ../../../sun/tools/common
110.19 +# @build SimpleApplication ShutdownSimpleApplication
110.20 +# @build LoggerWeakRefLeak
110.21 # @run shell/timeout=240 LoggerWeakRefLeak.sh
110.22
110.23 -# The timeout is: 2 minutes for infrastructure and 1 minute for the test
110.24 +# The timeout is: 2 minutes for infrastructure and 2 minutes for the test
110.25 #
110.26
110.27 -if [ "${TESTJAVA}" = "" ]
110.28 -then
110.29 - echo "TESTJAVA not set. Test cannot execute. Failed."
110.30 - exit 1
110.31 -fi
110.32 +. ${TESTSRC}/../../../sun/tools/common/CommonSetup.sh
110.33 +. ${TESTSRC}/../../../sun/tools/common/ApplicationSetup.sh
110.34
110.35 -if [ "${TESTSRC}" = "" ]
110.36 -then
110.37 - echo "TESTSRC not set. Test cannot execute. Failed."
110.38 - exit 1
110.39 -fi
110.40 -
110.41 -if [ "${TESTCLASSES}" = "" ]
110.42 -then
110.43 - echo "TESTCLASSES not set. Test cannot execute. Failed."
110.44 - exit 1
110.45 -fi
110.46 -
110.47 -JAVA="${TESTJAVA}"/bin/java
110.48 -JMAP="${TESTJAVA}"/bin/jmap
110.49 -JPS="${TESTJAVA}"/bin/jps
110.50 -
110.51 -set -eu
110.52
110.53 TEST_NAME="LoggerWeakRefLeak"
110.54 TARGET_CLASS="java\.lang\.ref\.WeakReference"
110.55
110.56 -is_cygwin=false
110.57 -is_mks=false
110.58 -is_windows=false
110.59 -
110.60 -case `uname -s` in
110.61 -CYGWIN*)
110.62 - is_cygwin=true
110.63 - is_windows=true
110.64 - ;;
110.65 -Windows_*)
110.66 - is_mks=true
110.67 - is_windows=true
110.68 - ;;
110.69 -*)
110.70 - ;;
110.71 -esac
110.72 -
110.73 -
110.74 -# wrapper for grep
110.75 -#
110.76 -grep_cmd() {
110.77 - set +e
110.78 - if $is_windows; then
110.79 - # need dos2unix to get rid of CTRL-M chars from java output
110.80 - dos2unix | grep "$@"
110.81 - status="$?"
110.82 - else
110.83 - grep "$@"
110.84 - status="$?"
110.85 - fi
110.86 - set -e
110.87 -}
110.88 -
110.89
110.90 # MAIN begins here
110.91 #
110.92 @@ -105,62 +55,64 @@
110.93 # see if this version of jmap supports the '-histo:live' option
110.94 jmap_option="-histo:live"
110.95 set +e
110.96 -"${JMAP}" "$jmap_option" 0 > "$TEST_NAME.jmap" 2>&1
110.97 -grep '^Usage: ' "$TEST_NAME.jmap" > /dev/null 2>&1
110.98 +"${JMAP}" 2>&1 | grep ':live' > /dev/null 2>&1
110.99 status="$?"
110.100 set -e
110.101 -if [ "$status" = 0 ]; then
110.102 - echo "INFO: switching jmap option from '$jmap_option'\c"
110.103 - jmap_option="-histo"
110.104 - echo " to '$jmap_option'."
110.105 +if [ "$status" != 0 ]; then
110.106 + # usage message doesn't show ':live' option
110.107 +
110.108 + if $isWindows; then
110.109 + # If SA isn't present, then jmap gives a different usage message
110.110 + # that doesn't show the ':live' option. However, that's a bug that
110.111 + # is covered by 6971851 so we try using the option just to be sure.
110.112 + # For some reason, this problem has only been seen on OpenJDK6 on
110.113 + # Windows. Not sure why.
110.114 + set +e
110.115 + # Note: Don't copy this code to try probing process 0 on Linux; it
110.116 + # will kill the process group in strange ways.
110.117 + "${JMAP}" "$jmap_option" 0 2>&1 | grep 'Usage' > /dev/null 2>&1
110.118 + status="$?"
110.119 + set -e
110.120 + if [ "$status" = 0 ]; then
110.121 + # Usage message generated so flag the problem.
110.122 + status=1
110.123 + else
110.124 + # No usage message so clear the flag.
110.125 + status=0
110.126 + fi
110.127 + fi
110.128 +
110.129 + if [ "$status" != 0 ]; then
110.130 + echo "ERROR: 'jmap $jmap_option' is not supported so this test"
110.131 + echo "ERROR: cannot work reliably. Aborting!"
110.132 + exit 2
110.133 + fi
110.134 fi
110.135
110.136 -"${JAVA}" ${TESTVMOPTS} -classpath "${TESTCLASSES}" \
110.137 - "$TEST_NAME" $seconds > "$TEST_NAME.log" 2>&1 &
110.138 -test_pid="$!"
110.139 -echo "INFO: starting $TEST_NAME as pid = $test_pid"
110.140 +# Start application and use TEST_NAME.port for coordination
110.141 +startApplication "$TEST_NAME" "$TEST_NAME.port" $seconds
110.142
110.143 -# wait for test program to get going
110.144 -count=0
110.145 -while [ "$count" -lt 30 ]; do
110.146 - sleep 2
110.147 - grep_cmd '^INFO: call count = 0$' < "$TEST_NAME.log" > /dev/null 2>&1
110.148 - if [ "$status" = 0 ]; then
110.149 - break
110.150 - fi
110.151 - count=`expr $count + 1`
110.152 -done
110.153 -
110.154 -if [ "$count" -ge 30 ]; then
110.155 - echo "ERROR: $TEST_NAME failed to get going." >&2
110.156 - echo "INFO: killing $test_pid"
110.157 - kill "$test_pid"
110.158 - exit 1
110.159 -elif [ "$count" -gt 1 ]; then
110.160 - echo "INFO: $TEST_NAME took $count loops to start."
110.161 -fi
110.162 -
110.163 -if $is_cygwin; then
110.164 - # We need the Windows pid for jmap and not the Cygwin pid.
110.165 - # Note: '\t' works on Cygwin, but doesn't seem to work on Solaris.
110.166 - jmap_pid=`"${JPS}"| grep_cmd "[ \t]$TEST_NAME$" | sed 's/[ \t].*//'`
110.167 - if [ -z "$jmap_pid" ]; then
110.168 - echo "FAIL: jps could not map Cygwin pid to Windows pid." >&2
110.169 - echo "INFO: killing $test_pid"
110.170 - kill "$test_pid"
110.171 - exit 2
110.172 - fi
110.173 - echo "INFO: pid = $test_pid maps to Windows pid = $jmap_pid"
110.174 -else
110.175 - jmap_pid="$test_pid"
110.176 -fi
110.177 +finished_early=false
110.178
110.179 decreasing_cnt=0
110.180 increasing_cnt=0
110.181 loop_cnt=0
110.182 prev_instance_cnt=0
110.183
110.184 +MAX_JMAP_TRY_CNT=10
110.185 +jmap_retry_cnt=0
110.186 +loop_cnt_on_retry=0
110.187 +
110.188 while true; do
110.189 + # see if the target process has finished its run and bail if it has
110.190 + set +e
110.191 + grep "^INFO: final loop count = " "$appOutput" > /dev/null 2>&1
110.192 + status="$?"
110.193 + set -e
110.194 + if [ "$status" = 0 ]; then
110.195 + break
110.196 + fi
110.197 +
110.198 # Output format for 'jmap -histo' in JDK1.5.0:
110.199 #
110.200 # <#bytes> <#instances> <class_name>
110.201 @@ -170,38 +122,70 @@
110.202 # <num>: <#instances> <#bytes> <class_name>
110.203 #
110.204 set +e
110.205 - "${JMAP}" "$jmap_option" "$jmap_pid" > "$TEST_NAME.jmap" 2>&1
110.206 + "${JMAP}" "$jmap_option" "$appJavaPid" > "$TEST_NAME.jmap" 2>&1
110.207 status="$?"
110.208 set -e
110.209
110.210 if [ "$status" != 0 ]; then
110.211 echo "INFO: jmap exited with exit code = $status"
110.212 - if [ "$loop_cnt" = 0 ]; then
110.213 - echo "INFO: on the first iteration so no samples were taken."
110.214 - echo "INFO: start of jmap output:"
110.215 - cat "$TEST_NAME.jmap"
110.216 - echo "INFO: end of jmap output."
110.217 +
110.218 + # There are intermittent jmap failures; see 6498448.
110.219 + #
110.220 + # So far the following have been observed in a jmap call
110.221 + # that was not in a race with target process termination:
110.222 + #
110.223 + # (Solaris specific, 2nd sample)
110.224 + # <pid>: Unable to open door: target process not responding or HotSpot VM not loaded
110.225 + # The -F option can be used when the target process is not responding
110.226 + #
110.227 + # (on Solaris so far)
110.228 + # java.io.IOException
110.229 + #
110.230 + # (on Solaris so far, 1st sample)
110.231 + # <pid>: Permission denied
110.232 + #
110.233 + sed 's/^/INFO: /' "$TEST_NAME.jmap"
110.234 +
110.235 + if [ "$loop_cnt" = "$loop_cnt_on_retry" ]; then
110.236 + # loop count hasn't changed
110.237 + jmap_retry_cnt=`expr $jmap_retry_cnt + 1`
110.238 + else
110.239 + # loop count has changed so remember it
110.240 + jmap_retry_cnt=1
110.241 + loop_cnt_on_retry="$loop_cnt"
110.242 + fi
110.243 +
110.244 + # This is '-ge' because we have the original attempt plus
110.245 + # MAX_JMAP_TRY_CNT - 1 retries.
110.246 + if [ "$jmap_retry_cnt" -ge "$MAX_JMAP_TRY_CNT" ]; then
110.247 + echo "INFO: jmap failed $MAX_JMAP_TRY_CNT times in a row" \
110.248 + "without making any progress."
110.249 echo "FAIL: jmap is unable to take any samples." >&2
110.250 - echo "INFO: killing $test_pid"
110.251 - kill "$test_pid"
110.252 + killApplication
110.253 exit 2
110.254 fi
110.255 - echo "INFO: The likely reason is that $TEST_NAME has finished running."
110.256 - break
110.257 +
110.258 + # short delay and try again
110.259 + # Note: sleep 1 didn't help with "<pid>: Permission denied"
110.260 + sleep 2
110.261 + echo "INFO: retrying jmap (retry=$jmap_retry_cnt, loop=$loop_cnt)."
110.262 + continue
110.263 fi
110.264
110.265 - instance_cnt=`grep_cmd "[ ]$TARGET_CLASS$" \
110.266 - < "$TEST_NAME.jmap" \
110.267 + set +e
110.268 + instance_cnt=`grep "${PATTERN_WS}${TARGET_CLASS}${PATTERN_EOL}" \
110.269 + "$TEST_NAME.jmap" \
110.270 | sed '
110.271 # strip leading whitespace; does nothing in JDK1.5.0
110.272 - s/^[ ][ ]*//
110.273 + s/^'"${PATTERN_WS}${PATTERN_WS}"'*//
110.274 # strip <#bytes> in JDK1.5.0; does nothing otherwise
110.275 - s/^[1-9][0-9]*[ ][ ]*//
110.276 + s/^[1-9][0-9]*'"${PATTERN_WS}${PATTERN_WS}"'*//
110.277 # strip <num>: field; does nothing in JDK1.5.0
110.278 - s/^[1-9][0-9]*:[ ][ ]*//
110.279 + s/^[1-9][0-9]*:'"${PATTERN_WS}${PATTERN_WS}"'*//
110.280 # strip <class_name> field
110.281 - s/[ ].*//
110.282 + s/'"${PATTERN_WS}"'.*//
110.283 '`
110.284 + set -e
110.285 if [ -z "$instance_cnt" ]; then
110.286 echo "INFO: instance count is unexpectedly empty"
110.287 if [ "$loop_cnt" = 0 ]; then
110.288 @@ -211,8 +195,7 @@
110.289 cat "$TEST_NAME.jmap"
110.290 echo "INFO: end of jmap output."
110.291 echo "FAIL: cannot find the instance count value." >&2
110.292 - echo "INFO: killing $test_pid"
110.293 - kill "$test_pid"
110.294 + killApplication
110.295 exit 2
110.296 fi
110.297 else
110.298 @@ -221,7 +204,17 @@
110.299 if [ "$instance_cnt" -gt "$prev_instance_cnt" ]; then
110.300 increasing_cnt=`expr $increasing_cnt + 1`
110.301 else
110.302 + # actually decreasing or the same
110.303 decreasing_cnt=`expr $decreasing_cnt + 1`
110.304 +
110.305 + # For these particular WeakReference leaks, the count was
110.306 + # always observed to be increasing so if we get a decreasing
110.307 + # or the same count, then the leaks are fixed in the bits
110.308 + # being tested.
110.309 + echo "INFO: finishing early due to non-increasing instance count."
110.310 + finished_early=true
110.311 + killApplication
110.312 + break
110.313 fi
110.314 prev_instance_cnt="$instance_cnt"
110.315 fi
110.316 @@ -232,8 +225,22 @@
110.317 loop_cnt=`expr $loop_cnt + 1`
110.318 done
110.319
110.320 +if [ $finished_early = false ]; then
110.321 + stopApplication "$TEST_NAME.port"
110.322 + waitForApplication
110.323 +fi
110.324 +
110.325 +echo "INFO: $TEST_NAME has finished running."
110.326 echo "INFO: increasing_cnt = $increasing_cnt"
110.327 echo "INFO: decreasing_cnt = $decreasing_cnt"
110.328 +if [ "$jmap_retry_cnt" -gt 0 ]; then
110.329 + echo "INFO: jmap_retry_cnt = $jmap_retry_cnt (in $loop_cnt iterations)"
110.330 +fi
110.331 +
110.332 +if [ "$loop_cnt" = 0 ]; then
110.333 + echo "FAIL: jmap is unable to take any samples." >&2
110.334 + exit 2
110.335 +fi
110.336
110.337 echo "INFO: The instance count of" `eval echo $TARGET_CLASS` "objects"
110.338 if [ "$decreasing_cnt" = 0 ]; then
110.339 @@ -242,6 +249,6 @@
110.340 exit 2
110.341 fi
110.342
110.343 -echo "INFO: is both increasing and decreasing."
110.344 +echo "INFO: is not always increasing."
110.345 echo "PASS: This indicates that there is not a memory leak."
110.346 exit 0
111.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
111.2 +++ b/test/javax/swing/JColorChooser/Test6199676.java Mon Aug 09 16:02:19 2010 -0700
111.3 @@ -0,0 +1,117 @@
111.4 +/*
111.5 + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
111.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
111.7 + *
111.8 + * This code is free software; you can redistribute it and/or modify it
111.9 + * under the terms of the GNU General Public License version 2 only, as
111.10 + * published by the Free Software Foundation.
111.11 + *
111.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
111.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
111.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
111.15 + * version 2 for more details (a copy is included in the LICENSE file that
111.16 + * accompanied this code).
111.17 + *
111.18 + * You should have received a copy of the GNU General Public License version
111.19 + * 2 along with this work; if not, write to the Free Software Foundation,
111.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
111.21 + *
111.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
111.23 + * or visit www.oracle.com if you need additional information or have any
111.24 + * questions.
111.25 + */
111.26 +
111.27 +/*
111.28 + * @test
111.29 + * @bug 6199676
111.30 + * @summary Tests preview panel after L&F changing
111.31 + * @author Sergey Malenkov
111.32 + */
111.33 +
111.34 +import java.awt.Component;
111.35 +import java.awt.Container;
111.36 +import javax.swing.JColorChooser;
111.37 +import javax.swing.JFrame;
111.38 +import javax.swing.JPanel;
111.39 +import javax.swing.SwingUtilities;
111.40 +import javax.swing.UIManager;
111.41 +import javax.swing.UIManager.LookAndFeelInfo;
111.42 +
111.43 +public class Test6199676 implements Runnable {
111.44 + public static void main(String[] args) {
111.45 + SwingUtilities.invokeLater(new Test6199676());
111.46 + }
111.47 +
111.48 + private static void exit(String error) {
111.49 + if (error != null) {
111.50 + System.err.println(error);
111.51 + System.exit(1);
111.52 + }
111.53 + else {
111.54 + System.exit(0);
111.55 + }
111.56 + }
111.57 +
111.58 + private static Component getPreview(Container container) {
111.59 + String name = "ColorChooser.previewPanelHolder";
111.60 + for (Component component : container.getComponents()) {
111.61 + if (!name.equals(component.getName())) {
111.62 + component = (component instanceof Container)
111.63 + ? getPreview((Container) component)
111.64 + : null;
111.65 + }
111.66 + if (component instanceof Container) {
111.67 + container = (Container) component;
111.68 + return 1 == container.getComponentCount()
111.69 + ? container.getComponent(0)
111.70 + : null;
111.71 + }
111.72 + }
111.73 + return null;
111.74 + }
111.75 +
111.76 + private static boolean isShowing(Component component) {
111.77 + return (component != null) && component.isShowing();
111.78 + }
111.79 +
111.80 + private int index;
111.81 + private boolean updated;
111.82 + private JColorChooser chooser;
111.83 +
111.84 + public synchronized void run() {
111.85 + if (this.chooser == null) {
111.86 + this.chooser = new JColorChooser();
111.87 +
111.88 + JFrame frame = new JFrame(getClass().getName());
111.89 + frame.add(this.chooser);
111.90 + frame.setVisible(true);
111.91 + }
111.92 + else if (this.updated) {
111.93 + if (isShowing(this.chooser.getPreviewPanel())) {
111.94 + exit("custom preview panel is showing");
111.95 + }
111.96 + exit(null);
111.97 + }
111.98 + else {
111.99 + Component component = this.chooser.getPreviewPanel();
111.100 + if (component == null) {
111.101 + component = getPreview(this.chooser);
111.102 + }
111.103 + if (!isShowing(component)) {
111.104 + exit("default preview panel is not showing");
111.105 + }
111.106 + this.updated = true;
111.107 + this.chooser.setPreviewPanel(new JPanel());
111.108 + }
111.109 + LookAndFeelInfo[] infos = UIManager.getInstalledLookAndFeels();
111.110 + LookAndFeelInfo info = infos[++this.index % infos.length];
111.111 + try {
111.112 + UIManager.setLookAndFeel(info.getClassName());
111.113 + }
111.114 + catch (Exception exception) {
111.115 + exit("could not change L&F");
111.116 + }
111.117 + SwingUtilities.updateComponentTreeUI(this.chooser);
111.118 + SwingUtilities.invokeLater(this);
111.119 + }
111.120 +}
112.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
112.2 +++ b/test/javax/swing/JComboBox/4743225/bug4743225.java Mon Aug 09 16:02:19 2010 -0700
112.3 @@ -0,0 +1,111 @@
112.4 +/*
112.5 + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
112.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
112.7 + *
112.8 + * This code is free software; you can redistribute it and/or modify it
112.9 + * under the terms of the GNU General Public License version 2 only, as
112.10 + * published by the Free Software Foundation.
112.11 + *
112.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
112.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
112.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
112.15 + * version 2 for more details (a copy is included in the LICENSE file that
112.16 + * accompanied this code).
112.17 + *
112.18 + * You should have received a copy of the GNU General Public License version
112.19 + * 2 along with this work; if not, write to the Free Software Foundation,
112.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
112.21 + *
112.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
112.23 + * or visit www.oracle.com if you need additional information or have any
112.24 + * questions.
112.25 + */
112.26 +
112.27 +/* @test
112.28 + * @bug 4743225
112.29 + * @summary Size of JComboBox list is wrong when list is populated via PopupMenuListener
112.30 + * @author Alexander Potochkin
112.31 + */
112.32 +
112.33 +import sun.awt.SunToolkit;
112.34 +
112.35 +import javax.accessibility.AccessibleContext;
112.36 +import javax.swing.JComboBox;
112.37 +import javax.swing.JFrame;
112.38 +import javax.swing.SwingUtilities;
112.39 +import javax.swing.event.PopupMenuEvent;
112.40 +import javax.swing.event.PopupMenuListener;
112.41 +import javax.swing.plaf.basic.BasicComboPopup;
112.42 +import java.awt.FlowLayout;
112.43 +import java.awt.Point;
112.44 +import java.awt.Robot;
112.45 +import java.awt.Toolkit;
112.46 +import java.awt.event.InputEvent;
112.47 +
112.48 +public class bug4743225 extends JFrame {
112.49 +
112.50 + private static JComboBox cb;
112.51 + private static volatile boolean flag;
112.52 +
112.53 + public bug4743225() {
112.54 + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
112.55 + setLayout(new FlowLayout());
112.56 + cb = new JComboBox(new Object[] {"one", "two", "three"});
112.57 + cb.addPopupMenuListener(new PopupMenuListener() {
112.58 + public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
112.59 + cb.addItem("Test");
112.60 + }
112.61 +
112.62 + public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
112.63 + }
112.64 +
112.65 + public void popupMenuCanceled(PopupMenuEvent e) {
112.66 + }
112.67 + });
112.68 + add(cb);
112.69 + pack();
112.70 + }
112.71 +
112.72 + public static BasicComboPopup getPopup() {
112.73 + AccessibleContext c = cb.getAccessibleContext();
112.74 + for(int i = 0; i < c.getAccessibleChildrenCount(); i ++) {
112.75 + if (c.getAccessibleChild(i) instanceof BasicComboPopup) {
112.76 + return (BasicComboPopup) c.getAccessibleChild(i);
112.77 + }
112.78 + }
112.79 + throw new AssertionError("No BasicComboPopup found");
112.80 + }
112.81 +
112.82 + public static void main(String... args) throws Exception {
112.83 +
112.84 + Robot robot = new Robot();
112.85 + robot.setAutoDelay(20);
112.86 + SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
112.87 +
112.88 + SwingUtilities.invokeAndWait(new Runnable() {
112.89 + public void run() {
112.90 + new bug4743225().setVisible(true);
112.91 + }
112.92 + });
112.93 + toolkit.realSync();
112.94 +
112.95 + // calling this method from main thread is ok
112.96 + Point point = cb.getLocationOnScreen();
112.97 + robot.mouseMove(point.x + 10, point.y + 10);
112.98 + robot.mousePress(InputEvent.BUTTON1_MASK);
112.99 + robot.mouseRelease(InputEvent.BUTTON1_MASK);
112.100 + toolkit.realSync();
112.101 +
112.102 + SwingUtilities.invokeAndWait(new Runnable() {
112.103 + public void run() {
112.104 + if(getPopup().getList().getLastVisibleIndex() == 3) {
112.105 + flag = true;
112.106 + }
112.107 + }
112.108 + });
112.109 +
112.110 + if (!flag) {
112.111 + throw new RuntimeException("The ComboBox popup wasn't correctly updated");
112.112 + }
112.113 + }
112.114 +}
113.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
113.2 +++ b/test/javax/swing/JFormattedTextField/Test6462562.java Mon Aug 09 16:02:19 2010 -0700
113.3 @@ -0,0 +1,360 @@
113.4 +/*
113.5 + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
113.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
113.7 + *
113.8 + * This code is free software; you can redistribute it and/or modify it
113.9 + * under the terms of the GNU General Public License version 2 only, as
113.10 + * published by the Free Software Foundation.
113.11 + *
113.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
113.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
113.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
113.15 + * version 2 for more details (a copy is included in the LICENSE file that
113.16 + * accompanied this code).
113.17 + *
113.18 + * You should have received a copy of the GNU General Public License version
113.19 + * 2 along with this work; if not, write to the Free Software Foundation,
113.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
113.21 + *
113.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
113.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
113.24 + * have any questions.
113.25 + */
113.26 +
113.27 +/* @test
113.28 + @bug 6462562
113.29 + @summary Tests text input into JFormattedTextField
113.30 + with an InternationalFormatter
113.31 + @author Peter Zhelezniakov
113.32 + @run main Test6462562
113.33 +*/
113.34 +
113.35 +import java.awt.event.ActionEvent;
113.36 +import java.text.DateFormat;
113.37 +import java.text.NumberFormat;
113.38 +import java.text.ParseException;
113.39 +import java.text.SimpleDateFormat;
113.40 +import java.util.Date;
113.41 +import java.util.Locale;
113.42 +import javax.swing.Action;
113.43 +import javax.swing.JFormattedTextField;
113.44 +import javax.swing.SwingUtilities;
113.45 +import javax.swing.text.Caret;
113.46 +import javax.swing.text.DateFormatter;
113.47 +import javax.swing.text.DefaultEditorKit;
113.48 +import javax.swing.text.InternationalFormatter;
113.49 +import javax.swing.text.NumberFormatter;
113.50 +
113.51 +
113.52 +public class Test6462562
113.53 +{
113.54 + static final String BACKSPACE = new String("backspace");
113.55 + static final String DELETE = new String("delete");
113.56 +
113.57 + boolean failed = false;
113.58 +
113.59 + void test() {
113.60 + testPercentFormat();
113.61 + testCurrencyFormat();
113.62 + testIntegerFormat();
113.63 + testDateFormat();
113.64 +
113.65 + if (failed) {
113.66 + throw new RuntimeException("Some testcases failed, see output above");
113.67 + }
113.68 + System.err.println("(-; All testcases passed ;-)");
113.69 + }
113.70 +
113.71 + TestFormattedTextField create(NumberFormat format) {
113.72 + format.setMaximumFractionDigits(0);
113.73 + NumberFormatter fmt = new NumberFormatter(format);
113.74 + return new TestFormattedTextField(fmt);
113.75 + }
113.76 +
113.77 + TestFormattedTextField create(DateFormat format) {
113.78 + DateFormatter fmt = new DateFormatter(format);
113.79 + return new TestFormattedTextField(fmt);
113.80 + }
113.81 +
113.82 + public static void main(String[] args) throws Exception {
113.83 + SwingUtilities.invokeAndWait(new Runnable() {
113.84 + public void run() {
113.85 + new Test6462562().test();
113.86 + }
113.87 + });
113.88 + }
113.89 +
113.90 + class TestFormattedTextField extends JFormattedTextField
113.91 + {
113.92 + final Action backspace;
113.93 + final Action delete;
113.94 + final Action insert;
113.95 +
113.96 + final ActionEvent dummyEvent;
113.97 +
113.98 + public TestFormattedTextField(InternationalFormatter fmt) {
113.99 + super(fmt);
113.100 + fmt.setAllowsInvalid(false);
113.101 + fmt.setOverwriteMode(true);
113.102 +
113.103 + backspace = getActionMap().get(DefaultEditorKit.deletePrevCharAction);
113.104 + delete = getActionMap().get(DefaultEditorKit.deleteNextCharAction);
113.105 + insert = getActionMap().get(DefaultEditorKit.insertContentAction);
113.106 + dummyEvent = new ActionEvent(this, 0, null);
113.107 + }
113.108 +
113.109 + public boolean test(int pos, int selectionLength, String todo, Object expectedResult) {
113.110 + Object v0 = getValue();
113.111 +
113.112 + Caret caret = getCaret();
113.113 + caret.setDot(pos);
113.114 + if (selectionLength > 0) {
113.115 + caret.moveDot(pos + selectionLength);
113.116 + }
113.117 +
113.118 + String desc = todo;
113.119 + if (todo == BACKSPACE) {
113.120 + backspace.actionPerformed(dummyEvent);
113.121 + } else if (todo == DELETE) {
113.122 + delete.actionPerformed(dummyEvent);
113.123 + } else {
113.124 + desc = "insert('" + todo + "')";
113.125 + insert.actionPerformed(new ActionEvent(this, 0, todo));
113.126 + }
113.127 +
113.128 + try {
113.129 + commitEdit();
113.130 + } catch (ParseException e) {
113.131 + e.printStackTrace();
113.132 + failed = true;
113.133 + return false;
113.134 + }
113.135 +
113.136 + Object v1 = getValue();
113.137 + if (! v1.equals(expectedResult)) {
113.138 + System.err.printf("Failure: value='%s', mark=%d, dot=%d, action=%s\n",
113.139 + v0, pos, pos + selectionLength, desc);
113.140 + System.err.printf(" Result: '%s', expected: '%s'\n", v1, expectedResult);
113.141 + failed = true;
113.142 + return false;
113.143 + }
113.144 + return true;
113.145 + }
113.146 + }
113.147 +
113.148 + void testPercentFormat() {
113.149 + NumberFormat format = NumberFormat.getPercentInstance(Locale.US);
113.150 + TestFormattedTextField ftf = create(format);
113.151 + ftf.setValue(.34);
113.152 +
113.153 + System.err.println("Testing NumberFormat.getPercentInstance(Locale.US)");
113.154 +
113.155 + // test inserting individual characters
113.156 + ftf.test(0, 0, "1", .14);
113.157 + ftf.test(2, 0, "2", 1.42);
113.158 + ftf.test(1, 0, "0", 1.02);
113.159 +
113.160 + // test inserting several characters at once - e.g. from clipboard
113.161 + ftf.test(0, 0, "1024", 10.24);
113.162 + ftf.test(3, 0, "333", 103.33);
113.163 + ftf.test(6, 0, "77", 10333.77);
113.164 + ftf.test(4, 0, "99", 10399.77);
113.165 + ftf.test(6, 0, "00", 10390.07);
113.166 +
113.167 + // test inserting strings that contain some formatting
113.168 + ftf.test(0, 0, "2,2", 2290.07);
113.169 + ftf.test(2, 0, "2,2", 222.27);
113.170 + ftf.test(4, 0, "2,2", 222.22);
113.171 + ftf.test(6, 0, "33,33", 2222233.33);
113.172 +
113.173 + // test delete
113.174 + ftf.test(0, 0, DELETE, 222233.33);
113.175 + ftf.test(10, 0, DELETE, 222233.33);
113.176 + ftf.test(5, 0, DELETE, 22223.33);
113.177 + ftf.test(6, 0, DELETE, 2222.33);
113.178 +
113.179 + // test backspace
113.180 + ftf.test(0, 0, BACKSPACE, 2222.33);
113.181 + ftf.test(7, 0, BACKSPACE, 222.23);
113.182 + ftf.test(4, 0, BACKSPACE, 22.23);
113.183 + ftf.test(2, 0, BACKSPACE, 2.23);
113.184 +
113.185 + // test replacing selection
113.186 + ftf.test(0, 1, "555", 555.23);
113.187 + ftf.test(4, 2, "555", 5555.55);
113.188 + ftf.test(2, 3, "1", 551.55);
113.189 + ftf.test(3, 2, "6", 55.65);
113.190 + ftf.test(4, 2, "12", 556.12);
113.191 + ftf.test(3, 4, "0", 5.5);
113.192 + ftf.test(0, 3, "111222333444555", 1112223334445.55);
113.193 +
113.194 + // test deleting selection
113.195 + ftf.test(0, 2, DELETE, 12223334445.55);
113.196 + ftf.test(0, 3, BACKSPACE, 223334445.55);
113.197 + ftf.test(12, 2, DELETE, 2233344.45);
113.198 + ftf.test(9, 2, BACKSPACE, 22333.44);
113.199 + ftf.test(4, 3, DELETE, 223.44);
113.200 + ftf.test(1, 2, BACKSPACE, 23.44);
113.201 + ftf.test(3, 3, DELETE, .23);
113.202 + ftf.test(1, 2, BACKSPACE, .02);
113.203 + }
113.204 +
113.205 + void testCurrencyFormat() {
113.206 + NumberFormat format = NumberFormat.getCurrencyInstance(Locale.US);
113.207 + TestFormattedTextField ftf = create(format);
113.208 + ftf.setValue(56L);
113.209 +
113.210 + System.err.println("Testing NumberFormat.getCurrencyInstance(Locale.US)");
113.211 +
113.212 + // test inserting individual characters
113.213 + ftf.test(1, 0, "1", 16L);
113.214 + ftf.test(3, 0, "2", 162L);
113.215 + ftf.test(2, 0, "0", 102L);
113.216 +
113.217 + // test inserting several characters at once - e.g. from clipboard
113.218 + ftf.test(1, 0, "1024", 1024L);
113.219 + ftf.test(4, 0, "333", 10333L);
113.220 + ftf.test(7, 0, "77", 1033377L);
113.221 + ftf.test(5, 0, "99", 1039977L);
113.222 + ftf.test(7, 0, "00", 1039007L);
113.223 +
113.224 + // test inserting strings that contain some formatting
113.225 + ftf.test(1, 0, "2,2", 229007L);
113.226 + ftf.test(3, 0, "2,2", 22227L);
113.227 + ftf.test(4, 0, "2,2", 2222L);
113.228 + ftf.test(6, 0, "33,33", 22223333L);
113.229 +
113.230 + // test delete
113.231 + ftf.test(1, 0, DELETE, 2223333L);
113.232 + ftf.test(10, 0, DELETE, 2223333L);
113.233 + ftf.test(5, 0, DELETE, 222333L);
113.234 + ftf.test(5, 0, DELETE, 22233L);
113.235 +
113.236 + // test backspace
113.237 + ftf.test(1, 0, BACKSPACE, 22233L);
113.238 + ftf.test(7, 0, BACKSPACE, 2223L);
113.239 + ftf.test(4, 0, BACKSPACE, 223L);
113.240 + ftf.test(2, 0, BACKSPACE, 23L);
113.241 +
113.242 + // test replacing selection
113.243 + ftf.test(1, 1, "555", 5553L);
113.244 + ftf.test(4, 2, "555", 55555L);
113.245 + ftf.test(2, 3, "1", 5155L);
113.246 + ftf.test(3, 2, "6", 565L);
113.247 + ftf.test(1, 3, "111222333444555", 111222333444555L);
113.248 +
113.249 + // test deleting selection
113.250 + ftf.test(1, 2, DELETE, 1222333444555L);
113.251 + ftf.test(1, 3, BACKSPACE, 22333444555L);
113.252 + ftf.test(13, 2, DELETE, 223334445L);
113.253 + ftf.test(10, 2, BACKSPACE, 2233344L);
113.254 + ftf.test(4, 4, DELETE, 2244L);
113.255 + ftf.test(1, 4, BACKSPACE, 4L);
113.256 + }
113.257 +
113.258 + void testIntegerFormat() {
113.259 + NumberFormat format = NumberFormat.getIntegerInstance(Locale.US);
113.260 + TestFormattedTextField ftf = create(format);
113.261 + ftf.setValue(56L);
113.262 +
113.263 + System.err.println("Testing NumberFormat.getIntegerInstance(Locale.US)");
113.264 +
113.265 + // test inserting individual characters
113.266 + ftf.test(0, 0, "1", 16L);
113.267 + ftf.test(2, 0, "2", 162L);
113.268 + ftf.test(1, 0, "0", 102L);
113.269 +
113.270 + // test inserting several characters at once - e.g. from clipboard
113.271 + ftf.test(0, 0, "1024", 1024L);
113.272 + ftf.test(3, 0, "333", 10333L);
113.273 + ftf.test(6, 0, "77", 1033377L);
113.274 + ftf.test(4, 0, "99", 1039977L);
113.275 + ftf.test(6, 0, "00", 1039007L);
113.276 +
113.277 + // test inserting strings that contain some formatting
113.278 + ftf.test(0, 0, "2,2", 229007L);
113.279 + ftf.test(2, 0, "2,2", 22227L);
113.280 + ftf.test(3, 0, "2,2", 2222L);
113.281 + ftf.test(5, 0, "33,33", 22223333L);
113.282 +
113.283 + // test delete
113.284 + ftf.test(0, 0, DELETE, 2223333L);
113.285 + ftf.test(9, 0, DELETE, 2223333L);
113.286 + ftf.test(4, 0, DELETE, 222333L);
113.287 + ftf.test(4, 0, DELETE, 22233L);
113.288 +
113.289 + // test backspace
113.290 + ftf.test(0, 0, BACKSPACE, 22233L);
113.291 + ftf.test(6, 0, BACKSPACE, 2223L);
113.292 + ftf.test(2, 0, BACKSPACE, 223L);
113.293 + ftf.test(2, 0, BACKSPACE, 23L);
113.294 +
113.295 + // test replacing selection
113.296 + ftf.test(0, 1, "555", 5553L);
113.297 + ftf.test(3, 2, "555", 55555L);
113.298 + ftf.test(1, 3, "1", 5155L);
113.299 + ftf.test(2, 2, "6", 565L);
113.300 + ftf.test(0, 3, "111222333444555", 111222333444555L);
113.301 +
113.302 + // test deleting selection
113.303 + ftf.test(0, 2, DELETE, 1222333444555L);
113.304 + ftf.test(0, 3, BACKSPACE, 22333444555L);
113.305 + ftf.test(12, 2, DELETE, 223334445L);
113.306 + ftf.test(9, 2, BACKSPACE, 2233344L);
113.307 + ftf.test(3, 4, DELETE, 2244L);
113.308 + ftf.test(0, 4, BACKSPACE, 4L);
113.309 + }
113.310 +
113.311 + Date date(DateFormat format, String spec) {
113.312 + try {
113.313 + return format.parse(spec);
113.314 + } catch (ParseException e) {
113.315 + throw new Error("Error in test");
113.316 + }
113.317 + }
113.318 +
113.319 + void testDateFormat() {
113.320 + DateFormat format = new SimpleDateFormat("MM/dd/yyyy", Locale.US);
113.321 + TestFormattedTextField ftf = create(format);
113.322 + ftf.setValue(date(format, "12/05/2005"));
113.323 +
113.324 + System.err.println("Testing SimpleDateFormat(\"MM/dd/yyyy\", Locale.US)");
113.325 +
113.326 + // test inserting individual characters
113.327 + ftf.test(0, 0, "0", date(format, "02/05/2005"));
113.328 + ftf.test(4, 0, "4", date(format, "02/04/2005"));
113.329 + ftf.test(6, 0, "1", date(format, "02/04/1005"));
113.330 + ftf.test(9, 0, "9", date(format, "02/04/1009"));
113.331 +
113.332 + // test inserting several characters at once - e.g. from clipboard
113.333 + ftf.test(0, 0, "11", date(format, "11/04/1009"));
113.334 + ftf.test(3, 0, "23", date(format, "11/23/1009"));
113.335 + ftf.test(6, 0, "191", date(format, "11/23/1919"));
113.336 +
113.337 + // test delete
113.338 + ftf.test(0, 0, DELETE, date(format, "01/23/1919"));
113.339 + ftf.test(3, 0, DELETE, date(format, "01/03/1919"));
113.340 + ftf.test(10, 0, DELETE, date(format, "01/03/1919"));
113.341 + ftf.test(1, 0, DELETE, date(format, "12/03/1918"));
113.342 + ftf.test(4, 0, DELETE, date(format, "11/30/1918"));
113.343 +
113.344 + // test backspace
113.345 + ftf.test(0, 0, BACKSPACE, date(format, "11/30/1918"));
113.346 + ftf.test(1, 0, BACKSPACE, date(format, "01/30/1918"));
113.347 + ftf.test(4, 0, BACKSPACE, date(format, "12/31/1917"));
113.348 + ftf.test(10, 0, BACKSPACE, date(format, "12/31/0191"));
113.349 + ftf.test(3, 0, BACKSPACE, date(format, "01/31/0191"));
113.350 + ftf.test(5, 0, BACKSPACE, date(format, "01/03/0191"));
113.351 +
113.352 + // test replacing selection
113.353 + ftf.test(0, 1, "1", date(format, "11/03/0191"));
113.354 + ftf.test(3, 1, "2", date(format, "11/23/0191"));
113.355 + ftf.test(6, 2, "20", date(format, "11/23/2091"));
113.356 +
113.357 + // test deleting selection
113.358 + ftf.test(0, 1, BACKSPACE, date(format, "01/23/2091"));
113.359 + ftf.test(3, 1, DELETE, date(format, "01/03/2091"));
113.360 + ftf.test(6, 2, BACKSPACE, date(format, "01/03/0091"));
113.361 + ftf.test(8, 1, DELETE, date(format, "01/03/0001"));
113.362 + }
113.363 +}
114.1 --- a/test/sun/net/ftp/FtpGetContent.java Fri Aug 06 12:52:07 2010 -0700
114.2 +++ b/test/sun/net/ftp/FtpGetContent.java Mon Aug 09 16:02:19 2010 -0700
114.3 @@ -391,6 +391,10 @@
114.4 done = true;
114.5 }
114.6
114.7 + synchronized boolean done() {
114.8 + return done;
114.9 + }
114.10 +
114.11 synchronized public void setPortEnabled(boolean ok) {
114.12 portEnabled = ok;
114.13 }
114.14 @@ -431,12 +435,13 @@
114.15 public void run() {
114.16 try {
114.17 Socket client;
114.18 - while (!done) {
114.19 + while (!done()) {
114.20 client = server.accept();
114.21 (new FtpServerHandler(client)).start();
114.22 }
114.23 - server.close();
114.24 } catch(Exception e) {
114.25 + } finally {
114.26 + try { server.close(); } catch (IOException unused) {}
114.27 }
114.28 }
114.29 }
114.30 @@ -463,18 +468,13 @@
114.31 bytesRead = stream.read(buffer);
114.32 }
114.33 stream.close();
114.34 - server.terminate();
114.35 - server.interrupt();
114.36 if (totalBytes != filesize)
114.37 throw new RuntimeException("wrong file size!");
114.38 } catch (IOException e) {
114.39 - try {
114.40 - server.terminate();
114.41 - server.interrupt();
114.42 - } catch (Exception e2) {
114.43 - }
114.44 throw new RuntimeException(e.getMessage());
114.45 + } finally {
114.46 + server.terminate();
114.47 + server.server.close();
114.48 }
114.49 }
114.50 -
114.51 }
115.1 --- a/test/sun/net/ftp/FtpURL.java Fri Aug 06 12:52:07 2010 -0700
115.2 +++ b/test/sun/net/ftp/FtpURL.java Mon Aug 09 16:02:19 2010 -0700
115.3 @@ -438,8 +438,9 @@
115.4 client = server.accept();
115.5 (new FtpServerHandler(client)).run();
115.6 }
115.7 - server.close();
115.8 } catch(Exception e) {
115.9 + } finally {
115.10 + try { server.close(); } catch (IOException unused) {}
115.11 }
115.12 }
115.13 }
115.14 @@ -448,10 +449,9 @@
115.15 }
115.16
115.17 public FtpURL() throws Exception {
115.18 - FtpServer server = null;
115.19 + FtpServer server = new FtpServer(0);
115.20 BufferedReader in = null;
115.21 try {
115.22 - server = new FtpServer(0);
115.23 server.start();
115.24 int port = server.getPort();
115.25
115.26 @@ -497,17 +497,14 @@
115.27 throw new RuntimeException("Incorrect filename received");
115.28 if (! "/usr".equals(server.pwd()))
115.29 throw new RuntimeException("Incorrect pwd received");
115.30 - in.close();
115.31 // We're done!
115.32
115.33 } catch (Exception e) {
115.34 - try {
115.35 - in.close();
115.36 - server.terminate();
115.37 - server.interrupt();
115.38 - } catch(Exception ex) {
115.39 - }
115.40 throw new RuntimeException("FTP support error: " + e.getMessage());
115.41 + } finally {
115.42 + try { in.close(); } catch (IOException unused) {}
115.43 + server.terminate();
115.44 + server.server.close();
115.45 }
115.46 }
115.47 }
116.1 --- a/test/sun/net/www/http/ChunkedInputStream/ChunkedEncodingWithProgressMonitorTest.java Fri Aug 06 12:52:07 2010 -0700
116.2 +++ b/test/sun/net/www/http/ChunkedInputStream/ChunkedEncodingWithProgressMonitorTest.java Mon Aug 09 16:02:19 2010 -0700
116.3 @@ -30,9 +30,7 @@
116.4 * @summary ChunkedEncoding unit test; MeteredStream/ProgressData problem
116.5 */
116.6
116.7 -import java.io.*;
116.8 import java.net.*;
116.9 -import java.security.*;
116.10 import java.util.BitSet;
116.11 import sun.net.ProgressMeteringPolicy;
116.12 import sun.net.ProgressMonitor;
116.13 @@ -42,8 +40,10 @@
116.14 public class ChunkedEncodingWithProgressMonitorTest {
116.15 public static void main (String[] args) throws Exception {
116.16 ProgressMonitor.setMeteringPolicy(new MyProgressMeteringPolicy());
116.17 - ProgressMonitor.getDefault().addProgressListener(new MyProgressListener());
116.18 + ProgressListener listener = new MyProgressListener();
116.19 + ProgressMonitor.getDefault().addProgressListener(listener);
116.20 ChunkedEncodingTest.test();
116.21 + ProgressMonitor.getDefault().removeProgressListener(listener);
116.22
116.23 if (flag.cardinality() != 3) {
116.24 throw new RuntimeException("All three methods in ProgressListener"+
117.1 --- a/test/sun/net/www/http/ChunkedOutputStream/Test.java Fri Aug 06 12:52:07 2010 -0700
117.2 +++ b/test/sun/net/www/http/ChunkedOutputStream/Test.java Mon Aug 09 16:02:19 2010 -0700
117.3 @@ -34,7 +34,7 @@
117.4
117.5 public class Test implements HttpHandler {
117.6
117.7 - static int count = 0;
117.8 + static volatile int count = 0;
117.9
117.10 static final String str1 = "Helloworld1234567890abcdefghijklmnopqrstuvwxyz"+
117.11 "1234567890abcdefkjsdlkjflkjsldkfjlsdkjflkj"+
117.12 @@ -46,9 +46,9 @@
117.13 public void handle(HttpExchange exchange) {
117.14 String reqbody;
117.15 try {
117.16 - switch (count) {
117.17 - case 0: /* test1 -- keeps conn alive */
117.18 - case 1: /* test2 -- closes conn */
117.19 + switch (exchange.getRequestURI().toString()) {
117.20 + case "/test/test1": /* test1 -- keeps conn alive */
117.21 + case "/test/test2": /* test2 -- closes conn */
117.22 printRequestURI(exchange);
117.23 reqbody = read(exchange.getRequestBody());
117.24 if (!reqbody.equals(str1)) {
117.25 @@ -72,7 +72,7 @@
117.26 resHeaders.set("Connection", "close");
117.27 }
117.28 break;
117.29 - case 2: /* test 3 */
117.30 + case "/test/test3": /* test 3 */
117.31 printRequestURI(exchange);
117.32 reqbody = read(exchange.getRequestBody());
117.33
117.34 @@ -93,19 +93,19 @@
117.35 exchange.sendResponseHeaders(200, reqbody.length());
117.36 write(exchange.getResponseBody(), reqbody);
117.37 break;
117.38 - case 3: /* test 4 */
117.39 - case 4: /* test 5 */
117.40 + case "/test/test4": /* test 4 */
117.41 + case "/test/test5": /* test 5 */
117.42 printRequestURI(exchange);
117.43 break;
117.44 - case 5: /* test 6 */
117.45 + case "/test/test6": /* test 6 */
117.46 printRequestURI(exchange);
117.47 resHeaders = exchange.getResponseHeaders() ;
117.48 resHeaders.set("Location", "http://foo.bar/");
117.49 resHeaders.set("Connection", "close");
117.50 exchange.sendResponseHeaders(307, 0);
117.51 break;
117.52 - case 6: /* test 7 */
117.53 - case 7: /* test 8 */
117.54 + case "/test/test7": /* test 7 */
117.55 + case "/test/test8": /* test 8 */
117.56 printRequestURI(exchange);
117.57 reqbody = read(exchange.getRequestBody());
117.58 if (reqbody != null && !"".equals(reqbody)) {
117.59 @@ -116,7 +116,7 @@
117.60 resHeaders.set("Connection", "close");
117.61 exchange.sendResponseHeaders(200, 0);
117.62 break;
117.63 - case 8: /* test 9 */
117.64 + case "/test/test9": /* test 9 */
117.65 printRequestURI(exchange);
117.66 reqbody = read(exchange.getRequestBody());
117.67 if (!reqbody.equals(str1)) {
117.68 @@ -134,7 +134,7 @@
117.69 exchange.sendResponseHeaders(200, reqbody.length());
117.70 write(exchange.getResponseBody(), reqbody);
117.71 break;
117.72 - case 9: /* test10 */
117.73 + case "/test/test10": /* test10 */
117.74 printRequestURI(exchange);
117.75 InputStream is = exchange.getRequestBody();
117.76 String s = read (is, str1.length());
117.77 @@ -158,7 +158,7 @@
117.78 exchange.sendResponseHeaders(200, 0);
117.79 }
117.80 break;
117.81 - case 10: /* test11 */
117.82 + case "/test/test11": /* test11 */
117.83 printRequestURI(exchange);
117.84 is = exchange.getRequestBody();
117.85 s = read (is, str1.length());
117.86 @@ -182,7 +182,7 @@
117.87 exchange.sendResponseHeaders(200, 0);
117.88 }
117.89 break;
117.90 - case 11: /* test12 */
117.91 + case "/test/test12": /* test12 */
117.92 printRequestURI(exchange);
117.93 is = exchange.getRequestBody();
117.94
117.95 @@ -203,8 +203,8 @@
117.96 }
117.97 break;
117.98 }
117.99 + count ++;
117.100 exchange.close();
117.101 - count ++;
117.102 } catch (IOException e) {
117.103 e.printStackTrace();
117.104 }
118.1 --- a/test/sun/net/www/http/HttpClient/B6726695.java Fri Aug 06 12:52:07 2010 -0700
118.2 +++ b/test/sun/net/www/http/HttpClient/B6726695.java Mon Aug 09 16:02:19 2010 -0700
118.3 @@ -147,6 +147,8 @@
118.4 serverIgnore(s);
118.5 } catch (IOException e) {
118.6 e.printStackTrace();
118.7 + } finally {
118.8 + try { server.close(); } catch (IOException unused) {}
118.9 }
118.10 }
118.11
119.1 --- a/test/sun/net/www/http/HttpClient/MultiThreadTest.java Fri Aug 06 12:52:07 2010 -0700
119.2 +++ b/test/sun/net/www/http/HttpClient/MultiThreadTest.java Mon Aug 09 16:02:19 2010 -0700
119.3 @@ -100,11 +100,12 @@
119.4 }
119.5 } catch (Exception e) {
119.6 throw new RuntimeException (e.getMessage());
119.7 - }
119.8 - synchronized (threadlock) {
119.9 - threadCounter --;
119.10 - if (threadCounter == 0) {
119.11 - threadlock.notifyAll();
119.12 + } finally {
119.13 + synchronized (threadlock) {
119.14 + threadCounter --;
119.15 + if (threadCounter == 0) {
119.16 + threadlock.notifyAll();
119.17 + }
119.18 }
119.19 }
119.20 }
120.1 --- a/test/sun/net/www/http/HttpClient/ProxyTest.java Fri Aug 06 12:52:07 2010 -0700
120.2 +++ b/test/sun/net/www/http/HttpClient/ProxyTest.java Mon Aug 09 16:02:19 2010 -0700
120.3 @@ -47,7 +47,7 @@
120.4 private class HttpProxyServer extends Thread {
120.5 private ServerSocket server;
120.6 private int port;
120.7 - private boolean done = false;
120.8 + private volatile boolean done = false;
120.9 private String askedUrl;
120.10
120.11 /**
120.12 @@ -125,12 +125,8 @@
120.13 }
120.14 }
120.15
120.16 - public HttpProxyServer(int port) {
120.17 - this.port = port;
120.18 - }
120.19 -
120.20 - public HttpProxyServer() {
120.21 - this(0);
120.22 + public HttpProxyServer() throws IOException {
120.23 + server = new ServerSocket(0);
120.24 }
120.25
120.26 public int getPort() {
120.27 @@ -148,51 +144,49 @@
120.28 */
120.29 synchronized public void terminate() {
120.30 done = true;
120.31 + try { server.close(); } catch (IOException unused) {}
120.32 }
120.33
120.34 public void run() {
120.35 try {
120.36 - server = new ServerSocket(port);
120.37 Socket client;
120.38 while (!done) {
120.39 client = server.accept();
120.40 (new HttpProxyHandler(client)).start();
120.41 }
120.42 - server.close();
120.43 } catch (Exception e) {
120.44 + } finally {
120.45 + try { server.close(); } catch (IOException unused) {}
120.46 }
120.47 }
120.48 }
120.49
120.50 - public static void main(String[] args) {
120.51 + public static void main(String[] args) throws Exception {
120.52 ProxyTest test = new ProxyTest();
120.53 }
120.54
120.55 - public ProxyTest() {
120.56 + public ProxyTest() throws Exception {
120.57 + BufferedReader in = null;
120.58 String testURL = "ftp://anonymous:password@myhost.mydomain/index.html";
120.59 HttpProxyServer server = new HttpProxyServer();
120.60 try {
120.61 - server.start();
120.62 - int port = 0;
120.63 - while (port == 0) {
120.64 - Thread.sleep(500);
120.65 - port = server.getPort();
120.66 - }
120.67 + server.start();
120.68 + int port = server.getPort();
120.69
120.70 - System.setProperty("ftp.proxyHost","localhost");
120.71 - System.setProperty("ftp.proxyPort", String.valueOf(port));
120.72 - URL url = new URL(testURL);
120.73 - InputStream ins = url.openStream();
120.74 - BufferedReader in = new BufferedReader(new InputStreamReader(ins));
120.75 - String line;
120.76 - do {
120.77 - line = in.readLine();
120.78 - } while (line != null);
120.79 - in.close();
120.80 - server.terminate();
120.81 - server.interrupt();
120.82 + Proxy ftpProxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("localhost", port));
120.83 + URL url = new URL(testURL);
120.84 + InputStream ins = (url.openConnection(ftpProxy)).getInputStream();
120.85 + in = new BufferedReader(new InputStreamReader(ins));
120.86 + String line;
120.87 + do {
120.88 + line = in.readLine();
120.89 + } while (line != null);
120.90 + in.close();
120.91 } catch (Exception e) {
120.92 e.printStackTrace();
120.93 + } finally {
120.94 + server.terminate();
120.95 + try { in.close(); } catch (IOException unused) {}
120.96 }
120.97 /*
120.98 * If the URLs don't match, we've got a bug!
121.1 --- a/test/sun/net/www/http/KeepAliveCache/KeepAliveTimerThread.java Fri Aug 06 12:52:07 2010 -0700
121.2 +++ b/test/sun/net/www/http/KeepAliveCache/KeepAliveTimerThread.java Mon Aug 09 16:02:19 2010 -0700
121.3 @@ -91,9 +91,10 @@
121.4 out.flush();
121.5
121.6 s.close();
121.7 - server.close();
121.8 } catch (Exception e) {
121.9 e.printStackTrace();
121.10 + } finally {
121.11 + try { server.close(); } catch (IOException unused) {}
121.12 }
121.13 }
121.14 }
121.15 @@ -118,6 +119,8 @@
121.16 if (grp.activeCount() > 0) {
121.17 throw new RuntimeException("Keep-alive thread started in wrong thread group");
121.18 }
121.19 +
121.20 + grp.destroy();
121.21 }
121.22
121.23 }
122.1 --- a/test/sun/net/www/http/KeepAliveStream/KeepAliveStreamCloseWithWrongContentLength.java Fri Aug 06 12:52:07 2010 -0700
122.2 +++ b/test/sun/net/www/http/KeepAliveStream/KeepAliveStreamCloseWithWrongContentLength.java Mon Aug 09 16:02:19 2010 -0700
122.3 @@ -43,10 +43,6 @@
122.4 srv = s;
122.5 }
122.6
122.7 - Socket getSocket () {
122.8 - return (s);
122.9 - }
122.10 -
122.11 public void run() {
122.12 try {
122.13 s = srv.accept ();
122.14 @@ -57,7 +53,7 @@
122.15 is.read();
122.16 }
122.17 OutputStreamWriter ow =
122.18 - new OutputStreamWriter(s.getOutputStream());
122.19 + new OutputStreamWriter((os = s.getOutputStream()));
122.20 ow.write("HTTP/1.0 200 OK\n");
122.21
122.22 // Note: The client expects 10 bytes.
122.23 @@ -71,19 +67,16 @@
122.24 // Note: The (buggy) server only sends 9 bytes.
122.25 ow.write("123456789");
122.26 ow.flush();
122.27 - ow.close();
122.28 } catch (Exception e) {
122.29 + } finally {
122.30 + try {if (os != null) { os.close(); }} catch (IOException e) {}
122.31 }
122.32 }
122.33 }
122.34
122.35 - /*
122.36 - *
122.37 - */
122.38 -
122.39 - public static void main (String[] args) {
122.40 + public static void main (String[] args) throws Exception {
122.41 + ServerSocket serversocket = new ServerSocket (0);
122.42 try {
122.43 - ServerSocket serversocket = new ServerSocket (0);
122.44 int port = serversocket.getLocalPort ();
122.45 XServer server = new XServer (serversocket);
122.46 server.start ();
122.47 @@ -100,11 +93,12 @@
122.48 }
122.49 }
122.50 is.close();
122.51 - server.getSocket().close ();
122.52 } catch (IOException e) {
122.53 return;
122.54 } catch (NullPointerException e) {
122.55 throw new RuntimeException (e);
122.56 + } finally {
122.57 + if (serversocket != null) serversocket.close();
122.58 }
122.59 }
122.60 }
123.1 --- a/test/sun/net/www/httptest/HttpServer.java Fri Aug 06 12:52:07 2010 -0700
123.2 +++ b/test/sun/net/www/httptest/HttpServer.java Mon Aug 09 16:02:19 2010 -0700
123.3 @@ -188,6 +188,7 @@
123.4 sock.configureBlocking (false);
123.5 sock.register (selector, SelectionKey.OP_READ);
123.6 nconn ++;
123.7 + System.out.println("SERVER: new connection. chan[" + sock + "]");
123.8 if (nconn == maxconn) {
123.9 /* deregister */
123.10 listenerKey.cancel ();
123.11 @@ -197,7 +198,9 @@
123.12 if (key.isReadable()) {
123.13 boolean closed;
123.14 SocketChannel chan = (SocketChannel) key.channel();
123.15 + System.out.println("SERVER: connection readable. chan[" + chan + "]");
123.16 if (key.attachment() != null) {
123.17 + System.out.println("Server: comsume");
123.18 closed = consume (chan);
123.19 } else {
123.20 closed = read (chan, key);
123.21 @@ -375,6 +378,7 @@
123.22
123.23 synchronized void orderlyCloseChannel (SelectionKey key) throws IOException {
123.24 SocketChannel ch = (SocketChannel)key.channel ();
123.25 + System.out.println("SERVER: orderlyCloseChannel chan[" + ch + "]");
123.26 ch.socket().shutdownOutput();
123.27 key.attach (this);
123.28 clist.add (key);
123.29 @@ -382,6 +386,8 @@
123.30
123.31 synchronized void abortiveCloseChannel (SelectionKey key) throws IOException {
123.32 SocketChannel ch = (SocketChannel)key.channel ();
123.33 + System.out.println("SERVER: abortiveCloseChannel chan[" + ch + "]");
123.34 +
123.35 Socket s = ch.socket ();
123.36 s.setSoLinger (true, 0);
123.37 ch.close();
124.1 --- a/test/sun/net/www/protocol/http/DigestTest.java Fri Aug 06 12:52:07 2010 -0700
124.2 +++ b/test/sun/net/www/protocol/http/DigestTest.java Mon Aug 09 16:02:19 2010 -0700
124.3 @@ -95,10 +95,11 @@
124.4 os.write (reply.getBytes());
124.5 Thread.sleep (2000);
124.6 s1.close ();
124.7 - }
124.8 - catch (Exception e) {
124.9 + } catch (Exception e) {
124.10 System.out.println (e);
124.11 e.printStackTrace();
124.12 + } finally {
124.13 + try { s.close(); } catch (IOException unused) {}
124.14 }
124.15 }
124.16
124.17 @@ -204,15 +205,12 @@
124.18
124.19
124.20 public static void main(String[] args) throws Exception {
124.21 - int nLoops = 1;
124.22 - int nSize = 10;
124.23 - int port, n =0;
124.24 - byte b[] = new byte[nSize];
124.25 + int port;
124.26 DigestServer server;
124.27 ServerSocket sock;
124.28
124.29 try {
124.30 - sock = new ServerSocket (5000);
124.31 + sock = new ServerSocket (0);
124.32 port = sock.getLocalPort ();
124.33 }
124.34 catch (Exception e) {
124.35 @@ -225,21 +223,18 @@
124.36 boolean passed = false;
124.37
124.38 try {
124.39 -
124.40 Authenticator.setDefault (new MyAuthenticator ());
124.41 String s = "http://localhost:" + port + DigestServer.uri;
124.42 URL url = new URL(s);
124.43 java.net.URLConnection conURL = url.openConnection();
124.44
124.45 InputStream in = conURL.getInputStream();
124.46 - int c;
124.47 - while ((c = in.read ()) != -1) {
124.48 - }
124.49 + while (in.read () != -1) {}
124.50 in.close ();
124.51 - }
124.52 - catch(ProtocolException e) {
124.53 + } catch(ProtocolException e) {
124.54 passed = true;
124.55 }
124.56 +
124.57 if (!passed) {
124.58 throw new RuntimeException ("Expected a ProtocolException from wrong password");
124.59 }
125.1 --- a/test/sun/security/krb5/ConfPlusProp.java Fri Aug 06 12:52:07 2010 -0700
125.2 +++ b/test/sun/security/krb5/ConfPlusProp.java Mon Aug 09 16:02:19 2010 -0700
125.3 @@ -1,5 +1,5 @@
125.4 /*
125.5 - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
125.6 + * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
125.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
125.8 *
125.9 * This code is free software; you can redistribute it and/or modify it
125.10 @@ -24,6 +24,7 @@
125.11 * @test
125.12 * @bug 6857795
125.13 * @bug 6858589
125.14 + * @bug 6972005
125.15 * @summary krb5.conf ignored if system properties on realm and kdc are provided
125.16 */
125.17
125.18 @@ -96,7 +97,8 @@
125.19 System.setProperty("java.security.krb5.conf", "i-am-not-a file");
125.20 refresh();
125.21
125.22 - checkDefaultRealm(null);
125.23 + // Default realm might come from DNS
125.24 + //checkDefaultRealm(null);
125.25 check("R1", null);
125.26 check("R2", null);
125.27 check("R3", null);
126.1 --- a/test/sun/security/krb5/confplusprop.conf Fri Aug 06 12:52:07 2010 -0700
126.2 +++ b/test/sun/security/krb5/confplusprop.conf Mon Aug 09 16:02:19 2010 -0700
126.3 @@ -1,6 +1,7 @@
126.4 [libdefaults]
126.5 default_realm = R1
126.6 forwardable = well
126.7 +dns_lookup_realm = false
126.8
126.9 [realms]
126.10 R1 = {
127.1 --- a/test/sun/security/krb5/confplusprop2.conf Fri Aug 06 12:52:07 2010 -0700
127.2 +++ b/test/sun/security/krb5/confplusprop2.conf Mon Aug 09 16:02:19 2010 -0700
127.3 @@ -1,3 +1,6 @@
127.4 +[libdefaults]
127.5 +dns_lookup_realm = false
127.6 +
127.7 [realms]
127.8 R1 = {
127.9 kdc = k12
128.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
128.2 +++ b/test/sun/security/util/DerOutputStream/LocaleInTime.java Mon Aug 09 16:02:19 2010 -0700
128.3 @@ -0,0 +1,42 @@
128.4 +/*
128.5 + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
128.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
128.7 + *
128.8 + * This code is free software; you can redistribute it and/or modify it
128.9 + * under the terms of the GNU General Public License version 2 only, as
128.10 + * published by the Free Software Foundation.
128.11 + *
128.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
128.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
128.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
128.15 + * version 2 for more details (a copy is included in the LICENSE file that
128.16 + * accompanied this code).
128.17 + *
128.18 + * You should have received a copy of the GNU General Public License version
128.19 + * 2 along with this work; if not, write to the Free Software Foundation,
128.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
128.21 + *
128.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
128.23 + * or visit www.oracle.com if you need additional information or have any
128.24 + * questions.
128.25 + */
128.26 +
128.27 +/*
128.28 + * @test
128.29 + * @bug 6670889
128.30 + * @summary Keystore created under Hindi Locale causing ArrayIndexOutOfBoundsException
128.31 + * @run main/othervm -Duser.language=hi -Duser.region=IN LocaleInTime
128.32 + */
128.33 +
128.34 +import java.util.Date;
128.35 +import sun.security.util.DerOutputStream;
128.36 +import sun.security.util.DerValue;
128.37 +
128.38 +public class LocaleInTime {
128.39 + public static void main(String args[]) throws Exception {
128.40 + DerOutputStream out = new DerOutputStream();
128.41 + out.putUTCTime(new Date());
128.42 + DerValue val = new DerValue(out.toByteArray());
128.43 + System.out.println(val.getUTCTime());
128.44 + }
128.45 +}
129.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
129.2 +++ b/test/sun/security/x509/AlgorithmId/TurkishRegion.java Mon Aug 09 16:02:19 2010 -0700
129.3 @@ -0,0 +1,40 @@
129.4 +/*
129.5 + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
129.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
129.7 + *
129.8 + * This code is free software; you can redistribute it and/or modify it
129.9 + * under the terms of the GNU General Public License version 2 only, as
129.10 + * published by the Free Software Foundation.
129.11 + *
129.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
129.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
129.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
129.15 + * version 2 for more details (a copy is included in the LICENSE file that
129.16 + * accompanied this code).
129.17 + *
129.18 + * You should have received a copy of the GNU General Public License version
129.19 + * 2 along with this work; if not, write to the Free Software Foundation,
129.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
129.21 + *
129.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
129.23 + * or visit www.oracle.com if you need additional information or have any
129.24 + * questions.
129.25 + */
129.26 +
129.27 +/*
129.28 + * @test
129.29 + * @bug 6867345
129.30 + * @summary Turkish regional options cause NPE in
129.31 + * sun.security.x509.AlgorithmId.algOID
129.32 + * @run main/othervm -Duser.language=tr -Duser.region=TR TurkishRegion
129.33 + * @author Xuelei Fan
129.34 + */
129.35 +
129.36 +import sun.security.x509.*;
129.37 +
129.38 +public class TurkishRegion {
129.39 +
129.40 + public static void main(String[] args) throws Exception {
129.41 + AlgorithmId algId = AlgorithmId.get("PBEWITHMD5ANDDES");
129.42 + }
129.43 +}
130.1 --- a/test/sun/tools/common/ApplicationSetup.sh Fri Aug 06 12:52:07 2010 -0700
130.2 +++ b/test/sun/tools/common/ApplicationSetup.sh Mon Aug 09 16:02:19 2010 -0700
130.3 @@ -1,7 +1,7 @@
130.4 #!/bin/sh
130.5
130.6 #
130.7 -# Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
130.8 +# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
130.9 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
130.10 #
130.11 # This code is free software; you can redistribute it and/or modify it
130.12 @@ -24,54 +24,187 @@
130.13 #
130.14
130.15
130.16 -# Support function to start and stop a given application
130.17 +# Support functions to start, stop, wait for or kill a given SimpleApplication
130.18
130.19 -# Starts a given application as background process, usage:
130.20 -# startApplication <class> [args...]
130.21 +# Starts a given app as background process, usage:
130.22 +# startApplication <class> port-file [args...]
130.23 #
130.24 -# Waits for application to print something to indicate it is running
130.25 -# (and initialized). Output is directed to ${TESTCLASSES}/Application.out.
130.26 -# Sets $pid to be the process-id of the application.
130.27 -
130.28 +# The following variables are set:
130.29 +#
130.30 +# appJavaPid - application's Java pid
130.31 +# appOtherPid - pid associated with the app other than appJavaPid
130.32 +# appPidList - all pids associated with the app
130.33 +# appOutput - file containing stdout and stderr from the app
130.34 +#
130.35 +# Waits for at least one line of output from the app to indicate
130.36 +# that it is up and running.
130.37 +#
130.38 startApplication()
130.39 {
130.40 - OUTPUTFILE=${TESTCLASSES}/Application.out
130.41 - ${JAVA} $1 $2 $3 $4 $5 $6 > ${OUTPUTFILE} &
130.42 - pid="$!"
130.43 -
130.44 - # MKS creates an intermediate shell to launch ${JAVA} so
130.45 - # ${pid} is not the actual pid. We have put in a small sleep
130.46 - # to give the intermediate shell process time to launch the
130.47 - # "java" process.
130.48 - if [ "$OS" = "Windows" ]; then
130.49 - sleep 2
130.50 - if [ "${isCygwin}" = "true" ] ; then
130.51 - realpid=`ps -p ${pid} | tail -1 | awk '{print $4;}'`
130.52 - else
130.53 - realpid=`ps -o pid,ppid,comm|grep ${pid}|grep "java"|cut -c1-6`
130.54 - fi
130.55 - pid=${realpid}
130.56 - fi
130.57 -
130.58 - echo "Waiting for Application to initialize..."
130.59 - attempts=0
130.60 + appOutput="${TESTCLASSES}/Application.out"
130.61 +
130.62 + ${JAVA} -classpath "${TESTCLASSES}" "$@" > "$appOutput" 2>&1 &
130.63 + appJavaPid="$!"
130.64 + appOtherPid=
130.65 + appPidList="$appJavaPid"
130.66 +
130.67 + echo "INFO: waiting for $1 to initialize..."
130.68 + _cnt=0
130.69 while true; do
130.70 + # if the app doesn't start then the JavaTest/JTREG timeout will
130.71 + # kick in so this isn't really a endless loop
130.72 sleep 1
130.73 - out=`tail -1 ${OUTPUTFILE}`
130.74 - if [ ! -z "$out" ]; then
130.75 + out=`tail -1 "$appOutput"`
130.76 + if [ -n "$out" ]; then
130.77 + # we got some output from the app so it's running
130.78 break
130.79 fi
130.80 - attempts=`expr $attempts + 1`
130.81 - echo "Waiting $attempts second(s) ..."
130.82 + _cnt=`expr $_cnt + 1`
130.83 + echo "INFO: waited $_cnt second(s) ..."
130.84 done
130.85 + unset _cnt
130.86
130.87 - echo "Application is process $pid"
130.88 + if $isWindows; then
130.89 + # Windows requires special handling
130.90 + appOtherPid="$appJavaPid"
130.91 +
130.92 + if $isCygwin; then
130.93 + appJavaPid=`ps -p "$appOtherPid" \
130.94 + | sed -n '
130.95 + # See if $appOtherPid is in PID column; there are sometimes
130.96 + # non-blanks in column 1 (I and S observed so far)
130.97 + /^.'"${PATTERN_WS}${PATTERN_WS}*${appOtherPid}${PATTERN_WS}"'/{
130.98 + # strip PID column
130.99 + s/^.'"${PATTERN_WS}${PATTERN_WS}*${appOtherPid}${PATTERN_WS}${PATTERN_WS}"'*//
130.100 + # strip PPID column
130.101 + s/^[1-9][0-9]*'"${PATTERN_WS}${PATTERN_WS}"'*//
130.102 + # strip PGID column
130.103 + s/^[1-9][0-9]*'"${PATTERN_WS}${PATTERN_WS}"'*//
130.104 + # strip everything after WINPID column
130.105 + s/'"${PATTERN_WS}"'.*//
130.106 + p
130.107 + q
130.108 + }
130.109 + '`
130.110 + echo "INFO: Cygwin pid=$appOtherPid maps to Windows pid=$appJavaPid"
130.111 + else
130.112 + # show PID, PPID and COMM columns only
130.113 + appJavaPid=`ps -o pid,ppid,comm \
130.114 + | sed -n '
130.115 + # see if appOtherPid is in either PID or PPID columns
130.116 + /'"${PATTERN_WS}${appOtherPid}${PATTERN_WS}"'/{
130.117 + # see if this is a java command
130.118 + /java'"${PATTERN_EOL}"'/{
130.119 + # strip leading white space
130.120 + s/^'"${PATTERN_WS}${PATTERN_WS}"'*//
130.121 + # strip everything after the first word
130.122 + s/'"${PATTERN_WS}"'.*//
130.123 + # print the pid and we are done
130.124 + p
130.125 + q
130.126 + }
130.127 + }
130.128 + '`
130.129 + echo "INFO: MKS shell pid=$appOtherPid; Java pid=$appJavaPid"
130.130 + fi
130.131 +
130.132 + if [ -z "$appJavaPid" ]; then
130.133 + echo "ERROR: could not find app's Java pid." >&2
130.134 + killApplication
130.135 + exit 2
130.136 + fi
130.137 + appPidList="$appOtherPid $appJavaPid"
130.138 + fi
130.139 +
130.140 + echo "INFO: $1 is process $appJavaPid"
130.141 + echo "INFO: $1 output is in $appOutput"
130.142 }
130.143
130.144 -# Stops an application by invoking the given class and argument, usage:
130.145 -# stopApplication <class> <argument>
130.146 +
130.147 +# Stops a simple application by invoking ShutdownSimpleApplication
130.148 +# class with a specific port-file, usage:
130.149 +# stopApplication port-file
130.150 +#
130.151 +# Note: When this function returns, the SimpleApplication (or a subclass)
130.152 +# may still be running because the application has not yet reached the
130.153 +# shutdown check.
130.154 +#
130.155 stopApplication()
130.156 {
130.157 - $JAVA -classpath "${TESTCLASSES}" $1 $2
130.158 + $JAVA -classpath "${TESTCLASSES}" ShutdownSimpleApplication $1
130.159 }
130.160
130.161 +
130.162 +# Wait for a simple application to stop running.
130.163 +#
130.164 +waitForApplication() {
130.165 + if [ $isWindows = false ]; then
130.166 + # non-Windows is easy; just one process
130.167 + echo "INFO: waiting for $appJavaPid"
130.168 + set +e
130.169 + wait "$appJavaPid"
130.170 + set -e
130.171 +
130.172 + elif $isCygwin; then
130.173 + # Cygwin pid and not the Windows pid
130.174 + echo "INFO: waiting for $appOtherPid"
130.175 + set +e
130.176 + wait "$appOtherPid"
130.177 + set -e
130.178 +
130.179 + else # implied isMKS
130.180 + # MKS has intermediate shell and Java process
130.181 + echo "INFO: waiting for $appJavaPid"
130.182 +
130.183 + # appJavaPid can be empty if pid search in startApplication() failed
130.184 + if [ -n "$appJavaPid" ]; then
130.185 + # only need to wait for the Java process
130.186 + set +e
130.187 + wait "$appJavaPid"
130.188 + set -e
130.189 + fi
130.190 + fi
130.191 +}
130.192 +
130.193 +
130.194 +# Kills a simple application by sending a SIGTERM to the appropriate
130.195 +# process(es); on Windows SIGQUIT (-9) is used.
130.196 +#
130.197 +killApplication()
130.198 +{
130.199 + if [ $isWindows = false ]; then
130.200 + # non-Windows is easy; just one process
130.201 + echo "INFO: killing $appJavaPid"
130.202 + set +e
130.203 + kill -TERM "$appJavaPid" # try a polite SIGTERM first
130.204 + sleep 2
130.205 + # send SIGQUIT (-9) just in case SIGTERM didn't do it
130.206 + # but don't show any complaints
130.207 + kill -QUIT "$appJavaPid" > /dev/null 2>&1
130.208 + wait "$appJavaPid"
130.209 + set -e
130.210 +
130.211 + elif $isCygwin; then
130.212 + # Cygwin pid and not the Windows pid
130.213 + echo "INFO: killing $appOtherPid"
130.214 + set +e
130.215 + kill -9 "$appOtherPid"
130.216 + wait "$appOtherPid"
130.217 + set -e
130.218 +
130.219 + else # implied isMKS
130.220 + # MKS has intermediate shell and Java process
130.221 + echo "INFO: killing $appPidList"
130.222 + set +e
130.223 + kill -9 $appPidList
130.224 + set -e
130.225 +
130.226 + # appJavaPid can be empty if pid search in startApplication() failed
130.227 + if [ -n "$appJavaPid" ]; then
130.228 + # only need to wait for the Java process
130.229 + set +e
130.230 + wait "$appJavaPid"
130.231 + set -e
130.232 + fi
130.233 + fi
130.234 +}
131.1 --- a/test/sun/tools/common/CommonSetup.sh Fri Aug 06 12:52:07 2010 -0700
131.2 +++ b/test/sun/tools/common/CommonSetup.sh Mon Aug 09 16:02:19 2010 -0700
131.3 @@ -1,7 +1,7 @@
131.4 #!/bin/sh
131.5
131.6 #
131.7 -# Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
131.8 +# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
131.9 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
131.10 #
131.11 # This code is free software; you can redistribute it and/or modify it
131.12 @@ -24,56 +24,94 @@
131.13 #
131.14
131.15
131.16 -# Common setup for tool tests.
131.17 +# Common setup for tool tests and other tests that use jtools.
131.18 # Checks that TESTJAVA, TESTSRC, and TESTCLASSES environment variables are set.
131.19 -# Creates the following for use by the tool tests
131.20 -# JAVA java launcher
131.21 -# JSTACK jstack utility
131.22 -# JMAP jmap utility
131.23 -# JINFO jinfo utility
131.24 -# JHAT jhat utility
131.25 -# PS path separator (";" or ":")
131.26 -# OS operating system
131.27 +#
131.28 +# Creates the following constants for use by the caller:
131.29 +# JAVA - java launcher
131.30 +# JHAT - jhat utility
131.31 +# JINFO - jinfo utility
131.32 +# JMAP - jmap utility
131.33 +# JPS - jps utility
131.34 +# JSTACK - jstack utility
131.35 +# OS - operating system name
131.36 +# PATTERN_EOL - grep or sed end-of-line pattern
131.37 +# PATTERN_WS - grep or sed whitespace pattern
131.38 +# PS - path separator (";" or ":")
131.39 +#
131.40 +# Sets the following variables:
131.41 +#
131.42 +# isCygwin - true if environment is Cygwin
131.43 +# isMKS - true if environment is MKS
131.44 +# isLinux - true if OS is Linux
131.45 +# isSolaris - true if OS is Solaris
131.46 +# isWindows - true if OS is Windows
131.47
131.48
131.49 -if [ "${TESTJAVA}" = "" ]
131.50 -then
131.51 - echo "TESTJAVA not set. Test cannot execute. Failed."
131.52 +if [ -z "${TESTJAVA}" ]; then
131.53 + echo "ERROR: TESTJAVA not set. Test cannot execute. Failed."
131.54 exit 1
131.55 fi
131.56 -
131.57 -if [ "${TESTSRC}" = "" ]
131.58 -then
131.59 - echo "TESTSRC not set. Test cannot execute. Failed."
131.60 +
131.61 +if [ -z "${TESTSRC}" ]; then
131.62 + echo "ERROR: TESTSRC not set. Test cannot execute. Failed."
131.63 exit 1
131.64 fi
131.65 -
131.66 -if [ "${TESTCLASSES}" = "" ]
131.67 -then
131.68 - echo "TESTCLASSES not set. Test cannot execute. Failed."
131.69 +
131.70 +if [ -z "${TESTCLASSES}" ]; then
131.71 + echo "ERROR: TESTCLASSES not set. Test cannot execute. Failed."
131.72 exit 1
131.73 fi
131.74 -
131.75 +
131.76 +# only enable these after checking the expected incoming env variables
131.77 +set -eu
131.78 +
131.79 JAVA="${TESTJAVA}/bin/java"
131.80 +JHAT="${TESTJAVA}/bin/jhat"
131.81 +JINFO="${TESTJAVA}/bin/jinfo"
131.82 +JMAP="${TESTJAVA}/bin/jmap"
131.83 +JPS="${TESTJAVA}/bin/jps"
131.84 JSTACK="${TESTJAVA}/bin/jstack"
131.85 -JMAP="${TESTJAVA}/bin/jmap"
131.86 -JINFO="${TESTJAVA}/bin/jinfo"
131.87 -JHAT="${TESTJAVA}/bin/jhat"
131.88 +
131.89 +isCygwin=false
131.90 +isMKS=false
131.91 +isLinux=false
131.92 +isSolaris=false
131.93 +isUnknownOS=false
131.94 +isWindows=false
131.95
131.96 OS=`uname -s`
131.97
131.98 +# start with some UNIX like defaults
131.99 +PATTERN_EOL='$'
131.100 +# blank and tab
131.101 +PATTERN_WS='[ ]'
131.102 +PS=":"
131.103 +
131.104 case "$OS" in
131.105 + CYGWIN* )
131.106 + OS="Windows"
131.107 + PATTERN_EOL='[
131.108 ]*$'
131.109 + # blank and tab
131.110 + PATTERN_WS='[ \t]'
131.111 + isCygwin=true
131.112 + isWindows=true
131.113 + ;;
131.114 + Linux )
131.115 + OS="Linux"
131.116 + isLinux=true
131.117 + ;;
131.118 + SunOS )
131.119 + OS="Solaris"
131.120 + isSolaris=true
131.121 + ;;
131.122 Windows* )
131.123 + OS="Windows"
131.124 + PATTERN_EOL='[
131.125 ]*$'
131.126 PS=";"
131.127 - OS="Windows"
131.128 - ;;
131.129 - CYGWIN* )
131.130 - PS=";"
131.131 - OS="Windows"
131.132 - isCygwin=true
131.133 + isWindows=true
131.134 ;;
131.135 * )
131.136 - PS=":"
131.137 + isUnknownOS=true
131.138 ;;
131.139 esac
131.140 -
132.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
132.2 +++ b/test/sun/tools/common/CommonTests.sh Mon Aug 09 16:02:19 2010 -0700
132.3 @@ -0,0 +1,314 @@
132.4 +#!/bin/sh
132.5 +
132.6 +#
132.7 +# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
132.8 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
132.9 +#
132.10 +# This code is free software; you can redistribute it and/or modify it
132.11 +# under the terms of the GNU General Public License version 2 only, as
132.12 +# published by the Free Software Foundation.
132.13 +#
132.14 +# This code is distributed in the hope that it will be useful, but WITHOUT
132.15 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
132.16 +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
132.17 +# version 2 for more details (a copy is included in the LICENSE file that
132.18 +# accompanied this code).
132.19 +#
132.20 +# You should have received a copy of the GNU General Public License version
132.21 +# 2 along with this work; if not, write to the Free Software Foundation,
132.22 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
132.23 +#
132.24 +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
132.25 +# or visit www.oracle.com if you need additional information or have any
132.26 +# questions.
132.27 +#
132.28 +
132.29 +
132.30 +# @test
132.31 +# @bug 6964018
132.32 +# @summary Unit test for common tools infrastructure.
132.33 +#
132.34 +# @build SimpleApplication SleeperApplication ShutdownSimpleApplication
132.35 +# @run shell CommonTests.sh
132.36 +
132.37 +. ${TESTSRC}/CommonSetup.sh
132.38 +. ${TESTSRC}/ApplicationSetup.sh
132.39 +
132.40 +# hope for the best:
132.41 +status=0
132.42 +
132.43 +
132.44 +# Test program path constants from CommonSetup.sh:
132.45 +#
132.46 +for name in JAVA JHAT JINFO JMAP JPS JSTACK; do
132.47 + eval value=$`echo $name`
132.48 +
132.49 + echo "INFO: $name=$value"
132.50 + if [ -x "$value" ]; then
132.51 + echo "INFO: '$value' is executable."
132.52 + else
132.53 + echo "ERROR: '$value' is not executable." >&2
132.54 + status=1
132.55 + fi
132.56 +done
132.57 +
132.58 +
132.59 +# Display flag values from CommonSetup.sh:
132.60 +#
132.61 +for name in isCygwin isMKS isLinux isSolaris isUnknownOS isWindows; do
132.62 + eval value=$`echo $name`
132.63 + echo "INFO: flag $name=$value"
132.64 +done
132.65 +
132.66 +
132.67 +# Test OS constant from CommonSetup.sh:
132.68 +#
132.69 +if [ -z "$OS" ]; then
132.70 + echo "ERROR: OS constant cannot be empty." >&2
132.71 + status=1
132.72 +fi
132.73 +
132.74 +
132.75 +# Display the PATTERN_EOL value:
132.76 +#
132.77 +echo "INFO: PATTERN_EOL="`echo "$PATTERN_EOL" | od -c`
132.78 +
132.79 +
132.80 +# Test PATTERN_EOL with 'grep' for a regular line.
132.81 +#
132.82 +TESTOUT="${TESTCLASSES}/testout.grep_reg_line_eol"
132.83 +set +e
132.84 +echo 'regular line' | grep "line${PATTERN_EOL}" > "$TESTOUT"
132.85 +set -e
132.86 +if [ -s "$TESTOUT" ]; then
132.87 + echo "INFO: PATTERN_EOL works for regular line with grep."
132.88 +else
132.89 + echo "ERROR: PATTERN_EOL does not work for regular line with grep." >&2
132.90 + status=1
132.91 +fi
132.92 +
132.93 +
132.94 +if $isWindows; then
132.95 + # Test PATTERN_EOL with 'grep' for a CR line.
132.96 + #
132.97 + TESTOUT="${TESTCLASSES}/testout.grep_cr_line_eol"
132.98 + set +e
132.99 + echo 'CR line
132.100 ' | grep "line${PATTERN_EOL}" > "$TESTOUT"
132.101 + set -e
132.102 + if [ -s "$TESTOUT" ]; then
132.103 + echo "INFO: PATTERN_EOL works for CR line with grep."
132.104 + else
132.105 + echo "ERROR: PATTERN_EOL does not work for CR line with grep." >&2
132.106 + status=1
132.107 + fi
132.108 +fi
132.109 +
132.110 +
132.111 +# Test PATTERN_EOL with 'sed' for a regular line.
132.112 +#
132.113 +TESTOUT="${TESTCLASSES}/testout.sed_reg_line_eol"
132.114 +echo 'regular line' | sed -n "/line${PATTERN_EOL}/p" > "$TESTOUT"
132.115 +if [ -s "$TESTOUT" ]; then
132.116 + echo "INFO: PATTERN_EOL works for regular line with sed."
132.117 +else
132.118 + echo "ERROR: PATTERN_EOL does not work for regular line with sed." >&2
132.119 + status=1
132.120 +fi
132.121 +
132.122 +
132.123 +if $isWindows; then
132.124 + # Test PATTERN_EOL with 'sed' for a CR line.
132.125 + #
132.126 + TESTOUT="${TESTCLASSES}/testout.sed_cr_line_eol"
132.127 + echo 'CR line
132.128 ' | sed -n "/line${PATTERN_EOL}/p" > "$TESTOUT"
132.129 + if [ -s "$TESTOUT" ]; then
132.130 + echo "INFO: PATTERN_EOL works for CR line with sed."
132.131 + else
132.132 + echo "ERROR: PATTERN_EOL does not work for CR line with sed." >&2
132.133 + status=1
132.134 + fi
132.135 +fi
132.136 +
132.137 +
132.138 +# Display the PATTERN_WS value:
132.139 +#
132.140 +echo "INFO: PATTERN_WS="`echo "$PATTERN_WS" | od -c`
132.141 +
132.142 +
132.143 +# Test PATTERN_WS with 'grep' for a blank.
132.144 +#
132.145 +TESTOUT="${TESTCLASSES}/testout.grep_blank"
132.146 +set +e
132.147 +echo 'blank: ' | grep "$PATTERN_WS" > "$TESTOUT"
132.148 +set -e
132.149 +if [ -s "$TESTOUT" ]; then
132.150 + echo "INFO: PATTERN_WS works for blanks with grep."
132.151 +else
132.152 + echo "ERROR: PATTERN_WS does not work for blanks with grep." >&2
132.153 + status=1
132.154 +fi
132.155 +
132.156 +
132.157 +# Test PATTERN_WS with 'grep' for a tab.
132.158 +#
132.159 +TESTOUT="${TESTCLASSES}/testout.grep_tab"
132.160 +set +e
132.161 +echo 'tab: ' | grep "$PATTERN_WS" > "$TESTOUT"
132.162 +set -e
132.163 +if [ -s "$TESTOUT" ]; then
132.164 + echo "INFO: PATTERN_WS works for tabs with grep."
132.165 +else
132.166 + echo "ERROR: PATTERN_WS does not work for tabs with grep." >&2
132.167 + status=1
132.168 +fi
132.169 +
132.170 +
132.171 +# Test PATTERN_WS with 'sed' for a blank.
132.172 +#
132.173 +TESTOUT="${TESTCLASSES}/testout.sed_blank"
132.174 +echo 'blank: ' | sed -n "/$PATTERN_WS/p" > "$TESTOUT"
132.175 +if [ -s "$TESTOUT" ]; then
132.176 + echo "INFO: PATTERN_WS works for blanks with sed."
132.177 +else
132.178 + echo "ERROR: PATTERN_WS does not work for blanks with sed." >&2
132.179 + status=1
132.180 +fi
132.181 +
132.182 +
132.183 +# Test PATTERN_WS with 'sed' for a tab.
132.184 +#
132.185 +TESTOUT="${TESTCLASSES}/testout.sed_tab"
132.186 +echo 'tab: ' | sed -n "/$PATTERN_WS/p" > "$TESTOUT"
132.187 +if [ -s "$TESTOUT" ]; then
132.188 + echo "INFO: PATTERN_WS works for tabs with sed."
132.189 +else
132.190 + echo "ERROR: PATTERN_WS does not work for tabs with sed." >&2
132.191 + status=1
132.192 +fi
132.193 +
132.194 +
132.195 +# Test startApplication and use PORTFILE for coordination
132.196 +# The app sleeps for 30 seconds.
132.197 +#
132.198 +PORTFILE="${TESTCLASSES}"/shutdown.port
132.199 +startApplication SleeperApplication "${PORTFILE}" 30
132.200 +
132.201 +
132.202 +# Test appJavaPid in "ps" cmd output.
132.203 +#
132.204 +TESTOUT="${TESTCLASSES}/testout.ps_app"
132.205 +set +e
132.206 +if $isCygwin; then
132.207 + # On Cygwin, appJavaPid is the Windows pid for the Java process
132.208 + # and appOtherPid is the Cygwin pid for the Java process.
132.209 + ps -p "$appOtherPid" \
132.210 + | grep "${PATTERN_WS}${appJavaPid}${PATTERN_WS}" > "$TESTOUT"
132.211 +else
132.212 + # output only pid and comm columns to avoid mismatches
132.213 + ps -eo pid,comm \
132.214 + | grep "^${PATTERN_WS}*${appJavaPid}${PATTERN_WS}" > "$TESTOUT"
132.215 +fi
132.216 +set -e
132.217 +if [ -s "$TESTOUT" ]; then
132.218 + echo "INFO: begin appJavaPid=$appJavaPid in 'ps' cmd output:"
132.219 + cat "$TESTOUT"
132.220 + echo "INFO: end appJavaPid=$appJavaPid in 'ps' cmd output."
132.221 +else
132.222 + echo "ERROR: 'ps' cmd should show appJavaPid=$appJavaPid." >&2
132.223 + status=1
132.224 +fi
132.225 +
132.226 +if [ -n "$appOtherPid" ]; then
132.227 + # Test appOtherPid in "ps" cmd output, if we have one.
132.228 + #
132.229 + TESTOUT="${TESTCLASSES}/testout.ps_other"
132.230 + set +e
132.231 + if $isCygwin; then
132.232 + ps -p "$appOtherPid" \
132.233 + | grep "${PATTERN_WS}${appOtherPid}${PATTERN_WS}" > "$TESTOUT"
132.234 + else
132.235 + # output only pid and comm columns to avoid mismatches
132.236 + ps -eo pid,comm \
132.237 + | grep "^${PATTERN_WS}*${appOtherPid}${PATTERN_WS}" > "$TESTOUT"
132.238 + fi
132.239 + set -e
132.240 + if [ -s "$TESTOUT" ]; then
132.241 + echo "INFO: begin appOtherPid=$appOtherPid in 'ps' cmd output:"
132.242 + cat "$TESTOUT"
132.243 + echo "INFO: end appOtherPid=$appOtherPid in 'ps' cmd output."
132.244 + else
132.245 + echo "ERROR: 'ps' cmd should show appOtherPid=$appOtherPid." >&2
132.246 + status=1
132.247 + fi
132.248 +fi
132.249 +
132.250 +
132.251 +# Test stopApplication and PORTFILE for coordination
132.252 +#
132.253 +stopApplication "${PORTFILE}"
132.254 +
132.255 +
132.256 +# Test application still running after stopApplication.
132.257 +#
132.258 +# stopApplication just lets the app know that it can stop, but the
132.259 +# app might still be doing work. This test just demonstrates that
132.260 +# fact and doesn't fail if the app is already done.
132.261 +#
132.262 +TESTOUT="${TESTCLASSES}/testout.after_stop"
132.263 +set +e
132.264 +if $isCygwin; then
132.265 + # On Cygwin, appJavaPid is the Windows pid for the Java process
132.266 + # and appOtherPid is the Cygwin pid for the Java process.
132.267 + ps -p "$appOtherPid" \
132.268 + | grep "${PATTERN_WS}${appJavaPid}${PATTERN_WS}" > "$TESTOUT"
132.269 +else
132.270 + # output only pid and comm columns to avoid mismatches
132.271 + ps -eo pid,comm \
132.272 + | grep "^${PATTERN_WS}*${appJavaPid}${PATTERN_WS}" > "$TESTOUT"
132.273 +fi
132.274 +set -e
132.275 +if [ -s "$TESTOUT" ]; then
132.276 + echo "INFO: it is okay for appJavaPid=$appJavaPid to still be running" \
132.277 + "after stopApplication() is called."
132.278 + echo "INFO: begin 'after_stop' output:"
132.279 + cat "$TESTOUT"
132.280 + echo "INFO: end 'after_stop' output."
132.281 +fi
132.282 +
132.283 +
132.284 +# Test waitForApplication
132.285 +#
132.286 +# The app might already be gone so this function shouldn't generate
132.287 +# a fatal error in either call.
132.288 +#
132.289 +waitForApplication
132.290 +
132.291 +if [ $isWindows = false ]; then
132.292 + # Windows can recycle pids quickly so we can't use this test there
132.293 + TESTOUT="${TESTCLASSES}/testout.after_kill"
132.294 + set +e
132.295 + # output only pid and comm columns to avoid mismatches
132.296 + ps -eo pid,comm \
132.297 + | grep "^${PATTERN_WS}*${appJavaPid}${PATTERN_WS}" > "$TESTOUT"
132.298 + set -e
132.299 + if [ -s "$TESTOUT" ]; then
132.300 + echo "ERROR: 'ps' cmd should not show appJavaPid." >&2
132.301 + echo "ERROR: begin 'after_kill' output:" >&2
132.302 + cat "$TESTOUT" >&2
132.303 + echo "ERROR: end 'after_kill' output." >&2
132.304 + status=1
132.305 + else
132.306 + echo "INFO: 'ps' cmd does not show appJavaPid after" \
132.307 + "waitForApplication() is called."
132.308 + fi
132.309 +fi
132.310 +
132.311 +
132.312 +# Test killApplication
132.313 +#
132.314 +# The app is already be gone so this function shouldn't generate
132.315 +# a fatal error.
132.316 +#
132.317 +killApplication
132.318 +
132.319 +exit $status
133.1 --- a/test/sun/tools/common/ShutdownSimpleApplication.java Fri Aug 06 12:52:07 2010 -0700
133.2 +++ b/test/sun/tools/common/ShutdownSimpleApplication.java Mon Aug 09 16:02:19 2010 -0700
133.3 @@ -1,5 +1,5 @@
133.4 /*
133.5 - * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
133.6 + * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
133.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
133.8 *
133.9 * This code is free software; you can redistribute it and/or modify it
133.10 @@ -22,10 +22,13 @@
133.11 */
133.12
133.13 /*
133.14 + * Used to shutdown SimpleApplication (or a subclass). The argument to
133.15 + * this class is the name of a file that contains the TCP port number
133.16 + * on which SimpleApplication (or a subclass) is listening.
133.17 *
133.18 - *
133.19 - * Used to shutdown SimpleApplication. The argument to this class is
133.20 - * the TCP port number where SimpleApplication is listening.
133.21 + * Note: When this program returns, the SimpleApplication (or a subclass)
133.22 + * may still be running because the application has not yet reached the
133.23 + * shutdown check.
133.24 */
133.25 import java.net.Socket;
133.26 import java.net.InetSocketAddress;
133.27 @@ -35,6 +38,11 @@
133.28 public class ShutdownSimpleApplication {
133.29 public static void main(String args[]) throws Exception {
133.30
133.31 + if (args.length != 1) {
133.32 + throw new RuntimeException("Usage: ShutdownSimpleApplication" +
133.33 + " port-file");
133.34 + }
133.35 +
133.36 // read the (TCP) port number from the given file
133.37
133.38 File f = new File(args[0]);
133.39 @@ -42,21 +50,27 @@
133.40 byte b[] = new byte[8];
133.41 int n = fis.read(b);
133.42 if (n < 1) {
133.43 - throw new RuntimeException("Empty file");
133.44 + throw new RuntimeException("Empty port-file");
133.45 }
133.46 fis.close();
133.47
133.48 String str = new String(b, 0, n, "UTF-8");
133.49 - System.out.println("Port number of application is: " + str);
133.50 + System.out.println("INFO: Port number of SimpleApplication: " + str);
133.51 int port = Integer.parseInt(str);
133.52
133.53 // Now connect to the port (which will shutdown application)
133.54
133.55 - System.out.println("Connecting to port " + port +
133.56 - " to shutdown Application ...");
133.57 + System.out.println("INFO: Connecting to port " + port +
133.58 + " to shutdown SimpleApplication ...");
133.59 + System.out.flush();
133.60
133.61 Socket s = new Socket();
133.62 s.connect( new InetSocketAddress(port) );
133.63 s.close();
133.64 +
133.65 + System.out.println("INFO: done connecting to SimpleApplication.");
133.66 + System.out.flush();
133.67 +
133.68 + System.exit(0);
133.69 }
133.70 }
134.1 --- a/test/sun/tools/common/SimpleApplication.java Fri Aug 06 12:52:07 2010 -0700
134.2 +++ b/test/sun/tools/common/SimpleApplication.java Mon Aug 09 16:02:19 2010 -0700
134.3 @@ -1,5 +1,5 @@
134.4 /*
134.5 - * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
134.6 + * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
134.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
134.8 *
134.9 * This code is free software; you can redistribute it and/or modify it
134.10 @@ -22,10 +22,12 @@
134.11 */
134.12
134.13 /*
134.14 + * A simple application used by unit tests. The first argument to this
134.15 + * class is the name of a file to which a TCP port number can be written.
134.16 *
134.17 - *
134.18 - * A simple application used for tool unit tests. It does nothing else
134.19 - * bind to a TCP port and wait for a shutdown message.
134.20 + * By default, this class does nothing other than bind to a TCP port,
134.21 + * write the TCP port number to a file, and wait for an incoming connection
134.22 + * in order to complete the application shutdown protocol.
134.23 */
134.24 import java.net.Socket;
134.25 import java.net.ServerSocket;
134.26 @@ -33,25 +35,86 @@
134.27 import java.io.FileOutputStream;
134.28
134.29 public class SimpleApplication {
134.30 - public static void main(String args[]) throws Exception {
134.31 + private static SimpleApplication myApp; // simple app or a subclass
134.32 + private static String myAppName; // simple app name
134.33 + private static int myPort; // coordination port #
134.34 + private static ServerSocket mySS; // coordination socket
134.35 +
134.36 + // protected so a subclass can extend it; not public so creation is
134.37 + // limited.
134.38 + protected SimpleApplication() {
134.39 + // save simple app (or subclass) name for messages
134.40 + myAppName = getClass().getName();
134.41 + }
134.42 +
134.43 + // return the simple application (or a subclass)
134.44 + final public static SimpleApplication getMyApp() {
134.45 + return myApp;
134.46 + }
134.47 +
134.48 + // set the simple application (for use by a subclass)
134.49 + final public static void setMyApp(SimpleApplication _myApp) {
134.50 + myApp = _myApp;
134.51 + }
134.52 +
134.53 + // execute the application finish protocol
134.54 + final public void doMyAppFinish(String[] args) throws Exception {
134.55 + System.out.println("INFO: " + myAppName + " is waiting on port: " +
134.56 + myPort);
134.57 + System.out.flush();
134.58 +
134.59 + // wait for test harness to connect
134.60 + Socket s = mySS.accept();
134.61 + s.close();
134.62 + mySS.close();
134.63 +
134.64 + System.out.println("INFO: " + myAppName + " is shutting down.");
134.65 + System.out.flush();
134.66 + }
134.67 +
134.68 + // execute the application start protocol
134.69 + final public void doMyAppStart(String[] args) throws Exception {
134.70 + if (args.length < 1) {
134.71 + throw new RuntimeException("Usage: " + myAppName +
134.72 + " port-file [arg(s)]");
134.73 + }
134.74 +
134.75 // bind to a random port
134.76 - ServerSocket ss = new ServerSocket(0);
134.77 - int port = ss.getLocalPort();
134.78 + mySS = new ServerSocket(0);
134.79 + myPort = mySS.getLocalPort();
134.80
134.81 // Write the port number to the given file
134.82 File f = new File(args[0]);
134.83 FileOutputStream fos = new FileOutputStream(f);
134.84 - fos.write( Integer.toString(port).getBytes("UTF-8") );
134.85 + fos.write( Integer.toString(myPort).getBytes("UTF-8") );
134.86 fos.close();
134.87
134.88 - System.out.println("Application waiting on port: " + port);
134.89 + System.out.println("INFO: " + myAppName + " created socket on port: " +
134.90 + myPort);
134.91 + System.out.flush();
134.92 + }
134.93 +
134.94 + // execute the app work (subclass can override this)
134.95 + public void doMyAppWork(String[] args) throws Exception {
134.96 + }
134.97 +
134.98 + public static void main(String[] args) throws Exception {
134.99 + if (myApp == null) {
134.100 + // create myApp since a subclass hasn't done so
134.101 + myApp = new SimpleApplication();
134.102 + }
134.103 +
134.104 + myApp.doMyAppStart(args); // do the app start protocol
134.105 +
134.106 + System.out.println("INFO: " + myAppName + " is calling doMyAppWork()");
134.107 + System.out.flush();
134.108 + myApp.doMyAppWork(args); // do the app work
134.109 + System.out.println("INFO: " + myAppName + " returned from" +
134.110 + " doMyAppWork()");
134.111 System.out.flush();
134.112
134.113 - // wait for test harness to connect
134.114 - Socket s = ss.accept();
134.115 - s.close();
134.116 - ss.close();
134.117 + myApp.doMyAppFinish(args); // do the app finish protocol
134.118
134.119 - System.out.println("Application shutdown.");
134.120 + System.exit(0);
134.121 }
134.122 }
135.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
135.2 +++ b/test/sun/tools/common/SleeperApplication.java Mon Aug 09 16:02:19 2010 -0700
135.3 @@ -0,0 +1,59 @@
135.4 +/*
135.5 + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
135.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
135.7 + *
135.8 + * This code is free software; you can redistribute it and/or modify it
135.9 + * under the terms of the GNU General Public License version 2 only, as
135.10 + * published by the Free Software Foundation.
135.11 + *
135.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
135.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
135.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
135.15 + * version 2 for more details (a copy is included in the LICENSE file that
135.16 + * accompanied this code).
135.17 + *
135.18 + * You should have received a copy of the GNU General Public License version
135.19 + * 2 along with this work; if not, write to the Free Software Foundation,
135.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
135.21 + *
135.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
135.23 + * or visit www.oracle.com if you need additional information or have any
135.24 + * questions.
135.25 + */
135.26 +
135.27 +/*
135.28 + * An example subclass of SimpleApplication that illustrates how to
135.29 + * override the doMyAppWork() method.
135.30 + */
135.31 +
135.32 +public class SleeperApplication extends SimpleApplication {
135.33 + public static int DEFAULT_SLEEP_TIME = 60; // time is in seconds
135.34 +
135.35 + // execute the sleeper app work
135.36 + public void doMyAppWork(String[] args) throws Exception {
135.37 + int sleep_time = DEFAULT_SLEEP_TIME;
135.38 +
135.39 + // args[0] is the port-file
135.40 + if (args.length < 2) {
135.41 + System.out.println("INFO: using default sleep time of "
135.42 + + sleep_time + " seconds.");
135.43 + } else {
135.44 + try {
135.45 + sleep_time = Integer.parseInt(args[1]);
135.46 + } catch (NumberFormatException nfe) {
135.47 + throw new RuntimeException("Error: '" + args[1] +
135.48 + "': is not a valid seconds value.");
135.49 + }
135.50 + }
135.51 +
135.52 + Thread.sleep(sleep_time * 1000); // our "work" is to sleep
135.53 + }
135.54 +
135.55 + public static void main(String[] args) throws Exception {
135.56 + SleeperApplication myApp = new SleeperApplication();
135.57 +
135.58 + SimpleApplication.setMyApp(myApp);
135.59 +
135.60 + SimpleApplication.main(args);
135.61 + }
135.62 +}
136.1 --- a/test/sun/tools/jhat/ParseTest.sh Fri Aug 06 12:52:07 2010 -0700
136.2 +++ b/test/sun/tools/jhat/ParseTest.sh Mon Aug 09 16:02:19 2010 -0700
136.3 @@ -1,7 +1,7 @@
136.4 #!/bin/sh
136.5
136.6 #
136.7 -# Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
136.8 +# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
136.9 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
136.10 #
136.11 # This code is free software; you can redistribute it and/or modify it
136.12 @@ -32,7 +32,11 @@
136.13 # @run shell ParseTest.sh
136.14
136.15 . ${TESTSRC}/../common/CommonSetup.sh
136.16 -. ${TESTSRC}/../common/ApplicationSetup.sh
136.17 +
136.18 +# all return statuses are checked in this test
136.19 +set +e
136.20 +
136.21 +failed=0
136.22
136.23 DUMPFILE="minimal.bin"
136.24
137.1 --- a/test/sun/tools/jinfo/Basic.sh Fri Aug 06 12:52:07 2010 -0700
137.2 +++ b/test/sun/tools/jinfo/Basic.sh Mon Aug 09 16:02:19 2010 -0700
137.3 @@ -1,7 +1,7 @@
137.4 #!/bin/sh
137.5
137.6 #
137.7 -# Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
137.8 +# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
137.9 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
137.10 #
137.11 # This code is free software; you can redistribute it and/or modify it
137.12 @@ -35,53 +35,57 @@
137.13 . ${TESTSRC}/../common/CommonSetup.sh
137.14 . ${TESTSRC}/../common/ApplicationSetup.sh
137.15
137.16 -# Start application (send output to shutdown.port)
137.17 +# Start application and use PORTFILE for coordination
137.18 PORTFILE="${TESTCLASSES}"/shutdown.port
137.19 -startApplication \
137.20 - -classpath "${TESTCLASSES}" SimpleApplication "${PORTFILE}"
137.21 +startApplication SimpleApplication "${PORTFILE}"
137.22 +
137.23 +# all return statuses are checked in this test
137.24 +set +e
137.25
137.26 failed=0
137.27
137.28 -if [ "$OS" != "Windows" ]; then
137.29 +if [ $isWindows = false ]; then
137.30 # -sysprops option
137.31 - ${JINFO} -sysprops $pid
137.32 + ${JINFO} -sysprops $appJavaPid
137.33 if [ $? != 0 ]; then failed=1; fi
137.34
137.35 # -flags option
137.36 - ${JINFO} -flags $pid
137.37 + ${JINFO} -flags $appJavaPid
137.38 if [ $? != 0 ]; then failed=1; fi
137.39
137.40 # no option
137.41 - ${JINFO} $pid
137.42 + ${JINFO} $appJavaPid
137.43 if [ $? != 0 ]; then failed=1; fi
137.44
137.45 fi
137.46
137.47
137.48 # -flag option
137.49 -${JINFO} -flag +PrintGC $pid
137.50 +${JINFO} -flag +PrintGC $appJavaPid
137.51 if [ $? != 0 ]; then failed=1; fi
137.52
137.53 -${JINFO} -flag -PrintGC $pid
137.54 +${JINFO} -flag -PrintGC $appJavaPid
137.55 if [ $? != 0 ]; then failed=1; fi
137.56
137.57 -${JINFO} -flag PrintGC $pid
137.58 +${JINFO} -flag PrintGC $appJavaPid
137.59 if [ $? != 0 ]; then failed=1; fi
137.60
137.61 -if [ "$OS" = "SunOS" ]; then
137.62 +if $isSolaris; then
137.63
137.64 - ${JINFO} -flag +ExtendedDTraceProbes $pid
137.65 + ${JINFO} -flag +ExtendedDTraceProbes $appJavaPid
137.66 if [ $? != 0 ]; then failed=1; fi
137.67
137.68 - ${JINFO} -flag -ExtendedDTraceProbes $pid
137.69 + ${JINFO} -flag -ExtendedDTraceProbes $appJavaPid
137.70 if [ $? != 0 ]; then failed=1; fi
137.71
137.72 - ${JINFO} -flag ExtendedDTraceProbes $pid
137.73 + ${JINFO} -flag ExtendedDTraceProbes $appJavaPid
137.74 if [ $? != 0 ]; then failed=1; fi
137.75
137.76 fi
137.77
137.78 -stopApplication ShutdownSimpleApplication "${PORTFILE}"
137.79 +set -e
137.80 +
137.81 +stopApplication "${PORTFILE}"
137.82 +waitForApplication
137.83
137.84 exit $failed
137.85 -
138.1 --- a/test/sun/tools/jmap/Basic.sh Fri Aug 06 12:52:07 2010 -0700
138.2 +++ b/test/sun/tools/jmap/Basic.sh Mon Aug 09 16:02:19 2010 -0700
138.3 @@ -1,7 +1,7 @@
138.4 #!/bin/sh
138.5
138.6 #
138.7 -# Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
138.8 +# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
138.9 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
138.10 #
138.11 # This code is free software; you can redistribute it and/or modify it
138.12 @@ -35,24 +35,25 @@
138.13 . ${TESTSRC}/../common/CommonSetup.sh
138.14 . ${TESTSRC}/../common/ApplicationSetup.sh
138.15
138.16 -# Start application (send output to shutdown.port)
138.17 +# Start application and use PORTFILE for coordination
138.18 PORTFILE="${TESTCLASSES}"/shutdown.port
138.19 -startApplication \
138.20 - -classpath "${TESTCLASSES}" SimpleApplication "${PORTFILE}"
138.21 +startApplication SimpleApplication "${PORTFILE}"
138.22 +
138.23 +# all return statuses are checked in this test
138.24 +set +e
138.25
138.26 failed=0
138.27
138.28 # -histo[:live] option
138.29 -${JMAP} -histo $pid
138.30 +${JMAP} -histo $appJavaPid
138.31 if [ $? != 0 ]; then failed=1; fi
138.32
138.33 -${JMAP} -histo:live $pid
138.34 +${JMAP} -histo:live $appJavaPid
138.35 if [ $? != 0 ]; then failed=1; fi
138.36
138.37 # -dump option
138.38 -p=`expr $pid`
138.39 -DUMPFILE="java_pid${p}.hprof"
138.40 -${JMAP} -dump:format=b,file=${DUMPFILE} $pid
138.41 +DUMPFILE="java_pid${appJavaPid}.hprof"
138.42 +${JMAP} -dump:format=b,file=${DUMPFILE} $appJavaPid
138.43 if [ $? != 0 ]; then failed=1; fi
138.44
138.45 # check that heap dump is parsable
138.46 @@ -63,7 +64,7 @@
138.47 rm ${DUMPFILE}
138.48
138.49 # -dump:live option
138.50 -${JMAP} -dump:live,format=b,file=${DUMPFILE} $pid
138.51 +${JMAP} -dump:live,format=b,file=${DUMPFILE} $appJavaPid
138.52 if [ $? != 0 ]; then failed=1; fi
138.53
138.54 # check that heap dump is parsable
138.55 @@ -71,9 +72,11 @@
138.56 if [ $? != 0 ]; then failed=1; fi
138.57
138.58 # dump file is large so remove it
138.59 -rm ${DUMPFILE}
138.60 +rm -f ${DUMPFILE}
138.61
138.62 -stopApplication ShutdownSimpleApplication "${PORTFILE}"
138.63 +set -e
138.64 +
138.65 +stopApplication "${PORTFILE}"
138.66 +waitForApplication
138.67
138.68 exit $failed
138.69 -
139.1 --- a/test/sun/tools/jrunscript/common.sh Fri Aug 06 12:52:07 2010 -0700
139.2 +++ b/test/sun/tools/jrunscript/common.sh Mon Aug 09 16:02:19 2010 -0700
139.3 @@ -1,5 +1,5 @@
139.4 #
139.5 -# Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
139.6 +# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
139.7 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
139.8 #
139.9 # This code is free software; you can redistribute it and/or modify it
139.10 @@ -43,10 +43,20 @@
139.11 Windows_*)
139.12 PS=";"
139.13 FS="\\"
139.14 + # MKS diff deals with trailing CRs automatically
139.15 + golden_diff="diff"
139.16 + ;;
139.17 + CYGWIN*)
139.18 + PS=":"
139.19 + FS="/"
139.20 + # Cygwin diff needs to be told to ignore trailing CRs
139.21 + golden_diff="diff --strip-trailing-cr"
139.22 ;;
139.23 *)
139.24 PS=":"
139.25 FS="/"
139.26 + # Assume any other platform doesn't have the trailing CR stuff
139.27 + golden_diff="diff"
139.28 ;;
139.29 esac
139.30
140.1 --- a/test/sun/tools/jrunscript/jrunscript-eTest.sh Fri Aug 06 12:52:07 2010 -0700
140.2 +++ b/test/sun/tools/jrunscript/jrunscript-eTest.sh Mon Aug 09 16:02:19 2010 -0700
140.3 @@ -1,7 +1,7 @@
140.4 #!/bin/sh
140.5
140.6 #
140.7 -# Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
140.8 +# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
140.9 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
140.10 #
140.11 # This code is free software; you can redistribute it and/or modify it
140.12 @@ -42,7 +42,7 @@
140.13 rm -f jrunscript-eTest.out 2>/dev/null
140.14 ${JRUNSCRIPT} -e "println('hello')" > jrunscript-eTest.out 2>&1
140.15
140.16 -diff jrunscript-eTest.out ${TESTSRC}/dash-e.out
140.17 +$golden_diff jrunscript-eTest.out ${TESTSRC}/dash-e.out
140.18 if [ $? != 0 ]
140.19 then
140.20 echo "Output of jrunscript -e differ from expected output. Failed."
140.21 @@ -55,7 +55,7 @@
140.22 rm -f jrunscript-eTest.out 2>/dev/null
140.23 ${JRUNSCRIPT} -l js -e "println('hello')" > jrunscript-eTest.out 2>&1
140.24
140.25 -diff jrunscript-eTest.out ${TESTSRC}/dash-e.out
140.26 +$golden_diff jrunscript-eTest.out ${TESTSRC}/dash-e.out
140.27 if [ $? != 0 ]
140.28 then
140.29 echo "Output of jrunscript -e differ from expected output. Failed."
141.1 --- a/test/sun/tools/jrunscript/jrunscript-fTest.sh Fri Aug 06 12:52:07 2010 -0700
141.2 +++ b/test/sun/tools/jrunscript/jrunscript-fTest.sh Mon Aug 09 16:02:19 2010 -0700
141.3 @@ -1,7 +1,7 @@
141.4 #!/bin/sh
141.5
141.6 #
141.7 -# Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
141.8 +# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
141.9 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
141.10 #
141.11 # This code is free software; you can redistribute it and/or modify it
141.12 @@ -42,7 +42,7 @@
141.13 rm -f jrunscript-fTest.out 2>/dev/null
141.14 ${JRUNSCRIPT} -f ${TESTSRC}/hello.js > jrunscript-fTest.out 2>&1
141.15
141.16 -diff jrunscript-fTest.out ${TESTSRC}/dash-f.out
141.17 +$golden_diff jrunscript-fTest.out ${TESTSRC}/dash-f.out
141.18 if [ $? != 0 ]
141.19 then
141.20 echo "Output of jrunscript -f differ from expected output. Failed."
141.21 @@ -56,7 +56,7 @@
141.22 rm -f jrunscript-fTest.out 2>/dev/null
141.23 ${JRUNSCRIPT} -l js -f ${TESTSRC}/hello.js > jrunscript-fTest.out 2>&1
141.24
141.25 -diff jrunscript-fTest.out ${TESTSRC}/dash-f.out
141.26 +$golden_diff jrunscript-fTest.out ${TESTSRC}/dash-f.out
141.27 if [ $? != 0 ]
141.28 then
141.29 echo "Output of jrunscript -f differ from expected output. Failed."
142.1 --- a/test/sun/tools/jrunscript/jrunscriptTest.sh Fri Aug 06 12:52:07 2010 -0700
142.2 +++ b/test/sun/tools/jrunscript/jrunscriptTest.sh Mon Aug 09 16:02:19 2010 -0700
142.3 @@ -1,7 +1,7 @@
142.4 #!/bin/sh
142.5
142.6 #
142.7 -# Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
142.8 +# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
142.9 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
142.10 #
142.11 # This code is free software; you can redistribute it and/or modify it
142.12 @@ -49,7 +49,7 @@
142.13 new java.lang.Runnable() { run: function() { println('I am runnable'); }}.run();
142.14 EOF
142.15
142.16 -diff jrunscriptTest.out ${TESTSRC}/repl.out
142.17 +$golden_diff jrunscriptTest.out ${TESTSRC}/repl.out
142.18 if [ $? != 0 ]
142.19 then
142.20 echo "Output of jrunscript session differ from expected output. Failed."
142.21 @@ -67,7 +67,7 @@
142.22 new java.lang.Runnable() { run: function() { println('I am runnable'); }}.run();
142.23 EOF
142.24
142.25 -diff jrunscriptTest.out ${TESTSRC}/repl.out
142.26 +$golden_diff jrunscriptTest.out ${TESTSRC}/repl.out
142.27 if [ $? != 0 ]
142.28 then
142.29 echo "Output of jrunscript -l js differ from expected output. Failed."
143.1 --- a/test/sun/tools/jstack/Basic.sh Fri Aug 06 12:52:07 2010 -0700
143.2 +++ b/test/sun/tools/jstack/Basic.sh Mon Aug 09 16:02:19 2010 -0700
143.3 @@ -1,7 +1,7 @@
143.4 #!/bin/sh
143.5
143.6 #
143.7 -# Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
143.8 +# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
143.9 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
143.10 #
143.11 # This code is free software; you can redistribute it and/or modify it
143.12 @@ -35,22 +35,26 @@
143.13 . ${TESTSRC}/../common/CommonSetup.sh
143.14 . ${TESTSRC}/../common/ApplicationSetup.sh
143.15
143.16 -# Start application (send output to shutdown.port)
143.17 +# Start application and use PORTFILE for coordination
143.18 PORTFILE="${TESTCLASSES}"/shutdown.port
143.19 -startApplication \
143.20 - -classpath "${TESTCLASSES}" SimpleApplication "${PORTFILE}"
143.21 +startApplication SimpleApplication "${PORTFILE}"
143.22 +
143.23 +# all return statuses are checked in this test
143.24 +set +e
143.25
143.26 failed=0
143.27
143.28 # normal
143.29 -$JSTACK $pid 2>&1
143.30 +$JSTACK $appJavaPid 2>&1
143.31 if [ $? != 0 ]; then failed=1; fi
143.32
143.33 # long
143.34 -$JSTACK -l $pid 2>&1
143.35 +$JSTACK -l $appJavaPid 2>&1
143.36 if [ $? != 0 ]; then failed=1; fi
143.37
143.38 -stopApplication ShutdownSimpleApplication "${PORTFILE}"
143.39 +set -e
143.40 +
143.41 +stopApplication "${PORTFILE}"
143.42 +waitForApplication
143.43
143.44 exit $failed
143.45 -