This commit is contained in:
Alejandro Murillo 2016-06-30 10:31:19 -07:00
commit a0e450c561
65 changed files with 444 additions and 490 deletions

View File

@ -56,6 +56,7 @@ SUNWprivate_1.1 {
JNU_ThrowArrayIndexOutOfBoundsException;
JNU_ThrowByName;
JNU_ThrowByNameWithLastError;
JNU_ThrowByNameWithMessageAndLastError;
JNU_ThrowClassNotFoundException;
JNU_ThrowIllegalAccessError;
JNU_ThrowIllegalAccessException;

View File

@ -182,7 +182,17 @@ void setOSNameAndVersion(java_props_t *sprops) {
// Copy out the char*
osVersionCStr = strdup([nsVerStr UTF8String]);
}
// Fallback if running on pre-10.9 Mac OS
if (osVersionCStr == NULL) {
NSDictionary *version = [NSDictionary dictionaryWithContentsOfFile :
@"/System/Library/CoreServices/SystemVersion.plist"];
if (version != NULL) {
NSString *nsVerStr = [version objectForKey : @"ProductVersion"];
if (nsVerStr != NULL) {
osVersionCStr = strdup([nsVerStr UTF8String]);
}
}
}
if (osVersionCStr == NULL) {
osVersionCStr = strdup("Unknown");
}
@ -190,7 +200,9 @@ void setOSNameAndVersion(java_props_t *sprops) {
}
static Boolean getProxyInfoForProtocol(CFDictionaryRef inDict, CFStringRef inEnabledKey, CFStringRef inHostKey, CFStringRef inPortKey, CFStringRef *outProxyHost, int *ioProxyPort) {
static Boolean getProxyInfoForProtocol(CFDictionaryRef inDict, CFStringRef inEnabledKey,
CFStringRef inHostKey, CFStringRef inPortKey,
CFStringRef *outProxyHost, int *ioProxyPort) {
/* See if the proxy is enabled. */
CFNumberRef cf_enabled = CFDictionaryGetValue(inDict, inEnabledKey);
if (cf_enabled == NULL) {

View File

@ -221,7 +221,7 @@ public class DateFormatSymbols implements Serializable, Cloneable {
* </ul>
* The zone ID is <em>not</em> localized; it's one of the valid IDs of
* the {@link java.util.TimeZone TimeZone} class that are not
* <a href="../java/util/TimeZone.html#CustomID">custom IDs</a>.
* <a href="../util/TimeZone.html#CustomID">custom IDs</a>.
* All other entries are localized names.
* @see java.util.TimeZone
* @serial

View File

@ -93,7 +93,7 @@ import sun.security.jca.*;
* provide authenticity assurances for both confidential data and
* Additional Associated Data (AAD) that is not encrypted. (Please see
* <a href="http://www.ietf.org/rfc/rfc5116.txt"> RFC 5116 </a> for more
* information on AEAD and AEAD algorithms such as GCM/CCM.) Both
* information on AEAD and AAD algorithms such as GCM/CCM.) Both
* confidential and AAD data can be used when calculating the
* authentication tag (similar to a {@link Mac}). This tag is appended
* to the ciphertext during encryption, and is verified on decryption.
@ -1186,7 +1186,7 @@ public class Cipher {
* determined from the given key, or if the given key has a keysize that
* exceeds the maximum allowable keysize (as determined from the
* configured jurisdiction policy files).
* @throws UnsupportedOperationException if (@code opmode} is
* @throws UnsupportedOperationException if {@code opmode} is
* {@code WRAP_MODE} or {@code UNWRAP_MODE} but the mode is not implemented
* by the underlying {@code CipherSpi}.
*/
@ -1239,7 +1239,7 @@ public class Cipher {
* determined from the given key, or if the given key has a keysize that
* exceeds the maximum allowable keysize (as determined from the
* configured jurisdiction policy files).
* @throws UnsupportedOperationException if (@code opmode} is
* @throws UnsupportedOperationException if {@code opmode} is
* {@code WRAP_MODE} or {@code UNWRAP_MODE} but the mode is not implemented
* by the underlying {@code CipherSpi}.
*/
@ -1325,7 +1325,7 @@ public class Cipher {
* algorithm parameters imply a cryptographic strength that would exceed
* the legal limits (as determined from the configured jurisdiction
* policy files).
* @throws UnsupportedOperationException if (@code opmode} is
* @throws UnsupportedOperationException if {@code opmode} is
* {@code WRAP_MODE} or {@code UNWRAP_MODE} but the mode is not implemented
* by the underlying {@code CipherSpi}.
*/
@ -1386,7 +1386,7 @@ public class Cipher {
* algorithm parameters imply a cryptographic strength that would exceed
* the legal limits (as determined from the configured jurisdiction
* policy files).
* @throws UnsupportedOperationException if (@code opmode} is
* @throws UnsupportedOperationException if {@code opmode} is
* {@code WRAP_MODE} or {@code UNWRAP_MODE} but the mode is not implemented
* by the underlying {@code CipherSpi}.
*/
@ -1468,7 +1468,7 @@ public class Cipher {
* algorithm parameters imply a cryptographic strength that would exceed
* the legal limits (as determined from the configured jurisdiction
* policy files).
* @throws UnsupportedOperationException if (@code opmode} is
* @throws UnsupportedOperationException if {@code opmode} is
* {@code WRAP_MODE} or {@code UNWRAP_MODE} but the mode is not implemented
* by the underlying {@code CipherSpi}.
*/
@ -1529,7 +1529,7 @@ public class Cipher {
* algorithm parameters imply a cryptographic strength that would exceed
* the legal limits (as determined from the configured jurisdiction
* policy files).
* @throws UnsupportedOperationException if (@code opmode} is
* @throws UnsupportedOperationException if {@code opmode} is
* {@code WRAP_MODE} or {@code UNWRAP_MODE} but the mode is not implemented
* by the underlying {@code CipherSpi}.
*/
@ -1616,7 +1616,7 @@ public class Cipher {
* in the given certificate has a keysize that exceeds the maximum
* allowable keysize (as determined by the configured jurisdiction policy
* files).
* @throws UnsupportedOperationException if (@code opmode} is
* @throws UnsupportedOperationException if {@code opmode} is
* {@code WRAP_MODE} or {@code UNWRAP_MODE} but the mode is not implemented
* by the underlying {@code CipherSpi}.
*/
@ -1686,7 +1686,7 @@ public class Cipher {
* in the given certificate has a keysize that exceeds the maximum
* allowable keysize (as determined by the configured jurisdiction policy
* files).
* @throws UnsupportedOperationException if (@code opmode} is
* @throws UnsupportedOperationException if {@code opmode} is
* {@code WRAP_MODE} or {@code UNWRAP_MODE} but the mode is not implemented
* by the underlying {@code CipherSpi}.
*/

View File

@ -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
@ -97,10 +97,11 @@ final class StatusResponseManager {
t.setDaemon(true);
return t;
}
});
}, new ThreadPoolExecutor.DiscardPolicy());
threadMgr.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
threadMgr.setContinueExistingPeriodicTasksAfterShutdownPolicy(false);
threadMgr.setKeepAliveTime(5000, TimeUnit.MILLISECONDS);
threadMgr.allowCoreThreadTimeOut(true);
responseCache = Cache.newSoftMemoryCache(cacheCapacity, cacheLifetime);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
@ -147,9 +147,9 @@ JNU_ThrowInstantiationException(JNIEnv *env, const char *msg)
JNU_ThrowByName(env, "java/lang/InstantiationException", msg);
}
/* Throw an exception by name, using the string returned by
* JVM_LastErrorString for the detail string. If the last-error
/*
* Throw an exception by name, using the string returned by
* getLastErrorString for the detail string. If the last-error
* string is NULL, use the given default detail string.
*/
JNIEXPORT void JNICALL
@ -174,9 +174,64 @@ JNU_ThrowByNameWithLastError(JNIEnv *env, const char *name,
}
}
/* Throw an IOException, using the last-error string for the detail
* string. If the last-error string is NULL, use the given default
* detail string.
/*
* Throw an exception by name, using a given message and the string
* returned by getLastErrorString to construct the detail string.
*/
JNIEXPORT void JNICALL
JNU_ThrowByNameWithMessageAndLastError
(JNIEnv *env, const char *name, const char *message)
{
char buf[256];
size_t n = getLastErrorString(buf, sizeof(buf));
size_t messagelen = message == NULL ? 0 : strlen(message);
if (n > 0) {
jstring s = JNU_NewStringPlatform(env, buf);
if (s != NULL) {
jobject x = NULL;
if (messagelen) {
jstring s2 = NULL;
size_t messageextlen = messagelen + 4;
char *str1 = (char *)malloc((messageextlen) * sizeof(char));
if (str1 == 0) {
JNU_ThrowOutOfMemoryError(env, 0);
return;
}
jio_snprintf(str1, messageextlen, " (%s)", message);
s2 = (*env)->NewStringUTF(env, str1);
free(str1);
if (s2 != NULL) {
jstring s3 = JNU_CallMethodByName(
env, NULL, s, "concat",
"(Ljava/lang/String;)Ljava/lang/String;",
s2).l;
(*env)->DeleteLocalRef(env, s2);
if (s3 != NULL) {
(*env)->DeleteLocalRef(env, s);
s = s3;
}
}
}
x = JNU_NewObjectByName(env, name, "(Ljava/lang/String;)V", s);
if (x != NULL) {
(*env)->Throw(env, x);
}
}
}
if (!(*env)->ExceptionOccurred(env)) {
if (messagelen) {
JNU_ThrowByName(env, name, message);
} else {
JNU_ThrowByName(env, name, "no further information");
}
}
}
/*
* Convenience method.
* Call JNU_ThrowByNameWithLastError for java.io.IOException.
*/
JNIEXPORT void JNICALL
JNU_ThrowIOExceptionWithLastError(JNIEnv *env, const char *defaultDetail)

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
@ -98,15 +98,22 @@ JNIEXPORT void JNICALL
JNU_ThrowInstantiationException(JNIEnv *env, const char *msg);
/* Throw an exception by name, using the string returned by
* JVM_LastErrorString for the detail string. If the last-error
* getLastErrorString for the detail string. If the last-error
* string is NULL, use the given default detail string.
*/
JNIEXPORT void JNICALL
JNU_ThrowByNameWithLastError(JNIEnv *env, const char *name,
const char *defaultMessage);
const char *defaultDetail);
/* Throw an exception by name, using a given message and the string
* returned by getLastErrorString to construct the detail string.
*/
JNIEXPORT void JNICALL
JNU_ThrowByNameWithMessageAndLastError
(JNIEnv *env, const char *name, const char *message);
/* Throw an IOException, using the last-error string for the detail
* string. If the last-error string is NULL, use the given default
* string. If the last-error string is NULL, use the given default
* detail string.
*/
JNIEXPORT void JNICALL

View File

@ -621,8 +621,8 @@ static int getFlags0(JNIEnv *env, jstring name) {
(*env)->ReleaseStringUTFChars(env, name, name_utf);
if (ret < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"ioctl SIOCGLIFFLAGS failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "getFlags() failed");
return -1;
}
@ -1061,8 +1061,8 @@ static int openSocket(JNIEnv *env, int proto) {
// If EPROTONOSUPPORT is returned it means we don't have
// support for this proto so don't throw an exception.
if (errno != EPROTONOSUPPORT) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Socket creation failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Socket creation failed");
}
return -1;
}
@ -1087,13 +1087,13 @@ static int openSocketWithFallback(JNIEnv *env, const char *ifname) {
if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
if (errno == EPROTONOSUPPORT) {
if ((sock = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"IPV6 Socket creation failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "IPV6 Socket creation failed");
return -1;
}
} else { // errno is not NOSUPPORT
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"IPV4 Socket creation failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "IPV4 Socket creation failed");
return -1;
}
}
@ -1122,15 +1122,15 @@ static netif *enumIPv4Interfaces(JNIEnv *env, int sock, netif *ifs) {
// SIOCGIFCOUNT doesn't work
ifc.ifc_buf = NULL;
if (ioctl(sock, SIOCGIFCONF, (char *)&ifc) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"ioctl SIOCGIFCONF failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGIFCONF) failed");
return ifs;
}
#elif defined(_AIX)
ifc.ifc_buf = NULL;
if (ioctl(sock, SIOCGSIZIFCONF, &(ifc.ifc_len)) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"ioctl SIOCGSIZIFCONF failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGSIZIFCONF) failed");
return ifs;
}
#endif /* __linux__ */
@ -1142,8 +1142,8 @@ static netif *enumIPv4Interfaces(JNIEnv *env, int sock, netif *ifs) {
siocgifconfRequest = CSIOCGIFCONF;
#endif
if (ioctl(sock, siocgifconfRequest, (char *)&ifc) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"ioctl SIOCGIFCONF failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGIFCONF) failed");
free(buf);
return ifs;
}
@ -1268,8 +1268,8 @@ static netif *enumIPv6Interfaces(JNIEnv *env, int sock, netif *ifs) {
ifc.ifc_buf = NULL;
if (ioctl(sock, SIOCGSIZIFCONF, &(ifc.ifc_len)) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"ioctl SIOCGSIZIFCONF failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGSIZIFCONF) failed");
return ifs;
}
bufsize = ifc.ifc_len;
@ -1282,8 +1282,8 @@ static netif *enumIPv6Interfaces(JNIEnv *env, int sock, netif *ifs) {
ifc.ifc_len = bufsize;
ifc.ifc_buf = buf;
if (ioctl(sock, SIOCGIFCONF, (char *)&ifc) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"ioctl CSIOCGIFCONF failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGIFCONF) failed");
free(buf);
return ifs;
}
@ -1368,16 +1368,16 @@ static struct sockaddr *getBroadcast
// Let's make sure the interface does have a broadcast address.
if (ioctl(sock, SIOCGIFFLAGS, (char *)&if2) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"ioctl SIOCGIFFLAGS failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGIFFLAGS) failed");
return ret;
}
if (if2.ifr_flags & IFF_BROADCAST) {
// It does, let's retrieve it
if (ioctl(sock, SIOCGIFBRDADDR, (char *)&if2) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"ioctl SIOCGIFBRDADDR failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGIFBRDADDR) failed");
return ret;
}
@ -1400,8 +1400,8 @@ static short getSubnet(JNIEnv *env, int sock, const char *ifname) {
strncpy(if2.ifr_name, ifname, sizeof(if2.ifr_name) - 1);
if (ioctl(sock, SIOCGIFNETMASK, (char *)&if2) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"ioctl SIOCGIFNETMASK failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGIFNETMASK) failed");
return -1;
}
@ -1463,8 +1463,8 @@ static int getMacAddress
memset((char *)&ifr, 0, sizeof(ifr));
strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name) - 1);
if (ioctl(sock, SIOCGIFHWADDR, &ifr) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"ioctl SIOCGIFHWADDR failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGIFHWADDR) failed");
return -1;
}
@ -1493,8 +1493,8 @@ static int getMTU(JNIEnv *env, int sock, const char *ifname) {
}
if (ioctl(sock, SIOCGIFMTU, (char *)&if2) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"ioctl SIOCGIFMTU failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGIFMTU) failed");
return -1;
}
@ -1535,15 +1535,15 @@ static int openSocketWithFallback(JNIEnv *env, const char *ifname) {
if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
if (errno == EPROTONOSUPPORT) {
if ((sock = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"IPV6 Socket creation failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "IPV6 Socket creation failed");
return -1;
}
alreadyV6=1;
} else { // errno is not NOSUPPORT
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"IPV4 Socket creation failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "IPV4 Socket creation failed");
return -1;
}
}
@ -1562,8 +1562,8 @@ static int openSocketWithFallback(JNIEnv *env, const char *ifname) {
if (ioctl(sock, SIOCGLIFNETMASK, (char *)&if2) < 0) {
close(sock);
if ((sock = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"IPV6 Socket creation failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "IPV6 Socket creation failed");
return -1;
}
}
@ -1607,8 +1607,8 @@ static netif *enumIPvXInterfaces(JNIEnv *env, int sock, netif *ifs, int family)
numifs.lifn_family = family;
numifs.lifn_flags = 0;
if (ioctl(sock, SIOCGLIFNUM, (char *)&numifs) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"ioctl SIOCGLIFNUM failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGLIFNUM) failed");
return ifs;
}
@ -1621,8 +1621,8 @@ static netif *enumIPvXInterfaces(JNIEnv *env, int sock, netif *ifs, int family)
ifc.lifc_len = bufsize;
ifc.lifc_buf = buf;
if (ioctl(sock, SIOCGLIFCONF, (char *)&ifc) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"ioctl SIOCGLIFCONF failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGLIFCONF) failed");
free(buf);
return ifs;
}
@ -1689,16 +1689,16 @@ static struct sockaddr *getBroadcast
// Let's make sure the interface does have a broadcast address
if (ioctl(sock, SIOCGLIFFLAGS, (char *)&if2) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"ioctl SIOCGLIFFLAGS failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGLIFFLAGS) failed");
return ret;
}
if (if2.lifr_flags & IFF_BROADCAST) {
// It does, let's retrieve it
if (ioctl(sock, SIOCGLIFBRDADDR, (char *)&if2) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"ioctl SIOCGLIFBRDADDR failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGLIFBRDADDR) failed");
return ret;
}
@ -1721,8 +1721,8 @@ static short getSubnet(JNIEnv *env, int sock, const char *ifname) {
strncpy(if2.lifr_name, ifname, sizeof(if2.lifr_name) - 1);
if (ioctl(sock, SIOCGLIFNETMASK, (char *)&if2) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"ioctl SIOCGLIFNETMASK failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGLIFNETMASK) failed");
return -1;
}
@ -1764,8 +1764,8 @@ static int getMacFromDevice
msg.len = DL_PHYS_ADDR_REQ_SIZE;
if (putmsg(fd, &msg, NULL, 0) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"putmsg failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "putmsg() failed");
return -1;
}
@ -1775,8 +1775,8 @@ static int getMacFromDevice
msg.len = 0;
msg.maxlen = sizeof (buf);
if (getmsg(fd, &msg, NULL, &flags) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"getmsg failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "getmsg() failed");
return -1;
}
@ -1860,8 +1860,8 @@ static int getMTU(JNIEnv *env, int sock, const char *ifname) {
strncpy(if2.lifr_name, ifname, sizeof(if2.lifr_name) - 1);
if (ioctl(sock, SIOCGLIFMTU, (char *)&if2) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"ioctl SIOCGLIFMTU failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGLIFMTU) failed");
return -1;
}
@ -1900,13 +1900,13 @@ static int openSocketWithFallback(JNIEnv *env, const char *ifname) {
if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
if (errno == EPROTONOSUPPORT) {
if ((sock = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"IPV6 Socket creation failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "IPV6 Socket creation failed");
return -1;
}
} else { // errno is not NOSUPPORT
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"IPV4 Socket creation failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "IPV4 Socket creation failed");
return -1;
}
}
@ -1927,8 +1927,8 @@ static netif *enumIPv4Interfaces(JNIEnv *env, int sock, netif *ifs) {
struct ifaddrs *ifa, *origifa;
if (getifaddrs(&origifa) != 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"getifaddrs() function failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "getifaddrs() failed");
return ifs;
}
@ -1997,8 +1997,8 @@ static netif *enumIPv6Interfaces(JNIEnv *env, int sock, netif *ifs) {
struct in6_ifreq ifr6;
if (getifaddrs(&origifa) != 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"getifaddrs() function failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "getifaddrs() failed");
return ifs;
}
@ -2014,8 +2014,8 @@ static netif *enumIPv6Interfaces(JNIEnv *env, int sock, netif *ifs) {
MIN(sizeof(ifr6.ifr_addr), ifa->ifa_addr->sa_len));
if (ioctl(sock, SIOCGIFNETMASK_IN6, (caddr_t)&ifr6) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"ioctl SIOCGIFNETMASK_IN6 failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGIFNETMASK_IN6) failed");
freeifaddrs(origifa);
freeif(ifs);
return NULL;
@ -2075,16 +2075,16 @@ static struct sockaddr *getBroadcast
// Make sure the interface does have a broadcast address
if (ioctl(sock, SIOCGIFFLAGS, (char *)&if2) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"ioctl SIOCGIFFLAGS failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGIFFLAGS) failed");
return ret;
}
if (if2.ifr_flags & IFF_BROADCAST) {
// It does, let's retrieve it
if (ioctl(sock, SIOCGIFBRDADDR, (char *)&if2) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"ioctl SIOCGIFBRDADDR failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGIFBRDADDR) failed");
return ret;
}
@ -2107,8 +2107,8 @@ static short getSubnet(JNIEnv *env, int sock, const char *ifname) {
strncpy(if2.ifr_name, ifname, sizeof(if2.ifr_name) - 1);
if (ioctl(sock, SIOCGIFNETMASK, (char *)&if2) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"ioctl SIOCGIFNETMASK failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGIFNETMASK) failed");
return -1;
}
@ -2156,8 +2156,8 @@ static int getMTU(JNIEnv *env, int sock, const char *ifname) {
strncpy(if2.ifr_name, ifname, sizeof(if2.ifr_name) - 1);
if (ioctl(sock, SIOCGIFMTU, (char *)&if2) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"ioctl SIOCGIFMTU failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "ioctl(SIOCGIFMTU) failed");
return -1;
}

View File

@ -221,8 +221,8 @@ Java_java_net_PlainDatagramSocketImpl_bind0(JNIEnv *env, jobject this,
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "BindException",
"Bind failed");
} else {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Bind failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Bind failed");
}
return;
}
@ -233,8 +233,8 @@ Java_java_net_PlainDatagramSocketImpl_bind0(JNIEnv *env, jobject this,
* that the system chose for us and store it in the Socket object.
*/
if (getsockname(fd, (struct sockaddr *)&him, &slen) == -1) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error getting socket name");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error getting socket name");
return;
}
@ -469,7 +469,7 @@ Java_java_net_PlainDatagramSocketImpl_send(JNIEnv *env, jobject this,
JNU_ThrowByName(env, JNU_JAVANETPKG "PortUnreachableException",
"ICMP Port Unreachable");
} else {
NET_ThrowByNameWithLastError(env, "java/io/IOException", "sendto failed");
JNU_ThrowIOExceptionWithLastError(env, "sendto failed");
}
}
@ -520,7 +520,8 @@ Java_java_net_PlainDatagramSocketImpl_peek(JNIEnv *env, jobject this,
} else if (errno == ENOMEM) {
JNU_ThrowOutOfMemoryError(env, "NET_Timeout native heap allocation failed");
} else {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Peek failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Peek failed");
}
return ret;
}
@ -544,7 +545,8 @@ Java_java_net_PlainDatagramSocketImpl_peek(JNIEnv *env, jobject this,
if (errno == EBADF) {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
} else {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Peek failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Peek failed");
}
}
return 0;
@ -616,7 +618,8 @@ Java_java_net_PlainDatagramSocketImpl_peekData(JNIEnv *env, jobject this,
} else if (errno == EBADF) {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
} else {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Receive failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Receive failed");
#else
} else {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
@ -681,7 +684,8 @@ Java_java_net_PlainDatagramSocketImpl_peekData(JNIEnv *env, jobject this,
if (errno == EBADF) {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
} else {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Receive failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Receive failed");
}
}
} else {
@ -827,7 +831,8 @@ Java_java_net_PlainDatagramSocketImpl_receive0(JNIEnv *env, jobject this,
} else if (errno == EBADF) {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
} else {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Receive failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Receive failed");
#else
} else {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
@ -859,7 +864,8 @@ Java_java_net_PlainDatagramSocketImpl_receive0(JNIEnv *env, jobject this,
if (errno == EBADF) {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
} else {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Receive failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Receive failed");
}
}
} else {
@ -932,8 +938,8 @@ Java_java_net_PlainDatagramSocketImpl_datagramSocketCreate(JNIEnv *env,
}
if ((fd = socket(domain, SOCK_DGRAM, 0)) == -1) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error creating socket");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error creating socket");
return;
}
@ -1080,8 +1086,8 @@ static void mcast_set_if_by_if_v4(JNIEnv *env, jobject this, int fd, jobject val
if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF,
(const char*)&in, sizeof(in)) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error setting socket option");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
}
}
@ -1109,8 +1115,8 @@ static void mcast_set_if_by_if_v6(JNIEnv *env, jobject this, int fd, jobject val
"IPV6_MULTICAST_IF failed (interface has IPv4 "
"address only?)");
} else {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error setting socket option");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
}
return;
}
@ -1129,8 +1135,8 @@ static void mcast_set_if_by_addr_v4(JNIEnv *env, jobject this, int fd, jobject v
if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF,
(const char*)&in, sizeof(in)) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error setting socket option");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
}
}
@ -1256,8 +1262,10 @@ static void mcast_set_loop_v4(JNIEnv *env, jobject this, int fd, jobject value)
on = (*env)->GetBooleanField(env, value, fid);
loopback = (!on ? 1 : 0);
if (NET_SetSockOpt(fd, IPPROTO_IP, IP_MULTICAST_LOOP, (const void *)&loopback, sizeof(char)) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
if (NET_SetSockOpt(fd, IPPROTO_IP, IP_MULTICAST_LOOP,
(const void *)&loopback, sizeof(char)) < 0) {
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
return;
}
}
@ -1280,8 +1288,10 @@ static void mcast_set_loop_v6(JNIEnv *env, jobject this, int fd, jobject value)
on = (*env)->GetBooleanField(env, value, fid);
loopback = (!on ? 1 : 0);
if (NET_SetSockOpt(fd, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, (const void *)&loopback, sizeof(int)) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
if (NET_SetSockOpt(fd, IPPROTO_IPV6, IPV6_MULTICAST_LOOP,
(const void *)&loopback, sizeof(int)) < 0) {
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
return;
}
@ -1420,7 +1430,8 @@ Java_java_net_PlainDatagramSocketImpl_socketSetOption0(JNIEnv *env,
}
if (NET_SetSockOpt(fd, level, optname, (const void *)&optval, optlen) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
return;
}
}
@ -1483,8 +1494,8 @@ jobject getMulticastInterface(JNIEnv *env, jobject this, int fd, jint opt) {
if (getsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF,
(char *)inP, &len) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error getting socket option");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error getting socket option");
return NULL;
}
@ -1581,8 +1592,8 @@ jobject getMulticastInterface(JNIEnv *env, jobject this, int fd, jint opt) {
if (getsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_IF,
(char*)&index, &len) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error getting socket option");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error getting socket option");
return NULL;
}
@ -1726,8 +1737,8 @@ Java_java_net_PlainDatagramSocketImpl_socketGetOption(JNIEnv *env, jobject this,
len = SOCKADDR_LEN;
if (getsockname(fd, (struct sockaddr *)&him, &len) == -1) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error getting socket name");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error getting socket name");
return NULL;
}
iaObj = NET_SockaddrToInetAddress(env, (struct sockaddr *)&him, &port);
@ -1752,8 +1763,8 @@ Java_java_net_PlainDatagramSocketImpl_socketGetOption(JNIEnv *env, jobject this,
}
if (NET_GetSockOpt(fd, level, optname, (void *)&optval, &optlen) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error getting socket option");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error getting socket option");
return NULL;
}
@ -1805,8 +1816,8 @@ static void setTTL(JNIEnv *env, int fd, jint ttl) {
char ittl = (char)ttl;
if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_TTL, (char*)&ittl,
sizeof(ittl)) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error setting socket option");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
}
}
@ -1818,8 +1829,8 @@ static void setHopLimit(JNIEnv *env, int fd, jint ttl) {
int ittl = (int)ttl;
if (setsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS,
(char*)&ittl, sizeof(ittl)) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error setting socket option");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
}
}
#endif
@ -1901,8 +1912,8 @@ Java_java_net_PlainDatagramSocketImpl_getTimeToLive(JNIEnv *env, jobject this) {
if (getsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS,
(char*)&ttl, &len) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error getting socket option");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error getting socket option");
return -1;
}
return (jint)ttl;
@ -1913,8 +1924,8 @@ Java_java_net_PlainDatagramSocketImpl_getTimeToLive(JNIEnv *env, jobject this) {
socklen_t len = sizeof(ttl);
if (getsockopt(fd, IPPROTO_IP, IP_MULTICAST_TTL,
(char*)&ttl, &len) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error getting socket option");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error getting socket option");
return -1;
}
return (jint)ttl;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
@ -476,7 +476,8 @@ Java_java_net_PlainSocketImpl_socketConnect(JNIEnv *env, jobject this,
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
"Socket closed");
} else {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "connect failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "connect failed");
}
return;
}
@ -498,8 +499,8 @@ Java_java_net_PlainSocketImpl_socketConnect(JNIEnv *env, jobject this,
*/
socklen_t slen = SOCKADDR_LEN;
if (getsockname(fd, (struct sockaddr *)&him, &slen) == -1) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error getting socket name");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error getting socket name");
} else {
localport = NET_GetPortFromSockaddr((struct sockaddr *)&him);
(*env)->SetIntField(env, this, psi_localportID, localport);
@ -536,8 +537,9 @@ Java_java_net_PlainSocketImpl_socketBind(JNIEnv *env, jobject this,
}
/* bind */
if (NET_InetAddressToSockaddr(env, iaObj, localport, (struct sockaddr *)&him, &len, JNI_TRUE) != 0) {
return;
if (NET_InetAddressToSockaddr(env, iaObj, localport, (struct sockaddr *)&him,
&len, JNI_TRUE) != 0) {
return;
}
setDefaultScopeID(env, (struct sockaddr *)&him);
@ -547,8 +549,8 @@ Java_java_net_PlainSocketImpl_socketBind(JNIEnv *env, jobject this,
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "BindException",
"Bind failed");
} else {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Bind failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Bind failed");
}
return;
}
@ -563,8 +565,8 @@ Java_java_net_PlainSocketImpl_socketBind(JNIEnv *env, jobject this,
* that the system chose for us and store it in the Socket object.
*/
if (getsockname(fd, (struct sockaddr *)&him, &slen) == -1) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error getting socket name");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error getting socket name");
return;
}
localport = NET_GetPortFromSockaddr((struct sockaddr *)&him);
@ -580,8 +582,8 @@ Java_java_net_PlainSocketImpl_socketBind(JNIEnv *env, jobject this,
* Signature: (I)V
*/
JNIEXPORT void JNICALL
Java_java_net_PlainSocketImpl_socketListen (JNIEnv *env, jobject this,
jint count)
Java_java_net_PlainSocketImpl_socketListen(JNIEnv *env, jobject this,
jint count)
{
/* this FileDescriptor fd field */
jobject fdObj = (*env)->GetObjectField(env, this, psi_fdID);
@ -604,8 +606,8 @@ Java_java_net_PlainSocketImpl_socketListen (JNIEnv *env, jobject this,
count -= 1;
if (listen(fd, count) == -1) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Listen failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Listen failed");
}
}
@ -684,7 +686,8 @@ Java_java_net_PlainSocketImpl_socketAccept(JNIEnv *env, jobject this,
} else if (errno == ENOMEM) {
JNU_ThrowOutOfMemoryError(env, "NET_Timeout native heap allocation failed");
} else {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Accept failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Accept failed");
}
return;
}
@ -727,7 +730,8 @@ Java_java_net_PlainSocketImpl_socketAccept(JNIEnv *env, jobject this,
if (errno == EBADF) {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
} else {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException", "Accept failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Accept failed");
}
}
return;
@ -781,8 +785,8 @@ Java_java_net_PlainSocketImpl_socketAvailable(JNIEnv *env, jobject this) {
if (errno == ECONNRESET) {
JNU_ThrowByName(env, "sun/net/ConnectionResetException", "");
} else {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"ioctl FIONREAD failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "ioctl FIONREAD failed");
}
}
return ret;
@ -936,8 +940,8 @@ Java_java_net_PlainSocketImpl_socketSetOption0(JNIEnv *env, jobject this,
return;
}
#endif /* __solaris__ */
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error setting socket option");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
}
}
@ -981,8 +985,8 @@ Java_java_net_PlainSocketImpl_socketGetOption(JNIEnv *env, jobject this,
len = SOCKADDR_LEN;
if (getsockname(fd, (struct sockaddr *)&him, &len) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error getting socket name");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error getting socket name");
return -1;
}
iaObj = NET_SockaddrToInetAddress(env, (struct sockaddr *)&him, &port);
@ -1014,8 +1018,8 @@ Java_java_net_PlainSocketImpl_socketGetOption(JNIEnv *env, jobject this,
}
if (NET_GetSockOpt(fd, level, optname, (void *)&optval, &optlen) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error getting socket option");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error getting socket option");
return -1;
}
@ -1063,6 +1067,6 @@ Java_java_net_PlainSocketImpl_socketSendUrgentData(JNIEnv *env, jobject this,
}
n = NET_Send(fd, (char *)&d, 1, MSG_OOB);
if (n == -1) {
NET_ThrowByNameWithLastError(env, "java/io/IOException", "Write failed");
JNU_ThrowIOExceptionWithLastError(env, "Write failed");
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
@ -111,8 +111,8 @@ Java_java_net_SocketInputStream_socketRead0(JNIEnv *env, jobject this,
} else if (errno == ENOMEM) {
JNU_ThrowOutOfMemoryError(env, "NET_Timeout native heap allocation failed");
} else {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"select/poll failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "select/poll failed");
}
}
if (bufP != BUF) {
@ -145,8 +145,8 @@ Java_java_net_SocketInputStream_socketRead0(JNIEnv *env, jobject this,
break;
default:
NET_ThrowByNameWithLastError(env,
JNU_JAVANETPKG "SocketException", "Read failed");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Read failed");
}
}
} else {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
@ -114,8 +114,8 @@ Java_java_net_SocketOutputStream_socketWrite0(JNIEnv *env, jobject this,
JNU_ThrowByName(env, "sun/net/ConnectionResetException",
"Connection reset");
} else {
NET_ThrowByNameWithLastError(env, "java/net/SocketException",
"Write failed");
JNU_ThrowByNameWithMessageAndLastError
(env, "java/net/SocketException", "Write failed");
}
if (bufP != BUF) {
free(bufP);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
@ -1713,8 +1713,8 @@ static void setMulticastInterface(JNIEnv *env, jobject this, int fd, int fd1,
in.s_addr = htonl(getInetAddress_addr(env, value));
if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF,
(const char*)&in, sizeof(in)) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error setting socket option");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
}
return;
}
@ -1741,7 +1741,7 @@ static void setMulticastInterface(JNIEnv *env, jobject this, int fd, int fd1,
}
index = (*env)->GetIntField(env, value, ni_indexID);
if ( isAdapterIpv6Enabled(env, index) != 0 ) {
if (isAdapterIpv6Enabled(env, index) != 0) {
if (setsockopt(fd1, IPPROTO_IPV6, IPV6_MULTICAST_IF,
(const char*)&index, sizeof(index)) < 0) {
if (errno == EINVAL && index > 0) {
@ -1749,8 +1749,8 @@ static void setMulticastInterface(JNIEnv *env, jobject this, int fd, int fd1,
"IPV6_MULTICAST_IF failed (interface has IPv4 "
"address only?)");
} else {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error setting socket option");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
}
return;
}
@ -1758,13 +1758,13 @@ static void setMulticastInterface(JNIEnv *env, jobject this, int fd, int fd1,
/* If there are any IPv4 addresses on this interface then
* repeat the operation on the IPv4 fd */
if (getInet4AddrFromIf (env, value, &in) < 0) {
if (getInet4AddrFromIf(env, value, &in) < 0) {
return;
}
if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF,
(const char*)&in, sizeof(in)) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error setting socket option");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
}
return;
} else {
@ -1781,8 +1781,8 @@ static void setMulticastInterface(JNIEnv *env, jobject this, int fd, int fd1,
if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF,
(const char*)&in, sizeof(in)) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error setting socket option");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error setting socket option");
}
return;
}
@ -1932,8 +1932,8 @@ static jobject getIPv4NetworkInterface (JNIEnv *env, jobject this, int fd, jint
int len = sizeof(struct in_addr);
if (getsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF,
(char *)inP, &len) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error getting socket option");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error getting socket option");
return NULL;
}
@ -2056,8 +2056,8 @@ jobject getMulticastInterface(JNIEnv *env, jobject this, int fd, int fd1, jint o
{
if (getsockopt(fd1, IPPROTO_IPV6, IPV6_MULTICAST_IF,
(char*)&index, &len) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error getting socket option");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error getting socket option");
return NULL;
}
}
@ -2288,8 +2288,8 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_socketLocalAddress(JNIEnv *env, j
}
if (getsockname(fd, (struct sockaddr *)&him, &len) == -1) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error getting socket name");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error getting socket name");
return NULL;
}
iaObj = NET_SockaddrToInetAddress(env, (struct sockaddr *)&him, &port);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
@ -1054,8 +1054,8 @@ Java_java_net_TwoStacksPlainSocketImpl_socketGetOption(JNIEnv *env, jobject this
}
if (getsockname(fd, (struct sockaddr *)&him, &len) < 0) {
NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
"Error getting socket name");
JNU_ThrowByNameWithMessageAndLastError
(env, JNU_JAVANETPKG "SocketException", "Error getting socket name");
return -1;
}
iaObj = NET_SockaddrToInetAddress(env, (struct sockaddr *)&him, &port);

