This commit is contained in:
Lana Steuck 2016-06-23 21:13:13 +00:00
commit a3a286d448
93 changed files with 1707 additions and 957 deletions
jdk
src
test

@ -1,5 +1,5 @@
/*
* Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1994, 2016, 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
@ -359,10 +359,10 @@ class BufferedInputStream extends FilterInputStream {
* See the general contract of the <code>skip</code>
* method of <code>InputStream</code>.
*
* @exception IOException if the stream does not support seek,
* or if this input stream has been closed by
* invoking its {@link #close()} method, or an
* I/O error occurs.
* @throws IOException if this input stream has been closed by
* invoking its {@link #close()} method,
* {@code in.skip(n)} throws an IOException,
* or an I/O error occurs.
*/
public synchronized long skip(long n) throws IOException {
getBufIfOpen(); // Check for closed stream

@ -1,5 +1,5 @@
/*
* Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1994, 2016, 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
@ -144,8 +144,7 @@ class FilterInputStream extends InputStream {
*
* @param n the number of bytes to be skipped.
* @return the actual number of bytes skipped.
* @exception IOException if the stream does not support seek,
* or if some other I/O error occurs.
* @throws IOException if {@code in.skip(n)} throws an IOException.
*/
public long skip(long n) throws IOException {
return in.skip(n);

@ -1,5 +1,5 @@
/*
* Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1994, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -325,7 +325,7 @@ public abstract class InputStream implements Closeable {
* returns 0, and no bytes are skipped. Subclasses may handle the negative
* value differently.
*
* <p> The <code>skip</code> method of this class creates a
* <p> The <code>skip</code> method implementation of this class creates a
* byte array and then repeatedly reads into it until <code>n</code> bytes
* have been read or the end of the stream has been reached. Subclasses are
* encouraged to provide a more efficient implementation of this method.
@ -333,8 +333,7 @@ public abstract class InputStream implements Closeable {
*
* @param n the number of bytes to be skipped.
* @return the actual number of bytes skipped.
* @exception IOException if the stream does not support seek,
* or if some other I/O error occurs.
* @throws IOException if an I/O error occurs.
*/
public long skip(long n) throws IOException {

@ -1,5 +1,5 @@
/*
* Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1994, 2016, 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
@ -291,10 +291,10 @@ class PushbackInputStream extends FilterInputStream {
*
* @param n {@inheritDoc}
* @return {@inheritDoc}
* @exception IOException if the stream does not support seek,
* or the stream has been closed by
* invoking its {@link #close()} method,
* or an I/O error occurs.
* @throws IOException if the stream has been closed by
* invoking its {@link #close()} method,
* {@code in.skip(n)} throws an IOException,
* or an I/O error occurs.
* @see java.io.FilterInputStream#in
* @see java.io.InputStream#skip(long n)
* @since 1.2

@ -300,8 +300,9 @@ class MulticastSocket extends DatagramSocket {
*
* @param mcastaddr is the multicast address to join
*
* @exception IOException if there is an error joining
* or when the address is not a multicast address.
* @exception IOException if there is an error joining, or when the address
* is not a multicast address, or the platform does not support
* multicasting
* @exception SecurityException if a security manager exists and its
* {@code checkMulticast} method doesn't allow the join.
*
@ -384,8 +385,9 @@ class MulticastSocket extends DatagramSocket {
* {@link MulticastSocket#setInterface(InetAddress)} or
* {@link MulticastSocket#setNetworkInterface(NetworkInterface)}
*
* @exception IOException if there is an error joining
* or when the address is not a multicast address.
* @exception IOException if there is an error joining, or when the address
* is not a multicast address, or the platform does not support
* multicasting
* @exception SecurityException if a security manager exists and its
* {@code checkMulticast} method doesn't allow the join.
* @throws IllegalArgumentException if mcastaddr is null or is a

@ -265,8 +265,14 @@ public final class URLPermission extends Permission {
URLPermission that = (URLPermission)p;
if (!this.methods.get(0).equals("*") &&
Collections.indexOfSubList(this.methods, that.methods) == -1) {
if (this.methods.isEmpty() && !that.methods.isEmpty()) {
return false;
}
if (!this.methods.isEmpty() &&
!this.methods.get(0).equals("*") &&
Collections.indexOfSubList(this.methods,
that.methods) == -1) {
return false;
}
@ -455,15 +461,11 @@ public final class URLPermission extends Permission {
}
private String actions() {
StringBuilder b = new StringBuilder();
for (String s : methods) {
b.append(s);
String b = String.join(",", methods);
if (!requestHeaders.isEmpty()) {
b += ":" + String.join(",", requestHeaders);
}
b.append(":");
for (String s : requestHeaders) {
b.append(s);
}
return b.toString();
return b;
}
/**

@ -40,10 +40,11 @@ import java.net.StandardSocketOptions; // javadoc
* address.
*
* <p> In the case of a channel to an {@link StandardProtocolFamily#INET IPv4} socket,
* the underlying operating system supports <a href="http://www.ietf.org/rfc/rfc2236.txt">
* <i>RFC&nbsp;2236: Internet Group Management Protocol, Version 2 (IGMPv2)</i></a>.
* It may optionally support source filtering as specified by <a
* href="http://www.ietf.org/rfc/rfc3376.txt"> <i>RFC&nbsp;3376: Internet Group
* the underlying operating system optionally supports
* <a href="http://www.ietf.org/rfc/rfc2236.txt"> <i>RFC&nbsp;2236: Internet Group
* Management Protocol, Version 2 (IGMPv2)</i></a>. When IGMPv2 is supported then
* the operating system may additionally support source filtering as specified by
* <a href="http://www.ietf.org/rfc/rfc3376.txt"> <i>RFC&nbsp;3376: Internet Group
* Management Protocol, Version 3 (IGMPv3)</i></a>.
* For channels to an {@link StandardProtocolFamily#INET6 IPv6} socket, the equivalent
* standards are <a href="http://www.ietf.org/rfc/rfc2710.txt"> <i>RFC&nbsp;2710:
@ -167,7 +168,8 @@ public interface MulticastChannel
* If the channel already has source-specific membership of the
* group on the interface
* @throws UnsupportedOperationException
* If the channel's socket is not an Internet Protocol socket
* If the channel's socket is not an Internet Protocol socket, or
* the platform does not support multicasting
* @throws ClosedChannelException
* If this channel is closed
* @throws IOException
@ -214,8 +216,9 @@ public interface MulticastChannel
* If the channel is currently a member of the group on the given
* interface to receive all datagrams
* @throws UnsupportedOperationException
* If the channel's socket is not an Internet Protocol socket or
* source filtering is not supported
* If the channel's socket is not an Internet Protocol socket, or
* source filtering is not supported, or the platform does not
* support multicasting
* @throws ClosedChannelException
* If this channel is closed
* @throws IOException

@ -3895,8 +3895,7 @@ public final class Formatter implements Closeable, Flushable {
TimeZone tz = t.getTimeZone();
sb.append(tz.getDisplayName((t.get(Calendar.DST_OFFSET) != 0),
TimeZone.SHORT,
Objects.requireNonNullElse(l,
Locale.getDefault(Locale.Category.FORMAT))));
Objects.requireNonNullElse(l, Locale.US)));
break;
}
@ -3904,8 +3903,7 @@ public final class Formatter implements Closeable, Flushable {
case DateTime.NAME_OF_DAY_ABBREV: // 'a'
case DateTime.NAME_OF_DAY: { // 'A'
int i = t.get(Calendar.DAY_OF_WEEK);
Locale lt = Objects.requireNonNullElse(l,
Locale.getDefault(Locale.Category.FORMAT));
Locale lt = Objects.requireNonNullElse(l, Locale.US);
DateFormatSymbols dfs = DateFormatSymbols.getInstance(lt);
if (c == DateTime.NAME_OF_DAY)
sb.append(dfs.getWeekdays()[i]);
@ -3917,8 +3915,7 @@ public final class Formatter implements Closeable, Flushable {
case DateTime.NAME_OF_MONTH_ABBREV_X: // 'h' -- same b
case DateTime.NAME_OF_MONTH: { // 'B'
int i = t.get(Calendar.MONTH);
Locale lt = Objects.requireNonNullElse(l,
Locale.getDefault(Locale.Category.FORMAT));
Locale lt = Objects.requireNonNullElse(l, Locale.US);
DateFormatSymbols dfs = DateFormatSymbols.getInstance(lt);
if (c == DateTime.NAME_OF_MONTH)
sb.append(dfs.getMonths()[i]);

@ -925,7 +925,6 @@ public final class Scanner implements Iterator<String>, Closeable {
needInput = true;
return null;
}
// Must look for next delims. Simply attempting to match the
// pattern at this point may find a match but it might not be
// the first longest match because of missing input, or it might
@ -941,16 +940,13 @@ public final class Scanner implements Iterator<String>, Closeable {
foundNextDelim = matcher.find();
}
if (foundNextDelim) {
// In two rare cases that more input might cause the match to be
// lost or change.
// (1) if requireEnd() is true, more input might cause the match
// to be lost, we must wait for more input.
// (2) while hitting the end is okay IF the match does not
// go away AND the beginning of the next delims does not change
// (we don't care if they potentially extend further). But it's
// possible that more input could cause the beginning of the
// delims change, so have to wait for more input as well.
if ((matcher.requireEnd() || matcher.hitEnd()) && !sourceClosed) {
// In the rare case that more input could cause the match
// to be lost and there is more input coming we must wait
// for more input. Note that hitting the end is okay as long
// as the match cannot go away. It is the beginning of the
// next delims we want to be sure about, we don't care if
// they potentially extend further.
if (matcher.requireEnd() && !sourceClosed) {
needInput = true;
return null;
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1994, 2016, 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
@ -165,8 +165,10 @@ public class NetworkClient {
// server & port will be the proxy address and port
s = new Socket(Proxy.NO_PROXY);
}
} else
} else {
s = createSocket();
}
// Instance specific timeouts do have priority, that means
// connectTimeout & readTimeout (-1 means not set)
// Then global default timeouts
@ -194,7 +196,7 @@ public class NetworkClient {
* to create the socket.
*/
protected Socket createSocket() throws IOException {
return new java.net.Socket();
return new java.net.Socket(Proxy.NO_PROXY); // direct connection
}
protected InetAddress getLocalAddress() throws IOException {

@ -1,97 +0,0 @@
/*
* Copyright (c) 1996, 1998, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*-
* netdoc urls point either into the local filesystem or externally
* through an http url, with network documents being preferred. Useful for
* FAQs & other documents which are likely to be changing over time at the
* central site, and where the user will want the most recent edition.
*
* @author Steven B. Byrne
*/
package sun.net.www.protocol.netdoc;
import java.net.URL;
import java.net.URLConnection;
import java.net.MalformedURLException;
import java.net.URLStreamHandler;
import java.io.InputStream;
import java.io.IOException;
import sun.security.action.GetPropertyAction;
public class Handler extends URLStreamHandler {
static URL base;
/*
* Attempt to find a load the given url using the default (network)
* documentation location. If that fails, use the local copy
*/
public synchronized URLConnection openConnection(URL u)
throws IOException
{
URLConnection uc = null;
URL ru;
boolean localonly = Boolean.parseBoolean(
GetPropertyAction.privilegedGetProperty("newdoc.localonly"));
String docurl = GetPropertyAction.privilegedGetProperty("doc.url");
String file = u.getFile();
if (!localonly) {
try {
if (base == null) {
base = new URL(docurl);
}
ru = new URL(base, file);
} catch (MalformedURLException e) {
ru = null;
}
if (ru != null) {
uc = ru.openConnection();
}
}
if (uc == null) {
try {
ru = new URL("file", "~", file);
uc = ru.openConnection();
InputStream is = uc.getInputStream(); // Check for success.
} catch (MalformedURLException e) {
uc = null;
} catch (IOException e) {
uc = null;
}
}
if (uc == null) {
throw new IOException("Can't find file for URL: "
+u.toExternalForm());
}
return uc;
}
}

@ -354,8 +354,8 @@ abstract class SeedGenerator {
// We wait 250milli quanta, so the minimum wait time
// cannot be under 250milli.
int latch = 0;
long l = System.currentTimeMillis() + 250;
while (System.currentTimeMillis() < l) {
long startTime = System.nanoTime();
while (System.nanoTime() - startTime < 250000000) {
synchronized(this){};
latch++;
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2016, 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,7 +34,6 @@ import java.nio.charset.CoderResult;
import java.nio.charset.CodingErrorAction;
import java.nio.charset.StandardCharsets;
import java.util.Objects;
import sun.util.logging.PlatformLogger;
/**
* A Charset implementation for reading PropertyResourceBundle, in order
@ -94,12 +93,11 @@ public class PropertyResourceBundleCharset extends Charset {
return cr;
}
// Invalid or unmappable UTF-8 sequence detected.
// Switching to the ISO 8859-1 decorder.
assert cr.isMalformed() || cr.isUnmappable();
in.reset();
out.reset();
PlatformLogger.getLogger(getClass().getCanonicalName()).info(
"Invalid or unmappable UTF-8 sequence detected. " +
"Switching encoding from UTF-8 to ISO-8859-1");
cdISO_8859_1 = StandardCharsets.ISO_8859_1.newDecoder();
return cdISO_8859_1.decode(in, out, false);
}

@ -617,6 +617,7 @@ class Stream extends ExchangeImpl {
void sendBodyImpl() throws IOException, InterruptedException {
if (requestContentLen == 0) {
// no body
requestSent();
return;
}
DataFrame df;
@ -667,7 +668,7 @@ class Stream extends ExchangeImpl {
responseFlowController); // TODO: filter headers
if (body == null) {
receiveData();
return processor.onResponseComplete();
body = processor.onResponseComplete();
} else
receiveDataAsync(processor);
responseReceived();

@ -34,7 +34,6 @@ import java.util.concurrent.CompletionStage;
import java.util.concurrent.Executor;
import java.util.function.Consumer;
import java.util.function.Supplier;
import java.util.stream.Stream;
import static java.lang.System.Logger.Level.ERROR;
import static java.lang.System.Logger.Level.WARNING;
@ -103,15 +102,6 @@ final class WS implements WebSocket {
}
}
@Override
public CompletableFuture<WebSocket> sendText(Stream<? extends CharSequence> message) {
requireNonNull(message, "message");
synchronized (stateLock) {
checkState();
return transmitter.sendText(message);
}
}
@Override
public CompletableFuture<WebSocket> sendBinary(ByteBuffer message, boolean isLast) {
requireNonNull(message, "message");
@ -179,11 +169,11 @@ final class WS implements WebSocket {
}
@Override
public long request(long n) {
public void request(long n) {
if (n < 0L) {
throw new IllegalArgumentException("The number must not be negative: " + n);
}
return receiver.request(n);
receiver.request(n);
}
@Override

@ -25,6 +25,7 @@
package java.net.http;
import java.net.URI;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@ -59,8 +60,7 @@ final class WSBuilder implements WebSocket.Builder {
private final LinkedHashMap<String, List<String>> headers = new LinkedHashMap<>();
private final WebSocket.Listener listener;
private Collection<String> subprotocols = Collections.emptyList();
private long timeout;
private TimeUnit timeUnit;
private Duration timeout;
WSBuilder(URI uri, HttpClient client, WebSocket.Listener listener) {
checkURI(requireNonNull(uri, "uri"));
@ -93,13 +93,8 @@ final class WSBuilder implements WebSocket.Builder {
}
@Override
public WebSocket.Builder connectTimeout(long timeout, TimeUnit unit) {
if (timeout < 0) {
throw new IllegalArgumentException("Negative timeout: " + timeout);
}
requireNonNull(unit, "unit");
this.timeout = timeout;
this.timeUnit = unit;
public WebSocket.Builder connectTimeout(Duration timeout) {
this.timeout = requireNonNull(timeout, "timeout");
return this;
}
@ -139,9 +134,7 @@ final class WSBuilder implements WebSocket.Builder {
return new ArrayList<>(subprotocols);
}
long getTimeout() { return timeout; }
TimeUnit getTimeUnit() { return timeUnit; }
Duration getConnectTimeout() { return timeout; }
private static Collection<String> checkSubprotocols(String mostPreferred,
String... lesserPreferred) {

@ -206,7 +206,7 @@ final class WSFrameConsumer implements WSFrame.Consumer {
boolean binaryNonEmpty = data.hasRemaining();
WSShared<CharBuffer> textData;
try {
textData = decoder.decode(data, part.isLast());
textData = decoder.decode(data, part == MessagePart.WHOLE || part == MessagePart.LAST);
} catch (CharacterCodingException e) {
throw new WSProtocolException
("5.6.", "Invalid UTF-8 sequence in frame " + opcode, NOT_CONSISTENT, e);

@ -30,7 +30,6 @@ import java.net.http.WSOutgoingMessage.Binary;
import java.net.http.WSOutgoingMessage.Close;
import java.net.http.WSOutgoingMessage.Ping;
import java.net.http.WSOutgoingMessage.Pong;
import java.net.http.WSOutgoingMessage.StreamedText;
import java.net.http.WSOutgoingMessage.Text;
import java.net.http.WSOutgoingMessage.Visitor;
import java.nio.ByteBuffer;
@ -122,11 +121,6 @@ final class WSMessageSender {
previousIsLast = message.isLast;
}
@Override
public void visit(StreamedText streamedText) {
throw new IllegalArgumentException("Not yet implemented");
}
@Override
public void visit(Binary message) {
buffers[1] = message.bytes;

@ -32,11 +32,14 @@ import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.time.Duration;
import java.time.temporal.ChronoUnit;
import java.util.Arrays;
import java.util.Base64;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import java.util.function.Predicate;
import java.util.stream.Collectors;
@ -77,8 +80,12 @@ final class WSOpeningHandshake {
WSOpeningHandshake(WSBuilder b) {
URI httpURI = createHttpUri(b.getUri());
HttpRequest.Builder requestBuilder = b.getClient().request(httpURI);
if (b.getTimeUnit() != null) {
requestBuilder.timeout(b.getTimeUnit(), b.getTimeout());
Duration connectTimeout = b.getConnectTimeout();
if (connectTimeout != null) {
requestBuilder.timeout(
TimeUnit.of(ChronoUnit.MILLIS),
connectTimeout.get(ChronoUnit.MILLIS)
);
}
Collection<String> s = b.getSubprotocols();
if (!s.isEmpty()) {

@ -25,13 +25,11 @@
package java.net.http;
import java.nio.ByteBuffer;
import java.util.stream.Stream;
abstract class WSOutgoingMessage {
interface Visitor {
void visit(Text message);
void visit(StreamedText message);
void visit(Binary message);
void visit(Ping message);
void visit(Pong message);
@ -64,25 +62,6 @@ abstract class WSOutgoingMessage {
}
}
static final class StreamedText extends WSOutgoingMessage {
public final Stream<? extends CharSequence> characters;
StreamedText(Stream<? extends CharSequence> characters) {
this.characters = characters;
}
@Override
void accept(Visitor visitor) {
visitor.visit(this);
}
@Override
public String toString() {
return WSUtils.toStringSimple(this) + "[characters=" + characters + "]";
}
}
static final class Binary extends WSOutgoingMessage {
public final boolean isLast;

@ -101,11 +101,10 @@ final class WSReceiver {
}
}
long request(long n) {
void request(long n) {
long newDemand = demand.accumulateAndGet(n, (p, i) -> p + i < 0 ? Long.MAX_VALUE : p + i);
handler.signal();
assert newDemand >= 0 : newDemand;
return newDemand;
}
private boolean getData() throws IOException {

@ -28,7 +28,6 @@ import java.net.http.WSOutgoingMessage.Binary;
import java.net.http.WSOutgoingMessage.Close;
import java.net.http.WSOutgoingMessage.Ping;
import java.net.http.WSOutgoingMessage.Pong;
import java.net.http.WSOutgoingMessage.StreamedText;
import java.net.http.WSOutgoingMessage.Text;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
@ -40,7 +39,6 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.function.Consumer;
import java.util.stream.Stream;
import static java.lang.String.format;
import static java.net.http.Pair.pair;
@ -83,11 +81,6 @@ final class WSTransmitter {
return acceptMessage(new Text(isLast, message));
}
CompletableFuture<WebSocket> sendText(Stream<? extends CharSequence> message) {
checkAndUpdateText(true);
return acceptMessage(new StreamedText(message));
}
CompletableFuture<WebSocket> sendBinary(ByteBuffer message, boolean isLast) {
checkAndUpdateBinary(isLast);
return acceptMessage(new Binary(isLast, message));

@ -28,13 +28,11 @@ import java.io.IOException;
import java.net.ProtocolException;
import java.net.URI;
import java.nio.ByteBuffer;
import java.time.Duration;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.TimeUnit;
import java.util.stream.Stream;
/**
* A WebSocket client conforming to RFC&nbsp;6455.
@ -47,8 +45,9 @@ import java.util.stream.Stream;
* receive messages. When the {@code WebSocket} is no longer
* needed it must be closed: a Close message must both be {@linkplain
* #sendClose() sent} and {@linkplain Listener#onClose(WebSocket, Optional,
* String) received}. Or to close abruptly, {@link #abort()} is called. Once
* closed it remains closed, cannot be reopened.
* String) received}. Otherwise, invoke {@link #abort() abort} to close abruptly.
*
* <p> Once closed the {@code WebSocket} remains closed and cannot be reopened.
*
* <p> Messages of type {@code X} are sent through the {@code WebSocket.sendX}
* methods and received through {@link WebSocket.Listener}{@code .onX} methods
@ -71,10 +70,6 @@ import java.util.stream.Stream;
* arranged from the {@code buffer}'s {@link ByteBuffer#position() position} to
* the {@code buffer}'s {@link ByteBuffer#limit() limit}.
*
* <p> All message exchange is run by the threads belonging to the {@linkplain
* HttpClient#executorService() executor service} of {@code WebSocket}'s {@link
* HttpClient}.
*
* <p> Unless otherwise noted, passing a {@code null} argument to a constructor
* or method of this type will cause a {@link NullPointerException
* NullPointerException} to be thrown.
@ -217,22 +212,17 @@ public interface WebSocket {
* Sets a timeout for the opening handshake.
*
* <p> If the opening handshake is not finished within the specified
* timeout then {@link #buildAsync()} completes exceptionally with a
* {@code HttpTimeoutException}.
* amount of time then {@link #buildAsync()} completes exceptionally
* with a {@code HttpTimeoutException}.
*
* <p> If the timeout is not specified then it's deemed infinite.
* <p> If this method is not invoked then the timeout is deemed infinite.
*
* @param timeout
* the maximum time to wait
* @param unit
* the time unit of the timeout argument
* the timeout
*
* @return this builder
*
* @throws IllegalArgumentException
* if the {@code timeout} is negative
*/
Builder connectTimeout(long timeout, TimeUnit unit);
Builder connectTimeout(Duration timeout);
/**
* Builds a {@code WebSocket}.
@ -506,7 +496,7 @@ public interface WebSocket {
* <p> Once a Close message is received, the server will not send any
* more messages.
*
* <p> A Close message may consist of a close code and a reason for
* <p> A Close message may consist of a status code and a reason for
* closing. The reason will have a UTF-8 representation not longer than
* {@code 123} bytes. The reason may be useful for debugging or passing
* information relevant to the connection but is not necessarily human
@ -545,12 +535,8 @@ public interface WebSocket {
* the time {@code onError} is invoked, no more messages can be sent on
* this {@code WebSocket}.
*
* @apiNote Errors associated with send operations ({@link
* WebSocket#sendText(CharSequence, boolean) sendText}, {@link
* #sendBinary(ByteBuffer, boolean) sendBinary}, {@link
* #sendPing(ByteBuffer) sendPing}, {@link #sendPong(ByteBuffer)
* sendPong} and {@link #sendClose(CloseCode, CharSequence) sendClose})
* are reported to the {@code CompletionStage} operations return.
* @apiNote Errors associated with {@code sendX} methods are reported to
* the {@code CompletableFuture} these methods return.
*
* @implSpec The default implementation does nothing.
*
@ -563,8 +549,8 @@ public interface WebSocket {
}
/**
* A marker used by {@link WebSocket.Listener} for partial message
* receiving.
* A marker used by {@link WebSocket.Listener} in cases where a partial
* message may be received.
*
* @since 9
*/
@ -586,19 +572,9 @@ public interface WebSocket {
LAST,
/**
* A whole message. The message consists of a single part.
* A whole message consisting of a single part.
*/
WHOLE;
/**
* Tells whether a part of a message received with this marker is the
* last part.
*
* @return {@code true} if LAST or WHOLE, {@code false} otherwise
*/
public boolean isLast() {
return this == LAST || this == WHOLE;
}
WHOLE
}
/**
@ -630,7 +606,7 @@ public interface WebSocket {
* @param message
* the message
* @param isLast
* {@code true} if this is the final part of the message,
* {@code true} if this is the last part of the message,
* {@code false} otherwise
*
* @return a CompletableFuture with this WebSocket
@ -678,43 +654,6 @@ public interface WebSocket {
return sendText(message, true);
}
/**
* Sends a whole Text message with characters from {@code
* CharacterSequence}s provided by the given {@code Stream}.
*
* <p> This is a convenience method. For the general case use {@link
* #sendText(CharSequence, boolean)}.
*
* <p> Returns a {@code CompletableFuture<WebSocket>} which completes
* normally when the message has been sent or completes exceptionally if an
* error occurs.
*
* <p> Streamed character sequences should not be modified until the
* returned {@code CompletableFuture} completes (either normally or
* exceptionally).
*
* <p> The returned {@code CompletableFuture} can complete exceptionally
* with:
* <ul>
* <li> {@link IOException}
* if an I/O error occurs during this operation
* <li> {@link IllegalStateException}
* if the {@code WebSocket} closes while this operation is in progress;
* or if a Close message has been sent already;
* or if there is an outstanding send operation;
* or if a previous Binary message was not sent with {@code isLast == true}
* </ul>
*
* @param message
* the message
*
* @return a CompletableFuture with this WebSocket
*
* @throws IllegalArgumentException
* if {@code message} is a malformed (or an incomplete) UTF-16 sequence
*/
CompletableFuture<WebSocket> sendText(Stream<? extends CharSequence> message);
/**
* Sends a Binary message with bytes from the given {@code ByteBuffer}.
*
@ -737,50 +676,13 @@ public interface WebSocket {
* @param message
* the message
* @param isLast
* {@code true} if this is the final part of the message,
* {@code true} if this is the last part of the message,
* {@code false} otherwise
*
* @return a CompletableFuture with this WebSocket
*/
CompletableFuture<WebSocket> sendBinary(ByteBuffer message, boolean isLast);
/**
* Sends a Binary message with bytes from the given {@code byte[]}.
*
* <p> Returns a {@code CompletableFuture<WebSocket>} which completes
* normally when the message has been sent or completes exceptionally if an
* error occurs.
*
* <p> The returned {@code CompletableFuture} can complete exceptionally
* with:
* <ul>
* <li> {@link IOException}
* if an I/O error occurs during this operation
* <li> {@link IllegalStateException}
* if the {@code WebSocket} closes while this operation is in progress;
* or if a Close message has been sent already;
* or if there is an outstanding send operation;
* or if a previous Text message was not sent with {@code isLast == true}
* </ul>
*
* @implSpec This is equivalent to:
* <pre>{@code
* sendBinary(ByteBuffer.wrap(message), isLast)
* }</pre>
*
* @param message
* the message
* @param isLast
* {@code true} if this is the final part of the message,
* {@code false} otherwise
*
* @return a CompletableFuture with this WebSocket
*/
default CompletableFuture<WebSocket> sendBinary(byte[] message, boolean isLast) {
Objects.requireNonNull(message, "message");
return sendBinary(ByteBuffer.wrap(message), isLast);
}
/**
* Sends a Ping message.
*
@ -858,10 +760,11 @@ public interface WebSocket {
* normally when the message has been sent or completes exceptionally if an
* error occurs.
*
* <p> A Close message may consist of a close code and a reason for closing.
* The reason must have a valid UTF-8 representation not longer than {@code
* 123} bytes. The reason may be useful for debugging or passing information
* relevant to the connection but is not necessarily human readable.
* <p> A Close message may consist of a status code and a reason for
* closing. The reason must have a UTF-8 representation not longer than
* {@code 123} bytes. The reason may be useful for debugging or passing
* information relevant to the connection but is not necessarily human
* readable.
*
* <p> The returned {@code CompletableFuture} can complete exceptionally
* with:
@ -910,24 +813,21 @@ public interface WebSocket {
CompletableFuture<WebSocket> sendClose();
/**
* Requests {@code n} more messages to be received by the {@link Listener
* Allows {@code n} more messages to be received by the {@link Listener
* Listener}.
*
* <p> The actual number might be fewer if either of the endpoints decide to
* close the connection before that or an error occurs.
* <p> The actual number of received messages might be fewer if a Close
* message is received, the connection closes or an error occurs.
*
* <p> A {@code WebSocket} that has just been created, hasn't requested
* anything yet. Usually the initial request for messages is done in {@link
* Listener#onOpen(java.net.http.WebSocket) Listener.onOpen}.
*
* If all requested messages have been received, and the server sends more,
* then these messages are queued.
*
* @implNote This implementation does not distinguish between partial and
* whole messages, because it's not known beforehand how a message will be
* received.
*
* <p> If a server sends more messages than requested, the implementation
* <p> If a server sends more messages than requested, this implementation
* queues up these messages on the TCP connection and may eventually force
* the sender to stop sending through TCP flow control.
*
@ -936,12 +836,8 @@ public interface WebSocket {
*
* @throws IllegalArgumentException
* if {@code n < 0}
*
* @return resulting unfulfilled demand with this request taken into account
*/
// TODO return void as it's breaking encapsulation (leaking info when exactly something deemed delivered)
// or demand behaves after LONG.MAX_VALUE
long request(long n);
void request(long n);
/**
* Returns a {@linkplain Builder#subprotocols(String, String...) subprotocol}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2016, 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
@ -60,7 +60,6 @@ class DigestClientId extends SimpleClientId {
final private String[] propvals;
final private int myHash;
private int pHash = 0;
DigestClientId(int version, String hostname, int port,
String protocol, Control[] bindCtls, OutputStream trace,
@ -78,12 +77,9 @@ class DigestClientId extends SimpleClientId {
propvals = new String[SASL_PROPS.length];
for (int i = 0; i < SASL_PROPS.length; i++) {
propvals[i] = (String) env.get(SASL_PROPS[i]);
if (propvals[i] != null) {
pHash = pHash * 31 + propvals[i].hashCode();
}
}
}
myHash = super.hashCode() + pHash;
myHash = super.hashCode() ^ Arrays.hashCode(propvals);
}
public boolean equals(Object obj) {
@ -92,7 +88,6 @@ class DigestClientId extends SimpleClientId {
}
DigestClientId other = (DigestClientId)obj;
return myHash == other.myHash
&& pHash == other.pHash
&& super.equals(obj)
&& Arrays.equals(propvals, other.propvals);
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2016, 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
@ -49,21 +49,23 @@ class SimpleClientId extends ClientId {
socketFactory);
this.username = username;
int pwdHashCode = 0;
if (passwd == null) {
this.passwd = null;
} else if (passwd instanceof String) {
this.passwd = passwd;
} else if (passwd instanceof byte[]) {
this.passwd = ((byte[])passwd).clone();
pwdHashCode = Arrays.hashCode((byte[])passwd);
} else if (passwd instanceof char[]) {
this.passwd = ((char[])passwd).clone();
pwdHashCode = Arrays.hashCode((char[])passwd);
} else {
this.passwd = passwd;
pwdHashCode = passwd.hashCode();
}
myHash = super.hashCode()
+ (username != null ? username.hashCode() : 0)
+ (passwd != null ? passwd.hashCode() : 0);
^ (username != null ? username.hashCode() : 0)
^ pwdHashCode;
}
public boolean equals(Object obj) {

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
*/
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
@ -54,6 +54,8 @@ import java.util.*;
import java.security.AccessController;
import java.security.PrivilegedAction;
import sun.security.util.Debug;
import static sun.security.pkcs11.wrapper.PKCS11Constants.*;
/**
@ -85,7 +87,8 @@ public class PKCS11 {
return null;
}
});
initializeLibrary();
boolean enableDebug = Debug.getInstance("sunpkcs11") != null;
initializeLibrary(enableDebug);
}
public static void loadNative() {
@ -109,7 +112,7 @@ public class PKCS11 {
* @preconditions
* @postconditions
*/
private static native void initializeLibrary();
private static native void initializeLibrary(boolean debug);
// XXX
/**

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
*/
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
@ -73,6 +73,8 @@ jclass jLongClass;
JavaVM* jvm = NULL;
jboolean debug = 0;
JNIEXPORT jint JNICALL DEF_JNI_OnLoad(JavaVM *vm, void *reserved) {
jvm = vm;
return JNI_VERSION_1_4;
@ -92,7 +94,7 @@ JNIEXPORT jint JNICALL DEF_JNI_OnLoad(JavaVM *vm, void *reserved) {
*/
JNIEXPORT void JNICALL
Java_sun_security_pkcs11_wrapper_PKCS11_initializeLibrary
(JNIEnv *env, jclass thisClass)
(JNIEnv *env, jclass thisClass, jboolean enableDebug)
{
#ifndef NO_CALLBACKS
if (notifyListLock == NULL) {
@ -101,6 +103,7 @@ Java_sun_security_pkcs11_wrapper_PKCS11_initializeLibrary
#endif
prefetchFields(env, thisClass);
debug = enableDebug;
}
jclass fetchClass(JNIEnv *env, const char *name) {

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
*/
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
@ -152,6 +152,8 @@ JNIEXPORT jlongArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1Generate
CK_OBJECT_HANDLE_PTR ckpKeyHandles; /* pointer to array with Public and Private Key */
jlongArray jKeyHandles = NULL;
CK_RV rv;
int attempts;
const int MAX_ATTEMPTS = 3;
CK_FUNCTION_LIST_PTR ckpFunctions = getFunctionList(env, obj);
if (ckpFunctions == NULL) { return NULL; }
@ -190,10 +192,35 @@ JNIEXPORT jlongArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1Generate
return NULL;
}
rv = (*ckpFunctions->C_GenerateKeyPair)(ckSessionHandle, &ckMechanism,
ckpPublicKeyAttributes, ckPublicKeyAttributesLength,
ckpPrivateKeyAttributes, ckPrivateKeyAttributesLength,
ckpPublicKeyHandle, ckpPrivateKeyHandle);
/*
* Workaround for NSS bug 1012786:
*
* Key generation may fail with CKR_FUNCTION_FAILED error
* if there is insufficient entropy to generate a random key.
*
* PKCS11 spec says the following about CKR_FUNCTION_FAILED error
* (see section 11.1.1):
*
* ... In any event, although the function call failed, the situation
* is not necessarily totally hopeless, as it is likely to be
* when CKR_GENERAL_ERROR is returned. Depending on what the root cause of
* the error actually was, it is possible that an attempt
* to make the exact same function call again would succeed.
*
* Call C_GenerateKeyPair() several times if CKR_FUNCTION_FAILED occurs.
*/
for (attempts = 0; attempts < MAX_ATTEMPTS; attempts++) {
rv = (*ckpFunctions->C_GenerateKeyPair)(ckSessionHandle, &ckMechanism,
ckpPublicKeyAttributes, ckPublicKeyAttributesLength,
ckpPrivateKeyAttributes, ckPrivateKeyAttributesLength,
ckpPublicKeyHandle, ckpPrivateKeyHandle);
if (rv == CKR_FUNCTION_FAILED) {
printDebug("C_1GenerateKeyPair(): C_GenerateKeyPair() failed \
with CKR_FUNCTION_FAILED error, try again\n");
} else {
break;
}
}
if (ckAssertReturnValueOK(env, rv) == CK_ASSERT_OK) {
jKeyHandles = ckULongArrayToJLongArray(env, ckpKeyHandles, 2);

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
*/
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
@ -1143,3 +1143,15 @@ void p11free(void *p, char *file, int line) {
#endif
// prints a message to stdout if debug output is enabled
void printDebug(const char *format, ...) {
if (debug == JNI_TRUE) {
va_list args;
fprintf(stdout, "sunpkcs11: ");
va_start(args, format);
vfprintf(stdout, format, args);
va_end(args);
fflush(stdout);
}
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
*/
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
@ -159,6 +159,7 @@
#include "pkcs-11v2-20a3.h"
#include <jni.h>
#include <jni_util.h>
#include <stdarg.h>
#define MAX_STACK_BUFFER_LEN (4 * 1024)
#define MAX_HEAP_BUFFER_LEN (64 * 1024)
@ -217,6 +218,10 @@
#define TRACE_UNINTEND
#endif
/* debug output */
extern jboolean debug;
void printDebug(const char *format, ...);
#define CK_ASSERT_OK 0L
#define CLASS_INFO "sun/security/pkcs11/wrapper/CK_INFO"

@ -101,7 +101,7 @@ public final class ImagePluginConfiguration {
List<Plugin> orderedPlugins = PluginOrderingGraph.sort(entry.getValue());
Category category = entry.getKey();
for (Plugin p : orderedPlugins) {
if (Utils.isPostProcessor(category)) {
if (category.isPostProcessor()) {
@SuppressWarnings("unchecked")
PostProcessorPlugin pp = (PostProcessorPlugin) p;
postProcessingPlugins.add(pp);

@ -39,15 +39,7 @@ import java.nio.ByteOrder;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Date;
import java.util.Formatter;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;
import jdk.internal.module.ConfigurableModuleFinder;
@ -96,11 +88,9 @@ public class JlinkTask {
}, "--help"),
new Option<JlinkTask>(true, (task, opt, arg) -> {
String[] dirs = arg.split(File.pathSeparator);
task.options.modulePath = new Path[dirs.length];
int i = 0;
for (String dir : dirs) {
task.options.modulePath[i++] = Paths.get(dir);
}
Arrays.stream(dirs)
.map(Paths::get)
.forEach(task.options.modulePath::add);
}, "--modulepath", "--mp"),
new Option<JlinkTask>(true, (task, opt, arg) -> {
for (String mn : arg.split(",")) {
@ -176,7 +166,7 @@ public class JlinkTask {
String saveoptsfile;
boolean version;
boolean fullVersion;
Path[] modulePath;
List<Path> modulePath = new ArrayList<>();
Set<String> limitMods = new HashSet<>();
Set<String> addMods = new HashSet<>();
Path output;
@ -203,7 +193,7 @@ public class JlinkTask {
return EXIT_OK;
}
if (taskHelper.getExistingImage() == null) {
if (options.modulePath == null || options.modulePath.length == 0) {
if (options.modulePath == null || options.modulePath.isEmpty()) {
throw taskHelper.newBadArgs("err.modulepath.must.be.specified").showUsage(true);
}
createImage();
@ -245,7 +235,7 @@ public class JlinkTask {
* Jlink API entry point.
*/
public static void createImage(JlinkConfiguration config,
PluginsConfiguration plugins)
PluginsConfiguration plugins)
throws Exception {
Objects.requireNonNull(config);
Objects.requireNonNull(config.getOutput());
@ -254,10 +244,9 @@ public class JlinkTask {
if (config.getModulepaths().isEmpty()) {
throw new Exception("Empty module paths");
}
Path[] arr = new Path[config.getModulepaths().size()];
arr = config.getModulepaths().toArray(arr);
ModuleFinder finder
= newModuleFinder(arr, config.getLimitmods(), config.getModules());
= newModuleFinder(config.getModulepaths(), config.getLimitmods(), config.getModules());
// First create the image provider
ImageProvider imageProvider
@ -332,10 +321,12 @@ public class JlinkTask {
return addMods;
}
private static ModuleFinder newModuleFinder(Path[] paths,
Set<String> limitMods,
Set<String> addMods) {
ModuleFinder finder = ModuleFinder.of(paths);
public static ModuleFinder newModuleFinder(List<Path> paths,
Set<String> limitMods,
Set<String> addMods)
{
ModuleFinder finder = ModuleFinder.of(paths.toArray(new Path[0]));
// jmods are located at link-time
if (finder instanceof ConfigurableModuleFinder) {

@ -35,7 +35,6 @@ import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import jdk.tools.jlink.plugin.Plugin;
import jdk.tools.jlink.plugin.Plugin.Category;
@ -57,46 +56,16 @@ public class Utils {
.collect(Collectors.toList());
}
public static boolean isPostProcessor(Category category) {
return category.equals(Category.VERIFIER)
|| category.equals(Category.PROCESSOR)
|| category.equals(Category.PACKAGER);
}
public static boolean isPreProcessor(Category category) {
return category.equals(Category.COMPRESSOR)
|| category.equals(Category.FILTER)
|| category.equals(Category.MODULEINFO_TRANSFORMER)
|| category.equals(Category.SORTER)
|| category.equals(Category.TRANSFORMER)
|| category.equals(Category.METAINFO_ADDER);
}
public static boolean isPostProcessor(Plugin provider) {
Set<Category> types = provider.getType();
Objects.requireNonNull(types);
for (Category pt : types) {
return isPostProcessor(pt);
}
return false;
return provider.getType().isPostProcessor();
}
public static boolean isPreProcessor(Plugin provider) {
Set<Category> types = provider.getType();
Objects.requireNonNull(types);
for (Category pt : types) {
return isPreProcessor(pt);
}
return false;
return !isPostProcessor(provider);
}
public static Category getCategory(Plugin provider) {
Set<Category> types = provider.getType();
Objects.requireNonNull(types);
for (Category t : types) {
return t;
}
return null;
return provider.getType();
}
public static List<Plugin> getPreProcessors(List<Plugin> plugins) {

@ -27,36 +27,19 @@ package jdk.tools.jlink.internal.packager;
import jdk.tools.jlink.Jlink;
import jdk.tools.jlink.builder.ImageBuilder;
import jdk.tools.jlink.builder.DefaultImageBuilder;
import jdk.tools.jlink.internal.JlinkTask;
import jdk.tools.jlink.plugin.Plugin;
import jdk.tools.jlink.builder.*;
import jdk.tools.jlink.plugin.ModulePool;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.StringReader;
import java.lang.module.ModuleFinder;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.ResourceBundle;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;
import java.util.stream.Collectors;
/**
* AppRuntimeImageBuilder is a private API used only by the Java Packager to generate
@ -143,4 +126,14 @@ public final class AppRuntimeImageBuilder {
Jlink jlink = new Jlink();
jlink.build(jlinkConfig, pluginConfig);
}
/**
* Returns a ModuleFinder that limits observability to the given root
* modules, their transitive dependences, plus a set of other modules.
*/
public static ModuleFinder moduleFinder(List<Path> modulepaths,
Set<String> roots,
Set<String> otherModules) {
return JlinkTask.newModuleFinder(modulepaths, roots, otherModules);
}
}

@ -25,9 +25,7 @@
package jdk.tools.jlink.internal.plugins;
import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import jdk.tools.jlink.internal.ModulePoolImpl;
import jdk.tools.jlink.plugin.ModulePool;
@ -77,10 +75,8 @@ public final class DefaultCompressPlugin implements TransformerPlugin, ResourceP
}
@Override
public Set<Category> getType() {
Set<Category> set = new HashSet<>();
set.add(Category.COMPRESSOR);
return Collections.unmodifiableSet(set);
public Category getType() {
return Category.COMPRESSOR;
}
@Override

@ -26,9 +26,7 @@ package jdk.tools.jlink.internal.plugins;
import java.io.UncheckedIOException;
import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.function.Predicate;
import jdk.tools.jlink.plugin.TransformerPlugin;
import jdk.tools.jlink.plugin.ModulePool;
@ -60,10 +58,8 @@ public final class ExcludeFilesPlugin implements TransformerPlugin {
}
@Override
public Set<Category> getType() {
Set<Category> set = new HashSet<>();
set.add(Category.FILTER);
return Collections.unmodifiableSet(set);
public Category getType() {
return Category.FILTER;
}
@Override

@ -25,9 +25,7 @@
package jdk.tools.jlink.internal.plugins;
import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.function.Predicate;
import jdk.tools.jlink.plugin.TransformerPlugin;
import jdk.tools.jlink.plugin.ModuleEntry;
@ -73,10 +71,8 @@ public final class ExcludePlugin implements TransformerPlugin {
}
@Override
public Set<Category> getType() {
Set<Category> set = new HashSet<>();
set.add(Category.FILTER);
return Collections.unmodifiableSet(set);
public Category getType() {
return Category.FILTER;
}
@Override

@ -32,10 +32,8 @@ import java.io.UncheckedIOException;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import java.util.function.Predicate;
import java.util.stream.Collectors;
@ -159,10 +157,8 @@ public final class ExcludeVMPlugin implements TransformerPlugin {
}
@Override
public Set<Category> getType() {
Set<Category> set = new HashSet<>();
set.add(Category.FILTER);
return Collections.unmodifiableSet(set);
public Category getType() {
return Category.FILTER;
}
@Override

@ -36,11 +36,9 @@ import java.nio.file.Paths;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import jdk.tools.jlink.internal.ModuleEntryImpl;
import jdk.tools.jlink.plugin.PluginException;
import jdk.tools.jlink.plugin.ModuleEntry;
@ -187,13 +185,6 @@ public class FileCopierPlugin implements TransformerPlugin {
}
}
@Override
public Set<Category> getType() {
Set<Category> set = new HashSet<>();
set.add(Category.TRANSFORMER);
return Collections.unmodifiableSet(set);
}
@Override
public void configure(Map<String, String> config) {
List<String> arguments = Utils.parseList(config.get(NAME));

@ -60,11 +60,6 @@ public final class GenerateJLIClassesPlugin implements TransformerPlugin {
public GenerateJLIClassesPlugin() {
}
@Override
public Set<Category> getType() {
return Collections.singleton(Category.TRANSFORMER);
}
@Override
public String getName() {
return NAME;

@ -25,9 +25,9 @@
package jdk.tools.jlink.internal.plugins;
import java.io.ByteArrayInputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.IllformedLocaleException;
import java.util.Locale;
import java.util.List;
@ -82,15 +82,15 @@ public final class IncludeLocalesPlugin implements TransformerPlugin, ResourcePr
"sun.util.resources.ext",
"sun.util.resources.provider");
private static final String METAINFONAME = "LocaleDataMetaInfo";
private static final String META_FILES =
"*module-info.class," +
"*LocaleDataProvider.class," +
"*" + METAINFONAME + ".class,";
private static final String INCLUDE_LOCALE_FILES =
"*sun/text/resources/ext/[^\\/]+_%%.class," +
"*sun/util/resources/ext/[^\\/]+_%%.class," +
"*sun/text/resources/cldr/ext/[^\\/]+_%%.class," +
"*sun/util/resources/cldr/ext/[^\\/]+_%%.class,";
private static final List<String> META_FILES = List.of(
".+module-info.class",
".+LocaleDataProvider.class",
".+" + METAINFONAME + ".class");
private static final List<String> INCLUDE_LOCALE_FILES = List.of(
".+sun/text/resources/ext/[^_]+_",
".+sun/util/resources/ext/[^_]+_",
".+sun/text/resources/cldr/ext/[^_]+_",
".+sun/util/resources/cldr/ext/[^_]+_");
private Predicate<String> predicate;
private String userParam;
private List<Locale.LanguageRange> priorityList;
@ -134,10 +134,8 @@ public final class IncludeLocalesPlugin implements TransformerPlugin, ResourcePr
}
@Override
public Set<Category> getType() {
Set<Category> set = new HashSet<>();
set.add(Category.FILTER);
return Collections.unmodifiableSet(set);
public Category getType() {
return Category.FILTER;
}
@Override
@ -206,15 +204,17 @@ public final class IncludeLocalesPlugin implements TransformerPlugin, ResourcePr
String.format(PluginsResourceBundle.getMessage(NAME + ".nomatchinglocales"), userParam));
}
String value = META_FILES + filtered.stream()
.map(s -> includeLocaleFilePatterns(s))
.collect(Collectors.joining(","));
List<String> value = Stream.concat(
META_FILES.stream(),
filtered.stream().flatMap(s -> includeLocaleFilePatterns(s).stream()))
.map(s -> "regex:" + s)
.collect(Collectors.toList());
predicate = ResourceFilter.includeFilter(value);
}
private String includeLocaleFilePatterns(String tag) {
private List<String> includeLocaleFilePatterns(String tag) {
List<String> files = new ArrayList<>();
String pTag = tag.replaceAll("-", "_");
String files = "";
int lastDelimiter = tag.length();
String isoSpecial = pTag.matches("^(he|yi|id).*") ?
pTag.replaceFirst("he", "iw")
@ -224,11 +224,11 @@ public final class IncludeLocalesPlugin implements TransformerPlugin, ResourcePr
// Add tag patterns including parents
while (true) {
pTag = pTag.substring(0, lastDelimiter);
files += INCLUDE_LOCALE_FILES.replaceAll("%%", pTag);
files.addAll(includeLocaleFiles(pTag));
if (!isoSpecial.isEmpty()) {
isoSpecial = isoSpecial.substring(0, lastDelimiter);
files += INCLUDE_LOCALE_FILES.replaceAll("%%", isoSpecial);
files.addAll(includeLocaleFiles(isoSpecial));
}
lastDelimiter = pTag.lastIndexOf('_');
@ -240,31 +240,37 @@ public final class IncludeLocalesPlugin implements TransformerPlugin, ResourcePr
final String lang = pTag;
// Add possible special locales of the COMPAT provider
files += Set.of(jaJPJPTag, noNONYTag, thTHTHTag).stream()
Set.of(jaJPJPTag, noNONYTag, thTHTHTag).stream()
.filter(stag -> lang.equals(stag.substring(0,2)))
.map(t -> INCLUDE_LOCALE_FILES.replaceAll("%%", t.replaceAll("-", "_")))
.collect(Collectors.joining(","));
.map(t -> includeLocaleFiles(t.replaceAll("-", "_")))
.forEach(files::addAll);
// Add possible UN.M49 files (unconditional for now) for each language
files += INCLUDE_LOCALE_FILES.replaceAll("%%", lang + "_[0-9]{3}");
files.addAll(includeLocaleFiles(lang + "_[0-9]{3}"));
if (!isoSpecial.isEmpty()) {
files += INCLUDE_LOCALE_FILES.replaceAll("%%", isoSpecial + "_[0-9]{3}");
files.addAll(includeLocaleFiles(isoSpecial + "_[0-9]{3}"));
}
// Add Thai BreakIterator related data files
if (lang.equals("th")) {
files += "*sun/text/resources/thai_dict," +
"*sun/text/resources/[^\\/]+BreakIteratorData_th,";
files.add(".+sun/text/resources/thai_dict");
files.add(".+sun/text/resources/[^_]+BreakIteratorData_th");
}
// Add Taiwan resource bundles for Hong Kong
if (tag.startsWith("zh-HK")) {
files += INCLUDE_LOCALE_FILES.replaceAll("%%", "zh_TW");
files.addAll(includeLocaleFiles("zh_TW"));
}
return files;
}
private List<String> includeLocaleFiles(String localeStr) {
return INCLUDE_LOCALE_FILES.stream()
.map(s -> s + localeStr + ".class")
.collect(Collectors.toList());
}
private boolean stripUnsupportedLocales(byte[] bytes, ClassReader cr) {
char[] buf = new char[cr.getMaxStringLength()];
boolean[] modified = new boolean[1];

@ -31,7 +31,6 @@ import java.io.UncheckedIOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@ -284,11 +283,4 @@ public final class OptimizationPlugin extends AsmPlugin {
}
}
}
@Override
public Set<Category> getType() {
Set<Category> set = new HashSet<>();
set.add(Category.TRANSFORMER);
return Collections.unmodifiableSet(set);
}
}

@ -32,7 +32,6 @@ import java.nio.file.PathMatcher;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -143,11 +142,8 @@ public final class OrderResourcesPlugin implements TransformerPlugin {
}
@Override
public Set<Category> getType() {
Set<Category> set = new HashSet<>();
set.add(Category.SORTER);
return Collections.unmodifiableSet(set);
public Category getType() {
return Category.SORTER;
}
@Override

@ -49,8 +49,8 @@ public final class ReleaseInfoPlugin implements TransformerPlugin {
private final Map<String, String> release = new HashMap<>();
@Override
public Set<Category> getType() {
return Collections.singleton(Category.METAINFO_ADDER);
public Category getType() {
return Category.METAINFO_ADDER;
}
@Override

@ -343,10 +343,8 @@ public class StringSharingPlugin implements TransformerPlugin, ResourcePrevisito
}
@Override
public Set<Category> getType() {
Set<Category> set = new HashSet<>();
set.add(Category.COMPRESSOR);
return Collections.unmodifiableSet(set);
public Category getType() {
return Category.COMPRESSOR;
}
@Override

@ -27,8 +27,6 @@ package jdk.tools.jlink.internal.plugins;
import java.io.ByteArrayInputStream;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.function.Predicate;
import jdk.internal.org.objectweb.asm.ClassReader;
import jdk.internal.org.objectweb.asm.ClassWriter;
@ -57,13 +55,6 @@ public final class StripDebugPlugin implements TransformerPlugin {
return NAME;
}
@Override
public Set<Category> getType() {
Set<Category> set = new HashSet<>();
set.add(Category.TRANSFORMER);
return Collections.unmodifiableSet(set);
}
@Override
public String getDescription() {
return PluginsResourceBundle.getDescription(NAME);

@ -25,8 +25,6 @@
package jdk.tools.jlink.internal.plugins;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import jdk.tools.jlink.plugin.ModuleEntry;
import jdk.tools.jlink.plugin.ModulePool;
import jdk.tools.jlink.plugin.TransformerPlugin;
@ -45,10 +43,8 @@ public final class StripNativeCommandsPlugin implements TransformerPlugin {
}
@Override
public Set<Category> getType() {
Set<Category> set = new HashSet<>();
set.add(Category.FILTER);
return Collections.unmodifiableSet(set);
public Category getType() {
return Category.FILTER;
}
@Override

@ -82,11 +82,6 @@ public final class SystemModuleDescriptorPlugin implements TransformerPlugin {
this.enabled = true;
}
@Override
public Set<Category> getType() {
return Collections.singleton(Category.TRANSFORMER);
}
@Override
public String getName() {
return NAME;

@ -29,9 +29,7 @@ import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.function.Predicate;
import java.util.zip.Deflater;
import jdk.tools.jlink.internal.ModulePoolImpl;
@ -66,10 +64,8 @@ public final class ZipPlugin implements TransformerPlugin {
}
@Override
public Set<Category> getType() {
Set<Category> set = new HashSet<>();
set.add(Category.COMPRESSOR);
return Collections.unmodifiableSet(set);
public Category getType() {
return Category.COMPRESSOR;
}
@Override

@ -57,19 +57,29 @@ public interface Plugin {
SORTER("SORTER"),
COMPRESSOR("COMPRESSOR"),
METAINFO_ADDER("METAINFO_ADDER"),
VERIFIER("VERIFIER"),
PROCESSOR("PROCESSOR"),
PACKAGER("PACKAGER");
VERIFIER("VERIFIER", true),
PROCESSOR("PROCESSOR", true),
PACKAGER("PACKAGER", true);
private final String name;
private final boolean postProcessor;
Category(String name, boolean postProcessor) {
this.name = name;
this.postProcessor = postProcessor;
}
Category(String name) {
this.name = name;
this(name, false);
}
public String getName() {
return name;
}
public boolean isPostProcessor() {
return postProcessor;
}
}
/**
@ -90,11 +100,12 @@ public interface Plugin {
}
/**
* The Plugin set of types.
* @return The set of types.
* The type of this plugin.
*
* @return The type of this plugin
*/
public default Set<Category> getType() {
return Collections.emptySet();
public default Category getType() {
return Category.TRANSFORMER;
}
/**

@ -272,8 +272,6 @@ sun/security/pkcs11/tls/TestMasterSecret.java 8077138,8023434
sun/security/pkcs11/tls/TestPRF.java 8077138,8023434 windows-all
sun/security/pkcs11/tls/TestPremaster.java 8077138,8023434 windows-all
sun/security/pkcs11/rsa/TestKeyPairGenerator.java 8074580 generic-all
sun/security/krb5/auto/HttpNegotiateServer.java 8038079 generic-all
sun/security/tools/keytool/autotest.sh 8130302 generic-all
@ -387,8 +385,6 @@ com/sun/jndi/ldap/DeadSSLLdapTimeoutTest.java 8141370 linux-i5
# core_tools
tools/jlink/plugins/IncludeLocalesPluginTest.java 8159781 generic-all
tools/jlink/JLinkOptimTest.java 8159264 generic-all
############################################################################

@ -0,0 +1,73 @@
/*
* Copyright (c) 2016, 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 8158802
* @summary com.sun.jndi.ldap.SimpleClientId produces wrong hash code
* @modules java.naming/com.sun.jndi.ldap
*/
import java.io.OutputStream;
import java.lang.reflect.Constructor;
import javax.naming.ldap.Control;
public class SimpleClientIdHashCode {
public static void main(String[] args) throws Throwable {
Class<?> simpleClientIdClass
= Class.forName("com.sun.jndi.ldap.SimpleClientId");
Constructor<?> init = simpleClientIdClass.getDeclaredConstructor(
int.class, String.class, int.class, String.class,
Control[].class, OutputStream.class, String.class,
String.class, Object.class);
init.setAccessible(true);
Object p1 = new byte[]{66,77};
Object p2 = new char[]{'w','d'};
Object p3 = "word";
test(init, new byte[]{65}, new byte[]{65});
test(init, new char[]{'p'}, new char[]{'p'});
test(init, "pass", "pass");
test(init, p1, p1);
test(init, p2, p2);
test(init, p3, p3);
test(init, null, null);
}
private static void test(Constructor<?> init, Object pass1, Object pass2)
throws Throwable {
Object o1 = init.newInstance(1, "host", 3, "", null, System.out,
null, null, pass1);
Object o2 = init.newInstance(1, "host", 3, "", null, System.out,
null, null, pass2);
if (!o1.equals(o2))
throw new RuntimeException("Objects not equal");
if (o1.hashCode() != o2.hashCode())
throw new RuntimeException("Inconsistent hash codes");
}
}

@ -157,7 +157,7 @@ public class ConfigurationTest {
*
* The test consists of three configurations:
* - Configuration cf1: m1, m2 requires public m1
* - Configuration cf2: m3 requires m1
* - Configuration cf2: m3 requires m2
*/
public void testRequiresPublic2() {
@ -219,7 +219,7 @@ public class ConfigurationTest {
*
* The test consists of three configurations:
* - Configuration cf1: m1
* - Configuration cf2: m2 requires public m3, m3 requires m2
* - Configuration cf2: m2 requires public m1, m3 requires m2
*/
public void testRequiresPublic3() {
@ -283,7 +283,7 @@ public class ConfigurationTest {
* The test consists of three configurations:
* - Configuration cf1: m1
* - Configuration cf2: m2 requires public m1
* - Configuraiton cf3: m3 requires m3
* - Configuraiton cf3: m3 requires m2
*/
public void testRequiresPublic4() {
@ -657,8 +657,8 @@ public class ConfigurationTest {
* Basic test of binding services with configurations.
*
* Configuration cf1: p@1.0 provides p.S
* Test configuration cf2: m1 uses p.S, p@2.0 provides p.S
* Test configuration cf2: m1 uses p.S
* Test configuration cf2: m1 uses p.S, p@2.0 uses p.S
*/
public void testServiceBindingWithConfigurations3() {
@ -896,7 +896,7 @@ public class ConfigurationTest {
Configuration cf2 = resolveRequires(cf1, finder, "m1");
assertTrue(cf2.modules().size() == 1);
assertTrue(cf1.findModule("m1").isPresent());
assertTrue(cf2.findModule("m1").isPresent());
}
@ -1305,7 +1305,7 @@ public class ConfigurationTest {
/**
* Test "provides p.S" where p is not local
* Test "provides p.S with q.T" where q.T is not local
*/
@Test(expectedExceptions = { ResolutionException.class })
public void testProviderPackageNotLocal() {

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -110,7 +110,7 @@ public class ModuleReferenceTest {
ModuleReference mref3 = new ModuleReference(descriptor1, null, supplier);
assertTrue(mref1.equals(mref1));
assertTrue(mref1.equals(mref1));
assertTrue(mref1.equals(mref2));
assertTrue(mref2.equals(mref1));
assertTrue(mref1.hashCode() == mref2.hashCode());

@ -0,0 +1,64 @@
/*
* Copyright (c) 2016, 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 8144008
* @summary Setting NO_PROXY on HTTP URL connections does not stop proxying
* @run main/othervm NoProxyTest
*/
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.Proxy;
import java.net.ProxySelector;
import java.net.SocketAddress;
import java.net.URI;
import java.net.URL;
import java.net.URLConnection;
import java.util.List;
public class NoProxyTest {
static class NoProxyTestSelector extends ProxySelector {
@Override
public List<Proxy> select(URI uri) {
throw new RuntimeException("Should not reach here as proxy==Proxy.NO_PROXY");
}
@Override
public void connectFailed(URI u, SocketAddress s, IOException e) { }
}
public static void main(String args[]) throws MalformedURLException {
ProxySelector.setDefault(new NoProxyTestSelector());
URL url = URI.create("http://127.0.0.1/").toURL();
URLConnection connection;
try {
connection = url.openConnection(Proxy.NO_PROXY);
connection.connect();
} catch (IOException ignore) {
//ignore
}
}
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -26,7 +26,7 @@ import java.io.*;
/**
* @test
* @bug 8010464 8027570 8027687 8029354
* @bug 8010464 8027570 8027687 8029354 8114860 8071660
*/
public class URLPermissionTest {
@ -110,6 +110,8 @@ public class URLPermissionTest {
static class ActionImpliesTest extends Test {
String arg1, arg2;
String url1 = "http://www.foo.com/-";
String url2 = "http://www.foo.com/a/b";
ActionImpliesTest(String arg1, String arg2, boolean expected) {
this.arg1 = arg1;
@ -117,10 +119,17 @@ public class URLPermissionTest {
this.expected = expected;
}
ActionImpliesTest(String ur11, String url2, String arg1, String arg2,
boolean expected) {
this.url1 = ur11;
this.url2 = url2;
this.arg1 = arg1;
this.arg2 = arg2;
this.expected = expected;
}
@Override
boolean execute() {
String url1 = "http://www.foo.com/-";
String url2 = "http://www.foo.com/a/b";
URLPermission p1 = new URLPermission(url1, arg1);
URLPermission p2 = new URLPermission(url2, arg2);
boolean result = p1.implies(p2);
@ -129,10 +138,37 @@ public class URLPermissionTest {
}
}
static ActionsStringTest actionstest(String arg, String expectedActions) {
return new ActionsStringTest(arg, expectedActions);
}
static class ActionsStringTest extends Test {
String expectedActions;
String arg;
public ActionsStringTest(String arg, String expectedActions) {
this.arg = arg;
this.expectedActions = expectedActions;
}
@Override
boolean execute() {
String url = "http://www.foo.com/";
URLPermission urlp = new URLPermission(url, arg);
return (expectedActions.equals(urlp.getActions()));
}
}
static ActionImpliesTest actest(String arg1, String arg2, boolean expected) {
return new ActionImpliesTest(arg1, arg2, expected);
}
static ActionImpliesTest actest(String url1, String url2, String arg1,
String arg2, boolean expected) {
return new ActionImpliesTest(url1, url2, arg1, arg2, expected);
}
static class HashCodeTest extends Test {
String arg1, arg2;
int hash;
@ -292,6 +328,9 @@ public class URLPermissionTest {
imtest("https:*", "http:*", false)
};
static final String FOO_URL = "http://www.foo.com/";
static final String BAR_URL = "http://www.bar.com/";
static Test[] actionImplies = {
actest("GET", "GET", true),
actest("GET", "POST", false),
@ -305,7 +344,28 @@ public class URLPermissionTest {
actest("GET:X-Foo,X-Bar", "GET:x-bar,x-foo", true),
actest("GET:X-Bar,X-Foo,X-Bar,Y-Foo", "GET:x-bar,x-foo", true),
actest("GET:*", "GET:x-bar,x-foo", true),
actest("*:*", "GET:x-bar,x-foo", true)
actest("*:*", "GET:x-bar,x-foo", true),
actest("", "GET:x-bar,x-foo", false),
actest("GET:x-bar,x-foo", "", true),
actest("", "", true),
actest("GET,DELETE", "GET,DELETE:x-foo", false),
actest(FOO_URL, BAR_URL, "", "GET:x-bar,x-foo", false),
actest(FOO_URL, BAR_URL, "GET:x-bar,x-foo", "", false),
actest(FOO_URL, BAR_URL, "", "", false)
};
static Test[] actionsStringTest = {
actionstest("", ""),
actionstest(":X-Bar", ":X-Bar"),
actionstest("GET", "GET"),
actionstest("get", "GET"),
actionstest("GET,POST", "GET,POST"),
actionstest("GET,post", "GET,POST"),
actionstest("get,post", "GET,POST"),
actionstest("get,post,DELETE", "DELETE,GET,POST"),
actionstest("GET,POST:", "GET,POST"),
actionstest("GET:X-Foo,X-bar", "GET:X-Bar,X-Foo"),
actionstest("GET,POST,DELETE:X-Bar,X-Foo,X-Bar,Y-Foo", "DELETE,GET,POST:X-Bar,X-Bar,X-Foo,Y-Foo")
};
static Test[] equalityTests = {
@ -449,6 +509,23 @@ public class URLPermissionTest {
System.out.println ("action test " + i + " OK");
}
for (int i = 0; i < actionsStringTest.length; i++) {
ActionsStringTest test = (ActionsStringTest) actionsStringTest[i];
Exception caught = null;
boolean result = false;
try {
result = test.execute();
} catch (Exception e) {
caught = e;
}
if (!result) {
failed = true;
System.out.println("test failed: " + test.arg + ": "
+ test.expectedActions + " Exception: " + caught);
}
System.out.println("Actions String test " + i + " OK");
}
serializationTest("http://www.foo.com/-", "GET,DELETE:*");
serializationTest("https://www.foo.com/-", "POST:X-Foo");
serializationTest("https:*", "*:*");

@ -32,10 +32,9 @@ import java.net.http.WebSocket.CloseCode;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.channels.SocketChannel;
import java.time.Duration;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import java.util.stream.Stream;
/*
* @test
@ -83,13 +82,7 @@ public class BasicWebSocketAPITest {
(ws) ->
TestKit.assertThrows(NullPointerException.class,
"message",
() -> ws.sendBinary((byte[]) null, true))
);
checkAndClose(
(ws) ->
TestKit.assertThrows(NullPointerException.class,
"message",
() -> ws.sendBinary((ByteBuffer) null, true))
() -> ws.sendBinary(null, true))
);
checkAndClose(
(ws) ->
@ -125,13 +118,7 @@ public class BasicWebSocketAPITest {
(ws) ->
TestKit.assertThrows(NullPointerException.class,
"message",
() -> ws.sendText((CharSequence) null))
);
checkAndClose(
(ws) ->
TestKit.assertThrows(NullPointerException.class,
"message",
() -> ws.sendText((Stream<? extends CharSequence>) null))
() -> ws.sendText(null))
);
checkAndClose(
(ws) ->
@ -214,17 +201,7 @@ public class BasicWebSocketAPITest {
// FIXME: check timeout works
// (i.e. it directly influences the time WebSocket waits for connection + opening handshake)
TestKit.assertNotThrows(
() -> WebSocket.newBuilder(ws, defaultListener()).connectTimeout(1, TimeUnit.SECONDS)
);
WebSocket.Builder builder = WebSocket.newBuilder(ws, defaultListener());
TestKit.assertThrows(IllegalArgumentException.class,
"(?i).*\\bnegative\\b.*",
() -> builder.connectTimeout(-1, TimeUnit.SECONDS)
);
WebSocket.Builder builder1 = WebSocket.newBuilder(ws, defaultListener());
TestKit.assertThrows(NullPointerException.class,
"unit",
() -> builder1.connectTimeout(1, null)
() -> WebSocket.newBuilder(ws, defaultListener()).connectTimeout(Duration.ofSeconds(1))
);
// FIXME: check these headers are actually received by the server
TestKit.assertNotThrows(

@ -23,17 +23,22 @@
/**
* @test
* @bug 8146156
* @bug 8146156 8159548
* @summary test whether uppercasing follows Locale.Category.FORMAT locale.
* @run main/othervm FormatLocale
*/
import java.time.LocalDate;
import java.time.ZonedDateTime;
import java.time.ZoneId;
import java.time.Month;
import java.util.Calendar;
import java.util.Formatter;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.Locale;
import java.util.Locale.Category;
import java.util.TimeZone;
import java.util.stream.IntStream;
public class FormatLocale {
@ -61,7 +66,7 @@ public class FormatLocale {
"N\u0130SAN",
"1,00000E+08");
public static void main(String [] args) {
static void formatLocaleTest() {
StringBuilder sb = new StringBuilder();
IntStream.range(0, src.size()).forEach(i -> {
@ -79,4 +84,44 @@ public class FormatLocale {
}
});
}
static void nullLocaleTest() {
String fmt = "%1$ta %1$tA %1$th %1$tB %1tZ";
String expected = "Fri Friday Jan January PST";
StringBuilder sb = new StringBuilder();
Locale orig = Locale.getDefault();
try {
Locale.setDefault(Locale.JAPAN);
Formatter f = new Formatter(sb, (Locale)null);
ZoneId zid = ZoneId.of("America/Los_Angeles");
Calendar c = new GregorianCalendar(TimeZone.getTimeZone(zid), Locale.US);
c.set(2016, 0, 1, 0, 0, 0);
f.format(fmt, c);
if (!sb.toString().equals(expected)) {
throw new RuntimeException(
"Localized text returned with null locale.\n" +
" expected: " + expected + "\n" +
" returned: " + sb.toString());
}
sb.setLength(0);
ZonedDateTime zdt = ZonedDateTime.of(2016, 1, 1, 0, 0, 0, 0, zid);
f.format(fmt, zdt);
if (!sb.toString().equals(expected)) {
throw new RuntimeException(
"Localized text returned with null locale.\n" +
" expected: " + expected + "\n" +
" returned: " + sb.toString());
}
} finally {
Locale.setDefault(orig);
}
}
public static void main(String [] args) {
formatLocaleTest();
nullLocaleTest();
}
}

@ -24,7 +24,7 @@
/**
* @test
* @bug 4313885 4926319 4927634 5032610 5032622 5049968 5059533 6223711 6277261 6269946 6288823
* 8072722 8072582 8139414
* 8072722 8139414
* @summary Basic tests of java.util.Scanner methods
* @key randomness
* @modules jdk.localedata
@ -512,27 +512,9 @@ public class ScanTest {
}
public static void boundaryDelimTest() throws Exception {
// 8072582
StringBuilder sb = new StringBuilder();
append(sb, 'a', 228); sb.append(",");
append(sb, 'b', 293); sb.append("#,#");
append(sb, 'c', 308); sb.append(",");
append(sb, 'd', 188); sb.append("#,#");
append(sb, 'e', 2);
try (Scanner scanner = new Scanner(sb.toString())) {
scanner.useDelimiter("(#,#)|(,)");
while(scanner.hasNext()){
String next = scanner.next();
if(next.contains("#")){
System.out.printf("[%s]%n", next);
failCount++;
}
}
}
// 8139414
int i = 1019;
sb = new StringBuilder();
StringBuilder sb = new StringBuilder();
sb.append("--;");
for (int j = 0; j < 1019; ++j) {
sb.append(j%10);

@ -27,7 +27,6 @@
/*
* @test
* @bug 8043758
* @key intermittent
* @summary Datagram Transport Layer Security (DTLS)
* @modules java.base/sun.security.util
* @build DTLSOverDatagram

@ -1,4 +1,4 @@
/**
/*
* Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -73,6 +73,7 @@ public class CipherTestUtils {
private static final List<TestParameters> TESTS = new ArrayList<>(3);
private static final List<Exception> EXCEPTIONS
= Collections.synchronizedList(new ArrayList<>(1));
private static final String CLIENT_PUBLIC_KEY
= "-----BEGIN CERTIFICATE-----\n"
+ "MIICtTCCAh4CCQDkYJ46DMcGRjANBgkqhkiG9w0BAQUFADCBnDELMAkGA1UEBhMC\n"
@ -191,7 +192,7 @@ public class CipherTestUtils {
private final X509TrustManager clientTrustManager;
private final X509TrustManager serverTrustManager;
static abstract class Server implements Runnable {
static abstract class Server implements Runnable, AutoCloseable {
final CipherTestUtils cipherTest;
@ -240,12 +241,11 @@ public class CipherTestUtils {
public static class TestParameters {
String cipherSuite;
String protocol;
String clientAuth;
final String cipherSuite;
final String protocol;
final String clientAuth;
TestParameters(String cipherSuite, String protocol,
String clientAuth) {
TestParameters(String cipherSuite, String protocol, String clientAuth) {
this.cipherSuite = cipherSuite;
this.protocol = protocol;
this.clientAuth = clientAuth;
@ -267,10 +267,7 @@ public class CipherTestUtils {
private static volatile CipherTestUtils instance = null;
public static CipherTestUtils getInstance() throws IOException,
FileNotFoundException, KeyStoreException,
NoSuchAlgorithmException, CertificateException,
UnrecoverableKeyException, InvalidKeySpecException {
public static CipherTestUtils getInstance() throws Exception {
if (instance == null) {
synchronized (CipherTestUtils.class) {
if (instance == null) {
@ -281,21 +278,10 @@ public class CipherTestUtils {
return instance;
}
public static void setTestedArguments(String testedProtocol,
String testedCipherSuite) {
TestParameters testedParams;
String cipherSuite = testedCipherSuite.trim();
if (cipherSuite.startsWith("SSL_")) {
testedParams =
new TestParameters(cipherSuite, testedProtocol, null);
TESTS.add(testedParams);
} else {
System.out.println("Your input Cipher suites is not correct, "
+ "please try another one .");
}
public static void setTestedArguments(String protocol, String ciphersuite) {
ciphersuite = ciphersuite.trim();
TestParameters params = new TestParameters(ciphersuite, protocol, null);
TESTS.add(params);
}
public X509ExtendedKeyManager getClientKeyManager() {
@ -318,10 +304,7 @@ public class CipherTestUtils {
EXCEPTIONS.add(e);
}
private CipherTestUtils()
throws IOException, FileNotFoundException, KeyStoreException,
NoSuchAlgorithmException, CertificateException,
UnrecoverableKeyException, InvalidKeySpecException {
private CipherTestUtils() throws Exception {
factory = (SSLSocketFactory) SSLSocketFactory.getDefault();
KeyStore serverKeyStore = createServerKeyStore(SERVER_PUBLIC_KEY,
SERVER_PRIVATE_KEY);
@ -329,12 +312,11 @@ public class CipherTestUtils {
CA_PRIVATE_KEY);
if (serverKeyStore != null) {
KeyManagerFactory keyFactory1
= KeyManagerFactory.getInstance(
KeyManagerFactory keyFactory = KeyManagerFactory.getInstance(
KeyManagerFactory.getDefaultAlgorithm());
keyFactory1.init(serverKeyStore, PASSWORD);
serverKeyManager = (X509ExtendedKeyManager) keyFactory1.
getKeyManagers()[0];
keyFactory.init(serverKeyStore, PASSWORD);
serverKeyManager = (X509ExtendedKeyManager)
keyFactory.getKeyManagers()[0];
} else {
serverKeyManager = null;
}
@ -346,12 +328,11 @@ public class CipherTestUtils {
clientKeyStore =
createServerKeyStore(CLIENT_PUBLIC_KEY,CLIENT_PRIVATE_KEY);
if (clientKeyStore != null) {
KeyManagerFactory keyFactory
= KeyManagerFactory.getInstance(
KeyManagerFactory keyFactory = KeyManagerFactory.getInstance(
KeyManagerFactory.getDefaultAlgorithm());
keyFactory.init(clientKeyStore, PASSWORD);
clientKeyManager = (X509ExtendedKeyManager) keyFactory.
getKeyManagers()[0];
clientKeyManager = (X509ExtendedKeyManager)
keyFactory.getKeyManagers()[0];
} else {
clientKeyManager = null;
}
@ -395,8 +376,8 @@ public class CipherTestUtils {
this.cipherTest = cipherTest;
}
Client(CipherTestUtils cipherTest,
String testedCipherSuite) throws Exception {
Client(CipherTestUtils cipherTest, String testedCipherSuite)
throws Exception {
this.cipherTest = cipherTest;
}
@ -417,7 +398,7 @@ public class CipherTestUtils {
CipherTestUtils.addFailure(e);
System.out.println("** Failed " + params
+ "**, got exception:");
e.printStackTrace(System.err);
e.printStackTrace(System.out);
}
});
}
@ -448,11 +429,7 @@ public class CipherTestUtils {
}
public static void printStringArray(String[] stringArray) {
System.out.print(stringArray.length + " : ");
for (String stringArray1 : stringArray) {
System.out.print(stringArray1);
System.out.print(",");
}
System.out.println(Arrays.toString(stringArray));
System.out.println();
}
@ -496,15 +473,15 @@ public class CipherTestUtils {
System.out.println("-----------------------");
}
private static KeyStore createServerKeyStore(String publicKeyStr,
private static KeyStore createServerKeyStore(String publicKey,
String keySpecStr) throws KeyStoreException, IOException,
NoSuchAlgorithmException, CertificateException,
InvalidKeySpecException {
KeyStore ks = KeyStore.getInstance("JKS");
ks.load(null, null);
if (publicKeyStr == null || keySpecStr == null) {
throw new IllegalArgumentException("publicKeyStr or "
if (publicKey == null || keySpecStr == null) {
throw new IllegalArgumentException("publicKey or "
+ "keySpecStr cannot be null");
}
String strippedPrivateKey = keySpecStr.substring(
@ -518,8 +495,7 @@ public class CipherTestUtils {
= (RSAPrivateKey) kf.generatePrivate(priKeySpec);
// generate certificate chain
try (InputStream is =
new ByteArrayInputStream(publicKeyStr.getBytes())) {
try (InputStream is = new ByteArrayInputStream(publicKey.getBytes())) {
// generate certificate from cert string
CertificateFactory cf = CertificateFactory.getInstance("X.509");
Certificate keyCert = cf.generateCertificate(is);
@ -530,10 +506,9 @@ public class CipherTestUtils {
return ks;
}
public static int mainServer(PeerFactory peerFactory,
public static Server mainServer(PeerFactory peerFactory,
String expectedException) throws Exception {
long time = System.currentTimeMillis();
setTestedArguments(peerFactory.getTestedProtocol(),
peerFactory.getTestedCipher());
@ -542,14 +517,11 @@ public class CipherTestUtils {
secureRandom.nextInt();
CipherTestUtils cipherTest = CipherTestUtils.getInstance();
Server server = peerFactory.newServer(cipherTest, PeerFactory.FREE_PORT);
Thread serverThread = new Thread(server, "Server");
Server srv = peerFactory.newServer(cipherTest, PeerFactory.FREE_PORT);
Thread serverThread = new Thread(srv, "Server");
serverThread.start();
time = System.currentTimeMillis() - time;
System.out.println("Elapsed time " + time);
return server.getPort();
return srv;
}
public static void mainClient(PeerFactory peerFactory, int port,
@ -566,7 +538,6 @@ public class CipherTestUtils {
CipherTestUtils cipherTest = CipherTestUtils.getInstance();
peerFactory.newClient(cipherTest, port).run();
cipherTest.checkResult(expectedException);
JSSEServer.closeServer = true;
time = System.currentTimeMillis() - time;
System.out.println("Elapsed time " + time);
@ -582,9 +553,11 @@ public class CipherTestUtils {
abstract String getTestedCipher();
abstract Client newClient(CipherTestUtils cipherTest, int testPort) throws Exception;
abstract Client newClient(CipherTestUtils cipherTest, int testPort)
throws Exception;
abstract Server newServer(CipherTestUtils cipherTest, int testPort) throws Exception;
abstract Server newServer(CipherTestUtils cipherTest, int testPort)
throws Exception;
boolean isSupported(String cipherSuite) {
return true;
@ -618,7 +591,7 @@ class AlwaysTrustManager implements X509TrustManager {
try {
trustManager.checkClientTrusted(chain, authType);
} catch (CertificateException excep) {
System.out.println("ERROR in client trust manager");
System.out.println("ERROR in client trust manager: " + excep);
}
}
@ -628,7 +601,7 @@ class AlwaysTrustManager implements X509TrustManager {
try {
trustManager.checkServerTrusted(chain, authType);
} catch (CertificateException excep) {
System.out.println("ERROR in server Trust manger");
System.out.println("ERROR in server trust manager: " + excep);
}
}

@ -1,5 +1,5 @@
/**
* Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
/*
* Copyright (c) 2010, 2016, 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
@ -35,39 +35,37 @@ class JSSEClient extends CipherTestUtils.Client {
private static final String DEFAULT = "DEFAULT";
private static final String TLS = "TLS";
private final SSLContext sslContext;
private final SSLContext context;
private final MyX509KeyManager keyManager;
private final int serverPort;
private final String serverHost;
private final String testedProtocol;
private final int port;
private final String host;
private final String protocol;
JSSEClient(CipherTestUtils cipherTest, String serverHost, int serverPort,
String testedProtocols, String testedCipherSuite) throws Exception {
super(cipherTest, testedCipherSuite);
this.serverHost = serverHost;
this.serverPort = serverPort;
this.testedProtocol = testedProtocols;
this.keyManager =
new MyX509KeyManager(cipherTest.getClientKeyManager());
sslContext = SSLContext.getInstance(TLS);
JSSEClient(CipherTestUtils cipherTest, String host, int port,
String protocols, String ciphersuite) throws Exception {
super(cipherTest, ciphersuite);
this.host = host;
this.port = port;
this.protocol = protocols;
this.keyManager = new MyX509KeyManager(
cipherTest.getClientKeyManager());
context = SSLContext.getInstance(TLS);
}
@Override
void runTest(CipherTestUtils.TestParameters params) throws Exception {
SSLSocket socket = null;
try {
System.out.println("Connecting to server...");
keyManager.setAuthType(params.clientAuth);
sslContext.init(new KeyManager[]{keyManager},
new TrustManager[]{cipherTest.getClientTrustManager()},
CipherTestUtils.secureRandom);
SSLSocketFactory factory = (SSLSocketFactory) sslContext.
getSocketFactory();
socket = (SSLSocket) factory.createSocket(serverHost,
serverPort);
keyManager.setAuthType(params.clientAuth);
context.init(
new KeyManager[]{ keyManager },
new TrustManager[]{ cipherTest.getClientTrustManager() },
CipherTestUtils.secureRandom);
SSLSocketFactory factory = (SSLSocketFactory)context.getSocketFactory();
System.out.println("Connecting to server...");
try (SSLSocket socket = (SSLSocket) factory.createSocket(host, port)) {
socket.setSoTimeout(CipherTestUtils.TIMEOUT);
socket.setEnabledCipherSuites(params.cipherSuite.split(","));
if (params.protocol != null && !params.protocol.trim().equals("")
if (params.protocol != null && !params.protocol.trim().isEmpty()
&& !params.protocol.trim().equals(DEFAULT)) {
socket.setEnabledProtocols(params.protocol.split(","));
}
@ -105,16 +103,11 @@ class JSSEClient extends CipherTestUtils.Client {
if ("EC".equals(keyAlg)) {
keyAlg = "ECDSA";
}
if (params.clientAuth == null ? keyAlg != null
: !params.clientAuth.equals(keyAlg)) {
if (!params.clientAuth.equals(keyAlg)) {
throw new RuntimeException("Certificate type mismatch: "
+ keyAlg + " != " + params.clientAuth);
}
}
} finally {
if (socket != null) {
socket.close();
}
}
}
}

@ -1,4 +1,4 @@
/**
/*
* Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -33,13 +33,11 @@ import javax.net.ssl.TrustManager;
public class JSSEServer extends CipherTestUtils.Server {
private final SSLServerSocket serverSocket;
private final int serverPort;
static volatile boolean closeServer = false;
private static volatile boolean closeServer = false;
JSSEServer(CipherTestUtils cipherTest, int serverPort,
String protocol, String cipherSuite) throws Exception {
super(cipherTest);
this.serverPort = serverPort;
SSLContext serverContext = SSLContext.getInstance("TLS");
serverContext.init(new KeyManager[]{cipherTest.getServerKeyManager()},
new TrustManager[]{cipherTest.getServerTrustManager()},
@ -56,7 +54,7 @@ public class JSSEServer extends CipherTestUtils.Server {
@Override
public void run() {
System.out.println("JSSE Server listening on port " + serverPort);
System.out.println("JSSE Server listening on port " + getPort());
while (!closeServer) {
try (final SSLSocket socket = (SSLSocket) serverSocket.accept()) {
socket.setSoTimeout(CipherTestUtils.TIMEOUT);
@ -68,12 +66,12 @@ public class JSSEServer extends CipherTestUtils.Server {
} catch (IOException e) {
CipherTestUtils.addFailure(e);
System.out.println("Got IOException:");
e.printStackTrace(System.err);
e.printStackTrace(System.out);
}
} catch (Exception e) {
CipherTestUtils.addFailure(e);
System.out.println("Exception:");
e.printStackTrace(System.err);
e.printStackTrace(System.out);
}
}
}
@ -81,4 +79,12 @@ public class JSSEServer extends CipherTestUtils.Server {
int getPort() {
return serverSocket.getLocalPort();
}
@Override
public void close() throws IOException {
closeServer = true;
if (serverSocket != null && !serverSocket.isClosed()) {
serverSocket.close();
}
}
}

@ -1,4 +1,4 @@
/**
/*
* Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -20,59 +20,9 @@
* questions.
*/
import static java.lang.System.out;
import java.security.Provider;
import java.security.Security;
/**
* @test
* @bug 8049429
* @modules java.management
* jdk.crypto.ec/sun.security.ec
* @compile CipherTestUtils.java JSSEClient.java JSSEServer.java
* @summary Test that all cipher suites work in all versions and all client
* authentication types. The way this is setup the server is stateless and
* all checking is done on the client side.
* @run main/othervm -DSERVER_PROTOCOL=SSLv3
* -DCLIENT_PROTOCOL=SSLv3
* -DCIPHER=SSL_RSA_WITH_RC4_128_MD5 TestJSSE
* @run main/othervm -DSERVER_PROTOCOL=TLSv1
* -DCLIENT_PROTOCOL=SSLv3,TLSv1,TLSv1.1,TLSv1.2
* -DCIPHER=SSL_RSA_WITH_RC4_128_MD5 TestJSSE
* @run main/othervm -DSERVER_PROTOCOL=TLSv1.1
* -DCLIENT_PROTOCOL=SSLv3,TLSv1,TLSv1.1,TLSv1.2
* -DCIPHER=SSL_RSA_WITH_RC4_128_MD5 TestJSSE
* @run main/othervm -DSERVER_PROTOCOL=TLSv1.2
* -DCLIENT_PROTOCOL=SSLv3,TLSv1,TLSv1.1,TLSv1.2
* -DCIPHER=SSL_RSA_WITH_RC4_128_MD5 TestJSSE
* @run main/othervm -DSERVER_PROTOCOL=SSLv3,TLSv1
* -DCLIENT_PROTOCOL=TLSv1 -DCIPHER=SSL_RSA_WITH_RC4_128_MD5 TestJSSE
* @run main/othervm -DSERVER_PROTOCOL=SSLv3,TLSv1,TLSv1.1
* -DCLIENT_PROTOCOL=TLSv1.1 -DCIPHER=SSL_RSA_WITH_RC4_128_MD5 TestJSSE
* @run main/othervm -DSERVER_PROTOCOL=SSLv3
* -DCLIENT_PROTOCOL=TLSv1.1,TLSv1.2
* -DCIPHER=SSL_RSA_WITH_RC4_128_MD5
* TestJSSE javax.net.ssl.SSLHandshakeException
* @run main/othervm -DSERVER_PROTOCOL=TLSv1
* -DCLIENT_PROTOCOL=TLSv1.1,TLSv1.2
* -DCIPHER=SSL_RSA_WITH_RC4_128_MD5
* TestJSSE javax.net.ssl.SSLHandshakeException
* @run main/othervm -DSERVER_PROTOCOL=SSLv3,TLSv1,TLSv1.1,TLSv1.2
* -DCLIENT_PROTOCOL=TLSv1.2 -DCIPHER=SSL_RSA_WITH_RC4_128_MD5 TestJSSE
* @run main/othervm -DSERVER_PROTOCOL=SSLv2Hello,SSLv3,TLSv1
* -DCLIENT_PROTOCOL=DEFAULT -DCIPHER=SSL_RSA_WITH_RC4_128_MD5 TestJSSE
* @run main/othervm -DSERVER_PROTOCOL=SSLv2Hello,SSLv3,TLSv1,TLSv1.1,TLSv1.2
* -DCLIENT_PROTOCOL=DEFAULT -DCIPHER=SSL_RSA_WITH_RC4_128_MD5 TestJSSE
* @run main/othervm -DSERVER_PROTOCOL=SSLv2Hello,SSLv3,TLSv1,TLSv1.1,TLSv1.2
* -DCLIENT_PROTOCOL=DEFAULT -Djdk.tls.client.protocols=TLSv1
* -DCIPHER=SSL_RSA_WITH_RC4_128_MD5 TestJSSE
* @run main/othervm -DSERVER_PROTOCOL=SSLv2Hello,SSLv3,TLSv1
* -DCLIENT_PROTOCOL=DEFAULT -Djdk.tls.client.protocols=TLSv1.2
* -DCIPHER=SSL_RSA_WITH_RC4_128_MD5
* TestJSSE javax.net.ssl.SSLHandshakeException
*
*/
public class TestJSSE {
private static final String LOCAL_IP = "127.0.0.1";
@ -82,72 +32,64 @@ public class TestJSSE {
// and keys used in this test are not disabled.
Security.setProperty("jdk.tls.disabledAlgorithms", "");
String serverProtocol = System.getProperty("SERVER_PROTOCOL");
String clientProtocol = System.getProperty("CLIENT_PROTOCOL");
// enable debug output
System.setProperty("javax.net.debug", "ssl,record");
String srvProtocol = System.getProperty("SERVER_PROTOCOL");
String clnProtocol = System.getProperty("CLIENT_PROTOCOL");
String cipher = System.getProperty("CIPHER");
if (serverProtocol == null
|| clientProtocol == null
|| cipher == null) {
throw new IllegalArgumentException("SERVER_PROTOCOL "
+ "or CLIENT_PROTOCOL or CIPHER is missing");
if (srvProtocol == null || clnProtocol == null || cipher == null) {
throw new IllegalArgumentException("Incorrect parameters");
}
out.println("ServerProtocol =" + serverProtocol);
out.println("ClientProtocol =" + clientProtocol);
out.println("Cipher =" + cipher);
int port = server(serverProtocol, cipher, args);
client(port, clientProtocol, cipher, args);
}
System.out.println("ServerProtocol = " + srvProtocol);
System.out.println("ClientProtocol = " + clnProtocol);
System.out.println("Cipher = " + cipher);
public static void client(int testPort,
String testProtocols, String testCipher,
String... exception) throws Exception {
String expectedException = exception.length >= 1
? exception[0] : null;
out.println("=========================================");
out.println(" Testing - https://" + LOCAL_IP + ":" + testPort);
out.println(" Testing - Protocol : " + testProtocols);
out.println(" Testing - Cipher : " + testCipher);
try {
CipherTestUtils.mainClient(new JSSEFactory(LOCAL_IP, testProtocols,
testCipher, "Client JSSE"),
testPort, expectedException);
} catch (Exception e) {
throw new RuntimeException(e);
try (CipherTestUtils.Server srv = server(srvProtocol, cipher, args)) {
client(srv.getPort(), clnProtocol, cipher, args);
}
}
public static int server(String testProtocol, String testCipher,
String... exception) throws Exception {
public static void client(int port, String protocols, String cipher,
String... exceptions) throws Exception {
String expectedException = exception.length >= 1
? exception[0] : null;
out.println(" This is Server");
out.println(" Testing Protocol: " + testProtocol);
out.println(" Testing Cipher: " + testCipher);
String expectedExcp = exceptions.length >= 1 ? exceptions[0] : null;
try {
int port = CipherTestUtils.mainServer(new JSSEFactory(
null, testProtocol, testCipher, "Server JSSE"),
expectedException);
System.out.println("This is client");
System.out.println("Testing protocol: " + protocols);
System.out.println("Testing cipher : " + cipher);
out.println(" Testing Port: " + port);
return port;
} catch (Exception e) {
throw new RuntimeException(e);
}
CipherTestUtils.mainClient(
new JSSEFactory(LOCAL_IP, protocols, cipher, "Client JSSE"),
port, expectedExcp);
}
public static CipherTestUtils.Server server(String protocol,
String cipher, String... exceptions) throws Exception {
String expectedExcp = exceptions.length >= 1 ? exceptions[0] : null;
System.out.println("This is server");
System.out.println("Testing protocol: " + protocol);
System.out.println("Testing cipher : " + cipher);
return CipherTestUtils.mainServer(
new JSSEFactory(null, protocol, cipher, "Server JSSE"),
expectedExcp);
}
private static class JSSEFactory extends CipherTestUtils.PeerFactory {
final String testedCipherSuite, testedProtocol, testHost;
final String name;
private final String cipher;
private final String protocol;
private final String host;
private final String name;
JSSEFactory(String testHost, String testedProtocol,
String testedCipherSuite, String name) {
this.testedCipherSuite = testedCipherSuite;
this.testedProtocol = testedProtocol;
this.testHost = testHost;
JSSEFactory(String host, String protocol, String cipher, String name) {
this.cipher = cipher;
this.protocol = protocol;
this.host = host;
this.name = name;
}
@ -158,26 +100,24 @@ public class TestJSSE {
@Override
String getTestedCipher() {
return testedCipherSuite;
return cipher;
}
@Override
String getTestedProtocol() {
return testedProtocol;
return protocol;
}
@Override
CipherTestUtils.Client newClient(CipherTestUtils cipherTest, int testPort)
CipherTestUtils.Client newClient(CipherTestUtils cipherTest, int port)
throws Exception {
return new JSSEClient(cipherTest, testHost, testPort,
testedProtocol, testedCipherSuite);
return new JSSEClient(cipherTest, host, port, protocol, cipher);
}
@Override
CipherTestUtils.Server newServer(CipherTestUtils cipherTest, int testPort)
CipherTestUtils.Server newServer(CipherTestUtils cipherTest, int port)
throws Exception {
return new JSSEServer(cipherTest, testPort,
testedProtocol, testedCipherSuite);
return new JSSEServer(cipherTest, port, protocol, cipher);
}
}
}

@ -0,0 +1,54 @@
/*
* Copyright (c) 2016, 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 8049429
* @modules java.management
* jdk.crypto.ec/sun.security.ec
* @summary Test that all cipher suites work in all versions and all client
* authentication types. The way this is setup the server is stateless
* and all checking is done on the client side.
* @compile CipherTestUtils.java JSSEClient.java JSSEServer.java
* @run main/othervm
* -DSERVER_PROTOCOL=SSLv2Hello,SSLv3,TLSv1
* -DCLIENT_PROTOCOL=DEFAULT
* -DCIPHER=SSL_RSA_WITH_RC4_128_MD5
* TestJSSE
* @run main/othervm
* -DSERVER_PROTOCOL=SSLv2Hello,SSLv3,TLSv1,TLSv1.1,TLSv1.2
* -DCLIENT_PROTOCOL=DEFAULT
* -DCIPHER=SSL_RSA_WITH_RC4_128_MD5
* TestJSSE
* @run main/othervm
* -DSERVER_PROTOCOL=SSLv2Hello,SSLv3,TLSv1,TLSv1.1,TLSv1.2
* -DCLIENT_PROTOCOL=DEFAULT
* -Djdk.tls.client.protocols=TLSv1
* -DCIPHER=SSL_RSA_WITH_RC4_128_MD5
* TestJSSE
* @run main/othervm
* -DSERVER_PROTOCOL=SSLv2Hello,SSLv3,TLSv1
* -DCLIENT_PROTOCOL=DEFAULT
* -Djdk.tls.client.protocols=TLSv1.2
* -DCIPHER=SSL_RSA_WITH_RC4_128_MD5
* TestJSSE javax.net.ssl.SSLHandshakeException
*/

@ -0,0 +1,52 @@
/*
* Copyright (c) 2016, 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 8049429
* @modules java.management
* jdk.crypto.ec/sun.security.ec
* @summary Test that all cipher suites work in all versions and all client
* authentication types. The way this is setup the server is stateless
* and all checking is done on the client side.
* @compile CipherTestUtils.java JSSEClient.java JSSEServer.java
* @run main/othervm
* -DSERVER_PROTOCOL=SSLv3
* -DCLIENT_PROTOCOL=SSLv3
* -DCIPHER=SSL_RSA_WITH_RC4_128_MD5
* TestJSSE
* @run main/othervm
* -DSERVER_PROTOCOL=SSLv3,TLSv1
* -DCLIENT_PROTOCOL=TLSv1
* -DCIPHER=SSL_RSA_WITH_RC4_128_MD5
* TestJSSE
* @run main/othervm
* -DSERVER_PROTOCOL=SSLv3,TLSv1,TLSv1.1
* -DCLIENT_PROTOCOL=TLSv1.1
* -DCIPHER=SSL_RSA_WITH_RC4_128_MD5
* TestJSSE
* @run main/othervm
* -DSERVER_PROTOCOL=SSLv3,TLSv1,TLSv1.1,TLSv1.2
* -DCLIENT_PROTOCOL=TLSv1.2
* -DCIPHER=SSL_RSA_WITH_RC4_128_MD5
* TestJSSE
*/

@ -0,0 +1,37 @@
/*
* Copyright (c) 2016, 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 8049429
* @modules java.management
* jdk.crypto.ec/sun.security.ec
* @summary Test that all cipher suites work in all versions and all client
* authentication types. The way this is setup the server is stateless
* and all checking is done on the client side.
* @compile CipherTestUtils.java JSSEClient.java JSSEServer.java
* @run main/othervm
* -DSERVER_PROTOCOL=TLSv1
* -DCLIENT_PROTOCOL=TLSv1.1,TLSv1.2
* -DCIPHER=SSL_RSA_WITH_RC4_128_MD5
* TestJSSE javax.net.ssl.SSLHandshakeException
*/

@ -0,0 +1,52 @@
/*
* Copyright (c) 2016, 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 8049429
* @modules java.management
* jdk.crypto.ec/sun.security.ec
* @summary Test that all cipher suites work in all versions and all client
* authentication types. The way this is setup the server is stateless
* and all checking is done on the client side.
* @compile CipherTestUtils.java JSSEClient.java JSSEServer.java
* @run main/othervm
* -DSERVER_PROTOCOL=SSLv3
* -DCLIENT_PROTOCOL=TLSv1.1,TLSv1.2
* -DCIPHER=SSL_RSA_WITH_RC4_128_MD5
* TestJSSE javax.net.ssl.SSLHandshakeException
* @run main/othervm
* -DSERVER_PROTOCOL=TLSv1
* -DCLIENT_PROTOCOL=SSLv3,TLSv1,TLSv1.1,TLSv1.2
* -DCIPHER=SSL_RSA_WITH_RC4_128_MD5
* TestJSSE
* @run main/othervm
* -DSERVER_PROTOCOL=TLSv1.1
* -DCLIENT_PROTOCOL=SSLv3,TLSv1,TLSv1.1,TLSv1.2
* -DCIPHER=SSL_RSA_WITH_RC4_128_MD5
* TestJSSE
* @run main/othervm
* -DSERVER_PROTOCOL=TLSv1.2
* -DCLIENT_PROTOCOL=SSLv3,TLSv1,TLSv1.1,TLSv1.2
* -DCIPHER=SSL_RSA_WITH_RC4_128_MD5
* TestJSSE
*/

@ -178,8 +178,11 @@ public class SSLSocketSSLEngineTemplate {
char[] passphrase = "passphrase".toCharArray();
ks.load(new FileInputStream(keyFilename), passphrase);
ts.load(new FileInputStream(trustFilename), passphrase);
try (FileInputStream keyFile = new FileInputStream(keyFilename);
FileInputStream trustFile = new FileInputStream(trustFilename)) {
ks.load(keyFile, passphrase);
ts.load(trustFile, passphrase);
}
KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
kmf.init(ks, passphrase);
@ -310,6 +313,7 @@ public class SSLSocketSSLEngineTemplate {
if (retry &&
serverIn.remaining() < clientMsg.length) {
log("Need to read more from client");
serverIn.compact();
retry = false;
continue;
} else {

@ -0,0 +1,120 @@
/*
* Copyright (c) 2016, 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.util.ArrayList;
import javax.naming.InitialContext;
import javax.naming.Context;
import javax.naming.NameNotFoundException;
import javax.rmi.PortableRemoteObject;
public class HelloClient implements Runnable {
static final int MAX_RETRY = 10;
static final int ONE_SECOND = 1000;
private static boolean responseReceived;
public static void main(String args[]) throws Exception {
executeRmiClientCall();
}
@Override
public void run() {
try {
executeRmiClientCall();
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
public static boolean isResponseReceived () {
return responseReceived;
}
public static void executeRmiClientCall() throws Exception {
Context ic;
Object objref;
HelloInterface helloSvc;
String response;
Object testResponse;
int retryCount = 0;
ArrayList<Test> listParam = new ArrayList<Test>();
listParam.add(null);
System.out.println("HelloClient.main: enter ...");
while (retryCount < MAX_RETRY) {
try {
ic = new InitialContext();
System.out.println("HelloClient.main: HelloService lookup ...");
// STEP 1: Get the Object reference from the Name Service
// using JNDI call.
objref = ic.lookup("HelloService");
System.out.println("HelloClient: Obtained a ref. to Hello server.");
// STEP 2: Narrow the object reference to the concrete type and
// invoke the method.
helloSvc = (HelloInterface) PortableRemoteObject.narrow(objref,
HelloInterface.class);
Test3 test3 = new Test3(listParam);
Test3 test3Response = helloSvc.sayHelloWithTest3(test3);
System.out.println("Server says: Test3 response == " + test3Response);
Test3 test3WithNullList = new Test3(null);
test3Response = helloSvc.sayHelloWithTest3(test3WithNullList);
System.out.println("Server says: Test3 response == "
+ test3Response);
Test4 test4 = new Test4(listParam);
Test3 test4Response = helloSvc.sayHelloWithTest3(test4);
System.out.println("Server says: Test4 response == " + test4Response);
responseReceived = true;
break;
} catch (NameNotFoundException nnfEx) {
System.err.println("NameNotFoundException Caught .... try again");
retryCount++;
try {
Thread.sleep(ONE_SECOND);
} catch (InterruptedException e) {
e.printStackTrace();
}
continue;
} catch (Throwable t) {
System.err.println("Exception " + t + "Caught");
t.printStackTrace();
throw new RuntimeException(t);
}
}
System.err.println("HelloClient terminating ");
try {
Thread.sleep(ONE_SECOND);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}

@ -0,0 +1,41 @@
/*
* Copyright (c) 2016, 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.rmi.RemoteException;
import javax.rmi.PortableRemoteObject;
public class HelloImpl extends PortableRemoteObject implements HelloInterface {
public HelloImpl() throws java.rmi.RemoteException {
super(); // invoke rmi linking and remote object initialization
}
@Override
public Test3 sayHelloWithTest3(Test3 test) throws RemoteException {
System.out.println("sayHelloToTest3: ENTER " );
return test;
}
}

@ -0,0 +1,28 @@
/*
* Copyright (c) 2016, 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.rmi.Remote;
public interface HelloInterface extends Remote {
public Test3 sayHelloWithTest3( Test3 test ) throws java.rmi.RemoteException;
}

@ -0,0 +1,58 @@
/*
* Copyright (c) 2016, 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 javax.naming.InitialContext;
import javax.naming.Context;
public class HelloServer {
static final int MAX_RETRY = 10;
static final int ONE_SECOND = 1000;
public static void main(String[] args) {
int retryCount = 0;
while (retryCount < MAX_RETRY) {
try {
// Step 1: Instantiate the Hello servant
HelloImpl helloRef = new HelloImpl();
// Step 2: Publish the reference in the Naming Service
// using JNDI API
Context initialNamingContext = new InitialContext();
initialNamingContext.rebind("HelloService", helloRef);
System.out.println("Hello Server: Ready...");
break;
} catch (Exception e) {
System.out.println("Server initialization problem: " + e);
e.printStackTrace();
retryCount++;
try {
Thread.sleep(ONE_SECOND);
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
}
}
}

@ -0,0 +1,157 @@
/*
* Copyright (c) 2016, 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 8146975
* @summary test RMI-IIOP with value object return
* @library /lib/testlibrary
* @build jdk.testlibrary.*
* @compile -addmods java.corba Test.java Test3.java Test4.java
* HelloInterface.java HelloServer.java
* HelloClient.java HelloImpl.java _HelloImpl_Tie.java _HelloInterface_Stub.java
* RmiIiopReturnValueTest.java
* @run main/othervm -addmods java.corba
* -Djava.naming.provider.url=iiop://localhost:5050
* -Djava.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory
* RmiIiopReturnValueTest -port 5049
* @run main/othervm/secure=java.lang.SecurityManager/policy=jtreg.test.policy
* -addmods java.corba -Djava.naming.provider.url=iiop://localhost:5050
* -Djava.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory
* RmiIiopReturnValueTest -port 5049
*/
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import jdk.testlibrary.JDKToolFinder;
import jdk.testlibrary.JDKToolLauncher;
public class RmiIiopReturnValueTest {
static final String ORBD = JDKToolFinder.getTestJDKTool("orbd");
static final String JAVA = JDKToolFinder.getTestJDKTool("java");
static final JDKToolLauncher orbdLauncher = JDKToolLauncher.createUsingTestJDK("orbd");
static final String CLASSPATH = System.getProperty("java.class.path");
static final int FIVE_SECONDS = 5000;
private static Throwable clientException;
private static boolean exceptionInClient;
private static Process orbdProcess;
private static Process rmiServerProcess;
public static void main(String[] args) throws Exception {
startTestComponents();
stopTestComponents();
System.err.println("Test completed OK ");
}
static void startTestComponents () throws Exception {
startOrbd();
Thread.sleep(FIVE_SECONDS);
startRmiIiopServer();
Thread.sleep(FIVE_SECONDS);
executeRmiIiopClient();
}
private static void stopTestComponents() throws Exception {
stopRmiIiopServer();
stopOrbd();
if (exceptionInClient) {
throw new RuntimeException(clientException);
} else if (!isResponseReceived()) {
throw new RuntimeException("Expected Response not received");
}
}
static void startOrbd() throws Exception {
System.out.println("\nStarting orbd with NS port 5050 and activation port 5049 ");
//orbd -ORBInitialHost localhost -ORBInitialPort 5050 -port 5049
orbdLauncher.addToolArg("-ORBInitialHost").addToolArg("localhost")
.addToolArg("-ORBInitialPort").addToolArg("5050")
.addToolArg("-port").addToolArg("5049");
System.out.println("RmiIiopReturnValueTest: Executing: " + Arrays.asList(orbdLauncher.getCommand()));
ProcessBuilder pb = new ProcessBuilder(orbdLauncher.getCommand());
pb.redirectError(ProcessBuilder.Redirect.INHERIT);
orbdProcess = pb.start();
}
static void startRmiIiopServer() throws Exception {
System.out.println("\nStarting RmiIiopServer");
// java -addmods java.corba -cp .
// -Djava.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory
// -Djava.naming.provider.url=iiop://localhost:5050 HelloServer -port 5049
List<String> commands = new ArrayList<>();
commands.add(RmiIiopReturnValueTest.JAVA);
commands.add("-addmods");
commands.add("java.corba");
commands.add("-Djava.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory");
commands.add("-Djava.naming.provider.url=iiop://localhost:5050");
commands.add("-cp");
commands.add(RmiIiopReturnValueTest.CLASSPATH);
commands.add("HelloServer");
commands.add("-port");
commands.add("5049");
System.out.println("RmiIiopReturnValueTest: Executing: " + commands);
ProcessBuilder pb = new ProcessBuilder(commands);
pb.redirectError(ProcessBuilder.Redirect.INHERIT);
rmiServerProcess = pb.start();
}
static boolean isResponseReceived() {
return HelloClient.isResponseReceived();
}
static void stopRmiIiopServer() throws Exception {
if (rmiServerProcess != null) {
System.out.println("RmiIiopReturnValueTest.stopRmiIiopServer: destroy rmiServerProcess");
rmiServerProcess.destroyForcibly();
rmiServerProcess.waitFor();
System.out.println("serverProcess exitCode:"
+ rmiServerProcess.exitValue());
}
}
static void stopOrbd() throws Exception {
System.out.println("RmiIiopReturnValueTest.stopOrbd: destroy orbdProcess ");
orbdProcess.destroyForcibly();
orbdProcess.waitFor();
System.out.println("orbd exitCode:"
+ orbdProcess.exitValue());
}
static void executeRmiIiopClient() throws Exception {
System.out.println("RmiIiopReturnValueTest.executeRmiIiopClient: HelloClient.executeRmiClientCall");
try {
HelloClient.executeRmiClientCall();
} catch (Throwable t) {
clientException = t;
exceptionInClient = true;
}
}
}

@ -0,0 +1,29 @@
/*
* Copyright (c) 2016, 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.Serializable;
public class Test implements Serializable {
}

@ -0,0 +1,36 @@
/*
* Copyright (c) 2016, 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.Serializable;
import java.util.List;
public class Test3 implements Serializable {
private List<Test> list;
public Test3(List<Test> list) {
this.list = list;
}
}

@ -0,0 +1,41 @@
/*
* Copyright (c) 2016, 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.util.List;
public class Test4 extends Test3 {
private int aNumber = 1;
public Test4(List<Test> list) {
super(list);
}
/**
*
*/
private static final long serialVersionUID = 1L;
}

@ -0,0 +1,103 @@
/*
* Copyright (c) 2016, 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.
*/
// Tie class generated by rmic, do not edit.
// Contents subject to change without notice.
import java.io.Serializable;
import java.rmi.Remote;
import java.rmi.RemoteException;
import javax.rmi.CORBA.Tie;
import javax.rmi.CORBA.Util;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
import org.omg.CORBA.SystemException;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
import org.omg.CORBA.portable.ResponseHandler;
import org.omg.CORBA.portable.UnknownException;
import org.omg.CORBA_2_3.portable.ObjectImpl;
public class _HelloImpl_Tie extends ObjectImpl implements Tie {
volatile private HelloImpl target = null;
private static final String[] _type_ids = {
"RMI:HelloInterface:0000000000000000"
};
public void setTarget(Remote target) {
this.target = (HelloImpl) target;
}
public Remote getTarget() {
return target;
}
public org.omg.CORBA.Object thisObject() {
return this;
}
public void deactivate() {
_orb().disconnect(this);
_set_delegate(null);
target = null;
}
public ORB orb() {
return _orb();
}
public void orb(ORB orb) {
orb.connect(this);
}
public String[] _ids() {
return (String[]) _type_ids.clone();
}
public OutputStream _invoke(String method, InputStream _in, ResponseHandler reply) throws SystemException {
try {
HelloImpl target = this.target;
if (target == null) {
throw new java.io.IOException();
}
org.omg.CORBA_2_3.portable.InputStream in =
(org.omg.CORBA_2_3.portable.InputStream) _in;
if (method.equals("sayHelloWithTest3")) {
Test3 arg0 = (Test3) in.read_value(Test3.class);
Test3 result = target.sayHelloWithTest3(arg0);
org.omg.CORBA_2_3.portable.OutputStream out =
(org.omg.CORBA_2_3.portable.OutputStream) reply.createReply();
out.write_value(result,Test3.class);
return out;
}
throw new BAD_OPERATION();
} catch (SystemException ex) {
throw ex;
} catch (Throwable ex) {
throw new UnknownException(ex);
}
}
}

@ -0,0 +1,93 @@
/*
* Copyright (c) 2016, 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.
*/
// Stub class generated by rmic, do not edit.
// Contents subject to change without notice.
import java.io.Serializable;
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.rmi.UnexpectedException;
import javax.rmi.CORBA.Stub;
import javax.rmi.CORBA.Util;
import org.omg.CORBA.ORB;
import org.omg.CORBA.SystemException;
import org.omg.CORBA.portable.ApplicationException;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
import org.omg.CORBA.portable.RemarshalException;
import org.omg.CORBA.portable.ResponseHandler;
import org.omg.CORBA.portable.ServantObject;
public class _HelloInterface_Stub extends Stub implements HelloInterface {
private static final String[] _type_ids = {
"RMI:HelloInterface:0000000000000000"
};
public String[] _ids() {
return (String[]) _type_ids.clone();
}
public Test3 sayHelloWithTest3(Test3 arg0) throws java.rmi.RemoteException {
if (!Util.isLocal(this)) {
try {
org.omg.CORBA_2_3.portable.InputStream in = null;
try {
org.omg.CORBA_2_3.portable.OutputStream out =
(org.omg.CORBA_2_3.portable.OutputStream)
_request("sayHelloWithTest3", true);
out.write_value(arg0,Test3.class);
in = (org.omg.CORBA_2_3.portable.InputStream)_invoke(out);
return (Test3) in.read_value(Test3.class);
} catch (ApplicationException ex) {
in = (org.omg.CORBA_2_3.portable.InputStream) ex.getInputStream();
String $_id = in.read_string();
throw new UnexpectedException($_id);
} catch (RemarshalException ex) {
return sayHelloWithTest3(arg0);
} finally {
_releaseReply(in);
}
} catch (SystemException ex) {
throw Util.mapSystemException(ex);
}
} else {
ServantObject so = _servant_preinvoke("sayHelloWithTest3",HelloInterface.class);
if (so == null) {
return sayHelloWithTest3(arg0);
}
try {
Test3 arg0Copy = (Test3) Util.copyObject(arg0,_orb());
Test3 result = ((HelloInterface)so.servant).sayHelloWithTest3(arg0Copy);
return (Test3)Util.copyObject(result,_orb());
} catch (Throwable ex) {
Throwable exCopy = (Throwable)Util.copyObject(ex,_orb());
throw Util.wrapException(exCopy);
} finally {
_servant_postinvoke(so);
}
}
}
}

@ -0,0 +1,45 @@
/*
* Copyright (c) 2016, 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.
*/
grant codeBase "jrt:/java.corba" {
permission java.security.AllPermission;
};
grant {
permission java.io.FilePermission "./-", "read,write,execute";
permission java.io.FilePermission "*", "read";
permission java.net.SocketPermission "*:*", "connect, accept, listen, resolve";
permission java.util.PropertyPermission "*", "read, write";
permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
permission java.io.SerializablePermission "enableSubclassImplementation";
permission java.lang.RuntimePermission "accessClassInPackage.jdk.internal.misc";
permission java.lang.RuntimePermission "accessClassInPackage.sun.corba";
permission java.lang.RuntimePermission "defineClassInPackage.sun.corba";
permission java.lang.RuntimePermission "reflectionFactoryAccess";
permission sun.corba.BridgePermission "getBridge";
permission java.lang.RuntimePermission "accessClassInPackage.jdk.internal.reflect";
permission java.util.PropertyPermission "*", "read, write";
permission java.io.FilePermission "<<ALL FILES>>", "read,write,execute";
};

@ -31,17 +31,16 @@
* HelloImpl.java _HelloImpl_Tie.java _HelloInterface_Stub.java ConcurrentHashMapTest.java
* @run main/othervm -addmods java.corba -Djava.naming.provider.url=iiop://localhost:1050
* -Djava.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory ConcurrentHashMapTest
* @run main/othervm/secure=java.lang.SecurityManager/policy=jtreg.test.policy
* -addmods java.corba -Djava.naming.provider.url=iiop://localhost:1050
* -Djava.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory ConcurrentHashMapTest
* @key intermittent
*/
import java.io.DataInputStream;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.CountDownLatch;
import jdk.testlibrary.JDKToolFinder;
import jdk.testlibrary.JDKToolLauncher;
@ -83,7 +82,7 @@ public class ConcurrentHashMapTest {
}
static void startOrbd() throws Exception {
System.out.println("\nStarting orbd on port 1050 ");
System.out.println("\nStarting orbd with NS port 1050 ");
//orbd -ORBInitialHost localhost -ORBInitialPort 1050
orbdLauncher.addToolArg("-ORBInitialHost").addToolArg("localhost")
@ -98,7 +97,7 @@ public class ConcurrentHashMapTest {
static void startRmiIiopServer() throws Exception {
System.out.println("\nStarting RmiServer");
// java -cp .
// java -cp . -addmods java.corba
// -Djava.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory
// -Djava.naming.provider.url=iiop://localhost:1050 HelloServer
List<String> commands = new ArrayList<>();
@ -122,17 +121,15 @@ public class ConcurrentHashMapTest {
}
static void stopRmiIiopServer() throws Exception {
rmiServerProcess.destroy();
rmiServerProcess.destroyForcibly();
rmiServerProcess.waitFor();
//rmiServerProcess.waitFor(30, TimeUnit.SECONDS);
System.out.println("serverProcess exitCode:"
+ rmiServerProcess.exitValue());
}
static void stopOrbd() throws Exception {
orbdProcess.destroy();
orbdProcess.destroyForcibly();
orbdProcess.waitFor();
//orbdProcess.waitFor(30, TimeUnit.SECONDS);
System.out.println("orbd exitCode:"
+ orbdProcess.exitValue());
}

@ -0,0 +1,43 @@
/*
* Copyright (c) 2016, 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.
*/
grant codeBase "jrt:/java.corba" {
permission java.security.AllPermission;
};
grant {
permission java.io.FilePermission "./-", "read,write,execute";
permission java.io.FilePermission "*", "read";
permission java.net.SocketPermission "*:*", "connect, accept, listen, resolve";
permission java.util.PropertyPermission "*", "read, write";
permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
permission java.io.SerializablePermission "enableSubclassImplementation";
permission java.lang.RuntimePermission "accessClassInPackage.jdk.internal.misc";
permission java.lang.RuntimePermission "accessClassInPackage.sun.corba";
permission java.lang.RuntimePermission "defineClassInPackage.sun.corba";
permission java.lang.RuntimePermission "reflectionFactoryAccess";
permission sun.corba.BridgePermission "getBridge";
permission java.lang.RuntimePermission "accessClassInPackage.jdk.internal.reflect";
permission java.util.PropertyPermission "*", "read, write";
permission java.io.FilePermission "<<ALL FILES>>", "read,write,execute";
};

@ -29,8 +29,9 @@
* @library ..
* @library /lib/testlibrary
* @build jdk.testlibrary.*
* @run main/othervm TestKeyPairGenerator
* @run main/othervm TestKeyPairGenerator sm TestKeyPairGenerator.policy
* @run main/othervm -Djava.security.debug=sunpkcs11 TestKeyPairGenerator
* @run main/othervm -Djava.security.debug=sunpkcs11 TestKeyPairGenerator
* sm TestKeyPairGenerator.policy
* @key intermittent randomness
*/

@ -26,7 +26,6 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -64,13 +63,6 @@ public class DefaultProviderTest {
private static class Custom implements TransformerPlugin {
private boolean enabled = true;
@Override
public Set<Category> getType() {
Set<Category> set = new HashSet<>();
set.add(Category.TRANSFORMER);
return Collections.unmodifiableSet(set);
}
@Override
public Set<State> getState() {
return enabled ? EnumSet.of(State.AUTO_ENABLED, State.FUNCTIONAL)

@ -90,10 +90,8 @@ public class IntegrationTest {
}
@Override
public Set<Category> getType() {
Set<Category> set = new HashSet<>();
set.add(Category.PROCESSOR);
return Collections.unmodifiableSet(set);
public Category getType() {
return Category.PROCESSOR;
}
@Override
@ -138,13 +136,6 @@ public class IntegrationTest {
}, out);
}
@Override
public Set<Category> getType() {
Set<Category> set = new HashSet<>();
set.add(Category.TRANSFORMER);
return Collections.unmodifiableSet(set);
}
@Override
public String getDescription() {
return null;

@ -9,11 +9,9 @@ import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Stream;
import jdk.internal.org.objectweb.asm.ClassReader;
import jdk.internal.org.objectweb.asm.Opcodes;
@ -132,13 +130,6 @@ public class JLinkOptimTest {
public String getName() {
return NAME;
}
@Override
public Set<Category> getType() {
Set<Category> set = new HashSet<>();
set.add(Category.TRANSFORMER);
return Collections.unmodifiableSet(set);
}
}
private static void testForName() throws Exception {

@ -26,10 +26,8 @@ import java.io.UncheckedIOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import jdk.tools.jlink.internal.PluginRepository;
import jdk.tools.jlink.plugin.ExecutableImage;
@ -75,10 +73,8 @@ public class JLinkPostProcessingTest {
}
@Override
public Set<Category> getType() {
Set<Category> set = new HashSet<>();
set.add(Category.PROCESSOR);
return Collections.unmodifiableSet(set);
public Category getType() {
return Category.PROCESSOR;
}
@Override

@ -23,9 +23,7 @@
package plugin;
import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.function.Function;
import jdk.tools.jlink.plugin.ModuleEntry;
import jdk.tools.jlink.plugin.ModulePool;
@ -58,9 +56,7 @@ public class CustomPlugin implements TransformerPlugin {
}
@Override
public Set<Category> getType() {
Set<Category> set = new HashSet<>();
set.add(Category.PROCESSOR);
return Collections.unmodifiableSet(set);
public Category getType() {
return Category.PROCESSOR;
}
}

@ -26,9 +26,7 @@ import java.io.File;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import jdk.tools.jlink.plugin.ModuleEntry;
import jdk.tools.jlink.plugin.ModulePool;
import jdk.tools.jlink.plugin.TransformerPlugin;
@ -62,13 +60,6 @@ public final class HelloPlugin implements TransformerPlugin {
}
}
@Override
public Set<Category> getType() {
Set<Category> set = new HashSet<>();
set.add(Category.TRANSFORMER);
return Collections.unmodifiableSet(set);
}
@Override
public String getDescription() {
return NAME + "-description";

@ -33,10 +33,8 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import jdk.tools.jlink.internal.ImagePluginConfiguration;
import jdk.tools.jlink.internal.PluginRepository;
@ -199,13 +197,6 @@ public class LastSorterTest {
return name;
}
@Override
public Set<Category> getType() {
Set<Category> set = new HashSet<>();
set.add(Category.TRANSFORMER);
return Collections.unmodifiableSet(set);
}
@Override
public void configure(Map<String, String> config) {
String arguments = config.get(name);

@ -260,8 +260,8 @@ public class PluginOrderTest {
}
@Override
public Set<Category> getType() {
return Collections.singleton(category);
public Category getType() {
return category;
}
@Override

@ -32,10 +32,8 @@
import java.lang.reflect.Layer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import jdk.tools.jlink.internal.ImagePluginConfiguration;
import jdk.tools.jlink.internal.PluginRepository;
@ -137,13 +135,6 @@ public class PluginsNegativeTest {
return name;
}
@Override
public Set<Category> getType() {
Set<Category> set = new HashSet<>();
set.add(Category.TRANSFORMER);
return Collections.unmodifiableSet(set);
}
@Override
public String getDescription() {
return null;

@ -34,11 +34,9 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import jdk.tools.jlink.internal.ImagePluginConfiguration;
@ -160,12 +158,5 @@ public class PrevisitorTest {
}
});
}
@Override
public Set<Category> getType() {
Set<Category> set = new HashSet<>();
set.add(Category.TRANSFORMER);
return Collections.unmodifiableSet(set);
}
}
}