This commit is contained in:
Alejandro Murillo 2015-09-09 08:33:14 -07:00
commit 6a3d511525
22 changed files with 540 additions and 299 deletions

View File

@ -38,7 +38,9 @@ include SetupJavaCompilers.gmk
$(eval $(call SetupJavaCompilation,BUILD_TOOLS_JDK, \
SETUP := GENERATE_OLDBYTECODE, \
ADD_JAVAC_FLAGS := "-Xbootclasspath/p:$(BUILDTOOLS_OUTPUTDIR)/interim_jimage_classes$(PATH_SEP)$(BUILDTOOLS_OUTPUTDIR)/interim_cldrconverter_classes", \
ADD_JAVAC_FLAGS := -Xbootclasspath/p:$(call PathList, \
$(BUILDTOOLS_OUTPUTDIR)/interim_jimage_classes \
$(BUILDTOOLS_OUTPUTDIR)/interim_cldrconverter_classes), \
SRC := $(JDK_TOPDIR)/make/src/classes $(BUILDTOOLS_OUTPUTDIR)/interim_cldrconverter_classes, \
BIN := $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes, \
COPY := boot.modules ext.modules))
@ -126,11 +128,11 @@ TOOL_CLDRCONVERTER = $(JAVA_SMALL) -cp $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes
build.tools.cldrconverter.CLDRConverter
TOOL_GENMODULESXML = $(JAVA_SMALL) -Xbootclasspath/p:$(INTERIM_LANGTOOLS_JAR) \
-cp "$(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes$(PATH_SEP)$(JDK_OUTPUTDIR)" \
-cp $(call PathList, $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes $(JDK_OUTPUTDIR)) \
build.tools.module.GenJdepsModulesXml
TOOL_IMAGEBUILDER = $(JAVA_SMALL) -Xbootclasspath/p:$(BUILDTOOLS_OUTPUTDIR)/interim_jimage_classes \
-cp "$(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes$(PATH_SEP)$(JDK_OUTPUTDIR)" \
-cp $(call PathList, $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes $(JDK_OUTPUTDIR)) \
build.tools.module.ImageBuilder
##########################################################################################

View File