View File

@ -32,10 +32,10 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import jdk.tools.jlink.internal.ExecutableImage;
import jdk.tools.jlink.internal.JlinkTask;
import jdk.tools.jlink.plugin.Plugin;
import jdk.tools.jlink.plugin.PluginException;
import jdk.tools.jlink.plugin.ExecutableImage;
import jdk.tools.jlink.builder.ImageBuilder;
import jdk.tools.jlink.internal.PluginRepository;

View File

@ -57,7 +57,7 @@ import java.util.Set;
import jdk.tools.jlink.internal.BasicImageWriter;
import jdk.tools.jlink.internal.plugins.FileCopierPlugin;
import jdk.tools.jlink.internal.plugins.FileCopierPlugin.SymImageFile;
import jdk.tools.jlink.plugin.ExecutableImage;
import jdk.tools.jlink.internal.ExecutableImage;
import jdk.tools.jlink.plugin.ModulePool;
import jdk.tools.jlink.plugin.ModuleEntry;
import jdk.tools.jlink.plugin.PluginException;

View File

@ -27,7 +27,7 @@ package jdk.tools.jlink.builder;
import java.io.DataOutputStream;
import java.util.Properties;
import jdk.tools.jlink.plugin.ExecutableImage;
import jdk.tools.jlink.internal.ExecutableImage;
import jdk.tools.jlink.plugin.PluginException;
import jdk.tools.jlink.plugin.ModulePool;

