diff --git a/src/share/classes/com/sun/security/ntlm/Client.java b/src/share/classes/com/sun/security/ntlm/Client.java
index aed8f37084dd795dab914844246fed0dc846d1dc..f4be91aa3fa36fce1ee7d75541e34b28eb26e4cb 100644
--- a/src/share/classes/com/sun/security/ntlm/Client.java
+++ b/src/share/classes/com/sun/security/ntlm/Client.java
@@ -69,14 +69,16 @@ public final class Client extends NTLM {
* This method does not make any modification to this parameter, it neither
* needs to access the content of this parameter after this method call,
* so you are free to modify or nullify this parameter after this call.
- * @throws NullPointerException if {@code username} or {@code password} is null.
- * @throws NTLMException if {@code version} is illegal
+ * @throws NTLMException if {@code username} or {@code password} is null,
+ * or {@code version} is illegal.
+ *
*/
public Client(String version, String hostname, String username,
String domain, char[] password) throws NTLMException {
super(version);
if ((username == null || password == null)) {
- throw new NullPointerException("username/password cannot be null");
+ throw new NTLMException(NTLMException.PROTOCOL,
+ "username/password cannot be null");
}
this.hostname = hostname;
this.username = username;
@@ -117,13 +119,13 @@ public final class Client extends NTLM {
* @param nonce random 8-byte array to be used in message generation,
* must not be null except for original NTLM v1
* @return the message generated
- * @throws NullPointerException if {@code type2} or {@code nonce} is null
- * for NTLM v1.
- * @throws NTLMException if the incoming message is invalid
+ * @throws NTLMException if the incoming message is invalid, or
+ * {@code nonce} is null for NTLM v1.
*/
public byte[] type3(byte[] type2, byte[] nonce) throws NTLMException {
if (type2 == null || (v != Version.NTLM && nonce == null)) {
- throw new NullPointerException("type2 and nonce cannot be null");
+ throw new NTLMException(NTLMException.PROTOCOL,
+ "type2 and nonce cannot be null");
}
debug("NTLM Client: Type 2 received\n");
debug(type2);
diff --git a/src/share/classes/com/sun/security/ntlm/NTLMException.java b/src/share/classes/com/sun/security/ntlm/NTLMException.java
index 279fd2623884bf4b7da7608f17062955a7c39c34..7275b4ae6d962d9e0aff32baaec4a7434ddb1154 100644
--- a/src/share/classes/com/sun/security/ntlm/NTLMException.java
+++ b/src/share/classes/com/sun/security/ntlm/NTLMException.java
@@ -65,6 +65,11 @@ public final class NTLMException extends GeneralSecurityException {
*/
public final static int BAD_VERSION = 5;
+ /**
+ * Protocol errors.
+ */
+ public final static int PROTOCOL = 6;
+
private int errorCode;
/**
diff --git a/src/share/classes/com/sun/security/ntlm/Server.java b/src/share/classes/com/sun/security/ntlm/Server.java
index 1871375a4b7f50394b5847115e25eabc2f9a54e0..bc23d473fb18c9b7b2c9d64b9c13d34627db1301 100644
--- a/src/share/classes/com/sun/security/ntlm/Server.java
+++ b/src/share/classes/com/sun/security/ntlm/Server.java
@@ -62,12 +62,13 @@ public abstract class Server extends NTLM {
* is selected, authentication succeeds if one of LM (or LMv2) or
* NTLM (or NTLMv2) is verified.
* @param domain the domain, must not be null
- * @throws NullPointerException if {@code domain} is null.
+ * @throws NTLMException if {@code domain} is null.
*/
public Server(String version, String domain) throws NTLMException {
super(version);
if (domain == null) {
- throw new NullPointerException("domain cannot be null");
+ throw new NTLMException(NTLMException.PROTOCOL,
+ "domain cannot be null");
}
this.allVersion = (version == null);
this.domain = domain;
@@ -80,12 +81,13 @@ public abstract class Server extends NTLM {
* @param nonce the random 8-byte array to be used in message generation,
* must not be null
* @return the message generated
- * @throws NullPointerException if type1 or nonce is null
- * @throws NTLMException if the incoming message is invalid
+ * @throws NTLMException if the incoming message is invalid, or
+ * {@code nonce} is null.
*/
- public byte[] type2(byte[] type1, byte[] nonce) {
+ public byte[] type2(byte[] type1, byte[] nonce) throws NTLMException {
if (nonce == null) {
- throw new NullPointerException("nonce cannot be null");
+ throw new NTLMException(NTLMException.PROTOCOL,
+ "nonce cannot be null");
}
debug("NTLM Server: Type 1 received\n");
if (type1 != null) debug(type1);
@@ -105,13 +107,14 @@ public abstract class Server extends NTLM {
* @param type3 the incoming Type3 message from client, must not be null
* @param nonce the same nonce provided in {@link #type2}, must not be null
* @return username and hostname of the client in a byte array
- * @throws NullPointerException if {@code type3} or {@code nonce} is null
- * @throws NTLMException if the incoming message is invalid
+ * @throws NTLMException if the incoming message is invalid, or
+ * {@code nonce} is null.
*/
public String[] verify(byte[] type3, byte[] nonce)
throws NTLMException {
if (type3 == null || nonce == null) {
- throw new NullPointerException("type1 or nonce cannot be null");
+ throw new NTLMException(NTLMException.PROTOCOL,
+ "type1 or nonce cannot be null");
}
debug("NTLM Server: Type 3 received\n");
if (type3 != null) debug(type3);
diff --git a/src/share/classes/com/sun/security/sasl/ntlm/FactoryImpl.java b/src/share/classes/com/sun/security/sasl/ntlm/FactoryImpl.java
index 6ee1b66f968e1c4bc78a8f034a3652fd2452b96a..af234bce5a9d4740193097396e944423bcdb424d 100644
--- a/src/share/classes/com/sun/security/sasl/ntlm/FactoryImpl.java
+++ b/src/share/classes/com/sun/security/sasl/ntlm/FactoryImpl.java
@@ -70,6 +70,12 @@ SaslServerFactory{
if (mechs[i].equals("NTLM") &&
PolicyUtils.checkPolicy(mechPolicies[0], props)) {
+ if (cbh == null) {
+ throw new SaslException(
+ "Callback handler with support for " +
+ "RealmCallback, NameCallback, and PasswordCallback " +
+ "required");
+ }
return new NTLMClient(mechs[i], authorizationId,
protocol, serverName, props, cbh);
}
@@ -98,9 +104,9 @@ SaslServerFactory{
}
if (cbh == null) {
throw new SaslException(
- "Callback handler with support for AuthorizeCallback, "+
- "RealmCallback, NameCallback, and PasswordCallback " +
- "required");
+ "Callback handler with support for " +
+ "RealmCallback, NameCallback, and PasswordCallback " +
+ "required");
}
return new NTLMServer(mech, protocol, serverName, props, cbh);
}
diff --git a/src/share/classes/com/sun/security/sasl/ntlm/NTLMClient.java b/src/share/classes/com/sun/security/sasl/ntlm/NTLMClient.java
index f015f02aa8cf635699e849e18d905e0e1051d46f..dbb1d610d317e4faaf4dd9d283b2a83b85ec1d6c 100644
--- a/src/share/classes/com/sun/security/sasl/ntlm/NTLMClient.java
+++ b/src/share/classes/com/sun/security/sasl/ntlm/NTLMClient.java
@@ -107,7 +107,7 @@ final class NTLMClient implements SaslClient {
* @param protocol non-null for Sasl, useless for NTLM
* @param serverName non-null for Sasl, but can be null for NTLM
* @param props can be null
- * @param cbh can be null for Sasl, but will throw NPE for NTLM
+ * @param cbh can be null for Sasl, already null-checked in factory
* @throws SaslException
*/
NTLMClient(String mech, String authzid, String protocol, String serverName,
@@ -166,7 +166,7 @@ final class NTLMClient implements SaslClient {
pcb.getPassword());
} catch (NTLMException ne) {
throw new SaslException(
- "NTLM: Invalid version string: " + version, ne);
+ "NTLM: client creation failure", ne);
}
}
@@ -183,17 +183,20 @@ final class NTLMClient implements SaslClient {
@Override
public byte[] unwrap(byte[] incoming, int offset, int len)
throws SaslException {
- throw new UnsupportedOperationException("Not supported.");
+ throw new IllegalStateException("Not supported.");
}
@Override
public byte[] wrap(byte[] outgoing, int offset, int len)
throws SaslException {
- throw new UnsupportedOperationException("Not supported.");
+ throw new IllegalStateException("Not supported.");
}
@Override
public Object getNegotiatedProperty(String propName) {
+ if (!isComplete()) {
+ throw new IllegalStateException("authentication not complete");
+ }
switch (propName) {
case Sasl.QOP:
return "auth";
diff --git a/src/share/classes/com/sun/security/sasl/ntlm/NTLMServer.java b/src/share/classes/com/sun/security/sasl/ntlm/NTLMServer.java
index 1a76a77052d4d2e8fbce574244363810fd9f5790..916f7691b5708bd2753dedda3d0dd886b95da7d0 100644
--- a/src/share/classes/com/sun/security/sasl/ntlm/NTLMServer.java
+++ b/src/share/classes/com/sun/security/sasl/ntlm/NTLMServer.java
@@ -106,7 +106,7 @@ final class NTLMServer implements SaslServer {
* @param serverName not null for Sasl, can be null in NTLM. If non-null,
* might be used as domain if not provided in props
* @param props can be null
- * @param cbh can be null for Sasl, but will throw NPE in auth for NTLM
+ * @param cbh can be null for Sasl, already null-checked in factory
* @throws SaslException
*/
NTLMServer(String mech, String protocol, String serverName,
@@ -132,7 +132,7 @@ final class NTLMServer implements SaslServer {
domain = serverName;
}
if (domain == null) {
- throw new NullPointerException("Domain must be provided as"
+ throw new SaslException("Domain must be provided as"
+ " the serverName argument or in props");
}
@@ -159,7 +159,7 @@ final class NTLMServer implements SaslServer {
};
} catch (NTLMException ne) {
throw new SaslException(
- "NTLM: Invalid version string: " + version, ne);
+ "NTLM: server creation failure", ne);
}
nonce = new byte[8];
}
@@ -182,8 +182,8 @@ final class NTLMServer implements SaslServer {
hostname = out[1];
return null;
}
- } catch (GeneralSecurityException ex) {
- throw new SaslException("", ex);
+ } catch (NTLMException ex) {
+ throw new SaslException("NTLM: generate response failure", ex);
}
}
@@ -194,23 +194,29 @@ final class NTLMServer implements SaslServer {
@Override
public String getAuthorizationID() {
+ if (!isComplete()) {
+ throw new IllegalStateException("authentication not complete");
+ }
return authzId;
}
@Override
public byte[] unwrap(byte[] incoming, int offset, int len)
throws SaslException {
- throw new UnsupportedOperationException("Not supported yet.");
+ throw new IllegalStateException("Not supported yet.");
}
@Override
public byte[] wrap(byte[] outgoing, int offset, int len)
throws SaslException {
- throw new UnsupportedOperationException("Not supported yet.");
+ throw new IllegalStateException("Not supported yet.");
}
@Override
public Object getNegotiatedProperty(String propName) {
+ if (!isComplete()) {
+ throw new IllegalStateException("authentication not complete");
+ }
switch (propName) {
case Sasl.QOP:
return "auth";
diff --git a/src/share/classes/com/sun/servicetag/SunConnection.java b/src/share/classes/com/sun/servicetag/SunConnection.java
index a28fbf9ed9b2227499336f0b41afcd1810ad1bf6..91ea977c54b7682fdc60c50f3693ce80a63ab677 100644
--- a/src/share/classes/com/sun/servicetag/SunConnection.java
+++ b/src/share/classes/com/sun/servicetag/SunConnection.java
@@ -101,10 +101,7 @@ class SunConnection {
return new URL(registerURL);
} catch (MalformedURLException ex) {
// should never reach here
- InternalError x =
- new InternalError(ex.getMessage());
- x.initCause(ex);
- throw x;
+ throw new InternalError(ex.getMessage(), ex);
}
}
@@ -171,9 +168,7 @@ class SunConnection {
try {
BrowserSupport.browse(url.toURI());
} catch (URISyntaxException ex) {
- InternalError x = new InternalError("Error in registering: " + ex.getMessage());
- x.initCause(ex);
- throw x;
+ throw new InternalError("Error in registering: " + ex.getMessage(), ex);
} catch (IllegalArgumentException ex) {
if (Util.isVerbose()) {
ex.printStackTrace();
@@ -232,9 +227,7 @@ class SunConnection {
return (returnCode == HttpURLConnection.HTTP_OK);
} catch (MalformedURLException me) {
// should never reach here
- InternalError x = new InternalError("Error in registering: " + me.getMessage());
- x.initCause(me);
- throw x;
+ throw new InternalError("Error in registering: " + me.getMessage(), me);
} catch (Exception ioe) {
// SocketTimeoutException, IOException or UnknownHostException
if (Util.isVerbose()) {
@@ -262,10 +255,9 @@ class SunConnection {
BrowserSupport.browse(registerPage.toURI());
} catch (FileNotFoundException ex) {
// should never reach here
- InternalError x =
- new InternalError("Error in launching " + registerPage + ": " + ex.getMessage());
- x.initCause(ex);
- throw x;
+ throw new InternalError(
+ "Error in launching " + registerPage + ": " + ex.getMessage()
+ , ex);
} catch (IllegalArgumentException ex) {
if (Util.isVerbose()) {
ex.printStackTrace();
diff --git a/src/share/classes/java/io/BufferedReader.java b/src/share/classes/java/io/BufferedReader.java
index 51a60731480d86c9ea093e0fb7867f1cd1a9026c..556abb2a403a4d5d326d75a7fefc61f822a8bdf1 100644
--- a/src/share/classes/java/io/BufferedReader.java
+++ b/src/share/classes/java/io/BufferedReader.java
@@ -514,9 +514,12 @@ public class BufferedReader extends Reader {
synchronized (lock) {
if (in == null)
return;
- in.close();
- in = null;
- cb = null;
+ try {
+ in.close();
+ } finally {
+ in = null;
+ cb = null;
+ }
}
}
}
diff --git a/src/share/classes/java/io/BufferedWriter.java b/src/share/classes/java/io/BufferedWriter.java
index 220a47edf20ffd6c75699f56e894de1289550f93..83a467e726618293fae3694d5301e776715218e3 100644
--- a/src/share/classes/java/io/BufferedWriter.java
+++ b/src/share/classes/java/io/BufferedWriter.java
@@ -255,15 +255,15 @@ public class BufferedWriter extends Writer {
}
}
+ @SuppressWarnings("try")
public void close() throws IOException {
synchronized (lock) {
if (out == null) {
return;
}
- try {
+ try (Writer w = out) {
flushBuffer();
} finally {
- out.close();
out = null;
cb = null;
}
diff --git a/src/share/classes/java/io/Closeable.java b/src/share/classes/java/io/Closeable.java
index 7f3cc8dcd0c507faba1819cb2a1b9da0b19bfe52..e771989615e84efc3946870b6263324c89e17298 100644
--- a/src/share/classes/java/io/Closeable.java
+++ b/src/share/classes/java/io/Closeable.java
@@ -42,6 +42,12 @@ public interface Closeable extends AutoCloseable {
* with it. If the stream is already closed then invoking this
* method has no effect.
*
+ *
As noted in {@link AutoCloseable#close()}, cases where the
+ * close may fail require careful attention. It is strongly advised
+ * to relinquish the underlying resources and to internally
+ * mark the {@code Closeable} as closed, prior to throwing
+ * the {@code IOException}.
+ *
* @throws IOException if an I/O error occurs
*/
public void close() throws IOException;
diff --git a/src/share/classes/java/io/FilterOutputStream.java b/src/share/classes/java/io/FilterOutputStream.java
index 6de18f00d16b5751dc23a79a00533f0bab03e366..209e63b77c9837f2f117a162f245097b25be3d8c 100644
--- a/src/share/classes/java/io/FilterOutputStream.java
+++ b/src/share/classes/java/io/FilterOutputStream.java
@@ -152,11 +152,10 @@ class FilterOutputStream extends OutputStream {
* @see java.io.FilterOutputStream#flush()
* @see java.io.FilterOutputStream#out
*/
+ @SuppressWarnings("try")
public void close() throws IOException {
- try {
- flush();
- } catch (IOException ignored) {
+ try (OutputStream ostream = out) {
+ flush();
}
- out.close();
}
}
diff --git a/src/share/classes/java/lang/AutoCloseable.java b/src/share/classes/java/lang/AutoCloseable.java
index 54ecda38fed2e9d213be88532e1a5455543082f2..d928a9d0f1cb8a6dc3182cf475e98b0b59bed3ae 100644
--- a/src/share/classes/java/lang/AutoCloseable.java
+++ b/src/share/classes/java/lang/AutoCloseable.java
@@ -43,6 +43,15 @@ public interface AutoCloseable {
* throw more specific exceptions, or to throw no exception at all
* if the close operation cannot fail.
*
+ *
Cases where the close operation may fail require careful
+ * attention by implementers. It is strongly advised to relinquish
+ * the underlying resources and to internally mark the
+ * resource as closed, prior to throwing the exception. The {@code
+ * close} method is unlikely to be invoked more than once and so
+ * this ensures that the resources are released in a timely manner.
+ * Furthermore it reduces problems that could arise when the resource
+ * wraps, or is wrapped, by another resource.
+ *
*
Implementers of this interface are also strongly advised
* to not have the {@code close} method throw {@link
* InterruptedException}.
diff --git a/src/share/classes/java/lang/InternalError.java b/src/share/classes/java/lang/InternalError.java
index f49e9c24724647880f93fc74e186f33f5020be65..8d33821ff3ccf349cd337abf6f9df2aea556d437 100644
--- a/src/share/classes/java/lang/InternalError.java
+++ b/src/share/classes/java/lang/InternalError.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1994, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -32,8 +32,7 @@ package java.lang;
* @author unascribed
* @since JDK1.0
*/
-public
-class InternalError extends VirtualMachineError {
+public class InternalError extends VirtualMachineError {
private static final long serialVersionUID = -9062593416125562365L;
/**
@@ -47,9 +46,45 @@ class InternalError extends VirtualMachineError {
* Constructs an InternalError with the specified
* detail message.
*
- * @param s the detail message.
+ * @param message the detail message.
*/
- public InternalError(String s) {
- super(s);
+ public InternalError(String message) {
+ super(message);
}
+
+
+ /**
+ * Constructs an {@code InternalError} with the specified detail
+ * message and cause.
Note that the detail message associated
+ * with {@code cause} is not automatically incorporated in
+ * this error's detail message.
+ *
+ * @param message the detail message (which is saved for later retrieval
+ * by the {@link #getMessage()} method).
+ * @param cause the cause (which is saved for later retrieval by the
+ * {@link #getCause()} method). (A {@code null} value is
+ * permitted, and indicates that the cause is nonexistent or
+ * unknown.)
+ * @since 1.8
+ */
+ public InternalError(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * Constructs an {@code InternalError} with the specified cause
+ * and a detail message of {@code (cause==null ? null :
+ * cause.toString())} (which typically contains the class and
+ * detail message of {@code cause}).
+ *
+ * @param cause the cause (which is saved for later retrieval by the
+ * {@link #getCause()} method). (A {@code null} value is
+ * permitted, and indicates that the cause is nonexistent or
+ * unknown.)
+ * @since 1.8
+ */
+ public InternalError(Throwable cause) {
+ super(cause);
+ }
+
}
diff --git a/src/share/classes/java/lang/System.java b/src/share/classes/java/lang/System.java
index e4adf8d0bc5f4ee7a8fc32d620cd8c85484a1a3d..5c33dd08fca5b6a259f6618949fd263f257c5aa2 100644
--- a/src/share/classes/java/lang/System.java
+++ b/src/share/classes/java/lang/System.java
@@ -632,6 +632,7 @@ public final class System {
*
*
On UNIX systems, it returns {@code "\n"}; on Microsoft
* Windows systems it returns {@code "\r\n"}.
+ * @since 1.7
*/
public static String lineSeparator() {
return lineSeparator;
diff --git a/src/share/classes/java/lang/VirtualMachineError.java b/src/share/classes/java/lang/VirtualMachineError.java
index 2843147bff2d7506a4e1d89c0235113efa3c5fb4..e86d89642cb290358204af5cc937589132faa27e 100644
--- a/src/share/classes/java/lang/VirtualMachineError.java
+++ b/src/share/classes/java/lang/VirtualMachineError.java
@@ -1,9 +1,9 @@
/*
- * Copyright (c) 1995, 1997, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
+ * under the terms of the GNU General Public License version 2 only, asP
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
@@ -33,8 +33,9 @@ package java.lang;
* @author Frank Yellin
* @since JDK1.0
*/
-abstract public
-class VirtualMachineError extends Error {
+abstract public class VirtualMachineError extends Error {
+ private static final long serialVersionUID = 4161983926571568670L;
+
/**
* Constructs a VirtualMachineError with no detail message.
*/
@@ -46,9 +47,43 @@ class VirtualMachineError extends Error {
* Constructs a VirtualMachineError with the specified
* detail message.
*
- * @param s the detail message.
+ * @param message the detail message.
+ */
+ public VirtualMachineError(String message) {
+ super(message);
+ }
+
+ /**
+ * Constructs a {@code VirtualMachineError} with the specified
+ * detail message and cause.
Note that the detail message
+ * associated with {@code cause} is not automatically
+ * incorporated in this error's detail message.
+ *
+ * @param message the detail message (which is saved for later retrieval
+ * by the {@link #getMessage()} method).
+ * @param cause the cause (which is saved for later retrieval by the
+ * {@link #getCause()} method). (A {@code null} value is
+ * permitted, and indicates that the cause is nonexistent or
+ * unknown.)
+ * @since 1.8
+ */
+ public VirtualMachineError(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * Constructs an a {@code VirtualMachineError} with the specified
+ * cause and a detail message of {@code (cause==null ? null :
+ * cause.toString())} (which typically contains the class and
+ * detail message of {@code cause}).
+ *
+ * @param cause the cause (which is saved for later retrieval by the
+ * {@link #getCause()} method). (A {@code null} value is
+ * permitted, and indicates that the cause is nonexistent or
+ * unknown.)
+ * @since 1.8
*/
- public VirtualMachineError(String s) {
- super(s);
+ public VirtualMachineError(Throwable cause) {
+ super(cause);
}
}
diff --git a/src/share/classes/java/net/HttpCookie.java b/src/share/classes/java/net/HttpCookie.java
index 34e60126912c9c1fe55c61657715d620a97b145f..a932a5fef1000330eef5bc0b46063dd96500542d 100644
--- a/src/share/classes/java/net/HttpCookie.java
+++ b/src/share/classes/java/net/HttpCookie.java
@@ -748,10 +748,14 @@ public final class HttpCookie implements Cloneable {
&& (embeddedDotInDomain == -1 || embeddedDotInDomain == domain.length() - 1))
return false;
- // if the host name contains no dot and the domain name is .local
+ // if the host name contains no dot and the domain name
+ // is .local or host.local
int firstDotInHost = host.indexOf('.');
- if (firstDotInHost == -1 && isLocalDomain)
+ if (firstDotInHost == -1 &&
+ (isLocalDomain ||
+ domain.equalsIgnoreCase(host + ".local"))) {
return true;
+ }
int domainLength = domain.length();
int lengthDiff = host.length() - domainLength;
diff --git a/src/share/classes/java/util/Observable.java b/src/share/classes/java/util/Observable.java
index a208303ad94e76a3bd6ac4dbb64a6c7394202154..7104071ff622639a6dab0293bc818eaa88d51749 100644
--- a/src/share/classes/java/util/Observable.java
+++ b/src/share/classes/java/util/Observable.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1994, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -44,7 +44,7 @@ package java.util;
* notifications on separate threads, or may guarantee that their
* subclass follows this order, as they choose.
*
- * Note that this notification mechanism is has nothing to do with threads
+ * Note that this notification mechanism has nothing to do with threads
* and is completely separate from the wait and notify
* mechanism of class Object.
*
diff --git a/src/share/classes/java/util/prefs/Preferences.java b/src/share/classes/java/util/prefs/Preferences.java
index 94461838926d52a86159417b75682267da26c522..fe20a74b6f0384c9a8f7cc3497429a474ec7e725 100644
--- a/src/share/classes/java/util/prefs/Preferences.java
+++ b/src/share/classes/java/util/prefs/Preferences.java
@@ -256,11 +256,9 @@ public abstract class Preferences {
.getContextClassLoader())
.newInstance();
} catch (Exception e) {
- InternalError error = new InternalError(
+ throw new InternalError(
"Can't instantiate Preferences factory "
- + factoryName);
- error.initCause(e);
- throw error;
+ + factoryName, e);
}
}
}
@@ -299,11 +297,9 @@ public abstract class Preferences {
return (PreferencesFactory)
Class.forName(platformFactory, false, null).newInstance();
} catch (Exception e) {
- InternalError error = new InternalError(
+ throw new InternalError(
"Can't instantiate platform default Preferences factory "
- + platformFactory);
- error.initCause(e);
- throw error;
+ + platformFactory, e);
}
}
diff --git a/src/share/classes/javax/swing/RepaintManager.java b/src/share/classes/javax/swing/RepaintManager.java
index 5a6e15e57b690bb3663261ed49002081225865d1..59749fcad08cf38182e840cafa1d75f86fec7027 100644
--- a/src/share/classes/javax/swing/RepaintManager.java
+++ b/src/share/classes/javax/swing/RepaintManager.java
@@ -758,6 +758,11 @@ public class RepaintManager
for(i=0 ; i < count ; i++) {
dirtyComponent = roots.get(i);
rect = tmpDirtyComponents.get(dirtyComponent);
+ // Sometimes when RepaintManager is changed during the painting
+ // we may get null here, see #6995769 for details
+ if (rect == null) {
+ continue;
+ }
localBoundsH = dirtyComponent.getHeight();
localBoundsW = dirtyComponent.getWidth();
diff --git a/src/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java b/src/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java
index 06675413cad12cc519aee5e07470ec836be94479..f06d6d7715523626aa04b8dc4b980142acd60100 100644
--- a/src/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java
+++ b/src/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java
@@ -2167,7 +2167,7 @@ public class MetalLookAndFeel extends BasicLookAndFeel
/**
* Returns a {@code LayoutStyle} implementing the Java look and feel
* design guidelines as specified at
- * http://java.sun.com/products/jlf/ed2/book/HIG.Visual2.html.
+ * http://www.oracle.com/technetwork/java/hig-136467.html.
*
* @return LayoutStyle implementing the Java look and feel design
* guidelines
diff --git a/src/share/classes/sun/font/FontManagerFactory.java b/src/share/classes/sun/font/FontManagerFactory.java
index b9f4a6f129889a40681b0cbe52beb36a01dca890..20618e286cb413e5442a0379033307bf5501d846 100644
--- a/src/share/classes/sun/font/FontManagerFactory.java
+++ b/src/share/classes/sun/font/FontManagerFactory.java
@@ -78,20 +78,11 @@ public final class FontManagerFactory {
ClassLoader cl = ClassLoader.getSystemClassLoader();
Class fmClass = Class.forName(fmClassName, true, cl);
instance = (FontManager) fmClass.newInstance();
- } catch (ClassNotFoundException ex) {
- InternalError err = new InternalError();
- err.initCause(ex);
- throw err;
+ } catch (ClassNotFoundException |
+ InstantiationException |
+ IllegalAccessException ex) {
+ throw new InternalError(ex);
- } catch (InstantiationException ex) {
- InternalError err = new InternalError();
- err.initCause(ex);
- throw err;
-
- } catch (IllegalAccessException ex) {
- InternalError err = new InternalError();
- err.initCause(ex);
- throw err;
}
return null;
}
diff --git a/src/share/classes/sun/management/ManagementFactoryHelper.java b/src/share/classes/sun/management/ManagementFactoryHelper.java
index 64ac47f9c4495a135eb15e45db5df1801ac51869..d290106834478c245f6749ffb8346bb3454b590f 100644
--- a/src/share/classes/sun/management/ManagementFactoryHelper.java
+++ b/src/share/classes/sun/management/ManagementFactoryHelper.java
@@ -171,7 +171,8 @@ public class ManagementFactoryHelper {
ObjectName result = objname;
if (result == null) {
synchronized (this) {
- if (objname == null) {
+ result = objname;
+ if (result == null) {
result = Util.newObjectName(LOGGING_MXBEAN_NAME);
objname = result;
}
@@ -228,7 +229,8 @@ public class ManagementFactoryHelper {
ObjectName result = objname;
if (result == null) {
synchronized (this) {
- if (objname == null) {
+ result = objname;
+ if (result == null) {
result = Util.newObjectName(BUFFER_POOL_MXBEAN_NAME +
",name=" + pool.getName());
objname = result;
diff --git a/src/share/classes/sun/misc/URLClassPath.java b/src/share/classes/sun/misc/URLClassPath.java
index 5db540d60020573158cb450ef892a8f872c5afa9..cee982369c40512ee6f061816a518cb57fd7a46c 100644
--- a/src/share/classes/sun/misc/URLClassPath.java
+++ b/src/share/classes/sun/misc/URLClassPath.java
@@ -717,7 +717,7 @@ public class URLClassPath {
try {
ensureOpen();
} catch (IOException e) {
- throw (InternalError) new InternalError().initCause(e);
+ throw new InternalError(e);
}
return index;
}
@@ -812,7 +812,7 @@ public class URLClassPath {
try {
ensureOpen();
} catch (IOException e) {
- throw (InternalError) new InternalError().initCause(e);
+ throw new InternalError(e);
}
final JarEntry entry = jar.getJarEntry(name);
if (entry != null)
@@ -900,7 +900,7 @@ public class URLClassPath {
try {
newLoader.ensureOpen();
} catch (IOException e) {
- throw (InternalError) new InternalError().initCause(e);
+ throw new InternalError(e);
}
final JarEntry entry = newLoader.jar.getJarEntry(name);
if (entry != null) {
diff --git a/src/share/classes/sun/reflect/MethodAccessorGenerator.java b/src/share/classes/sun/reflect/MethodAccessorGenerator.java
index 551beb027161011e592d2167fb366c99e3bca0cb..a489f52dde0ccd1e1cb2fe519a568bf94f01a90a 100644
--- a/src/share/classes/sun/reflect/MethodAccessorGenerator.java
+++ b/src/share/classes/sun/reflect/MethodAccessorGenerator.java
@@ -401,10 +401,8 @@ class MethodAccessorGenerator extends AccessorGenerator {
0,
bytes.length,
declaringClass.getClassLoader()).newInstance();
- } catch (InstantiationException |
- IllegalAccessException e) {
- throw (InternalError)
- new InternalError().initCause(e);
+ } catch (InstantiationException | IllegalAccessException e) {
+ throw new InternalError(e);
}
}
});
diff --git a/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java b/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java
index 6bfe8b350016471076dda0bc0ccb8733fa6cda02..d3cff5716ef46664274b112745f63415ade5733e 100644
--- a/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java
+++ b/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -40,6 +40,7 @@ import java.security.PrivilegedAction;
* @since 1.5
*/
class AnnotationInvocationHandler implements InvocationHandler, Serializable {
+ private static final long serialVersionUID = 6182022883658399397L;
private final Class extends Annotation> type;
private final Map memberValues;
diff --git a/src/share/classes/sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.java b/src/share/classes/sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.java
index 9c60803aa4a761686e0dd2b30ed521a76d1a7381..c69fe484630660afc708eed3266c4db65d5bd210 100644
--- a/src/share/classes/sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.java
+++ b/src/share/classes/sun/reflect/annotation/AnnotationTypeMismatchExceptionProxy.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -34,6 +34,7 @@ import java.lang.reflect.Method;
* @since 1.5
*/
class AnnotationTypeMismatchExceptionProxy extends ExceptionProxy {
+ private static final long serialVersionUID = 7844069490309503934L;
private Method member;
private String foundType;
diff --git a/src/share/classes/sun/reflect/annotation/EnumConstantNotPresentExceptionProxy.java b/src/share/classes/sun/reflect/annotation/EnumConstantNotPresentExceptionProxy.java
index 67e9645867b30ff00cd325dafb5031f00f1bc70c..b229c0041e757ef0b007336cec59dc6e2a6c7198 100644
--- a/src/share/classes/sun/reflect/annotation/EnumConstantNotPresentExceptionProxy.java
+++ b/src/share/classes/sun/reflect/annotation/EnumConstantNotPresentExceptionProxy.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -32,6 +32,7 @@ package sun.reflect.annotation;
* @since 1.5
*/
public class EnumConstantNotPresentExceptionProxy extends ExceptionProxy {
+ private static final long serialVersionUID = -604662101303187330L;
Class extends Enum>> enumType;
String constName;
diff --git a/src/share/classes/sun/reflect/annotation/TypeNotPresentExceptionProxy.java b/src/share/classes/sun/reflect/annotation/TypeNotPresentExceptionProxy.java
index de3a92fa0e758c547125b00c91da5ee3aac6c1dc..76cba1dcb72e2c6929fc189479ad76d0d889a3bc 100644
--- a/src/share/classes/sun/reflect/annotation/TypeNotPresentExceptionProxy.java
+++ b/src/share/classes/sun/reflect/annotation/TypeNotPresentExceptionProxy.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -33,6 +33,7 @@ import java.lang.annotation.*;
* @since 1.5
*/
public class TypeNotPresentExceptionProxy extends ExceptionProxy {
+ private static final long serialVersionUID = 5565925172427947573L;
String typeName;
Throwable cause;
diff --git a/src/share/classes/sun/reflect/generics/parser/SignatureParser.java b/src/share/classes/sun/reflect/generics/parser/SignatureParser.java
index 62ed0d7690362f9993b4a7817f4d22e9daf3b2fa..16a7f0a69f1b419f8d201e794e36f034f0ea9b6a 100644
--- a/src/share/classes/sun/reflect/generics/parser/SignatureParser.java
+++ b/src/share/classes/sun/reflect/generics/parser/SignatureParser.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,17 +25,15 @@
package sun.reflect.generics.parser;
-
import java.lang.reflect.GenericSignatureFormatError;
import java.util.*;
import sun.reflect.generics.tree.*;
-
/**
* Parser for type signatures, as defined in the Java Virtual
-// Machine Specification (JVMS) chapter 4.
+ * Machine Specification (JVMS) chapter 4.
* Converts the signatures into an abstract syntax tree (AST) representation.
-// See the package sun.reflect.generics.tree for details of the AST.
+ * See the package sun.reflect.generics.tree for details of the AST.
*/
public class SignatureParser {
// The input is conceptually a character stream (though currently it's
@@ -58,8 +56,8 @@ public class SignatureParser {
// if (current != x {error("expected an x");
//
// where x is some character constant.
- // The assertion inidcates, that, as currently written,
- // the code should nver reach this point unless the input is an
+ // The assertion indicates, that, as currently written,
+ // the code should never reach this point unless the input is an
// x. On the other hand, the test is there to check the legality
// of the input wrt to a given production. It may be that at a later
// time the code might be called directly, and if the input is
@@ -68,7 +66,7 @@ public class SignatureParser {
private char[] input; // the input signature
private int index = 0; // index into the input
-// used to mark end of input
+ // used to mark end of input
private static final char EOI = ':';
private static final boolean DEBUG = false;
@@ -104,6 +102,11 @@ public class SignatureParser {
index++;
}
+ // For debugging, prints current character to the end of the input.
+ private String remainder() {
+ return new String(input, index, input.length-index);
+ }
+
// Match c against a "set" of characters
private boolean matches(char c, char... set) {
for (char e : set) {
@@ -117,8 +120,17 @@ public class SignatureParser {
// Currently throws a GenericSignatureFormatError.
private Error error(String errorMsg) {
- if (DEBUG) System.out.println("Parse error:" + errorMsg);
- return new GenericSignatureFormatError();
+ return new GenericSignatureFormatError("Signature Parse error: " + errorMsg +
+ "\n\tRemaining input: " + remainder());
+ }
+
+ /**
+ * Verify the parse has made forward progress; throw an exception
+ * if no progress.
+ */
+ private void progress(int startingPosition) {
+ if (index <= startingPosition)
+ throw error("Failure to make progress!");
}
/**
@@ -163,6 +175,7 @@ public class SignatureParser {
/**
* Parses a type signature
* and produces an abstract syntax tree representing it.
+ *
* @param s a string representing the input type signature
* @return An abstract syntax tree for a type signature
* corresponding to the input string
@@ -183,38 +196,58 @@ public class SignatureParser {
// and when it completes parsing, it leaves the input at the first
// character after the input parses.
- // parse a class signature based on the implicit input.
+ /*
+ * Note on grammar conventions: a trailing "*" matches zero or
+ * more occurrences, a trailing "+" matches one or more occurrences,
+ * "_opt" indicates an optional component.
+ */
+
+ /**
+ * ClassSignature:
+ * FormalTypeParameters_opt SuperclassSignature SuperinterfaceSignature*
+ */
private ClassSignature parseClassSignature() {
+ // parse a class signature based on the implicit input.
assert(index == 0);
return ClassSignature.make(parseZeroOrMoreFormalTypeParameters(),
- parseClassTypeSignature(),
+ parseClassTypeSignature(), // Only rule for SuperclassSignature
parseSuperInterfaces());
}
private FormalTypeParameter[] parseZeroOrMoreFormalTypeParameters(){
- if (current() == '<') { return parseFormalTypeParameters();}
- else {return new FormalTypeParameter[0];}
+ if (current() == '<') {
+ return parseFormalTypeParameters();
+ } else {
+ return new FormalTypeParameter[0];
+ }
}
-
+ /**
+ * FormalTypeParameters:
+ * "<" FormalTypeParameter+ ">"
+ */
private FormalTypeParameter[] parseFormalTypeParameters(){
- Collection ftps =
- new ArrayList(3);
+ List ftps = new ArrayList<>(3);
assert(current() == '<'); // should not have been called at all
- if (current() != '<') { throw error("expected <");}
+ if (current() != '<') { throw error("expected '<'");}
advance();
ftps.add(parseFormalTypeParameter());
while (current() != '>') {
+ int startingPosition = index;
ftps.add(parseFormalTypeParameter());
+ progress(startingPosition);
}
advance();
- FormalTypeParameter[] ftpa = new FormalTypeParameter[ftps.size()];
- return ftps.toArray(ftpa);
+ return ftps.toArray(new FormalTypeParameter[ftps.size()]);
}
+ /**
+ * FormalTypeParameter:
+ * Identifier ClassBound InterfaceBound*
+ */
private FormalTypeParameter parseFormalTypeParameter(){
String id = parseIdentifier();
- FieldTypeSignature[] bs = parseZeroOrMoreBounds();
+ FieldTypeSignature[] bs = parseBounds();
return FormalTypeParameter.make(id, bs);
}
@@ -229,7 +262,8 @@ public class SignatureParser {
case '[':
case ':':
case '>':
- case '<': return result.toString();
+ case '<':
+ return result.toString();
default:{
result.append(c);
advance();
@@ -239,26 +273,42 @@ public class SignatureParser {
}
return result.toString();
}
-
+ /**
+ * FieldTypeSignature:
+ * ClassTypeSignature
+ * ArrayTypeSignature
+ * TypeVariableSignature
+ */
private FieldTypeSignature parseFieldTypeSignature() {
+ return parseFieldTypeSignature(true);
+ }
+
+ private FieldTypeSignature parseFieldTypeSignature(boolean allowArrays) {
switch(current()) {
case 'L':
return parseClassTypeSignature();
case 'T':
return parseTypeVariableSignature();
case '[':
- return parseArrayTypeSignature();
+ if (allowArrays)
+ return parseArrayTypeSignature();
+ else
+ throw error("Array signature not allowed here.");
default: throw error("Expected Field Type Signature");
}
}
+ /**
+ * ClassTypeSignature:
+ * "L" PackageSpecifier_opt SimpleClassTypeSignature ClassTypeSignatureSuffix* ";"
+ */
private ClassTypeSignature parseClassTypeSignature(){
assert(current() == 'L');
if (current() != 'L') { throw error("expected a class type");}
advance();
- List scts =
- new ArrayList(5);
- scts.add(parseSimpleClassTypeSignature(false));
+ List scts = new ArrayList<>(5);
+ scts.add(parsePackageNameAndSimpleClassTypeSignature());
+
parseClassTypeSignatureSuffix(scts);
if (current() != ';')
throw error("expected ';' got '" + current() + "'");
@@ -267,25 +317,65 @@ public class SignatureParser {
return ClassTypeSignature.make(scts);
}
- private SimpleClassTypeSignature parseSimpleClassTypeSignature(boolean dollar){
- String id = parseIdentifier();
- char c = current();
- switch (c) {
- case ';':
- case '/':
- return SimpleClassTypeSignature.make(id, dollar, new TypeArgument[0]) ;
- case '<': {
- return SimpleClassTypeSignature.make(id, dollar, parseTypeArguments());
- }
- default: {throw error("expected < or ; or /");}
+ /**
+ * PackageSpecifier:
+ * Identifier "/" PackageSpecifier*
+ */
+ private SimpleClassTypeSignature parsePackageNameAndSimpleClassTypeSignature() {
+ // Parse both any optional leading PackageSpecifier as well as
+ // the following SimpleClassTypeSignature.
+
+ String id = parseIdentifier();
+
+ if (current() == '/') { // package name
+ StringBuilder idBuild = new StringBuilder(id);
+
+ while(current() == '/') {
+ advance();
+ idBuild.append(".");
+ idBuild.append(parseIdentifier());
}
+ id = idBuild.toString();
+ }
+
+ switch (current()) {
+ case ';':
+ return SimpleClassTypeSignature.make(id, false, new TypeArgument[0]); // all done!
+ case '<':
+ if (DEBUG) System.out.println("\t remainder: " + remainder());
+ return SimpleClassTypeSignature.make(id, false, parseTypeArguments());
+ default:
+ throw error("expected '<' or ';' but got " + current());
+ }
}
+ /**
+ * SimpleClassTypeSignature:
+ * Identifier TypeArguments_opt
+ */
+ private SimpleClassTypeSignature parseSimpleClassTypeSignature(boolean dollar){
+ String id = parseIdentifier();
+ char c = current();
+
+ switch (c) {
+ case ';':
+ case '.':
+ return SimpleClassTypeSignature.make(id, dollar, new TypeArgument[0]) ;
+ case '<':
+ return SimpleClassTypeSignature.make(id, dollar, parseTypeArguments());
+ default:
+ throw error("expected '<' or ';' or '.', got '" + c + "'.");
+ }
+ }
+
+ /**
+ * ClassTypeSignatureSuffix:
+ * "." SimpleClassTypeSignature
+ */
private void parseClassTypeSignatureSuffix(List scts) {
- while (current() == '/' || current() == '.') {
- boolean dollar = (current() == '.');
+ while (current() == '.') {
advance();
- scts.add(parseSimpleClassTypeSignature(dollar));
+ scts.add(parseSimpleClassTypeSignature(true));
}
}
@@ -294,10 +384,14 @@ public class SignatureParser {
else {return new TypeArgument[0];}
}
+ /**
+ * TypeArguments:
+ * "<" TypeArgument+ ">"
+ */
private TypeArgument[] parseTypeArguments() {
- Collection tas = new ArrayList(3);
+ List tas = new ArrayList<>(3);
assert(current() == '<');
- if (current() != '<') { throw error("expected <");}
+ if (current() != '<') { throw error("expected '<'");}
advance();
tas.add(parseTypeArgument());
while (current() != '>') {
@@ -305,10 +399,14 @@ public class SignatureParser {
tas.add(parseTypeArgument());
}
advance();
- TypeArgument[] taa = new TypeArgument[tas.size()];
- return tas.toArray(taa);
+ return tas.toArray(new TypeArgument[tas.size()]);
}
+ /**
+ * TypeArgument:
+ * WildcardIndicator_opt FieldTypeSignature
+ * "*"
+ */
private TypeArgument parseTypeArgument() {
FieldTypeSignature[] ub, lb;
ub = new FieldTypeSignature[1];
@@ -334,18 +432,20 @@ public class SignatureParser {
ub[0] = SimpleClassTypeSignature.make("java.lang.Object", false, ta);
return Wildcard.make(ub, lb);
}
- default: return parseFieldTypeSignature();
+ default:
+ return parseFieldTypeSignature();
}
}
- // TypeVariableSignature -> T identifier
-
- private TypeVariableSignature parseTypeVariableSignature(){
+ /**
+ * TypeVariableSignature:
+ * "T" Identifier ";"
+ */
+ private TypeVariableSignature parseTypeVariableSignature() {
assert(current() == 'T');
if (current() != 'T') { throw error("expected a type variable usage");}
advance();
- TypeVariableSignature ts =
- TypeVariableSignature.make(parseIdentifier());
+ TypeVariableSignature ts = TypeVariableSignature.make(parseIdentifier());
if (current() != ';') {
throw error("; expected in signature of type variable named" +
ts.getIdentifier());
@@ -354,16 +454,21 @@ public class SignatureParser {
return ts;
}
- // ArrayTypeSignature -> [ TypeSignature
-
+ /**
+ * ArrayTypeSignature:
+ * "[" TypeSignature
+ */
private ArrayTypeSignature parseArrayTypeSignature() {
if (current() != '[') {throw error("expected array type signature");}
advance();
return ArrayTypeSignature.make(parseTypeSignature());
}
- // TypeSignature -> BaseType | FieldTypeSignature
-
+ /**
+ * TypeSignature:
+ * FieldTypeSignature
+ * BaseType
+ */
private TypeSignature parseTypeSignature() {
switch (current()) {
case 'B':
@@ -373,8 +478,11 @@ public class SignatureParser {
case 'I':
case 'J':
case 'S':
- case 'Z':return parseBaseType();
- default: return parseFieldTypeSignature();
+ case 'Z':
+ return parseBaseType();
+
+ default:
+ return parseFieldTypeSignature();
}
}
@@ -408,12 +516,18 @@ public class SignatureParser {
assert(false);
throw error("expected primitive type");
}
- }
+ }
}
- private FieldTypeSignature[] parseZeroOrMoreBounds() {
- Collection fts =
- new ArrayList(3);
+ /**
+ * ClassBound:
+ * ":" FieldTypeSignature_opt
+ *
+ * InterfaceBound:
+ * ":" FieldTypeSignature
+ */
+ private FieldTypeSignature[] parseBounds() {
+ List fts = new ArrayList<>(3);
if (current() == ':') {
advance();
@@ -430,24 +544,31 @@ public class SignatureParser {
advance();
fts.add(parseFieldTypeSignature());
}
- }
+ } else
+ error("Bound expected");
- FieldTypeSignature[] fta = new FieldTypeSignature[fts.size()];
- return fts.toArray(fta);
+ return fts.toArray(new FieldTypeSignature[fts.size()]);
}
+ /**
+ * SuperclassSignature:
+ * ClassTypeSignature
+ */
private ClassTypeSignature[] parseSuperInterfaces() {
- Collection cts =
- new ArrayList(5);
+ List cts = new ArrayList<>(5);
while(current() == 'L') {
cts.add(parseClassTypeSignature());
}
- ClassTypeSignature[] cta = new ClassTypeSignature[cts.size()];
- return cts.toArray(cta);
+ return cts.toArray(new ClassTypeSignature[cts.size()]);
}
- // parse a method signature based on the implicit input.
+
+ /**
+ * MethodTypeSignature:
+ * FormalTypeParameters_opt "(" TypeSignature* ")" ReturnType ThrowsSignature*
+ */
private MethodTypeSignature parseMethodTypeSignature() {
+ // Parse a method signature based on the implicit input.
FieldTypeSignature[] ets;
assert(index == 0);
@@ -457,19 +578,19 @@ public class SignatureParser {
parseZeroOrMoreThrowsSignatures());
}
- // (TypeSignature*)
+ // "(" TypeSignature* ")"
private TypeSignature[] parseFormalParameters() {
- if (current() != '(') {throw error("expected (");}
+ if (current() != '(') {throw error("expected '('");}
advance();
TypeSignature[] pts = parseZeroOrMoreTypeSignatures();
- if (current() != ')') {throw error("expected )");}
+ if (current() != ')') {throw error("expected ')'");}
advance();
return pts;
}
- // TypeSignature*
+ // TypeSignature*
private TypeSignature[] parseZeroOrMoreTypeSignatures() {
- Collection ts = new ArrayList();
+ List ts = new ArrayList<>();
boolean stop = false;
while (!stop) {
switch(current()) {
@@ -484,47 +605,46 @@ public class SignatureParser {
case 'L':
case 'T':
case '[': {
- ts.add(parseTypeSignature());
- break;
- }
+ ts.add(parseTypeSignature());
+ break;
+ }
default: stop = true;
}
}
- /* while( matches(current(),
- 'B', 'C', 'D', 'F', 'I', 'J', 'S', 'Z', 'L', 'T', '[')
- ) {
- ts.add(parseTypeSignature());
- }*/
- TypeSignature[] ta = new TypeSignature[ts.size()];
- return ts.toArray(ta);
+ return ts.toArray(new TypeSignature[ts.size()]);
}
- // ReturnType -> V | TypeSignature
-
+ /**
+ * ReturnType:
+ * TypeSignature
+ * VoidDescriptor
+ */
private ReturnType parseReturnType(){
- if (current() == 'V') {
+ if (current() == 'V') {
advance();
return VoidDescriptor.make();
- } else return parseTypeSignature();
+ } else
+ return parseTypeSignature();
}
// ThrowSignature*
private FieldTypeSignature[] parseZeroOrMoreThrowsSignatures(){
- Collection ets =
- new ArrayList(3);
+ List ets = new ArrayList<>(3);
while( current() == '^') {
ets.add(parseThrowsSignature());
}
- FieldTypeSignature[] eta = new FieldTypeSignature[ets.size()];
- return ets.toArray(eta);
+ return ets.toArray(new FieldTypeSignature[ets.size()]);
}
- // ThrowSignature -> ^ FieldTypeSignature
-
+ /**
+ * ThrowsSignature:
+ * "^" ClassTypeSignature
+ * "^" TypeVariableSignature
+ */
private FieldTypeSignature parseThrowsSignature() {
assert(current() == '^');
if (current() != '^') { throw error("expected throws signature");}
advance();
- return parseFieldTypeSignature();
+ return parseFieldTypeSignature(false);
}
}
diff --git a/src/share/classes/sun/security/pkcs11/Session.java b/src/share/classes/sun/security/pkcs11/Session.java
index 308b7542e7d188d35863d3f2a65c3a1bd947b6bd..99d6da78682ea19481a5cf10077b145decf51c21 100644
--- a/src/share/classes/sun/security/pkcs11/Session.java
+++ b/src/share/classes/sun/security/pkcs11/Session.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -87,7 +87,7 @@ final class Session implements Comparable {
}
long id() {
- if (token.isPresent(this) == false) {
+ if (token.isPresent(this.id) == false) {
throw new ProviderException("Token has been removed");
}
lastAccess = System.currentTimeMillis();
@@ -167,7 +167,9 @@ final class SessionRef extends PhantomReference
void dispose() {
refList.remove(this);
try {
- token.p11.C_CloseSession(id);
+ if (token.isPresent(id)) {
+ token.p11.C_CloseSession(id);
+ }
} catch (PKCS11Exception e1) {
// ignore
} catch (ProviderException e2) {
diff --git a/src/share/classes/sun/security/pkcs11/Token.java b/src/share/classes/sun/security/pkcs11/Token.java
index dcb3e61979ec37710f16c3cfcb98d578c0f8fe97..f19f8b7ca20716ad8b8b77302fcc4fe88d8226f3 100644
--- a/src/share/classes/sun/security/pkcs11/Token.java
+++ b/src/share/classes/sun/security/pkcs11/Token.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -217,7 +217,7 @@ class Token implements Serializable {
// return whether a token is present (i.e. token not removed)
// returns cached value if current, otherwise performs new check
- boolean isPresent(Session session) {
+ boolean isPresent(long sessionID) {
if (removable == false) {
return true;
}
@@ -238,7 +238,7 @@ class Token implements Serializable {
// the token should return an error
CK_SESSION_INFO sessInfo =
provider.p11.C_GetSessionInfo
- (session.idInternal());
+ (sessionID);
ok = true;
}
} catch (PKCS11Exception e) {
diff --git a/src/share/classes/sun/security/provider/certpath/X509CertPath.java b/src/share/classes/sun/security/provider/certpath/X509CertPath.java
index 8fe9750d2f1883b6b1f23ea2f45ecf9b015a8604..9180a500d4d770b117805d92663781ec88bc47b4 100644
--- a/src/share/classes/sun/security/provider/certpath/X509CertPath.java
+++ b/src/share/classes/sun/security/provider/certpath/X509CertPath.java
@@ -105,7 +105,13 @@ public class X509CertPath extends CertPath {
super("X.509");
// Ensure that the List contains only X509Certificates
- for (Certificate obj : certs) {
+ //
+ // Note; The certs parameter is not necessarily to be of Certificate
+ // for some old code. For compatibility, to make sure the exception
+ // is CertificateException, rather than ClassCastException, please
+ // don't use
+ // for (Certificate obj : certs)
+ for (Object obj : certs) {
if (obj instanceof X509Certificate == false) {
throw new CertificateException
("List is not all X509Certificates: "
diff --git a/src/share/classes/sun/security/x509/X500Name.java b/src/share/classes/sun/security/x509/X500Name.java
index ce4c69c695688e2e00081d7935a6ff400f30118b..551ec609267c5eb778f2174fe248519144180471 100644
--- a/src/share/classes/sun/security/x509/X500Name.java
+++ b/src/share/classes/sun/security/x509/X500Name.java
@@ -1401,8 +1401,7 @@ public class X500Name implements GeneralNameInterface, Principal {
principalConstructor = constr;
principalField = (Field)result[1];
} catch (Exception e) {
- throw (InternalError)new InternalError("Could not obtain "
- + "X500Principal access").initCause(e);
+ throw new InternalError("Could not obtain X500Principal access", e);
}
}
diff --git a/src/share/classes/sun/swing/DefaultLayoutStyle.java b/src/share/classes/sun/swing/DefaultLayoutStyle.java
index 2ffdcf8ac0de7fe36cb96a75f87029c950c00425..3d284c3eb8e76081635aa22dcefead6779e8e487 100644
--- a/src/share/classes/sun/swing/DefaultLayoutStyle.java
+++ b/src/share/classes/sun/swing/DefaultLayoutStyle.java
@@ -48,10 +48,12 @@ public class DefaultLayoutStyle extends LayoutStyle {
@Override
public int getPreferredGap(JComponent component1, JComponent component2,
ComponentPlacement type, int position, Container parent) {
-
if (component1 == null || component2 == null || type == null) {
throw new NullPointerException();
}
+
+ checkPosition(position);
+
if (type == ComponentPlacement.INDENT &&
(position == SwingConstants.EAST ||
position == SwingConstants.WEST)) {
diff --git a/src/share/classes/sun/tools/jconsole/ProxyClient.java b/src/share/classes/sun/tools/jconsole/ProxyClient.java
index 10780035b0f680ab2ef21f7f0618d62c7cb0a0fe..6e129fd5569fe7c3890ad874b4ebf38c0a103c0b 100644
--- a/src/share/classes/sun/tools/jconsole/ProxyClient.java
+++ b/src/share/classes/sun/tools/jconsole/ProxyClient.java
@@ -208,7 +208,7 @@ public class ProxyClient implements JConsoleContext {
serverStubClass = Class.forName(rmiServerImplStubClassName).asSubclass(Remote.class);
} catch (ClassNotFoundException e) {
// should never reach here
- throw (InternalError) new InternalError(e.getMessage()).initCause(e);
+ throw new InternalError(e.getMessage(), e);
}
rmiServerImplStubClass = serverStubClass;
}
@@ -395,18 +395,10 @@ public class ProxyClient implements JConsoleContext {
} catch (MalformedObjectNameException e) {
// should not reach here
throw new InternalError(e.getMessage());
- } catch (IntrospectionException e) {
- InternalError ie = new InternalError(e.getMessage());
- ie.initCause(e);
- throw ie;
- } catch (InstanceNotFoundException e) {
- InternalError ie = new InternalError(e.getMessage());
- ie.initCause(e);
- throw ie;
- } catch (ReflectionException e) {
- InternalError ie = new InternalError(e.getMessage());
- ie.initCause(e);
- throw ie;
+ } catch (IntrospectionException |
+ InstanceNotFoundException |
+ ReflectionException e) {
+ throw new InternalError(e.getMessage(), e);
}
if (hasPlatformMXBeans) {
diff --git a/src/solaris/classes/sun/nio/ch/InheritedChannel.java b/src/solaris/classes/sun/nio/ch/InheritedChannel.java
index 4c88a8d42193a6b3b2c14eb182c58cd2943de38a..e749c6af10be4c0d6ba7edeb4e3bbb9bdef4dece 100644
--- a/src/solaris/classes/sun/nio/ch/InheritedChannel.java
+++ b/src/solaris/classes/sun/nio/ch/InheritedChannel.java
@@ -166,8 +166,8 @@ class InheritedChannel {
// is implemented.
Class paramTypes[] = { int.class };
- Constructor ctr = Reflect.lookupConstructor("java.io.FileDescriptor",
- paramTypes);
+ Constructor> ctr = Reflect.lookupConstructor("java.io.FileDescriptor",
+ paramTypes);
Object args[] = { new Integer(fdVal) };
FileDescriptor fd = (FileDescriptor)Reflect.invoke(ctr, args);
diff --git a/src/solaris/lib/content-types.properties b/src/solaris/lib/content-types.properties
index 2126b01188a55cbb4f357e97d66fc0ce4fea995e..559de96f66a7ce4a8c3d8e6de67cf6748f1fd1df 100644
--- a/src/solaris/lib/content-types.properties
+++ b/src/solaris/lib/content-types.properties
@@ -225,6 +225,10 @@ image/png: \
icon=png;\
action=browser
+image/bmp: \
+ description=Bitmap Image;\
+ file_extensions=.bmp;
+
text/html: \
description=HTML Document;\
file_extensions=.htm,.html;\
diff --git a/src/windows/classes/sun/nio/ch/WindowsAsynchronousFileChannelImpl.java b/src/windows/classes/sun/nio/ch/WindowsAsynchronousFileChannelImpl.java
index 126342a2f651eaa07da499770222a4f874441230..b85271e686e13cec469d09b3b474e341670014b5 100644
--- a/src/windows/classes/sun/nio/ch/WindowsAsynchronousFileChannelImpl.java
+++ b/src/windows/classes/sun/nio/ch/WindowsAsynchronousFileChannelImpl.java
@@ -55,9 +55,7 @@ public class WindowsAsynchronousFileChannelImpl
try {
return new Iocp(null, ThreadPool.createDefault()).start();
} catch (IOException ioe) {
- InternalError e = new InternalError();
- e.initCause(ioe);
- throw e;
+ throw new InternalError(ioe);
}
}
}
diff --git a/src/windows/lib/content-types.properties b/src/windows/lib/content-types.properties
index 1cbfcbddb1f1161222e7de6d583befbc80883297..894935256763fb0930dcb662bba3e3bcaf31c303 100644
--- a/src/windows/lib/content-types.properties
+++ b/src/windows/lib/content-types.properties
@@ -222,6 +222,10 @@ image/png: \
icon=png;\
action=browser
+image/bmp: \
+ description=Bitmap Image;\
+ file_extensions=.bmp;
+
text/html: \
description=HTML Document;\
file_extensions=.htm,.html;\
diff --git a/test/ProblemList.txt b/test/ProblemList.txt
index b5664392126ed0b6653bdbd54e9d17aa2455c7c6..704e78e5b30a2b6b67ff922932b7951b589f1d3f 100644
--- a/test/ProblemList.txt
+++ b/test/ProblemList.txt
@@ -198,10 +198,16 @@ java/beans/XMLEncoder/6329581/Test6329581.java generic-all
# requires junit
java/lang/invoke/InvokeDynamicPrintArgs.java generic-all
+# 7079093
+java/lang/instrument/ManifestTest.sh windows-all
+
############################################################################
# jdk_management
+# 6944188
+java/lang/management/ThreadMXBean/ThreadStateTest.java generic-all
+
# 7067973
java/lang/management/MemoryMXBean/CollectionUsageThreshold.java generic-all
@@ -368,6 +374,12 @@ com/sun/net/httpserver/Test9a.java generic-all
# 7079145 java/net/ipv6tests/UdpTest.java hang at IPv6 only data exchange
java/net/ipv6tests/UdpTest.java linux-all
+# 7079012
+java/net/NetworkInterface/NetParamsTest.java solaris-all
+
+# 7081476
+java/net/InetSocketAddress/B6469803.java generic-all
+
############################################################################
# jdk_io
@@ -375,6 +387,12 @@ java/net/ipv6tests/UdpTest.java linux-all
# 6962637
java/io/File/MaxPathLength.java windows-all
+# 6671616
+java/io/File/BlockIsDirectory.java solaris-all
+
+# 7076644
+java/io/File/Basic.java windows-all
+
############################################################################
# jdk_nio
@@ -382,6 +400,9 @@ java/io/File/MaxPathLength.java windows-all
# 6963118
java/nio/channels/Selector/Wakeup.java windows-all
+# 7076700
+java/nio/channels/SocketChannel/AdaptSocket.java generic-all
+
############################################################################
# jdk_rmi
@@ -499,6 +520,12 @@ sun/security/ssl/sanity/interop/ClientJSSEServerJSSE.java generic-all
# 7079203 sun/security/tools/keytool/printssl.sh fails on solaris with timeout
sun/security/tools/keytool/printssl.sh solaris-all
+# 7054637
+sun/security/tools/jarsigner/ec.sh solaris-all
+
+# 7081817
+sun/security/provider/certpath/X509CertPath/IllegalCertiticates.java generic-all
+
############################################################################
# jdk_swing (not using samevm)
diff --git a/test/com/sun/security/sasl/ntlm/Conformance.java b/test/com/sun/security/sasl/ntlm/Conformance.java
new file mode 100644
index 0000000000000000000000000000000000000000..4c1301e25c23d546aad240c15fb808de697e2436
--- /dev/null
+++ b/test/com/sun/security/sasl/ntlm/Conformance.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7043847 7043860 7043882 7043938 7043959
+ * @summary NTML impl of SaslServer conformance errors
+ */
+import java.io.IOException;
+import javax.security.sasl.*;
+import java.util.*;
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.UnsupportedCallbackException;
+
+public class Conformance {
+
+ public static void main(String[] args) throws Exception {
+ try {
+ Sasl.createSaslClient(new String[] {"NTLM"}, "abc", "ldap",
+ "server", new HashMap(), null);
+ } catch (SaslException se) {
+ System.out.println(se);
+ }
+ try {
+ Sasl.createSaslServer("NTLM", "ldap",
+ "server", new HashMap(), null);
+ } catch (SaslException se) {
+ System.out.println(se);
+ }
+ try {
+ Sasl.createSaslClient(new String[] {"NTLM"}, "abc", "ldap",
+ "server", null, new CallbackHandler() {
+ @Override
+ public void handle(Callback[] callbacks) throws
+ IOException, UnsupportedCallbackException { }
+ });
+ } catch (SaslException se) {
+ System.out.println(se);
+ }
+ try {
+ SaslServer saslServer =
+ Sasl.createSaslServer("NTLM", "ldap", "abc", null, new CallbackHandler() {
+ @Override
+ public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { }
+ });
+ System.err.println("saslServer = " + saslServer);
+ System.err.println("saslServer.isComplete() = " + saslServer.isComplete());
+ // IllegalStateException is expected here
+ saslServer.getNegotiatedProperty("prop");
+ System.err.println("No IllegalStateException");
+ } catch (IllegalStateException se) {
+ System.out.println(se);
+ }
+ try {
+ SaslServer saslServer =
+ Sasl.createSaslServer("NTLM", "ldap", "abc", null, new CallbackHandler() {
+ @Override
+ public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { }
+ });
+ System.err.println("saslServer = " + saslServer);
+ System.err.println("saslServer.isComplete() = " + saslServer.isComplete());
+ // IllegalStateException is expected here
+ saslServer.getAuthorizationID();
+ System.err.println("No IllegalStateException");
+ } catch (IllegalStateException se) {
+ System.out.println(se);
+ }
+ try {
+ SaslServer saslServer =
+ Sasl.createSaslServer("NTLM", "ldap", "abc", null, new CallbackHandler() {
+ @Override
+ public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { }
+ });
+ System.err.println("saslServer = " + saslServer);
+ System.err.println("saslServer.isComplete() = " + saslServer.isComplete());
+ // IllegalStateException is expected here
+ saslServer.wrap(new byte[0], 0, 0);
+ System.err.println("No IllegalStateException");
+ } catch (IllegalStateException se) {
+ System.out.println(se);
+ }
+ }
+}
diff --git a/test/java/awt/MenuBar/MenuBarSetFont/MenuBarSetFont.java b/test/java/awt/MenuBar/MenuBarSetFont/MenuBarSetFont.java
new file mode 100644
index 0000000000000000000000000000000000000000..559d7de4d97dd725196eee94c49a535252caf1d7
--- /dev/null
+++ b/test/java/awt/MenuBar/MenuBarSetFont/MenuBarSetFont.java
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import sun.awt.SunToolkit;
+
+import java.awt.Button;
+import java.awt.CardLayout;
+import java.awt.Font;
+import java.awt.Frame;
+import java.awt.Menu;
+import java.awt.MenuBar;
+import java.awt.Point;
+import java.awt.Robot;
+import java.awt.Toolkit;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.InputEvent;
+
+/**
+ * @test
+ * @bug 6263470
+ * @summary Tries to change font of MenuBar. Test passes if the font has changed
+ * fails otherwise.
+ * @author Vyacheslav.Baranov: area=menu
+ * @run main MenuBarSetFont
+ */
+public final class MenuBarSetFont {
+
+ private static final Frame frame = new Frame();
+ private static final MenuBar mb = new MenuBar();
+ private static volatile boolean clicked;
+
+ private static final class Listener implements ActionListener {
+ @Override
+ public void actionPerformed(final ActionEvent e) {
+ //Click on this button is performed
+ //_only_ if font of MenuBar is not changed on time
+ MenuBarSetFont.clicked = true;
+ }
+ }
+
+ private static void addMenu() {
+ mb.add(new Menu("w"));
+ frame.validate();
+ }
+
+ public static void main(final String[] args) throws Exception {
+ //Components initialization.
+ frame.setMenuBar(mb);
+ mb.setFont(new Font("Helvetica", Font.ITALIC, 5));
+
+ final Button button = new Button("Click Me");
+ button.addActionListener(new Listener());
+ frame.setLayout(new CardLayout());
+ frame.add(button, "First");
+ frame.setSize(400, 400);
+ frame.setVisible(true);
+ sleep();
+
+ final int fInsets = frame.getInsets().top; //Frame insets without menu.
+ addMenu();
+ final int fMenuInsets = frame.getInsets().top; //Frame insets with menu.
+ final int menuBarHeight = fMenuInsets - fInsets;
+ // There is no way to change menubar height on windows. But on windows
+ // we can try to split menubar in 2 rows.
+ for (int i = 0; i < 100 && fMenuInsets == frame.getInsets().top; ++i) {
+ // Fill whole menubar.
+ addMenu();
+ }
+
+ mb.remove(0);
+ frame.validate();
+ sleep();
+
+ // Test execution.
+ // On XToolkit, menubar font should be changed to 60.
+ // On WToolkit, menubar font should be changed to default and menubar
+ // should be splitted in 2 rows.
+ mb.setFont(new Font("Helvetica", Font.ITALIC, 60));
+ sleep();
+
+ final Robot r = new Robot();
+ r.setAutoDelay(200);
+ final Point pt = frame.getLocation();
+ r.mouseMove(pt.x + frame.getWidth() / 2,
+ pt.y + fMenuInsets + menuBarHeight / 2);
+ r.mousePress(InputEvent.BUTTON1_MASK);
+ r.mouseRelease(InputEvent.BUTTON1_MASK);
+
+ sleep();
+ frame.dispose();
+
+ if (clicked) {
+ fail("Font was not changed");
+ }
+ }
+
+ private static void sleep() {
+ ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
+ try {
+ Thread.sleep(500L);
+ } catch (InterruptedException ignored) {
+ }
+ }
+
+ private static void fail(final String message) {
+ throw new RuntimeException(message);
+ }
+}
diff --git a/test/java/io/IOException/LastErrorString.java b/test/java/io/IOException/LastErrorString.java
index 403c810415451716d87c9ffecb4147dcd239658c..3d6d9edb93436a88e819dc24fc1740c81c44053c 100644
--- a/test/java/io/IOException/LastErrorString.java
+++ b/test/java/io/IOException/LastErrorString.java
@@ -23,6 +23,7 @@
/* @test
@bug 4167937
+ @ignore Test truncates system files when run as root, see 7042603
@summary Test code paths that use the JVM_LastErrorString procedure
*/
diff --git a/test/java/io/etc/FailingFlushAndClose.java b/test/java/io/etc/FailingFlushAndClose.java
new file mode 100644
index 0000000000000000000000000000000000000000..3a07d54ff0b4eb375373a7e043a60ca27f3e0a4e
--- /dev/null
+++ b/test/java/io/etc/FailingFlushAndClose.java
@@ -0,0 +1,268 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.*;
+
+/**
+ * @test
+ * @bug 7015589
+ * @summary Test that buffering streams are considered closed even when the
+ * close or flush from the underlying stream fails.
+ */
+
+public class FailingFlushAndClose {
+
+ static int failed;
+
+ static void fail(String msg) {
+ System.err.println("FAIL: " + msg);
+ failed++;
+ }
+
+ static void failWithIOE(String msg) throws IOException {
+ fail(msg);
+ throw new IOException(msg);
+ }
+
+ static class FailingCloseInputStream extends InputStream {
+ boolean closed;
+ @Override
+ public int read()throws IOException {
+ if (closed)
+ failWithIOE("input stream is closed");
+ return 1;
+ }
+ @Override
+ public void close() throws IOException {
+ if (!closed) {
+ closed = true;
+ throw new IOException("close failed");
+ }
+ }
+ }
+
+ static class FailingCloseOutputStream extends OutputStream {
+ boolean closed;
+ @Override
+ public void write(int b) throws IOException {
+ if (closed)
+ failWithIOE("output stream is closed");
+ }
+ @Override
+ public void flush() throws IOException {
+ if (closed)
+ failWithIOE("output stream is closed");
+ }
+ @Override
+ public void close() throws IOException {
+ if (!closed) {
+ closed = true;
+ throw new IOException("close failed");
+ }
+ }
+ }
+
+ static class FailingFlushOutputStream extends OutputStream {
+ boolean closed;
+ @Override
+ public void write(int b) throws IOException {
+ if (closed)
+ failWithIOE("output stream is closed");
+ }
+ @Override
+ public void flush() throws IOException {
+ if (closed) {
+ failWithIOE("output stream is closed");
+ } else {
+ throw new IOException("flush failed");
+ }
+ }
+ @Override
+ public void close() throws IOException {
+ closed = true;
+ }
+ }
+
+ static class FailingCloseReader extends Reader {
+ boolean closed;
+ @Override
+ public int read(char[] cbuf, int off, int len) throws IOException {
+ if (closed)
+ failWithIOE("reader is closed");
+ return 1;
+ }
+ @Override
+ public void close() throws IOException {
+ if (!closed) {
+ closed = true;
+ throw new IOException("close failed");
+ }
+ }
+ }
+
+ static class FailingCloseWriter extends Writer {
+ boolean closed;
+ @Override
+ public void write(char[] cbuf, int off, int len) throws IOException {
+ if (closed)
+ failWithIOE("writer is closed");
+ }
+ @Override
+ public void flush() throws IOException {
+ if (closed)
+ failWithIOE("writer is closed");
+ }
+ @Override
+ public void close() throws IOException {
+ if (!closed) {
+ closed = true;
+ throw new IOException("close failed");
+ }
+ }
+ }
+
+ static class FailingFlushWriter extends Writer {
+ boolean closed;
+ @Override
+ public void write(char[] cbuf, int off, int len) throws IOException {
+ if (closed)
+ failWithIOE("writer is closed");
+ }
+ @Override
+ public void flush() throws IOException {
+ if (closed) {
+ failWithIOE("writer is closed");
+ } else {
+ throw new IOException("flush failed");
+ }
+ }
+ @Override
+ public void close() throws IOException {
+ if (!closed) {
+ closed = true;
+ throw new IOException("close failed");
+ }
+ }
+ }
+
+ static void testFailingClose(InputStream in) throws IOException {
+ System.out.println(in.getClass());
+ in.read(new byte[100]);
+ try {
+ in.close();
+ fail("close did not fail");
+ } catch (IOException expected) { }
+ try {
+ in.read(new byte[100]);
+ fail("read did not fail");
+ } catch (IOException expected) { }
+ }
+
+ static void testFailingClose(OutputStream out) throws IOException {
+ System.out.println(out.getClass());
+ out.write(1);
+ try {
+ out.close();
+ fail("close did not fail");
+ } catch (IOException expected) { }
+ try {
+ out.write(1);
+ if (!(out instanceof BufferedOutputStream))
+ fail("write did not fail");
+ } catch (IOException expected) { }
+ }
+
+ static void testFailingFlush(OutputStream out) throws IOException {
+ System.out.println(out.getClass());
+ out.write(1);
+ try {
+ out.flush();
+ fail("flush did not fail");
+ } catch (IOException expected) { }
+ if (out instanceof BufferedOutputStream) {
+ out.write(1);
+ try {
+ out.close();
+ fail("close did not fail");
+ } catch (IOException expected) { }
+ }
+ }
+
+ static void testFailingClose(Reader r) throws IOException {
+ System.out.println(r.getClass());
+ r.read(new char[100]);
+ try {
+ r.close();
+ fail("close did not fail");
+ } catch (IOException expected) { }
+ try {
+ r.read(new char[100]);
+ fail("read did not fail");
+ } catch (IOException expected) { }
+ }
+
+ static void testFailingClose(Writer w) throws IOException {
+ System.out.println(w.getClass());
+ w.write("message");
+ try {
+ w.close();
+ fail("close did not fail");
+ } catch (IOException expected) { }
+ try {
+ w.write("another message");
+ fail("write did not fail");
+ } catch (IOException expected) { }
+ }
+
+ static void testFailingFlush(Writer w) throws IOException {
+ System.out.println(w.getClass());
+ w.write("message");
+ try {
+ w.flush();
+ fail("flush did not fail");
+ } catch (IOException expected) { }
+ if (w instanceof BufferedWriter) {
+ // assume this message will be buffered
+ w.write("another message");
+ try {
+ w.close();
+ fail("close did not fail");
+ } catch (IOException expected) { }
+ }
+ }
+
+ public static void main(String[] args) throws IOException {
+
+ testFailingClose(new BufferedInputStream(new FailingCloseInputStream()));
+ testFailingClose(new BufferedOutputStream(new FailingCloseOutputStream()));
+
+ testFailingClose(new BufferedReader(new FailingCloseReader()));
+ testFailingClose(new BufferedWriter(new FailingCloseWriter()));
+
+ testFailingFlush(new BufferedOutputStream(new FailingFlushOutputStream()));
+ testFailingFlush(new BufferedWriter(new FailingFlushWriter()));
+
+ if (failed > 0)
+ throw new RuntimeException(failed + " test(s) failed - see log for details");
+ }
+}
diff --git a/test/java/lang/ProcessBuilder/Basic.java b/test/java/lang/ProcessBuilder/Basic.java
index 677735474a83f3b69a81b0f0aafe90ae2daf1a6b..a9ba3b376c168c9f093e950fb67467bc65e4dc6c 100644
--- a/test/java/lang/ProcessBuilder/Basic.java
+++ b/test/java/lang/ProcessBuilder/Basic.java
@@ -1803,7 +1803,7 @@ public class Basic {
p.getInputStream().close();
p.getErrorStream().close();
- p.getOutputStream().close();
+ try { p.getOutputStream().close(); } catch (IOException flushFailed) { }
InputStream[] streams = { p.getInputStream(), p.getErrorStream() };
for (final InputStream in : streams) {
diff --git a/test/java/lang/management/ManagementFactory/GetObjectName.java b/test/java/lang/management/ManagementFactory/GetObjectName.java
new file mode 100644
index 0000000000000000000000000000000000000000..8333989c5c3037d2b9d06ad34988bf652b1563dd
--- /dev/null
+++ b/test/java/lang/management/ManagementFactory/GetObjectName.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+ * @bug 7068328
+ * @summary Test if getObjectName handles properly when called by
+ * multiple threads simultaneously. Run in othervm mode to
+ * make sure the object name is not initialized to begin with.
+ * @run main/othervm GetObjectName
+ */
+
+import java.lang.management.BufferPoolMXBean;
+import java.lang.management.ManagementFactory;
+import java.lang.management.PlatformLoggingMXBean;
+import java.lang.management.PlatformManagedObject;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+
+public class GetObjectName {
+ private static boolean failed = false;
+ public static void main(String[] args) throws Exception {
+ int tasks = 10000;
+ ExecutorService executor = Executors.newFixedThreadPool(10);
+ submitTasks(executor, tasks);
+ executor.shutdown();
+ executor.awaitTermination(10, TimeUnit.SECONDS);
+ if (!failed) {
+ System.out.println("Test passed.");
+ }
+ }
+
+ static void submitTasks(ExecutorService executor, int count) {
+ for (int i=0; i < count && !failed; i++) {
+ executor.execute(new Runnable() {
+ @Override
+ public void run() {
+ List mbeans = new ArrayList<>();
+ mbeans.add(ManagementFactory.getPlatformMXBean(PlatformLoggingMXBean.class));
+ mbeans.addAll(ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class));
+ for (PlatformManagedObject pmo : mbeans) {
+ // Name should not be null
+ if (pmo.getObjectName() == null) {
+ failed = true;
+ throw new RuntimeException("TEST FAILED: getObjectName() returns null");
+ }
+ }
+ }
+ });
+ }
+ }
+}
diff --git a/test/java/lang/reflect/Generics/Probe.java b/test/java/lang/reflect/Generics/Probe.java
index 2d9aa0144de464336705b0fd7fdd1a1f9bee6e86..15babb6c56c43be3e968cc20907ffdfee72bba94 100644
--- a/test/java/lang/reflect/Generics/Probe.java
+++ b/test/java/lang/reflect/Generics/Probe.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 5003916 6704655 6873951
+ * @bug 5003916 6704655 6873951 6476261
* @summary Testing parsing of signatures attributes of nested classes
* @author Joseph D. Darcy
*/
@@ -38,12 +38,12 @@ import static java.util.Arrays.*;
"java.util.concurrent.ConcurrentHashMap$KeyIterator",
"java.util.concurrent.ConcurrentHashMap$ValueIterator",
"java.util.AbstractList$ListItr",
-// "java.util.EnumMap$EntryIterator",
-// "java.util.EnumMap$KeyIterator",
-// "java.util.EnumMap$ValueIterator",
-// "java.util.IdentityHashMap$EntryIterator",
-// "java.util.IdentityHashMap$KeyIterator",
-// "java.util.IdentityHashMap$ValueIterator",
+ "java.util.EnumMap$EntryIterator",
+ "java.util.EnumMap$KeyIterator",
+ "java.util.EnumMap$ValueIterator",
+ "java.util.IdentityHashMap$EntryIterator",
+ "java.util.IdentityHashMap$KeyIterator",
+ "java.util.IdentityHashMap$ValueIterator",
"java.util.WeakHashMap$EntryIterator",
"java.util.WeakHashMap$KeyIterator",
"java.util.WeakHashMap$ValueIterator",
@@ -52,12 +52,12 @@ import static java.util.Arrays.*;
"java.util.HashMap$ValueIterator",
"java.util.LinkedHashMap$EntryIterator",
"java.util.LinkedHashMap$KeyIterator",
- "java.util.LinkedHashMap$ValueIterator"})
+ "java.util.LinkedHashMap$ValueIterator",
+ "javax.swing.JComboBox$AccessibleJComboBox"})
public class Probe {
public static void main (String... args) throws Throwable {
Classes classesAnnotation = (Probe.class).getAnnotation(Classes.class);
- List names =
- new ArrayList(asList(classesAnnotation.value()));
+ List names = new ArrayList<>(asList(classesAnnotation.value()));
int errs = 0;
for(String name: names) {
diff --git a/test/java/lang/reflect/Generics/SignatureTest.java b/test/java/lang/reflect/Generics/SignatureTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..993f74812a206af11cf2b3f377b80277669cd5a6
--- /dev/null
+++ b/test/java/lang/reflect/Generics/SignatureTest.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6476261
+ * @summary More testing of parsing of signatures attributes of nested classes
+ */
+
+import java.lang.reflect.*;
+
+public class SignatureTest {
+ class Inner1 {
+ class Inner11 {
+ }
+ }
+
+ public void f(SignatureTest.Inner1.Inner11 x) {}
+ public void g(SignatureTest.Inner1 x) {}
+
+ public static void main(String[] args) throws Exception {
+ Class clazz = SignatureTest.class;
+ for (Method m : clazz.getDeclaredMethods()) {
+ System.out.println();
+ System.out.println(m.toString());
+ System.out.println(m.toGenericString());
+ System.out.println(m.getGenericParameterTypes());
+ }
+ }
+}
diff --git a/test/java/lang/reflect/Generics/TestBadSignatures.java b/test/java/lang/reflect/Generics/TestBadSignatures.java
new file mode 100644
index 0000000000000000000000000000000000000000..6d380244ed27a006d4d944513afc224edbbe5bce
--- /dev/null
+++ b/test/java/lang/reflect/Generics/TestBadSignatures.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6832374 7052898
+ * @summary Test bad signatures get a GenericSignatureFormatError thrown.
+ * @author Joseph D. Darcy
+ */
+
+import java.lang.reflect.*;
+import sun.reflect.generics.parser.SignatureParser;
+
+public class TestBadSignatures {
+ public static void main(String[] args) {
+ String[] badSignatures = {
+ // Missing ":" after first type bound
+ "(TE;[Ljava/lang/RuntimeException;)V^[TE;",
+ };
+
+ for(String badSig : badSignatures) {
+ try {
+ SignatureParser.make().parseMethodSig(badSig);
+ throw new RuntimeException("Expected GenericSignatureFormatError for " +
+ badSig);
+ } catch(GenericSignatureFormatError gsfe) {
+ System.out.println(gsfe.toString()); // Expected
+ }
+ }
+ }
+}
diff --git a/test/java/net/CookieHandler/TestHttpCookie.java b/test/java/net/CookieHandler/TestHttpCookie.java
index 7d167532cd18e000f04f7eecec06a3de84dd63b6..cf93df935e9508b559466cf88edbb760f1928080 100644
--- a/test/java/net/CookieHandler/TestHttpCookie.java
+++ b/test/java/net/CookieHandler/TestHttpCookie.java
@@ -362,12 +362,13 @@ public class TestHttpCookie {
eq(c1, c2, false);
header("Test domainMatches()");
- dm(".foo.com", "y.x.foo.com", false);
- dm(".foo.com", "x.foo.com", true);
- dm(".com", "whatever.com", false);
- dm(".com.", "whatever.com", false);
- dm(".ajax.com", "ajax.com", true);
- dm(".local", "example.local", true);
+ dm(".foo.com", "y.x.foo.com", false);
+ dm(".foo.com", "x.foo.com", true);
+ dm(".com", "whatever.com", false);
+ dm(".com.", "whatever.com", false);
+ dm(".ajax.com", "ajax.com", true);
+ dm(".local", "example.local", true);
+ dm("example.local", "example", true);
// bug 6277808
testCount++;
diff --git a/test/java/nio/channels/DatagramChannel/NetworkConfiguration.java b/test/java/nio/channels/DatagramChannel/NetworkConfiguration.java
index f22b3503749b2ead83de558a09efc75aea5f250f..7833a4b892cbefff3a681a345c4db0618bbca9eb 100644
--- a/test/java/nio/channels/DatagramChannel/NetworkConfiguration.java
+++ b/test/java/nio/channels/DatagramChannel/NetworkConfiguration.java
@@ -57,11 +57,22 @@ class NetworkConfiguration {
return ip6Interfaces.get(nif);
}
+ // IPv6 not supported for Windows XP/Server 2003
+ static boolean isIPv6Supported() {
+ if (System.getProperty("os.name").startsWith("Windows")) {
+ String ver = System.getProperty("os.version");
+ int major = Integer.parseInt(ver.split("\\.")[0]);
+ return (major >= 6);
+ }
+ return true;
+ }
+
static NetworkConfiguration probe() throws IOException {
Map> ip4Interfaces =
new HashMap>();
Map> ip6Interfaces =
new HashMap>();
+ boolean isIPv6Supported = isIPv6Supported();
// find the interfaces that support IPv4 and IPv6
List nifs = Collections
@@ -81,7 +92,7 @@ class NetworkConfiguration {
}
list.add(addr);
ip4Interfaces.put(nif, list);
- } else if (addr instanceof Inet6Address) {
+ } else if (isIPv6Supported && (addr instanceof Inet6Address)) {
List list = ip6Interfaces.get(nif);
if (list == null) {
list = new LinkedList();
diff --git a/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java b/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java
index 6d444d50f9b0772687c2fbb11063156034cae795..426a98eb86d829b5dd9747e1a2be43b58cbeaa66 100644
--- a/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java
+++ b/test/java/nio/channels/DatagramChannel/SelectWhenRefused.java
@@ -22,7 +22,7 @@
*/
/* @test
- * @bug 6935563
+ * @bug 6935563 7044870
* @summary Test that Selector does not select an unconnected DatagramChannel when
* ICMP port unreachable received
*/
@@ -35,14 +35,15 @@ import java.io.IOException;
public class SelectWhenRefused {
public static void main(String[] args) throws IOException {
- DatagramChannel dc = DatagramChannel.open().bind(new InetSocketAddress(0));
- int port = dc.socket().getLocalPort();
- dc.close();
+ DatagramChannel dc1 = DatagramChannel.open().bind(new InetSocketAddress(0));
+ int port = dc1.socket().getLocalPort();
// datagram sent to this address should be refused
SocketAddress refuser = new InetSocketAddress(InetAddress.getLocalHost(), port);
- dc = DatagramChannel.open().bind(new InetSocketAddress(0));
+ DatagramChannel dc = DatagramChannel.open().bind(new InetSocketAddress(0));
+ dc1.close();
+
Selector sel = Selector.open();
try {
dc.configureBlocking(false);
@@ -52,6 +53,10 @@ public class SelectWhenRefused {
sendDatagram(dc, refuser);
int n = sel.select(2000);
if (n > 0) {
+ sel.selectedKeys().clear();
+ // BindException will be thrown if another service is using
+ // our expected refuser port, cannot run just exit.
+ DatagramChannel.open().bind(refuser).close();
throw new RuntimeException("Unexpected wakeup");
}
@@ -80,6 +85,8 @@ public class SelectWhenRefused {
throw new RuntimeException("Unexpected wakeup after disconnect");
}
+ } catch(BindException e) {
+ // Do nothing, some other test has used this port
} finally {
sel.close();
dc.close();
diff --git a/test/javax/swing/GroupLayout/7071166/bug7071166.java b/test/javax/swing/GroupLayout/7071166/bug7071166.java
new file mode 100644
index 0000000000000000000000000000000000000000..d579699ffd8a581a51f85f85ec8ddf269f4fc114
--- /dev/null
+++ b/test/javax/swing/GroupLayout/7071166/bug7071166.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7071166
+ * @summary LayoutStyle.getPreferredGap() - IAE is expected but not thrown
+ * @author Pavel Porvatov
+ */
+
+import javax.swing.*;
+import static javax.swing.SwingConstants.*;
+import java.awt.*;
+
+public class bug7071166 {
+ private static final int[] POSITIONS = {NORTH, EAST, SOUTH, WEST, // valid positions
+ NORTH_EAST, SOUTH_EAST, SOUTH_WEST, NORTH_WEST, 123, -456}; // invalid positions
+
+ public static void main(String[] args) throws Exception {
+ for (UIManager.LookAndFeelInfo lookAndFeelInfo : UIManager.getInstalledLookAndFeels()) {
+ UIManager.setLookAndFeel(lookAndFeelInfo.getClassName());
+
+ System.out.println("LookAndFeel: " + lookAndFeelInfo.getName());
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ LayoutStyle layoutStyle = LayoutStyle.getInstance();
+
+ System.out.println("LayoutStyle: " + layoutStyle);
+
+ for (int i = 0; i < POSITIONS.length; i++) {
+ int position = POSITIONS[i];
+
+ try {
+ layoutStyle.getPreferredGap(new JButton(), new JButton(),
+ LayoutStyle.ComponentPlacement.RELATED, position, new Container());
+
+ if (i > 3) {
+ throw new RuntimeException("IllegalArgumentException is not thrown for position " +
+ position);
+ }
+ } catch (IllegalArgumentException e) {
+ if (i <= 3) {
+ throw new RuntimeException("IllegalArgumentException is thrown for position " +
+ position);
+ }
+ }
+ }
+ }
+ });
+
+ System.out.println("passed");
+ }
+ }
+}