@ -77,9 +77,9 @@ $(BEANINFO_OUTPUTDIR)/_the.generated_beaninfo: $(BEANS_SRC) \
$(ECHO) Generating beaninfo
$(MKDIR) -p $(BEANINFO_OUTPUTDIR)/javax/swing
$(JAVA) -Djava.awt.headless=true $(NEW_JAVADOC) \
-sourcepath "$(subst $(SPACE),$(PATH_SEP),\
-sourcepath $(call PathList,\
$(wildcard $(JDK_TOPDIR)/src/*/*/classes) \
$(SUPPORT_OUTPUTDIR)/gensrc/java.base)" \
$(SUPPORT_OUTPUTDIR)/gensrc/java.base) \
-doclet build.tools.swingbeaninfo.GenDocletBeanInfo \
-x $(SWINGBEAN_DEBUG_FLAG) -d $(BEANINFO_OUTPUTDIR)/javax/swing \
-t $(DOCLET_DATA_DIR)/SwingBeanInfo.template \

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 1997, 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
@ -28,8 +28,7 @@
SUNWprivate_1.1 {
global:
JNI_OnLoad;
Java_java_net_AbstractPlainDatagramSocketImpl_init;
Java_java_net_AbstractPlainDatagramSocketImpl_dataAvailable;
Java_java_net_PlainDatagramSocketImpl_dataAvailable;
Java_java_net_PlainSocketImpl_socketListen;
Java_java_net_PlainDatagramSocketImpl_getTTL;
Java_java_net_PlainDatagramSocketImpl_init;

View File

@ -31,8 +31,9 @@ include RMICompilation.gmk
##########################################################################################
BTRMIC_CP := $(INTERIM_CORBA_JAR)$(PATH_SEP)$(BUILDTOOLS_OUTPUTDIR)/interim_rmic_classes$(PATH_SEP)$(INTERIM_LANGTOOLS_JAR)
BTRMIC_ARGS := "-Xbootclasspath/p:$(BTRMIC_CP)" -cp "$(BTRMIC_CP)"
BTRMIC_CP := $(call PathList, $(INTERIM_CORBA_JAR) \
$(BUILDTOOLS_OUTPUTDIR)/interim_rmic_classes $(INTERIM_LANGTOOLS_JAR))
BTRMIC_ARGS := -Xbootclasspath/p:$(BTRMIC_CP) -cp $(BTRMIC_CP)
RMIC := $(JAVA) $(BTRMIC_ARGS) sun.rmi.rmic.Main
CLASSES_DIR := $(JDK_OUTPUTDIR)/modules

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 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
@ -68,7 +68,6 @@ abstract class AbstractPlainDatagramSocketImpl extends DatagramSocketImpl
return null;
}
});
init();
}
/**
@ -364,6 +363,5 @@ abstract class AbstractPlainDatagramSocketImpl extends DatagramSocketImpl
return connectDisabled;
}
native int dataAvailable();
private static native void init();
abstract int dataAvailable();
}

View File

@ -233,8 +233,7 @@ public class DistributionPointFetcher {
}
CertStore ucs = null;
try {
ucs = URICertStore.getInstance
(new URICertStore.URICertStoreParameters(uri));
ucs = URICertStore.getInstance(new URICertStoreParameters(uri));
} catch (InvalidAlgorithmParameterException |
NoSuchAlgorithmException e) {
if (debug != null) {

View File

@ -44,9 +44,7 @@ import java.security.cert.CRLException;
import java.security.cert.CRLSelector;
import java.security.cert.URICertStoreParameters;
import java.security.cert.X509Certificate;
import java.security.cert.X509CertSelector;
import java.security.cert.X509CRL;
import java.security.cert.X509CRLSelector;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@ -160,12 +158,11 @@ class URICertStore extends CertStoreSpi {
throw new InvalidAlgorithmParameterException
("params must be instanceof URICertStoreParameters");
}
this.uri = ((URICertStoreParameters) params).uri;
this.uri = ((URICertStoreParameters) params).getURI();
// if ldap URI, use an LDAPCertStore to fetch certs and CRLs
if (uri.getScheme().toLowerCase(Locale.ENGLISH).equals("ldap")) {
ldap = true;
URICertStoreParameters lparams = new URICertStoreParameters(uri);
ldapCertStore = CertStore.getInstance("LDAP", lparams);
ldapCertStore = CertStore.getInstance("LDAP", params);
}
try {
factory = CertificateFactory.getInstance("X.509");
@ -183,7 +180,7 @@ class URICertStore extends CertStoreSpi {
static synchronized CertStore getInstance(URICertStoreParameters params)
throws NoSuchAlgorithmException, InvalidAlgorithmParameterException {
if (debug != null) {
debug.println("CertStore URI:" + params.uri);
debug.println("CertStore URI:" + params.getURI());
}
CertStore ucs = certStoreCache.get(params);
if (ucs == null) {
@ -212,8 +209,7 @@ class URICertStore extends CertStoreSpi {
}
URI uri = ((URIName) gn).getURI();
try {
return URICertStore.getInstance
(new URICertStore.URICertStoreParameters(uri));
return URICertStore.getInstance(new URICertStoreParameters(uri));
} catch (Exception ex) {
if (debug != null) {
debug.println("exception creating CertStore: " + ex);
@ -420,40 +416,6 @@ class URICertStore extends CertStoreSpi {
}
}
/**
* CertStoreParameters for the URICertStore.
*/
static class URICertStoreParameters implements CertStoreParameters {
private final URI uri;
private volatile int hashCode = 0;
URICertStoreParameters(URI uri) {
this.uri = uri;
}
@Override public boolean equals(Object obj) {
if (!(obj instanceof URICertStoreParameters)) {
return false;
}
URICertStoreParameters params = (URICertStoreParameters) obj;
return uri.equals(params.uri);
}
@Override public int hashCode() {
if (hashCode == 0) {
int result = 17;
result = 37*result + uri.hashCode();
hashCode = result;
}
return hashCode;
}
@Override public Object clone() {
try {
return super.clone();
} catch (CloneNotSupportedException e) {
/* Cannot happen */
throw new InternalError(e.toString(), e);
}
}
}
/**
* This class allows the URICertStore to be accessed as a CertStore.
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007,2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 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
@ -130,6 +130,8 @@ class PlainDatagramSocketImpl extends AbstractPlainDatagramSocketImpl
protected native void disconnect0(int family);
native int dataAvailable();
/**
* Perform class load-time initializations.
*/

View File

