Merge jdk8-b27
authorlana
Sat, 18 Feb 2012 16:11:47 -0800
changeset 5079c68342532e2e
parent 5030 4196fc971f65
parent 5078 2a3f026b3a29
child 5080 7d683ab46571
child 5092 f525c1e9e12c
child 5103 6a5d6b2800f6
child 5109 f959bde6990a
child 5117 75247b827d6c
child 5175 e4f3f5ceb082
Merge
src/linux/doc/man/apt.1
src/linux/doc/man/ja/apt.1
src/share/classes/com/sun/management/DiagnosticCommandArgumentInfo.java
src/share/classes/com/sun/management/DiagnosticCommandInfo.java
src/share/classes/sun/nio/ch/SctpMessageInfoImpl.java
src/share/classes/sun/nio/ch/SctpStdSocketOption.java
src/solaris/classes/sun/nio/ch/SctpAssocChange.java
src/solaris/classes/sun/nio/ch/SctpAssociationImpl.java
src/solaris/classes/sun/nio/ch/SctpChannelImpl.java
src/solaris/classes/sun/nio/ch/SctpMultiChannelImpl.java
src/solaris/classes/sun/nio/ch/SctpNet.java
src/solaris/classes/sun/nio/ch/SctpNotification.java
src/solaris/classes/sun/nio/ch/SctpPeerAddrChange.java
src/solaris/classes/sun/nio/ch/SctpResultContainer.java
src/solaris/classes/sun/nio/ch/SctpSendFailed.java
src/solaris/classes/sun/nio/ch/SctpServerChannelImpl.java
src/solaris/classes/sun/nio/ch/SctpShutdown.java
src/solaris/doc/sun/man/man1/apt.1
src/solaris/doc/sun/man/man1/ja/apt.1
src/solaris/native/sun/nio/ch/Sctp.h
src/solaris/native/sun/nio/ch/SctpChannelImpl.c
src/solaris/native/sun/nio/ch/SctpNet.c
src/solaris/native/sun/nio/ch/SctpServerChannelImpl.c
src/windows/classes/sun/nio/ch/SctpChannelImpl.java
src/windows/classes/sun/nio/ch/SctpMultiChannelImpl.java
src/windows/classes/sun/nio/ch/SctpServerChannelImpl.java
test/com/sun/management/HotSpotDiagnosticMXBean/ExecuteDiagnosticCommand.java
test/com/sun/management/HotSpotDiagnosticMXBean/GetDiagnosticCommandInfo.java
test/com/sun/management/HotSpotDiagnosticMXBean/GetDiagnosticCommands.java
     1.1 --- a/make/com/sun/Makefile	Thu Feb 16 13:01:36 2012 -0800
     1.2 +++ b/make/com/sun/Makefile	Sat Feb 18 16:11:47 2012 -0800
     1.3 @@ -47,7 +47,6 @@
     1.4                       org rowset net/httpserver
     1.5  SUBDIRS_misc       = $(SCRIPT_SUBDIR) tracing servicetag nio demo
     1.6  
     1.7 -# Omit mirror since it's built with the apt tool.
     1.8  SUBDIRS_tools      = tools
     1.9  
    1.10  include $(BUILDDIR)/common/Subdirs.gmk
     2.1 --- a/make/com/sun/nio/sctp/Exportedfiles.gmk	Thu Feb 16 13:01:36 2012 -0800
     2.2 +++ b/make/com/sun/nio/sctp/Exportedfiles.gmk	Sat Feb 18 16:11:47 2012 -0800
     2.3 @@ -29,11 +29,11 @@
     2.4  
     2.5  ifneq ($(PLATFORM), windows)
     2.6  FILES_export = \
     2.7 -    sun/nio/ch/SctpAssocChange.java \
     2.8 -    sun/nio/ch/SctpChannelImpl.java \
     2.9 -    sun/nio/ch/SctpNet.java \
    2.10 -    sun/nio/ch/SctpPeerAddrChange.java \
    2.11 -    sun/nio/ch/SctpResultContainer.java \
    2.12 -    sun/nio/ch/SctpServerChannelImpl.java \
    2.13 -    sun/nio/ch/SctpStdSocketOption.java
    2.14 +    sun/nio/ch/sctp/AssociationChange.java \
    2.15 +    sun/nio/ch/sctp/SctpChannelImpl.java \
    2.16 +    sun/nio/ch/sctp/SctpNet.java \
    2.17 +    sun/nio/ch/sctp/PeerAddrChange.java \
    2.18 +    sun/nio/ch/sctp/ResultContainer.java \
    2.19 +    sun/nio/ch/sctp/SctpServerChannelImpl.java \
    2.20 +    sun/nio/ch/sctp/SctpStdSocketOption.java
    2.21  endif
     3.1 --- a/make/com/sun/nio/sctp/FILES_java.gmk	Thu Feb 16 13:01:36 2012 -0800
     3.2 +++ b/make/com/sun/nio/sctp/FILES_java.gmk	Sat Feb 18 16:11:47 2012 -0800
     3.3 @@ -42,25 +42,25 @@
     3.4  	com/sun/nio/sctp/SendFailedNotification.java \
     3.5  	com/sun/nio/sctp/ShutdownNotification.java \
     3.6  	\
     3.7 -	sun/nio/ch/SctpMessageInfoImpl.java \
     3.8 -	sun/nio/ch/SctpStdSocketOption.java
     3.9 +	sun/nio/ch/sctp/MessageInfoImpl.java \
    3.10 +	sun/nio/ch/sctp/SctpStdSocketOption.java
    3.11  
    3.12  ifneq ($(PLATFORM), windows)
    3.13  FILES_java += \
    3.14 -	sun/nio/ch/SctpAssocChange.java \
    3.15 -	sun/nio/ch/SctpAssociationImpl.java \
    3.16 -	sun/nio/ch/SctpChannelImpl.java \
    3.17 -	sun/nio/ch/SctpMultiChannelImpl.java \
    3.18 -	sun/nio/ch/SctpNet.java \
    3.19 -	sun/nio/ch/SctpNotification.java \
    3.20 -	sun/nio/ch/SctpPeerAddrChange.java \
    3.21 -	sun/nio/ch/SctpResultContainer.java \
    3.22 -	sun/nio/ch/SctpSendFailed.java \
    3.23 -	sun/nio/ch/SctpServerChannelImpl.java \
    3.24 -	sun/nio/ch/SctpShutdown.java
    3.25 +	sun/nio/ch/sctp/AssociationChange.java \
    3.26 +	sun/nio/ch/sctp/AssociationImpl.java \
    3.27 +	sun/nio/ch/sctp/PeerAddrChange.java \
    3.28 +	sun/nio/ch/sctp/ResultContainer.java \
    3.29 +	sun/nio/ch/sctp/SctpChannelImpl.java \
    3.30 +	sun/nio/ch/sctp/SctpMultiChannelImpl.java \
    3.31 +	sun/nio/ch/sctp/SctpNet.java \
    3.32 +	sun/nio/ch/sctp/SctpNotification.java \
    3.33 +	sun/nio/ch/sctp/SctpServerChannelImpl.java \
    3.34 +	sun/nio/ch/sctp/SendFailed.java \
    3.35 +	sun/nio/ch/sctp/Shutdown.java
    3.36  else
    3.37  FILES_java += \
    3.38 -	sun/nio/ch/SctpChannelImpl.java \
    3.39 -	sun/nio/ch/SctpMultiChannelImpl.java \
    3.40 -	sun/nio/ch/SctpServerChannelImpl.java
    3.41 +	sun/nio/ch/sctp/SctpChannelImpl.java \
    3.42 +	sun/nio/ch/sctp/SctpMultiChannelImpl.java \
    3.43 +	sun/nio/ch/sctp/SctpServerChannelImpl.java
    3.44  endif
     4.1 --- a/make/com/sun/nio/sctp/Makefile	Thu Feb 16 13:01:36 2012 -0800
     4.2 +++ b/make/com/sun/nio/sctp/Makefile	Sat Feb 18 16:11:47 2012 -0800
     4.3 @@ -47,14 +47,16 @@
     4.4  #
     4.5  # Find platform-specific C source files
     4.6  #
     4.7 -vpath %.c $(PLATFORM_SRC)/native/sun/nio/ch
     4.8 +vpath %.c $(PLATFORM_SRC)/native/sun/nio/ch/sctp
     4.9  
    4.10  #
    4.11  # Include nio.h, net_util.h, sun_nio_ch_IOStatus.h, etc
    4.12  #
    4.13  OTHER_INCLUDES += \
    4.14    -I$(SHARE_SRC)/native/sun/nio/ch \
    4.15 +  -I$(SHARE_SRC)/native/sun/nio/ch/sctp \
    4.16    -I$(SHARE_SRC)/native/java/net \
    4.17 +  -I$(PLATFORM_SRC)/native/sun/nio/ch \
    4.18    -I$(PLATFORM_SRC)/native/java/net \
    4.19    -I$(CLASSHDRDIR)/../../../../java/java.nio/nio/CClassHeaders
    4.20  
    4.21 @@ -75,5 +77,5 @@
    4.22  
    4.23  clean clobber::
    4.24  	$(RM) -r $(CLASSDESTDIR)/com/sun/nio/sctp
    4.25 -	$(RM) -r $(CLASSDESTDIR)/sun/nio/ch
    4.26 +	$(RM) -r $(CLASSDESTDIR)/sun/nio/ch/sctp
    4.27  
     5.1 --- a/make/com/sun/nio/sctp/mapfile-vers	Thu Feb 16 13:01:36 2012 -0800
     5.2 +++ b/make/com/sun/nio/sctp/mapfile-vers	Sat Feb 18 16:11:47 2012 -0800
     5.3 @@ -25,30 +25,30 @@
     5.4  
     5.5  SUNWprivate_1.1 {
     5.6  	global:
     5.7 -		Java_sun_nio_ch_SctpNet_init;
     5.8 -		Java_sun_nio_ch_SctpNet_socket0;
     5.9 -		Java_sun_nio_ch_SctpNet_bindx;
    5.10 -		Java_sun_nio_ch_SctpNet_branch0;
    5.11 -		Java_sun_nio_ch_SctpNet_listen0;
    5.12 -		Java_sun_nio_ch_SctpNet_connect0;
    5.13 -		Java_sun_nio_ch_SctpNet_close0;
    5.14 -		Java_sun_nio_ch_SctpNet_preClose0;
    5.15 -		Java_sun_nio_ch_SctpNet_getLocalAddresses0;
    5.16 -		Java_sun_nio_ch_SctpNet_getRemoteAddresses0;
    5.17 -		Java_sun_nio_ch_SctpNet_getPrimAddrOption0;
    5.18 -		Java_sun_nio_ch_SctpNet_setPrimAddrOption0;
    5.19 -		Java_sun_nio_ch_SctpNet_setPeerPrimAddrOption0;
    5.20 -		Java_sun_nio_ch_SctpNet_getInitMsgOption0;
    5.21 -		Java_sun_nio_ch_SctpNet_setInitMsgOption0;
    5.22 -		Java_sun_nio_ch_SctpNet_getIntOption0;
    5.23 -		Java_sun_nio_ch_SctpNet_setIntOption0;
    5.24 -		Java_sun_nio_ch_SctpNet_shutdown0;
    5.25 -		Java_sun_nio_ch_SctpChannelImpl_initIDs;
    5.26 -		Java_sun_nio_ch_SctpChannelImpl_checkConnect;
    5.27 -		Java_sun_nio_ch_SctpChannelImpl_receive0;
    5.28 -		Java_sun_nio_ch_SctpChannelImpl_send0;
    5.29 -		Java_sun_nio_ch_SctpServerChannelImpl_initIDs;
    5.30 -		Java_sun_nio_ch_SctpServerChannelImpl_accept0;
    5.31 +		Java_sun_nio_ch_sctp_SctpNet_init;
    5.32 +		Java_sun_nio_ch_sctp_SctpNet_socket0;
    5.33 +		Java_sun_nio_ch_sctp_SctpNet_bindx;
    5.34 +		Java_sun_nio_ch_sctp_SctpNet_branch0;
    5.35 +		Java_sun_nio_ch_sctp_SctpNet_listen0;
    5.36 +		Java_sun_nio_ch_sctp_SctpNet_connect0;
    5.37 +		Java_sun_nio_ch_sctp_SctpNet_close0;
    5.38 +		Java_sun_nio_ch_sctp_SctpNet_preClose0;
    5.39 +		Java_sun_nio_ch_sctp_SctpNet_getLocalAddresses0;
    5.40 +		Java_sun_nio_ch_sctp_SctpNet_getRemoteAddresses0;
    5.41 +		Java_sun_nio_ch_sctp_SctpNet_getPrimAddrOption0;
    5.42 +		Java_sun_nio_ch_sctp_SctpNet_setPrimAddrOption0;
    5.43 +		Java_sun_nio_ch_sctp_SctpNet_setPeerPrimAddrOption0;
    5.44 +		Java_sun_nio_ch_sctp_SctpNet_getInitMsgOption0;
    5.45 +		Java_sun_nio_ch_sctp_SctpNet_setInitMsgOption0;
    5.46 +		Java_sun_nio_ch_sctp_SctpNet_getIntOption0;
    5.47 +		Java_sun_nio_ch_sctp_SctpNet_setIntOption0;
    5.48 +		Java_sun_nio_ch_sctp_SctpNet_shutdown0;
    5.49 +		Java_sun_nio_ch_sctp_SctpChannelImpl_initIDs;
    5.50 +		Java_sun_nio_ch_sctp_SctpChannelImpl_checkConnect;
    5.51 +		Java_sun_nio_ch_sctp_SctpChannelImpl_receive0;
    5.52 +		Java_sun_nio_ch_sctp_SctpChannelImpl_send0;
    5.53 +		Java_sun_nio_ch_sctp_SctpServerChannelImpl_initIDs;
    5.54 +		Java_sun_nio_ch_sctp_SctpServerChannelImpl_accept0;
    5.55                  JNI_OnLoad;
    5.56  	local:
    5.57  		*;
     6.1 --- a/make/common/Release.gmk	Thu Feb 16 13:01:36 2012 -0800
     6.2 +++ b/make/common/Release.gmk	Sat Feb 18 16:11:47 2012 -0800
     6.3 @@ -132,7 +132,6 @@
     6.4  JDK_MAN_PAGES =            \
     6.5  	$(JRE_MAN_PAGES)   \
     6.6  	appletviewer.1     \
     6.7 -        apt.1              \
     6.8  	extcheck.1         \
     6.9  	idlj.1             \
    6.10  	jar.1              \
    6.11 @@ -264,7 +263,6 @@
    6.12  	com/sun/java/swing		\
    6.13  	com/sun/javadoc			\
    6.14  	com/sun/jmx			\
    6.15 -	com/sun/mirror			\
    6.16  	com/sun/source			\
    6.17  	com/sun/naming			\
    6.18  	com/sun/security/auth		\
    6.19 @@ -346,7 +344,6 @@
    6.20  	com/sun/javadoc		\
    6.21  	com/sun/jdi		\
    6.22  	com/sun/jarsigner	\
    6.23 -	com/sun/mirror		\
    6.24  	com/sun/source          \
    6.25  	com/sun/tools/classfile \
    6.26  	com/sun/tools/doclets   \
    6.27 @@ -356,16 +353,16 @@
    6.28  	com/sun/tools/hat       \
    6.29  	com/sun/tools/javac     \
    6.30  	com/sun/tools/javadoc   \
    6.31 -	com/sun/tools/apt       \
    6.32  	com/sun/tools/javah     \
    6.33  	com/sun/tools/javap     \
    6.34  	com/sun/tools/corba     \
    6.35  	com/sun/tools/internal/xjc       \
    6.36  	com/sun/tools/internal/ws       \
    6.37 -	META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory \
    6.38 -	META-INF/services/com.sun.tools.xjc.Plugin \
    6.39 +	META-INF/services/com.sun.tools.internal.ws.wscompile.Plugin \
    6.40 +	META-INF/services/com.sun.tools.internal.xjc.Plugin \
    6.41  	com/sun/istack/internal/tools       \
    6.42 -	com/sun/istack/internal/ws       \
    6.43 +	com/sun/tools/internal/jxc/ap   \
    6.44 +	com/sun/tools/internal/ws/wscompile/plugin/at_generated \
    6.45          com/sun/codemodel       \
    6.46          com/sun/tools/internal/jxc             \
    6.47          com/sun/xml/internal/rngom       \
    6.48 @@ -438,7 +435,6 @@
    6.49  	java-rmi.cgi \
    6.50  	javac$(EXE_SUFFIX) \
    6.51  	javadoc$(EXE_SUFFIX) \
    6.52 -	apt$(EXE_SUFFIX) \
    6.53  	javah$(EXE_SUFFIX) \
    6.54  	javap$(EXE_SUFFIX) \
    6.55  	jcmd$(EXE_SUFFIX) \
    6.56 @@ -525,13 +521,10 @@
    6.57  	$(ECHO) "com/sun/javadoc/" >> $@
    6.58  	$(ECHO) "com/sun/jdi/" >> $@
    6.59  	$(ECHO) "com/sun/jarsigner/" >> $@
    6.60 -	$(ECHO) "com/sun/mirror/" >> $@
    6.61  	$(ECHO) "com/sun/source/" >> $@
    6.62  	$(ECHO) "com/sun/istack/internal/tools/" >> $@
    6.63 -	$(ECHO) "com/sun/istack/internal/ws/" >> $@
    6.64  	$(ECHO) "META-INF/services/com.sun.jdi.connect.Connector" >> $@
    6.65  	$(ECHO) "META-INF/services/com.sun.jdi.connect.spi.TransportService" >> $@
    6.66 -	$(ECHO) "META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory" >> $@
    6.67  	$(ECHO) "META-INF/services/com.sun.tools.xjc.Plugin" >> $@
    6.68  	$(ECHO) "com/sun/tools/" >> $@
    6.69  	$(ECHO) "sun/jvmstat/" >> $@
    6.70 @@ -1000,7 +993,7 @@
    6.71  	@#
    6.72  	@# files that might not exist need to be touched.
    6.73  	@#
    6.74 -	$(TOUCH) $(CLASSBINDIR)/META-INF/services/com.sun.tools.xjc.Plugin
    6.75 +	$(TOUCH) $(CLASSBINDIR)/META-INF/services/com.sun.tools.internal.xjc.Plugin
    6.76  	@#
    6.77  	@# lib/tools.jar
    6.78  	@#
     7.1 --- a/make/common/internal/Defs-jaxws.gmk	Thu Feb 16 13:01:36 2012 -0800
     7.2 +++ b/make/common/internal/Defs-jaxws.gmk	Sat Feb 18 16:11:47 2012 -0800
     7.3 @@ -34,7 +34,6 @@
     7.4       javax/xml/ws \
     7.5       javax/jws \
     7.6       javax/annotation \
     7.7 -     com/sun/istack/internal \
     7.8       com/sun/xml/internal/bind \
     7.9       com/sun/xml/internal/fastinfoset \
    7.10       com/sun/xml/internal/messaging \
    7.11 @@ -42,13 +41,13 @@
    7.12       com/sun/xml/internal/txw2 \
    7.13       com/sun/xml/internal/ws \
    7.14       com/sun/xml/internal/stream/buffer
    7.15 +
    7.16  NOT_USED_PACKAGES += \
    7.17       com/sun/tools/internal/txw2
    7.18  
    7.19  IMPORT_TOOLS_PACKAGES += \
    7.20       com/sun/codemodel \
    7.21       com/sun/istack/internal/tools \
    7.22 -     com/sun/istack/internal/ws \
    7.23       com/sun/xml/internal/rngom \
    7.24       com/sun/xml/internal/xsom \
    7.25       com/sun/xml/internal/dtdparser \
    7.26 @@ -56,6 +55,9 @@
    7.27       com/sun/tools/internal/ws \
    7.28       com/sun/tools/internal/jxc \
    7.29       org/relaxng \
    7.30 -     META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory \
    7.31 -     META-INF/services/com.sun.tools.internal.xjc.Plugin
    7.32 +     META-INF/services/com.sun.tools.internal.ws.wscompile.Plugin \
    7.33 +     META-INF/services/com.sun.tools.internal.xjc.Plugin \
    7.34 +     com/sun/tools/internal/jxc/ap \
    7.35 +     com/sun/tools/internal/ws/wscompile/plugin/at_generated
    7.36  
    7.37 +
     8.1 --- a/make/common/internal/Defs-langtools.gmk	Thu Feb 16 13:01:36 2012 -0800
     8.2 +++ b/make/common/internal/Defs-langtools.gmk	Sat Feb 18 16:11:47 2012 -0800
     8.3 @@ -1,5 +1,5 @@
     8.4  #
     8.5 -# Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
     8.6 +# Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
     8.7  # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     8.8  #
     8.9  # This code is free software; you can redistribute it and/or modify it
    8.10 @@ -32,9 +32,7 @@
    8.11  
    8.12  IMPORT_TOOLS_PACKAGES +=            \
    8.13        com/sun/javadoc               \
    8.14 -      com/sun/mirror                \
    8.15        com/sun/source                \
    8.16 -      com/sun/tools/apt             \
    8.17        com/sun/tools/classfile       \
    8.18        com/sun/tools/doclets         \
    8.19        com/sun/tools/javac           \
     9.1 --- a/make/docs/Makefile	Thu Feb 16 13:01:36 2012 -0800
     9.2 +++ b/make/docs/Makefile	Sat Feb 18 16:11:47 2012 -0800
     9.3 @@ -1,4 +1,4 @@
     9.4 -# Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
     9.5 +# Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
     9.6  # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     9.7  #
     9.8  # This code is free software; you can redistribute it and/or modify it
     9.9 @@ -358,64 +358,6 @@
    9.10  
    9.11  #############################################################
    9.12  #
    9.13 -# mirrordocs
    9.14 -#
    9.15 -
    9.16 -# Part of langtools
    9.17 -ifdef LANGTOOLS_DIST
    9.18 -  ALL_OTHER_TARGETS += mirrordocs
    9.19 -endif
    9.20 -
    9.21 -MIRROR_DOCDIR      := $(JDK_API_DOCSDIR)/apt/mirror
    9.22 -MIRROR2COREAPI     := ../../$(JDKJRE2COREAPI)
    9.23 -MIRROR_DOCTITLE    := Mirror API
    9.24 -MIRROR_WINDOWTITLE := Mirror API
    9.25 -MIRROR_HEADER      := <strong>Mirror API</strong>
    9.26 -MIRROR_BOTTOM      := $(call CommonBottom,$(MIRROR_FIRST_COPYRIGHT_YEAR))
    9.27 -MIRROR_GROUPNAME   := Packages
    9.28 -MIRROR_OVERVIEW    := $(IMPORTSRCDIR)/com/sun/mirror/overview.html
    9.29 -MIRROR_REGEXP      := com.sun.mirror.*
    9.30 -# MIRROR_PKGS is located in NON_CORE_PKGS.gmk
    9.31 -
    9.32 -# The index.html, options, and packages files
    9.33 -MIRROR_INDEX_FILE    = $(MIRROR_DOCDIR)/index.html
    9.34 -MIRROR_OPTIONS_FILE  = $(DOCSTMPDIR)/mirror.options
    9.35 -MIRROR_PACKAGES_FILE = $(DOCSTMPDIR)/mirror.packages
    9.36 -
    9.37 -mirrordocs: $(MIRROR_INDEX_FILE)
    9.38 -
    9.39 -# Set relative location to core api document root
    9.40 -$(MIRROR_INDEX_FILE): GET2DOCSDIR=$(MIRROR2COREAPI)/..
    9.41 -
    9.42 -# Run javadoc if the index file is out of date or missing
    9.43 -$(MIRROR_INDEX_FILE): $(MIRROR_OPTIONS_FILE) $(MIRROR_PACKAGES_FILE)
    9.44 -	$(prep-javadoc)
    9.45 -	$(call JavadocSummary,$(MIRROR_OPTIONS_FILE),$(MIRROR_PACKAGES_FILE))
    9.46 -	$(JAVADOC_CMD) $(JAVADOC_VM_MEMORY_FLAGS) -d $(@D) \
    9.47 -	  @$(MIRROR_OPTIONS_FILE) @$(MIRROR_PACKAGES_FILE)
    9.48 -
    9.49 -# Create file with javadoc options in it
    9.50 -$(MIRROR_OPTIONS_FILE): $(MIRROR_OVERVIEW)
    9.51 -	$(prep-target)
    9.52 -	@($(call OptionOnly,$(COMMON_JAVADOCFLAGS))			; \
    9.53 -	  $(call OptionPair,-sourcepath,$(RELEASEDOCS_SOURCEPATH))	; \
    9.54 -	  $(call OptionPair,-encoding,ascii)				; \
    9.55 -	  $(call OptionPair,-overview,$(MIRROR_OVERVIEW))		; \
    9.56 -	  $(call OptionPair,-doctitle,$(MIRROR_DOCTITLE))		; \
    9.57 -	  $(call OptionPair,-windowtitle,$(MIRROR_WINDOWTITLE) $(DRAFT_WINTITLE));\
    9.58 -	  $(call OptionPair,-header,$(MIRROR_HEADER)$(DRAFT_HEADER))	; \
    9.59 -	  $(call OptionPair,-bottom,$(MIRROR_BOTTOM)$(DRAFT_BOTTOM)) 	; \
    9.60 -	  $(call OptionTrip,-group,$(MIRROR_GROUPNAME),$(MIRROR_REGEXP)); \
    9.61 -	  $(call OptionTrip,-linkoffline,$(MIRROR2COREAPI),$(COREAPI_DOCSDIR)); \
    9.62 -        ) >> $@
    9.63 -
    9.64 -# Create a file with the package names in it
    9.65 -$(MIRROR_PACKAGES_FILE): $(DIRECTORY_CACHE) $(call PackageDependencies,$(MIRROR_PKGS))
    9.66 -	$(prep-target)
    9.67 -	$(call PackageFilter,$(MIRROR_PKGS))
    9.68 -
    9.69 -#############################################################
    9.70 -#
    9.71  # docletapidocs
    9.72  #
    9.73  
    10.1 --- a/make/docs/NON_CORE_PKGS.gmk	Thu Feb 16 13:01:36 2012 -0800
    10.2 +++ b/make/docs/NON_CORE_PKGS.gmk	Sat Feb 18 16:11:47 2012 -0800
    10.3 @@ -1,5 +1,5 @@
    10.4  #
    10.5 -# Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
    10.6 +# Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
    10.7  # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    10.8  #
    10.9  # This code is free software; you can redistribute it and/or modify it
   10.10 @@ -71,11 +71,6 @@
   10.11  
   10.12  TAGLETAPI_FILE   = com/sun/tools/doclets/Taglet.java
   10.13  
   10.14 -MIRROR_PKGS      = com.sun.mirror.apt           \
   10.15 -                   com.sun.mirror.declaration   \
   10.16 -                   com.sun.mirror.type          \
   10.17 -                   com.sun.mirror.util
   10.18 -
   10.19  ATTACH_PKGS      = com.sun.tools.attach         \
   10.20                     com.sun.tools.attach.spi
   10.21  
    11.1 --- a/make/java/management/mapfile-vers	Thu Feb 16 13:01:36 2012 -0800
    11.2 +++ b/make/java/management/mapfile-vers	Sat Feb 18 16:11:47 2012 -0800
    11.3 @@ -54,9 +54,6 @@
    11.4  	    Java_sun_management_GcInfoBuilder_getLastGcInfo0;
    11.5  	    Java_sun_management_GcInfoBuilder_getNumGcExtAttributes;
    11.6  	    Java_sun_management_HotSpotDiagnostic_dumpHeap;
    11.7 -	    Java_sun_management_HotSpotDiagnostic_executeDiagnosticCommand0;
    11.8 -	    Java_sun_management_HotSpotDiagnostic_getDiagnosticCommandInfo0;
    11.9 -	    Java_sun_management_HotSpotDiagnostic_getDiagnosticCommands0;
   11.10  	    Java_sun_management_HotspotThread_getInternalThreadCount;
   11.11  	    Java_sun_management_HotspotThread_getInternalThreadTimes0;
   11.12  	    Java_sun_management_MemoryImpl_getMemoryManagers0;
    12.1 --- a/make/launchers/Makefile	Thu Feb 16 13:01:36 2012 -0800
    12.2 +++ b/make/launchers/Makefile	Sat Feb 18 16:11:47 2012 -0800
    12.3 @@ -1,5 +1,5 @@
    12.4  #
    12.5 -# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
    12.6 +# Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
    12.7  # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    12.8  #
    12.9  # This code is free software; you can redistribute it and/or modify it
   12.10 @@ -55,7 +55,6 @@
   12.11  
   12.12  define make-all-launchers
   12.13  $(make-appletviewer)
   12.14 -$(call make-launcher, apt, com.sun.tools.apt.Main, , )
   12.15  $(call make-launcher, extcheck, com.sun.tools.extcheck.Main, , )
   12.16  $(call make-launcher, idlj, com.sun.tools.corba.se.idl.toJavaPortable.Compile, , )
   12.17  $(call make-launcher, jar, sun.tools.jar.Main, , )
    13.1 --- a/make/launchers/Makefile.launcher	Thu Feb 16 13:01:36 2012 -0800
    13.2 +++ b/make/launchers/Makefile.launcher	Sat Feb 18 16:11:47 2012 -0800
    13.3 @@ -1,5 +1,5 @@
    13.4  #
    13.5 -# Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved.
    13.6 +# Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
    13.7  # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    13.8  #
    13.9  # This code is free software; you can redistribute it and/or modify it
   13.10 @@ -47,10 +47,6 @@
   13.11  endif
   13.12  
   13.13  # Some tools need the wildcard expansion option
   13.14 -ifeq ($(PROGRAM),apt)
   13.15 -  WILDCARDS=true
   13.16 -  NEVER_ACT_AS_SERVER_CLASS_MACHINE=true
   13.17 -endif
   13.18  ifeq ($(PROGRAM),javac)
   13.19    WILDCARDS=true
   13.20    MAIN_JAVA_ARGS += -J-Xss4m -J-ea:com.sun.tools...
    14.1 --- a/src/linux/doc/man/apt.1	Thu Feb 16 13:01:36 2012 -0800
    14.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.3 @@ -1,153 +0,0 @@
    14.4 -." Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
    14.5 -." DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    14.6 -."
    14.7 -." This code is free software; you can redistribute it and/or modify it
    14.8 -." under the terms of the GNU General Public License version 2 only, as
    14.9 -." published by the Free Software Foundation.
   14.10 -."
   14.11 -." This code is distributed in the hope that it will be useful, but WITHOUT
   14.12 -." ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   14.13 -." FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   14.14 -." version 2 for more details (a copy is included in the LICENSE file that
   14.15 -." accompanied this code).
   14.16 -."
   14.17 -." You should have received a copy of the GNU General Public License version
   14.18 -." 2 along with this work; if not, write to the Free Software Foundation,
   14.19 -." Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   14.20 -."
   14.21 -." Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   14.22 -." or visit www.oracle.com if you need additional information or have any
   14.23 -." questions.
   14.24 -."
   14.25 -.TH apt 1 "10 May 2011"
   14.26 -
   14.27 -.LP
   14.28 -.SH "NAME"
   14.29 -.LP
   14.30 -.LP
   14.31 -\f2apt\fP \- annotation processing tool
   14.32 -.LP
   14.33 -.SH "SYNOPSIS"
   14.34 -.LP
   14.35 -.LP
   14.36 -\f2apt [\-classpath \fP\f2classpath\fP] [\-sourcepath \f2sourcepath\fP] [\-d \f2directory\fP] [\-s \f2directory\fP] [\-factorypath \f2path\fP] [\-factory \f2class\fP] [\-print] [\-nocompile] [\-A\f2key\fP[\f2=val\fP] ...] [\f2javac option\fP] sourcefiles [@files]
   14.37 -.LP
   14.38 -.SH "PARAMETERS"
   14.39 -.LP
   14.40 -.LP
   14.41 -Options may be in any order. For a discussion of parameters which apply to a specific option, see OPTIONS below.
   14.42 -.LP
   14.43 -.RS 3
   14.44 -.TP 3
   14.45 -sourcefiles 
   14.46 -Zero or more source files to be processed. 
   14.47 -.TP 3
   14.48 -@files 
   14.49 -One or more files that list source files or other options 
   14.50 -.RE
   14.51 -
   14.52 -.LP
   14.53 -.SH "DESCRIPTION"
   14.54 -.LP
   14.55 -.LP
   14.56 -\f3Note\fP: The \f2apt\fP tool and its associated API contained in the package \f2com.sun.mirror\fP have been deprecated since JDK 7 and are planned to be removed in the next major JDK release. Use the options available in the \f2javac(1)\fP tool and the APIs contained in the packages \f2javax.annotation.processing\fP and \f2javax.lang.model\fP to process annotations.
   14.57 -.LP
   14.58 -.LP
   14.59 -The tool \f2apt\fP, annotation processing tool, includes reflective APIs and supporting infrastructure to process program annotations. The \f2apt\fP reflective APIs provide a build\-time, source\-based, read\-only view of program structure. These reflective APIs are designed to cleanly model the Java(TM) programming language's type system after the addition of generics. First, \f2apt\fP runs annotation processors that can produce new source code and other files. Next, \f2apt\fP can cause compilation of both original and generated source files, easing development. The reflective APIs and other APIs used to interact with the tool are subpackages of \f2com.sun.mirror\fP.
   14.60 -.LP
   14.61 -.LP
   14.62 -A fuller discussion of how the tool operates as well as instructions for developing with \f2apt\fP are in 
   14.63 -.na
   14.64 -\f4Getting Started with \fP\f4apt\fP. @
   14.65 -.fi
   14.66 -http://download.oracle.com/javase/7/docs/technotes/guides/apt/GettingStarted.html
   14.67 -.LP
   14.68 -.SH "OPTIONS"
   14.69 -.LP
   14.70 -.SS 
   14.71 -apt specific options
   14.72 -.LP
   14.73 -.RS 3
   14.74 -.TP 3
   14.75 -\-s dir 
   14.76 -Specify the directory root under which processor\-generated source files will be placed; files are placed in subdirectories based on package namespace. 
   14.77 -.TP 3
   14.78 -\-nocompile 
   14.79 -Do not compile source files to class files. 
   14.80 -.TP 3
   14.81 -\-print 
   14.82 -Print out textual representation of specified types; perform no annotation processing or compilation. 
   14.83 -.TP 3
   14.84 -\-A[key[=val]] 
   14.85 -Options to pass to annotation processors \-\- these are not interpreted by \f2apt\fP directly, but are made available for use by individual processors 
   14.86 -.TP 3
   14.87 -\-factorypath path 
   14.88 -Specify where to find annotation processor factories; if this option is used, the classpath is \f2not\fP searched for factories. 
   14.89 -.TP 3
   14.90 -\-factory classname 
   14.91 -Name of annotation processor factory to use; bypasses default discovery process 
   14.92 -.TP 3
   14.93 -\-version 
   14.94 -Print version information. 
   14.95 -.TP 3
   14.96 -\-X 
   14.97 -Display information about non\-standard options. 
   14.98 -.RE
   14.99 -
  14.100 -.LP
  14.101 -.SS 
  14.102 -Options shared with javac
  14.103 -.LP
  14.104 -.RS 3
  14.105 -.TP 3
  14.106 -\-d dir 
  14.107 -Specify where to place processor and javac generated class files 
  14.108 -.TP 3
  14.109 -\-cp path or \-classpath path 
  14.110 -Specify where to find user class files and annotation processor factories. If \f2\-factorypath\fP is given, the classpath is not searched for factories. 
  14.111 -.RE
  14.112 -
  14.113 -.LP
  14.114 -.LP
  14.115 -Consult the javac(1) man page for information on \f2javac\fP options.
  14.116 -.LP
  14.117 -.SS 
  14.118 -Non\-Standard Options
  14.119 -.LP
  14.120 -.RS 3
  14.121 -.TP 3
  14.122 -\-XListAnnotationTypes 
  14.123 -List found annotation types. 
  14.124 -.TP 3
  14.125 -\-XListDeclarations 
  14.126 -List specified and included declarations. 
  14.127 -.TP 3
  14.128 -\-XPrintAptRounds 
  14.129 -Print information about initial and recursive \f2apt\fP rounds. 
  14.130 -.TP 3
  14.131 -\-XPrintFactoryInfo 
  14.132 -Print information about which annotations a factory is asked to process. 
  14.133 -.TP 3
  14.134 -\-XclassesAsDecls 
  14.135 -Treat both class and source files as declarations to process. 
  14.136 -.RE
  14.137 -
  14.138 -.LP
  14.139 -.LP
  14.140 -\f3Note\fP: Because these options are non\-standard, they are subject to change without notice.
  14.141 -.LP
  14.142 -.SH "NOTES"
  14.143 -.LP
  14.144 -.LP
  14.145 -The \f2apt\fP tool and its associated API contained in the package \f2com.sun.mirror\fP have been deprecated since JDK 7 and are planned to be removed in the next major JDK release. Use the options available in the \f2javac(1)\fP tool and the APIs contained in the packages \f2javax.annotation.processing\fP and \f2javax.lang.model\fP to process annotations.
  14.146 -.LP
  14.147 -.SH "SEE ALSO"
  14.148 -.LP
  14.149 -.RS 3
  14.150 -.TP 2
  14.151 -o
  14.152 -javac(1), java(1) 
  14.153 -.RE
  14.154 -
  14.155 -.LP
  14.156 - 
    15.1 --- a/src/linux/doc/man/ja/apt.1	Thu Feb 16 13:01:36 2012 -0800
    15.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.3 @@ -1,153 +0,0 @@
    15.4 -." Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
    15.5 -." DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    15.6 -."
    15.7 -." This code is free software; you can redistribute it and/or modify it
    15.8 -." under the terms of the GNU General Public License version 2 only, as
    15.9 -." published by the Free Software Foundation.
   15.10 -."
   15.11 -." This code is distributed in the hope that it will be useful, but WITHOUT
   15.12 -." ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   15.13 -." FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   15.14 -." version 2 for more details (a copy is included in the LICENSE file that
   15.15 -." accompanied this code).
   15.16 -."
   15.17 -." You should have received a copy of the GNU General Public License version
   15.18 -." 2 along with this work; if not, write to the Free Software Foundation,
   15.19 -." Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   15.20 -."
   15.21 -." Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   15.22 -." or visit www.oracle.com if you need additional information or have any
   15.23 -." questions.
   15.24 -."
   15.25 -.TH apt 1 "07 May 2011"
   15.26 -
   15.27 -.LP
   15.28 -.SH "NAME"
   15.29 -.LP
   15.30 -.LP
   15.31 -\f2apt\fP \- Ãí¼á½èÍý¥Ä¡¼¥ë
   15.32 -.LP
   15.33 -.SH "·Á¼°"
   15.34 -.LP
   15.35 -.LP
   15.36 -\f2apt [\-classpath \fP\f2classpath\fP] [\-sourcepath \f2sourcepath\fP] [\-d \f2directory\fP] [\-s \f2directory\fP] [\-factorypath \f2path\fP] [\-factory \f2class\fP] [\-print] [\-nocompile] [\-A\f2key\fP[\f2=val\fP] ...] [\f2javac option\fP] sourcefiles [@files]
   15.37 -.LP
   15.38 -.SH "¥Ñ¥é¥á¡¼¥¿"
   15.39 -.LP
   15.40 -.LP
   15.41 -¥ª¥×¥·¥ç¥ó¤Î»ØÄê½ç½ø¤Ë·è¤Þ¤ê¤Ï¤¢¤ê¤Þ¤»¤ó¡£ÆÃÄê¤Î¥ª¥×¥·¥ç¥ó¤ËŬÍѤµ¤ì¤ë¥Ñ¥é¥á¡¼¥¿¤Ë¤Ä¤¤¤Æ¤Ï¡¢²¼µ­¤Î¡Ö¥ª¥×¥·¥ç¥ó¡×¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£
   15.42 -.LP
   15.43 -.RS 3
   15.44 -.TP 3
   15.45 -sourcefiles 
   15.46 -¥¼¥í¡¢1 ¤Ä¡¢¤Þ¤¿¤ÏÊ£¿ô¤Î½èÍýÂоݤΥ½¡¼¥¹¥Õ¥¡¥¤¥ë 
   15.47 -.TP 3
   15.48 -@files 
   15.49 -¥½¡¼¥¹¥Õ¥¡¥¤¥ë¤Þ¤¿¤Ï¾¤Î¥ª¥×¥·¥ç¥ó¤ò°ìÍ÷ɽ¼¨¤¹¤ë 1 ¤Ä¤Þ¤¿¤ÏÊ£¿ô¤Î¥Õ¥¡¥¤¥ë 
   15.50 -.RE
   15.51 -
   15.52 -.LP
   15.53 -.SH "ÀâÌÀ"
   15.54 -.LP
   15.55 -.LP
   15.56 -\f3Ãí\fP: \f2apt\fP ¥Ä¡¼¥ë¤È¡¢¥Ñ¥Ã¥±¡¼¥¸ \f2com.sun.mirror\fP ¤Ë´Þ¤Þ¤ì¤Æ¤¤¤ë¤½¤ì¤Ë´ØÏ¢¤·¤¿ API ¤Ï¡¢JDK 7 °Ê¹ßÈó¿ä¾©¤Ë¤Ê¤Ã¤Æ¤ª¤ê¡¢JDK ¤Î¼¡¤Î¥á¥¸¥ã¡¼¥ê¥ê¡¼¥¹¤Çºï½ü¤µ¤ì¤ëͽÄê¤Ç¤¹¡£\f2javac(1)\fP ¥Ä¡¼¥ë¤ÇÍøÍѲÄǽ¤Ê¥ª¥×¥·¥ç¥ó¤È¡¢¥Ñ¥Ã¥±¡¼¥¸ \f2javax.annotation.processing\fP ¤ª¤è¤Ó \f2javax.lang.model\fP ¤Ë´Þ¤Þ¤ì¤Æ¤¤¤ë API ¤ò»ÈÍѤ·¤Æ¡¢Ãí¼á¤ò½èÍý¤·¤Æ¤¯¤À¤µ¤¤¡£
   15.57 -.LP
   15.58 -.LP
   15.59 -Ãí¼á½èÍý¥Ä¡¼¥ë \f2apt\fP ¤Ï¡¢¥ê¥Õ¥ì¥¯¥È API ¤È¥µ¥Ý¡¼¥È¥¤¥ó¥Õ¥é¥¹¥È¥é¥¯¥Á¥ã¡¼¤«¤é¹½À®¤µ¤ì¡¢¥×¥í¥°¥é¥àÃí¼á¤ò½èÍý¤·¤Þ¤¹¡£\f2apt\fP ¥ê¥Õ¥ì¥¯¥È API ¤Ï¡¢ ¹½ÃÛ»þ¤Î¥½¡¼¥¹¥Ù¡¼¥¹¤Ç¡¢¥×¥í¥°¥é¥à¹½Â¤¤Ë´Ø¤¹¤ëÆɤ߼è¤êÀìÍѥӥ塼¤òÄ󶡤·¤Þ¤¹¡£¤³¤ì¤é¤Î¥ê¥Õ¥ì¥¯¥È API ¤Ï¡¢Áí¾Î¤òÄɲä·¤¿¸å¤Ë¡¢Java(TM) ¥×¥í¥°¥é¥ß¥ó¥°¸À¸ì¤Î·¿¥·¥¹¥Æ¥à¤òÀµ¤·¤¯¥â¥Ç¥ë²½¤¹¤ë¤è¤¦¤ËÀ߷פµ¤ì¤Æ¤¤¤Þ¤¹¡£ºÇ½é¤Ë¡¢\f2apt\fP ¤Ï¡¢¿·¤·¤¤¥½¡¼¥¹¥³¡¼¥É¤È¾¤Î¥Õ¥¡¥¤¥ë¤òºîÀ®¤¹¤ëÃí¼á¥×¥í¥»¥Ã¥µ¤ò¼Â¹Ô¤·¤Þ¤¹¡£¼¡¤Ë¡¢\f2apt\fP ¤Ï¡¢¸µ¤Î¥½¡¼¥¹¥Õ¥¡¥¤¥ë¤ÈÀ¸À®¤·¤¿¥½¡¼¥¹¥Õ¥¡¥¤¥ë¤ÎξÊý¤ò¥³¥ó¥Ñ¥¤¥ë¤¹¤ë¤¿¤á¡¢³«È¯¤¬³Ú¤Ë¤Ê¤ê¤Þ¤¹¡£¥Ä¡¼¥ë¤È¤Î¥¤¥ó¥¿¥Õ¥§¡¼¥¹¤Ë»ÈÍѤµ¤ì¤ë¥ê¥Õ¥ì¥¯¥È API ¤Ê¤É¤Î API ¤Ï¡¢\f2com.sun.mirror\fP ¤Î¥µ¥Ö¥Ñ¥Ã¥±¡¼¥¸¤Ç¤¹¡£
   15.60 -.LP
   15.61 -.LP
   15.62 -¥Ä¡¼¥ë¤Îµ¡Ç½¤Ë´Ø¤¹¤ë¾ÜºÙ¤È¡¢\f2apt\fP ¤ò»ÈÍѤ·¤¿³«È¯ÊýË¡¤Ë¤Ä¤¤¤Æ¤Ï¡¢
   15.63 -.na
   15.64 -\f4¡Öapt ÆþÌç¡×\fP @
   15.65 -.fi
   15.66 -http://java.sun.com/javase/6/docs/technotes/guides/apt/GettingStarted.html¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£
   15.67 -.LP
   15.68 -.SH "¥ª¥×¥·¥ç¥ó"
   15.69 -.LP
   15.70 -.SS 
   15.71 -apt ¸ÇÍ­¤Î¥ª¥×¥·¥ç¥ó
   15.72 -.LP
   15.73 -.RS 3
   15.74 -.TP 3
   15.75 -\-s dir 
   15.76 -¥×¥í¥»¥Ã¥µ¤ÎÀ¸À®¤¹¤ë¥½¡¼¥¹¥Õ¥¡¥¤¥ë¤òÃÖ¤¯¥Ç¥£¥ì¥¯¥È¥ê¥ë¡¼¥È¤ò»ØÄꤷ¤Þ¤¹¡£ ¥Õ¥¡¥¤¥ë¤Ï¡¢¥Ñ¥Ã¥±¡¼¥¸¤Î̾Á°¶õ´Ö¤Ë´ð¤Å¤¤¤Æ¥µ¥Ö¥Ç¥£¥ì¥¯¥È¥ê¤ËÃÖ¤«¤ì¤Þ¤¹¡£ 
   15.77 -.TP 3
   15.78 -\-nocompile 
   15.79 -¥½¡¼¥¹¥Õ¥¡¥¤¥ë¤ò¥¯¥é¥¹¥Õ¥¡¥¤¥ë¤Ë¥³¥ó¥Ñ¥¤¥ë¤·¤Þ¤»¤ó¡£ 
   15.80 -.TP 3
   15.81 -\-print 
   15.82 -»ØÄꤷ¤¿¥¿¥¤¥×¤Î¥Æ¥­¥¹¥Èɽ¸½¤ò½ÐÎϤ·¤Þ¤¹¡£ Ãí¼á½èÍý¤Þ¤¿¤Ï¥³¥ó¥Ñ¥¤¥ë¤Ï¹Ô¤¤¤Þ¤»¤ó¡£ 
   15.83 -.TP 3
   15.84 -\-A[key[=val]] 
   15.85 -Ãí¼á¥×¥í¥»¥Ã¥µ¤ØÅϤ¹¥ª¥×¥·¥ç¥ó¤Ç¤¹¡£ ¤³¤Î¥ª¥×¥·¥ç¥ó¤Ï¡¢\f2apt\fP ¤¬Ä¾Àܲò¼á¤¹¤ë¤Î¤Ç¤Ï¤Ê¤¯¡¢¤½¤ì¤¾¤ì¤Î¥×¥í¥»¥Ã¥µ¤Ë¤è¤Ã¤Æ»ÈÍѤǤ­¤ë¤è¤¦¤ËÊѤ¨¤é¤ì¤Þ¤¹¡£ 
   15.86 -.TP 3
   15.87 -\-factorypath path 
   15.88 -Ãí¼á¥×¥í¥»¥Ã¥µ¥Õ¥¡¥¯¥È¥ê¤ò¸¡º÷¤¹¤ë¾ì½ê¤ò»ØÄꤷ¤Þ¤¹¡£ ¤³¤Î¥ª¥×¥·¥ç¥ó¤ò»ÈÍѤ¹¤ë¾ì¹ç¡¢¥¯¥é¥¹¥Ñ¥¹¤Î¥Õ¥¡¥¯¥È¥ê¤Ï¸¡º÷¤µ¤ì¤Þ¤»¤ó¡£ 
   15.89 -.TP 3
   15.90 -\-factory classname 
   15.91 -»ÈÍѤ¹¤ëÃí¼á¥×¥í¥»¥Ã¥µ¥Õ¥¡¥¯¥È¥ê¤Î̾Á°¤Ç¤¹¡£ ¥Ç¥Õ¥©¥ë¥È¤Î¸¡½Ð¥×¥í¥»¥¹¤ò¾Êά¤·¤Þ¤¹¡£ 
   15.92 -.TP 3
   15.93 -\-version 
   15.94 -¥Ð¡¼¥¸¥ç¥ó¾ðÊó¤ò½ÐÎϤ·¤Þ¤¹¡£ 
   15.95 -.TP 3
   15.96 -\-X 
   15.97 -Èóɸ½à¥ª¥×¥·¥ç¥ó¤Ë´Ø¤¹¤ë¾ðÊó¤òɽ¼¨¤·¤Þ¤¹¡£ 
   15.98 -.RE
   15.99 -
  15.100 -.LP
  15.101 -.SS 
  15.102 -javac ¤È¶¦ÍѤ¹¤ë¥ª¥×¥·¥ç¥ó
  15.103 -.LP
  15.104 -.RS 3
  15.105 -.TP 3
  15.106 -\-d dir 
  15.107 -¥×¥í¥»¥Ã¥µ¤È javac À¸À®¤Î¥¯¥é¥¹¥Õ¥¡¥¤¥ë¤òÃÖ¤¯¾ì½ê¤ò»ØÄꤷ¤Þ¤¹¡£ 
  15.108 -.TP 3
  15.109 -\-cp path ¤Þ¤¿¤Ï \-classpath path 
  15.110 -¥æ¡¼¥¶¡¼¥¯¥é¥¹¥Õ¥¡¥¤¥ë¤ÈÃí¼á¥×¥í¥»¥Ã¥µ¥Õ¥¡¥¯¥È¥ê¤ò¸¡º÷¤¹¤ë¾ì½ê¤ò»ØÄꤷ¤Þ¤¹¡£\f2\-factorypath\fP ¤¬»ØÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¡¢¥¯¥é¥¹¥Ñ¥¹¤Î¥Õ¥¡¥¯¥È¥ê¤Ï¸¡º÷¤µ¤ì¤Þ¤»¤ó¡£ 
  15.111 -.RE
  15.112 -
  15.113 -.LP
  15.114 -.LP
  15.115 -\f2javac\fP ¥ª¥×¥·¥ç¥ó¤Î¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï¡¢javac(1) ¤Î¥Þ¥Ë¥å¥¢¥ë¥Ú¡¼¥¸¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£
  15.116 -.LP
  15.117 -.SS 
  15.118 -Èóɸ½à¥ª¥×¥·¥ç¥ó
  15.119 -.LP
  15.120 -.RS 3
  15.121 -.TP 3
  15.122 -\-XListAnnotationTypes 
  15.123 -Ãí¼á¤Î·¿¤Ë¸¡½Ð¤µ¤ì¤ë¥ê¥¹¥È. 
  15.124 -.TP 3
  15.125 -\-XListDeclarations 
  15.126 -»ØÄꤪ¤è¤ÓÀë¸À¤¬¥¤¥ó¥¯¥ë¡¼¥É¤µ¤ì¤ë¥ê¥¹¥È. 
  15.127 -.TP 3
  15.128 -\-XPrintAptRounds 
  15.129 -½é´ü¤ª¤è¤ÓºÆµ¢Åª¤Ê \f2apt\fP ¥é¥¦¥ó¥É¤Ë´Ø¤¹¤ë¾ðÊó¤ò½ÐÎϤ¹¤ë. 
  15.130 -.TP 3
  15.131 -\-XPrintFactoryInfo 
  15.132 -½èÍý¤òÍ׵᤹¤ë¥Õ¥¡¥¯¥È¥ê¤ÎÃí¼á¤Ë´Ø¤¹¤ë¾ðÊó¤ò½ÐÎϤ¹¤ë. 
  15.133 -.TP 3
  15.134 -\-XclassesAsDecls 
  15.135 -¥¯¥é¥¹¥Õ¥¡¥¤¥ë¤È¥½¡¼¥¹¥Õ¥¡¥¤¥ë¤ÎξÊý¤ò¡¢½èÍýÂоݤÎÀë¸À¤È¤·¤Æ½èÍý¤·¤Þ¤¹¡£ 
  15.136 -.RE
  15.137 -
  15.138 -.LP
  15.139 -.LP
  15.140 -\f3Ãí\fP: ¤³¤ì¤é¤ÏÈóɸ½à¥ª¥×¥·¥ç¥ó¤Ê¤Î¤Ç¡¢Í½¹ð¤Ê¤¯Êѹ¹¤µ¤ì¤ë²ÄǽÀ­¤¬¤¢¤ê¤Þ¤¹¡£
  15.141 -.LP
  15.142 -.SH "Ãí"
  15.143 -.LP
  15.144 -.LP
  15.145 -\f2apt\fP ¥Ä¡¼¥ë¤È¡¢¥Ñ¥Ã¥±¡¼¥¸ \f2com.sun.mirror\fP ¤Ë´Þ¤Þ¤ì¤Æ¤¤¤ë¤½¤ì¤Ë´ØÏ¢¤·¤¿ API ¤Ï¡¢JDK 7 °Ê¹ßÈó¿ä¾©¤Ë¤Ê¤Ã¤Æ¤ª¤ê¡¢JDK ¤Î¼¡¤Î¥á¥¸¥ã¡¼¥ê¥ê¡¼¥¹¤Çºï½ü¤µ¤ì¤ëͽÄê¤Ç¤¹¡£\f2javac(1)\fP ¥Ä¡¼¥ë¤ÇÍøÍѲÄǽ¤Ê¥ª¥×¥·¥ç¥ó¤È¡¢¥Ñ¥Ã¥±¡¼¥¸ \f2javax.annotation.processing\fP ¤ª¤è¤Ó \f2javax.lang.model\fP ¤Ë´Þ¤Þ¤ì¤Æ¤¤¤ë API ¤ò»ÈÍѤ·¤Æ¡¢Ãí¼á¤ò½èÍý¤·¤Æ¤¯¤À¤µ¤¤¡£
  15.146 -.LP
  15.147 -.SH "´ØÏ¢¹àÌÜ"
  15.148 -.LP
  15.149 -.RS 3
  15.150 -.TP 2
  15.151 -o
  15.152 -javac(1), java(1) 
  15.153 -.RE
  15.154 -
  15.155 -.LP
  15.156 - 
    16.1 --- a/src/share/classes/com/sun/crypto/provider/PBEKey.java	Thu Feb 16 13:01:36 2012 -0800
    16.2 +++ b/src/share/classes/com/sun/crypto/provider/PBEKey.java	Sat Feb 18 16:11:47 2012 -0800
    16.3 @@ -55,9 +55,12 @@
    16.4              // Should allow an empty password.
    16.5              passwd = new char[0];
    16.6          }
    16.7 -        for (int i=0; i<passwd.length; i++) {
    16.8 -            if ((passwd[i] < '\u0020') || (passwd[i] > '\u007E')) {
    16.9 -                throw new InvalidKeySpecException("Password is not ASCII");
   16.10 +        // Accept "\0" to signify "zero-length password with no terminator".
   16.11 +        if (!(passwd.length == 1 && passwd[0] == 0)) {
   16.12 +            for (int i=0; i<passwd.length; i++) {
   16.13 +                if ((passwd[i] < '\u0020') || (passwd[i] > '\u007E')) {
   16.14 +                    throw new InvalidKeySpecException("Password is not ASCII");
   16.15 +                }
   16.16              }
   16.17          }
   16.18          this.key = new byte[passwd.length];
    17.1 --- a/src/share/classes/com/sun/crypto/provider/PKCS12PBECipherCore.java	Thu Feb 16 13:01:36 2012 -0800
    17.2 +++ b/src/share/classes/com/sun/crypto/provider/PKCS12PBECipherCore.java	Sat Feb 18 16:11:47 2012 -0800
    17.3 @@ -60,11 +60,16 @@
    17.4  
    17.5      static byte[] derive(char[] chars, byte[] salt,
    17.6                           int ic, int n, int type) {
    17.7 -        // Add in trailing NULL terminator.
    17.8 +        // Add in trailing NULL terminator.  Special case:
    17.9 +        // no terminator if password is "\0".
   17.10          int length = chars.length*2;
   17.11 -        if (length != 0) {
   17.12 +        if (length == 2 && chars[0] == 0) {
   17.13 +            chars = new char[0];
   17.14 +            length = 0;
   17.15 +        } else {
   17.16              length += 2;
   17.17          }
   17.18 +
   17.19          byte[] passwd = new byte[length];
   17.20          for (int i = 0, j = 0; i < chars.length; i++, j+=2) {
   17.21              passwd[j] = (byte) ((chars[i] >>> 8) & 0xFF);
   17.22 @@ -133,6 +138,9 @@
   17.23      }
   17.24  
   17.25      private static void concat(byte[] src, byte[] dst, int start, int len) {
   17.26 +        if (src.length == 0) {
   17.27 +            return;
   17.28 +        }
   17.29          int loop = len / src.length;
   17.30          int off, i;
   17.31          for (i = 0, off = 0; i < loop; i++, off += src.length)
    18.1 --- a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsProgressBarUI.java	Thu Feb 16 13:01:36 2012 -0800
    18.2 +++ b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsProgressBarUI.java	Sat Feb 18 16:11:47 2012 -0800
    18.3 @@ -137,6 +137,11 @@
    18.4                  g.setColor(progressBar.getForeground());
    18.5                  barRectHeight -= 2;
    18.6                  barRectWidth -= 2;
    18.7 +
    18.8 +                if (barRectWidth <= 0 || barRectHeight <= 0) {
    18.9 +                    return;
   18.10 +                }
   18.11 +
   18.12                  Graphics2D g2 = (Graphics2D)g;
   18.13                  g2.setStroke(new BasicStroke((float)(vertical ? barRectWidth : barRectHeight),
   18.14                                               BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
    19.1 --- a/src/share/classes/com/sun/management/DiagnosticCommandArgumentInfo.java	Thu Feb 16 13:01:36 2012 -0800
    19.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.3 @@ -1,151 +0,0 @@
    19.4 -/*
    19.5 - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
    19.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    19.7 - *
    19.8 - * This code is free software; you can redistribute it and/or modify it
    19.9 - * under the terms of the GNU General Public License version 2 only, as
   19.10 - * published by the Free Software Foundation.  Oracle designates this
   19.11 - * particular file as subject to the "Classpath" exception as provided
   19.12 - * by Oracle in the LICENSE file that accompanied this code.
   19.13 - *
   19.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   19.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   19.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   19.17 - * version 2 for more details (a copy is included in the LICENSE file that
   19.18 - * accompanied this code).
   19.19 - *
   19.20 - * You should have received a copy of the GNU General Public License version
   19.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   19.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   19.23 - *
   19.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   19.25 - * or visit www.oracle.com if you need additional information or have any
   19.26 - * questions.
   19.27 - */
   19.28 -
   19.29 -package com.sun.management;
   19.30 -
   19.31 -import java.beans.ConstructorProperties;
   19.32 -
   19.33 -/**
   19.34 - * Diagnostic Command Argument information. It contains the description
   19.35 - * of one parameter of the diagnostic command. A parameter can either be an
   19.36 - * option or an argument. Options are identified by the option name while
   19.37 - * arguments are identified by their position in the command line. The generic
   19.38 - * syntax of a diagnostic command is:
   19.39 - *  <blockquote>
   19.40 - *    &lt;command name&gt; [&lt;option&gt;=&lt;value&gt;] [&lt;argument_value&gt;]
   19.41 - * </blockquote>
   19.42 - * Example:
   19.43 - * <blockquote>
   19.44 - * command_name option1=value1 option2=value argumentA argumentB argumentC
   19.45 - * </blockquote>
   19.46 - * In this command line, the diagnostic command receives five parameters, two
   19.47 - * options named {@code option1} and {@code option2}, and three arguments.
   19.48 - * argumentA's position is 0, argumentB's position is 1 and argumentC's
   19.49 - * position is 2.
   19.50 - *
   19.51 - * @author  Frederic Parain
   19.52 - * @since   7u4
   19.53 - */
   19.54 -
   19.55 -public class DiagnosticCommandArgumentInfo {
   19.56 -    private final String name;
   19.57 -    private final String description;
   19.58 -    private final String type;
   19.59 -    private final String defaultValue;
   19.60 -    private final boolean mandatory;
   19.61 -    private final boolean option;
   19.62 -    private final int position;
   19.63 -
   19.64 -    /**
   19.65 -     * Returns the argument name
   19.66 -     *
   19.67 -     * @return the argument name
   19.68 -     */
   19.69 -    public String getName() {
   19.70 -        return name;
   19.71 -    }
   19.72 -
   19.73 -   /**
   19.74 -     * Returns the argument description
   19.75 -     *
   19.76 -     * @return the argument description
   19.77 -     */
   19.78 -    public String getDescription() {
   19.79 -        return description;
   19.80 -    }
   19.81 -
   19.82 -    /**
   19.83 -     * Returns the argument type
   19.84 -     *
   19.85 -     * @return the argument type
   19.86 -     */
   19.87 -    public String getType() {
   19.88 -        return type;
   19.89 -    }
   19.90 -
   19.91 -    /**
   19.92 -     * Returns the default value as a String if a default value
   19.93 -     * is defined, null otherwise.
   19.94 -     *
   19.95 -     * @return the default value as a String if a default value
   19.96 -     * is defined, null otherwise.
   19.97 -     */
   19.98 -    public String getDefault() {
   19.99 -        return defaultValue;
  19.100 -    }
  19.101 -
  19.102 -    /**
  19.103 -     * Returns {@code true} if the argument is mandatory,
  19.104 -     *         {@code false} otherwise
  19.105 -     *
  19.106 -     * @return {@code true} if the argument is mandatory,
  19.107 -     *         {@code false} otherwise
  19.108 -     */
  19.109 -    public boolean isMandatory() {
  19.110 -        return mandatory;
  19.111 -    }
  19.112 -
  19.113 -    /**
  19.114 -     * Returns {@code true} if the argument is an option,
  19.115 -     *         {@code false} otherwise. Options have to be specified using the
  19.116 -     *         &lt;key&gt;=&lt;value&gt; syntax on the command line, while other
  19.117 -     *         arguments are specified with a single &lt;value&gt; field and are
  19.118 -     *         identified by their position on command line.
  19.119 -     *
  19.120 -     * @return {@code true} if the argument is an option,
  19.121 -     *         {@code false} otherwise
  19.122 -     */
  19.123 -    public boolean isOption() {
  19.124 -        return option;
  19.125 -    }
  19.126 -
  19.127 -    /**
  19.128 -     * Returns the expected position of this argument if it is not an option,
  19.129 -     *         -1 otherwise. Argument position if defined from left to right,
  19.130 -     *         starting at zero and ignoring the diagnostic command name and
  19.131 -     *         options.
  19.132 -     *
  19.133 -     * @return the expected position of this argument if it is not an option,
  19.134 -     *         -1 otherwise.
  19.135 -     */
  19.136 -    public int getPosition() {
  19.137 -        return position;
  19.138 -    }
  19.139 -
  19.140 -    @ConstructorProperties({"name","description","type","default",
  19.141 -                "mandatory","option","position"})
  19.142 -    public DiagnosticCommandArgumentInfo(String name, String description,
  19.143 -                                         String type, String defaultValue,
  19.144 -                                         boolean mandatory, boolean option,
  19.145 -                                         int position) {
  19.146 -        this.name = name;
  19.147 -        this.description = description;
  19.148 -        this.type = type;
  19.149 -        this.defaultValue = defaultValue;
  19.150 -        this.mandatory = mandatory;
  19.151 -        this.option = option;
  19.152 -        this.position = position;
  19.153 -    }
  19.154 -}
    20.1 --- a/src/share/classes/com/sun/management/DiagnosticCommandInfo.java	Thu Feb 16 13:01:36 2012 -0800
    20.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.3 @@ -1,110 +0,0 @@
    20.4 -/*
    20.5 - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
    20.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    20.7 - *
    20.8 - * This code is free software; you can redistribute it and/or modify it
    20.9 - * under the terms of the GNU General Public License version 2 only, as
   20.10 - * published by the Free Software Foundation.  Oracle designates this
   20.11 - * particular file as subject to the "Classpath" exception as provided
   20.12 - * by Oracle in the LICENSE file that accompanied this code.
   20.13 - *
   20.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   20.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   20.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   20.17 - * version 2 for more details (a copy is included in the LICENSE file that
   20.18 - * accompanied this code).
   20.19 - *
   20.20 - * You should have received a copy of the GNU General Public License version
   20.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   20.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   20.23 - *
   20.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   20.25 - * or visit www.oracle.com if you need additional information or have any
   20.26 - * questions.
   20.27 - */
   20.28 -
   20.29 -package com.sun.management;
   20.30 -
   20.31 -import java.beans.ConstructorProperties;
   20.32 -import java.util.List;
   20.33 -
   20.34 -/**
   20.35 - * Diagnostic command information. It contains the description of a
   20.36 - * diagnostic command.
   20.37 - *
   20.38 - * @author  Frederic Parain
   20.39 - * @since   7u4
   20.40 - */
   20.41 -
   20.42 -public class DiagnosticCommandInfo {
   20.43 -    private final String name;
   20.44 -    private final String description;
   20.45 -    private final String impact;
   20.46 -    private final boolean enabled;
   20.47 -    private final List<DiagnosticCommandArgumentInfo> arguments;
   20.48 -
   20.49 -    /**
   20.50 -     * Returns the diagnostic command name
   20.51 -     *
   20.52 -     * @return the diagnostic command name
   20.53 -     */
   20.54 -    public String getName() {
   20.55 -        return name;
   20.56 -    }
   20.57 -
   20.58 -   /**
   20.59 -     * Returns the diagnostic command description
   20.60 -     *
   20.61 -     * @return the diagnostic command description
   20.62 -     */
   20.63 -    public String getDescription() {
   20.64 -        return description;
   20.65 -    }
   20.66 -
   20.67 -     /**
   20.68 -     * Returns the potential impact of the diagnostic command execution
   20.69 -     *         on the Java virtual machine behavior
   20.70 -     *
   20.71 -     * @return the potential impact of the diagnostic command execution
   20.72 -     *         on the Java virtual machine behavior
   20.73 -     */
   20.74 -    public String getImpact() {
   20.75 -        return impact;
   20.76 -    }
   20.77 -
   20.78 -    /**
   20.79 -     * Returns {@code true} if the diagnostic command is enabled,
   20.80 -     *         {@code false} otherwise. The enabled/disabled
   20.81 -     *         status of a diagnostic command can evolve during
   20.82 -     *         the lifetime of the Java virtual machine.
   20.83 -     *
   20.84 -     * @return {@code true} if the diagnostic command is enabled,
   20.85 -     *         {@code false} otherwise
   20.86 -     */
   20.87 -    public boolean isEnabled() {
   20.88 -        return enabled;
   20.89 -    }
   20.90 -
   20.91 -    /**
   20.92 -     * Returns the list of the diagnostic command arguments description.
   20.93 -     * If the diagnostic command has no arguments, it returns an empty list.
   20.94 -     *
   20.95 -     * @return a list of the diagnostic command arguments description
   20.96 -     */
   20.97 -    public List<DiagnosticCommandArgumentInfo> getArgumentsInfo() {
   20.98 -        return arguments;
   20.99 -    }
  20.100 -
  20.101 -    @ConstructorProperties({"name", "description","impact","enabled",
  20.102 -                "argumentsInfo"})
  20.103 -    public DiagnosticCommandInfo(String name, String description,
  20.104 -                                 String impact, boolean enabled,
  20.105 -                                 List<DiagnosticCommandArgumentInfo> arguments)
  20.106 -    {
  20.107 -        this.name = name;
  20.108 -        this.description = description;
  20.109 -        this.impact = impact;
  20.110 -        this.enabled = enabled;
  20.111 -        this.arguments = arguments;
  20.112 -    }
  20.113 -}
    21.1 --- a/src/share/classes/com/sun/management/HotSpotDiagnosticMXBean.java	Thu Feb 16 13:01:36 2012 -0800
    21.2 +++ b/src/share/classes/com/sun/management/HotSpotDiagnosticMXBean.java	Sat Feb 18 16:11:47 2012 -0800
    21.3 @@ -1,5 +1,5 @@
    21.4  /*
    21.5 - * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
    21.6 + * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
    21.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    21.8   *
    21.9   * This code is free software; you can redistribute it and/or modify it
   21.10 @@ -31,11 +31,6 @@
   21.11  /**
   21.12   * Diagnostic management interface for the HotSpot Virtual Machine.
   21.13   *
   21.14 - * <p>{@linkplain #getDiagnosticCommands Diagnostic commands}
   21.15 - * are actions that can be invoked dynamically and
   21.16 - * executed in a target Java virtual machine, mainly for troubleshooting
   21.17 - * and diagnosis.
   21.18 - *
   21.19   * <p>The diagnostic MBean is registered to the platform MBeanServer
   21.20   * as are other platform MBeans.
   21.21   *
   21.22 @@ -116,108 +111,4 @@
   21.23       *     ManagementPermission("control").
   21.24       */
   21.25      public void setVMOption(String name, String value);
   21.26 -
   21.27 -    /**
   21.28 -     * Returns the {@linkplain DiagnosticCommandInfo#getName() names}
   21.29 -     * of all diagnostic commands.
   21.30 -     * A diagnostic command is an action that can be invoked dynamically
   21.31 -     * mainly for troubleshooting and diagnosis.  The list of diagnostic
   21.32 -     * commands may change at runtime.  A diagnostic command may be
   21.33 -     * {@linkplain DiagnosticCommandInfo#isEnabled disabled} but will
   21.34 -     * not be removed from a previously returned list.
   21.35 -     *
   21.36 -     * @return the names of all diagnostic commands.
   21.37 -     *
   21.38 -     * @since 7u4
   21.39 -     */
   21.40 -    public List<String> getDiagnosticCommands();
   21.41 -
   21.42 -    /**
   21.43 -     * Returns a {@code DiagnosticCommandInfo} object describing the
   21.44 -     * diagnostic command of the specified name {@code command}
   21.45 -     *
   21.46 -     * @param command a diagnostic command name
   21.47 -     * @return a {@code DiagnosticCommandInfo} object
   21.48 -     * @throws java.lang.IllegalArgumentException if the {@code command}
   21.49 -     *         doesn't match any diagnostic command registered in the
   21.50 -     *         targeted Java virtual machine.
   21.51 -     *
   21.52 -     * @since 7u4
   21.53 -     */
   21.54 -    public DiagnosticCommandInfo getDiagnosticCommandInfo(String command);
   21.55 -
   21.56 -    /**
   21.57 -     * Returns a list of {@code DiagnosticCommandInfo} object describing
   21.58 -     * all diagnostic commands available on the targeted Java virtual machine
   21.59 -     *
   21.60 -     * @return a list of {@code DiagnosticCommandInfo} objects
   21.61 -     *
   21.62 -     * @since 7u4
   21.63 -     */
   21.64 -    public List<DiagnosticCommandInfo> getDiagnosticCommandInfo();
   21.65 -
   21.66 -    /**
   21.67 -     * Returns a list of {@code DiagnosticCommandInfo} object describing
   21.68 -     * all diagnostic commands specified in the {@code commands} list.
   21.69 -     *
   21.70 -     * @param commands {@code List} of {@code String} containing diagnostic
   21.71 -     *        command names
   21.72 -     * @return a {@code List} of {@code DiagnosticCommandInfo} objects
   21.73 -     *
   21.74 -     * @throws java.lang.IllegalArgumentException if at least one
   21.75 -     *         command specified in the {@code commands } list
   21.76 -     *         doesn't match any diagnostic command registered in the
   21.77 -     *         targeted Java virtual machine.
   21.78 -     *
   21.79 -     * @since 7u4
   21.80 -     */
   21.81 -    public List<DiagnosticCommandInfo> getDiagnosticCommandInfo(List<String> commands);
   21.82 -
   21.83 -    /**
   21.84 -     * Executes the command line {@code commandLine}. The command line must
   21.85 -     * start with a diagnostic command name, optionally followed by parameters.
   21.86 -     * Each command has its own syntax but the generic syntax for a diagnostic
   21.87 -     * command line is:
   21.88 -     * <blockquote>
   21.89 -     *    &lt;command name&gt; [&lt;option&gt;=&lt;value&gt;] [&lt;argument_value&gt;]
   21.90 -     * </blockquote>
   21.91 -     *
   21.92 -     * @param commandLine command line to execute
   21.93 -     * @return a {@code String} object containing the diagnostic command
   21.94 -     *         output.
   21.95 -     *
   21.96 -     * @throws java.lang.IllegalArgumentException if the command line doesn't
   21.97 -     *         match any diagnostic command registered in the virtual machine
   21.98 -     *         of if the parameters don't match the diagnostic command syntax.
   21.99 -     * @throws java.lang.SecurityException
  21.100 -     *         if a security manager exists and the caller does not have
  21.101 -     *         ManagementPermission("control").
  21.102 -     *
  21.103 -     * @since 7u4
  21.104 -     */
  21.105 -    public String execute(String commandLine);
  21.106 -
  21.107 -    /**
  21.108 -     * Invokes the diagnostic command named {@code cmd} with the parameters
  21.109 -     * specified in {@code args}. Each command has its own syntax but
  21.110 -     * the generic syntax for parameters is:
  21.111 -     * <blockquote>
  21.112 -     *    [&lt;option&gt;=&lt;value&gt;] [&lt;argument_value&gt;]
  21.113 -     * </blockquote>
  21.114 -     *
  21.115 -     * @param cmd a diagnostic command name
  21.116 -     * @param args the command parameters
  21.117 -     * @return a {@code String} object containing the diagnostic command
  21.118 -     *         output.
  21.119 -     *
  21.120 -     * @throws java.lang.IllegalArgumentException if the command line doesn't
  21.121 -     *         match any diagnostic command registered in the virtual machine
  21.122 -     *         of if the parameters don't match the diagnostic command syntax.
  21.123 -     * @throws java.lang.SecurityException
  21.124 -     *         if a security manager exists and the caller does not have
  21.125 -     *         ManagementPermission("control").
  21.126 -     *
  21.127 -     * @since 7u4
  21.128 -     */
  21.129 -    public String execute(String cmd, String... args);
  21.130  }
    22.1 --- a/src/share/classes/com/sun/nio/sctp/MessageInfo.java	Thu Feb 16 13:01:36 2012 -0800
    22.2 +++ b/src/share/classes/com/sun/nio/sctp/MessageInfo.java	Sat Feb 18 16:11:47 2012 -0800
    22.3 @@ -94,7 +94,7 @@
    22.4          if (streamNumber < 0 || streamNumber > 65536)
    22.5              throw new IllegalArgumentException("Invalid stream number");
    22.6  
    22.7 -        return new sun.nio.ch.SctpMessageInfoImpl(null, address, streamNumber);
    22.8 +        return new sun.nio.ch.sctp.MessageInfoImpl(null, address, streamNumber);
    22.9      }
   22.10      /**
   22.11       * Creates a {@code MessageInfo} instance suitable for use when
   22.12 @@ -133,8 +133,8 @@
   22.13          if (streamNumber < 0 || streamNumber > 65536)
   22.14              throw new IllegalArgumentException("Invalid stream number");
   22.15  
   22.16 -        return new sun.nio.ch.SctpMessageInfoImpl(association, address,
   22.17 -                streamNumber);
   22.18 +        return new sun.nio.ch.sctp.MessageInfoImpl(association,
   22.19 +                                                   address, streamNumber);
   22.20      }
   22.21  
   22.22      /**
    23.1 --- a/src/share/classes/com/sun/nio/sctp/SctpChannel.java	Thu Feb 16 13:01:36 2012 -0800
    23.2 +++ b/src/share/classes/com/sun/nio/sctp/SctpChannel.java	Sat Feb 18 16:11:47 2012 -0800
    23.3 @@ -162,7 +162,7 @@
    23.4       */
    23.5      public static SctpChannel open() throws
    23.6          IOException {
    23.7 -        return new sun.nio.ch.SctpChannelImpl((SelectorProvider)null);
    23.8 +        return new sun.nio.ch.sctp.SctpChannelImpl((SelectorProvider)null);
    23.9      }
   23.10  
   23.11      /**
    24.1 --- a/src/share/classes/com/sun/nio/sctp/SctpMultiChannel.java	Thu Feb 16 13:01:36 2012 -0800
    24.2 +++ b/src/share/classes/com/sun/nio/sctp/SctpMultiChannel.java	Sat Feb 18 16:11:47 2012 -0800
    24.3 @@ -162,7 +162,7 @@
    24.4       */
    24.5      public static SctpMultiChannel open() throws
    24.6          IOException {
    24.7 -        return new sun.nio.ch.SctpMultiChannelImpl((SelectorProvider)null);
    24.8 +        return new sun.nio.ch.sctp.SctpMultiChannelImpl((SelectorProvider)null);
    24.9      }
   24.10  
   24.11      /**
    25.1 --- a/src/share/classes/com/sun/nio/sctp/SctpServerChannel.java	Thu Feb 16 13:01:36 2012 -0800
    25.2 +++ b/src/share/classes/com/sun/nio/sctp/SctpServerChannel.java	Sat Feb 18 16:11:47 2012 -0800
    25.3 @@ -98,7 +98,7 @@
    25.4       */
    25.5      public static SctpServerChannel open() throws
    25.6          IOException {
    25.7 -        return new sun.nio.ch.SctpServerChannelImpl((SelectorProvider)null);
    25.8 +        return new sun.nio.ch.sctp.SctpServerChannelImpl((SelectorProvider)null);
    25.9      }
   25.10  
   25.11      /**
    26.1 --- a/src/share/classes/com/sun/nio/sctp/SctpStandardSocketOptions.java	Thu Feb 16 13:01:36 2012 -0800
    26.2 +++ b/src/share/classes/com/sun/nio/sctp/SctpStandardSocketOptions.java	Sat Feb 18 16:11:47 2012 -0800
    26.3 @@ -25,7 +25,7 @@
    26.4  package com.sun.nio.sctp;
    26.5  
    26.6  import java.net.SocketAddress;
    26.7 -import sun.nio.ch.SctpStdSocketOption;
    26.8 +import sun.nio.ch.sctp.SctpStdSocketOption;
    26.9  
   26.10  /**
   26.11   * SCTP channels supports the socket options defined by this class
   26.12 @@ -50,7 +50,7 @@
   26.13       */
   26.14      public static final SctpSocketOption<Boolean> SCTP_DISABLE_FRAGMENTS = new
   26.15          SctpStdSocketOption<Boolean>("SCTP_DISABLE_FRAGMENTS", Boolean.class,
   26.16 -        sun.nio.ch.SctpStdSocketOption.SCTP_DISABLE_FRAGMENTS);
   26.17 +        sun.nio.ch.sctp.SctpStdSocketOption.SCTP_DISABLE_FRAGMENTS);
   26.18  
   26.19      /**
   26.20       * Enables or disables explicit message completion.
   26.21 @@ -69,7 +69,7 @@
   26.22       */
   26.23      public static final SctpSocketOption<Boolean> SCTP_EXPLICIT_COMPLETE = new
   26.24          SctpStdSocketOption<Boolean>("SCTP_EXPLICIT_COMPLETE", Boolean.class,
   26.25 -        sun.nio.ch.SctpStdSocketOption.SCTP_EXPLICIT_COMPLETE);
   26.26 +        sun.nio.ch.sctp.SctpStdSocketOption.SCTP_EXPLICIT_COMPLETE);
   26.27  
   26.28      /**
   26.29       * Fragmented interleave controls how the presentation of messages occur
   26.30 @@ -120,7 +120,7 @@
   26.31      public static final SctpSocketOption<Integer> SCTP_FRAGMENT_INTERLEAVE =
   26.32              new SctpStdSocketOption<Integer>("SCTP_FRAGMENT_INTERLEAVE",
   26.33                    Integer.class,
   26.34 -                  sun.nio.ch.SctpStdSocketOption.SCTP_FRAGMENT_INTERLEAVE);
   26.35 +                  sun.nio.ch.sctp.SctpStdSocketOption.SCTP_FRAGMENT_INTERLEAVE);
   26.36  
   26.37      /**
   26.38       * The maximum number of streams requested by the local endpoint during
   26.39 @@ -171,7 +171,7 @@
   26.40       */
   26.41      public static final SctpSocketOption<Boolean> SCTP_NODELAY =
   26.42          new SctpStdSocketOption<Boolean>("SCTP_NODELAY", Boolean.class,
   26.43 -        sun.nio.ch.SctpStdSocketOption.SCTP_NODELAY);
   26.44 +        sun.nio.ch.sctp.SctpStdSocketOption.SCTP_NODELAY);
   26.45  
   26.46      /**
   26.47       * Requests that the local SCTP stack use the given peer address as
   26.48 @@ -246,7 +246,7 @@
   26.49       */
   26.50      public static final SctpSocketOption<Integer> SO_SNDBUF =
   26.51          new SctpStdSocketOption<Integer>("SO_SNDBUF", Integer.class,
   26.52 -        sun.nio.ch.SctpStdSocketOption.SO_SNDBUF);
   26.53 +        sun.nio.ch.sctp.SctpStdSocketOption.SO_SNDBUF);
   26.54  
   26.55      /**
   26.56       * The size of the socket receive buffer.
   26.57 @@ -273,7 +273,7 @@
   26.58       */
   26.59      public static final SctpSocketOption<Integer> SO_RCVBUF =
   26.60          new SctpStdSocketOption<Integer>("SO_RCVBUF", Integer.class,
   26.61 -        sun.nio.ch.SctpStdSocketOption.SO_RCVBUF);
   26.62 +        sun.nio.ch.sctp.SctpStdSocketOption.SO_RCVBUF);
   26.63  
   26.64      /**
   26.65       * Linger on close if data is present.
   26.66 @@ -304,7 +304,7 @@
   26.67       */
   26.68      public static final SctpSocketOption<Integer> SO_LINGER =
   26.69          new SctpStdSocketOption<Integer>("SO_LINGER", Integer.class,
   26.70 -        sun.nio.ch.SctpStdSocketOption.SO_LINGER);
   26.71 +        sun.nio.ch.sctp.SctpStdSocketOption.SO_LINGER);
   26.72  
   26.73      /**
   26.74       * This class is used to set the maximum number of inbound/outbound streams
    27.1 --- a/src/share/classes/java/awt/List.java	Thu Feb 16 13:01:36 2012 -0800
    27.2 +++ b/src/share/classes/java/awt/List.java	Sat Feb 18 16:11:47 2012 -0800
    27.3 @@ -115,7 +115,7 @@
    27.4       * @see #addItem(String)
    27.5       * @see #getItem(int)
    27.6       */
    27.7 -    Vector      items = new Vector();
    27.8 +    Vector<String>      items = new Vector<>();
    27.9  
   27.10      /**
   27.11       * This field will represent the number of visible rows in the
   27.12 @@ -306,7 +306,7 @@
   27.13      //       to insure that it cannot be overridden by client subclasses.
   27.14      //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
   27.15      final String getItemImpl(int index) {
   27.16 -        return (String)items.elementAt(index);
   27.17 +        return items.elementAt(index);
   27.18      }
   27.19  
   27.20      /**
   27.21 @@ -415,7 +415,7 @@
   27.22          if (peer != null) {
   27.23              peer.removeAll();
   27.24          }
   27.25 -        items = new Vector();
   27.26 +        items = new Vector<>();
   27.27          selected = new int[0];
   27.28      }
   27.29  
   27.30 @@ -490,9 +490,9 @@
   27.31      public synchronized int[] getSelectedIndexes() {
   27.32          ListPeer peer = (ListPeer)this.peer;
   27.33          if (peer != null) {
   27.34 -            selected = ((ListPeer)peer).getSelectedIndexes();
   27.35 +            selected = peer.getSelectedIndexes();
   27.36          }
   27.37 -        return (int[])selected.clone();
   27.38 +        return selected.clone();
   27.39      }
   27.40  
   27.41      /**
   27.42 @@ -908,7 +908,7 @@
   27.43       * @since 1.4
   27.44       */
   27.45      public synchronized ItemListener[] getItemListeners() {
   27.46 -        return (ItemListener[])(getListeners(ItemListener.class));
   27.47 +        return getListeners(ItemListener.class);
   27.48      }
   27.49  
   27.50      /**
   27.51 @@ -975,7 +975,7 @@
   27.52       * @since 1.4
   27.53       */
   27.54      public synchronized ActionListener[] getActionListeners() {
   27.55 -        return (ActionListener[])(getListeners(ActionListener.class));
   27.56 +        return getListeners(ActionListener.class);
   27.57      }
   27.58  
   27.59      /**
    28.1 --- a/src/share/classes/java/awt/Window.java	Thu Feb 16 13:01:36 2012 -0800
    28.2 +++ b/src/share/classes/java/awt/Window.java	Sat Feb 18 16:11:47 2012 -0800
    28.3 @@ -398,10 +398,10 @@
    28.4              initIDs();
    28.5          }
    28.6  
    28.7 -        String s = (String) java.security.AccessController.doPrivileged(
    28.8 +        String s = java.security.AccessController.doPrivileged(
    28.9              new GetPropertyAction("java.awt.syncLWRequests"));
   28.10          systemSyncLWRequests = (s != null && s.equals("true"));
   28.11 -        s = (String) java.security.AccessController.doPrivileged(
   28.12 +        s = java.security.AccessController.doPrivileged(
   28.13              new GetPropertyAction("java.awt.Window.locationByPlatform"));
   28.14          locationByPlatformProp = (s != null && s.equals("true"));
   28.15      }
   28.16 @@ -1378,7 +1378,7 @@
   28.17                  // make sure the privileged action is only
   28.18                  // for getting the property! We don't want the
   28.19                  // above checkTopLevelWindow call to always succeed!
   28.20 -                warningString = (String) AccessController.doPrivileged(
   28.21 +                warningString = AccessController.doPrivileged(
   28.22                        new GetPropertyAction("awt.appletWarning",
   28.23                                              "Java Applet Window"));
   28.24              }
    29.1 --- a/src/share/classes/java/awt/color/ICC_Profile.java	Thu Feb 16 13:01:36 2012 -0800
    29.2 +++ b/src/share/classes/java/awt/color/ICC_Profile.java	Sat Feb 18 16:11:47 2012 -0800
    29.3 @@ -921,9 +921,9 @@
    29.4       */
    29.5      private static ICC_Profile getStandardProfile(final String name) {
    29.6  
    29.7 -        return (ICC_Profile) AccessController.doPrivileged(
    29.8 -            new PrivilegedAction() {
    29.9 -                 public Object run() {
   29.10 +        return AccessController.doPrivileged(
   29.11 +            new PrivilegedAction<ICC_Profile>() {
   29.12 +                 public ICC_Profile run() {
   29.13                       ICC_Profile p = null;
   29.14                       try {
   29.15                           p = getInstance (name);
    30.1 --- a/src/share/classes/java/awt/event/InputEvent.java	Thu Feb 16 13:01:36 2012 -0800
    30.2 +++ b/src/share/classes/java/awt/event/InputEvent.java	Sat Feb 18 16:11:47 2012 -0800
    30.3 @@ -321,14 +321,15 @@
    30.4       * @param when         a long int that gives the time the event occurred.
    30.5       *                     Passing negative or zero value
    30.6       *                     is not recommended
    30.7 -     * @param modifiers    the modifier keys down during event (e.g. shift, ctrl,
    30.8 -     *                     alt, meta)
    30.9 -     *                     Passing negative parameter is not recommended.
   30.10 -     *                     Zero value means no modifiers.
   30.11 -     *                     Either extended _DOWN_MASK or old _MASK modifiers
   30.12 -     *                     should be used, but both models should not be mixed
   30.13 -     *                     in one event. Use of the extended modifiers is
   30.14 -     *                     preferred
   30.15 +     * @param modifiers    a modifier mask describing the modifier keys and mouse
   30.16 +     *                     buttons (for example, shift, ctrl, alt, and meta) that
   30.17 +     *                     are down during the event.
   30.18 +     *                     Only extended modifiers are allowed to be used as a
   30.19 +     *                     value for this parameter (see the {@link InputEvent#getModifiersEx}
   30.20 +     *                     class for the description of extended modifiers).
   30.21 +     *                     Passing negative parameter
   30.22 +     *                     is not recommended.
   30.23 +     *                     Zero value means that no modifiers were passed
   30.24       * @throws IllegalArgumentException if <code>source</code> is null
   30.25       * @see #getSource()
   30.26       * @see #getID()
   30.27 @@ -416,9 +417,13 @@
   30.28  
   30.29      /**
   30.30       * Returns the extended modifier mask for this event.
   30.31 +     * <P>
   30.32 +     * Extended modifiers are the modifiers that ends with the _DOWN_MASK suffix,
   30.33 +     * such as ALT_DOWN_MASK, BUTTON1_DOWN_MASK, and others.
   30.34 +     * <P>
   30.35       * Extended modifiers represent the state of all modal keys,
   30.36       * such as ALT, CTRL, META, and the mouse buttons just after
   30.37 -     * the event occurred
   30.38 +     * the event occurred.
   30.39       * <P>
   30.40       * For example, if the user presses <b>button 1</b> followed by
   30.41       * <b>button 2</b>, and then releases them in the same order,
    31.1 --- a/src/share/classes/java/awt/event/MouseEvent.java	Thu Feb 16 13:01:36 2012 -0800
    31.2 +++ b/src/share/classes/java/awt/event/MouseEvent.java	Sat Feb 18 16:11:47 2012 -0800
    31.3 @@ -488,14 +488,15 @@
    31.4       * @param when         A long integer that gives the time the event occurred.
    31.5       *                     Passing negative or zero value
    31.6       *                     is not recommended
    31.7 -     * @param modifiers    The modifier keys down during event (e.g. shift, ctrl,
    31.8 -     *                     alt, meta)
    31.9 +     * @param modifiers    a modifier mask describing the modifier keys and mouse
   31.10 +     *                     buttons (for example, shift, ctrl, alt, and meta) that
   31.11 +     *                     are down during the event.
   31.12 +     *                     Only extended modifiers are allowed to be used as a
   31.13 +     *                     value for this parameter (see the {@link InputEvent#getModifiersEx}
   31.14 +     *                     class for the description of extended modifiers).
   31.15       *                     Passing negative parameter
   31.16       *                     is not recommended.
   31.17 -     *                     Zero value means that no modifiers were passed.
   31.18 -     *                     Use either an extended _DOWN_MASK or old _MASK modifiers,
   31.19 -     *                     however do not mix models in the one event.
   31.20 -     *                     The extended modifiers are preferred for using
   31.21 +     *                     Zero value means that no modifiers were passed
   31.22       * @param x            The horizontal x coordinate for the mouse location.
   31.23       *                       It is allowed to pass negative values
   31.24       * @param y            The vertical y coordinate for the mouse location.
   31.25 @@ -586,14 +587,15 @@
   31.26       * @param when         A long integer that gives the time the event occurred.
   31.27       *                     Passing negative or zero value
   31.28       *                     is not recommended
   31.29 -     * @param modifiers    The modifier keys down during event (e.g. shift, ctrl,
   31.30 -     *                     alt, meta)
   31.31 +     * @param modifiers    a modifier mask describing the modifier keys and mouse
   31.32 +     *                     buttons (for example, shift, ctrl, alt, and meta) that
   31.33 +     *                     are down during the event.
   31.34 +     *                     Only extended modifiers are allowed to be used as a
   31.35 +     *                     value for this parameter (see the {@link InputEvent#getModifiersEx}
   31.36 +     *                     class for the description of extended modifiers).
   31.37       *                     Passing negative parameter
   31.38       *                     is not recommended.
   31.39 -     *                     Zero value means that no modifiers were passed.
   31.40 -     *                     Use either an extended _DOWN_MASK or old _MASK modifiers,
   31.41 -     *                     however do not mix models in the one event.
   31.42 -     *                     The extended modifiers are preferred for using
   31.43 +     *                     Zero value means that no modifiers were passed
   31.44       * @param x            The horizontal x coordinate for the mouse location.
   31.45       *                       It is allowed to pass negative values
   31.46       * @param y            The vertical y coordinate for the mouse location.
   31.47 @@ -657,14 +659,15 @@
   31.48       * @param when         A long integer that gives the time the event occurred.
   31.49       *                     Passing negative or zero value
   31.50       *                     is not recommended
   31.51 -     * @param modifiers    The modifier keys down during event (e.g. shift, ctrl,
   31.52 -     *                     alt, meta)
   31.53 +     * @param modifiers    a modifier mask describing the modifier keys and mouse
   31.54 +     *                     buttons (for example, shift, ctrl, alt, and meta) that
   31.55 +     *                     are down during the event.
   31.56 +     *                     Only extended modifiers are allowed to be used as a
   31.57 +     *                     value for this parameter (see the {@link InputEvent#getModifiersEx}
   31.58 +     *                     class for the description of extended modifiers).
   31.59       *                     Passing negative parameter
   31.60       *                     is not recommended.
   31.61 -     *                     Zero value means that no modifiers were passed.
   31.62 -     *                     Use either an extended _DOWN_MASK or old _MASK modifiers,
   31.63 -     *                     however do not mix models in the one event.
   31.64 -     *                     The extended modifiers are preferred for using
   31.65 +     *                     Zero value means that no modifiers were passed
   31.66       * @param x            The horizontal x coordinate for the mouse location.
   31.67       *                       It is allowed to pass negative values
   31.68       * @param y            The vertical y coordinate for the mouse location.
    32.1 --- a/src/share/classes/java/lang/management/ManagementPermission.java	Thu Feb 16 13:01:36 2012 -0800
    32.2 +++ b/src/share/classes/java/lang/management/ManagementPermission.java	Sat Feb 18 16:11:47 2012 -0800
    32.3 @@ -1,5 +1,5 @@
    32.4  /*
    32.5 - * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
    32.6 + * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
    32.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    32.8   *
    32.9   * This code is free software; you can redistribute it and/or modify it
   32.10 @@ -46,12 +46,17 @@
   32.11   * <tr>
   32.12   *   <td>control</td>
   32.13   *   <td>Ability to control the runtime characteristics of the Java virtual
   32.14 - *       machine, for example, setting the -verbose:gc and -verbose:class flag,
   32.15 - *       setting the threshold of a memory pool, and enabling and disabling
   32.16 - *       the thread contention monitoring support.
   32.17 + *       machine, for example, enabling and disabling the verbose output for
   32.18 + *       the class loading or memory system, setting the threshold of a memory
   32.19 + *       pool, and enabling and disabling the thread contention monitoring
   32.20 + *       support. Some actions controlled by this permission can disclose
   32.21 + *       information about the running application, like the -verbose:class
   32.22 + *       flag.
   32.23   *   </td>
   32.24   *   <td>This allows an attacker to control the runtime characteristics
   32.25 - *       of the Java virtual machine and cause the system to misbehave.
   32.26 + *       of the Java virtual machine and cause the system to misbehave. An
   32.27 + *       attacker can also access some information related to the running
   32.28 + *       application.
   32.29   *   </td>
   32.30   * </tr>
   32.31   * <tr>
    33.1 --- a/src/share/classes/java/util/jar/Attributes.java	Thu Feb 16 13:01:36 2012 -0800
    33.2 +++ b/src/share/classes/java/util/jar/Attributes.java	Sat Feb 18 16:11:47 2012 -0800
    33.3 @@ -71,7 +71,7 @@
    33.4       * @param size the initial number of attributes
    33.5       */
    33.6      public Attributes(int size) {
    33.7 -        map = new HashMap(size);
    33.8 +        map = new HashMap<>(size);
    33.9      }
   33.10  
   33.11      /**
   33.12 @@ -81,7 +81,7 @@
   33.13       * @param attr the specified Attributes
   33.14       */
   33.15      public Attributes(Attributes attr) {
   33.16 -        map = new HashMap(attr);
   33.17 +        map = new HashMap<>(attr);
   33.18      }
   33.19  
   33.20  
   33.21 @@ -296,9 +296,9 @@
   33.22       * XXX Need to handle UTF8 values and break up lines longer than 72 bytes
   33.23       */
   33.24       void write(DataOutputStream os) throws IOException {
   33.25 -        Iterator it = entrySet().iterator();
   33.26 +        Iterator<Map.Entry<Object, Object>> it = entrySet().iterator();
   33.27          while (it.hasNext()) {
   33.28 -            Map.Entry e = (Map.Entry)it.next();
   33.29 +            Map.Entry<Object, Object> e = it.next();
   33.30              StringBuffer buffer = new StringBuffer(
   33.31                                          ((Name)e.getKey()).toString());
   33.32              buffer.append(": ");
   33.33 @@ -340,9 +340,9 @@
   33.34  
   33.35          // write out all attributes except for the version
   33.36          // we wrote out earlier
   33.37 -        Iterator it = entrySet().iterator();
   33.38 +        Iterator<Map.Entry<Object, Object>> it = entrySet().iterator();
   33.39          while (it.hasNext()) {
   33.40 -            Map.Entry e = (Map.Entry)it.next();
   33.41 +            Map.Entry<Object, Object> e = it.next();
   33.42              String name = ((Name)e.getKey()).toString();
   33.43              if ((version != null) && ! (name.equalsIgnoreCase(vername))) {
   33.44  
   33.45 @@ -499,7 +499,7 @@
   33.46           */
   33.47          public boolean equals(Object o) {
   33.48              if (o instanceof Name) {
   33.49 -                Comparator c = ASCIICaseInsensitiveComparator.CASE_INSENSITIVE_ORDER;
   33.50 +                Comparator<String> c = ASCIICaseInsensitiveComparator.CASE_INSENSITIVE_ORDER;
   33.51                  return c.compare(name, ((Name)o).name) == 0;
   33.52              } else {
   33.53                  return false;
    34.1 --- a/src/share/classes/java/util/jar/JarOutputStream.java	Thu Feb 16 13:01:36 2012 -0800
    34.2 +++ b/src/share/classes/java/util/jar/JarOutputStream.java	Sat Feb 18 16:11:47 2012 -0800
    34.3 @@ -1,5 +1,5 @@
    34.4  /*
    34.5 - * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
    34.6 + * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
    34.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    34.8   *
    34.9   * This code is free software; you can redistribute it and/or modify it
   34.10 @@ -135,7 +135,7 @@
   34.11       * The bytes are assumed to be in Intel (little-endian) byte order.
   34.12       */
   34.13      private static int get16(byte[] b, int off) {
   34.14 -        return (b[off] & 0xff) | ((b[off+1] & 0xff) << 8);
   34.15 +        return Byte.toUnsignedInt(b[off]) | ( Byte.toUnsignedInt(b[off+1]) << 8);
   34.16      }
   34.17  
   34.18      /*
    35.1 --- a/src/share/classes/java/util/jar/JarVerifier.java	Thu Feb 16 13:01:36 2012 -0800
    35.2 +++ b/src/share/classes/java/util/jar/JarVerifier.java	Sat Feb 18 16:11:47 2012 -0800
    35.3 @@ -48,21 +48,21 @@
    35.4  
    35.5      /* a table mapping names to code signers, for jar entries that have
    35.6         had their actual hashes verified */
    35.7 -    private Hashtable verifiedSigners;
    35.8 +    private Hashtable<String, CodeSigner[]> verifiedSigners;
    35.9  
   35.10      /* a table mapping names to code signers, for jar entries that have
   35.11         passed the .SF/.DSA/.EC -> MANIFEST check */
   35.12 -    private Hashtable sigFileSigners;
   35.13 +    private Hashtable<String, CodeSigner[]> sigFileSigners;
   35.14  
   35.15      /* a hash table to hold .SF bytes */
   35.16 -    private Hashtable sigFileData;
   35.17 +    private Hashtable<String, byte[]> sigFileData;
   35.18  
   35.19      /** "queue" of pending PKCS7 blocks that we couldn't parse
   35.20       *  until we parsed the .SF file */
   35.21 -    private ArrayList pendingBlocks;
   35.22 +    private ArrayList<SignatureFileVerifier> pendingBlocks;
   35.23  
   35.24      /* cache of CodeSigner objects */
   35.25 -    private ArrayList signerCache;
   35.26 +    private ArrayList<CodeSigner[]> signerCache;
   35.27  
   35.28      /* Are we parsing a block? */
   35.29      private boolean parsingBlockOrSF = false;
   35.30 @@ -94,10 +94,10 @@
   35.31  
   35.32      public JarVerifier(byte rawBytes[]) {
   35.33          manifestRawBytes = rawBytes;
   35.34 -        sigFileSigners = new Hashtable();
   35.35 -        verifiedSigners = new Hashtable();
   35.36 -        sigFileData = new Hashtable(11);
   35.37 -        pendingBlocks = new ArrayList();
   35.38 +        sigFileSigners = new Hashtable<>();
   35.39 +        verifiedSigners = new Hashtable<>();
   35.40 +        sigFileData = new Hashtable<>(11);
   35.41 +        pendingBlocks = new ArrayList<>();
   35.42          baos = new ByteArrayOutputStream();
   35.43          manifestDigests = new ArrayList<>();
   35.44      }
   35.45 @@ -248,10 +248,9 @@
   35.46                      sigFileData.put(key, bytes);
   35.47                      // check pending blocks, we can now process
   35.48                      // anyone waiting for this .SF file
   35.49 -                    Iterator it = pendingBlocks.iterator();
   35.50 +                    Iterator<SignatureFileVerifier> it = pendingBlocks.iterator();
   35.51                      while (it.hasNext()) {
   35.52 -                        SignatureFileVerifier sfv =
   35.53 -                            (SignatureFileVerifier) it.next();
   35.54 +                        SignatureFileVerifier sfv = it.next();
   35.55                          if (sfv.needSignatureFile(key)) {
   35.56                              if (debug != null) {
   35.57                                  debug.println(
   35.58 @@ -270,7 +269,7 @@
   35.59                  String key = uname.substring(0, uname.lastIndexOf("."));
   35.60  
   35.61                  if (signerCache == null)
   35.62 -                    signerCache = new ArrayList();
   35.63 +                    signerCache = new ArrayList<>();
   35.64  
   35.65                  if (manDig == null) {
   35.66                      synchronized(manifestRawBytes) {
   35.67 @@ -287,7 +286,7 @@
   35.68  
   35.69                  if (sfv.needSignatureFileBytes()) {
   35.70                      // see if we have already parsed an external .SF file
   35.71 -                    byte[] bytes = (byte[]) sigFileData.get(key);
   35.72 +                    byte[] bytes = sigFileData.get(key);
   35.73  
   35.74                      if (bytes == null) {
   35.75                          // put this block on queue for later processing
   35.76 @@ -343,7 +342,7 @@
   35.77       */
   35.78      public CodeSigner[] getCodeSigners(String name)
   35.79      {
   35.80 -        return (CodeSigner[])verifiedSigners.get(name);
   35.81 +        return verifiedSigners.get(name);
   35.82      }
   35.83  
   35.84      public CodeSigner[] getCodeSigners(JarFile jar, JarEntry entry)
   35.85 @@ -376,15 +375,14 @@
   35.86          CodeSigner[] signers) {
   35.87  
   35.88          if (signers != null) {
   35.89 -            ArrayList certChains = new ArrayList();
   35.90 +            ArrayList<java.security.cert.Certificate> certChains = new ArrayList<>();
   35.91              for (int i = 0; i < signers.length; i++) {
   35.92                  certChains.addAll(
   35.93                      signers[i].getSignerCertPath().getCertificates());
   35.94              }
   35.95  
   35.96              // Convert into a Certificate[]
   35.97 -            return (java.security.cert.Certificate[])
   35.98 -                certChains.toArray(
   35.99 +            return certChains.toArray(
  35.100                      new java.security.cert.Certificate[certChains.size()]);
  35.101          }
  35.102          return null;
  35.103 @@ -418,8 +416,8 @@
  35.104          // MANIFEST.MF is always treated as signed and verified,
  35.105          // move its signers from sigFileSigners to verifiedSigners.
  35.106          if (sigFileSigners.containsKey(JarFile.MANIFEST_NAME)) {
  35.107 -            verifiedSigners.put(JarFile.MANIFEST_NAME,
  35.108 -                    sigFileSigners.remove(JarFile.MANIFEST_NAME));
  35.109 +            CodeSigner[] codeSigners = sigFileSigners.remove(JarFile.MANIFEST_NAME);
  35.110 +            verifiedSigners.put(JarFile.MANIFEST_NAME, codeSigners);
  35.111          }
  35.112      }
  35.113  
  35.114 @@ -493,10 +491,10 @@
  35.115  
  35.116      // Extended JavaUtilJarAccess CodeSource API Support
  35.117  
  35.118 -    private Map urlToCodeSourceMap = new HashMap();
  35.119 -    private Map signerToCodeSource = new HashMap();
  35.120 +    private Map<URL, Map<CodeSigner[], CodeSource>> urlToCodeSourceMap = new HashMap<>();
  35.121 +    private Map<CodeSigner[], CodeSource> signerToCodeSource = new HashMap<>();
  35.122      private URL lastURL;
  35.123 -    private Map lastURLMap;
  35.124 +    private Map<CodeSigner[], CodeSource> lastURLMap;
  35.125  
  35.126      /*
  35.127       * Create a unique mapping from codeSigner cache entries to CodeSource.
  35.128 @@ -504,19 +502,19 @@
  35.129       * and shared JAR file although in practice there will be a single URL in use.
  35.130       */
  35.131      private synchronized CodeSource mapSignersToCodeSource(URL url, CodeSigner[] signers) {
  35.132 -        Map map;
  35.133 +        Map<CodeSigner[], CodeSource> map;
  35.134          if (url == lastURL) {
  35.135              map = lastURLMap;
  35.136          } else {
  35.137 -            map = (Map) urlToCodeSourceMap.get(url);
  35.138 +            map = urlToCodeSourceMap.get(url);
  35.139              if (map == null) {
  35.140 -                map = new HashMap();
  35.141 +                map = new HashMap<>();
  35.142                  urlToCodeSourceMap.put(url, map);
  35.143              }
  35.144              lastURLMap = map;
  35.145              lastURL = url;
  35.146          }
  35.147 -        CodeSource cs = (CodeSource) map.get(signers);
  35.148 +        CodeSource cs = map.get(signers);
  35.149          if (cs == null) {
  35.150              cs = new VerifierCodeSource(csdomain, url, signers);
  35.151              signerToCodeSource.put(signers, cs);
  35.152 @@ -524,16 +522,16 @@
  35.153          return cs;
  35.154      }
  35.155  
  35.156 -    private CodeSource[] mapSignersToCodeSources(URL url, List signers, boolean unsigned) {
  35.157 -        List sources = new ArrayList();
  35.158 +    private CodeSource[] mapSignersToCodeSources(URL url, List<CodeSigner[]> signers, boolean unsigned) {
  35.159 +        List<CodeSource> sources = new ArrayList<>();
  35.160  
  35.161          for (int i = 0; i < signers.size(); i++) {
  35.162 -            sources.add(mapSignersToCodeSource(url, (CodeSigner[]) signers.get(i)));
  35.163 +            sources.add(mapSignersToCodeSource(url, signers.get(i)));
  35.164          }
  35.165          if (unsigned) {
  35.166              sources.add(mapSignersToCodeSource(url, null));
  35.167          }
  35.168 -        return (CodeSource[]) sources.toArray(new CodeSource[sources.size()]);
  35.169 +        return sources.toArray(new CodeSource[sources.size()]);
  35.170      }
  35.171      private CodeSigner[] emptySigner = new CodeSigner[0];
  35.172  
  35.173 @@ -553,7 +551,7 @@
  35.174           * but this handles a CodeSource of any type, just in case.
  35.175           */
  35.176          CodeSource[] sources = mapSignersToCodeSources(cs.getLocation(), getJarCodeSigners(), true);
  35.177 -        List sourceList = new ArrayList();
  35.178 +        List<CodeSource> sourceList = new ArrayList<>();
  35.179          for (int i = 0; i < sources.length; i++) {
  35.180              sourceList.add(sources[i]);
  35.181          }
  35.182 @@ -574,6 +572,7 @@
  35.183       * signing data that can be compared by object reference identity.
  35.184       */
  35.185      private static class VerifierCodeSource extends CodeSource {
  35.186 +        private static final long serialVersionUID = -9047366145967768825L;
  35.187  
  35.188          URL vlocation;
  35.189          CodeSigner[] vsigners;
  35.190 @@ -641,16 +640,16 @@
  35.191              return vcerts;
  35.192          }
  35.193      }
  35.194 -    private Map signerMap;
  35.195 +    private Map<String, CodeSigner[]> signerMap;
  35.196  
  35.197 -    private synchronized Map signerMap() {
  35.198 +    private synchronized Map<String, CodeSigner[]> signerMap() {
  35.199          if (signerMap == null) {
  35.200              /*
  35.201               * Snapshot signer state so it doesn't change on us. We care
  35.202               * only about the asserted signatures. Verification of
  35.203               * signature validity happens via the JarEntry apis.
  35.204               */
  35.205 -            signerMap = new HashMap(verifiedSigners.size() + sigFileSigners.size());
  35.206 +            signerMap = new HashMap<>(verifiedSigners.size() + sigFileSigners.size());
  35.207              signerMap.putAll(verifiedSigners);
  35.208              signerMap.putAll(sigFileSigners);
  35.209          }
  35.210 @@ -658,15 +657,15 @@
  35.211      }
  35.212  
  35.213      public synchronized Enumeration<String> entryNames(JarFile jar, final CodeSource[] cs) {
  35.214 -        final Map map = signerMap();
  35.215 -        final Iterator itor = map.entrySet().iterator();
  35.216 +        final Map<String, CodeSigner[]> map = signerMap();
  35.217 +        final Iterator<Map.Entry<String, CodeSigner[]>> itor = map.entrySet().iterator();
  35.218          boolean matchUnsigned = false;
  35.219  
  35.220          /*
  35.221           * Grab a single copy of the CodeSigner arrays. Check
  35.222           * to see if we can optimize CodeSigner equality test.
  35.223           */
  35.224 -        List req = new ArrayList(cs.length);
  35.225 +        List<CodeSigner[]> req = new ArrayList<>(cs.length);
  35.226          for (int i = 0; i < cs.length; i++) {
  35.227              CodeSigner[] match = findMatchingSigners(cs[i]);
  35.228              if (match != null) {
  35.229 @@ -678,8 +677,8 @@
  35.230              }
  35.231          }
  35.232  
  35.233 -        final List signersReq = req;
  35.234 -        final Enumeration enum2 = (matchUnsigned) ? unsignedEntryNames(jar) : emptyEnumeration;
  35.235 +        final List<CodeSigner[]> signersReq = req;
  35.236 +        final Enumeration<String> enum2 = (matchUnsigned) ? unsignedEntryNames(jar) : emptyEnumeration;
  35.237  
  35.238          return new Enumeration<String>() {
  35.239  
  35.240 @@ -691,14 +690,14 @@
  35.241                  }
  35.242  
  35.243                  while (itor.hasNext()) {
  35.244 -                    Map.Entry e = (Map.Entry) itor.next();
  35.245 -                    if (signersReq.contains((CodeSigner[]) e.getValue())) {
  35.246 -                        name = (String) e.getKey();
  35.247 +                    Map.Entry<String, CodeSigner[]> e = itor.next();
  35.248 +                    if (signersReq.contains(e.getValue())) {
  35.249 +                        name = e.getKey();
  35.250                          return true;
  35.251                      }
  35.252                  }
  35.253                  while (enum2.hasMoreElements()) {
  35.254 -                    name = (String) enum2.nextElement();
  35.255 +                    name = enum2.nextElement();
  35.256                      return true;
  35.257                  }
  35.258                  return false;
  35.259 @@ -719,13 +718,13 @@
  35.260       * Like entries() but screens out internal JAR mechanism entries
  35.261       * and includes signed entries with no ZIP data.
  35.262       */
  35.263 -    public Enumeration<JarEntry> entries2(final JarFile jar, Enumeration e) {
  35.264 -        final Map map = new HashMap();
  35.265 +    public Enumeration<JarEntry> entries2(final JarFile jar, Enumeration<? extends ZipEntry> e) {
  35.266 +        final Map<String, CodeSigner[]> map = new HashMap<>();
  35.267          map.putAll(signerMap());
  35.268 -        final Enumeration enum_ = e;
  35.269 +        final Enumeration<? extends ZipEntry> enum_ = e;
  35.270          return new Enumeration<JarEntry>() {
  35.271  
  35.272 -            Enumeration signers = null;
  35.273 +            Enumeration<String> signers = null;
  35.274              JarEntry entry;
  35.275  
  35.276              public boolean hasMoreElements() {
  35.277 @@ -733,7 +732,7 @@
  35.278                      return true;
  35.279                  }
  35.280                  while (enum_.hasMoreElements()) {
  35.281 -                    ZipEntry ze = (ZipEntry) enum_.nextElement();
  35.282 +                    ZipEntry ze = enum_.nextElement();
  35.283                      if (JarVerifier.isSigningRelated(ze.getName())) {
  35.284                          continue;
  35.285                      }
  35.286 @@ -744,7 +743,7 @@
  35.287                      signers = Collections.enumeration(map.keySet());
  35.288                  }
  35.289                  while (signers.hasMoreElements()) {
  35.290 -                    String name = (String) signers.nextElement();
  35.291 +                    String name = signers.nextElement();
  35.292                      entry = jar.newEntry(new ZipEntry(name));
  35.293                      return true;
  35.294                  }
  35.295 @@ -764,7 +763,7 @@
  35.296              }
  35.297          };
  35.298      }
  35.299 -    private Enumeration emptyEnumeration = new Enumeration<String>() {
  35.300 +    private Enumeration<String> emptyEnumeration = new Enumeration<String>() {
  35.301  
  35.302          public boolean hasMoreElements() {
  35.303              return false;
  35.304 @@ -797,8 +796,8 @@
  35.305      }
  35.306  
  35.307      private Enumeration<String> unsignedEntryNames(JarFile jar) {
  35.308 -        final Map map = signerMap();
  35.309 -        final Enumeration entries = jar.entries();
  35.310 +        final Map<String, CodeSigner[]> map = signerMap();
  35.311 +        final Enumeration<JarEntry> entries = jar.entries();
  35.312          return new Enumeration<String>() {
  35.313  
  35.314              String name;
  35.315 @@ -813,7 +812,7 @@
  35.316                  }
  35.317                  while (entries.hasMoreElements()) {
  35.318                      String value;
  35.319 -                    ZipEntry e = (ZipEntry) entries.nextElement();
  35.320 +                    ZipEntry e = entries.nextElement();
  35.321                      value = e.getName();
  35.322                      if (e.isDirectory() || isSigningRelated(value)) {
  35.323                          continue;
  35.324 @@ -836,14 +835,14 @@
  35.325              }
  35.326          };
  35.327      }
  35.328 -    private List jarCodeSigners;
  35.329 +    private List<CodeSigner[]> jarCodeSigners;
  35.330  
  35.331 -    private synchronized List getJarCodeSigners() {
  35.332 +    private synchronized List<CodeSigner[]> getJarCodeSigners() {
  35.333          CodeSigner[] signers;
  35.334          if (jarCodeSigners == null) {
  35.335 -            HashSet set = new HashSet();
  35.336 +            HashSet<CodeSigner[]> set = new HashSet<>();
  35.337              set.addAll(signerMap().values());
  35.338 -            jarCodeSigners = new ArrayList();
  35.339 +            jarCodeSigners = new ArrayList<>();
  35.340              jarCodeSigners.addAll(set);
  35.341          }
  35.342          return jarCodeSigners;
  35.343 @@ -858,7 +857,7 @@
  35.344      public CodeSource getCodeSource(URL url, String name) {
  35.345          CodeSigner[] signers;
  35.346  
  35.347 -        signers = (CodeSigner[]) signerMap().get(name);
  35.348 +        signers = signerMap().get(name);
  35.349          return mapSignersToCodeSource(url, signers);
  35.350      }
  35.351  
    36.1 --- a/src/share/classes/java/util/jar/Manifest.java	Thu Feb 16 13:01:36 2012 -0800
    36.2 +++ b/src/share/classes/java/util/jar/Manifest.java	Sat Feb 18 16:11:47 2012 -0800
    36.3 @@ -1,5 +1,5 @@
    36.4  /*
    36.5 - * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
    36.6 + * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
    36.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    36.8   *
    36.9   * This code is free software; you can redistribute it and/or modify it
   36.10 @@ -339,7 +339,7 @@
   36.11                      return -1;
   36.12                  }
   36.13              }
   36.14 -            return buf[pos++] & 0xff;
   36.15 +            return Byte.toUnsignedInt(buf[pos++]);
   36.16          }
   36.17  
   36.18          public int read(byte[] b, int off, int len) throws IOException {
    37.1 --- a/src/share/classes/java/util/zip/InflaterInputStream.java	Thu Feb 16 13:01:36 2012 -0800
    37.2 +++ b/src/share/classes/java/util/zip/InflaterInputStream.java	Sat Feb 18 16:11:47 2012 -0800
    37.3 @@ -1,5 +1,5 @@
    37.4  /*
    37.5 - * Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved.
    37.6 + * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
    37.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    37.8   *
    37.9   * This code is free software; you can redistribute it and/or modify it
   37.10 @@ -119,7 +119,7 @@
   37.11       */
   37.12      public int read() throws IOException {
   37.13          ensureOpen();
   37.14 -        return read(singleByteBuf, 0, 1) == -1 ? -1 : singleByteBuf[0] & 0xff;
   37.15 +        return read(singleByteBuf, 0, 1) == -1 ? -1 : Byte.toUnsignedInt(singleByteBuf[0]);
   37.16      }
   37.17  
   37.18      /**
    38.1 --- a/src/share/classes/java/util/zip/ZipInputStream.java	Thu Feb 16 13:01:36 2012 -0800
    38.2 +++ b/src/share/classes/java/util/zip/ZipInputStream.java	Sat Feb 18 16:11:47 2012 -0800
    38.3 @@ -1,5 +1,5 @@
    38.4  /*
    38.5 - * Copyright (c) 1996, 2009, Oracle and/or its affiliates. All rights reserved.
    38.6 + * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
    38.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    38.8   *
    38.9   * This code is free software; you can redistribute it and/or modify it
   38.10 @@ -435,7 +435,7 @@
   38.11       * The bytes are assumed to be in Intel (little-endian) byte order.
   38.12       */
   38.13      private static final int get16(byte b[], int off) {
   38.14 -        return (b[off] & 0xff) | ((b[off+1] & 0xff) << 8);
   38.15 +        return Byte.toUnsignedInt(b[off]) | (Byte.toUnsignedInt(b[off+1]) << 8);
   38.16      }
   38.17  
   38.18      /*
    39.1 --- a/src/share/classes/javax/crypto/CipherSpi.java	Thu Feb 16 13:01:36 2012 -0800
    39.2 +++ b/src/share/classes/javax/crypto/CipherSpi.java	Sat Feb 18 16:11:47 2012 -0800
    39.3 @@ -1,5 +1,5 @@
    39.4  /*
    39.5 - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
    39.6 + * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
    39.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    39.8   *
    39.9   * This code is free software; you can redistribute it and/or modify it
   39.10 @@ -775,7 +775,7 @@
   39.11              int outOfs = output.arrayOffset() + outPos;
   39.12              byte[] inArray = new byte[getTempArraySize(inLen)];
   39.13              int total = 0;
   39.14 -            while (inLen > 0) {
   39.15 +            do {
   39.16                  int chunk = Math.min(inLen, inArray.length);
   39.17                  input.get(inArray, 0, chunk);
   39.18                  int n;
   39.19 @@ -787,7 +787,7 @@
   39.20                  total += n;
   39.21                  outOfs += n;
   39.22                  inLen -= chunk;
   39.23 -            }
   39.24 +            } while (inLen > 0);
   39.25              output.position(outPos + total);
   39.26              return total;
   39.27          } else { // output is not backed by an accessible byte[]
   39.28 @@ -804,7 +804,7 @@
   39.29              int outSize = outArray.length;
   39.30              int total = 0;
   39.31              boolean resized = false;
   39.32 -            while (inLen > 0) {
   39.33 +            do {
   39.34                  int chunk = Math.min(inLen, outSize);
   39.35                  if ((a1 == false) && (resized == false)) {
   39.36                      input.get(inArray, 0, chunk);
   39.37 @@ -834,7 +834,7 @@
   39.38                      int newOut = engineGetOutputSize(chunk);
   39.39                      outArray = new byte[newOut];
   39.40                  }
   39.41 -            }
   39.42 +            } while (inLen > 0);
   39.43              input.position(inLimit);
   39.44              return total;
   39.45          }
    40.1 --- a/src/share/classes/javax/net/ssl/ExtendedSSLSession.java	Thu Feb 16 13:01:36 2012 -0800
    40.2 +++ b/src/share/classes/javax/net/ssl/ExtendedSSLSession.java	Sat Feb 18 16:11:47 2012 -0800
    40.3 @@ -1,5 +1,5 @@
    40.4  /*
    40.5 - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
    40.6 + * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
    40.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    40.8   *
    40.9   * This code is free software; you can redistribute it and/or modify it
   40.10 @@ -43,7 +43,7 @@
   40.11       * The signature algorithm name must be a standard Java Security
   40.12       * name (such as "SHA1withRSA", "SHA256withECDSA", and so on).
   40.13       * See Appendix A in the <a href=
   40.14 -     * "../../../technotes/guides/security/crypto/CryptoSpec.html#AppA">
   40.15 +     * "{@docRoot}/../technotes/guides/security/crypto/CryptoSpec.html#AppA">
   40.16       * Java Cryptography Architecture API Specification &amp; Reference </a>
   40.17       * for information about standard algorithm names.
   40.18       * <p>
   40.19 @@ -71,7 +71,7 @@
   40.20       * The signature algorithm name must be a standard Java Security
   40.21       * name (such as "SHA1withRSA", "SHA256withECDSA", and so on).
   40.22       * See Appendix A in the <a href=
   40.23 -     * "../../../technotes/guides/security/crypto/CryptoSpec.html#AppA">
   40.24 +     * "{@docRoot}/../technotes/guides/security/crypto/CryptoSpec.html#AppA">
   40.25       * Java Cryptography Architecture API Specification &amp; Reference </a>
   40.26       * for information about standard algorithm names.
   40.27       *
    41.1 --- a/src/share/classes/javax/net/ssl/SSLParameters.java	Thu Feb 16 13:01:36 2012 -0800
    41.2 +++ b/src/share/classes/javax/net/ssl/SSLParameters.java	Sat Feb 18 16:11:47 2012 -0800
    41.3 @@ -1,5 +1,5 @@
    41.4  /*
    41.5 - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
    41.6 + * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
    41.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    41.8   *
    41.9   * This code is free software; you can redistribute it and/or modify it
   41.10 @@ -242,7 +242,7 @@
   41.11       *
   41.12       * @param algorithm The standard string name of the endpoint
   41.13       *     identification algorithm (or null).  See Appendix A in the <a href=
   41.14 -     *     "../../../technotes/guides/security/crypto/CryptoSpec.html#AppA">
   41.15 +     *   "{@docRoot}/../technotes/guides/security/crypto/CryptoSpec.html#AppA">
   41.16       *     Java Cryptography Architecture API Specification &amp; Reference </a>
   41.17       *     for information about standard algorithm names.
   41.18       *
    42.1 --- a/src/share/classes/javax/print/attribute/standard/PrinterStateReasons.java	Thu Feb 16 13:01:36 2012 -0800
    42.2 +++ b/src/share/classes/javax/print/attribute/standard/PrinterStateReasons.java	Sat Feb 18 16:11:47 2012 -0800
    42.3 @@ -180,8 +180,7 @@
    42.4          if (severity == null) {
    42.5              throw new NullPointerException("severity is null");
    42.6          }
    42.7 -        return super.put((PrinterStateReason) reason,
    42.8 -                         (Severity) severity);
    42.9 +        return super.put(reason, severity);
   42.10      }
   42.11  
   42.12      /**
    43.1 --- a/src/share/classes/javax/print/attribute/standard/ReferenceUriSchemesSupported.java	Thu Feb 16 13:01:36 2012 -0800
    43.2 +++ b/src/share/classes/javax/print/attribute/standard/ReferenceUriSchemesSupported.java	Sat Feb 18 16:11:47 2012 -0800
    43.3 @@ -141,7 +141,7 @@
    43.4       * Returns the string table for class ReferenceUriSchemesSupported.
    43.5       */
    43.6      protected String[] getStringTable() {
    43.7 -        return (String[])myStringTable.clone();
    43.8 +        return myStringTable.clone();
    43.9      }
   43.10  
   43.11      /**
    44.1 --- a/src/share/classes/javax/security/auth/x500/X500Principal.java	Thu Feb 16 13:01:36 2012 -0800
    44.2 +++ b/src/share/classes/javax/security/auth/x500/X500Principal.java	Sat Feb 18 16:11:47 2012 -0800
    44.3 @@ -1,5 +1,5 @@
    44.4  /*
    44.5 - * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
    44.6 + * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
    44.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    44.8   *
    44.9   * This code is free software; you can redistribute it and/or modify it
   44.10 @@ -107,10 +107,17 @@
   44.11       * defined in RFC 1779 and RFC 2253
   44.12       * (and listed in {@link #getName(String format) getName(String format)}),
   44.13       * as well as the T, DNQ or DNQUALIFIER, SURNAME, GIVENNAME, INITIALS,
   44.14 -     * GENERATION, EMAILADDRESS, and SERIALNUMBER keywords whose OIDs are
   44.15 -     * defined in RFC 3280 and its successor.
   44.16 +     * GENERATION, EMAILADDRESS, and SERIALNUMBER keywords whose Object
   44.17 +     * Identifiers (OIDs) are defined in RFC 3280 and its successor.
   44.18       * Any other attribute type must be specified as an OID.
   44.19       *
   44.20 +     * <p>This implementation enforces a more restrictive OID syntax than
   44.21 +     * defined in RFC 1779 and 2253. It uses the more correct syntax defined in
   44.22 +     * <a href="http://www.ietf.org/rfc/rfc4512.txt">RFC 4512</a>, which
   44.23 +     * specifies that OIDs contain at least 2 digits:
   44.24 +     *
   44.25 +     * <p>{@code numericoid = number 1*( DOT number ) }
   44.26 +     *
   44.27       * @param name an X.500 distinguished name in RFC 1779 or RFC 2253 format
   44.28       * @exception NullPointerException if the <code>name</code>
   44.29       *                  is <code>null</code>
   44.30 @@ -135,10 +142,17 @@
   44.31       * keywords recognized by <code>X500Principal(String)</code>. Keywords
   44.32       * MUST be specified in all upper-case, otherwise they will be ignored.
   44.33       * Improperly specified keywords are ignored; however if a keyword in the
   44.34 -     * name maps to an improperly specified OID, an
   44.35 +     * name maps to an improperly specified Object Identifier (OID), an
   44.36       * <code>IllegalArgumentException</code> is thrown. It is permissible to
   44.37       * have 2 different keywords that map to the same OID.
   44.38       *
   44.39 +     * <p>This implementation enforces a more restrictive OID syntax than
   44.40 +     * defined in RFC 1779 and 2253. It uses the more correct syntax defined in
   44.41 +     * <a href="http://www.ietf.org/rfc/rfc4512.txt">RFC 4512</a>, which
   44.42 +     * specifies that OIDs contain at least 2 digits:
   44.43 +     *
   44.44 +     * <p>{@code numericoid = number 1*( DOT number ) }
   44.45 +     *
   44.46       * @param name an X.500 distinguished name in RFC 1779 or RFC 2253 format
   44.47       * @param keywordMap an attribute type keyword map, where each key is a
   44.48       *   keyword String that maps to a corresponding object identifier in String
    45.1 --- a/src/share/classes/javax/security/auth/x500/package.html	Thu Feb 16 13:01:36 2012 -0800
    45.2 +++ b/src/share/classes/javax/security/auth/x500/package.html	Sat Feb 18 16:11:47 2012 -0800
    45.3 @@ -2,7 +2,7 @@
    45.4  <html>
    45.5  <head>
    45.6  <!--
    45.7 -Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
    45.8 +Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
    45.9  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   45.10  
   45.11  This code is free software; you can redistribute it and/or modify it
   45.12 @@ -30,17 +30,26 @@
   45.13  <body bgcolor="white">
   45.14  
   45.15      This package contains the classes that should be used to store 
   45.16 -    X500 Principal and X500 Private Crendentials in a
   45.17 +    X500 Principal and X500 Private Credentials in a
   45.18      <i>Subject</i>.
   45.19  
   45.20 -<!--
   45.21  <h2>Package Specification</h2>
   45.22  
   45.23 -##### FILL IN ANY SPECS NEEDED BY JAVA COMPATIBILITY KIT #####
   45.24  <ul>
   45.25 -  <li><a href="">##### REFER TO ANY FRAMEMAKER SPECIFICATION HERE #####</a>
   45.26 +  <li><a href="http://www.ietf.org/rfc/rfc1779.txt">
   45.27 +    RFC 1779: A String Representation of Distinguished Names</a></li>
   45.28 +  <li><a href="http://www.ietf.org/rfc/rfc2253.txt">
   45.29 +    RFC 2253: Lightweight Directory Access Protocol (v3):
   45.30 +    UTF-8 String Representation of Distinguished Names</a></li>
   45.31 +  <li><a href="http://www.ietf.org/rfc/rfc3280.txt">
   45.32 +    RFC 3280: Internet X.509 Public Key Infrastructure
   45.33 +    Certificate and Certificate Revocation List (CRL) Profile</a></li>
   45.34 +  <li><a href="http://www.ietf.org/rfc/rfc4512.txt">
   45.35 +    RFC 4512: Lightweight Directory Access Protocol (LDAP):
   45.36 +    Directory Information Models</a></li>
   45.37  </ul>
   45.38  
   45.39 +<!--
   45.40  <h2>Related Documentation</h2>
   45.41  
   45.42  For overviews, tutorials, examples, guides, and tool documentation, please see:
    46.1 --- a/src/share/classes/javax/swing/JOptionPane.java	Thu Feb 16 13:01:36 2012 -0800
    46.2 +++ b/src/share/classes/javax/swing/JOptionPane.java	Sat Feb 18 16:11:47 2012 -0800
    46.3 @@ -34,7 +34,6 @@
    46.4  import java.awt.Frame;
    46.5  import java.awt.Point;
    46.6  import java.awt.HeadlessException;
    46.7 -import java.awt.Toolkit;
    46.8  import java.awt.Window;
    46.9  import java.beans.PropertyChangeEvent;
   46.10  import java.beans.PropertyChangeListener;
   46.11 @@ -994,8 +993,7 @@
   46.12                  // if the user closed the window without selecting a button
   46.13                  // (newValue = null in that case).  Otherwise, close the dialog.
   46.14                  if (dialog.isVisible() && event.getSource() == JOptionPane.this &&
   46.15 -                        (event.getPropertyName().equals(VALUE_PROPERTY) ||
   46.16 -                                event.getPropertyName().equals(INPUT_VALUE_PROPERTY)) &&
   46.17 +                        (event.getPropertyName().equals(VALUE_PROPERTY)) &&
   46.18                          event.getNewValue() != null &&
   46.19                          event.getNewValue() != JOptionPane.UNINITIALIZED_VALUE) {
   46.20                      dialog.setVisible(false);
    47.1 --- a/src/share/classes/javax/swing/plaf/basic/BasicOptionPaneUI.java	Thu Feb 16 13:01:36 2012 -0800
    47.2 +++ b/src/share/classes/javax/swing/plaf/basic/BasicOptionPaneUI.java	Sat Feb 18 16:11:47 2012 -0800
    47.3 @@ -1236,6 +1236,7 @@
    47.4                  int       index = list.locationToIndex(e.getPoint());
    47.5  
    47.6                  optionPane.setInputValue(list.getModel().getElementAt(index));
    47.7 +                optionPane.setValue(JOptionPane.OK_OPTION);
    47.8              }
    47.9          }
   47.10  
    48.1 --- a/src/share/classes/javax/swing/plaf/synth/SynthTreeUI.java	Thu Feb 16 13:01:36 2012 -0800
    48.2 +++ b/src/share/classes/javax/swing/plaf/synth/SynthTreeUI.java	Sat Feb 18 16:11:47 2012 -0800
    48.3 @@ -434,6 +434,8 @@
    48.4  
    48.5          // Empty out the renderer pane, allowing renderers to be gc'ed.
    48.6          rendererPane.removeAll();
    48.7 +
    48.8 +        paintContext = null;
    48.9      }
   48.10  
   48.11      private void configureRenderer(SynthContext context) {
    49.1 --- a/src/share/classes/javax/swing/tree/DefaultTreeCellRenderer.java	Thu Feb 16 13:01:36 2012 -0800
    49.2 +++ b/src/share/classes/javax/swing/tree/DefaultTreeCellRenderer.java	Sat Feb 18 16:11:47 2012 -0800
    49.3 @@ -156,7 +156,7 @@
    49.4      protected Color borderSelectionColor;
    49.5  
    49.6      private boolean isDropCell;
    49.7 -    private boolean fillBackground = true;
    49.8 +    private boolean fillBackground;
    49.9  
   49.10      /**
   49.11       * Set to true after the constructor has run.
    50.1 --- a/src/share/classes/sun/awt/image/OffScreenImageSource.java	Thu Feb 16 13:01:36 2012 -0800
    50.2 +++ b/src/share/classes/sun/awt/image/OffScreenImageSource.java	Sat Feb 18 16:11:47 2012 -0800
    50.3 @@ -1,5 +1,5 @@
    50.4  /*
    50.5 - * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
    50.6 + * Copyright (c) 1995, 2012, Oracle and/or its affiliates. All rights reserved.
    50.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    50.8   *
    50.9   * This code is free software; you can redistribute it and/or modify it
   50.10 @@ -185,6 +185,7 @@
   50.11              theConsumer.setDimensions(image.getWidth(), image.getHeight());
   50.12              theConsumer.setProperties(properties);
   50.13              sendPixels();
   50.14 +            theConsumer.imageComplete(ImageConsumer.SINGLEFRAMEDONE);
   50.15              theConsumer.imageComplete(ImageConsumer.STATICIMAGEDONE);
   50.16          } catch (NullPointerException e) {
   50.17              if (theConsumer != null) {
    51.1 --- a/src/share/classes/sun/beans/infos/ComponentBeanInfo.java	Thu Feb 16 13:01:36 2012 -0800
    51.2 +++ b/src/share/classes/sun/beans/infos/ComponentBeanInfo.java	Sat Feb 18 16:11:47 2012 -0800
    51.3 @@ -32,7 +32,7 @@
    51.4   */
    51.5  
    51.6  public class ComponentBeanInfo extends SimpleBeanInfo {
    51.7 -    private static final Class beanClass = java.awt.Component.class;
    51.8 +    private static final Class<java.awt.Component> beanClass = java.awt.Component.class;
    51.9  
   51.10      public PropertyDescriptor[] getPropertyDescriptors() {
   51.11          try {
    52.1 --- a/src/share/classes/sun/font/FileFont.java	Thu Feb 16 13:01:36 2012 -0800
    52.2 +++ b/src/share/classes/sun/font/FileFont.java	Sat Feb 18 16:11:47 2012 -0800
    52.3 @@ -163,7 +163,9 @@
    52.4                  }
    52.5              }
    52.6          }
    52.7 -        scaler.dispose();
    52.8 +        if (scaler != null) {
    52.9 +            scaler.dispose();
   52.10 +        }
   52.11          scaler = FontScaler.getNullScaler();
   52.12      }
   52.13  
    53.1 --- a/src/share/classes/sun/font/StandardGlyphVector.java	Thu Feb 16 13:01:36 2012 -0800
    53.2 +++ b/src/share/classes/sun/font/StandardGlyphVector.java	Sat Feb 18 16:11:47 2012 -0800
    53.3 @@ -1740,8 +1740,9 @@
    53.4                                                       tx,
    53.5                                                       sgv.font.getStyle(),
    53.6                                                       aa, fm);
    53.7 -
    53.8 -            FontStrike strike = sgv.font2D.getStrike(desc);  // !!! getStrike(desc, false)
    53.9 +            // Get the strike via the handle. Shouldn't matter
   53.10 +            // if we've invalidated the font but its an extra precaution.
   53.11 +            FontStrike strike = sgv.font2D.handle.font2D.getStrike(desc);  // !!! getStrike(desc, false)
   53.12  
   53.13              return new GlyphStrike(sgv, strike, dx, dy);
   53.14          }
    54.1 --- a/src/share/classes/sun/font/SunFontManager.java	Thu Feb 16 13:01:36 2012 -0800
    54.2 +++ b/src/share/classes/sun/font/SunFontManager.java	Sat Feb 18 16:11:47 2012 -0800
    54.3 @@ -2619,6 +2619,9 @@
    54.4          physicalFonts.remove(oldFont.fullName);
    54.5          fullNameToFont.remove(oldFont.fullName.toLowerCase(Locale.ENGLISH));
    54.6          FontFamily.remove(oldFont);
    54.7 +        if (oldFont instanceof FileFont) {
    54.8 +            ((FileFont)oldFont).deregisterFontAndClearStrikeCache();
    54.9 +        }
   54.10  
   54.11          if (localeFullNamesToFont != null) {
   54.12              Map.Entry[] mapEntries =
    55.1 --- a/src/share/classes/sun/font/TrueTypeFont.java	Thu Feb 16 13:01:36 2012 -0800
    55.2 +++ b/src/share/classes/sun/font/TrueTypeFont.java	Sat Feb 18 16:11:47 2012 -0800
    55.3 @@ -1037,6 +1037,9 @@
    55.4              if (head_Table != null && head_Table.capacity() >= 18) {
    55.5                  ShortBuffer sb = head_Table.asShortBuffer();
    55.6                  upem = sb.get(9) & 0xffff;
    55.7 +                if (upem < 16 || upem > 16384) {
    55.8 +                    upem = 2048;
    55.9 +                }
   55.10              }
   55.11  
   55.12              ByteBuffer os2_Table = getTableBuffer(os_2Tag);
    56.1 --- a/src/share/classes/sun/management/HotSpotDiagnostic.java	Thu Feb 16 13:01:36 2012 -0800
    56.2 +++ b/src/share/classes/sun/management/HotSpotDiagnostic.java	Sat Feb 18 16:11:47 2012 -0800
    56.3 @@ -1,5 +1,5 @@
    56.4  /*
    56.5 - * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
    56.6 + * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
    56.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    56.8   *
    56.9   * This code is free software; you can redistribute it and/or modify it
   56.10 @@ -27,13 +27,9 @@
   56.11  
   56.12  import java.io.IOException;
   56.13  import java.util.ArrayList;
   56.14 -import java.util.Arrays;
   56.15 -import java.util.Collections;
   56.16  import java.util.List;
   56.17  import javax.management.ObjectName;
   56.18  
   56.19 -import com.sun.management.DiagnosticCommandInfo;
   56.20 -import com.sun.management.DiagnosticCommandArgumentInfo;
   56.21  import com.sun.management.HotSpotDiagnosticMXBean;
   56.22  import com.sun.management.VMOption;
   56.23  
   56.24 @@ -120,54 +116,7 @@
   56.25          }
   56.26      }
   56.27  
   56.28 -    public List<String> getDiagnosticCommands() {
   56.29 -        String[] commands = getDiagnosticCommands0();
   56.30 -        return commands == null ? Collections.<String>emptyList() :
   56.31 -            Arrays.asList(commands);
   56.32 -    }
   56.33 -
   56.34 -    public DiagnosticCommandInfo getDiagnosticCommandInfo(String command) {
   56.35 -        String[] array = new String[] { command };
   56.36 -        return getDiagnosticCommandInfo0(array)[0];
   56.37 -    }
   56.38 -
   56.39 -    public List<DiagnosticCommandInfo> getDiagnosticCommandInfo() {
   56.40 -        String[] commands = getDiagnosticCommands0();
   56.41 -        return Arrays.asList(getDiagnosticCommandInfo0(commands));
   56.42 -    }
   56.43 -
   56.44 -    public List<DiagnosticCommandInfo> getDiagnosticCommandInfo(
   56.45 -        List<String> commands) {
   56.46 -        return Arrays.asList(getDiagnosticCommandInfo0(
   56.47 -            commands.toArray(new String[commands.size()])));
   56.48 -    }
   56.49 -
   56.50 -    public String execute(String command) {
   56.51 -        Util.checkControlAccess();
   56.52 -        return executeDiagnosticCommand0(command);
   56.53 -    }
   56.54 -
   56.55 -    public String execute(String cmd, String... arguments) {
   56.56 -        if(cmd == null) {
   56.57 -            throw new NullPointerException("Missing command name");
   56.58 -        }
   56.59 -        StringBuilder sb = new StringBuilder();
   56.60 -        sb.append(cmd);
   56.61 -        sb.append(" ");
   56.62 -        for(String arg : arguments) {
   56.63 -            sb.append(arg);
   56.64 -            sb.append(" ");
   56.65 -        }
   56.66 -        return execute(sb.toString());
   56.67 -    }
   56.68 -
   56.69      public ObjectName getObjectName() {
   56.70          return Util.newObjectName("com.sun.management:type=HotSpotDiagnostic");
   56.71      }
   56.72 -
   56.73 -    private native String[] getDiagnosticCommands0();
   56.74 -    private native DiagnosticCommandInfo[] getDiagnosticCommandInfo0(
   56.75 -        String[] commands) throws IllegalArgumentException;
   56.76 -    private native String executeDiagnosticCommand0(String command)
   56.77 -        throws IllegalArgumentException;
   56.78  }
    57.1 --- a/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java	Thu Feb 16 13:01:36 2012 -0800
    57.2 +++ b/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java	Sat Feb 18 16:11:47 2012 -0800
    57.3 @@ -270,7 +270,7 @@
    57.4      protected Proxy instProxy;
    57.5  
    57.6      private CookieHandler cookieHandler;
    57.7 -    private ResponseCache cacheHandler;
    57.8 +    private final ResponseCache cacheHandler;
    57.9  
   57.10      // the cached response, and cached response headers and body
   57.11      protected CacheResponse cachedResponse;
   57.12 @@ -1579,7 +1579,7 @@
   57.13  
   57.14                  if (respCode == 200 || respCode == 203 || respCode == 206 ||
   57.15                      respCode == 300 || respCode == 301 || respCode == 410) {
   57.16 -                    if (cacheHandler != null) {
   57.17 +                    if (cacheHandler != null && getUseCaches()) {
   57.18                          // give cache a chance to save response in cache
   57.19                          URI uri = ParseUtil.toURI(url);
   57.20                          if (uri != null) {
    58.1 --- a/src/share/classes/sun/nio/ch/AbstractPollArrayWrapper.java	Thu Feb 16 13:01:36 2012 -0800
    58.2 +++ b/src/share/classes/sun/nio/ch/AbstractPollArrayWrapper.java	Sat Feb 18 16:11:47 2012 -0800
    58.3 @@ -35,15 +35,15 @@
    58.4   * @since 1.4
    58.5   */
    58.6  
    58.7 -abstract class AbstractPollArrayWrapper {
    58.8 +public abstract class AbstractPollArrayWrapper {
    58.9  
   58.10      // Event masks
   58.11 -    static final short POLLIN       = 0x0001;
   58.12 -    static final short POLLOUT      = 0x0004;
   58.13 -    static final short POLLERR      = 0x0008;
   58.14 -    static final short POLLHUP      = 0x0010;
   58.15 -    static final short POLLNVAL     = 0x0020;
   58.16 -    static final short POLLREMOVE   = 0x0800;
   58.17 +    public static final short POLLIN       = 0x0001;
   58.18 +    public static final short POLLOUT      = 0x0004;
   58.19 +    public static final short POLLERR      = 0x0008;
   58.20 +    public static final short POLLHUP      = 0x0010;
   58.21 +    public static final short POLLNVAL     = 0x0020;
   58.22 +    public static final short POLLREMOVE   = 0x0800;
   58.23  
   58.24      // Miscellaneous constants
   58.25      static final short SIZE_POLLFD   = 8;
    59.1 --- a/src/share/classes/sun/nio/ch/AbstractPollSelectorImpl.java	Thu Feb 16 13:01:36 2012 -0800
    59.2 +++ b/src/share/classes/sun/nio/ch/AbstractPollSelectorImpl.java	Sat Feb 18 16:11:47 2012 -0800
    59.3 @@ -67,7 +67,7 @@
    59.4          this.channelOffset = offset;
    59.5      }
    59.6  
    59.7 -    void putEventOps(SelectionKeyImpl sk, int ops) {
    59.8 +    public void putEventOps(SelectionKeyImpl sk, int ops) {
    59.9          synchronized (closeLock) {
   59.10              if (closed)
   59.11                  throw new ClosedSelectorException();
    60.1 --- a/src/share/classes/sun/nio/ch/IOStatus.java	Thu Feb 16 13:01:36 2012 -0800
    60.2 +++ b/src/share/classes/sun/nio/ch/IOStatus.java	Sat Feb 18 16:11:47 2012 -0800
    60.3 @@ -28,16 +28,16 @@
    60.4  
    60.5  // Constants for reporting I/O status
    60.6  
    60.7 -final class IOStatus {
    60.8 +public final class IOStatus {
    60.9  
   60.10      private IOStatus() { }
   60.11  
   60.12 -    static final int EOF = -1;              // End of file
   60.13 -    static final int UNAVAILABLE = -2;      // Nothing available (non-blocking)
   60.14 -    static final int INTERRUPTED = -3;      // System call interrupted
   60.15 -    static final int UNSUPPORTED = -4;      // Operation not supported
   60.16 -    static final int THROWN = -5;           // Exception thrown in JNI code
   60.17 -    static final int UNSUPPORTED_CASE = -6; // This case not supported
   60.18 +    public static final int EOF = -1;              // End of file
   60.19 +    public static final int UNAVAILABLE = -2;      // Nothing available (non-blocking)
   60.20 +    public static final int INTERRUPTED = -3;      // System call interrupted
   60.21 +    public static final int UNSUPPORTED = -4;      // Operation not supported
   60.22 +    public static final int THROWN = -5;           // Exception thrown in JNI code
   60.23 +    public static final int UNSUPPORTED_CASE = -6; // This case not supported
   60.24  
   60.25      // The following two methods are for use in try/finally blocks where a
   60.26      // status value needs to be normalized before being returned to the invoker
   60.27 @@ -55,28 +55,28 @@
   60.28      //     }
   60.29      //
   60.30  
   60.31 -    static int normalize(int n) {
   60.32 +    public static int normalize(int n) {
   60.33          if (n == UNAVAILABLE)
   60.34              return 0;
   60.35          return n;
   60.36      }
   60.37  
   60.38 -    static boolean check(int n) {
   60.39 +    public static boolean check(int n) {
   60.40          return (n >= UNAVAILABLE);
   60.41      }
   60.42  
   60.43 -    static long normalize(long n) {
   60.44 +    public static long normalize(long n) {
   60.45          if (n == UNAVAILABLE)
   60.46              return 0;
   60.47          return n;
   60.48      }
   60.49  
   60.50 -    static boolean check(long n) {
   60.51 +    public static boolean check(long n) {
   60.52          return (n >= UNAVAILABLE);
   60.53      }
   60.54  
   60.55      // Return true iff n is not one of the IOStatus values
   60.56 -    static boolean checkAll(long n) {
   60.57 +    public static boolean checkAll(long n) {
   60.58          return ((n > EOF) || (n < UNSUPPORTED_CASE));
   60.59      }
   60.60  
    61.1 --- a/src/share/classes/sun/nio/ch/IOUtil.java	Thu Feb 16 13:01:36 2012 -0800
    61.2 +++ b/src/share/classes/sun/nio/ch/IOUtil.java	Sat Feb 18 16:11:47 2012 -0800
    61.3 @@ -34,7 +34,7 @@
    61.4   * File-descriptor based I/O utilities that are shared by NIO classes.
    61.5   */
    61.6  
    61.7 -class IOUtil {
    61.8 +public class IOUtil {
    61.9  
   61.10      private IOUtil() { }                // No instantiation
   61.11  
   61.12 @@ -309,7 +309,7 @@
   61.13          }
   61.14      }
   61.15  
   61.16 -    static FileDescriptor newFD(int i) {
   61.17 +    public static FileDescriptor newFD(int i) {
   61.18          FileDescriptor fd = new FileDescriptor();
   61.19          setfdVal(fd, i);
   61.20          return fd;
   61.21 @@ -326,10 +326,11 @@
   61.22  
   61.23      static native boolean drain(int fd) throws IOException;
   61.24  
   61.25 -    static native void configureBlocking(FileDescriptor fd, boolean blocking)
   61.26 +    public static native void configureBlocking(FileDescriptor fd,
   61.27 +                                                boolean blocking)
   61.28          throws IOException;
   61.29  
   61.30 -    static native int fdVal(FileDescriptor fd);
   61.31 +    public static native int fdVal(FileDescriptor fd);
   61.32  
   61.33      static native void setfdVal(FileDescriptor fd, int value);
   61.34  
    62.1 --- a/src/share/classes/sun/nio/ch/Net.java	Thu Feb 16 13:01:36 2012 -0800
    62.2 +++ b/src/share/classes/sun/nio/ch/Net.java	Sat Feb 18 16:11:47 2012 -0800
    62.3 @@ -33,7 +33,7 @@
    62.4  import java.security.PrivilegedAction;
    62.5  
    62.6  
    62.7 -class Net {                                             // package-private
    62.8 +public class Net {
    62.9  
   62.10      private Net() { }
   62.11  
   62.12 @@ -75,7 +75,7 @@
   62.13          return canJoin6WithIPv4Group0();
   62.14      }
   62.15  
   62.16 -    static InetSocketAddress checkAddress(SocketAddress sa) {
   62.17 +    public static InetSocketAddress checkAddress(SocketAddress sa) {
   62.18          if (sa == null)
   62.19              throw new NullPointerException();
   62.20          if (!(sa instanceof InetSocketAddress))
   62.21 @@ -330,7 +330,7 @@
   62.22      // Due to oddities SO_REUSEADDR on windows reuse is ignored
   62.23      private static native int socket0(boolean preferIPv6, boolean stream, boolean reuse);
   62.24  
   62.25 -    static void bind(FileDescriptor fd, InetAddress addr, int port)
   62.26 +    public static void bind(FileDescriptor fd, InetAddress addr, int port)
   62.27          throws IOException
   62.28      {
   62.29          bind(UNSPEC, fd, addr, port);
   62.30 @@ -383,7 +383,7 @@
   62.31      private static native InetAddress localInetAddress(FileDescriptor fd)
   62.32          throws IOException;
   62.33  
   62.34 -    static InetSocketAddress localAddress(FileDescriptor fd)
   62.35 +    public static InetSocketAddress localAddress(FileDescriptor fd)
   62.36          throws IOException
   62.37      {
   62.38          return new InetSocketAddress(localInetAddress(fd), localPort(fd));
    63.1 --- a/src/share/classes/sun/nio/ch/SctpMessageInfoImpl.java	Thu Feb 16 13:01:36 2012 -0800
    63.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    63.3 @@ -1,170 +0,0 @@
    63.4 -/*
    63.5 - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
    63.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    63.7 - *
    63.8 - * This code is free software; you can redistribute it and/or modify it
    63.9 - * under the terms of the GNU General Public License version 2 only, as
   63.10 - * published by the Free Software Foundation.  Oracle designates this
   63.11 - * particular file as subject to the "Classpath" exception as provided
   63.12 - * by Oracle in the LICENSE file that accompanied this code.
   63.13 - *
   63.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   63.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   63.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   63.17 - * version 2 for more details (a copy is included in the LICENSE file that
   63.18 - * accompanied this code).
   63.19 - *
   63.20 - * You should have received a copy of the GNU General Public License version
   63.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   63.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   63.23 - *
   63.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   63.25 - * or visit www.oracle.com if you need additional information or have any
   63.26 - * questions.
   63.27 - */
   63.28 -package sun.nio.ch;
   63.29 -
   63.30 -import java.net.SocketAddress;
   63.31 -import com.sun.nio.sctp.MessageInfo;
   63.32 -import com.sun.nio.sctp.Association;
   63.33 -
   63.34 -/**
   63.35 - * An implementation of a MessageInfo.
   63.36 - */
   63.37 -public class SctpMessageInfoImpl extends MessageInfo {
   63.38 -    private final SocketAddress address;
   63.39 -    private final int bytes;          /* 0 */
   63.40 -
   63.41 -    private Association association;
   63.42 -    private int assocId;
   63.43 -    private int streamNumber;
   63.44 -    private boolean complete = true;
   63.45 -    private boolean unordered;  /* false */
   63.46 -    private long timeToLive;    /* 0L */
   63.47 -    private int ppid;           /* 0 */
   63.48 -
   63.49 -    public SctpMessageInfoImpl(Association association,
   63.50 -                               SocketAddress address,
   63.51 -                               int streamNumber) {
   63.52 -        this.association = association;
   63.53 -        this.address = address;
   63.54 -        this.streamNumber = streamNumber;
   63.55 -        bytes = 0;
   63.56 -    }
   63.57 -
   63.58 -    /* Invoked from native */
   63.59 -    private SctpMessageInfoImpl(int assocId,
   63.60 -                                SocketAddress address,
   63.61 -                                int bytes,
   63.62 -                                int streamNumber,
   63.63 -                                boolean complete,
   63.64 -                                boolean unordered,
   63.65 -                                int ppid) {
   63.66 -        this.assocId = assocId;
   63.67 -        this.address = address;
   63.68 -        this.bytes = bytes;
   63.69 -        this.streamNumber = streamNumber;
   63.70 -        this.complete = complete;
   63.71 -        this.unordered = unordered;
   63.72 -        this.ppid = ppid;
   63.73 -    }
   63.74 -
   63.75 -    @Override
   63.76 -    public Association association() {
   63.77 -        return association;
   63.78 -    }
   63.79 -
   63.80 -    /**
   63.81 -     * SctpMessageInfoImpl instances created from native will need to have their
   63.82 -     * association set from the channel.
   63.83 -     */
   63.84 -    void setAssociation(Association association) {
   63.85 -        this.association = association;
   63.86 -    }
   63.87 -
   63.88 -    int associationID() {
   63.89 -        return assocId;
   63.90 -    }
   63.91 -
   63.92 -    @Override
   63.93 -    public SocketAddress address() {
   63.94 -        return address;
   63.95 -    }
   63.96 -
   63.97 -    @Override
   63.98 -    public int bytes() {
   63.99 -        return bytes;
  63.100 -    }
  63.101 -
  63.102 -    @Override
  63.103 -    public int streamNumber() {
  63.104 -        return streamNumber;
  63.105 -    }
  63.106 -
  63.107 -    @Override
  63.108 -    public MessageInfo streamNumber(int streamNumber) {
  63.109 -        if (streamNumber < 0 || streamNumber > 65536)
  63.110 -            throw new IllegalArgumentException("Invalid stream number");
  63.111 -
  63.112 -        this.streamNumber = streamNumber;
  63.113 -        return this;
  63.114 -    }
  63.115 -
  63.116 -    @Override
  63.117 -    public int payloadProtocolID() {
  63.118 -        return ppid;
  63.119 -    }
  63.120 -
  63.121 -    @Override
  63.122 -    public MessageInfo payloadProtocolID(int ppid) {
  63.123 -        this.ppid = ppid;
  63.124 -        return this;
  63.125 -    }
  63.126 -
  63.127 -    @Override
  63.128 -    public boolean isComplete() {
  63.129 -        return complete;
  63.130 -    }
  63.131 -
  63.132 -    @Override
  63.133 -    public MessageInfo complete(boolean complete) {
  63.134 -        this.complete = complete;
  63.135 -        return this;
  63.136 -    }
  63.137 -
  63.138 -    @Override
  63.139 -    public boolean isUnordered() {
  63.140 -        return unordered;
  63.141 -    }
  63.142 -
  63.143 -    @Override
  63.144 -    public MessageInfo unordered(boolean unordered) {
  63.145 -        this.unordered = unordered;
  63.146 -        return this;
  63.147 -    }
  63.148 -
  63.149 -    @Override
  63.150 -    public long timeToLive() {
  63.151 -        return timeToLive;
  63.152 -    }
  63.153 -
  63.154 -    @Override
  63.155 -    public MessageInfo timeToLive(long millis) {
  63.156 -        timeToLive = millis;
  63.157 -        return this;
  63.158 -    }
  63.159 -
  63.160 -    @Override
  63.161 -    public String toString() {
  63.162 -        StringBuilder sb = new StringBuilder(super.toString());
  63.163 -        sb.append( "[Address: ").append(address)
  63.164 -          .append(", Association: ").append(association)
  63.165 -          .append(", Assoc ID: ").append(assocId)
  63.166 -          .append(", Bytes: ").append(bytes)
  63.167 -          .append(", Stream Number: ").append(streamNumber)
  63.168 -          .append(", Complete: ").append(complete)
  63.169 -          .append(", isUnordered: ").append(unordered)
  63.170 -          .append("]");
  63.171 -        return sb.toString();
  63.172 -    }
  63.173 -}
    64.1 --- a/src/share/classes/sun/nio/ch/SctpStdSocketOption.java	Thu Feb 16 13:01:36 2012 -0800
    64.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    64.3 @@ -1,76 +0,0 @@
    64.4 -/*
    64.5 - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
    64.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    64.7 - *
    64.8 - * This code is free software; you can redistribute it and/or modify it
    64.9 - * under the terms of the GNU General Public License version 2 only, as
   64.10 - * published by the Free Software Foundation.  Oracle designates this
   64.11 - * particular file as subject to the "Classpath" exception as provided
   64.12 - * by Oracle in the LICENSE file that accompanied this code.
   64.13 - *
   64.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   64.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   64.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   64.17 - * version 2 for more details (a copy is included in the LICENSE file that
   64.18 - * accompanied this code).
   64.19 - *
   64.20 - * You should have received a copy of the GNU General Public License version
   64.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   64.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   64.23 - *
   64.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   64.25 - * or visit www.oracle.com if you need additional information or have any
   64.26 - * questions.
   64.27 - */
   64.28 -package sun.nio.ch;
   64.29 -
   64.30 -import com.sun.nio.sctp.SctpSocketOption;
   64.31 -
   64.32 -public class SctpStdSocketOption<T>
   64.33 -    implements SctpSocketOption<T>
   64.34 -{
   64.35 -    /* for native mapping of int options */
   64.36 -    public static final int SCTP_DISABLE_FRAGMENTS = 1;
   64.37 -    public static final int SCTP_EXPLICIT_COMPLETE = 2;
   64.38 -    public static final int SCTP_FRAGMENT_INTERLEAVE = 3;
   64.39 -    public static final int SCTP_NODELAY = 4;
   64.40 -    public static final int SO_SNDBUF = 5;
   64.41 -    public static final int SO_RCVBUF = 6;
   64.42 -    public static final int SO_LINGER = 7;
   64.43 -
   64.44 -    private final String name;
   64.45 -    private final Class<T> type;
   64.46 -
   64.47 -    /* for native mapping of int options */
   64.48 -    private int constValue;
   64.49 -
   64.50 -    public SctpStdSocketOption(String name, Class<T> type) {
   64.51 -        this.name = name;
   64.52 -        this.type = type;
   64.53 -    }
   64.54 -
   64.55 -    public SctpStdSocketOption(String name, Class<T> type, int constValue) {
   64.56 -        this.name = name;
   64.57 -        this.type = type;
   64.58 -        this.constValue = constValue;
   64.59 -    }
   64.60 -
   64.61 -    @Override
   64.62 -    public String name() {
   64.63 -        return name;
   64.64 -    }
   64.65 -
   64.66 -    @Override
   64.67 -    public Class<T> type() {
   64.68 -        return type;
   64.69 -    }
   64.70 -
   64.71 -    @Override
   64.72 -    public String toString() {
   64.73 -        return name;
   64.74 -    }
   64.75 -
   64.76 -    int constValue() {
   64.77 -        return constValue;
   64.78 -    }
   64.79 -}
    65.1 --- a/src/share/classes/sun/nio/ch/SelChImpl.java	Thu Feb 16 13:01:36 2012 -0800
    65.2 +++ b/src/share/classes/sun/nio/ch/SelChImpl.java	Sat Feb 18 16:11:47 2012 -0800
    65.3 @@ -36,7 +36,7 @@
    65.4   * @since 1.4
    65.5   */
    65.6  
    65.7 -interface SelChImpl extends Channel {
    65.8 +public interface SelChImpl extends Channel {
    65.9  
   65.10      FileDescriptor getFD();
   65.11  
    66.1 --- a/src/share/classes/sun/nio/ch/SelectionKeyImpl.java	Thu Feb 16 13:01:36 2012 -0800
    66.2 +++ b/src/share/classes/sun/nio/ch/SelectionKeyImpl.java	Sat Feb 18 16:11:47 2012 -0800
    66.3 @@ -34,12 +34,12 @@
    66.4   * An implementation of SelectionKey for Solaris.
    66.5   */
    66.6  
    66.7 -class SelectionKeyImpl
    66.8 +public class SelectionKeyImpl
    66.9      extends AbstractSelectionKey
   66.10  {
   66.11  
   66.12      final SelChImpl channel;                            // package-private
   66.13 -    final SelectorImpl selector;                        // package-private
   66.14 +    public final SelectorImpl selector;
   66.15  
   66.16      // Index for a pollfd array in Selector that this key is registered with
   66.17      private int index;
   66.18 @@ -91,15 +91,15 @@
   66.19      // The nio versions of these operations do not care if a key
   66.20      // has been invalidated. They are for internal use by nio code.
   66.21  
   66.22 -    void nioReadyOps(int ops) {                 // package-private
   66.23 +    public void nioReadyOps(int ops) {
   66.24          readyOps = ops;
   66.25      }
   66.26  
   66.27 -    int nioReadyOps() {                         // package-private
   66.28 +    public int nioReadyOps() {
   66.29          return readyOps;
   66.30      }
   66.31  
   66.32 -    SelectionKey nioInterestOps(int ops) {      // package-private
   66.33 +    public SelectionKey nioInterestOps(int ops) {
   66.34          if ((ops & ~channel().validOps()) != 0)
   66.35              throw new IllegalArgumentException();
   66.36          channel.translateAndSetInterestOps(ops, this);
   66.37 @@ -107,7 +107,7 @@
   66.38          return this;
   66.39      }
   66.40  
   66.41 -    int nioInterestOps() {                       // package-private
   66.42 +    public int nioInterestOps() {
   66.43          return interestOps;
   66.44      }
   66.45  
    67.1 --- a/src/share/classes/sun/nio/ch/SelectorImpl.java	Thu Feb 16 13:01:36 2012 -0800
    67.2 +++ b/src/share/classes/sun/nio/ch/SelectorImpl.java	Sat Feb 18 16:11:47 2012 -0800
    67.3 @@ -36,7 +36,7 @@
    67.4   * Base Selector implementation class.
    67.5   */
    67.6  
    67.7 -abstract class SelectorImpl
    67.8 +public abstract class SelectorImpl
    67.9      extends AbstractSelector
   67.10  {
   67.11  
   67.12 @@ -118,7 +118,7 @@
   67.13  
   67.14      protected abstract void implClose() throws IOException;
   67.15  
   67.16 -    void putEventOps(SelectionKeyImpl sk, int ops) { }
   67.17 +    public void putEventOps(SelectionKeyImpl sk, int ops) { }
   67.18  
   67.19      protected final SelectionKey register(AbstractSelectableChannel ch,
   67.20                                            int ops,
    68.1 --- a/src/share/classes/sun/nio/ch/Util.java	Thu Feb 16 13:01:36 2012 -0800
    68.2 +++ b/src/share/classes/sun/nio/ch/Util.java	Sat Feb 18 16:11:47 2012 -0800
    68.3 @@ -40,7 +40,7 @@
    68.4  import sun.security.action.GetPropertyAction;
    68.5  
    68.6  
    68.7 -class Util {
    68.8 +public class Util {
    68.9  
   68.10      // -- Caches --
   68.11  
   68.12 @@ -158,7 +158,7 @@
   68.13      /**
   68.14       * Returns a temporary buffer of at least the given size
   68.15       */
   68.16 -    static ByteBuffer getTemporaryDirectBuffer(int size) {
   68.17 +    public static ByteBuffer getTemporaryDirectBuffer(int size) {
   68.18          BufferCache cache = bufferCache.get();
   68.19          ByteBuffer buf = cache.get(size);
   68.20          if (buf != null) {
   68.21 @@ -178,7 +178,7 @@
   68.22      /**
   68.23       * Releases a temporary buffer by returning to the cache or freeing it.
   68.24       */
   68.25 -    static void releaseTemporaryDirectBuffer(ByteBuffer buf) {
   68.26 +    public static void releaseTemporaryDirectBuffer(ByteBuffer buf) {
   68.27          offerFirstTemporaryDirectBuffer(buf);
   68.28      }
   68.29  
   68.30 @@ -467,7 +467,7 @@
   68.31  
   68.32      private static boolean loaded = false;
   68.33  
   68.34 -    static void load() {
   68.35 +    public static void load() {
   68.36          synchronized (Util.class) {
   68.37              if (loaded)
   68.38                  return;
    69.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    69.2 +++ b/src/share/classes/sun/nio/ch/sctp/MessageInfoImpl.java	Sat Feb 18 16:11:47 2012 -0800
    69.3 @@ -0,0 +1,170 @@
    69.4 +/*
    69.5 + * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
    69.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    69.7 + *
    69.8 + * This code is free software; you can redistribute it and/or modify it
    69.9 + * under the terms of the GNU General Public License version 2 only, as
   69.10 + * published by the Free Software Foundation.  Oracle designates this
   69.11 + * particular file as subject to the "Classpath" exception as provided
   69.12 + * by Oracle in the LICENSE file that accompanied this code.
   69.13 + *
   69.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
   69.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   69.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   69.17 + * version 2 for more details (a copy is included in the LICENSE file that
   69.18 + * accompanied this code).
   69.19 + *
   69.20 + * You should have received a copy of the GNU General Public License version
   69.21 + * 2 along with this work; if not, write to the Free Software Foundation,
   69.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   69.23 + *
   69.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   69.25 + * or visit www.oracle.com if you need additional information or have any
   69.26 + * questions.
   69.27 + */
   69.28 +package sun.nio.ch.sctp;
   69.29 +
   69.30 +import java.net.SocketAddress;
   69.31 +import com.sun.nio.sctp.MessageInfo;
   69.32 +import com.sun.nio.sctp.Association;
   69.33 +
   69.34 +/**
   69.35 + * An implementation of a MessageInfo.
   69.36 + */
   69.37 +public class MessageInfoImpl extends MessageInfo {
   69.38 +    private final SocketAddress address;
   69.39 +    private final int bytes;          /* 0 */
   69.40 +
   69.41 +    private Association association;
   69.42 +    private int assocId;
   69.43 +    private int streamNumber;
   69.44 +    private boolean complete = true;
   69.45 +    private boolean unordered;  /* false */
   69.46 +    private long timeToLive;    /* 0L */
   69.47 +    private int ppid;           /* 0 */
   69.48 +
   69.49 +    public MessageInfoImpl(Association association,
   69.50 +                           SocketAddress address,
   69.51 +                           int streamNumber) {
   69.52 +        this.association = association;
   69.53 +        this.address = address;
   69.54 +        this.streamNumber = streamNumber;
   69.55 +        bytes = 0;
   69.56 +    }
   69.57 +
   69.58 +    /* Invoked from native */
   69.59 +    private MessageInfoImpl(int assocId,
   69.60 +                            SocketAddress address,
   69.61 +                            int bytes,
   69.62 +                            int streamNumber,
   69.63 +                            boolean complete,
   69.64 +                            boolean unordered,
   69.65 +                            int ppid) {
   69.66 +        this.assocId = assocId;
   69.67 +        this.address = address;
   69.68 +        this.bytes = bytes;
   69.69 +        this.streamNumber = streamNumber;
   69.70 +        this.complete = complete;
   69.71 +        this.unordered = unordered;
   69.72 +        this.ppid = ppid;
   69.73 +    }
   69.74 +
   69.75 +    @Override
   69.76 +    public Association association() {
   69.77 +        return association;
   69.78 +    }
   69.79 +
   69.80 +    /**
   69.81 +     * MessageInfoImpl instances created from native will need to have their
   69.82 +     * association set from the channel.
   69.83 +     */
   69.84 +    void setAssociation(Association association) {
   69.85 +        this.association = association;
   69.86 +    }
   69.87 +
   69.88 +    int associationID() {
   69.89 +        return assocId;
   69.90 +    }
   69.91 +
   69.92 +    @Override
   69.93 +    public SocketAddress address() {
   69.94 +        return address;
   69.95 +    }
   69.96 +
   69.97 +    @Override
   69.98 +    public int bytes() {
   69.99 +        return bytes;
  69.100 +    }
  69.101 +
  69.102 +    @Override
  69.103 +    public int streamNumber() {
  69.104 +        return streamNumber;
  69.105 +    }
  69.106 +
  69.107 +    @Override
  69.108 +    public MessageInfo streamNumber(int streamNumber) {
  69.109 +        if (streamNumber < 0 || streamNumber > 65536)
  69.110 +            throw new IllegalArgumentException("Invalid stream number");
  69.111 +
  69.112 +        this.streamNumber = streamNumber;
  69.113 +        return this;
  69.114 +    }
  69.115 +
  69.116 +    @Override
  69.117 +    public int payloadProtocolID() {
  69.118 +        return ppid;
  69.119 +    }
  69.120 +
  69.121 +    @Override
  69.122 +    public MessageInfo payloadProtocolID(int ppid) {
  69.123 +        this.ppid = ppid;
  69.124 +        return this;
  69.125 +    }
  69.126 +
  69.127 +    @Override
  69.128 +    public boolean isComplete() {
  69.129 +        return complete;
  69.130 +    }
  69.131 +
  69.132 +    @Override
  69.133 +    public MessageInfo complete(boolean complete) {
  69.134 +        this.complete = complete;
  69.135 +        return this;
  69.136 +    }
  69.137 +
  69.138 +    @Override
  69.139 +    public boolean isUnordered() {
  69.140 +        return unordered;
  69.141 +    }
  69.142 +
  69.143 +    @Override
  69.144 +    public MessageInfo unordered(boolean unordered) {
  69.145 +        this.unordered = unordered;
  69.146 +        return this;
  69.147 +    }
  69.148 +
  69.149 +    @Override
  69.150 +    public long timeToLive() {
  69.151 +        return timeToLive;
  69.152 +    }
  69.153 +
  69.154 +    @Override
  69.155 +    public MessageInfo timeToLive(long millis) {
  69.156 +        timeToLive = millis;
  69.157 +        return this;
  69.158 +    }
  69.159 +
  69.160 +    @Override
  69.161 +    public String toString() {
  69.162 +        StringBuilder sb = new StringBuilder(super.toString());
  69.163 +        sb.append( "[Address: ").append(address)
  69.164 +          .append(", Association: ").append(association)
  69.165 +          .append(", Assoc ID: ").append(assocId)
  69.166 +          .append(", Bytes: ").append(bytes)
  69.167 +          .append(", Stream Number: ").append(streamNumber)
  69.168 +          .append(", Complete: ").append(complete)
  69.169 +          .append(", isUnordered: ").append(unordered)
  69.170 +          .append("]");
  69.171 +        return sb.toString();
  69.172 +    }
  69.173 +}
    70.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    70.2 +++ b/src/share/classes/sun/nio/ch/sctp/SctpStdSocketOption.java	Sat Feb 18 16:11:47 2012 -0800
    70.3 @@ -0,0 +1,76 @@
    70.4 +/*
    70.5 + * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
    70.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    70.7 + *
    70.8 + * This code is free software; you can redistribute it and/or modify it
    70.9 + * under the terms of the GNU General Public License version 2 only, as
   70.10 + * published by the Free Software Foundation.  Oracle designates this
   70.11 + * particular file as subject to the "Classpath" exception as provided
   70.12 + * by Oracle in the LICENSE file that accompanied this code.
   70.13 + *
   70.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
   70.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   70.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   70.17 + * version 2 for more details (a copy is included in the LICENSE file that
   70.18 + * accompanied this code).
   70.19 + *
   70.20 + * You should have received a copy of the GNU General Public License version
   70.21 + * 2 along with this work; if not, write to the Free Software Foundation,
   70.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   70.23 + *
   70.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   70.25 + * or visit www.oracle.com if you need additional information or have any
   70.26 + * questions.
   70.27 + */
   70.28 +package sun.nio.ch.sctp;
   70.29 +
   70.30 +import com.sun.nio.sctp.SctpSocketOption;
   70.31 +
   70.32 +public class SctpStdSocketOption<T>
   70.33 +    implements SctpSocketOption<T>
   70.34 +{
   70.35 +    /* for native mapping of int options */
   70.36 +    public static final int SCTP_DISABLE_FRAGMENTS = 1;
   70.37 +    public static final int SCTP_EXPLICIT_COMPLETE = 2;
   70.38 +    public static final int SCTP_FRAGMENT_INTERLEAVE = 3;
   70.39 +    public static final int SCTP_NODELAY = 4;
   70.40 +    public static final int SO_SNDBUF = 5;
   70.41 +    public static final int SO_RCVBUF = 6;
   70.42 +    public static final int SO_LINGER = 7;
   70.43 +
   70.44 +    private final String name;
   70.45 +    private final Class<T> type;
   70.46 +
   70.47 +    /* for native mapping of int options */
   70.48 +    private int constValue;
   70.49 +
   70.50 +    public SctpStdSocketOption(String name, Class<T> type) {
   70.51 +        this.name = name;
   70.52 +        this.type = type;
   70.53 +    }
   70.54 +
   70.55 +    public SctpStdSocketOption(String name, Class<T> type, int constValue) {
   70.56 +        this.name = name;
   70.57 +        this.type = type;
   70.58 +        this.constValue = constValue;
   70.59 +    }
   70.60 +
   70.61 +    @Override
   70.62 +    public String name() {
   70.63 +        return name;
   70.64 +    }
   70.65 +
   70.66 +    @Override
   70.67 +    public Class<T> type() {
   70.68 +        return type;
   70.69 +    }
   70.70 +
   70.71 +    @Override
   70.72 +    public String toString() {
   70.73 +        return name;
   70.74 +    }
   70.75 +
   70.76 +    int constValue() {
   70.77 +        return constValue;
   70.78 +    }
   70.79 +}
    71.1 --- a/src/share/classes/sun/security/pkcs/PKCS7.java	Thu Feb 16 13:01:36 2012 -0800
    71.2 +++ b/src/share/classes/sun/security/pkcs/PKCS7.java	Sat Feb 18 16:11:47 2012 -0800
    71.3 @@ -1,5 +1,5 @@
    71.4  /*
    71.5 - * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
    71.6 + * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
    71.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    71.8   *
    71.9   * This code is free software; you can redistribute it and/or modify it
   71.10 @@ -72,16 +72,19 @@
   71.11  
   71.12      /*
   71.13       * Random number generator for creating nonce values
   71.14 +     * (Lazy initialization)
   71.15       */
   71.16 -    private static final SecureRandom RANDOM;
   71.17 -    static {
   71.18 -        SecureRandom tmp = null;
   71.19 -        try {
   71.20 -            tmp = SecureRandom.getInstance("SHA1PRNG");
   71.21 -        } catch (NoSuchAlgorithmException e) {
   71.22 -            // should not happen
   71.23 +    private static class SecureRandomHolder {
   71.24 +        static final SecureRandom RANDOM;
   71.25 +        static {
   71.26 +            SecureRandom tmp = null;
   71.27 +            try {
   71.28 +                tmp = SecureRandom.getInstance("SHA1PRNG");
   71.29 +            } catch (NoSuchAlgorithmException e) {
   71.30 +                // should not happen
   71.31 +            }
   71.32 +            RANDOM = tmp;
   71.33          }
   71.34 -        RANDOM = tmp;
   71.35      }
   71.36  
   71.37      /*
   71.38 @@ -862,8 +865,8 @@
   71.39  
   71.40          // Generate a nonce
   71.41          BigInteger nonce = null;
   71.42 -        if (RANDOM != null) {
   71.43 -            nonce = new BigInteger(64, RANDOM);
   71.44 +        if (SecureRandomHolder.RANDOM != null) {
   71.45 +            nonce = new BigInteger(64, SecureRandomHolder.RANDOM);
   71.46              tsQuery.setNonce(nonce);
   71.47          }
   71.48          tsQuery.requestCertificate(true);
    72.1 --- a/src/share/classes/sun/security/pkcs12/PKCS12KeyStore.java	Thu Feb 16 13:01:36 2012 -0800
    72.2 +++ b/src/share/classes/sun/security/pkcs12/PKCS12KeyStore.java	Sat Feb 18 16:11:47 2012 -0800
    72.3 @@ -253,11 +253,25 @@
    72.4          }
    72.5  
    72.6          try {
    72.7 -            // Use JCE
    72.8 -            SecretKey skey = getPBEKey(password);
    72.9 -            Cipher cipher = Cipher.getInstance(algOid.toString());
   72.10 -            cipher.init(Cipher.DECRYPT_MODE, skey, algParams);
   72.11 -            byte[] privateKeyInfo = cipher.doFinal(encryptedKey);
   72.12 +            byte[] privateKeyInfo;
   72.13 +            while (true) {
   72.14 +                try {
   72.15 +                    // Use JCE
   72.16 +                    SecretKey skey = getPBEKey(password);
   72.17 +                    Cipher cipher = Cipher.getInstance(algOid.toString());
   72.18 +                    cipher.init(Cipher.DECRYPT_MODE, skey, algParams);
   72.19 +                    privateKeyInfo = cipher.doFinal(encryptedKey);
   72.20 +                    break;
   72.21 +                } catch (Exception e) {
   72.22 +                    if (password.length == 0) {
   72.23 +                        // Retry using an empty password
   72.24 +                        // without a NULL terminator.
   72.25 +                        password = new char[1];
   72.26 +                        continue;
   72.27 +                    }
   72.28 +                    throw e;
   72.29 +                }
   72.30 +            }
   72.31  
   72.32              PKCS8EncodedKeySpec kspec = new PKCS8EncodedKeySpec(privateKeyInfo);
   72.33  
   72.34 @@ -1251,16 +1265,24 @@
   72.35                  ObjectIdentifier algOid = in.getOID();
   72.36                  AlgorithmParameters algParams = parseAlgParameters(in);
   72.37  
   72.38 -                try {
   72.39 -                    // Use JCE
   72.40 -                    SecretKey skey = getPBEKey(password);
   72.41 -                    Cipher cipher = Cipher.getInstance(algOid.toString());
   72.42 -                    cipher.init(Cipher.DECRYPT_MODE, skey, algParams);
   72.43 -                    safeContentsData = cipher.doFinal(safeContentsData);
   72.44 -
   72.45 -                } catch (Exception e) {
   72.46 -                    throw new IOException("failed to decrypt safe"
   72.47 -                            + " contents entry: " + e, e);
   72.48 +                while (true) {
   72.49 +                    try {
   72.50 +                        // Use JCE
   72.51 +                        SecretKey skey = getPBEKey(password);
   72.52 +                        Cipher cipher = Cipher.getInstance(algOid.toString());
   72.53 +                        cipher.init(Cipher.DECRYPT_MODE, skey, algParams);
   72.54 +                        safeContentsData = cipher.doFinal(safeContentsData);
   72.55 +                        break;
   72.56 +                    } catch (Exception e) {
   72.57 +                        if (password.length == 0) {
   72.58 +                            // Retry using an empty password
   72.59 +                            // without a NULL terminator.
   72.60 +                            password = new char[1];
   72.61 +                            continue;
   72.62 +                        }
   72.63 +                        throw new IOException(
   72.64 +                                "failed to decrypt safe contents entry: " + e, e);
   72.65 +                    }
   72.66                  }
   72.67              } else {
   72.68                  throw new IOException("public key protected PKCS12" +
    73.1 --- a/src/share/classes/sun/tools/jar/CommandLine.java	Thu Feb 16 13:01:36 2012 -0800
    73.2 +++ b/src/share/classes/sun/tools/jar/CommandLine.java	Sat Feb 18 16:11:47 2012 -0800
    73.3 @@ -55,7 +55,7 @@
    73.4      public static String[] parse(String[] args)
    73.5          throws IOException
    73.6      {
    73.7 -        ArrayList newArgs = new ArrayList(args.length);
    73.8 +        List<String> newArgs = new ArrayList<>(args.length);
    73.9          for (int i = 0; i < args.length; i++) {
   73.10              String arg = args[i];
   73.11              if (arg.length() > 1 && arg.charAt(0) == '@') {
   73.12 @@ -69,10 +69,10 @@
   73.13                  newArgs.add(arg);
   73.14              }
   73.15          }
   73.16 -        return (String[])newArgs.toArray(new String[newArgs.size()]);
   73.17 +        return newArgs.toArray(new String[newArgs.size()]);
   73.18      }
   73.19  
   73.20 -    private static void loadCmdFile(String name, List args)
   73.21 +    private static void loadCmdFile(String name, List<String> args)
   73.22          throws IOException
   73.23      {
   73.24          Reader r = new BufferedReader(new FileReader(name));
   73.25 @@ -83,7 +83,7 @@
   73.26          st.commentChar('#');
   73.27          st.quoteChar('"');
   73.28          st.quoteChar('\'');
   73.29 -        while (st.nextToken() != st.TT_EOF) {
   73.30 +        while (st.nextToken() != StreamTokenizer.TT_EOF) {
   73.31              args.add(st.sval);
   73.32          }
   73.33          r.close();
    74.1 --- a/src/share/classes/sun/tools/jar/Manifest.java	Thu Feb 16 13:01:36 2012 -0800
    74.2 +++ b/src/share/classes/sun/tools/jar/Manifest.java	Sat Feb 18 16:11:47 2012 -0800
    74.3 @@ -47,10 +47,10 @@
    74.4      /* list of headers that all pertain to a particular
    74.5       * file in the archive
    74.6       */
    74.7 -    private Vector entries = new Vector();
    74.8 +    private Vector<MessageHeader> entries = new Vector<>();
    74.9      private byte[] tmpbuf = new byte[512];
   74.10      /* a hashtable of entries, for fast lookup */
   74.11 -    private Hashtable tableEntries = new Hashtable();
   74.12 +    private Hashtable<String, MessageHeader> tableEntries = new Hashtable<>();
   74.13  
   74.14      static final String[] hashes = {"SHA"};
   74.15      static final byte[] EOL = {(byte)'\r', (byte)'\n'};
   74.16 @@ -115,14 +115,14 @@
   74.17      }
   74.18  
   74.19      public MessageHeader getEntry(String name) {
   74.20 -        return (MessageHeader) tableEntries.get(name);
   74.21 +        return tableEntries.get(name);
   74.22      }
   74.23  
   74.24      public MessageHeader entryAt(int i) {
   74.25 -        return (MessageHeader) entries.elementAt(i);
   74.26 +        return entries.elementAt(i);
   74.27      }
   74.28  
   74.29 -    public Enumeration entries() {
   74.30 +    public Enumeration<MessageHeader> entries() {
   74.31          return entries.elements();
   74.32      }
   74.33  
   74.34 @@ -214,7 +214,7 @@
   74.35          /* the first header in the file should be the global one.
   74.36           * It should say "Manifest-Version: x.x"; if not add it
   74.37           */
   74.38 -        MessageHeader globals = (MessageHeader) entries.elementAt(0);
   74.39 +        MessageHeader globals = entries.elementAt(0);
   74.40  
   74.41          if (globals.findValue("Manifest-Version") == null) {
   74.42              /* Assume this is a user-defined manifest.  If it has a Name: <..>
   74.43 @@ -238,7 +238,7 @@
   74.44          globals.print(ps);
   74.45  
   74.46          for (int i = 1; i < entries.size(); ++i) {
   74.47 -            MessageHeader mh = (MessageHeader) entries.elementAt(i);
   74.48 +            MessageHeader mh = entries.elementAt(i);
   74.49              mh.print(ps);
   74.50          }
   74.51      }
    75.1 --- a/src/share/classes/sun/tools/jar/SignatureFile.java	Thu Feb 16 13:01:36 2012 -0800
    75.2 +++ b/src/share/classes/sun/tools/jar/SignatureFile.java	Sat Feb 18 16:11:47 2012 -0800
    75.3 @@ -47,7 +47,7 @@
    75.4   *
    75.5   * <p>Each entry section contains the name of an entry (which must
    75.6   * have a counterpart in the manifest). Like the manifest it contains
    75.7 - * a hash, the hash of the manifest section correspondind to the
    75.8 + * a hash, the hash of the manifest section corresponding to the
    75.9   * name. Since the manifest entry contains the hash of the data, this
   75.10   * is equivalent to a signature of the data, plus the attributes of
   75.11   * the manifest entry.
   75.12 @@ -66,7 +66,7 @@
   75.13  
   75.14      /* list of headers that all pertain to a particular file in the
   75.15       * archive */
   75.16 -    private Vector entries = new Vector();
   75.17 +    private Vector<MessageHeader> entries = new Vector<>();
   75.18  
   75.19      /* Right now we only support SHA hashes */
   75.20      static final String[] hashes = {"SHA"};
   75.21 @@ -98,7 +98,7 @@
   75.22       * character in length.  */
   75.23      private SignatureFile(String name) throws JarException {
   75.24  
   75.25 -        entries = new Vector();
   75.26 +        entries = new Vector<>();
   75.27  
   75.28          if (name != null) {
   75.29              if (name.length() > 8 || name.indexOf('.') != -1) {
   75.30 @@ -142,9 +142,9 @@
   75.31          this(name, true);
   75.32  
   75.33          this.manifest = manifest;
   75.34 -        Enumeration enum_ = manifest.entries();
   75.35 +        Enumeration<MessageHeader> enum_ = manifest.entries();
   75.36          while (enum_.hasMoreElements()) {
   75.37 -            MessageHeader mh = (MessageHeader)enum_.nextElement();
   75.38 +            MessageHeader mh = enum_.nextElement();
   75.39              String entryName = mh.findValue("Name");
   75.40              if (entryName != null) {
   75.41                  add(entryName);
   75.42 @@ -269,9 +269,9 @@
   75.43       *the entry does not exist.
   75.44       */
   75.45      public MessageHeader getEntry(String name) {
   75.46 -        Enumeration enum_ = entries();
   75.47 +        Enumeration<MessageHeader> enum_ = entries();
   75.48          while(enum_.hasMoreElements()) {
   75.49 -            MessageHeader mh = (MessageHeader)enum_.nextElement();
   75.50 +            MessageHeader mh = enum_.nextElement();
   75.51              if (name.equals(mh.findValue("Name"))) {
   75.52                  return mh;
   75.53              }
   75.54 @@ -282,13 +282,13 @@
   75.55      /**
   75.56       * Returns the n-th entry. The global header is a entry 0.  */
   75.57      public MessageHeader entryAt(int n) {
   75.58 -        return (MessageHeader) entries.elementAt(n);
   75.59 +        return entries.elementAt(n);
   75.60      }
   75.61  
   75.62      /**
   75.63       * Returns an enumeration of the entries.
   75.64       */
   75.65 -    public Enumeration entries() {
   75.66 +    public Enumeration<MessageHeader> entries() {
   75.67          return entries.elements();
   75.68      }
   75.69  
   75.70 @@ -322,11 +322,11 @@
   75.71          }
   75.72      }
   75.73  
   75.74 -    private Hashtable digests = new Hashtable();
   75.75 +    private Hashtable<String, MessageDigest> digests = new Hashtable<>();
   75.76  
   75.77      private MessageDigest getDigest(String algorithm)
   75.78      throws NoSuchAlgorithmException {
   75.79 -        MessageDigest dig = (MessageDigest)digests.get(algorithm);
   75.80 +        MessageDigest dig = digests.get(algorithm);
   75.81          if (dig == null) {
   75.82              dig = MessageDigest.getInstance(algorithm);
   75.83              digests.put(algorithm, dig);
   75.84 @@ -344,7 +344,7 @@
   75.85          /* the first header in the file should be the global one.
   75.86           * It should say "SignatureFile-Version: x.x"; barf if not
   75.87           */
   75.88 -        MessageHeader globals = (MessageHeader) entries.elementAt(0);
   75.89 +        MessageHeader globals = entries.elementAt(0);
   75.90          if (globals.findValue("Signature-Version") == null) {
   75.91              throw new JarException("Signature file requires " +
   75.92                              "Signature-Version: 1.0 in 1st header");
   75.93 @@ -354,7 +354,7 @@
   75.94          globals.print(ps);
   75.95  
   75.96          for (int i = 1; i < entries.size(); ++i) {
   75.97 -            MessageHeader mh = (MessageHeader) entries.elementAt(i);
   75.98 +            MessageHeader mh = entries.elementAt(i);
   75.99              mh.print(ps);
  75.100          }
  75.101      }
    76.1 --- a/src/share/demo/management/MemoryMonitor/MemoryMonitor.java	Thu Feb 16 13:01:36 2012 -0800
    76.2 +++ b/src/share/demo/management/MemoryMonitor/MemoryMonitor.java	Sat Feb 18 16:11:47 2012 -0800
    76.3 @@ -213,10 +213,10 @@
    76.4  
    76.5              // Calculate remaining size
    76.6              float ssH = ascent + descent;
    76.7 -            float remainingHeight = (float) (y2 - (ssH*2) - 0.5f);
    76.8 +            float remainingHeight = y2 - (ssH*2) - 0.5f;
    76.9              float blockHeight = remainingHeight/10;
   76.10              float blockWidth = 20.0f;
   76.11 -            float remainingWidth = (float) (x2 - blockWidth - 10);
   76.12 +            float remainingWidth = x2 - blockWidth - 10;
   76.13  
   76.14              // .. Memory Free ..
   76.15              big.setColor(mfColor);
   76.16 @@ -224,7 +224,7 @@
   76.17              int i = 0;
   76.18              for ( ; i < MemUsage ; i++) {
   76.19                  mfRect.setRect(x1+5,(float) y1+ssH+i*blockHeight,
   76.20 -                                blockWidth,(float) blockHeight-1);
   76.21 +                                blockWidth, blockHeight-1);
   76.22                  big.fill(mfRect);
   76.23              }
   76.24  
   76.25 @@ -232,13 +232,13 @@
   76.26              big.setColor(Color.green);
   76.27              for ( ; i < 10; i++)  {
   76.28                  muRect.setRect(x1+5,(float) y1 + ssH+i*blockHeight,
   76.29 -                                blockWidth,(float) blockHeight-1);
   76.30 +                                blockWidth, blockHeight-1);
   76.31                  big.fill(muRect);
   76.32              }
   76.33  
   76.34              // .. Draw History Graph ..
   76.35              if (remainingWidth <= 30) remainingWidth = (float)30;
   76.36 -            if (remainingHeight <= ssH) remainingHeight = (float)ssH;
   76.37 +            if (remainingHeight <= ssH) remainingHeight = ssH;
   76.38              big.setColor(graphColor);
   76.39              int graphX = x1+30;
   76.40              int graphY = y1 + (int) ssH;
   76.41 @@ -347,8 +347,8 @@
   76.42                      big = bimg.createGraphics();
   76.43                      big.setFont(font);
   76.44                      FontMetrics fm = big.getFontMetrics(font);
   76.45 -                    ascent = (int) fm.getAscent();
   76.46 -                    descent = (int) fm.getDescent();
   76.47 +                    ascent = fm.getAscent();
   76.48 +                    descent = fm.getDescent();
   76.49                  }
   76.50                  repaint();
   76.51                  try {
    77.1 --- a/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipConstants.java	Thu Feb 16 13:01:36 2012 -0800
    77.2 +++ b/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipConstants.java	Sat Feb 18 16:11:47 2012 -0800
    77.3 @@ -185,11 +185,11 @@
    77.4       */
    77.5      ///////////////////////////////////////////////////////
    77.6      static final int CH(byte[] b, int n) {
    77.7 -       return b[n] & 0xff;
    77.8 +        return Byte.toUnsignedInt(b[n]);
    77.9      }
   77.10  
   77.11      static final int SH(byte[] b, int n) {
   77.12 -        return (b[n] & 0xff) | ((b[n + 1] & 0xff) << 8);
   77.13 +        return Byte.toUnsignedInt(b[n]) | (Byte.toUnsignedInt(b[n + 1]) << 8);
   77.14      }
   77.15  
   77.16      static final long LG(byte[] b, int n) {
    78.1 --- a/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileStore.java	Thu Feb 16 13:01:36 2012 -0800
    78.2 +++ b/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileStore.java	Sat Feb 18 16:11:47 2012 -0800
    78.3 @@ -61,7 +61,7 @@
    78.4      private final ZipFileSystem zfs;
    78.5  
    78.6      ZipFileStore(ZipPath zpath) {
    78.7 -        this.zfs = (ZipFileSystem)zpath.getFileSystem();
    78.8 +        this.zfs = zpath.getFileSystem();
    78.9      }
   78.10  
   78.11      @Override
    79.1 --- a/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileSystem.java	Thu Feb 16 13:01:36 2012 -0800
    79.2 +++ b/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileSystem.java	Sat Feb 18 16:11:47 2012 -0800
    79.3 @@ -1609,7 +1609,7 @@
    79.4          synchronized (inflaters) {
    79.5              int size = inflaters.size();
    79.6              if (size > 0) {
    79.7 -                Inflater inf = (Inflater)inflaters.remove(size - 1);
    79.8 +                Inflater inf = inflaters.remove(size - 1);
    79.9                  return inf;
   79.10              } else {
   79.11                  return new Inflater(true);
   79.12 @@ -1638,7 +1638,7 @@
   79.13          synchronized (deflaters) {
   79.14              int size = deflaters.size();
   79.15              if (size > 0) {
   79.16 -                Deflater def = (Deflater)deflaters.remove(size - 1);
   79.17 +                Deflater def = deflaters.remove(size - 1);
   79.18                  return def;
   79.19              } else {
   79.20                  return new Deflater(Deflater.DEFAULT_COMPRESSION, true);
    80.1 --- a/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileSystemProvider.java	Thu Feb 16 13:01:36 2012 -0800
    80.2 +++ b/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileSystemProvider.java	Sat Feb 18 16:11:47 2012 -0800
    80.3 @@ -211,7 +211,7 @@
    80.4      public <V extends FileAttributeView> V
    80.5          getFileAttributeView(Path path, Class<V> type, LinkOption... options)
    80.6      {
    80.7 -        return (V)ZipFileAttributeView.get(toZipPath(path), type);
    80.8 +        return ZipFileAttributeView.get(toZipPath(path), type);
    80.9      }
   80.10  
   80.11      @Override
    81.1 --- a/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipInfo.java	Thu Feb 16 13:01:36 2012 -0800
    81.2 +++ b/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipInfo.java	Sat Feb 18 16:11:47 2012 -0800
    81.3 @@ -78,12 +78,12 @@
    81.4                  // twice
    81.5                  long len = LOCHDR + CENNAM(cen, pos) + CENEXT(cen, pos) + CENHDR;
    81.6                  if (zfs.readFullyAt(buf, 0, len, locoff(cen, pos)) != len)
    81.7 -                    zfs.zerror("read loc header failed");
    81.8 +                    ZipFileSystem.zerror("read loc header failed");
    81.9                  if (LOCEXT(buf) > CENEXT(cen, pos) + CENHDR) {
   81.10                      // have to read the second time;
   81.11                      len = LOCHDR + LOCNAM(buf) + LOCEXT(buf);
   81.12                      if (zfs.readFullyAt(buf, 0, len, locoff(cen, pos)) != len)
   81.13 -                        zfs.zerror("read loc header failed");
   81.14 +                        ZipFileSystem.zerror("read loc header failed");
   81.15                  }
   81.16                  printLOC(buf);
   81.17                  pos += CENHDR + CENNAM(cen, pos) + CENEXT(cen, pos) + CENCOM(cen, pos);
    82.1 --- a/src/share/native/sun/management/HotSpotDiagnostic.c	Thu Feb 16 13:01:36 2012 -0800
    82.2 +++ b/src/share/native/sun/management/HotSpotDiagnostic.c	Sat Feb 18 16:11:47 2012 -0800
    82.3 @@ -1,5 +1,5 @@
    82.4  /*
    82.5 - * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
    82.6 + * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
    82.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    82.8   *
    82.9   * This code is free software; you can redistribute it and/or modify it
   82.10 @@ -34,141 +34,3 @@
   82.11  {
   82.12      jmm_interface->DumpHeap0(env, outputfile, live);
   82.13  }
   82.14 -
   82.15 -JNIEXPORT jobjectArray JNICALL
   82.16 -Java_sun_management_HotSpotDiagnostic_getDiagnosticCommands0
   82.17 -  (JNIEnv *env, jobject dummy)
   82.18 -{
   82.19 -  if ((jmm_version > JMM_VERSION_1_2_1)
   82.20 -      || (jmm_version == JMM_VERSION_1_2 && ((jmm_version&0xFF)>=2))) {
   82.21 -    return jmm_interface->GetDiagnosticCommands(env);
   82.22 -  }
   82.23 -  JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
   82.24 -                  "Diagnostic commands are not supported by this VM");
   82.25 -}
   82.26 -
   82.27 -jobject getDiagnosticCommandArgumentInfoArray(JNIEnv *env, jstring command,
   82.28 -                                              int num_arg) {
   82.29 -  int i;
   82.30 -  jobject obj;
   82.31 -  jobjectArray result;
   82.32 -  dcmdArgInfo* dcmd_arg_info_array;
   82.33 -  jclass dcmdArgInfoCls;
   82.34 -  jclass arraysCls;
   82.35 -  jmethodID mid;
   82.36 -  jobject resultList;
   82.37 -
   82.38 -  dcmd_arg_info_array = (dcmdArgInfo*) malloc(num_arg * sizeof(dcmdArgInfo));
   82.39 -  if (dcmd_arg_info_array == NULL) {
   82.40 -    return NULL;
   82.41 -  }
   82.42 -  jmm_interface->GetDiagnosticCommandArgumentsInfo(env, command,
   82.43 -                                                   dcmd_arg_info_array);
   82.44 -  dcmdArgInfoCls = (*env)->FindClass(env,
   82.45 -                                     "com/sun/management/DiagnosticCommandArgumentInfo");
   82.46 -  result = (*env)->NewObjectArray(env, num_arg, dcmdArgInfoCls, NULL);
   82.47 -  if (result == NULL) {
   82.48 -    free(dcmd_arg_info_array);
   82.49 -    return NULL;
   82.50 -  }
   82.51 -  for (i=0; i<num_arg; i++) {
   82.52 -    obj = JNU_NewObjectByName(env,
   82.53 -                              "com/sun/management/DiagnosticCommandArgumentInfo",
   82.54 -                              "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZZI)V",
   82.55 -                              (*env)->NewStringUTF(env,dcmd_arg_info_array[i].name),
   82.56 -                              (*env)->NewStringUTF(env,dcmd_arg_info_array[i].description),
   82.57 -                              (*env)->NewStringUTF(env,dcmd_arg_info_array[i].type),
   82.58 -                              dcmd_arg_info_array[i].default_string == NULL ? NULL:
   82.59 -                              (*env)->NewStringUTF(env, dcmd_arg_info_array[i].default_string),
   82.60 -                              dcmd_arg_info_array[i].mandatory,
   82.61 -                              dcmd_arg_info_array[i].option,
   82.62 -                              dcmd_arg_info_array[i].position);
   82.63 -    if (obj == NULL) {
   82.64 -      free(dcmd_arg_info_array);
   82.65 -      return NULL;
   82.66 -    }
   82.67 -    (*env)->SetObjectArrayElement(env, result, i, obj);
   82.68 -  }
   82.69 -  free(dcmd_arg_info_array);
   82.70 -  arraysCls = (*env)->FindClass(env, "java/util/Arrays");
   82.71 -  mid = (*env)->GetStaticMethodID(env, arraysCls,
   82.72 -                                  "asList", "([Ljava/lang/Object;)Ljava/util/List;");
   82.73 -  resultList = (*env)->CallStaticObjectMethod(env, arraysCls, mid, result);
   82.74 -  return resultList;
   82.75 -}
   82.76 -
   82.77 -/* Throws IllegalArgumentException if at least one the diagnostic command
   82.78 - * passed in argument is not supported by the JVM
   82.79 - */
   82.80 -JNIEXPORT jobjectArray JNICALL
   82.81 -Java_sun_management_HotSpotDiagnostic_getDiagnosticCommandInfo0
   82.82 -(JNIEnv *env, jobject dummy, jobjectArray commands)
   82.83 -{
   82.84 -  int i;
   82.85 -  jclass dcmdInfoCls;
   82.86 -  jobject result;
   82.87 -  jobjectArray args;
   82.88 -  jobject obj;
   82.89 -
   82.90 -  if (commands == NULL) {
   82.91 -    JNU_ThrowNullPointerException(env, "Invalid String Array");
   82.92 -    return NULL;
   82.93 -  }
   82.94 -  if ((jmm_version > JMM_VERSION_1_2_1)
   82.95 -      || (jmm_version == JMM_VERSION_1_2 && ((jmm_version&0xFF)>=2))) {
   82.96 -    jsize num_commands = (*env)->GetArrayLength(env, commands);
   82.97 -    dcmdInfo* dcmd_info_array = (dcmdInfo*) malloc(num_commands *
   82.98 -                                                   sizeof(dcmdInfo));
   82.99 -    if (dcmd_info_array == NULL) {
  82.100 -      JNU_ThrowOutOfMemoryError(env, NULL);
  82.101 -    }
  82.102 -    jmm_interface->GetDiagnosticCommandInfo(env, commands, dcmd_info_array);
  82.103 -    dcmdInfoCls = (*env)->FindClass(env,
  82.104 -                                    "com/sun/management/DiagnosticCommandInfo");
  82.105 -    result = (*env)->NewObjectArray(env, num_commands, dcmdInfoCls, NULL);
  82.106 -    if (result == NULL) {
  82.107 -      free(dcmd_info_array);
  82.108 -      JNU_ThrowOutOfMemoryError(env, 0);
  82.109 -    }
  82.110 -    for (i=0; i<num_commands; i++) {
  82.111 -      args = getDiagnosticCommandArgumentInfoArray(env,
  82.112 -                                                   (*env)->GetObjectArrayElement(env,commands,i),
  82.113 -                                                   dcmd_info_array[i].num_arguments);
  82.114 -      if (args == NULL) {
  82.115 -        free(dcmd_info_array);
  82.116 -        JNU_ThrowOutOfMemoryError(env, 0);
  82.117 -      }
  82.118 -      obj = JNU_NewObjectByName(env,
  82.119 -                                "com/sun/management/DiagnosticCommandInfo",
  82.120 -                                "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZLjava/util/List;)V",
  82.121 -                                (*env)->NewStringUTF(env,dcmd_info_array[i].name),
  82.122 -                                (*env)->NewStringUTF(env,dcmd_info_array[i].description),
  82.123 -                                (*env)->NewStringUTF(env,dcmd_info_array[i].impact),
  82.124 -                                dcmd_info_array[i].enabled,
  82.125 -                                args);
  82.126 -      if (obj == NULL) {
  82.127 -        free(dcmd_info_array);
  82.128 -        JNU_ThrowOutOfMemoryError(env, 0);
  82.129 -      }
  82.130 -      (*env)->SetObjectArrayElement(env, result, i, obj);
  82.131 -    }
  82.132 -    free(dcmd_info_array);
  82.133 -    return result;
  82.134 -  }
  82.135 -  JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
  82.136 -                  "Diagnostic commands are not supported by this VM");
  82.137 -}
  82.138 -
  82.139 -/* Throws IllegalArgumentException if the diagnostic command
  82.140 - * passed in argument is not supported by the JVM
  82.141 - */
  82.142 -JNIEXPORT jstring JNICALL
  82.143 -Java_sun_management_HotSpotDiagnostic_executeDiagnosticCommand0
  82.144 -(JNIEnv *env, jobject dummy, jstring command) {
  82.145 -  if((jmm_version > JMM_VERSION_1_2_1 )
  82.146 -     || (jmm_version == JMM_VERSION_1_2 && ((jmm_version&0xFF)>=2))) {
  82.147 -    return jmm_interface->ExecuteDiagnosticCommand(env, command);
  82.148 -  }
  82.149 -  JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
  82.150 -                  "Diagnostic commands are not supported by this VM");
  82.151 -}
    83.1 --- a/src/solaris/classes/sun/nio/ch/DevPollSelectorImpl.java	Thu Feb 16 13:01:36 2012 -0800
    83.2 +++ b/src/solaris/classes/sun/nio/ch/DevPollSelectorImpl.java	Sat Feb 18 16:11:47 2012 -0800
    83.3 @@ -180,7 +180,7 @@
    83.4              ((SelChImpl)selch).kill();
    83.5      }
    83.6  
    83.7 -    void putEventOps(SelectionKeyImpl sk, int ops) {
    83.8 +    public void putEventOps(SelectionKeyImpl sk, int ops) {
    83.9          if (closed)
   83.10              throw new ClosedSelectorException();
   83.11          int fd = IOUtil.fdVal(sk.channel.getFD());
    84.1 --- a/src/solaris/classes/sun/nio/ch/EPollSelectorImpl.java	Thu Feb 16 13:01:36 2012 -0800
    84.2 +++ b/src/solaris/classes/sun/nio/ch/EPollSelectorImpl.java	Sat Feb 18 16:11:47 2012 -0800
    84.3 @@ -181,7 +181,7 @@
    84.4              ((SelChImpl)selch).kill();
    84.5      }
    84.6  
    84.7 -    void putEventOps(SelectionKeyImpl sk, int ops) {
    84.8 +    public void putEventOps(SelectionKeyImpl sk, int ops) {
    84.9          if (closed)
   84.10              throw new ClosedSelectorException();
   84.11          pollWrapper.setInterest(sk.channel, ops);
    85.1 --- a/src/solaris/classes/sun/nio/ch/NativeThread.java	Thu Feb 16 13:01:36 2012 -0800
    85.2 +++ b/src/solaris/classes/sun/nio/ch/NativeThread.java	Sat Feb 18 16:11:47 2012 -0800
    85.3 @@ -37,21 +37,21 @@
    85.4  // always returns -1 and the signal(long) method has no effect.
    85.5  
    85.6  
    85.7 -class NativeThread {
    85.8 +public class NativeThread {
    85.9  
   85.10      // Returns an opaque token representing the native thread underlying the
   85.11      // invoking Java thread.  On systems that do not require signalling, this
   85.12      // method always returns -1.
   85.13      //
   85.14 -    static native long current();
   85.15 +    public static native long current();
   85.16  
   85.17      // Signals the given native thread so as to release it from a blocking I/O
   85.18      // operation.  On systems that do not require signalling, this method has
   85.19      // no effect.
   85.20      //
   85.21 -    static native void signal(long nt);
   85.22 +    public static native void signal(long nt);
   85.23  
   85.24 -    static native void init();
   85.25 +    private static native void init();
   85.26  
   85.27      static {
   85.28          Util.load();
    86.1 --- a/src/solaris/classes/sun/nio/ch/PollArrayWrapper.java	Thu Feb 16 13:01:36 2012 -0800
    86.2 +++ b/src/solaris/classes/sun/nio/ch/PollArrayWrapper.java	Sat Feb 18 16:11:47 2012 -0800
    86.3 @@ -41,9 +41,9 @@
    86.4   * @since 1.4
    86.5   */
    86.6  
    86.7 -class PollArrayWrapper extends AbstractPollArrayWrapper {
    86.8 +public class PollArrayWrapper extends AbstractPollArrayWrapper {
    86.9  
   86.10 -    static final short POLLCONN = POLLOUT;
   86.11 +    public static final short POLLCONN = POLLOUT;
   86.12  
   86.13      // File descriptor to write for interrupt
   86.14      int interruptFD;
    87.1 --- a/src/solaris/classes/sun/nio/ch/SctpAssocChange.java	Thu Feb 16 13:01:36 2012 -0800
    87.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    87.3 @@ -1,120 +0,0 @@
    87.4 -/*
    87.5 - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
    87.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    87.7 - *
    87.8 - * This code is free software; you can redistribute it and/or modify it
    87.9 - * under the terms of the GNU General Public License version 2 only, as
   87.10 - * published by the Free Software Foundation.  Oracle designates this
   87.11 - * particular file as subject to the "Classpath" exception as provided
   87.12 - * by Oracle in the LICENSE file that accompanied this code.
   87.13 - *
   87.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   87.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   87.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   87.17 - * version 2 for more details (a copy is included in the LICENSE file that
   87.18 - * accompanied this code).
   87.19 - *
   87.20 - * You should have received a copy of the GNU General Public License version
   87.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   87.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   87.23 - *
   87.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   87.25 - * or visit www.oracle.com if you need additional information or have any
   87.26 - * questions.
   87.27 - */
   87.28 -package sun.nio.ch;
   87.29 -
   87.30 -import com.sun.nio.sctp.Association;
   87.31 -import com.sun.nio.sctp.AssociationChangeNotification;
   87.32 -
   87.33 -/**
   87.34 - * An implementation of AssociationChangeNotification
   87.35 - */
   87.36 -public class SctpAssocChange extends AssociationChangeNotification
   87.37 -    implements SctpNotification
   87.38 -{
   87.39 -    /* static final ints so that they can be referenced from native */
   87.40 -    private final static int SCTP_COMM_UP = 1;
   87.41 -    private final static int SCTP_COMM_LOST = 2;
   87.42 -    private final static int SCTP_RESTART = 3;
   87.43 -    private final static int SCTP_SHUTDOWN = 4;
   87.44 -    private final static int SCTP_CANT_START = 5;
   87.45 -
   87.46 -    private Association association;
   87.47 -
   87.48 -    /* assocId is used to lookup the association before the notification is
   87.49 -     * returned to user code */
   87.50 -    private int assocId;
   87.51 -    private AssocChangeEvent event;
   87.52 -    private int maxOutStreams;
   87.53 -    private int maxInStreams;
   87.54 -
   87.55 -    /* Invoked from native */
   87.56 -    private SctpAssocChange(int assocId,
   87.57 -                            int intEvent,
   87.58 -                            int maxOutStreams,
   87.59 -                            int maxInStreams) {
   87.60 -        switch (intEvent) {
   87.61 -            case SCTP_COMM_UP :
   87.62 -                this.event = AssocChangeEvent.COMM_UP;
   87.63 -                break;
   87.64 -            case SCTP_COMM_LOST :
   87.65 -                this.event = AssocChangeEvent.COMM_LOST;
   87.66 -                break;
   87.67 -            case SCTP_RESTART :
   87.68 -                this.event = AssocChangeEvent.RESTART;
   87.69 -                break;
   87.70 -            case SCTP_SHUTDOWN :
   87.71 -                this.event = AssocChangeEvent.SHUTDOWN;
   87.72 -                break;
   87.73 -            case SCTP_CANT_START :
   87.74 -                this.event = AssocChangeEvent.CANT_START;
   87.75 -                break;
   87.76 -            default :
   87.77 -                throw new AssertionError(
   87.78 -                      "Unknown Association Change Event type: " + intEvent);
   87.79 -        }
   87.80 -
   87.81 -        this.assocId = assocId;
   87.82 -        this.maxOutStreams = maxOutStreams;
   87.83 -        this.maxInStreams = maxInStreams;
   87.84 -    }
   87.85 -
   87.86 -    @Override
   87.87 -    public int assocId() {
   87.88 -        return assocId;
   87.89 -    }
   87.90 -
   87.91 -    @Override
   87.92 -    public void setAssociation(Association association) {
   87.93 -        this.association = association;
   87.94 -    }
   87.95 -
   87.96 -    @Override
   87.97 -    public Association association() {
   87.98 -        assert association != null;
   87.99 -        return association;
  87.100 -    }
  87.101 -
  87.102 -    @Override
  87.103 -    public AssocChangeEvent event() {
  87.104 -        return event;
  87.105 -    }
  87.106 -
  87.107 -    int maxOutStreams() {
  87.108 -        return maxOutStreams;
  87.109 -    }
  87.110 -
  87.111 -    int maxInStreams() {
  87.112 -        return maxInStreams;
  87.113 -    }
  87.114 -
  87.115 -    @Override
  87.116 -    public String toString() {
  87.117 -        StringBuilder sb = new StringBuilder();
  87.118 -        sb.append(super.toString()).append(" [");
  87.119 -        sb.append("Association:").append(association);
  87.120 -        sb.append(", Event: ").append(event).append("]");
  87.121 -        return sb.toString();
  87.122 -    }
  87.123 -}
    88.1 --- a/src/solaris/classes/sun/nio/ch/SctpAssociationImpl.java	Thu Feb 16 13:01:36 2012 -0800
    88.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    88.3 @@ -1,52 +0,0 @@
    88.4 -/*
    88.5 - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
    88.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    88.7 - *
    88.8 - * This code is free software; you can redistribute it and/or modify it
    88.9 - * under the terms of the GNU General Public License version 2 only, as
   88.10 - * published by the Free Software Foundation.  Oracle designates this
   88.11 - * particular file as subject to the "Classpath" exception as provided
   88.12 - * by Oracle in the LICENSE file that accompanied this code.
   88.13 - *
   88.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   88.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   88.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   88.17 - * version 2 for more details (a copy is included in the LICENSE file that
   88.18 - * accompanied this code).
   88.19 - *
   88.20 - * You should have received a copy of the GNU General Public License version
   88.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   88.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   88.23 - *
   88.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   88.25 - * or visit www.oracle.com if you need additional information or have any
   88.26 - * questions.
   88.27 - */
   88.28 -package sun.nio.ch;
   88.29 -
   88.30 -import com.sun.nio.sctp.Association;
   88.31 -
   88.32 -/**
   88.33 - * An implementation of Association
   88.34 - */
   88.35 -public class SctpAssociationImpl extends Association {
   88.36 -    public SctpAssociationImpl(int associationID,
   88.37 -                               int maxInStreams,
   88.38 -                               int maxOutStreams) {
   88.39 -        super(associationID, maxInStreams, maxOutStreams);
   88.40 -    }
   88.41 -
   88.42 -    @Override
   88.43 -    public String toString() {
   88.44 -        StringBuffer sb = new StringBuffer(super.toString());
   88.45 -        return sb.append("[associationID:")
   88.46 -                 .append(associationID())
   88.47 -                 .append(", maxIn:")
   88.48 -                 .append(maxInboundStreams())
   88.49 -                 .append(", maxOut:")
   88.50 -                 .append(maxOutboundStreams())
   88.51 -                 .append("]")
   88.52 -                 .toString();
   88.53 -    }
   88.54 -}
   88.55 -
    89.1 --- a/src/solaris/classes/sun/nio/ch/SctpChannelImpl.java	Thu Feb 16 13:01:36 2012 -0800
    89.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    89.3 @@ -1,1097 +0,0 @@
    89.4 -/*
    89.5 - * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
    89.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    89.7 - *
    89.8 - * This code is free software; you can redistribute it and/or modify it
    89.9 - * under the terms of the GNU General Public License version 2 only, as
   89.10 - * published by the Free Software Foundation.  Oracle designates this
   89.11 - * particular file as subject to the "Classpath" exception as provided
   89.12 - * by Oracle in the LICENSE file that accompanied this code.
   89.13 - *
   89.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   89.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   89.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   89.17 - * version 2 for more details (a copy is included in the LICENSE file that
   89.18 - * accompanied this code).
   89.19 - *
   89.20 - * You should have received a copy of the GNU General Public License version
   89.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   89.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   89.23 - *
   89.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   89.25 - * or visit www.oracle.com if you need additional information or have any
   89.26 - * questions.
   89.27 - */
   89.28 -package sun.nio.ch;
   89.29 -
   89.30 -import java.net.InetAddress;
   89.31 -import java.net.SocketAddress;
   89.32 -import java.net.SocketException;
   89.33 -import java.net.InetSocketAddress;
   89.34 -import java.io.FileDescriptor;
   89.35 -import java.io.IOException;
   89.36 -import java.util.Collections;
   89.37 -import java.util.Set;
   89.38 -import java.util.HashSet;
   89.39 -import java.nio.ByteBuffer;
   89.40 -import java.nio.channels.SelectionKey;
   89.41 -import java.nio.channels.ClosedChannelException;
   89.42 -import java.nio.channels.ConnectionPendingException;
   89.43 -import java.nio.channels.NoConnectionPendingException;
   89.44 -import java.nio.channels.AlreadyConnectedException;
   89.45 -import java.nio.channels.NotYetBoundException;
   89.46 -import java.nio.channels.NotYetConnectedException;
   89.47 -import java.nio.channels.spi.SelectorProvider;
   89.48 -import com.sun.nio.sctp.AbstractNotificationHandler;
   89.49 -import com.sun.nio.sctp.Association;
   89.50 -import com.sun.nio.sctp.AssociationChangeNotification;
   89.51 -import com.sun.nio.sctp.HandlerResult;
   89.52 -import com.sun.nio.sctp.IllegalReceiveException;
   89.53 -import com.sun.nio.sctp.InvalidStreamException;
   89.54 -import com.sun.nio.sctp.IllegalUnbindException;
   89.55 -import com.sun.nio.sctp.MessageInfo;
   89.56 -import com.sun.nio.sctp.NotificationHandler;
   89.57 -import com.sun.nio.sctp.SctpChannel;
   89.58 -import com.sun.nio.sctp.SctpSocketOption;
   89.59 -import static com.sun.nio.sctp.SctpStandardSocketOptions.*;
   89.60 -import static sun.nio.ch.SctpResultContainer.SEND_FAILED;
   89.61 -import static sun.nio.ch.SctpResultContainer.ASSOCIATION_CHANGED;
   89.62 -import static sun.nio.ch.SctpResultContainer.PEER_ADDRESS_CHANGED;
   89.63 -import static sun.nio.ch.SctpResultContainer.SHUTDOWN;
   89.64 -
   89.65 -/**
   89.66 - * An implementation of an SctpChannel
   89.67 - */
   89.68 -public class SctpChannelImpl extends SctpChannel
   89.69 -    implements SelChImpl
   89.70 -{
   89.71 -    private final FileDescriptor fd;
   89.72 -
   89.73 -    private final int fdVal;
   89.74 -
   89.75 -    /* IDs of native threads doing send and receivess, for signalling */
   89.76 -    private volatile long receiverThread = 0;
   89.77 -    private volatile long senderThread = 0;
   89.78 -
   89.79 -    /* Lock held by current receiving or connecting thread */
   89.80 -    private final Object receiveLock = new Object();
   89.81 -
   89.82 -    /* Lock held by current sending or connecting thread */
   89.83 -    private final Object sendLock = new Object();
   89.84 -
   89.85 -    private final ThreadLocal<Boolean> receiveInvoked =
   89.86 -        new ThreadLocal<Boolean>() {
   89.87 -             @Override protected Boolean initialValue() {
   89.88 -                 return Boolean.FALSE;
   89.89 -            }
   89.90 -    };
   89.91 -
   89.92 -    /* Lock held by any thread that modifies the state fields declared below
   89.93 -       DO NOT invoke a blocking I/O operation while holding this lock! */
   89.94 -    private final Object stateLock = new Object();
   89.95 -
   89.96 -    private enum ChannelState {
   89.97 -        UNINITIALIZED,
   89.98 -        UNCONNECTED,
   89.99 -        PENDING,
  89.100 -        CONNECTED,
  89.101 -        KILLPENDING,
  89.102 -        KILLED,
  89.103 -    }
  89.104 -    /* -- The following fields are protected by stateLock -- */
  89.105 -    private ChannelState state = ChannelState.UNINITIALIZED;
  89.106 -
  89.107 -    /* Binding; Once bound the port will remain constant. */
  89.108 -    int port = -1;
  89.109 -    private HashSet<InetSocketAddress> localAddresses = new HashSet<InetSocketAddress>();
  89.110 -    /* Has the channel been bound to the wildcard address */
  89.111 -    private boolean wildcard; /* false */
  89.112 -    //private InetSocketAddress remoteAddress = null;
  89.113 -
  89.114 -    /* Input/Output open */
  89.115 -    private boolean readyToConnect;
  89.116 -
  89.117 -    /* Shutdown */
  89.118 -    private boolean isShutdown;
  89.119 -
  89.120 -    private Association association;
  89.121 -
  89.122 -    private Set<SocketAddress> remoteAddresses = Collections.emptySet();
  89.123 -
  89.124 -    /* -- End of fields protected by stateLock -- */
  89.125 -
  89.126 -    /**
  89.127 -     * Constructor for normal connecting sockets
  89.128 -     */
  89.129 -    public SctpChannelImpl(SelectorProvider provider) throws IOException {
  89.130 -        //TODO: update provider remove public modifier
  89.131 -        super(provider);
  89.132 -        this.fd = SctpNet.socket(true);
  89.133 -        this.fdVal = IOUtil.fdVal(fd);
  89.134 -        this.state = ChannelState.UNCONNECTED;
  89.135 -    }
  89.136 -
  89.137 -    /**
  89.138 -     * Constructor for sockets obtained from server sockets
  89.139 -     */
  89.140 -    public SctpChannelImpl(SelectorProvider provider, FileDescriptor fd)
  89.141 -         throws IOException {
  89.142 -        this(provider, fd, null);
  89.143 -    }
  89.144 -
  89.145 -    /**
  89.146 -     * Constructor for sockets obtained from branching
  89.147 -     */
  89.148 -    public SctpChannelImpl(SelectorProvider provider,
  89.149 -                           FileDescriptor fd,
  89.150 -                           Association association)
  89.151 -            throws IOException {
  89.152 -        super(provider);
  89.153 -        this.fd = fd;
  89.154 -        this.fdVal = IOUtil.fdVal(fd);
  89.155 -        this.state = ChannelState.CONNECTED;
  89.156 -        port = (Net.localAddress(fd)).getPort();
  89.157 -
  89.158 -        if (association != null) { /* branched */
  89.159 -            this.association = association;
  89.160 -        } else { /* obtained from server channel */
  89.161 -            /* Receive COMM_UP */
  89.162 -            ByteBuffer buf = Util.getTemporaryDirectBuffer(50);
  89.163 -            try {
  89.164 -                receive(buf, null, null, true);
  89.165 -            } finally {
  89.166 -                Util.releaseTemporaryDirectBuffer(buf);
  89.167 -            }
  89.168 -        }
  89.169 -    }
  89.170 -
  89.171 -    /**
  89.172 -     * Binds the channel's socket to a local address.
  89.173 -     */
  89.174 -    @Override
  89.175 -    public SctpChannel bind(SocketAddress local) throws IOException {
  89.176 -        synchronized (receiveLock) {
  89.177 -            synchronized (sendLock) {
  89.178 -                synchronized (stateLock) {
  89.179 -                    ensureOpenAndUnconnected();
  89.180 -                    if (isBound())
  89.181 -                        SctpNet.throwAlreadyBoundException();
  89.182 -                    InetSocketAddress isa = (local == null) ?
  89.183 -                        new InetSocketAddress(0) : Net.checkAddress(local);
  89.184 -                    Net.bind(fd, isa.getAddress(), isa.getPort());
  89.185 -                    InetSocketAddress boundIsa = Net.localAddress(fd);
  89.186 -                    port = boundIsa.getPort();
  89.187 -                    localAddresses.add(isa);
  89.188 -                    if (isa.getAddress().isAnyLocalAddress())
  89.189 -                        wildcard = true;
  89.190 -                }
  89.191 -            }
  89.192 -        }
  89.193 -        return this;
  89.194 -    }
  89.195 -
  89.196 -    @Override
  89.197 -    public SctpChannel bindAddress(InetAddress address)
  89.198 -            throws IOException {
  89.199 -        bindUnbindAddress(address, true);
  89.200 -        localAddresses.add(new InetSocketAddress(address, port));
  89.201 -        return this;
  89.202 -    }
  89.203 -
  89.204 -    @Override
  89.205 -    public SctpChannel unbindAddress(InetAddress address)
  89.206 -            throws IOException {
  89.207 -        bindUnbindAddress(address, false);
  89.208 -        localAddresses.remove(new InetSocketAddress(address, port));
  89.209 -        return this;
  89.210 -    }
  89.211 -
  89.212 -    private SctpChannel bindUnbindAddress(InetAddress address, boolean add)
  89.213 -            throws IOException {
  89.214 -        if (address == null)
  89.215 -            throw new IllegalArgumentException();
  89.216 -
  89.217 -        synchronized (receiveLock) {
  89.218 -            synchronized (sendLock) {
  89.219 -                synchronized (stateLock) {
  89.220 -                    if (!isOpen())
  89.221 -                        throw new ClosedChannelException();
  89.222 -                    if (!isBound())
  89.223 -                        throw new NotYetBoundException();
  89.224 -                    if (wildcard)
  89.225 -                        throw new IllegalStateException(
  89.226 -                                "Cannot add or remove addresses from a channel that is bound to the wildcard address");
  89.227 -                    if (address.isAnyLocalAddress())
  89.228 -                        throw new IllegalArgumentException(
  89.229 -                                "Cannot add or remove the wildcard address");
  89.230 -                    if (add) {
  89.231 -                        for (InetSocketAddress addr : localAddresses) {
  89.232 -                            if (addr.getAddress().equals(address)) {
  89.233 -                                SctpNet.throwAlreadyBoundException();
  89.234 -                            }
  89.235 -                        }
  89.236 -                    } else { /*removing */
  89.237 -                        /* Verify that there is more than one address
  89.238 -                         * and that address is already bound */
  89.239 -                        if (localAddresses.size() <= 1)
  89.240 -                            throw new IllegalUnbindException("Cannot remove address from a channel with only one address bound");
  89.241 -                        boolean foundAddress = false;
  89.242 -                        for (InetSocketAddress addr : localAddresses) {
  89.243 -                            if (addr.getAddress().equals(address)) {
  89.244 -                                foundAddress = true;
  89.245 -                                break;
  89.246 -                            }
  89.247 -                        }
  89.248 -                        if (!foundAddress )
  89.249 -                            throw new IllegalUnbindException("Cannot remove address from a channel that is not bound to that address");
  89.250 -                    }
  89.251 -
  89.252 -                    SctpNet.bindx(fdVal, new InetAddress[]{address}, port, add);
  89.253 -
  89.254 -                    /* Update our internal Set to reflect the addition/removal */
  89.255 -                    if (add)
  89.256 -                        localAddresses.add(new InetSocketAddress(address, port));
  89.257 -                    else {
  89.258 -                        for (InetSocketAddress addr : localAddresses) {
  89.259 -                            if (addr.getAddress().equals(address)) {
  89.260 -                                localAddresses.remove(addr);
  89.261 -                                break;
  89.262 -                            }
  89.263 -                        }
  89.264 -                    }
  89.265 -                }
  89.266 -            }
  89.267 -        }
  89.268 -        return this;
  89.269 -    }
  89.270 -
  89.271 -    private boolean isBound() {
  89.272 -        synchronized (stateLock) {
  89.273 -            return port == -1 ? false : true;
  89.274 -        }
  89.275 -    }
  89.276 -
  89.277 -    private boolean isConnected() {
  89.278 -        synchronized (stateLock) {
  89.279 -            return (state == ChannelState.CONNECTED);
  89.280 -        }
  89.281 -    }
  89.282 -
  89.283 -    private void ensureOpenAndUnconnected() throws IOException {
  89.284 -        synchronized (stateLock) {
  89.285 -            if (!isOpen())
  89.286 -                throw new ClosedChannelException();
  89.287 -            if (isConnected())
  89.288 -                throw new AlreadyConnectedException();
  89.289 -            if (state == ChannelState.PENDING)
  89.290 -                throw new ConnectionPendingException();
  89.291 -        }
  89.292 -    }
  89.293 -
  89.294 -    private boolean ensureReceiveOpen() throws ClosedChannelException {
  89.295 -        synchronized (stateLock) {
  89.296 -            if (!isOpen())
  89.297 -                throw new ClosedChannelException();
  89.298 -            if (!isConnected())
  89.299 -                throw new NotYetConnectedException();
  89.300 -            else
  89.301 -                return true;
  89.302 -        }
  89.303 -    }
  89.304 -
  89.305 -    private void ensureSendOpen() throws ClosedChannelException {
  89.306 -        synchronized (stateLock) {
  89.307 -            if (!isOpen())
  89.308 -                throw new ClosedChannelException();
  89.309 -            if (isShutdown)
  89.310 -                throw new ClosedChannelException();
  89.311 -            if (!isConnected())
  89.312 -                throw new NotYetConnectedException();
  89.313 -        }
  89.314 -    }
  89.315 -
  89.316 -    private void receiverCleanup() throws IOException {
  89.317 -        synchronized (stateLock) {
  89.318 -            receiverThread = 0;
  89.319 -            if (state == ChannelState.KILLPENDING)
  89.320 -                kill();
  89.321 -        }
  89.322 -    }
  89.323 -
  89.324 -    private void senderCleanup() throws IOException {
  89.325 -        synchronized (stateLock) {
  89.326 -            senderThread = 0;
  89.327 -            if (state == ChannelState.KILLPENDING)
  89.328 -                kill();
  89.329 -        }
  89.330 -    }
  89.331 -
  89.332 -    @Override
  89.333 -    public Association association() throws ClosedChannelException {
  89.334 -        synchronized (stateLock) {
  89.335 -            if (!isOpen())
  89.336 -                throw new ClosedChannelException();
  89.337 -            if (!isConnected())
  89.338 -                return null;
  89.339 -
  89.340 -            return association;
  89.341 -        }
  89.342 -    }
  89.343 -
  89.344 -    @Override
  89.345 -    public boolean connect(SocketAddress endpoint) throws IOException {
  89.346 -        synchronized (receiveLock) {
  89.347 -            synchronized (sendLock) {
  89.348 -                ensureOpenAndUnconnected();
  89.349 -                InetSocketAddress isa = Net.checkAddress(endpoint);
  89.350 -                SecurityManager sm = System.getSecurityManager();
  89.351 -                if (sm != null)
  89.352 -                    sm.checkConnect(isa.getAddress().getHostAddress(),
  89.353 -                                    isa.getPort());
  89.354 -                synchronized (blockingLock()) {
  89.355 -                    int n = 0;
  89.356 -                    try {
  89.357 -                        try {
  89.358 -                            begin();
  89.359 -                            synchronized (stateLock) {
  89.360 -                                if (!isOpen()) {
  89.361 -                                    return false;
  89.362 -                                }
  89.363 -                                receiverThread = NativeThread.current();
  89.364 -                            }
  89.365 -                            for (;;) {
  89.366 -                                InetAddress ia = isa.getAddress();
  89.367 -                                if (ia.isAnyLocalAddress())
  89.368 -                                    ia = InetAddress.getLocalHost();
  89.369 -                                n = SctpNet.connect(fdVal, ia, isa.getPort());
  89.370 -                                if (  (n == IOStatus.INTERRUPTED)
  89.371 -                                      && isOpen())
  89.372 -                                    continue;
  89.373 -                                break;
  89.374 -                            }
  89.375 -                        } finally {
  89.376 -                            receiverCleanup();
  89.377 -                            end((n > 0) || (n == IOStatus.UNAVAILABLE));
  89.378 -                            assert IOStatus.check(n);
  89.379 -                        }
  89.380 -                    } catch (IOException x) {
  89.381 -                        /* If an exception was thrown, close the channel after
  89.382 -                         * invoking end() so as to avoid bogus
  89.383 -                         * AsynchronousCloseExceptions */
  89.384 -                        close();
  89.385 -                        throw x;
  89.386 -                    }
  89.387 -
  89.388 -                    if (n > 0) {
  89.389 -                        synchronized (stateLock) {
  89.390 -                            /* Connection succeeded */
  89.391 -                            state = ChannelState.CONNECTED;
  89.392 -                            if (!isBound()) {
  89.393 -                                InetSocketAddress boundIsa =
  89.394 -                                        Net.localAddress(fd);
  89.395 -                                port = boundIsa.getPort();
  89.396 -                            }
  89.397 -
  89.398 -                            /* Receive COMM_UP */
  89.399 -                            ByteBuffer buf = Util.getTemporaryDirectBuffer(50);
  89.400 -                            try {
  89.401 -                                receive(buf, null, null, true);
  89.402 -                            } finally {
  89.403 -                                Util.releaseTemporaryDirectBuffer(buf);
  89.404 -                            }
  89.405 -
  89.406 -                            /* cache remote addresses */
  89.407 -                            try {
  89.408 -                                remoteAddresses = getRemoteAddresses();
  89.409 -                            } catch (IOException unused) { /* swallow exception */ }
  89.410 -
  89.411 -                            return true;
  89.412 -                        }
  89.413 -                    } else  {
  89.414 -                        synchronized (stateLock) {
  89.415 -                            /* If nonblocking and no exception then connection
  89.416 -                             * pending; disallow another invocation */
  89.417 -                            if (!isBlocking())
  89.418 -                                state = ChannelState.PENDING;
  89.419 -                            else
  89.420 -                                assert false;
  89.421 -                        }
  89.422 -                    }
  89.423 -                }
  89.424 -                return false;
  89.425 -            }
  89.426 -        }
  89.427 -    }
  89.428 -
  89.429 -    @Override
  89.430 -    public boolean connect(SocketAddress endpoint,
  89.431 -                           int maxOutStreams,
  89.432 -                           int maxInStreams)
  89.433 -            throws IOException {
  89.434 -        ensureOpenAndUnconnected();
  89.435 -        return setOption(SCTP_INIT_MAXSTREAMS, InitMaxStreams.
  89.436 -                create(maxInStreams, maxOutStreams)).connect(endpoint);
  89.437 -
  89.438 -    }
  89.439 -
  89.440 -    @Override
  89.441 -    public boolean isConnectionPending() {
  89.442 -        synchronized (stateLock) {
  89.443 -            return (state == ChannelState.PENDING);
  89.444 -        }
  89.445 -    }
  89.446 -
  89.447 -    @Override
  89.448 -    public boolean finishConnect() throws IOException {
  89.449 -        synchronized (receiveLock) {
  89.450 -            synchronized (sendLock) {
  89.451 -                synchronized (stateLock) {
  89.452 -                    if (!isOpen())
  89.453 -                        throw new ClosedChannelException();
  89.454 -                    if (isConnected())
  89.455 -                        return true;
  89.456 -                    if (state != ChannelState.PENDING)
  89.457 -                        throw new NoConnectionPendingException();
  89.458 -                }
  89.459 -                int n = 0;
  89.460 -                try {
  89.461 -                    try {
  89.462 -                        begin();
  89.463 -                        synchronized (blockingLock()) {
  89.464 -                            synchronized (stateLock) {
  89.465 -                                if (!isOpen()) {
  89.466 -                                    return false;
  89.467 -                                }
  89.468 -                                receiverThread = NativeThread.current();
  89.469 -                            }
  89.470 -                            if (!isBlocking()) {
  89.471 -                                for (;;) {
  89.472 -                                    n = checkConnect(fd, false, readyToConnect);
  89.473 -                                    if (  (n == IOStatus.INTERRUPTED)
  89.474 -                                          && isOpen())
  89.475 -                                        continue;
  89.476 -                                    break;
  89.477 -                                }
  89.478 -                            } else {
  89.479 -                                for (;;) {
  89.480 -                                    n = checkConnect(fd, true, readyToConnect);
  89.481 -                                    if (n == 0) {
  89.482 -                                        // Loop in case of
  89.483 -                                        // spurious notifications
  89.484 -                                        continue;
  89.485 -                                    }
  89.486 -                                    if (  (n == IOStatus.INTERRUPTED)
  89.487 -                                          && isOpen())
  89.488 -                                        continue;
  89.489 -                                    break;
  89.490 -                                }
  89.491 -                            }
  89.492 -                        }
  89.493 -                    } finally {
  89.494 -                        synchronized (stateLock) {
  89.495 -                            receiverThread = 0;
  89.496 -                            if (state == ChannelState.KILLPENDING) {
  89.497 -                                kill();
  89.498 -                                /* poll()/getsockopt() does not report
  89.499 -                                 * error (throws exception, with n = 0)
  89.500 -                                 * on Linux platform after dup2 and
  89.501 -                                 * signal-wakeup. Force n to 0 so the
  89.502 -                                 * end() can throw appropriate exception */
  89.503 -                                n = 0;
  89.504 -                            }
  89.505 -                        }
  89.506 -                        end((n > 0) || (n == IOStatus.UNAVAILABLE));
  89.507 -                        assert IOStatus.check(n);
  89.508 -                    }
  89.509 -                } catch (IOException x) {
  89.510 -                    /* If an exception was thrown, close the channel after
  89.511 -                     * invoking end() so as to avoid bogus
  89.512 -                     * AsynchronousCloseExceptions */
  89.513 -                    close();
  89.514 -                    throw x;
  89.515 -                }
  89.516 -
  89.517 -                if (n > 0) {
  89.518 -                    synchronized (stateLock) {
  89.519 -                        state = ChannelState.CONNECTED;
  89.520 -                        if (!isBound()) {
  89.521 -                            InetSocketAddress boundIsa =
  89.522 -                                    Net.localAddress(fd);
  89.523 -                            port = boundIsa.getPort();
  89.524 -                        }
  89.525 -
  89.526 -                        /* Receive COMM_UP */
  89.527 -                        ByteBuffer buf = Util.getTemporaryDirectBuffer(50);
  89.528 -                        try {
  89.529 -                            receive(buf, null, null, true);
  89.530 -                        } finally {
  89.531 -                            Util.releaseTemporaryDirectBuffer(buf);
  89.532 -                        }
  89.533 -
  89.534 -                        /* cache remote addresses */
  89.535 -                        try {
  89.536 -                            remoteAddresses = getRemoteAddresses();
  89.537 -                        } catch (IOException unused) { /* swallow exception */ }
  89.538 -
  89.539 -                        return true;
  89.540 -                    }
  89.541 -                }
  89.542 -            }
  89.543 -        }
  89.544 -        return false;
  89.545 -    }
  89.546 -
  89.547 -    @Override
  89.548 -    protected void implConfigureBlocking(boolean block) throws IOException {
  89.549 -        IOUtil.configureBlocking(fd, block);
  89.550 -    }
  89.551 -
  89.552 -    @Override
  89.553 -    public void implCloseSelectableChannel() throws IOException {
  89.554 -        synchronized (stateLock) {
  89.555 -            SctpNet.preClose(fdVal);
  89.556 -
  89.557 -            if (receiverThread != 0)
  89.558 -                NativeThread.signal(receiverThread);
  89.559 -
  89.560 -            if (senderThread != 0)
  89.561 -                NativeThread.signal(senderThread);
  89.562 -
  89.563 -            if (!isRegistered())
  89.564 -                kill();
  89.565 -        }
  89.566 -    }
  89.567 -
  89.568 -    @Override
  89.569 -    public FileDescriptor getFD() {
  89.570 -        return fd;
  89.571 -    }
  89.572 -
  89.573 -    @Override
  89.574 -    public int getFDVal() {
  89.575 -        return fdVal;
  89.576 -    }
  89.577 -
  89.578 -    /**
  89.579 -     * Translates native poll revent ops into a ready operation ops
  89.580 -     */
  89.581 -    private boolean translateReadyOps(int ops, int initialOps, SelectionKeyImpl sk) {
  89.582 -        int intOps = sk.nioInterestOps();
  89.583 -        int oldOps = sk.nioReadyOps();
  89.584 -        int newOps = initialOps;
  89.585 -
  89.586 -        if ((ops & PollArrayWrapper.POLLNVAL) != 0) {
  89.587 -            /* This should only happen if this channel is pre-closed while a
  89.588 -             * selection operation is in progress
  89.589 -             * ## Throw an error if this channel has not been pre-closed */
  89.590 -            return false;
  89.591 -        }
  89.592 -
  89.593 -        if ((ops & (PollArrayWrapper.POLLERR
  89.594 -                    | PollArrayWrapper.POLLHUP)) != 0) {
  89.595 -            newOps = intOps;
  89.596 -            sk.nioReadyOps(newOps);
  89.597 -            /* No need to poll again in checkConnect,
  89.598 -             * the error will be detected there */
  89.599 -            readyToConnect = true;
  89.600 -            return (newOps & ~oldOps) != 0;
  89.601 -        }
  89.602 -
  89.603 -        if (((ops & PollArrayWrapper.POLLIN) != 0) &&
  89.604 -            ((intOps & SelectionKey.OP_READ) != 0) &&
  89.605 -            isConnected())
  89.606 -            newOps |= SelectionKey.OP_READ;
  89.607 -
  89.608 -        if (((ops & PollArrayWrapper.POLLCONN) != 0) &&
  89.609 -            ((intOps & SelectionKey.OP_CONNECT) != 0) &&
  89.610 -            ((state == ChannelState.UNCONNECTED) || (state == ChannelState.PENDING))) {
  89.611 -            newOps |= SelectionKey.OP_CONNECT;
  89.612 -            readyToConnect = true;
  89.613 -        }
  89.614 -
  89.615 -        if (((ops & PollArrayWrapper.POLLOUT) != 0) &&
  89.616 -            ((intOps & SelectionKey.OP_WRITE) != 0) &&
  89.617 -            isConnected())
  89.618 -            newOps |= SelectionKey.OP_WRITE;
  89.619 -
  89.620 -        sk.nioReadyOps(newOps);
  89.621 -        return (newOps & ~oldOps) != 0;
  89.622 -    }
  89.623 -
  89.624 -    @Override
  89.625 -    public boolean translateAndUpdateReadyOps(int ops, SelectionKeyImpl sk) {
  89.626 -        return translateReadyOps(ops, sk.nioReadyOps(), sk);
  89.627 -    }
  89.628 -
  89.629 -    @Override
  89.630 -    @SuppressWarnings("all")
  89.631 -    public boolean translateAndSetReadyOps(int ops, SelectionKeyImpl sk) {
  89.632 -        return translateReadyOps(ops, 0, sk);
  89.633 -    }
  89.634 -
  89.635 -    @Override
  89.636 -    public void translateAndSetInterestOps(int ops, SelectionKeyImpl sk) {
  89.637 -        int newOps = 0;
  89.638 -        if ((ops & SelectionKey.OP_READ) != 0)
  89.639 -            newOps |= PollArrayWrapper.POLLIN;
  89.640 -        if ((ops & SelectionKey.OP_WRITE) != 0)
  89.641 -            newOps |= PollArrayWrapper.POLLOUT;
  89.642 -        if ((ops & SelectionKey.OP_CONNECT) != 0)
  89.643 -            newOps |= PollArrayWrapper.POLLCONN;
  89.644 -        sk.selector.putEventOps(sk, newOps);
  89.645 -    }
  89.646 -
  89.647 -    @Override
  89.648 -    public void kill() throws IOException {
  89.649 -        synchronized (stateLock) {
  89.650 -            if (state == ChannelState.KILLED)
  89.651 -                return;
  89.652 -            if (state == ChannelState.UNINITIALIZED) {
  89.653 -                state = ChannelState.KILLED;
  89.654 -                return;
  89.655 -            }
  89.656 -            assert !isOpen() && !isRegistered();
  89.657 -
  89.658 -            /* Postpone the kill if there is a waiting reader
  89.659 -             * or writer thread. */
  89.660 -            if (receiverThread == 0 && senderThread == 0) {
  89.661 -                SctpNet.close(fdVal);
  89.662 -                state = ChannelState.KILLED;
  89.663 -            } else {
  89.664 -                state = ChannelState.KILLPENDING;
  89.665 -            }
  89.666 -        }
  89.667 -    }
  89.668 -
  89.669 -    @Override
  89.670 -    public <T> SctpChannel setOption(SctpSocketOption<T> name, T value)
  89.671 -            throws IOException {
  89.672 -        if (name == null)
  89.673 -            throw new NullPointerException();
  89.674 -        if (!supportedOptions().contains(name))
  89.675 -            throw new UnsupportedOperationException("'" + name + "' not supported");
  89.676 -
  89.677 -        synchronized (stateLock) {
  89.678 -            if (!isOpen())
  89.679 -                throw new ClosedChannelException();
  89.680 -
  89.681 -            SctpNet.setSocketOption(fdVal, name, value, 0 /*oneToOne*/);
  89.682 -        }
  89.683 -        return this;
  89.684 -    }
  89.685 -
  89.686 -    @Override
  89.687 -    @SuppressWarnings("unchecked")
  89.688 -    public <T> T getOption(SctpSocketOption<T> name) throws IOException {
  89.689 -        if (name == null)
  89.690 -            throw new NullPointerException();
  89.691 -        if (!supportedOptions().contains(name))
  89.692 -            throw new UnsupportedOperationException("'" + name + "' not supported");
  89.693 -
  89.694 -        synchronized (stateLock) {
  89.695 -            if (!isOpen())
  89.696 -                throw new ClosedChannelException();
  89.697 -
  89.698 -            return (T)SctpNet.getSocketOption(fdVal, name, 0 /*oneToOne*/);
  89.699 -        }
  89.700 -    }
  89.701 -
  89.702 -    private static class DefaultOptionsHolder {
  89.703 -        static final Set<SctpSocketOption<?>> defaultOptions = defaultOptions();
  89.704 -
  89.705 -        private static Set<SctpSocketOption<?>> defaultOptions() {
  89.706 -            HashSet<SctpSocketOption<?>> set = new HashSet<SctpSocketOption<?>>(10);
  89.707 -            set.add(SCTP_DISABLE_FRAGMENTS);
  89.708 -            set.add(SCTP_EXPLICIT_COMPLETE);
  89.709 -            set.add(SCTP_FRAGMENT_INTERLEAVE);
  89.710 -            set.add(SCTP_INIT_MAXSTREAMS);
  89.711 -            set.add(SCTP_NODELAY);
  89.712 -            set.add(SCTP_PRIMARY_ADDR);
  89.713 -            set.add(SCTP_SET_PEER_PRIMARY_ADDR);
  89.714 -            set.add(SO_SNDBUF);
  89.715 -            set.add(SO_RCVBUF);
  89.716 -            set.add(SO_LINGER);
  89.717 -            return Collections.unmodifiableSet(set);
  89.718 -        }
  89.719 -    }
  89.720 -
  89.721 -    @Override
  89.722 -    public final Set<SctpSocketOption<?>> supportedOptions() {
  89.723 -        return DefaultOptionsHolder.defaultOptions;
  89.724 -    }
  89.725 -
  89.726 -    @Override
  89.727 -    public <T> MessageInfo receive(ByteBuffer buffer,
  89.728 -                                   T attachment,
  89.729 -                                   NotificationHandler<T> handler)
  89.730 -            throws IOException {
  89.731 -        return receive(buffer, attachment, handler, false);
  89.732 -    }
  89.733 -
  89.734 -    private <T> MessageInfo receive(ByteBuffer buffer,
  89.735 -                                    T attachment,
  89.736 -                                    NotificationHandler<T> handler,
  89.737 -                                    boolean fromConnect)
  89.738 -            throws IOException {
  89.739 -        if (buffer == null)
  89.740 -            throw new IllegalArgumentException("buffer cannot be null");
  89.741 -
  89.742 -        if (buffer.isReadOnly())
  89.743 -            throw new IllegalArgumentException("Read-only buffer");
  89.744 -
  89.745 -        if (receiveInvoked.get())
  89.746 -            throw new IllegalReceiveException(
  89.747 -                    "cannot invoke receive from handler");
  89.748 -        receiveInvoked.set(Boolean.TRUE);
  89.749 -
  89.750 -        try {
  89.751 -            SctpResultContainer resultContainer = new SctpResultContainer();
  89.752 -            do {
  89.753 -                resultContainer.clear();
  89.754 -                synchronized (receiveLock) {
  89.755 -                    if (!ensureReceiveOpen())
  89.756 -                        return null;
  89.757 -
  89.758 -                    int n = 0;
  89.759 -                    try {
  89.760 -                        begin();
  89.761 -
  89.762 -                        synchronized (stateLock) {
  89.763 -                            if(!isOpen())
  89.764 -                                return null;
  89.765 -                            receiverThread = NativeThread.current();
  89.766 -                        }
  89.767 -
  89.768 -                        do {
  89.769 -                            n = receive(fdVal, buffer, resultContainer, fromConnect);
  89.770 -                        } while ((n == IOStatus.INTERRUPTED) && isOpen());
  89.771 -                    } finally {
  89.772 -                        receiverCleanup();
  89.773 -                        end((n > 0) || (n == IOStatus.UNAVAILABLE));
  89.774 -                        assert IOStatus.check(n);
  89.775 -                    }
  89.776 -
  89.777 -                    if (!resultContainer.isNotification()) {
  89.778 -                        /* message or nothing */
  89.779 -                        if (resultContainer.hasSomething()) {
  89.780 -                            /* Set the association before returning */
  89.781 -                            SctpMessageInfoImpl info =
  89.782 -                                    resultContainer.getMessageInfo();
  89.783 -                            synchronized (stateLock) {
  89.784 -                                assert association != null;
  89.785 -                                info.setAssociation(association);
  89.786 -                            }
  89.787 -                            return info;
  89.788 -                        } else
  89.789 -                            /* Non-blocking may return null if nothing available*/
  89.790 -                            return null;
  89.791 -                    } else { /* notification */
  89.792 -                        synchronized (stateLock) {
  89.793 -                            handleNotificationInternal(
  89.794 -                                    resultContainer);
  89.795 -                        }
  89.796 -                    }
  89.797 -
  89.798 -                    if (fromConnect)  {
  89.799 -                        /* If we reach here, then it was connect that invoked
  89.800 -                         * receive and received the COMM_UP. We have already
  89.801 -                         * handled the COMM_UP with the internal notification
  89.802 -                         * handler. Simply return. */
  89.803 -                        return null;
  89.804 -                    }
  89.805 -                }  /* receiveLock */
  89.806 -            } while (handler == null ? true :
  89.807 -                (invokeNotificationHandler(resultContainer, handler, attachment)
  89.808 -                 == HandlerResult.CONTINUE));
  89.809 -
  89.810 -            return null;
  89.811 -        } finally {
  89.812 -            receiveInvoked.set(Boolean.FALSE);
  89.813 -        }
  89.814 -    }
  89.815 -
  89.816 -    private int receive(int fd,
  89.817 -                        ByteBuffer dst,
  89.818 -                        SctpResultContainer resultContainer,
  89.819 -                        boolean peek)
  89.820 -            throws IOException {
  89.821 -        int pos = dst.position();
  89.822 -        int lim = dst.limit();
  89.823 -        assert (pos <= lim);
  89.824 -        int rem = (pos <= lim ? lim - pos : 0);
  89.825 -        if (dst instanceof DirectBuffer && rem > 0)
  89.826 -            return receiveIntoNativeBuffer(fd, resultContainer, dst, rem, pos, peek);
  89.827 -
  89.828 -        /* Substitute a native buffer */
  89.829 -        int newSize = Math.max(rem, 1);
  89.830 -        ByteBuffer bb = Util.getTemporaryDirectBuffer(newSize);
  89.831 -        try {
  89.832 -            int n = receiveIntoNativeBuffer(fd, resultContainer, bb, newSize, 0, peek);
  89.833 -            bb.flip();
  89.834 -            if (n > 0 && rem > 0)
  89.835 -                dst.put(bb);
  89.836 -            return n;
  89.837 -        } finally {
  89.838 -            Util.releaseTemporaryDirectBuffer(bb);
  89.839 -        }
  89.840 -    }
  89.841 -
  89.842 -    private int receiveIntoNativeBuffer(int fd,
  89.843 -                                        SctpResultContainer resultContainer,
  89.844 -                                        ByteBuffer bb,
  89.845 -                                        int rem,
  89.846 -                                        int pos,
  89.847 -                                        boolean peek)
  89.848 -        throws IOException
  89.849 -    {
  89.850 -        int n = receive0(fd, resultContainer, ((DirectBuffer)bb).address() + pos, rem, peek);
  89.851 -
  89.852 -        if (n > 0)
  89.853 -            bb.position(pos + n);
  89.854 -        return n;
  89.855 -    }
  89.856 -
  89.857 -    private InternalNotificationHandler internalNotificationHandler =
  89.858 -            new InternalNotificationHandler();
  89.859 -
  89.860 -    private void handleNotificationInternal(SctpResultContainer resultContainer)
  89.861 -    {
  89.862 -        invokeNotificationHandler(resultContainer,
  89.863 -                internalNotificationHandler, null);
  89.864 -    }
  89.865 -
  89.866 -    private class InternalNotificationHandler
  89.867 -            extends AbstractNotificationHandler<Object>
  89.868 -    {
  89.869 -        @Override
  89.870 -        public HandlerResult handleNotification(
  89.871 -                AssociationChangeNotification not, Object unused) {
  89.872 -            if (not.event().equals(
  89.873 -                    AssociationChangeNotification.AssocChangeEvent.COMM_UP) &&
  89.874 -                    association == null) {
  89.875 -                SctpAssocChange sac = (SctpAssocChange) not;
  89.876 -                association = new SctpAssociationImpl
  89.877 -                       (sac.assocId(), sac.maxInStreams(), sac.maxOutStreams());
  89.878 -            }
  89.879 -            return HandlerResult.CONTINUE;
  89.880 -        }
  89.881 -    }
  89.882 -
  89.883 -    private <T> HandlerResult invokeNotificationHandler
  89.884 -                                 (SctpResultContainer resultContainer,
  89.885 -                                  NotificationHandler<T> handler,
  89.886 -                                  T attachment) {
  89.887 -        SctpNotification notification = resultContainer.notification();
  89.888 -        synchronized (stateLock) {
  89.889 -            notification.setAssociation(association);
  89.890 -        }
  89.891 -
  89.892 -        if (!(handler instanceof AbstractNotificationHandler)) {
  89.893 -            return handler.handleNotification(notification, attachment);
  89.894 -        }
  89.895 -
  89.896 -        /* AbstractNotificationHandler */
  89.897 -        AbstractNotificationHandler<T> absHandler =
  89.898 -                (AbstractNotificationHandler<T>)handler;
  89.899 -        switch(resultContainer.type()) {
  89.900 -            case ASSOCIATION_CHANGED :
  89.901 -                return absHandler.handleNotification(
  89.902 -                        resultContainer.getAssociationChanged(), attachment);
  89.903 -            case PEER_ADDRESS_CHANGED :
  89.904 -                return absHandler.handleNotification(
  89.905 -                        resultContainer.getPeerAddressChanged(), attachment);
  89.906 -            case SEND_FAILED :
  89.907 -                return absHandler.handleNotification(
  89.908 -                        resultContainer.getSendFailed(), attachment);
  89.909 -            case SHUTDOWN :
  89.910 -                return absHandler.handleNotification(
  89.911 -                        resultContainer.getShutdown(), attachment);
  89.912 -            default :
  89.913 -                /* implementation specific handlers */
  89.914 -                return absHandler.handleNotification(
  89.915 -                        resultContainer.notification(), attachment);
  89.916 -        }
  89.917 -    }
  89.918 -
  89.919 -    private void checkAssociation(Association sendAssociation) {
  89.920 -        synchronized (stateLock) {
  89.921 -            if (sendAssociation != null && !sendAssociation.equals(association)) {
  89.922 -                throw new IllegalArgumentException(
  89.923 -                        "Cannot send to another association");
  89.924 -            }
  89.925 -        }
  89.926 -    }
  89.927 -
  89.928 -    private void checkStreamNumber(int streamNumber) {
  89.929 -        synchronized (stateLock) {
  89.930 -            if (association != null) {
  89.931 -                if (streamNumber < 0 ||
  89.932 -                      streamNumber >= association.maxOutboundStreams())
  89.933 -                    throw new InvalidStreamException();
  89.934 -            }
  89.935 -        }
  89.936 -    }
  89.937 -
  89.938 -    /* TODO: Add support for ttl and isComplete to both 121 12M
  89.939 -     *       SCTP_EOR not yet supported on reference platforms
  89.940 -     *       TTL support limited...
  89.941 -     */
  89.942 -    @Override
  89.943 -    public int send(ByteBuffer buffer, MessageInfo messageInfo)
  89.944 -            throws IOException {
  89.945 -        if (buffer == null)
  89.946 -            throw new IllegalArgumentException("buffer cannot be null");
  89.947 -
  89.948 -        if (messageInfo == null)
  89.949 -            throw new IllegalArgumentException("messageInfo cannot be null");
  89.950 -
  89.951 -        checkAssociation(messageInfo.association());
  89.952 -        checkStreamNumber(messageInfo.streamNumber());
  89.953 -
  89.954 -        synchronized (sendLock) {
  89.955 -            ensureSendOpen();
  89.956 -
  89.957 -            int n = 0;
  89.958 -            try {
  89.959 -                begin();
  89.960 -
  89.961 -                synchronized (stateLock) {
  89.962 -                    if(!isOpen())
  89.963 -                        return 0;
  89.964 -                    senderThread = NativeThread.current();
  89.965 -                }
  89.966 -
  89.967 -                do {
  89.968 -                    n = send(fdVal, buffer, messageInfo);
  89.969 -                } while ((n == IOStatus.INTERRUPTED) && isOpen());
  89.970 -
  89.971 -                return IOStatus.normalize(n);
  89.972 -            } finally {
  89.973 -                senderCleanup();
  89.974 -                end((n > 0) || (n == IOStatus.UNAVAILABLE));
  89.975 -                assert IOStatus.check(n);
  89.976 -            }
  89.977 -        }
  89.978 -    }
  89.979 -
  89.980 -    private int send(int fd, ByteBuffer src, MessageInfo messageInfo)
  89.981 -            throws IOException {
  89.982 -        int streamNumber = messageInfo.streamNumber();
  89.983 -        SocketAddress target = messageInfo.address();
  89.984 -        boolean unordered = messageInfo.isUnordered();
  89.985 -        int ppid = messageInfo.payloadProtocolID();
  89.986 -
  89.987 -        if (src instanceof DirectBuffer)
  89.988 -            return sendFromNativeBuffer(fd, src, target, streamNumber,
  89.989 -                    unordered, ppid);
  89.990 -
  89.991 -        /* Substitute a native buffer */
  89.992 -        int pos = src.position();
  89.993 -        int lim = src.limit();
  89.994 -        assert (pos <= lim && streamNumber >= 0);
  89.995 -
  89.996 -        int rem = (pos <= lim ? lim - pos : 0);
  89.997 -        ByteBuffer bb = Util.getTemporaryDirectBuffer(rem);
  89.998 -        try {
  89.999 -            bb.put(src);
 89.1000 -            bb.flip();
 89.1001 -            /* Do not update src until we see how many bytes were written */
 89.1002 -            src.position(pos);
 89.1003 -
 89.1004 -            int n = sendFromNativeBuffer(fd, bb, target, streamNumber,
 89.1005 -                    unordered, ppid);
 89.1006 -            if (n > 0) {
 89.1007 -                /* now update src */
 89.1008 -                src.position(pos + n);
 89.1009 -            }
 89.1010 -            return n;
 89.1011 -        } finally {
 89.1012 -            Util.releaseTemporaryDirectBuffer(bb);
 89.1013 -        }
 89.1014 -    }
 89.1015 -
 89.1016 -    private int sendFromNativeBuffer(int fd,
 89.1017 -                                     ByteBuffer bb,
 89.1018 -                                     SocketAddress target,
 89.1019 -                                     int streamNumber,
 89.1020 -                                     boolean unordered,
 89.1021 -                                     int ppid)
 89.1022 -            throws IOException {
 89.1023 -        int pos = bb.position();
 89.1024 -        int lim = bb.limit();
 89.1025 -        assert (pos <= lim);
 89.1026 -        int rem = (pos <= lim ? lim - pos : 0);
 89.1027 -
 89.1028 -        int written = send0(fd, ((DirectBuffer)bb).address() + pos,
 89.1029 -                            rem, target, -1 /*121*/, streamNumber, unordered, ppid);
 89.1030 -        if (written > 0)
 89.1031 -            bb.position(pos + written);
 89.1032 -        return written;
 89.1033 -    }
 89.1034 -
 89.1035 -    @Override
 89.1036 -    public SctpChannel shutdown() throws IOException {
 89.1037 -        synchronized(stateLock) {
 89.1038 -            if (isShutdown)
 89.1039 -                return this;
 89.1040 -
 89.1041 -            ensureSendOpen();
 89.1042 -            SctpNet.shutdown(fdVal, -1);
 89.1043 -            if (senderThread != 0)
 89.1044 -                NativeThread.signal(senderThread);
 89.1045 -            isShutdown = true;
 89.1046 -        }
 89.1047 -        return this;
 89.1048 -    }
 89.1049 -
 89.1050 -    @Override
 89.1051 -    public Set<SocketAddress> getAllLocalAddresses()
 89.1052 -            throws IOException {
 89.1053 -        synchronized (stateLock) {
 89.1054 -            if (!isOpen())
 89.1055 -                throw new ClosedChannelException();
 89.1056 -            if (!isBound())
 89.1057 -                return Collections.emptySet();
 89.1058 -
 89.1059 -            return SctpNet.getLocalAddresses(fdVal);
 89.1060 -        }
 89.1061 -    }
 89.1062 -
 89.1063 -    @Override
 89.1064 -    public Set<SocketAddress> getRemoteAddresses()
 89.1065 -            throws IOException {
 89.1066 -        synchronized (stateLock) {
 89.1067 -            if (!isOpen())
 89.1068 -                throw new ClosedChannelException();
 89.1069 -            if (!isConnected() || isShutdown)
 89.1070 -                return Collections.emptySet();
 89.1071 -
 89.1072 -            try {
 89.1073 -                return SctpNet.getRemoteAddresses(fdVal, 0/*unused*/);
 89.1074 -            } catch (SocketException unused) {
 89.1075 -                /* an open connected channel should always have remote addresses */
 89.1076 -                return remoteAddresses;
 89.1077 -            }
 89.1078 -        }
 89.1079 -    }
 89.1080 -
 89.1081 -    /* Native */
 89.1082 -    private static native void initIDs();
 89.1083 -
 89.1084 -    static native int receive0(int fd, SctpResultContainer resultContainer,
 89.1085 -            long address, int length, boolean peek) throws IOException;
 89.1086 -
 89.1087 -    static native int send0(int fd, long address, int length,
 89.1088 -            SocketAddress target, int assocId, int streamNumber,
 89.1089 -            boolean unordered, int ppid) throws IOException;
 89.1090 -
 89.1091 -    private static native int checkConnect(FileDescriptor fd, boolean block,
 89.1092 -            boolean ready) throws IOException;
 89.1093 -
 89.1094 -    static {
 89.1095 -        Util.load();   /* loads nio & net native libraries */
 89.1096 -        java.security.AccessController.doPrivileged(
 89.1097 -                new sun.security.action.LoadLibraryAction("sctp"));
 89.1098 -        initIDs();
 89.1099 -    }
 89.1100 -}
    90.1 --- a/src/solaris/classes/sun/nio/ch/SctpMultiChannelImpl.java	Thu Feb 16 13:01:36 2012 -0800
    90.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    90.3 @@ -1,985 +0,0 @@
    90.4 -/*
    90.5 - * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
    90.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    90.7 - *
    90.8 - * This code is free software; you can redistribute it and/or modify it
    90.9 - * under the terms of the GNU General Public License version 2 only, as
   90.10 - * published by the Free Software Foundation.  Oracle designates this
   90.11 - * particular file as subject to the "Classpath" exception as provided
   90.12 - * by Oracle in the LICENSE file that accompanied this code.
   90.13 - *
   90.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   90.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   90.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   90.17 - * version 2 for more details (a copy is included in the LICENSE file that
   90.18 - * accompanied this code).
   90.19 - *
   90.20 - * You should have received a copy of the GNU General Public License version
   90.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   90.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   90.23 - *
   90.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   90.25 - * or visit www.oracle.com if you need additional information or have any
   90.26 - * questions.
   90.27 - */
   90.28 -package sun.nio.ch;
   90.29 -
   90.30 -import java.net.InetAddress;
   90.31 -import java.net.SocketAddress;
   90.32 -import java.net.SocketException;
   90.33 -import java.net.InetSocketAddress;
   90.34 -import java.io.FileDescriptor;
   90.35 -import java.io.IOException;
   90.36 -import java.util.Collections;
   90.37 -import java.util.Map.Entry;
   90.38 -import java.util.Iterator;
   90.39 -import java.util.Set;
   90.40 -import java.util.HashSet;
   90.41 -import java.util.HashMap;
   90.42 -import java.nio.ByteBuffer;
   90.43 -import java.nio.channels.SelectionKey;
   90.44 -import java.nio.channels.ClosedChannelException;
   90.45 -import java.nio.channels.NotYetBoundException;
   90.46 -import java.nio.channels.spi.SelectorProvider;
   90.47 -import com.sun.nio.sctp.AbstractNotificationHandler;
   90.48 -import com.sun.nio.sctp.Association;
   90.49 -import com.sun.nio.sctp.AssociationChangeNotification;
   90.50 -import com.sun.nio.sctp.HandlerResult;
   90.51 -import com.sun.nio.sctp.IllegalReceiveException;
   90.52 -import com.sun.nio.sctp.InvalidStreamException;
   90.53 -import com.sun.nio.sctp.IllegalUnbindException;
   90.54 -import com.sun.nio.sctp.NotificationHandler;
   90.55 -import com.sun.nio.sctp.MessageInfo;
   90.56 -import com.sun.nio.sctp.SctpChannel;
   90.57 -import com.sun.nio.sctp.SctpMultiChannel;
   90.58 -import com.sun.nio.sctp.SctpSocketOption;
   90.59 -import static com.sun.nio.sctp.SctpStandardSocketOptions.*;
   90.60 -import static sun.nio.ch.SctpResultContainer.*;
   90.61 -
   90.62 -/**
   90.63 - * An implementation of SctpMultiChannel
   90.64 - */
   90.65 -public class SctpMultiChannelImpl extends SctpMultiChannel
   90.66 -    implements SelChImpl
   90.67 -{
   90.68 -    private final FileDescriptor fd;
   90.69 -
   90.70 -    private final int fdVal;
   90.71 -
   90.72 -    /* IDs of native threads doing send and receives, for signalling */
   90.73 -    private volatile long receiverThread = 0;
   90.74 -    private volatile long senderThread = 0;
   90.75 -
   90.76 -    /* Lock held by current receiving thread */
   90.77 -    private final Object receiveLock = new Object();
   90.78 -
   90.79 -    /* Lock held by current sending thread */
   90.80 -    private final Object sendLock = new Object();
   90.81 -
   90.82 -    /* Lock held by any thread that modifies the state fields declared below
   90.83 -     * DO NOT invoke a blocking I/O operation while holding this lock! */
   90.84 -    private final Object stateLock = new Object();
   90.85 -
   90.86 -    private enum ChannelState {
   90.87 -        UNINITIALIZED,
   90.88 -        KILLPENDING,
   90.89 -        KILLED,
   90.90 -    }
   90.91 -
   90.92 -    /* -- The following fields are protected by stateLock -- */
   90.93 -    private ChannelState state = ChannelState.UNINITIALIZED;
   90.94 -
   90.95 -    /* Binding: Once bound the port will remain constant. */
   90.96 -    int port = -1;
   90.97 -    private HashSet<InetSocketAddress> localAddresses = new HashSet<InetSocketAddress>();
   90.98 -    /* Has the channel been bound to the wildcard address */
   90.99 -    private boolean wildcard; /* false */
  90.100 -
  90.101 -    /* Keeps a map of addresses to association, and visa versa */
  90.102 -    private HashMap<SocketAddress, Association> addressMap =
  90.103 -                         new HashMap<SocketAddress, Association>();
  90.104 -    private HashMap<Association, Set<SocketAddress>> associationMap =
  90.105 -                         new HashMap<Association, Set<SocketAddress>>();
  90.106 -
  90.107 -    /* -- End of fields protected by stateLock -- */
  90.108 -
  90.109 -    /* If an association has been shutdown mark it for removal after
  90.110 -     * the user handler has been invoked */
  90.111 -    private final ThreadLocal<Association> associationToRemove =
  90.112 -        new ThreadLocal<Association>() {
  90.113 -             @Override protected Association initialValue() {
  90.114 -                 return null;
  90.115 -            }
  90.116 -    };
  90.117 -
  90.118 -    /* A notification handler cannot invoke receive */
  90.119 -    private final ThreadLocal<Boolean> receiveInvoked =
  90.120 -        new ThreadLocal<Boolean>() {
  90.121 -             @Override protected Boolean initialValue() {
  90.122 -                 return Boolean.FALSE;
  90.123 -            }
  90.124 -    };
  90.125 -
  90.126 -    public SctpMultiChannelImpl(SelectorProvider provider)
  90.127 -            throws IOException {
  90.128 -        //TODO: update provider, remove public modifier
  90.129 -        super(provider);
  90.130 -        this.fd = SctpNet.socket(false /*one-to-many*/);
  90.131 -        this.fdVal = IOUtil.fdVal(fd);
  90.132 -    }
  90.133 -
  90.134 -    @Override
  90.135 -    public SctpMultiChannel bind(SocketAddress local, int backlog)
  90.136 -            throws IOException {
  90.137 -        synchronized (receiveLock) {
  90.138 -            synchronized (sendLock) {
  90.139 -                synchronized (stateLock) {
  90.140 -                    ensureOpen();
  90.141 -                    if (isBound())
  90.142 -                        SctpNet.throwAlreadyBoundException();
  90.143 -                    InetSocketAddress isa = (local == null) ?
  90.144 -                        new InetSocketAddress(0) : Net.checkAddress(local);
  90.145 -
  90.146 -                    SecurityManager sm = System.getSecurityManager();
  90.147 -                    if (sm != null)
  90.148 -                        sm.checkListen(isa.getPort());
  90.149 -                    Net.bind(fd, isa.getAddress(), isa.getPort());
  90.150 -
  90.151 -                    InetSocketAddress boundIsa = Net.localAddress(fd);
  90.152 -                    port = boundIsa.getPort();
  90.153 -                    localAddresses.add(isa);
  90.154 -                    if (isa.getAddress().isAnyLocalAddress())
  90.155 -                        wildcard = true;
  90.156 -
  90.157 -                    SctpNet.listen(fdVal, backlog < 1 ? 50 : backlog);
  90.158 -                }
  90.159 -            }
  90.160 -        }
  90.161 -        return this;
  90.162 -    }
  90.163 -
  90.164 -    @Override
  90.165 -    public SctpMultiChannel bindAddress(InetAddress address)
  90.166 -            throws IOException {
  90.167 -        return bindUnbindAddress(address, true);
  90.168 -    }
  90.169 -
  90.170 -    @Override
  90.171 -    public SctpMultiChannel unbindAddress(InetAddress address)
  90.172 -            throws IOException {
  90.173 -        return bindUnbindAddress(address, false);
  90.174 -    }
  90.175 -
  90.176 -    private SctpMultiChannel bindUnbindAddress(InetAddress address,
  90.177 -                                               boolean add)
  90.178 -            throws IOException {
  90.179 -        if (address == null)
  90.180 -            throw new IllegalArgumentException();
  90.181 -
  90.182 -        synchronized (receiveLock) {
  90.183 -            synchronized (sendLock) {
  90.184 -                synchronized (stateLock) {
  90.185 -                    if (!isOpen())
  90.186 -                        throw new ClosedChannelException();
  90.187 -                    if (!isBound())
  90.188 -                        throw new NotYetBoundException();
  90.189 -                    if (wildcard)
  90.190 -                        throw new IllegalStateException(
  90.191 -                                "Cannot add or remove addresses from a channel that is bound to the wildcard address");
  90.192 -                    if (address.isAnyLocalAddress())
  90.193 -                        throw new IllegalArgumentException(
  90.194 -                                "Cannot add or remove the wildcard address");
  90.195 -                    if (add) {
  90.196 -                        for (InetSocketAddress addr : localAddresses) {
  90.197 -                            if (addr.getAddress().equals(address)) {
  90.198 -                                SctpNet.throwAlreadyBoundException();
  90.199 -                            }
  90.200 -                        }
  90.201 -                    } else { /*removing */
  90.202 -                        /* Verify that there is more than one address
  90.203 -                         * and that address is already bound */
  90.204 -                        if (localAddresses.size() <= 1)
  90.205 -                            throw new IllegalUnbindException("Cannot remove address from a channel with only one address bound");
  90.206 -                        boolean foundAddress = false;
  90.207 -                        for (InetSocketAddress addr : localAddresses) {
  90.208 -                            if (addr.getAddress().equals(address)) {
  90.209 -                                foundAddress = true;
  90.210 -                                break;
  90.211 -                            }
  90.212 -                        }
  90.213 -                        if (!foundAddress )
  90.214 -                            throw new IllegalUnbindException("Cannot remove address from a channel that is not bound to that address");
  90.215 -                    }
  90.216 -
  90.217 -                    SctpNet.bindx(fdVal, new InetAddress[]{address}, port, add);
  90.218 -
  90.219 -                    /* Update our internal Set to reflect the addition/removal */
  90.220 -                    if (add)
  90.221 -                        localAddresses.add(new InetSocketAddress(address, port));
  90.222 -                    else {
  90.223 -                        for (InetSocketAddress addr : localAddresses) {
  90.224 -                            if (addr.getAddress().equals(address)) {
  90.225 -                                localAddresses.remove(addr);
  90.226 -                                break;
  90.227 -                            }
  90.228 -                        }
  90.229 -                    }
  90.230 -                }
  90.231 -            }
  90.232 -        }
  90.233 -        return this;
  90.234 -    }
  90.235 -
  90.236 -    @Override
  90.237 -    public Set<Association> associations()
  90.238 -            throws ClosedChannelException, NotYetBoundException {
  90.239 -        synchronized (stateLock) {
  90.240 -            if (!isOpen())
  90.241 -                throw new ClosedChannelException();
  90.242 -            if (!isBound())
  90.243 -                throw new NotYetBoundException();
  90.244 -
  90.245 -            return Collections.unmodifiableSet(associationMap.keySet());
  90.246 -        }
  90.247 -    }
  90.248 -
  90.249 -    private boolean isBound() {
  90.250 -        synchronized (stateLock) {
  90.251 -            return port == -1 ? false : true;
  90.252 -        }
  90.253 -    }
  90.254 -
  90.255 -    private void ensureOpen() throws IOException {
  90.256 -        synchronized (stateLock) {
  90.257 -            if (!isOpen())
  90.258 -                throw new ClosedChannelException();
  90.259 -        }
  90.260 -    }
  90.261 -
  90.262 -    private void receiverCleanup() throws IOException {
  90.263 -        synchronized (stateLock) {
  90.264 -            receiverThread = 0;
  90.265 -            if (state == ChannelState.KILLPENDING)
  90.266 -                kill();
  90.267 -        }
  90.268 -    }
  90.269 -
  90.270 -    private void senderCleanup() throws IOException {
  90.271 -        synchronized (stateLock) {
  90.272 -            senderThread = 0;
  90.273 -            if (state == ChannelState.KILLPENDING)
  90.274 -                kill();
  90.275 -        }
  90.276 -    }
  90.277 -
  90.278 -    @Override
  90.279 -    protected void implConfigureBlocking(boolean block) throws IOException {
  90.280 -        IOUtil.configureBlocking(fd, block);
  90.281 -    }
  90.282 -
  90.283 -    @Override
  90.284 -    public void implCloseSelectableChannel() throws IOException {
  90.285 -        synchronized (stateLock) {
  90.286 -            SctpNet.preClose(fdVal);
  90.287 -
  90.288 -            if (receiverThread != 0)
  90.289 -                NativeThread.signal(receiverThread);
  90.290 -
  90.291 -            if (senderThread != 0)
  90.292 -                NativeThread.signal(senderThread);
  90.293 -
  90.294 -            if (!isRegistered())
  90.295 -                kill();
  90.296 -        }
  90.297 -    }
  90.298 -
  90.299 -    @Override
  90.300 -    public FileDescriptor getFD() {
  90.301 -        return fd;
  90.302 -    }
  90.303 -
  90.304 -    @Override
  90.305 -    public int getFDVal() {
  90.306 -        return fdVal;
  90.307 -    }
  90.308 -
  90.309 -    /**
  90.310 -     * Translates native poll revent ops into a ready operation ops
  90.311 -     */
  90.312 -    private boolean translateReadyOps(int ops, int initialOps,
  90.313 -                                      SelectionKeyImpl sk) {
  90.314 -        int intOps = sk.nioInterestOps();
  90.315 -        int oldOps = sk.nioReadyOps();
  90.316 -        int newOps = initialOps;
  90.317 -
  90.318 -        if ((ops & PollArrayWrapper.POLLNVAL) != 0) {
  90.319 -            /* This should only happen if this channel is pre-closed while a
  90.320 -             * selection operation is in progress
  90.321 -             * ## Throw an error if this channel has not been pre-closed */
  90.322 -            return false;
  90.323 -        }
  90.324 -
  90.325 -        if ((ops & (PollArrayWrapper.POLLERR
  90.326 -                    | PollArrayWrapper.POLLHUP)) != 0) {
  90.327 -            newOps = intOps;
  90.328 -            sk.nioReadyOps(newOps);
  90.329 -            return (newOps & ~oldOps) != 0;
  90.330 -        }
  90.331 -
  90.332 -        if (((ops & PollArrayWrapper.POLLIN) != 0) &&
  90.333 -            ((intOps & SelectionKey.OP_READ) != 0))
  90.334 -            newOps |= SelectionKey.OP_READ;
  90.335 -
  90.336 -        if (((ops & PollArrayWrapper.POLLOUT) != 0) &&
  90.337 -            ((intOps & SelectionKey.OP_WRITE) != 0))
  90.338 -            newOps |= SelectionKey.OP_WRITE;
  90.339 -
  90.340 -        sk.nioReadyOps(newOps);
  90.341 -        return (newOps & ~oldOps) != 0;
  90.342 -    }
  90.343 -
  90.344 -    @Override
  90.345 -    public boolean translateAndUpdateReadyOps(int ops, SelectionKeyImpl sk) {
  90.346 -        return translateReadyOps(ops, sk.nioReadyOps(), sk);
  90.347 -    }
  90.348 -
  90.349 -    @Override
  90.350 -    public boolean translateAndSetReadyOps(int ops, SelectionKeyImpl sk) {
  90.351 -        return translateReadyOps(ops, 0, sk);
  90.352 -    }
  90.353 -
  90.354 -    @Override
  90.355 -    public void translateAndSetInterestOps(int ops, SelectionKeyImpl sk) {
  90.356 -        int newOps = 0;
  90.357 -        if ((ops & SelectionKey.OP_READ) != 0)
  90.358 -            newOps |= PollArrayWrapper.POLLIN;
  90.359 -        if ((ops & SelectionKey.OP_WRITE) != 0)
  90.360 -            newOps |= PollArrayWrapper.POLLOUT;
  90.361 -        sk.selector.putEventOps(sk, newOps);
  90.362 -    }
  90.363 -
  90.364 -    @Override
  90.365 -    public void kill() throws IOException {
  90.366 -        synchronized (stateLock) {
  90.367 -            if (state == ChannelState.KILLED)
  90.368 -                return;
  90.369 -            if (state == ChannelState.UNINITIALIZED) {
  90.370 -                state = ChannelState.KILLED;
  90.371 -                return;
  90.372 -            }
  90.373 -            assert !isOpen() && !isRegistered();
  90.374 -
  90.375 -            /* Postpone the kill if there is a thread sending or receiving. */
  90.376 -            if (receiverThread == 0 && senderThread == 0) {
  90.377 -                SctpNet.close(fdVal);
  90.378 -                state = ChannelState.KILLED;
  90.379 -            } else {
  90.380 -                state = ChannelState.KILLPENDING;
  90.381 -            }
  90.382 -        }
  90.383 -    }
  90.384 -
  90.385 -    @Override
  90.386 -    public <T> SctpMultiChannel setOption(SctpSocketOption<T> name,
  90.387 -                                          T value,
  90.388 -                                          Association association)
  90.389 -            throws IOException {
  90.390 -        if (name == null)
  90.391 -            throw new NullPointerException();
  90.392 -        if (!(supportedOptions().contains(name)))
  90.393 -            throw new UnsupportedOperationException("'" + name + "' not supported");
  90.394 -
  90.395 -        synchronized (stateLock) {
  90.396 -            if (association != null && (name.equals(SCTP_PRIMARY_ADDR) ||
  90.397 -                    name.equals(SCTP_SET_PEER_PRIMARY_ADDR))) {
  90.398 -                checkAssociation(association);
  90.399 -            }
  90.400 -            if (!isOpen())
  90.401 -                throw new ClosedChannelException();
  90.402 -
  90.403 -            int assocId = association == null ? 0 : association.associationID();
  90.404 -            SctpNet.setSocketOption(fdVal, name, value, assocId);
  90.405 -        }
  90.406 -        return this;
  90.407 -    }
  90.408 -
  90.409 -    @Override
  90.410 -    @SuppressWarnings("unchecked")
  90.411 -    public <T> T getOption(SctpSocketOption<T> name, Association association)
  90.412 -            throws IOException {
  90.413 -        if (name == null)
  90.414 -            throw new NullPointerException();
  90.415 -        if (!supportedOptions().contains(name))
  90.416 -            throw new UnsupportedOperationException("'" + name + "' not supported");
  90.417 -
  90.418 -        synchronized (stateLock) {
  90.419 -            if (association != null && (name.equals(SCTP_PRIMARY_ADDR) ||
  90.420 -                    name.equals(SCTP_SET_PEER_PRIMARY_ADDR))) {
  90.421 -                checkAssociation(association);
  90.422 -            }
  90.423 -            if (!isOpen())
  90.424 -                throw new ClosedChannelException();
  90.425 -
  90.426 -            int assocId = association == null ? 0 : association.associationID();
  90.427 -            return (T)SctpNet.getSocketOption(fdVal, name, assocId);
  90.428 -        }
  90.429 -    }
  90.430 -
  90.431 -    private static class DefaultOptionsHolder {
  90.432 -        static final Set<SctpSocketOption<?>> defaultOptions = defaultOptions();
  90.433 -
  90.434 -        private static Set<SctpSocketOption<?>> defaultOptions() {
  90.435 -            HashSet<SctpSocketOption<?>> set = new HashSet<SctpSocketOption<?>>(10);
  90.436 -            set.add(SCTP_DISABLE_FRAGMENTS);
  90.437 -            set.add(SCTP_EXPLICIT_COMPLETE);
  90.438 -            set.add(SCTP_FRAGMENT_INTERLEAVE);
  90.439 -            set.add(SCTP_INIT_MAXSTREAMS);
  90.440 -            set.add(SCTP_NODELAY);
  90.441 -            set.add(SCTP_PRIMARY_ADDR);
  90.442 -            set.add(SCTP_SET_PEER_PRIMARY_ADDR);
  90.443 -            set.add(SO_SNDBUF);
  90.444 -            set.add(SO_RCVBUF);
  90.445 -            set.add(SO_LINGER);
  90.446 -            return Collections.unmodifiableSet(set);
  90.447 -        }
  90.448 -    }
  90.449 -
  90.450 -    @Override
  90.451 -    public final Set<SctpSocketOption<?>> supportedOptions() {
  90.452 -        return DefaultOptionsHolder.defaultOptions;
  90.453 -    }
  90.454 -
  90.455 -    @Override
  90.456 -    public <T> MessageInfo receive(ByteBuffer buffer,
  90.457 -                                   T attachment,
  90.458 -                                   NotificationHandler<T> handler)
  90.459 -            throws IOException {
  90.460 -        if (buffer == null)
  90.461 -            throw new IllegalArgumentException("buffer cannot be null");
  90.462 -
  90.463 -        if (buffer.isReadOnly())
  90.464 -            throw new IllegalArgumentException("Read-only buffer");
  90.465 -
  90.466 -        if (receiveInvoked.get())
  90.467 -            throw new IllegalReceiveException(
  90.468 -                    "cannot invoke receive from handler");
  90.469 -        receiveInvoked.set(Boolean.TRUE);
  90.470 -
  90.471 -        try {
  90.472 -            SctpResultContainer resultContainer = new SctpResultContainer();
  90.473 -            do {
  90.474 -                resultContainer.clear();
  90.475 -                synchronized (receiveLock) {
  90.476 -                    ensureOpen();
  90.477 -                    if (!isBound())
  90.478 -                        throw new NotYetBoundException();
  90.479 -
  90.480 -                    int n = 0;
  90.481 -                    try {
  90.482 -                        begin();
  90.483 -
  90.484 -                        synchronized (stateLock) {
  90.485 -                            if(!isOpen())
  90.486 -                                return null;
  90.487 -                            receiverThread = NativeThread.current();
  90.488 -                        }
  90.489 -
  90.490 -                        do {
  90.491 -                            n = receive(fdVal, buffer, resultContainer);
  90.492 -                        } while ((n == IOStatus.INTERRUPTED) && isOpen());
  90.493 -
  90.494 -                    } finally {
  90.495 -                        receiverCleanup();
  90.496 -                        end((n > 0) || (n == IOStatus.UNAVAILABLE));
  90.497 -                        assert IOStatus.check(n);
  90.498 -                    }
  90.499 -
  90.500 -                    if (!resultContainer.isNotification()) {
  90.501 -                        /* message or nothing */
  90.502 -                        if (resultContainer.hasSomething()) {
  90.503 -                            /* Set the association before returning */
  90.504 -                            SctpMessageInfoImpl info =
  90.505 -                                    resultContainer.getMessageInfo();
  90.506 -                            info.setAssociation(lookupAssociation(info.
  90.507 -                                    associationID()));
  90.508 -                            SecurityManager sm = System.getSecurityManager();
  90.509 -                            if (sm != null) {
  90.510 -                                InetSocketAddress isa  = (InetSocketAddress)info.address();
  90.511 -                                if (!addressMap.containsKey(isa)) {
  90.512 -                                    /* must be a new association */
  90.513 -                                    try {
  90.514 -                                        sm.checkAccept(isa.getAddress().getHostAddress(),
  90.515 -                                                       isa.getPort());
  90.516 -                                    } catch (SecurityException se) {
  90.517 -                                        buffer.clear();
  90.518 -                                        throw se;
  90.519 -                                    }
  90.520 -                                }
  90.521 -                            }
  90.522 -
  90.523 -                            assert info.association() != null;
  90.524 -                            return info;
  90.525 -                        } else  {
  90.526 -                          /* Non-blocking may return null if nothing available*/
  90.527 -                            return null;
  90.528 -                        }
  90.529 -                    } else { /* notification */
  90.530 -                        synchronized (stateLock) {
  90.531 -                            handleNotificationInternal(
  90.532 -                                    resultContainer);
  90.533 -                        }
  90.534 -                    }
  90.535 -                } /* receiveLock */
  90.536 -            } while (handler == null ? true :
  90.537 -                (invokeNotificationHandler(resultContainer, handler, attachment)
  90.538 -                 == HandlerResult.CONTINUE));
  90.539 -        } finally {
  90.540 -            receiveInvoked.set(Boolean.FALSE);
  90.541 -        }
  90.542 -
  90.543 -        return null;
  90.544 -    }
  90.545 -
  90.546 -    private int receive(int fd,
  90.547 -                        ByteBuffer dst,
  90.548 -                        SctpResultContainer resultContainer)
  90.549 -            throws IOException {
  90.550 -        int pos = dst.position();
  90.551 -        int lim = dst.limit();
  90.552 -        assert (pos <= lim);
  90.553 -        int rem = (pos <= lim ? lim - pos : 0);
  90.554 -        if (dst instanceof DirectBuffer && rem > 0)
  90.555 -            return receiveIntoNativeBuffer(fd, resultContainer, dst, rem, pos);
  90.556 -
  90.557 -        /* Substitute a native buffer. */
  90.558 -        int newSize = Math.max(rem, 1);
  90.559 -        ByteBuffer bb = Util.getTemporaryDirectBuffer(newSize);
  90.560 -        try {
  90.561 -            int n = receiveIntoNativeBuffer(fd, resultContainer, bb, newSize, 0);
  90.562 -            bb.flip();
  90.563 -            if (n > 0 && rem > 0)
  90.564 -                dst.put(bb);
  90.565 -            return n;
  90.566 -        } finally {
  90.567 -            Util.releaseTemporaryDirectBuffer(bb);
  90.568 -        }
  90.569 -    }
  90.570 -
  90.571 -    private int receiveIntoNativeBuffer(int fd,
  90.572 -                                        SctpResultContainer resultContainer,
  90.573 -                                        ByteBuffer bb,
  90.574 -                                        int rem,
  90.575 -                                        int pos)
  90.576 -            throws IOException {
  90.577 -        int n = receive0(fd, resultContainer, ((DirectBuffer)bb).address() + pos, rem);
  90.578 -        if (n > 0)
  90.579 -            bb.position(pos + n);
  90.580 -        return n;
  90.581 -    }
  90.582 -
  90.583 -    private InternalNotificationHandler internalNotificationHandler =
  90.584 -            new InternalNotificationHandler();
  90.585 -
  90.586 -    private void handleNotificationInternal(SctpResultContainer resultContainer)
  90.587 -    {
  90.588 -        invokeNotificationHandler(resultContainer,
  90.589 -                internalNotificationHandler, null);
  90.590 -    }
  90.591 -
  90.592 -    private class InternalNotificationHandler
  90.593 -            extends AbstractNotificationHandler<Object>
  90.594 -    {
  90.595 -        @Override
  90.596 -        public HandlerResult handleNotification(
  90.597 -                AssociationChangeNotification not, Object unused) {
  90.598 -            SctpAssocChange sac = (SctpAssocChange) not;
  90.599 -
  90.600 -            /* Update map to reflect change in association */
  90.601 -            switch (not.event()) {
  90.602 -                case COMM_UP :
  90.603 -                    Association newAssociation = new SctpAssociationImpl
  90.604 -                       (sac.assocId(), sac.maxInStreams(), sac.maxOutStreams());
  90.605 -                    addAssociation(newAssociation);
  90.606 -                    break;
  90.607 -                case SHUTDOWN :
  90.608 -                case COMM_LOST :
  90.609 -                //case RESTART: ???
  90.610 -                    /* mark association for removal after user handler invoked*/
  90.611 -                    associationToRemove.set(lookupAssociation(sac.assocId()));
  90.612 -            }
  90.613 -            return HandlerResult.CONTINUE;
  90.614 -        }
  90.615 -    }
  90.616 -
  90.617 -    private <T> HandlerResult invokeNotificationHandler(
  90.618 -                                   SctpResultContainer resultContainer,
  90.619 -                                   NotificationHandler<T> handler,
  90.620 -                                   T attachment) {
  90.621 -        HandlerResult result;
  90.622 -        SctpNotification notification = resultContainer.notification();
  90.623 -        notification.setAssociation(lookupAssociation(notification.assocId()));
  90.624 -
  90.625 -        if (!(handler instanceof AbstractNotificationHandler)) {
  90.626 -            result = handler.handleNotification(notification, attachment);
  90.627 -        } else { /* AbstractNotificationHandler */
  90.628 -            AbstractNotificationHandler<T> absHandler =
  90.629 -                    (AbstractNotificationHandler<T>)handler;
  90.630 -            switch(resultContainer.type()) {
  90.631 -                case ASSOCIATION_CHANGED :
  90.632 -                    result = absHandler.handleNotification(
  90.633 -                            resultContainer.getAssociationChanged(), attachment);
  90.634 -                    break;
  90.635 -                case PEER_ADDRESS_CHANGED :
  90.636 -                    result = absHandler.handleNotification(
  90.637 -                            resultContainer.getPeerAddressChanged(), attachment);
  90.638 -                    break;
  90.639 -                case SEND_FAILED :
  90.640 -                    result = absHandler.handleNotification(
  90.641 -                            resultContainer.getSendFailed(), attachment);
  90.642 -                    break;
  90.643 -                case SHUTDOWN :
  90.644 -                    result =  absHandler.handleNotification(
  90.645 -                            resultContainer.getShutdown(), attachment);
  90.646 -                    break;
  90.647 -                default :
  90.648 -                    /* implementation specific handlers */
  90.649 -                    result =  absHandler.handleNotification(
  90.650 -                            resultContainer.notification(), attachment);
  90.651 -            }
  90.652 -        }
  90.653 -
  90.654 -        if (!(handler instanceof InternalNotificationHandler)) {
  90.655 -            /* Only remove associations after user handler
  90.656 -             * has finished with them */
  90.657 -            Association assoc = associationToRemove.get();
  90.658 -            if (assoc != null) {
  90.659 -                removeAssociation(assoc);
  90.660 -                associationToRemove.set(null);
  90.661 -            }
  90.662 -
  90.663 -        }
  90.664 -
  90.665 -        return result;
  90.666 -    }
  90.667 -
  90.668 -    private Association lookupAssociation(int assocId) {
  90.669 -        /* Lookup the association in our internal map */
  90.670 -        synchronized (stateLock) {
  90.671 -            Set<Association> assocs = associationMap.keySet();
  90.672 -            for (Association a : assocs) {
  90.673 -                if (a.associationID() == assocId) {
  90.674 -                    return a;
  90.675 -                }
  90.676 -            }
  90.677 -        }
  90.678 -        return null;
  90.679 -    }
  90.680 -
  90.681 -    private void addAssociation(Association association) {
  90.682 -        synchronized (stateLock) {
  90.683 -            int assocId = association.associationID();
  90.684 -            Set<SocketAddress> addresses = null;
  90.685 -
  90.686 -            try {
  90.687 -                addresses = SctpNet.getRemoteAddresses(fdVal, assocId);
  90.688 -            } catch (IOException unused) {
  90.689 -                /* OK, determining connected addresses may not be possible
  90.690 -                 * shutdown, connection lost, etc */
  90.691 -            }
  90.692 -
  90.693 -            associationMap.put(association, addresses);
  90.694 -            if (addresses != null) {
  90.695 -                for (SocketAddress addr : addresses)
  90.696 -                    addressMap.put(addr, association);
  90.697 -            }
  90.698 -        }
  90.699 -    }
  90.700 -
  90.701 -    private void removeAssociation(Association association) {
  90.702 -        synchronized (stateLock) {
  90.703 -            int assocId = association.associationID();
  90.704 -            Set<SocketAddress> addresses = null;
  90.705 -
  90.706 -             try {
  90.707 -                addresses = SctpNet.getRemoteAddresses(fdVal, assocId);
  90.708 -            } catch (IOException unused) {
  90.709 -                /* OK, determining connected addresses may not be possible
  90.710 -                 * shutdown, connection lost, etc */
  90.711 -            }
  90.712 -
  90.713 -            Set<Association> assocs = associationMap.keySet();
  90.714 -            for (Association a : assocs) {
  90.715 -                if (a.associationID() == assocId) {
  90.716 -                    associationMap.remove(a);
  90.717 -                    break;
  90.718 -                }
  90.719 -            }
  90.720 -            if (addresses != null) {
  90.721 -                for (SocketAddress addr : addresses)
  90.722 -                    addressMap.remove(addr);
  90.723 -            } else {
  90.724 -                /* We cannot determine the connected addresses */
  90.725 -                Set<java.util.Map.Entry<SocketAddress, Association>> addrAssocs =
  90.726 -                        addressMap.entrySet();
  90.727 -                Iterator<Entry<SocketAddress, Association>> iterator = addrAssocs.iterator();
  90.728 -                while (iterator.hasNext()) {
  90.729 -                    Entry<SocketAddress, Association> entry = iterator.next();
  90.730 -                    if (entry.getValue().equals(association)) {
  90.731 -                        iterator.remove();
  90.732 -                    }
  90.733 -                }
  90.734 -            }
  90.735 -        }
  90.736 -    }
  90.737 -
  90.738 -    /**
  90.739 -     * @throws  IllegalArgumentException
  90.740 -     *          If the given association is not controlled by this channel
  90.741 -     *
  90.742 -     * @return  {@code true} if, and only if, the given association is one
  90.743 -     *          of the current associations controlled by this channel
  90.744 -     */
  90.745 -    private boolean checkAssociation(Association messageAssoc) {
  90.746 -        synchronized (stateLock) {
  90.747 -            for (Association association : associationMap.keySet()) {
  90.748 -                if (messageAssoc.equals(association)) {
  90.749 -                    return true;
  90.750 -                }
  90.751 -            }
  90.752 -        }
  90.753 -        throw new IllegalArgumentException(
  90.754 -              "Given Association is not controlled by this channel");
  90.755 -    }
  90.756 -
  90.757 -    private void checkStreamNumber(Association assoc, int streamNumber) {
  90.758 -        synchronized (stateLock) {
  90.759 -            if (streamNumber < 0 || streamNumber >= assoc.maxOutboundStreams())
  90.760 -                throw new InvalidStreamException();
  90.761 -        }
  90.762 -    }
  90.763 -
  90.764 -    /* TODO: Add support for ttl and isComplete to both 121 12M
  90.765 -     *       SCTP_EOR not yet supported on reference platforms
  90.766 -     *       TTL support limited...
  90.767 -     */
  90.768 -    @Override
  90.769 -    public int send(ByteBuffer buffer, MessageInfo messageInfo)
  90.770 -            throws IOException {
  90.771 -        if (buffer == null)
  90.772 -            throw new IllegalArgumentException("buffer cannot be null");
  90.773 -
  90.774 -        if (messageInfo == null)
  90.775 -            throw new IllegalArgumentException("messageInfo cannot be null");
  90.776 -
  90.777 -        synchronized (sendLock) {
  90.778 -            ensureOpen();
  90.779 -
  90.780 -            if (!isBound())
  90.781 -                bind(null, 0);
  90.782 -
  90.783 -            int n = 0;
  90.784 -            try {
  90.785 -                int assocId = -1;
  90.786 -                SocketAddress address = null;
  90.787 -                begin();
  90.788 -
  90.789 -                synchronized (stateLock) {
  90.790 -                    if(!isOpen())
  90.791 -                        return 0;
  90.792 -                    senderThread = NativeThread.current();
  90.793 -
  90.794 -                    /* Determine what address or association to send to */
  90.795 -                    Association assoc = messageInfo.association();
  90.796 -                    InetSocketAddress addr = (InetSocketAddress)messageInfo.address();
  90.797 -                    if (assoc != null) {
  90.798 -                        checkAssociation(assoc);
  90.799 -                        checkStreamNumber(assoc, messageInfo.streamNumber());
  90.800 -                        assocId = assoc.associationID();
  90.801 -                        /* have we also got a preferred address */
  90.802 -                        if (addr != null) {
  90.803 -                            if (!assoc.equals(addressMap.get(addr)))
  90.804 -                                throw new IllegalArgumentException("given preferred address is not part of this association");
  90.805 -                            address = addr;
  90.806 -                        }
  90.807 -                    } else if (addr != null) {
  90.808 -                        address = addr;
  90.809 -                        Association association = addressMap.get(addr);
  90.810 -                        if (association != null) {
  90.811 -                            checkStreamNumber(association, messageInfo.streamNumber());
  90.812 -                            assocId = association.associationID();
  90.813 -
  90.814 -                        } else { /* must be new association */
  90.815 -                            SecurityManager sm = System.getSecurityManager();
  90.816 -                            if (sm != null)
  90.817 -                                sm.checkConnect(addr.getAddress().getHostAddress(),
  90.818 -                                                addr.getPort());
  90.819 -                        }
  90.820 -                    } else {
  90.821 -                        throw new AssertionError(
  90.822 -                            "Both association and address cannot be null");
  90.823 -                    }
  90.824 -                }
  90.825 -
  90.826 -                do {
  90.827 -                    n = send(fdVal, buffer, assocId, address, messageInfo);
  90.828 -                } while ((n == IOStatus.INTERRUPTED) && isOpen());
  90.829 -
  90.830 -                return IOStatus.normalize(n);
  90.831 -            } finally {
  90.832 -                senderCleanup();
  90.833 -                end((n > 0) || (n == IOStatus.UNAVAILABLE));
  90.834 -                assert IOStatus.check(n);
  90.835 -            }
  90.836 -        }
  90.837 -    }
  90.838 -
  90.839 -    private int send(int fd,
  90.840 -                     ByteBuffer src,
  90.841 -                     int assocId,
  90.842 -                     SocketAddress target,
  90.843 -                     MessageInfo messageInfo)
  90.844 -            throws IOException {
  90.845 -        int streamNumber = messageInfo.streamNumber();
  90.846 -        boolean unordered = messageInfo.isUnordered();
  90.847 -        int ppid = messageInfo.payloadProtocolID();
  90.848 -
  90.849 -        if (src instanceof DirectBuffer)
  90.850 -            return sendFromNativeBuffer(fd, src, target, assocId,
  90.851 -                    streamNumber, unordered, ppid);
  90.852 -
  90.853 -        /* Substitute a native buffer */
  90.854 -        int pos = src.position();
  90.855 -        int lim = src.limit();
  90.856 -        assert (pos <= lim && streamNumber >= 0);
  90.857 -
  90.858 -        int rem = (pos <= lim ? lim - pos : 0);
  90.859 -        ByteBuffer bb = Util.getTemporaryDirectBuffer(rem);
  90.860 -        try {
  90.861 -            bb.put(src);
  90.862 -            bb.flip();
  90.863 -            /* Do not update src until we see how many bytes were written */
  90.864 -            src.position(pos);
  90.865 -
  90.866 -            int n = sendFromNativeBuffer(fd, bb, target, assocId,
  90.867 -                    streamNumber, unordered, ppid);
  90.868 -            if (n > 0) {
  90.869 -                /* now update src */
  90.870 -                src.position(pos + n);
  90.871 -            }
  90.872 -            return n;
  90.873 -        } finally {
  90.874 -            Util.releaseTemporaryDirectBuffer(bb);
  90.875 -        }
  90.876 -    }
  90.877 -
  90.878 -    private int sendFromNativeBuffer(int fd,
  90.879 -                                     ByteBuffer bb,
  90.880 -                                     SocketAddress target,
  90.881 -                                     int assocId,
  90.882 -                                     int streamNumber,
  90.883 -                                     boolean unordered,
  90.884 -                                     int ppid)
  90.885 -            throws IOException {
  90.886 -        int pos = bb.position();
  90.887 -        int lim = bb.limit();
  90.888 -        assert (pos <= lim);
  90.889 -        int rem = (pos <= lim ? lim - pos : 0);
  90.890 -
  90.891 -        int written = send0(fd, ((DirectBuffer)bb).address() + pos,
  90.892 -                            rem, target, assocId, streamNumber, unordered, ppid);
  90.893 -        if (written > 0)
  90.894 -            bb.position(pos + written);
  90.895 -        return written;
  90.896 -    }
  90.897 -
  90.898 -    @Override
  90.899 -    public SctpMultiChannel shutdown(Association association)
  90.900 -            throws IOException {
  90.901 -        synchronized (stateLock) {
  90.902 -            checkAssociation(association);
  90.903 -            if (!isOpen())
  90.904 -                throw new ClosedChannelException();
  90.905 -
  90.906 -            SctpNet.shutdown(fdVal, association.associationID());
  90.907 -        }
  90.908 -        return this;
  90.909 -    }
  90.910 -
  90.911 -    @Override
  90.912 -    public Set<SocketAddress> getAllLocalAddresses()
  90.913 -            throws IOException {
  90.914 -        synchronized (stateLock) {
  90.915 -            if (!isOpen())
  90.916 -                throw new ClosedChannelException();
  90.917 -            if (!isBound())
  90.918 -                return Collections.emptySet();
  90.919 -
  90.920 -            return SctpNet.getLocalAddresses(fdVal);
  90.921 -        }
  90.922 -    }
  90.923 -
  90.924 -    @Override
  90.925 -    public Set<SocketAddress> getRemoteAddresses(Association association)
  90.926 -            throws IOException {
  90.927 -        synchronized (stateLock) {
  90.928 -            checkAssociation(association);
  90.929 -            if (!isOpen())
  90.930 -                throw new ClosedChannelException();
  90.931 -
  90.932 -            try {
  90.933 -                return SctpNet.getRemoteAddresses(fdVal, association.associationID());
  90.934 -            } catch (SocketException se) {
  90.935 -                /* a valid association should always have remote addresses */
  90.936 -                Set<SocketAddress> addrs = associationMap.get(association);
  90.937 -                return addrs != null ? addrs : Collections.<SocketAddress>emptySet();
  90.938 -            }
  90.939 -        }
  90.940 -    }
  90.941 -
  90.942 -    @Override
  90.943 -    public SctpChannel branch(Association association)
  90.944 -            throws IOException {
  90.945 -        synchronized (stateLock) {
  90.946 -            checkAssociation(association);
  90.947 -            if (!isOpen())
  90.948 -                throw new ClosedChannelException();
  90.949 -
  90.950 -            FileDescriptor bFd = SctpNet.branch(fdVal,
  90.951 -                                                association.associationID());
  90.952 -            /* successfully branched, we can now remove it from assoc list */
  90.953 -            removeAssociation(association);
  90.954 -
  90.955 -            return new SctpChannelImpl(provider(), bFd, association);
  90.956 -        }
  90.957 -    }
  90.958 -
  90.959 -    /* Use common native implementation shared between
  90.960 -     * one-to-one and one-to-many */
  90.961 -    private static int receive0(int fd,
  90.962 -                                SctpResultContainer resultContainer,
  90.963 -                                long address,
  90.964 -                                int length)
  90.965 -            throws IOException{
  90.966 -        return SctpChannelImpl.receive0(fd, resultContainer, address,
  90.967 -                length, false /*peek */);
  90.968 -    }
  90.969 -
  90.970 -    private static int send0(int fd,
  90.971 -                             long address,
  90.972 -                             int length,
  90.973 -                             SocketAddress target,
  90.974 -                             int assocId,
  90.975 -                             int streamNumber,
  90.976 -                             boolean unordered,
  90.977 -                             int ppid)
  90.978 -            throws IOException {
  90.979 -        return SctpChannelImpl.send0(fd, address, length, target, assocId,
  90.980 -                streamNumber, unordered, ppid);
  90.981 -    }
  90.982 -
  90.983 -    static {
  90.984 -        Util.load();   /* loads nio & net native libraries */
  90.985 -        java.security.AccessController.doPrivileged(
  90.986 -                new sun.security.action.LoadLibraryAction("sctp"));
  90.987 -    }
  90.988 -}
    91.1 --- a/src/solaris/classes/sun/nio/ch/SctpNet.java	Thu Feb 16 13:01:36 2012 -0800
    91.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    91.3 @@ -1,313 +0,0 @@
    91.4 -/*
    91.5 - * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
    91.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    91.7 - *
    91.8 - * This code is free software; you can redistribute it and/or modify it
    91.9 - * under the terms of the GNU General Public License version 2 only, as
   91.10 - * published by the Free Software Foundation.  Oracle designates this
   91.11 - * particular file as subject to the "Classpath" exception as provided
   91.12 - * by Oracle in the LICENSE file that accompanied this code.
   91.13 - *
   91.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   91.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   91.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   91.17 - * version 2 for more details (a copy is included in the LICENSE file that
   91.18 - * accompanied this code).
   91.19 - *
   91.20 - * You should have received a copy of the GNU General Public License version
   91.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   91.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   91.23 - *
   91.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   91.25 - * or visit www.oracle.com if you need additional information or have any
   91.26 - * questions.
   91.27 - */
   91.28 -package sun.nio.ch;
   91.29 -
   91.30 -import java.io.FileDescriptor;
   91.31 -import java.io.IOException;
   91.32 -import java.net.InetAddress;
   91.33 -import java.net.InetSocketAddress;
   91.34 -import java.net.SocketAddress;
   91.35 -import java.nio.channels.AlreadyBoundException;
   91.36 -import java.util.Set;
   91.37 -import java.util.HashSet;
   91.38 -import java.security.AccessController;
   91.39 -import sun.security.action.GetPropertyAction;
   91.40 -import com.sun.nio.sctp.SctpSocketOption;
   91.41 -import static com.sun.nio.sctp.SctpStandardSocketOptions.*;
   91.42 -
   91.43 -public class SctpNet {
   91.44 -    static final String osName = AccessController.doPrivileged(
   91.45 -                    new GetPropertyAction("os.name"));
   91.46 -
   91.47 -    /* -- Miscellaneous SCTP utilities -- */
   91.48 -
   91.49 -    private static boolean IPv4MappedAddresses() {
   91.50 -        if ("SunOS".equals(osName)) {
   91.51 -            /* Solaris supports IPv4Mapped Addresses with bindx */
   91.52 -            return true;
   91.53 -        } /* else {  //other OS/implementations  */
   91.54 -
   91.55 -        /* lksctp/linux requires Ipv4 addresses */
   91.56 -        return false;
   91.57 -    }
   91.58 -
   91.59 -    static boolean throwAlreadyBoundException() throws IOException {
   91.60 -        throw new AlreadyBoundException();
   91.61 -    }
   91.62 -
   91.63 -    static void listen(int fd, int backlog) throws IOException {
   91.64 -        listen0(fd, backlog);
   91.65 -    }
   91.66 -
   91.67 -    static int connect(int fd, InetAddress remote, int remotePort)
   91.68 -            throws IOException {
   91.69 -        return connect0(fd, remote, remotePort);
   91.70 -    }
   91.71 -
   91.72 -    static void close(int fd) throws IOException {
   91.73 -        close0(fd);
   91.74 -    }
   91.75 -
   91.76 -    static void preClose(int fd) throws IOException {
   91.77 -        preClose0(fd);
   91.78 -    }
   91.79 -
   91.80 -    /**
   91.81 -     * @param  oneToOne
   91.82 -     *         if {@code true} returns a one-to-one sctp socket, otherwise
   91.83 -     *         returns a one-to-many sctp socket
   91.84 -     */
   91.85 -    static FileDescriptor socket(boolean oneToOne) throws IOException {
   91.86 -        int nativefd = socket0(oneToOne);
   91.87 -        return IOUtil.newFD(nativefd);
   91.88 -    }
   91.89 -
   91.90 -    static void bindx(int fd, InetAddress[] addrs, int port, boolean add)
   91.91 -            throws IOException {
   91.92 -        bindx(fd, addrs, port, addrs.length, add,
   91.93 -                IPv4MappedAddresses());
   91.94 -    }
   91.95 -
   91.96 -    static Set<SocketAddress> getLocalAddresses(int fd)
   91.97 -            throws IOException {
   91.98 -        HashSet<SocketAddress> set = null;
   91.99 -        SocketAddress[] saa = getLocalAddresses0(fd);
  91.100 -
  91.101 -        if (saa != null) {
  91.102 -            set = new HashSet<SocketAddress>(saa.length);
  91.103 -            for (SocketAddress sa : saa)
  91.104 -                set.add(sa);
  91.105 -        }
  91.106 -
  91.107 -        return set;
  91.108 -    }
  91.109 -
  91.110 -    static Set<SocketAddress> getRemoteAddresses(int fd, int assocId)
  91.111 -            throws IOException {
  91.112 -        HashSet<SocketAddress> set = null;
  91.113 -        SocketAddress[] saa = getRemoteAddresses0(fd, assocId);
  91.114 -
  91.115 -        if (saa != null) {
  91.116 -            set = new HashSet<SocketAddress>(saa.length);
  91.117 -            for (SocketAddress sa : saa)
  91.118 -                set.add(sa);
  91.119 -        }
  91.120 -
  91.121 -        return set;
  91.122 -    }
  91.123 -
  91.124 -    static <T> void setSocketOption(int fd,
  91.125 -                                    SctpSocketOption<T> name,
  91.126 -                                    T value,
  91.127 -                                    int assocId)
  91.128 -            throws IOException {
  91.129 -        if (value == null)
  91.130 -            throw new IllegalArgumentException("Invalid option value");
  91.131 -
  91.132 -        if (name.equals(SCTP_INIT_MAXSTREAMS)) {
  91.133 -            InitMaxStreams maxStreamValue = (InitMaxStreams)value;
  91.134 -            SctpNet.setInitMsgOption0(fd,
  91.135 -                 maxStreamValue.maxInStreams(), maxStreamValue.maxOutStreams());
  91.136 -        } else if (name.equals(SCTP_PRIMARY_ADDR) ||
  91.137 -                   name.equals(SCTP_SET_PEER_PRIMARY_ADDR)) {
  91.138 -
  91.139 -            SocketAddress addr  = (SocketAddress) value;
  91.140 -            if (addr == null)
  91.141 -                throw new IllegalArgumentException("Invalid option value");
  91.142 -
  91.143 -            Net.checkAddress(addr);
  91.144 -            InetSocketAddress netAddr = (InetSocketAddress)addr;
  91.145 -
  91.146 -            if (name.equals(SCTP_PRIMARY_ADDR)) {
  91.147 -                setPrimAddrOption0(fd,
  91.148 -                                   assocId,
  91.149 -                                   netAddr.getAddress(),
  91.150 -                                   netAddr.getPort());
  91.151 -            } else {
  91.152 -                setPeerPrimAddrOption0(fd,
  91.153 -                                       assocId,
  91.154 -                                       netAddr.getAddress(),
  91.155 -                                       netAddr.getPort(),
  91.156 -                                       IPv4MappedAddresses());
  91.157 -            }
  91.158 -        } else if (name.equals(SCTP_DISABLE_FRAGMENTS) ||
  91.159 -            name.equals(SCTP_EXPLICIT_COMPLETE) ||
  91.160 -            name.equals(SCTP_FRAGMENT_INTERLEAVE) ||
  91.161 -            name.equals(SCTP_NODELAY) ||
  91.162 -            name.equals(SO_SNDBUF) ||
  91.163 -            name.equals(SO_RCVBUF) ||
  91.164 -            name.equals(SO_LINGER)) {
  91.165 -            setIntOption(fd, name, value);
  91.166 -        } else {
  91.167 -            throw new AssertionError("Unknown socket option");
  91.168 -        }
  91.169 -    }
  91.170 -
  91.171 -    static Object getSocketOption(int fd, SctpSocketOption<?> name, int assocId)
  91.172 -             throws IOException {
  91.173 -         if (name.equals(SCTP_SET_PEER_PRIMARY_ADDR)) {
  91.174 -            throw new IllegalArgumentException(
  91.175 -                    "SCTP_SET_PEER_PRIMARY_ADDR cannot be retrieved");
  91.176 -        } else if (name.equals(SCTP_INIT_MAXSTREAMS)) {
  91.177 -            /* container for holding maxIn/Out streams */
  91.178 -            int[] values = new int[2];
  91.179 -            SctpNet.getInitMsgOption0(fd, values);
  91.180 -            return InitMaxStreams.create(values[0], values[1]);
  91.181 -        } else if (name.equals(SCTP_PRIMARY_ADDR)) {
  91.182 -            return getPrimAddrOption0(fd, assocId);
  91.183 -        } else if (name.equals(SCTP_DISABLE_FRAGMENTS) ||
  91.184 -            name.equals(SCTP_EXPLICIT_COMPLETE) ||
  91.185 -            name.equals(SCTP_FRAGMENT_INTERLEAVE) ||
  91.186 -            name.equals(SCTP_NODELAY) ||
  91.187 -            name.equals(SO_SNDBUF) ||
  91.188 -            name.equals(SO_RCVBUF) ||
  91.189 -            name.equals(SO_LINGER)) {
  91.190 -            return getIntOption(fd, name);
  91.191 -        } else {
  91.192 -            throw new AssertionError("Unknown socket option");
  91.193 -        }
  91.194 -    }
  91.195 -
  91.196 -    static void setIntOption(int fd, SctpSocketOption<?> name, Object value)
  91.197 -            throws IOException {
  91.198 -        if (value == null)
  91.199 -            throw new IllegalArgumentException("Invalid option value");
  91.200 -
  91.201 -        Class<?> type = name.type();
  91.202 -        if (type != Integer.class && type != Boolean.class)
  91.203 -            throw new AssertionError("Should not reach here");
  91.204 -
  91.205 -        if (name == SO_RCVBUF ||
  91.206 -            name == SO_SNDBUF)
  91.207 -        {
  91.208 -            int i = ((Integer)value).intValue();
  91.209 -            if (i < 0)
  91.210 -                throw new IllegalArgumentException(
  91.211 -                        "Invalid send/receive buffer size");
  91.212 -        } else if (name == SO_LINGER) {
  91.213 -            int i = ((Integer)value).intValue();
  91.214 -            if (i < 0)
  91.215 -                value = Integer.valueOf(-1);
  91.216 -            if (i > 65535)
  91.217 -                value = Integer.valueOf(65535);
  91.218 -        } else if (name.equals(SCTP_FRAGMENT_INTERLEAVE)) {
  91.219 -            int i = ((Integer)value).intValue();
  91.220 -            if (i < 0 || i > 2)
  91.221 -                throw new IllegalArgumentException(
  91.222 -                        "Invalid value for SCTP_FRAGMENT_INTERLEAVE");
  91.223 -        }
  91.224 -
  91.225 -        int arg;
  91.226 -        if (type == Integer.class) {
  91.227 -            arg = ((Integer)value).intValue();
  91.228 -        } else {
  91.229 -            boolean b = ((Boolean)value).booleanValue();
  91.230 -            arg = (b) ? 1 : 0;
  91.231 -        }
  91.232 -
  91.233 -        setIntOption0(fd, ((SctpStdSocketOption)name).constValue(), arg);
  91.234 -    }
  91.235 -
  91.236 -    static Object getIntOption(int fd, SctpSocketOption<?> name)
  91.237 -            throws IOException {
  91.238 -        Class<?> type = name.type();
  91.239 -
  91.240 -        if (type != Integer.class && type != Boolean.class)
  91.241 -            throw new AssertionError("Should not reach here");
  91.242 -
  91.243 -        if (!(name instanceof SctpStdSocketOption))
  91.244 -            throw new AssertionError("Should not reach here");
  91.245 -
  91.246 -        int value = getIntOption0(fd,
  91.247 -                ((SctpStdSocketOption)name).constValue());
  91.248 -
  91.249 -        if (type == Integer.class) {
  91.250 -            return Integer.valueOf(value);
  91.251 -        } else {
  91.252 -            return (value == 0) ? Boolean.FALSE : Boolean.TRUE;
  91.253 -        }
  91.254 -    }
  91.255 -
  91.256 -    static void shutdown(int fd, int assocId)
  91.257 -            throws IOException {
  91.258 -        shutdown0(fd, assocId);
  91.259 -    }
  91.260 -
  91.261 -    static FileDescriptor branch(int fd, int assocId) throws IOException {
  91.262 -        int nativefd = branch0(fd, assocId);
  91.263 -        return IOUtil.newFD(nativefd);
  91.264 -    }
  91.265 -
  91.266 -    /* Native Methods */
  91.267 -    static native int socket0(boolean oneToOne) throws IOException;
  91.268 -
  91.269 -    static native void listen0(int fd, int backlog) throws IOException;
  91.270 -
  91.271 -    static native int connect0(int fd, InetAddress remote, int remotePort)
  91.272 -        throws IOException;
  91.273 -
  91.274 -    static native void close0(int fd) throws IOException;
  91.275 -
  91.276 -    static native void preClose0(int fd) throws IOException;
  91.277 -
  91.278 -    static native void bindx(int fd, InetAddress[] addrs, int port, int length,
  91.279 -            boolean add, boolean preferIPv6) throws IOException;
  91.280 -
  91.281 -    static native int getIntOption0(int fd, int opt) throws IOException;
  91.282 -
  91.283 -    static native void setIntOption0(int fd, int opt, int arg)
  91.284 -        throws IOException;
  91.285 -
  91.286 -    static native SocketAddress[] getLocalAddresses0(int fd) throws IOException;
  91.287 -
  91.288 -    static native SocketAddress[] getRemoteAddresses0(int fd, int assocId)
  91.289 -            throws IOException;
  91.290 -
  91.291 -    static native int branch0(int fd, int assocId) throws IOException;
  91.292 -
  91.293 -    static native void setPrimAddrOption0(int fd, int assocId, InetAddress ia,
  91.294 -            int port) throws IOException;
  91.295 -
  91.296 -    static native void setPeerPrimAddrOption0(int fd, int assocId,
  91.297 -            InetAddress ia, int port, boolean preferIPv6) throws IOException;
  91.298 -
  91.299 -    static native SocketAddress getPrimAddrOption0(int fd, int assocId)
  91.300 -            throws IOException;
  91.301 -
  91.302 -    /* retVals [0] maxInStreams, [1] maxOutStreams */
  91.303 -    static native void getInitMsgOption0(int fd, int[] retVals) throws IOException;
  91.304 -
  91.305 -    static native void setInitMsgOption0(int fd, int arg1, int arg2)
  91.306 -            throws IOException;
  91.307 -
  91.308 -    static native void shutdown0(int fd, int assocId);
  91.309 -
  91.310 -    static native void init();
  91.311 -
  91.312 -    static {
  91.313 -        init();
  91.314 -    }
  91.315 -}
  91.316 -
    92.1 --- a/src/solaris/classes/sun/nio/ch/SctpNotification.java	Thu Feb 16 13:01:36 2012 -0800
    92.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    92.3 @@ -1,37 +0,0 @@
    92.4 -/*
    92.5 - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
    92.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    92.7 - *
    92.8 - * This code is free software; you can redistribute it and/or modify it
    92.9 - * under the terms of the GNU General Public License version 2 only, as
   92.10 - * published by the Free Software Foundation.  Oracle designates this
   92.11 - * particular file as subject to the "Classpath" exception as provided
   92.12 - * by Oracle in the LICENSE file that accompanied this code.
   92.13 - *
   92.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   92.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   92.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   92.17 - * version 2 for more details (a copy is included in the LICENSE file that
   92.18 - * accompanied this code).
   92.19 - *
   92.20 - * You should have received a copy of the GNU General Public License version
   92.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   92.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   92.23 - *
   92.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   92.25 - * or visit www.oracle.com if you need additional information or have any
   92.26 - * questions.
   92.27 - */
   92.28 -package sun.nio.ch;
   92.29 -
   92.30 -import com.sun.nio.sctp.Association;
   92.31 -import com.sun.nio.sctp.Notification;
   92.32 -
   92.33 -/**
   92.34 - * All Notification implemenations MUST implement this interface to provide
   92.35 - * access to the native association identidier.
   92.36 - */
   92.37 -interface SctpNotification extends Notification {
   92.38 -    int assocId();
   92.39 -    void setAssociation(Association association);
   92.40 -}
    93.1 --- a/src/solaris/classes/sun/nio/ch/SctpPeerAddrChange.java	Thu Feb 16 13:01:36 2012 -0800
    93.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    93.3 @@ -1,119 +0,0 @@
    93.4 -/*
    93.5 - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
    93.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    93.7 - *
    93.8 - * This code is free software; you can redistribute it and/or modify it
    93.9 - * under the terms of the GNU General Public License version 2 only, as
   93.10 - * published by the Free Software Foundation.  Oracle designates this
   93.11 - * particular file as subject to the "Classpath" exception as provided
   93.12 - * by Oracle in the LICENSE file that accompanied this code.
   93.13 - *
   93.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   93.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   93.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   93.17 - * version 2 for more details (a copy is included in the LICENSE file that
   93.18 - * accompanied this code).
   93.19 - *
   93.20 - * You should have received a copy of the GNU General Public License version
   93.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   93.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   93.23 - *
   93.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   93.25 - * or visit www.oracle.com if you need additional information or have any
   93.26 - * questions.
   93.27 - */
   93.28 -package sun.nio.ch;
   93.29 -
   93.30 -import java.net.SocketAddress;
   93.31 -import com.sun.nio.sctp.Association;
   93.32 -import com.sun.nio.sctp.PeerAddressChangeNotification;
   93.33 -
   93.34 -/**
   93.35 - * An implementation of PeerAddressChangeNotification
   93.36 - */
   93.37 -public class SctpPeerAddrChange extends PeerAddressChangeNotification
   93.38 -    implements SctpNotification
   93.39 -{
   93.40 -    /* static final ints so that they can be referenced from native */
   93.41 -    private final static int SCTP_ADDR_AVAILABLE = 1;
   93.42 -    private final static int SCTP_ADDR_UNREACHABLE = 2;
   93.43 -    private final static int SCTP_ADDR_REMOVED = 3;
   93.44 -    private final static int SCTP_ADDR_ADDED = 4;
   93.45 -    private final static int SCTP_ADDR_MADE_PRIM = 5;
   93.46 -    private final static int SCTP_ADDR_CONFIRMED =6;
   93.47 -
   93.48 -    private Association association;
   93.49 -
   93.50 -    /* assocId is used to lookup the association before the notification is
   93.51 -     * returned to user code */
   93.52 -    private int assocId;
   93.53 -    private SocketAddress address;
   93.54 -    private AddressChangeEvent event;
   93.55 -
   93.56 -    /* Invoked from native */
   93.57 -    private SctpPeerAddrChange(int assocId, SocketAddress address, int intEvent) {
   93.58 -        switch (intEvent) {
   93.59 -            case SCTP_ADDR_AVAILABLE :
   93.60 -                this.event = AddressChangeEvent.ADDR_AVAILABLE;
   93.61 -                break;
   93.62 -            case SCTP_ADDR_UNREACHABLE :
   93.63 -                this.event = AddressChangeEvent.ADDR_UNREACHABLE;
   93.64 -                break;
   93.65 -            case SCTP_ADDR_REMOVED :
   93.66 -                this.event = AddressChangeEvent.ADDR_REMOVED;
   93.67 -                break;
   93.68 -            case SCTP_ADDR_ADDED :
   93.69 -                this.event = AddressChangeEvent.ADDR_ADDED;
   93.70 -                break;
   93.71 -            case SCTP_ADDR_MADE_PRIM :
   93.72 -                this.event = AddressChangeEvent.ADDR_MADE_PRIMARY;
   93.73 -                break;
   93.74 -            case SCTP_ADDR_CONFIRMED :
   93.75 -                this.event = AddressChangeEvent.ADDR_CONFIRMED;
   93.76 -                break;
   93.77 -            default:
   93.78 -                throw new AssertionError("Unknown event type");
   93.79 -        }
   93.80 -        this.assocId = assocId;
   93.81 -        this.address = address;
   93.82 -    }
   93.83 -
   93.84 -    @Override
   93.85 -    public int assocId() {
   93.86 -        return assocId;
   93.87 -    }
   93.88 -
   93.89 -    @Override
   93.90 -    public void setAssociation(Association association) {
   93.91 -        this.association = association;
   93.92 -    }
   93.93 -
   93.94 -    @Override
   93.95 -    public SocketAddress address() {
   93.96 -        assert address != null;
   93.97 -        return address;
   93.98 -    }
   93.99 -
  93.100 -    @Override
  93.101 -    public Association association() {
  93.102 -        assert association != null;
  93.103 -        return association;
  93.104 -    }
  93.105 -
  93.106 -    @Override
  93.107 -    public AddressChangeEvent event() {
  93.108 -        assert event != null;
  93.109 -        return event;
  93.110 -    }
  93.111 -
  93.112 -    @Override
  93.113 -    public String toString() {
  93.114 -        StringBuilder sb = new StringBuilder();
  93.115 -        sb.append(super.toString()).append(" [");
  93.116 -        sb.append("Address: ").append(address);
  93.117 -        sb.append(", Association:").append(association);
  93.118 -        sb.append(", Event: ").append(event).append("]");
  93.119 -        return sb.toString();
  93.120 -    }
  93.121 -}
  93.122 -
    94.1 --- a/src/solaris/classes/sun/nio/ch/SctpResultContainer.java	Thu Feb 16 13:01:36 2012 -0800
    94.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    94.3 @@ -1,128 +0,0 @@
    94.4 -/*
    94.5 - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
    94.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    94.7 - *
    94.8 - * This code is free software; you can redistribute it and/or modify it
    94.9 - * under the terms of the GNU General Public License version 2 only, as
   94.10 - * published by the Free Software Foundation.  Oracle designates this
   94.11 - * particular file as subject to the "Classpath" exception as provided
   94.12 - * by Oracle in the LICENSE file that accompanied this code.
   94.13 - *
   94.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   94.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   94.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   94.17 - * version 2 for more details (a copy is included in the LICENSE file that
   94.18 - * accompanied this code).
   94.19 - *
   94.20 - * You should have received a copy of the GNU General Public License version
   94.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   94.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   94.23 - *
   94.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   94.25 - * or visit www.oracle.com if you need additional information or have any
   94.26 - * questions.
   94.27 - */
   94.28 -package sun.nio.ch;
   94.29 -
   94.30 -/**
   94.31 - * Wraps the actual message or notification so that it can be
   94.32 - * set and returned from the native receive implementation.
   94.33 - */
   94.34 -public class SctpResultContainer {
   94.35 -    /* static final ints so that they can be referenced from native */
   94.36 -    static final int NOTHING = 0;
   94.37 -    static final int MESSAGE = 1;
   94.38 -    static final int SEND_FAILED = 2;
   94.39 -    static final int ASSOCIATION_CHANGED = 3;
   94.40 -    static final int PEER_ADDRESS_CHANGED = 4;
   94.41 -    static final int SHUTDOWN = 5;
   94.42 -
   94.43 -    private Object value;
   94.44 -    private int type;
   94.45 -
   94.46 -    int type() {
   94.47 -        return type;
   94.48 -    }
   94.49 -
   94.50 -    boolean hasSomething() {
   94.51 -        return type() != NOTHING;
   94.52 -    }
   94.53 -
   94.54 -    boolean isNotification() {
   94.55 -        return type() != MESSAGE && type() != NOTHING ? true : false;
   94.56 -    }
   94.57 -
   94.58 -    void clear() {
   94.59 -        type = NOTHING;
   94.60 -        value = null;
   94.61 -    }
   94.62 -
   94.63 -    SctpNotification notification() {
   94.64 -        assert type() != MESSAGE && type() != NOTHING;
   94.65 -
   94.66 -        return (SctpNotification) value;
   94.67 -    }
   94.68 -
   94.69 -    SctpMessageInfoImpl getMessageInfo() {
   94.70 -        assert type() == MESSAGE;
   94.71 -
   94.72 -        if (value instanceof SctpMessageInfoImpl)
   94.73 -            return (SctpMessageInfoImpl) value;
   94.74 -
   94.75 -        return null;
   94.76 -    }
   94.77 -
   94.78 -    SctpSendFailed getSendFailed() {
   94.79 -        assert type() == SEND_FAILED;
   94.80 -
   94.81 -        if (value instanceof SctpSendFailed)
   94.82 -            return (SctpSendFailed) value;
   94.83 -
   94.84 -        return null;
   94.85 -    }
   94.86 -
   94.87 -    SctpAssocChange getAssociationChanged() {
   94.88 -        assert type() == ASSOCIATION_CHANGED;
   94.89 -
   94.90 -        if (value instanceof SctpAssocChange)
   94.91 -            return (SctpAssocChange) value;
   94.92 -
   94.93 -        return null;
   94.94 -    }
   94.95 -
   94.96 -    SctpPeerAddrChange getPeerAddressChanged() {
   94.97 -        assert type() == PEER_ADDRESS_CHANGED;
   94.98 -
   94.99 -        if (value instanceof SctpPeerAddrChange)
  94.100 -            return (SctpPeerAddrChange) value;
  94.101 -
  94.102 -        return null;
  94.103 -    }
  94.104 -
  94.105 -    SctpShutdown getShutdown() {
  94.106 -        assert type() == SHUTDOWN;
  94.107 -
  94.108 -        if (value instanceof SctpShutdown)
  94.109 -            return (SctpShutdown) value;
  94.110 -
  94.111 -        return null;
  94.112 -    }
  94.113 -
  94.114 -    @Override
  94.115 -    public String toString() {
  94.116 -        StringBuilder sb = new StringBuilder();
  94.117 -        sb.append("Type: ");
  94.118 -        switch (type) {
  94.119 -            case NOTHING:              sb.append("NOTHING");             break;
  94.120 -            case MESSAGE:              sb.append("MESSAGE");             break;
  94.121 -            case SEND_FAILED:          sb.append("SEND FAILED");         break;
  94.122 -            case ASSOCIATION_CHANGED:  sb.append("ASSOCIATION CHANGE");  break;
  94.123 -            case PEER_ADDRESS_CHANGED: sb.append("PEER ADDRESS CHANGE"); break;
  94.124 -            case SHUTDOWN:             sb.append("SHUTDOWN");            break;
  94.125 -            default :                  sb.append("Unknown result type");
  94.126 -        }
  94.127 -        sb.append(", Value: ");
  94.128 -        sb.append((value == null) ? "null" : value.toString());
  94.129 -        return sb.toString();
  94.130 -    }
  94.131 -}
    95.1 --- a/src/solaris/classes/sun/nio/ch/SctpSendFailed.java	Thu Feb 16 13:01:36 2012 -0800
    95.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    95.3 @@ -1,110 +0,0 @@
    95.4 -/*
    95.5 - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
    95.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    95.7 - *
    95.8 - * This code is free software; you can redistribute it and/or modify it
    95.9 - * under the terms of the GNU General Public License version 2 only, as
   95.10 - * published by the Free Software Foundation.  Oracle designates this
   95.11 - * particular file as subject to the "Classpath" exception as provided
   95.12 - * by Oracle in the LICENSE file that accompanied this code.
   95.13 - *
   95.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   95.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   95.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   95.17 - * version 2 for more details (a copy is included in the LICENSE file that
   95.18 - * accompanied this code).
   95.19 - *
   95.20 - * You should have received a copy of the GNU General Public License version
   95.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   95.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   95.23 - *
   95.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   95.25 - * or visit www.oracle.com if you need additional information or have any
   95.26 - * questions.
   95.27 - */
   95.28 -package sun.nio.ch;
   95.29 -
   95.30 -import java.nio.ByteBuffer;
   95.31 -import java.net.SocketAddress;
   95.32 -import com.sun.nio.sctp.Association;
   95.33 -import com.sun.nio.sctp.SendFailedNotification;
   95.34 -
   95.35 -/**
   95.36 - * An implementation of SendFailedNotification
   95.37 - */
   95.38 -public class SctpSendFailed extends SendFailedNotification
   95.39 -    implements SctpNotification
   95.40 -{
   95.41 -    private Association association;
   95.42 -    /* assocId is used to lookup the association before the notification is
   95.43 -     * returned to user code */
   95.44 -    private int assocId;
   95.45 -    private SocketAddress address;
   95.46 -    private ByteBuffer buffer;
   95.47 -    private int errorCode;
   95.48 -    private int streamNumber;
   95.49 -
   95.50 -    /* Invoked from native */
   95.51 -    private SctpSendFailed(int assocId,
   95.52 -                           SocketAddress address,
   95.53 -                           ByteBuffer buffer,
   95.54 -                           int errorCode,
   95.55 -                           int streamNumber) {
   95.56 -        this.assocId = assocId;
   95.57 -        this.errorCode = errorCode;
   95.58 -        this.streamNumber = streamNumber;
   95.59 -        this.address = address;
   95.60 -        this.buffer = buffer;
   95.61 -    }
   95.62 -
   95.63 -    @Override
   95.64 -    public int assocId() {
   95.65 -        return assocId;
   95.66 -    }
   95.67 -
   95.68 -    @Override
   95.69 -    public void setAssociation(Association association) {
   95.70 -        this.association = association;
   95.71 -    }
   95.72 -
   95.73 -    @Override
   95.74 -    public Association association() {
   95.75 -        /* may be null */
   95.76 -        return association;
   95.77 -    }
   95.78 -
   95.79 -    @Override
   95.80 -    public SocketAddress address() {
   95.81 -        assert address != null;
   95.82 -        return address;
   95.83 -    }
   95.84 -
   95.85 -    @Override
   95.86 -    public ByteBuffer buffer() {
   95.87 -        assert buffer != null;
   95.88 -        return buffer;
   95.89 -    }
   95.90 -
   95.91 -    @Override
   95.92 -    public int errorCode() {
   95.93 -        return errorCode;
   95.94 -    }
   95.95 -
   95.96 -    @Override
   95.97 -    public int streamNumber() {
   95.98 -        return streamNumber;
   95.99 -    }
  95.100 -
  95.101 -    @Override
  95.102 -    public String toString() {
  95.103 -        StringBuilder sb = new StringBuilder();
  95.104 -        sb.append(super.toString()).append(" [");
  95.105 -        sb.append("Association:").append(association);
  95.106 -        sb.append(", Address: ").append(address);
  95.107 -        sb.append(", buffer: ").append(buffer);
  95.108 -        sb.append(", errorCode: ").append(errorCode);
  95.109 -        sb.append(", streamNumber: ").append(streamNumber);
  95.110 -        sb.append("]");
  95.111 -        return sb.toString();
  95.112 -    }
  95.113 -}
    96.1 --- a/src/solaris/classes/sun/nio/ch/SctpServerChannelImpl.java	Thu Feb 16 13:01:36 2012 -0800
    96.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    96.3 @@ -1,425 +0,0 @@
    96.4 -/*
    96.5 - * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
    96.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    96.7 - *
    96.8 - * This code is free software; you can redistribute it and/or modify it
    96.9 - * under the terms of the GNU General Public License version 2 only, as
   96.10 - * published by the Free Software Foundation.  Oracle designates this
   96.11 - * particular file as subject to the "Classpath" exception as provided
   96.12 - * by Oracle in the LICENSE file that accompanied this code.
   96.13 - *
   96.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   96.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   96.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   96.17 - * version 2 for more details (a copy is included in the LICENSE file that
   96.18 - * accompanied this code).
   96.19 - *
   96.20 - * You should have received a copy of the GNU General Public License version
   96.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   96.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   96.23 - *
   96.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   96.25 - * or visit www.oracle.com if you need additional information or have any
   96.26 - * questions.
   96.27 - */
   96.28 -package sun.nio.ch;
   96.29 -
   96.30 -import java.net.SocketAddress;
   96.31 -import java.net.InetSocketAddress;
   96.32 -import java.net.InetAddress;
   96.33 -import java.io.FileDescriptor;
   96.34 -import java.io.IOException;
   96.35 -import java.util.Collections;
   96.36 -import java.util.Set;
   96.37 -import java.util.HashSet;
   96.38 -import java.nio.channels.SelectionKey;
   96.39 -import java.nio.channels.ClosedChannelException;
   96.40 -import java.nio.channels.NotYetBoundException;
   96.41 -import java.nio.channels.spi.SelectorProvider;
   96.42 -import com.sun.nio.sctp.IllegalUnbindException;
   96.43 -import com.sun.nio.sctp.SctpChannel;
   96.44 -import com.sun.nio.sctp.SctpServerChannel;
   96.45 -import com.sun.nio.sctp.SctpSocketOption;
   96.46 -import com.sun.nio.sctp.SctpStandardSocketOptions;
   96.47 -
   96.48 -/**
   96.49 - * An implementation of SctpServerChannel
   96.50 - */
   96.51 -public class SctpServerChannelImpl extends SctpServerChannel
   96.52 -    implements SelChImpl
   96.53 -{
   96.54 -    private final FileDescriptor fd;
   96.55 -
   96.56 -    private final int fdVal;
   96.57 -
   96.58 -    /* IDs of native thread doing accept, for signalling */
   96.59 -    private volatile long thread = 0;
   96.60 -
   96.61 -    /* Lock held by thread currently blocked in this channel */
   96.62 -    private final Object lock = new Object();
   96.63 -
   96.64 -    /* Lock held by any thread that modifies the state fields declared below
   96.65 -     * DO NOT invoke a blocking I/O operation while holding this lock! */
   96.66 -    private final Object stateLock = new Object();
   96.67 -
   96.68 -    private enum ChannelState {
   96.69 -        UNINITIALIZED,
   96.70 -        INUSE,
   96.71 -        KILLPENDING,
   96.72 -        KILLED,
   96.73 -    }
   96.74 -    /* -- The following fields are protected by stateLock -- */
   96.75 -    private ChannelState state = ChannelState.UNINITIALIZED;
   96.76 -
   96.77 -    /* Binding: Once bound the port will remain constant. */
   96.78 -    int port = -1;
   96.79 -    private HashSet<InetSocketAddress> localAddresses = new HashSet<InetSocketAddress>();
   96.80 -    /* Has the channel been bound to the wildcard address */
   96.81 -    private boolean wildcard; /* false */
   96.82 -
   96.83 -    /* -- End of fields protected by stateLock -- */
   96.84 -
   96.85 -    /**
   96.86 -     * Initializes a new instance of this class.
   96.87 -     */
   96.88 -    public SctpServerChannelImpl(SelectorProvider provider)
   96.89 -            throws IOException {
   96.90 -        //TODO: update provider remove public modifier
   96.91 -        super(provider);
   96.92 -        this.fd = SctpNet.socket(true);
   96.93 -        this.fdVal = IOUtil.fdVal(fd);
   96.94 -        this.state = ChannelState.INUSE;
   96.95 -    }
   96.96 -
   96.97 -    @Override
   96.98 -    public SctpServerChannel bind(SocketAddress local, int backlog)
   96.99 -            throws IOException {
  96.100 -        synchronized (lock) {
  96.101 -            synchronized (stateLock) {
  96.102 -                if (!isOpen())
  96.103 -                    throw new ClosedChannelException();
  96.104 -                if (isBound())
  96.105 -                    SctpNet.throwAlreadyBoundException();
  96.106 -
  96.107 -                InetSocketAddress isa = (local == null) ?
  96.108 -                    new InetSocketAddress(0) : Net.checkAddress(local);
  96.109 -                SecurityManager sm = System.getSecurityManager();
  96.110 -                if (sm != null)
  96.111 -                    sm.checkListen(isa.getPort());
  96.112 -                Net.bind(fd, isa.getAddress(), isa.getPort());
  96.113 -
  96.114 -                InetSocketAddress boundIsa = Net.localAddress(fd);
  96.115 -                port = boundIsa.getPort();
  96.116 -                localAddresses.add(isa);
  96.117 -                    if (isa.getAddress().isAnyLocalAddress())
  96.118 -                        wildcard = true;
  96.119 -
  96.120 -                SctpNet.listen(fdVal, backlog < 1 ? 50 : backlog);
  96.121 -            }
  96.122 -        }
  96.123 -        return this;
  96.124 -    }
  96.125 -
  96.126 -    @Override
  96.127 -    public SctpServerChannel bindAddress(InetAddress address)
  96.128 -            throws IOException {
  96.129 -        return bindUnbindAddress(address, true);
  96.130 -    }
  96.131 -
  96.132 -    @Override
  96.133 -    public SctpServerChannel unbindAddress(InetAddress address)
  96.134 -            throws IOException {
  96.135 -        return bindUnbindAddress(address, false);
  96.136 -    }
  96.137 -
  96.138 -    private SctpServerChannel bindUnbindAddress(InetAddress address, boolean add)
  96.139 -            throws IOException {
  96.140 -        if (address == null)
  96.141 -            throw new IllegalArgumentException();
  96.142 -
  96.143 -        synchronized (lock) {
  96.144 -            synchronized (stateLock) {
  96.145 -                if (!isOpen())
  96.146 -                    throw new ClosedChannelException();
  96.147 -                if (!isBound())
  96.148 -                    throw new NotYetBoundException();
  96.149 -                if (wildcard)
  96.150 -                    throw new IllegalStateException(
  96.151 -                            "Cannot add or remove addresses from a channel that is bound to the wildcard address");
  96.152 -                if (address.isAnyLocalAddress())
  96.153 -                    throw new IllegalArgumentException(
  96.154 -                            "Cannot add or remove the wildcard address");
  96.155 -                if (add) {
  96.156 -                    for (InetSocketAddress addr : localAddresses) {
  96.157 -                        if (addr.getAddress().equals(address)) {
  96.158 -                            SctpNet.throwAlreadyBoundException();
  96.159 -                        }
  96.160 -                    }
  96.161 -                } else { /*removing */
  96.162 -                    /* Verify that there is more than one address
  96.163 -                     * and that address is already bound */
  96.164 -                    if (localAddresses.size() <= 1)
  96.165 -                        throw new IllegalUnbindException("Cannot remove address from a channel with only one address bound");
  96.166 -                    boolean foundAddress = false;
  96.167 -                    for (InetSocketAddress addr : localAddresses) {
  96.168 -                        if (addr.getAddress().equals(address)) {
  96.169 -                            foundAddress = true;
  96.170 -                            break;
  96.171 -                        }
  96.172 -                    }
  96.173 -                    if (!foundAddress )
  96.174 -                        throw new IllegalUnbindException("Cannot remove address from a channel that is not bound to that address");
  96.175 -                }
  96.176 -
  96.177 -                SctpNet.bindx(fdVal, new InetAddress[]{address}, port, add);
  96.178 -
  96.179 -                /* Update our internal Set to reflect the addition/removal */
  96.180 -                if (add)
  96.181 -                    localAddresses.add(new InetSocketAddress(address, port));
  96.182 -                else {
  96.183 -                    for (InetSocketAddress addr : localAddresses) {
  96.184 -                        if (addr.getAddress().equals(address)) {
  96.185 -                            localAddresses.remove(addr);
  96.186 -                            break;
  96.187 -                        }
  96.188 -                    }
  96.189 -                }
  96.190 -            }
  96.191 -        }
  96.192 -        return this;
  96.193 -    }
  96.194 -
  96.195 -    private boolean isBound() {
  96.196 -        synchronized (stateLock) {
  96.197 -            return port == -1 ? false : true;
  96.198 -        }
  96.199 -    }
  96.200 -
  96.201 -    private void acceptCleanup() throws IOException {
  96.202 -        synchronized (stateLock) {
  96.203 -            thread = 0;
  96.204 -            if (state == ChannelState.KILLPENDING)
  96.205 -                kill();
  96.206 -        }
  96.207 -    }
  96.208 -
  96.209 -    @Override
  96.210 -    public SctpChannel accept() throws IOException {
  96.211 -        synchronized (lock) {
  96.212 -            if (!isOpen())
  96.213 -                throw new ClosedChannelException();
  96.214 -            if (!isBound())
  96.215 -                throw new NotYetBoundException();
  96.216 -            SctpChannel sc = null;
  96.217 -
  96.218 -            int n = 0;
  96.219 -            FileDescriptor newfd = new FileDescriptor();
  96.220 -            InetSocketAddress[] isaa = new InetSocketAddress[1];
  96.221 -
  96.222 -            try {
  96.223 -                begin();
  96.224 -                if (!isOpen())
  96.225 -                    return null;
  96.226 -                thread = NativeThread.current();
  96.227 -                for (;;) {
  96.228 -                    n = accept0(fd, newfd, isaa);
  96.229 -                    if ((n == IOStatus.INTERRUPTED) && isOpen())
  96.230 -                        continue;
  96.231 -                    break;
  96.232 -                }
  96.233 -            } finally {
  96.234 -                acceptCleanup();
  96.235 -                end(n > 0);
  96.236 -                assert IOStatus.check(n);
  96.237 -            }
  96.238 -
  96.239 -            if (n < 1)
  96.240 -                return null;
  96.241 -
  96.242 -            IOUtil.configureBlocking(newfd, true);
  96.243 -            InetSocketAddress isa = isaa[0];
  96.244 -            sc = new SctpChannelImpl(provider(), newfd);
  96.245 -
  96.246 -            SecurityManager sm = System.getSecurityManager();
  96.247 -            if (sm != null)
  96.248 -                sm.checkAccept(isa.getAddress().getHostAddress(),
  96.249 -                               isa.getPort());
  96.250 -
  96.251 -            return sc;
  96.252 -        }
  96.253 -    }
  96.254 -
  96.255 -    @Override
  96.256 -    protected void implConfigureBlocking(boolean block) throws IOException {
  96.257 -        IOUtil.configureBlocking(fd, block);
  96.258 -    }
  96.259 -
  96.260 -    @Override
  96.261 -    public void implCloseSelectableChannel() throws IOException {
  96.262 -        synchronized (stateLock) {
  96.263 -            SctpNet.preClose(fdVal);
  96.264 -            if (thread != 0)
  96.265 -                NativeThread.signal(thread);
  96.266 -            if (!isRegistered())
  96.267 -                kill();
  96.268 -        }
  96.269 -    }
  96.270 -
  96.271 -    @Override
  96.272 -    public void kill() throws IOException {
  96.273 -        synchronized (stateLock) {
  96.274 -            if (state == ChannelState.KILLED)
  96.275 -                return;
  96.276 -            if (state == ChannelState.UNINITIALIZED) {
  96.277 -                state = ChannelState.KILLED;
  96.278 -                return;
  96.279 -            }
  96.280 -            assert !isOpen() && !isRegistered();
  96.281 -
  96.282 -            // Postpone the kill if there is a thread in accept
  96.283 -            if (thread == 0) {
  96.284 -                SctpNet.close(fdVal);
  96.285 -                state = ChannelState.KILLED;
  96.286 -            } else {
  96.287 -                state = ChannelState.KILLPENDING;
  96.288 -            }
  96.289 -        }
  96.290 -    }
  96.291 -
  96.292 -    @Override
  96.293 -    public FileDescriptor getFD() {
  96.294 -        return fd;
  96.295 -    }
  96.296 -
  96.297 -    @Override
  96.298 -    public int getFDVal() {
  96.299 -        return fdVal;
  96.300 -    }
  96.301 -
  96.302 -    /**
  96.303 -     * Translates native poll revent ops into a ready operation ops
  96.304 -     */
  96.305 -    private boolean translateReadyOps(int ops, int initialOps,
  96.306 -                                     SelectionKeyImpl sk) {
  96.307 -        int intOps = sk.nioInterestOps();
  96.308 -        int oldOps = sk.nioReadyOps();
  96.309 -        int newOps = initialOps;
  96.310 -
  96.311 -        if ((ops & PollArrayWrapper.POLLNVAL) != 0) {
  96.312 -            /* This should only happen if this channel is pre-closed while a
  96.313 -             * selection operation is in progress
  96.314 -             * ## Throw an error if this channel has not been pre-closed */
  96.315 -            return false;
  96.316 -        }
  96.317 -
  96.318 -        if ((ops & (PollArrayWrapper.POLLERR
  96.319 -                    | PollArrayWrapper.POLLHUP)) != 0) {
  96.320 -            newOps = intOps;
  96.321 -            sk.nioReadyOps(newOps);
  96.322 -            return (newOps & ~oldOps) != 0;
  96.323 -        }
  96.324 -
  96.325 -        if (((ops & PollArrayWrapper.POLLIN) != 0) &&
  96.326 -            ((intOps & SelectionKey.OP_ACCEPT) != 0))
  96.327 -                newOps |= SelectionKey.OP_ACCEPT;
  96.328 -
  96.329 -        sk.nioReadyOps(newOps);
  96.330 -        return (newOps & ~oldOps) != 0;
  96.331 -    }
  96.332 -
  96.333 -    @Override
  96.334 -    public boolean translateAndUpdateReadyOps(int ops, SelectionKeyImpl sk) {
  96.335 -        return translateReadyOps(ops, sk.nioReadyOps(), sk);
  96.336 -    }
  96.337 -
  96.338 -    @Override
  96.339 -    public boolean translateAndSetReadyOps(int ops, SelectionKeyImpl sk) {
  96.340 -        return translateReadyOps(ops, 0, sk);
  96.341 -    }
  96.342 -
  96.343 -    @Override
  96.344 -    public void translateAndSetInterestOps(int ops, SelectionKeyImpl sk) {
  96.345 -        int newOps = 0;
  96.346 -
  96.347 -        /* Translate ops */
  96.348 -        if ((ops & SelectionKey.OP_ACCEPT) != 0)
  96.349 -            newOps |= PollArrayWrapper.POLLIN;
  96.350 -        /* Place ops into pollfd array */
  96.351 -        sk.selector.putEventOps(sk, newOps);
  96.352 -
  96.353 -    }
  96.354 -
  96.355 -    @Override
  96.356 -    public <T> SctpServerChannel setOption(SctpSocketOption<T> name, T value)
  96.357 -            throws IOException {
  96.358 -        if (name == null)
  96.359 -            throw new NullPointerException();
  96.360 -        if (!supportedOptions().contains(name))
  96.361 -            throw new UnsupportedOperationException("'" + name + "' not supported");
  96.362 -
  96.363 -        synchronized (stateLock) {
  96.364 -            if (!isOpen())
  96.365 -                throw new ClosedChannelException();
  96.366 -
  96.367 -            SctpNet.setSocketOption(fdVal, name, value, 0 /*oneToOne*/);
  96.368 -            return this;
  96.369 -        }
  96.370 -    }
  96.371 -
  96.372 -    @Override
  96.373 -    @SuppressWarnings("unchecked")
  96.374 -    public <T> T getOption(SctpSocketOption<T> name) throws IOException {
  96.375 -        if (name == null)
  96.376 -            throw new NullPointerException();
  96.377 -        if (!supportedOptions().contains(name))
  96.378 -            throw new UnsupportedOperationException("'" + name + "' not supported");
  96.379 -
  96.380 -        synchronized (stateLock) {
  96.381 -            if (!isOpen())
  96.382 -                throw new ClosedChannelException();
  96.383 -
  96.384 -            return (T) SctpNet.getSocketOption(fdVal, name, 0 /*oneToOne*/);
  96.385 -        }
  96.386 -    }
  96.387 -
  96.388 -    private static class DefaultOptionsHolder {
  96.389 -        static final Set<SctpSocketOption<?>> defaultOptions = defaultOptions();
  96.390 -
  96.391 -        private static Set<SctpSocketOption<?>> defaultOptions() {
  96.392 -            HashSet<SctpSocketOption<?>> set = new HashSet<SctpSocketOption<?>>(1);
  96.393 -            set.add(SctpStandardSocketOptions.SCTP_INIT_MAXSTREAMS);
  96.394 -            return Collections.unmodifiableSet(set);
  96.395 -        }
  96.396 -    }
  96.397 -
  96.398 -    @Override
  96.399 -    public final Set<SctpSocketOption<?>> supportedOptions() {
  96.400 -        return DefaultOptionsHolder.defaultOptions;
  96.401 -    }
  96.402 -
  96.403 -    @Override
  96.404 -    public Set<SocketAddress> getAllLocalAddresses()
  96.405 -            throws IOException {
  96.406 -        synchronized (stateLock) {
  96.407 -            if (!isOpen())
  96.408 -                throw new ClosedChannelException();
  96.409 -            if (!isBound())
  96.410 -                return Collections.emptySet();
  96.411 -
  96.412 -            return SctpNet.getLocalAddresses(fdVal);
  96.413 -        }
  96.414 -    }
  96.415 -
  96.416 -    /* Native */
  96.417 -    private static native void initIDs();
  96.418 -
  96.419 -    private static native int accept0(FileDescriptor ssfd,
  96.420 -        FileDescriptor newfd, InetSocketAddress[] isaa) throws IOException;
  96.421 -
  96.422 -    static {
  96.423 -        Util.load();   // loads nio & net native libraries
  96.424 -        java.security.AccessController.doPrivileged(
  96.425 -                new sun.security.action.LoadLibraryAction("sctp"));
  96.426 -        initIDs();
  96.427 -    }
  96.428 -}
    97.1 --- a/src/solaris/classes/sun/nio/ch/SctpShutdown.java	Thu Feb 16 13:01:36 2012 -0800
    97.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    97.3 @@ -1,69 +0,0 @@
    97.4 -/*
    97.5 - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
    97.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    97.7 - *
    97.8 - * This code is free software; you can redistribute it and/or modify it
    97.9 - * under the terms of the GNU General Public License version 2 only, as
   97.10 - * published by the Free Software Foundation.  Oracle designates this
   97.11 - * particular file as subject to the "Classpath" exception as provided
   97.12 - * by Oracle in the LICENSE file that accompanied this code.
   97.13 - *
   97.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
   97.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   97.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   97.17 - * version 2 for more details (a copy is included in the LICENSE file that
   97.18 - * accompanied this code).
   97.19 - *
   97.20 - * You should have received a copy of the GNU General Public License version
   97.21 - * 2 along with this work; if not, write to the Free Software Foundation,
   97.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   97.23 - *
   97.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   97.25 - * or visit www.oracle.com if you need additional information or have any
   97.26 - * questions.
   97.27 - */
   97.28 -package sun.nio.ch;
   97.29 -
   97.30 -import com.sun.nio.sctp.Association;
   97.31 -import com.sun.nio.sctp.ShutdownNotification;
   97.32 -
   97.33 -/**
   97.34 - * An implementation of ShutdownNotification
   97.35 - */
   97.36 -public class SctpShutdown extends ShutdownNotification
   97.37 -    implements SctpNotification
   97.38 -{
   97.39 -    private Association association;
   97.40 -    /* assocId is used to lookup the association before the notification is
   97.41 -     * returned to user code */
   97.42 -    private int assocId;
   97.43 -
   97.44 -    /* Invoked from native */
   97.45 -    private SctpShutdown(int assocId) {
   97.46 -        this.assocId = assocId;
   97.47 -    }
   97.48 -
   97.49 -    @Override
   97.50 -    public int assocId() {
   97.51 -        return assocId;
   97.52 -    }
   97.53 -
   97.54 -    @Override
   97.55 -    public void setAssociation(Association association) {
   97.56 -        this.association = association;
   97.57 -    }
   97.58 -
   97.59 -    @Override
   97.60 -    public Association association() {
   97.61 -        assert association != null;
   97.62 -        return association;
   97.63 -    }
   97.64 -
   97.65 -    @Override
   97.66 -    public String toString() {
   97.67 -        StringBuilder sb = new StringBuilder();
   97.68 -        sb.append(super.toString()).append(" [");
   97.69 -        sb.append("Association:").append(association).append("]");
   97.70 -        return sb.toString();
   97.71 -    }
   97.72 -}
    98.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    98.2 +++ b/src/solaris/classes/sun/nio/ch/sctp/AssociationChange.java	Sat Feb 18 16:11:47 2012 -0800
    98.3 @@ -0,0 +1,120 @@
    98.4 +/*
    98.5 + * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
    98.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    98.7 + *
    98.8 + * This code is free software; you can redistribute it and/or modify it
    98.9 + * under the terms of the GNU General Public License version 2 only, as
   98.10 + * published by the Free Software Foundation.  Oracle designates this
   98.11 + * particular file as subject to the "Classpath" exception as provided
   98.12 + * by Oracle in the LICENSE file that accompanied this code.
   98.13 + *
   98.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
   98.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   98.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   98.17 + * version 2 for more details (a copy is included in the LICENSE file that
   98.18 + * accompanied this code).
   98.19 + *
   98.20 + * You should have received a copy of the GNU General Public License version
   98.21 + * 2 along with this work; if not, write to the Free Software Foundation,
   98.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   98.23 + *
   98.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   98.25 + * or visit www.oracle.com if you need additional information or have any
   98.26 + * questions.
   98.27 + */
   98.28 +package sun.nio.ch.sctp;
   98.29 +
   98.30 +import com.sun.nio.sctp.Association;
   98.31 +import com.sun.nio.sctp.AssociationChangeNotification;
   98.32 +
   98.33 +/**
   98.34 + * An implementation of AssociationChangeNotification
   98.35 + */
   98.36 +public class AssociationChange extends AssociationChangeNotification
   98.37 +    implements SctpNotification
   98.38 +{
   98.39 +    /* static final ints so that they can be referenced from native */
   98.40 +    private final static int SCTP_COMM_UP = 1;
   98.41 +    private final static int SCTP_COMM_LOST = 2;
   98.42 +    private final static int SCTP_RESTART = 3;
   98.43 +    private final static int SCTP_SHUTDOWN = 4;
   98.44 +    private final static int SCTP_CANT_START = 5;
   98.45 +
   98.46 +    private Association association;
   98.47 +
   98.48 +    /* assocId is used to lookup the association before the notification is
   98.49 +     * returned to user code */
   98.50 +    private int assocId;
   98.51 +    private AssocChangeEvent event;
   98.52 +    private int maxOutStreams;
   98.53 +    private int maxInStreams;
   98.54 +
   98.55 +    /* Invoked from native */
   98.56 +    private AssociationChange(int assocId,
   98.57 +                              int intEvent,
   98.58 +                              int maxOutStreams,
   98.59 +                              int maxInStreams) {
   98.60 +        switch (intEvent) {
   98.61 +            case SCTP_COMM_UP :
   98.62 +                this.event = AssocChangeEvent.COMM_UP;
   98.63 +                break;
   98.64 +            case SCTP_COMM_LOST :
   98.65 +                this.event = AssocChangeEvent.COMM_LOST;
   98.66 +                break;
   98.67 +            case SCTP_RESTART :
   98.68 +                this.event = AssocChangeEvent.RESTART;
   98.69 +                break;
   98.70 +            case SCTP_SHUTDOWN :
   98.71 +                this.event = AssocChangeEvent.SHUTDOWN;
   98.72 +                break;
   98.73 +            case SCTP_CANT_START :
   98.74 +                this.event = AssocChangeEvent.CANT_START;
   98.75 +                break;
   98.76 +            default :
   98.77 +                throw new AssertionError(
   98.78 +                      "Unknown Association Change Event type: " + intEvent);
   98.79 +        }
   98.80 +
   98.81 +        this.assocId = assocId;
   98.82 +        this.maxOutStreams = maxOutStreams;
   98.83 +        this.maxInStreams = maxInStreams;
   98.84 +    }
   98.85 +
   98.86 +    @Override
   98.87 +    public int assocId() {
   98.88 +        return assocId;
   98.89 +    }
   98.90 +
   98.91 +    @Override
   98.92 +    public void setAssociation(Association association) {
   98.93 +        this.association = association;
   98.94 +    }
   98.95 +
   98.96 +    @Override
   98.97 +    public Association association() {
   98.98 +        assert association != null;
   98.99 +        return association;
  98.100 +    }
  98.101 +
  98.102 +    @Override
  98.103 +    public AssocChangeEvent event() {
  98.104 +        return event;
  98.105 +    }
  98.106 +
  98.107 +    int maxOutStreams() {
  98.108 +        return maxOutStreams;
  98.109 +    }
  98.110 +
  98.111 +    int maxInStreams() {
  98.112 +        return maxInStreams;
  98.113 +    }
  98.114 +
  98.115 +    @Override
  98.116 +    public String toString() {
  98.117 +        StringBuilder sb = new StringBuilder();
  98.118 +        sb.append(super.toString()).append(" [");
  98.119 +        sb.append("Association:").append(association);
  98.120 +        sb.append(", Event: ").append(event).append("]");
  98.121 +        return sb.toString();
  98.122 +    }
  98.123 +}
    99.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    99.2 +++ b/src/solaris/classes/sun/nio/ch/sctp/AssociationImpl.java	Sat Feb 18 16:11:47 2012 -0800
    99.3 @@ -0,0 +1,52 @@
    99.4 +/*
    99.5 + * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
    99.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    99.7 + *
    99.8 + * This code is free software; you can redistribute it and/or modify it
    99.9 + * under the terms of the GNU General Public License version 2 only, as
   99.10 + * published by the Free Software Foundation.  Oracle designates this
   99.11 + * particular file as subject to the "Classpath" exception as provided
   99.12 + * by Oracle in the LICENSE file that accompanied this code.
   99.13 + *
   99.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
   99.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   99.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   99.17 + * version 2 for more details (a copy is included in the LICENSE file that
   99.18 + * accompanied this code).
   99.19 + *
   99.20 + * You should have received a copy of the GNU General Public License version
   99.21 + * 2 along with this work; if not, write to the Free Software Foundation,
   99.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   99.23 + *
   99.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   99.25 + * or visit www.oracle.com if you need additional information or have any
   99.26 + * questions.
   99.27 + */
   99.28 +package sun.nio.ch.sctp;
   99.29 +
   99.30 +import com.sun.nio.sctp.Association;
   99.31 +
   99.32 +/**
   99.33 + * An implementation of Association
   99.34 + */
   99.35 +public class AssociationImpl extends Association {
   99.36 +    public AssociationImpl(int associationID,
   99.37 +                           int maxInStreams,
   99.38 +                           int maxOutStreams) {
   99.39 +        super(associationID, maxInStreams, maxOutStreams);
   99.40 +    }
   99.41 +
   99.42 +    @Override
   99.43 +    public String toString() {
   99.44 +        StringBuffer sb = new StringBuffer(super.toString());
   99.45 +        return sb.append("[associationID:")
   99.46 +                 .append(associationID())
   99.47 +                 .append(", maxIn:")
   99.48 +                 .append(maxInboundStreams())
   99.49 +                 .append(", maxOut:")
   99.50 +                 .append(maxOutboundStreams())
   99.51 +                 .append("]")
   99.52 +                 .toString();
   99.53 +    }
   99.54 +}
   99.55 +
   100.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   100.2 +++ b/src/solaris/classes/sun/nio/ch/sctp/PeerAddrChange.java	Sat Feb 18 16:11:47 2012 -0800
   100.3 @@ -0,0 +1,119 @@
   100.4 +/*
   100.5 + * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
   100.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   100.7 + *
   100.8 + * This code is free software; you can redistribute it and/or modify it
   100.9 + * under the terms of the GNU General Public License version 2 only, as
  100.10 + * published by the Free Software Foundation.  Oracle designates this
  100.11 + * particular file as subject to the "Classpath" exception as provided
  100.12 + * by Oracle in the LICENSE file that accompanied this code.
  100.13 + *
  100.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
  100.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  100.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  100.17 + * version 2 for more details (a copy is included in the LICENSE file that
  100.18 + * accompanied this code).
  100.19 + *
  100.20 + * You should have received a copy of the GNU General Public License version
  100.21 + * 2 along with this work; if not, write to the Free Software Foundation,
  100.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  100.23 + *
  100.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  100.25 + * or visit www.oracle.com if you need additional information or have any
  100.26 + * questions.
  100.27 + */
  100.28 +package sun.nio.ch.sctp;
  100.29 +
  100.30 +import java.net.SocketAddress;
  100.31 +import com.sun.nio.sctp.Association;
  100.32 +import com.sun.nio.sctp.PeerAddressChangeNotification;
  100.33 +
  100.34 +/**
  100.35 + * An implementation of PeerAddressChangeNotification
  100.36 + */
  100.37 +public class PeerAddrChange extends PeerAddressChangeNotification
  100.38 +    implements SctpNotification
  100.39 +{
  100.40 +    /* static final ints so that they can be referenced from native */
  100.41 +    private final static int SCTP_ADDR_AVAILABLE = 1;
  100.42 +    private final static int SCTP_ADDR_UNREACHABLE = 2;
  100.43 +    private final static int SCTP_ADDR_REMOVED = 3;
  100.44 +    private final static int SCTP_ADDR_ADDED = 4;
  100.45 +    private final static int SCTP_ADDR_MADE_PRIM = 5;
  100.46 +    private final static int SCTP_ADDR_CONFIRMED =6;
  100.47 +
  100.48 +    private Association association;
  100.49 +
  100.50 +    /* assocId is used to lookup the association before the notification is
  100.51 +     * returned to user code */
  100.52 +    private int assocId;
  100.53 +    private SocketAddress address;
  100.54 +    private AddressChangeEvent event;
  100.55 +
  100.56 +    /* Invoked from native */
  100.57 +    private PeerAddrChange(int assocId, SocketAddress address, int intEvent) {
  100.58 +        switch (intEvent) {
  100.59 +            case SCTP_ADDR_AVAILABLE :
  100.60 +                this.event = AddressChangeEvent.ADDR_AVAILABLE;
  100.61 +                break;
  100.62 +            case SCTP_ADDR_UNREACHABLE :
  100.63 +                this.event = AddressChangeEvent.ADDR_UNREACHABLE;
  100.64 +                break;
  100.65 +            case SCTP_ADDR_REMOVED :
  100.66 +                this.event = AddressChangeEvent.ADDR_REMOVED;
  100.67 +                break;
  100.68 +            case SCTP_ADDR_ADDED :
  100.69 +                this.event = AddressChangeEvent.ADDR_ADDED;
  100.70 +                break;
  100.71 +            case SCTP_ADDR_MADE_PRIM :
  100.72 +                this.event = AddressChangeEvent.ADDR_MADE_PRIMARY;
  100.73 +                break;
  100.74 +            case SCTP_ADDR_CONFIRMED :
  100.75 +                this.event = AddressChangeEvent.ADDR_CONFIRMED;
  100.76 +                break;
  100.77 +            default:
  100.78 +                throw new AssertionError("Unknown event type");
  100.79 +        }
  100.80 +        this.assocId = assocId;
  100.81 +        this.address = address;
  100.82 +    }
  100.83 +
  100.84 +    @Override
  100.85 +    public int assocId() {
  100.86 +        return assocId;
  100.87 +    }
  100.88 +
  100.89 +    @Override
  100.90 +    public void setAssociation(Association association) {
  100.91 +        this.association = association;
  100.92 +    }
  100.93 +
  100.94 +    @Override
  100.95 +    public SocketAddress address() {
  100.96 +        assert address != null;
  100.97 +        return address;
  100.98 +    }
  100.99 +
 100.100 +    @Override
 100.101 +    public Association association() {
 100.102 +        assert association != null;
 100.103 +        return association;
 100.104 +    }
 100.105 +
 100.106 +    @Override
 100.107 +    public AddressChangeEvent event() {
 100.108 +        assert event != null;
 100.109 +        return event;
 100.110 +    }
 100.111 +
 100.112 +    @Override
 100.113 +    public String toString() {
 100.114 +        StringBuilder sb = new StringBuilder();
 100.115 +        sb.append(super.toString()).append(" [");
 100.116 +        sb.append("Address: ").append(address);
 100.117 +        sb.append(", Association:").append(association);
 100.118 +        sb.append(", Event: ").append(event).append("]");
 100.119 +        return sb.toString();
 100.120 +    }
 100.121 +}
 100.122 +
   101.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   101.2 +++ b/src/solaris/classes/sun/nio/ch/sctp/ResultContainer.java	Sat Feb 18 16:11:47 2012 -0800
   101.3 @@ -0,0 +1,128 @@
   101.4 +/*
   101.5 + * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
   101.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   101.7 + *
   101.8 + * This code is free software; you can redistribute it and/or modify it
   101.9 + * under the terms of the GNU General Public License version 2 only, as
  101.10 + * published by the Free Software Foundation.  Oracle designates this
  101.11 + * particular file as subject to the "Classpath" exception as provided
  101.12 + * by Oracle in the LICENSE file that accompanied this code.
  101.13 + *
  101.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
  101.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  101.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  101.17 + * version 2 for more details (a copy is included in the LICENSE file that
  101.18 + * accompanied this code).
  101.19 + *
  101.20 + * You should have received a copy of the GNU General Public License version
  101.21 + * 2 along with this work; if not, write to the Free Software Foundation,
  101.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  101.23 + *
  101.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  101.25 + * or visit www.oracle.com if you need additional information or have any
  101.26 + * questions.
  101.27 + */
  101.28 +package sun.nio.ch.sctp;
  101.29 +
  101.30 +/**
  101.31 + * Wraps the actual message or notification so that it can be
  101.32 + * set and returned from the native receive implementation.
  101.33 + */
  101.34 +public class ResultContainer {
  101.35 +    /* static final ints so that they can be referenced from native */
  101.36 +    static final int NOTHING = 0;
  101.37 +    static final int MESSAGE = 1;
  101.38 +    static final int SEND_FAILED = 2;
  101.39 +    static final int ASSOCIATION_CHANGED = 3;
  101.40 +    static final int PEER_ADDRESS_CHANGED = 4;
  101.41 +    static final int SHUTDOWN = 5;
  101.42 +
  101.43 +    private Object value;
  101.44 +    private int type;
  101.45 +
  101.46 +    int type() {
  101.47 +        return type;
  101.48 +    }
  101.49 +
  101.50 +    boolean hasSomething() {
  101.51 +        return type() != NOTHING;
  101.52 +    }
  101.53 +
  101.54 +    boolean isNotification() {
  101.55 +        return type() != MESSAGE && type() != NOTHING ? true : false;
  101.56 +    }
  101.57 +
  101.58 +    void clear() {
  101.59 +        type = NOTHING;
  101.60 +        value = null;
  101.61 +    }
  101.62 +
  101.63 +    SctpNotification notification() {
  101.64 +        assert type() != MESSAGE && type() != NOTHING;
  101.65 +
  101.66 +        return (SctpNotification) value;
  101.67 +    }
  101.68 +
  101.69 +    MessageInfoImpl getMessageInfo() {
  101.70 +        assert type() == MESSAGE;
  101.71 +
  101.72 +        if (value instanceof MessageInfoImpl)
  101.73 +            return (MessageInfoImpl) value;
  101.74 +
  101.75 +        return null;
  101.76 +    }
  101.77 +
  101.78 +    SendFailed getSendFailed() {
  101.79 +        assert type() == SEND_FAILED;
  101.80 +
  101.81 +        if (value instanceof SendFailed)
  101.82 +            return (SendFailed) value;
  101.83 +
  101.84 +        return null;
  101.85 +    }
  101.86 +
  101.87 +    AssociationChange getAssociationChanged() {
  101.88 +        assert type() == ASSOCIATION_CHANGED;
  101.89 +
  101.90 +        if (value instanceof AssociationChange)
  101.91 +            return (AssociationChange) value;
  101.92 +
  101.93 +        return null;
  101.94 +    }
  101.95 +
  101.96 +    PeerAddrChange getPeerAddressChanged() {
  101.97 +        assert type() == PEER_ADDRESS_CHANGED;
  101.98 +
  101.99 +        if (value instanceof PeerAddrChange)
 101.100 +            return (PeerAddrChange) value;
 101.101 +
 101.102 +        return null;
 101.103 +    }
 101.104 +
 101.105 +    Shutdown getShutdown() {
 101.106 +        assert type() == SHUTDOWN;
 101.107 +
 101.108 +        if (value instanceof Shutdown)
 101.109 +            return (Shutdown) value;
 101.110 +
 101.111 +        return null;
 101.112 +    }
 101.113 +
 101.114 +    @Override
 101.115 +    public String toString() {
 101.116 +        StringBuilder sb = new StringBuilder();
 101.117 +        sb.append("Type: ");
 101.118 +        switch (type) {
 101.119 +            case NOTHING:              sb.append("NOTHING");             break;
 101.120 +            case MESSAGE:              sb.append("MESSAGE");             break;
 101.121 +            case SEND_FAILED:          sb.append("SEND FAILED");         break;
 101.122 +            case ASSOCIATION_CHANGED:  sb.append("ASSOCIATION CHANGE");  break;
 101.123 +            case PEER_ADDRESS_CHANGED: sb.append("PEER ADDRESS CHANGE"); break;
 101.124 +            case SHUTDOWN:             sb.append("SHUTDOWN");            break;
 101.125 +            default :                  sb.append("Unknown result type");
 101.126 +        }
 101.127 +        sb.append(", Value: ");
 101.128 +        sb.append((value == null) ? "null" : value.toString());
 101.129 +        return sb.toString();
 101.130 +    }
 101.131 +}
   102.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   102.2 +++ b/src/solaris/classes/sun/nio/ch/sctp/SctpChannelImpl.java	Sat Feb 18 16:11:47 2012 -0800
   102.3 @@ -0,0 +1,1106 @@
   102.4 +/*
   102.5 + * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
   102.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   102.7 + *
   102.8 + * This code is free software; you can redistribute it and/or modify it
   102.9 + * under the terms of the GNU General Public License version 2 only, as
  102.10 + * published by the Free Software Foundation.  Oracle designates this
  102.11 + * particular file as subject to the "Classpath" exception as provided
  102.12 + * by Oracle in the LICENSE file that accompanied this code.
  102.13 + *
  102.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
  102.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  102.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  102.17 + * version 2 for more details (a copy is included in the LICENSE file that
  102.18 + * accompanied this code).
  102.19 + *
  102.20 + * You should have received a copy of the GNU General Public License version
  102.21 + * 2 along with this work; if not, write to the Free Software Foundation,
  102.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  102.23 + *
  102.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  102.25 + * or visit www.oracle.com if you need additional information or have any
  102.26 + * questions.
  102.27 + */
  102.28 +package sun.nio.ch.sctp;
  102.29 +
  102.30 +import java.net.InetAddress;
  102.31 +import java.net.SocketAddress;
  102.32 +import java.net.SocketException;
  102.33 +import java.net.InetSocketAddress;
  102.34 +import java.io.FileDescriptor;
  102.35 +import java.io.IOException;
  102.36 +import java.util.Collections;
  102.37 +import java.util.Set;
  102.38 +import java.util.HashSet;
  102.39 +import java.nio.ByteBuffer;
  102.40 +import java.nio.channels.SelectionKey;
  102.41 +import java.nio.channels.ClosedChannelException;
  102.42 +import java.nio.channels.ConnectionPendingException;
  102.43 +import java.nio.channels.NoConnectionPendingException;
  102.44 +import java.nio.channels.AlreadyConnectedException;
  102.45 +import java.nio.channels.NotYetBoundException;
  102.46 +import java.nio.channels.NotYetConnectedException;
  102.47 +import java.nio.channels.spi.SelectorProvider;
  102.48 +import com.sun.nio.sctp.AbstractNotificationHandler;
  102.49 +import com.sun.nio.sctp.Association;
  102.50 +import com.sun.nio.sctp.AssociationChangeNotification;
  102.51 +import com.sun.nio.sctp.HandlerResult;
  102.52 +import com.sun.nio.sctp.IllegalReceiveException;
  102.53 +import com.sun.nio.sctp.InvalidStreamException;
  102.54 +import com.sun.nio.sctp.IllegalUnbindException;
  102.55 +import com.sun.nio.sctp.MessageInfo;
  102.56 +import com.sun.nio.sctp.NotificationHandler;
  102.57 +import com.sun.nio.sctp.SctpChannel;
  102.58 +import com.sun.nio.sctp.SctpSocketOption;
  102.59 +import sun.nio.ch.DirectBuffer;
  102.60 +import sun.nio.ch.IOStatus;
  102.61 +import sun.nio.ch.IOUtil;
  102.62 +import sun.nio.ch.NativeThread;
  102.63 +import sun.nio.ch.Net;
  102.64 +import sun.nio.ch.PollArrayWrapper;
  102.65 +import sun.nio.ch.SelChImpl;
  102.66 +import sun.nio.ch.SelectionKeyImpl;
  102.67 +import sun.nio.ch.Util;
  102.68 +import static com.sun.nio.sctp.SctpStandardSocketOptions.*;
  102.69 +import static sun.nio.ch.sctp.ResultContainer.SEND_FAILED;
  102.70 +import static sun.nio.ch.sctp.ResultContainer.ASSOCIATION_CHANGED;
  102.71 +import static sun.nio.ch.sctp.ResultContainer.PEER_ADDRESS_CHANGED;
  102.72 +import static sun.nio.ch.sctp.ResultContainer.SHUTDOWN;
  102.73 +
  102.74 +/**
  102.75 + * An implementation of an SctpChannel
  102.76 + */
  102.77 +public class SctpChannelImpl extends SctpChannel
  102.78 +    implements SelChImpl
  102.79 +{
  102.80 +    private final FileDescriptor fd;
  102.81 +
  102.82 +    private final int fdVal;
  102.83 +
  102.84 +    /* IDs of native threads doing send and receivess, for signalling */
  102.85 +    private volatile long receiverThread = 0;
  102.86 +    private volatile long senderThread = 0;
  102.87 +
  102.88 +    /* Lock held by current receiving or connecting thread */
  102.89 +    private final Object receiveLock = new Object();
  102.90 +
  102.91 +    /* Lock held by current sending or connecting thread */
  102.92 +    private final Object sendLock = new Object();
  102.93 +
  102.94 +    private final ThreadLocal<Boolean> receiveInvoked =
  102.95 +        new ThreadLocal<Boolean>() {
  102.96 +             @Override protected Boolean initialValue() {
  102.97 +                 return Boolean.FALSE;
  102.98 +            }
  102.99 +    };
 102.100 +
 102.101 +    /* Lock held by any thread that modifies the state fields declared below
 102.102 +       DO NOT invoke a blocking I/O operation while holding this lock! */
 102.103 +    private final Object stateLock = new Object();
 102.104 +
 102.105 +    private enum ChannelState {
 102.106 +        UNINITIALIZED,
 102.107 +        UNCONNECTED,
 102.108 +        PENDING,
 102.109 +        CONNECTED,
 102.110 +        KILLPENDING,
 102.111 +        KILLED,
 102.112 +    }
 102.113 +    /* -- The following fields are protected by stateLock -- */
 102.114 +    private ChannelState state = ChannelState.UNINITIALIZED;
 102.115 +
 102.116 +    /* Binding; Once bound the port will remain constant. */
 102.117 +    int port = -1;
 102.118 +    private HashSet<InetSocketAddress> localAddresses = new HashSet<InetSocketAddress>();
 102.119 +    /* Has the channel been bound to the wildcard address */
 102.120 +    private boolean wildcard; /* false */
 102.121 +    //private InetSocketAddress remoteAddress = null;
 102.122 +
 102.123 +    /* Input/Output open */
 102.124 +    private boolean readyToConnect;
 102.125 +
 102.126 +    /* Shutdown */
 102.127 +    private boolean isShutdown;
 102.128 +
 102.129 +    private Association association;
 102.130 +
 102.131 +    private Set<SocketAddress> remoteAddresses = Collections.emptySet();
 102.132 +
 102.133 +    /* -- End of fields protected by stateLock -- */
 102.134 +
 102.135 +    /**
 102.136 +     * Constructor for normal connecting sockets
 102.137 +     */
 102.138 +    public SctpChannelImpl(SelectorProvider provider) throws IOException {
 102.139 +        //TODO: update provider remove public modifier
 102.140 +        super(provider);
 102.141 +        this.fd = SctpNet.socket(true);
 102.142 +        this.fdVal = IOUtil.fdVal(fd);
 102.143 +        this.state = ChannelState.UNCONNECTED;
 102.144 +    }
 102.145 +
 102.146 +    /**
 102.147 +     * Constructor for sockets obtained from server sockets
 102.148 +     */
 102.149 +    public SctpChannelImpl(SelectorProvider provider, FileDescriptor fd)
 102.150 +         throws IOException {
 102.151 +        this(provider, fd, null);
 102.152 +    }
 102.153 +
 102.154 +    /**
 102.155 +     * Constructor for sockets obtained from branching
 102.156 +     */
 102.157 +    public SctpChannelImpl(SelectorProvider provider,
 102.158 +                           FileDescriptor fd,
 102.159 +                           Association association)
 102.160 +            throws IOException {
 102.161 +        super(provider);
 102.162 +        this.fd = fd;
 102.163 +        this.fdVal = IOUtil.fdVal(fd);
 102.164 +        this.state = ChannelState.CONNECTED;
 102.165 +        port = (Net.localAddress(fd)).getPort();
 102.166 +
 102.167 +        if (association != null) { /* branched */
 102.168 +            this.association = association;
 102.169 +        } else { /* obtained from server channel */
 102.170 +            /* Receive COMM_UP */
 102.171 +            ByteBuffer buf = Util.getTemporaryDirectBuffer(50);
 102.172 +            try {
 102.173 +                receive(buf, null, null, true);
 102.174 +            } finally {
 102.175 +                Util.releaseTemporaryDirectBuffer(buf);
 102.176 +            }
 102.177 +        }
 102.178 +    }
 102.179 +
 102.180 +    /**
 102.181 +     * Binds the channel's socket to a local address.
 102.182 +     */
 102.183 +    @Override
 102.184 +    public SctpChannel bind(SocketAddress local) throws IOException {
 102.185 +        synchronized (receiveLock) {
 102.186 +            synchronized (sendLock) {
 102.187 +                synchronized (stateLock) {
 102.188 +                    ensureOpenAndUnconnected();
 102.189 +                    if (isBound())
 102.190 +                        SctpNet.throwAlreadyBoundException();
 102.191 +                    InetSocketAddress isa = (local == null) ?
 102.192 +                        new InetSocketAddress(0) : Net.checkAddress(local);
 102.193 +                    Net.bind(fd, isa.getAddress(), isa.getPort());
 102.194 +                    InetSocketAddress boundIsa = Net.localAddress(fd);
 102.195 +                    port = boundIsa.getPort();
 102.196 +                    localAddresses.add(isa);
 102.197 +                    if (isa.getAddress().isAnyLocalAddress())
 102.198 +                        wildcard = true;
 102.199 +                }
 102.200 +            }
 102.201 +        }
 102.202 +        return this;
 102.203 +    }
 102.204 +
 102.205 +    @Override
 102.206 +    public SctpChannel bindAddress(InetAddress address)
 102.207 +            throws IOException {
 102.208 +        bindUnbindAddress(address, true);
 102.209 +        localAddresses.add(new InetSocketAddress(address, port));
 102.210 +        return this;
 102.211 +    }
 102.212 +
 102.213 +    @Override
 102.214 +    public SctpChannel unbindAddress(InetAddress address)
 102.215 +            throws IOException {
 102.216 +        bindUnbindAddress(address, false);
 102.217 +        localAddresses.remove(new InetSocketAddress(address, port));
 102.218 +        return this;
 102.219 +    }
 102.220 +
 102.221 +    private SctpChannel bindUnbindAddress(InetAddress address, boolean add)
 102.222 +            throws IOException {
 102.223 +        if (address == null)
 102.224 +            throw new IllegalArgumentException();
 102.225 +
 102.226 +        synchronized (receiveLock) {
 102.227 +            synchronized (sendLock) {
 102.228 +                synchronized (stateLock) {
 102.229 +                    if (!isOpen())
 102.230 +                        throw new ClosedChannelException();
 102.231 +                    if (!isBound())
 102.232 +                        throw new NotYetBoundException();
 102.233 +                    if (wildcard)
 102.234 +                        throw new IllegalStateException(
 102.235 +                                "Cannot add or remove addresses from a channel that is bound to the wildcard address");
 102.236 +                    if (address.isAnyLocalAddress())
 102.237 +                        throw new IllegalArgumentException(
 102.238 +                                "Cannot add or remove the wildcard address");
 102.239 +                    if (add) {
 102.240 +                        for (InetSocketAddress addr : localAddresses) {
 102.241 +                            if (addr.getAddress().equals(address)) {
 102.242 +                                SctpNet.throwAlreadyBoundException();
 102.243 +                            }
 102.244 +                        }
 102.245 +                    } else { /*removing */
 102.246 +                        /* Verify that there is more than one address
 102.247 +                         * and that address is already bound */
 102.248 +                        if (localAddresses.size() <= 1)
 102.249 +                            throw new IllegalUnbindException("Cannot remove address from a channel with only one address bound");
 102.250 +                        boolean foundAddress = false;
 102.251 +                        for (InetSocketAddress addr : localAddresses) {
 102.252 +                            if (addr.getAddress().equals(address)) {
 102.253 +                                foundAddress = true;
 102.254 +                                break;
 102.255 +                            }
 102.256 +                        }
 102.257 +                        if (!foundAddress )
 102.258 +                            throw new IllegalUnbindException("Cannot remove address from a channel that is not bound to that address");
 102.259 +                    }
 102.260 +
 102.261 +                    SctpNet.bindx(fdVal, new InetAddress[]{address}, port, add);
 102.262 +
 102.263 +                    /* Update our internal Set to reflect the addition/removal */
 102.264 +                    if (add)
 102.265 +                        localAddresses.add(new InetSocketAddress(address, port));
 102.266 +                    else {
 102.267 +                        for (InetSocketAddress addr : localAddresses) {
 102.268 +                            if (addr.getAddress().equals(address)) {
 102.269 +                                localAddresses.remove(addr);
 102.270 +                                break;
 102.271 +                            }
 102.272 +                        }
 102.273 +                    }
 102.274 +                }
 102.275 +            }
 102.276 +        }
 102.277 +        return this;
 102.278 +    }
 102.279 +
 102.280 +    private boolean isBound() {
 102.281 +        synchronized (stateLock) {
 102.282 +            return port == -1 ? false : true;
 102.283 +        }
 102.284 +    }
 102.285 +
 102.286 +    private boolean isConnected() {
 102.287 +        synchronized (stateLock) {
 102.288 +            return (state == ChannelState.CONNECTED);
 102.289 +        }
 102.290 +    }
 102.291 +
 102.292 +    private void ensureOpenAndUnconnected() throws IOException {
 102.293 +        synchronized (stateLock) {
 102.294 +            if (!isOpen())
 102.295 +                throw new ClosedChannelException();
 102.296 +            if (isConnected())
 102.297 +                throw new AlreadyConnectedException();
 102.298 +            if (state == ChannelState.PENDING)
 102.299 +                throw new ConnectionPendingException();
 102.300 +        }
 102.301 +    }
 102.302 +
 102.303 +    private boolean ensureReceiveOpen() throws ClosedChannelException {
 102.304 +        synchronized (stateLock) {
 102.305 +            if (!isOpen())
 102.306 +                throw new ClosedChannelException();
 102.307 +            if (!isConnected())
 102.308 +                throw new NotYetConnectedException();
 102.309 +            else
 102.310 +                return true;
 102.311 +        }
 102.312 +    }
 102.313 +
 102.314 +    private void ensureSendOpen() throws ClosedChannelException {
 102.315 +        synchronized (stateLock) {
 102.316 +            if (!isOpen())
 102.317 +                throw new ClosedChannelException();
 102.318 +            if (isShutdown)
 102.319 +                throw new ClosedChannelException();
 102.320 +            if (!isConnected())
 102.321 +                throw new NotYetConnectedException();
 102.322 +        }
 102.323 +    }
 102.324 +
 102.325 +    private void receiverCleanup() throws IOException {
 102.326 +        synchronized (stateLock) {
 102.327 +            receiverThread = 0;
 102.328 +            if (state == ChannelState.KILLPENDING)
 102.329 +                kill();
 102.330 +        }
 102.331 +    }
 102.332 +
 102.333 +    private void senderCleanup() throws IOException {
 102.334 +        synchronized (stateLock) {
 102.335 +            senderThread = 0;
 102.336 +            if (state == ChannelState.KILLPENDING)
 102.337 +                kill();
 102.338 +        }
 102.339 +    }
 102.340 +
 102.341 +    @Override
 102.342 +    public Association association() throws ClosedChannelException {
 102.343 +        synchronized (stateLock) {
 102.344 +            if (!isOpen())
 102.345 +                throw new ClosedChannelException();
 102.346 +            if (!isConnected())
 102.347 +                return null;
 102.348 +
 102.349 +            return association;
 102.350 +        }
 102.351 +    }
 102.352 +
 102.353 +    @Override
 102.354 +    public boolean connect(SocketAddress endpoint) throws IOException {
 102.355 +        synchronized (receiveLock) {
 102.356 +            synchronized (sendLock) {
 102.357 +                ensureOpenAndUnconnected();
 102.358 +                InetSocketAddress isa = Net.checkAddress(endpoint);
 102.359 +                SecurityManager sm = System.getSecurityManager();
 102.360 +                if (sm != null)
 102.361 +                    sm.checkConnect(isa.getAddress().getHostAddress(),
 102.362 +                                    isa.getPort());
 102.363 +                synchronized (blockingLock()) {
 102.364 +                    int n = 0;
 102.365 +                    try {
 102.366 +                        try {
 102.367 +                            begin();
 102.368 +                            synchronized (stateLock) {
 102.369 +                                if (!isOpen()) {
 102.370 +                                    return false;
 102.371 +                                }
 102.372 +                                receiverThread = NativeThread.current();
 102.373 +                            }
 102.374 +                            for (;;) {
 102.375 +                                InetAddress ia = isa.getAddress();
 102.376 +                                if (ia.isAnyLocalAddress())
 102.377 +                                    ia = InetAddress.getLocalHost();
 102.378 +                                n = SctpNet.connect(fdVal, ia, isa.getPort());
 102.379 +                                if (  (n == IOStatus.INTERRUPTED)
 102.380 +                                      && isOpen())
 102.381 +                                    continue;
 102.382 +                                break;
 102.383 +                            }
 102.384 +                        } finally {
 102.385 +                            receiverCleanup();
 102.386 +                            end((n > 0) || (n == IOStatus.UNAVAILABLE));
 102.387 +                            assert IOStatus.check(n);
 102.388 +                        }
 102.389 +                    } catch (IOException x) {
 102.390 +                        /* If an exception was thrown, close the channel after
 102.391 +                         * invoking end() so as to avoid bogus
 102.392 +                         * AsynchronousCloseExceptions */
 102.393 +                        close();
 102.394 +                        throw x;
 102.395 +                    }
 102.396 +
 102.397 +                    if (n > 0) {
 102.398 +                        synchronized (stateLock) {
 102.399 +                            /* Connection succeeded */
 102.400 +                            state = ChannelState.CONNECTED;
 102.401 +                            if (!isBound()) {
 102.402 +                                InetSocketAddress boundIsa =
 102.403 +                                        Net.localAddress(fd);
 102.404 +                                port = boundIsa.getPort();
 102.405 +                            }
 102.406 +
 102.407 +                            /* Receive COMM_UP */
 102.408 +                            ByteBuffer buf = Util.getTemporaryDirectBuffer(50);
 102.409 +                            try {
 102.410 +                                receive(buf, null, null, true);
 102.411 +                            } finally {
 102.412 +                                Util.releaseTemporaryDirectBuffer(buf);
 102.413 +                            }
 102.414 +
 102.415 +                            /* cache remote addresses */
 102.416 +                            try {
 102.417 +                                remoteAddresses = getRemoteAddresses();
 102.418 +                            } catch (IOException unused) { /* swallow exception */ }
 102.419 +
 102.420 +                            return true;
 102.421 +                        }
 102.422 +                    } else  {
 102.423 +                        synchronized (stateLock) {
 102.424 +                            /* If nonblocking and no exception then connection
 102.425 +                             * pending; disallow another invocation */
 102.426 +                            if (!isBlocking())
 102.427 +                                state = ChannelState.PENDING;
 102.428 +                            else
 102.429 +                                assert false;
 102.430 +                        }
 102.431 +                    }
 102.432 +                }
 102.433 +                return false;
 102.434 +            }
 102.435 +        }
 102.436 +    }
 102.437 +
 102.438 +    @Override
 102.439 +    public boolean connect(SocketAddress endpoint,
 102.440 +                           int maxOutStreams,
 102.441 +                           int maxInStreams)
 102.442 +            throws IOException {
 102.443 +        ensureOpenAndUnconnected();
 102.444 +        return setOption(SCTP_INIT_MAXSTREAMS, InitMaxStreams.
 102.445 +                create(maxInStreams, maxOutStreams)).connect(endpoint);
 102.446 +
 102.447 +    }
 102.448 +
 102.449 +    @Override
 102.450 +    public boolean isConnectionPending() {
 102.451 +        synchronized (stateLock) {
 102.452 +            return (state == ChannelState.PENDING);
 102.453 +        }
 102.454 +    }
 102.455 +
 102.456 +    @Override
 102.457 +    public boolean finishConnect() throws IOException {
 102.458 +        synchronized (receiveLock) {
 102.459 +            synchronized (sendLock) {
 102.460 +                synchronized (stateLock) {
 102.461 +                    if (!isOpen())
 102.462 +                        throw new ClosedChannelException();
 102.463 +                    if (isConnected())
 102.464 +                        return true;
 102.465 +                    if (state != ChannelState.PENDING)
 102.466 +                        throw new NoConnectionPendingException();
 102.467 +                }
 102.468 +                int n = 0;
 102.469 +                try {
 102.470 +                    try {
 102.471 +                        begin();
 102.472 +                        synchronized (blockingLock()) {
 102.473 +                            synchronized (stateLock) {
 102.474 +                                if (!isOpen()) {
 102.475 +                                    return false;
 102.476 +                                }
 102.477 +                                receiverThread = NativeThread.current();
 102.478 +                            }
 102.479 +                            if (!isBlocking()) {
 102.480 +                                for (;;) {
 102.481 +                                    n = checkConnect(fd, false, readyToConnect);
 102.482 +                                    if (  (n == IOStatus.INTERRUPTED)
 102.483 +                                          && isOpen())
 102.484 +                                        continue;
 102.485 +                                    break;
 102.486 +                                }
 102.487 +                            } else {
 102.488 +                                for (;;) {
 102.489 +                                    n = checkConnect(fd, true, readyToConnect);
 102.490 +                                    if (n == 0) {
 102.491 +                                        // Loop in case of
 102.492 +                                        // spurious notifications
 102.493 +                                        continue;
 102.494 +                                    }
 102.495 +                                    if (  (n == IOStatus.INTERRUPTED)
 102.496 +                                          && isOpen())
 102.497 +                                        continue;
 102.498 +                                    break;
 102.499 +                                }
 102.500 +                            }
 102.501 +                        }
 102.502 +                    } finally {
 102.503 +                        synchronized (stateLock) {
 102.504 +                            receiverThread = 0;
 102.505 +                            if (state == ChannelState.KILLPENDING) {
 102.506 +                                kill();
 102.507 +                                /* poll()/getsockopt() does not report
 102.508 +                                 * error (throws exception, with n = 0)
 102.509 +                                 * on Linux platform after dup2 and
 102.510 +                                 * signal-wakeup. Force n to 0 so the
 102.511 +                                 * end() can throw appropriate exception */
 102.512 +                                n = 0;
 102.513 +                            }
 102.514 +                        }
 102.515 +                        end((n > 0) || (n == IOStatus.UNAVAILABLE));
 102.516 +                        assert IOStatus.check(n);
 102.517 +                    }
 102.518 +                } catch (IOException x) {
 102.519 +                    /* If an exception was thrown, close the channel after
 102.520 +                     * invoking end() so as to avoid bogus
 102.521 +                     * AsynchronousCloseExceptions */
 102.522 +                    close();
 102.523 +                    throw x;
 102.524 +                }
 102.525 +
 102.526 +                if (n > 0) {
 102.527 +                    synchronized (stateLock) {
 102.528 +                        state = ChannelState.CONNECTED;
 102.529 +                        if (!isBound()) {
 102.530 +                            InetSocketAddress boundIsa =
 102.531 +                                    Net.localAddress(fd);
 102.532 +                            port = boundIsa.getPort();
 102.533 +                        }
 102.534 +
 102.535 +                        /* Receive COMM_UP */
 102.536 +                        ByteBuffer buf = Util.getTemporaryDirectBuffer(50);
 102.537 +                        try {
 102.538 +                            receive(buf, null, null, true);
 102.539 +                        } finally {
 102.540 +                            Util.releaseTemporaryDirectBuffer(buf);
 102.541 +                        }
 102.542 +
 102.543 +                        /* cache remote addresses */
 102.544 +                        try {
 102.545 +                            remoteAddresses = getRemoteAddresses();
 102.546 +                        } catch (IOException unused) { /* swallow exception */ }
 102.547 +
 102.548 +                        return true;
 102.549 +                    }
 102.550 +                }
 102.551 +            }
 102.552 +        }
 102.553 +        return false;
 102.554 +    }
 102.555 +
 102.556 +    @Override
 102.557 +    protected void implConfigureBlocking(boolean block) throws IOException {
 102.558 +        IOUtil.configureBlocking(fd, block);
 102.559 +    }
 102.560 +
 102.561 +    @Override
 102.562 +    public void implCloseSelectableChannel() throws IOException {
 102.563 +        synchronized (stateLock) {
 102.564 +            SctpNet.preClose(fdVal);
 102.565 +
 102.566 +            if (receiverThread != 0)
 102.567 +                NativeThread.signal(receiverThread);
 102.568 +
 102.569 +            if (senderThread != 0)
 102.570 +                NativeThread.signal(senderThread);
 102.571 +
 102.572 +            if (!isRegistered())
 102.573 +                kill();
 102.574 +        }
 102.575 +    }
 102.576 +
 102.577 +    @Override
 102.578 +    public FileDescriptor getFD() {
 102.579 +        return fd;
 102.580 +    }
 102.581 +
 102.582 +    @Override
 102.583 +    public int getFDVal() {
 102.584 +        return fdVal;
 102.585 +    }
 102.586 +
 102.587 +    /**
 102.588 +     * Translates native poll revent ops into a ready operation ops
 102.589 +     */
 102.590 +    private boolean translateReadyOps(int ops, int initialOps, SelectionKeyImpl sk) {
 102.591 +        int intOps = sk.nioInterestOps();
 102.592 +        int oldOps = sk.nioReadyOps();
 102.593 +        int newOps = initialOps;
 102.594 +
 102.595 +        if ((ops & PollArrayWrapper.POLLNVAL) != 0) {
 102.596 +            /* This should only happen if this channel is pre-closed while a
 102.597 +             * selection operation is in progress
 102.598 +             * ## Throw an error if this channel has not been pre-closed */
 102.599 +            return false;
 102.600 +        }
 102.601 +
 102.602 +        if ((ops & (PollArrayWrapper.POLLERR
 102.603 +                    | PollArrayWrapper.POLLHUP)) != 0) {
 102.604 +            newOps = intOps;
 102.605 +            sk.nioReadyOps(newOps);
 102.606 +            /* No need to poll again in checkConnect,
 102.607 +             * the error will be detected there */
 102.608 +            readyToConnect = true;
 102.609 +            return (newOps & ~oldOps) != 0;
 102.610 +        }
 102.611 +
 102.612 +        if (((ops & PollArrayWrapper.POLLIN) != 0) &&
 102.613 +            ((intOps & SelectionKey.OP_READ) != 0) &&
 102.614 +            isConnected())
 102.615 +            newOps |= SelectionKey.OP_READ;
 102.616 +
 102.617 +        if (((ops & PollArrayWrapper.POLLCONN) != 0) &&
 102.618 +            ((intOps & SelectionKey.OP_CONNECT) != 0) &&
 102.619 +            ((state == ChannelState.UNCONNECTED) || (state == ChannelState.PENDING))) {
 102.620 +            newOps |= SelectionKey.OP_CONNECT;
 102.621 +            readyToConnect = true;
 102.622 +        }
 102.623 +
 102.624 +        if (((ops & PollArrayWrapper.POLLOUT) != 0) &&
 102.625 +            ((intOps & SelectionKey.OP_WRITE) != 0) &&
 102.626 +            isConnected())
 102.627 +            newOps |= SelectionKey.OP_WRITE;
 102.628 +
 102.629 +        sk.nioReadyOps(newOps);
 102.630 +        return (newOps & ~oldOps) != 0;
 102.631 +    }
 102.632 +
 102.633 +    @Override
 102.634 +    public boolean translateAndUpdateReadyOps(int ops, SelectionKeyImpl sk) {
 102.635 +        return translateReadyOps(ops, sk.nioReadyOps(), sk);
 102.636 +    }
 102.637 +
 102.638 +    @Override
 102.639 +    @SuppressWarnings("all")
 102.640 +    public boolean translateAndSetReadyOps(int ops, SelectionKeyImpl sk) {
 102.641 +        return translateReadyOps(ops, 0, sk);
 102.642 +    }
 102.643 +
 102.644 +    @Override
 102.645 +    public void translateAndSetInterestOps(int ops, SelectionKeyImpl sk) {
 102.646 +        int newOps = 0;
 102.647 +        if ((ops & SelectionKey.OP_READ) != 0)
 102.648 +            newOps |= PollArrayWrapper.POLLIN;
 102.649 +        if ((ops & SelectionKey.OP_WRITE) != 0)
 102.650 +            newOps |= PollArrayWrapper.POLLOUT;
 102.651 +        if ((ops & SelectionKey.OP_CONNECT) != 0)
 102.652 +            newOps |= PollArrayWrapper.POLLCONN;
 102.653 +        sk.selector.putEventOps(sk, newOps);
 102.654 +    }
 102.655 +
 102.656 +    @Override
 102.657 +    public void kill() throws IOException {
 102.658 +        synchronized (stateLock) {
 102.659 +            if (state == ChannelState.KILLED)
 102.660 +                return;
 102.661 +            if (state == ChannelState.UNINITIALIZED) {
 102.662 +                state = ChannelState.KILLED;
 102.663 +                return;
 102.664 +            }
 102.665 +            assert !isOpen() && !isRegistered();
 102.666 +
 102.667 +            /* Postpone the kill if there is a waiting reader
 102.668 +             * or writer thread. */
 102.669 +            if (receiverThread == 0 && senderThread == 0) {
 102.670 +                SctpNet.close(fdVal);
 102.671 +                state = ChannelState.KILLED;
 102.672 +            } else {
 102.673 +                state = ChannelState.KILLPENDING;
 102.674 +            }
 102.675 +        }
 102.676 +    }
 102.677 +
 102.678 +    @Override
 102.679 +    public <T> SctpChannel setOption(SctpSocketOption<T> name, T value)
 102.680 +            throws IOException {
 102.681 +        if (name == null)
 102.682 +            throw new NullPointerException();
 102.683 +        if (!supportedOptions().contains(name))
 102.684 +            throw new UnsupportedOperationException("'" + name + "' not supported");
 102.685 +
 102.686 +        synchronized (stateLock) {
 102.687 +            if (!isOpen())
 102.688 +                throw new ClosedChannelException();
 102.689 +
 102.690 +            SctpNet.setSocketOption(fdVal, name, value, 0 /*oneToOne*/);
 102.691 +        }
 102.692 +        return this;
 102.693 +    }
 102.694 +
 102.695 +    @Override
 102.696 +    @SuppressWarnings("unchecked")
 102.697 +    public <T> T getOption(SctpSocketOption<T> name) throws IOException {
 102.698 +        if (name == null)
 102.699 +            throw new NullPointerException();
 102.700 +        if (!supportedOptions().contains(name))
 102.701 +            throw new UnsupportedOperationException("'" + name + "' not supported");
 102.702 +
 102.703 +        synchronized (stateLock) {
 102.704 +            if (!isOpen())
 102.705 +                throw new ClosedChannelException();
 102.706 +
 102.707 +            return (T)SctpNet.getSocketOption(fdVal, name, 0 /*oneToOne*/);
 102.708 +        }
 102.709 +    }
 102.710 +
 102.711 +    private static class DefaultOptionsHolder {
 102.712 +        static final Set<SctpSocketOption<?>> defaultOptions = defaultOptions();
 102.713 +
 102.714 +        private static Set<SctpSocketOption<?>> defaultOptions() {
 102.715 +            HashSet<SctpSocketOption<?>> set = new HashSet<SctpSocketOption<?>>(10);
 102.716 +            set.add(SCTP_DISABLE_FRAGMENTS);
 102.717 +            set.add(SCTP_EXPLICIT_COMPLETE);
 102.718 +            set.add(SCTP_FRAGMENT_INTERLEAVE);
 102.719 +            set.add(SCTP_INIT_MAXSTREAMS);
 102.720 +            set.add(SCTP_NODELAY);
 102.721 +            set.add(SCTP_PRIMARY_ADDR);
 102.722 +            set.add(SCTP_SET_PEER_PRIMARY_ADDR);
 102.723 +            set.add(SO_SNDBUF);
 102.724 +            set.add(SO_RCVBUF);
 102.725 +            set.add(SO_LINGER);
 102.726 +            return Collections.unmodifiableSet(set);
 102.727 +        }
 102.728 +    }
 102.729 +
 102.730 +    @Override
 102.731 +    public final Set<SctpSocketOption<?>> supportedOptions() {
 102.732 +        return DefaultOptionsHolder.defaultOptions;
 102.733 +    }
 102.734 +
 102.735 +    @Override
 102.736 +    public <T> MessageInfo receive(ByteBuffer buffer,
 102.737 +                                   T attachment,
 102.738 +                                   NotificationHandler<T> handler)
 102.739 +            throws IOException {
 102.740 +        return receive(buffer, attachment, handler, false);
 102.741 +    }
 102.742 +
 102.743 +    private <T> MessageInfo receive(ByteBuffer buffer,
 102.744 +                                    T attachment,
 102.745 +                                    NotificationHandler<T> handler,
 102.746 +                                    boolean fromConnect)
 102.747 +            throws IOException {
 102.748 +        if (buffer == null)
 102.749 +            throw new IllegalArgumentException("buffer cannot be null");
 102.750 +
 102.751 +        if (buffer.isReadOnly())
 102.752 +            throw new IllegalArgumentException("Read-only buffer");
 102.753 +
 102.754 +        if (receiveInvoked.get())
 102.755 +            throw new IllegalReceiveException(
 102.756 +                    "cannot invoke receive from handler");
 102.757 +        receiveInvoked.set(Boolean.TRUE);
 102.758 +
 102.759 +        try {
 102.760 +            ResultContainer resultContainer = new ResultContainer();
 102.761 +            do {
 102.762 +                resultContainer.clear();
 102.763 +                synchronized (receiveLock) {
 102.764 +                    if (!ensureReceiveOpen())
 102.765 +                        return null;
 102.766 +
 102.767 +                    int n = 0;
 102.768 +                    try {
 102.769 +                        begin();
 102.770 +
 102.771 +                        synchronized (stateLock) {
 102.772 +                            if(!isOpen())
 102.773 +                                return null;
 102.774 +                            receiverThread = NativeThread.current();
 102.775 +                        }
 102.776 +
 102.777 +                        do {
 102.778 +                            n = receive(fdVal, buffer, resultContainer, fromConnect);
 102.779 +                        } while ((n == IOStatus.INTERRUPTED) && isOpen());
 102.780 +                    } finally {
 102.781 +                        receiverCleanup();
 102.782 +                        end((n > 0) || (n == IOStatus.UNAVAILABLE));
 102.783 +                        assert IOStatus.check(n);
 102.784 +                    }
 102.785 +
 102.786 +                    if (!resultContainer.isNotification()) {
 102.787 +                        /* message or nothing */
 102.788 +                        if (resultContainer.hasSomething()) {
 102.789 +                            /* Set the association before returning */
 102.790 +                            MessageInfoImpl info =
 102.791 +                                    resultContainer.getMessageInfo();
 102.792 +                            synchronized (stateLock) {
 102.793 +                                assert association != null;
 102.794 +                                info.setAssociation(association);
 102.795 +                            }
 102.796 +                            return info;
 102.797 +                        } else
 102.798 +                            /* Non-blocking may return null if nothing available*/
 102.799 +                            return null;
 102.800 +                    } else { /* notification */
 102.801 +                        synchronized (stateLock) {
 102.802 +                            handleNotificationInternal(
 102.803 +                                    resultContainer);
 102.804 +                        }
 102.805 +                    }
 102.806 +
 102.807 +                    if (fromConnect)  {
 102.808 +                        /* If we reach here, then it was connect that invoked
 102.809 +                         * receive and received the COMM_UP. We have already
 102.810 +                         * handled the COMM_UP with the internal notification
 102.811 +                         * handler. Simply return. */
 102.812 +                        return null;
 102.813 +                    }
 102.814 +                }  /* receiveLock */
 102.815 +            } while (handler == null ? true :
 102.816 +                (invokeNotificationHandler(resultContainer, handler, attachment)
 102.817 +                 == HandlerResult.CONTINUE));
 102.818 +
 102.819 +            return null;
 102.820 +        } finally {
 102.821 +            receiveInvoked.set(Boolean.FALSE);
 102.822 +        }
 102.823 +    }
 102.824 +
 102.825 +    private int receive(int fd,
 102.826 +                        ByteBuffer dst,
 102.827 +                        ResultContainer resultContainer,
 102.828 +                        boolean peek)
 102.829 +            throws IOException {
 102.830 +        int pos = dst.position();
 102.831 +        int lim = dst.limit();
 102.832 +        assert (pos <= lim);
 102.833 +        int rem = (pos <= lim ? lim - pos : 0);
 102.834 +        if (dst instanceof DirectBuffer && rem > 0)
 102.835 +            return receiveIntoNativeBuffer(fd, resultContainer, dst, rem, pos, peek);
 102.836 +
 102.837 +        /* Substitute a native buffer */
 102.838 +        int newSize = Math.max(rem, 1);
 102.839 +        ByteBuffer bb = Util.getTemporaryDirectBuffer(newSize);
 102.840 +        try {
 102.841 +            int n = receiveIntoNativeBuffer(fd, resultContainer, bb, newSize, 0, peek);
 102.842 +            bb.flip();
 102.843 +            if (n > 0 && rem > 0)
 102.844 +                dst.put(bb);
 102.845 +            return n;
 102.846 +        } finally {
 102.847 +            Util.releaseTemporaryDirectBuffer(bb);
 102.848 +        }
 102.849 +    }
 102.850 +
 102.851 +    private int receiveIntoNativeBuffer(int fd,
 102.852 +                                        ResultContainer resultContainer,
 102.853 +                                        ByteBuffer bb,
 102.854 +                                        int rem,
 102.855 +                                        int pos,
 102.856 +                                        boolean peek)
 102.857 +        throws IOException
 102.858 +    {
 102.859 +        int n = receive0(fd, resultContainer, ((DirectBuffer)bb).address() + pos, rem, peek);
 102.860 +
 102.861 +        if (n > 0)
 102.862 +            bb.position(pos + n);
 102.863 +        return n;
 102.864 +    }
 102.865 +
 102.866 +    private InternalNotificationHandler internalNotificationHandler =
 102.867 +            new InternalNotificationHandler();
 102.868 +
 102.869 +    private void handleNotificationInternal(ResultContainer resultContainer)
 102.870 +    {
 102.871 +        invokeNotificationHandler(resultContainer,
 102.872 +                internalNotificationHandler, null);
 102.873 +    }
 102.874 +
 102.875 +    private class InternalNotificationHandler
 102.876 +            extends AbstractNotificationHandler<Object>
 102.877 +    {
 102.878 +        @Override
 102.879 +        public HandlerResult handleNotification(
 102.880 +                AssociationChangeNotification not, Object unused) {
 102.881 +            if (not.event().equals(
 102.882 +                    AssociationChangeNotification.AssocChangeEvent.COMM_UP) &&
 102.883 +                    association == null) {
 102.884 +                AssociationChange sac = (AssociationChange) not;
 102.885 +                association = new AssociationImpl
 102.886 +                       (sac.assocId(), sac.maxInStreams(), sac.maxOutStreams());
 102.887 +            }
 102.888 +            return HandlerResult.CONTINUE;
 102.889 +        }
 102.890 +    }
 102.891 +
 102.892 +    private <T> HandlerResult invokeNotificationHandler
 102.893 +                                 (ResultContainer resultContainer,
 102.894 +                                  NotificationHandler<T> handler,
 102.895 +                                  T attachment) {
 102.896 +        SctpNotification notification = resultContainer.notification();
 102.897 +        synchronized (stateLock) {
 102.898 +            notification.setAssociation(association);
 102.899 +        }
 102.900 +
 102.901 +        if (!(handler instanceof AbstractNotificationHandler)) {
 102.902 +            return handler.handleNotification(notification, attachment);
 102.903 +        }
 102.904 +
 102.905 +        /* AbstractNotificationHandler */
 102.906 +        AbstractNotificationHandler<T> absHandler =
 102.907 +                (AbstractNotificationHandler<T>)handler;
 102.908 +        switch(resultContainer.type()) {
 102.909 +            case ASSOCIATION_CHANGED :
 102.910 +                return absHandler.handleNotification(
 102.911 +                        resultContainer.getAssociationChanged(), attachment);
 102.912 +            case PEER_ADDRESS_CHANGED :
 102.913 +                return absHandler.handleNotification(
 102.914 +                        resultContainer.getPeerAddressChanged(), attachment);
 102.915 +            case SEND_FAILED :
 102.916 +                return absHandler.handleNotification(
 102.917 +                        resultContainer.getSendFailed(), attachment);
 102.918 +            case SHUTDOWN :
 102.919 +                return absHandler.handleNotification(
 102.920 +                        resultContainer.getShutdown(), attachment);
 102.921 +            default :
 102.922 +                /* implementation specific handlers */
 102.923 +                return absHandler.handleNotification(
 102.924 +                        resultContainer.notification(), attachment);
 102.925 +        }
 102.926 +    }
 102.927 +
 102.928 +    private void checkAssociation(Association sendAssociation) {
 102.929 +        synchronized (stateLock) {
 102.930 +            if (sendAssociation != null && !sendAssociation.equals(association)) {
 102.931 +                throw new IllegalArgumentException(
 102.932 +                        "Cannot send to another association");
 102.933 +            }
 102.934 +        }
 102.935 +    }
 102.936 +
 102.937 +    private void checkStreamNumber(int streamNumber) {
 102.938 +        synchronized (stateLock) {
 102.939 +            if (association != null) {
 102.940 +                if (streamNumber < 0 ||
 102.941 +                      streamNumber >= association.maxOutboundStreams())
 102.942 +                    throw new InvalidStreamException();
 102.943 +            }
 102.944 +        }
 102.945 +    }
 102.946 +
 102.947 +    /* TODO: Add support for ttl and isComplete to both 121 12M
 102.948 +     *       SCTP_EOR not yet supported on reference platforms
 102.949 +     *       TTL support limited...
 102.950 +     */
 102.951 +    @Override
 102.952 +    public int send(ByteBuffer buffer, MessageInfo messageInfo)
 102.953 +            throws IOException {
 102.954 +        if (buffer == null)
 102.955 +            throw new IllegalArgumentException("buffer cannot be null");
 102.956 +
 102.957 +        if (messageInfo == null)
 102.958 +            throw new IllegalArgumentException("messageInfo cannot be null");
 102.959 +
 102.960 +        checkAssociation(messageInfo.association());
 102.961 +        checkStreamNumber(messageInfo.streamNumber());
 102.962 +
 102.963 +        synchronized (sendLock) {
 102.964 +            ensureSendOpen();
 102.965 +
 102.966 +            int n = 0;
 102.967 +            try {
 102.968 +                begin();
 102.969 +
 102.970 +                synchronized (stateLock) {
 102.971 +                    if(!isOpen())
 102.972 +                        return 0;
 102.973 +                    senderThread = NativeThread.current();
 102.974 +                }
 102.975 +
 102.976 +                do {
 102.977 +                    n = send(fdVal, buffer, messageInfo);
 102.978 +                } while ((n == IOStatus.INTERRUPTED) && isOpen());
 102.979 +
 102.980 +                return IOStatus.normalize(n);
 102.981 +            } finally {
 102.982 +                senderCleanup();
 102.983 +                end((n > 0) || (n == IOStatus.UNAVAILABLE));
 102.984 +                assert IOStatus.check(n);
 102.985 +            }
 102.986 +        }
 102.987 +    }
 102.988 +
 102.989 +    private int send(int fd, ByteBuffer src, MessageInfo messageInfo)
 102.990 +            throws IOException {
 102.991 +        int streamNumber = messageInfo.streamNumber();
 102.992 +        SocketAddress target = messageInfo.address();
 102.993 +        boolean unordered = messageInfo.isUnordered();
 102.994 +        int ppid = messageInfo.payloadProtocolID();
 102.995 +
 102.996 +        if (src instanceof DirectBuffer)
 102.997 +            return sendFromNativeBuffer(fd, src, target, streamNumber,
 102.998 +                    unordered, ppid);
 102.999 +
102.1000 +        /* Substitute a native buffer */
102.1001 +        int pos = src.position();
102.1002 +        int lim = src.limit();
102.1003 +        assert (pos <= lim && streamNumber >= 0);
102.1004 +
102.1005 +        int rem = (pos <= lim ? lim - pos : 0);
102.1006 +        ByteBuffer bb = Util.getTemporaryDirectBuffer(rem);
102.1007 +        try {
102.1008 +            bb.put(src);
102.1009 +            bb.flip();
102.1010 +            /* Do not update src until we see how many bytes were written */
102.1011 +            src.position(pos);
102.1012 +
102.1013 +            int n = sendFromNativeBuffer(fd, bb, target, streamNumber,
102.1014 +                    unordered, ppid);
102.1015 +            if (n > 0) {
102.1016 +                /* now update src */
102.1017 +                src.position(pos + n);
102.1018 +            }
102.1019 +            return n;
102.1020 +        } finally {
102.1021 +            Util.releaseTemporaryDirectBuffer(bb);
102.1022 +        }
102.1023 +    }
102.1024 +
102.1025 +    private int sendFromNativeBuffer(int fd,
102.1026 +                                     ByteBuffer bb,
102.1027 +                                     SocketAddress target,
102.1028 +                                     int streamNumber,
102.1029 +                                     boolean unordered,
102.1030 +                                     int ppid)
102.1031 +            throws IOException {
102.1032 +        int pos = bb.position();
102.1033 +        int lim = bb.limit();
102.1034 +        assert (pos <= lim);
102.1035 +        int rem = (pos <= lim ? lim - pos : 0);
102.1036 +
102.1037 +        int written = send0(fd, ((DirectBuffer)bb).address() + pos,
102.1038 +                            rem, target, -1 /*121*/, streamNumber, unordered, ppid);
102.1039 +        if (written > 0)
102.1040 +            bb.position(pos + written);
102.1041 +        return written;
102.1042 +    }
102.1043 +
102.1044 +    @Override
102.1045 +    public SctpChannel shutdown() throws IOException {
102.1046 +        synchronized(stateLock) {
102.1047 +            if (isShutdown)
102.1048 +                return this;
102.1049 +
102.1050 +            ensureSendOpen();
102.1051 +            SctpNet.shutdown(fdVal, -1);
102.1052 +            if (senderThread != 0)
102.1053 +                NativeThread.signal(senderThread);
102.1054 +            isShutdown = true;
102.1055 +        }
102.1056 +        return this;
102.1057 +    }
102.1058 +
102.1059 +    @Override
102.1060 +    public Set<SocketAddress> getAllLocalAddresses()
102.1061 +            throws IOException {
102.1062 +        synchronized (stateLock) {
102.1063 +            if (!isOpen())
102.1064 +                throw new ClosedChannelException();
102.1065 +            if (!isBound())
102.1066 +                return Collections.emptySet();
102.1067 +
102.1068 +            return SctpNet.getLocalAddresses(fdVal);
102.1069 +        }
102.1070 +    }
102.1071 +
102.1072 +    @Override
102.1073 +    public Set<SocketAddress> getRemoteAddresses()
102.1074 +            throws IOException {
102.1075 +        synchronized (stateLock) {
102.1076 +            if (!isOpen())
102.1077 +                throw new ClosedChannelException();
102.1078 +            if (!isConnected() || isShutdown)
102.1079 +                return Collections.emptySet();
102.1080 +
102.1081 +            try {
102.1082 +                return SctpNet.getRemoteAddresses(fdVal, 0/*unused*/);
102.1083 +            } catch (SocketException unused) {
102.1084 +                /* an open connected channel should always have remote addresses */
102.1085 +                return remoteAddresses;
102.1086 +            }
102.1087 +        }
102.1088 +    }
102.1089 +
102.1090 +    /* Native */
102.1091 +    private static native void initIDs();
102.1092 +
102.1093 +    static native int receive0(int fd, ResultContainer resultContainer,
102.1094 +            long address, int length, boolean peek) throws IOException;
102.1095 +
102.1096 +    static native int send0(int fd, long address, int length,
102.1097 +            SocketAddress target, int assocId, int streamNumber,
102.1098 +            boolean unordered, int ppid) throws IOException;
102.1099 +
102.1100 +    private static native int checkConnect(FileDescriptor fd, boolean block,
102.1101 +            boolean ready) throws IOException;
102.1102 +
102.1103 +    static {
102.1104 +        Util.load();   /* loads nio & net native libraries */
102.1105 +        java.security.AccessController.doPrivileged(
102.1106 +                new sun.security.action.LoadLibraryAction("sctp"));
102.1107 +        initIDs();
102.1108 +    }
102.1109 +}
   103.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   103.2 +++ b/src/solaris/classes/sun/nio/ch/sctp/SctpMultiChannelImpl.java	Sat Feb 18 16:11:47 2012 -0800
   103.3 @@ -0,0 +1,994 @@
   103.4 +/*
   103.5 + * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
   103.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   103.7 + *
   103.8 + * This code is free software; you can redistribute it and/or modify it
   103.9 + * under the terms of the GNU General Public License version 2 only, as
  103.10 + * published by the Free Software Foundation.  Oracle designates this
  103.11 + * particular file as subject to the "Classpath" exception as provided
  103.12 + * by Oracle in the LICENSE file that accompanied this code.
  103.13 + *
  103.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
  103.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  103.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  103.17 + * version 2 for more details (a copy is included in the LICENSE file that
  103.18 + * accompanied this code).
  103.19 + *
  103.20 + * You should have received a copy of the GNU General Public License version
  103.21 + * 2 along with this work; if not, write to the Free Software Foundation,
  103.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  103.23 + *
  103.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  103.25 + * or visit www.oracle.com if you need additional information or have any
  103.26 + * questions.
  103.27 + */
  103.28 +package sun.nio.ch.sctp;
  103.29 +
  103.30 +import java.net.InetAddress;
  103.31 +import java.net.SocketAddress;
  103.32 +import java.net.SocketException;
  103.33 +import java.net.InetSocketAddress;
  103.34 +import java.io.FileDescriptor;
  103.35 +import java.io.IOException;
  103.36 +import java.util.Collections;
  103.37 +import java.util.Map.Entry;
  103.38 +import java.util.Iterator;
  103.39 +import java.util.Set;
  103.40 +import java.util.HashSet;
  103.41 +import java.util.HashMap;
  103.42 +import java.nio.ByteBuffer;
  103.43 +import java.nio.channels.SelectionKey;
  103.44 +import java.nio.channels.ClosedChannelException;
  103.45 +import java.nio.channels.NotYetBoundException;
  103.46 +import java.nio.channels.spi.SelectorProvider;
  103.47 +import com.sun.nio.sctp.AbstractNotificationHandler;
  103.48 +import com.sun.nio.sctp.Association;
  103.49 +import com.sun.nio.sctp.AssociationChangeNotification;
  103.50 +import com.sun.nio.sctp.HandlerResult;
  103.51 +import com.sun.nio.sctp.IllegalReceiveException;
  103.52 +import com.sun.nio.sctp.InvalidStreamException;
  103.53 +import com.sun.nio.sctp.IllegalUnbindException;
  103.54 +import com.sun.nio.sctp.NotificationHandler;
  103.55 +import com.sun.nio.sctp.MessageInfo;
  103.56 +import com.sun.nio.sctp.SctpChannel;
  103.57 +import com.sun.nio.sctp.SctpMultiChannel;
  103.58 +import com.sun.nio.sctp.SctpSocketOption;
  103.59 +import sun.nio.ch.DirectBuffer;
  103.60 +import sun.nio.ch.NativeThread;
  103.61 +import sun.nio.ch.IOStatus;
  103.62 +import sun.nio.ch.IOUtil;
  103.63 +import sun.nio.ch.Net;
  103.64 +import sun.nio.ch.PollArrayWrapper;
  103.65 +import sun.nio.ch.SelChImpl;
  103.66 +import sun.nio.ch.SelectionKeyImpl;
  103.67 +import sun.nio.ch.Util;
  103.68 +import static com.sun.nio.sctp.SctpStandardSocketOptions.*;
  103.69 +import static sun.nio.ch.sctp.ResultContainer.*;
  103.70 +
  103.71 +/**
  103.72 + * An implementation of SctpMultiChannel
  103.73 + */
  103.74 +public class SctpMultiChannelImpl extends SctpMultiChannel
  103.75 +    implements SelChImpl
  103.76 +{
  103.77 +    private final FileDescriptor fd;
  103.78 +
  103.79 +    private final int fdVal;
  103.80 +
  103.81 +    /* IDs of native threads doing send and receives, for signalling */
  103.82 +    private volatile long receiverThread = 0;
  103.83 +    private volatile long senderThread = 0;
  103.84 +
  103.85 +    /* Lock held by current receiving thread */
  103.86 +    private final Object receiveLock = new Object();
  103.87 +
  103.88 +    /* Lock held by current sending thread */
  103.89 +    private final Object sendLock = new Object();
  103.90 +
  103.91 +    /* Lock held by any thread that modifies the state fields declared below
  103.92 +     * DO NOT invoke a blocking I/O operation while holding this lock! */
  103.93 +    private final Object stateLock = new Object();
  103.94 +
  103.95 +    private enum ChannelState {
  103.96 +        UNINITIALIZED,
  103.97 +        KILLPENDING,
  103.98 +        KILLED,
  103.99 +    }
 103.100 +
 103.101 +    /* -- The following fields are protected by stateLock -- */
 103.102 +    private ChannelState state = ChannelState.UNINITIALIZED;
 103.103 +
 103.104 +    /* Binding: Once bound the port will remain constant. */
 103.105 +    int port = -1;
 103.106 +    private HashSet<InetSocketAddress> localAddresses = new HashSet<InetSocketAddress>();
 103.107 +    /* Has the channel been bound to the wildcard address */
 103.108 +    private boolean wildcard; /* false */
 103.109 +
 103.110 +    /* Keeps a map of addresses to association, and visa versa */
 103.111 +    private HashMap<SocketAddress, Association> addressMap =
 103.112 +                         new HashMap<SocketAddress, Association>();
 103.113 +    private HashMap<Association, Set<SocketAddress>> associationMap =
 103.114 +                         new HashMap<Association, Set<SocketAddress>>();
 103.115 +
 103.116 +    /* -- End of fields protected by stateLock -- */
 103.117 +
 103.118 +    /* If an association has been shutdown mark it for removal after
 103.119 +     * the user handler has been invoked */
 103.120 +    private final ThreadLocal<Association> associationToRemove =
 103.121 +        new ThreadLocal<Association>() {
 103.122 +             @Override protected Association initialValue() {
 103.123 +                 return null;
 103.124 +            }
 103.125 +    };
 103.126 +
 103.127 +    /* A notification handler cannot invoke receive */
 103.128 +    private final ThreadLocal<Boolean> receiveInvoked =
 103.129 +        new ThreadLocal<Boolean>() {
 103.130 +             @Override protected Boolean initialValue() {
 103.131 +                 return Boolean.FALSE;
 103.132 +            }
 103.133 +    };
 103.134 +
 103.135 +    public SctpMultiChannelImpl(SelectorProvider provider)
 103.136 +            throws IOException {
 103.137 +        //TODO: update provider, remove public modifier
 103.138 +        super(provider);
 103.139 +        this.fd = SctpNet.socket(false /*one-to-many*/);
 103.140 +        this.fdVal = IOUtil.fdVal(fd);
 103.141 +    }
 103.142 +
 103.143 +    @Override
 103.144 +    public SctpMultiChannel bind(SocketAddress local, int backlog)
 103.145 +            throws IOException {
 103.146 +        synchronized (receiveLock) {
 103.147 +            synchronized (sendLock) {
 103.148 +                synchronized (stateLock) {
 103.149 +                    ensureOpen();
 103.150 +                    if (isBound())
 103.151 +                        SctpNet.throwAlreadyBoundException();
 103.152 +                    InetSocketAddress isa = (local == null) ?
 103.153 +                        new InetSocketAddress(0) : Net.checkAddress(local);
 103.154 +
 103.155 +                    SecurityManager sm = System.getSecurityManager();
 103.156 +                    if (sm != null)
 103.157 +                        sm.checkListen(isa.getPort());
 103.158 +                    Net.bind(fd, isa.getAddress(), isa.getPort());
 103.159 +
 103.160 +                    InetSocketAddress boundIsa = Net.localAddress(fd);
 103.161 +                    port = boundIsa.getPort();
 103.162 +                    localAddresses.add(isa);
 103.163 +                    if (isa.getAddress().isAnyLocalAddress())
 103.164 +                        wildcard = true;
 103.165 +
 103.166 +                    SctpNet.listen(fdVal, backlog < 1 ? 50 : backlog);
 103.167 +                }
 103.168 +            }
 103.169 +        }
 103.170 +        return this;
 103.171 +    }
 103.172 +
 103.173 +    @Override
 103.174 +    public SctpMultiChannel bindAddress(InetAddress address)
 103.175 +            throws IOException {
 103.176 +        return bindUnbindAddress(address, true);
 103.177 +    }
 103.178 +
 103.179 +    @Override
 103.180 +    public SctpMultiChannel unbindAddress(InetAddress address)
 103.181 +            throws IOException {
 103.182 +        return bindUnbindAddress(address, false);
 103.183 +    }
 103.184 +
 103.185 +    private SctpMultiChannel bindUnbindAddress(InetAddress address,
 103.186 +                                               boolean add)
 103.187 +            throws IOException {
 103.188 +        if (address == null)
 103.189 +            throw new IllegalArgumentException();
 103.190 +
 103.191 +        synchronized (receiveLock) {
 103.192 +            synchronized (sendLock) {
 103.193 +                synchronized (stateLock) {
 103.194 +                    if (!isOpen())
 103.195 +                        throw new ClosedChannelException();
 103.196 +                    if (!isBound())
 103.197 +                        throw new NotYetBoundException();
 103.198 +                    if (wildcard)
 103.199 +                        throw new IllegalStateException(
 103.200 +                                "Cannot add or remove addresses from a channel that is bound to the wildcard address");
 103.201 +                    if (address.isAnyLocalAddress())
 103.202 +                        throw new IllegalArgumentException(
 103.203 +                                "Cannot add or remove the wildcard address");
 103.204 +                    if (add) {
 103.205 +                        for (InetSocketAddress addr : localAddresses) {
 103.206 +                            if (addr.getAddress().equals(address)) {
 103.207 +                                SctpNet.throwAlreadyBoundException();
 103.208 +                            }
 103.209 +                        }
 103.210 +                    } else { /*removing */
 103.211 +                        /* Verify that there is more than one address
 103.212 +                         * and that address is already bound */
 103.213 +                        if (localAddresses.size() <= 1)
 103.214 +                            throw new IllegalUnbindException("Cannot remove address from a channel with only one address bound");
 103.215 +                        boolean foundAddress = false;
 103.216 +                        for (InetSocketAddress addr : localAddresses) {
 103.217 +                            if (addr.getAddress().equals(address)) {
 103.218 +                                foundAddress = true;
 103.219 +                                break;
 103.220 +                            }
 103.221 +                        }
 103.222 +                        if (!foundAddress )
 103.223 +                            throw new IllegalUnbindException("Cannot remove address from a channel that is not bound to that address");
 103.224 +                    }
 103.225 +
 103.226 +                    SctpNet.bindx(fdVal, new InetAddress[]{address}, port, add);
 103.227 +
 103.228 +                    /* Update our internal Set to reflect the addition/removal */
 103.229 +                    if (add)
 103.230 +                        localAddresses.add(new InetSocketAddress(address, port));
 103.231 +                    else {
 103.232 +                        for (InetSocketAddress addr : localAddresses) {
 103.233 +                            if (addr.getAddress().equals(address)) {
 103.234 +                                localAddresses.remove(addr);
 103.235 +                                break;
 103.236 +                            }
 103.237 +                        }
 103.238 +                    }
 103.239 +                }
 103.240 +            }
 103.241 +        }
 103.242 +        return this;
 103.243 +    }
 103.244 +
 103.245 +    @Override
 103.246 +    public Set<Association> associations()
 103.247 +            throws ClosedChannelException, NotYetBoundException {
 103.248 +        synchronized (stateLock) {
 103.249 +            if (!isOpen())
 103.250 +                throw new ClosedChannelException();
 103.251 +            if (!isBound())
 103.252 +                throw new NotYetBoundException();
 103.253 +
 103.254 +            return Collections.unmodifiableSet(associationMap.keySet());
 103.255 +        }
 103.256 +    }
 103.257 +
 103.258 +    private boolean isBound() {
 103.259 +        synchronized (stateLock) {
 103.260 +            return port == -1 ? false : true;
 103.261 +        }
 103.262 +    }
 103.263 +
 103.264 +    private void ensureOpen() throws IOException {
 103.265 +        synchronized (stateLock) {
 103.266 +            if (!isOpen())
 103.267 +                throw new ClosedChannelException();
 103.268 +        }
 103.269 +    }
 103.270 +
 103.271 +    private void receiverCleanup() throws IOException {
 103.272 +        synchronized (stateLock) {
 103.273 +            receiverThread = 0;
 103.274 +            if (state == ChannelState.KILLPENDING)
 103.275 +                kill();
 103.276 +        }
 103.277 +    }
 103.278 +
 103.279 +    private void senderCleanup() throws IOException {
 103.280 +        synchronized (stateLock) {
 103.281 +            senderThread = 0;
 103.282 +            if (state == ChannelState.KILLPENDING)
 103.283 +                kill();
 103.284 +        }
 103.285 +    }
 103.286 +
 103.287 +    @Override
 103.288 +    protected void implConfigureBlocking(boolean block) throws IOException {
 103.289 +        IOUtil.configureBlocking(fd, block);
 103.290 +    }
 103.291 +
 103.292 +    @Override
 103.293 +    public void implCloseSelectableChannel() throws IOException {
 103.294 +        synchronized (stateLock) {
 103.295 +            SctpNet.preClose(fdVal);
 103.296 +
 103.297 +            if (receiverThread != 0)
 103.298 +                NativeThread.signal(receiverThread);
 103.299 +
 103.300 +            if (senderThread != 0)
 103.301 +                NativeThread.signal(senderThread);
 103.302 +
 103.303 +            if (!isRegistered())
 103.304 +                kill();
 103.305 +        }
 103.306 +    }
 103.307 +
 103.308 +    @Override
 103.309 +    public FileDescriptor getFD() {
 103.310 +        return fd;
 103.311 +    }
 103.312 +
 103.313 +    @Override
 103.314 +    public int getFDVal() {
 103.315 +        return fdVal;
 103.316 +    }
 103.317 +
 103.318 +    /**
 103.319 +     * Translates native poll revent ops into a ready operation ops
 103.320 +     */
 103.321 +    private boolean translateReadyOps(int ops, int initialOps,
 103.322 +                                      SelectionKeyImpl sk) {
 103.323 +        int intOps = sk.nioInterestOps();
 103.324 +        int oldOps = sk.nioReadyOps();
 103.325 +        int newOps = initialOps;
 103.326 +
 103.327 +        if ((ops & PollArrayWrapper.POLLNVAL) != 0) {
 103.328 +            /* This should only happen if this channel is pre-closed while a
 103.329 +             * selection operation is in progress
 103.330 +             * ## Throw an error if this channel has not been pre-closed */
 103.331 +            return false;
 103.332 +        }
 103.333 +
 103.334 +        if ((ops & (PollArrayWrapper.POLLERR
 103.335 +                    | PollArrayWrapper.POLLHUP)) != 0) {
 103.336 +            newOps = intOps;
 103.337 +            sk.nioReadyOps(newOps);
 103.338 +            return (newOps & ~oldOps) != 0;
 103.339 +        }
 103.340 +
 103.341 +        if (((ops & PollArrayWrapper.POLLIN) != 0) &&
 103.342 +            ((intOps & SelectionKey.OP_READ) != 0))
 103.343 +            newOps |= SelectionKey.OP_READ;
 103.344 +
 103.345 +        if (((ops & PollArrayWrapper.POLLOUT) != 0) &&
 103.346 +            ((intOps & SelectionKey.OP_WRITE) != 0))
 103.347 +            newOps |= SelectionKey.OP_WRITE;
 103.348 +
 103.349 +        sk.nioReadyOps(newOps);
 103.350 +        return (newOps & ~oldOps) != 0;
 103.351 +    }
 103.352 +
 103.353 +    @Override
 103.354 +    public boolean translateAndUpdateReadyOps(int ops, SelectionKeyImpl sk) {
 103.355 +        return translateReadyOps(ops, sk.nioReadyOps(), sk);
 103.356 +    }
 103.357 +
 103.358 +    @Override
 103.359 +    public boolean translateAndSetReadyOps(int ops, SelectionKeyImpl sk) {
 103.360 +        return translateReadyOps(ops, 0, sk);
 103.361 +    }
 103.362 +
 103.363 +    @Override
 103.364 +    public void translateAndSetInterestOps(int ops, SelectionKeyImpl sk) {
 103.365 +        int newOps = 0;
 103.366 +        if ((ops & SelectionKey.OP_READ) != 0)
 103.367 +            newOps |= PollArrayWrapper.POLLIN;
 103.368 +        if ((ops & SelectionKey.OP_WRITE) != 0)
 103.369 +            newOps |= PollArrayWrapper.POLLOUT;
 103.370 +        sk.selector.putEventOps(sk, newOps);
 103.371 +    }
 103.372 +
 103.373 +    @Override
 103.374 +    public void kill() throws IOException {
 103.375 +        synchronized (stateLock) {
 103.376 +            if (state == ChannelState.KILLED)
 103.377 +                return;
 103.378 +            if (state == ChannelState.UNINITIALIZED) {
 103.379 +                state = ChannelState.KILLED;
 103.380 +                return;
 103.381 +            }
 103.382 +            assert !isOpen() && !isRegistered();
 103.383 +
 103.384 +            /* Postpone the kill if there is a thread sending or receiving. */
 103.385 +            if (receiverThread == 0 && senderThread == 0) {
 103.386 +                SctpNet.close(fdVal);
 103.387 +                state = ChannelState.KILLED;
 103.388 +            } else {
 103.389 +                state = ChannelState.KILLPENDING;
 103.390 +            }
 103.391 +        }
 103.392 +    }
 103.393 +
 103.394 +    @Override
 103.395 +    public <T> SctpMultiChannel setOption(SctpSocketOption<T> name,
 103.396 +                                          T value,
 103.397 +                                          Association association)
 103.398 +            throws IOException {
 103.399 +        if (name == null)
 103.400 +            throw new NullPointerException();
 103.401 +        if (!(supportedOptions().contains(name)))
 103.402 +            throw new UnsupportedOperationException("'" + name + "' not supported");
 103.403 +
 103.404 +        synchronized (stateLock) {
 103.405 +            if (association != null && (name.equals(SCTP_PRIMARY_ADDR) ||
 103.406 +                    name.equals(SCTP_SET_PEER_PRIMARY_ADDR))) {
 103.407 +                checkAssociation(association);
 103.408 +            }
 103.409 +            if (!isOpen())
 103.410 +                throw new ClosedChannelException();
 103.411 +
 103.412 +            int assocId = association == null ? 0 : association.associationID();
 103.413 +            SctpNet.setSocketOption(fdVal, name, value, assocId);
 103.414 +        }
 103.415 +        return this;
 103.416 +    }
 103.417 +
 103.418 +    @Override
 103.419 +    @SuppressWarnings("unchecked")
 103.420 +    public <T> T getOption(SctpSocketOption<T> name, Association association)
 103.421 +            throws IOException {
 103.422 +        if (name == null)
 103.423 +            throw new NullPointerException();
 103.424 +        if (!supportedOptions().contains(name))
 103.425 +            throw new UnsupportedOperationException("'" + name + "' not supported");
 103.426 +
 103.427 +        synchronized (stateLock) {
 103.428 +            if (association != null && (name.equals(SCTP_PRIMARY_ADDR) ||
 103.429 +                    name.equals(SCTP_SET_PEER_PRIMARY_ADDR))) {
 103.430 +                checkAssociation(association);
 103.431 +            }
 103.432 +            if (!isOpen())
 103.433 +                throw new ClosedChannelException();
 103.434 +
 103.435 +            int assocId = association == null ? 0 : association.associationID();
 103.436 +            return (T)SctpNet.getSocketOption(fdVal, name, assocId);
 103.437 +        }
 103.438 +    }
 103.439 +
 103.440 +    private static class DefaultOptionsHolder {
 103.441 +        static final Set<SctpSocketOption<?>> defaultOptions = defaultOptions();
 103.442 +
 103.443 +        private static Set<SctpSocketOption<?>> defaultOptions() {
 103.444 +            HashSet<SctpSocketOption<?>> set = new HashSet<SctpSocketOption<?>>(10);
 103.445 +            set.add(SCTP_DISABLE_FRAGMENTS);
 103.446 +            set.add(SCTP_EXPLICIT_COMPLETE);
 103.447 +            set.add(SCTP_FRAGMENT_INTERLEAVE);
 103.448 +            set.add(SCTP_INIT_MAXSTREAMS);
 103.449 +            set.add(SCTP_NODELAY);
 103.450 +            set.add(SCTP_PRIMARY_ADDR);
 103.451 +            set.add(SCTP_SET_PEER_PRIMARY_ADDR);
 103.452 +            set.add(SO_SNDBUF);
 103.453 +            set.add(SO_RCVBUF);
 103.454 +            set.add(SO_LINGER);
 103.455 +            return Collections.unmodifiableSet(set);
 103.456 +        }
 103.457 +    }
 103.458 +
 103.459 +    @Override
 103.460 +    public final Set<SctpSocketOption<?>> supportedOptions() {
 103.461 +        return DefaultOptionsHolder.defaultOptions;
 103.462 +    }
 103.463 +
 103.464 +    @Override
 103.465 +    public <T> MessageInfo receive(ByteBuffer buffer,
 103.466 +                                   T attachment,
 103.467 +                                   NotificationHandler<T> handler)
 103.468 +            throws IOException {
 103.469 +        if (buffer == null)
 103.470 +            throw new IllegalArgumentException("buffer cannot be null");
 103.471 +
 103.472 +        if (buffer.isReadOnly())
 103.473 +            throw new IllegalArgumentException("Read-only buffer");
 103.474 +
 103.475 +        if (receiveInvoked.get())
 103.476 +            throw new IllegalReceiveException(
 103.477 +                    "cannot invoke receive from handler");
 103.478 +        receiveInvoked.set(Boolean.TRUE);
 103.479 +
 103.480 +        try {
 103.481 +            ResultContainer resultContainer = new ResultContainer();
 103.482 +            do {
 103.483 +                resultContainer.clear();
 103.484 +                synchronized (receiveLock) {
 103.485 +                    ensureOpen();
 103.486 +                    if (!isBound())
 103.487 +                        throw new NotYetBoundException();
 103.488 +
 103.489 +                    int n = 0;
 103.490 +                    try {
 103.491 +                        begin();
 103.492 +
 103.493 +                        synchronized (stateLock) {
 103.494 +                            if(!isOpen())
 103.495 +                                return null;
 103.496 +                            receiverThread = NativeThread.current();
 103.497 +                        }
 103.498 +
 103.499 +                        do {
 103.500 +                            n = receive(fdVal, buffer, resultContainer);
 103.501 +                        } while ((n == IOStatus.INTERRUPTED) && isOpen());
 103.502 +
 103.503 +                    } finally {
 103.504 +                        receiverCleanup();
 103.505 +                        end((n > 0) || (n == IOStatus.UNAVAILABLE));
 103.506 +                        assert IOStatus.check(n);
 103.507 +                    }
 103.508 +
 103.509 +                    if (!resultContainer.isNotification()) {
 103.510 +                        /* message or nothing */
 103.511 +                        if (resultContainer.hasSomething()) {
 103.512 +                            /* Set the association before returning */
 103.513 +                            MessageInfoImpl info =
 103.514 +                                    resultContainer.getMessageInfo();
 103.515 +                            info.setAssociation(lookupAssociation(info.
 103.516 +                                    associationID()));
 103.517 +                            SecurityManager sm = System.getSecurityManager();
 103.518 +                            if (sm != null) {
 103.519 +                                InetSocketAddress isa  = (InetSocketAddress)info.address();
 103.520 +                                if (!addressMap.containsKey(isa)) {
 103.521 +                                    /* must be a new association */
 103.522 +                                    try {
 103.523 +                                        sm.checkAccept(isa.getAddress().getHostAddress(),
 103.524 +                                                       isa.getPort());
 103.525 +                                    } catch (SecurityException se) {
 103.526 +                                        buffer.clear();
 103.527 +                                        throw se;
 103.528 +                                    }
 103.529 +                                }
 103.530 +                            }
 103.531 +
 103.532 +                            assert info.association() != null;
 103.533 +                            return info;
 103.534 +                        } else  {
 103.535 +                          /* Non-blocking may return null if nothing available*/
 103.536 +                            return null;
 103.537 +                        }
 103.538 +                    } else { /* notification */
 103.539 +                        synchronized (stateLock) {
 103.540 +                            handleNotificationInternal(
 103.541 +                                    resultContainer);
 103.542 +                        }
 103.543 +                    }
 103.544 +                } /* receiveLock */
 103.545 +            } while (handler == null ? true :
 103.546 +                (invokeNotificationHandler(resultContainer, handler, attachment)
 103.547 +                 == HandlerResult.CONTINUE));
 103.548 +        } finally {
 103.549 +            receiveInvoked.set(Boolean.FALSE);
 103.550 +        }
 103.551 +
 103.552 +        return null;
 103.553 +    }
 103.554 +
 103.555 +    private int receive(int fd,
 103.556 +                        ByteBuffer dst,
 103.557 +                        ResultContainer resultContainer)
 103.558 +            throws IOException {
 103.559 +        int pos = dst.position();
 103.560 +        int lim = dst.limit();
 103.561 +        assert (pos <= lim);
 103.562 +        int rem = (pos <= lim ? lim - pos : 0);
 103.563 +        if (dst instanceof DirectBuffer && rem > 0)
 103.564 +            return receiveIntoNativeBuffer(fd, resultContainer, dst, rem, pos);
 103.565 +
 103.566 +        /* Substitute a native buffer. */
 103.567 +        int newSize = Math.max(rem, 1);
 103.568 +        ByteBuffer bb = Util.getTemporaryDirectBuffer(newSize);
 103.569 +        try {
 103.570 +            int n = receiveIntoNativeBuffer(fd, resultContainer, bb, newSize, 0);
 103.571 +            bb.flip();
 103.572 +            if (n > 0 && rem > 0)
 103.573 +                dst.put(bb);
 103.574 +            return n;
 103.575 +        } finally {
 103.576 +            Util.releaseTemporaryDirectBuffer(bb);
 103.577 +        }
 103.578 +    }
 103.579 +
 103.580 +    private int receiveIntoNativeBuffer(int fd,
 103.581 +                                        ResultContainer resultContainer,
 103.582 +                                        ByteBuffer bb,
 103.583 +                                        int rem,
 103.584 +                                        int pos)
 103.585 +            throws IOException {
 103.586 +        int n = receive0(fd, resultContainer, ((DirectBuffer)bb).address() + pos, rem);
 103.587 +        if (n > 0)
 103.588 +            bb.position(pos + n);
 103.589 +        return n;
 103.590 +    }
 103.591 +
 103.592 +    private InternalNotificationHandler internalNotificationHandler =
 103.593 +            new InternalNotificationHandler();
 103.594 +
 103.595 +    private void handleNotificationInternal(ResultContainer resultContainer)
 103.596 +    {
 103.597 +        invokeNotificationHandler(resultContainer,
 103.598 +                internalNotificationHandler, null);
 103.599 +    }
 103.600 +
 103.601 +    private class InternalNotificationHandler
 103.602 +            extends AbstractNotificationHandler<Object>
 103.603 +    {
 103.604 +        @Override
 103.605 +        public HandlerResult handleNotification(
 103.606 +                AssociationChangeNotification not, Object unused) {
 103.607 +            AssociationChange sac = (AssociationChange) not;
 103.608 +
 103.609 +            /* Update map to reflect change in association */
 103.610 +            switch (not.event()) {
 103.611 +                case COMM_UP :
 103.612 +                    Association newAssociation = new AssociationImpl
 103.613 +                       (sac.assocId(), sac.maxInStreams(), sac.maxOutStreams());
 103.614 +                    addAssociation(newAssociation);
 103.615 +                    break;
 103.616 +                case SHUTDOWN :
 103.617 +                case COMM_LOST :
 103.618 +                //case RESTART: ???
 103.619 +                    /* mark association for removal after user handler invoked*/
 103.620 +                    associationToRemove.set(lookupAssociation(sac.assocId()));
 103.621 +            }
 103.622 +            return HandlerResult.CONTINUE;
 103.623 +        }
 103.624 +    }
 103.625 +
 103.626 +    private <T> HandlerResult invokeNotificationHandler(
 103.627 +                                   ResultContainer resultContainer,
 103.628 +                                   NotificationHandler<T> handler,
 103.629 +                                   T attachment) {
 103.630 +        HandlerResult result;
 103.631 +        SctpNotification notification = resultContainer.notification();
 103.632 +        notification.setAssociation(lookupAssociation(notification.assocId()));
 103.633 +
 103.634 +        if (!(handler instanceof AbstractNotificationHandler)) {
 103.635 +            result = handler.handleNotification(notification, attachment);
 103.636 +        } else { /* AbstractNotificationHandler */
 103.637 +            AbstractNotificationHandler<T> absHandler =
 103.638 +                    (AbstractNotificationHandler<T>)handler;
 103.639 +            switch(resultContainer.type()) {
 103.640 +                case ASSOCIATION_CHANGED :
 103.641 +                    result = absHandler.handleNotification(
 103.642 +                            resultContainer.getAssociationChanged(), attachment);
 103.643 +                    break;
 103.644 +                case PEER_ADDRESS_CHANGED :
 103.645 +                    result = absHandler.handleNotification(
 103.646 +                            resultContainer.getPeerAddressChanged(), attachment);
 103.647 +                    break;
 103.648 +                case SEND_FAILED :
 103.649 +                    result = absHandler.handleNotification(
 103.650 +                            resultContainer.getSendFailed(), attachment);
 103.651 +                    break;
 103.652 +                case SHUTDOWN :
 103.653 +                    result =  absHandler.handleNotification(
 103.654 +                            resultContainer.getShutdown(), attachment);
 103.655 +                    break;
 103.656 +                default :
 103.657 +                    /* implementation specific handlers */
 103.658 +                    result =  absHandler.handleNotification(
 103.659 +                            resultContainer.notification(), attachment);
 103.660 +            }
 103.661 +        }
 103.662 +
 103.663 +        if (!(handler instanceof InternalNotificationHandler)) {
 103.664 +            /* Only remove associations after user handler
 103.665 +             * has finished with them */
 103.666 +            Association assoc = associationToRemove.get();
 103.667 +            if (assoc != null) {
 103.668 +                removeAssociation(assoc);
 103.669 +                associationToRemove.set(null);
 103.670 +            }
 103.671 +
 103.672 +        }
 103.673 +
 103.674 +        return result;
 103.675 +    }
 103.676 +
 103.677 +    private Association lookupAssociation(int assocId) {
 103.678 +        /* Lookup the association in our internal map */
 103.679 +        synchronized (stateLock) {
 103.680 +            Set<Association> assocs = associationMap.keySet();
 103.681 +            for (Association a : assocs) {
 103.682 +                if (a.associationID() == assocId) {
 103.683 +                    return a;
 103.684 +                }
 103.685 +            }
 103.686 +        }
 103.687 +        return null;
 103.688 +    }
 103.689 +
 103.690 +    private void addAssociation(Association association) {
 103.691 +        synchronized (stateLock) {
 103.692 +            int assocId = association.associationID();
 103.693 +            Set<SocketAddress> addresses = null;
 103.694 +
 103.695 +            try {
 103.696 +                addresses = SctpNet.getRemoteAddresses(fdVal, assocId);
 103.697 +            } catch (IOException unused) {
 103.698 +                /* OK, determining connected addresses may not be possible
 103.699 +                 * shutdown, connection lost, etc */
 103.700 +            }
 103.701 +
 103.702 +            associationMap.put(association, addresses);
 103.703 +            if (addresses != null) {
 103.704 +                for (SocketAddress addr : addresses)
 103.705 +                    addressMap.put(addr, association);
 103.706 +            }
 103.707 +        }
 103.708 +    }
 103.709 +
 103.710 +    private void removeAssociation(Association association) {
 103.711 +        synchronized (stateLock) {
 103.712 +            int assocId = association.associationID();
 103.713 +            Set<SocketAddress> addresses = null;
 103.714 +
 103.715 +             try {
 103.716 +                addresses = SctpNet.getRemoteAddresses(fdVal, assocId);
 103.717 +            } catch (IOException unused) {
 103.718 +                /* OK, determining connected addresses may not be possible
 103.719 +                 * shutdown, connection lost, etc */
 103.720 +            }
 103.721 +
 103.722 +            Set<Association> assocs = associationMap.keySet();
 103.723 +            for (Association a : assocs) {
 103.724 +                if (a.associationID() == assocId) {
 103.725 +                    associationMap.remove(a);
 103.726 +                    break;
 103.727 +                }
 103.728 +            }
 103.729 +            if (addresses != null) {
 103.730 +                for (SocketAddress addr : addresses)
 103.731 +                    addressMap.remove(addr);
 103.732 +            } else {
 103.733 +                /* We cannot determine the connected addresses */
 103.734 +                Set<java.util.Map.Entry<SocketAddress, Association>> addrAssocs =
 103.735 +                        addressMap.entrySet();
 103.736 +                Iterator<Entry<SocketAddress, Association>> iterator = addrAssocs.iterator();
 103.737 +                while (iterator.hasNext()) {
 103.738 +                    Entry<SocketAddress, Association> entry = iterator.next();
 103.739 +                    if (entry.getValue().equals(association)) {
 103.740 +                        iterator.remove();
 103.741 +                    }
 103.742 +                }
 103.743 +            }
 103.744 +        }
 103.745 +    }
 103.746 +
 103.747 +    /**
 103.748 +     * @throws  IllegalArgumentException
 103.749 +     *          If the given association is not controlled by this channel
 103.750 +     *
 103.751 +     * @return  {@code true} if, and only if, the given association is one
 103.752 +     *          of the current associations controlled by this channel
 103.753 +     */
 103.754 +    private boolean checkAssociation(Association messageAssoc) {
 103.755 +        synchronized (stateLock) {
 103.756 +            for (Association association : associationMap.keySet()) {
 103.757 +                if (messageAssoc.equals(association)) {
 103.758 +                    return true;
 103.759 +                }
 103.760 +            }
 103.761 +        }
 103.762 +        throw new IllegalArgumentException(
 103.763 +              "Given Association is not controlled by this channel");
 103.764 +    }
 103.765 +
 103.766 +    private void checkStreamNumber(Association assoc, int streamNumber) {
 103.767 +        synchronized (stateLock) {
 103.768 +            if (streamNumber < 0 || streamNumber >= assoc.maxOutboundStreams())
 103.769 +                throw new InvalidStreamException();
 103.770 +        }
 103.771 +    }
 103.772 +
 103.773 +    /* TODO: Add support for ttl and isComplete to both 121 12M
 103.774 +     *       SCTP_EOR not yet supported on reference platforms
 103.775 +     *       TTL support limited...
 103.776 +     */
 103.777 +    @Override
 103.778 +    public int send(ByteBuffer buffer, MessageInfo messageInfo)
 103.779 +            throws IOException {
 103.780 +        if (buffer == null)
 103.781 +            throw new IllegalArgumentException("buffer cannot be null");
 103.782 +
 103.783 +        if (messageInfo == null)
 103.784 +            throw new IllegalArgumentException("messageInfo cannot be null");
 103.785 +
 103.786 +        synchronized (sendLock) {
 103.787 +            ensureOpen();
 103.788 +
 103.789 +            if (!isBound())
 103.790 +                bind(null, 0);
 103.791 +
 103.792 +            int n = 0;
 103.793 +            try {
 103.794 +                int assocId = -1;
 103.795 +                SocketAddress address = null;
 103.796 +                begin();
 103.797 +
 103.798 +                synchronized (stateLock) {
 103.799 +                    if(!isOpen())
 103.800 +                        return 0;
 103.801 +                    senderThread = NativeThread.current();
 103.802 +
 103.803 +                    /* Determine what address or association to send to */
 103.804 +                    Association assoc = messageInfo.association();
 103.805 +                    InetSocketAddress addr = (InetSocketAddress)messageInfo.address();
 103.806 +                    if (assoc != null) {
 103.807 +                        checkAssociation(assoc);
 103.808 +                        checkStreamNumber(assoc, messageInfo.streamNumber());
 103.809 +                        assocId = assoc.associationID();
 103.810 +                        /* have we also got a preferred address */
 103.811 +                        if (addr != null) {
 103.812 +                            if (!assoc.equals(addressMap.get(addr)))
 103.813 +                                throw new IllegalArgumentException("given preferred address is not part of this association");
 103.814 +                            address = addr;
 103.815 +                        }
 103.816 +                    } else if (addr != null) {
 103.817 +                        address = addr;
 103.818 +                        Association association = addressMap.get(addr);
 103.819 +                        if (association != null) {
 103.820 +                            checkStreamNumber(association, messageInfo.streamNumber());
 103.821 +                            assocId = association.associationID();
 103.822 +
 103.823 +                        } else { /* must be new association */
 103.824 +                            SecurityManager sm = System.getSecurityManager();
 103.825 +                            if (sm != null)
 103.826 +                                sm.checkConnect(addr.getAddress().getHostAddress(),
 103.827 +                                                addr.getPort());
 103.828 +                        }
 103.829 +                    } else {
 103.830 +                        throw new AssertionError(
 103.831 +                            "Both association and address cannot be null");
 103.832 +                    }
 103.833 +                }
 103.834 +
 103.835 +                do {
 103.836 +                    n = send(fdVal, buffer, assocId, address, messageInfo);
 103.837 +                } while ((n == IOStatus.INTERRUPTED) && isOpen());
 103.838 +
 103.839 +                return IOStatus.normalize(n);
 103.840 +            } finally {
 103.841 +                senderCleanup();
 103.842 +                end((n > 0) || (n == IOStatus.UNAVAILABLE));
 103.843 +                assert IOStatus.check(n);
 103.844 +            }
 103.845 +        }
 103.846 +    }
 103.847 +
 103.848 +    private int send(int fd,
 103.849 +                     ByteBuffer src,
 103.850 +                     int assocId,
 103.851 +                     SocketAddress target,
 103.852 +                     MessageInfo messageInfo)
 103.853 +            throws IOException {
 103.854 +        int streamNumber = messageInfo.streamNumber();
 103.855 +        boolean unordered = messageInfo.isUnordered();
 103.856 +        int ppid = messageInfo.payloadProtocolID();
 103.857 +
 103.858 +        if (src instanceof DirectBuffer)
 103.859 +            return sendFromNativeBuffer(fd, src, target, assocId,
 103.860 +                    streamNumber, unordered, ppid);
 103.861 +
 103.862 +        /* Substitute a native buffer */
 103.863 +        int pos = src.position();
 103.864 +        int lim = src.limit();
 103.865 +        assert (pos <= lim && streamNumber >= 0);
 103.866 +
 103.867 +        int rem = (pos <= lim ? lim - pos : 0);
 103.868 +        ByteBuffer bb = Util.getTemporaryDirectBuffer(rem);
 103.869 +        try {
 103.870 +            bb.put(src);
 103.871 +            bb.flip();
 103.872 +            /* Do not update src until we see how many bytes were written */
 103.873 +            src.position(pos);
 103.874 +
 103.875 +            int n = sendFromNativeBuffer(fd, bb, target, assocId,
 103.876 +                    streamNumber, unordered, ppid);
 103.877 +            if (n > 0) {
 103.878 +                /* now update src */
 103.879 +                src.position(pos + n);
 103.880 +            }
 103.881 +            return n;
 103.882 +        } finally {
 103.883 +            Util.releaseTemporaryDirectBuffer(bb);
 103.884 +        }
 103.885 +    }
 103.886 +
 103.887 +    private int sendFromNativeBuffer(int fd,
 103.888 +                                     ByteBuffer bb,
 103.889 +                                     SocketAddress target,
 103.890 +                                     int assocId,
 103.891 +                                     int streamNumber,
 103.892 +                                     boolean unordered,
 103.893 +                                     int ppid)
 103.894 +            throws IOException {
 103.895 +        int pos = bb.position();
 103.896 +        int lim = bb.limit();
 103.897 +        assert (pos <= lim);
 103.898 +        int rem = (pos <= lim ? lim - pos : 0);
 103.899 +
 103.900 +        int written = send0(fd, ((DirectBuffer)bb).address() + pos,
 103.901 +                            rem, target, assocId, streamNumber, unordered, ppid);
 103.902 +        if (written > 0)
 103.903 +            bb.position(pos + written);
 103.904 +        return written;
 103.905 +    }
 103.906 +
 103.907 +    @Override
 103.908 +    public SctpMultiChannel shutdown(Association association)
 103.909 +            throws IOException {
 103.910 +        synchronized (stateLock) {
 103.911 +            checkAssociation(association);
 103.912 +            if (!isOpen())
 103.913 +                throw new ClosedChannelException();
 103.914 +
 103.915 +            SctpNet.shutdown(fdVal, association.associationID());
 103.916 +        }
 103.917 +        return this;
 103.918 +    }
 103.919 +
 103.920 +    @Override
 103.921 +    public Set<SocketAddress> getAllLocalAddresses()
 103.922 +            throws IOException {
 103.923 +        synchronized (stateLock) {
 103.924 +            if (!isOpen())
 103.925 +                throw new ClosedChannelException();
 103.926 +            if (!isBound())
 103.927 +                return Collections.emptySet();
 103.928 +
 103.929 +            return SctpNet.getLocalAddresses(fdVal);
 103.930 +        }
 103.931 +    }
 103.932 +
 103.933 +    @Override
 103.934 +    public Set<SocketAddress> getRemoteAddresses(Association association)
 103.935 +            throws IOException {
 103.936 +        synchronized (stateLock) {
 103.937 +            checkAssociation(association);
 103.938 +            if (!isOpen())
 103.939 +                throw new ClosedChannelException();
 103.940 +
 103.941 +            try {
 103.942 +                return SctpNet.getRemoteAddresses(fdVal, association.associationID());
 103.943 +            } catch (SocketException se) {
 103.944 +                /* a valid association should always have remote addresses */
 103.945 +                Set<SocketAddress> addrs = associationMap.get(association);
 103.946 +                return addrs != null ? addrs : Collections.<SocketAddress>emptySet();
 103.947 +            }
 103.948 +        }
 103.949 +    }
 103.950 +
 103.951 +    @Override
 103.952 +    public SctpChannel branch(Association association)
 103.953 +            throws IOException {
 103.954 +        synchronized (stateLock) {
 103.955 +            checkAssociation(association);
 103.956 +            if (!isOpen())
 103.957 +                throw new ClosedChannelException();
 103.958 +
 103.959 +            FileDescriptor bFd = SctpNet.branch(fdVal,
 103.960 +                                                association.associationID());
 103.961 +            /* successfully branched, we can now remove it from assoc list */
 103.962 +            removeAssociation(association);
 103.963 +
 103.964 +            return new SctpChannelImpl(provider(), bFd, association);
 103.965 +        }
 103.966 +    }
 103.967 +
 103.968 +    /* Use common native implementation shared between
 103.969 +     * one-to-one and one-to-many */
 103.970 +    private static int receive0(int fd,
 103.971 +                                ResultContainer resultContainer,
 103.972 +                                long address,
 103.973 +                                int length)
 103.974 +            throws IOException{
 103.975 +        return SctpChannelImpl.receive0(fd, resultContainer, address,
 103.976 +                length, false /*peek */);
 103.977 +    }
 103.978 +
 103.979 +    private static int send0(int fd,
 103.980 +                             long address,
 103.981 +                             int length,
 103.982 +                             SocketAddress target,
 103.983 +                             int assocId,
 103.984 +                             int streamNumber,
 103.985 +                             boolean unordered,
 103.986 +                             int ppid)
 103.987 +            throws IOException {
 103.988 +        return SctpChannelImpl.send0(fd, address, length, target, assocId,
 103.989 +                streamNumber, unordered, ppid);
 103.990 +    }
 103.991 +
 103.992 +    static {
 103.993 +        Util.load();   /* loads nio & net native libraries */
 103.994 +        java.security.AccessController.doPrivileged(
 103.995 +                new sun.security.action.LoadLibraryAction("sctp"));
 103.996 +    }
 103.997 +}
   104.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   104.2 +++ b/src/solaris/classes/sun/nio/ch/sctp/SctpNet.java	Sat Feb 18 16:11:47 2012 -0800
   104.3 @@ -0,0 +1,315 @@
   104.4 +/*
   104.5 + * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
   104.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   104.7 + *
   104.8 + * This code is free software; you can redistribute it and/or modify it
   104.9 + * under the terms of the GNU General Public License version 2 only, as
  104.10 + * published by the Free Software Foundation.  Oracle designates this
  104.11 + * particular file as subject to the "Classpath" exception as provided
  104.12 + * by Oracle in the LICENSE file that accompanied this code.
  104.13 + *
  104.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
  104.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  104.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  104.17 + * version 2 for more details (a copy is included in the LICENSE file that
  104.18 + * accompanied this code).
  104.19 + *
  104.20 + * You should have received a copy of the GNU General Public License version
  104.21 + * 2 along with this work; if not, write to the Free Software Foundation,
  104.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  104.23 + *
  104.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  104.25 + * or visit www.oracle.com if you need additional information or have any
  104.26 + * questions.
  104.27 + */
  104.28 +package sun.nio.ch.sctp;
  104.29 +
  104.30 +import java.io.FileDescriptor;
  104.31 +import java.io.IOException;
  104.32 +import java.net.InetAddress;
  104.33 +import java.net.InetSocketAddress;
  104.34 +import java.net.SocketAddress;
  104.35 +import java.nio.channels.AlreadyBoundException;
  104.36 +import java.util.Set;
  104.37 +import java.util.HashSet;
  104.38 +import java.security.AccessController;
  104.39 +import sun.security.action.GetPropertyAction;
  104.40 +import sun.nio.ch.IOUtil;
  104.41 +import sun.nio.ch.Net;
  104.42 +import com.sun.nio.sctp.SctpSocketOption;
  104.43 +import static com.sun.nio.sctp.SctpStandardSocketOptions.*;
  104.44 +
  104.45 +public class SctpNet {
  104.46 +    static final String osName = AccessController.doPrivileged(
  104.47 +                    new GetPropertyAction("os.name"));
  104.48 +
  104.49 +    /* -- Miscellaneous SCTP utilities -- */
  104.50 +
  104.51 +    private static boolean IPv4MappedAddresses() {
  104.52 +        if ("SunOS".equals(osName)) {
  104.53 +            /* Solaris supports IPv4Mapped Addresses with bindx */
  104.54 +            return true;
  104.55 +        } /* else {  //other OS/implementations  */
  104.56 +
  104.57 +        /* lksctp/linux requires Ipv4 addresses */
  104.58 +        return false;
  104.59 +    }
  104.60 +
  104.61 +    static boolean throwAlreadyBoundException() throws IOException {
  104.62 +        throw new AlreadyBoundException();
  104.63 +    }
  104.64 +
  104.65 +    static void listen(int fd, int backlog) throws IOException {
  104.66 +        listen0(fd, backlog);
  104.67 +    }
  104.68 +
  104.69 +    static int connect(int fd, InetAddress remote, int remotePort)
  104.70 +            throws IOException {
  104.71 +        return connect0(fd, remote, remotePort);
  104.72 +    }
  104.73 +
  104.74 +    static void close(int fd) throws IOException {
  104.75 +        close0(fd);
  104.76 +    }
  104.77 +
  104.78 +    static void preClose(int fd) throws IOException {
  104.79 +        preClose0(fd);
  104.80 +    }
  104.81 +
  104.82 +    /**
  104.83 +     * @param  oneToOne
  104.84 +     *         if {@code true} returns a one-to-one sctp socket, otherwise
  104.85 +     *         returns a one-to-many sctp socket
  104.86 +     */
  104.87 +    static FileDescriptor socket(boolean oneToOne) throws IOException {
  104.88 +        int nativefd = socket0(oneToOne);
  104.89 +        return IOUtil.newFD(nativefd);
  104.90 +    }
  104.91 +
  104.92 +    static void bindx(int fd, InetAddress[] addrs, int port, boolean add)
  104.93 +            throws IOException {
  104.94 +        bindx(fd, addrs, port, addrs.length, add,
  104.95 +                IPv4MappedAddresses());
  104.96 +    }
  104.97 +
  104.98 +    static Set<SocketAddress> getLocalAddresses(int fd)
  104.99 +            throws IOException {
 104.100 +        HashSet<SocketAddress> set = null;
 104.101 +        SocketAddress[] saa = getLocalAddresses0(fd);
 104.102 +
 104.103 +        if (saa != null) {
 104.104 +            set = new HashSet<SocketAddress>(saa.length);
 104.105 +            for (SocketAddress sa : saa)
 104.106 +                set.add(sa);
 104.107 +        }
 104.108 +
 104.109 +        return set;
 104.110 +    }
 104.111 +
 104.112 +    static Set<SocketAddress> getRemoteAddresses(int fd, int assocId)
 104.113 +            throws IOException {
 104.114 +        HashSet<SocketAddress> set = null;
 104.115 +        SocketAddress[] saa = getRemoteAddresses0(fd, assocId);
 104.116 +
 104.117 +        if (saa != null) {
 104.118 +            set = new HashSet<SocketAddress>(saa.length);
 104.119 +            for (SocketAddress sa : saa)
 104.120 +                set.add(sa);
 104.121 +        }
 104.122 +
 104.123 +        return set;
 104.124 +    }
 104.125 +
 104.126 +    static <T> void setSocketOption(int fd,
 104.127 +                                    SctpSocketOption<T> name,
 104.128 +                                    T value,
 104.129 +                                    int assocId)
 104.130 +            throws IOException {
 104.131 +        if (value == null)
 104.132 +            throw new IllegalArgumentException("Invalid option value");
 104.133 +
 104.134 +        if (name.equals(SCTP_INIT_MAXSTREAMS)) {
 104.135 +            InitMaxStreams maxStreamValue = (InitMaxStreams)value;
 104.136 +            SctpNet.setInitMsgOption0(fd,
 104.137 +                 maxStreamValue.maxInStreams(), maxStreamValue.maxOutStreams());
 104.138 +        } else if (name.equals(SCTP_PRIMARY_ADDR) ||
 104.139 +                   name.equals(SCTP_SET_PEER_PRIMARY_ADDR)) {
 104.140 +
 104.141 +            SocketAddress addr  = (SocketAddress) value;
 104.142 +            if (addr == null)
 104.143 +                throw new IllegalArgumentException("Invalid option value");
 104.144 +
 104.145 +            Net.checkAddress(addr);
 104.146 +            InetSocketAddress netAddr = (InetSocketAddress)addr;
 104.147 +
 104.148 +            if (name.equals(SCTP_PRIMARY_ADDR)) {
 104.149 +                setPrimAddrOption0(fd,
 104.150 +                                   assocId,
 104.151 +                                   netAddr.getAddress(),
 104.152 +                                   netAddr.getPort());
 104.153 +            } else {
 104.154 +                setPeerPrimAddrOption0(fd,
 104.155 +                                       assocId,
 104.156 +                                       netAddr.getAddress(),
 104.157 +                                       netAddr.getPort(),
 104.158 +                                       IPv4MappedAddresses());
 104.159 +            }
 104.160 +        } else if (name.equals(SCTP_DISABLE_FRAGMENTS) ||
 104.161 +            name.equals(SCTP_EXPLICIT_COMPLETE) ||
 104.162 +            name.equals(SCTP_FRAGMENT_INTERLEAVE) ||
 104.163 +            name.equals(SCTP_NODELAY) ||
 104.164 +            name.equals(SO_SNDBUF) ||
 104.165 +            name.equals(SO_RCVBUF) ||
 104.166 +            name.equals(SO_LINGER)) {
 104.167 +            setIntOption(fd, name, value);
 104.168 +        } else {
 104.169 +            throw new AssertionError("Unknown socket option");
 104.170 +        }
 104.171 +    }
 104.172 +
 104.173 +    static Object getSocketOption(int fd, SctpSocketOption<?> name, int assocId)
 104.174 +             throws IOException {
 104.175 +         if (name.equals(SCTP_SET_PEER_PRIMARY_ADDR)) {
 104.176 +            throw new IllegalArgumentException(
 104.177 +                    "SCTP_SET_PEER_PRIMARY_ADDR cannot be retrieved");
 104.178 +        } else if (name.equals(SCTP_INIT_MAXSTREAMS)) {
 104.179 +            /* container for holding maxIn/Out streams */
 104.180 +            int[] values = new int[2];
 104.181 +            SctpNet.getInitMsgOption0(fd, values);
 104.182 +            return InitMaxStreams.create(values[0], values[1]);
 104.183 +        } else if (name.equals(SCTP_PRIMARY_ADDR)) {
 104.184 +            return getPrimAddrOption0(fd, assocId);
 104.185 +        } else if (name.equals(SCTP_DISABLE_FRAGMENTS) ||
 104.186 +            name.equals(SCTP_EXPLICIT_COMPLETE) ||
 104.187 +            name.equals(SCTP_FRAGMENT_INTERLEAVE) ||
 104.188 +            name.equals(SCTP_NODELAY) ||
 104.189 +            name.equals(SO_SNDBUF) ||
 104.190 +            name.equals(SO_RCVBUF) ||
 104.191 +            name.equals(SO_LINGER)) {
 104.192 +            return getIntOption(fd, name);
 104.193 +        } else {
 104.194 +            throw new AssertionError("Unknown socket option");
 104.195 +        }
 104.196 +    }
 104.197 +
 104.198 +    static void setIntOption(int fd, SctpSocketOption<?> name, Object value)
 104.199 +            throws IOException {
 104.200 +        if (value == null)
 104.201 +            throw new IllegalArgumentException("Invalid option value");
 104.202 +
 104.203 +        Class<?> type = name.type();
 104.204 +        if (type != Integer.class && type != Boolean.class)
 104.205 +            throw new AssertionError("Should not reach here");
 104.206 +
 104.207 +        if (name == SO_RCVBUF ||
 104.208 +            name == SO_SNDBUF)
 104.209 +        {
 104.210 +            int i = ((Integer)value).intValue();
 104.211 +            if (i < 0)
 104.212 +                throw new IllegalArgumentException(
 104.213 +                        "Invalid send/receive buffer size");
 104.214 +        } else if (name == SO_LINGER) {
 104.215 +            int i = ((Integer)value).intValue();
 104.216 +            if (i < 0)
 104.217 +                value = Integer.valueOf(-1);
 104.218 +            if (i > 65535)
 104.219 +                value = Integer.valueOf(65535);
 104.220 +        } else if (name.equals(SCTP_FRAGMENT_INTERLEAVE)) {
 104.221 +            int i = ((Integer)value).intValue();
 104.222 +            if (i < 0 || i > 2)
 104.223 +                throw new IllegalArgumentException(
 104.224 +                        "Invalid value for SCTP_FRAGMENT_INTERLEAVE");
 104.225 +        }
 104.226 +
 104.227 +        int arg;
 104.228 +        if (type == Integer.class) {
 104.229 +            arg = ((Integer)value).intValue();
 104.230 +        } else {
 104.231 +            boolean b = ((Boolean)value).booleanValue();
 104.232 +            arg = (b) ? 1 : 0;
 104.233 +        }
 104.234 +
 104.235 +        setIntOption0(fd, ((SctpStdSocketOption)name).constValue(), arg);
 104.236 +    }
 104.237 +
 104.238 +    static Object getIntOption(int fd, SctpSocketOption<?> name)
 104.239 +            throws IOException {
 104.240 +        Class<?> type = name.type();
 104.241 +
 104.242 +        if (type != Integer.class && type != Boolean.class)
 104.243 +            throw new AssertionError("Should not reach here");
 104.244 +
 104.245 +        if (!(name instanceof SctpStdSocketOption))
 104.246 +            throw new AssertionError("Should not reach here");
 104.247 +
 104.248 +        int value = getIntOption0(fd,
 104.249 +                ((SctpStdSocketOption)name).constValue());
 104.250 +
 104.251 +        if (type == Integer.class) {
 104.252 +            return Integer.valueOf(value);
 104.253 +        } else {
 104.254 +            return (value == 0) ? Boolean.FALSE : Boolean.TRUE;
 104.255 +        }
 104.256 +    }
 104.257 +
 104.258 +    static void shutdown(int fd, int assocId)
 104.259 +            throws IOException {
 104.260 +        shutdown0(fd, assocId);
 104.261 +    }
 104.262 +
 104.263 +    static FileDescriptor branch(int fd, int assocId) throws IOException {
 104.264 +        int nativefd = branch0(fd, assocId);
 104.265 +        return IOUtil.newFD(nativefd);
 104.266 +    }
 104.267 +
 104.268 +    /* Native Methods */
 104.269 +    static native int socket0(boolean oneToOne) throws IOException;
 104.270 +
 104.271 +    static native void listen0(int fd, int backlog) throws IOException;
 104.272 +
 104.273 +    static native int connect0(int fd, InetAddress remote, int remotePort)
 104.274 +        throws IOException;
 104.275 +
 104.276 +    static native void close0(int fd) throws IOException;
 104.277 +
 104.278 +    static native void preClose0(int fd) throws IOException;
 104.279 +
 104.280 +    static native void bindx(int fd, InetAddress[] addrs, int port, int length,
 104.281 +            boolean add, boolean preferIPv6) throws IOException;
 104.282 +
 104.283 +    static native int getIntOption0(int fd, int opt) throws IOException;
 104.284 +
 104.285 +    static native void setIntOption0(int fd, int opt, int arg)
 104.286 +        throws IOException;
 104.287 +
 104.288 +    static native SocketAddress[] getLocalAddresses0(int fd) throws IOException;
 104.289 +
 104.290 +    static native SocketAddress[] getRemoteAddresses0(int fd, int assocId)
 104.291 +            throws IOException;
 104.292 +
 104.293 +    static native int branch0(int fd, int assocId) throws IOException;
 104.294 +
 104.295 +    static native void setPrimAddrOption0(int fd, int assocId, InetAddress ia,
 104.296 +            int port) throws IOException;
 104.297 +
 104.298 +    static native void setPeerPrimAddrOption0(int fd, int assocId,
 104.299 +            InetAddress ia, int port, boolean preferIPv6) throws IOException;
 104.300 +
 104.301 +    static native SocketAddress getPrimAddrOption0(int fd, int assocId)
 104.302 +            throws IOException;
 104.303 +
 104.304 +    /* retVals [0] maxInStreams, [1] maxOutStreams */
 104.305 +    static native void getInitMsgOption0(int fd, int[] retVals) throws IOException;
 104.306 +
 104.307 +    static native void setInitMsgOption0(int fd, int arg1, int arg2)
 104.308 +            throws IOException;
 104.309 +
 104.310 +    static native void shutdown0(int fd, int assocId);
 104.311 +
 104.312 +    static native void init();
 104.313 +
 104.314 +    static {
 104.315 +        init();
 104.316 +    }
 104.317 +}
 104.318 +
   105.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   105.2 +++ b/src/solaris/classes/sun/nio/ch/sctp/SctpNotification.java	Sat Feb 18 16:11:47 2012 -0800
   105.3 @@ -0,0 +1,37 @@
   105.4 +/*
   105.5 + * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
   105.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   105.7 + *
   105.8 + * This code is free software; you can redistribute it and/or modify it
   105.9 + * under the terms of the GNU General Public License version 2 only, as
  105.10 + * published by the Free Software Foundation.  Oracle designates this
  105.11 + * particular file as subject to the "Classpath" exception as provided
  105.12 + * by Oracle in the LICENSE file that accompanied this code.
  105.13 + *
  105.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
  105.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  105.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  105.17 + * version 2 for more details (a copy is included in the LICENSE file that
  105.18 + * accompanied this code).
  105.19 + *
  105.20 + * You should have received a copy of the GNU General Public License version
  105.21 + * 2 along with this work; if not, write to the Free Software Foundation,
  105.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  105.23 + *
  105.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  105.25 + * or visit www.oracle.com if you need additional information or have any
  105.26 + * questions.
  105.27 + */
  105.28 +package sun.nio.ch.sctp;
  105.29 +
  105.30 +import com.sun.nio.sctp.Association;
  105.31 +import com.sun.nio.sctp.Notification;
  105.32 +
  105.33 +/**
  105.34 + * All Notification implemenations MUST implement this interface to provide
  105.35 + * access to the native association identidier.
  105.36 + */
  105.37 +interface SctpNotification extends Notification {
  105.38 +    int assocId();
  105.39 +    void setAssociation(Association association);
  105.40 +}
   106.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   106.2 +++ b/src/solaris/classes/sun/nio/ch/sctp/SctpServerChannelImpl.java	Sat Feb 18 16:11:47 2012 -0800
   106.3 @@ -0,0 +1,434 @@
   106.4 +/*
   106.5 + * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
   106.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   106.7 + *
   106.8 + * This code is free software; you can redistribute it and/or modify it
   106.9 + * under the terms of the GNU General Public License version 2 only, as
  106.10 + * published by the Free Software Foundation.  Oracle designates this
  106.11 + * particular file as subject to the "Classpath" exception as provided
  106.12 + * by Oracle in the LICENSE file that accompanied this code.
  106.13 + *
  106.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
  106.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  106.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  106.17 + * version 2 for more details (a copy is included in the LICENSE file that
  106.18 + * accompanied this code).
  106.19 + *
  106.20 + * You should have received a copy of the GNU General Public License version
  106.21 + * 2 along with this work; if not, write to the Free Software Foundation,
  106.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  106.23 + *
  106.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  106.25 + * or visit www.oracle.com if you need additional information or have any
  106.26 + * questions.
  106.27 + */
  106.28 +package sun.nio.ch.sctp;
  106.29 +
  106.30 +import java.net.SocketAddress;
  106.31 +import java.net.InetSocketAddress;
  106.32 +import java.net.InetAddress;
  106.33 +import java.io.FileDescriptor;
  106.34 +import java.io.IOException;
  106.35 +import java.util.Collections;
  106.36 +import java.util.Set;
  106.37 +import java.util.HashSet;
  106.38 +import java.nio.channels.SelectionKey;
  106.39 +import java.nio.channels.ClosedChannelException;
  106.40 +import java.nio.channels.NotYetBoundException;
  106.41 +import java.nio.channels.spi.SelectorProvider;
  106.42 +import com.sun.nio.sctp.IllegalUnbindException;
  106.43 +import com.sun.nio.sctp.SctpChannel;
  106.44 +import com.sun.nio.sctp.SctpServerChannel;
  106.45 +import com.sun.nio.sctp.SctpSocketOption;
  106.46 +import com.sun.nio.sctp.SctpStandardSocketOptions;
  106.47 +import sun.nio.ch.DirectBuffer;
  106.48 +import sun.nio.ch.NativeThread;
  106.49 +import sun.nio.ch.IOStatus;
  106.50 +import sun.nio.ch.IOUtil;
  106.51 +import sun.nio.ch.Net;
  106.52 +import sun.nio.ch.PollArrayWrapper;
  106.53 +import sun.nio.ch.SelChImpl;
  106.54 +import sun.nio.ch.SelectionKeyImpl;
  106.55 +import sun.nio.ch.Util;
  106.56 +
  106.57 +/**
  106.58 + * An implementation of SctpServerChannel
  106.59 + */
  106.60 +public class SctpServerChannelImpl extends SctpServerChannel
  106.61 +    implements SelChImpl
  106.62 +{
  106.63 +    private final FileDescriptor fd;
  106.64 +
  106.65 +    private final int fdVal;
  106.66 +
  106.67 +    /* IDs of native thread doing accept, for signalling */
  106.68 +    private volatile long thread = 0;
  106.69 +
  106.70 +    /* Lock held by thread currently blocked in this channel */
  106.71 +    private final Object lock = new Object();
  106.72 +
  106.73 +    /* Lock held by any thread that modifies the state fields declared below
  106.74 +     * DO NOT invoke a blocking I/O operation while holding this lock! */
  106.75 +    private final Object stateLock = new Object();
  106.76 +
  106.77 +    private enum ChannelState {
  106.78 +        UNINITIALIZED,
  106.79 +        INUSE,
  106.80 +        KILLPENDING,
  106.81 +        KILLED,
  106.82 +    }
  106.83 +    /* -- The following fields are protected by stateLock -- */
  106.84 +    private ChannelState state = ChannelState.UNINITIALIZED;
  106.85 +
  106.86 +    /* Binding: Once bound the port will remain constant. */
  106.87 +    int port = -1;
  106.88 +    private HashSet<InetSocketAddress> localAddresses = new HashSet<InetSocketAddress>();
  106.89 +    /* Has the channel been bound to the wildcard address */
  106.90 +    private boolean wildcard; /* false */
  106.91 +
  106.92 +    /* -- End of fields protected by stateLock -- */
  106.93 +
  106.94 +    /**
  106.95 +     * Initializes a new instance of this class.
  106.96 +     */
  106.97 +    public SctpServerChannelImpl(SelectorProvider provider)
  106.98 +            throws IOException {
  106.99 +        //TODO: update provider remove public modifier
 106.100 +        super(provider);
 106.101 +        this.fd = SctpNet.socket(true);
 106.102 +        this.fdVal = IOUtil.fdVal(fd);
 106.103 +        this.state = ChannelState.INUSE;
 106.104 +    }
 106.105 +
 106.106 +    @Override
 106.107 +    public SctpServerChannel bind(SocketAddress local, int backlog)
 106.108 +            throws IOException {
 106.109 +        synchronized (lock) {
 106.110 +            synchronized (stateLock) {
 106.111 +                if (!isOpen())
 106.112 +                    throw new ClosedChannelException();
 106.113 +                if (isBound())
 106.114 +                    SctpNet.throwAlreadyBoundException();
 106.115 +
 106.116 +                InetSocketAddress isa = (local == null) ?
 106.117 +                    new InetSocketAddress(0) : Net.checkAddress(local);
 106.118 +                SecurityManager sm = System.getSecurityManager();
 106.119 +                if (sm != null)
 106.120 +                    sm.checkListen(isa.getPort());
 106.121 +                Net.bind(fd, isa.getAddress(), isa.getPort());
 106.122 +
 106.123 +                InetSocketAddress boundIsa = Net.localAddress(fd);
 106.124 +                port = boundIsa.getPort();
 106.125 +                localAddresses.add(isa);
 106.126 +                    if (isa.getAddress().isAnyLocalAddress())
 106.127 +                        wildcard = true;
 106.128 +
 106.129 +                SctpNet.listen(fdVal, backlog < 1 ? 50 : backlog);
 106.130 +            }
 106.131 +        }
 106.132 +        return this;
 106.133 +    }
 106.134 +
 106.135 +    @Override
 106.136 +    public SctpServerChannel bindAddress(InetAddress address)
 106.137 +            throws IOException {
 106.138 +        return bindUnbindAddress(address, true);
 106.139 +    }
 106.140 +
 106.141 +    @Override
 106.142 +    public SctpServerChannel unbindAddress(InetAddress address)
 106.143 +            throws IOException {
 106.144 +        return bindUnbindAddress(address, false);
 106.145 +    }
 106.146 +
 106.147 +    private SctpServerChannel bindUnbindAddress(InetAddress address, boolean add)
 106.148 +            throws IOException {
 106.149 +        if (address == null)
 106.150 +            throw new IllegalArgumentException();
 106.151 +
 106.152 +        synchronized (lock) {
 106.153 +            synchronized (stateLock) {
 106.154 +                if (!isOpen())
 106.155 +                    throw new ClosedChannelException();
 106.156 +                if (!isBound())
 106.157 +                    throw new NotYetBoundException();
 106.158 +                if (wildcard)
 106.159 +                    throw new IllegalStateException(
 106.160 +                            "Cannot add or remove addresses from a channel that is bound to the wildcard address");
 106.161 +                if (address.isAnyLocalAddress())
 106.162 +                    throw new IllegalArgumentException(
 106.163 +                            "Cannot add or remove the wildcard address");
 106.164 +                if (add) {
 106.165 +                    for (InetSocketAddress addr : localAddresses) {
 106.166 +                        if (addr.getAddress().equals(address)) {
 106.167 +                            SctpNet.throwAlreadyBoundException();
 106.168 +                        }
 106.169 +                    }
 106.170 +                } else { /*removing */
 106.171 +                    /* Verify that there is more than one address
 106.172 +                     * and that address is already bound */
 106.173 +                    if (localAddresses.size() <= 1)
 106.174 +                        throw new IllegalUnbindException("Cannot remove address from a channel with only one address bound");
 106.175 +                    boolean foundAddress = false;
 106.176 +                    for (InetSocketAddress addr : localAddresses) {
 106.177 +                        if (addr.getAddress().equals(address)) {
 106.178 +                            foundAddress = true;
 106.179 +                            break;
 106.180 +                        }
 106.181 +                    }
 106.182 +                    if (!foundAddress )
 106.183 +                        throw new IllegalUnbindException("Cannot remove address from a channel that is not bound to that address");
 106.184 +                }
 106.185 +
 106.186 +                SctpNet.bindx(fdVal, new InetAddress[]{address}, port, add);
 106.187 +
 106.188 +                /* Update our internal Set to reflect the addition/removal */
 106.189 +                if (add)
 106.190 +                    localAddresses.add(new InetSocketAddress(address, port));
 106.191 +                else {
 106.192 +                    for (InetSocketAddress addr : localAddresses) {
 106.193 +                        if (addr.getAddress().equals(address)) {
 106.194 +                            localAddresses.remove(addr);
 106.195 +                            break;
 106.196 +                        }
 106.197 +                    }
 106.198 +                }
 106.199 +            }
 106.200 +        }
 106.201 +        return this;
 106.202 +    }
 106.203 +
 106.204 +    private boolean isBound() {
 106.205 +        synchronized (stateLock) {
 106.206 +            return port == -1 ? false : true;
 106.207 +        }
 106.208 +    }
 106.209 +
 106.210 +    private void acceptCleanup() throws IOException {
 106.211 +        synchronized (stateLock) {
 106.212 +            thread = 0;
 106.213 +            if (state == ChannelState.KILLPENDING)
 106.214 +                kill();
 106.215 +        }
 106.216 +    }
 106.217 +
 106.218 +    @Override
 106.219 +    public SctpChannel accept() throws IOException {
 106.220 +        synchronized (lock) {
 106.221 +            if (!isOpen())
 106.222 +                throw new ClosedChannelException();
 106.223 +            if (!isBound())
 106.224 +                throw new NotYetBoundException();
 106.225 +            SctpChannel sc = null;
 106.226 +
 106.227 +            int n = 0;
 106.228 +            FileDescriptor newfd = new FileDescriptor();
 106.229 +            InetSocketAddress[] isaa = new InetSocketAddress[1];
 106.230 +
 106.231 +            try {
 106.232 +                begin();
 106.233 +                if (!isOpen())
 106.234 +                    return null;
 106.235 +                thread = NativeThread.current();
 106.236 +                for (;;) {
 106.237 +                    n = accept0(fd, newfd, isaa);
 106.238 +                    if ((n == IOStatus.INTERRUPTED) && isOpen())
 106.239 +                        continue;
 106.240 +                    break;
 106.241 +                }
 106.242 +            } finally {
 106.243 +                acceptCleanup();
 106.244 +                end(n > 0);
 106.245 +                assert IOStatus.check(n);
 106.246 +            }
 106.247 +
 106.248 +            if (n < 1)
 106.249 +                return null;
 106.250 +
 106.251 +            IOUtil.configureBlocking(newfd, true);
 106.252 +            InetSocketAddress isa = isaa[0];
 106.253 +            sc = new SctpChannelImpl(provider(), newfd);
 106.254 +
 106.255 +            SecurityManager sm = System.getSecurityManager();
 106.256 +            if (sm != null)
 106.257 +                sm.checkAccept(isa.getAddress().getHostAddress(),
 106.258 +                               isa.getPort());
 106.259 +
 106.260 +            return sc;
 106.261 +        }
 106.262 +    }
 106.263 +
 106.264 +    @Override
 106.265 +    protected void implConfigureBlocking(boolean block) throws IOException {
 106.266 +        IOUtil.configureBlocking(fd, block);
 106.267 +    }
 106.268 +
 106.269 +    @Override
 106.270 +    public void implCloseSelectableChannel() throws IOException {
 106.271 +        synchronized (stateLock) {
 106.272 +            SctpNet.preClose(fdVal);
 106.273 +            if (thread != 0)
 106.274 +                NativeThread.signal(thread);
 106.275 +            if (!isRegistered())
 106.276 +                kill();
 106.277 +        }
 106.278 +    }
 106.279 +
 106.280 +    @Override
 106.281 +    public void kill() throws IOException {
 106.282 +        synchronized (stateLock) {
 106.283 +            if (state == ChannelState.KILLED)
 106.284 +                return;
 106.285 +            if (state == ChannelState.UNINITIALIZED) {
 106.286 +                state = ChannelState.KILLED;
 106.287 +                return;
 106.288 +            }
 106.289 +            assert !isOpen() && !isRegistered();
 106.290 +
 106.291 +            // Postpone the kill if there is a thread in accept
 106.292 +            if (thread == 0) {
 106.293 +                SctpNet.close(fdVal);
 106.294 +                state = ChannelState.KILLED;
 106.295 +            } else {
 106.296 +                state = ChannelState.KILLPENDING;
 106.297 +            }
 106.298 +        }
 106.299 +    }
 106.300 +
 106.301 +    @Override
 106.302 +    public FileDescriptor getFD() {
 106.303 +        return fd;
 106.304 +    }
 106.305 +
 106.306 +    @Override
 106.307 +    public int getFDVal() {
 106.308 +        return fdVal;
 106.309 +    }
 106.310 +
 106.311 +    /**
 106.312 +     * Translates native poll revent ops into a ready operation ops
 106.313 +     */
 106.314 +    private boolean translateReadyOps(int ops, int initialOps,
 106.315 +                                     SelectionKeyImpl sk) {
 106.316 +        int intOps = sk.nioInterestOps();
 106.317 +        int oldOps = sk.nioReadyOps();
 106.318 +        int newOps = initialOps;
 106.319 +
 106.320 +        if ((ops & PollArrayWrapper.POLLNVAL) != 0) {
 106.321 +            /* This should only happen if this channel is pre-closed while a
 106.322 +             * selection operation is in progress
 106.323 +             * ## Throw an error if this channel has not been pre-closed */
 106.324 +            return false;
 106.325 +        }
 106.326 +
 106.327 +        if ((ops & (PollArrayWrapper.POLLERR
 106.328 +                    | PollArrayWrapper.POLLHUP)) != 0) {
 106.329 +            newOps = intOps;
 106.330 +            sk.nioReadyOps(newOps);
 106.331 +            return (newOps & ~oldOps) != 0;
 106.332 +        }
 106.333 +
 106.334 +        if (((ops & PollArrayWrapper.POLLIN) != 0) &&
 106.335 +            ((intOps & SelectionKey.OP_ACCEPT) != 0))
 106.336 +                newOps |= SelectionKey.OP_ACCEPT;
 106.337 +
 106.338 +        sk.nioReadyOps(newOps);
 106.339 +        return (newOps & ~oldOps) != 0;
 106.340 +    }
 106.341 +
 106.342 +    @Override
 106.343 +    public boolean translateAndUpdateReadyOps(int ops, SelectionKeyImpl sk) {
 106.344 +        return translateReadyOps(ops, sk.nioReadyOps(), sk);
 106.345 +    }
 106.346 +
 106.347 +    @Override
 106.348 +    public boolean translateAndSetReadyOps(int ops, SelectionKeyImpl sk) {
 106.349 +        return translateReadyOps(ops, 0, sk);
 106.350 +    }
 106.351 +
 106.352 +    @Override
 106.353 +    public void translateAndSetInterestOps(int ops, SelectionKeyImpl sk) {
 106.354 +        int newOps = 0;
 106.355 +
 106.356 +        /* Translate ops */
 106.357 +        if ((ops & SelectionKey.OP_ACCEPT) != 0)
 106.358 +            newOps |= PollArrayWrapper.POLLIN;
 106.359 +        /* Place ops into pollfd array */
 106.360 +        sk.selector.putEventOps(sk, newOps);
 106.361 +
 106.362 +    }
 106.363 +
 106.364 +    @Override
 106.365 +    public <T> SctpServerChannel setOption(SctpSocketOption<T> name, T value)
 106.366 +            throws IOException {
 106.367 +        if (name == null)
 106.368 +            throw new NullPointerException();
 106.369 +        if (!supportedOptions().contains(name))
 106.370 +            throw new UnsupportedOperationException("'" + name + "' not supported");
 106.371 +
 106.372 +        synchronized (stateLock) {
 106.373 +            if (!isOpen())
 106.374 +                throw new ClosedChannelException();
 106.375 +
 106.376 +            SctpNet.setSocketOption(fdVal, name, value, 0 /*oneToOne*/);
 106.377 +            return this;
 106.378 +        }
 106.379 +    }
 106.380 +
 106.381 +    @Override
 106.382 +    @SuppressWarnings("unchecked")
 106.383 +    public <T> T getOption(SctpSocketOption<T> name) throws IOException {
 106.384 +        if (name == null)
 106.385 +            throw new NullPointerException();
 106.386 +        if (!supportedOptions().contains(name))
 106.387 +            throw new UnsupportedOperationException("'" + name + "' not supported");
 106.388 +
 106.389 +        synchronized (stateLock) {
 106.390 +            if (!isOpen())
 106.391 +                throw new ClosedChannelException();
 106.392 +
 106.393 +            return (T) SctpNet.getSocketOption(fdVal, name, 0 /*oneToOne*/);
 106.394 +        }
 106.395 +    }
 106.396 +
 106.397 +    private static class DefaultOptionsHolder {
 106.398 +        static final Set<SctpSocketOption<?>> defaultOptions = defaultOptions();
 106.399 +
 106.400 +        private static Set<SctpSocketOption<?>> defaultOptions() {
 106.401 +            HashSet<SctpSocketOption<?>> set = new HashSet<SctpSocketOption<?>>(1);
 106.402 +            set.add(SctpStandardSocketOptions.SCTP_INIT_MAXSTREAMS);
 106.403 +            return Collections.unmodifiableSet(set);
 106.404 +        }
 106.405 +    }
 106.406 +
 106.407 +    @Override
 106.408 +    public final Set<SctpSocketOption<?>> supportedOptions() {
 106.409 +        return DefaultOptionsHolder.defaultOptions;
 106.410 +    }
 106.411 +
 106.412 +    @Override
 106.413 +    public Set<SocketAddress> getAllLocalAddresses()
 106.414 +            throws IOException {
 106.415 +        synchronized (stateLock) {
 106.416 +            if (!isOpen())
 106.417 +                throw new ClosedChannelException();
 106.418 +            if (!isBound())
 106.419 +                return Collections.emptySet();
 106.420 +
 106.421 +            return SctpNet.getLocalAddresses(fdVal);
 106.422 +        }
 106.423 +    }
 106.424 +
 106.425 +    /* Native */
 106.426 +    private static native void initIDs();
 106.427 +
 106.428 +    private static native int accept0(FileDescriptor ssfd,
 106.429 +        FileDescriptor newfd, InetSocketAddress[] isaa) throws IOException;
 106.430 +
 106.431 +    static {
 106.432 +        Util.load();   // loads nio & net native libraries
 106.433 +        java.security.AccessController.doPrivileged(
 106.434 +                new sun.security.action.LoadLibraryAction("sctp"));
 106.435 +        initIDs();
 106.436 +    }
 106.437 +}
   107.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   107.2 +++ b/src/solaris/classes/sun/nio/ch/sctp/SendFailed.java	Sat Feb 18 16:11:47 2012 -0800
   107.3 @@ -0,0 +1,110 @@
   107.4 +/*
   107.5 + * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
   107.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   107.7 + *
   107.8 + * This code is free software; you can redistribute it and/or modify it
   107.9 + * under the terms of the GNU General Public License version 2 only, as
  107.10 + * published by the Free Software Foundation.  Oracle designates this
  107.11 + * particular file as subject to the "Classpath" exception as provided
  107.12 + * by Oracle in the LICENSE file that accompanied this code.
  107.13 + *
  107.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
  107.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  107.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  107.17 + * version 2 for more details (a copy is included in the LICENSE file that
  107.18 + * accompanied this code).
  107.19 + *
  107.20 + * You should have received a copy of the GNU General Public License version
  107.21 + * 2 along with this work; if not, write to the Free Software Foundation,
  107.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  107.23 + *
  107.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  107.25 + * or visit www.oracle.com if you need additional information or have any
  107.26 + * questions.
  107.27 + */
  107.28 +package sun.nio.ch.sctp;
  107.29 +
  107.30 +import java.nio.ByteBuffer;
  107.31 +import java.net.SocketAddress;
  107.32 +import com.sun.nio.sctp.Association;
  107.33 +import com.sun.nio.sctp.SendFailedNotification;
  107.34 +
  107.35 +/**
  107.36 + * An implementation of SendFailedNotification
  107.37 + */
  107.38 +public class SendFailed extends SendFailedNotification
  107.39 +    implements SctpNotification
  107.40 +{
  107.41 +    private Association association;
  107.42 +    /* assocId is used to lookup the association before the notification is
  107.43 +     * returned to user code */
  107.44 +    private int assocId;
  107.45 +    private SocketAddress address;
  107.46 +    private ByteBuffer buffer;
  107.47 +    private int errorCode;
  107.48 +    private int streamNumber;
  107.49 +
  107.50 +    /* Invoked from native */
  107.51 +    private SendFailed(int assocId,
  107.52 +                       SocketAddress address,
  107.53 +                       ByteBuffer buffer,
  107.54 +                       int errorCode,
  107.55 +                       int streamNumber) {
  107.56 +        this.assocId = assocId;
  107.57 +        this.errorCode = errorCode;
  107.58 +        this.streamNumber = streamNumber;
  107.59 +        this.address = address;
  107.60 +        this.buffer = buffer;
  107.61 +    }
  107.62 +
  107.63 +    @Override
  107.64 +    public int assocId() {
  107.65 +        return assocId;
  107.66 +    }
  107.67 +
  107.68 +    @Override
  107.69 +    public void setAssociation(Association association) {
  107.70 +        this.association = association;
  107.71 +    }
  107.72 +
  107.73 +    @Override
  107.74 +    public Association association() {
  107.75 +        /* may be null */
  107.76 +        return association;
  107.77 +    }
  107.78 +
  107.79 +    @Override
  107.80 +    public SocketAddress address() {
  107.81 +        assert address != null;
  107.82 +        return address;
  107.83 +    }
  107.84 +
  107.85 +    @Override
  107.86 +    public ByteBuffer buffer() {
  107.87 +        assert buffer != null;
  107.88 +        return buffer;
  107.89 +    }
  107.90 +
  107.91 +    @Override
  107.92 +    public int errorCode() {
  107.93 +        return errorCode;
  107.94 +    }
  107.95 +
  107.96 +    @Override
  107.97 +    public int streamNumber() {
  107.98 +        return streamNumber;
  107.99 +    }
 107.100 +
 107.101 +    @Override
 107.102 +    public String toString() {
 107.103 +        StringBuilder sb = new StringBuilder();
 107.104 +        sb.append(super.toString()).append(" [");
 107.105 +        sb.append("Association:").append(association);
 107.106 +        sb.append(", Address: ").append(address);
 107.107 +        sb.append(", buffer: ").append(buffer);
 107.108 +        sb.append(", errorCode: ").append(errorCode);
 107.109 +        sb.append(", streamNumber: ").append(streamNumber);
 107.110 +        sb.append("]");
 107.111 +        return sb.toString();
 107.112 +    }
 107.113 +}
   108.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   108.2 +++ b/src/solaris/classes/sun/nio/ch/sctp/Shutdown.java	Sat Feb 18 16:11:47 2012 -0800
   108.3 @@ -0,0 +1,69 @@
   108.4 +/*
   108.5 + * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
   108.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   108.7 + *
   108.8 + * This code is free software; you can redistribute it and/or modify it
   108.9 + * under the terms of the GNU General Public License version 2 only, as
  108.10 + * published by the Free Software Foundation.  Oracle designates this
  108.11 + * particular file as subject to the "Classpath" exception as provided
  108.12 + * by Oracle in the LICENSE file that accompanied this code.
  108.13 + *
  108.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
  108.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  108.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  108.17 + * version 2 for more details (a copy is included in the LICENSE file that
  108.18 + * accompanied this code).
  108.19 + *
  108.20 + * You should have received a copy of the GNU General Public License version
  108.21 + * 2 along with this work; if not, write to the Free Software Foundation,
  108.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  108.23 + *
  108.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  108.25 + * or visit www.oracle.com if you need additional information or have any
  108.26 + * questions.
  108.27 + */
  108.28 +package sun.nio.ch.sctp;
  108.29 +
  108.30 +import com.sun.nio.sctp.Association;
  108.31 +import com.sun.nio.sctp.ShutdownNotification;
  108.32 +
  108.33 +/**
  108.34 + * An implementation of ShutdownNotification
  108.35 + */
  108.36 +public class Shutdown extends ShutdownNotification
  108.37 +    implements SctpNotification
  108.38 +{
  108.39 +    private Association association;
  108.40 +    /* assocId is used to lookup the association before the notification is
  108.41 +     * returned to user code */
  108.42 +    private int assocId;
  108.43 +
  108.44 +    /* Invoked from native */
  108.45 +    private Shutdown(int assocId) {
  108.46 +        this.assocId = assocId;
  108.47 +    }
  108.48 +
  108.49 +    @Override
  108.50 +    public int assocId() {
  108.51 +        return assocId;
  108.52 +    }
  108.53 +
  108.54 +    @Override
  108.55 +    public void setAssociation(Association association) {
  108.56 +        this.association = association;
  108.57 +    }
  108.58 +
  108.59 +    @Override
  108.60 +    public Association association() {
  108.61 +        assert association != null;
  108.62 +        return association;
  108.63 +    }
  108.64 +
  108.65 +    @Override
  108.66 +    public String toString() {
  108.67 +        StringBuilder sb = new StringBuilder();
  108.68 +        sb.append(super.toString()).append(" [");
  108.69 +        sb.append("Association:").append(association).append("]");
  108.70 +        return sb.toString();
  108.71 +    }
  108.72 +}
   109.1 --- a/src/solaris/doc/sun/man/man1/apt.1	Thu Feb 16 13:01:36 2012 -0800
   109.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   109.3 @@ -1,153 +0,0 @@
   109.4 -." Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
   109.5 -." DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   109.6 -."
   109.7 -." This code is free software; you can redistribute it and/or modify it
   109.8 -." under the terms of the GNU General Public License version 2 only, as
   109.9 -." published by the Free Software Foundation.
  109.10 -."
  109.11 -." This code is distributed in the hope that it will be useful, but WITHOUT
  109.12 -." ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  109.13 -." FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  109.14 -." version 2 for more details (a copy is included in the LICENSE file that
  109.15 -." accompanied this code).
  109.16 -."
  109.17 -." You should have received a copy of the GNU General Public License version
  109.18 -." 2 along with this work; if not, write to the Free Software Foundation,
  109.19 -." Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  109.20 -."
  109.21 -." Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  109.22 -." or visit www.oracle.com if you need additional information or have any
  109.23 -." questions.
  109.24 -."
  109.25 -.TH apt 1 "10 May 2011"
  109.26 -
  109.27 -.LP
  109.28 -.SH "NAME"
  109.29 -.LP
  109.30 -.LP
  109.31 -\f2apt\fP \- annotation processing tool
  109.32 -.LP
  109.33 -.SH "SYNOPSIS"
  109.34 -.LP
  109.35 -.LP
  109.36 -\f2apt [\-classpath \fP\f2classpath\fP] [\-sourcepath \f2sourcepath\fP] [\-d \f2directory\fP] [\-s \f2directory\fP] [\-factorypath \f2path\fP] [\-factory \f2class\fP] [\-print] [\-nocompile] [\-A\f2key\fP[\f2=val\fP] ...] [\f2javac option\fP] sourcefiles [@files]
  109.37 -.LP
  109.38 -.SH "PARAMETERS"
  109.39 -.LP
  109.40 -.LP
  109.41 -Options may be in any order. For a discussion of parameters which apply to a specific option, see OPTIONS below.
  109.42 -.LP
  109.43 -.RS 3
  109.44 -.TP 3
  109.45 -sourcefiles 
  109.46 -Zero or more source files to be processed. 
  109.47 -.TP 3
  109.48 -@files 
  109.49 -One or more files that list source files or other options 
  109.50 -.RE
  109.51 -
  109.52 -.LP
  109.53 -.SH "DESCRIPTION"
  109.54 -.LP
  109.55 -.LP
  109.56 -\f3Note\fP: The \f2apt\fP tool and its associated API contained in the package \f2com.sun.mirror\fP have been deprecated since JDK 7 and are planned to be removed in the next major JDK release. Use the options available in the \f2javac(1)\fP tool and the APIs contained in the packages \f2javax.annotation.processing\fP and \f2javax.lang.model\fP to process annotations.
  109.57 -.LP
  109.58 -.LP
  109.59 -The tool \f2apt\fP, annotation processing tool, includes reflective APIs and supporting infrastructure to process program annotations. The \f2apt\fP reflective APIs provide a build\-time, source\-based, read\-only view of program structure. These reflective APIs are designed to cleanly model the Java(TM) programming language's type system after the addition of generics. First, \f2apt\fP runs annotation processors that can produce new source code and other files. Next, \f2apt\fP can cause compilation of both original and generated source files, easing development. The reflective APIs and other APIs used to interact with the tool are subpackages of \f2com.sun.mirror\fP.
  109.60 -.LP
  109.61 -.LP
  109.62 -A fuller discussion of how the tool operates as well as instructions for developing with \f2apt\fP are in 
  109.63 -.na
  109.64 -\f4Getting Started with \fP\f4apt\fP. @
  109.65 -.fi
  109.66 -http://download.oracle.com/javase/7/docs/technotes/guides/apt/GettingStarted.html
  109.67 -.LP
  109.68 -.SH "OPTIONS"
  109.69 -.LP
  109.70 -.SS 
  109.71 -apt specific options
  109.72 -.LP
  109.73 -.RS 3
  109.74 -.TP 3
  109.75 -\-s dir 
  109.76 -Specify the directory root under which processor\-generated source files will be placed; files are placed in subdirectories based on package namespace. 
  109.77 -.TP 3
  109.78 -\-nocompile 
  109.79 -Do not compile source files to class files. 
  109.80 -.TP 3
  109.81 -\-print 
  109.82 -Print out textual representation of specified types; perform no annotation processing or compilation. 
  109.83 -.TP 3
  109.84 -\-A[key[=val]] 
  109.85 -Options to pass to annotation processors \-\- these are not interpreted by \f2apt\fP directly, but are made available for use by individual processors 
  109.86 -.TP 3
  109.87 -\-factorypath path 
  109.88 -Specify where to find annotation processor factories; if this option is used, the classpath is \f2not\fP searched for factories. 
  109.89 -.TP 3
  109.90 -\-factory classname 
  109.91 -Name of annotation processor factory to use; bypasses default discovery process 
  109.92 -.TP 3
  109.93 -\-version 
  109.94 -Print version information. 
  109.95 -.TP 3
  109.96 -\-X 
  109.97 -Display information about non\-standard options. 
  109.98 -.RE
  109.99 -
 109.100 -.LP
 109.101 -.SS 
 109.102 -Options shared with javac
 109.103 -.LP
 109.104 -.RS 3
 109.105 -.TP 3
 109.106 -\-d dir 
 109.107 -Specify where to place processor and javac generated class files 
 109.108 -.TP 3
 109.109 -\-cp path or \-classpath path 
 109.110 -Specify where to find user class files and annotation processor factories. If \f2\-factorypath\fP is given, the classpath is not searched for factories. 
 109.111 -.RE
 109.112 -
 109.113 -.LP
 109.114 -.LP
 109.115 -Consult the javac(1) man page for information on \f2javac\fP options.
 109.116 -.LP
 109.117 -.SS 
 109.118 -Non\-Standard Options
 109.119 -.LP
 109.120 -.RS 3
 109.121 -.TP 3
 109.122 -\-XListAnnotationTypes 
 109.123 -List found annotation types. 
 109.124 -.TP 3
 109.125 -\-XListDeclarations 
 109.126 -List specified and included declarations. 
 109.127 -.TP 3
 109.128 -\-XPrintAptRounds 
 109.129 -Print information about initial and recursive \f2apt\fP rounds. 
 109.130 -.TP 3
 109.131 -\-XPrintFactoryInfo 
 109.132 -Print information about which annotations a factory is asked to process. 
 109.133 -.TP 3
 109.134 -\-XclassesAsDecls 
 109.135 -Treat both class and source files as declarations to process. 
 109.136 -.RE
 109.137 -
 109.138 -.LP
 109.139 -.LP
 109.140 -\f3Note\fP: Because these options are non\-standard, they are subject to change without notice.
 109.141 -.LP
 109.142 -.SH "NOTES"
 109.143 -.LP
 109.144 -.LP
 109.145 -The \f2apt\fP tool and its associated API contained in the package \f2com.sun.mirror\fP have been deprecated since JDK 7 and are planned to be removed in the next major JDK release. Use the options available in the \f2javac(1)\fP tool and the APIs contained in the packages \f2javax.annotation.processing\fP and \f2javax.lang.model\fP to process annotations.
 109.146 -.LP
 109.147 -.SH "SEE ALSO"
 109.148 -.LP
 109.149 -.RS 3
 109.150 -.TP 2
 109.151 -o
 109.152 -javac(1), java(1) 
 109.153 -.RE
 109.154 -
 109.155 -.LP
 109.156 - 
   110.1 --- a/src/solaris/doc/sun/man/man1/ja/apt.1	Thu Feb 16 13:01:36 2012 -0800
   110.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   110.3 @@ -1,153 +0,0 @@
   110.4 -." Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
   110.5 -." DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   110.6 -."
   110.7 -." This code is free software; you can redistribute it and/or modify it
   110.8 -." under the terms of the GNU General Public License version 2 only, as
   110.9 -." published by the Free Software Foundation.
  110.10 -."
  110.11 -." This code is distributed in the hope that it will be useful, but WITHOUT
  110.12 -." ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  110.13 -." FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  110.14 -." version 2 for more details (a copy is included in the LICENSE file that
  110.15 -." accompanied this code).
  110.16 -."
  110.17 -." You should have received a copy of the GNU General Public License version
  110.18 -." 2 along with this work; if not, write to the Free Software Foundation,
  110.19 -." Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  110.20 -."
  110.21 -." Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  110.22 -." or visit www.oracle.com if you need additional information or have any
  110.23 -." questions.
  110.24 -."
  110.25 -.TH apt 1 "07 May 2011"
  110.26 -
  110.27 -.LP
  110.28 -.SH "NAME"
  110.29 -.LP
  110.30 -.LP
  110.31 -\f2apt\fP \- Ãí¼á½èÍý¥Ä¡¼¥ë
  110.32 -.LP
  110.33 -.SH "·Á¼°"
  110.34 -.LP
  110.35 -.LP
  110.36 -\f2apt [\-classpath \fP\f2classpath\fP] [\-sourcepath \f2sourcepath\fP] [\-d \f2directory\fP] [\-s \f2directory\fP] [\-factorypath \f2path\fP] [\-factory \f2class\fP] [\-print] [\-nocompile] [\-A\f2key\fP[\f2=val\fP] ...] [\f2javac option\fP] sourcefiles [@files]
  110.37 -.LP
  110.38 -.SH "¥Ñ¥é¥á¡¼¥¿"
  110.39 -.LP
  110.40 -.LP
  110.41 -¥ª¥×¥·¥ç¥ó¤Î»ØÄê½ç½ø¤Ë·è¤Þ¤ê¤Ï¤¢¤ê¤Þ¤»¤ó¡£ÆÃÄê¤Î¥ª¥×¥·¥ç¥ó¤ËŬÍѤµ¤ì¤ë¥Ñ¥é¥á¡¼¥¿¤Ë¤Ä¤¤¤Æ¤Ï¡¢²¼µ­¤Î¡Ö¥ª¥×¥·¥ç¥ó¡×¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£
  110.42 -.LP
  110.43 -.RS 3
  110.44 -.TP 3
  110.45 -sourcefiles 
  110.46 -¥¼¥í¡¢1 ¤Ä¡¢¤Þ¤¿¤ÏÊ£¿ô¤Î½èÍýÂоݤΥ½¡¼¥¹¥Õ¥¡¥¤¥ë 
  110.47 -.TP 3
  110.48 -@files 
  110.49 -¥½¡¼¥¹¥Õ¥¡¥¤¥ë¤Þ¤¿¤Ï¾¤Î¥ª¥×¥·¥ç¥ó¤ò°ìÍ÷ɽ¼¨¤¹¤ë 1 ¤Ä¤Þ¤¿¤ÏÊ£¿ô¤Î¥Õ¥¡¥¤¥ë 
  110.50 -.RE
  110.51 -
  110.52 -.LP
  110.53 -.SH "ÀâÌÀ"
  110.54 -.LP
  110.55 -.LP
  110.56 -\f3Ãí\fP: \f2apt\fP ¥Ä¡¼¥ë¤È¡¢¥Ñ¥Ã¥±¡¼¥¸ \f2com.sun.mirror\fP ¤Ë´Þ¤Þ¤ì¤Æ¤¤¤ë¤½¤ì¤Ë´ØÏ¢¤·¤¿ API ¤Ï¡¢JDK 7 °Ê¹ßÈó¿ä¾©¤Ë¤Ê¤Ã¤Æ¤ª¤ê¡¢JDK ¤Î¼¡¤Î¥á¥¸¥ã¡¼¥ê¥ê¡¼¥¹¤Çºï½ü¤µ¤ì¤ëͽÄê¤Ç¤¹¡£\f2javac(1)\fP ¥Ä¡¼¥ë¤ÇÍøÍѲÄǽ¤Ê¥ª¥×¥·¥ç¥ó¤È¡¢¥Ñ¥Ã¥±¡¼¥¸ \f2javax.annotation.processing\fP ¤ª¤è¤Ó \f2javax.lang.model\fP ¤Ë´Þ¤Þ¤ì¤Æ¤¤¤ë API ¤ò»ÈÍѤ·¤Æ¡¢Ãí¼á¤ò½èÍý¤·¤Æ¤¯¤À¤µ¤¤¡£
  110.57 -.LP
  110.58 -.LP
  110.59 -Ãí¼á½èÍý¥Ä¡¼¥ë \f2apt\fP ¤Ï¡¢¥ê¥Õ¥ì¥¯¥È API ¤È¥µ¥Ý¡¼¥È¥¤¥ó¥Õ¥é¥¹¥È¥é¥¯¥Á¥ã¡¼¤«¤é¹½À®¤µ¤ì¡¢¥×¥í¥°¥é¥àÃí¼á¤ò½èÍý¤·¤Þ¤¹¡£\f2apt\fP ¥ê¥Õ¥ì¥¯¥È API ¤Ï¡¢ ¹½ÃÛ»þ¤Î¥½¡¼¥¹¥Ù¡¼¥¹¤Ç¡¢¥×¥í¥°¥é¥à¹½Â¤¤Ë´Ø¤¹¤ëÆɤ߼è¤êÀìÍѥӥ塼¤òÄ󶡤·¤Þ¤¹¡£¤³¤ì¤é¤Î¥ê¥Õ¥ì¥¯¥È API ¤Ï¡¢Áí¾Î¤òÄɲä·¤¿¸å¤Ë¡¢Java(TM) ¥×¥í¥°¥é¥ß¥ó¥°¸À¸ì¤Î·¿¥·¥¹¥Æ¥à¤òÀµ¤·¤¯¥â¥Ç¥ë²½¤¹¤ë¤è¤¦¤ËÀ߷פµ¤ì¤Æ¤¤¤Þ¤¹¡£ºÇ½é¤Ë¡¢\f2apt\fP ¤Ï¡¢¿·¤·¤¤¥½¡¼¥¹¥³¡¼¥É¤È¾¤Î¥Õ¥¡¥¤¥ë¤òºîÀ®¤¹¤ëÃí¼á¥×¥í¥»¥Ã¥µ¤ò¼Â¹Ô¤·¤Þ¤¹¡£¼¡¤Ë¡¢\f2apt\fP ¤Ï¡¢¸µ¤Î¥½¡¼¥¹¥Õ¥¡¥¤¥ë¤ÈÀ¸À®¤·¤¿¥½¡¼¥¹¥Õ¥¡¥¤¥ë¤ÎξÊý¤ò¥³¥ó¥Ñ¥¤¥ë¤¹¤ë¤¿¤á¡¢³«È¯¤¬³Ú¤Ë¤Ê¤ê¤Þ¤¹¡£¥Ä¡¼¥ë¤È¤Î¥¤¥ó¥¿¥Õ¥§¡¼¥¹¤Ë»ÈÍѤµ¤ì¤ë¥ê¥Õ¥ì¥¯¥È API ¤Ê¤É¤Î API ¤Ï¡¢\f2com.sun.mirror\fP ¤Î¥µ¥Ö¥Ñ¥Ã¥±¡¼¥¸¤Ç¤¹¡£
  110.60 -.LP
  110.61 -.LP
  110.62 -¥Ä¡¼¥ë¤Îµ¡Ç½¤Ë´Ø¤¹¤ë¾ÜºÙ¤È¡¢\f2apt\fP ¤ò»ÈÍѤ·¤¿³«È¯ÊýË¡¤Ë¤Ä¤¤¤Æ¤Ï¡¢
  110.63 -.na
  110.64 -\f4¡Öapt ÆþÌç¡×\fP @
  110.65 -.fi
  110.66 -http://java.sun.com/javase/6/docs/technotes/guides/apt/GettingStarted.html¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£
  110.67 -.LP
  110.68 -.SH "¥ª¥×¥·¥ç¥ó"
  110.69 -.LP
  110.70 -.SS 
  110.71 -apt ¸ÇÍ­¤Î¥ª¥×¥·¥ç¥ó
  110.72 -.LP
  110.73 -.RS 3
  110.74 -.TP 3
  110.75 -\-s dir 
  110.76 -¥×¥í¥»¥Ã¥µ¤ÎÀ¸À®¤¹¤ë¥½¡¼¥¹¥Õ¥¡¥¤¥ë¤òÃÖ¤¯¥Ç¥£¥ì¥¯¥È¥ê¥ë¡¼¥È¤ò»ØÄꤷ¤Þ¤¹¡£ ¥Õ¥¡¥¤¥ë¤Ï¡¢¥Ñ¥Ã¥±¡¼¥¸¤Î̾Á°¶õ´Ö¤Ë´ð¤Å¤¤¤Æ¥µ¥Ö¥Ç¥£¥ì¥¯¥È¥ê¤ËÃÖ¤«¤ì¤Þ¤¹¡£ 
  110.77 -.TP 3
  110.78 -\-nocompile 
  110.79 -¥½¡¼¥¹¥Õ¥¡¥¤¥ë¤ò¥¯¥é¥¹¥Õ¥¡¥¤¥ë¤Ë¥³¥ó¥Ñ¥¤¥ë¤·¤Þ¤»¤ó¡£ 
  110.80 -.TP 3
  110.81 -\-print 
  110.82 -»ØÄꤷ¤¿¥¿¥¤¥×¤Î¥Æ¥­¥¹¥Èɽ¸½¤ò½ÐÎϤ·¤Þ¤¹¡£ Ãí¼á½èÍý¤Þ¤¿¤Ï¥³¥ó¥Ñ¥¤¥ë¤Ï¹Ô¤¤¤Þ¤»¤ó¡£ 
  110.83 -.TP 3
  110.84 -\-A[key[=val]] 
  110.85 -Ãí¼á¥×¥í¥»¥Ã¥µ¤ØÅϤ¹¥ª¥×¥·¥ç¥ó¤Ç¤¹¡£ ¤³¤Î¥ª¥×¥·¥ç¥ó¤Ï¡¢\f2apt\fP ¤¬Ä¾Àܲò¼á¤¹¤ë¤Î¤Ç¤Ï¤Ê¤¯¡¢¤½¤ì¤¾¤ì¤Î¥×¥í¥»¥Ã¥µ¤Ë¤è¤Ã¤Æ»ÈÍѤǤ­¤ë¤è¤¦¤ËÊѤ¨¤é¤ì¤Þ¤¹¡£ 
  110.86 -.TP 3
  110.87 -\-factorypath path 
  110.88 -Ãí¼á¥×¥í¥»¥Ã¥µ¥Õ¥¡¥¯¥È¥ê¤ò¸¡º÷¤¹¤ë¾ì½ê¤ò»ØÄꤷ¤Þ¤¹¡£ ¤³¤Î¥ª¥×¥·¥ç¥ó¤ò»ÈÍѤ¹¤ë¾ì¹ç¡¢¥¯¥é¥¹¥Ñ¥¹¤Î¥Õ¥¡¥¯¥È¥ê¤Ï¸¡º÷¤µ¤ì¤Þ¤»¤ó¡£ 
  110.89 -.TP 3
  110.90 -\-factory classname 
  110.91 -»ÈÍѤ¹¤ëÃí¼á¥×¥í¥»¥Ã¥µ¥Õ¥¡¥¯¥È¥ê¤Î̾Á°¤Ç¤¹¡£ ¥Ç¥Õ¥©¥ë¥È¤Î¸¡½Ð¥×¥í¥»¥¹¤ò¾Êά¤·¤Þ¤¹¡£ 
  110.92 -.TP 3
  110.93 -\-version 
  110.94 -¥Ð¡¼¥¸¥ç¥ó¾ðÊó¤ò½ÐÎϤ·¤Þ¤¹¡£ 
  110.95 -.TP 3
  110.96 -\-X 
  110.97 -Èóɸ½à¥ª¥×¥·¥ç¥ó¤Ë´Ø¤¹¤ë¾ðÊó¤òɽ¼¨¤·¤Þ¤¹¡£ 
  110.98 -.RE
  110.99 -
 110.100 -.LP
 110.101 -.SS 
 110.102 -javac ¤È¶¦ÍѤ¹¤ë¥ª¥×¥·¥ç¥ó
 110.103 -.LP
 110.104 -.RS 3
 110.105 -.TP 3
 110.106 -\-d dir 
 110.107 -¥×¥í¥»¥Ã¥µ¤È javac À¸À®¤Î¥¯¥é¥¹¥Õ¥¡¥¤¥ë¤òÃÖ¤¯¾ì½ê¤ò»ØÄꤷ¤Þ¤¹¡£ 
 110.108 -.TP 3
 110.109 -\-cp path ¤Þ¤¿¤Ï \-classpath path 
 110.110 -¥æ¡¼¥¶¡¼¥¯¥é¥¹¥Õ¥¡¥¤¥ë¤ÈÃí¼á¥×¥í¥»¥Ã¥µ¥Õ¥¡¥¯¥È¥ê¤ò¸¡º÷¤¹¤ë¾ì½ê¤ò»ØÄꤷ¤Þ¤¹¡£\f2\-factorypath\fP ¤¬»ØÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¡¢¥¯¥é¥¹¥Ñ¥¹¤Î¥Õ¥¡¥¯¥È¥ê¤Ï¸¡º÷¤µ¤ì¤Þ¤»¤ó¡£ 
 110.111 -.RE
 110.112 -
 110.113 -.LP
 110.114 -.LP
 110.115 -\f2javac\fP ¥ª¥×¥·¥ç¥ó¤Î¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï¡¢javac(1) ¤Î¥Þ¥Ë¥å¥¢¥ë¥Ú¡¼¥¸¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£
 110.116 -.LP
 110.117 -.SS 
 110.118 -Èóɸ½à¥ª¥×¥·¥ç¥ó
 110.119 -.LP
 110.120 -.RS 3
 110.121 -.TP 3
 110.122 -\-XListAnnotationTypes 
 110.123 -Ãí¼á¤Î·¿¤Ë¸¡½Ð¤µ¤ì¤ë¥ê¥¹¥È. 
 110.124 -.TP 3
 110.125 -\-XListDeclarations 
 110.126 -»ØÄꤪ¤è¤ÓÀë¸À¤¬¥¤¥ó¥¯¥ë¡¼¥É¤µ¤ì¤ë¥ê¥¹¥È. 
 110.127 -.TP 3
 110.128 -\-XPrintAptRounds 
 110.129 -½é´ü¤ª¤è¤ÓºÆµ¢Åª¤Ê \f2apt\fP ¥é¥¦¥ó¥É¤Ë´Ø¤¹¤ë¾ðÊó¤ò½ÐÎϤ¹¤ë. 
 110.130 -.TP 3
 110.131 -\-XPrintFactoryInfo 
 110.132 -½èÍý¤òÍ׵᤹¤ë¥Õ¥¡¥¯¥È¥ê¤ÎÃí¼á¤Ë´Ø¤¹¤ë¾ðÊó¤ò½ÐÎϤ¹¤ë. 
 110.133 -.TP 3
 110.134 -\-XclassesAsDecls 
 110.135 -¥¯¥é¥¹¥Õ¥¡¥¤¥ë¤È¥½¡¼¥¹¥Õ¥¡¥¤¥ë¤ÎξÊý¤ò¡¢½èÍýÂоݤÎÀë¸À¤È¤·¤Æ½èÍý¤·¤Þ¤¹¡£ 
 110.136 -.RE
 110.137 -
 110.138 -.LP
 110.139 -.LP
 110.140 -\f3Ãí\fP: ¤³¤ì¤é¤ÏÈóɸ½à¥ª¥×¥·¥ç¥ó¤Ê¤Î¤Ç¡¢Í½¹ð¤Ê¤¯Êѹ¹¤µ¤ì¤ë²ÄǽÀ­¤¬¤¢¤ê¤Þ¤¹¡£
 110.141 -.LP
 110.142 -.SH "Ãí"
 110.143 -.LP
 110.144 -.LP
 110.145 -\f2apt\fP ¥Ä¡¼¥ë¤È¡¢¥Ñ¥Ã¥±¡¼¥¸ \f2com.sun.mirror\fP ¤Ë´Þ¤Þ¤ì¤Æ¤¤¤ë¤½¤ì¤Ë´ØÏ¢¤·¤¿ API ¤Ï¡¢JDK 7 °Ê¹ßÈó¿ä¾©¤Ë¤Ê¤Ã¤Æ¤ª¤ê¡¢JDK ¤Î¼¡¤Î¥á¥¸¥ã¡¼¥ê¥ê¡¼¥¹¤Çºï½ü¤µ¤ì¤ëͽÄê¤Ç¤¹¡£\f2javac(1)\fP ¥Ä¡¼¥ë¤ÇÍøÍѲÄǽ¤Ê¥ª¥×¥·¥ç¥ó¤È¡¢¥Ñ¥Ã¥±¡¼¥¸ \f2javax.annotation.processing\fP ¤ª¤è¤Ó \f2javax.lang.model\fP ¤Ë´Þ¤Þ¤ì¤Æ¤¤¤ë API ¤ò»ÈÍѤ·¤Æ¡¢Ãí¼á¤ò½èÍý¤·¤Æ¤¯¤À¤µ¤¤¡£
 110.146 -.LP
 110.147 -.SH "´ØÏ¢¹àÌÜ"
 110.148 -.LP
 110.149 -.RS 3
 110.150 -.TP 2
 110.151 -o
 110.152 -javac(1), java(1) 
 110.153 -.RE
 110.154 -
 110.155 -.LP
 110.156 - 
   111.1 --- a/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c	Thu Feb 16 13:01:36 2012 -0800
   111.2 +++ b/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c	Sat Feb 18 16:11:47 2012 -0800
   111.3 @@ -171,6 +171,53 @@
   111.4      return array;
   111.5  }
   111.6  
   111.7 +/**
   111.8 + * Convert a GSList to an array of filenames (with the parent folder)
   111.9 + */
  111.10 +static jobjectArray toPathAndFilenamesArray(JNIEnv *env, GSList* list)
  111.11 +{
  111.12 +    jstring str;
  111.13 +    jclass stringCls;
  111.14 +    GSList *iterator;
  111.15 +    jobjectArray array;
  111.16 +    int i;
  111.17 +    char* entry;
  111.18 +
  111.19 +
  111.20 +    if (list == NULL) {
  111.21 +        return NULL;
  111.22 +    }
  111.23 +
  111.24 +    stringCls = (*env)->FindClass(env, "java/lang/String");
  111.25 +    if (stringCls == NULL) {
  111.26 +        JNU_ThrowInternalError(env, "Could not get java.lang.String class");
  111.27 +        return NULL;
  111.28 +    }
  111.29 +
  111.30 +    array = (*env)->NewObjectArray(env, fp_gtk_g_slist_length(list), stringCls,
  111.31 +            NULL);
  111.32 +    if (array == NULL) {
  111.33 +        JNU_ThrowInternalError(env, "Could not instantiate array files array");
  111.34 +        return NULL;
  111.35 +    }
  111.36 +
  111.37 +    i = 0;
  111.38 +    for (iterator = list; iterator; iterator = iterator->next) {
  111.39 +        entry = (char*) iterator->data;
  111.40 +
  111.41 +        //check for leading slash.
  111.42 +        if (entry[0] == '/') {
  111.43 +            entry++;
  111.44 +        }
  111.45 +
  111.46 +        str = (*env)->NewStringUTF(env, entry);
  111.47 +        (*env)->SetObjectArrayElement(env, array, i, str);
  111.48 +        i++;
  111.49 +    }
  111.50 +
  111.51 +    return array;
  111.52 +}
  111.53 +
  111.54  static void handle_response(GtkWidget* aDialog, gint responseId, gpointer obj)
  111.55  {
  111.56      JNIEnv *env;
  111.57 @@ -183,16 +230,25 @@
  111.58      env = (JNIEnv *) JNU_GetEnv(jvm, JNI_VERSION_1_2);
  111.59      current_folder = NULL;
  111.60      filenames = NULL;
  111.61 +    gboolean full_path_names = FALSE;
  111.62  
  111.63      if (responseId == GTK_RESPONSE_ACCEPT) {
  111.64          current_folder = fp_gtk_file_chooser_get_current_folder(
  111.65                  GTK_FILE_CHOOSER(aDialog));
  111.66 +        if (current_folder == NULL) {
  111.67 +            full_path_names = TRUE;
  111.68 +        }
  111.69          filenames = fp_gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(aDialog));
  111.70      }
  111.71 -
  111.72 -    jcurrent_folder = (*env)->NewStringUTF(env, current_folder);
  111.73 -    jfilenames = toFilenamesArray(env, filenames);
  111.74 -
  111.75 +    if (full_path_names) {
  111.76 +        //This is a hack for use with "Recent Folders" in gtk where each
  111.77 +        //file could have its own directory.
  111.78 +        jcurrent_folder = (*env)->NewStringUTF(env, "/");
  111.79 +        jfilenames = toPathAndFilenamesArray(env, filenames);
  111.80 +    } else {
  111.81 +        jcurrent_folder = (*env)->NewStringUTF(env, current_folder);
  111.82 +        jfilenames = toFilenamesArray(env, filenames);
  111.83 +    }
  111.84      (*env)->CallVoidMethod(env, obj, setFileInternalMethodID, jcurrent_folder,
  111.85              jfilenames);
  111.86      fp_g_free(current_folder);
   112.1 --- a/src/solaris/native/sun/nio/ch/Sctp.h	Thu Feb 16 13:01:36 2012 -0800
   112.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   112.3 @@ -1,334 +0,0 @@
   112.4 -/*
   112.5 - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
   112.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   112.7 - *
   112.8 - * This code is free software; you can redistribute it and/or modify it
   112.9 - * under the terms of the GNU General Public License version 2 only, as
  112.10 - * published by the Free Software Foundation.  Oracle designates this
  112.11 - * particular file as subject to the "Classpath" exception as provided
  112.12 - * by Oracle in the LICENSE file that accompanied this code.
  112.13 - *
  112.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
  112.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  112.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  112.17 - * version 2 for more details (a copy is included in the LICENSE file that
  112.18 - * accompanied this code).
  112.19 - *
  112.20 - * You should have received a copy of the GNU General Public License version
  112.21 - * 2 along with this work; if not, write to the Free Software Foundation,
  112.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  112.23 - *
  112.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  112.25 - * or visit www.oracle.com if you need additional information or have any
  112.26 - * questions.
  112.27 - */
  112.28 -
  112.29 -#ifndef SUN_NIO_CH_SCTP_H
  112.30 -#define SUN_NIO_CH_SCTP_H
  112.31 -
  112.32 -#ifdef __solaris__
  112.33 -
  112.34 -#define _XPG4_2
  112.35 -#define __EXTENSIONS__
  112.36 -#include <sys/socket.h>
  112.37 -#include <netinet/sctp.h>
  112.38 -#include "jni.h"
  112.39 -
  112.40 -/* Current Solaris headers don't comply with draft rfc */
  112.41 -#ifndef SCTP_EOF
  112.42 -#define SCTP_EOF MSG_EOF
  112.43 -#endif
  112.44 -
  112.45 -#ifndef SCTP_UNORDERED
  112.46 -#define SCTP_UNORDERED MSG_UNORDERED
  112.47 -#endif
  112.48 -
  112.49 -/* The current version of the socket API extension shipped with Solaris does
  112.50 - * not define the following options that the Java API (optionally) supports */
  112.51 -#ifndef SCTP_EXPLICIT_EOR
  112.52 -#define SCTP_EXPLICIT_EOR -1
  112.53 -#endif
  112.54 -#ifndef SCTP_FRAGMENT_INTERLEAVE
  112.55 -#define SCTP_FRAGMENT_INTERLEAVE -1
  112.56 -#endif
  112.57 -#ifndef SCTP_SET_PEER_PRIMARY_ADDR
  112.58 -#define SCTP_SET_PEER_PRIMARY_ADDR -1
  112.59 -#endif
  112.60 -
  112.61 -/* Function types to support dynamic linking of socket API extension functions
  112.62 - * for SCTP. This is so that there is no linkage depandancy during build or
  112.63 - * runtime for libsctp.*/
  112.64 -typedef int sctp_getladdrs_func(int sock, sctp_assoc_t id, void **addrs);
  112.65 -typedef int sctp_freeladdrs_func(void* addrs);
  112.66 -typedef int sctp_getpaddrs_func(int sock, sctp_assoc_t id, void **addrs);
  112.67 -typedef int sctp_freepaddrs_func(void *addrs);
  112.68 -typedef int sctp_bindx_func(int sock, void *addrs, int addrcnt, int flags);
  112.69 -typedef int sctp_peeloff_func(int sock, sctp_assoc_t id);
  112.70 -
  112.71 -
  112.72 -
  112.73 -#else /* __linux__ */
  112.74 -#include <stdint.h>
  112.75 -#include <linux/types.h>
  112.76 -#include <sys/socket.h>
  112.77 -#include <netinet/in.h>
  112.78 -#include "jni.h"
  112.79 -
  112.80 -//Causes compiler error if not found, should make warning and uncomment
  112.81 -/*#include <netinet/sctp.h>*/
  112.82 -
  112.83 -#ifndef IPPROTO_SCTP
  112.84 -#define IPPROTO_SCTP    132
  112.85 -#endif
  112.86 -
  112.87 -/* The current version of lksctp does
  112.88 - * not define the following option that the Java API (optionally) supports */
  112.89 -#ifndef SCTP_EXPLICIT_EOR
  112.90 -#define SCTP_EXPLICIT_EOR -1
  112.91 -#endif
  112.92 -
  112.93 -/* Definitions taken from lksctp-tools-1.0.8/src/include/netinet/sctp.h */
  112.94 -#ifndef SCTP_INITMSG
  112.95 -
  112.96 -enum sctp_optname {
  112.97 -        SCTP_RTOINFO,
  112.98 -#define SCTP_RTOINFO SCTP_RTOINFO
  112.99 -        SCTP_ASSOCINFO,
 112.100 -#define SCTP_ASSOCINFO SCTP_ASSOCINFO
 112.101 -        SCTP_INITMSG,
 112.102 -#define SCTP_INITMSG SCTP_INITMSG
 112.103 -        SCTP_NODELAY,   /* Get/set nodelay option. */
 112.104 -#define SCTP_NODELAY    SCTP_NODELAY
 112.105 -        SCTP_AUTOCLOSE,
 112.106 -#define SCTP_AUTOCLOSE SCTP_AUTOCLOSE
 112.107 -        SCTP_SET_PEER_PRIMARY_ADDR,
 112.108 -#define SCTP_SET_PEER_PRIMARY_ADDR SCTP_SET_PEER_PRIMARY_ADDR
 112.109 -        SCTP_PRIMARY_ADDR,
 112.110 -#define SCTP_PRIMARY_ADDR SCTP_PRIMARY_ADDR
 112.111 -        SCTP_ADAPTATION_LAYER,
 112.112 -#define SCTP_ADAPTATION_LAYER SCTP_ADAPTATION_LAYER
 112.113 -        SCTP_DISABLE_FRAGMENTS,
 112.114 -#define SCTP_DISABLE_FRAGMENTS SCTP_DISABLE_FRAGMENTS
 112.115 -        SCTP_PEER_ADDR_PARAMS,
 112.116 -#define SCTP_PEER_ADDR_PARAMS SCTP_PEER_ADDR_PARAMS
 112.117 -        SCTP_DEFAULT_SEND_PARAM,
 112.118 -#define SCTP_DEFAULT_SEND_PARAM SCTP_DEFAULT_SEND_PARAM
 112.119 -        SCTP_EVENTS,
 112.120 -#define SCTP_EVENTS SCTP_EVENTS
 112.121 -        SCTP_I_WANT_MAPPED_V4_ADDR,  /* Turn on/off mapped v4 addresses  */
 112.122 -#define SCTP_I_WANT_MAPPED_V4_ADDR SCTP_I_WANT_MAPPED_V4_ADDR
 112.123 -        SCTP_MAXSEG,    /* Get/set maximum fragment. */
 112.124 -#define SCTP_MAXSEG     SCTP_MAXSEG
 112.125 -        SCTP_STATUS,
 112.126 -#define SCTP_STATUS SCTP_STATUS
 112.127 -        SCTP_GET_PEER_ADDR_INFO,
 112.128 -#define SCTP_GET_PEER_ADDR_INFO SCTP_GET_PEER_ADDR_INFO
 112.129 -        SCTP_DELAYED_ACK_TIME,
 112.130 -#define SCTP_DELAYED_ACK_TIME SCTP_DELAYED_ACK_TIME
 112.131 -        SCTP_CONTEXT,   /* Receive Context */
 112.132 -#define SCTP_CONTEXT SCTP_CONTEXT
 112.133 -        SCTP_FRAGMENT_INTERLEAVE,
 112.134 -#define SCTP_FRAGMENT_INTERLEAVE SCTP_FRAGMENT_INTERLEAVE
 112.135 -        SCTP_PARTIAL_DELIVERY_POINT,    /* Set/Get partial delivery point */
 112.136 -#define SCTP_PARTIAL_DELIVERY_POINT SCTP_PARTIAL_DELIVERY_POINT
 112.137 -        SCTP_MAX_BURST,         /* Set/Get max burst */
 112.138 -#define SCTP_MAX_BURST SCTP_MAX_BURST
 112.139 -};
 112.140 -
 112.141 -enum sctp_sac_state {
 112.142 -        SCTP_COMM_UP,
 112.143 -        SCTP_COMM_LOST,
 112.144 -        SCTP_RESTART,
 112.145 -        SCTP_SHUTDOWN_COMP,
 112.146 -        SCTP_CANT_STR_ASSOC,
 112.147 -};
 112.148 -
 112.149 -enum sctp_spc_state {
 112.150 -        SCTP_ADDR_AVAILABLE,
 112.151 -        SCTP_ADDR_UNREACHABLE,
 112.152 -        SCTP_ADDR_REMOVED,
 112.153 -        SCTP_ADDR_ADDED,
 112.154 -        SCTP_ADDR_MADE_PRIM,
 112.155 -        SCTP_ADDR_CONFIRMED,
 112.156 -};
 112.157 -
 112.158 -enum sctp_sinfo_flags {
 112.159 -        SCTP_UNORDERED = 1,  /* Send/receive message unordered. */
 112.160 -        SCTP_ADDR_OVER = 2,  /* Override the primary destination. */
 112.161 -        SCTP_ABORT=4,        /* Send an ABORT message to the peer. */
 112.162 -        SCTP_EOF=MSG_FIN,    /* Initiate graceful shutdown process. */
 112.163 -};
 112.164 -
 112.165 -enum sctp_sn_type {
 112.166 -        SCTP_SN_TYPE_BASE     = (1<<15),
 112.167 -        SCTP_ASSOC_CHANGE,
 112.168 -        SCTP_PEER_ADDR_CHANGE,
 112.169 -        SCTP_SEND_FAILED,
 112.170 -        SCTP_REMOTE_ERROR,
 112.171 -        SCTP_SHUTDOWN_EVENT,
 112.172 -        SCTP_PARTIAL_DELIVERY_EVENT,
 112.173 -        SCTP_ADAPTATION_INDICATION,
 112.174 -};
 112.175 -
 112.176 -typedef enum sctp_cmsg_type {
 112.177 -        SCTP_INIT,              /* 5.2.1 SCTP Initiation Structure */
 112.178 -#define SCTP_INIT SCTP_INIT
 112.179 -        SCTP_SNDRCV,            /* 5.2.2 SCTP Header Information Structure */
 112.180 -#define SCTP_SNDRCV SCTP_SNDRCV
 112.181 -} sctp_cmsg_t;
 112.182 -
 112.183 -enum sctp_msg_flags {
 112.184 -        MSG_NOTIFICATION = 0x8000,
 112.185 -#define MSG_NOTIFICATION MSG_NOTIFICATION
 112.186 -};
 112.187 -
 112.188 -#define SCTP_BINDX_ADD_ADDR 0x01
 112.189 -#define SCTP_BINDX_REM_ADDR 0x02
 112.190 -
 112.191 -typedef __s32 sctp_assoc_t;
 112.192 -
 112.193 -struct sctp_initmsg {
 112.194 -        __u16 sinit_num_ostreams;
 112.195 -        __u16 sinit_max_instreams;
 112.196 -        __u16 sinit_max_attempts;
 112.197 -        __u16 sinit_max_init_timeo;
 112.198 -};
 112.199 -
 112.200 -struct sctp_sndrcvinfo {
 112.201 -        __u16 sinfo_stream;
 112.202 -        __u16 sinfo_ssn;
 112.203 -        __u16 sinfo_flags;
 112.204 -        __u32 sinfo_ppid;
 112.205 -        __u32 sinfo_context;
 112.206 -        __u32 sinfo_timetolive;
 112.207 -        __u32 sinfo_tsn;
 112.208 -        __u32 sinfo_cumtsn;
 112.209 -        sctp_assoc_t sinfo_assoc_id;
 112.210 -};
 112.211 -
 112.212 -struct sctp_event_subscribe {
 112.213 -        __u8 sctp_data_io_event;
 112.214 -        __u8 sctp_association_event;
 112.215 -        __u8 sctp_address_event;
 112.216 -        __u8 sctp_send_failure_event;
 112.217 -        __u8 sctp_peer_error_event;
 112.218 -        __u8 sctp_shutdown_event;
 112.219 -        __u8 sctp_partial_delivery_event;
 112.220 -        __u8 sctp_adaptation_layer_event;
 112.221 -};
 112.222 -
 112.223 -struct sctp_send_failed {
 112.224 -        __u16 ssf_type;
 112.225 -        __u16 ssf_flags;
 112.226 -        __u32 ssf_length;
 112.227 -        __u32 ssf_error;
 112.228 -        struct sctp_sndrcvinfo ssf_info;
 112.229 -        sctp_assoc_t ssf_assoc_id;
 112.230 -        __u8 ssf_data[0];
 112.231 -};
 112.232 -
 112.233 -struct sctp_assoc_change {
 112.234 -        __u16 sac_type;
 112.235 -        __u16 sac_flags;
 112.236 -        __u32 sac_length;
 112.237 -        __u16 sac_state;
 112.238 -        __u16 sac_error;
 112.239 -        __u16 sac_outbound_streams;
 112.240 -        __u16 sac_inbound_streams;
 112.241 -        sctp_assoc_t sac_assoc_id;
 112.242 -        __u8 sac_info[0];
 112.243 -};
 112.244 -
 112.245 -struct sctp_shutdown_event {
 112.246 -        __u16 sse_type;
 112.247 -        __u16 sse_flags;
 112.248 -        __u32 sse_length;
 112.249 -        sctp_assoc_t sse_assoc_id;
 112.250 -};
 112.251 -
 112.252 -struct sctp_paddr_change {
 112.253 -        __u16 spc_type;
 112.254 -        __u16 spc_flags;
 112.255 -        __u32 spc_length;
 112.256 -        struct sockaddr_storage spc_aaddr;
 112.257 -        int spc_state;
 112.258 -        int spc_error;
 112.259 -        sctp_assoc_t spc_assoc_id;
 112.260 -} __attribute__((packed, aligned(4)));
 112.261 -
 112.262 -struct sctp_remote_error {
 112.263 -        __u16 sre_type;
 112.264 -        __u16 sre_flags;
 112.265 -        __u32 sre_length;
 112.266 -        __u16 sre_error;
 112.267 -        sctp_assoc_t sre_assoc_id;
 112.268 -        __u8 sre_data[0];
 112.269 -};
 112.270 -
 112.271 -struct sctp_adaptation_event {
 112.272 -        __u16 sai_type;
 112.273 -        __u16 sai_flags;
 112.274 -        __u32 sai_length;
 112.275 -        __u32 sai_adaptation_ind;
 112.276 -        sctp_assoc_t sai_assoc_id;
 112.277 -};
 112.278 -
 112.279 -struct sctp_setprim {
 112.280 -        sctp_assoc_t            ssp_assoc_id;
 112.281 -        struct sockaddr_storage ssp_addr;
 112.282 -} __attribute__((packed, aligned(4)));
 112.283 -
 112.284 -struct sctp_setpeerprim {
 112.285 -        sctp_assoc_t            sspp_assoc_id;
 112.286 -        struct sockaddr_storage sspp_addr;
 112.287 -} __attribute__((packed, aligned(4)));
 112.288 -
 112.289 -
 112.290 -struct sctp_pdapi_event {
 112.291 -        __u16 pdapi_type;
 112.292 -        __u16 pdapi_flags;
 112.293 -        __u32 pdapi_length;
 112.294 -        __u32 pdapi_indication;
 112.295 -        sctp_assoc_t pdapi_assoc_id;
 112.296 -};
 112.297 -
 112.298 -union sctp_notification {
 112.299 -        struct {
 112.300 -                __u16 sn_type;             /* Notification type. */
 112.301 -                __u16 sn_flags;
 112.302 -                __u32 sn_length;
 112.303 -        } sn_header;
 112.304 -        struct sctp_assoc_change sn_assoc_change;
 112.305 -        struct sctp_paddr_change sn_paddr_change;
 112.306 -        struct sctp_remote_error sn_remote_error;
 112.307 -        struct sctp_send_failed sn_send_failed;
 112.308 -        struct sctp_shutdown_event sn_shutdown_event;
 112.309 -        struct sctp_adaptation_event sn_adaptation_event;
 112.310 -        struct sctp_pdapi_event sn_pdapi_event;
 112.311 -};
 112.312 -
 112.313 -#endif /* SCTP_INITMSG */
 112.314 -
 112.315 -/* Function types to support dynamic linking of socket API extension functions
 112.316 - * for SCTP. This is so that there is no linkage depandancy during build or
 112.317 - * runtime for libsctp.*/
 112.318 -typedef int sctp_getladdrs_func(int sd, sctp_assoc_t id, struct sockaddr **addrs);
 112.319 -typedef int sctp_freeladdrs_func(struct sockaddr *addrs);
 112.320 -typedef int sctp_getpaddrs_func(int sd, sctp_assoc_t id, struct sockaddr **addrs);
 112.321 -typedef int sctp_freepaddrs_func(struct sockaddr *addrs);
 112.322 -typedef int sctp_bindx_func(int sd, struct sockaddr *addrs, int addrcnt, int flags);
 112.323 -typedef int sctp_peeloff_func(int sock, sctp_assoc_t id);
 112.324 -
 112.325 -
 112.326 -#endif /* __linux__ */
 112.327 -
 112.328 -sctp_getladdrs_func* nio_sctp_getladdrs;
 112.329 -sctp_freeladdrs_func* nio_sctp_freeladdrs;
 112.330 -sctp_getpaddrs_func* nio_sctp_getpaddrs;
 112.331 -sctp_freepaddrs_func* nio_sctp_freepaddrs;
 112.332 -sctp_bindx_func* nio_sctp_bindx;
 112.333 -sctp_peeloff_func* nio_sctp_peeloff;
 112.334 -
 112.335 -jboolean loadSocketExtensionFuncs(JNIEnv* env);
 112.336 -
 112.337 -#endif /* !SUN_NIO_CH_SCTP_H */
   113.1 --- a/src/solaris/native/sun/nio/ch/SctpChannelImpl.c	Thu Feb 16 13:01:36 2012 -0800
   113.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   113.3 @@ -1,594 +0,0 @@
   113.4 -/*
   113.5 - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
   113.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   113.7 - *
   113.8 - * This code is free software; you can redistribute it and/or modify it
   113.9 - * under the terms of the GNU General Public License version 2 only, as
  113.10 - * published by the Free Software Foundation.  Oracle designates this
  113.11 - * particular file as subject to the "Classpath" exception as provided
  113.12 - * by Oracle in the LICENSE file that accompanied this code.
  113.13 - *
  113.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
  113.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  113.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  113.17 - * version 2 for more details (a copy is included in the LICENSE file that
  113.18 - * accompanied this code).
  113.19 - *
  113.20 - * You should have received a copy of the GNU General Public License version
  113.21 - * 2 along with this work; if not, write to the Free Software Foundation,
  113.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  113.23 - *
  113.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  113.25 - * or visit www.oracle.com if you need additional information or have any
  113.26 - * questions.
  113.27 - */
  113.28 -
  113.29 -#include <stdlib.h>
  113.30 -#include <string.h>
  113.31 -#include "Sctp.h"
  113.32 -
  113.33 -#include "jni.h"
  113.34 -#include "nio_util.h"
  113.35 -#include "nio.h"
  113.36 -#include "net_util.h"
  113.37 -#include "net_util_md.h"
  113.38 -#include "sun_nio_ch_SctpNet.h"
  113.39 -#include "sun_nio_ch_SctpChannelImpl.h"
  113.40 -#include "sun_nio_ch_SctpAssocChange.h"
  113.41 -#include "sun_nio_ch_SctpResultContainer.h"
  113.42 -#include "sun_nio_ch_SctpPeerAddrChange.h"
  113.43 -
  113.44 -/* sizeof(union sctp_notification */
  113.45 -#define NOTIFICATION_BUFFER_SIZE 280
  113.46 -
  113.47 -#define MESSAGE_IMPL_CLASS              "sun/nio/ch/SctpMessageInfoImpl"
  113.48 -#define RESULT_CONTAINER_CLASS          "sun/nio/ch/SctpResultContainer"
  113.49 -#define SEND_FAILED_CLASS               "sun/nio/ch/SctpSendFailed"
  113.50 -#define ASSOC_CHANGE_CLASS              "sun/nio/ch/SctpAssocChange"
  113.51 -#define PEER_CHANGE_CLASS               "sun/nio/ch/SctpPeerAddrChange"
  113.52 -#define SHUTDOWN_CLASS                  "sun/nio/ch/SctpShutdown"
  113.53 -
  113.54 -struct controlData {
  113.55 -    int assocId;
  113.56 -    unsigned short streamNumber;
  113.57 -    jboolean unordered;
  113.58 -    unsigned int ppid;
  113.59 -};
  113.60 -
  113.61 -static jclass    smi_class;    /* sun.nio.ch.SctpMessageInfoImpl            */
  113.62 -static jmethodID smi_ctrID;    /* sun.nio.ch.SctpMessageInfoImpl.<init>     */
  113.63 -static jfieldID  src_valueID;  /* sun.nio.ch.SctpResultContainer.value      */
  113.64 -static jfieldID  src_typeID;   /* sun.nio.ch.SctpResultContainer.type       */
  113.65 -static jclass    ssf_class;    /* sun.nio.ch.SctpSendFailed                 */
  113.66 -static jmethodID ssf_ctrID;    /* sun.nio.ch.SctpSendFailed.<init>          */
  113.67 -static jclass    sac_class;    /* sun.nio.ch.SctpAssociationChanged         */
  113.68 -static jmethodID sac_ctrID;    /* sun.nio.ch.SctpAssociationChanged.<init>  */
  113.69 -static jclass    spc_class;    /* sun.nio.ch.SctpPeerAddressChanged         */
  113.70 -static jmethodID spc_ctrID;    /* sun.nio.ch.SctpPeerAddressChanged.<init>  */
  113.71 -static jclass    ss_class;     /* sun.nio.ch.SctpShutdown                   */
  113.72 -static jmethodID ss_ctrID;     /* sun.nio.ch.SctpShutdown.<init>            */
  113.73 -static jfieldID  isa_addrID;   /* java.net.InetSocketAddress.addr           */
  113.74 -static jfieldID  isa_portID;   /* java.net.InetSocketAddress.port           */
  113.75 -
  113.76 -/* defined in SctpNet.c */
  113.77 -jobject SockAddrToInetSocketAddress(JNIEnv* env, struct sockaddr* addr);
  113.78 -
  113.79 -/* use SocketChannelImpl's checkConnect implementation */
  113.80 -extern jint Java_sun_nio_ch_SocketChannelImpl_checkConnect(JNIEnv* env,
  113.81 -    jobject this, jobject fdo, jboolean block, jboolean ready);
  113.82 -
  113.83 -/*
  113.84 - * Class:     sun_nio_ch_SctpChannelImpl
  113.85 - * Method:    initIDs
  113.86 - * Signature: ()V
  113.87 - */
  113.88 -JNIEXPORT void JNICALL Java_sun_nio_ch_SctpChannelImpl_initIDs
  113.89 -  (JNIEnv *env, jclass klass) {
  113.90 -    jclass cls;
  113.91 -
  113.92 -    /* SctpMessageInfoImpl */
  113.93 -    cls = (*env)->FindClass(env, MESSAGE_IMPL_CLASS);
  113.94 -    CHECK_NULL(cls);
  113.95 -    smi_class = (*env)->NewGlobalRef(env, cls);
  113.96 -    CHECK_NULL(smi_class);
  113.97 -    smi_ctrID = (*env)->GetMethodID(env, cls, "<init>",
  113.98 -            "(ILjava/net/SocketAddress;IIZZI)V");
  113.99 -    CHECK_NULL(smi_ctrID);
 113.100 -
 113.101 -    /* SctpResultContainer */
 113.102 -    cls = (*env)->FindClass(env, RESULT_CONTAINER_CLASS);
 113.103 -    CHECK_NULL(cls);
 113.104 -    src_valueID = (*env)->GetFieldID(env, cls, "value", "Ljava/lang/Object;");
 113.105 -    CHECK_NULL(src_valueID);
 113.106 -    src_typeID = (*env)->GetFieldID(env, cls, "type", "I");
 113.107 -    CHECK_NULL(src_typeID);
 113.108 -
 113.109 -    /* SctpSendFailed */
 113.110 -    cls = (*env)->FindClass(env, SEND_FAILED_CLASS);
 113.111 -    CHECK_NULL(cls);
 113.112 -    ssf_class = (*env)->NewGlobalRef(env, cls);
 113.113 -    CHECK_NULL(ssf_class);
 113.114 -    ssf_ctrID = (*env)->GetMethodID(env, cls, "<init>",
 113.115 -        "(ILjava/net/SocketAddress;Ljava/nio/ByteBuffer;II)V");
 113.116 -    CHECK_NULL(ssf_ctrID);
 113.117 -
 113.118 -    /* SctpAssocChange */
 113.119 -    cls = (*env)->FindClass(env, ASSOC_CHANGE_CLASS);
 113.120 -    CHECK_NULL(cls);
 113.121 -    sac_class = (*env)->NewGlobalRef(env, cls);
 113.122 -    CHECK_NULL(sac_class);
 113.123 -    sac_ctrID = (*env)->GetMethodID(env, cls, "<init>", "(IIII)V");
 113.124 -    CHECK_NULL(sac_ctrID);
 113.125 -
 113.126 -    /* SctpPeerAddrChange */
 113.127 -    cls = (*env)->FindClass(env, PEER_CHANGE_CLASS);
 113.128 -    CHECK_NULL(cls);
 113.129 -    spc_class = (*env)->NewGlobalRef(env, cls);
 113.130 -    CHECK_NULL(spc_class);
 113.131 -    spc_ctrID = (*env)->GetMethodID(env, cls, "<init>",
 113.132 -            "(ILjava/net/SocketAddress;I)V");
 113.133 -    CHECK_NULL(spc_ctrID);
 113.134 -
 113.135 -    /* sun.nio.ch.SctpShutdown */
 113.136 -    cls = (*env)->FindClass(env, SHUTDOWN_CLASS);
 113.137 -    CHECK_NULL(cls);
 113.138 -    ss_class = (*env)->NewGlobalRef(env, cls);
 113.139 -    CHECK_NULL(ss_class);
 113.140 -    ss_ctrID = (*env)->GetMethodID(env, cls, "<init>", "(I)V");
 113.141 -    CHECK_NULL(ss_ctrID);
 113.142 -
 113.143 -    /* InetSocketAddress */
 113.144 -    cls = (*env)->FindClass(env, "java/net/InetSocketAddress");
 113.145 -    CHECK_NULL(cls);
 113.146 -    isa_addrID = (*env)->GetFieldID(env, cls, "addr", "Ljava/net/InetAddress;");
 113.147 -    CHECK_NULL(isa_addrID);
 113.148 -    isa_portID = (*env)->GetFieldID(env, cls, "port", "I");
 113.149 -}
 113.150 -
 113.151 -void getControlData
 113.152 -  (struct msghdr* msg, struct controlData* cdata) {
 113.153 -    struct cmsghdr* cmsg;
 113.154 -
 113.155 -    for (cmsg = CMSG_FIRSTHDR(msg); cmsg != NULL; cmsg = CMSG_NXTHDR(msg, cmsg)) {
 113.156 -        if (cmsg->cmsg_level == IPPROTO_SCTP && cmsg->cmsg_type == SCTP_SNDRCV) {
 113.157 -            struct sctp_sndrcvinfo *sri;
 113.158 -
 113.159 -            sri = (struct sctp_sndrcvinfo *) CMSG_DATA(cmsg);
 113.160 -            cdata->assocId = sri->sinfo_assoc_id;
 113.161 -            cdata->streamNumber = sri->sinfo_stream;
 113.162 -            cdata->unordered = (sri->sinfo_flags & SCTP_UNORDERED) ? JNI_TRUE :
 113.163 -                JNI_FALSE;
 113.164 -            cdata->ppid = ntohl(sri->sinfo_ppid);
 113.165 -
 113.166 -            return;
 113.167 -        }
 113.168 -    }
 113.169 -    return;
 113.170 -}
 113.171 -
 113.172 -void setControlData
 113.173 -  (struct msghdr* msg, struct controlData* cdata) {
 113.174 -    struct cmsghdr* cmsg;
 113.175 -    struct sctp_sndrcvinfo *sri;
 113.176 -
 113.177 -    cmsg = CMSG_FIRSTHDR(msg);
 113.178 -    cmsg->cmsg_level = IPPROTO_SCTP;
 113.179 -    cmsg->cmsg_type = SCTP_SNDRCV;
 113.180 -    cmsg->cmsg_len = CMSG_LEN(sizeof(struct sctp_sndrcvinfo));
 113.181 -
 113.182 -    /* Initialize the payload */
 113.183 -    sri = (struct sctp_sndrcvinfo*) CMSG_DATA(cmsg);
 113.184 -    memset(sri, 0, sizeof (*sri));
 113.185 -
 113.186 -    if (cdata->streamNumber > 0) {
 113.187 -        sri->sinfo_stream = cdata->streamNumber;
 113.188 -    }
 113.189 -    if (cdata->assocId > 0) {
 113.190 -        sri->sinfo_assoc_id = cdata->assocId;
 113.191 -    }
 113.192 -    if (cdata->unordered == JNI_TRUE) {
 113.193 -        sri->sinfo_flags = sri->sinfo_flags | SCTP_UNORDERED;
 113.194 -    }
 113.195 -
 113.196 -    if (cdata->ppid > 0) {
 113.197 -        sri->sinfo_ppid = htonl(cdata->ppid);
 113.198 -    }
 113.199 -
 113.200 -    /* Sum of the length of all control messages in the buffer. */
 113.201 -    msg->msg_controllen = cmsg->cmsg_len;
 113.202 -}
 113.203 -
 113.204 -// TODO: test: can create send failed without any data? if so need to
 113.205 -// update API so that buffer can be null if no data.
 113.206 -void handleSendFailed
 113.207 -  (JNIEnv* env, int fd, jobject resultContainerObj, struct sctp_send_failed *ssf,
 113.208 -   int read, jboolean isEOR, struct sockaddr* sap) {
 113.209 -    jobject bufferObj = NULL, resultObj, isaObj;
 113.210 -    char *addressP;
 113.211 -    struct sctp_sndrcvinfo *sri;
 113.212 -    int remaining, dataLength;
 113.213 -
 113.214 -    /* the actual undelivered message data is directly after the ssf */
 113.215 -    int dataOffset = sizeof(struct sctp_send_failed);
 113.216 -
 113.217 -    sri = (struct sctp_sndrcvinfo*) &ssf->ssf_info;
 113.218 -
 113.219 -    /* the number of bytes remaining to be read in the sctp_send_failed notif*/
 113.220 -    remaining = ssf->ssf_length - read;
 113.221 -
 113.222 -    /* the size of the actual undelivered message */
 113.223 -    dataLength = ssf->ssf_length - dataOffset;
 113.224 -
 113.225 -    /* retrieved address from sockaddr */
 113.226 -    isaObj = SockAddrToInetSocketAddress(env, sap);
 113.227 -
 113.228 -    /* data retrieved from sff_data */
 113.229 -    if (dataLength > 0) {
 113.230 -        struct iovec iov[1];
 113.231 -        struct msghdr msg[1];
 113.232 -        int rv, alreadyRead;
 113.233 -        char *dataP = (char*) ssf;
 113.234 -        dataP += dataOffset;
 113.235 -
 113.236 -        if ((addressP = malloc(dataLength)) == NULL) {
 113.237 -            JNU_ThrowOutOfMemoryError(env, "handleSendFailed");
 113.238 -            return;
 113.239 -        }
 113.240 -
 113.241 -        memset(msg, 0, sizeof (*msg));
 113.242 -        msg->msg_iov = iov;
 113.243 -        msg->msg_iovlen = 1;
 113.244 -
 113.245 -        bufferObj = (*env)->NewDirectByteBuffer(env, addressP, dataLength);
 113.246 -        CHECK_NULL(bufferObj);
 113.247 -
 113.248 -        alreadyRead = read - dataOffset;
 113.249 -        if (alreadyRead > 0) {
 113.250 -            memcpy(addressP, /*ssf->ssf_data*/ dataP, alreadyRead);
 113.251 -            iov->iov_base = addressP + alreadyRead;
 113.252 -            iov->iov_len = dataLength - alreadyRead;
 113.253 -        } else {
 113.254 -            iov->iov_base = addressP;
 113.255 -            iov->iov_len = dataLength;
 113.256 -        }
 113.257 -
 113.258 -        if (remaining > 0) {
 113.259 -            if ((rv = recvmsg(fd, msg, 0)) < 0) {
 113.260 -                handleSocketError(env, errno);
 113.261 -                return;
 113.262 -            }
 113.263 -
 113.264 -            if (rv != (dataLength - alreadyRead) || !(msg->msg_flags & MSG_EOR)) {
 113.265 -                //TODO: assert false: "should not reach here";
 113.266 -                return;
 113.267 -            }
 113.268 -            // TODO: Set and document (in API) buffers position.
 113.269 -        }
 113.270 -    }
 113.271 -
 113.272 -    /* create SctpSendFailed */
 113.273 -    resultObj = (*env)->NewObject(env, ssf_class, ssf_ctrID, ssf->ssf_assoc_id,
 113.274 -            isaObj, bufferObj, ssf->ssf_error, sri->sinfo_stream);
 113.275 -    CHECK_NULL(resultObj);
 113.276 -    (*env)->SetObjectField(env, resultContainerObj, src_valueID, resultObj);
 113.277 -    (*env)->SetIntField(env, resultContainerObj, src_typeID,
 113.278 -            sun_nio_ch_SctpResultContainer_SEND_FAILED);
 113.279 -}
 113.280 -
 113.281 -void handleAssocChange
 113.282 -  (JNIEnv* env, jobject resultContainerObj, struct sctp_assoc_change *sac) {
 113.283 -    jobject resultObj;
 113.284 -    int state = 0;
 113.285 -
 113.286 -    switch (sac->sac_state) {
 113.287 -        case SCTP_COMM_UP :
 113.288 -            state = sun_nio_ch_SctpAssocChange_SCTP_COMM_UP;
 113.289 -            break;
 113.290 -        case SCTP_COMM_LOST :
 113.291 -            state = sun_nio_ch_SctpAssocChange_SCTP_COMM_LOST;
 113.292 -            break;
 113.293 -        case SCTP_RESTART :
 113.294 -            state = sun_nio_ch_SctpAssocChange_SCTP_RESTART;
 113.295 -            break;
 113.296 -        case SCTP_SHUTDOWN_COMP :
 113.297 -            state = sun_nio_ch_SctpAssocChange_SCTP_SHUTDOWN;
 113.298 -            break;
 113.299 -        case SCTP_CANT_STR_ASSOC :
 113.300 -            state = sun_nio_ch_SctpAssocChange_SCTP_CANT_START;
 113.301 -    }
 113.302 -
 113.303 -    /* create SctpAssociationChanged */
 113.304 -    resultObj = (*env)->NewObject(env, sac_class, sac_ctrID, sac->sac_assoc_id,
 113.305 -        state, sac->sac_outbound_streams, sac->sac_inbound_streams);
 113.306 -    CHECK_NULL(resultObj);
 113.307 -    (*env)->SetObjectField(env, resultContainerObj, src_valueID, resultObj);
 113.308 -    (*env)->SetIntField(env, resultContainerObj, src_typeID,
 113.309 -            sun_nio_ch_SctpResultContainer_ASSOCIATION_CHANGED);
 113.310 -}
 113.311 -
 113.312 -void handleShutdown
 113.313 -  (JNIEnv* env, jobject resultContainerObj, struct sctp_shutdown_event* sse) {
 113.314 -    /* create SctpShutdown */
 113.315 -    jobject resultObj = (*env)->NewObject(env, ss_class, ss_ctrID, sse->sse_assoc_id);
 113.316 -    CHECK_NULL(resultObj);
 113.317 -    (*env)->SetObjectField(env, resultContainerObj, src_valueID, resultObj);
 113.318 -    (*env)->SetIntField(env, resultContainerObj, src_typeID,
 113.319 -            sun_nio_ch_SctpResultContainer_SHUTDOWN);
 113.320 -}
 113.321 -
 113.322 -void handlePeerAddrChange
 113.323 -  (JNIEnv* env, jobject resultContainerObj, struct sctp_paddr_change* spc) {
 113.324 -    int event = 0;
 113.325 -    jobject addressObj, resultObj;
 113.326 -    unsigned int state = spc->spc_state;
 113.327 -
 113.328 -    switch (state) {
 113.329 -        case SCTP_ADDR_AVAILABLE :
 113.330 -            event = sun_nio_ch_SctpPeerAddrChange_SCTP_ADDR_AVAILABLE;
 113.331 -            break;
 113.332 -        case SCTP_ADDR_UNREACHABLE :
 113.333 -            event = sun_nio_ch_SctpPeerAddrChange_SCTP_ADDR_UNREACHABLE;
 113.334 -            break;
 113.335 -        case SCTP_ADDR_REMOVED :
 113.336 -            event = sun_nio_ch_SctpPeerAddrChange_SCTP_ADDR_REMOVED;
 113.337 -            break;
 113.338 -        case SCTP_ADDR_ADDED :
 113.339 -            event = sun_nio_ch_SctpPeerAddrChange_SCTP_ADDR_ADDED;
 113.340 -            break;
 113.341 -        case SCTP_ADDR_MADE_PRIM :
 113.342 -            event = sun_nio_ch_SctpPeerAddrChange_SCTP_ADDR_MADE_PRIM;
 113.343 -#ifdef __linux__  /* Solaris currently doesn't support SCTP_ADDR_CONFIRMED */
 113.344 -            break;
 113.345 -        case SCTP_ADDR_CONFIRMED :
 113.346 -            event = sun_nio_ch_SctpPeerAddrChange_SCTP_ADDR_CONFIRMED;
 113.347 -#endif  /* __linux__ */
 113.348 -    }
 113.349 -
 113.350 -    addressObj = SockAddrToInetSocketAddress(env, (struct sockaddr*)&spc->spc_aaddr);
 113.351 -
 113.352 -    /* create SctpPeerAddressChanged */
 113.353 -    resultObj = (*env)->NewObject(env, spc_class, spc_ctrID, spc->spc_assoc_id,
 113.354 -            addressObj, event);
 113.355 -    CHECK_NULL(resultObj);
 113.356 -    (*env)->SetObjectField(env, resultContainerObj, src_valueID, resultObj);
 113.357 -    (*env)->SetIntField(env, resultContainerObj, src_typeID,
 113.358 -            sun_nio_ch_SctpResultContainer_PEER_ADDRESS_CHANGED);
 113.359 -}
 113.360 -
 113.361 -void handleUninteresting
 113.362 -  (union sctp_notification *snp) {
 113.363 -    //fprintf(stdout,"\nNative: handleUninterestingNotification: Receive notification type [%u]", snp->sn_header.sn_type);
 113.364 -}
 113.365 -
 113.366 -/**
 113.367 - * Handle notifications from the SCTP stack.
 113.368 - * Returns JNI_TRUE if the notification is one that is of interest to the
 113.369 - * Java API, otherwise JNI_FALSE.
 113.370 - */
 113.371 -jboolean handleNotification
 113.372 -  (JNIEnv* env, int fd, jobject resultContainerObj, union sctp_notification* snp,
 113.373 -   int read, jboolean isEOR, struct sockaddr* sap) {
 113.374 -    switch (snp->sn_header.sn_type) {
 113.375 -        case SCTP_SEND_FAILED:
 113.376 -            handleSendFailed(env, fd, resultContainerObj, &snp->sn_send_failed,
 113.377 -                    read, isEOR, sap);
 113.378 -            return JNI_TRUE;
 113.379 -        case SCTP_ASSOC_CHANGE:
 113.380 -            handleAssocChange(env, resultContainerObj, &snp->sn_assoc_change);
 113.381 -            return JNI_TRUE;
 113.382 -        case SCTP_SHUTDOWN_EVENT:
 113.383 -            handleShutdown(env, resultContainerObj, &snp->sn_shutdown_event);
 113.384 -            return JNI_TRUE;
 113.385 -        case SCTP_PEER_ADDR_CHANGE:
 113.386 -            handlePeerAddrChange(env, resultContainerObj, &snp->sn_paddr_change);
 113.387 -            return JNI_TRUE;
 113.388 -        default :
 113.389 -            /* the Java API is not interested in this event, maybe we are? */
 113.390 -            handleUninteresting(snp);
 113.391 -    }
 113.392 -    return JNI_FALSE;
 113.393 -}
 113.394 -
 113.395 -void handleMessage
 113.396 -  (JNIEnv* env, jobject resultContainerObj, struct msghdr* msg,int read,
 113.397 -   jboolean isEOR, struct sockaddr* sap) {
 113.398 -    jobject isa, resultObj;
 113.399 -    struct controlData cdata[1];
 113.400 -
 113.401 -    if (read == 0) {
 113.402 -        /* we reached EOF */
 113.403 -        read = -1;
 113.404 -    }
 113.405 -
 113.406 -    isa = SockAddrToInetSocketAddress(env, sap);
 113.407 -    getControlData(msg, cdata);
 113.408 -
 113.409 -    /* create SctpMessageInfoImpl */
 113.410 -    resultObj = (*env)->NewObject(env, smi_class, smi_ctrID, cdata->assocId,
 113.411 -                                  isa, read, cdata->streamNumber,
 113.412 -                                  isEOR ? JNI_TRUE : JNI_FALSE,
 113.413 -                                  cdata->unordered, cdata->ppid);
 113.414 -    CHECK_NULL(resultObj);
 113.415 -    (*env)->SetObjectField(env, resultContainerObj, src_valueID, resultObj);
 113.416 -    (*env)->SetIntField(env, resultContainerObj, src_typeID,
 113.417 -                        sun_nio_ch_SctpResultContainer_MESSAGE);
 113.418 -}
 113.419 -
 113.420 -/*
 113.421 - * Class:     sun_nio_ch_SctpChannelImpl
 113.422 - * Method:    receive0
 113.423 - * Signature: (ILsun/nio/ch/SctpResultContainer;JIZ)I
 113.424 - */
 113.425 -JNIEXPORT jint JNICALL Java_sun_nio_ch_SctpChannelImpl_receive0
 113.426 -  (JNIEnv *env, jclass klass, jint fd, jobject resultContainerObj,
 113.427 -   jlong address, jint length, jboolean peek) {
 113.428 -    SOCKADDR sa;
 113.429 -    int sa_len = sizeof(sa);
 113.430 -    ssize_t rv = 0;
 113.431 -    jlong *addr = jlong_to_ptr(address);
 113.432 -    struct iovec iov[1];
 113.433 -    struct msghdr msg[1];
 113.434 -    char cbuf[CMSG_SPACE(sizeof (struct sctp_sndrcvinfo))];
 113.435 -    int flags = peek == JNI_TRUE ? MSG_PEEK : 0;
 113.436 -
 113.437 -    /* Set up the msghdr structure for receiving */
 113.438 -    memset(msg, 0, sizeof (*msg));
 113.439 -    msg->msg_name = &sa;
 113.440 -    msg->msg_namelen = sa_len;
 113.441 -    iov->iov_base = addr;
 113.442 -    iov->iov_len = length;
 113.443 -    msg->msg_iov = iov;
 113.444 -    msg->msg_iovlen = 1;
 113.445 -    msg->msg_control = cbuf;
 113.446 -    msg->msg_controllen = sizeof(cbuf);
 113.447 -    msg->msg_flags = 0;
 113.448 -
 113.449 -    do {
 113.450 -        if ((rv = recvmsg(fd, msg, flags)) < 0) {
 113.451 -            if (errno == EWOULDBLOCK) {
 113.452 -                return IOS_UNAVAILABLE;
 113.453 -            } else if (errno == EINTR) {
 113.454 -                return IOS_INTERRUPTED;
 113.455 -
 113.456 -#ifdef __linux__
 113.457 -            } else if (errno == ENOTCONN) {
 113.458 -                /* ENOTCONN when EOF reached */
 113.459 -                rv = 0;
 113.460 -                /* there will be no control data */
 113.461 -                msg->msg_controllen = 0;
 113.462 -#endif /* __linux__ */
 113.463 -
 113.464 -            } else {
 113.465 -                handleSocketError(env, errno);
 113.466 -                return 0;
 113.467 -            }
 113.468 -        }
 113.469 -
 113.470 -        if (msg->msg_flags & MSG_NOTIFICATION) {
 113.471 -            char *bufp = (char*)addr;
 113.472 -            union sctp_notification *snp;
 113.473 -
 113.474 -            if (!(msg->msg_flags & MSG_EOR) && length < NOTIFICATION_BUFFER_SIZE) {
 113.475 -                char buf[NOTIFICATION_BUFFER_SIZE];
 113.476 -                int rvSAVE = rv;
 113.477 -                memcpy(buf, addr, rv);
 113.478 -                iov->iov_base = buf + rv;
 113.479 -                iov->iov_len = NOTIFICATION_BUFFER_SIZE - rv;
 113.480 -                if ((rv = recvmsg(fd, msg, flags)) < 0) {
 113.481 -                    handleSocketError(env, errno);
 113.482 -                    return 0;
 113.483 -                }
 113.484 -                bufp = buf;
 113.485 -                rv += rvSAVE;
 113.486 -            }
 113.487 -            snp = (union sctp_notification *) bufp;
 113.488 -            if (handleNotification(env, fd, resultContainerObj, snp, rv,
 113.489 -                                   (msg->msg_flags & MSG_EOR),
 113.490 -                                   (struct sockaddr*)&sa ) == JNI_TRUE) {
 113.491 -                /* We have received a notification that is of interest to
 113.492 -                   to the Java API. The appropriate notification will be
 113.493 -                   set in the result container. */
 113.494 -                return 0;
 113.495 -            }
 113.496 -
 113.497 -            // set iov back to addr, and reset msg_controllen
 113.498 -            iov->iov_base = addr;
 113.499 -            iov->iov_len = length;
 113.500 -            msg->msg_control = cbuf;
 113.501 -            msg->msg_controllen = sizeof(cbuf);
 113.502 -        }
 113.503 -    } while (msg->msg_flags & MSG_NOTIFICATION);
 113.504 -
 113.505 -    handleMessage(env, resultContainerObj, msg, rv,
 113.506 -            (msg->msg_flags & MSG_EOR), (struct sockaddr*)&sa);
 113.507 -    return rv;
 113.508 -}
 113.509 -
 113.510 -/*
 113.511 - * Class:     sun_nio_ch_SctpChannelImpl
 113.512 - * Method:    send0
 113.513 - * Signature: (IJILjava/net/SocketAddress;IIZI)I
 113.514 - */
 113.515 -JNIEXPORT jint JNICALL Java_sun_nio_ch_SctpChannelImpl_send0
 113.516 -  (JNIEnv *env, jclass klass, jint fd, jlong address, jint length,
 113.517 -   jobject saTarget, jint assocId, jint streamNumber, jboolean unordered,
 113.518 -   jint ppid) {
 113.519 -    SOCKADDR sa;
 113.520 -    int sa_len = sizeof(sa);
 113.521 -    ssize_t rv = 0;
 113.522 -    jlong *addr = jlong_to_ptr(address);
 113.523 -    struct iovec iov[1];
 113.524 -    struct msghdr msg[1];
 113.525 -    int cbuf_size = CMSG_SPACE(sizeof (struct sctp_sndrcvinfo));
 113.526 -    char cbuf[CMSG_SPACE(sizeof (struct sctp_sndrcvinfo))];
 113.527 -    struct controlData cdata[1];
 113.528 -
 113.529 -    /* SctpChannel:
 113.530 -     *    saTarget may contain the preferred address or NULL to use primary,
 113.531 -     *    assocId will always be -1
 113.532 -     * SctpMultiChannell:
 113.533 -     *    Setup new association, saTarget will contain address, assocId = -1
 113.534 -     *    Association already existing, assocId != -1, saTarget = preferred addr
 113.535 -     */
 113.536 -    if (saTarget != NULL /*&& assocId <= 0*/) {
 113.537 -
 113.538 -        jobject targetAddress = (*env)->GetObjectField(env, saTarget, isa_addrID);
 113.539 -        jint targetPort = (*env)->GetIntField(env, saTarget, isa_portID);
 113.540 -
 113.541 -        if (NET_InetAddressToSockaddr(env, targetAddress, targetPort,
 113.542 -                                      (struct sockaddr *)&sa,
 113.543 -                                      &sa_len, JNI_TRUE) != 0) {
 113.544 -            return IOS_THROWN;
 113.545 -        }
 113.546 -    } else {
 113.547 -        memset(&sa, '\x0', sa_len);
 113.548 -        sa_len = 0;
 113.549 -    }
 113.550 -
 113.551 -    /* Set up the msghdr structure for sending */
 113.552 -    memset(msg, 0, sizeof (*msg));
 113.553 -    memset(cbuf, 0, cbuf_size);
 113.554 -    msg->msg_name = &sa;
 113.555 -    msg->msg_namelen = sa_len;
 113.556 -    iov->iov_base = addr;
 113.557 -    iov->iov_len = length;
 113.558 -    msg->msg_iov = iov;
 113.559 -    msg->msg_iovlen = 1;
 113.560 -    msg->msg_control = cbuf;
 113.561 -    msg->msg_controllen = cbuf_size;
 113.562 -    msg->msg_flags = 0;
 113.563 -
 113.564 -    cdata->streamNumber = streamNumber;
 113.565 -    cdata->assocId = assocId;
 113.566 -    cdata->unordered = unordered;
 113.567 -    cdata->ppid = ppid;
 113.568 -    setControlData(msg, cdata);
 113.569 -
 113.570 -    if ((rv = sendmsg(fd, msg, 0)) < 0) {
 113.571 -        if (errno == EWOULDBLOCK) {
 113.572 -            return IOS_UNAVAILABLE;
 113.573 -        } else if (errno == EINTR) {
 113.574 -            return IOS_INTERRUPTED;
 113.575 -        } else if (errno == EPIPE) {
 113.576 -            JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
 113.577 -                            "Socket is shutdown for writing");
 113.578 -        } else {
 113.579 -            handleSocketError(env, errno);
 113.580 -            return 0;
 113.581 -        }
 113.582 -    }
 113.583 -
 113.584 -    return rv;
 113.585 -}
 113.586 -
 113.587 -/*
 113.588 - * Class:     sun_nio_ch_SctpChannelImpl
 113.589 - * Method:    checkConnect
 113.590 - * Signature: (Ljava/io/FileDescriptor;ZZ)I
 113.591 - */
 113.592 -JNIEXPORT jint JNICALL Java_sun_nio_ch_SctpChannelImpl_checkConnect
 113.593 -  (JNIEnv* env, jobject this, jobject fdo, jboolean block, jboolean ready) {
 113.594 -    return Java_sun_nio_ch_SocketChannelImpl_checkConnect(env, this,
 113.595 -                                                          fdo, block, ready);
 113.596 -}
 113.597 -
   114.1 --- a/src/solaris/native/sun/nio/ch/SctpNet.c	Thu Feb 16 13:01:36 2012 -0800
   114.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   114.3 @@ -1,753 +0,0 @@
   114.4 -/*
   114.5 - * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
   114.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   114.7 - *
   114.8 - * This code is free software; you can redistribute it and/or modify it
   114.9 - * under the terms of the GNU General Public License version 2 only, as
  114.10 - * published by the Free Software Foundation.  Oracle designates this
  114.11 - * particular file as subject to the "Classpath" exception as provided
  114.12 - * by Oracle in the LICENSE file that accompanied this code.
  114.13 - *
  114.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
  114.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  114.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  114.17 - * version 2 for more details (a copy is included in the LICENSE file that
  114.18 - * accompanied this code).
  114.19 - *
  114.20 - * You should have received a copy of the GNU General Public License version
  114.21 - * 2 along with this work; if not, write to the Free Software Foundation,
  114.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  114.23 - *
  114.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  114.25 - * or visit www.oracle.com if you need additional information or have any
  114.26 - * questions.
  114.27 - */
  114.28 -
  114.29 -#include <stdlib.h>
  114.30 -#include <string.h>
  114.31 -#include <dlfcn.h>
  114.32 -
  114.33 -#include "Sctp.h"
  114.34 -#include "jni.h"
  114.35 -#include "jni_util.h"
  114.36 -#include "nio_util.h"
  114.37 -#include "nio.h"
  114.38 -#include "net_util.h"
  114.39 -#include "net_util_md.h"
  114.40 -#include "sun_nio_ch_SctpNet.h"
  114.41 -#include "sun_nio_ch_SctpStdSocketOption.h"
  114.42 -
  114.43 -static jclass isaCls = 0;
  114.44 -static jmethodID isaCtrID = 0;
  114.45 -
  114.46 -static const char* nativeSctpLib = "libsctp.so.1";
  114.47 -static jboolean funcsLoaded = JNI_FALSE;
  114.48 -
  114.49 -JNIEXPORT jint JNICALL JNI_OnLoad
  114.50 -  (JavaVM *vm, void *reserved) {
  114.51 -    return JNI_VERSION_1_2;
  114.52 -}
  114.53 -
  114.54 -static int preCloseFD = -1;     /* File descriptor to which we dup other fd's
  114.55 -                                   before closing them for real */
  114.56 -
  114.57 -/**
  114.58 - * Loads the native sctp library that contains the socket extension
  114.59 - * functions, as well as locating the individual functions.
  114.60 - * There will be a pending exception if this method returns false.
  114.61 - */
  114.62 -jboolean loadSocketExtensionFuncs
  114.63 -  (JNIEnv* env) {
  114.64 -    if (dlopen(nativeSctpLib, RTLD_GLOBAL | RTLD_LAZY) == NULL) {
  114.65 -        JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
  114.66 -              dlerror());
  114.67 -        return JNI_FALSE;
  114.68 -    }
  114.69 -
  114.70 -    if ((nio_sctp_getladdrs = (sctp_getladdrs_func*)
  114.71 -            dlsym(RTLD_DEFAULT, "sctp_getladdrs")) == NULL) {
  114.72 -        JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
  114.73 -              dlerror());
  114.74 -        return JNI_FALSE;
  114.75 -    }
  114.76 -
  114.77 -    if ((nio_sctp_freeladdrs = (sctp_freeladdrs_func*)
  114.78 -            dlsym(RTLD_DEFAULT, "sctp_freeladdrs")) == NULL) {
  114.79 -        JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
  114.80 -              dlerror());
  114.81 -        return JNI_FALSE;
  114.82 -    }
  114.83 -
  114.84 -    if ((nio_sctp_getpaddrs = (sctp_getpaddrs_func*)
  114.85 -            dlsym(RTLD_DEFAULT, "sctp_getpaddrs")) == NULL) {
  114.86 -        JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
  114.87 -              dlerror());
  114.88 -        return JNI_FALSE;
  114.89 -    }
  114.90 -
  114.91 -    if ((nio_sctp_freepaddrs = (sctp_freepaddrs_func*)
  114.92 -            dlsym(RTLD_DEFAULT, "sctp_freepaddrs")) == NULL) {
  114.93 -        JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
  114.94 -              dlerror());
  114.95 -        return JNI_FALSE;
  114.96 -    }
  114.97 -
  114.98 -    if ((nio_sctp_bindx = (sctp_bindx_func*)
  114.99 -            dlsym(RTLD_DEFAULT, "sctp_bindx")) == NULL) {
 114.100 -        JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
 114.101 -              dlerror());
 114.102 -        return JNI_FALSE;
 114.103 -    }
 114.104 -
 114.105 -    if ((nio_sctp_peeloff = (sctp_peeloff_func*)
 114.106 -            dlsym(RTLD_DEFAULT, "sctp_peeloff")) == NULL) {
 114.107 -        JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
 114.108 -              dlerror());
 114.109 -        return JNI_FALSE;
 114.110 -    }
 114.111 -
 114.112 -    funcsLoaded = JNI_TRUE;
 114.113 -    return JNI_TRUE;
 114.114 -}
 114.115 -
 114.116 -jint
 114.117 -handleSocketError(JNIEnv *env, jint errorValue)
 114.118 -{
 114.119 -    char *xn;
 114.120 -    switch (errorValue) {
 114.121 -        case EINPROGRESS:     /* Non-blocking connect */
 114.122 -            return 0;
 114.123 -        case EPROTO:
 114.124 -            xn= JNU_JAVANETPKG "ProtocolException";
 114.125 -            break;
 114.126 -        case ECONNREFUSED:
 114.127 -            xn = JNU_JAVANETPKG "ConnectException";
 114.128 -            break;
 114.129 -        case ETIMEDOUT:
 114.130 -            xn = JNU_JAVANETPKG "ConnectException";
 114.131 -            break;
 114.132 -        case EHOSTUNREACH:
 114.133 -            xn = JNU_JAVANETPKG "NoRouteToHostException";
 114.134 -            break;
 114.135 -        case EADDRINUSE:  /* Fall through */
 114.136 -        case EADDRNOTAVAIL:
 114.137 -            xn = JNU_JAVANETPKG "BindException";
 114.138 -            break;
 114.139 -        default:
 114.140 -            xn = JNU_JAVANETPKG "SocketException";
 114.141 -            break;
 114.142 -    }
 114.143 -    errno = errorValue;
 114.144 -    JNU_ThrowByNameWithLastError(env, xn, "NioSocketError");
 114.145 -    return IOS_THROWN;
 114.146 -}
 114.147 -
 114.148 -/*
 114.149 - * Class:     sun_nio_ch_SctpNet
 114.150 - * Method:    init
 114.151 - * Signature: ()V
 114.152 - */
 114.153 -JNIEXPORT void JNICALL
 114.154 -Java_sun_nio_ch_SctpNet_init
 114.155 -  (JNIEnv *env, jclass cl) {
 114.156 -    int sp[2];
 114.157 -    if (socketpair(PF_UNIX, SOCK_STREAM, 0, sp) < 0) {
 114.158 -        JNU_ThrowIOExceptionWithLastError(env, "socketpair failed");
 114.159 -        return;
 114.160 -    }
 114.161 -    preCloseFD = sp[0];
 114.162 -    close(sp[1]);
 114.163 -}
 114.164 -
 114.165 -/*
 114.166 - * Class:     sun_nio_ch_SctpNet
 114.167 - * Method:    socket0
 114.168 - * Signature: (Z)I
 114.169 - */
 114.170 -JNIEXPORT jint JNICALL Java_sun_nio_ch_SctpNet_socket0
 114.171 -  (JNIEnv *env, jclass klass, jboolean oneToOne) {
 114.172 -    int fd;
 114.173 -    struct sctp_event_subscribe event;
 114.174 -#ifdef AF_INET6
 114.175 -    int domain = ipv6_available() ? AF_INET6 : AF_INET;
 114.176 -#else
 114.177 -    int domain = AF_INET;
 114.178 -#endif
 114.179 -
 114.180 -    /* Try to load the socket API extension functions */
 114.181 -    if (!funcsLoaded && !loadSocketExtensionFuncs(env)) {
 114.182 -        return 0;
 114.183 -    }
 114.184 -
 114.185 -    fd = socket(domain, (oneToOne ? SOCK_STREAM : SOCK_SEQPACKET), IPPROTO_SCTP);
 114.186 -
 114.187 -    if (fd < 0) {
 114.188 -        return handleSocketError(env, errno);
 114.189 -    }
 114.190 -
 114.191 -    /* Enable events */
 114.192 -    memset(&event, 0, sizeof(event));
 114.193 -    event.sctp_data_io_event = 1;
 114.194 -    event.sctp_association_event = 1;
 114.195 -    event.sctp_address_event = 1;
 114.196 -    event.sctp_send_failure_event = 1;
 114.197 -    //event.sctp_peer_error_event = 1;
 114.198 -    event.sctp_shutdown_event = 1;
 114.199 -    //event.sctp_partial_delivery_event = 1;
 114.200 -    //event.sctp_adaptation_layer_event = 1;
 114.201 -    if (setsockopt(fd, IPPROTO_SCTP, SCTP_EVENTS, &event, sizeof(event)) != 0) {
 114.202 -       handleSocketError(env, errno);
 114.203 -    }
 114.204 -    return fd;
 114.205 -}
 114.206 -
 114.207 -/*
 114.208 - * Class:     sun_nio_ch_SctpNet
 114.209 - * Method:    bindx
 114.210 - * Signature: (I[Ljava/net/InetAddress;IIZ)V
 114.211 - */
 114.212 -JNIEXPORT void JNICALL Java_sun_nio_ch_SctpNet_bindx
 114.213 -  (JNIEnv *env, jclass klass, jint fd, jobjectArray addrs, jint port,
 114.214 -   jint addrsLength, jboolean add, jboolean preferIPv6) {
 114.215 -    SOCKADDR *sap, *tmpSap;
 114.216 -    int i, sa_len = sizeof(SOCKADDR);
 114.217 -    jobject ia;
 114.218 -
 114.219 -    if (addrsLength < 1)
 114.220 -        return;
 114.221 -
 114.222 -    if ((sap = calloc(addrsLength,  sa_len)) == NULL) {
 114.223 -          JNU_ThrowOutOfMemoryError(env, "heap allocation failure");
 114.224 -        return;
 114.225 -    }
 114.226 -
 114.227 -    tmpSap = sap;
 114.228 -    for (i=0; i<addrsLength; i++) {
 114.229 -        ia = (*env)->GetObjectArrayElement(env, addrs, i);
 114.230 -        if (NET_InetAddressToSockaddr(env, ia, port, (struct sockaddr*)tmpSap,
 114.231 -                                      &sa_len, preferIPv6) != 0) {
 114.232 -            free(sap);
 114.233 -            return;
 114.234 -        }
 114.235 -        tmpSap++;
 114.236 -    }
 114.237 -
 114.238 -    if (nio_sctp_bindx(fd, (void*)sap, addrsLength, add ? SCTP_BINDX_ADD_ADDR :
 114.239 -                       SCTP_BINDX_REM_ADDR) != 0) {
 114.240 -        handleSocketError(env, errno);
 114.241 -    }
 114.242 -
 114.243 -    free(sap);
 114.244 -}
 114.245 -
 114.246 -/*
 114.247 - * Class:     sun_nio_ch_SctpNet
 114.248 - * Method:    listen0
 114.249 - * Signature: (II)V
 114.250 - */
 114.251 -JNIEXPORT void JNICALL
 114.252 -Java_sun_nio_ch_SctpNet_listen0
 114.253 -  (JNIEnv *env, jclass cl, jint fd, jint backlog) {
 114.254 -    if (listen(fd, backlog) < 0)
 114.255 -        handleSocketError(env, errno);
 114.256 -}
 114.257 -
 114.258 -/*
 114.259 - * Class:     sun_nio_ch_SctpNet
 114.260 - * Method:    connect0
 114.261 - * Signature: (ILjava/net/InetAddress;I)I
 114.262 - */
 114.263 -JNIEXPORT jint JNICALL
 114.264 -Java_sun_nio_ch_SctpNet_connect0
 114.265 -  (JNIEnv *env, jclass clazz, int fd, jobject iao, jint port) {
 114.266 -    SOCKADDR sa;
 114.267 -    int sa_len = SOCKADDR_LEN;
 114.268 -    int rv;
 114.269 -
 114.270 -    if (NET_InetAddressToSockaddr(env, iao, port, (struct sockaddr *) &sa,
 114.271 -                                  &sa_len, JNI_TRUE) != 0) {
 114.272 -        return IOS_THROWN;
 114.273 -    }
 114.274 -
 114.275 -    rv = connect(fd, (struct sockaddr *)&sa, sa_len);
 114.276 -    if (rv != 0) {
 114.277 -        if (errno == EINPROGRESS) {
 114.278 -            return IOS_UNAVAILABLE;
 114.279 -        } else if (errno == EINTR) {
 114.280 -            return IOS_INTERRUPTED;
 114.281 -        }
 114.282 -        return handleSocketError(env, errno);
 114.283 -    }
 114.284 -    return 1;
 114.285 -}
 114.286 -
 114.287 -/*
 114.288 - * Class:     sun_nio_ch_SctpNet
 114.289 - * Method:    close0
 114.290 - * Signature: (I)V
 114.291 - */
 114.292 -JNIEXPORT void JNICALL
 114.293 -Java_sun_nio_ch_SctpNet_close0
 114.294 -  (JNIEnv *env, jclass clazz, jint fd) {
 114.295 -    if (fd != -1) {
 114.296 -        int rv = close(fd);
 114.297 -        if (rv < 0)
 114.298 -            JNU_ThrowIOExceptionWithLastError(env, "Close failed");
 114.299 -    }
 114.300 -}
 114.301 -
 114.302 -/*
 114.303 - * Class:     sun_nio_ch_SctpNet
 114.304 - * Method:    preClose0
 114.305 - * Signature: (I)V
 114.306 - */
 114.307 -JNIEXPORT void JNICALL
 114.308 -Java_sun_nio_ch_SctpNet_preClose0
 114.309 -  (JNIEnv *env, jclass clazz, jint fd) {
 114.310 -    if (preCloseFD >= 0) {
 114.311 -        if (dup2(preCloseFD, fd) < 0)
 114.312 -            JNU_ThrowIOExceptionWithLastError(env, "dup2 failed");
 114.313 -    }
 114.314 -}
 114.315 -
 114.316 -void initializeISA
 114.317 -  (JNIEnv* env) {
 114.318 -    if (isaCls == 0) {
 114.319 -        jclass c = (*env)->FindClass(env, "java/net/InetSocketAddress");
 114.320 -        CHECK_NULL(c);
 114.321 -        isaCls = (*env)->NewGlobalRef(env, c);
 114.322 -        CHECK_NULL(isaCls);
 114.323 -        (*env)->DeleteLocalRef(env, c);
 114.324 -        isaCtrID = (*env)->GetMethodID(env, isaCls, "<init>",
 114.325 -                                     "(Ljava/net/InetAddress;I)V");
 114.326 -    }
 114.327 -}
 114.328 -
 114.329 -jobject SockAddrToInetSocketAddress
 114.330 -  (JNIEnv *env, struct sockaddr* sap) {
 114.331 -    int port = 0;
 114.332 -
 114.333 -    jobject ia = NET_SockaddrToInetAddress(env, sap, &port);
 114.334 -    if (ia == NULL)
 114.335 -        return NULL;
 114.336 -
 114.337 -    if (isaCls == 0) {
 114.338 -        initializeISA(env);
 114.339 -        CHECK_NULL_RETURN(isaCls, NULL);
 114.340 -    }
 114.341 -
 114.342 -    return (*env)->NewObject(env, isaCls, isaCtrID, ia, port);
 114.343 -}
 114.344 -
 114.345 -/*
 114.346 - * Class:     sun_nio_ch_SctpNet
 114.347 - * Method:    getLocalAddresses0
 114.348 - * Signature: (I)[Ljava/net/SocketAddress;
 114.349 - */
 114.350 -JNIEXPORT jobjectArray JNICALL Java_sun_nio_ch_SctpNet_getLocalAddresses0
 114.351 -  (JNIEnv *env, jclass klass, jint fd) {
 114.352 -    void *addr_buf, *laddr;
 114.353 -    struct sockaddr* sap;
 114.354 -    int i, addrCount;
 114.355 -    jobjectArray isaa;
 114.356 -
 114.357 -#ifdef __solaris__
 114.358 -    if ((addrCount = nio_sctp_getladdrs(fd, 0, (void **)&addr_buf)) == -1) {
 114.359 -#else /* __linux__ */
 114.360 -    if ((addrCount = nio_sctp_getladdrs(fd, 0, (struct sockaddr **)&addr_buf)) == -1) {
 114.361 -#endif
 114.362 -        handleSocketError(env, errno);
 114.363 -        return NULL;
 114.364 -    }
 114.365 -
 114.366 -    if (addrCount < 1)
 114.367 -        return NULL;
 114.368 -
 114.369 -    if (isaCls == 0) {
 114.370 -        initializeISA(env);
 114.371 -        CHECK_NULL_RETURN(isaCls, NULL);
 114.372 -    }
 114.373 -
 114.374 -    isaa = (*env)->NewObjectArray(env, addrCount, isaCls, NULL);
 114.375 -    if (isaa == NULL) {
 114.376 -        nio_sctp_freeladdrs(addr_buf);
 114.377 -        return NULL;
 114.378 -    }
 114.379 -
 114.380 -    laddr = addr_buf;
 114.381 -    for (i=0; i<addrCount; i++) {
 114.382 -        int port = 0;
 114.383 -        jobject isa = NULL, ia;
 114.384 -        sap = (struct sockaddr*)addr_buf;
 114.385 -        ia = NET_SockaddrToInetAddress(env, sap, &port);
 114.386 -        if (ia != NULL)
 114.387 -            isa = (*env)->NewObject(env, isaCls, isaCtrID, ia, port);
 114.388 -        if (isa != NULL)
 114.389 -            (*env)->SetObjectArrayElement(env, isaa, i, isa);
 114.390 -
 114.391 -        if (sap->sa_family == AF_INET)
 114.392 -            addr_buf = ((struct sockaddr_in*)addr_buf) + 1;
 114.393 -        else
 114.394 -            addr_buf = ((struct sockaddr_in6*)addr_buf) + 1;
 114.395 -    }
 114.396 -
 114.397 -    nio_sctp_freeladdrs(laddr);
 114.398 -    return isaa;
 114.399 -}
 114.400 -
 114.401 -jobjectArray getRemoteAddresses
 114.402 -  (JNIEnv *env, jint fd, sctp_assoc_t id) {
 114.403 -    void *addr_buf, *paddr;
 114.404 -    struct sockaddr* sap;
 114.405 -    int i, addrCount;
 114.406 -    jobjectArray isaa;
 114.407 -
 114.408 -#if __solaris__
 114.409 -    if ((addrCount = nio_sctp_getpaddrs(fd, id, (void **)&addr_buf)) == -1) {
 114.410 -#else /* __linux__ */
 114.411 -    if ((addrCount = nio_sctp_getpaddrs(fd, id, (struct sockaddr**)&addr_buf)) == -1) {
 114.412 -#endif
 114.413 -        handleSocketError(env, errno);
 114.414 -        return NULL;
 114.415 -    }
 114.416 -
 114.417 -    if (addrCount < 1)
 114.418 -        return NULL;
 114.419 -
 114.420 -    if (isaCls == 0) {
 114.421 -        initializeISA(env);
 114.422 -        CHECK_NULL_RETURN(isaCls, NULL);
 114.423 -    }
 114.424 -
 114.425 -    isaa = (*env)->NewObjectArray(env, addrCount, isaCls, NULL);
 114.426 -    if (isaa == NULL) {
 114.427 -        nio_sctp_freepaddrs(addr_buf);
 114.428 -        return NULL;
 114.429 -    }
 114.430 -
 114.431 -    paddr = addr_buf;
 114.432 -    for (i=0; i<addrCount; i++) {
 114.433 -        jobject ia, isa = NULL;
 114.434 -        int port;
 114.435 -        sap = (struct sockaddr*)addr_buf;
 114.436 -        ia = NET_SockaddrToInetAddress(env, sap, &port);
 114.437 -        if (ia != NULL)
 114.438 -            isa = (*env)->NewObject(env, isaCls, isaCtrID, ia, port);
 114.439 -        if (isa != NULL)
 114.440 -            (*env)->SetObjectArrayElement(env, isaa, i, isa);
 114.441 -
 114.442 -        if (sap->sa_family == AF_INET)
 114.443 -            addr_buf = ((struct sockaddr_in*)addr_buf) + 1;
 114.444 -        else
 114.445 -            addr_buf = ((struct sockaddr_in6*)addr_buf) + 1;
 114.446 -    }
 114.447 -
 114.448 -    nio_sctp_freepaddrs(paddr);
 114.449 -
 114.450 -    return isaa;
 114.451 -}
 114.452 -
 114.453 - /*
 114.454 - * Class:     sun_nio_ch_SctpNet
 114.455 - * Method:    getRemoteAddresses0
 114.456 - * Signature: (II)[Ljava/net/SocketAddress;
 114.457 - */
 114.458 -JNIEXPORT jobjectArray JNICALL Java_sun_nio_ch_SctpNet_getRemoteAddresses0
 114.459 -  (JNIEnv *env, jclass klass, jint fd, jint assocId) {
 114.460 -    return getRemoteAddresses(env, fd, assocId);
 114.461 -}
 114.462 -
 114.463 -/* Map the Java level option to the native level */
 114.464 -int mapSocketOption
 114.465 -  (jint cmd, int *level, int *optname) {
 114.466 -    static struct {
 114.467 -        jint cmd;
 114.468 -        int level;
 114.469 -        int optname;
 114.470 -    } const opts[] = {
 114.471 -        { sun_nio_ch_SctpStdSocketOption_SCTP_DISABLE_FRAGMENTS,   IPPROTO_SCTP, SCTP_DISABLE_FRAGMENTS },
 114.472 -        { sun_nio_ch_SctpStdSocketOption_SCTP_EXPLICIT_COMPLETE,   IPPROTO_SCTP, SCTP_EXPLICIT_EOR },
 114.473 -        { sun_nio_ch_SctpStdSocketOption_SCTP_FRAGMENT_INTERLEAVE, IPPROTO_SCTP, SCTP_FRAGMENT_INTERLEAVE },
 114.474 -        { sun_nio_ch_SctpStdSocketOption_SCTP_NODELAY,             IPPROTO_SCTP, SCTP_NODELAY },
 114.475 -        { sun_nio_ch_SctpStdSocketOption_SO_SNDBUF,                SOL_SOCKET,   SO_SNDBUF },
 114.476 -        { sun_nio_ch_SctpStdSocketOption_SO_RCVBUF,                SOL_SOCKET,   SO_RCVBUF },
 114.477 -        { sun_nio_ch_SctpStdSocketOption_SO_LINGER,                SOL_SOCKET,   SO_LINGER } };
 114.478 -
 114.479 -    int i;
 114.480 -    for (i=0; i<(int)(sizeof(opts) / sizeof(opts[0])); i++) {
 114.481 -        if (cmd == opts[i].cmd) {
 114.482 -            *level = opts[i].level;
 114.483 -            *optname = opts[i].optname;
 114.484 -            return 0;
 114.485 -        }
 114.486 -    }
 114.487 -
 114.488 -    /* not found */
 114.489 -    return -1;
 114.490 -}
 114.491 -
 114.492 -/*
 114.493 - * Class:     sun_nio_ch_SctpNet
 114.494 - * Method:    setIntOption0
 114.495 - * Signature: (III)V
 114.496 - */
 114.497 -JNIEXPORT void JNICALL Java_sun_nio_ch_SctpNet_setIntOption0
 114.498 -  (JNIEnv *env, jclass klass, jint fd, jint opt, int arg) {
 114.499 -    int klevel, kopt;
 114.500 -    int result;
 114.501 -    struct linger linger;
 114.502 -    void *parg;
 114.503 -    int arglen;
 114.504 -
 114.505 -    if (mapSocketOption(opt, &klevel, &kopt) < 0) {
 114.506 -        JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
 114.507 -                                     "Unsupported socket option");
 114.508 -        return;
 114.509 -    }
 114.510 -
 114.511 -    if (opt == sun_nio_ch_SctpStdSocketOption_SO_LINGER) {
 114.512 -        parg = (void *)&linger;
 114.513 -        arglen = sizeof(linger);
 114.514 -        if (arg >= 0) {
 114.515 -            linger.l_onoff = 1;
 114.516 -            linger.l_linger = arg;
 114.517 -        } else {
 114.518 -            linger.l_onoff = 0;
 114.519 -            linger.l_linger = 0;
 114.520 -        }
 114.521 -    } else {
 114.522 -        parg = (void *)&arg;
 114.523 -        arglen = sizeof(arg);
 114.524 -    }
 114.525 -
 114.526 -    if (NET_SetSockOpt(fd, klevel, kopt, parg, arglen) < 0) {
 114.527 -        JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
 114.528 -                                     "sun_nio_ch_SctpNet.setIntOption0");
 114.529 -    }
 114.530 -}
 114.531 -
 114.532 -/*
 114.533 - * Class:     sun_nio_ch_SctpNet
 114.534 - * Method:    getIntOption0
 114.535 - * Signature: (II)I
 114.536 - */
 114.537 -JNIEXPORT int JNICALL Java_sun_nio_ch_SctpNet_getIntOption0
 114.538 -  (JNIEnv *env, jclass klass, jint fd, jint opt) {
 114.539 -    int klevel, kopt;
 114.540 -    int result;
 114.541 -    struct linger linger;
 114.542 -    void *arg;
 114.543 -    int arglen;
 114.544 -
 114.545 -    if (mapSocketOption(opt, &klevel, &kopt) < 0) {
 114.546 -        JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
 114.547 -                                     "Unsupported socket option");
 114.548 -        return -1;
 114.549 -    }
 114.550 -
 114.551 -    if (opt == sun_nio_ch_SctpStdSocketOption_SO_LINGER) {
 114.552 -        arg = (void *)&linger;
 114.553 -        arglen = sizeof(linger);
 114.554 -    } else {
 114.555 -        arg = (void *)&result;
 114.556 -        arglen = sizeof(result);
 114.557 -    }
 114.558 -
 114.559 -    if (NET_GetSockOpt(fd, klevel, kopt, arg, &arglen) < 0) {
 114.560 -        JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
 114.561 -                                     "sun.nio.ch.Net.getIntOption");
 114.562 -        return -1;
 114.563 -    }
 114.564 -
 114.565 -    if (opt == sun_nio_ch_SctpStdSocketOption_SO_LINGER)
 114.566 -        return linger.l_onoff ? linger.l_linger : -1;
 114.567 -    else
 114.568 -        return result;
 114.569 -}
 114.570 -
 114.571 -/*
 114.572 - * Class:     sun_nio_ch_SctpNet
 114.573 - * Method:    getPrimAddrOption0
 114.574 - * Signature: (II)Ljava/net/SocketAddress;
 114.575 - */
 114.576 -JNIEXPORT jobject JNICALL Java_sun_nio_ch_SctpNet_getPrimAddrOption0
 114.577 -  (JNIEnv *env, jclass klass, jint fd, jint assocId) {
 114.578 -    struct sctp_setprim prim;
 114.579 -    unsigned int prim_len = sizeof(prim);
 114.580 -    struct sockaddr* sap = (struct sockaddr*)&prim.ssp_addr;
 114.581 -
 114.582 -    prim.ssp_assoc_id = assocId;
 114.583 -
 114.584 -    if (getsockopt(fd, IPPROTO_SCTP, SCTP_PRIMARY_ADDR, &prim, &prim_len) < 0) {
 114.585 -        JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
 114.586 -                                     "sun.nio.ch.SctpNet.getPrimAddrOption0");
 114.587 -        return NULL;
 114.588 -    }
 114.589 -
 114.590 -    return SockAddrToInetSocketAddress(env, sap);
 114.591 -}
 114.592 -
 114.593 -/*
 114.594 - * Class:     sun_nio_ch_SctpNet
 114.595 - * Method:    setPrimAddrOption0
 114.596 - * Signature: (IILjava/net/InetAddress;I)V
 114.597 - */
 114.598 -JNIEXPORT void JNICALL Java_sun_nio_ch_SctpNet_setPrimAddrOption0
 114.599 -  (JNIEnv *env, jclass klass, jint fd, jint assocId, jobject iaObj, jint port) {
 114.600 -    struct sctp_setprim prim;
 114.601 -    struct sockaddr* sap = (struct sockaddr*)&prim.ssp_addr;
 114.602 -    int sap_len;
 114.603 -
 114.604 -    if (NET_InetAddressToSockaddr(env, iaObj, port, sap,
 114.605 -                                  &sap_len, JNI_TRUE) != 0) {
 114.606 -        return;
 114.607 -    }
 114.608 -
 114.609 -    prim.ssp_assoc_id = assocId;
 114.610 -
 114.611 -    if (setsockopt(fd, IPPROTO_SCTP, SCTP_PRIMARY_ADDR, &prim, sizeof(prim)) < 0) {
 114.612 -        JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
 114.613 -                                     "sun.nio.ch.SctpNet.setPrimAddrOption0");
 114.614 -    }
 114.615 -}
 114.616 -
 114.617 -/*
 114.618 - * Class:     sun_nio_ch_SctpNet
 114.619 - * Method:    setPeerPrimAddrOption0
 114.620 - * Signature: (IILjava/net/InetAddress;I)V
 114.621 - */
 114.622 -JNIEXPORT void JNICALL Java_sun_nio_ch_SctpNet_setPeerPrimAddrOption0
 114.623 -  (JNIEnv *env, jclass klass, jint fd, jint assocId,
 114.624 -   jobject iaObj, jint port, jboolean preferIPv6) {
 114.625 -    struct sctp_setpeerprim prim;
 114.626 -    struct sockaddr* sap = (struct sockaddr*)&prim.sspp_addr;
 114.627 -    int sap_len;
 114.628 -
 114.629 -    if (NET_InetAddressToSockaddr(env, iaObj, port, sap,
 114.630 -                                  &sap_len, preferIPv6) != 0) {
 114.631 -        return;
 114.632 -    }
 114.633 -
 114.634 -    prim.sspp_assoc_id = assocId;
 114.635 -
 114.636 -    if (setsockopt(fd, IPPROTO_SCTP, SCTP_SET_PEER_PRIMARY_ADDR, &prim,
 114.637 -            sizeof(prim)) < 0) {
 114.638 -        JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
 114.639 -                                     "sun.nio.ch.SctpNet.setPeerPrimAddrOption0");
 114.640 -    }
 114.641 -}
 114.642 -
 114.643 -/*
 114.644 - * Class:     sun_nio_ch_SctpNet
 114.645 - * Method:    getInitMsgOption0
 114.646 - * Signature: (I[I)V
 114.647 - */
 114.648 -JNIEXPORT void JNICALL Java_sun_nio_ch_SctpNet_getInitMsgOption0
 114.649 -  (JNIEnv *env, jclass klass, jint fd, jintArray retVal) {
 114.650 -    struct sctp_initmsg sctp_initmsg;
 114.651 -    unsigned int sim_len = sizeof(sctp_initmsg);
 114.652 -    int vals[2];
 114.653 -
 114.654 -    if (getsockopt(fd, IPPROTO_SCTP, SCTP_INITMSG, &sctp_initmsg,
 114.655 -            &sim_len) < 0) {
 114.656 -        JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
 114.657 -                                     "sun.nio.ch.SctpNet.getInitMsgOption0");
 114.658 -        return;
 114.659 -    }
 114.660 -
 114.661 -    vals[0] = sctp_initmsg.sinit_max_instreams;
 114.662 -    vals[1] = sctp_initmsg.sinit_num_ostreams;
 114.663 -    (*env)->SetIntArrayRegion(env, retVal, 0, 2, vals);
 114.664 -}
 114.665 -
 114.666 -/*
 114.667 - * Class:     sun_nio_ch_SctpNet
 114.668 - * Method:    setInitMsgOption0
 114.669 - * Signature: (III)V
 114.670 - */
 114.671 -JNIEXPORT void JNICALL Java_sun_nio_ch_SctpNet_setInitMsgOption0
 114.672 -  (JNIEnv *env, jclass klass, jint fd, jint inArg, jint outArg) {
 114.673 -    struct sctp_initmsg sctp_initmsg;
 114.674 -
 114.675 -    sctp_initmsg.sinit_max_instreams = (unsigned int)inArg;
 114.676 -    sctp_initmsg.sinit_num_ostreams = (unsigned int)outArg;
 114.677 -    sctp_initmsg.sinit_max_attempts = 0;  // default
 114.678 -    sctp_initmsg.sinit_max_init_timeo = 0;  // default
 114.679 -
 114.680 -    if (setsockopt(fd, IPPROTO_SCTP, SCTP_INITMSG, &sctp_initmsg,
 114.681 -          sizeof(sctp_initmsg)) < 0) {
 114.682 -        JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
 114.683 -                                     "sun.nio.ch.SctpNet.setInitMsgOption0");
 114.684 -    }
 114.685 -}
 114.686 -
 114.687 -/*
 114.688 - * Class:     sun_nio_ch_SctpNet
 114.689 - * Method:    shutdown0
 114.690 - * Signature: (II)V
 114.691 - */
 114.692 -JNIEXPORT void JNICALL Java_sun_nio_ch_SctpNet_shutdown0
 114.693 -  (JNIEnv *env, jclass klass, jint fd, jint assocId) {
 114.694 -    int rv;
 114.695 -    struct msghdr msg[1];
 114.696 -    struct iovec iov[1];
 114.697 -    int cbuf_size = CMSG_SPACE(sizeof (struct sctp_sndrcvinfo));
 114.698 -    char cbuf[CMSG_SPACE(sizeof (struct sctp_sndrcvinfo))];
 114.699 -    struct cmsghdr* cmsg;
 114.700 -    struct sctp_sndrcvinfo *sri;
 114.701 -
 114.702 -    /* SctpSocketChannel */
 114.703 -    if (assocId < 0) {
 114.704 -        shutdown(fd, SHUT_WR);
 114.705 -        return;
 114.706 -    }
 114.707 -
 114.708 -    memset(msg, 0, sizeof (*msg));
 114.709 -    memset(cbuf, 0, cbuf_size);
 114.710 -    msg->msg_name = NULL;
 114.711 -    msg->msg_namelen = 0;
 114.712 -    iov->iov_base = NULL;
 114.713 -    iov->iov_len = 0;
 114.714 -    msg->msg_iov = iov;
 114.715 -    msg->msg_iovlen = 1;
 114.716 -    msg->msg_control = cbuf;
 114.717 -    msg->msg_controllen = cbuf_size;
 114.718 -    msg->msg_flags = 0;
 114.719 -
 114.720 -    cmsg = CMSG_FIRSTHDR(msg);
 114.721 -    cmsg->cmsg_level = IPPROTO_SCTP;
 114.722 -    cmsg->cmsg_type = SCTP_SNDRCV;
 114.723 -    cmsg->cmsg_len = CMSG_LEN(sizeof(struct sctp_sndrcvinfo));
 114.724 -
 114.725 -    /* Initialize the payload: */
 114.726 -    sri = (struct sctp_sndrcvinfo*) CMSG_DATA(cmsg);
 114.727 -    memset(sri, 0, sizeof (*sri));
 114.728 -
 114.729 -    if (assocId > 0) {
 114.730 -        sri->sinfo_assoc_id = assocId;
 114.731 -    }
 114.732 -
 114.733 -    sri->sinfo_flags = sri->sinfo_flags | SCTP_EOF;
 114.734 -
 114.735 -    /* Sum of the length of all control messages in the buffer. */
 114.736 -    msg->msg_controllen = cmsg->cmsg_len;
 114.737 -
 114.738 -    if ((rv = sendmsg(fd, msg, 0)) < 0) {
 114.739 -        handleSocketError(env, errno);
 114.740 -    }
 114.741 -}
 114.742 -
 114.743 -/*
 114.744 - * Class:     sun_nio_ch_SctpNet
 114.745 - * Method:    branch
 114.746 - * Signature: (II)I
 114.747 - */
 114.748 -JNIEXPORT int JNICALL Java_sun_nio_ch_SctpNet_branch0
 114.749 -  (JNIEnv *env, jclass klass, jint fd, jint assocId) {
 114.750 -    int newfd = 0;
 114.751 -    if ((newfd = nio_sctp_peeloff(fd, assocId)) < 0) {
 114.752 -        handleSocketError(env, errno);
 114.753 -    }
 114.754 -
 114.755 -    return newfd;
 114.756 -}
   115.1 --- a/src/solaris/native/sun/nio/ch/SctpServerChannelImpl.c	Thu Feb 16 13:01:36 2012 -0800
   115.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   115.3 @@ -1,53 +0,0 @@
   115.4 -/*
   115.5 - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
   115.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   115.7 - *
   115.8 - * This code is free software; you can redistribute it and/or modify it
   115.9 - * under the terms of the GNU General Public License version 2 only, as
  115.10 - * published by the Free Software Foundation.  Oracle designates this
  115.11 - * particular file as subject to the "Classpath" exception as provided
  115.12 - * by Oracle in the LICENSE file that accompanied this code.
  115.13 - *
  115.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
  115.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  115.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  115.17 - * version 2 for more details (a copy is included in the LICENSE file that
  115.18 - * accompanied this code).
  115.19 - *
  115.20 - * You should have received a copy of the GNU General Public License version
  115.21 - * 2 along with this work; if not, write to the Free Software Foundation,
  115.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  115.23 - *
  115.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  115.25 - * or visit www.oracle.com if you need additional information or have any
  115.26 - * questions.
  115.27 - */
  115.28 -
  115.29 -#include "sun_nio_ch_SctpServerChannelImpl.h"
  115.30 -
  115.31 -extern void Java_sun_nio_ch_ServerSocketChannelImpl_initIDs(JNIEnv* env,
  115.32 -    jclass c);
  115.33 -
  115.34 -extern jint Java_sun_nio_ch_ServerSocketChannelImpl_accept0(JNIEnv* env,
  115.35 -    jobject this, jobject ssfdo, jobject newfdo, jobjectArray isaa);
  115.36 -
  115.37 -/*
  115.38 - * Class:     sun_nio_ch_SctpServerChannelImpl
  115.39 - * Method:    initIDs
  115.40 - * Signature: ()V
  115.41 - */
  115.42 -JNIEXPORT void JNICALL Java_sun_nio_ch_SctpServerChannelImpl_initIDs
  115.43 -  (JNIEnv* env, jclass c) {
  115.44 -    Java_sun_nio_ch_ServerSocketChannelImpl_initIDs(env, c);
  115.45 -}
  115.46 -
  115.47 -/*
  115.48 - * Class:     sun_nio_ch_SctpServerChannelImpl
  115.49 - * Method:    accept0
  115.50 - * Signature: (Ljava/io/FileDescriptor;Ljava/io/FileDescriptor;[Ljava/net/InetSocketAddress;)I
  115.51 - */
  115.52 -JNIEXPORT jint JNICALL Java_sun_nio_ch_SctpServerChannelImpl_accept0
  115.53 -  (JNIEnv* env, jobject this, jobject ssfdo, jobject newfdo, jobjectArray isaa) {
  115.54 -    return Java_sun_nio_ch_ServerSocketChannelImpl_accept0(env, this,
  115.55 -                                                           ssfdo, newfdo, isaa);
  115.56 -}
   116.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   116.2 +++ b/src/solaris/native/sun/nio/ch/sctp/Sctp.h	Sat Feb 18 16:11:47 2012 -0800
   116.3 @@ -0,0 +1,334 @@
   116.4 +/*
   116.5 + * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
   116.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   116.7 + *
   116.8 + * This code is free software; you can redistribute it and/or modify it
   116.9 + * under the terms of the GNU General Public License version 2 only, as
  116.10 + * published by the Free Software Foundation.  Oracle designates this
  116.11 + * particular file as subject to the "Classpath" exception as provided
  116.12 + * by Oracle in the LICENSE file that accompanied this code.
  116.13 + *
  116.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
  116.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  116.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  116.17 + * version 2 for more details (a copy is included in the LICENSE file that
  116.18 + * accompanied this code).
  116.19 + *
  116.20 + * You should have received a copy of the GNU General Public License version
  116.21 + * 2 along with this work; if not, write to the Free Software Foundation,
  116.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  116.23 + *
  116.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  116.25 + * or visit www.oracle.com if you need additional information or have any
  116.26 + * questions.
  116.27 + */
  116.28 +
  116.29 +#ifndef SUN_NIO_CH_SCTP_H
  116.30 +#define SUN_NIO_CH_SCTP_H
  116.31 +
  116.32 +#ifdef __solaris__
  116.33 +
  116.34 +#define _XPG4_2
  116.35 +#define __EXTENSIONS__
  116.36 +#include <sys/socket.h>
  116.37 +#include <netinet/sctp.h>
  116.38 +#include "jni.h"
  116.39 +
  116.40 +/* Current Solaris headers don't comply with draft rfc */
  116.41 +#ifndef SCTP_EOF
  116.42 +#define SCTP_EOF MSG_EOF
  116.43 +#endif
  116.44 +
  116.45 +#ifndef SCTP_UNORDERED
  116.46 +#define SCTP_UNORDERED MSG_UNORDERED
  116.47 +#endif
  116.48 +
  116.49 +/* The current version of the socket API extension shipped with Solaris does
  116.50 + * not define the following options that the Java API (optionally) supports */
  116.51 +#ifndef SCTP_EXPLICIT_EOR
  116.52 +#define SCTP_EXPLICIT_EOR -1
  116.53 +#endif
  116.54 +#ifndef SCTP_FRAGMENT_INTERLEAVE
  116.55 +#define SCTP_FRAGMENT_INTERLEAVE -1
  116.56 +#endif
  116.57 +#ifndef SCTP_SET_PEER_PRIMARY_ADDR
  116.58 +#define SCTP_SET_PEER_PRIMARY_ADDR -1
  116.59 +#endif
  116.60 +
  116.61 +/* Function types to support dynamic linking of socket API extension functions
  116.62 + * for SCTP. This is so that there is no linkage depandancy during build or
  116.63 + * runtime for libsctp.*/
  116.64 +typedef int sctp_getladdrs_func(int sock, sctp_assoc_t id, void **addrs);
  116.65 +typedef int sctp_freeladdrs_func(void* addrs);
  116.66 +typedef int sctp_getpaddrs_func(int sock, sctp_assoc_t id, void **addrs);
  116.67 +typedef int sctp_freepaddrs_func(void *addrs);
  116.68 +typedef int sctp_bindx_func(int sock, void *addrs, int addrcnt, int flags);
  116.69 +typedef int sctp_peeloff_func(int sock, sctp_assoc_t id);
  116.70 +
  116.71 +
  116.72 +
  116.73 +#else /* __linux__ */
  116.74 +#include <stdint.h>
  116.75 +#include <linux/types.h>
  116.76 +#include <sys/socket.h>
  116.77 +#include <netinet/in.h>
  116.78 +#include "jni.h"
  116.79 +
  116.80 +//Causes compiler error if not found, should make warning and uncomment
  116.81 +/*#include <netinet/sctp.h>*/
  116.82 +
  116.83 +#ifndef IPPROTO_SCTP
  116.84 +#define IPPROTO_SCTP    132
  116.85 +#endif
  116.86 +
  116.87 +/* The current version of lksctp does
  116.88 + * not define the following option that the Java API (optionally) supports */
  116.89 +#ifndef SCTP_EXPLICIT_EOR
  116.90 +#define SCTP_EXPLICIT_EOR -1
  116.91 +#endif
  116.92 +
  116.93 +/* Definitions taken from lksctp-tools-1.0.8/src/include/netinet/sctp.h */
  116.94 +#ifndef SCTP_INITMSG
  116.95 +
  116.96 +enum sctp_optname {
  116.97 +        SCTP_RTOINFO,
  116.98 +#define SCTP_RTOINFO SCTP_RTOINFO
  116.99 +        SCTP_ASSOCINFO,
 116.100 +#define SCTP_ASSOCINFO SCTP_ASSOCINFO
 116.101 +        SCTP_INITMSG,
 116.102 +#define SCTP_INITMSG SCTP_INITMSG
 116.103 +        SCTP_NODELAY,   /* Get/set nodelay option. */
 116.104 +#define SCTP_NODELAY    SCTP_NODELAY
 116.105 +        SCTP_AUTOCLOSE,
 116.106 +#define SCTP_AUTOCLOSE SCTP_AUTOCLOSE
 116.107 +        SCTP_SET_PEER_PRIMARY_ADDR,
 116.108 +#define SCTP_SET_PEER_PRIMARY_ADDR SCTP_SET_PEER_PRIMARY_ADDR
 116.109 +        SCTP_PRIMARY_ADDR,
 116.110 +#define SCTP_PRIMARY_ADDR SCTP_PRIMARY_ADDR
 116.111 +        SCTP_ADAPTATION_LAYER,
 116.112 +#define SCTP_ADAPTATION_LAYER SCTP_ADAPTATION_LAYER
 116.113 +        SCTP_DISABLE_FRAGMENTS,
 116.114 +#define SCTP_DISABLE_FRAGMENTS SCTP_DISABLE_FRAGMENTS
 116.115 +        SCTP_PEER_ADDR_PARAMS,
 116.116 +#define SCTP_PEER_ADDR_PARAMS SCTP_PEER_ADDR_PARAMS
 116.117 +        SCTP_DEFAULT_SEND_PARAM,
 116.118 +#define SCTP_DEFAULT_SEND_PARAM SCTP_DEFAULT_SEND_PARAM
 116.119 +        SCTP_EVENTS,
 116.120 +#define SCTP_EVENTS SCTP_EVENTS
 116.121 +        SCTP_I_WANT_MAPPED_V4_ADDR,  /* Turn on/off mapped v4 addresses  */
 116.122 +#define SCTP_I_WANT_MAPPED_V4_ADDR SCTP_I_WANT_MAPPED_V4_ADDR
 116.123 +        SCTP_MAXSEG,    /* Get/set maximum fragment. */
 116.124 +#define SCTP_MAXSEG     SCTP_MAXSEG
 116.125 +        SCTP_STATUS,
 116.126 +#define SCTP_STATUS SCTP_STATUS
 116.127 +        SCTP_GET_PEER_ADDR_INFO,
 116.128 +#define SCTP_GET_PEER_ADDR_INFO SCTP_GET_PEER_ADDR_INFO
 116.129 +        SCTP_DELAYED_ACK_TIME,
 116.130 +#define SCTP_DELAYED_ACK_TIME SCTP_DELAYED_ACK_TIME
 116.131 +        SCTP_CONTEXT,   /* Receive Context */
 116.132 +#define SCTP_CONTEXT SCTP_CONTEXT
 116.133 +        SCTP_FRAGMENT_INTERLEAVE,
 116.134 +#define SCTP_FRAGMENT_INTERLEAVE SCTP_FRAGMENT_INTERLEAVE
 116.135 +        SCTP_PARTIAL_DELIVERY_POINT,    /* Set/Get partial delivery point */
 116.136 +#define SCTP_PARTIAL_DELIVERY_POINT SCTP_PARTIAL_DELIVERY_POINT
 116.137 +        SCTP_MAX_BURST,         /* Set/Get max burst */
 116.138 +#define SCTP_MAX_BURST SCTP_MAX_BURST
 116.139 +};
 116.140 +
 116.141 +enum sctp_sac_state {
 116.142 +        SCTP_COMM_UP,
 116.143 +        SCTP_COMM_LOST,
 116.144 +        SCTP_RESTART,
 116.145 +        SCTP_SHUTDOWN_COMP,
 116.146 +        SCTP_CANT_STR_ASSOC,
 116.147 +};
 116.148 +
 116.149 +enum sctp_spc_state {
 116.150 +        SCTP_ADDR_AVAILABLE,
 116.151 +        SCTP_ADDR_UNREACHABLE,
 116.152 +        SCTP_ADDR_REMOVED,
 116.153 +        SCTP_ADDR_ADDED,
 116.154 +        SCTP_ADDR_MADE_PRIM,
 116.155 +        SCTP_ADDR_CONFIRMED,
 116.156 +};
 116.157 +
 116.158 +enum sctp_sinfo_flags {
 116.159 +        SCTP_UNORDERED = 1,  /* Send/receive message unordered. */
 116.160 +        SCTP_ADDR_OVER = 2,  /* Override the primary destination. */
 116.161 +        SCTP_ABORT=4,        /* Send an ABORT message to the peer. */
 116.162 +        SCTP_EOF=MSG_FIN,    /* Initiate graceful shutdown process. */
 116.163 +};
 116.164 +
 116.165 +enum sctp_sn_type {
 116.166 +        SCTP_SN_TYPE_BASE     = (1<<15),
 116.167 +        SCTP_ASSOC_CHANGE,
 116.168 +        SCTP_PEER_ADDR_CHANGE,
 116.169 +        SCTP_SEND_FAILED,
 116.170 +        SCTP_REMOTE_ERROR,
 116.171 +        SCTP_SHUTDOWN_EVENT,
 116.172 +        SCTP_PARTIAL_DELIVERY_EVENT,
 116.173 +        SCTP_ADAPTATION_INDICATION,
 116.174 +};
 116.175 +
 116.176 +typedef enum sctp_cmsg_type {
 116.177 +        SCTP_INIT,              /* 5.2.1 SCTP Initiation Structure */
 116.178 +#define SCTP_INIT SCTP_INIT
 116.179 +        SCTP_SNDRCV,            /* 5.2.2 SCTP Header Information Structure */
 116.180 +#define SCTP_SNDRCV SCTP_SNDRCV
 116.181 +} sctp_cmsg_t;
 116.182 +
 116.183 +enum sctp_msg_flags {
 116.184 +        MSG_NOTIFICATION = 0x8000,
 116.185 +#define MSG_NOTIFICATION MSG_NOTIFICATION
 116.186 +};
 116.187 +
 116.188 +#define SCTP_BINDX_ADD_ADDR 0x01
 116.189 +#define SCTP_BINDX_REM_ADDR 0x02
 116.190 +
 116.191 +typedef __s32 sctp_assoc_t;
 116.192 +
 116.193 +struct sctp_initmsg {
 116.194 +        __u16 sinit_num_ostreams;
 116.195 +        __u16 sinit_max_instreams;
 116.196 +        __u16 sinit_max_attempts;
 116.197 +        __u16 sinit_max_init_timeo;
 116.198 +};
 116.199 +
 116.200 +struct sctp_sndrcvinfo {
 116.201 +        __u16 sinfo_stream;
 116.202 +        __u16 sinfo_ssn;
 116.203 +        __u16 sinfo_flags;
 116.204 +        __u32 sinfo_ppid;
 116.205 +        __u32 sinfo_context;
 116.206 +        __u32 sinfo_timetolive;
 116.207 +        __u32 sinfo_tsn;
 116.208 +        __u32 sinfo_cumtsn;
 116.209 +        sctp_assoc_t sinfo_assoc_id;
 116.210 +};
 116.211 +
 116.212 +struct sctp_event_subscribe {
 116.213 +        __u8 sctp_data_io_event;
 116.214 +        __u8 sctp_association_event;
 116.215 +        __u8 sctp_address_event;
 116.216 +        __u8 sctp_send_failure_event;
 116.217 +        __u8 sctp_peer_error_event;
 116.218 +        __u8 sctp_shutdown_event;
 116.219 +        __u8 sctp_partial_delivery_event;
 116.220 +        __u8 sctp_adaptation_layer_event;
 116.221 +};
 116.222 +
 116.223 +struct sctp_send_failed {
 116.224 +        __u16 ssf_type;
 116.225 +        __u16 ssf_flags;
 116.226 +        __u32 ssf_length;
 116.227 +        __u32 ssf_error;
 116.228 +        struct sctp_sndrcvinfo ssf_info;
 116.229 +        sctp_assoc_t ssf_assoc_id;
 116.230 +        __u8 ssf_data[0];
 116.231 +};
 116.232 +
 116.233 +struct sctp_assoc_change {
 116.234 +        __u16 sac_type;
 116.235 +        __u16 sac_flags;
 116.236 +        __u32 sac_length;
 116.237 +        __u16 sac_state;
 116.238 +        __u16 sac_error;
 116.239 +        __u16 sac_outbound_streams;
 116.240 +        __u16 sac_inbound_streams;
 116.241 +        sctp_assoc_t sac_assoc_id;
 116.242 +        __u8 sac_info[0];
 116.243 +};
 116.244 +
 116.245 +struct sctp_shutdown_event {
 116.246 +        __u16 sse_type;
 116.247 +        __u16 sse_flags;
 116.248 +        __u32 sse_length;
 116.249 +        sctp_assoc_t sse_assoc_id;
 116.250 +};
 116.251 +
 116.252 +struct sctp_paddr_change {
 116.253 +        __u16 spc_type;
 116.254 +        __u16 spc_flags;
 116.255 +        __u32 spc_length;
 116.256 +        struct sockaddr_storage spc_aaddr;
 116.257 +        int spc_state;
 116.258 +        int spc_error;
 116.259 +        sctp_assoc_t spc_assoc_id;
 116.260 +} __attribute__((packed, aligned(4)));
 116.261 +
 116.262 +struct sctp_remote_error {
 116.263 +        __u16 sre_type;
 116.264 +        __u16 sre_flags;
 116.265 +        __u32 sre_length;
 116.266 +        __u16 sre_error;
 116.267 +        sctp_assoc_t sre_assoc_id;
 116.268 +        __u8 sre_data[0];
 116.269 +};
 116.270 +
 116.271 +struct sctp_adaptation_event {
 116.272 +        __u16 sai_type;
 116.273 +        __u16 sai_flags;
 116.274 +        __u32 sai_length;
 116.275 +        __u32 sai_adaptation_ind;
 116.276 +        sctp_assoc_t sai_assoc_id;
 116.277 +};
 116.278 +
 116.279 +struct sctp_setprim {
 116.280 +        sctp_assoc_t            ssp_assoc_id;
 116.281 +        struct sockaddr_storage ssp_addr;
 116.282 +} __attribute__((packed, aligned(4)));
 116.283 +
 116.284 +struct sctp_setpeerprim {
 116.285 +        sctp_assoc_t            sspp_assoc_id;
 116.286 +        struct sockaddr_storage sspp_addr;
 116.287 +} __attribute__((packed, aligned(4)));
 116.288 +
 116.289 +
 116.290 +struct sctp_pdapi_event {
 116.291 +        __u16 pdapi_type;
 116.292 +        __u16 pdapi_flags;
 116.293 +        __u32 pdapi_length;
 116.294 +        __u32 pdapi_indication;
 116.295 +        sctp_assoc_t pdapi_assoc_id;
 116.296 +};
 116.297 +
 116.298 +union sctp_notification {
 116.299 +        struct {
 116.300 +                __u16 sn_type;             /* Notification type. */
 116.301 +                __u16 sn_flags;
 116.302 +                __u32 sn_length;
 116.303 +        } sn_header;
 116.304 +        struct sctp_assoc_change sn_assoc_change;
 116.305 +        struct sctp_paddr_change sn_paddr_change;
 116.306 +        struct sctp_remote_error sn_remote_error;
 116.307 +        struct sctp_send_failed sn_send_failed;
 116.308 +        struct sctp_shutdown_event sn_shutdown_event;
 116.309 +        struct sctp_adaptation_event sn_adaptation_event;
 116.310 +        struct sctp_pdapi_event sn_pdapi_event;
 116.311 +};
 116.312 +
 116.313 +#endif /* SCTP_INITMSG */
 116.314 +
 116.315 +/* Function types to support dynamic linking of socket API extension functions
 116.316 + * for SCTP. This is so that there is no linkage depandancy during build or
 116.317 + * runtime for libsctp.*/
 116.318 +typedef int sctp_getladdrs_func(int sd, sctp_assoc_t id, struct sockaddr **addrs);
 116.319 +typedef int sctp_freeladdrs_func(struct sockaddr *addrs);
 116.320 +typedef int sctp_getpaddrs_func(int sd, sctp_assoc_t id, struct sockaddr **addrs);
 116.321 +typedef int sctp_freepaddrs_func(struct sockaddr *addrs);
 116.322 +typedef int sctp_bindx_func(int sd, struct sockaddr *addrs, int addrcnt, int flags);
 116.323 +typedef int sctp_peeloff_func(int sock, sctp_assoc_t id);
 116.324 +
 116.325 +
 116.326 +#endif /* __linux__ */
 116.327 +
 116.328 +sctp_getladdrs_func* nio_sctp_getladdrs;
 116.329 +sctp_freeladdrs_func* nio_sctp_freeladdrs;
 116.330 +sctp_getpaddrs_func* nio_sctp_getpaddrs;
 116.331 +sctp_freepaddrs_func* nio_sctp_freepaddrs;
 116.332 +sctp_bindx_func* nio_sctp_bindx;
 116.333 +sctp_peeloff_func* nio_sctp_peeloff;
 116.334 +
 116.335 +jboolean loadSocketExtensionFuncs(JNIEnv* env);
 116.336 +
 116.337 +#endif /* !SUN_NIO_CH_SCTP_H */
   117.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   117.2 +++ b/src/solaris/native/sun/nio/ch/sctp/SctpChannelImpl.c	Sat Feb 18 16:11:47 2012 -0800
   117.3 @@ -0,0 +1,596 @@
   117.4 +/*
   117.5 + * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
   117.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   117.7 + *
   117.8 + * This code is free software; you can redistribute it and/or modify it
   117.9 + * under the terms of the GNU General Public License version 2 only, as
  117.10 + * published by the Free Software Foundation.  Oracle designates this
  117.11 + * particular file as subject to the "Classpath" exception as provided
  117.12 + * by Oracle in the LICENSE file that accompanied this code.
  117.13 + *
  117.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
  117.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  117.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  117.17 + * version 2 for more details (a copy is included in the LICENSE file that
  117.18 + * accompanied this code).
  117.19 + *
  117.20 + * You should have received a copy of the GNU General Public License version
  117.21 + * 2 along with this work; if not, write to the Free Software Foundation,
  117.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  117.23 + *
  117.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  117.25 + * or visit www.oracle.com if you need additional information or have any
  117.26 + * questions.
  117.27 + */
  117.28 +
  117.29 +#include <stdlib.h>
  117.30 +#include <string.h>
  117.31 +#include "Sctp.h"
  117.32 +
  117.33 +#include "jni.h"
  117.34 +#include "nio_util.h"
  117.35 +#include "nio.h"
  117.36 +#include "net_util.h"
  117.37 +#include "net_util_md.h"
  117.38 +#include "sun_nio_ch_sctp_SctpNet.h"
  117.39 +#include "sun_nio_ch_sctp_SctpChannelImpl.h"
  117.40 +#include "sun_nio_ch_sctp_AssociationChange.h"
  117.41 +#include "sun_nio_ch_sctp_ResultContainer.h"
  117.42 +#include "sun_nio_ch_sctp_PeerAddrChange.h"
  117.43 +
  117.44 +/* sizeof(union sctp_notification */
  117.45 +#define NOTIFICATION_BUFFER_SIZE 280
  117.46 +
  117.47 +#define MESSAGE_IMPL_CLASS              "sun/nio/ch/sctp/MessageInfoImpl"
  117.48 +#define RESULT_CONTAINER_CLASS          "sun/nio/ch/sctp/ResultContainer"
  117.49 +#define SEND_FAILED_CLASS               "sun/nio/ch/sctp/SendFailed"
  117.50 +#define ASSOC_CHANGE_CLASS              "sun/nio/ch/sctp/AssociationChange"
  117.51 +#define PEER_CHANGE_CLASS               "sun/nio/ch/sctp/PeerAddrChange"
  117.52 +#define SHUTDOWN_CLASS                  "sun/nio/ch/sctp/Shutdown"
  117.53 +
  117.54 +struct controlData {
  117.55 +    int assocId;
  117.56 +    unsigned short streamNumber;
  117.57 +    jboolean unordered;
  117.58 +    unsigned int ppid;
  117.59 +};
  117.60 +
  117.61 +static jclass    smi_class;    /* sun.nio.ch.sctp.MessageInfoImpl            */
  117.62 +static jmethodID smi_ctrID;    /* sun.nio.ch.sctp.MessageInfoImpl.<init>     */
  117.63 +static jfieldID  src_valueID;  /* sun.nio.ch.sctp.ResultContainer.value      */
  117.64 +static jfieldID  src_typeID;   /* sun.nio.ch.sctp.ResultContainer.type       */
  117.65 +static jclass    ssf_class;    /* sun.nio.ch.sctp.SendFailed                 */
  117.66 +static jmethodID ssf_ctrID;    /* sun.nio.ch.sctp.SendFailed.<init>          */
  117.67 +static jclass    sac_class;    /* sun.nio.ch.sctp.AssociationChange          */
  117.68 +static jmethodID sac_ctrID;    /* sun.nio.ch.sctp.AssociationChange.<init>   */
  117.69 +static jclass    spc_class;    /* sun.nio.ch.sctp.PeerAddressChanged         */
  117.70 +static jmethodID spc_ctrID;    /* sun.nio.ch.sctp.PeerAddressChanged.<init>  */
  117.71 +static jclass    ss_class;     /* sun.nio.ch.sctp.Shutdown                   */
  117.72 +static jmethodID ss_ctrID;     /* sun.nio.ch.sctp.Shutdown.<init>            */
  117.73 +static jfieldID  isa_addrID;   /* java.net.InetSocketAddress.addr            */
  117.74 +static jfieldID  isa_portID;   /* java.net.InetSocketAddress.port            */
  117.75 +
  117.76 +/* defined in SctpNet.c */
  117.77 +jobject SockAddrToInetSocketAddress(JNIEnv* env, struct sockaddr* addr);
  117.78 +
  117.79 +jint handleSocketError(JNIEnv *env, jint errorValue);
  117.80 +
  117.81 +/* use SocketChannelImpl's checkConnect implementation */
  117.82 +extern jint Java_sun_nio_ch_SocketChannelImpl_checkConnect(JNIEnv* env,
  117.83 +    jobject this, jobject fdo, jboolean block, jboolean ready);
  117.84 +
  117.85 +/*
  117.86 + * Class:     sun_nio_ch_sctp_SctpChannelImpl
  117.87 + * Method:    initIDs
  117.88 + * Signature: ()V
  117.89 + */
  117.90 +JNIEXPORT void JNICALL Java_sun_nio_ch_sctp_SctpChannelImpl_initIDs
  117.91 +  (JNIEnv *env, jclass klass) {
  117.92 +    jclass cls;
  117.93 +
  117.94 +    /* MessageInfoImpl */
  117.95 +    cls = (*env)->FindClass(env, MESSAGE_IMPL_CLASS);
  117.96 +    CHECK_NULL(cls);
  117.97 +    smi_class = (*env)->NewGlobalRef(env, cls);
  117.98 +    CHECK_NULL(smi_class);
  117.99 +    smi_ctrID = (*env)->GetMethodID(env, cls, "<init>",
 117.100 +            "(ILjava/net/SocketAddress;IIZZI)V");
 117.101 +    CHECK_NULL(smi_ctrID);
 117.102 +
 117.103 +    /* ResultContainer */
 117.104 +    cls = (*env)->FindClass(env, RESULT_CONTAINER_CLASS);
 117.105 +    CHECK_NULL(cls);
 117.106 +    src_valueID = (*env)->GetFieldID(env, cls, "value", "Ljava/lang/Object;");
 117.107 +    CHECK_NULL(src_valueID);
 117.108 +    src_typeID = (*env)->GetFieldID(env, cls, "type", "I");
 117.109 +    CHECK_NULL(src_typeID);
 117.110 +
 117.111 +    /* SendFailed */
 117.112 +    cls = (*env)->FindClass(env, SEND_FAILED_CLASS);
 117.113 +    CHECK_NULL(cls);
 117.114 +    ssf_class = (*env)->NewGlobalRef(env, cls);
 117.115 +    CHECK_NULL(ssf_class);
 117.116 +    ssf_ctrID = (*env)->GetMethodID(env, cls, "<init>",
 117.117 +        "(ILjava/net/SocketAddress;Ljava/nio/ByteBuffer;II)V");
 117.118 +    CHECK_NULL(ssf_ctrID);
 117.119 +
 117.120 +    /* AssociationChange */
 117.121 +    cls = (*env)->FindClass(env, ASSOC_CHANGE_CLASS);
 117.122 +    CHECK_NULL(cls);
 117.123 +    sac_class = (*env)->NewGlobalRef(env, cls);
 117.124 +    CHECK_NULL(sac_class);
 117.125 +    sac_ctrID = (*env)->GetMethodID(env, cls, "<init>", "(IIII)V");
 117.126 +    CHECK_NULL(sac_ctrID);
 117.127 +
 117.128 +    /* PeerAddrChange */
 117.129 +    cls = (*env)->FindClass(env, PEER_CHANGE_CLASS);
 117.130 +    CHECK_NULL(cls);
 117.131 +    spc_class = (*env)->NewGlobalRef(env, cls);
 117.132 +    CHECK_NULL(spc_class);
 117.133 +    spc_ctrID = (*env)->GetMethodID(env, cls, "<init>",
 117.134 +            "(ILjava/net/SocketAddress;I)V");
 117.135 +    CHECK_NULL(spc_ctrID);
 117.136 +
 117.137 +    /* Shutdown */
 117.138 +    cls = (*env)->FindClass(env, SHUTDOWN_CLASS);
 117.139 +    CHECK_NULL(cls);
 117.140 +    ss_class = (*env)->NewGlobalRef(env, cls);
 117.141 +    CHECK_NULL(ss_class);
 117.142 +    ss_ctrID = (*env)->GetMethodID(env, cls, "<init>", "(I)V");
 117.143 +    CHECK_NULL(ss_ctrID);
 117.144 +
 117.145 +    /* InetSocketAddress */
 117.146 +    cls = (*env)->FindClass(env, "java/net/InetSocketAddress");
 117.147 +    CHECK_NULL(cls);
 117.148 +    isa_addrID = (*env)->GetFieldID(env, cls, "addr", "Ljava/net/InetAddress;");
 117.149 +    CHECK_NULL(isa_addrID);
 117.150 +    isa_portID = (*env)->GetFieldID(env, cls, "port", "I");
 117.151 +}
 117.152 +
 117.153 +void getControlData
 117.154 +  (struct msghdr* msg, struct controlData* cdata) {
 117.155 +    struct cmsghdr* cmsg;
 117.156 +
 117.157 +    for (cmsg = CMSG_FIRSTHDR(msg); cmsg != NULL; cmsg = CMSG_NXTHDR(msg, cmsg)) {
 117.158 +        if (cmsg->cmsg_level == IPPROTO_SCTP && cmsg->cmsg_type == SCTP_SNDRCV) {
 117.159 +            struct sctp_sndrcvinfo *sri;
 117.160 +
 117.161 +            sri = (struct sctp_sndrcvinfo *) CMSG_DATA(cmsg);
 117.162 +            cdata->assocId = sri->sinfo_assoc_id;
 117.163 +            cdata->streamNumber = sri->sinfo_stream;
 117.164 +            cdata->unordered = (sri->sinfo_flags & SCTP_UNORDERED) ? JNI_TRUE :
 117.165 +                JNI_FALSE;
 117.166 +            cdata->ppid = ntohl(sri->sinfo_ppid);
 117.167 +
 117.168 +            return;
 117.169 +        }
 117.170 +    }
 117.171 +    return;
 117.172 +}
 117.173 +
 117.174 +void setControlData
 117.175 +  (struct msghdr* msg, struct controlData* cdata) {
 117.176 +    struct cmsghdr* cmsg;
 117.177 +    struct sctp_sndrcvinfo *sri;
 117.178 +
 117.179 +    cmsg = CMSG_FIRSTHDR(msg);
 117.180 +    cmsg->cmsg_level = IPPROTO_SCTP;
 117.181 +    cmsg->cmsg_type = SCTP_SNDRCV;
 117.182 +    cmsg->cmsg_len = CMSG_LEN(sizeof(struct sctp_sndrcvinfo));
 117.183 +
 117.184 +    /* Initialize the payload */
 117.185 +    sri = (struct sctp_sndrcvinfo*) CMSG_DATA(cmsg);
 117.186 +    memset(sri, 0, sizeof (*sri));
 117.187 +
 117.188 +    if (cdata->streamNumber > 0) {
 117.189 +        sri->sinfo_stream = cdata->streamNumber;
 117.190 +    }
 117.191 +    if (cdata->assocId > 0) {
 117.192 +        sri->sinfo_assoc_id = cdata->assocId;
 117.193 +    }
 117.194 +    if (cdata->unordered == JNI_TRUE) {
 117.195 +        sri->sinfo_flags = sri->sinfo_flags | SCTP_UNORDERED;
 117.196 +    }
 117.197 +
 117.198 +    if (cdata->ppid > 0) {
 117.199 +        sri->sinfo_ppid = htonl(cdata->ppid);
 117.200 +    }
 117.201 +
 117.202 +    /* Sum of the length of all control messages in the buffer. */
 117.203 +    msg->msg_controllen = cmsg->cmsg_len;
 117.204 +}
 117.205 +
 117.206 +// TODO: test: can create send failed without any data? if so need to
 117.207 +// update API so that buffer can be null if no data.
 117.208 +void handleSendFailed
 117.209 +  (JNIEnv* env, int fd, jobject resultContainerObj, struct sctp_send_failed *ssf,
 117.210 +   int read, jboolean isEOR, struct sockaddr* sap) {
 117.211 +    jobject bufferObj = NULL, resultObj, isaObj;
 117.212 +    char *addressP;
 117.213 +    struct sctp_sndrcvinfo *sri;
 117.214 +    int remaining, dataLength;
 117.215 +
 117.216 +    /* the actual undelivered message data is directly after the ssf */
 117.217 +    int dataOffset = sizeof(struct sctp_send_failed);
 117.218 +
 117.219 +    sri = (struct sctp_sndrcvinfo*) &ssf->ssf_info;
 117.220 +
 117.221 +    /* the number of bytes remaining to be read in the sctp_send_failed notif*/
 117.222 +    remaining = ssf->ssf_length - read;
 117.223 +
 117.224 +    /* the size of the actual undelivered message */
 117.225 +    dataLength = ssf->ssf_length - dataOffset;
 117.226 +
 117.227 +    /* retrieved address from sockaddr */
 117.228 +    isaObj = SockAddrToInetSocketAddress(env, sap);
 117.229 +
 117.230 +    /* data retrieved from sff_data */
 117.231 +    if (dataLength > 0) {
 117.232 +        struct iovec iov[1];
 117.233 +        struct msghdr msg[1];
 117.234 +        int rv, alreadyRead;
 117.235 +        char *dataP = (char*) ssf;
 117.236 +        dataP += dataOffset;
 117.237 +
 117.238 +        if ((addressP = malloc(dataLength)) == NULL) {
 117.239 +            JNU_ThrowOutOfMemoryError(env, "handleSendFailed");
 117.240 +            return;
 117.241 +        }
 117.242 +
 117.243 +        memset(msg, 0, sizeof (*msg));
 117.244 +        msg->msg_iov = iov;
 117.245 +        msg->msg_iovlen = 1;
 117.246 +
 117.247 +        bufferObj = (*env)->NewDirectByteBuffer(env, addressP, dataLength);
 117.248 +        CHECK_NULL(bufferObj);
 117.249 +
 117.250 +        alreadyRead = read - dataOffset;
 117.251 +        if (alreadyRead > 0) {
 117.252 +            memcpy(addressP, /*ssf->ssf_data*/ dataP, alreadyRead);
 117.253 +            iov->iov_base = addressP + alreadyRead;
 117.254 +            iov->iov_len = dataLength - alreadyRead;
 117.255 +        } else {
 117.256 +            iov->iov_base = addressP;
 117.257 +            iov->iov_len = dataLength;
 117.258 +        }
 117.259 +
 117.260 +        if (remaining > 0) {
 117.261 +            if ((rv = recvmsg(fd, msg, 0)) < 0) {
 117.262 +                handleSocketError(env, errno);
 117.263 +                return;
 117.264 +            }
 117.265 +
 117.266 +            if (rv != (dataLength - alreadyRead) || !(msg->msg_flags & MSG_EOR)) {
 117.267 +                //TODO: assert false: "should not reach here";
 117.268 +                return;
 117.269 +            }
 117.270 +            // TODO: Set and document (in API) buffers position.
 117.271 +        }
 117.272 +    }
 117.273 +
 117.274 +    /* create SendFailed */
 117.275 +    resultObj = (*env)->NewObject(env, ssf_class, ssf_ctrID, ssf->ssf_assoc_id,
 117.276 +            isaObj, bufferObj, ssf->ssf_error, sri->sinfo_stream);
 117.277 +    CHECK_NULL(resultObj);
 117.278 +    (*env)->SetObjectField(env, resultContainerObj, src_valueID, resultObj);
 117.279 +    (*env)->SetIntField(env, resultContainerObj, src_typeID,
 117.280 +            sun_nio_ch_sctp_ResultContainer_SEND_FAILED);
 117.281 +}
 117.282 +
 117.283 +void handleAssocChange
 117.284 +  (JNIEnv* env, jobject resultContainerObj, struct sctp_assoc_change *sac) {
 117.285 +    jobject resultObj;
 117.286 +    int state = 0;
 117.287 +
 117.288 +    switch (sac->sac_state) {
 117.289 +        case SCTP_COMM_UP :
 117.290 +            state = sun_nio_ch_sctp_AssociationChange_SCTP_COMM_UP;
 117.291 +            break;
 117.292 +        case SCTP_COMM_LOST :
 117.293 +            state = sun_nio_ch_sctp_AssociationChange_SCTP_COMM_LOST;
 117.294 +            break;
 117.295 +        case SCTP_RESTART :
 117.296 +            state = sun_nio_ch_sctp_AssociationChange_SCTP_RESTART;
 117.297 +            break;
 117.298 +        case SCTP_SHUTDOWN_COMP :
 117.299 +            state = sun_nio_ch_sctp_AssociationChange_SCTP_SHUTDOWN;
 117.300 +            break;
 117.301 +        case SCTP_CANT_STR_ASSOC :
 117.302 +            state = sun_nio_ch_sctp_AssociationChange_SCTP_CANT_START;
 117.303 +    }
 117.304 +
 117.305 +    /* create AssociationChange */
 117.306 +    resultObj = (*env)->NewObject(env, sac_class, sac_ctrID, sac->sac_assoc_id,
 117.307 +        state, sac->sac_outbound_streams, sac->sac_inbound_streams);
 117.308 +    CHECK_NULL(resultObj);
 117.309 +    (*env)->SetObjectField(env, resultContainerObj, src_valueID, resultObj);
 117.310 +    (*env)->SetIntField(env, resultContainerObj, src_typeID,
 117.311 +            sun_nio_ch_sctp_ResultContainer_ASSOCIATION_CHANGED);
 117.312 +}
 117.313 +
 117.314 +void handleShutdown
 117.315 +  (JNIEnv* env, jobject resultContainerObj, struct sctp_shutdown_event* sse) {
 117.316 +    /* create Shutdown */
 117.317 +    jobject resultObj = (*env)->NewObject(env, ss_class, ss_ctrID, sse->sse_assoc_id);
 117.318 +    CHECK_NULL(resultObj);
 117.319 +    (*env)->SetObjectField(env, resultContainerObj, src_valueID, resultObj);
 117.320 +    (*env)->SetIntField(env, resultContainerObj, src_typeID,
 117.321 +            sun_nio_ch_sctp_ResultContainer_SHUTDOWN);
 117.322 +}
 117.323 +
 117.324 +void handlePeerAddrChange
 117.325 +  (JNIEnv* env, jobject resultContainerObj, struct sctp_paddr_change* spc) {
 117.326 +    int event = 0;
 117.327 +    jobject addressObj, resultObj;
 117.328 +    unsigned int state = spc->spc_state;
 117.329 +
 117.330 +    switch (state) {
 117.331 +        case SCTP_ADDR_AVAILABLE :
 117.332 +            event = sun_nio_ch_sctp_PeerAddrChange_SCTP_ADDR_AVAILABLE;
 117.333 +            break;
 117.334 +        case SCTP_ADDR_UNREACHABLE :
 117.335 +            event = sun_nio_ch_sctp_PeerAddrChange_SCTP_ADDR_UNREACHABLE;
 117.336 +            break;
 117.337 +        case SCTP_ADDR_REMOVED :
 117.338 +            event = sun_nio_ch_sctp_PeerAddrChange_SCTP_ADDR_REMOVED;
 117.339 +            break;
 117.340 +        case SCTP_ADDR_ADDED :
 117.341 +            event = sun_nio_ch_sctp_PeerAddrChange_SCTP_ADDR_ADDED;
 117.342 +            break;
 117.343 +        case SCTP_ADDR_MADE_PRIM :
 117.344 +            event = sun_nio_ch_sctp_PeerAddrChange_SCTP_ADDR_MADE_PRIM;
 117.345 +#ifdef __linux__  /* Solaris currently doesn't support SCTP_ADDR_CONFIRMED */
 117.346 +            break;
 117.347 +        case SCTP_ADDR_CONFIRMED :
 117.348 +            event = sun_nio_ch_sctp_PeerAddrChange_SCTP_ADDR_CONFIRMED;
 117.349 +#endif  /* __linux__ */
 117.350 +    }
 117.351 +
 117.352 +    addressObj = SockAddrToInetSocketAddress(env, (struct sockaddr*)&spc->spc_aaddr);
 117.353 +
 117.354 +    /* create PeerAddressChanged */
 117.355 +    resultObj = (*env)->NewObject(env, spc_class, spc_ctrID, spc->spc_assoc_id,
 117.356 +            addressObj, event);
 117.357 +    CHECK_NULL(resultObj);
 117.358 +    (*env)->SetObjectField(env, resultContainerObj, src_valueID, resultObj);
 117.359 +    (*env)->SetIntField(env, resultContainerObj, src_typeID,
 117.360 +            sun_nio_ch_sctp_ResultContainer_PEER_ADDRESS_CHANGED);
 117.361 +}
 117.362 +
 117.363 +void handleUninteresting
 117.364 +  (union sctp_notification *snp) {
 117.365 +    //fprintf(stdout,"\nNative: handleUninterestingNotification: Receive notification type [%u]", snp->sn_header.sn_type);
 117.366 +}
 117.367 +
 117.368 +/**
 117.369 + * Handle notifications from the SCTP stack.
 117.370 + * Returns JNI_TRUE if the notification is one that is of interest to the
 117.371 + * Java API, otherwise JNI_FALSE.
 117.372 + */
 117.373 +jboolean handleNotification
 117.374 +  (JNIEnv* env, int fd, jobject resultContainerObj, union sctp_notification* snp,
 117.375 +   int read, jboolean isEOR, struct sockaddr* sap) {
 117.376 +    switch (snp->sn_header.sn_type) {
 117.377 +        case SCTP_SEND_FAILED:
 117.378 +            handleSendFailed(env, fd, resultContainerObj, &snp->sn_send_failed,
 117.379 +                    read, isEOR, sap);
 117.380 +            return JNI_TRUE;
 117.381 +        case SCTP_ASSOC_CHANGE:
 117.382 +            handleAssocChange(env, resultContainerObj, &snp->sn_assoc_change);
 117.383 +            return JNI_TRUE;
 117.384 +        case SCTP_SHUTDOWN_EVENT:
 117.385 +            handleShutdown(env, resultContainerObj, &snp->sn_shutdown_event);
 117.386 +            return JNI_TRUE;
 117.387 +        case SCTP_PEER_ADDR_CHANGE:
 117.388 +            handlePeerAddrChange(env, resultContainerObj, &snp->sn_paddr_change);
 117.389 +            return JNI_TRUE;
 117.390 +        default :
 117.391 +            /* the Java API is not interested in this event, maybe we are? */
 117.392 +            handleUninteresting(snp);
 117.393 +    }
 117.394 +    return JNI_FALSE;
 117.395 +}
 117.396 +
 117.397 +void handleMessage
 117.398 +  (JNIEnv* env, jobject resultContainerObj, struct msghdr* msg,int read,
 117.399 +   jboolean isEOR, struct sockaddr* sap) {
 117.400 +    jobject isa, resultObj;
 117.401 +    struct controlData cdata[1];
 117.402 +
 117.403 +    if (read == 0) {
 117.404 +        /* we reached EOF */
 117.405 +        read = -1;
 117.406 +    }
 117.407 +
 117.408 +    isa = SockAddrToInetSocketAddress(env, sap);
 117.409 +    getControlData(msg, cdata);
 117.410 +
 117.411 +    /* create MessageInfoImpl */
 117.412 +    resultObj = (*env)->NewObject(env, smi_class, smi_ctrID, cdata->assocId,
 117.413 +                                  isa, read, cdata->streamNumber,
 117.414 +                                  isEOR ? JNI_TRUE : JNI_FALSE,
 117.415 +                                  cdata->unordered, cdata->ppid);
 117.416 +    CHECK_NULL(resultObj);
 117.417 +    (*env)->SetObjectField(env, resultContainerObj, src_valueID, resultObj);
 117.418 +    (*env)->SetIntField(env, resultContainerObj, src_typeID,
 117.419 +                        sun_nio_ch_sctp_ResultContainer_MESSAGE);
 117.420 +}
 117.421 +
 117.422 +/*
 117.423 + * Class:     sun_nio_ch_sctp_SctpChannelImpl
 117.424 + * Method:    receive0
 117.425 + * Signature: (ILsun/nio/ch/sctp/ResultContainer;JIZ)I
 117.426 + */
 117.427 +JNIEXPORT jint JNICALL Java_sun_nio_ch_sctp_SctpChannelImpl_receive0
 117.428 +  (JNIEnv *env, jclass klass, jint fd, jobject resultContainerObj,
 117.429 +   jlong address, jint length, jboolean peek) {
 117.430 +    SOCKADDR sa;
 117.431 +    int sa_len = sizeof(sa);
 117.432 +    ssize_t rv = 0;
 117.433 +    jlong *addr = jlong_to_ptr(address);
 117.434 +    struct iovec iov[1];
 117.435 +    struct msghdr msg[1];
 117.436 +    char cbuf[CMSG_SPACE(sizeof (struct sctp_sndrcvinfo))];
 117.437 +    int flags = peek == JNI_TRUE ? MSG_PEEK : 0;
 117.438 +
 117.439 +    /* Set up the msghdr structure for receiving */
 117.440 +    memset(msg, 0, sizeof (*msg));
 117.441 +    msg->msg_name = &sa;
 117.442 +    msg->msg_namelen = sa_len;
 117.443 +    iov->iov_base = addr;
 117.444 +    iov->iov_len = length;
 117.445 +    msg->msg_iov = iov;
 117.446 +    msg->msg_iovlen = 1;
 117.447 +    msg->msg_control = cbuf;
 117.448 +    msg->msg_controllen = sizeof(cbuf);
 117.449 +    msg->msg_flags = 0;
 117.450 +
 117.451 +    do {
 117.452 +        if ((rv = recvmsg(fd, msg, flags)) < 0) {
 117.453 +            if (errno == EWOULDBLOCK) {
 117.454 +                return IOS_UNAVAILABLE;
 117.455 +            } else if (errno == EINTR) {
 117.456 +                return IOS_INTERRUPTED;
 117.457 +
 117.458 +#ifdef __linux__
 117.459 +            } else if (errno == ENOTCONN) {
 117.460 +                /* ENOTCONN when EOF reached */
 117.461 +                rv = 0;
 117.462 +                /* there will be no control data */
 117.463 +                msg->msg_controllen = 0;
 117.464 +#endif /* __linux__ */
 117.465 +
 117.466 +            } else {
 117.467 +                handleSocketError(env, errno);
 117.468 +                return 0;
 117.469 +            }
 117.470 +        }
 117.471 +
 117.472 +        if (msg->msg_flags & MSG_NOTIFICATION) {
 117.473 +            char *bufp = (char*)addr;
 117.474 +            union sctp_notification *snp;
 117.475 +
 117.476 +            if (!(msg->msg_flags & MSG_EOR) && length < NOTIFICATION_BUFFER_SIZE) {
 117.477 +                char buf[NOTIFICATION_BUFFER_SIZE];
 117.478 +                int rvSAVE = rv;
 117.479 +                memcpy(buf, addr, rv);
 117.480 +                iov->iov_base = buf + rv;
 117.481 +                iov->iov_len = NOTIFICATION_BUFFER_SIZE - rv;
 117.482 +                if ((rv = recvmsg(fd, msg, flags)) < 0) {
 117.483 +                    handleSocketError(env, errno);
 117.484 +                    return 0;
 117.485 +                }
 117.486 +                bufp = buf;
 117.487 +                rv += rvSAVE;
 117.488 +            }
 117.489 +            snp = (union sctp_notification *) bufp;
 117.490 +            if (handleNotification(env, fd, resultContainerObj, snp, rv,
 117.491 +                                   (msg->msg_flags & MSG_EOR),
 117.492 +                                   (struct sockaddr*)&sa ) == JNI_TRUE) {
 117.493 +                /* We have received a notification that is of interest to
 117.494 +                   to the Java API. The appropriate notification will be
 117.495 +                   set in the result container. */
 117.496 +                return 0;
 117.497 +            }
 117.498 +
 117.499 +            // set iov back to addr, and reset msg_controllen
 117.500 +            iov->iov_base = addr;
 117.501 +            iov->iov_len = length;
 117.502 +            msg->msg_control = cbuf;
 117.503 +            msg->msg_controllen = sizeof(cbuf);
 117.504 +        }
 117.505 +    } while (msg->msg_flags & MSG_NOTIFICATION);
 117.506 +
 117.507 +    handleMessage(env, resultContainerObj, msg, rv,
 117.508 +            (msg->msg_flags & MSG_EOR), (struct sockaddr*)&sa);
 117.509 +    return rv;
 117.510 +}
 117.511 +
 117.512 +/*
 117.513 + * Class:     sun_nio_ch_sctp_SctpChannelImpl
 117.514 + * Method:    send0
 117.515 + * Signature: (IJILjava/net/SocketAddress;IIZI)I
 117.516 + */
 117.517 +JNIEXPORT jint JNICALL Java_sun_nio_ch_sctp_SctpChannelImpl_send0
 117.518 +  (JNIEnv *env, jclass klass, jint fd, jlong address, jint length,
 117.519 +   jobject saTarget, jint assocId, jint streamNumber, jboolean unordered,
 117.520 +   jint ppid) {
 117.521 +    SOCKADDR sa;
 117.522 +    int sa_len = sizeof(sa);
 117.523 +    ssize_t rv = 0;
 117.524 +    jlong *addr = jlong_to_ptr(address);
 117.525 +    struct iovec iov[1];
 117.526 +    struct msghdr msg[1];
 117.527 +    int cbuf_size = CMSG_SPACE(sizeof (struct sctp_sndrcvinfo));
 117.528 +    char cbuf[CMSG_SPACE(sizeof (struct sctp_sndrcvinfo))];
 117.529 +    struct controlData cdata[1];
 117.530 +
 117.531 +    /* SctpChannel:
 117.532 +     *    saTarget may contain the preferred address or NULL to use primary,
 117.533 +     *    assocId will always be -1
 117.534 +     * SctpMultiChannell:
 117.535 +     *    Setup new association, saTarget will contain address, assocId = -1
 117.536 +     *    Association already existing, assocId != -1, saTarget = preferred addr
 117.537 +     */
 117.538 +    if (saTarget != NULL /*&& assocId <= 0*/) {
 117.539 +
 117.540 +        jobject targetAddress = (*env)->GetObjectField(env, saTarget, isa_addrID);
 117.541 +        jint targetPort = (*env)->GetIntField(env, saTarget, isa_portID);
 117.542 +
 117.543 +        if (NET_InetAddressToSockaddr(env, targetAddress, targetPort,
 117.544 +                                      (struct sockaddr *)&sa,
 117.545 +                                      &sa_len, JNI_TRUE) != 0) {
 117.546 +            return IOS_THROWN;
 117.547 +        }
 117.548 +    } else {
 117.549 +        memset(&sa, '\x0', sa_len);
 117.550 +        sa_len = 0;
 117.551 +    }
 117.552 +
 117.553 +    /* Set up the msghdr structure for sending */
 117.554 +    memset(msg, 0, sizeof (*msg));
 117.555 +    memset(cbuf, 0, cbuf_size);
 117.556 +    msg->msg_name = &sa;
 117.557 +    msg->msg_namelen = sa_len;
 117.558 +    iov->iov_base = addr;
 117.559 +    iov->iov_len = length;
 117.560 +    msg->msg_iov = iov;
 117.561 +    msg->msg_iovlen = 1;
 117.562 +    msg->msg_control = cbuf;
 117.563 +    msg->msg_controllen = cbuf_size;
 117.564 +    msg->msg_flags = 0;
 117.565 +
 117.566 +    cdata->streamNumber = streamNumber;
 117.567 +    cdata->assocId = assocId;
 117.568 +    cdata->unordered = unordered;
 117.569 +    cdata->ppid = ppid;
 117.570 +    setControlData(msg, cdata);
 117.571 +
 117.572 +    if ((rv = sendmsg(fd, msg, 0)) < 0) {
 117.573 +        if (errno == EWOULDBLOCK) {
 117.574 +            return IOS_UNAVAILABLE;
 117.575 +        } else if (errno == EINTR) {
 117.576 +            return IOS_INTERRUPTED;
 117.577 +        } else if (errno == EPIPE) {
 117.578 +            JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
 117.579 +                            "Socket is shutdown for writing");
 117.580 +        } else {
 117.581 +            handleSocketError(env, errno);
 117.582 +            return 0;
 117.583 +        }
 117.584 +    }
 117.585 +
 117.586 +    return rv;
 117.587 +}
 117.588 +
 117.589 +/*
 117.590 + * Class:     sun_nio_ch_sctp_SctpChannelImpl
 117.591 + * Method:    checkConnect
 117.592 + * Signature: (Ljava/io/FileDescriptor;ZZ)I
 117.593 + */
 117.594 +JNIEXPORT jint JNICALL Java_sun_nio_ch_sctp_SctpChannelImpl_checkConnect
 117.595 +  (JNIEnv* env, jobject this, jobject fdo, jboolean block, jboolean ready) {
 117.596 +    return Java_sun_nio_ch_SocketChannelImpl_checkConnect(env, this,
 117.597 +                                                          fdo, block, ready);
 117.598 +}
 117.599 +
   118.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   118.2 +++ b/src/solaris/native/sun/nio/ch/sctp/SctpNet.c	Sat Feb 18 16:11:47 2012 -0800
   118.3 @@ -0,0 +1,753 @@
   118.4 +/*
   118.5 + * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
   118.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   118.7 + *
   118.8 + * This code is free software; you can redistribute it and/or modify it
   118.9 + * under the terms of the GNU General Public License version 2 only, as
  118.10 + * published by the Free Software Foundation.  Oracle designates this
  118.11 + * particular file as subject to the "Classpath" exception as provided
  118.12 + * by Oracle in the LICENSE file that accompanied this code.
  118.13 + *
  118.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
  118.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  118.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  118.17 + * version 2 for more details (a copy is included in the LICENSE file that
  118.18 + * accompanied this code).
  118.19 + *
  118.20 + * You should have received a copy of the GNU General Public License version
  118.21 + * 2 along with this work; if not, write to the Free Software Foundation,
  118.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  118.23 + *
  118.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  118.25 + * or visit www.oracle.com if you need additional information or have any
  118.26 + * questions.
  118.27 + */
  118.28 +
  118.29 +#include <stdlib.h>
  118.30 +#include <string.h>
  118.31 +#include <dlfcn.h>
  118.32 +
  118.33 +#include "Sctp.h"
  118.34 +#include "jni.h"
  118.35 +#include "jni_util.h"
  118.36 +#include "nio_util.h"
  118.37 +#include "nio.h"
  118.38 +#include "net_util.h"
  118.39 +#include "net_util_md.h"
  118.40 +#include "sun_nio_ch_sctp_SctpNet.h"
  118.41 +#include "sun_nio_ch_sctp_SctpStdSocketOption.h"
  118.42 +
  118.43 +static jclass isaCls = 0;
  118.44 +static jmethodID isaCtrID = 0;
  118.45 +
  118.46 +static const char* nativeSctpLib = "libsctp.so.1";
  118.47 +static jboolean funcsLoaded = JNI_FALSE;
  118.48 +
  118.49 +JNIEXPORT jint JNICALL JNI_OnLoad
  118.50 +  (JavaVM *vm, void *reserved) {
  118.51 +    return JNI_VERSION_1_2;
  118.52 +}
  118.53 +
  118.54 +static int preCloseFD = -1;     /* File descriptor to which we dup other fd's
  118.55 +                                   before closing them for real */
  118.56 +
  118.57 +/**
  118.58 + * Loads the native sctp library that contains the socket extension
  118.59 + * functions, as well as locating the individual functions.
  118.60 + * There will be a pending exception if this method returns false.
  118.61 + */
  118.62 +jboolean loadSocketExtensionFuncs
  118.63 +  (JNIEnv* env) {
  118.64 +    if (dlopen(nativeSctpLib, RTLD_GLOBAL | RTLD_LAZY) == NULL) {
  118.65 +        JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
  118.66 +              dlerror());
  118.67 +        return JNI_FALSE;
  118.68 +    }
  118.69 +
  118.70 +    if ((nio_sctp_getladdrs = (sctp_getladdrs_func*)
  118.71 +            dlsym(RTLD_DEFAULT, "sctp_getladdrs")) == NULL) {
  118.72 +        JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
  118.73 +              dlerror());
  118.74 +        return JNI_FALSE;
  118.75 +    }
  118.76 +
  118.77 +    if ((nio_sctp_freeladdrs = (sctp_freeladdrs_func*)
  118.78 +            dlsym(RTLD_DEFAULT, "sctp_freeladdrs")) == NULL) {
  118.79 +        JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
  118.80 +              dlerror());
  118.81 +        return JNI_FALSE;
  118.82 +    }
  118.83 +
  118.84 +    if ((nio_sctp_getpaddrs = (sctp_getpaddrs_func*)
  118.85 +            dlsym(RTLD_DEFAULT, "sctp_getpaddrs")) == NULL) {
  118.86 +        JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
  118.87 +              dlerror());
  118.88 +        return JNI_FALSE;
  118.89 +    }
  118.90 +
  118.91 +    if ((nio_sctp_freepaddrs = (sctp_freepaddrs_func*)
  118.92 +            dlsym(RTLD_DEFAULT, "sctp_freepaddrs")) == NULL) {
  118.93 +        JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
  118.94 +              dlerror());
  118.95 +        return JNI_FALSE;
  118.96 +    }
  118.97 +
  118.98 +    if ((nio_sctp_bindx = (sctp_bindx_func*)
  118.99 +            dlsym(RTLD_DEFAULT, "sctp_bindx")) == NULL) {
 118.100 +        JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
 118.101 +              dlerror());
 118.102 +        return JNI_FALSE;
 118.103 +    }
 118.104 +
 118.105 +    if ((nio_sctp_peeloff = (sctp_peeloff_func*)
 118.106 +            dlsym(RTLD_DEFAULT, "sctp_peeloff")) == NULL) {
 118.107 +        JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
 118.108 +              dlerror());
 118.109 +        return JNI_FALSE;
 118.110 +    }
 118.111 +
 118.112 +    funcsLoaded = JNI_TRUE;
 118.113 +    return JNI_TRUE;
 118.114 +}
 118.115 +
 118.116 +jint
 118.117 +handleSocketError(JNIEnv *env, jint errorValue)
 118.118 +{
 118.119 +    char *xn;
 118.120 +    switch (errorValue) {
 118.121 +        case EINPROGRESS:     /* Non-blocking connect */
 118.122 +            return 0;
 118.123 +        case EPROTO:
 118.124 +            xn= JNU_JAVANETPKG "ProtocolException";
 118.125 +            break;
 118.126 +        case ECONNREFUSED:
 118.127 +            xn = JNU_JAVANETPKG "ConnectException";
 118.128 +            break;
 118.129 +        case ETIMEDOUT:
 118.130 +            xn = JNU_JAVANETPKG "ConnectException";
 118.131 +            break;
 118.132 +        case EHOSTUNREACH:
 118.133 +            xn = JNU_JAVANETPKG "NoRouteToHostException";
 118.134 +            break;
 118.135 +        case EADDRINUSE:  /* Fall through */
 118.136 +        case EADDRNOTAVAIL:
 118.137 +            xn = JNU_JAVANETPKG "BindException";
 118.138 +            break;
 118.139 +        default:
 118.140 +            xn = JNU_JAVANETPKG "SocketException";
 118.141 +            break;
 118.142 +    }
 118.143 +    errno = errorValue;
 118.144 +    JNU_ThrowByNameWithLastError(env, xn, "NioSocketError");
 118.145 +    return IOS_THROWN;
 118.146 +}
 118.147 +
 118.148 +/*
 118.149 + * Class:     sun_nio_ch_sctp_SctpNet
 118.150 + * Method:    init
 118.151 + * Signature: ()V
 118.152 + */
 118.153 +JNIEXPORT void JNICALL
 118.154 +Java_sun_nio_ch_sctp_SctpNet_init
 118.155 +  (JNIEnv *env, jclass cl) {
 118.156 +    int sp[2];
 118.157 +    if (socketpair(PF_UNIX, SOCK_STREAM, 0, sp) < 0) {
 118.158 +        JNU_ThrowIOExceptionWithLastError(env, "socketpair failed");
 118.159 +        return;
 118.160 +    }
 118.161 +    preCloseFD = sp[0];
 118.162 +    close(sp[1]);
 118.163 +}
 118.164 +
 118.165 +/*
 118.166 + * Class:     sun_nio_ch_sctp_SctpNet
 118.167 + * Method:    socket0
 118.168 + * Signature: (Z)I
 118.169 + */
 118.170 +JNIEXPORT jint JNICALL Java_sun_nio_ch_sctp_SctpNet_socket0
 118.171 +  (JNIEnv *env, jclass klass, jboolean oneToOne) {
 118.172 +    int fd;
 118.173 +    struct sctp_event_subscribe event;
 118.174 +#ifdef AF_INET6
 118.175 +    int domain = ipv6_available() ? AF_INET6 : AF_INET;
 118.176 +#else
 118.177 +    int domain = AF_INET;
 118.178 +#endif
 118.179 +
 118.180 +    /* Try to load the socket API extension functions */
 118.181 +    if (!funcsLoaded && !loadSocketExtensionFuncs(env)) {
 118.182 +        return 0;
 118.183 +    }
 118.184 +
 118.185 +    fd = socket(domain, (oneToOne ? SOCK_STREAM : SOCK_SEQPACKET), IPPROTO_SCTP);
 118.186 +
 118.187 +    if (fd < 0) {
 118.188 +        return handleSocketError(env, errno);
 118.189 +    }
 118.190 +
 118.191 +    /* Enable events */
 118.192 +    memset(&event, 0, sizeof(event));
 118.193 +    event.sctp_data_io_event = 1;
 118.194 +    event.sctp_association_event = 1;
 118.195 +    event.sctp_address_event = 1;
 118.196 +    event.sctp_send_failure_event = 1;
 118.197 +    //event.sctp_peer_error_event = 1;
 118.198 +    event.sctp_shutdown_event = 1;
 118.199 +    //event.sctp_partial_delivery_event = 1;
 118.200 +    //event.sctp_adaptation_layer_event = 1;
 118.201 +    if (setsockopt(fd, IPPROTO_SCTP, SCTP_EVENTS, &event, sizeof(event)) != 0) {
 118.202 +       handleSocketError(env, errno);
 118.203 +    }
 118.204 +    return fd;
 118.205 +}
 118.206 +
 118.207 +/*
 118.208 + * Class:     sun_nio_ch_sctp_SctpNet
 118.209 + * Method:    bindx
 118.210 + * Signature: (I[Ljava/net/InetAddress;IIZ)V
 118.211 + */
 118.212 +JNIEXPORT void JNICALL Java_sun_nio_ch_sctp_SctpNet_bindx
 118.213 +  (JNIEnv *env, jclass klass, jint fd, jobjectArray addrs, jint port,
 118.214 +   jint addrsLength, jboolean add, jboolean preferIPv6) {
 118.215 +    SOCKADDR *sap, *tmpSap;
 118.216 +    int i, sa_len = sizeof(SOCKADDR);
 118.217 +    jobject ia;
 118.218 +
 118.219 +    if (addrsLength < 1)
 118.220 +        return;
 118.221 +
 118.222 +    if ((sap = calloc(addrsLength,  sa_len)) == NULL) {
 118.223 +          JNU_ThrowOutOfMemoryError(env, "heap allocation failure");
 118.224 +        return;
 118.225 +    }
 118.226 +
 118.227 +    tmpSap = sap;
 118.228 +    for (i=0; i<addrsLength; i++) {
 118.229 +        ia = (*env)->GetObjectArrayElement(env, addrs, i);
 118.230 +        if (NET_InetAddressToSockaddr(env, ia, port, (struct sockaddr*)tmpSap,
 118.231 +                                      &sa_len, preferIPv6) != 0) {
 118.232 +            free(sap);
 118.233 +            return;
 118.234 +        }
 118.235 +        tmpSap++;
 118.236 +    }
 118.237 +
 118.238 +    if (nio_sctp_bindx(fd, (void*)sap, addrsLength, add ? SCTP_BINDX_ADD_ADDR :
 118.239 +                       SCTP_BINDX_REM_ADDR) != 0) {
 118.240 +        handleSocketError(env, errno);
 118.241 +    }
 118.242 +
 118.243 +    free(sap);
 118.244 +}
 118.245 +
 118.246 +/*
 118.247 + * Class:     sun_nio_ch_sctp_SctpNet
 118.248 + * Method:    listen0
 118.249 + * Signature: (II)V
 118.250 + */
 118.251 +JNIEXPORT void JNICALL
 118.252 +Java_sun_nio_ch_sctp_SctpNet_listen0
 118.253 +  (JNIEnv *env, jclass cl, jint fd, jint backlog) {
 118.254 +    if (listen(fd, backlog) < 0)
 118.255 +        handleSocketError(env, errno);
 118.256 +}
 118.257 +
 118.258 +/*
 118.259 + * Class:     sun_nio_ch_sctp_SctpNet
 118.260 + * Method:    connect0
 118.261 + * Signature: (ILjava/net/InetAddress;I)I
 118.262 + */
 118.263 +JNIEXPORT jint JNICALL
 118.264 +Java_sun_nio_ch_sctp_SctpNet_connect0
 118.265 +  (JNIEnv *env, jclass clazz, int fd, jobject iao, jint port) {
 118.266 +    SOCKADDR sa;
 118.267 +    int sa_len = SOCKADDR_LEN;
 118.268 +    int rv;
 118.269 +
 118.270 +    if (NET_InetAddressToSockaddr(env, iao, port, (struct sockaddr *) &sa,
 118.271 +                                  &sa_len, JNI_TRUE) != 0) {
 118.272 +        return IOS_THROWN;
 118.273 +    }
 118.274 +
 118.275 +    rv = connect(fd, (struct sockaddr *)&sa, sa_len);
 118.276 +    if (rv != 0) {
 118.277 +        if (errno == EINPROGRESS) {
 118.278 +            return IOS_UNAVAILABLE;
 118.279 +        } else if (errno == EINTR) {
 118.280 +            return IOS_INTERRUPTED;
 118.281 +        }
 118.282 +        return handleSocketError(env, errno);
 118.283 +    }
 118.284 +    return 1;
 118.285 +}
 118.286 +
 118.287 +/*
 118.288 + * Class:     sun_nio_ch_sctp_SctpNet
 118.289 + * Method:    close0
 118.290 + * Signature: (I)V
 118.291 + */
 118.292 +JNIEXPORT void JNICALL
 118.293 +Java_sun_nio_ch_sctp_SctpNet_close0
 118.294 +  (JNIEnv *env, jclass clazz, jint fd) {
 118.295 +    if (fd != -1) {
 118.296 +        int rv = close(fd);
 118.297 +        if (rv < 0)
 118.298 +            JNU_ThrowIOExceptionWithLastError(env, "Close failed");
 118.299 +    }
 118.300 +}
 118.301 +
 118.302 +/*
 118.303 + * Class:     sun_nio_ch_sctp_SctpNet
 118.304 + * Method:    preClose0
 118.305 + * Signature: (I)V
 118.306 + */
 118.307 +JNIEXPORT void JNICALL
 118.308 +Java_sun_nio_ch_sctp_SctpNet_preClose0
 118.309 +  (JNIEnv *env, jclass clazz, jint fd) {
 118.310 +    if (preCloseFD >= 0) {
 118.311 +        if (dup2(preCloseFD, fd) < 0)
 118.312 +            JNU_ThrowIOExceptionWithLastError(env, "dup2 failed");
 118.313 +    }
 118.314 +}
 118.315 +
 118.316 +void initializeISA
 118.317 +  (JNIEnv* env) {
 118.318 +    if (isaCls == 0) {
 118.319 +        jclass c = (*env)->FindClass(env, "java/net/InetSocketAddress");
 118.320 +        CHECK_NULL(c);
 118.321 +        isaCls = (*env)->NewGlobalRef(env, c);
 118.322 +        CHECK_NULL(isaCls);
 118.323 +        (*env)->DeleteLocalRef(env, c);
 118.324 +        isaCtrID = (*env)->GetMethodID(env, isaCls, "<init>",
 118.325 +                                     "(Ljava/net/InetAddress;I)V");
 118.326 +    }
 118.327 +}
 118.328 +
 118.329 +jobject SockAddrToInetSocketAddress
 118.330 +  (JNIEnv *env, struct sockaddr* sap) {
 118.331 +    int port = 0;
 118.332 +
 118.333 +    jobject ia = NET_SockaddrToInetAddress(env, sap, &port);
 118.334 +    if (ia == NULL)
 118.335 +        return NULL;
 118.336 +
 118.337 +    if (isaCls == 0) {
 118.338 +        initializeISA(env);
 118.339 +        CHECK_NULL_RETURN(isaCls, NULL);
 118.340 +    }
 118.341 +
 118.342 +    return (*env)->NewObject(env, isaCls, isaCtrID, ia, port);
 118.343 +}
 118.344 +
 118.345 +/*
 118.346 + * Class:     sun_nio_ch_sctp_SctpNet
 118.347 + * Method:    getLocalAddresses0
 118.348 + * Signature: (I)[Ljava/net/SocketAddress;
 118.349 + */
 118.350 +JNIEXPORT jobjectArray JNICALL Java_sun_nio_ch_sctp_SctpNet_getLocalAddresses0
 118.351 +  (JNIEnv *env, jclass klass, jint fd) {
 118.352 +    void *addr_buf, *laddr;
 118.353 +    struct sockaddr* sap;
 118.354 +    int i, addrCount;
 118.355 +    jobjectArray isaa;
 118.356 +
 118.357 +#ifdef __solaris__
 118.358 +    if ((addrCount = nio_sctp_getladdrs(fd, 0, (void **)&addr_buf)) == -1) {
 118.359 +#else /* __linux__ */
 118.360 +    if ((addrCount = nio_sctp_getladdrs(fd, 0, (struct sockaddr **)&addr_buf)) == -1) {
 118.361 +#endif
 118.362 +        handleSocketError(env, errno);
 118.363 +        return NULL;
 118.364 +    }
 118.365 +
 118.366 +    if (addrCount < 1)
 118.367 +        return NULL;
 118.368 +
 118.369 +    if (isaCls == 0) {
 118.370 +        initializeISA(env);
 118.371 +        CHECK_NULL_RETURN(isaCls, NULL);
 118.372 +    }
 118.373 +
 118.374 +    isaa = (*env)->NewObjectArray(env, addrCount, isaCls, NULL);
 118.375 +    if (isaa == NULL) {
 118.376 +        nio_sctp_freeladdrs(addr_buf);
 118.377 +        return NULL;
 118.378 +    }
 118.379 +
 118.380 +    laddr = addr_buf;
 118.381 +    for (i=0; i<addrCount; i++) {
 118.382 +        int port = 0;
 118.383 +        jobject isa = NULL, ia;
 118.384 +        sap = (struct sockaddr*)addr_buf;
 118.385 +        ia = NET_SockaddrToInetAddress(env, sap, &port);
 118.386 +        if (ia != NULL)
 118.387 +            isa = (*env)->NewObject(env, isaCls, isaCtrID, ia, port);
 118.388 +        if (isa != NULL)
 118.389 +            (*env)->SetObjectArrayElement(env, isaa, i, isa);
 118.390 +
 118.391 +        if (sap->sa_family == AF_INET)
 118.392 +            addr_buf = ((struct sockaddr_in*)addr_buf) + 1;
 118.393 +        else
 118.394 +            addr_buf = ((struct sockaddr_in6*)addr_buf) + 1;
 118.395 +    }
 118.396 +
 118.397 +    nio_sctp_freeladdrs(laddr);
 118.398 +    return isaa;
 118.399 +}
 118.400 +
 118.401 +jobjectArray getRemoteAddresses
 118.402 +  (JNIEnv *env, jint fd, sctp_assoc_t id) {
 118.403 +    void *addr_buf, *paddr;
 118.404 +    struct sockaddr* sap;
 118.405 +    int i, addrCount;
 118.406 +    jobjectArray isaa;
 118.407 +
 118.408 +#if __solaris__
 118.409 +    if ((addrCount = nio_sctp_getpaddrs(fd, id, (void **)&addr_buf)) == -1) {
 118.410 +#else /* __linux__ */
 118.411 +    if ((addrCount = nio_sctp_getpaddrs(fd, id, (struct sockaddr**)&addr_buf)) == -1) {
 118.412 +#endif
 118.413 +        handleSocketError(env, errno);
 118.414 +        return NULL;
 118.415 +    }
 118.416 +
 118.417 +    if (addrCount < 1)
 118.418 +        return NULL;
 118.419 +
 118.420 +    if (isaCls == 0) {
 118.421 +        initializeISA(env);
 118.422 +        CHECK_NULL_RETURN(isaCls, NULL);
 118.423 +    }
 118.424 +
 118.425 +    isaa = (*env)->NewObjectArray(env, addrCount, isaCls, NULL);
 118.426 +    if (isaa == NULL) {
 118.427 +        nio_sctp_freepaddrs(addr_buf);
 118.428 +        return NULL;
 118.429 +    }
 118.430 +
 118.431 +    paddr = addr_buf;
 118.432 +    for (i=0; i<addrCount; i++) {
 118.433 +        jobject ia, isa = NULL;
 118.434 +        int port;
 118.435 +        sap = (struct sockaddr*)addr_buf;
 118.436 +        ia = NET_SockaddrToInetAddress(env, sap, &port);
 118.437 +        if (ia != NULL)
 118.438 +            isa = (*env)->NewObject(env, isaCls, isaCtrID, ia, port);
 118.439 +        if (isa != NULL)
 118.440 +            (*env)->SetObjectArrayElement(env, isaa, i, isa);
 118.441 +
 118.442 +        if (sap->sa_family == AF_INET)
 118.443 +            addr_buf = ((struct sockaddr_in*)addr_buf) + 1;
 118.444 +        else
 118.445 +            addr_buf = ((struct sockaddr_in6*)addr_buf) + 1;
 118.446 +    }
 118.447 +
 118.448 +    nio_sctp_freepaddrs(paddr);
 118.449 +
 118.450 +    return isaa;
 118.451 +}
 118.452 +
 118.453 + /*
 118.454 + * Class:     sun_nio_ch_sctp_SctpNet
 118.455 + * Method:    getRemoteAddresses0
 118.456 + * Signature: (II)[Ljava/net/SocketAddress;
 118.457 + */
 118.458 +JNIEXPORT jobjectArray JNICALL Java_sun_nio_ch_sctp_SctpNet_getRemoteAddresses0
 118.459 +  (JNIEnv *env, jclass klass, jint fd, jint assocId) {
 118.460 +    return getRemoteAddresses(env, fd, assocId);
 118.461 +}
 118.462 +
 118.463 +/* Map the Java level option to the native level */
 118.464 +int mapSocketOption
 118.465 +  (jint cmd, int *level, int *optname) {
 118.466 +    static struct {
 118.467 +        jint cmd;
 118.468 +        int level;
 118.469 +        int optname;
 118.470 +    } const opts[] = {
 118.471 +        { sun_nio_ch_sctp_SctpStdSocketOption_SCTP_DISABLE_FRAGMENTS,   IPPROTO_SCTP, SCTP_DISABLE_FRAGMENTS },
 118.472 +        { sun_nio_ch_sctp_SctpStdSocketOption_SCTP_EXPLICIT_COMPLETE,   IPPROTO_SCTP, SCTP_EXPLICIT_EOR },
 118.473 +        { sun_nio_ch_sctp_SctpStdSocketOption_SCTP_FRAGMENT_INTERLEAVE, IPPROTO_SCTP, SCTP_FRAGMENT_INTERLEAVE },
 118.474 +        { sun_nio_ch_sctp_SctpStdSocketOption_SCTP_NODELAY,             IPPROTO_SCTP, SCTP_NODELAY },
 118.475 +        { sun_nio_ch_sctp_SctpStdSocketOption_SO_SNDBUF,                SOL_SOCKET,   SO_SNDBUF },
 118.476 +        { sun_nio_ch_sctp_SctpStdSocketOption_SO_RCVBUF,                SOL_SOCKET,   SO_RCVBUF },
 118.477 +        { sun_nio_ch_sctp_SctpStdSocketOption_SO_LINGER,                SOL_SOCKET,   SO_LINGER } };
 118.478 +
 118.479 +    int i;
 118.480 +    for (i=0; i<(int)(sizeof(opts) / sizeof(opts[0])); i++) {
 118.481 +        if (cmd == opts[i].cmd) {
 118.482 +            *level = opts[i].level;
 118.483 +            *optname = opts[i].optname;
 118.484 +            return 0;
 118.485 +        }
 118.486 +    }
 118.487 +
 118.488 +    /* not found */
 118.489 +    return -1;
 118.490 +}
 118.491 +
 118.492 +/*
 118.493 + * Class:     sun_nio_ch_sctp_SctpNet
 118.494 + * Method:    setIntOption0
 118.495 + * Signature: (III)V
 118.496 + */
 118.497 +JNIEXPORT void JNICALL Java_sun_nio_ch_sctp_SctpNet_setIntOption0
 118.498 +  (JNIEnv *env, jclass klass, jint fd, jint opt, int arg) {
 118.499 +    int klevel, kopt;
 118.500 +    int result;
 118.501 +    struct linger linger;
 118.502 +    void *parg;
 118.503 +    int arglen;
 118.504 +
 118.505 +    if (mapSocketOption(opt, &klevel, &kopt) < 0) {
 118.506 +        JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
 118.507 +                                     "Unsupported socket option");
 118.508 +        return;
 118.509 +    }
 118.510 +
 118.511 +    if (opt == sun_nio_ch_sctp_SctpStdSocketOption_SO_LINGER) {
 118.512 +        parg = (void *)&linger;
 118.513 +        arglen = sizeof(linger);
 118.514 +        if (arg >= 0) {
 118.515 +            linger.l_onoff = 1;
 118.516 +            linger.l_linger = arg;
 118.517 +        } else {
 118.518 +            linger.l_onoff = 0;
 118.519 +            linger.l_linger = 0;
 118.520 +        }
 118.521 +    } else {
 118.522 +        parg = (void *)&arg;
 118.523 +        arglen = sizeof(arg);
 118.524 +    }
 118.525 +
 118.526 +    if (NET_SetSockOpt(fd, klevel, kopt, parg, arglen) < 0) {
 118.527 +        JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
 118.528 +                                     "sun_nio_ch_sctp_SctpNet.setIntOption0");
 118.529 +    }
 118.530 +}
 118.531 +
 118.532 +/*
 118.533 + * Class:     sun_nio_ch_sctp_SctpNet
 118.534 + * Method:    getIntOption0
 118.535 + * Signature: (II)I
 118.536 + */
 118.537 +JNIEXPORT int JNICALL Java_sun_nio_ch_sctp_SctpNet_getIntOption0
 118.538 +  (JNIEnv *env, jclass klass, jint fd, jint opt) {
 118.539 +    int klevel, kopt;
 118.540 +    int result;
 118.541 +    struct linger linger;
 118.542 +    void *arg;
 118.543 +    int arglen;
 118.544 +
 118.545 +    if (mapSocketOption(opt, &klevel, &kopt) < 0) {
 118.546 +        JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
 118.547 +                                     "Unsupported socket option");
 118.548 +        return -1;
 118.549 +    }
 118.550 +
 118.551 +    if (opt == sun_nio_ch_sctp_SctpStdSocketOption_SO_LINGER) {
 118.552 +        arg = (void *)&linger;
 118.553 +        arglen = sizeof(linger);
 118.554 +    } else {
 118.555 +        arg = (void *)&result;
 118.556 +        arglen = sizeof(result);
 118.557 +    }
 118.558 +
 118.559 +    if (NET_GetSockOpt(fd, klevel, kopt, arg, &arglen) < 0) {
 118.560 +        JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
 118.561 +                                     "sun.nio.ch.Net.getIntOption");
 118.562 +        return -1;
 118.563 +    }
 118.564 +
 118.565 +    if (opt == sun_nio_ch_sctp_SctpStdSocketOption_SO_LINGER)
 118.566 +        return linger.l_onoff ? linger.l_linger : -1;
 118.567 +    else
 118.568 +        return result;
 118.569 +}
 118.570 +
 118.571 +/*
 118.572 + * Class:     sun_nio_ch_sctp_SctpNet
 118.573 + * Method:    getPrimAddrOption0
 118.574 + * Signature: (II)Ljava/net/SocketAddress;
 118.575 + */
 118.576 +JNIEXPORT jobject JNICALL Java_sun_nio_ch_sctp_SctpNet_getPrimAddrOption0
 118.577 +  (JNIEnv *env, jclass klass, jint fd, jint assocId) {
 118.578 +    struct sctp_setprim prim;
 118.579 +    unsigned int prim_len = sizeof(prim);
 118.580 +    struct sockaddr* sap = (struct sockaddr*)&prim.ssp_addr;
 118.581 +
 118.582 +    prim.ssp_assoc_id = assocId;
 118.583 +
 118.584 +    if (getsockopt(fd, IPPROTO_SCTP, SCTP_PRIMARY_ADDR, &prim, &prim_len) < 0) {
 118.585 +        JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
 118.586 +                                     "sun.nio.ch.SctpNet.getPrimAddrOption0");
 118.587 +        return NULL;
 118.588 +    }
 118.589 +
 118.590 +    return SockAddrToInetSocketAddress(env, sap);
 118.591 +}
 118.592 +
 118.593 +/*
 118.594 + * Class:     sun_nio_ch_sctp_SctpNet
 118.595 + * Method:    setPrimAddrOption0
 118.596 + * Signature: (IILjava/net/InetAddress;I)V
 118.597 + */
 118.598 +JNIEXPORT void JNICALL Java_sun_nio_ch_sctp_SctpNet_setPrimAddrOption0
 118.599 +  (JNIEnv *env, jclass klass, jint fd, jint assocId, jobject iaObj, jint port) {
 118.600 +    struct sctp_setprim prim;
 118.601 +    struct sockaddr* sap = (struct sockaddr*)&prim.ssp_addr;
 118.602 +    int sap_len;
 118.603 +
 118.604 +    if (NET_InetAddressToSockaddr(env, iaObj, port, sap,
 118.605 +                                  &sap_len, JNI_TRUE) != 0) {
 118.606 +        return;
 118.607 +    }
 118.608 +
 118.609 +    prim.ssp_assoc_id = assocId;
 118.610 +
 118.611 +    if (setsockopt(fd, IPPROTO_SCTP, SCTP_PRIMARY_ADDR, &prim, sizeof(prim)) < 0) {
 118.612 +        JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
 118.613 +                                     "sun.nio.ch.SctpNet.setPrimAddrOption0");
 118.614 +    }
 118.615 +}
 118.616 +
 118.617 +/*
 118.618 + * Class:     sun_nio_ch_sctp_SctpNet
 118.619 + * Method:    setPeerPrimAddrOption0
 118.620 + * Signature: (IILjava/net/InetAddress;I)V
 118.621 + */
 118.622 +JNIEXPORT void JNICALL Java_sun_nio_ch_sctp_SctpNet_setPeerPrimAddrOption0
 118.623 +  (JNIEnv *env, jclass klass, jint fd, jint assocId,
 118.624 +   jobject iaObj, jint port, jboolean preferIPv6) {
 118.625 +    struct sctp_setpeerprim prim;
 118.626 +    struct sockaddr* sap = (struct sockaddr*)&prim.sspp_addr;
 118.627 +    int sap_len;
 118.628 +
 118.629 +    if (NET_InetAddressToSockaddr(env, iaObj, port, sap,
 118.630 +                                  &sap_len, preferIPv6) != 0) {
 118.631 +        return;
 118.632 +    }
 118.633 +
 118.634 +    prim.sspp_assoc_id = assocId;
 118.635 +
 118.636 +    if (setsockopt(fd, IPPROTO_SCTP, SCTP_SET_PEER_PRIMARY_ADDR, &prim,
 118.637 +            sizeof(prim)) < 0) {
 118.638 +        JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
 118.639 +                                     "sun.nio.ch.SctpNet.setPeerPrimAddrOption0");
 118.640 +    }
 118.641 +}
 118.642 +
 118.643 +/*
 118.644 + * Class:     sun_nio_ch_sctp_SctpNet
 118.645 + * Method:    getInitMsgOption0
 118.646 + * Signature: (I[I)V
 118.647 + */
 118.648 +JNIEXPORT void JNICALL Java_sun_nio_ch_sctp_SctpNet_getInitMsgOption0
 118.649 +  (JNIEnv *env, jclass klass, jint fd, jintArray retVal) {
 118.650 +    struct sctp_initmsg sctp_initmsg;
 118.651 +    unsigned int sim_len = sizeof(sctp_initmsg);
 118.652 +    int vals[2];
 118.653 +
 118.654 +    if (getsockopt(fd, IPPROTO_SCTP, SCTP_INITMSG, &sctp_initmsg,
 118.655 +            &sim_len) < 0) {
 118.656 +        JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
 118.657 +                                     "sun.nio.ch.SctpNet.getInitMsgOption0");
 118.658 +        return;
 118.659 +    }
 118.660 +
 118.661 +    vals[0] = sctp_initmsg.sinit_max_instreams;
 118.662 +    vals[1] = sctp_initmsg.sinit_num_ostreams;
 118.663 +    (*env)->SetIntArrayRegion(env, retVal, 0, 2, vals);
 118.664 +}
 118.665 +
 118.666 +/*
 118.667 + * Class:     sun_nio_ch_sctp_SctpNet
 118.668 + * Method:    setInitMsgOption0
 118.669 + * Signature: (III)V
 118.670 + */
 118.671 +JNIEXPORT void JNICALL Java_sun_nio_ch_sctp_SctpNet_setInitMsgOption0
 118.672 +  (JNIEnv *env, jclass klass, jint fd, jint inArg, jint outArg) {
 118.673 +    struct sctp_initmsg sctp_initmsg;
 118.674 +
 118.675 +    sctp_initmsg.sinit_max_instreams = (unsigned int)inArg;
 118.676 +    sctp_initmsg.sinit_num_ostreams = (unsigned int)outArg;
 118.677 +    sctp_initmsg.sinit_max_attempts = 0;  // default
 118.678 +    sctp_initmsg.sinit_max_init_timeo = 0;  // default
 118.679 +
 118.680 +    if (setsockopt(fd, IPPROTO_SCTP, SCTP_INITMSG, &sctp_initmsg,
 118.681 +          sizeof(sctp_initmsg)) < 0) {
 118.682 +        JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
 118.683 +                                     "sun.nio.ch.SctpNet.setInitMsgOption0");
 118.684 +    }
 118.685 +}
 118.686 +
 118.687 +/*
 118.688 + * Class:     sun_nio_ch_sctp_SctpNet
 118.689 + * Method:    shutdown0
 118.690 + * Signature: (II)V
 118.691 + */
 118.692 +JNIEXPORT void JNICALL Java_sun_nio_ch_sctp_SctpNet_shutdown0
 118.693 +  (JNIEnv *env, jclass klass, jint fd, jint assocId) {
 118.694 +    int rv;
 118.695 +    struct msghdr msg[1];
 118.696 +    struct iovec iov[1];
 118.697 +    int cbuf_size = CMSG_SPACE(sizeof (struct sctp_sndrcvinfo));
 118.698 +    char cbuf[CMSG_SPACE(sizeof (struct sctp_sndrcvinfo))];
 118.699 +    struct cmsghdr* cmsg;
 118.700 +    struct sctp_sndrcvinfo *sri;
 118.701 +
 118.702 +    /* SctpSocketChannel */
 118.703 +    if (assocId < 0) {
 118.704 +        shutdown(fd, SHUT_WR);
 118.705 +        return;
 118.706 +    }
 118.707 +
 118.708 +    memset(msg, 0, sizeof (*msg));
 118.709 +    memset(cbuf, 0, cbuf_size);
 118.710 +    msg->msg_name = NULL;
 118.711 +    msg->msg_namelen = 0;
 118.712 +    iov->iov_base = NULL;
 118.713 +    iov->iov_len = 0;
 118.714 +    msg->msg_iov = iov;
 118.715 +    msg->msg_iovlen = 1;
 118.716 +    msg->msg_control = cbuf;
 118.717 +    msg->msg_controllen = cbuf_size;
 118.718 +    msg->msg_flags = 0;
 118.719 +
 118.720 +    cmsg = CMSG_FIRSTHDR(msg);
 118.721 +    cmsg->cmsg_level = IPPROTO_SCTP;
 118.722 +    cmsg->cmsg_type = SCTP_SNDRCV;
 118.723 +    cmsg->cmsg_len = CMSG_LEN(sizeof(struct sctp_sndrcvinfo));
 118.724 +
 118.725 +    /* Initialize the payload: */
 118.726 +    sri = (struct sctp_sndrcvinfo*) CMSG_DATA(cmsg);
 118.727 +    memset(sri, 0, sizeof (*sri));
 118.728 +
 118.729 +    if (assocId > 0) {
 118.730 +        sri->sinfo_assoc_id = assocId;
 118.731 +    }
 118.732 +
 118.733 +    sri->sinfo_flags = sri->sinfo_flags | SCTP_EOF;
 118.734 +
 118.735 +    /* Sum of the length of all control messages in the buffer. */
 118.736 +    msg->msg_controllen = cmsg->cmsg_len;
 118.737 +
 118.738 +    if ((rv = sendmsg(fd, msg, 0)) < 0) {
 118.739 +        handleSocketError(env, errno);
 118.740 +    }
 118.741 +}
 118.742 +
 118.743 +/*
 118.744 + * Class:     sun_nio_ch_sctp_SctpNet
 118.745 + * Method:    branch
 118.746 + * Signature: (II)I
 118.747 + */
 118.748 +JNIEXPORT int JNICALL Java_sun_nio_ch_sctp_SctpNet_branch0
 118.749 +  (JNIEnv *env, jclass klass, jint fd, jint assocId) {
 118.750 +    int newfd = 0;
 118.751 +    if ((newfd = nio_sctp_peeloff(fd, assocId)) < 0) {
 118.752 +        handleSocketError(env, errno);
 118.753 +    }
 118.754 +
 118.755 +    return newfd;
 118.756 +}
   119.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   119.2 +++ b/src/solaris/native/sun/nio/ch/sctp/SctpServerChannelImpl.c	Sat Feb 18 16:11:47 2012 -0800
   119.3 @@ -0,0 +1,53 @@
   119.4 +/*
   119.5 + * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
   119.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   119.7 + *
   119.8 + * This code is free software; you can redistribute it and/or modify it
   119.9 + * under the terms of the GNU General Public License version 2 only, as
  119.10 + * published by the Free Software Foundation.  Oracle designates this
  119.11 + * particular file as subject to the "Classpath" exception as provided
  119.12 + * by Oracle in the LICENSE file that accompanied this code.
  119.13 + *
  119.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
  119.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  119.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  119.17 + * version 2 for more details (a copy is included in the LICENSE file that
  119.18 + * accompanied this code).
  119.19 + *
  119.20 + * You should have received a copy of the GNU General Public License version
  119.21 + * 2 along with this work; if not, write to the Free Software Foundation,
  119.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  119.23 + *
  119.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  119.25 + * or visit www.oracle.com if you need additional information or have any
  119.26 + * questions.
  119.27 + */
  119.28 +
  119.29 +#include "sun_nio_ch_sctp_SctpServerChannelImpl.h"
  119.30 +
  119.31 +extern void Java_sun_nio_ch_ServerSocketChannelImpl_initIDs(JNIEnv* env,
  119.32 +    jclass c);
  119.33 +
  119.34 +extern jint Java_sun_nio_ch_ServerSocketChannelImpl_accept0(JNIEnv* env,
  119.35 +    jobject this, jobject ssfdo, jobject newfdo, jobjectArray isaa);
  119.36 +
  119.37 +/*
  119.38 + * Class:     sun_nio_ch_sctp_SctpServerChannelImpl
  119.39 + * Method:    initIDs
  119.40 + * Signature: ()V
  119.41 + */
  119.42 +JNIEXPORT void JNICALL Java_sun_nio_ch_sctp_SctpServerChannelImpl_initIDs
  119.43 +  (JNIEnv* env, jclass c) {
  119.44 +    Java_sun_nio_ch_ServerSocketChannelImpl_initIDs(env, c);
  119.45 +}
  119.46 +
  119.47 +/*
  119.48 + * Class:     sun_nio_ch_sctp_SctpServerChannelImpl
  119.49 + * Method:    accept0
  119.50 + * Signature: (Ljava/io/FileDescriptor;Ljava/io/FileDescriptor;[Ljava/net/InetSocketAddress;)I
  119.51 + */
  119.52 +JNIEXPORT jint JNICALL Java_sun_nio_ch_sctp_SctpServerChannelImpl_accept0
  119.53 +  (JNIEnv* env, jobject this, jobject ssfdo, jobject newfdo, jobjectArray isaa) {
  119.54 +    return Java_sun_nio_ch_ServerSocketChannelImpl_accept0(env, this,
  119.55 +                                                           ssfdo, newfdo, isaa);
  119.56 +}
   120.1 --- a/src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c	Thu Feb 16 13:01:36 2012 -0800
   120.2 +++ b/src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c	Sat Feb 18 16:11:47 2012 -0800
   120.3 @@ -605,9 +605,12 @@
   120.4  
   120.5  JNIEXPORT jbyteArray JNICALL
   120.6  Java_sun_nio_fs_UnixNativeDispatcher_readdir(JNIEnv* env, jclass this, jlong value) {
   120.7 -    char entry[sizeof(struct dirent64) + PATH_MAX + 1];
   120.8 -    struct dirent64* ptr = (struct dirent64*)&entry;
   120.9      struct dirent64* result;
  120.10 +    struct {
  120.11 +        struct dirent64 buf;
  120.12 +        char name_extra[PATH_MAX + 1 - sizeof result->d_name];
  120.13 +    } entry;
  120.14 +    struct dirent64* ptr = &entry.buf;
  120.15      int res;
  120.16      DIR* dirp = jlong_to_ptr(value);
  120.17  
   121.1 --- a/src/windows/classes/sun/nio/ch/SctpChannelImpl.java	Thu Feb 16 13:01:36 2012 -0800
   121.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   121.3 @@ -1,150 +0,0 @@
   121.4 -/*
   121.5 - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
   121.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   121.7 - *
   121.8 - * This code is free software; you can redistribute it and/or modify it
   121.9 - * under the terms of the GNU General Public License version 2 only, as
  121.10 - * published by the Free Software Foundation.  Oracle designates this
  121.11 - * particular file as subject to the "Classpath" exception as provided
  121.12 - * by Oracle in the LICENSE file that accompanied this code.
  121.13 - *
  121.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
  121.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  121.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  121.17 - * version 2 for more details (a copy is included in the LICENSE file that
  121.18 - * accompanied this code).
  121.19 - *
  121.20 - * You should have received a copy of the GNU General Public License version
  121.21 - * 2 along with this work; if not, write to the Free Software Foundation,
  121.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  121.23 - *
  121.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  121.25 - * or visit www.oracle.com if you need additional information or have any
  121.26 - * questions.
  121.27 - */
  121.28 -package sun.nio.ch;
  121.29 -
  121.30 -import java.net.SocketAddress;
  121.31 -import java.net.InetAddress;
  121.32 -import java.io.IOException;
  121.33 -import java.util.Set;
  121.34 -import java.nio.ByteBuffer;
  121.35 -import java.nio.channels.spi.SelectorProvider;
  121.36 -import com.sun.nio.sctp.Association;
  121.37 -import com.sun.nio.sctp.MessageInfo;
  121.38 -import com.sun.nio.sctp.NotificationHandler;
  121.39 -import com.sun.nio.sctp.SctpChannel;
  121.40 -import com.sun.nio.sctp.SctpSocketOption;
  121.41 -
  121.42 -/**
  121.43 - * Unimplemented.
  121.44 - */
  121.45 -public class SctpChannelImpl extends SctpChannel
  121.46 -{
  121.47 -    private static final String message = "SCTP not supported on this platform";
  121.48 -
  121.49 -    public SctpChannelImpl(SelectorProvider provider) {
  121.50 -        super(provider);
  121.51 -        throw new UnsupportedOperationException(message);
  121.52 -    }
  121.53 -
  121.54 -    @Override
  121.55 -    public Association association() {
  121.56 -        throw new UnsupportedOperationException(message);
  121.57 -    }
  121.58 -
  121.59 -    @Override
  121.60 -    public SctpChannel bind(SocketAddress local)
  121.61 -                            throws IOException {
  121.62 -        throw new UnsupportedOperationException(message);
  121.63 -    }
  121.64 -
  121.65 -    @Override
  121.66 -    public SctpChannel bindAddress(InetAddress address)
  121.67 -         throws IOException {
  121.68 -        throw new UnsupportedOperationException(message);
  121.69 -    }
  121.70 -
  121.71 -    @Override
  121.72 -    public SctpChannel unbindAddress(InetAddress address)
  121.73 -         throws IOException {
  121.74 -        throw new UnsupportedOperationException(message);
  121.75 -    }
  121.76 -
  121.77 -    @Override
  121.78 -    public boolean connect(SocketAddress remote) throws IOException {
  121.79 -        throw new UnsupportedOperationException(message);
  121.80 -    }
  121.81 -
  121.82 -    @Override
  121.83 -    public boolean connect(SocketAddress remote, int maxOutStreams,
  121.84 -       int maxInStreams) throws IOException {
  121.85 -        throw new UnsupportedOperationException(message);
  121.86 -    }
  121.87 -
  121.88 -    @Override
  121.89 -    public boolean isConnectionPending() {
  121.90 -        throw new UnsupportedOperationException(message);
  121.91 -    }
  121.92 -
  121.93 -    @Override
  121.94 -    public boolean finishConnect() throws IOException {
  121.95 -        throw new UnsupportedOperationException(message);
  121.96 -    }
  121.97 -
  121.98 -    @Override
  121.99 -    public Set<SocketAddress> getAllLocalAddresses()
 121.100 -            throws IOException {
 121.101 -        throw new UnsupportedOperationException(message);
 121.102 -    }
 121.103 -
 121.104 -    @Override
 121.105 -    public Set<SocketAddress> getRemoteAddresses()
 121.106 -            throws IOException {
 121.107 -        throw new UnsupportedOperationException(message);
 121.108 -    }
 121.109 -
 121.110 -    @Override
 121.111 -    public SctpChannel shutdown() throws IOException {
 121.112 -        throw new UnsupportedOperationException(message);
 121.113 -    }
 121.114 -
 121.115 -    @Override
 121.116 -    public <T> T getOption(SctpSocketOption<T> name)
 121.117 -            throws IOException {
 121.118 -        throw new UnsupportedOperationException(message);
 121.119 -    }
 121.120 -
 121.121 -    @Override
 121.122 -    public <T> SctpChannel setOption(SctpSocketOption<T> name, T value)
 121.123 -        throws IOException {
 121.124 -        throw new UnsupportedOperationException(message);
 121.125 -    }
 121.126 -
 121.127 -    @Override
 121.128 -    public Set<SctpSocketOption<?>> supportedOptions() {
 121.129 -        throw new UnsupportedOperationException(message);
 121.130 -    }
 121.131 -
 121.132 -    @Override
 121.133 -    public <T> MessageInfo receive(ByteBuffer dst, T attachment,
 121.134 -            NotificationHandler<T> handler) throws IOException {
 121.135 -        throw new UnsupportedOperationException(message);
 121.136 -    }
 121.137 -
 121.138 -    @Override
 121.139 -    public int send(ByteBuffer src, MessageInfo messageInfo)
 121.140 -            throws IOException {
 121.141 -        throw new UnsupportedOperationException(message);
 121.142 -    }
 121.143 -
 121.144 -    @Override
 121.145 -    protected void implConfigureBlocking(boolean block) throws IOException {
 121.146 -        throw new UnsupportedOperationException(message);
 121.147 -    }
 121.148 -
 121.149 -    @Override
 121.150 -    public void implCloseSelectableChannel() throws IOException {
 121.151 -        throw new UnsupportedOperationException(message);
 121.152 -    }
 121.153 -}
   122.1 --- a/src/windows/classes/sun/nio/ch/SctpMultiChannelImpl.java	Thu Feb 16 13:01:36 2012 -0800
   122.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   122.3 @@ -1,137 +0,0 @@
   122.4 -/*
   122.5 - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
   122.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   122.7 - *
   122.8 - * This code is free software; you can redistribute it and/or modify it
   122.9 - * under the terms of the GNU General Public License version 2 only, as
  122.10 - * published by the Free Software Foundation.  Oracle designates this
  122.11 - * particular file as subject to the "Classpath" exception as provided
  122.12 - * by Oracle in the LICENSE file that accompanied this code.
  122.13 - *
  122.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
  122.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  122.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  122.17 - * version 2 for more details (a copy is included in the LICENSE file that
  122.18 - * accompanied this code).
  122.19 - *
  122.20 - * You should have received a copy of the GNU General Public License version
  122.21 - * 2 along with this work; if not, write to the Free Software Foundation,
  122.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  122.23 - *
  122.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  122.25 - * or visit www.oracle.com if you need additional information or have any
  122.26 - * questions.
  122.27 - */
  122.28 -package sun.nio.ch;
  122.29 -
  122.30 -import java.net.SocketAddress;
  122.31 -import java.net.InetAddress;
  122.32 -import java.io.IOException;
  122.33 -import java.util.Set;
  122.34 -import java.nio.ByteBuffer;
  122.35 -import java.nio.channels.spi.SelectorProvider;
  122.36 -import com.sun.nio.sctp.Association;
  122.37 -import com.sun.nio.sctp.SctpChannel;
  122.38 -import com.sun.nio.sctp.MessageInfo;
  122.39 -import com.sun.nio.sctp.NotificationHandler;
  122.40 -import com.sun.nio.sctp.SctpMultiChannel;
  122.41 -import com.sun.nio.sctp.SctpSocketOption;
  122.42 -
  122.43 -/**
  122.44 - * Unimplemented.
  122.45 - */
  122.46 -public class SctpMultiChannelImpl extends SctpMultiChannel
  122.47 -{
  122.48 -    private static final String message = "SCTP not supported on this platform";
  122.49 -
  122.50 -    public SctpMultiChannelImpl(SelectorProvider provider) {
  122.51 -        super(provider);
  122.52 -        throw new UnsupportedOperationException(message);
  122.53 -    }
  122.54 -
  122.55 -    @Override
  122.56 -    public Set<Association> associations() {
  122.57 -        throw new UnsupportedOperationException(message);
  122.58 -    }
  122.59 -
  122.60 -    @Override
  122.61 -    public SctpMultiChannel bind(SocketAddress local,
  122.62 -            int backlog) throws IOException {
  122.63 -        throw new UnsupportedOperationException(message);
  122.64 -    }
  122.65 -
  122.66 -    @Override
  122.67 -    public SctpMultiChannel bindAddress(InetAddress address)
  122.68 -         throws IOException {
  122.69 -        throw new UnsupportedOperationException(message);
  122.70 -    }
  122.71 -
  122.72 -    @Override
  122.73 -    public SctpMultiChannel unbindAddress(InetAddress address)
  122.74 -         throws IOException {
  122.75 -        throw new UnsupportedOperationException(message);
  122.76 -    }
  122.77 -
  122.78 -    @Override
  122.79 -    public Set<SocketAddress> getAllLocalAddresses()
  122.80 -            throws IOException {
  122.81 -        throw new UnsupportedOperationException(message);
  122.82 -    }
  122.83 -
  122.84 -    @Override
  122.85 -    public Set<SocketAddress> getRemoteAddresses
  122.86 -            (Association association) throws IOException {
  122.87 -        throw new UnsupportedOperationException(message);
  122.88 -    }
  122.89 -
  122.90 -    @Override
  122.91 -    public SctpMultiChannel shutdown(Association association)
  122.92 -            throws IOException {
  122.93 -        throw new UnsupportedOperationException(message);
  122.94 -    }
  122.95 -
  122.96 -    @Override
  122.97 -    public <T> T getOption(SctpSocketOption<T> name,
  122.98 -            Association association) throws IOException {
  122.99 -        throw new UnsupportedOperationException(message);
 122.100 -    }
 122.101 -
 122.102 -    @Override
 122.103 -    public <T> SctpMultiChannel setOption(SctpSocketOption<T> name,
 122.104 -            T value, Association association) throws IOException {
 122.105 -        throw new UnsupportedOperationException(message);
 122.106 -    }
 122.107 -
 122.108 -    @Override
 122.109 -    public Set<SctpSocketOption<?>> supportedOptions() {
 122.110 -        throw new UnsupportedOperationException(message);
 122.111 -    }
 122.112 -
 122.113 -    @Override
 122.114 -    public <T> MessageInfo receive(ByteBuffer buffer, T attachment,
 122.115 -            NotificationHandler<T> handler) throws IOException {
 122.116 -        throw new UnsupportedOperationException(message);
 122.117 -    }
 122.118 -
 122.119 -    @Override
 122.120 -    public int send(ByteBuffer buffer, MessageInfo messageInfo)
 122.121 -            throws IOException {
 122.122 -        throw new UnsupportedOperationException(message);
 122.123 -    }
 122.124 -
 122.125 -    @Override
 122.126 -    public SctpChannel branch(Association association)
 122.127 -            throws IOException {
 122.128 -        throw new UnsupportedOperationException(message);
 122.129 -    }
 122.130 -
 122.131 -    @Override
 122.132 -    protected void implConfigureBlocking(boolean block) throws IOException {
 122.133 -        throw new UnsupportedOperationException(message);
 122.134 -    }
 122.135 -
 122.136 -    @Override
 122.137 -    public void implCloseSelectableChannel() throws IOException {
 122.138 -        throw new UnsupportedOperationException(message);
 122.139 -    }
 122.140 -}
   123.1 --- a/src/windows/classes/sun/nio/ch/SctpServerChannelImpl.java	Thu Feb 16 13:01:36 2012 -0800
   123.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   123.3 @@ -1,102 +0,0 @@
   123.4 -/*
   123.5 - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
   123.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   123.7 - *
   123.8 - * This code is free software; you can redistribute it and/or modify it
   123.9 - * under the terms of the GNU General Public License version 2 only, as
  123.10 - * published by the Free Software Foundation.  Oracle designates this
  123.11 - * particular file as subject to the "Classpath" exception as provided
  123.12 - * by Oracle in the LICENSE file that accompanied this code.
  123.13 - *
  123.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
  123.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  123.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  123.17 - * version 2 for more details (a copy is included in the LICENSE file that
  123.18 - * accompanied this code).
  123.19 - *
  123.20 - * You should have received a copy of the GNU General Public License version
  123.21 - * 2 along with this work; if not, write to the Free Software Foundation,
  123.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  123.23 - *
  123.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  123.25 - * or visit www.oracle.com if you need additional information or have any
  123.26 - * questions.
  123.27 - */
  123.28 -package sun.nio.ch;
  123.29 -
  123.30 -import java.net.SocketAddress;
  123.31 -import java.net.InetAddress;
  123.32 -import java.io.IOException;
  123.33 -import java.util.Set;
  123.34 -import java.nio.channels.spi.SelectorProvider;
  123.35 -import com.sun.nio.sctp.SctpChannel;
  123.36 -import com.sun.nio.sctp.SctpServerChannel;
  123.37 -import com.sun.nio.sctp.SctpSocketOption;
  123.38 -
  123.39 -/**
  123.40 - * Unimplemented.
  123.41 - */
  123.42 -public class SctpServerChannelImpl extends SctpServerChannel
  123.43 -{
  123.44 -    private static final String message = "SCTP not supported on this platform";
  123.45 -
  123.46 -    public SctpServerChannelImpl(SelectorProvider provider) {
  123.47 -        super(provider);
  123.48 -        throw new UnsupportedOperationException(message);
  123.49 -    }
  123.50 -
  123.51 -    @Override
  123.52 -    public SctpChannel accept() throws IOException {
  123.53 -        throw new UnsupportedOperationException(message);
  123.54 -    }
  123.55 -
  123.56 -    @Override
  123.57 -    public SctpServerChannel bind(SocketAddress local,
  123.58 -            int backlog) throws IOException {
  123.59 -        throw new UnsupportedOperationException(message);
  123.60 -    }
  123.61 -
  123.62 -    @Override
  123.63 -    public SctpServerChannel bindAddress(InetAddress address)
  123.64 -         throws IOException {
  123.65 -        throw new UnsupportedOperationException(message);
  123.66 -    }
  123.67 -
  123.68 -    @Override
  123.69 -    public SctpServerChannel unbindAddress(InetAddress address)
  123.70 -         throws IOException {
  123.71 -        throw new UnsupportedOperationException(message);
  123.72 -    }
  123.73 -
  123.74 -    @Override
  123.75 -    public Set<SocketAddress> getAllLocalAddresses()
  123.76 -            throws IOException {
  123.77 -        throw new UnsupportedOperationException(message);
  123.78 -    }
  123.79 -
  123.80 -    @Override
  123.81 -    public <T> T getOption(SctpSocketOption<T> name) throws IOException {
  123.82 -        throw new UnsupportedOperationException(message);
  123.83 -    }
  123.84 -
  123.85 -    @Override
  123.86 -    public <T> SctpServerChannel setOption(SctpSocketOption<T> name,
  123.87 -            T value) throws IOException {
  123.88 -        throw new UnsupportedOperationException(message);
  123.89 -    }
  123.90 -
  123.91 -    @Override
  123.92 -    public Set<SctpSocketOption<?>> supportedOptions() {
  123.93 -        throw new UnsupportedOperationException(message);
  123.94 -    }
  123.95 -
  123.96 -    @Override
  123.97 -    protected void implConfigureBlocking(boolean block) throws IOException {
  123.98 -        throw new UnsupportedOperationException(message);
  123.99 -    }
 123.100 -
 123.101 -    @Override
 123.102 -    public void implCloseSelectableChannel() throws IOException {
 123.103 -        throw new UnsupportedOperationException(message);
 123.104 -    }
 123.105 -}
   124.1 --- a/src/windows/classes/sun/nio/ch/WindowsSelectorImpl.java	Thu Feb 16 13:01:36 2012 -0800
   124.2 +++ b/src/windows/classes/sun/nio/ch/WindowsSelectorImpl.java	Sat Feb 18 16:11:47 2012 -0800
   124.3 @@ -585,7 +585,7 @@
   124.4              ((SelChImpl)selch).kill();
   124.5      }
   124.6  
   124.7 -    void putEventOps(SelectionKeyImpl sk, int ops) {
   124.8 +    public void putEventOps(SelectionKeyImpl sk, int ops) {
   124.9          synchronized (closeLock) {
  124.10              if (pollWrapper == null)
  124.11                  throw new ClosedSelectorException();
   125.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   125.2 +++ b/src/windows/classes/sun/nio/ch/sctp/SctpChannelImpl.java	Sat Feb 18 16:11:47 2012 -0800
   125.3 @@ -0,0 +1,150 @@
   125.4 +/*
   125.5 + * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
   125.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   125.7 + *
   125.8 + * This code is free software; you can redistribute it and/or modify it
   125.9 + * under the terms of the GNU General Public License version 2 only, as
  125.10 + * published by the Free Software Foundation.  Oracle designates this
  125.11 + * particular file as subject to the "Classpath" exception as provided
  125.12 + * by Oracle in the LICENSE file that accompanied this code.
  125.13 + *
  125.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
  125.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  125.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  125.17 + * version 2 for more details (a copy is included in the LICENSE file that
  125.18 + * accompanied this code).
  125.19 + *
  125.20 + * You should have received a copy of the GNU General Public License version
  125.21 + * 2 along with this work; if not, write to the Free Software Foundation,
  125.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  125.23 + *
  125.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  125.25 + * or visit www.oracle.com if you need additional information or have any
  125.26 + * questions.
  125.27 + */
  125.28 +package sun.nio.ch.sctp;
  125.29 +
  125.30 +import java.net.SocketAddress;
  125.31 +import java.net.InetAddress;
  125.32 +import java.io.IOException;
  125.33 +import java.util.Set;
  125.34 +import java.nio.ByteBuffer;
  125.35 +import java.nio.channels.spi.SelectorProvider;
  125.36 +import com.sun.nio.sctp.Association;
  125.37 +import com.sun.nio.sctp.MessageInfo;
  125.38 +import com.sun.nio.sctp.NotificationHandler;
  125.39 +import com.sun.nio.sctp.SctpChannel;
  125.40 +import com.sun.nio.sctp.SctpSocketOption;
  125.41 +
  125.42 +/**
  125.43 + * Unimplemented.
  125.44 + */
  125.45 +public class SctpChannelImpl extends SctpChannel
  125.46 +{
  125.47 +    private static final String message = "SCTP not supported on this platform";
  125.48 +
  125.49 +    public SctpChannelImpl(SelectorProvider provider) {
  125.50 +        super(provider);
  125.51 +        throw new UnsupportedOperationException(message);
  125.52 +    }
  125.53 +
  125.54 +    @Override
  125.55 +    public Association association() {
  125.56 +        throw new UnsupportedOperationException(message);
  125.57 +    }
  125.58 +
  125.59 +    @Override
  125.60 +    public SctpChannel bind(SocketAddress local)
  125.61 +                            throws IOException {
  125.62 +        throw new UnsupportedOperationException(message);
  125.63 +    }
  125.64 +
  125.65 +    @Override
  125.66 +    public SctpChannel bindAddress(InetAddress address)
  125.67 +         throws IOException {
  125.68 +        throw new UnsupportedOperationException(message);
  125.69 +    }
  125.70 +
  125.71 +    @Override
  125.72 +    public SctpChannel unbindAddress(InetAddress address)
  125.73 +         throws IOException {
  125.74 +        throw new UnsupportedOperationException(message);
  125.75 +    }
  125.76 +
  125.77 +    @Override
  125.78 +    public boolean connect(SocketAddress remote) throws IOException {
  125.79 +        throw new UnsupportedOperationException(message);
  125.80 +    }
  125.81 +
  125.82 +    @Override
  125.83 +    public boolean connect(SocketAddress remote, int maxOutStreams,
  125.84 +       int maxInStreams) throws IOException {
  125.85 +        throw new UnsupportedOperationException(message);
  125.86 +    }
  125.87 +
  125.88 +    @Override
  125.89 +    public boolean isConnectionPending() {
  125.90 +        throw new UnsupportedOperationException(message);
  125.91 +    }
  125.92 +
  125.93 +    @Override
  125.94 +    public boolean finishConnect() throws IOException {
  125.95 +        throw new UnsupportedOperationException(message);
  125.96 +    }
  125.97 +
  125.98 +    @Override
  125.99 +    public Set<SocketAddress> getAllLocalAddresses()
 125.100 +            throws IOException {
 125.101 +        throw new UnsupportedOperationException(message);
 125.102 +    }
 125.103 +
 125.104 +    @Override
 125.105 +    public Set<SocketAddress> getRemoteAddresses()
 125.106 +            throws IOException {
 125.107 +        throw new UnsupportedOperationException(message);
 125.108 +    }
 125.109 +
 125.110 +    @Override
 125.111 +    public SctpChannel shutdown() throws IOException {
 125.112 +        throw new UnsupportedOperationException(message);
 125.113 +    }
 125.114 +
 125.115 +    @Override
 125.116 +    public <T> T getOption(SctpSocketOption<T> name)
 125.117 +            throws IOException {
 125.118 +        throw new UnsupportedOperationException(message);
 125.119 +    }
 125.120 +
 125.121 +    @Override
 125.122 +    public <T> SctpChannel setOption(SctpSocketOption<T> name, T value)
 125.123 +        throws IOException {
 125.124 +        throw new UnsupportedOperationException(message);
 125.125 +    }
 125.126 +
 125.127 +    @Override
 125.128 +    public Set<SctpSocketOption<?>> supportedOptions() {
 125.129 +        throw new UnsupportedOperationException(message);
 125.130 +    }
 125.131 +
 125.132 +    @Override
 125.133 +    public <T> MessageInfo receive(ByteBuffer dst, T attachment,
 125.134 +            NotificationHandler<T> handler) throws IOException {
 125.135 +        throw new UnsupportedOperationException(message);
 125.136 +    }
 125.137 +
 125.138 +    @Override
 125.139 +    public int send(ByteBuffer src, MessageInfo messageInfo)
 125.140 +            throws IOException {
 125.141 +        throw new UnsupportedOperationException(message);
 125.142 +    }
 125.143 +
 125.144 +    @Override
 125.145 +    protected void implConfigureBlocking(boolean block) throws IOException {
 125.146 +        throw new UnsupportedOperationException(message);
 125.147 +    }
 125.148 +
 125.149 +    @Override
 125.150 +    public void implCloseSelectableChannel() throws IOException {
 125.151 +        throw new UnsupportedOperationException(message);
 125.152 +    }
 125.153 +}
   126.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   126.2 +++ b/src/windows/classes/sun/nio/ch/sctp/SctpMultiChannelImpl.java	Sat Feb 18 16:11:47 2012 -0800
   126.3 @@ -0,0 +1,137 @@
   126.4 +/*
   126.5 + * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
   126.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   126.7 + *
   126.8 + * This code is free software; you can redistribute it and/or modify it
   126.9 + * under the terms of the GNU General Public License version 2 only, as
  126.10 + * published by the Free Software Foundation.  Oracle designates this
  126.11 + * particular file as subject to the "Classpath" exception as provided
  126.12 + * by Oracle in the LICENSE file that accompanied this code.
  126.13 + *
  126.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
  126.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  126.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  126.17 + * version 2 for more details (a copy is included in the LICENSE file that
  126.18 + * accompanied this code).
  126.19 + *
  126.20 + * You should have received a copy of the GNU General Public License version
  126.21 + * 2 along with this work; if not, write to the Free Software Foundation,
  126.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  126.23 + *
  126.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  126.25 + * or visit www.oracle.com if you need additional information or have any
  126.26 + * questions.
  126.27 + */
  126.28 +package sun.nio.ch.sctp;
  126.29 +
  126.30 +import java.net.SocketAddress;
  126.31 +import java.net.InetAddress;
  126.32 +import java.io.IOException;
  126.33 +import java.util.Set;
  126.34 +import java.nio.ByteBuffer;
  126.35 +import java.nio.channels.spi.SelectorProvider;
  126.36 +import com.sun.nio.sctp.Association;
  126.37 +import com.sun.nio.sctp.SctpChannel;
  126.38 +import com.sun.nio.sctp.MessageInfo;
  126.39 +import com.sun.nio.sctp.NotificationHandler;
  126.40 +import com.sun.nio.sctp.SctpMultiChannel;
  126.41 +import com.sun.nio.sctp.SctpSocketOption;
  126.42 +
  126.43 +/**
  126.44 + * Unimplemented.
  126.45 + */
  126.46 +public class SctpMultiChannelImpl extends SctpMultiChannel
  126.47 +{
  126.48 +    private static final String message = "SCTP not supported on this platform";
  126.49 +
  126.50 +    public SctpMultiChannelImpl(SelectorProvider provider) {
  126.51 +        super(provider);
  126.52 +        throw new UnsupportedOperationException(message);
  126.53 +    }
  126.54 +
  126.55 +    @Override
  126.56 +    public Set<Association> associations() {
  126.57 +        throw new UnsupportedOperationException(message);
  126.58 +    }
  126.59 +
  126.60 +    @Override
  126.61 +    public SctpMultiChannel bind(SocketAddress local,
  126.62 +            int backlog) throws IOException {
  126.63 +        throw new UnsupportedOperationException(message);
  126.64 +    }
  126.65 +
  126.66 +    @Override
  126.67 +    public SctpMultiChannel bindAddress(InetAddress address)
  126.68 +         throws IOException {
  126.69 +        throw new UnsupportedOperationException(message);
  126.70 +    }
  126.71 +
  126.72 +    @Override
  126.73 +    public SctpMultiChannel unbindAddress(InetAddress address)
  126.74 +         throws IOException {
  126.75 +        throw new UnsupportedOperationException(message);
  126.76 +    }
  126.77 +
  126.78 +    @Override
  126.79 +    public Set<SocketAddress> getAllLocalAddresses()
  126.80 +            throws IOException {
  126.81 +        throw new UnsupportedOperationException(message);
  126.82 +    }
  126.83 +
  126.84 +    @Override
  126.85 +    public Set<SocketAddress> getRemoteAddresses
  126.86 +            (Association association) throws IOException {
  126.87 +        throw new UnsupportedOperationException(message);
  126.88 +    }
  126.89 +
  126.90 +    @Override
  126.91 +    public SctpMultiChannel shutdown(Association association)
  126.92 +            throws IOException {
  126.93 +        throw new UnsupportedOperationException(message);
  126.94 +    }
  126.95 +
  126.96 +    @Override
  126.97 +    public <T> T getOption(SctpSocketOption<T> name,
  126.98 +            Association association) throws IOException {
  126.99 +        throw new UnsupportedOperationException(message);
 126.100 +    }
 126.101 +
 126.102 +    @Override
 126.103 +    public <T> SctpMultiChannel setOption(SctpSocketOption<T> name,
 126.104 +            T value, Association association) throws IOException {
 126.105 +        throw new UnsupportedOperationException(message);
 126.106 +    }
 126.107 +
 126.108 +    @Override
 126.109 +    public Set<SctpSocketOption<?>> supportedOptions() {
 126.110 +        throw new UnsupportedOperationException(message);
 126.111 +    }
 126.112 +
 126.113 +    @Override
 126.114 +    public <T> MessageInfo receive(ByteBuffer buffer, T attachment,
 126.115 +            NotificationHandler<T> handler) throws IOException {
 126.116 +        throw new UnsupportedOperationException(message);
 126.117 +    }
 126.118 +
 126.119 +    @Override
 126.120 +    public int send(ByteBuffer buffer, MessageInfo messageInfo)
 126.121 +            throws IOException {
 126.122 +        throw new UnsupportedOperationException(message);
 126.123 +    }
 126.124 +
 126.125 +    @Override
 126.126 +    public SctpChannel branch(Association association)
 126.127 +            throws IOException {
 126.128 +        throw new UnsupportedOperationException(message);
 126.129 +    }
 126.130 +
 126.131 +    @Override
 126.132 +    protected void implConfigureBlocking(boolean block) throws IOException {
 126.133 +        throw new UnsupportedOperationException(message);
 126.134 +    }
 126.135 +
 126.136 +    @Override
 126.137 +    public void implCloseSelectableChannel() throws IOException {
 126.138 +        throw new UnsupportedOperationException(message);
 126.139 +    }
 126.140 +}
   127.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   127.2 +++ b/src/windows/classes/sun/nio/ch/sctp/SctpServerChannelImpl.java	Sat Feb 18 16:11:47 2012 -0800
   127.3 @@ -0,0 +1,102 @@
   127.4 +/*
   127.5 + * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
   127.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   127.7 + *
   127.8 + * This code is free software; you can redistribute it and/or modify it
   127.9 + * under the terms of the GNU General Public License version 2 only, as
  127.10 + * published by the Free Software Foundation.  Oracle designates this
  127.11 + * particular file as subject to the "Classpath" exception as provided
  127.12 + * by Oracle in the LICENSE file that accompanied this code.
  127.13 + *
  127.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
  127.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  127.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  127.17 + * version 2 for more details (a copy is included in the LICENSE file that
  127.18 + * accompanied this code).
  127.19 + *
  127.20 + * You should have received a copy of the GNU General Public License version
  127.21 + * 2 along with this work; if not, write to the Free Software Foundation,
  127.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  127.23 + *
  127.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  127.25 + * or visit www.oracle.com if you need additional information or have any
  127.26 + * questions.
  127.27 + */
  127.28 +package sun.nio.ch.sctp;
  127.29 +
  127.30 +import java.net.SocketAddress;
  127.31 +import java.net.InetAddress;
  127.32 +import java.io.IOException;
  127.33 +import java.util.Set;
  127.34 +import java.nio.channels.spi.SelectorProvider;
  127.35 +import com.sun.nio.sctp.SctpChannel;
  127.36 +import com.sun.nio.sctp.SctpServerChannel;
  127.37 +import com.sun.nio.sctp.SctpSocketOption;
  127.38 +
  127.39 +/**
  127.40 + * Unimplemented.
  127.41 + */
  127.42 +public class SctpServerChannelImpl extends SctpServerChannel
  127.43 +{
  127.44 +    private static final String message = "SCTP not supported on this platform";
  127.45 +
  127.46 +    public SctpServerChannelImpl(SelectorProvider provider) {
  127.47 +        super(provider);
  127.48 +        throw new UnsupportedOperationException(message);
  127.49 +    }
  127.50 +
  127.51 +    @Override
  127.52 +    public SctpChannel accept() throws IOException {
  127.53 +        throw new UnsupportedOperationException(message);
  127.54 +    }
  127.55 +
  127.56 +    @Override
  127.57 +    public SctpServerChannel bind(SocketAddress local,
  127.58 +            int backlog) throws IOException {
  127.59 +        throw new UnsupportedOperationException(message);
  127.60 +    }
  127.61 +
  127.62 +    @Override
  127.63 +    public SctpServerChannel bindAddress(InetAddress address)
  127.64 +         throws IOException {
  127.65 +        throw new UnsupportedOperationException(message);
  127.66 +    }
  127.67 +
  127.68 +    @Override
  127.69 +    public SctpServerChannel unbindAddress(InetAddress address)
  127.70 +         throws IOException {
  127.71 +        throw new UnsupportedOperationException(message);
  127.72 +    }
  127.73 +
  127.74 +    @Override
  127.75 +    public Set<SocketAddress> getAllLocalAddresses()
  127.76 +            throws IOException {
  127.77 +        throw new UnsupportedOperationException(message);
  127.78 +    }
  127.79 +
  127.80 +    @Override
  127.81 +    public <T> T getOption(SctpSocketOption<T> name) throws IOException {
  127.82 +        throw new UnsupportedOperationException(message);
  127.83 +    }
  127.84 +
  127.85 +    @Override
  127.86 +    public <T> SctpServerChannel setOption(SctpSocketOption<T> name,
  127.87 +            T value) throws IOException {
  127.88 +        throw new UnsupportedOperationException(message);
  127.89 +    }
  127.90 +
  127.91 +    @Override
  127.92 +    public Set<SctpSocketOption<?>> supportedOptions() {
  127.93 +        throw new UnsupportedOperationException(message);
  127.94 +    }
  127.95 +
  127.96 +    @Override
  127.97 +    protected void implConfigureBlocking(boolean block) throws IOException {
  127.98 +        throw new UnsupportedOperationException(message);
  127.99 +    }
 127.100 +
 127.101 +    @Override
 127.102 +    public void implCloseSelectableChannel() throws IOException {
 127.103 +        throw new UnsupportedOperationException(message);
 127.104 +    }
 127.105 +}
   128.1 --- a/test/Makefile	Thu Feb 16 13:01:36 2012 -0800
   128.2 +++ b/test/Makefile	Sat Feb 18 16:11:47 2012 -0800
   128.3 @@ -517,14 +517,14 @@
   128.4  JDK_ALL_TARGETS += jdk_nio2
   128.5  JDK_DEFAULT_TARGETS += jdk_nio2
   128.6  jdk_nio2: $(call TestDirs, java/nio/Buffer java/nio/ByteOrder \
   128.7 -          java/nio/channels java/nio/MappedByteBuffer)
   128.8 +          java/nio/channels java/nio/MappedByteBuffer sun/nio/ch)
   128.9  	$(call SharedLibraryPermissions,java/nio/channels)
  128.10  	$(call RunAgentvmBatch)
  128.11  
  128.12  # Stable agentvm testruns (minus items from PROBLEM_LIST)
  128.13  JDK_ALL_TARGETS += jdk_nio3
  128.14  JDK_DEFAULT_TARGETS += jdk_nio3
  128.15 -jdk_nio3: $(call TestDirs, sun/nio)
  128.16 +jdk_nio3: $(call TestDirs, java/nio/charset sun/nio/cs)
  128.17  	$(call RunAgentvmBatch)
  128.18  
  128.19  # All nio tests
   129.1 --- a/test/ProblemList.txt	Thu Feb 16 13:01:36 2012 -0800
   129.2 +++ b/test/ProblemList.txt	Sat Feb 18 16:11:47 2012 -0800
   129.3 @@ -211,78 +211,9 @@
   129.4  
   129.5  # jdk_management
   129.6  
   129.7 -# Failing, bug was filed: 6959636
   129.8 -javax/management/loading/LibraryLoader/LibraryLoaderTest.java   generic-all
   129.9 -
  129.10 -# Access denied messages on windows/mks, filed 6954450
  129.11 -sun/management/jmxremote/bootstrap/RmiSslNoKeyStoreTest.sh      windows-all
  129.12 -
  129.13 -# Fails on linux: KO: StringMonitor notification missed or not emitted
  129.14 -javax/management/monitor/NonComparableAttributeValueTest.java   generic-all
  129.15 -
  129.16 -# Port conflict? Fails with communication error
  129.17 -sun/management/jmxremote/bootstrap/PasswordFilePermissionTest.sh generic-all
  129.18 -
  129.19 -# Fails on Windows 2000, Test failed for iiop java.lang.NullPointerException
  129.20 -#  at org.omg.stub.javax.management.remote.rmi._RMIConnectionImpl_Tie._invoke(Unknown Source)
  129.21 -#  at com.sun.corba.se.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:653)
  129.22 -javax/management/remote/mandatory/connection/ReconnectTest.java generic-all
  129.23 -
  129.24 -# Solaris 10 sparc, NPE from org.omg.stub.javax.management.remote.rmi._RMIConnectionImpl_Tie._invoke
  129.25 -javax/management/remote/mandatory/threads/ExecutorTest.java     generic-all
  129.26 -
  129.27 -# Linux 32bit Fedora 9, IllegalStateException
  129.28 -javax/management/monitor/RuntimeExceptionTest.java              generic-all
  129.29 -
  129.30 -# Problems with rmi connection, othervm
  129.31 -javax/management/remote/mandatory/subjectDelegation/SubjectDelegation2Test.java generic-all
  129.32 -
  129.33 -# Fails with port already in use
  129.34 -sun/management/jmxremote/bootstrap/SSLConfigFilePermissionTest.sh generic-all
  129.35 -
  129.36 -# Fails with port already in use
  129.37 -sun/management/jmxremote/bootstrap/RmiRegistrySslTest.sh        generic-all
  129.38 -
  129.39 -# Windows, connection can't last that long
  129.40 -javax/management/eventService/LeaseTest.java                    generic-all
  129.41 -
  129.42 -# Linux othervm, X64, java.lang.Exception: Failed: ratio=102.4027795593753
  129.43 -javax/management/remote/mandatory/notif/ListenerScaleTest.java  generic-all
  129.44 -
  129.45 -# Windows run seems to have triggered a hotspot gc error (see 6801625)
  129.46 -com/sun/management/HotSpotDiagnosticMXBean/DumpHeap.sh          generic-all
  129.47 -
  129.48 -# rmi problem? othervm, java.lang.reflect.UndeclaredThrowableException
  129.49 -javax/management/remote/mandatory/subjectDelegation/SubjectDelegation3Test.java generic-all
  129.50 -
  129.51 -# Linux Fedora 9 32bit NPE in rmi server somehere??? othervm
  129.52 -javax/management/remote/mandatory/notif/NotificationBufferDeadlockTest.java generic-all
  129.53 -
  129.54 -# Times out on solaris sparc, with othervm
  129.55 -javax/management/eventService/AddRemoveListenerTest.java        generic-all
  129.56 -
  129.57 -# Linux i586 and x64 -server, timed out waiting for threads to expire? othervm
  129.58 -javax/management/eventService/EventClientThreadTest.java        generic-all
  129.59 -
  129.60 -# Linux i586 -server, Expected to receive 20, but got 21, othervm
  129.61 -#   Fails on Linux X64 -server 20!=21
  129.62 -javax/management/eventService/FetchingTest.java                 generic-all
  129.63 -
  129.64 -# NPE on windows 2000 i586 -client and -server
  129.65 -javax/management/eventService/CustomForwarderTest.java          windows-all
  129.66 -
  129.67 -# Windows i586 failure, callback did not complete
  129.68 -javax/management/eventService/LeaseManagerDeadlockTest.java     windows-all
  129.69 -
  129.70 -# Port already in use
  129.71 -sun/management/jmxremote/bootstrap/LocalManagementTest.sh       generic-all
  129.72 -
  129.73 -# Failed to initialize connector (also overflowing jtreg io buffers)
  129.74 -sun/management/jmxremote/bootstrap/RmiBootstrapTest.sh          generic-all
  129.75 -sun/management/jmxremote/bootstrap/RmiSslBootstrapTest.sh       generic-all
  129.76 -
  129.77 -# Windows X64, java.lang.IllegalStateException
  129.78 -javax/management/monitor/AttributeArbitraryDataTypeTest.java    generic-all
  129.79 +# 7073626
  129.80 +sun/management/jmxremote/bootstrap/RmiBootstrapTest.sh          windows-all
  129.81 +sun/management/jmxremote/bootstrap/RmiSslBootstrapTest.sh       windows-all
  129.82  
  129.83  ############################################################################
  129.84  
  129.85 @@ -410,71 +341,11 @@
  129.86  
  129.87  # jdk_rmi
  129.88  
  129.89 -# Port already in use, fails on sparc, othervm
  129.90 -java/rmi/reliability/benchmark/runRmiBench.sh                   generic-all
  129.91 +# 7140992
  129.92 +java/rmi/server/Unreferenced/finiteGCLatency/FiniteGCLatency.java generic-all
  129.93  
  129.94 -# Already in use port issues? othervm solaris
  129.95 -java/rmi/activation/rmidViaInheritedChannel/InheritedChannelNotServerSocket.java generic-all
  129.96 -java/rmi/activation/rmidViaInheritedChannel/RmidViaInheritedChannel.java generic-all
  129.97 -
  129.98 -java/rmi/transport/rapidExportUnexport/RapidExportUnexport.java         generic-all
  129.99 -java/rmi/transport/dgcDeadLock/TestImpl_Stub.java                       generic-all
 129.100 -
 129.101 -# Address already in use, othervm mode, solaris
 129.102 -java/rmi/activation/Activatable/elucidateNoSuchMethod/ElucidateNoSuchMethod.java        generic-all
 129.103 -java/rmi/activation/Activatable/forceLogSnapshot/ForceLogSnapshot.java  generic-all
 129.104 -
 129.105 -# Registry already running on port, solaris
 129.106 -java/rmi/Naming/legalRegistryNames/LegalRegistryNames.java      generic-all
 129.107 -
 129.108 -# Fails on Linux 32 and 64bit -server?, impl not garbage collected???
 129.109 -java/rmi/transport/pinLastArguments/PinLastArguments.java       generic-all
 129.110 -
 129.111 -# Times out on solaris sparc
 129.112 -java/rmi/server/RemoteServer/AddrInUse.java                     generic-all
 129.113 -
 129.114 -# Connection error on Windows i586 -server
 129.115 -#  Also connection errors in othervm on Solaris 10 sparc, same port???
 129.116 -sun/rmi/transport/tcp/DeadCachedConnection.java                 generic-all
 129.117 -
 129.118 -# Connection errors in othervm on Solaris 10 sparc, same port???
 129.119 -java/rmi/activation/Activatable/checkActivateRef/CheckActivateRef.java generic-all
 129.120 -java/rmi/activation/Activatable/checkAnnotations/CheckAnnotations.java generic-all
 129.121 -java/rmi/activation/Activatable/checkImplClassLoader/CheckImplClassLoader.java generic-all
 129.122 -java/rmi/activation/Activatable/checkRegisterInLog/CheckRegisterInLog.java generic-all
 129.123 -java/rmi/activation/Activatable/createPrivateActivable/CreatePrivateActivatable.java generic-all
 129.124 -java/rmi/activation/Activatable/downloadParameterClass/DownloadParameterClass.java generic-all
 129.125 -java/rmi/activation/Activatable/extLoadedImpl/ext.sh generic-all
 129.126 -java/rmi/activation/Activatable/inactiveGroup/InactiveGroup.java generic-all
 129.127 -java/rmi/activation/Activatable/lookupActivationSystem/LookupActivationSystem.java generic-all
 129.128 -java/rmi/activation/Activatable/nestedActivate/NestedActivate.java generic-all
 129.129 -java/rmi/activation/Activatable/restartCrashedService/RestartCrashedService.java generic-all
 129.130 -java/rmi/activation/Activatable/restartLatecomer/RestartLatecomer.java generic-all
 129.131 -java/rmi/activation/Activatable/shutdownGracefully/ShutdownGracefully.java generic-all
 129.132 -java/rmi/activation/Activatable/unregisterInactive/UnregisterInactive.java generic-all
 129.133 -java/rmi/activation/ActivateFailedException/activateFails/ActivateFails.java generic-all
 129.134 -java/rmi/activation/ActivationGroup/downloadActivationGroup/DownloadActivationGroup.java generic-all
 129.135 -java/rmi/activation/ActivationSystem/activeGroup/IdempotentActiveGroup.java generic-all
 129.136 -java/rmi/reliability/juicer/AppleUserImpl.java generic-all
 129.137 -java/rmi/server/RMISocketFactory/useSocketFactory/unicast/UseCustomSocketFactory.java generic-all
 129.138 -java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/KeepAliveDuringCall.java generic-all
 129.139 -java/rmi/transport/handshakeTimeout/HandshakeTimeout.java generic-all
 129.140 -java/rmi/activation/Activatable/restartService/RestartService.java generic-all
 129.141 -java/rmi/activation/ActivationSystem/modifyDescriptor/ModifyDescriptor.java generic-all
 129.142 -java/rmi/activation/ActivationSystem/stubClassesPermitted/StubClassesPermitted.java generic-all
 129.143 -java/rmi/activation/ActivationSystem/unregisterGroup/UnregisterGroup.java generic-all
 129.144 -java/rmi/activation/CommandEnvironment/SetChildEnv.java generic-all
 129.145 -java/rmi/registry/classPathCodebase/ClassPathCodebase.java generic-all
 129.146 -java/rmi/registry/reexport/Reexport.java generic-all
 129.147 -java/rmi/server/Unreferenced/finiteGCLatency/FiniteGCLatency.java generic-all
 129.148 -java/rmi/server/Unreferenced/leaseCheckInterval/LeaseCheckInterval.java generic-all
 129.149 -java/rmi/server/Unreferenced/unreferencedContext/UnreferencedContext.java generic-all
 129.150 -java/rmi/server/useCustomRef/UseCustomRef.java generic-all
 129.151 -java/rmi/transport/checkFQDN/CheckFQDN.java generic-all
 129.152 -java/rmi/transport/checkLeaseInfoLeak/CheckLeaseLeak.java generic-all
 129.153 -java/rmi/server/RMISocketFactory/useSocketFactory/activatable/UseCustomSocketFactory.java generic-all
 129.154 -java/rmi/server/RMISocketFactory/useSocketFactory/registry/UseCustomSocketFactory.java generic-all
 129.155 -java/rmi/server/UnicastRemoteObject/unexportObject/UnexportLeak.java generic-all
 129.156 +# 6948101
 129.157 +java/rmi/transport/pinLastArguments/PinLastArguments.java	generic-all
 129.158  
 129.159  # 7132247
 129.160  java/rmi/registry/readTest/readTest.sh				windows-all
 129.161 @@ -557,6 +428,9 @@
 129.162  
 129.163  # jdk_tools
 129.164  
 129.165 +# 6461635
 129.166 +com/sun/tools/attach/BasicTests.sh                              generic-all
 129.167 +
 129.168  # Filed 6952105
 129.169  com/sun/jdi/SuspendThreadTest.java                              generic-all
 129.170  
 129.171 @@ -572,15 +446,16 @@
 129.172  # Filed 6402201
 129.173  com/sun/jdi/ProcessAttachTest.sh                                generic-all
 129.174  
 129.175 -# Filed 6986875
 129.176 -sun/tools/jps/jps-Vvml.sh                                       generic-all
 129.177 -
 129.178  # Filed 6979016
 129.179  sun/tools/jconsole/ResourceCheckTest.sh                         generic-all
 129.180  
 129.181  # 7132203
 129.182  sun/jvmstat/monitor/MonitoredVm/CR6672135.java			generic-all
 129.183  
 129.184 +# Tests take too long
 129.185 +tools/pack200/CommandLineTests.java                         	generic-all
 129.186 +tools/pack200/Pack200Test.java                              	generic-all
 129.187 +
 129.188  ############################################################################
 129.189  
 129.190  # jdk_util
 129.191 @@ -588,11 +463,6 @@
 129.192  # Filed 6933803
 129.193  java/util/concurrent/ThreadPoolExecutor/CoreThreadTimeOut.java  generic-all
 129.194  
 129.195 -# Filed 7022325
 129.196 -# Fails with assertion error on windows
 129.197 -#   11 separate stacktraces created... file reuse problem?
 129.198 -java/util/zip/ZipFile/ReadLongZipFileName.java                  generic-all
 129.199 -
 129.200  # Filed 6772009
 129.201  java/util/concurrent/locks/ReentrantLock/CancelledLockLoops.java generic-all
 129.202  
   130.1 --- a/test/TEST.ROOT	Thu Feb 16 13:01:36 2012 -0800
   130.2 +++ b/test/TEST.ROOT	Sat Feb 18 16:11:47 2012 -0800
   130.3 @@ -4,3 +4,9 @@
   130.4  
   130.5  # The list of keywords supported in the entire test suite
   130.6  keys=2d dnd i18n
   130.7 +
   130.8 +# Tests that must run in othervm mode
   130.9 +othervm.dirs=java/rmi sun/rmi javax/management
  130.10 +
  130.11 +# Tests that cannot run concurrently
  130.12 +exclusiveAccess.dirs=java/rmi sun/rmi sun/management/jmxremote sun/tools/jstatd
   131.1 --- a/test/com/sun/management/HotSpotDiagnosticMXBean/ExecuteDiagnosticCommand.java	Thu Feb 16 13:01:36 2012 -0800
   131.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   131.3 @@ -1,64 +0,0 @@
   131.4 -/*
   131.5 - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
   131.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   131.7 - *
   131.8 - * This code is free software; you can redistribute it and/or modify it
   131.9 - * under the terms of the GNU General Public License version 2 only, as
  131.10 - * published by the Free Software Foundation.
  131.11 - *
  131.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
  131.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  131.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  131.15 - * version 2 for more details (a copy is included in the LICENSE file that
  131.16 - * accompanied this code).
  131.17 - *
  131.18 - * You should have received a copy of the GNU General Public License version
  131.19 - * 2 along with this work; if not, write to the Free Software Foundation,
  131.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  131.21 - *
  131.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  131.23 - * or visit www.oracle.com if you need additional information or have any
  131.24 - * questions.
  131.25 - */
  131.26 -
  131.27 -/*
  131.28 - * @test
  131.29 - * @bug     7104647
  131.30 - * @summary Basic Test for HotSpotDiagnosticMXBean.execute()
  131.31 - * @author  Frederic Parain
  131.32 - *
  131.33 - * @run main ExecuteDiagnosticCommand
  131.34 - */
  131.35 -
  131.36 -import com.sun.management.HotSpotDiagnosticMXBean;
  131.37 -import com.sun.management.VMOption;
  131.38 -import java.lang.management.ManagementFactory;
  131.39 -import java.util.List;
  131.40 -import javax.management.MBeanServer;
  131.41 -
  131.42 -public class ExecuteDiagnosticCommand {
  131.43 -    private static String HOTSPOT_DIAGNOSTIC_MXBEAN_NAME =
  131.44 -        "com.sun.management:type=HotSpotDiagnostic";
  131.45 -
  131.46 -    public static void main(String[] args) throws Exception {
  131.47 -        HotSpotDiagnosticMXBean mbean =
  131.48 -            ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class);
  131.49 -        executeDiagnosticCommand(mbean);
  131.50 -
  131.51 -        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
  131.52 -        mbean = ManagementFactory.newPlatformMXBeanProxy(mbs,
  131.53 -                    HOTSPOT_DIAGNOSTIC_MXBEAN_NAME,
  131.54 -                    HotSpotDiagnosticMXBean.class);
  131.55 -        executeDiagnosticCommand(mbean);
  131.56 -    }
  131.57 -
  131.58 -    private static void executeDiagnosticCommand(HotSpotDiagnosticMXBean mbean) {
  131.59 -        String s = mbean.execute("help help");
  131.60 -        System.out.println(s);
  131.61 -        s = mbean.execute("help", "help");
  131.62 -        System.out.println(s);
  131.63 -        String tab[] = { "help"};
  131.64 -        s = mbean.execute("help", tab);
  131.65 -        System.out.println(s);
  131.66 -    }
  131.67 -}
   132.1 --- a/test/com/sun/management/HotSpotDiagnosticMXBean/GetDiagnosticCommandInfo.java	Thu Feb 16 13:01:36 2012 -0800
   132.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   132.3 @@ -1,117 +0,0 @@
   132.4 -/*
   132.5 - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
   132.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   132.7 - *
   132.8 - * This code is free software; you can redistribute it and/or modify it
   132.9 - * under the terms of the GNU General Public License version 2 only, as
  132.10 - * published by the Free Software Foundation.
  132.11 - *
  132.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
  132.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  132.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  132.15 - * version 2 for more details (a copy is included in the LICENSE file that
  132.16 - * accompanied this code).
  132.17 - *
  132.18 - * You should have received a copy of the GNU General Public License version
  132.19 - * 2 along with this work; if not, write to the Free Software Foundation,
  132.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  132.21 - *
  132.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  132.23 - * or visit www.oracle.com if you need additional information or have any
  132.24 - * questions.
  132.25 - */
  132.26 -
  132.27 -/*
  132.28 - * @test
  132.29 - * @bug     7104647
  132.30 - * @summary Basic Test for HotSpotDiagnosticMXBean.getDiagnosticCommandInfo()
  132.31 - * @author  Frederic Parain
  132.32 - *
  132.33 - * @run main GetDiagnosticCommandInfo
  132.34 - */
  132.35 -
  132.36 -import com.sun.management.HotSpotDiagnosticMXBean;
  132.37 -import com.sun.management.DiagnosticCommandInfo;
  132.38 -import com.sun.management.DiagnosticCommandArgumentInfo;
  132.39 -import com.sun.management.VMOption;
  132.40 -import java.lang.management.ManagementFactory;
  132.41 -import java.util.List;
  132.42 -import javax.management.MBeanServer;
  132.43 -
  132.44 -public class GetDiagnosticCommandInfo {
  132.45 -    private static String HOTSPOT_DIAGNOSTIC_MXBEAN_NAME =
  132.46 -        "com.sun.management:type=HotSpotDiagnostic";
  132.47 -
  132.48 -    public static void main(String[] args) throws Exception {
  132.49 -        HotSpotDiagnosticMXBean mbean =
  132.50 -            ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class);
  132.51 -        checkDiagnosticCommandArguments(mbean);
  132.52 -
  132.53 -        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
  132.54 -        mbean = ManagementFactory.newPlatformMXBeanProxy(mbs,
  132.55 -                    HOTSPOT_DIAGNOSTIC_MXBEAN_NAME,
  132.56 -                    HotSpotDiagnosticMXBean.class);
  132.57 -        checkDiagnosticCommandArguments(mbean);
  132.58 -    }
  132.59 -
  132.60 -    private static void checkDiagnosticCommandArguments(HotSpotDiagnosticMXBean mbean) {
  132.61 -        // check getDiagnosticCommandInfo()
  132.62 -        StringBuilder sb = new StringBuilder();
  132.63 -        List<DiagnosticCommandInfo> infoList = mbean.getDiagnosticCommandInfo();
  132.64 -        for(DiagnosticCommandInfo info : infoList) {
  132.65 -            printCommandInfo(info,sb);
  132.66 -        }
  132.67 -        // check getDiagnosticCommandInfo(List<String>)
  132.68 -        List<String> commands = mbean.getDiagnosticCommands();
  132.69 -        List<DiagnosticCommandInfo> list2 =
  132.70 -            mbean.getDiagnosticCommandInfo(commands);
  132.71 -        for(DiagnosticCommandInfo info : list2) {
  132.72 -            printCommandInfo(info,sb);
  132.73 -        }
  132.74 -        // check getDiagnosticCommandInfo(String)
  132.75 -        for(String cmd : commands) {
  132.76 -            DiagnosticCommandInfo info2 = mbean.getDiagnosticCommandInfo(cmd);
  132.77 -            printCommandInfo(info2,sb);
  132.78 -        }
  132.79 -        System.out.println(sb.toString());
  132.80 -    }
  132.81 -
  132.82 -    private static void printCommandInfo(DiagnosticCommandInfo info,
  132.83 -                                         StringBuilder sb) {
  132.84 -        sb.append("\t").append(info.getName()).append(":\n");
  132.85 -        sb.append("\t\tDescription=").append(info.getDescription()).append("\n");
  132.86 -        sb.append("\t\tImpact=").append(info.getImpact()).append("\n");
  132.87 -        sb.append("\t\tStatus=");
  132.88 -        if (info.isEnabled()) {
  132.89 -            sb.append("Enabled\n");
  132.90 -        } else {
  132.91 -            sb.append("Disbled\n");
  132.92 -        }
  132.93 -        sb.append("\t\tArguments=");
  132.94 -        for(DiagnosticCommandArgumentInfo arg : info.getArgumentsInfo()) {
  132.95 -            printArgumentInfo(arg,sb);
  132.96 -        }
  132.97 -    }
  132.98 -
  132.99 -    private static void printArgumentInfo(DiagnosticCommandArgumentInfo info,
 132.100 -                                          StringBuilder sb) {
 132.101 -        sb.append("\t\t\t").append(info.getName()).append(":\n");
 132.102 -        sb.append("\t\t\t\tType=").append(info.getType()).append("\n");
 132.103 -        sb.append("\t\t\t\tDescription=").append(info.getDescription()).append("\n");
 132.104 -        if(info.getDefault() != null) {
 132.105 -            sb.append("\t\t\t\tDefault=").append(info.getDefault()).append("\n");
 132.106 -        }
 132.107 -        if(info.isMandatory()) {
 132.108 -            sb.append("\t\t\t\tMandatory\n");
 132.109 -        } else {
 132.110 -            sb.append("\t\t\t\tOptional\n");
 132.111 -        }
 132.112 -        if(info.isOption()) {
 132.113 -            sb.append("\t\t\t\tIs an option\n");
 132.114 -        } else {
 132.115 -            sb.append("\t\t\t\tIs an argument expected at position");
 132.116 -            sb.append(info.getPosition());
 132.117 -            sb.append("\n");
 132.118 -        }
 132.119 -    }
 132.120 -}
   133.1 --- a/test/com/sun/management/HotSpotDiagnosticMXBean/GetDiagnosticCommands.java	Thu Feb 16 13:01:36 2012 -0800
   133.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   133.3 @@ -1,62 +0,0 @@
   133.4 -/*
   133.5 - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
   133.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   133.7 - *
   133.8 - * This code is free software; you can redistribute it and/or modify it
   133.9 - * under the terms of the GNU General Public License version 2 only, as
  133.10 - * published by the Free Software Foundation.
  133.11 - *
  133.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
  133.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  133.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  133.15 - * version 2 for more details (a copy is included in the LICENSE file that
  133.16 - * accompanied this code).
  133.17 - *
  133.18 - * You should have received a copy of the GNU General Public License version
  133.19 - * 2 along with this work; if not, write to the Free Software Foundation,
  133.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  133.21 - *
  133.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  133.23 - * or visit www.oracle.com if you need additional information or have any
  133.24 - * questions.
  133.25 - */
  133.26 -
  133.27 -/*
  133.28 - * @test
  133.29 - * @bug     7104647
  133.30 - * @summary Basic Test for HotSpotDiagnosticMXBean.getDiagnosticCommands()
  133.31 - * @author  Frederic Parain
  133.32 - *
  133.33 - * @run main GetDiagnosticCommands
  133.34 - */
  133.35 -
  133.36 -import com.sun.management.HotSpotDiagnosticMXBean;
  133.37 -import com.sun.management.VMOption;
  133.38 -import java.lang.management.ManagementFactory;
  133.39 -import java.util.List;
  133.40 -import javax.management.MBeanServer;
  133.41 -
  133.42 -public class GetDiagnosticCommands {
  133.43 -    private static String HOTSPOT_DIAGNOSTIC_MXBEAN_NAME =
  133.44 -        "com.sun.management:type=HotSpotDiagnostic";
  133.45 -
  133.46 -    public static void main(String[] args) throws Exception {
  133.47 -        HotSpotDiagnosticMXBean mbean =
  133.48 -            ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class);
  133.49 -        checkDiagnosticCommands(mbean);
  133.50 -
  133.51 -        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
  133.52 -        mbean = ManagementFactory.newPlatformMXBeanProxy(mbs,
  133.53 -                    HOTSPOT_DIAGNOSTIC_MXBEAN_NAME,
  133.54 -                    HotSpotDiagnosticMXBean.class);
  133.55 -        checkDiagnosticCommands(mbean);
  133.56 -    }
  133.57 -
  133.58 -    private static void checkDiagnosticCommands(HotSpotDiagnosticMXBean mbean) {
  133.59 -        List<String> commands = mbean.getDiagnosticCommands();
  133.60 -        System.out.println("Commands:");
  133.61 -        for (String cmd : commands) {
  133.62 -            System.out.println(cmd);
  133.63 -        }
  133.64 -    }
  133.65 -}
   134.1 --- a/test/java/awt/Choice/ChoiceMouseWheelTest/ChoiceMouseWheelTest.java	Thu Feb 16 13:01:36 2012 -0800
   134.2 +++ b/test/java/awt/Choice/ChoiceMouseWheelTest/ChoiceMouseWheelTest.java	Sat Feb 18 16:11:47 2012 -0800
   134.3 @@ -96,7 +96,10 @@
   134.4  
   134.5              // Test mouse wheel over the choice
   134.6              String name = Toolkit.getDefaultToolkit().getClass().getName();
   134.7 -            if(!name.equals("sun.awt.X11.XToolkit")) { // mouse wheel doesn't work for the choice on X11, so skip it
   134.8 +
   134.9 +            // mouse wheel doesn't work for the choice on X11 and Mac, so skip it
  134.10 +            if(!name.equals("sun.awt.X11.XToolkit")
  134.11 +               && !name.equals("sun.lwawt.macosx.LWCToolkit")) {
  134.12                  robot.mouseWheel(1);
  134.13                  Util.waitForIdle(robot);
  134.14  
   135.1 --- a/test/java/awt/print/PaintSetEnabledDeadlock/PaintSetEnabledDeadlock.java	Thu Feb 16 13:01:36 2012 -0800
   135.2 +++ b/test/java/awt/print/PaintSetEnabledDeadlock/PaintSetEnabledDeadlock.java	Sat Feb 18 16:11:47 2012 -0800
   135.3 @@ -54,9 +54,12 @@
   135.4              Util.clickOnComp(frame.button, robot);
   135.5          }
   135.6  
   135.7 -        frame.panel.stop();
   135.8 +        boolean ret = frame.panel.stop();
   135.9          frame.dispose();
  135.10  
  135.11 +        if (!ret) {
  135.12 +            throw new RuntimeException("Test failed!");
  135.13 +        }
  135.14          System.out.println("Test passed.");
  135.15      }
  135.16  
  135.17 @@ -140,17 +143,19 @@
  135.18          }
  135.19      }
  135.20  
  135.21 -    public void stop() {
  135.22 +    public boolean stop() {
  135.23          active = false;
  135.24          try {
  135.25 -            synchronized (sync) {
  135.26 -                sync.notify();
  135.27 -            }
  135.28 -            synchronized (thread) {
  135.29 -                thread.wait();
  135.30 +            sync();
  135.31 +            thread.join(1000);
  135.32 +            if (thread.isAlive()) {
  135.33 +                thread.interrupt();
  135.34 +                return false;
  135.35              }
  135.36          } catch (InterruptedException ex) {
  135.37 +            return false;
  135.38          }
  135.39 +        return true;
  135.40      }
  135.41  
  135.42      public void draw() {
   136.1 --- a/test/java/nio/file/WatchService/Basic.java	Thu Feb 16 13:01:36 2012 -0800
   136.2 +++ b/test/java/nio/file/WatchService/Basic.java	Sat Feb 18 16:11:47 2012 -0800
   136.3 @@ -25,7 +25,7 @@
   136.4   * @bug 4313887 6838333 7017446
   136.5   * @summary Unit test for java.nio.file.WatchService
   136.6   * @library ..
   136.7 - * @run main/timeout=120 Basic
   136.8 + * @run main Basic
   136.9   */
  136.10  
  136.11  import java.nio.file.*;
  136.12 @@ -281,11 +281,11 @@
  136.13  
  136.14              System.out.println("poll with timeout...");
  136.15              try {
  136.16 -                long start = System.currentTimeMillis();
  136.17 +                long start = System.nanoTime();
  136.18                  key = watcher.poll(3000, TimeUnit.MILLISECONDS);
  136.19                  if (key != null)
  136.20                      throw new RuntimeException("no keys registered");
  136.21 -                long waited = System.currentTimeMillis() - start;
  136.22 +                long waited = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start);
  136.23                  if (waited < 2900)
  136.24                      throw new RuntimeException("poll was too short");
  136.25              } catch (InterruptedException x) {
  136.26 @@ -358,14 +358,14 @@
  136.27          }
  136.28  
  136.29          // assume that poll throws exception immediately
  136.30 -        long start = System.currentTimeMillis();
  136.31 +        long start = System.nanoTime();
  136.32          try {
  136.33              watcher.poll(10000, TimeUnit.MILLISECONDS);
  136.34              throw new RuntimeException("ClosedWatchServiceException not thrown");
  136.35          } catch (InterruptedException x) {
  136.36              throw new RuntimeException(x);
  136.37          } catch (ClosedWatchServiceException  x) {
  136.38 -            long waited = System.currentTimeMillis() - start;
  136.39 +            long waited = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start);
  136.40              if (waited > 5000)
  136.41                  throw new RuntimeException("poll was too long");
  136.42          }
   137.1 --- a/test/java/nio/file/WatchService/SensitivityModifier.java	Thu Feb 16 13:01:36 2012 -0800
   137.2 +++ b/test/java/nio/file/WatchService/SensitivityModifier.java	Sat Feb 18 16:11:47 2012 -0800
   137.3 @@ -23,9 +23,9 @@
   137.4  
   137.5  /* @test
   137.6   * @bug 4313887
   137.7 - * @summary Sanity test for Sun-specific sensitivyt level watch event modifier
   137.8 + * @summary Sanity test for Sun-specific sensitivity level watch event modifier
   137.9   * @library ..
  137.10 - * @run main/timeout=330 Basic
  137.11 + * @run main/timeout=240 SensitivityModifier
  137.12   */
  137.13  
  137.14  import java.nio.file.*;
  137.15 @@ -96,6 +96,7 @@
  137.16  
  137.17              // drain events (to avoid interference)
  137.18              do {
  137.19 +                key.pollEvents();
  137.20                  key.reset();
  137.21                  key = watcher.poll(1, TimeUnit.SECONDS);
  137.22              } while (key != null);
   138.1 --- a/test/java/util/concurrent/FutureTask/BlockingTaskExecutor.java	Thu Feb 16 13:01:36 2012 -0800
   138.2 +++ b/test/java/util/concurrent/FutureTask/BlockingTaskExecutor.java	Sat Feb 18 16:11:47 2012 -0800
   138.3 @@ -75,10 +75,10 @@
   138.4              throw new Error("Executor stuck");
   138.5  
   138.6          // Wait for the invocation thread to complete.
   138.7 -        thread.join(1000);
   138.8 +        thread.join(5000);
   138.9          if (thread.isAlive()) {
  138.10              thread.interrupt();
  138.11 -            thread.join(1000);
  138.12 +            thread.join(5000);
  138.13              throw new Error("invokeAll stuck");
  138.14          }
  138.15      }
   139.1 --- a/test/java/util/concurrent/ThreadPoolExecutor/Custom.java	Thu Feb 16 13:01:36 2012 -0800
   139.2 +++ b/test/java/util/concurrent/ThreadPoolExecutor/Custom.java	Sat Feb 18 16:11:47 2012 -0800
   139.3 @@ -100,8 +100,8 @@
   139.4          equal(countExecutorThreads(), threadCount);
   139.5          equal(CustomTask.births.get(), threadCount);
   139.6          tpe.shutdown();
   139.7 -        tpe.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
   139.8 -        Thread.sleep(10);
   139.9 +        tpe.awaitTermination(120, TimeUnit.SECONDS);
  139.10 +        Thread.sleep(1000);
  139.11          equal(countExecutorThreads(), 0);
  139.12  
  139.13          CustomSTPE stpe = new CustomSTPE();
  139.14 @@ -110,8 +110,8 @@
  139.15          equal(CustomSTPE.decorations.get(), threadCount);
  139.16          equal(countExecutorThreads(), threadCount);
  139.17          stpe.shutdown();
  139.18 -        stpe.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
  139.19 -        Thread.sleep(10);
  139.20 +        stpe.awaitTermination(120, TimeUnit.SECONDS);
  139.21 +        Thread.sleep(1000);
  139.22          equal(countExecutorThreads(), 0);
  139.23  
  139.24          System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
   140.1 --- a/test/java/util/concurrent/locks/Lock/FlakyMutex.java	Thu Feb 16 13:01:36 2012 -0800
   140.2 +++ b/test/java/util/concurrent/locks/Lock/FlakyMutex.java	Sat Feb 18 16:11:47 2012 -0800
   140.3 @@ -86,7 +86,7 @@
   140.4                  } catch (Throwable t) { unexpected(t); }}});}
   140.5          barrier.await();
   140.6          es.shutdown();
   140.7 -        check(es.awaitTermination(10, TimeUnit.SECONDS));
   140.8 +        check(es.awaitTermination(30, TimeUnit.SECONDS));
   140.9      }
  140.10  
  140.11      private static class FlakySync extends AbstractQueuedLongSynchronizer {
   141.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   141.2 +++ b/test/javax/crypto/CipherSpi/DirectBBRemaining.java	Sat Feb 18 16:11:47 2012 -0800
   141.3 @@ -0,0 +1,181 @@
   141.4 +/*
   141.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
   141.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   141.7 + *
   141.8 + * This code is free software; you can redistribute it and/or modify it
   141.9 + * under the terms of the GNU General Public License version 2 only, as
  141.10 + * published by the Free Software Foundation.
  141.11 + *
  141.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  141.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  141.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  141.15 + * version 2 for more details (a copy is included in the LICENSE file that
  141.16 + * accompanied this code).
  141.17 + *
  141.18 + * You should have received a copy of the GNU General Public License version
  141.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  141.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  141.21 + *
  141.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  141.23 + * or visit www.oracle.com if you need additional information or have any
  141.24 + * questions.
  141.25 + */
  141.26 +
  141.27 +/**
  141.28 + * @test
  141.29 + * @bug 7142509
  141.30 + * @summary Cipher.doFinal(ByteBuffer,ByteBuffer) fails to
  141.31 + *     process when in.remaining() == 0
  141.32 + */
  141.33 +
  141.34 +import java.nio.ByteBuffer;
  141.35 +import java.security.SecureRandom;
  141.36 +import java.util.Arrays;
  141.37 +import java.util.Random;
  141.38 +
  141.39 +import javax.crypto.Cipher;
  141.40 +import javax.crypto.SecretKey;
  141.41 +import javax.crypto.spec.SecretKeySpec;
  141.42 +
  141.43 +/*
  141.44 + * Simple test case to show that Cipher.doFinal(ByteBuffer, ByteBuffer) fails to
  141.45 + * process the data internally buffered inBB the cipher when input.remaining()
  141.46 + * == 0 and at least one buffer is a direct buffer.
  141.47 + */
  141.48 +public class DirectBBRemaining {
  141.49 +
  141.50 +    private static Random random = new SecureRandom();
  141.51 +    private static int testSizes = 40;
  141.52 +    private static int outputFrequency = 5;
  141.53 +
  141.54 +    public static void main(String args[]) throws Exception {
  141.55 +        boolean failedOnce = false;
  141.56 +        Exception failedReason = null;
  141.57 +
  141.58 +        byte[] keyBytes = new byte[8];
  141.59 +        random.nextBytes(keyBytes);
  141.60 +        SecretKey key = new SecretKeySpec(keyBytes, "DES");
  141.61 +
  141.62 +        Cipher cipher = Cipher.getInstance("DES/CBC/PKCS5Padding", "SunJCE");
  141.63 +        cipher.init(Cipher.ENCRYPT_MODE, key);
  141.64 +
  141.65 +        /*
  141.66 +         * Iterate through various sizes to make sure that the code does empty
  141.67 +         * blocks, single partial blocks, 1 full block, full + partial blocks,
  141.68 +         * multiple full blocks, etc. 5 blocks (using DES) is probably overkill
  141.69 +         * but will feel more confident the fix isn't breaking anything.
  141.70 +         */
  141.71 +        System.out.println("Output test results for every "
  141.72 +                + outputFrequency + " tests...");
  141.73 +
  141.74 +        for (int size = 0; size <= testSizes; size++) {
  141.75 +            boolean output = (size % outputFrequency) == 0;
  141.76 +            if (output) {
  141.77 +                System.out.print("\nTesting buffer size: " + size + ":");
  141.78 +            }
  141.79 +
  141.80 +            int outSize = cipher.getOutputSize(size);
  141.81 +
  141.82 +            try {
  141.83 +                encrypt(cipher, size,
  141.84 +                        ByteBuffer.allocate(size),
  141.85 +                        ByteBuffer.allocate(outSize),
  141.86 +                        ByteBuffer.allocateDirect(size),
  141.87 +                        ByteBuffer.allocateDirect(outSize),
  141.88 +                        output);
  141.89 +            } catch (Exception e) {
  141.90 +                System.out.print("\n    Failed with size " + size);
  141.91 +                failedOnce = true;
  141.92 +                failedReason = e;
  141.93 +
  141.94 +                // If we got an exception, let's be safe for future
  141.95 +                // testing and reset the cipher to a known good state.
  141.96 +                cipher.init(Cipher.ENCRYPT_MODE, key);
  141.97 +            }
  141.98 +        }
  141.99 +        if (failedOnce) {
 141.100 +            throw failedReason;
 141.101 +        }
 141.102 +        System.out.println("\nTest Passed...");
 141.103 +    }
 141.104 +
 141.105 +    private enum TestVariant {
 141.106 +
 141.107 +        HEAP_HEAP, HEAP_DIRECT, DIRECT_HEAP, DIRECT_DIRECT
 141.108 +    };
 141.109 +
 141.110 +    private static void encrypt(Cipher cipher, int size,
 141.111 +            ByteBuffer heapIn, ByteBuffer heapOut,
 141.112 +            ByteBuffer directIn, ByteBuffer directOut,
 141.113 +            boolean output) throws Exception {
 141.114 +
 141.115 +        ByteBuffer inBB = null;
 141.116 +        ByteBuffer outBB = null;
 141.117 +
 141.118 +        // Set up data and encrypt to known/expected values.
 141.119 +        byte[] testdata = new byte[size];
 141.120 +        random.nextBytes(testdata);
 141.121 +        byte[] expected = cipher.doFinal(testdata);
 141.122 +
 141.123 +        for (TestVariant tv : TestVariant.values()) {
 141.124 +            if (output) {
 141.125 +                System.out.print(" " + tv);
 141.126 +            }
 141.127 +
 141.128 +            switch (tv) {
 141.129 +            case HEAP_HEAP:
 141.130 +                inBB = heapIn;
 141.131 +                outBB = heapOut;
 141.132 +                break;
 141.133 +            case HEAP_DIRECT:
 141.134 +                inBB = heapIn;
 141.135 +                outBB = directOut;
 141.136 +                break;
 141.137 +            case DIRECT_HEAP:
 141.138 +                inBB = directIn;
 141.139 +                outBB = heapOut;
 141.140 +                break;
 141.141 +            case DIRECT_DIRECT:
 141.142 +                inBB = directIn;
 141.143 +                outBB = directOut;
 141.144 +                break;
 141.145 +            }
 141.146 +
 141.147 +            inBB.clear();
 141.148 +            outBB.clear();
 141.149 +
 141.150 +            inBB.put(testdata);
 141.151 +            inBB.flip();
 141.152 +
 141.153 +            // Process all data in one shot, but don't call doFinal() yet.
 141.154 +            // May store up to n-1 bytes (w/block size n) internally.
 141.155 +            cipher.update(inBB, outBB);
 141.156 +            if (inBB.hasRemaining()) {
 141.157 +                throw new Exception("buffer not empty");
 141.158 +            }
 141.159 +
 141.160 +            // finish encryption and process all data buffered
 141.161 +            cipher.doFinal(inBB, outBB);
 141.162 +            outBB.flip();
 141.163 +
 141.164 +            // validate output size
 141.165 +            if (outBB.remaining() != expected.length) {
 141.166 +                throw new Exception(
 141.167 +                        "incomplete encryption output, expected "
 141.168 +                        + expected.length + " bytes but was only "
 141.169 +                        + outBB.remaining() + " bytes");
 141.170 +            }
 141.171 +
 141.172 +            // validate output data
 141.173 +            byte[] encrypted = new byte[outBB.remaining()];
 141.174 +            outBB.get(encrypted);
 141.175 +            if (!Arrays.equals(expected, encrypted)) {
 141.176 +                throw new Exception("bad encryption output");
 141.177 +            }
 141.178 +
 141.179 +            if (!Arrays.equals(cipher.doFinal(), cipher.doFinal())) {
 141.180 +                throw new Exception("Internal buffers still held data!");
 141.181 +            }
 141.182 +        }
 141.183 +    }
 141.184 +}
   142.1 --- a/test/javax/security/auth/x500/X500Principal/Parse.java	Thu Feb 16 13:01:36 2012 -0800
   142.2 +++ b/test/javax/security/auth/x500/X500Principal/Parse.java	Sat Feb 18 16:11:47 2012 -0800
   142.3 @@ -1,5 +1,5 @@
   142.4  /*
   142.5 - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
   142.6 + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
   142.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   142.8   *
   142.9   * This code is free software; you can redistribute it and/or modify it
  142.10 @@ -23,7 +23,7 @@
  142.11  
  142.12  /*
  142.13   * @test
  142.14 - * @bug 7024771
  142.15 + * @bug 7024771 7024604
  142.16   * @summary various X500Principal DN parsing tests
  142.17   */
  142.18  
  142.19 @@ -32,12 +32,18 @@
  142.20  public class Parse {
  142.21  
  142.22      private static TestCase[] testCases = {
  142.23 -        new TestCase("CN=prefix\\<>suffix", false)
  142.24 +        new TestCase("CN=prefix\\<>suffix", false),
  142.25 +        new TestCase("OID.1=value", false),
  142.26 +        new TestCase("oid.1=value", false),
  142.27 +        new TestCase("OID.1.2=value", true),
  142.28 +        new TestCase("oid.1.2=value", true),
  142.29 +        new TestCase("1=value", false),
  142.30 +        new TestCase("1.2=value", true)
  142.31      };
  142.32  
  142.33      public static void main(String args[]) throws Exception {
  142.34 -        for (int i = 0; i < testCases.length; i++) {
  142.35 -            testCases[i].run();
  142.36 +        for (TestCase testCase : testCases) {
  142.37 +            testCase.run();
  142.38          }
  142.39          System.out.println("Test completed ok.");
  142.40      }
   143.1 --- a/test/javax/swing/JFileChooser/6396844/TwentyThousandTest.java	Thu Feb 16 13:01:36 2012 -0800
   143.2 +++ b/test/javax/swing/JFileChooser/6396844/TwentyThousandTest.java	Sat Feb 18 16:11:47 2012 -0800
   143.3 @@ -1,5 +1,5 @@
   143.4  /*
   143.5 - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
   143.6 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
   143.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   143.8   *
   143.9   * This code is free software; you can redistribute it and/or modify it
  143.10 @@ -26,28 +26,29 @@
  143.11   * @bug 6396844
  143.12   * @summary Tests memory leak for 20000 files
  143.13   * @author Sergey Malenkov
  143.14 - * @run main/othervm/timeout=1000 -mx256m TwentyThousandTest
  143.15 + * @library ../../regtesthelpers
  143.16 + * @build Util
  143.17 + * @run main/othervm/timeout=1000 -mx128m TwentyThousandTest
  143.18   */
  143.19  
  143.20 +import sun.java2d.Disposer;
  143.21 +import sun.java2d.DisposerRecord;
  143.22 +
  143.23  import javax.swing.*;
  143.24 -import java.awt.event.ActionEvent;
  143.25 -import java.awt.event.ActionListener;
  143.26 +import java.awt.event.HierarchyEvent;
  143.27 +import java.awt.event.HierarchyListener;
  143.28  import java.io.File;
  143.29  import java.io.FileWriter;
  143.30  
  143.31 -public class TwentyThousandTest implements ActionListener, Runnable {
  143.32 +public class TwentyThousandTest {
  143.33  
  143.34      private static final int FILES = 20000;
  143.35 -    private static final int ATTEMPTS = 100;
  143.36 +    private static final int ATTEMPTS = 20;
  143.37      private static final int INTERVAL = 100;
  143.38  
  143.39 -    private static final boolean ALWAYS_NEW_INSTANCE = false;
  143.40 -    private static final boolean UPDATE_UI_EACH_INTERVAL = true;
  143.41 -    private static final boolean AUTO_CLOSE_DIALOG = true;
  143.42 +    private static String tmpDir;
  143.43  
  143.44 -    private static JFileChooser CHOOSER;
  143.45 -
  143.46 -    private static String tmpDir;
  143.47 +    private static volatile boolean disposerComplete;
  143.48  
  143.49      public static void main(String[] args) throws Exception {
  143.50          tmpDir = System.getProperty("java.io.tmpdir");
  143.51 @@ -77,15 +78,13 @@
  143.52  
  143.53              System.out.println("Do " + ATTEMPTS + " attempts for " + laf.getClassName());
  143.54  
  143.55 -            for ( int i = 0; i < ATTEMPTS; i++ ) {
  143.56 +            for (int i = 0; i < ATTEMPTS; i++) {
  143.57                  System.out.print(i + " ");
  143.58  
  143.59                  doAttempt();
  143.60              }
  143.61  
  143.62              System.out.println();
  143.63 -
  143.64 -            CHOOSER = null;
  143.65          }
  143.66  
  143.67          System.out.println("Removing " + FILES + " files");
  143.68 @@ -94,7 +93,7 @@
  143.69              getTempFile(i).delete();
  143.70          }
  143.71  
  143.72 -        System.out.println( "Test passed successfully" );
  143.73 +        System.out.println("Test passed successfully");
  143.74      }
  143.75  
  143.76      private static File getTempFile(int i) {
  143.77 @@ -104,48 +103,55 @@
  143.78      private static void doAttempt() throws Exception {
  143.79          SwingUtilities.invokeAndWait(new Runnable() {
  143.80              public void run() {
  143.81 -                if ( ALWAYS_NEW_INSTANCE || ( CHOOSER == null ) )
  143.82 -                    CHOOSER = new JFileChooser(tmpDir);
  143.83 +                final JFileChooser chooser = new JFileChooser(tmpDir);
  143.84  
  143.85 -                if ( UPDATE_UI_EACH_INTERVAL )
  143.86 -                    CHOOSER.updateUI();
  143.87 +                chooser.updateUI();
  143.88  
  143.89 -                if ( AUTO_CLOSE_DIALOG ) {
  143.90 -                    Thread t = new Thread( new TwentyThousandTest( CHOOSER ) );
  143.91 -                    t.start();
  143.92 -                    CHOOSER.showOpenDialog( null );
  143.93 -                } else {
  143.94 -                    CHOOSER.showOpenDialog( null );
  143.95 -                }
  143.96 +                // Postpone JFileChooser closing until it becomes visible
  143.97 +                chooser.addHierarchyListener(new HierarchyListener() {
  143.98 +                    @Override
  143.99 +                    public void hierarchyChanged(HierarchyEvent e) {
 143.100 +                        if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) {
 143.101 +                            if (chooser.isShowing()) {
 143.102 +                                Thread thread = new Thread(new Runnable() {
 143.103 +                                    public void run() {
 143.104 +                                        try {
 143.105 +                                            Thread.sleep(INTERVAL);
 143.106 +
 143.107 +                                            // Close JFileChooser
 143.108 +                                            SwingUtilities.invokeLater(new Runnable() {
 143.109 +                                                public void run() {
 143.110 +                                                    chooser.cancelSelection();
 143.111 +                                                }
 143.112 +                                            });
 143.113 +                                        } catch (InterruptedException e) {
 143.114 +                                            throw new RuntimeException(e);
 143.115 +                                        }
 143.116 +                                    }
 143.117 +                                });
 143.118 +
 143.119 +                                thread.start();
 143.120 +                            }
 143.121 +                        }
 143.122 +                    }
 143.123 +                });
 143.124 +
 143.125 +                chooser.showOpenDialog(null);
 143.126              }
 143.127          });
 143.128  
 143.129 -        // Allow to collect garbage by GC
 143.130 -        Thread.sleep(1000);
 143.131 +        DisposerRecord disposerRecord = new DisposerRecord() {
 143.132 +            public void dispose() {
 143.133 +                disposerComplete = true;
 143.134 +            }
 143.135 +        };
 143.136  
 143.137 -        System.gc();
 143.138 -    }
 143.139 +        disposerComplete = false;
 143.140  
 143.141 -    private final JFileChooser chooser;
 143.142 +        Disposer.addRecord(new Object(), disposerRecord);
 143.143  
 143.144 -    TwentyThousandTest( JFileChooser chooser ) {
 143.145 -        this.chooser = chooser;
 143.146 -    }
 143.147 -
 143.148 -    public void run() {
 143.149 -        while ( !this.chooser.isShowing() ) {
 143.150 -            try {
 143.151 -                Thread.sleep( 30 );
 143.152 -            } catch ( InterruptedException exception ) {
 143.153 -                exception.printStackTrace();
 143.154 -            }
 143.155 +        while (!disposerComplete) {
 143.156 +            Util.generateOOME();
 143.157          }
 143.158 -        Timer timer = new Timer( INTERVAL, this );
 143.159 -        timer.setRepeats( false );
 143.160 -        timer.start();
 143.161 -    }
 143.162 -
 143.163 -    public void actionPerformed( ActionEvent event ) {
 143.164 -        this.chooser.cancelSelection();
 143.165      }
 143.166  }
   144.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   144.2 +++ b/test/javax/swing/JOptionPane/7138665/bug7138665.java	Sat Feb 18 16:11:47 2012 -0800
   144.3 @@ -0,0 +1,70 @@
   144.4 +/*
   144.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
   144.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   144.7 + *
   144.8 + * This code is free software; you can redistribute it and/or modify it
   144.9 + * under the terms of the GNU General Public License version 2 only, as
  144.10 + * published by the Free Software Foundation.
  144.11 + *
  144.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  144.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  144.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  144.15 + * version 2 for more details (a copy is included in the LICENSE file that
  144.16 + * accompanied this code).
  144.17 + *
  144.18 + * You should have received a copy of the GNU General Public License version
  144.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  144.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  144.21 + *
  144.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  144.23 + * or visit www.oracle.com if you need additional information or have any
  144.24 + * questions.
  144.25 + */
  144.26 +
  144.27 +/* @test
  144.28 +   @bug 7138665
  144.29 +   @summary JOptionPane.getValue() unexpected change between JRE 1.6 and JRE 1.7
  144.30 +   @author Pavel Porvatov
  144.31 +*/
  144.32 +
  144.33 +import sun.awt.SunToolkit;
  144.34 +
  144.35 +import javax.swing.*;
  144.36 +import java.awt.*;
  144.37 +import java.awt.event.KeyEvent;
  144.38 +
  144.39 +public class bug7138665 {
  144.40 +    public static void main(String[] args) throws Exception {
  144.41 +        SwingUtilities.invokeLater(new Runnable() {
  144.42 +            @Override
  144.43 +            public void run() {
  144.44 +                JOptionPane pane = new JOptionPane("Enter value", JOptionPane.QUESTION_MESSAGE,
  144.45 +                        JOptionPane.OK_CANCEL_OPTION, null, null, null);
  144.46 +                pane.setWantsInput(true);
  144.47 +
  144.48 +                JDialog dialog = pane.createDialog(null, "My Dialog");
  144.49 +                dialog.setVisible(true);
  144.50 +
  144.51 +                Object result = pane.getValue();
  144.52 +
  144.53 +                if (result == null || ((Integer) result).intValue() != JOptionPane.OK_OPTION) {
  144.54 +                    throw new RuntimeException("Invalid result: " + result);
  144.55 +                }
  144.56 +
  144.57 +                System.out.println("Test bug7138665 passed");
  144.58 +            }
  144.59 +        });
  144.60 +
  144.61 +        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
  144.62 +
  144.63 +        toolkit.realSync();
  144.64 +
  144.65 +        Robot robot = new Robot();
  144.66 +
  144.67 +        robot.setAutoDelay(100);
  144.68 +        robot.keyPress(KeyEvent.VK_ENTER);
  144.69 +        robot.keyRelease(KeyEvent.VK_ENTER);
  144.70 +
  144.71 +        toolkit.realSync();
  144.72 +    }
  144.73 +}
   145.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   145.2 +++ b/test/javax/swing/JProgressBar/7141573/bug7141573.java	Sat Feb 18 16:11:47 2012 -0800
   145.3 @@ -0,0 +1,62 @@
   145.4 +/*
   145.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
   145.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   145.7 + *
   145.8 + * This code is free software; you can redistribute it and/or modify it
   145.9 + * under the terms of the GNU General Public License version 2 only, as
  145.10 + * published by the Free Software Foundation.
  145.11 + *
  145.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  145.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  145.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  145.15 + * version 2 for more details (a copy is included in the LICENSE file that
  145.16 + * accompanied this code).
  145.17 + *
  145.18 + * You should have received a copy of the GNU General Public License version
  145.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  145.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  145.21 + *
  145.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  145.23 + * or visit www.oracle.com if you need additional information or have any
  145.24 + * questions.
  145.25 + */
  145.26 +
  145.27 +/* @test
  145.28 +   @bug 7141573
  145.29 +   @summary JProgressBar resize exception, if setStringPainted in Windows LAF
  145.30 +   @author Pavel Porvatov
  145.31 +*/
  145.32 +
  145.33 +import javax.swing.*;
  145.34 +import java.awt.image.BufferedImage;
  145.35 +
  145.36 +public class bug7141573 {
  145.37 +    public static void main(String[] args) throws Exception {
  145.38 +        try {
  145.39 +            UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
  145.40 +        } catch (Exception e) {
  145.41 +            System.out.println("WindowsLookAndFeel is not supported. The test bug7141573 is skipped.");
  145.42 +
  145.43 +            return;
  145.44 +        }
  145.45 +
  145.46 +        SwingUtilities.invokeAndWait(new Runnable() {
  145.47 +            @Override
  145.48 +            public void run() {
  145.49 +                BufferedImage image = new BufferedImage(200, 200, BufferedImage.TYPE_INT_ARGB);
  145.50 +
  145.51 +                JProgressBar bar = new JProgressBar();
  145.52 +
  145.53 +                bar.setStringPainted(true);
  145.54 +
  145.55 +                bar.setSize(100, 1);
  145.56 +                bar.paint(image.getGraphics());
  145.57 +
  145.58 +                bar.setSize(1, 100);
  145.59 +                bar.paint(image.getGraphics());
  145.60 +
  145.61 +                System.out.println("The test bug7141573 is passed.");
  145.62 +            }
  145.63 +        });
  145.64 +    }
  145.65 +}
   146.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   146.2 +++ b/test/javax/swing/JTree/4314199/bug4314199.html	Sat Feb 18 16:11:47 2012 -0800
   146.3 @@ -0,0 +1,8 @@
   146.4 +<html>
   146.5 +<body>
   146.6 +Select the last tree node (marked "Here") and click on the menu.
   146.7 +Look at the vertical line connecting nodes "Bug" and "Here". If
   146.8 +this line disappears when the menu drops down, test fails.
   146.9 +<applet  code="bug4314199.class" width=200 height=200></applet>
  146.10 +</body>
  146.11 +</html>
   147.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   147.2 +++ b/test/javax/swing/JTree/4314199/bug4314199.java	Sat Feb 18 16:11:47 2012 -0800
   147.3 @@ -0,0 +1,92 @@
   147.4 +/*
   147.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
   147.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   147.7 + *
   147.8 + * This code is free software; you can redistribute it and/or modify it
   147.9 + * under the terms of the GNU General Public License version 2 only, as
  147.10 + * published by the Free Software Foundation.
  147.11 + *
  147.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  147.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  147.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  147.15 + * version 2 for more details (a copy is included in the LICENSE file that
  147.16 + * accompanied this code).
  147.17 + *
  147.18 + * You should have received a copy of the GNU General Public License version
  147.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  147.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  147.21 + *
  147.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  147.23 + * or visit www.oracle.com if you need additional information or have any
  147.24 + * questions.
  147.25 + */
  147.26 +
  147.27 +
  147.28 +/*
  147.29 + * @test
  147.30 + * @bug 4314199
  147.31 + * @summary Tests that JTree repaints correctly in a container with a JMenu
  147.32 + * @author Peter Zhelezniakov
  147.33 + * @run applet/manual=yesno bug4314199.html
  147.34 + */
  147.35 +
  147.36 +import javax.swing.*;
  147.37 +import javax.swing.tree.*;
  147.38 +
  147.39 +public class bug4314199 extends JApplet {
  147.40 +
  147.41 +    public void init() {
  147.42 +
  147.43 +        try {
  147.44 +            UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
  147.45 +            SwingUtilities.invokeAndWait(new Runnable() {
  147.46 +
  147.47 +                public void run() {
  147.48 +                    createAndShowGUI();
  147.49 +                }
  147.50 +            });
  147.51 +        } catch (final Exception e) {
  147.52 +            SwingUtilities.invokeLater(new Runnable() {
  147.53 +
  147.54 +                public void run() {
  147.55 +                    createAndShowMessage("Test fails because of exception: "
  147.56 +                            + e.getMessage());
  147.57 +                }
  147.58 +            });
  147.59 +        }
  147.60 +
  147.61 +    }
  147.62 +
  147.63 +    private void createAndShowMessage(String message) {
  147.64 +        getContentPane().add(new JLabel(message));
  147.65 +    }
  147.66 +
  147.67 +    private void createAndShowGUI() {
  147.68 +        JMenuBar mb = new JMenuBar();
  147.69 +
  147.70 +        // needed to exactly align left edge of menu and angled line of tree
  147.71 +        mb.add(Box.createHorizontalStrut(27));
  147.72 +
  147.73 +        JMenu mn = new JMenu("Menu");
  147.74 +        JMenuItem mi = new JMenuItem("MenuItem");
  147.75 +        mn.add(mi);
  147.76 +        mb.add(mn);
  147.77 +        setJMenuBar(mb);
  147.78 +
  147.79 +        DefaultMutableTreeNode n1 = new DefaultMutableTreeNode("Root");
  147.80 +        DefaultMutableTreeNode n2 = new DefaultMutableTreeNode("Duke");
  147.81 +        n1.add(n2);
  147.82 +        DefaultMutableTreeNode n3 = new DefaultMutableTreeNode("Bug");
  147.83 +        n2.add(n3);
  147.84 +        n3.add(new DefaultMutableTreeNode("Blah"));
  147.85 +        n3.add(new DefaultMutableTreeNode("Blah"));
  147.86 +        n3.add(new DefaultMutableTreeNode("Blah"));
  147.87 +        DefaultMutableTreeNode n4 = new DefaultMutableTreeNode("Here");
  147.88 +        n2.add(n4);
  147.89 +
  147.90 +        JTree tree = new JTree(new DefaultTreeModel(n1));
  147.91 +        tree.putClientProperty("JTree.lineStyle", "Angled");
  147.92 +        tree.expandPath(new TreePath(new Object[]{n1, n2, n3}));
  147.93 +        setContentPane(tree);
  147.94 +    }
  147.95 +}
   148.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   148.2 +++ b/test/javax/swing/tree/DefaultTreeCellRenderer/7142955/bug7142955.java	Sat Feb 18 16:11:47 2012 -0800
   148.3 @@ -0,0 +1,72 @@
   148.4 +/*
   148.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
   148.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   148.7 + *
   148.8 + * This code is free software; you can redistribute it and/or modify it
   148.9 + * under the terms of the GNU General Public License version 2 only, as
  148.10 + * published by the Free Software Foundation.
  148.11 + *
  148.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  148.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  148.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  148.15 + * version 2 for more details (a copy is included in the LICENSE file that
  148.16 + * accompanied this code).
  148.17 + *
  148.18 + * You should have received a copy of the GNU General Public License version
  148.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  148.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  148.21 + *
  148.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  148.23 + * or visit www.oracle.com if you need additional information or have any
  148.24 + * questions.
  148.25 + */
  148.26 +
  148.27 +/* @test
  148.28 +   @bug 7142955
  148.29 +   @summary DefaultTreeCellRenderer doesn't honor 'Tree.rendererFillBackground' LAF property
  148.30 +   @author Pavel Porvatov
  148.31 +*/
  148.32 +
  148.33 +import javax.swing.*;
  148.34 +import javax.swing.tree.DefaultTreeCellRenderer;
  148.35 +import java.awt.*;
  148.36 +import java.awt.image.BufferedImage;
  148.37 +
  148.38 +public class bug7142955 {
  148.39 +    private static final Color TEST_COLOR = Color.RED;
  148.40 +
  148.41 +    public static void main(String[] args) throws Exception {
  148.42 +        UIManager.put("Tree.rendererFillBackground", Boolean.FALSE);
  148.43 +        UIManager.put("Tree.textBackground", TEST_COLOR);
  148.44 +
  148.45 +        SwingUtilities.invokeAndWait(new Runnable() {
  148.46 +            @Override
  148.47 +            public void run() {
  148.48 +                int w = 200;
  148.49 +                int h = 100;
  148.50 +
  148.51 +                BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
  148.52 +
  148.53 +                Graphics g = image.getGraphics();
  148.54 +
  148.55 +                g.setColor(Color.WHITE);
  148.56 +                g.fillRect(0, 0, image.getWidth(), image.getHeight());
  148.57 +
  148.58 +                DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
  148.59 +
  148.60 +                renderer.setSize(w, h);
  148.61 +                renderer.paint(g);
  148.62 +
  148.63 +                for (int y = 0; y < h; y++) {
  148.64 +                    for (int x = 0; x < w; x++) {
  148.65 +                        if (image.getRGB(x, y) == TEST_COLOR.getRGB()) {
  148.66 +                            throw new RuntimeException("Test bug7142955 failed");
  148.67 +                        }
  148.68 +                    }
  148.69 +                }
  148.70 +
  148.71 +                System.out.println("Test bug7142955 passed.");
  148.72 +            }
  148.73 +        });
  148.74 +    }
  148.75 +}
   149.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   149.2 +++ b/test/sun/net/www/protocol/http/NoCache.java	Sat Feb 18 16:11:47 2012 -0800
   149.3 @@ -0,0 +1,85 @@
   149.4 +/*
   149.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
   149.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   149.7 + *
   149.8 + * This code is free software; you can redistribute it and/or modify it
   149.9 + * under the terms of the GNU General Public License version 2 only, as
  149.10 + * published by the Free Software Foundation.
  149.11 + *
  149.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  149.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  149.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  149.15 + * version 2 for more details (a copy is included in the LICENSE file that
  149.16 + * accompanied this code).
  149.17 + *
  149.18 + * You should have received a copy of the GNU General Public License version
  149.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  149.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  149.21 + *
  149.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  149.23 + * or visit www.oracle.com if you need additional information or have any
  149.24 + * questions.
  149.25 + */
  149.26 +
  149.27 +/*
  149.28 + * @test
  149.29 + * @bug 7133367
  149.30 + * @summary ResponseCache.put should not be called when setUseCaches(false)
  149.31 + */
  149.32 +
  149.33 +import java.net.*;
  149.34 +import java.io.IOException;
  149.35 +import java.util.List;
  149.36 +import java.util.Map;
  149.37 +import com.sun.net.httpserver.HttpExchange;
  149.38 +import com.sun.net.httpserver.HttpHandler;
  149.39 +import com.sun.net.httpserver.HttpServer;
  149.40 +
  149.41 +public class NoCache
  149.42 +{
  149.43 +    public static void main(String[] args) throws IOException {
  149.44 +        ResponseCache.setDefault(new ThrowingCache());
  149.45 +
  149.46 +        HttpServer server = startHttpServer();
  149.47 +        try {
  149.48 +            URL url = new URL("http://" + InetAddress.getLocalHost().getHostAddress()
  149.49 +                          + ":" + server.getAddress().getPort() + "/NoCache/");
  149.50 +            URLConnection uc = url.openConnection();
  149.51 +            uc.setUseCaches(false);
  149.52 +            uc.getInputStream().close();
  149.53 +        } finally {
  149.54 +            server.stop(0);
  149.55 +            // clear the system-wide cache handler, samevm/agentvm mode
  149.56 +            ResponseCache.setDefault(null);
  149.57 +        }
  149.58 +    }
  149.59 +
  149.60 +    static class ThrowingCache extends ResponseCache {
  149.61 +        @Override
  149.62 +        public CacheResponse get(URI uri, String rqstMethod,
  149.63 +                                 Map<String,List<String>> rqstHeaders) {
  149.64 +            throw new RuntimeException("ResponseCache.get should not be called");
  149.65 +        }
  149.66 +
  149.67 +        @Override
  149.68 +        public CacheRequest put(URI uri, URLConnection conn) {
  149.69 +            throw new RuntimeException("ResponseCache.put should not be called");
  149.70 +        }
  149.71 +    }
  149.72 +
  149.73 +    // HTTP Server
  149.74 +    static HttpServer startHttpServer() throws IOException {
  149.75 +        HttpServer httpServer = HttpServer.create(new InetSocketAddress(0), 0);
  149.76 +        httpServer.createContext("/NoCache/", new SimpleHandler());
  149.77 +        httpServer.start();
  149.78 +        return httpServer;
  149.79 +    }
  149.80 +
  149.81 +    static class SimpleHandler implements HttpHandler {
  149.82 +        @Override
  149.83 +        public void handle(HttpExchange t) throws IOException {
  149.84 +            t.sendResponseHeaders(200, -1);
  149.85 +            t.close();
  149.86 +        }
  149.87 +    }
  149.88 +}
   150.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   150.2 +++ b/test/sun/security/krb5/auto/EmptyPassword.java	Sat Feb 18 16:11:47 2012 -0800
   150.3 @@ -0,0 +1,44 @@
   150.4 +/*
   150.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
   150.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   150.7 + *
   150.8 + * This code is free software; you can redistribute it and/or modify it
   150.9 + * under the terms of the GNU General Public License version 2 only, as
  150.10 + * published by the Free Software Foundation.
  150.11 + *
  150.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  150.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  150.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  150.15 + * version 2 for more details (a copy is included in the LICENSE file that
  150.16 + * accompanied this code).
  150.17 + *
  150.18 + * You should have received a copy of the GNU General Public License version
  150.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  150.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  150.21 + *
  150.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  150.23 + * or visit www.oracle.com if you need additional information or have any
  150.24 + * questions.
  150.25 + */
  150.26 +
  150.27 +/*
  150.28 + * @test
  150.29 + * @bug 6879540
  150.30 + * @summary enable empty password for kerberos 5
  150.31 + * @compile -XDignore.symbol.file EmptyPassword.java
  150.32 + * @run main/othervm EmptyPassword
  150.33 + */
  150.34 +
  150.35 +public class EmptyPassword {
  150.36 +
  150.37 +    public static void main(String[] args)
  150.38 +            throws Exception {
  150.39 +
  150.40 +        OneKDC kdc = new OneKDC("aes128-cts");
  150.41 +        kdc.addPrincipal("empty", "".toCharArray());
  150.42 +
  150.43 +        Context c = Context.fromUserPass("empty", "".toCharArray(), false);
  150.44 +        c.status();
  150.45 +    }
  150.46 +}
  150.47 +
   151.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   151.2 +++ b/test/sun/security/pkcs12/Bug6415637.java	Sat Feb 18 16:11:47 2012 -0800
   151.3 @@ -0,0 +1,313 @@
   151.4 +/*
   151.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
   151.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   151.7 + *
   151.8 + * This code is free software; you can redistribute it and/or modify it
   151.9 + * under the terms of the GNU General Public License version 2 only, as
  151.10 + * published by the Free Software Foundation.
  151.11 + *
  151.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  151.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  151.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  151.15 + * version 2 for more details (a copy is included in the LICENSE file that
  151.16 + * accompanied this code).
  151.17 + *
  151.18 + * You should have received a copy of the GNU General Public License version
  151.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  151.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  151.21 + *
  151.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  151.23 + * or visit www.oracle.com if you need additional information or have any
  151.24 + * questions.
  151.25 + */
  151.26 +
  151.27 +/*
  151.28 + * @test
  151.29 + * @bug 6415637
  151.30 + * @summary Support PKCS#12 key stores protected with an empty password
  151.31 + */
  151.32 +
  151.33 +import java.io.ByteArrayInputStream;
  151.34 +import java.math.BigInteger;
  151.35 +import java.security.KeyStore;
  151.36 +import java.security.cert.X509Certificate;
  151.37 +import java.security.interfaces.RSAPrivateCrtKey;
  151.38 +
  151.39 +public class Bug6415637 {
  151.40 +
  151.41 +    public static void main(String[] args) throws Exception {
  151.42 +        check(WITH_NULL);
  151.43 +        check(WITHOUT_NULL);
  151.44 +    }
  151.45 +
  151.46 +    private static void check(String encodedBlob) throws Exception {
  151.47 +        byte[] blob = new byte[encodedBlob.length() * 2];
  151.48 +        for (int i = 0; i < blob.length; ) {
  151.49 +            final char ch = encodedBlob.charAt(i / 2);
  151.50 +            blob[i++] = (byte) (ch >> 8);
  151.51 +            blob[i++] = (byte) ch;
  151.52 +        }
  151.53 +        KeyStore store = KeyStore.getInstance("PKCS12");
  151.54 +        store.load(new ByteArrayInputStream(blob), new char[0]);
  151.55 +        if (!store.aliases().nextElement().equals("test"))
  151.56 +            throw new Exception("test alias not found");
  151.57 +        KeyStore.PrivateKeyEntry e =
  151.58 +            (KeyStore.PrivateKeyEntry) store.getEntry("test",
  151.59 +                    new KeyStore.PasswordProtection(new char[0]));
  151.60 +        X509Certificate cert = (X509Certificate) e.getCertificateChain()[0];
  151.61 +        if (!cert.getSubjectDN().toString().equals("CN=Test Key"))
  151.62 +            throw new Exception("invalid certificate subject DN");
  151.63 +        RSAPrivateCrtKey key = (RSAPrivateCrtKey) e.getPrivateKey();
  151.64 +        if (!key.getPublicExponent().equals(BigInteger.valueOf(65537)))
  151.65 +            throw new Exception("invalid public exponent");
  151.66 +    }
  151.67 +
  151.68 +    private static final String WITH_NULL =
  151.69 +        "\u3082\u097c\u0201\u0330\u8209\u3606\u092a\u8648\u86f7\u0d01" +
  151.70 +        "\u0701\ua082\u0927\u0482\u0923\u3082\u091f\u3082\u0564\u0609" +
  151.71 +        "\u2a86\u4886\uf70d\u0107\u01a0\u8205\u5504\u8205\u5130\u8205" +
  151.72 +        "\u4d30\u8205\u4906\u0b2a\u8648\u86f7\u0d01\u0c0a\u0102\ua082" +
  151.73 +        "\u04fa\u3082\u04f6\u3028\u060a\u2a86\u4886\uf70d\u010c\u0103" +
  151.74 +        "\u301a\u0414\u8317\ucfd6\u89ab\uc03b\u79d6\u4c45\u1b10\uc3bd" +
  151.75 +        "\u3923\ub806\u0202\u0400\u0482\u04c8\ud51d\uf953\ud79e\u92c6" +
  151.76 +        "\u83c0\u92dc\ucd05\u69ab\ucc1b\ud538\u2ed9\u7796\ua426\uc14e" +
  151.77 +        "\udcbf\ue541\u40be\ud264\u3b5b\uf51f\u8e1a\u892f\u2813\ucdd6" +
  151.78 +        "\uf72e\uef55\u35ef\u4620\ude18\ued5e\ufae0\ubed4\uf84e\u276b" +
  151.79 +        "\u3596\uc33f\ub251\ue617\u6e00\ua80f\u6c82\u4acd\u7303\u26be" +
  151.80 +        "\uffb5\u1e49\u5fb1\uf87c\ua873\ue60a\u7415\u655c\u39f1\ucf16" +
  151.81 +        "\u8f5c\u85c6\u4100\u4130\u565b\u649a\u60d6\u6054\u868d\u7267" +
  151.82 +        "\u97a8\u8492\uc5a0\udb5e\u2880\udf55\ub0ee\ua641\u8224\u76d2" +
  151.83 +        "\u9b1e\u2a67\u1e32\ue1fc\u0a77\u435b\u669f\ued00\u6c30\u963f" +
  151.84 +        "\u7ee3\uc5c8\u198f\u8ede\u30e1\u015d\u1195\uc850\u3371\ub9e5" +
  151.85 +        "\u6968\u84c3\ub0e4\u22b7\u2a08\u4a9d\u9166\ua9ba\ud945\u0529" +
  151.86 +        "\ue1e7\u8aba\ub4ef\u7445\udc9a\ucf73\ud77b\ufafe\ue1df\u3180" +
  151.87 +        "\u9585\ued73\uca40\u06b0\ufdee\u95ba\u1aa3\ubd67\ua5c1\u84b4" +
  151.88 +        "\u4b50\uc1e1\u4547\ud837\u21bc\uac0d\u0a65\uebb5\u7281\ud9bc" +
  151.89 +        "\u2e2c\ua9bc\u7714\u0fc0\uab41\uce09\ud5e8\u5f8c\uc35d\uba6e" +
  151.90 +        "\u98a2\u95c3\u87ff\uba8c\u056a\udc9f\uf254\u3d38\uf40a\u77dd" +
  151.91 +        "\u4e30\u01de\ubef7\ud288\ue59c\ua143\ub30b\ud0ae\u63b9\u138b" +
  151.92 +        "\uc793\u3474\u18ca\udeed\u78d9\u2ae8\u63cc\ua5d1\u6779\u0229" +
  151.93 +        "\u7b72\ucfd4\ueecb\ue167\u08c0\u7556\u181d\u8d62\uc401\ub092" +
  151.94 +        "\u8cf5\ued71\uf29f\u843e\u13e1\u7e7b\uf589\u0329\u92bd\ud0e3" +
  151.95 +        "\u8dcc\u7541\uf195\ueef2\u3f3a\ueb01\uf5b0\u1869\u2216\uf351" +
  151.96 +        "\u488d\udffb\u6243\u1121\u9447\u8a3a\u006f\u008c\ue2b3\ued31" +
  151.97 +        "\u7f57\u6492\ue02f\u6f68\u387d\u58c0\uaadf\u2ee3\uf304\u3de9" +
  151.98 +        "\u9741\u47fa\udde8\ufe8a\u679a\u597d\u8c7c\u9c71\u570e\u1dbd" +
  151.99 +        "\ud555\ue853\uff63\u0fcb\u4b28\u3691\u33c8\uc31f\uc510\u6cba" +
 151.100 +        "\ud92c\u6462\u733a\u739e\uc792\ud861\u743e\u3bd3\u006b\u2276" +
 151.101 +        "\u9fb3\u0a31\u1eb3\ub97e\u4a80\uc076\uaabc\u35a0\u678d\u17c3" +
 151.102 +        "\ua225\ua77c\u7d9c\uef2d\u83e2\u6996\uba70\uf6f8\u79a1\u9399" +
 151.103 +        "\uc86b\u1cc5\ub2a5\u02c1\ud676\ua274\u4933\u6c60\u6832\ub0be" +
 151.104 +        "\u5354\u5af9\uae23\u0963\u722d\u9ad2\u4461\ub768\u2068\u0ccb" +
 151.105 +        "\u94fd\u88ac\u0f58\u3bc0\u212d\u30c8\u8860\uf7c9\u1dde\ub6b4" +
 151.106 +        "\u3549\u5bcd\ucf83\u9420\u3a40\u16ad\uc4d7\ucd87\ue73a\ue1c7" +
 151.107 +        "\u21df\u7f4f\u8659\u9f79\u5b36\uf206\uac66\uc9f3\u6336\u164d" +
 151.108 +        "\u9046\uf4d5\u285d\ufcd8\ubd55\u1fb9\ua533\u9101\u1e87\uc7b0" +
 151.109 +        "\u64e9\u3817\u216c\u8d41\uba51\u743a\uc74e\ue4ab\u2820\u972f" +
 151.110 +        "\ue191\u85b4\u0ea7\ud896\u23cf\u7df5\u1653\ua9f3\ub724\ucbc9" +
 151.111 +        "\u9738\ud2f8\u464e\ucf12\u99b8\u64e0\uf03b\u8d02\u85a8\uab52" +
 151.112 +        "\u8da3\uea34\ube99\ue5f8\u2b38\ub082\u399d\ue61e\u64a1\u7f90" +
 151.113 +        "\u26e9\ueb74\u6107\ufe2f\u82ca\u87a5\u3028\u8e1f\ue859\u61d4" +
 151.114 +        "\ud26d\u23a9\uaadc\u02a7\u8ab2\u43d4\uf6b9\udf7a\u8935\u45a4" +
 151.115 +        "\ufad6\ue7e4\u92b7\u35d7\u1044\u8ed3\u74ef\uaaa9\u713f\u6ebc" +
 151.116 +        "\u1158\u5e5c\u7522\ufe17\ua515\u59a1\u75dd\ue7ac\uafd9\u16a9" +
 151.117 +        "\u190e\u18fc\uc041\ufc9e\u3e16\u60c4\ufe51\u6d53\ufa52\u4c08" +
 151.118 +        "\uce2a\ue546\u017b\ud96b\ube18\u8cb9\udd50\ued40\u14b0\u7da1" +
 151.119 +        "\u2f2c\ubf9d\uc7c7\u1b73\ua155\ucaf8\ue54d\uebb0\u160a\ubd64" +
 151.120 +        "\u5ef7\ue1cf\u4633\u86c1\ubc91\u839d\ub148\u9f31\uf2b1\ud133" +
 151.121 +        "\u168f\u9374\u4667\u6aa9\u0482\ua2a6\ub5c0\ud9b7\ua070\uf6bd" +
 151.122 +        "\u16fe\u0f41\u986b\u3d33\u7cb9\u291d\u24f0\u704a\uc946\u10a2" +
 151.123 +        "\udbcf\u6c5f\u5a83\u5507\u036e\ube9f\uf60a\u9da8\u72dd\u23c9" +
 151.124 +        "\u8878\udd67\uf486\u1384\u751f\u4694\uee3c\udc2e\ud5d7\ud99a" +
 151.125 +        "\u5ee2\u5455\ub82d\u1837\u336d\u5724\u635b\ubd0b\u2e7c\u92be" +
 151.126 +        "\u2110\u9c0e\u1662\u43f6\u62ae\u32e3\uaea4\u1cc5\uadc0\u7511" +
 151.127 +        "\u6ad4\u0228\ue399\u5741\u2050\ue31a\u7dc8\uf6db\u67bb\u994a" +
 151.128 +        "\u5b5a\uaac6\u2210\u95b0\u462e\u0684\u335e\uac36\u7ab9\uab1e" +
 151.129 +        "\u0b75\u0f05\u74c5\ufcb3\ua0a5\ube7e\u45f8\u92d5\u3399\u7dd6" +
 151.130 +        "\uf96e\u7e01\u7823\u6690\u231c\u4c47\u2d10\u7e7f\u5eb8\u70dd" +
 151.131 +        "\u98d2\u6204\u3a92\u3990\u502b\u7cdb\u952a\ufa97\uea3b\ud990" +
 151.132 +        "\u436f\uf33a\u070d\u2aff\u7497\u2591\u37e4\ua590\ue7ba\u2c1e" +
 151.133 +        "\u53d9\u73fa\udc53\u944f\ua3a5\u5093\u33a4\uf080\u1193\u37f2" +
 151.134 +        "\u7642\ub033\u7f90\u9b44\uff89\ue6ef\u81be\u9e6e\u68a4\u5a00" +
 151.135 +        "\u9232\u4372\u40aa\u2748\u229d\u534d\u316b\u6e89\ufcb7\uff2e" +
 151.136 +        "\ub654\u1649\ucb13\u3c28\u4940\u43aa\uc07d\u247c\u313c\u3017" +
 151.137 +        "\u0609\u2a86\u4886\uf70d\u0109\u1431\u0a1e\u0800\u7400\u6500" +
 151.138 +        "\u7300\u7430\u2106\u092a\u8648\u86f7\u0d01\u0915\u3114\u0412" +
 151.139 +        "\u5469\u6d65\u2031\u3330\u3833\u3132\u3234\u3236\u3437\u3082" +
 151.140 +        "\u03b3\u0609\u2a86\u4886\uf70d\u0107\u06a0\u8203\ua430\u8203" +
 151.141 +        "\ua002\u0100\u3082\u0399\u0609\u2a86\u4886\uf70d\u0107\u0130" +
 151.142 +        "\u2806\u0a2a\u8648\u86f7\u0d01\u0c01\u0630\u1a04\u14de\ud8d8" +
 151.143 +        "\ua792\uf9d9\u6875\ua51d\u98ec\udf03\uc2b6\u5100\u8a02\u0204" +
 151.144 +        "\u0080\u8203\u6074\ub909\u3c60\ua522\ue4ac\u0f60\u2396\u7baa" +
 151.145 +        "\ud208\ub76c\u89a5\ue4ef\u205d\u2062\u4a5b\ua684\uceae\u01b9" +
 151.146 +        "\u1e7a\u6e03\ud996\u555a\u615b\uba70\u406f\u80a9\u901e\ua947" +
 151.147 +        "\u5b8f\u73f3\udea3\ud8b1\u9782\uac87\u231a\udcd2\u3ef0\u3a17" +
 151.148 +        "\u4092\u509f\u0e79\u4cd7\u8516\u5111\uebe1\u86e0\uc548\u5ffc" +
 151.149 +        "\u9a99\u11ed\uef13\u17af\u2707\u8984\u8770\u7064\u1943\u1dd3" +
 151.150 +        "\u45cf\u9f80\u65f8\u9b3e\u1f70\u6bd0\uc726\u5506\ufb20\u6bdc" +
 151.151 +        "\uba8c\u0b19\ucd01\ud0f0\u7040\udf63\u48a5\udf5f\u6559\u1b33" +
 151.152 +        "\ubdae\u8183\uc13f\ued10\ud6dc\ud0f0\u6a7f\ubc36\uc7ca\u320f" +
 151.153 +        "\u50b8\ud422\ufd99\u8843\u65e8\ue201\u843b\u64ee\ub891\u3ba2" +
 151.154 +        "\uecae\ufda0\u72d6\u8394\u2551\ufc44\u3778\u27c3\u061a\u6d3b" +
 151.155 +        "\ubd80\ue010\u06df\u39e7\u3d6a\u5ae2\u93fa\u4de4\u938f\u6f27" +
 151.156 +        "\ufd39\u4380\u60da\uf215\u79d4\uf6f1\ua02f\u959a\ua0ea\u1c38" +
 151.157 +        "\u80e3\u2744\u7506\u54b3\u77ad\u18ce\ucfec\u555e\u7bbe\u2e2f" +
 151.158 +        "\u9900\ub2ef\ua5b9\ubdf0\u5e15\ua681\u92c7\u4f86\u2e1a\ub893" +
 151.159 +        "\u01fc\u01d2\ub674\uff19\u04c3\ua1a0\u2cea\u72e0\ua8f1\u1358" +
 151.160 +        "\ube79\u7caa\u269d\u728a\ue435\u37bd\u6495\uc106\u8830\u9b17" +
 151.161 +        "\ue16d\uef78\uae2b\u5313\u1c96\uc0ee\u3098\ud743\ucd1c\u7407" +
 151.162 +        "\uf4f9\uee72\ub95e\u31e7\u6435\u0173\u0336\u93c5\u8a1b\u05b4" +
 151.163 +        "\u4359\uc4be\ud92b\u8d21\u83a9\u32b7\u6433\ua9bc\u27c2\ud842" +
 151.164 +        "\ua4f2\u81c5\ua86c\u2fd2\uba30\u53bd\uc277\u659f\u203b\u60e5" +
 151.165 +        "\u37f7\u0984\u31c2\u838a\u2107\u5840\u6411\u1b8d\u044e\ub0b6" +
 151.166 +        "\uf558\ue6d3\u62bb\u5464\uf83a\u4d5b\uf153\u9e18\ua353\ubd05" +
 151.167 +        "\uf204\ud543\u037d\ue5aa\u473a\ueb13\uac19\u0494\ua08e\u76c3" +
 151.168 +        "\ufbd7\u9f1c\u8ca9\u57ad\ud218\uc018\u67ac\u0ae9\ub559\ufe38" +
 151.169 +        "\u5641\uec0c\ue0ee\u606c\u1989\ue5a2\uff09\u8c61\u1386\ueb51" +
 151.170 +        "\u7cbd\u95cd\u80c5\u3532\u8605\u596d\u4cfd\u7797\u1e82\ud2fe" +
 151.171 +        "\uad6b\ua16e\ub6cf\u8fce\ud5a9\u207f\u1d0a\udabe\uc3a6\u5633" +
 151.172 +        "\u2023\u925f\u809f\uee7c\u5362\u5fd9\u8dfc\u6b5f\uc95b\u0ae9" +
 151.173 +        "\u7b26\u9e5b\u97e8\u9d6e\uaf91\u6d1a\u1d19\ufc27\u0815\uccbc" +
 151.174 +        "\u83d4\u2ce2\ue06e\u21a1\u88da\u09af\u9671\uc510\uac23\u398d" +
 151.175 +        "\ubea2\ua9a1\uf0d3\u490d\ub94b\u7ff7\u6636\ub1fa\u9b10\u1be3" +
 151.176 +        "\u179b\u6a8a\u4a6c\ude1f\u5da7\u7c02\u96ec\u70ac\u5045\udd2c" +
 151.177 +        "\u9f6d\uc37d\u5ba6\u4895\ue142\u0db9\uf2dc\uba2e\ud054\ud33e" +
 151.178 +        "\u1ed9\u144b\u5d85\u9156\u3a90\ue8cd\u0a01\u67f5\ua81b\u4f56" +
 151.179 +        "\u99dd\u4950\ua551\uacdb\udf31\u1f05\u7169\u3231\u0071\u80ec" +
 151.180 +        "\ua4e9\ud74e\u62cf\u8931\u11f1\uc925\u0319\uabd4\ufb86\u73c2" +
 151.181 +        "\u1479\u005b\uf05d\u4f8d\u44e4\u942b\ud338\ud05d\u2b3b\uf6f5" +
 151.182 +        "\udc0d\uf741\u798b\ud8e9\u36a5\u577b\u8a95\ud773\uffcb\u17b3" +
 151.183 +        "\u7174\u9616\u9b5e\ua577\u983c\u6e7a\u6cc8\u4a04\u042b\u503e" +
 151.184 +        "\ud744\ub65e\ue5de\ufa24\u8c71\u1127\ud47f\ud290\ufd4c\u5cbb" +
 151.185 +        "\u0e21\u77fd\u6553\ub82b\ucb49\u41e7\u8e3d\u4539\u925d\u6ba9" +
 151.186 +        "\uae47\u391c\ua79e\ub6e2\u7142\u7cb3\u02f5\u6495\u7a85\u2dea" +
 151.187 +        "\u787b\u22b7\u6ec2\uea8d\uf930\u3d30\u2130\u0906\u052b\u0e03" +
 151.188 +        "\u021a\u0500\u0414\ubfef\u99f5\u0bb0\uc9b3\uf96a\ue267\u6bc0" +
 151.189 +        "\u0202\u6d78\ub923\u0414\u5500\u095a\u2a04\u2d7e\u708d\u9779" +
 151.190 +        "\u9bdb\u2c4f\u82f2\uf89f\u0202\u0400";
 151.191 +
 151.192 +    private static final String WITHOUT_NULL =
 151.193 +        "\u3082\u097c\u0201\u0330\u8209\u3606\u092a\u8648\u86f7\u0d01" +
 151.194 +        "\u0701\ua082\u0927\u0482\u0923\u3082\u091f\u3082\u0564\u0609" +
 151.195 +        "\u2a86\u4886\uf70d\u0107\u01a0\u8205\u5504\u8205\u5130\u8205" +
 151.196 +        "\u4d30\u8205\u4906\u0b2a\u8648\u86f7\u0d01\u0c0a\u0102\ua082" +
 151.197 +        "\u04fa\u3082\u04f6\u3028\u060a\u2a86\u4886\uf70d\u010c\u0103" +
 151.198 +        "\u301a\u0414\ud258\ubbe7\ub641\ud196\u4969\u3c88\u70f1\u8c97" +
 151.199 +        "\u95b1\u8bf3\u0202\u0400\u0482\u04c8\u096a\u4686\uf519\u61da" +
 151.200 +        "\u1b3b\uebfd\u89b1\u044b\u3bd8\u79a7\ud022\ud880\ud173\ucde1" +
 151.201 +        "\ud2c1\u2c5d\u8ebb\u6bd4\u46db\ub90b\u04b9\ub091\ud1f3\ud468" +
 151.202 +        "\u3e93\u2c88\uca5a\u1c54\u5342\u1eca\u8565\ubbbd\ua022\u1ead" +
 151.203 +        "\ud0bb\u1a8c\u69cf\uf0f4\ucbfb\u488a\ube99\uf190\ue01c\ud87d" +
 151.204 +        "\u78ca\u9e5c\u82f9\u76ad\u811f\u37d0\u272b\u0481\u500c\u0a27" +
 151.205 +        "\u08d3\ub637\u3e39\u6db1\ubcba\ue354\u6924\ua9d5\u3555\u20d6" +
 151.206 +        "\u4c6b\u3189\u5f91\u382c\uf351\u4de2\ubade\u2a14\uea84\u16b6" +
 151.207 +        "\uf7f7\u36de\ubba6\ue952\u5f5d\u8243\u2318\ucf3d\u8ac8\u33d3" +
 151.208 +        "\u706c\ue3db\u6619\u7935\u7300\u89b3\u0bcd\uca9f\u0333\ua450" +
 151.209 +        "\u1be1\u3e42\ub465\uced5\ub055\u5843\uf40f\ua0f2\u6fea\u94fa" +
 151.210 +        "\ua51e\u4b5d\u93c9\ucb2e\u977e\uafd9\u2a2f\u784b\u0320\u5550" +
 151.211 +        "\u273f\u469f\uc42b\u2ce7\uedea\u4e0d\u54a5\u1a25\u4fac\ue346" +
 151.212 +        "\u2102\u7ab6\uea86\u554f\u7706\u8a80\uf6dd\u04f8\u3b37\u005a" +
 151.213 +        "\u4562\u2ef8\u59f9\u32b7\u31c0\ue7dc\ucbde\ue0e1\u2fd9\u0960" +
 151.214 +        "\u3e7a\ub4e5\u2a58\u1e2b\uef14\u9a44\u5444\u806d\uc475\u12ab" +
 151.215 +        "\ucc3d\ua03b\ubd52\ubf1c\ua9a6\u58aa\uee8b\u96c2\ud0c9\ua029" +
 151.216 +        "\u1db4\ub118\u4807\uecaa\ue182\uabb7\ud9ed\u66c5\u2c80\uc6a6" +
 151.217 +        "\u3f54\ubc73\u2632\ue1b0\u0d74\u001c\u5740\uc74b\ufadb\u25b4" +
 151.218 +        "\ua10e\u3191\u69e6\u0861\u452b\u955c\uac56\ud3c4\u86b7\u45f8" +
 151.219 +        "\u777a\uc336\u8cc7\ud471\u76b6\u11d8\ueb84\u14e4\uf44f\uc9ff" +
 151.220 +        "\u8929\u0d84\ubcfe\u8cc2\u9d07\u94e6\u1cf9\u19b5\u773a\u012d" +
 151.221 +        "\u0453\u4ff3\u40f2\ub144\ufc80\u571c\u0e13\uf890\u9fed\u2045" +
 151.222 +        "\u7baf\ufd88\u4920\u2b86\u491d\uecf8\ua5d9\u1e12\u48c7\u2c84" +
 151.223 +        "\u3fbe\u4df5\u11ce\u7b81\u83fc\u3efa\u697d\u1f3d\u8d81\u01b0" +
 151.224 +        "\u0bf1\u9012\u697f\u3b25\u3574\u5286\udded\u5be0\u7e92\u0a02" +
 151.225 +        "\ua486\ud19b\ue0b5\ua05c\u5ac2\u0ad5\u0d04\ua763\ub5c8\uf7e6" +
 151.226 +        "\u6e77\u2df3\ub9e7\uda30\ufccb\u7642\u5dc1\udf1f\uc922\uff69" +
 151.227 +        "\u4471\u4749\u937a\ud77d\u7c0d\u917c\uf2ef\u122c\u13b2\u8943" +
 151.228 +        "\u33aa\uad59\u86e8\u21c4\ueaa0\uf200\ue5f3\u6da0\ue8ef\uce7e" +
 151.229 +        "\u37b2\u3ddf\u0480\u08fc\uf89a\ud927\u3f5b\u75d3\ubdfe\u6ebd" +
 151.230 +        "\ufab1\u9f54\u1c20\u625b\u1391\u2af0\u43ba\u4395\udf22\u299e" +
 151.231 +        "\uf3bf\u7750\u5f68\u0120\u0ee0\u6960\ud939\u621f\uf845\u0025" +
 151.232 +        "\ue33c\u7ed9\ueadf\u0005\u6306\u7274\u5e67\ucf7a\uf3c6\u7371" +
 151.233 +        "\u487b\u79d7\u2142\ubc1a\ubfe4\u3536\u15db\ufe23\u4352\u6321" +
 151.234 +        "\u329d\uc251\u84c8\ufc0e\uc0ca\u5be6\uf530\u0177\ud9cb\ud132" +
 151.235 +        "\uf752\u3f26\uda90\ud9cf\u2e46\u3e09\u5d9a\u6902\udb3e\ub06c" +
 151.236 +        "\u722d\uf498\u3e93\u6cae\u43b5\u535a\u1cd1\uf0b2\u8d80\u9e53" +
 151.237 +        "\ue02e\uf782\u01ce\u5063\u73d1\u5571\uf0e7\ufa22\u7e48\u0c31" +
 151.238 +        "\u4642\u29fd\udcab\ue8d4\u7a77\u0880\u4855\u88c7\u7aa5\u0d9c" +
 151.239 +        "\uf8b7\uc91c\u127d\u2dd7\ude53\u9d3f\u132b\u965c\ubc80\udd97" +
 151.240 +        "\u87bf\ua0e8\ub2a2\u4e1f\u98fd\u72f3\u16ea\uc415\u5be3\ue8df" +
 151.241 +        "\u5681\u1f11\u4e3a\uac5d\u1684\u6602\ueb14\u0a96\ufcef\uaebf" +
 151.242 +        "\u1f2e\ud1a9\u435c\uf4e5\ub6b4\uaae2\u8244\u96a4\u0d3a\u752f" +
 151.243 +        "\uce21\u1bc9\u219e\uf17b\ud95e\ucd12\u1b0a\ucb85\ub0cd\u4ecb" +
 151.244 +        "\u6bb4\u5f7c\u2a93\ubb24\u9d7c\u6822\u80cd\u3f54\u78ad\u4fde" +
 151.245 +        "\ud57f\uec1d\ub54c\u0d78\u5946\u84c1\ua9ad\u0dea\u0292\ub279" +
 151.246 +        "\u1c76\u817e\ub910\ub1fa\ub1c0\u839d\u9eca\u6f83\u8211\u4112" +
 151.247 +        "\u440c\u4fbd\u6ef2\u897d\udfa9\ude9e\u1aef\u0f21\u26fb\uaca4" +
 151.248 +        "\u637e\ub072\u264f\ud24d\u9357\uc801\u0b84\u2d34\ueddf\u6063" +
 151.249 +        "\udc5d\u90dd\u5c62\ufb48\u8c5e\u7c4e\u3bdb\ub590\u7a75\udbd1" +
 151.250 +        "\udd78\uc8be\u5915\u7c8b\u8874\u578d\u3116\ub65a\uab8e\ud2ef" +
 151.251 +        "\u5d35\ubf8b\u2828\u8983\ua790\uedcf\u9698\ue023\u5786\u627b" +
 151.252 +        "\u9037\u1db7\u900e\u1f45\u0001\u7cf8\u14fd\ue437\u0dfd\ucacc" +
 151.253 +        "\u5edf\u1742\u7f6e\u612a\ud57d\udca0\u73a4\ud601\uc7f0\uca0e" +
 151.254 +        "\u5a44\u00b4\u233a\u84f2\u95b5\u5f16\uc291\u04fb\u369d\u6b99" +
 151.255 +        "\ue127\u493f\u66be\u86e9\u9672\u2849\u64a7\u851b\ue420\u8491" +
 151.256 +        "\ueb07\u6563\uc753\uc28e\ucad5\uec05\u6920\u8955\u5605\u25f6" +
 151.257 +        "\u6193\ubee5\u7a1a\ub73d\ucc27\uc8ce\u7179\u57c1\u7a2a\u37c1" +
 151.258 +        "\ua6c7\u2d8a\u4025\uc97d\u8c9d\u7b4b\u1ad5\uc6d7\u50fc\u246d" +
 151.259 +        "\u91a9\ua55d\u677a\udc83\u04c7\u3e14\u9950\u420c\udf02\u749b" +
 151.260 +        "\ude88\u5459\u2074\ua4ae\ud12d\uaf60\uba98\u630d\u313c\u3017" +
 151.261 +        "\u0609\u2a86\u4886\uf70d\u0109\u1431\u0a1e\u0800\u7400\u6500" +
 151.262 +        "\u7300\u7430\u2106\u092a\u8648\u86f7\u0d01\u0915\u3114\u0412" +
 151.263 +        "\u5469\u6d65\u2031\u3330\u3833\u3132\u3431\u3138\u3238\u3082" +
 151.264 +        "\u03b3\u0609\u2a86\u4886\uf70d\u0107\u06a0\u8203\ua430\u8203" +
 151.265 +        "\ua002\u0100\u3082\u0399\u0609\u2a86\u4886\uf70d\u0107\u0130" +
 151.266 +        "\u2806\u0a2a\u8648\u86f7\u0d01\u0c01\u0630\u1a04\u14af\ud4f5" +
 151.267 +        "\u0ff4\u0ede\u0da0\u6cc5\ufd9d\u3502\uae5e\u4cef\u3102\u0204" +
 151.268 +        "\u0080\u8203\u6028\ua7e6\u088b\u56b6\uf453\u9747\u68ec\uc064" +
 151.269 +        "\u2254\u693f\u25c5\uaa39\u3d87\uc97c\uc558\u5194\u7553\ude3a" +
 151.270 +        "\u4575\u9d85\ud843\u2bd0\ua2e8\u244f\u8593\uac84\u54b4\ubdc6" +
 151.271 +        "\ucea6\uba1a\ud3da\ua510\uee9d\uaf31\ub5c2\u3329\u0fed\u0e08" +
 151.272 +        "\u426b\u46fe\udcc5\u0979\ua9ed\u3123\u9a50\ud222\u3fc0\u771a" +
 151.273 +        "\u6f55\u9664\ud56f\u6b03\u6020\u78a4\u63b2\ue35e\u0816\u43a7" +
 151.274 +        "\u1909\u52e1\u8183\u1b8d\u9f5b\u19e4\uad73\u8461\ucc86\u3b49" +
 151.275 +        "\u322e\ue9d9\u3c66\uea22\u091e\u6621\ua8bf\u0169\u72d0\u535e" +
 151.276 +        "\u77dc\u1002\ubded\u7a91\u6cee\u58fa\uc295\uae8e\ue009\uabe9" +
 151.277 +        "\u6638\ucaea\u8bbf\uca27\udef5\u2881\u72ec\u8aa5\u582b\u9d6e" +
 151.278 +        "\u26bb\u3c70\u8bd6\uf5ec\u34ae\ua967\u5bb1\u22cb\u4b74\u0e50" +
 151.279 +        "\u5062\uc6f7\u7cb4\u58a3\uf43d\u57c0\u9654\u2f9c\u9308\u4546" +
 151.280 +        "\u6f4a\u37fe\u8d5d\u1465\u8621\u4cd8\u68d6\u0456\u96a4\ud3e2" +
 151.281 +        "\u76d1\u2675\u7654\u7649\u10e9\u9d0e\u8b04\uffb6\u020a\u2eb4" +
 151.282 +        "\uf24f\u150e\u7f0d\uf41b\u2c76\u538f\uc2df\u79dc\u0472\u1119" +
 151.283 +        "\uc148\ue2e8\u1820\ucd45\u08a7\u6bcd\u6eb0\ubd0a\ufff4\uec28" +
 151.284 +        "\u819b\u2adb\uefc8\ue8f7\ue233\u6535\uc938\u9771\u3681\u87cf" +
 151.285 +        "\u3a24\u4c71\ue1df\u3e19\u259c\uae5b\u27ed\u8a67\uf3e6\u7af0" +
 151.286 +        "\u48e1\uc542\uc471\ud8f4\ue317\u46e9\u0b4f\uec45\ua1d3\u2b88" +
 151.287 +        "\u8a22\udda1\u7c1a\u273c\ua0f7\u8bac\u3771\u28d2\u6ef8\u28d2" +
 151.288 +        "\ud83c\u196f\ue3fd\u9c79\u4305\u01b8\u3490\u0a91\ue4f3\uebc6" +
 151.289 +        "\u25a2\u7dd2\u72db\u7531\ucfca\u432f\u2beb\uc649\uf9c5\uc533" +
 151.290 +        "\u9f3a\ua611\u935c\ubca6\ud293\u54d6\u0dd1\u0aff\u82fb\u2d69" +
 151.291 +        "\u3da0\u3b33\u0986\u45b3\u3353\ub968\u7348\u454f\u9117\ub3dc" +
 151.292 +        "\ud7af\u06ca\ua34a\u9357\ue22f\uad3d\u4c76\ub386\ua8d7\u2a90" +
 151.293 +        "\u6d17\u9321\u7b00\u21e4\u1994\u9d18\u6439\u04c8\u8282\ub269" +
 151.294 +        "\uf786\u75c6\ua505\u983a\ua075\uffa0\ud662\u6ae5\ub126\u96d1" +
 151.295 +        "\u9e5e\u346b\ub7ee\ub0a3\u4ee8\ud204\u77ec\u2325\u5da8\ua326" +
 151.296 +        "\ua018\u0fd8\ue50e\u93cc\ucc40\u2d89\u2ffb\u54e0\u091a\u19fd" +
 151.297 +        "\u45d7\uc0ab\u77a2\u66ae\u794b\u6644\u21c3\ud782\u1e9e\u53e5" +
 151.298 +        "\u782e\u55e8\ud44e\u93e8\u379e\u5aa8\u353b\u95de\u7bc1\ucaf3" +
 151.299 +        "\u5223\ub5e9\uacbb\ub86b\u6014\u0626\ue7ad\ufd93\ue43a\ud864" +
 151.300 +        "\u1e6d\u14b2\ua12a\u94c5\u2ed9\ua7f7\u14f4\u0cbd\uca3b\u7c21" +
 151.301 +        "\ua85a\uf834\u6c99\ue1aa\u3832\u2515\u8170\u3c93\u7def\u94fe" +
 151.302 +        "\u9c3d\u4ab0\u73ed\u6c72\u8b94\ua407\uc719\uad1e\u6306\u4167" +
 151.303 +        "\u921e\uae53\u3fd4\uf569\u6f0b\u82b0\u0ca6\ud61f\ud526\u23c9" +
 151.304 +        "\u168d\u4baf\ucc4f\ud8a2\uc64a\ud649\u55e3\u7019\u8f20\u680c" +
 151.305 +        "\u5581\u2cb1\ub3a4\u3e37\u5fd3\ua3ca\uc115\u979c\uf910\u3797" +
 151.306 +        "\u05cb\u51d6\u74a4\uc5c0\u597b\uf27f\ud5e2\ue8ac\u4f3d\uc0c3" +
 151.307 +        "\u9594\u7799\u6876\ub1a3\u059a\uff03\uc2ee\uc8c2\uf224\u3720" +
 151.308 +        "\u9177\uabdb\u9202\u18d8\uffbe\u0516\u2a76\uedb5\ufe9e\u6d65" +
 151.309 +        "\u4c35\ue4cb\u75aa\u02be\ud24c\ua482\ufc67\ue4f9\u70c7\u3567" +
 151.310 +        "\ufc3f\uaa89\ue80a\u6507\u0a65\u4e18\uf919\u071d\u423c\u1756" +
 151.311 +        "\u30e5\u37f3\u19b3\u10fb\u6c30\u3d30\u2130\u0906\u052b\u0e03" +
 151.312 +        "\u021a\u0500\u0414\ufd05\u4444\ud347\u673c\u6da4\udb7c\u0733" +
 151.313 +        "\ud7bf\ud263\uc6b2\u0414\udd17\u155e\u2d4c\u25cb\ua028\u1a23" +
 151.314 +        "\ub8b0\uf6be\u925f\ude3a\u0202\u0400";
 151.315 +
 151.316 +}
   152.1 --- a/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/EngineArgs/DebugReportsOneExtraByte.java	Thu Feb 16 13:01:36 2012 -0800
   152.2 +++ b/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/EngineArgs/DebugReportsOneExtraByte.java	Sat Feb 18 16:11:47 2012 -0800
   152.3 @@ -1,5 +1,5 @@
   152.4  /*
   152.5 - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
   152.6 + * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
   152.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   152.8   *
   152.9   * This code is free software; you can redistribute it and/or modify it
   153.1 --- a/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/EngineArgs/DebugReportsOneExtraByte.sh	Thu Feb 16 13:01:36 2012 -0800
   153.2 +++ b/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/EngineArgs/DebugReportsOneExtraByte.sh	Sat Feb 18 16:11:47 2012 -0800
   153.3 @@ -1,7 +1,7 @@
   153.4  #! /bin/sh
   153.5  
   153.6  #
   153.7 -# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
   153.8 +# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
   153.9  # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  153.10  #
  153.11  # This code is free software; you can redistribute it and/or modify it
   154.1 --- a/test/sun/security/tools/jarsigner/ec.sh	Thu Feb 16 13:01:36 2012 -0800
   154.2 +++ b/test/sun/security/tools/jarsigner/ec.sh	Sat Feb 18 16:11:47 2012 -0800
   154.3 @@ -1,5 +1,5 @@
   154.4  #
   154.5 -# Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
   154.6 +# Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
   154.7  # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   154.8  #
   154.9  # This code is free software; you can redistribute it and/or modify it
  154.10 @@ -55,7 +55,8 @@
  154.11  
  154.12  $KT -alias a -dname CN=a -keyalg ec -genkey -validity 300 || exit 11
  154.13  $KT -alias b -dname CN=b -keyalg ec -genkey -validity 300 || exit 12
  154.14 -$KT -alias c -dname CN=c -keyalg ec -genkey -validity 300 || exit 13
  154.15 +# Ensure that key length is sufficient for the intended hash (SHA512withECDSA)
  154.16 +$KT -alias c -dname CN=c -keyalg ec -genkey -validity 300 -keysize 521 || exit 13
  154.17  $KT -alias x -dname CN=x -keyalg ec -genkey -validity 300 || exit 14
  154.18  
  154.19  $JARSIGNER -keystore $KS -storepass changeit $JFILE a -debug -strict || exit 21
   155.1 --- a/test/sun/tools/jcmd/jcmd-Defaults.sh	Thu Feb 16 13:01:36 2012 -0800
   155.2 +++ b/test/sun/tools/jcmd/jcmd-Defaults.sh	Sat Feb 18 16:11:47 2012 -0800
   155.3 @@ -28,6 +28,6 @@
   155.4  
   155.5  JCMD="${TESTJAVA}/bin/jcmd"
   155.6  
   155.7 -${JCMD} 2>&1 | awk -f ${TESTSRC}/jcmd_Output1.awk
   155.8 +${JCMD} -J-XX:+UsePerfData 2>&1 | awk -f ${TESTSRC}/jcmd_Output1.awk
   155.9  
  155.10 -${JCMD} -l 2>&1 | awk -f ${TESTSRC}/jcmd_Output1.awk
  155.11 +${JCMD} -J-XX:+UsePerfData -l 2>&1 | awk -f ${TESTSRC}/jcmd_Output1.awk
   156.1 --- a/test/sun/tools/jcmd/jcmd-f.sh	Thu Feb 16 13:01:36 2012 -0800
   156.2 +++ b/test/sun/tools/jcmd/jcmd-f.sh	Sat Feb 18 16:11:47 2012 -0800
   156.3 @@ -46,7 +46,7 @@
   156.4  
   156.5  # -f <script>
   156.6  rm -f jcmd.out 2>/dev/null
   156.7 -${JCMD} $appJavaPid -f ${TESTSRC}/dcmd-script.txt | awk '{ if (NR>1) print $0;}' > jcmd.out 2>&1
   156.8 +${JCMD} -J-XX:+UsePerfData $appJavaPid -f ${TESTSRC}/dcmd-script.txt | awk '{ if (NR>1) print $0;}' > jcmd.out 2>&1
   156.9  echo jcmd.out
  156.10  diff -w jcmd.out ${TESTSRC}/help_help.out
  156.11  if [ $? != 0 ]; then
   157.1 --- a/test/sun/tools/jcmd/jcmd-help-help.sh	Thu Feb 16 13:01:36 2012 -0800
   157.2 +++ b/test/sun/tools/jcmd/jcmd-help-help.sh	Sat Feb 18 16:11:47 2012 -0800
   157.3 @@ -46,7 +46,7 @@
   157.4  
   157.5  # help help
   157.6  rm -f jcmd.out 2>/dev/null
   157.7 -${JCMD} $appJavaPid help help | awk '{ if (NR>1) print $0;}' > jcmd.out 2>&1
   157.8 +${JCMD} -J-XX:+UsePerfData $appJavaPid help help | awk '{ if (NR>1) print $0;}' > jcmd.out 2>&1
   157.9  echo jcmd.out
  157.10  diff -w jcmd.out ${TESTSRC}/help_help.out
  157.11  if [ $? != 0 ]; then
   158.1 --- a/test/sun/tools/jcmd/jcmd-help.sh	Thu Feb 16 13:01:36 2012 -0800
   158.2 +++ b/test/sun/tools/jcmd/jcmd-help.sh	Sat Feb 18 16:11:47 2012 -0800
   158.3 @@ -29,7 +29,7 @@
   158.4  JCMD="${TESTJAVA}/bin/jcmd"
   158.5  
   158.6  rm -f jcmd.out 2>/dev/null
   158.7 -${JCMD} -h > jcmd.out 2>&1
   158.8 +${JCMD} -J-XX:+UsePerfData -h > jcmd.out 2>&1
   158.9  
  158.10  diff -w jcmd.out ${TESTSRC}/usage.out
  158.11  if [ $? != 0 ]
  158.12 @@ -40,7 +40,7 @@
  158.13  fi
  158.14  
  158.15  rm -f jcmd.out 2>/dev/null
  158.16 -${JCMD} -help > jcmd.out 2>&1
  158.17 +${JCMD} -J-XX:+UsePerfData -help > jcmd.out 2>&1
  158.18  
  158.19  diff -w jcmd.out ${TESTSRC}/usage.out
  158.20  if [ $? != 0 ]
   159.1 --- a/test/sun/tools/jcmd/jcmd-pid.sh	Thu Feb 16 13:01:36 2012 -0800
   159.2 +++ b/test/sun/tools/jcmd/jcmd-pid.sh	Sat Feb 18 16:11:47 2012 -0800
   159.3 @@ -45,11 +45,11 @@
   159.4  failed=0
   159.5  
   159.6  # help command 
   159.7 -${JCMD} $appJavaPid help 2>&1 | awk -f ${TESTSRC}/jcmd_pid_Output1.awk
   159.8 +${JCMD} -J-XX:+UsePerfData $appJavaPid help 2>&1 | awk -f ${TESTSRC}/jcmd_pid_Output1.awk
   159.9  if [ $? != 0 ]; then failed=1; fi
  159.10  
  159.11  # PerfCounter.list option
  159.12 -${JCMD} $appJavaPid PerfCounter.print 2>&1 | awk -f ${TESTSRC}/jcmd_pid_Output2.awk
  159.13 +${JCMD} -J-XX:+UsePerfData $appJavaPid PerfCounter.print 2>&1 | awk -f ${TESTSRC}/jcmd_pid_Output2.awk
  159.14  if [ $? != 0 ]; then failed=1; fi
  159.15  
  159.16  set -e
   160.1 --- a/test/sun/tools/jcmd/jcmd_Output1.awk	Thu Feb 16 13:01:36 2012 -0800
   160.2 +++ b/test/sun/tools/jcmd/jcmd_Output1.awk	Sat Feb 18 16:11:47 2012 -0800
   160.3 @@ -1,26 +1,26 @@
   160.4  #
   160.5  BEGIN	{
   160.6 -	    totallines=0; matched=0
   160.7 +            totallines=0; matched=0; current=0
   160.8  	}
   160.9  
  160.10  # match on a main class name followed by arbitrary arguments
  160.11  /^[0-9]+ [a-z|A-Z][a-z|A-Z|0-9|\.]*($| .*$)/	{
  160.12 -	    matched++;
  160.13 +	    current=1;
  160.14  	}
  160.15  
  160.16  # or match on a path name to a jar file followed by arbitraty arguments
  160.17  # - note, jar files ending with ".jar" is only a convention, not a requirement.
  160.18  #Theoretically, any valid file name could occur here.
  160.19  /^[0-9]+ .*\.jar($| .*$)/	{
  160.20 -	    matched++;
  160.21 +	    current=1;
  160.22  }
  160.23  
  160.24  # or match on the condition that the class name is not available
  160.25  /^[0-9]+ -- process information unavailable$/	{
  160.26 -	    matched++;
  160.27 +	    current=1;
  160.28  	}
  160.29  
  160.30 -	{ totallines++; print $0 }
  160.31 +	{ totallines++; matched+=current; current=0; print $0 }
  160.32  
  160.33  END	{
  160.34  	    if ((totallines > 0) && (matched == totallines)) {
   161.1 --- a/test/tools/launcher/Arrrghs.java	Thu Feb 16 13:01:36 2012 -0800
   161.2 +++ b/test/tools/launcher/Arrrghs.java	Sat Feb 18 16:11:47 2012 -0800
   161.3 @@ -24,7 +24,7 @@
   161.4  /**
   161.5   * @test
   161.6   * @bug 5030233 6214916 6356475 6571029 6684582 6742159 4459600 6758881 6753938
   161.7 - *      6894719 6968053 7067922
   161.8 + *      6894719 6968053
   161.9   * @summary Argument parsing validation.
  161.10   * @compile -XDignore.symbol.file Arrrghs.java
  161.11   * @run main Arrrghs
  161.12 @@ -373,21 +373,6 @@
  161.13          System.out.println(tr);
  161.14      }
  161.15  
  161.16 -    /*
  161.17 -     * a missing manifest entry 7067922, we ignore this test for locales
  161.18 -     * which are localized, thus the testing is limited to English locales.
  161.19 -     */
  161.20 -    static void test7067922() {
  161.21 -        if (!isEnglishLocale()) {
  161.22 -            return;
  161.23 -        }
  161.24 -        TestResult tr = null;
  161.25 -        createJar("cvf", "missingmainentry.jar", ".");
  161.26 -        tr = doExec(javaCmd, "-jar", "missingmainentry.jar");
  161.27 -        tr.contains("no main manifest attribute");
  161.28 -        System.out.println(tr);
  161.29 -    }
  161.30 -
  161.31      /**
  161.32       * @param args the command line arguments
  161.33       * @throws java.io.FileNotFoundException
  161.34 @@ -400,7 +385,6 @@
  161.35          runBasicErrorMessageTests();
  161.36          runMainMethodTests();
  161.37          test6894719();
  161.38 -        test7067922();
  161.39          runDiagOptionTests();
  161.40          if (testExitValue > 0) {
  161.41              System.out.println("Total of " + testExitValue + " failed");
   162.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   162.2 +++ b/test/tools/launcher/MainClassAttributeTest.java	Sat Feb 18 16:11:47 2012 -0800
   162.3 @@ -0,0 +1,103 @@
   162.4 +/*
   162.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
   162.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   162.7 + *
   162.8 + * This code is free software; you can redistribute it and/or modify it
   162.9 + * under the terms of the GNU General Public License version 2 only, as
  162.10 + * published by the Free Software Foundation.
  162.11 + *
  162.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
  162.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  162.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  162.15 + * version 2 for more details (a copy is included in the LICENSE file that
  162.16 + * accompanied this code).
  162.17 + *
  162.18 + * You should have received a copy of the GNU General Public License version
  162.19 + * 2 along with this work; if not, write to the Free Software Foundation,
  162.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  162.21 + *
  162.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  162.23 + * or visit www.oracle.com if you need additional information or have any
  162.24 + * questions.
  162.25 + */
  162.26 +
  162.27 +/**
  162.28 + * @test
  162.29 + * @bug 7067922
  162.30 + * @author sogoel
  162.31 + * @summary Test negative scenarios for main class attribute
  162.32 + * @build MainClassAttributeTest
  162.33 + * @run main MainClassAttributeTest
  162.34 + */
  162.35 +
  162.36 +import java.io.File;
  162.37 +import java.io.FileNotFoundException;
  162.38 +import java.io.IOException;
  162.39 +import java.util.ArrayList;
  162.40 +import java.util.List;
  162.41 +
  162.42 +/*
  162.43 + * This tests negative scenarios for Main class entry in a jar file.
  162.44 + * An error should be thrown for each of the test cases when such a
  162.45 + * jar is executed.
  162.46 + */
  162.47 +
  162.48 +public class MainClassAttributeTest extends TestHelper {
  162.49 +
  162.50 +    /*
  162.51 +     * These tests compare messages which could be localized, therefore
  162.52 +     * these tests compare messages only with English locales, and
  162.53 +     * for all other locales,  the exit values are checked.
  162.54 +     */
  162.55 +    static void runTest(File jarFile, String expectedErrorMessage) {
  162.56 +        TestResult tr = doExec(TestHelper.javaCmd,
  162.57 +                "-jar", jarFile.getAbsolutePath());
  162.58 +        if (isEnglishLocale() && !tr.contains(expectedErrorMessage)) {
  162.59 +            System.out.println(tr);
  162.60 +            throw new RuntimeException("expected string not found");
  162.61 +        }
  162.62 +        if (tr.isOK()) {
  162.63 +            System.out.println(tr);
  162.64 +            throw new RuntimeException("test exit with status 0");
  162.65 +        }
  162.66 +    }
  162.67 +
  162.68 +    // Missing manifest entry
  162.69 +    static void test1() throws IOException {
  162.70 +        File jarFile = new File("missingmainentry.jar");
  162.71 +        createJar("cvf", jarFile.getName(), ".");
  162.72 +        runTest(jarFile, "no main manifest attribute");
  162.73 +    }
  162.74 +
  162.75 +    // Entry point in manifest file has .class extension
  162.76 +    static void test2() throws IOException {
  162.77 +        File jarFile = new File("extensionmainentry.jar");
  162.78 +        createJar("Foo.class", jarFile, new File("Foo"), (String[])null);
  162.79 +        runTest(jarFile, "Error: Could not find or load main class");
  162.80 +    }
  162.81 +
  162.82 +    // Entry point in manifest file is misspelled
  162.83 +    static void test3() throws IOException {
  162.84 +        File jarFile = new File("misspelledmainentry.jar");
  162.85 +        createJar("FooMIS", jarFile, new File("Foo"), (String[])null);
  162.86 +        runTest(jarFile, "Error: Could not find or load main class");
  162.87 +    }
  162.88 +
  162.89 +    // Main-Class attribute is misspelled in manifest file
  162.90 +    static void test4() throws IOException {
  162.91 +        File jarFile = new File("misspelledMainAttribute.jar");
  162.92 +        File manifestFile = new File("manifest.txt");
  162.93 +        List<String> contents = new ArrayList<>();
  162.94 +        contents.add("MainClassName: Foo");
  162.95 +        createFile(manifestFile, contents);
  162.96 +        createJar("-cmf", manifestFile.getName(), jarFile.getName());
  162.97 +        runTest(jarFile, "no main manifest attribute");
  162.98 +    }
  162.99 +
 162.100 +    public static void main(String[] args) throws IOException {
 162.101 +        test1();
 162.102 +        test2();
 162.103 +        test3();
 162.104 +        test4();
 162.105 +    }
 162.106 +}