View File

@ -22,7 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package jdk.tools.jlink.plugin;
package jdk.tools.jlink.internal;
import java.nio.file.Path;
import java.util.List;

View File

@ -43,7 +43,6 @@ import java.util.stream.Stream;
import jdk.tools.jlink.internal.Archive.Entry;
import jdk.tools.jlink.internal.Archive.Entry.EntryType;
import jdk.tools.jlink.internal.ModulePoolImpl.CompressedModuleData;
import jdk.tools.jlink.plugin.ExecutableImage;
import jdk.tools.jlink.plugin.PluginException;
import jdk.tools.jlink.plugin.ModuleEntry;

View File

@ -32,15 +32,12 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import jdk.tools.jlink.plugin.ExecutableImage;
import jdk.tools.jlink.builder.ImageBuilder;
import jdk.tools.jlink.Jlink;
import jdk.tools.jlink.plugin.Plugin;
import jdk.tools.jlink.plugin.PluginException;
import jdk.tools.jlink.plugin.Plugin.Category;
import jdk.tools.jlink.plugin.ModulePool;
import jdk.tools.jlink.plugin.PostProcessorPlugin;
import jdk.tools.jlink.plugin.TransformerPlugin;
/**
* Plugins configuration.
@ -85,7 +82,7 @@ public final class ImagePluginConfiguration {
+ " added more than once to stack ");
}
seen.add(plug.getName());
Category category = Utils.getCategory(plug);
Category category = plug.getType();
if (category == null) {
throw new PluginException("Invalid category for "
+ plug.getName());
@ -94,26 +91,13 @@ public final class ImagePluginConfiguration {
lst.add(plug);
}
List<TransformerPlugin> transformerPlugins = new ArrayList<>();
List<PostProcessorPlugin> postProcessingPlugins = new ArrayList<>();
List<Plugin> orderedPlugins = new ArrayList<>();
plugins.entrySet().stream().forEach((entry) -> {
// Sort according to plugin constraints
List<Plugin> orderedPlugins = PluginOrderingGraph.sort(entry.getValue());
Category category = entry.getKey();
orderedPlugins.stream().forEach((p) -> {
if (category.isPostProcessor()) {
@SuppressWarnings("unchecked")
PostProcessorPlugin pp = (PostProcessorPlugin) p;
postProcessingPlugins.add(pp);
} else {
@SuppressWarnings("unchecked")
TransformerPlugin trans = (TransformerPlugin) p;
transformerPlugins.add(trans);
}
});
orderedPlugins.addAll(PluginOrderingGraph.sort(entry.getValue()));
});
Plugin lastSorter = null;
for (Plugin plugin : transformerPlugins) {
for (Plugin plugin : orderedPlugins) {
if (plugin.getName().equals(pluginsConfiguration.getLastSorterPluginName())) {
lastSorter = plugin;
break;
@ -145,7 +129,6 @@ public final class ImagePluginConfiguration {
};
}
return new ImagePluginStack(builder, transformerPlugins,
lastSorter, postProcessingPlugins);
return new ImagePluginStack(builder, orderedPlugins, lastSorter);
}
}

View File

@ -44,14 +44,11 @@ import java.util.stream.Stream;
import jdk.internal.jimage.decompressor.Decompressor;
import jdk.tools.jlink.plugin.Plugin;
import jdk.tools.jlink.plugin.ExecutableImage;
import jdk.tools.jlink.builder.ImageBuilder;
import jdk.tools.jlink.plugin.TransformerPlugin;
import jdk.tools.jlink.plugin.PluginException;
import jdk.tools.jlink.plugin.ModulePool;
import jdk.tools.jlink.plugin.LinkModule;
import jdk.tools.jlink.plugin.ModuleEntry;
import jdk.tools.jlink.plugin.PostProcessorPlugin;
/**
* Plugins Stack. Plugins entry point to apply transformations onto resources
@ -161,42 +158,34 @@ public final class ImagePluginStack {
private final ImageBuilder imageBuilder;
private final Plugin lastSorter;
private final List<TransformerPlugin> contentPlugins = new ArrayList<>();
private final List<PostProcessorPlugin> postProcessingPlugins = new ArrayList<>();
private final List<Plugin> plugins = new ArrayList<>();
private final List<ResourcePrevisitor> resourcePrevisitors = new ArrayList<>();
public ImagePluginStack() {
this(null, Collections.emptyList(), null,
Collections.emptyList());
this(null, Collections.emptyList(), null);
}
public ImagePluginStack(ImageBuilder imageBuilder,
List<TransformerPlugin> contentPlugins,
Plugin lastSorter,
List<PostProcessorPlugin> postprocessingPlugins) {
List<Plugin> plugins,
Plugin lastSorter) {
this.imageBuilder = Objects.requireNonNull(imageBuilder);
this.lastSorter = lastSorter;
Objects.requireNonNull(contentPlugins);
Objects.requireNonNull(postprocessingPlugins);
contentPlugins.stream().forEach((p) -> {
this.plugins.addAll(Objects.requireNonNull(plugins));
plugins.stream().forEach((p) -> {
Objects.requireNonNull(p);
if (p instanceof ResourcePrevisitor) {
resourcePrevisitors.add((ResourcePrevisitor) p);
}
this.contentPlugins.add(p);
});
postprocessingPlugins.stream().forEach((p) -> {
Objects.requireNonNull(p);
this.postProcessingPlugins.add(p);
});
}
public void operate(ImageProvider provider) throws Exception {
ExecutableImage img = provider.retrieve(this);
List<String> arguments = new ArrayList<>();
postProcessingPlugins.stream()
.map((plugin) -> plugin.process(img))
plugins.stream()
.filter(PostProcessor.class::isInstance)
.map((plugin) -> ((PostProcessor)plugin).process(img))
.filter((lst) -> (lst != null))
.forEach((lst) -> {
arguments.addAll(lst);
@ -241,7 +230,7 @@ public final class ImagePluginStack {
ModulePoolImpl current = resources;
List<ModuleEntry> frozenOrder = null;
for (TransformerPlugin p : contentPlugins) {
for (Plugin p : plugins) {
current.setReadOnly();
ModulePoolImpl output = null;
if (p == lastSorter) {

View File

@ -49,7 +49,6 @@ import static jdk.tools.jlink.internal.TaskHelper.JLINK_BUNDLE;
import jdk.tools.jlink.internal.TaskHelper.Option;
import jdk.tools.jlink.internal.TaskHelper.OptionsHelper;
import jdk.tools.jlink.internal.ImagePluginStack.ImageProvider;
import jdk.tools.jlink.plugin.ExecutableImage;
import jdk.tools.jlink.Jlink.JlinkConfiguration;
import jdk.tools.jlink.Jlink.PluginsConfiguration;
import jdk.tools.jlink.plugin.PluginException;
@ -184,8 +183,8 @@ public class JlinkTask {
optionsHelper.showHelp(PROGNAME);
return EXIT_OK;
}
if (optionsHelper.listPlugins()) {
optionsHelper.listPlugins(true);
if (optionsHelper.shouldListPlugins()) {
optionsHelper.listPlugins();
return EXIT_OK;
}
if (options.version || options.fullVersion) {

View File

@ -34,8 +34,6 @@ import java.util.Objects;
import java.util.ServiceLoader;
import jdk.tools.jlink.plugin.Plugin;
import jdk.tools.jlink.plugin.PluginException;
import jdk.tools.jlink.plugin.PostProcessorPlugin;
import jdk.tools.jlink.plugin.TransformerPlugin;
/**
*
@ -59,17 +57,7 @@ public final class PluginRepository {
*/
public static Plugin getPlugin(String name,
Layer pluginsLayer) {
Plugin tp = getPlugin(TransformerPlugin.class, name, pluginsLayer);
Plugin ppp = getPlugin(PostProcessorPlugin.class, name, pluginsLayer);
// We should not have a transformer plugin and a post processor plugin
// of the same name. That kind of duplicate is detected here.
if (tp != null && ppp != null) {
throw new PluginException("Multiple plugin "
+ "for the name " + name);
}
return tp != null? tp : ppp;
return getPlugin(Plugin.class, name, pluginsLayer);
}
/**
@ -112,10 +100,7 @@ public final class PluginRepository {
}
public static List<Plugin> getPlugins(Layer pluginsLayer) {
List<Plugin> plugins = new ArrayList<>();
plugins.addAll(getPlugins(TransformerPlugin.class, pluginsLayer));
plugins.addAll(getPlugins(PostProcessorPlugin.class, pluginsLayer));
return plugins;
return getPlugins(Plugin.class, pluginsLayer);
}
private static <T extends Plugin> T getPlugin(Class<T> clazz, String name,
@ -138,10 +123,10 @@ public final class PluginRepository {
}
/**
* The post processors accessible in the current context.
* The plugins accessible in the current context.
*
* @param pluginsLayer
* @return The list of post processors.
* @return The list of plugins.
*/
private static <T extends Plugin> List<T> getPlugins(Class<T> clazz, Layer pluginsLayer) {
Objects.requireNonNull(pluginsLayer);

View File

@ -22,15 +22,15 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package jdk.tools.jlink.plugin;
package jdk.tools.jlink.internal;
import java.util.List;
/**
* Implement this interface to develop a PostProcessor plugin.
* PostProcessor plugins are called once the image has been generated and is executable.
* Plugin wishing to post-proces must implement this interface. PostProcessors
* are called once the image has been generated and is executable.
**/
public interface PostProcessorPlugin extends Plugin {
public interface PostProcessor {
/**
* Post process an image.

View File

@ -428,7 +428,7 @@ public final class TaskHelper {
return opt.hasArg;
}
public boolean listPlugins() {
public boolean shouldListPlugins() {
return pluginOptions.listPlugins;
}
@ -570,26 +570,19 @@ public final class TaskHelper {
log.println(bundleHelper.getMessage("main.command.files"));
}
public void listPlugins(boolean showsImageBuilder) {
public void listPlugins() {
log.println("\n" + bundleHelper.getMessage("main.extended.help"));
List<Plugin> pluginList = PluginRepository.
getPlugins(pluginOptions.pluginsLayer);
for (Plugin plugin : Utils.
getSortedPreProcessors(pluginList)) {
showPlugin(plugin, log, showsImageBuilder);
}
if (showsImageBuilder) {
for (Plugin plugin : Utils.getSortedPostProcessors(pluginList)) {
showPlugin(plugin, log, showsImageBuilder);
}
for (Plugin plugin : Utils.getSortedPlugins(pluginList)) {
showPlugin(plugin, log);
}
log.println("\n" + bundleHelper.getMessage("main.extended.help.footer"));
}
private void showPlugin(Plugin plugin, PrintWriter log, boolean showsImageBuilder) {
if (showsPlugin(plugin, showsImageBuilder)) {
private void showPlugin(Plugin plugin, PrintWriter log) {
if (showsPlugin(plugin)) {
log.println("\n" + bundleHelper.getMessage("main.plugin.name")
+ ": " + plugin.getName());
@ -599,7 +592,7 @@ public final class TaskHelper {
+ ": " + plugin.getClass().getName());
log.println(bundleHelper.getMessage("main.plugin.module")
+ ": " + plugin.getClass().getModule().getName());
Category category = Utils.getCategory(plugin);
Category category = plugin.getType();
log.println(bundleHelper.getMessage("main.plugin.category")
+ ": " + category.getName());
log.println(bundleHelper.getMessage("main.plugin.state")
@ -722,14 +715,8 @@ public final class TaskHelper {
}
}
// Display all plugins or pre processors only.
private static boolean showsPlugin(Plugin plugin, boolean showsImageBuilder) {
if (!Utils.isDisabled(plugin) && plugin.getOption() != null) {
if (Utils.isPostProcessor(plugin) && !showsImageBuilder) {
return false;
}
return true;
}
return false;
// Display all plugins
private static boolean showsPlugin(Plugin plugin) {
return (!Utils.isDisabled(plugin) && plugin.getOption() != null);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* 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
@ -55,51 +55,10 @@ public class Utils {
.collect(Collectors.toList());
}
public static boolean isPostProcessor(Plugin provider) {
return provider.getType().isPostProcessor();
}
public static boolean isPreProcessor(Plugin provider) {
return !isPostProcessor(provider);
}
public static Category getCategory(Plugin provider) {
return provider.getType();
}
public static List<Plugin> getPreProcessors(List<Plugin> plugins) {
public static List<Plugin> getSortedPlugins(List<Plugin> plugins) {
List<Plugin> res = new ArrayList<>();
for (Plugin p : plugins) {
if (isPreProcessor(p)) {
res.add(p);
}
}
return res;
}
public static List<Plugin> getPostProcessors(List<Plugin> plugins) {
List<Plugin> res = new ArrayList<>();
for (Plugin p : plugins) {
if (isPostProcessor(p)) {
res.add(p);
}
}
return res;
}
public static List<Plugin> getSortedPostProcessors(List<Plugin> plugins) {
List<Plugin> res = getPostProcessors(plugins);
res.sort(new Comparator<Plugin>() {
@Override
public int compare(Plugin o1, Plugin o2) {
return o1.getName().compareTo(o2.getName());
}
});
return res;
}
public static List<Plugin> getSortedPreProcessors(List<Plugin> plugins) {
List<Plugin> res = getPreProcessors(plugins);
res.addAll(plugins);
res.sort(new Comparator<Plugin>() {
@Override
public int compare(Plugin o1, Plugin o2) {

View File

@ -28,7 +28,7 @@ import java.util.Map;
import jdk.tools.jlink.internal.ModulePoolImpl;
import jdk.tools.jlink.plugin.ModulePool;
import jdk.tools.jlink.plugin.TransformerPlugin;
import jdk.tools.jlink.plugin.Plugin;
import jdk.tools.jlink.internal.ImagePluginStack;
import jdk.tools.jlink.internal.ResourcePrevisitor;
import jdk.tools.jlink.internal.StringTable;
@ -37,7 +37,7 @@ import jdk.tools.jlink.internal.StringTable;
*
* ZIP and String Sharing compression plugin
*/
public final class DefaultCompressPlugin implements TransformerPlugin, ResourcePrevisitor {
public final class DefaultCompressPlugin implements Plugin, ResourcePrevisitor {
public static final String NAME = "compress";
public static final String FILTER = "filter";
public static final String LEVEL_0 = "0";

View File

@ -26,7 +26,7 @@ package jdk.tools.jlink.internal.plugins;
import java.util.Map;
import java.util.function.Predicate;
import jdk.tools.jlink.plugin.TransformerPlugin;
import jdk.tools.jlink.plugin.Plugin;
import jdk.tools.jlink.plugin.ModulePool;
import jdk.tools.jlink.plugin.ModuleEntry;
@ -34,7 +34,7 @@ import jdk.tools.jlink.plugin.ModuleEntry;
*
* Exclude files plugin
*/
public final class ExcludeFilesPlugin implements TransformerPlugin {
public final class ExcludeFilesPlugin implements Plugin {
public static final String NAME = "exclude-files";
private Predicate<String> predicate;

View File

@ -26,7 +26,7 @@ package jdk.tools.jlink.internal.plugins;
import java.util.Map;
import java.util.function.Predicate;
import jdk.tools.jlink.plugin.TransformerPlugin;
import jdk.tools.jlink.plugin.Plugin;
import jdk.tools.jlink.plugin.ModuleEntry;
import jdk.tools.jlink.plugin.ModulePool;
@ -34,7 +34,7 @@ import jdk.tools.jlink.plugin.ModulePool;
*
* Exclude resources plugin
*/
public final class ExcludePlugin implements TransformerPlugin {
public final class ExcludePlugin implements Plugin {
public static final String NAME = "exclude-resources";
private Predicate<String> predicate;

View File

@ -35,7 +35,7 @@ import java.util.Map;
import java.util.TreeSet;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import jdk.tools.jlink.plugin.TransformerPlugin;
import jdk.tools.jlink.plugin.Plugin;
import jdk.tools.jlink.plugin.ModulePool;
import jdk.tools.jlink.plugin.ModuleEntry;
import jdk.tools.jlink.plugin.PluginException;
@ -44,7 +44,7 @@ import jdk.tools.jlink.plugin.PluginException;
*
* Exclude VM plugin
*/
public final class ExcludeVMPlugin implements TransformerPlugin {
public final class ExcludeVMPlugin implements Plugin {
private static final class JvmComparator implements Comparator<Jvm> {

View File

@ -41,14 +41,14 @@ import jdk.tools.jlink.internal.PathModuleEntry;
import jdk.tools.jlink.plugin.PluginException;
import jdk.tools.jlink.plugin.ModuleEntry;
import jdk.tools.jlink.plugin.ModulePool;
import jdk.tools.jlink.plugin.TransformerPlugin;
import jdk.tools.jlink.plugin.Plugin;
import jdk.tools.jlink.internal.Utils;
/**
*
* Copy files to image from various locations.
*/
public class FileCopierPlugin implements TransformerPlugin {
public class FileCopierPlugin implements Plugin {
public static final String NAME = "copy-files";

View File

@ -34,12 +34,12 @@ import java.util.stream.Collectors;
import jdk.tools.jlink.plugin.ModuleEntry;
import jdk.tools.jlink.plugin.PluginException;
import jdk.tools.jlink.plugin.ModulePool;
import jdk.tools.jlink.plugin.TransformerPlugin;
import jdk.tools.jlink.plugin.Plugin;
/**
* Plugin to generate java.lang.invoke classes.
*/
public final class GenerateJLIClassesPlugin implements TransformerPlugin {
public final class GenerateJLIClassesPlugin implements Plugin {
private static final String NAME = "generate-jli-classes";

View File

@ -44,7 +44,7 @@ import jdk.tools.jlink.plugin.LinkModule;
import jdk.tools.jlink.plugin.ModuleEntry;
import jdk.tools.jlink.plugin.PluginException;
import jdk.tools.jlink.plugin.ModulePool;
import jdk.tools.jlink.plugin.TransformerPlugin;
import jdk.tools.jlink.plugin.Plugin;
/**
* Plugin to explicitly specify the locale data included in jdk.localedata
@ -68,7 +68,7 @@ import jdk.tools.jlink.plugin.TransformerPlugin;
* start with at least one white space character, e.g., " ar ar-EG ..."
* ^
*/
public final class IncludeLocalesPlugin implements TransformerPlugin, ResourcePrevisitor {
public final class IncludeLocalesPlugin implements Plugin, ResourcePrevisitor {
public static final String NAME = "include-locales";
private static final String MODULENAME = "jdk.localedata";

View File

@ -37,14 +37,14 @@ import java.util.function.ToIntFunction;
import jdk.tools.jlink.plugin.PluginException;
import jdk.tools.jlink.plugin.ModuleEntry;
import jdk.tools.jlink.plugin.ModulePool;
import jdk.tools.jlink.plugin.TransformerPlugin;
import jdk.tools.jlink.plugin.Plugin;
import jdk.tools.jlink.internal.Utils;
/**
*
* Order Resources plugin
*/
public final class OrderResourcesPlugin implements TransformerPlugin {
public final class OrderResourcesPlugin implements Plugin {
public static final String NAME = "order-resources";
private static final FileSystem JRT_FILE_SYSTEM = Utils.jrtFileSystem();

View File

@ -36,12 +36,12 @@ import jdk.tools.jlink.internal.Utils;
import jdk.tools.jlink.plugin.ModulePool;
import jdk.tools.jlink.plugin.Plugin.Category;
import jdk.tools.jlink.plugin.Plugin.State;
import jdk.tools.jlink.plugin.TransformerPlugin;
import jdk.tools.jlink.plugin.Plugin;
/**
* This plugin adds/deletes information for 'release' file.
*/
public final class ReleaseInfoPlugin implements TransformerPlugin {
public final class ReleaseInfoPlugin implements Plugin {
// option name
public static final String NAME = "release-info";
public static final String KEYS = "keys";

View File

@ -56,7 +56,7 @@ import jdk.internal.jimage.decompressor.CompressIndexes;
import jdk.internal.jimage.decompressor.SignatureParser;
import jdk.internal.jimage.decompressor.StringSharingDecompressor;
import jdk.tools.jlink.internal.ModulePoolImpl;
import jdk.tools.jlink.plugin.TransformerPlugin;
import jdk.tools.jlink.plugin.Plugin;
import jdk.tools.jlink.plugin.PluginException;
import jdk.tools.jlink.plugin.ModuleEntry;
import jdk.tools.jlink.plugin.ModulePool;
@ -68,7 +68,7 @@ import jdk.tools.jlink.internal.StringTable;
* A Plugin that stores the image classes constant pool UTF_8 entries into the
* Image StringsTable.
*/
public class StringSharingPlugin implements TransformerPlugin, ResourcePrevisitor {
public class StringSharingPlugin implements Plugin, ResourcePrevisitor {
public static final String NAME = "compact-cp";

View File

@ -29,13 +29,13 @@ import jdk.internal.org.objectweb.asm.ClassReader;
import jdk.internal.org.objectweb.asm.ClassWriter;
import jdk.tools.jlink.plugin.ModuleEntry;
import jdk.tools.jlink.plugin.ModulePool;
import jdk.tools.jlink.plugin.TransformerPlugin;
import jdk.tools.jlink.plugin.Plugin;
/**
*
* Strip debug attributes plugin
*/
public final class StripDebugPlugin implements TransformerPlugin {
public final class StripDebugPlugin implements Plugin {
public static final String NAME = "strip-debug";
private final Predicate<String> predicate;

View File

@ -26,13 +26,13 @@ package jdk.tools.jlink.internal.plugins;
import jdk.tools.jlink.plugin.ModuleEntry;
import jdk.tools.jlink.plugin.ModulePool;
import jdk.tools.jlink.plugin.TransformerPlugin;
import jdk.tools.jlink.plugin.Plugin;
/**
*
* Strip Native Commands plugin
*/
public final class StripNativeCommandsPlugin implements TransformerPlugin {
public final class StripNativeCommandsPlugin implements Plugin {
public static final String NAME = "strip-native-commands";

View File

@ -52,7 +52,7 @@ import jdk.internal.org.objectweb.asm.Opcodes;
import static jdk.internal.org.objectweb.asm.Opcodes.*;
import jdk.tools.jlink.plugin.PluginException;
import jdk.tools.jlink.plugin.ModulePool;
import jdk.tools.jlink.plugin.TransformerPlugin;
import jdk.tools.jlink.plugin.Plugin;
import jdk.tools.jlink.internal.plugins.SystemModuleDescriptorPlugin.Builder.*;
import jdk.tools.jlink.plugin.ModuleEntry;
@ -67,7 +67,7 @@ import jdk.tools.jlink.plugin.ModuleEntry;
* @see java.lang.module.SystemModuleFinder
* @see SystemModules
*/
public final class SystemModuleDescriptorPlugin implements TransformerPlugin {
public final class SystemModuleDescriptorPlugin implements Plugin {
private static final JavaLangModuleAccess JLMA = SharedSecrets.getJavaLangModuleAccess();
// TODO: packager has the dependency on the plugin name

View File

@ -34,13 +34,13 @@ import java.util.zip.Deflater;
import jdk.tools.jlink.internal.ModulePoolImpl;
import jdk.tools.jlink.plugin.ModuleEntry;
import jdk.tools.jlink.plugin.ModulePool;
import jdk.tools.jlink.plugin.TransformerPlugin;
import jdk.tools.jlink.plugin.Plugin;
/**
*
* ZIP Compression plugin
*/
public final class ZipPlugin implements TransformerPlugin {
public final class ZipPlugin implements Plugin {
public static final String NAME = "zip";
private Predicate<String> predicate;

View File

@ -25,7 +25,7 @@
package jdk.tools.jlink.internal.plugins.asm;
import java.util.Objects;
import jdk.tools.jlink.plugin.TransformerPlugin;
import jdk.tools.jlink.plugin.Plugin;
import jdk.tools.jlink.plugin.ModuleEntry;
import jdk.tools.jlink.plugin.ModulePool;
import jdk.tools.jlink.internal.ModulePoolImpl;
@ -35,7 +35,7 @@ import jdk.tools.jlink.internal.ModulePoolImpl;
* resources.
*
*/
public abstract class AsmPlugin implements TransformerPlugin {
public abstract class AsmPlugin implements Plugin {
public AsmPlugin() {
}

View File

@ -57,29 +57,19 @@ public interface Plugin {
SORTER("SORTER"),
COMPRESSOR("COMPRESSOR"),
METAINFO_ADDER("METAINFO_ADDER"),
VERIFIER("VERIFIER", true),
PROCESSOR("PROCESSOR", true),
PACKAGER("PACKAGER", true);
VERIFIER("VERIFIER"),
PROCESSOR("PROCESSOR"),
PACKAGER("PACKAGER");
private final String name;
private final boolean postProcessor;
Category(String name, boolean postProcessor) {
this.name = name;
this.postProcessor = postProcessor;
}
Category(String name) {
this(name, false);
this.name = name;
}
public String getName() {
return name;
}
public boolean isPostProcessor() {
return postProcessor;
}
}
/**
@ -209,4 +199,15 @@ public interface Plugin {
*/
public default void configure(Map<String, String> config) {
}
/**
* Visit the content of the modules that are composing the image.
*
* @param in Read only content.
* @param out The pool to fill with content. This pool must contain
* the result of the visit.
*
* @throws PluginException
*/
public void visit(ModulePool in, ModulePool out);
}

View File

@ -1,44 +0,0 @@
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package jdk.tools.jlink.plugin;
/**
* Implement this interface to develop a Transformer plugin.
* TransformerPlugin are called during image creation. This kind of plugin aims to
* modify the content of the runtime image.
*/
public interface TransformerPlugin extends Plugin {
/**
* Visit the content of the modules that are composing the image.
*
* @param in Read only content.
* @param out The pool to fill with content. This pool must contain
* the result of the visit.
*
* @throws PluginException
*/
public void visit(ModulePool in, ModulePool out);
}

View File

@ -29,20 +29,19 @@ module jdk.jlink {
requires jdk.internal.opt;
requires jdk.jdeps;
uses jdk.tools.jlink.plugin.TransformerPlugin;
uses jdk.tools.jlink.plugin.PostProcessorPlugin;
uses jdk.tools.jlink.plugin.Plugin;
provides jdk.tools.jlink.plugin.TransformerPlugin with jdk.tools.jlink.internal.plugins.FileCopierPlugin;
provides jdk.tools.jlink.plugin.TransformerPlugin with jdk.tools.jlink.internal.plugins.StripDebugPlugin;
provides jdk.tools.jlink.plugin.TransformerPlugin with jdk.tools.jlink.internal.plugins.ExcludePlugin;
provides jdk.tools.jlink.plugin.TransformerPlugin with jdk.tools.jlink.internal.plugins.ExcludeFilesPlugin;
provides jdk.tools.jlink.plugin.TransformerPlugin with jdk.tools.jlink.internal.plugins.SystemModuleDescriptorPlugin;
provides jdk.tools.jlink.plugin.TransformerPlugin with jdk.tools.jlink.internal.plugins.StripNativeCommandsPlugin;
provides jdk.tools.jlink.plugin.TransformerPlugin with jdk.tools.jlink.internal.plugins.OrderResourcesPlugin;
provides jdk.tools.jlink.plugin.TransformerPlugin with jdk.tools.jlink.internal.plugins.DefaultCompressPlugin;
provides jdk.tools.jlink.plugin.TransformerPlugin with jdk.tools.jlink.internal.plugins.OptimizationPlugin;
provides jdk.tools.jlink.plugin.TransformerPlugin with jdk.tools.jlink.internal.plugins.ExcludeVMPlugin;
provides jdk.tools.jlink.plugin.TransformerPlugin with jdk.tools.jlink.internal.plugins.IncludeLocalesPlugin;
provides jdk.tools.jlink.plugin.TransformerPlugin with jdk.tools.jlink.internal.plugins.GenerateJLIClassesPlugin;
provides jdk.tools.jlink.plugin.TransformerPlugin with jdk.tools.jlink.internal.plugins.ReleaseInfoPlugin;
provides jdk.tools.jlink.plugin.Plugin with jdk.tools.jlink.internal.plugins.FileCopierPlugin;
provides jdk.tools.jlink.plugin.Plugin with jdk.tools.jlink.internal.plugins.StripDebugPlugin;
provides jdk.tools.jlink.plugin.Plugin with jdk.tools.jlink.internal.plugins.ExcludePlugin;
provides jdk.tools.jlink.plugin.Plugin with jdk.tools.jlink.internal.plugins.ExcludeFilesPlugin;
provides jdk.tools.jlink.plugin.Plugin with jdk.tools.jlink.internal.plugins.SystemModuleDescriptorPlugin;
provides jdk.tools.jlink.plugin.Plugin with jdk.tools.jlink.internal.plugins.StripNativeCommandsPlugin;
provides jdk.tools.jlink.plugin.Plugin with jdk.tools.jlink.internal.plugins.OrderResourcesPlugin;
provides jdk.tools.jlink.plugin.Plugin with jdk.tools.jlink.internal.plugins.DefaultCompressPlugin;
provides jdk.tools.jlink.plugin.Plugin with jdk.tools.jlink.internal.plugins.OptimizationPlugin;
provides jdk.tools.jlink.plugin.Plugin with jdk.tools.jlink.internal.plugins.ExcludeVMPlugin;
provides jdk.tools.jlink.plugin.Plugin with jdk.tools.jlink.internal.plugins.IncludeLocalesPlugin;
provides jdk.tools.jlink.plugin.Plugin with jdk.tools.jlink.internal.plugins.GenerateJLIClassesPlugin;
provides jdk.tools.jlink.plugin.Plugin with jdk.tools.jlink.internal.plugins.ReleaseInfoPlugin;
}

View File

@ -510,25 +510,27 @@ public class SSLSocketWithStapling {
sslc.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
SSLServerSocketFactory sslssf = sslc.getServerSocketFactory();
SSLServerSocket sslServerSocket =
(SSLServerSocket) sslssf.createServerSocket(serverPort);
serverPort = sslServerSocket.getLocalPort();
try (SSLServerSocket sslServerSocket =
(SSLServerSocket) sslssf.createServerSocket(serverPort)) {
/*
* Signal Client, we're ready for his connect.
*/
serverReady = true;
serverPort = sslServerSocket.getLocalPort();
try (SSLSocket sslSocket = (SSLSocket) sslServerSocket.accept();
InputStream sslIS = sslSocket.getInputStream();
OutputStream sslOS = sslSocket.getOutputStream()) {
int numberIn = sslIS.read();
int numberSent = 85;
log("Server received number: " + numberIn);
sslOS.write(numberSent);
sslOS.flush();
log("Server sent number: " + numberSent);
/*
* Signal Client, we're ready for his connect.
*/
serverReady = true;
try (SSLSocket sslSocket = (SSLSocket) sslServerSocket.accept();
InputStream sslIS = sslSocket.getInputStream();
OutputStream sslOS = sslSocket.getOutputStream()) {
int numberIn = sslIS.read();
int numberSent = 85;
log("Server received number: " + numberIn);
sslOS.write(numberSent);
sslOS.flush();
log("Server sent number: " + numberSent);
}
}
}

View File

@ -25,6 +25,7 @@
# @summary (almost) all keytool behaviors
# @author Weijun Wang
# @run shell/timeout=600 standard.sh
# @key intermittent
#
# This test is always excecuted.
#

View File

@ -33,7 +33,6 @@ import jdk.tools.jlink.internal.PluginRepository;
import jdk.tools.jlink.plugin.Plugin;
import jdk.tools.jlink.plugin.PluginException;
import jdk.tools.jlink.plugin.ModulePool;
import jdk.tools.jlink.plugin.TransformerPlugin;
import tests.Helper;
/*
@ -60,7 +59,7 @@ public class DefaultProviderTest {
expectedOptions.put("option2", "value2");
}
private static class Custom implements TransformerPlugin {
private static class Custom implements Plugin {
private boolean enabled = true;
@Override

View File

@ -37,7 +37,7 @@ import java.util.stream.Stream;
import jdk.tools.jlink.internal.Archive;
import jdk.tools.jlink.internal.ImageFileCreator;
import jdk.tools.jlink.internal.ImagePluginStack;
import jdk.tools.jlink.plugin.ExecutableImage;
import jdk.tools.jlink.internal.ExecutableImage;
import jdk.tools.jlink.builder.ImageBuilder;
import jdk.tools.jlink.plugin.ModulePool;
@ -220,7 +220,7 @@ public class ImageFileCreatorTest {
};
ImagePluginStack stack = new ImagePluginStack(noopBuilder, Collections.emptyList(),
null, Collections.emptyList());
null);
ImageFileCreator.create(archives, ByteOrder.nativeOrder(), stack);
}

View File

@ -34,17 +34,17 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Function;
import jdk.tools.jlink.Jlink;
import jdk.tools.jlink.Jlink.JlinkConfiguration;
import jdk.tools.jlink.Jlink.PluginsConfiguration;
import jdk.tools.jlink.builder.DefaultImageBuilder;
import jdk.tools.jlink.plugin.ExecutableImage;
import jdk.tools.jlink.plugin.ModulePool;
import jdk.tools.jlink.plugin.PostProcessorPlugin;
import jdk.tools.jlink.plugin.TransformerPlugin;
import jdk.tools.jlink.plugin.Plugin;
import jdk.tools.jlink.internal.ExecutableImage;
import jdk.tools.jlink.internal.PostProcessor;
import jdk.tools.jlink.internal.plugins.DefaultCompressPlugin;
import jdk.tools.jlink.internal.plugins.StripDebugPlugin;
import jdk.tools.jlink.plugin.Plugin;
import tests.Helper;
import tests.JImageGenerator;
@ -70,7 +70,7 @@ public class IntegrationTest {
private static final List<Integer> ordered = new ArrayList<>();
public static class MyPostProcessor implements PostProcessorPlugin {
public static class MyPostProcessor implements PostProcessor, Plugin {
public static final String NAME = "mypostprocessor";
@ -98,9 +98,14 @@ public class IntegrationTest {
public void configure(Map<String, String> config) {
throw new UnsupportedOperationException("Shouldn't be called");
}
@Override
public void visit(ModulePool in, ModulePool out) {
in.transformAndCopy(Function.identity(), out);
}
}
public static class MyPlugin1 implements TransformerPlugin {
public static class MyPlugin1 implements Plugin {
Integer index;
Set<String> after;

View File

@ -26,7 +26,7 @@ import java.util.Map;
import java.util.Set;
import jdk.tools.jlink.plugin.ModulePool;
import jdk.tools.jlink.internal.PluginRepository;
import jdk.tools.jlink.plugin.TransformerPlugin;
import jdk.tools.jlink.plugin.Plugin;
import tests.Helper;
@ -46,7 +46,7 @@ import tests.Helper;
*/
public class JLinkOptionsTest {
private static class TestPlugin implements TransformerPlugin {
private static class TestPlugin implements Plugin {
private final String name;
private final String option;

View File

@ -28,10 +28,13 @@ import java.nio.file.Path;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import jdk.tools.jlink.plugin.Plugin;
import jdk.tools.jlink.plugin.ModulePool;
import jdk.tools.jlink.internal.PluginRepository;
import jdk.tools.jlink.plugin.ExecutableImage;
import jdk.tools.jlink.plugin.PostProcessorPlugin;
import jdk.tools.jlink.internal.PostProcessor;
import jdk.tools.jlink.internal.ExecutableImage;
import tests.Helper;
/*
@ -50,7 +53,7 @@ import tests.Helper;
*/
public class JLinkPostProcessingTest {
private static class PPPlugin implements PostProcessorPlugin {
private static class PPPlugin implements PostProcessor, Plugin {
private static ExecutableImage called;
private static final String NAME = "pp";
@ -67,6 +70,11 @@ public class JLinkPostProcessingTest {
return null;
}
@Override
public void visit(ModulePool in, ModulePool out) {
in.transformAndCopy(Function.identity(), out);
}
@Override
public String getName() {
return NAME;

View File

@ -35,7 +35,6 @@ import java.util.List;
import java.util.stream.Stream;
import jdk.tools.jlink.plugin.Plugin;
import jdk.tools.jlink.plugin.TransformerPlugin;
import jdk.tools.jlink.internal.PluginRepository;
import tests.Helper;
import tests.JImageGenerator;
@ -60,7 +59,7 @@ public class JLinkTest {
private static int getNumJlinkPlugins() {
ModuleDescriptor desc = Plugin.class.getModule().getDescriptor();
return desc.provides().
get(TransformerPlugin.class.getName()).
get(Plugin.class.getName()).
providers().size();
}

View File

@ -23,6 +23,6 @@
module customplugin {
requires jdk.jlink;
provides jdk.tools.jlink.plugin.TransformerPlugin with plugin.HelloPlugin;
provides jdk.tools.jlink.plugin.TransformerPlugin with plugin.CustomPlugin;
provides jdk.tools.jlink.plugin.Plugin with plugin.HelloPlugin;
provides jdk.tools.jlink.plugin.Plugin with plugin.CustomPlugin;
}

View File

@ -27,9 +27,9 @@ import java.util.Map;
import java.util.function.Function;
import jdk.tools.jlink.plugin.ModuleEntry;
import jdk.tools.jlink.plugin.ModulePool;
import jdk.tools.jlink.plugin.TransformerPlugin;
import jdk.tools.jlink.plugin.Plugin;
public class CustomPlugin implements TransformerPlugin {
public class CustomPlugin implements Plugin {
private final static String NAME = "custom-plugin";

View File

@ -29,12 +29,12 @@ import java.util.Collections;
import java.util.Map;
import jdk.tools.jlink.plugin.ModuleEntry;
import jdk.tools.jlink.plugin.ModulePool;
import jdk.tools.jlink.plugin.TransformerPlugin;
import jdk.tools.jlink.plugin.Plugin;
/**
* Custom plugin
*/
public final class HelloPlugin implements TransformerPlugin {
public final class HelloPlugin implements Plugin {
private static final String OUTPUT_FILE = "customplugin.txt";
public static final String NAME = "hello";

View File

@ -61,7 +61,6 @@ import jdk.tools.jlink.internal.plugins.ZipPlugin;
import jdk.tools.jlink.plugin.Plugin;
import jdk.tools.jlink.plugin.ModuleEntry;
import jdk.tools.jlink.plugin.ModulePool;
import jdk.tools.jlink.plugin.TransformerPlugin;
public class CompressorPluginTest {
@ -279,9 +278,8 @@ public class CompressorPluginTest {
ModulePoolImpl inputResources,
ModuleEntry res,
List<Pattern> includesPatterns) {
TransformerPlugin compressor = (TransformerPlugin) plugin;
ModulePool compressedModulePool = new ModulePoolImpl(ByteOrder.nativeOrder(), inputResources.getStringTable());
compressor.visit(inputResources, compressedModulePool);
plugin.visit(inputResources, compressedModulePool);
String path = res.getPath();
ModuleEntry compressed = compressedModulePool.findEntry(path).get();
CompressedResourceHeader header

View File

@ -40,7 +40,6 @@ import jdk.tools.jlink.internal.ModulePoolImpl;
import jdk.tools.jlink.internal.plugins.ExcludeFilesPlugin;
import jdk.tools.jlink.plugin.ModuleEntry;
import jdk.tools.jlink.plugin.ModulePool;
import jdk.tools.jlink.plugin.TransformerPlugin;
public class ExcludeFilesPluginTest {
public static void main(String[] args) throws Exception {

View File

@ -38,7 +38,6 @@ import jdk.tools.jlink.internal.plugins.ExcludeVMPlugin;
import jdk.tools.jlink.plugin.Plugin;
import jdk.tools.jlink.plugin.ModulePool;
import jdk.tools.jlink.plugin.ModuleEntry;
import jdk.tools.jlink.plugin.TransformerPlugin;
public class ExcludeVMPluginTest {
@ -173,7 +172,7 @@ public class ExcludeVMPluginTest {
}
ModulePool out = new ModulePoolImpl();
TransformerPlugin p = new ExcludeVMPlugin();
Plugin p = new ExcludeVMPlugin();
Map<String, String> config = new HashMap<>();
if (vm != null) {
config.put(ExcludeVMPlugin.NAME, vm);

View File

@ -45,7 +45,6 @@ import jdk.tools.jlink.Jlink.PluginsConfiguration;
import jdk.tools.jlink.plugin.Plugin;
import jdk.tools.jlink.plugin.ModuleEntry;
import jdk.tools.jlink.plugin.ModulePool;
import jdk.tools.jlink.plugin.TransformerPlugin;
public class LastSorterTest {
@ -167,7 +166,7 @@ public class LastSorterTest {
}
}
public static class SorterPlugin implements TransformerPlugin {
public static class SorterPlugin implements Plugin {
private final String name;
private String starts;

View File

@ -42,7 +42,7 @@ import jdk.tools.jlink.internal.ModulePoolImpl;
import jdk.tools.jlink.internal.plugins.OrderResourcesPlugin;
import jdk.tools.jlink.plugin.ModuleEntry;
import jdk.tools.jlink.plugin.ModulePool;
import jdk.tools.jlink.plugin.TransformerPlugin;
import jdk.tools.jlink.plugin.Plugin;
public class OrderResourcesPluginTest {
@ -93,7 +93,7 @@ public class OrderResourcesPluginTest {
ModulePool out = new ModulePoolImpl();
Map<String, String> config = new HashMap<>();
config.put(OrderResourcesPlugin.NAME, "/zazou/**,**/module-info.class");
TransformerPlugin p = new OrderResourcesPlugin();
Plugin p = new OrderResourcesPlugin();
p.configure(config);
p.visit(resources, out);
check(out.entries().collect(Collectors.toList()), sorted);
@ -116,7 +116,7 @@ public class OrderResourcesPluginTest {
ModulePool out = new ModulePoolImpl();
Map<String, String> config = new HashMap<>();
config.put(OrderResourcesPlugin.NAME, "@" + order.getAbsolutePath());
TransformerPlugin p = new OrderResourcesPlugin();
Plugin p = new OrderResourcesPlugin();
p.configure(config);
p.visit(resources, out);
check(out.entries().collect(Collectors.toList()), sorted2);

View File

@ -46,7 +46,6 @@ import jdk.tools.jlink.internal.PluginOrderingGraph;
import jdk.tools.jlink.plugin.Plugin;
import jdk.tools.jlink.plugin.Plugin.Category;
import jdk.tools.jlink.plugin.ModulePool;
import jdk.tools.jlink.plugin.TransformerPlugin;
public class PluginOrderTest {
@ -225,7 +224,7 @@ public class PluginOrderTest {
PluginOrderingGraph.sort(plugins);
}
private static class Plug implements TransformerPlugin {
private static class Plug implements Plugin {
private final Set<String> isBefore;
private final Set<String> isAfter;

View File

@ -44,7 +44,6 @@ import jdk.tools.jlink.Jlink.PluginsConfiguration;
import jdk.tools.jlink.plugin.Plugin;
import jdk.tools.jlink.plugin.ModuleEntry;
import jdk.tools.jlink.plugin.ModulePool;
import jdk.tools.jlink.plugin.TransformerPlugin;
public class PluginsNegativeTest {
@ -117,7 +116,7 @@ public class PluginsNegativeTest {
}
}
public static class CustomPlugin implements TransformerPlugin {
public static class CustomPlugin implements Plugin {
private final String name;

View File

@ -49,7 +49,6 @@ import jdk.tools.jlink.Jlink;
import jdk.tools.jlink.plugin.Plugin;
import jdk.tools.jlink.plugin.ModuleEntry;
import jdk.tools.jlink.plugin.ModulePool;
import jdk.tools.jlink.plugin.TransformerPlugin;
public class PrevisitorTest {
@ -107,7 +106,7 @@ public class PrevisitorTest {
}
}
private static class CustomPlugin implements TransformerPlugin, ResourcePrevisitor {
private static class CustomPlugin implements Plugin, ResourcePrevisitor {
private static String NAME = "plugin";

View File

@ -57,7 +57,7 @@ import jdk.tools.jlink.internal.StringTable;
import jdk.tools.jlink.internal.plugins.StringSharingPlugin;
import jdk.tools.jlink.plugin.ModuleEntry;
import jdk.tools.jlink.plugin.ModulePool;
import jdk.tools.jlink.plugin.TransformerPlugin;
import jdk.tools.jlink.plugin.Plugin;
import tests.Helper;
import tests.JImageValidator;
@ -119,7 +119,7 @@ public class StringSharingPluginTest {
try (java.util.stream.Stream<Path> stream = Files.walk(compiledClasses)) {
stream.forEach(c);
}
TransformerPlugin plugin = new StringSharingPlugin();
Plugin plugin = new StringSharingPlugin();
ModulePoolImpl result = new ModulePoolImpl(resources.getByteOrder(), resources.getStringTable());
plugin.visit(resources, result);

View File

@ -58,7 +58,7 @@ import jdk.tools.jlink.internal.ModulePoolImpl;
import jdk.tools.jlink.internal.plugins.StripDebugPlugin;
import jdk.tools.jlink.plugin.ModuleEntry;
import jdk.tools.jlink.plugin.ModulePool;
import jdk.tools.jlink.plugin.TransformerPlugin;
import jdk.tools.jlink.plugin.Plugin;
import tests.Helper;
public class StripDebugPluginTest {
@ -124,7 +124,7 @@ public class StripDebugPluginTest {
checkDebugAttributes(result1.getBytes());
}
private ModuleEntry stripDebug(TransformerPlugin debug, ModuleEntry classResource,
private ModuleEntry stripDebug(Plugin debug, ModuleEntry classResource,
String path, String infoPath, byte[] moduleInfo) throws Exception {
ModulePool resources = new ModulePoolImpl();
resources.add(classResource);