@ -1,89 +0,0 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
#include <sys/types.h>
#include <sys/socket.h>
#ifdef __solaris__
#include <unistd.h>
#include <stropts.h>
#ifndef BSD_COMP
#define BSD_COMP
#endif
#endif
#include <sys/ioctl.h>
#include "jvm.h"
#include "jni_util.h"
#include "net_util.h"
#include "java_net_AbstractPlainDatagramSocketImpl.h"
static jfieldID IO_fd_fdID;
static jfieldID apdsi_fdID;
/*
* Class: java_net_AbstractPlainDatagramSocketImpl
* Method: init
* Signature: ()V
*/
JNIEXPORT void JNICALL
Java_java_net_AbstractPlainDatagramSocketImpl_init(JNIEnv *env, jclass cls) {
apdsi_fdID = (*env)->GetFieldID(env, cls, "fd",
"Ljava/io/FileDescriptor;");
CHECK_NULL(apdsi_fdID);
IO_fd_fdID = NET_GetFileDescriptorID(env);
}
/*
* Class: java_net_AbstractPlainDatagramSocketImpl
* Method: dataAvailable
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_java_net_AbstractPlainDatagramSocketImpl_dataAvailable
(JNIEnv *env, jobject this) {
int fd, retval;
jobject fdObj = (*env)->GetObjectField(env, this, apdsi_fdID);
if (IS_NULL(fdObj)) {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
"Socket closed");
return -1;
}
fd = (*env)->GetIntField(env, fdObj, IO_fd_fdID);
if (ioctl(fd, FIONREAD, &retval) < 0) {
return -1;
}
return retval;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
@ -32,6 +32,12 @@
#ifdef __solaris__
#include <fcntl.h>
#include <unistd.h>
#include <stropts.h>
#ifndef BSD_COMP
#define BSD_COMP
#endif
#endif
#ifdef __linux__
#include <unistd.h>
@ -52,6 +58,8 @@
#endif
#endif // __linux__
#include <sys/ioctl.h>
#ifndef IPTOS_TOS_MASK
#define IPTOS_TOS_MASK 0x1e
#endif
@ -2240,3 +2248,28 @@ Java_java_net_PlainDatagramSocketImpl_leave(JNIEnv *env, jobject this,
{
mcast_join_leave(env, this, iaObj, niObj, JNI_FALSE);
}
/*
* Class: java_net_PlainDatagramSocketImpl
* Method: dataAvailable
* Signature: ()I
*/
JNIEXPORT jint JNICALL
Java_java_net_PlainDatagramSocketImpl_dataAvailable(JNIEnv *env, jobject this)
{
int fd, retval;
jobject fdObj = (*env)->GetObjectField(env, this, pdsi_fdID);
if (IS_NULL(fdObj)) {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
"Socket closed");
return -1;
}
fd = (*env)->GetIntField(env, fdObj, IO_fd_fdID);
if (ioctl(fd, FIONREAD, &retval) < 0) {
return -1;
}
return retval;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 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
@ -45,7 +45,7 @@ import java.security.PrivilegedAction;
class DefaultDatagramSocketImplFactory
{
static Class<?> prefixImplClass = null;
private final static Class<?> prefixImplClass;
/* the windows version. */
private static float version;
@ -54,16 +54,19 @@ class DefaultDatagramSocketImplFactory
private static boolean preferIPv4Stack = false;
/* If the version supports a dual stack TCP implementation */
private static boolean useDualStackImpl = false;
private final static boolean useDualStackImpl;
/* sun.net.useExclusiveBind */
private static String exclBindProp;
/* True if exclusive binding is on for Windows */
private static boolean exclusiveBind = true;
private final static boolean exclusiveBind;
static {
Class<?> prefixImplClassLocal = null;
boolean useDualStackImplLocal = false;
boolean exclusiveBindLocal = true;
// Determine Windows Version.
java.security.AccessController.doPrivileged(
new PrivilegedAction<Object>() {
@ -78,7 +81,7 @@ class DefaultDatagramSocketImplFactory
"java.net.preferIPv4Stack"));
exclBindProp = System.getProperty(
"sun.net.useExclusiveBind");
} catch (NumberFormatException e ) {
} catch (NumberFormatException e) {
assert false : e;
}
return null; // nothing to return
@ -87,14 +90,14 @@ class DefaultDatagramSocketImplFactory
// (version >= 6.0) implies Vista or greater.
if (version >= 6.0 && !preferIPv4Stack) {
useDualStackImpl = true;
useDualStackImplLocal = true;
}
if (exclBindProp != null) {
// sun.net.useExclusiveBind is true
exclusiveBind = exclBindProp.length() == 0 ? true
exclusiveBindLocal = exclBindProp.length() == 0 ? true
: Boolean.parseBoolean(exclBindProp);
} else if (version < 6.0) {
exclusiveBind = false;
exclusiveBindLocal = false;
}
// impl.prefix
@ -103,12 +106,16 @@ class DefaultDatagramSocketImplFactory
prefix = AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("impl.prefix", null));
if (prefix != null)
prefixImplClass = Class.forName("java.net."+prefix+"DatagramSocketImpl");
prefixImplClassLocal = Class.forName("java.net."+prefix+"DatagramSocketImpl");
} catch (Exception e) {
System.err.println("Can't find class: java.net." +
prefix +
"DatagramSocketImpl: check impl.prefix property");
}
prefixImplClass = prefixImplClassLocal;
useDualStackImpl = useDualStackImplLocal;
exclusiveBind = exclusiveBindLocal;
}
/**
@ -126,12 +133,10 @@ class DefaultDatagramSocketImplFactory
throw new SocketException("can't instantiate DatagramSocketImpl");
}
} else {
if (isMulticast)
exclusiveBind = false;
if (useDualStackImpl && !isMulticast)
return new DualStackPlainDatagramSocketImpl(exclusiveBind);
else
return new TwoStacksPlainDatagramSocketImpl(exclusiveBind);
return new TwoStacksPlainDatagramSocketImpl(exclusiveBind && !isMulticast);
}
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 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
@ -292,4 +292,6 @@ class DualStackPlainDatagramSocketImpl extends AbstractPlainDatagramSocketImpl
int optionValue) throws SocketException;
private static native int socketGetIntOption(int fd, int cmd) throws SocketException;
native int dataAvailable();
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 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
@ -207,6 +207,8 @@ class TwoStacksPlainDatagramSocketImpl extends AbstractPlainDatagramSocketImpl
protected native void disconnect0(int family);
native int dataAvailable();
/**
* Perform class load-time initializations.
*/

View File

@ -1,113 +0,0 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
#include <windows.h>
#include <winsock2.h>
#include "jvm.h"
#include "jni_util.h"
#include "net_util.h"
#include "java_net_AbstractPlainDatagramSocketImpl.h"
static jfieldID IO_fd_fdID = NULL;
static jfieldID apdsi_fdID = NULL;
static jfieldID apdsi_fd1ID = NULL;
static jclass two_stacks_clazz = NULL;
/*
* Class: java_net_AbstractPlainDatagramSocketImpl
* Method: init
* Signature: ()V
*/
JNIEXPORT void JNICALL
Java_java_net_AbstractPlainDatagramSocketImpl_init(JNIEnv *env, jclass cls) {
apdsi_fdID = (*env)->GetFieldID(env, cls, "fd",
"Ljava/io/FileDescriptor;");
CHECK_NULL(apdsi_fdID);
IO_fd_fdID = NET_GetFileDescriptorID(env);
CHECK_NULL(IO_fd_fdID);
two_stacks_clazz = (*env)->FindClass(env, "java/net/TwoStacksPlainDatagramSocketImpl");
CHECK_NULL(two_stacks_clazz);
/* Handle both TwoStacks and DualStack here */
if (JNU_Equals(env, cls, two_stacks_clazz)) {
/* fd1 present only in TwoStack.. */
apdsi_fd1ID = (*env)->GetFieldID(env, cls, "fd1",
"Ljava/io/FileDescriptor;");
CHECK_NULL(apdsi_fd1ID);
}
JNU_CHECK_EXCEPTION(env);
}
/*
* Class: java_net_AbstractPlainDatagramSocketImpl
* Method: dataAvailable
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_java_net_AbstractPlainDatagramSocketImpl_dataAvailable
(JNIEnv *env, jobject this) {
SOCKET fd;
SOCKET fd1;
int rv = -1, rv1 = -1;
jobject fdObj = (*env)->GetObjectField(env, this, apdsi_fdID);
if (!IS_NULL(fdObj)) {
int retval = 0;
fd = (SOCKET)(*env)->GetIntField(env, fdObj, IO_fd_fdID);
rv = ioctlsocket(fd, FIONREAD, &retval);
if (retval > 0) {
return retval;
}
}
if (!IS_NULL(apdsi_fd1ID)) {
/* TwoStacks */
jobject fd1Obj = (*env)->GetObjectField(env, this, apdsi_fd1ID);
if (!IS_NULL(fd1Obj)) {
int retval = 0;
fd1 = (SOCKET)(*env)->GetIntField(env, fd1Obj, IO_fd_fdID);
rv1 = ioctlsocket(fd1, FIONREAD, &retval);
if (retval > 0) {
return retval;
}
}
}
if (rv < 0 && rv1 < 0) {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
"Socket closed");
return -1;
}
return 0;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 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
@ -70,6 +70,9 @@ static jboolean purgeOutstandingICMP(JNIEnv *env, jint fd)
return got_icmp;
}
static jfieldID IO_fd_fdID = NULL;
static jfieldID pdsi_fdID = NULL;
/*
* Class: java_net_DualStackPlainDatagramSocketImpl
* Method: initIDs
@ -78,6 +81,13 @@ static jboolean purgeOutstandingICMP(JNIEnv *env, jint fd)
JNIEXPORT void JNICALL Java_java_net_DualStackPlainDatagramSocketImpl_initIDs
(JNIEnv *env, jclass clazz)
{
pdsi_fdID = (*env)->GetFieldID(env, clazz, "fd",
"Ljava/io/FileDescriptor;");
CHECK_NULL(pdsi_fdID);
IO_fd_fdID = NET_GetFileDescriptorID(env);
CHECK_NULL(IO_fd_fdID);
JNU_CHECK_EXCEPTION(env);
initInetAddressIDs(env);
}
@ -503,3 +513,32 @@ JNIEXPORT jint JNICALL Java_java_net_DualStackPlainDatagramSocketImpl_socketGetI
return result;
}
/*
* Class: java_net_DualStackPlainDatagramSocketImpl
* Method: dataAvailable
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_java_net_DualStackPlainDatagramSocketImpl_dataAvailable
(JNIEnv *env, jobject this) {
SOCKET fd;
int rv = -1;
jobject fdObj = (*env)->GetObjectField(env, this, pdsi_fdID);
if (!IS_NULL(fdObj)) {
int retval = 0;
fd = (SOCKET)(*env)->GetIntField(env, fdObj, IO_fd_fdID);
rv = ioctlsocket(fd, FIONREAD, &retval);
if (retval > 0) {
return retval;
}
}
if (rv < 0) {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
"Socket closed");
return -1;
}
return 0;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 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
@ -2563,3 +2563,44 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_leave(JNIEnv *env, jobject this,
{
mcast_join_leave (env, this, iaObj, niObj, JNI_FALSE);
}
/*
* Class: java_net_TwoStacksPlainDatagramSocketImpl
* Method: dataAvailable
* Signature: ()I
*/
JNIEXPORT jint JNICALL Java_java_net_TwoStacksPlainDatagramSocketImpl_dataAvailable
(JNIEnv *env, jobject this) {
SOCKET fd;
SOCKET fd1;
int rv = -1, rv1 = -1;
jobject fdObj = (*env)->GetObjectField(env, this, pdsi_fdID);
jobject fd1Obj;
if (!IS_NULL(fdObj)) {
int retval = 0;
fd = (SOCKET)(*env)->GetIntField(env, fdObj, IO_fd_fdID);
rv = ioctlsocket(fd, FIONREAD, &retval);
if (retval > 0) {
return retval;
}
}
fd1Obj = (*env)->GetObjectField(env, this, pdsi_fd1ID);
if (!IS_NULL(fd1Obj)) {
int retval = 0;
fd1 = (SOCKET)(*env)->GetIntField(env, fd1Obj, IO_fd_fdID);
rv1 = ioctlsocket(fd1, FIONREAD, &retval);
if (retval > 0) {
return retval;
}
}
if (rv < 0 && rv1 < 0) {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
"Socket closed");
return -1;
}
return 0;
}

View File

@ -25,18 +25,12 @@
package sun.security.provider.certpath.ldap;
import java.math.BigInteger;
import java.net.URI;
import java.util.*;
import java.security.*;
import java.security.cert.Certificate;
import java.security.cert.*;
import javax.security.auth.x500.X500Principal;
import java.util.*;
import sun.security.util.Cache;
import sun.security.util.Debug;
import sun.security.x509.X500Name;
/**
* A <code>CertStore</code> that retrieves <code>Certificates</code> and
@ -93,8 +87,6 @@ public final class LDAPCertStore extends CertStoreSpi {
private static final Debug debug = Debug.getInstance("certpath");
private final static boolean DEBUG = false;
private String ldapDN;
private LDAPCertStoreImpl impl;
@ -108,7 +100,7 @@ public final class LDAPCertStore extends CertStoreSpi {
String dn = null;
if (params == null) {
throw new InvalidAlgorithmParameterException(
"parameters required for LDAP Certore");
"Parameters required for LDAP certstore");
}
if (params instanceof LDAPCertStoreParameters) {
LDAPCertStoreParameters p = (LDAPCertStoreParameters) params;
@ -119,7 +111,9 @@ public final class LDAPCertStore extends CertStoreSpi {
URI u = p.getURI();
if (!u.getScheme().equalsIgnoreCase("ldap")) {
throw new InvalidAlgorithmParameterException(
"Only LDAP URIs are supported for LDAP Certore");
"Unsupported scheme '" + u.getScheme()
+ "', only LDAP URIs are supported "
+ "for LDAP certstore");
}
// Use the same default values as in LDAPCertStoreParameters
// if unspecified in URI
@ -137,8 +131,9 @@ public final class LDAPCertStore extends CertStoreSpi {
}
} else {
throw new InvalidAlgorithmParameterException(
"parameters must be either LDAPCertStoreParameters or " +
"URICertStoreParameters");
"Parameters must be either LDAPCertStoreParameters or "
+ "URICertStoreParameters, but instance of "
+ params.getClass().getName() + " passed");
}
Key k = new Key(serverName, port);
@ -236,6 +231,7 @@ public final class LDAPCertStore extends CertStoreSpi {
* match the specified selector
* @throws CertStoreException if an exception occurs
*/
@Override
public synchronized Collection<X509Certificate> engineGetCertificates
(CertSelector selector) throws CertStoreException {
if (debug != null) {
@ -245,7 +241,9 @@ public final class LDAPCertStore extends CertStoreSpi {
if (selector == null) {
selector = new X509CertSelector();
} else if (!(selector instanceof X509CertSelector)) {
throw new CertStoreException("need X509CertSelector to find certs");
throw new CertStoreException("Need X509CertSelector to find certs, "
+ "but instance of " + selector.getClass().getName()
+ " passed");
}
return impl.getCertificates((X509CertSelector) selector, ldapDN);
}
@ -271,6 +269,7 @@ public final class LDAPCertStore extends CertStoreSpi {
* match the specified selector
* @throws CertStoreException if an exception occurs
*/
@Override
public synchronized Collection<X509CRL> engineGetCRLs(CRLSelector selector)
throws CertStoreException {
if (debug != null) {
@ -281,7 +280,9 @@ public final class LDAPCertStore extends CertStoreSpi {
if (selector == null) {
selector = new X509CRLSelector();
} else if (!(selector instanceof X509CRLSelector)) {
throw new CertStoreException("need X509CRLSelector to find CRLs");
throw new CertStoreException("Need X509CRLSelector to find CRLs, "
+ "but instance of " + selector.getClass().getName()
+ " passed");
}
return impl.getCRLs((X509CRLSelector) selector, ldapDN);
}

View File

@ -363,10 +363,6 @@ com/sun/jdi/GetLocalVariables4Test.sh windows-all
# 8062512
java/util/spi/ResourceBundleControlProvider/UserDefaultControlTest.java generic-all
# 8029453
java/util/concurrent/locks/ReentrantLock/TimeoutLockLoops.java linux-all
############################################################################
# jdk_instrument

View File

@ -0,0 +1,114 @@
/*
* 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.
*
* 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 8072466
* @summary Deadlock when initializing MulticastSocket and DatagramSocket
* @library /lib/testlibrary
* @build jdk.testlibrary.*
* @run main/othervm MultiDead
*/
import java.net.DatagramSocket;
import java.net.MulticastSocket;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.CountDownLatch;
import jdk.testlibrary.JDKToolLauncher;
public class MultiDead {
private static final int THREAD_PAIR_COUNT = 4;
private static final int CHILDREN_COUNT = 20;
public static void main(String[] args) throws Throwable {
if (args.length == 0 || args[0].equals("parent")) {
parentProcess();
}
if (args.length > 0 && args[0].equals("child")) {
childProcess();
}
}
private static void parentProcess() throws Throwable {
JDKToolLauncher launcher = JDKToolLauncher
.createUsingTestJDK("java")
.addToolArg("MultiDead")
.addToolArg("child");
ProcessBuilder pb = new ProcessBuilder(launcher.getCommand());
AtomicReference<Process> child = new AtomicReference<>();
AtomicBoolean stopFlag = new AtomicBoolean(false);
Thread th = new Thread(() -> {
for (int i = 0; i < CHILDREN_COUNT; ++i) {
System.out.println("child #" + (i + 1) + " of " +
CHILDREN_COUNT);
try {
child.set(pb.start());
child.get().waitFor();
if (stopFlag.get()) {
break;
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
});
th.start();
th.join(CHILDREN_COUNT * 1000); // 1 sec for a child to complete
stopFlag.set(true);
if (th.isAlive()) {
if (child.get() != null) {
child.get().destroyForcibly();
}
throw new RuntimeException("Failed to complete on time.");
}
}
private static void childProcess() {
CountDownLatch latch = new CountDownLatch(1);
for (int i = 0; i < THREAD_PAIR_COUNT; ++i) {
new Thread(() -> {
try {
latch.await();
try (MulticastSocket a = new MulticastSocket(6000)) {
}
} catch (Exception ignore) {
}
}).start();
new Thread(() -> {
try {
latch.await();
try (DatagramSocket b = new DatagramSocket(6000)) {
}
} catch (Exception ignore) {
}
}).start();
}
latch.countDown();
}
}

View File

@ -35,7 +35,6 @@
* @test
* @bug 4486658 5031862
* @run main TimeoutLockLoops
* @key intermittent
* @summary Checks for responsiveness of locks to timeouts.
* Runs under the assumption that ITERS computations require more than
* TIMEOUT msecs to complete, which seems to be a safe assumption for

View File

@ -0,0 +1,247 @@
/*
* 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.
*/
import java.io.IOException;
import java.io.StringBufferInputStream;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.CertPath;
import java.security.cert.CertPathValidator;
import java.security.cert.CertPathValidatorException;
import java.security.cert.PKIXParameters;
import java.security.cert.TrustAnchor;
import java.security.cert.X509Certificate;
import java.text.DateFormat;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import sun.net.spi.nameservice.NameService;
import sun.net.spi.nameservice.NameServiceDescriptor;
/*
* @test
* @bug 8134708
* @summary Check if LDAP resources from CRLDP and AIA extensions can be loaded
* @run main/othervm ExtensionsWithLDAP
*/
public class ExtensionsWithLDAP {
/*
* Certificate:
* Data:
* Version: 3 (0x2)
* Serial Number: 11174053930990688938 (0x9b1236d8f9c1daaa)
* Signature Algorithm: sha512WithRSAEncryption
* Issuer: CN=Root
* Validity
* Not Before: Sep 1 18:03:59 2015 GMT
* Not After : Jan 17 18:03:59 2043 GMT
* Subject: CN=Root
*/
private static final String CA_CERT = ""
+ "-----BEGIN CERTIFICATE-----\n"
+ "MIIC8TCCAdmgAwIBAgIJAJsSNtj5wdqqMA0GCSqGSIb3DQEBDQUAMA8xDTALBgNV\n"
+ "BAMMBFJvb3QwHhcNMTUwOTAxMTgwMzU5WhcNNDMwMTE3MTgwMzU5WjAPMQ0wCwYD\n"
+ "VQQDDARSb290MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvj892vPm\n"
+ "bB++x9QqqyBveP+ZqQ2B1stV7vh5JmDnOTevkZUOcemp3SXu/esNLSbpL+fARYXH\n"
+ "V5ubnrfip6RbvcxPfVIIDJrRTLIIsU6W7M6/LJLbLkEVGy4ZV4IHkOw9W2O92rcv\n"
+ "BkoqhzZnOTGR6uT3rRcKx4RevEKBKhZO+OPPf//lnckOybmYL7t7yQrajzHro76b\n"
+ "QTXYjAUq/DKhglXfC7vF/JzlAvG2IunGmIfjGcnuDo/9X3Bxef/q5TxCS35fvb7t\n"
+ "svC+g2QhTcBkQh4uNW2jSjlTIVp1uErCfP5aCjLaez5mqmb1hxPIlcvsNR23HwU6\n"
+ "bQO7z7NBo9Do6QIDAQABo1AwTjAdBgNVHQ4EFgQUmLZNOBBkqdYoElyxklPYHmAb\n"
+ "QXIwHwYDVR0jBBgwFoAUmLZNOBBkqdYoElyxklPYHmAbQXIwDAYDVR0TBAUwAwEB\n"
+ "/zANBgkqhkiG9w0BAQ0FAAOCAQEAYV4fOhDi5q7+XNXCxO8Eil2frR9jqdP4LaQp\n"
+ "3L0evW0gvPX68s2WmkPWzIu4TJcpdGFQqxyQFSXuKBXjthyiln77QItGTHWeafES\n"
+ "q5ESrKdSaJZq1bTIrrReCIP74f+fY/F4Tnb3dCqzaljXfzpdbeRsIW6gF71xcOUQ\n"
+ "nnPEjGVPLUegN+Wn/jQpeLxxIB7FmNXncdRUfMfZ43xVSKuMCy1UUYqJqTa/pXZj\n"
+ "jCMeRPThRjRqHlJ69jStfWUQATbLyj9KN09rUaJxzmUSt61UqJi7sjcGySaCjAJc\n"
+ "IcCdVmX/DmRLsdv8W36O3MgrvpT1zR3kaAlv2d8HppnBqcL3xg==\n"
+ "-----END CERTIFICATE-----";
/*
* Certificate:
* Data:
* Version: 3 (0x2)
* Serial Number: 7 (0x7)
* Signature Algorithm: sha512WithRSAEncryption
* Issuer: CN=Root
* Validity
* Not Before: Sep 1 18:03:59 2015 GMT
* Not After : Jan 17 18:03:59 2043 GMT
* Subject: CN=EE
* ...
* X509v3 extensions:
* X509v3 CRL Distribution Points:
* Full Name:
* URI:ldap://ldap.host.for.crldp/main.crl
* Authority Information Access:
* CA Issuers - URI:ldap://ldap.host.for.aia/dc=Root?cACertificate
*/
private static final String EE_CERT = ""
+ "-----BEGIN CERTIFICATE-----\n"
+ "MIIDHTCCAgWgAwIBAgIBBzANBgkqhkiG9w0BAQ0FADAPMQ0wCwYDVQQDDARSb290\n"
+ "MB4XDTE1MDkwMTE4MDM1OVoXDTQzMDExNzE4MDM1OVowDTELMAkGA1UEAwwCRUUw\n"
+ "ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCpyz97liuWPDYcLH9TX8Bi\n"
+ "T78olCmAfmevvch6ncXUVuCzbdaKuKXwn4EVbDszsVJLoK5zdtP+X3iDhutj+IgK\n"
+ "mLhuczF3M9VIcWr+JJUyTH4+3h/RT8cjCDZOmk9iXkb5ifruVsLqzb9g+Vp140Oz\n"
+ "7leikne7KmclHvTfvFd0WDI7Gb9vo4f5rT717BXJ/n+M6pNk8DLpLiEu6eziYvXR\n"
+ "v5x+t5Go3x0eCXdaxEQUf2j876Wfr2qHRJK7lDfFe1DDsMg/KpKGiILYZ+g2qtVM\n"
+ "ZSxtp5BZEtfB5qV/IE5kWO+mCIAGpXSZIdbERR6pZUq8GLEe1T9e+sO6H24w2F19\n"
+ "AgMBAAGjgYUwgYIwNAYDVR0fBC0wKzApoCegJYYjbGRhcDovL2xkYXAuaG9zdC5m\n"
+ "b3IuY3JsZHAvbWFpbi5jcmwwSgYIKwYBBQUHAQEEPjA8MDoGCCsGAQUFBzAChi5s\n"
+ "ZGFwOi8vbGRhcC5ob3N0LmZvci5haWEvZGM9Um9vdD9jQUNlcnRpZmljYXRlMA0G\n"
+ "CSqGSIb3DQEBDQUAA4IBAQBWDfZHpuUx0yn5d3+BuztFqoks1MkGdk+USlH0TB1/\n"
+ "gWWBd+4S4PCKlpSur0gj2rMW4fP5HQfNlHci8JV8/bG4KuKRAXW56dg1818Hl3pc\n"
+ "iIrUSRn8uUjH3p9qb+Rb/u3mmVQRyJjN2t/zceNsO8/+Dd808OB9aEwGs8lMT0nn\n"
+ "ZYaaAqYz1GIY/Ecyx1vfEZEQ1ljo6i/r70C3igbypBUShxSiGsleiVTLOGNA+MN1\n"
+ "/a/Qh0bkaQyTGqK3bwvzzMeQVqWu2EWTBD/PmND5ExkpRICdv8LBVXfLnpoBr4lL\n"
+ "hnxn9+e0Ah+t8dS5EKfn44w5bI5PCu2bqxs6RCTxNjcY\n"
+ "-----END CERTIFICATE-----";
private static final String LDAP_HOST_CRLDP = "ldap.host.for.crldp";
private static final String LDAP_HOST_AIA = "ldap.host.for.aia";
// a date within the certificates validity period
static final Date validationDate;
static {
try {
validationDate = DateFormat.getDateInstance(
DateFormat.MEDIUM, Locale.US).parse("Sep 02, 2015");
} catch (ParseException e) {
throw new RuntimeException("Couldn't parse date", e);
}
}
public static void main(String[] args) throws Exception {
// enable CRLDP and AIA extensions
System.setProperty("com.sun.security.enableCRLDP", "true");
System.setProperty("com.sun.security.enableAIAcaIssuers", "true");
// register a local name service
System.setProperty("sun.net.spi.nameservice.provider.1", "ns,localdns");
X509Certificate trustedCert = loadCertificate(CA_CERT);
X509Certificate eeCert = loadCertificate(EE_CERT);
Set<TrustAnchor> trustedCertsSet = new HashSet<>();
trustedCertsSet.add(new TrustAnchor(trustedCert, null));
CertPath cp = (CertPath) CertificateFactory.getInstance("X509")
.generateCertPath(Arrays.asList(eeCert));
PKIXParameters params = new PKIXParameters(trustedCertsSet);
params.setDate(validationDate);
// certpath validator should try to parse CRLDP and AIA extensions,
// and load CRLs/certs which they point to
// if a local name service catched requests for resolving host names
// which extensions contain, then it means that certpath validator
// tried to load CRLs/certs which they point to
try {
CertPathValidator.getInstance("PKIX").validate(cp, params);
throw new RuntimeException("CertPathValidatorException not thrown");
} catch (CertPathValidatorException cpve) {
System.out.println("Expected exception: " + cpve);
}
// check if it tried to resolve a host name from CRLDP extension
if (!LocalNameService.requestedHosts.contains(LDAP_HOST_CRLDP)) {
throw new RuntimeException(
"A hostname from CRLDP extension not requested");
}
// check if it tried to resolve a host name from AIA extension
if (!LocalNameService.requestedHosts.contains(LDAP_HOST_AIA)) {
throw new RuntimeException(
"A hostname from AIA extension not requested");
}
System.out.println("Test passed");
}
// load a X509 certificate
public static X509Certificate loadCertificate(String s)
throws IOException, CertificateException {
try (StringBufferInputStream is = new StringBufferInputStream(s)) {
return (X509Certificate) CertificateFactory.getInstance("X509")
.generateCertificate(is);
}
}
// a local name service which log requested host names
public static class LocalNameService implements NameServiceDescriptor {
static final List<String> requestedHosts = new ArrayList<>();
@Override
public NameService createNameService() throws Exception {
System.out.println("LocalNameService: createNameService() called");
NameService ns = new NameService() {
@Override
public InetAddress[] lookupAllHostAddr(String host)
throws UnknownHostException {
System.out.println("LocalNameService: "
+ "NameService.lookupAllHostAddr(): " + host);
requestedHosts.add(host);
throw new UnknownHostException();
}
@Override
public String getHostByAddr(byte[] addr)
throws UnknownHostException {
System.out.println("LocalNameService: "
+ "NameService.getHostByAddr(): "
+ Arrays.toString(addr));
throw new UnknownHostException("No reverse lookup");
}
};
return ns;
}
@Override
public String getProviderName() {
return "localdns";
}
@Override
public String getType() {
return "ns";
}
}
}

View File

@ -0,0 +1 @@
ExtensionsWithLDAP$LocalNameService