Merge
authorvinnie
Mon, 13 Feb 2012 14:31:32 +0000
changeset 11843 95aeecf515eb
parent 11842 c2259ebc75e1 (current diff)
parent 11841 38a39c748880 (diff)
child 11844 861c6a6c78de
Merge
jdk/src/linux/doc/man/apt.1
jdk/src/linux/doc/man/ja/apt.1
jdk/src/share/classes/sun/nio/ch/SctpMessageInfoImpl.java
jdk/src/share/classes/sun/nio/ch/SctpStdSocketOption.java
jdk/src/solaris/classes/sun/nio/ch/SctpAssocChange.java
jdk/src/solaris/classes/sun/nio/ch/SctpAssociationImpl.java
jdk/src/solaris/classes/sun/nio/ch/SctpChannelImpl.java
jdk/src/solaris/classes/sun/nio/ch/SctpMultiChannelImpl.java
jdk/src/solaris/classes/sun/nio/ch/SctpNet.java
jdk/src/solaris/classes/sun/nio/ch/SctpNotification.java
jdk/src/solaris/classes/sun/nio/ch/SctpPeerAddrChange.java
jdk/src/solaris/classes/sun/nio/ch/SctpResultContainer.java
jdk/src/solaris/classes/sun/nio/ch/SctpSendFailed.java
jdk/src/solaris/classes/sun/nio/ch/SctpServerChannelImpl.java
jdk/src/solaris/classes/sun/nio/ch/SctpShutdown.java
jdk/src/solaris/doc/sun/man/man1/apt.1
jdk/src/solaris/doc/sun/man/man1/ja/apt.1
jdk/src/solaris/native/sun/nio/ch/Sctp.h
jdk/src/solaris/native/sun/nio/ch/SctpChannelImpl.c
jdk/src/solaris/native/sun/nio/ch/SctpNet.c
jdk/src/solaris/native/sun/nio/ch/SctpServerChannelImpl.c
jdk/src/windows/classes/sun/nio/ch/SctpChannelImpl.java
jdk/src/windows/classes/sun/nio/ch/SctpMultiChannelImpl.java
jdk/src/windows/classes/sun/nio/ch/SctpServerChannelImpl.java
--- a/.hgtags	Mon Feb 13 14:26:25 2012 +0000
+++ b/.hgtags	Mon Feb 13 14:31:32 2012 +0000
@@ -145,3 +145,5 @@
 b3a426170188f52981cf4573a2f14d487fddab0d jdk8-b21
 e8f03541af27e38aafb619b96863e17f65ffe53b jdk8-b22
 498124337041ad53cbaa7eb110f3d7acd6d4eac4 jdk8-b23
+7d3720d8c595d1519c31e9ff7366203fc2c61350 jdk8-b24
+0071a6d64113a35ba345bb1580c256de5ce17d3e jdk8-b25
--- a/.hgtags-top-repo	Mon Feb 13 14:26:25 2012 +0000
+++ b/.hgtags-top-repo	Mon Feb 13 14:31:32 2012 +0000
@@ -145,3 +145,5 @@
 cc771d92284f71765eca14d6d08703c4af254c04 jdk8-b21
 7ad075c809952e355d25030605da6af30456ed74 jdk8-b22
 60d6f64a86b1e511169d264727f6d51415978df0 jdk8-b23
+1a5f1d6b98d6827cdb529a4abe6e52a886d944f4 jdk8-b24
+221a378e06a326f45e5d89e2123cd6323e0181d1 jdk8-b25
--- a/corba/.hgtags	Mon Feb 13 14:26:25 2012 +0000
+++ b/corba/.hgtags	Mon Feb 13 14:31:32 2012 +0000
@@ -145,3 +145,5 @@
 f157fc2a71a38ce44007a6f18d5b011824dce705 jdk8-b21
 a11d0062c445d5f36651c78650ab88aa594bcbff jdk8-b22
 5218eb256658442b62b05295aafa5b5f35252972 jdk8-b23
+b98f0e6dddf987df565029a1f58417fc1844c3f3 jdk8-b24
+e45d6b406d5f91ff5256a5c82456ab1e7eb8becd jdk8-b25
--- a/hotspot/.hgtags	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/.hgtags	Mon Feb 13 14:31:32 2012 +0000
@@ -215,3 +215,8 @@
 dcc292399a39113957eebbd3e487b7e05e2c79fc hs23-b11
 e850d8e7ea54b91c7aa656e297f0f9f38dd4c296 jdk8-b23
 9e177d44b10fe92ecffa965fef9c5ac5433c1b46 hs23-b12
+a80fd4f45d7aaa154ed2f86a129f3c9c4035ec7a jdk8-b24
+b22de824749922986ce4d442bed029916b832807 hs23-b13
+64b46f975ab82948c1e021e17775ff4fab8bc40e hs23-b14
+9ad8feb5afbddec46d3cfe29fb5f73c2e99d5a43 jdk8-b25
+d71e662fe03741b6de498ca2077220148405a978 hs23-b15
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/LoaderConstraintTable.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/LoaderConstraintTable.java	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2012 Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -42,15 +42,6 @@
 
   private static synchronized void initialize(TypeDataBase db) {
     Type type = db.lookupType("LoaderConstraintTable");
-    nofBuckets = db.lookupIntConstant("LoaderConstraintTable::_nof_buckets").intValue();
-  }
-
-  // Fields
-  private static int nofBuckets;
-
-  // Accessors
-  public static int getNumOfBuckets() {
-    return nofBuckets;
   }
 
   public LoaderConstraintTable(Address addr) {
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/SystemDictionary.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/SystemDictionary.java	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,7 +36,6 @@
   private static AddressField placeholdersField;
   private static AddressField loaderConstraintTableField;
   private static sun.jvm.hotspot.types.OopField javaSystemLoaderField;
-  private static int nofBuckets;
 
   private static sun.jvm.hotspot.types.OopField objectKlassField;
   private static sun.jvm.hotspot.types.OopField classLoaderKlassField;
@@ -62,7 +61,6 @@
     placeholdersField = type.getAddressField("_placeholders");
     loaderConstraintTableField = type.getAddressField("_loader_constraints");
     javaSystemLoaderField = type.getOopField("_java_system_loader");
-    nofBuckets = db.lookupIntConstant("SystemDictionary::_nof_buckets").intValue();
 
     objectKlassField = type.getOopField(WK_KLASS("Object_klass"));
     classLoaderKlassField = type.getOopField(WK_KLASS("ClassLoader_klass"));
@@ -142,10 +140,6 @@
     return newOop(javaSystemLoaderField.getValue());
   }
 
-  public static int getNumOfBuckets() {
-    return nofBuckets;
-  }
-
   private static Oop newOop(OopHandle handle) {
     return VM.getVM().getObjectHeap().newOop(handle);
   }
--- a/hotspot/make/Makefile	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/make/Makefile	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -89,19 +89,31 @@
 ZERO_VM_TARGETS=productzero fastdebugzero optimizedzero jvmgzero
 SHARK_VM_TARGETS=productshark fastdebugshark optimizedshark jvmgshark
 
+COMMON_VM_PRODUCT_TARGETS=product product1 productkernel docs export_product
+COMMON_VM_FASTDEBUG_TARGETS=fastdebug fastdebug1 fastdebugkernel docs export_fastdebug
+COMMON_VM_DEBUG_TARGETS=jvmg jvmg1 jvmgkernel docs export_debug
+
 # JDK directory list
 JDK_DIRS=bin include jre lib demo
 
 all:           all_product all_fastdebug
-ifndef BUILD_CLIENT_ONLY
-all_product:   product product1 productkernel docs export_product
-all_fastdebug: fastdebug fastdebug1 fastdebugkernel docs export_fastdebug
-all_debug:     jvmg jvmg1 jvmgkernel docs export_debug
-else
+
+ifdef BUILD_CLIENT_ONLY
 all_product:   product1 docs export_product
 all_fastdebug: fastdebug1 docs export_fastdebug
 all_debug:     jvmg1 docs export_debug
+else
+ifeq ($(MACOSX_UNIVERSAL),true)
+all_product:   universal_product
+all_fastdebug: universal_fastdebug
+all_debug:     universal_debug
+else
+all_product:   $(COMMON_VM_PRODUCT_TARGETS)
+all_fastdebug: $(COMMON_VM_FASTDEBUG_TARGETS)
+all_debug:     $(COMMON_VM_DEBUG_TARGETS)
 endif
+endif
+
 all_optimized: optimized optimized1 optimizedkernel docs export_optimized
 
 allzero:           all_productzero all_fastdebugzero
@@ -232,20 +244,19 @@
 	$(MAKE) VM_SUBDIR=${VM_DEBUG} EXPORT_SUBDIR=/debug   generic_export
 export_optimized:
 	$(MAKE) VM_SUBDIR=optimized EXPORT_SUBDIR=/optimized generic_export
-export_product_jdk:
+export_product_jdk::
 	$(MAKE) ALT_EXPORT_PATH=$(JDK_IMAGE_DIR) \
 		VM_SUBDIR=product                            generic_export
-export_optimized_jdk:
+export_optimized_jdk::
 	$(MAKE) ALT_EXPORT_PATH=$(JDK_IMAGE_DIR) \
 		VM_SUBDIR=optimized                          generic_export
-export_fastdebug_jdk:
+export_fastdebug_jdk::
 	$(MAKE) ALT_EXPORT_PATH=$(JDK_IMAGE_DIR)/fastdebug \
 		VM_SUBDIR=fastdebug                          generic_export
-export_debug_jdk:
+export_debug_jdk::
 	$(MAKE) ALT_EXPORT_PATH=$(JDK_IMAGE_DIR)/debug \
 		VM_SUBDIR=${VM_DEBUG}                        generic_export
 
-
 # Export file copy rules
 XUSAGE=$(HS_SRC_DIR)/share/vm/Xusage.txt
 DOCS_DIR=$(OUTPUTDIR)/$(VM_PLATFORM)_docs
@@ -444,14 +455,14 @@
   endif
 	$(JDK_IMAGE_DIR)/bin/java -server -version
 
-copy_product_jdk:
+copy_product_jdk::
 	$(RM) -r $(JDK_IMAGE_DIR)
 	$(MKDIR) -p $(JDK_IMAGE_DIR)
 	($(CD) $(JDK_IMPORT_PATH) && \
 	 $(TAR) -cf - $(JDK_DIRS)) | \
 	 ($(CD) $(JDK_IMAGE_DIR) && $(TAR) -xf -)
 
-copy_fastdebug_jdk:
+copy_fastdebug_jdk::
 	$(RM) -r $(JDK_IMAGE_DIR)/fastdebug
 	$(MKDIR) -p $(JDK_IMAGE_DIR)/fastdebug
 	if [ -d $(JDK_IMPORT_PATH)/fastdebug ] ; then \
@@ -464,7 +475,7 @@
 	   ($(CD) $(JDK_IMAGE_DIR)/fastdebug && $(TAR) -xf -) ; \
 	fi
 
-copy_debug_jdk:
+copy_debug_jdk::
 	$(RM) -r $(JDK_IMAGE_DIR)/debug
 	$(MKDIR) -p $(JDK_IMAGE_DIR)/debug
 	if [ -d $(JDK_IMPORT_PATH)/debug ] ; then \
@@ -481,36 +492,6 @@
 	   ($(CD) $(JDK_IMAGE_DIR)/debug && $(TAR) -xf -) ; \
 	fi
 
-# macosx universal builds
-
-ifeq ($(MACOSX_UNIVERSAL), true)
-$(UNIVERSAL_LIPO_LIST):
-	lipo -create -output $@ $(EXPORT_JRE_LIB_DIR)/{i386,amd64}/$(subst $(EXPORT_JRE_LIB_DIR)/,,$@)
-
-$(UNIVERSAL_COPY_LIST):
-	$(CP) $(EXPORT_JRE_LIB_DIR)/i386/$(subst $(EXPORT_JRE_LIB_DIR)/,,$@) $@
-
-universalize: $(UNIVERSAL_LIPO_LIST) $(UNIVERSAL_COPY_LIST)
-endif
-
-universal_product:
-	$(QUIETLY) $(MAKE) ARCH_DATA_MODEL=32 MACOSX_UNIVERSAL=true all_product
-	$(QUIETLY) $(MAKE) ARCH_DATA_MODEL=64 MACOSX_UNIVERSAL=true all_product
-	$(MKDIR) -p $(EXPORT_JRE_LIB_DIR)/{client,server}
-	$(QUIETLY) $(MAKE) MACOSX_UNIVERSAL=true universalize
-
-universal_fastdebug:
-	$(QUIETLY) $(MAKE) ARCH_DATA_MODEL=32 MACOSX_UNIVERSAL=true all_fastdebug
-	$(QUIETLY) $(MAKE) ARCH_DATA_MODEL=64 MACOSX_UNIVERSAL=true all_fastdebug
-	$(MKDIR) -p $(EXPORT_JRE_LIB_DIR)/{client,server}
-	$(QUIETLY) $(MAKE) MACOSX_UNIVERSAL=true universalize
-
-universal_debug:
-	$(QUIETLY) $(MAKE) ARCH_DATA_MODEL=32 MACOSX_UNIVERSAL=true all_debug
-	$(QUIETLY) $(MAKE) ARCH_DATA_MODEL=64 MACOSX_UNIVERSAL=true all_debug
-	$(MKDIR) -p $(EXPORT_JRE_LIB_DIR)/{client,server}
-	$(QUIETLY) $(MAKE) MACOSX_UNIVERSAL=true universalize
-
 #
 # Check target
 #
@@ -630,6 +611,13 @@
 	@$(ECHO) \
 "  $(MAKE) ALT_JDK_IMPORT_PATH=/opt/java/jdk$(JDK_VERSION)"
 
+# Universal build support
+ifeq ($(OS_VENDOR), Darwin)
+ifeq ($(MACOSX_UNIVERSAL),true)
+include $(GAMMADIR)/make/$(OSNAME)/makefiles/universal.gmk
+endif
+endif
+
 # JPRT rule to build this workspace
 include $(GAMMADIR)/make/jprt.gmk
 
@@ -639,6 +627,4 @@
 	export_product export_fastdebug export_debug export_optimized \
 	export_jdk_product export_jdk_fastdebug export_jdk_debug \
 	create_jdk copy_jdk update_jdk test_jdk \
-	copy_product_jdk copy_fastdebug_jdk copy_debug_jdk universalize \
-	universal_product
-
+	copy_product_jdk copy_fastdebug_jdk copy_debug_jdk 
--- a/hotspot/make/bsd/makefiles/adlc.make	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/make/bsd/makefiles/adlc.make	Mon Feb 13 14:31:32 2012 +0000
@@ -61,10 +61,10 @@
 INCLUDES += $(Src_Dirs_I:%=-I%)
 
 # set flags for adlc compilation
-CPPFLAGS = $(SYSDEFS) $(INCLUDES)
+CXXFLAGS = $(SYSDEFS) $(INCLUDES)
 
 # Force assertions on.
-CPPFLAGS += -DASSERT
+CXXFLAGS += -DASSERT
 
 # CFLAGS_WARN holds compiler options to suppress/enable warnings.
 # Compiler warnings are treated as errors
@@ -111,7 +111,7 @@
 
 $(EXEC) : $(OBJECTS)
 	@echo Making adlc
-	$(QUIETLY) $(HOST.LINK_NOPROF.CC) -o $(EXEC) $(OBJECTS)
+	$(QUIETLY) $(HOST.LINK_NOPROF.CXX) -o $(EXEC) $(OBJECTS)
 
 # Random dependencies:
 $(OBJECTS): opcodes.hpp classes.hpp adlc.hpp adlcVMDeps.hpp adlparse.hpp archDesc.hpp arena.hpp dict2.hpp filebuff.hpp forms.hpp formsopt.hpp formssel.hpp
@@ -213,14 +213,14 @@
 $(OUTDIR)/%.o: %.cpp
 	@echo Compiling $<
 	$(QUIETLY) $(REMOVE_TARGET)
-	$(QUIETLY) $(HOST.COMPILE.CC) -o $@ $< $(COMPILE_DONE)
+	$(QUIETLY) $(HOST.COMPILE.CXX) -o $@ $< $(COMPILE_DONE)
 
 # Some object files are given a prefix, to disambiguate
 # them from objects of the same name built for the VM.
 $(OUTDIR)/adlc-%.o: %.cpp
 	@echo Compiling $<
 	$(QUIETLY) $(REMOVE_TARGET)
-	$(QUIETLY) $(HOST.COMPILE.CC) -o $@ $< $(COMPILE_DONE)
+	$(QUIETLY) $(HOST.COMPILE.CXX) -o $@ $< $(COMPILE_DONE)
 
 # #########################################################################
 
--- a/hotspot/make/bsd/makefiles/defs.make	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/make/bsd/makefiles/defs.make	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -171,10 +171,36 @@
 
 EXPORT_LIST += $(ADD_SA_BINARIES/$(HS_ARCH))
 
-UNIVERSAL_LIPO_LIST += $(EXPORT_JRE_LIB_DIR)/libjsig.$(LIBRARY_SUFFIX)
-UNIVERSAL_LIPO_LIST += $(EXPORT_JRE_LIB_DIR)/libsaproc.$(LIBRARY_SUFFIX)
-UNIVERSAL_LIPO_LIST += $(EXPORT_JRE_LIB_DIR)/server/libjvm.$(LIBRARY_SUFFIX)
+# Universal build settings
+ifeq ($(OS_VENDOR), Darwin)
+  # Build universal binaries by default on Mac OS X
+  MACOSX_UNIVERSAL = true
+  ifneq ($(ALT_MACOSX_UNIVERSAL),)
+    MACOSX_UNIVERSAL = $(ALT_MACOSX_UNIVERSAL)
+  endif
+  MAKE_ARGS += MACOSX_UNIVERSAL=$(MACOSX_UNIVERSAL)
+
+  # Universal settings
+  ifeq ($(MACOSX_UNIVERSAL), true)
 
-UNIVERSAL_COPY_LIST += $(EXPORT_JRE_LIB_DIR)/server/Xusage.txt
-UNIVERSAL_COPY_LIST += $(EXPORT_JRE_LIB_DIR)/client/Xusage.txt
-UNIVERSAL_COPY_LIST += $(EXPORT_JRE_LIB_DIR)/client/libjvm.$(LIBRARY_SUFFIX)
+    # Set universal export path but avoid using ARCH or PLATFORM subdirs
+    EXPORT_PATH=$(OUTPUTDIR)/export-universal$(EXPORT_SUBDIR)
+    ifneq ($(ALT_EXPORT_PATH),)
+      EXPORT_PATH=$(ALT_EXPORT_PATH)
+    endif
+
+    # Set universal image dir
+    JDK_IMAGE_DIR=$(OUTPUTDIR)/jdk-universal$(EXPORT_SUBDIR)
+
+    # Binaries to 'universalize' if built
+    UNIVERSAL_LIPO_LIST += $(EXPORT_JRE_LIB_DIR)/libjsig.$(LIBRARY_SUFFIX)
+    UNIVERSAL_LIPO_LIST += $(EXPORT_JRE_LIB_DIR)/libsaproc.$(LIBRARY_SUFFIX)
+    UNIVERSAL_LIPO_LIST += $(EXPORT_JRE_LIB_DIR)/server/libjvm.$(LIBRARY_SUFFIX)
+    UNIVERSAL_LIPO_LIST += $(EXPORT_JRE_LIB_DIR)/client/libjvm.$(LIBRARY_SUFFIX)
+
+    # Files to simply copy in place
+    UNIVERSAL_COPY_LIST += $(EXPORT_JRE_LIB_DIR)/server/Xusage.txt
+    UNIVERSAL_COPY_LIST += $(EXPORT_JRE_LIB_DIR)/client/Xusage.txt
+
+  endif
+endif
--- a/hotspot/make/bsd/makefiles/dtrace.make	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/make/bsd/makefiles/dtrace.make	Mon Feb 13 14:31:32 2012 +0000
@@ -105,11 +105,11 @@
 
 lib$(GENOFFS).dylib: $(DTRACE_SRCDIR)/$(GENOFFS).cpp $(DTRACE_SRCDIR)/$(GENOFFS).h \
                   $(LIBJVM.o)
-	$(QUIETLY) $(CCC) $(CPPFLAGS) $(GENOFFS_CFLAGS) $(SHARED_FLAG) $(PICFLAG) \
+	$(QUIETLY) $(CXX) $(CXXFLAGS) $(GENOFFS_CFLAGS) $(SHARED_FLAG) $(PICFLAG) \
 		 $(LFLAGS_GENOFFS) -o $@ $(DTRACE_SRCDIR)/$(GENOFFS).cpp -ljvm
 
 $(GENOFFS): $(DTRACE_SRCDIR)/$(GENOFFS)Main.c lib$(GENOFFS).dylib
-	$(QUIETLY) $(LINK.CC) -o $@ $(DTRACE_SRCDIR)/$(GENOFFS)Main.c \
+	$(QUIETLY) $(LINK.CXX) -o $@ $(DTRACE_SRCDIR)/$(GENOFFS)Main.c \
 		./lib$(GENOFFS).dylib
 
 # $@.tmp is created first to avoid an empty $(JVMOFFS).h if an error occurs.
@@ -135,7 +135,7 @@
 	fi
 
 $(JVMOFFS.o): $(JVMOFFS).h $(JVMOFFS).cpp 
-	$(QUIETLY) $(CCC) -c -I. -o $@ $(ARCHFLAG) -D$(TYPE) $(JVMOFFS).cpp
+	$(QUIETLY) $(CXX) -c -I. -o $@ $(ARCHFLAG) -D$(TYPE) $(JVMOFFS).cpp
 
 $(LIBJVM_DB): $(DTRACE_SRCDIR)/$(JVM_DB).c $(JVMOFFS.o) $(XLIBJVM_DB) $(LIBJVM_DB_MAPFILE)
 	@echo Making $@
--- a/hotspot/make/bsd/makefiles/gcc.make	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/make/bsd/makefiles/gcc.make	Mon Feb 13 14:31:32 2012 +0000
@@ -25,20 +25,19 @@
 OS_VENDOR = $(shell uname -s)
 
 #------------------------------------------------------------------------
-# CC, CPP & AS
+# CC, CXX & AS
 
 # When cross-compiling the ALT_COMPILER_PATH points
 # to the cross-compilation toolset
 ifdef CROSS_COMPILE_ARCH
- CPP = $(ALT_COMPILER_PATH)/g++
+ CXX = $(ALT_COMPILER_PATH)/g++
  CC  = $(ALT_COMPILER_PATH)/gcc
- HOSTCPP = g++
+ HOSTCXX = g++
  HOSTCC  = gcc
 else ifneq ($(OS_VENDOR), Darwin)
  CXX = g++
- CPP = $(CXX)
  CC  = gcc
- HOSTCPP = $(CPP)
+ HOSTCXX = $(CXX)
  HOSTCC  = $(CC)
 endif
 
@@ -53,7 +52,6 @@
   ifeq ($(origin CC), default)
    CC  = llvm-gcc
   endif
-  CPP  = $(CXX)
 
   ifeq ($(ARCH), i486)
   LLVM_SUPPORTS_STACKREALIGN := $(shell \
@@ -67,11 +65,11 @@
     CXX32 ?= g++-4.0
     CC32  ?= gcc-4.0
   endif
-  CPP = $(CXX32)
+  CXX = $(CXX32)
   CC  = $(CC32)
   endif
 
-  HOSTCPP = $(CPP)
+  HOSTCXX = $(CXX)
   HOSTCC  = $(CC)
 endif
 
--- a/hotspot/make/bsd/makefiles/launcher.make	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/make/bsd/makefiles/launcher.make	Mon Feb 13 14:31:32 2012 +0000
@@ -71,10 +71,10 @@
   LIBS_LAUNCHER             += -l$(JVM) $(LIBS)
 endif
 
-LINK_LAUNCHER = $(LINK.c)
+LINK_LAUNCHER = $(LINK.CC)
 
-LINK_LAUNCHER/PRE_HOOK  = $(LINK_LIB.CC/PRE_HOOK)
-LINK_LAUNCHER/POST_HOOK = $(LINK_LIB.CC/POST_HOOK)
+LINK_LAUNCHER/PRE_HOOK  = $(LINK_LIB.CXX/PRE_HOOK)
+LINK_LAUNCHER/POST_HOOK = $(LINK_LIB.CXX/POST_HOOK)
 
 LAUNCHER_OUT = launcher
 
@@ -90,11 +90,11 @@
 
 $(LAUNCHER_OUT)/%.o: $(LAUNCHERDIR_SHARE)/%.c
 	$(QUIETLY) [ -d $(LAUNCHER_OUT) ] || { mkdir -p $(LAUNCHER_OUT); }
-	$(QUIETLY) $(CC) -g -o $@ -c $< -MMD $(LAUNCHERFLAGS) $(CPPFLAGS)
+	$(QUIETLY) $(CC) -g -o $@ -c $< -MMD $(LAUNCHERFLAGS) $(CXXFLAGS)
 
 $(LAUNCHER_OUT)/%.o: $(LAUNCHERDIR)/%.c
 	$(QUIETLY) [ -d $(LAUNCHER_OUT) ] || { mkdir -p $(LAUNCHER_OUT); }
-	$(QUIETLY) $(CC) -g -o $@ -c $< -MMD $(LAUNCHERFLAGS) $(CPPFLAGS)
+	$(QUIETLY) $(CC) -g -o $@ -c $< -MMD $(LAUNCHERFLAGS) $(CXXFLAGS)
 
 $(LAUNCHER): $(OBJS) $(LIBJVM) $(LAUNCHER_MAPFILE)
 	$(QUIETLY) echo Linking launcher...
--- a/hotspot/make/bsd/makefiles/product.make	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/make/bsd/makefiles/product.make	Mon Feb 13 14:31:32 2012 +0000
@@ -55,4 +55,4 @@
 STRIP_AOUT   = $(STRIP) -x $@ || exit 1;
 
 # Don't strip in VM build; JDK build will strip libraries later
-# LINK_LIB.CC/POST_HOOK += $(STRIP_$(LINK_INTO))
+# LINK_LIB.CXX/POST_HOOK += $(STRIP_$(LINK_INTO))
--- a/hotspot/make/bsd/makefiles/rules.make	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/make/bsd/makefiles/rules.make	Mon Feb 13 14:31:32 2012 +0000
@@ -27,52 +27,39 @@
 # Tell make that .cpp is important
 .SUFFIXES: .cpp $(SUFFIXES)
 
-# For now.  Other makefiles use CPP as the c++ compiler, but that should really
-# name the preprocessor.
-ifeq    ($(CCC),)
-CCC             = $(CPP)
-endif
-
 DEMANGLER       = c++filt
 DEMANGLE        = $(DEMANGLER) < $@ > .$@ && mv -f .$@ $@
 
-# $(CC) is the c compiler (cc/gcc), $(CCC) is the c++ compiler (CC/g++).
-C_COMPILE       = $(CC) $(CPPFLAGS) $(CFLAGS)
-CC_COMPILE      = $(CCC) $(CPPFLAGS) $(CFLAGS)
+# $(CC) is the c compiler (cc/gcc), $(CXX) is the c++ compiler (CC/g++).
+CC_COMPILE       = $(CC) $(CXXFLAGS) $(CFLAGS)
+CXX_COMPILE      = $(CXX) $(CXXFLAGS) $(CFLAGS)
 
 AS.S            = $(AS) $(ASFLAGS)
 
-COMPILE.c       = $(C_COMPILE) -c
-GENASM.c        = $(C_COMPILE) -S
-LINK.c          = $(CC) $(LFLAGS) $(AOUT_FLAGS) $(PROF_AOUT_FLAGS)
-LINK_LIB.c      = $(CC) $(LFLAGS) $(SHARED_FLAG)
-PREPROCESS.c    = $(C_COMPILE) -E
+COMPILE.CC       = $(CC_COMPILE) -c
+GENASM.CC        = $(CC_COMPILE) -S
+LINK.CC          = $(CC) $(LFLAGS) $(AOUT_FLAGS) $(PROF_AOUT_FLAGS)
+LINK_LIB.CC      = $(CC) $(LFLAGS) $(SHARED_FLAG)
+PREPROCESS.CC    = $(CC_COMPILE) -E
 
-COMPILE.CC      = $(CC_COMPILE) -c
-GENASM.CC       = $(CC_COMPILE) -S
-LINK.CC         = $(CCC) $(LFLAGS) $(AOUT_FLAGS) $(PROF_AOUT_FLAGS)
-LINK_NOPROF.CC  = $(CCC) $(LFLAGS) $(AOUT_FLAGS)
-LINK_LIB.CC     = $(CCC) $(LFLAGS) $(SHARED_FLAG)
-PREPROCESS.CC   = $(CC_COMPILE) -E
+COMPILE.CXX      = $(CXX_COMPILE) -c
+GENASM.CXX       = $(CXX_COMPILE) -S
+LINK.CXX         = $(CXX) $(LFLAGS) $(AOUT_FLAGS) $(PROF_AOUT_FLAGS)
+LINK_NOPROF.CXX  = $(CXX) $(LFLAGS) $(AOUT_FLAGS)
+LINK_LIB.CXX     = $(CXX) $(LFLAGS) $(SHARED_FLAG)
+PREPROCESS.CXX   = $(CXX_COMPILE) -E
 
 # cross compiling the jvm with c2 requires host compilers to build
 # adlc tool
 
-HOST.CC_COMPILE      = $(HOSTCPP) $(CPPFLAGS) $(CFLAGS)
-HOST.COMPILE.CC      = $(HOST.CC_COMPILE) -c
-HOST.LINK_NOPROF.CC  = $(HOSTCPP) $(LFLAGS) $(AOUT_FLAGS)
+HOST.CXX_COMPILE      = $(HOSTCXX) $(CXXFLAGS) $(CFLAGS)
+HOST.COMPILE.CXX      = $(HOST.CXX_COMPILE) -c
+HOST.LINK_NOPROF.CXX  = $(HOSTCXX) $(LFLAGS) $(AOUT_FLAGS)
 
 
 # Effect of REMOVE_TARGET is to delete out-of-date files during "gnumake -k".
 REMOVE_TARGET   = rm -f $@
 
-# Synonyms.
-COMPILE.cpp     = $(COMPILE.CC)
-GENASM.cpp      = $(GENASM.CC)
-LINK.cpp        = $(LINK.CC)
-LINK_LIB.cpp    = $(LINK_LIB.CC)
-PREPROCESS.cpp  = $(PREPROCESS.CC)
-
 # Note use of ALT_BOOTDIR to explicitly specify location of java and
 # javac; this is the same environment variable used in the J2SE build
 # process for overriding the default spec, which is BOOTDIR.
@@ -161,14 +148,14 @@
 %.o: %.cpp
 	@echo Compiling $<
 	$(QUIETLY) $(REMOVE_TARGET)
-	$(QUIETLY) $(COMPILE.CC) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE)
+	$(QUIETLY) $(COMPILE.CXX) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE)
 else
 %.o: %.cpp
 	@echo Compiling $<
 	$(QUIETLY) $(REMOVE_TARGET)
 	$(QUIETLY) $(if $(findstring $@, $(NONPIC_OBJ_FILES)), \
-	   $(subst $(VM_PICFLAG), ,$(COMPILE.CC)) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE), \
-	   $(COMPILE.CC) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE))
+	   $(subst $(VM_PICFLAG), ,$(COMPILE.CXX)) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE), \
+	   $(COMPILE.CXX) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE))
 endif
 
 %.o: %.s
@@ -178,13 +165,13 @@
 
 %.s: %.cpp
 	@echo Generating assembly for $<
-	$(QUIETLY) $(GENASM.CC) -o $@ $<
+	$(QUIETLY) $(GENASM.CXX) -o $@ $<
 	$(QUIETLY) $(DEMANGLE) $(COMPILE_DONE)
 
 # Intermediate files (for debugging macros)
 %.i: %.cpp
 	@echo Preprocessing $< to $@
-	$(QUIETLY) $(PREPROCESS.CC) $< > $@ $(COMPILE_DONE)
+	$(QUIETLY) $(PREPROCESS.CXX) $< > $@ $(COMPILE_DONE)
 
 #  Override gnumake built-in rules which do sccs get operations badly.
 #  (They put the checked out code in the current directory, not in the
--- a/hotspot/make/bsd/makefiles/sparcWorks.make	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/make/bsd/makefiles/sparcWorks.make	Mon Feb 13 14:31:32 2012 +0000
@@ -23,13 +23,13 @@
 #
 
 #------------------------------------------------------------------------
-# CC, CPP & AS
+# CC, CXX & AS
 
-CPP = CC
+CXX = CC
 CC  = cc
 AS  = $(CC) -c
 
-HOSTCPP = $(CPP)
+HOSTCXX = $(CXX)
 HOSTCC  = $(CC)
 
 ARCHFLAG = $(ARCHFLAG/$(BUILDARCH))
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/make/bsd/makefiles/universal.gmk	Mon Feb 13 14:31:32 2012 +0000
@@ -0,0 +1,113 @@
+#
+# Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#  
+#
+
+# macosx universal builds
+universal_product:
+	$(MAKE) MACOSX_UNIVERSAL=true all_product_universal
+universal_fastdebug:
+	$(MAKE) MACOSX_UNIVERSAL=true all_fastdebug_universal
+universal_debug:
+	$(MAKE) MACOSX_UNIVERSAL=true all_debug_universal
+
+
+# Universal builds include 1 or more architectures in a single binary
+all_product_universal:
+#	$(QUIETLY) $(MAKE) ARCH_DATA_MODEL=32 $(COMMON_VM_PRODUCT_TARGETS)
+	$(QUIETLY) $(MAKE) ARCH_DATA_MODEL=64 $(COMMON_VM_PRODUCT_TARGETS)
+	$(QUIETLY) $(MAKE) EXPORT_SUBDIR= universalize
+all_fastdebug_universal:
+#	$(QUIETLY) $(MAKE) ARCH_DATA_MODEL=32 $(COMMON_VM_FASTDEBUG_TARGETS)
+	$(QUIETLY) $(MAKE) ARCH_DATA_MODEL=64 $(COMMON_VM_FASTDEBUG_TARGETS)
+	$(QUIETLY) $(MAKE) EXPORT_SUBDIR=/fastdebug universalize
+all_debug_universal:
+#	$(QUIETLY) $(MAKE) ARCH_DATA_MODEL=32 $(COMMON_VM_DEBUG_TARGETS)
+	$(QUIETLY) $(MAKE) ARCH_DATA_MODEL=64 $(COMMON_VM_DEBUG_TARGETS)
+	$(QUIETLY) $(MAKE) EXPORT_SUBDIR=/debug universalize
+
+
+# Consolidate architecture builds into a single Universal binary
+universalize: $(UNIVERSAL_LIPO_LIST) $(UNIVERSAL_COPY_LIST)
+	$(RM) -r $(EXPORT_PATH)/jre/lib/{i386,amd64}
+
+
+# Package built libraries in a universal binary
+$(UNIVERSAL_LIPO_LIST):
+	BUILT_LIPO_FILES="`find $(EXPORT_JRE_LIB_DIR)/{i386,amd64}/$(subst $(EXPORT_JRE_LIB_DIR)/,,$@) 2>/dev/null`"; \
+	if [ -n "$${BUILT_LIPO_FILES}" ]; then \
+	  $(MKDIR) -p $(shell dirname $@); \
+	  lipo -create -output $@ $${BUILT_LIPO_FILES}; \
+	fi	
+
+
+# Copy built non-universal binaries in place
+$(UNIVERSAL_COPY_LIST):
+	BUILT_COPY_FILES="`find $(EXPORT_JRE_LIB_DIR)/{i386,amd64}/$(subst $(EXPORT_JRE_LIB_DIR)/,,$@) 2>/dev/null`"; \
+	if [ -n "$${BUILT_COPY_FILES}" ]; then \
+	  for i in $${BUILT_COPY_FILES}; do \
+	    if [ -f $${i} ]; then \
+	      $(MKDIR) -p $(shell dirname $@); \
+	      $(CP) $${i} $@; \
+	    fi; \
+	  done; \
+	fi
+
+
+# Replace arch specific binaries with universal binaries
+export_universal:
+	$(RM) -r $(EXPORT_PATH)/jre/lib/{i386,amd64}
+	$(RM) -r $(JDK_IMAGE_DIR)/jre/lib/{i386,amd64}
+	$(RM) $(JDK_IMAGE_DIR)/jre/lib/{client,server}/libjsig.$(LIBRARY_SUFFIX)
+	($(CD) $(EXPORT_PATH) && \
+	  $(TAR) -cf - *) | \
+	  ($(CD) $(JDK_IMAGE_DIR) && $(TAR) -xpf -)
+
+
+# Overlay universal binaries
+copy_universal:
+	$(RM) -r $(JDK_IMAGE_DIR)$(COPY_SUBDIR)/jre/lib/{i386,amd64}
+	$(RM) $(JDK_IMAGE_DIR)$(COPY_SUBDIR)/jre/lib/{client,server}/libjsig.$(LIBRARY_SUFFIX)
+	($(CD) $(EXPORT_PATH)$(COPY_SUBDIR) && \
+	  $(TAR) -cf - *) | \
+	  ($(CD) $(JDK_IMAGE_DIR)$(COPY_SUBDIR) && $(TAR) -xpf -)
+
+
+# Additional processing for universal builds
+export_product_jdk::
+	$(MAKE) EXPORT_SUBDIR=           export_universal
+export_optimized_jdk::
+	$(MAKE) EXPORT_SUBDIR=           export_universal
+export_fastdebug_jdk::
+	$(MAKE) EXPORT_SUBDIR=/fastdebug export_universal
+export_debug_jdk::
+	$(MAKE) EXPORT_SUBDIR=/debug     export_universal
+copy_product_jdk::
+	$(MAKE) COPY_SUBDIR=             copy_universal
+copy_fastdebug_jdk::
+	$(MAKE) COPY_SUBDIR=/fastdebug   copy_universal
+copy_debug_jdk::
+	$(MAKE) COPY_SUBDIR=/debug       copy_universal
+
+.PHONY:	universal_product universal_fastdebug universal_debug \
+	all_product_universal all_fastdebug_universal all_debug_universal \
+	universalize export_universal copy_universal
--- a/hotspot/make/bsd/makefiles/vm.make	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/make/bsd/makefiles/vm.make	Mon Feb 13 14:31:32 2012 +0000
@@ -82,18 +82,22 @@
 BUILD_USER    = -DHOTSPOT_BUILD_USER="\"$(HOTSPOT_BUILD_USER)\""
 VM_DISTRO     = -DHOTSPOT_VM_DISTRO="\"$(HOTSPOT_VM_DISTRO)\""
 
-CPPFLAGS =           \
+CXXFLAGS =           \
   ${SYSDEFS}         \
   ${INCLUDES}        \
   ${BUILD_VERSION}   \
   ${BUILD_TARGET}    \
   ${BUILD_USER}      \
   ${HS_LIB_ARCH}     \
-  ${JRE_VERSION}     \
   ${VM_DISTRO}
 
+# This is VERY important! The version define must only be supplied to vm_version.o
+# If not, ccache will not re-use the cache at all, since the version string might contain
+# a time and date. 
+vm_version.o: CXXFLAGS += ${JRE_VERSION} 
+
 ifdef DEFAULT_LIBPATH
-CPPFLAGS += -DDEFAULT_LIBPATH="\"$(DEFAULT_LIBPATH)\""
+CXXFLAGS += -DDEFAULT_LIBPATH="\"$(DEFAULT_LIBPATH)\""
 endif
 
 ifndef JAVASE_EMBEDDED
@@ -260,9 +264,9 @@
   ifeq ($(STATIC_CXX), true)
     LFLAGS_VM              += $(STATIC_LIBGCC)
     LIBS_VM                += $(STATIC_STDCXX)
-    LINK_VM                = $(LINK_LIB.c)
+    LINK_VM                = $(LINK_LIB.CC)
   else
-    LINK_VM                = $(LINK_LIB.CC)
+    LINK_VM                = $(LINK_LIB.CXX)
   endif
 
   LIBS_VM                  += $(LIBS)
@@ -280,7 +284,7 @@
 $(PRECOMPILED_HEADER):
 	$(QUIETLY) echo Generating precompiled header $@
 	$(QUIETLY) mkdir -p $(PRECOMPILED_HEADER_DIR)
-	$(QUIETLY) $(COMPILE.CC) $(DEPFLAGS) -x c++-header $(PRECOMPILED_HEADER_SRC) -o $@ $(COMPILE_DONE)
+	$(QUIETLY) $(COMPILE.CXX) $(DEPFLAGS) -x c++-header $(PRECOMPILED_HEADER_SRC) -o $@ $(COMPILE_DONE)
 
 # making the library:
 
@@ -305,10 +309,10 @@
 $(LIBJVM): $(LIBJVM.o) $(LIBJVM_MAPFILE) $(LD_SCRIPT)
 	$(QUIETLY) {                                                    \
 	    echo Linking vm...;                                         \
-	    $(LINK_LIB.CC/PRE_HOOK)                                     \
+	    $(LINK_LIB.CXX/PRE_HOOK)                                     \
 	    $(LINK_VM) $(LD_SCRIPT_FLAG)                                \
 		       $(LFLAGS_VM) -o $@ $(LIBJVM.o) $(LIBS_VM);       \
-	    $(LINK_LIB.CC/POST_HOOK)                                    \
+	    $(LINK_LIB.CXX/POST_HOOK)                                    \
 	    rm -f $@.1; ln -s $@ $@.1;                                  \
 	    [ -f $(LIBJVM_G) ] || { ln -s $@ $(LIBJVM_G); ln -s $@.1 $(LIBJVM_G).1; }; \
 	}
--- a/hotspot/make/defs.make	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/make/defs.make	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -185,6 +185,15 @@
   BOOTDIR=$(ALT_BOOTDIR)
 endif
 
+# Select name of the export directory and honor ALT overrides
+EXPORT_PATH=$(OUTPUTDIR)/export-$(PLATFORM)$(EXPORT_SUBDIR)
+ifneq ($(ALT_EXPORT_PATH),)
+  EXPORT_PATH=$(ALT_EXPORT_PATH)
+endif
+
+# Default jdk image if one is created for you with create_jdk
+JDK_IMAGE_DIR=$(OUTPUTDIR)/jdk-$(PLATFORM)
+
 # The platform dependent defs.make defines platform specific variable such 
 # as ARCH, EXPORT_LIST etc. We must place the include here after BOOTDIR is defined.
 include $(GAMMADIR)/make/$(OSNAME)/makefiles/defs.make
@@ -263,15 +272,6 @@
 # includes this make/defs.make file.
 MAKE_ARGS += HOTSPOT_BUILD_VERSION=$(HOTSPOT_BUILD_VERSION)
 
-# Select name of export directory
-EXPORT_PATH=$(OUTPUTDIR)/export-$(PLATFORM)$(EXPORT_SUBDIR)
-ifneq ($(ALT_EXPORT_PATH),)
-  EXPORT_PATH=$(ALT_EXPORT_PATH)
-endif
-
-# Default jdk image if one is created for you with create_jdk
-JDK_IMAGE_DIR=$(OUTPUTDIR)/jdk-$(PLATFORM)
-
 # Various export sub directories
 EXPORT_INCLUDE_DIR = $(EXPORT_PATH)/include
 EXPORT_DOCS_DIR = $(EXPORT_PATH)/docs
--- a/hotspot/make/hotspot_version	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/make/hotspot_version	Mon Feb 13 14:31:32 2012 +0000
@@ -35,7 +35,7 @@
 
 HS_MAJOR_VER=23
 HS_MINOR_VER=0
-HS_BUILD_NUMBER=12
+HS_BUILD_NUMBER=15
 
 JDK_MAJOR_VER=1
 JDK_MINOR_VER=8
--- a/hotspot/make/jprt.properties	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/make/jprt.properties	Mon Feb 13 14:31:32 2012 +0000
@@ -438,12 +438,12 @@
     ${jprt.my.macosx.x64}-{product|fastdebug}-c2-GCOld_ParNewGC, \
     ${jprt.my.macosx.x64}-{product|fastdebug}-c2-GCOld_CMS, \
     ${jprt.my.macosx.x64}-{product|fastdebug}-c2-GCOld_G1, \
-    ${jprt.my.macosx.x64}-{product|fastdebug}-c2-GCOld_ParOldGC \
-    ${jprt.my.macosx.x64}-{product|fastdebug}-c2-jbb_default, \
-    ${jprt.my.macosx.x64}-{product|fastdebug}-c2-jbb_default_tiered, \
-    ${jprt.my.macosx.x64}-{product|fastdebug}-c2-jbb_ParallelGC, \
-    ${jprt.my.macosx.x64}-{product|fastdebug}-c2-jbb_G1, \
-    ${jprt.my.macosx.x64}-{product|fastdebug}-c2-jbb_ParOldGC
+    ${jprt.my.macosx.x64}-{product|fastdebug}-c2-GCOld_ParOldGC
+#    ${jprt.my.macosx.x64}-{product|fastdebug}-c2-jbb_default, \
+#    ${jprt.my.macosx.x64}-{product|fastdebug}-c2-jbb_default_tiered, \
+#    ${jprt.my.macosx.x64}-{product|fastdebug}-c2-jbb_ParallelGC, \
+#    ${jprt.my.macosx.x64}-{product|fastdebug}-c2-jbb_G1, \
+#    ${jprt.my.macosx.x64}-{product|fastdebug}-c2-jbb_ParOldGC
 
 jprt.my.windows.i586.test.targets = \
     ${jprt.my.windows.i586}-{product|fastdebug}-{c1|c2}-jvm98, \
--- a/hotspot/make/linux/makefiles/adlc.make	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/make/linux/makefiles/adlc.make	Mon Feb 13 14:31:32 2012 +0000
@@ -61,10 +61,10 @@
 INCLUDES += $(Src_Dirs_I:%=-I%)
 
 # set flags for adlc compilation
-CPPFLAGS = $(SYSDEFS) $(INCLUDES)
+CXXFLAGS = $(SYSDEFS) $(INCLUDES)
 
 # Force assertions on.
-CPPFLAGS += -DASSERT
+CXXFLAGS += -DASSERT
 
 # CFLAGS_WARN holds compiler options to suppress/enable warnings.
 # Compiler warnings are treated as errors
@@ -109,7 +109,7 @@
 
 $(EXEC) : $(OBJECTS)
 	@echo Making adlc
-	$(QUIETLY) $(HOST.LINK_NOPROF.CC) -o $(EXEC) $(OBJECTS)
+	$(QUIETLY) $(HOST.LINK_NOPROF.CXX) -o $(EXEC) $(OBJECTS)
 
 # Random dependencies:
 $(OBJECTS): opcodes.hpp classes.hpp adlc.hpp adlcVMDeps.hpp adlparse.hpp archDesc.hpp arena.hpp dict2.hpp filebuff.hpp forms.hpp formsopt.hpp formssel.hpp
@@ -211,14 +211,14 @@
 $(OUTDIR)/%.o: %.cpp
 	@echo Compiling $<
 	$(QUIETLY) $(REMOVE_TARGET)
-	$(QUIETLY) $(HOST.COMPILE.CC) -o $@ $< $(COMPILE_DONE)
+	$(QUIETLY) $(HOST.COMPILE.CXX) -o $@ $< $(COMPILE_DONE)
 
 # Some object files are given a prefix, to disambiguate
 # them from objects of the same name built for the VM.
 $(OUTDIR)/adlc-%.o: %.cpp
 	@echo Compiling $<
 	$(QUIETLY) $(REMOVE_TARGET)
-	$(QUIETLY) $(HOST.COMPILE.CC) -o $@ $< $(COMPILE_DONE)
+	$(QUIETLY) $(HOST.COMPILE.CXX) -o $@ $< $(COMPILE_DONE)
 
 # #########################################################################
 
--- a/hotspot/make/linux/makefiles/gcc.make	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/make/linux/makefiles/gcc.make	Mon Feb 13 14:31:32 2012 +0000
@@ -23,19 +23,19 @@
 #
 
 #------------------------------------------------------------------------
-# CC, CPP & AS
+# CC, CXX & AS
 
 # When cross-compiling the ALT_COMPILER_PATH points
 # to the cross-compilation toolset
 ifdef CROSS_COMPILE_ARCH
-CPP = $(ALT_COMPILER_PATH)/g++
+CXX = $(ALT_COMPILER_PATH)/g++
 CC  = $(ALT_COMPILER_PATH)/gcc
-HOSTCPP = g++
+HOSTCXX = g++
 HOSTCC  = gcc
 else
-CPP = g++
+CXX = g++
 CC  = gcc
-HOSTCPP = $(CPP)
+HOSTCXX = $(CXX)
 HOSTCC  = $(CC)
 endif
 
--- a/hotspot/make/linux/makefiles/launcher.make	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/make/linux/makefiles/launcher.make	Mon Feb 13 14:31:32 2012 +0000
@@ -54,10 +54,10 @@
   LIBS_LAUNCHER             += -l$(JVM) $(LIBS)
 endif
 
-LINK_LAUNCHER = $(LINK.c)
+LINK_LAUNCHER = $(LINK.CC)
 
-LINK_LAUNCHER/PRE_HOOK  = $(LINK_LIB.CC/PRE_HOOK)
-LINK_LAUNCHER/POST_HOOK = $(LINK_LIB.CC/POST_HOOK)
+LINK_LAUNCHER/PRE_HOOK  = $(LINK_LIB.CXX/PRE_HOOK)
+LINK_LAUNCHER/POST_HOOK = $(LINK_LIB.CXX/POST_HOOK)
 
 LAUNCHER_OUT = launcher
 
@@ -73,11 +73,11 @@
 
 $(LAUNCHER_OUT)/%.o: $(LAUNCHERDIR_SHARE)/%.c
 	$(QUIETLY) [ -d $(LAUNCHER_OUT) ] || { mkdir -p $(LAUNCHER_OUT); }
-	$(QUIETLY) $(CC) -g -o $@ -c $< -MMD $(LAUNCHERFLAGS) $(CPPFLAGS)
+	$(QUIETLY) $(CC) -g -o $@ -c $< -MMD $(LAUNCHERFLAGS) $(CXXFLAGS)
 
 $(LAUNCHER_OUT)/%.o: $(LAUNCHERDIR)/%.c
 	$(QUIETLY) [ -d $(LAUNCHER_OUT) ] || { mkdir -p $(LAUNCHER_OUT); }
-	$(QUIETLY) $(CC) -g -o $@ -c $< -MMD $(LAUNCHERFLAGS) $(CPPFLAGS)
+	$(QUIETLY) $(CC) -g -o $@ -c $< -MMD $(LAUNCHERFLAGS) $(CXXFLAGS)
 
 $(LAUNCHER): $(OBJS) $(LIBJVM) $(LAUNCHER_MAPFILE)
 	$(QUIETLY) echo Linking launcher...
--- a/hotspot/make/linux/makefiles/product.make	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/make/linux/makefiles/product.make	Mon Feb 13 14:31:32 2012 +0000
@@ -52,4 +52,4 @@
 
 # If we can create .debuginfo files, then the VM is stripped in vm.make
 # and this macro is not used.
-# LINK_LIB.CC/POST_HOOK += $(STRIP_$(LINK_INTO))
+# LINK_LIB.CXX/POST_HOOK += $(STRIP_$(LINK_INTO))
--- a/hotspot/make/linux/makefiles/rules.make	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/make/linux/makefiles/rules.make	Mon Feb 13 14:31:32 2012 +0000
@@ -27,52 +27,39 @@
 # Tell make that .cpp is important
 .SUFFIXES: .cpp $(SUFFIXES)
 
-# For now.  Other makefiles use CPP as the c++ compiler, but that should really
-# name the preprocessor.
-ifeq    ($(CCC),)
-CCC             = $(CPP)
-endif
-
 DEMANGLER       = c++filt
 DEMANGLE        = $(DEMANGLER) < $@ > .$@ && mv -f .$@ $@
 
-# $(CC) is the c compiler (cc/gcc), $(CCC) is the c++ compiler (CC/g++).
-C_COMPILE       = $(CC) $(CPPFLAGS) $(CFLAGS)
-CC_COMPILE      = $(CCC) $(CPPFLAGS) $(CFLAGS)
+# $(CC) is the c compiler (cc/gcc), $(CXX) is the c++ compiler (CC/g++).
+CC_COMPILE       = $(CC) $(CXXFLAGS) $(CFLAGS)
+CXX_COMPILE      = $(CXX) $(CXXFLAGS) $(CFLAGS)
 
 AS.S            = $(AS) $(ASFLAGS)
 
-COMPILE.c       = $(C_COMPILE) -c
-GENASM.c        = $(C_COMPILE) -S
-LINK.c          = $(CC) $(LFLAGS) $(AOUT_FLAGS) $(PROF_AOUT_FLAGS)
-LINK_LIB.c      = $(CC) $(LFLAGS) $(SHARED_FLAG)
-PREPROCESS.c    = $(C_COMPILE) -E
+COMPILE.CC       = $(CC_COMPILE) -c
+GENASM.CC        = $(CC_COMPILE) -S
+LINK.CC          = $(CC) $(LFLAGS) $(AOUT_FLAGS) $(PROF_AOUT_FLAGS)
+LINK_LIB.CC      = $(CC) $(LFLAGS) $(SHARED_FLAG)
+PREPROCESS.CC    = $(CC_COMPILE) -E
 
-COMPILE.CC      = $(CC_COMPILE) -c
-GENASM.CC       = $(CC_COMPILE) -S
-LINK.CC         = $(CCC) $(LFLAGS) $(AOUT_FLAGS) $(PROF_AOUT_FLAGS)
-LINK_NOPROF.CC  = $(CCC) $(LFLAGS) $(AOUT_FLAGS)
-LINK_LIB.CC     = $(CCC) $(LFLAGS) $(SHARED_FLAG)
-PREPROCESS.CC   = $(CC_COMPILE) -E
+COMPILE.CXX      = $(CXX_COMPILE) -c
+GENASM.CXX       = $(CXX_COMPILE) -S
+LINK.CXX         = $(CXX) $(LFLAGS) $(AOUT_FLAGS) $(PROF_AOUT_FLAGS)
+LINK_NOPROF.CXX  = $(CXX) $(LFLAGS) $(AOUT_FLAGS)
+LINK_LIB.CXX     = $(CXX) $(LFLAGS) $(SHARED_FLAG)
+PREPROCESS.CXX   = $(CXX_COMPILE) -E
 
 # cross compiling the jvm with c2 requires host compilers to build
 # adlc tool
 
-HOST.CC_COMPILE      = $(HOSTCPP) $(CPPFLAGS) $(CFLAGS)
-HOST.COMPILE.CC      = $(HOST.CC_COMPILE) -c
-HOST.LINK_NOPROF.CC  = $(HOSTCPP) $(LFLAGS) $(AOUT_FLAGS)
+HOST.CXX_COMPILE      = $(HOSTCXX) $(CXXFLAGS) $(CFLAGS)
+HOST.COMPILE.CXX      = $(HOST.CXX_COMPILE) -c
+HOST.LINK_NOPROF.CXX  = $(HOSTCXX) $(LFLAGS) $(AOUT_FLAGS)
 
 
 # Effect of REMOVE_TARGET is to delete out-of-date files during "gnumake -k".
 REMOVE_TARGET   = rm -f $@
 
-# Synonyms.
-COMPILE.cpp     = $(COMPILE.CC)
-GENASM.cpp      = $(GENASM.CC)
-LINK.cpp        = $(LINK.CC)
-LINK_LIB.cpp    = $(LINK_LIB.CC)
-PREPROCESS.cpp  = $(PREPROCESS.CC)
-
 # Note use of ALT_BOOTDIR to explicitly specify location of java and
 # javac; this is the same environment variable used in the J2SE build
 # process for overriding the default spec, which is BOOTDIR.
@@ -161,14 +148,14 @@
 %.o: %.cpp
 	@echo Compiling $<
 	$(QUIETLY) $(REMOVE_TARGET)
-	$(QUIETLY) $(COMPILE.CC) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE)
+	$(QUIETLY) $(COMPILE.CXX) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE)
 else
 %.o: %.cpp
 	@echo Compiling $<
 	$(QUIETLY) $(REMOVE_TARGET)
 	$(QUIETLY) $(if $(findstring $@, $(NONPIC_OBJ_FILES)), \
-	   $(subst $(VM_PICFLAG), ,$(COMPILE.CC)) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE), \
-	   $(COMPILE.CC) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE))
+	   $(subst $(VM_PICFLAG), ,$(COMPILE.CXX)) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE), \
+	   $(COMPILE.CXX) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE))
 endif
 
 %.o: %.s
@@ -178,13 +165,13 @@
 
 %.s: %.cpp
 	@echo Generating assembly for $<
-	$(QUIETLY) $(GENASM.CC) -o $@ $<
+	$(QUIETLY) $(GENASM.CXX) -o $@ $<
 	$(QUIETLY) $(DEMANGLE) $(COMPILE_DONE)
 
 # Intermediate files (for debugging macros)
 %.i: %.cpp
 	@echo Preprocessing $< to $@
-	$(QUIETLY) $(PREPROCESS.CC) $< > $@ $(COMPILE_DONE)
+	$(QUIETLY) $(PREPROCESS.CXX) $< > $@ $(COMPILE_DONE)
 
 #  Override gnumake built-in rules which do sccs get operations badly.
 #  (They put the checked out code in the current directory, not in the
--- a/hotspot/make/linux/makefiles/sparcWorks.make	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/make/linux/makefiles/sparcWorks.make	Mon Feb 13 14:31:32 2012 +0000
@@ -23,13 +23,13 @@
 #
 
 #------------------------------------------------------------------------
-# CC, CPP & AS
+# CC, CXX & AS
 
-CPP = CC
+CXX = CC
 CC  = cc
 AS  = $(CC) -c
 
-HOSTCPP = $(CPP)
+HOSTCXX = $(CXX)
 HOSTCC  = $(CC)
 
 ARCHFLAG = $(ARCHFLAG/$(BUILDARCH))
--- a/hotspot/make/linux/makefiles/vm.make	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/make/linux/makefiles/vm.make	Mon Feb 13 14:31:32 2012 +0000
@@ -88,16 +88,20 @@
 BUILD_USER    = -DHOTSPOT_BUILD_USER="\"$(HOTSPOT_BUILD_USER)\""
 VM_DISTRO     = -DHOTSPOT_VM_DISTRO="\"$(HOTSPOT_VM_DISTRO)\""
 
-CPPFLAGS =           \
+CXXFLAGS =           \
   ${SYSDEFS}         \
   ${INCLUDES}        \
   ${BUILD_VERSION}   \
   ${BUILD_TARGET}    \
   ${BUILD_USER}      \
   ${HS_LIB_ARCH}     \
-  ${JRE_VERSION}     \
   ${VM_DISTRO}
 
+# This is VERY important! The version define must only be supplied to vm_version.o
+# If not, ccache will not re-use the cache at all, since the version string might contain
+# a time and date. 
+vm_version.o: CXXFLAGS += ${JRE_VERSION}
+
 ifndef JAVASE_EMBEDDED
 CFLAGS += -DINCLUDE_TRACE
 endif
@@ -272,13 +276,13 @@
   LIBS_VM   += $(LLVM_LIBS)
 endif
 
-LINK_VM = $(LINK_LIB.c)
+LINK_VM = $(LINK_LIB.CC)
 
 # rule for building precompiled header
 $(PRECOMPILED_HEADER):
 	$(QUIETLY) echo Generating precompiled header $@
 	$(QUIETLY) mkdir -p $(PRECOMPILED_HEADER_DIR)
-	$(QUIETLY) $(COMPILE.CC) $(DEPFLAGS) -x c++-header $(PRECOMPILED_HEADER_SRC) -o $@ $(COMPILE_DONE)
+	$(QUIETLY) $(COMPILE.CXX) $(DEPFLAGS) -x c++-header $(PRECOMPILED_HEADER_SRC) -o $@ $(COMPILE_DONE)
 
 # making the library:
 
@@ -308,10 +312,10 @@
 $(LIBJVM): $(LIBJVM.o) $(LIBJVM_MAPFILE) $(LD_SCRIPT)
 	$(QUIETLY) {                                                    \
 	    echo Linking vm...;                                         \
-	    $(LINK_LIB.CC/PRE_HOOK)                                     \
+	    $(LINK_LIB.CXX/PRE_HOOK)                                     \
 	    $(LINK_VM) $(LD_SCRIPT_FLAG)                                \
 		       $(LFLAGS_VM) -o $@ $(LIBJVM.o) $(LIBS_VM);       \
-	    $(LINK_LIB.CC/POST_HOOK)                                    \
+	    $(LINK_LIB.CXX/POST_HOOK)                                    \
 	    rm -f $@.1; ln -s $@ $@.1;                                  \
 	    [ -f $(LIBJVM_G) ] || { ln -s $@ $(LIBJVM_G); ln -s $@.1 $(LIBJVM_G).1; }; \
             if [ \"$(CROSS_COMPILE_ARCH)\" = \"\" ] ; then                    \
--- a/hotspot/make/solaris/makefiles/adlc.make	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/make/solaris/makefiles/adlc.make	Mon Feb 13 14:31:32 2012 +0000
@@ -62,10 +62,10 @@
 INCLUDES += $(Src_Dirs_I:%=-I%)
 
 # set flags for adlc compilation
-CPPFLAGS = $(SYSDEFS) $(INCLUDES)
+CXXFLAGS = $(SYSDEFS) $(INCLUDES)
 
 # Force assertions on.
-CPPFLAGS += -DASSERT
+CXXFLAGS += -DASSERT
 
 ifndef USE_GCC
   # We need libCstd.so for adlc 
@@ -130,7 +130,7 @@
 
 $(EXEC) : $(OBJECTS)
 	@echo Making adlc
-	$(QUIETLY) $(LINK_NOPROF.CC) -o $(EXEC) $(OBJECTS)
+	$(QUIETLY) $(LINK_NOPROF.CXX) -o $(EXEC) $(OBJECTS)
 
 # Random dependencies:
 $(OBJECTS): opcodes.hpp classes.hpp adlc.hpp adlcVMDeps.hpp adlparse.hpp archDesc.hpp arena.hpp dict2.hpp filebuff.hpp forms.hpp formsopt.hpp formssel.hpp
@@ -228,14 +228,14 @@
 $(OUTDIR)/%.o: %.cpp
 	@echo Compiling $<
 	$(QUIETLY) $(REMOVE_TARGET)
-	$(QUIETLY) $(COMPILE.CC) -o $@ $< $(COMPILE_DONE)
+	$(QUIETLY) $(COMPILE.CXX) -o $@ $< $(COMPILE_DONE)
 
 # Some object files are given a prefix, to disambiguate
 # them from objects of the same name built for the VM.
 $(OUTDIR)/adlc-%.o: %.cpp
 	@echo Compiling $<
 	$(QUIETLY) $(REMOVE_TARGET)
-	$(QUIETLY) $(COMPILE.CC) -o $@ $< $(COMPILE_DONE)
+	$(QUIETLY) $(COMPILE.CXX) -o $@ $< $(COMPILE_DONE)
 
 # #########################################################################
 
--- a/hotspot/make/solaris/makefiles/dtrace.make	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/make/solaris/makefiles/dtrace.make	Mon Feb 13 14:31:32 2012 +0000
@@ -150,11 +150,11 @@
 
 lib$(GENOFFS).so: $(DTRACE_SRCDIR)/$(GENOFFS).cpp $(DTRACE_SRCDIR)/$(GENOFFS).h \
                   $(LIBJVM.o)
-	$(QUIETLY) $(CCC) $(CPPFLAGS) $(GENOFFS_CFLAGS) $(SHARED_FLAG) $(PICFLAG) \
+	$(QUIETLY) $(CXX) $(CXXFLAGS) $(GENOFFS_CFLAGS) $(SHARED_FLAG) $(PICFLAG) \
 		 $(LFLAGS_GENOFFS) -o $@ $(DTRACE_SRCDIR)/$(GENOFFS).cpp -lc
 
 $(GENOFFS): $(DTRACE_SRCDIR)/$(GENOFFS)Main.c lib$(GENOFFS).so
-	$(QUIETLY) $(LINK.CC) -z nodefs -o $@ $(DTRACE_SRCDIR)/$(GENOFFS)Main.c \
+	$(QUIETLY) $(LINK.CXX) -z nodefs -o $@ $(DTRACE_SRCDIR)/$(GENOFFS)Main.c \
 		./lib$(GENOFFS).so
 
 CONDITIONALLY_UPDATE_JVMOFFS_TARGET = \
@@ -178,7 +178,7 @@
 	$(QUIETLY) $(CONDITIONALLY_UPDATE_JVMOFFS_TARGET)
 
 $(JVMOFFS.o): $(JVMOFFS).h $(JVMOFFS).cpp 
-	$(QUIETLY) $(CCC) -c -I. -o $@ $(ARCHFLAG) -D$(TYPE) $(JVMOFFS).cpp
+	$(QUIETLY) $(CXX) -c -I. -o $@ $(ARCHFLAG) -D$(TYPE) $(JVMOFFS).cpp
 
 $(LIBJVM_DB): $(DTRACE_SRCDIR)/$(JVM_DB).c $(JVMOFFS.o) $(XLIBJVM_DB) $(LIBJVM_DB_MAPFILE)
 	@echo Making $@
--- a/hotspot/make/solaris/makefiles/gcc.make	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/make/solaris/makefiles/gcc.make	Mon Feb 13 14:31:32 2012 +0000
@@ -23,9 +23,9 @@
 #
 
 #------------------------------------------------------------------------
-# CC, CPP & AS
+# CC, CXX & AS
 
-CPP = g++
+CXX = g++
 CC  = gcc
 AS  = $(CC) -c
 
@@ -36,12 +36,12 @@
 CC_VER_MAJOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f1)
 CC_VER_MINOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f2)
 
-# Check for the versions of C++ and C compilers ($CPP and $CC) used. 
+# Check for the versions of C++ and C compilers ($CXX and $CC) used. 
 
 # Get the last thing on the line that looks like x.x+ (x is a digit).
 COMPILER_REV := \
-$(shell $(CPP) -dumpversion | sed 's/egcs-//' | cut -d'.' -f1)
-C_COMPILER_REV := \
+$(shell $(CXX) -dumpversion | sed 's/egcs-//' | cut -d'.' -f1)
+CC_COMPILER_REV := \
 $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f2)
 
 
--- a/hotspot/make/solaris/makefiles/launcher.make	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/make/solaris/makefiles/launcher.make	Mon Feb 13 14:31:32 2012 +0000
@@ -52,10 +52,10 @@
   LIBS_LAUNCHER             += -l$(JVM) $(LIBS)
 endif
 
-LINK_LAUNCHER = $(LINK.CC)
+LINK_LAUNCHER = $(LINK.CXX)
 
-LINK_LAUNCHER/PRE_HOOK  = $(LINK_LIB.CC/PRE_HOOK)
-LINK_LAUNCHER/POST_HOOK = $(LINK_LIB.CC/POST_HOOK)
+LINK_LAUNCHER/PRE_HOOK  = $(LINK_LIB.CXX/PRE_HOOK)
+LINK_LAUNCHER/POST_HOOK = $(LINK_LIB.CXX/POST_HOOK)
 
 ifeq ("${Platform_compiler}", "sparcWorks")
 # Enable the following LAUNCHERFLAGS addition if you need to compare the
@@ -86,11 +86,11 @@
 
 $(LAUNCHER_OUT)/%.o: $(LAUNCHERDIR_SHARE)/%.c
 	$(QUIETLY) [ -d $(LAUNCHER_OUT) ] || { mkdir -p $(LAUNCHER_OUT); }
-	$(QUIETLY) $(CC) -g -o $@ -c $< -MMD $(LAUNCHERFLAGS) $(CPPFLAGS)
+	$(QUIETLY) $(CC) -g -o $@ -c $< -MMD $(LAUNCHERFLAGS) $(CXXFLAGS)
 
 $(LAUNCHER_OUT)/%.o: $(LAUNCHERDIR)/%.c
 	$(QUIETLY) [ -d $(LAUNCHER_OUT) ] || { mkdir -p $(LAUNCHER_OUT); }
-	$(QUIETLY) $(CC) -g -o $@ -c $< -MMD $(LAUNCHERFLAGS) $(CPPFLAGS)
+	$(QUIETLY) $(CC) -g -o $@ -c $< -MMD $(LAUNCHERFLAGS) $(CXXFLAGS)
 
 $(LAUNCHER): $(OBJS) $(LIBJVM) $(LAUNCHER_MAPFILE)
 ifeq ($(filter -sbfast -xsbfast, $(CFLAGS_BROWSE)),)
--- a/hotspot/make/solaris/makefiles/product.make	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/make/solaris/makefiles/product.make	Mon Feb 13 14:31:32 2012 +0000
@@ -70,7 +70,7 @@
 
 # If we can create .debuginfo files, then the VM is stripped in vm.make
 # and this macro is not used.
-# LINK_LIB.CC/POST_HOOK += $(STRIP_LIB.CC/POST_HOOK)
+# LINK_LIB.CXX/POST_HOOK += $(STRIP_LIB.CXX/POST_HOOK)
 
 G_SUFFIX =
 SYSDEFS += -DPRODUCT
--- a/hotspot/make/solaris/makefiles/rules.make	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/make/solaris/makefiles/rules.make	Mon Feb 13 14:31:32 2012 +0000
@@ -27,44 +27,31 @@
 # Tell make that .cpp is important
 .SUFFIXES: .cpp $(SUFFIXES)
 
-# For now.  Other makefiles use CPP as the c++ compiler, but that should really
-# name the preprocessor.
-ifeq    ($(CCC),)
-CCC             = $(CPP)
-endif
-
 DEMANGLER       = c++filt
 DEMANGLE        = $(DEMANGLER) < $@ > .$@ && mv -f .$@ $@
 
-# $(CC) is the c compiler (cc/gcc), $(CCC) is the c++ compiler (CC/g++).
-C_COMPILE       = $(CC) $(CPPFLAGS) $(CFLAGS)
-CC_COMPILE      = $(CCC) $(CPPFLAGS) $(CFLAGS)
+# $(CC) is the c compiler (cc/gcc), $(CXX) is the c++ compiler (CC/g++).
+CC_COMPILE       = $(CC) $(CXXFLAGS) $(CFLAGS)
+CXX_COMPILE      = $(CXX) $(CXXFLAGS) $(CFLAGS)
 
 AS.S            = $(AS) $(ASFLAGS)
 
-COMPILE.c       = $(C_COMPILE) -c
-GENASM.c        = $(C_COMPILE) -S
-LINK.c          = $(CC) $(LFLAGS) $(AOUT_FLAGS) $(PROF_AOUT_FLAGS)
-LINK_LIB.c      = $(CC) $(LFLAGS) $(SHARED_FLAG)
-PREPROCESS.c    = $(C_COMPILE) -E
+COMPILE.CC       = $(CC_COMPILE) -c
+GENASM.CC        = $(CC_COMPILE) -S
+LINK.CC          = $(CC) $(LFLAGS) $(AOUT_FLAGS) $(PROF_AOUT_FLAGS)
+LINK_LIB.CC      = $(CC) $(LFLAGS) $(SHARED_FLAG)
+PREPROCESS.CC    = $(CC_COMPILE) -E
 
-COMPILE.CC      = $(CC_COMPILE) -c
-GENASM.CC       = $(CC_COMPILE) -S
-LINK.CC         = $(CCC) $(LFLAGS) $(AOUT_FLAGS) $(PROF_AOUT_FLAGS)
-LINK_NOPROF.CC  = $(CCC) $(LFLAGS) $(AOUT_FLAGS)
-LINK_LIB.CC     = $(CCC) $(LFLAGS) $(SHARED_FLAG)
-PREPROCESS.CC   = $(CC_COMPILE) -E
+COMPILE.CXX      = $(CXX_COMPILE) -c
+GENASM.CXX       = $(CXX_COMPILE) -S
+LINK.CXX         = $(CXX) $(LFLAGS) $(AOUT_FLAGS) $(PROF_AOUT_FLAGS)
+LINK_NOPROF.CXX  = $(CXX) $(LFLAGS) $(AOUT_FLAGS)
+LINK_LIB.CXX     = $(CXX) $(LFLAGS) $(SHARED_FLAG)
+PREPROCESS.CXX   = $(CXX_COMPILE) -E
 
 # Effect of REMOVE_TARGET is to delete out-of-date files during "gnumake -k".
 REMOVE_TARGET   = rm -f $@
 
-# Synonyms.
-COMPILE.cpp     = $(COMPILE.CC)
-GENASM.cpp      = $(GENASM.CC)
-LINK.cpp        = $(LINK.CC)
-LINK_LIB.cpp    = $(LINK_LIB.CC)
-PREPROCESS.cpp  = $(PREPROCESS.CC)
-
 # Note use of ALT_BOOTDIR to explicitly specify location of java and
 # javac; this is the same environment variable used in the J2SE build
 # process for overriding the default spec, which is BOOTDIR.
@@ -153,14 +140,14 @@
 %.o: %.cpp
 	@echo Compiling $<
 	$(QUIETLY) $(REMOVE_TARGET)
-	$(QUIETLY) $(COMPILE.CC) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE)
+	$(QUIETLY) $(COMPILE.CXX) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE)
 else
 %.o: %.cpp
 	@echo Compiling $<
 	$(QUIETLY) $(REMOVE_TARGET)
 	$(QUIETLY) $(if $(findstring $@, $(NONPIC_OBJ_FILES)), \
-	   $(subst $(VM_PICFLAG), ,$(COMPILE.CC)) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE), \
-	   $(COMPILE.CC) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE))
+	   $(subst $(VM_PICFLAG), ,$(COMPILE.CXX)) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE), \
+	   $(COMPILE.CXX) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE))
 endif
 
 %.o: %.s
@@ -170,13 +157,13 @@
 
 %.s: %.cpp
 	@echo Generating assembly for $<
-	$(QUIETLY) $(GENASM.CC) -o $@ $<
+	$(QUIETLY) $(GENASM.CXX) -o $@ $<
 	$(QUIETLY) $(DEMANGLE) $(COMPILE_DONE)
 
 # Intermediate files (for debugging macros)
 %.i: %.cpp
 	@echo Preprocessing $< to $@
-	$(QUIETLY) $(PREPROCESS.CC) $< > $@ $(COMPILE_DONE)
+	$(QUIETLY) $(PREPROCESS.CXX) $< > $@ $(COMPILE_DONE)
 
 #  Override gnumake built-in rules which do sccs get operations badly.
 #  (They put the checked out code in the current directory, not in the
--- a/hotspot/make/solaris/makefiles/saproc.make	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/make/solaris/makefiles/saproc.make	Mon Feb 13 14:31:32 2012 +0000
@@ -93,7 +93,7 @@
 	  exit 1; \
 	fi
 	@echo Making SA debugger back-end...
-	$(QUIETLY) $(CPP)                                               \
+	$(QUIETLY) $(CXX)                                               \
                    $(SYMFLAG) $(ARCHFLAG) $(SHARED_FLAG) $(PICFLAG)     \
 	           -I$(SASRCDIR)                                        \
 	           -I$(GENERATED)                                       \
--- a/hotspot/make/solaris/makefiles/sparcWorks.make	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/make/solaris/makefiles/sparcWorks.make	Mon Feb 13 14:31:32 2012 +0000
@@ -26,7 +26,7 @@
 
 # tell make which C and C++ compilers to use
 CC	= cc
-CPP	= CC
+CXX	= CC
 
 # Note that this 'as' is an older version of the Sun Studio 'fbe', and will
 #   use the older style options. The 'fbe' options will match 'cc' and 'CC'.
@@ -37,23 +37,23 @@
 
 REORDER_FLAG = -xF
 
-# Check for the versions of C++ and C compilers ($CPP and $CC) used. 
+# Check for the versions of C++ and C compilers ($CXX and $CC) used. 
 
 # Get the last thing on the line that looks like x.x+ (x is a digit).
 COMPILER_REV := \
-$(shell $(CPP) -V 2>&1 | sed -n 's/^.*[ ,\t]C++[ ,\t]\([1-9]\.[0-9][0-9]*\).*/\1/p')
-C_COMPILER_REV := \
+$(shell $(CXX) -V 2>&1 | sed -n 's/^.*[ ,\t]C++[ ,\t]\([1-9]\.[0-9][0-9]*\).*/\1/p')
+CC_COMPILER_REV := \
 $(shell $(CC) -V 2>&1 | sed -n 's/^.*[ ,\t]C[ ,\t]\([1-9]\.[0-9][0-9]*\).*/\1/p')
 
 # Pick which compiler is validated
 ifeq ($(JRE_RELEASE_VER),1.6.0)
   # Validated compiler for JDK6 is SS11 (5.8)
   VALIDATED_COMPILER_REVS   := 5.8
-  VALIDATED_C_COMPILER_REVS := 5.8
+  VALIDATED_CC_COMPILER_REVS := 5.8
 else
   # Validated compiler for JDK7 is SS12 update 1 + patches (5.10)
   VALIDATED_COMPILER_REVS   := 5.10
-  VALIDATED_C_COMPILER_REVS := 5.10
+  VALIDATED_CC_COMPILER_REVS := 5.10
 endif
 
 # Warning messages about not using the above validated versions
@@ -67,13 +67,13 @@
 	warning.)
 endif
 
-ENFORCE_C_COMPILER_REV${ENFORCE_C_COMPILER_REV} := $(strip ${VALIDATED_C_COMPILER_REVS})
-ifeq ($(filter ${ENFORCE_C_COMPILER_REV},${C_COMPILER_REV}),)
-PRINTABLE_C_REVS := $(subst $(shell echo ' '), or ,${ENFORCE_C_COMPILER_REV})
+ENFORCE_CC_COMPILER_REV${ENFORCE_CC_COMPILER_REV} := $(strip ${VALIDATED_CC_COMPILER_REVS})
+ifeq ($(filter ${ENFORCE_CC_COMPILER_REV},${CC_COMPILER_REV}),)
+PRINTABLE_C_REVS := $(subst $(shell echo ' '), or ,${ENFORCE_CC_COMPILER_REV})
 dummy_var_to_enforce_c_compiler_rev := $(shell \
-	echo >&2 WARNING: You are using cc version ${C_COMPILER_REV} and \
+	echo >&2 WARNING: You are using cc version ${CC_COMPILER_REV} and \
 	should be using version ${PRINTABLE_C_REVS}.; \
-	echo >&2 Set ENFORCE_C_COMPILER_REV=${C_COMPILER_REV} to avoid this \
+	echo >&2 Set ENFORCE_CC_COMPILER_REV=${CC_COMPILER_REV} to avoid this \
 	warning.)
 endif
 
@@ -98,7 +98,7 @@
                        } \
 	      END      { exit rc; }'
 
-LINK_LIB.CC/PRE_HOOK += $(JVM_CHECK_SYMBOLS) || exit 1;
+LINK_LIB.CXX/PRE_HOOK += $(JVM_CHECK_SYMBOLS) || exit 1;
 
 # New architecture options started in SS12 (5.9), we need both styles to build.
 #   The older arch options for SS11 (5.8) or older and also for /usr/ccs/bin/as.
@@ -518,7 +518,7 @@
 #FASTDEBUG_CFLAGS += -Qoption ccfe -xglobalstatic
 
 ifeq	(${COMPILER_REV_NUMERIC}, 502)
-COMPILER_DATE := $(shell $(CPP) -V 2>&1 | sed -n '/^.*[ ]C++[ ]\([1-9]\.[0-9][0-9]*\)/p' | awk '{ print $$NF; }')
+COMPILER_DATE := $(shell $(CXX) -V 2>&1 | sed -n '/^.*[ ]C++[ ]\([1-9]\.[0-9][0-9]*\)/p' | awk '{ print $$NF; }')
 ifeq	(${COMPILER_DATE}, 2001/01/31)
 # disable -g0 in fastdebug since SC6.1 dated 2001/01/31 seems to be buggy
 # use an innocuous value because it will get -g if it's empty
@@ -568,7 +568,7 @@
 # removing repeated lines.  The data can be extracted from
 # binaries in the field by using "mcs -p libjvm.so" or the older
 # command "what libjvm.so".
-LINK_LIB.CC/POST_HOOK += $(MCS) -c $@ || exit 1;
+LINK_LIB.CXX/POST_HOOK += $(MCS) -c $@ || exit 1;
 # (The exit 1 is necessary to cause a build failure if the command fails and
 # multiple commands are strung together, and the final semicolon is necessary
 # since the hook must terminate itself as a valid command.)
@@ -576,7 +576,7 @@
 # Also, strip debug and line number information (worth about 1.7Mb).
 # If we can create .debuginfo files, then the VM is stripped in vm.make
 # and this macro is not used.
-STRIP_LIB.CC/POST_HOOK = $(STRIP) -x $@ || exit 1;
-# STRIP_LIB.CC/POST_HOOK is incorporated into LINK_LIB.CC/POST_HOOK
+STRIP_LIB.CXX/POST_HOOK = $(STRIP) -x $@ || exit 1;
+# STRIP_LIB.CXX/POST_HOOK is incorporated into LINK_LIB.CXX/POST_HOOK
 # in certain configurations, such as product.make.  Other configurations,
 # such as debug.make, do not include the strip operation.
--- a/hotspot/make/solaris/makefiles/vm.make	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/make/solaris/makefiles/vm.make	Mon Feb 13 14:31:32 2012 +0000
@@ -76,16 +76,20 @@
 BUILD_USER    = -DHOTSPOT_BUILD_USER="\"$(HOTSPOT_BUILD_USER)\""
 VM_DISTRO     = -DHOTSPOT_VM_DISTRO="\"$(HOTSPOT_VM_DISTRO)\""
 
-CPPFLAGS =           \
+CXXFLAGS =           \
   ${SYSDEFS}         \
   ${INCLUDES}        \
   ${BUILD_VERSION}   \
   ${BUILD_TARGET}    \
   ${BUILD_USER}      \
   ${HS_LIB_ARCH}     \
-  ${JRE_VERSION}     \
   ${VM_DISTRO}
 
+# This is VERY important! The version define must only be supplied to vm_version.o
+# If not, ccache will not re-use the cache at all, since the version string might contain
+# a time and date. 
+vm_version.o: CXXFLAGS += ${JRE_VERSION} 
+
 # CFLAGS_WARN holds compiler options to suppress/enable warnings.
 CFLAGS += $(CFLAGS_WARN)
 
@@ -265,17 +269,17 @@
 endif
 
 ifdef USE_GCC
-LINK_VM = $(LINK_LIB.c)
+LINK_VM = $(LINK_LIB.CC)
 else
-LINK_VM = $(LINK_LIB.CC)
+LINK_VM = $(LINK_LIB.CXX)
 endif
 # making the library:
 $(LIBJVM): $(LIBJVM.o) $(LIBJVM_MAPFILE) 
 ifeq ($(filter -sbfast -xsbfast, $(CFLAGS_BROWSE)),)
 	@echo Linking vm...
-	$(QUIETLY) $(LINK_LIB.CC/PRE_HOOK)
+	$(QUIETLY) $(LINK_LIB.CXX/PRE_HOOK)
 	$(QUIETLY) $(LINK_VM) $(LFLAGS_VM) -o $@ $(LIBJVM.o) $(LIBS_VM)
-	$(QUIETLY) $(LINK_LIB.CC/POST_HOOK)
+	$(QUIETLY) $(LINK_LIB.CXX/POST_HOOK)
 	$(QUIETLY) rm -f $@.1 && ln -s $@ $@.1
 	$(QUIETLY) [ -f $(LIBJVM_G) ] || ln -s $@ $(LIBJVM_G)
 	$(QUIETLY) [ -f $(LIBJVM_G).1 ] || ln -s $@.1 $(LIBJVM_G).1
--- a/hotspot/make/windows/build_vm_def.sh	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/make/windows/build_vm_def.sh	Mon Feb 13 14:31:32 2012 +0000
@@ -57,10 +57,10 @@
 
 # When called from IDE the first param should contain the link version, otherwise may be nill
 if [ "x$1" != "x" ]; then
-LINK_VER="$1"
+LD_VER="$1"
 fi
 
-if [ "x$LINK_VER" != "x800" -a  "x$LINK_VER" != "x900" -a "x$LINK_VER" != "x1000" ]; then
+if [ "x$LD_VER" != "x800" -a  "x$LD_VER" != "x900" -a "x$LD_VER" != "x1000" ]; then
 $DUMPBIN /symbols *.obj | "$GREP" "??_7.*@@6B@" | "$GREP" -v "type_info" | "$AWK" '{print $7}' | "$SORT" | "$UNIQ" > vm2.def
 else
 # Can't use pipes when calling cl.exe or link.exe from IDE. Using transit file vm3.def
--- a/hotspot/make/windows/get_msc_ver.sh	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/make/windows/get_msc_ver.sh	Mon Feb 13 14:31:32 2012 +0000
@@ -72,8 +72,8 @@
   echo "MSC_VER_RAW=$MSC_VER_RAW"
 fi
 
-if [ "x$FORCE_LINK_VER" != "x" ]; then
-  echo "LINK_VER=$FORCE_LINK_VER"
+if [ "x$FORCE_LD_VER" != "x" ]; then
+  echo "LD_VER=$FORCE_LD_VER"
 else
   # use the "link" command that is co-located with the "cl" command
   cl_cmd=`which cl`
@@ -83,11 +83,11 @@
     # which can't find "cl" so just use which ever "link" we find
     link_cmd="link"
   fi
-  LINK_VER_RAW=`"$link_cmd" 2>&1 | "$HEAD" -n 1 | "$SED" 's/.*Version[\ ]*\([0-9][0-9.]*\).*/\1/'`
-  LINK_VER_MAJOR=`"$ECHO" $LINK_VER_RAW | "$CUT" -d'.' -f1`
-  LINK_VER_MINOR=`"$ECHO" $LINK_VER_RAW | "$CUT" -d'.' -f2`
-  LINK_VER_MICRO=`"$ECHO" $LINK_VER_RAW | "$CUT" -d'.' -f3`
-  LINK_VER=`"$EXPR" $LINK_VER_MAJOR \* 100 + $LINK_VER_MINOR`
-  echo "LINK_VER=$LINK_VER"
-  echo "LINK_VER_RAW=$LINK_VER_RAW"
+  LD_VER_RAW=`"$link_cmd" 2>&1 | "$HEAD" -n 1 | "$SED" 's/.*Version[\ ]*\([0-9][0-9.]*\).*/\1/'`
+  LD_VER_MAJOR=`"$ECHO" $LD_VER_RAW | "$CUT" -d'.' -f1`
+  LD_VER_MINOR=`"$ECHO" $LD_VER_RAW | "$CUT" -d'.' -f2`
+  LD_VER_MICRO=`"$ECHO" $LD_VER_RAW | "$CUT" -d'.' -f3`
+  LD_VER=`"$EXPR" $LD_VER_MAJOR \* 100 + $LD_VER_MINOR`
+  echo "LD_VER=$LD_VER"
+  echo "LD_VER_RAW=$LD_VER_RAW"
 fi
--- a/hotspot/make/windows/makefiles/adlc.make	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/make/windows/makefiles/adlc.make	Mon Feb 13 14:31:32 2012 +0000
@@ -45,9 +45,9 @@
 ADLCFLAGS=-q -T -U_LP64
 !endif
 
-ADLC_CPP_FLAGS=$(CPP_FLAGS) /D _CRT_SECURE_NO_WARNINGS /D _CRT_SECURE_NO_DEPRECATE
+ADLC_CXX_FLAGS=$(CXX_FLAGS) /D _CRT_SECURE_NO_WARNINGS /D _CRT_SECURE_NO_DEPRECATE
 
-CPP_INCLUDE_DIRS=\
+CXX_INCLUDE_DIRS=\
   /I "..\generated" \
   /I "$(WorkSpace)\src\share\vm" \
   /I "$(WorkSpace)\src\os\windows\vm" \
@@ -94,14 +94,14 @@
   $(AdlcOutDir)\dfa_$(Platform_arch_model).cpp
 
 {$(WorkSpace)\src\share\vm\adlc}.cpp.obj::
-        $(CPP) $(ADLC_CPP_FLAGS) $(EXH_FLAGS) $(CPP_INCLUDE_DIRS) /c $<
+        $(CXX) $(ADLC_CXX_FLAGS) $(EXH_FLAGS) $(CXX_INCLUDE_DIRS) /c $<
 
 {$(WorkSpace)\src\share\vm\opto}.cpp.obj::
-        $(CPP) $(ADLC_CPP_FLAGS) $(EXH_FLAGS) $(CPP_INCLUDE_DIRS) /c $<
+        $(CXX) $(ADLC_CXX_FLAGS) $(EXH_FLAGS) $(CXX_INCLUDE_DIRS) /c $<
 
 adlc.exe: main.obj adlparse.obj archDesc.obj arena.obj dfa.obj dict2.obj filebuff.obj \
           forms.obj formsopt.obj formssel.obj opcodes.obj output_c.obj output_h.obj
-	$(LINK) $(LINK_FLAGS) /subsystem:console /out:$@ $**
+	$(LD) $(LD_FLAGS) /subsystem:console /out:$@ $**
 !if "$(MT)" != ""
 # The previous link command created a .manifest file that we want to
 # insert into the linked artifact so we do not need to track it
--- a/hotspot/make/windows/makefiles/compile.make	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/make/windows/makefiles/compile.make	Mon Feb 13 14:31:32 2012 +0000
@@ -23,9 +23,9 @@
 #
 
 # Generic compiler settings
-CPP=cl.exe
+CXX=cl.exe
 
-# CPP Flags: (these vary slightly from VC6->VS2003->VS2005 compilers)
+# CXX Flags: (these vary slightly from VC6->VS2003->VS2005 compilers)
 #   /nologo   Supress copyright message at every cl.exe startup
 #   /W3       Warning level 3
 #   /Zi       Include debugging information
@@ -50,47 +50,47 @@
 # improving the quality of crash log stack traces involving jvm.dll.
 
 # These are always used in all compiles
-CPP_FLAGS=/nologo /W3 /WX
+CXX_FLAGS=/nologo /W3 /WX
 
 # Let's add debug information always too.
-CPP_FLAGS=$(CPP_FLAGS) /Zi
+CXX_FLAGS=$(CXX_FLAGS) /Zi
 
 # Based on BUILDARCH we add some flags and select the default compiler name
 !if "$(BUILDARCH)" == "ia64"
 MACHINE=IA64
 DEFAULT_COMPILER_NAME=VS2003
-CPP_FLAGS=$(CPP_FLAGS) /D "CC_INTERP" /D "_LP64" /D "IA64"
+CXX_FLAGS=$(CXX_FLAGS) /D "CC_INTERP" /D "_LP64" /D "IA64"
 !endif
 
 !if "$(BUILDARCH)" == "amd64"
 MACHINE=AMD64
 DEFAULT_COMPILER_NAME=VS2005
-CPP_FLAGS=$(CPP_FLAGS) /D "_LP64" /D "AMD64"
+CXX_FLAGS=$(CXX_FLAGS) /D "_LP64" /D "AMD64"
 LP64=1
 !endif
 
 !if "$(BUILDARCH)" == "i486"
 MACHINE=I386
 DEFAULT_COMPILER_NAME=VS2003
-CPP_FLAGS=$(CPP_FLAGS) /D "IA32"
+CXX_FLAGS=$(CXX_FLAGS) /D "IA32"
 !endif
 
 # Sanity check, this is the default if not amd64, ia64, or i486
 !ifndef DEFAULT_COMPILER_NAME
-CPP=ARCH_ERROR
+CXX=ARCH_ERROR
 !endif
 
-CPP_FLAGS=$(CPP_FLAGS) /D "WIN32" /D "_WINDOWS"
+CXX_FLAGS=$(CXX_FLAGS) /D "WIN32" /D "_WINDOWS"
 # Must specify this for sharedRuntimeTrig.cpp
-CPP_FLAGS=$(CPP_FLAGS) /D "VM_LITTLE_ENDIAN"
+CXX_FLAGS=$(CXX_FLAGS) /D "VM_LITTLE_ENDIAN"
 
 # Used for platform dispatching
-CPP_FLAGS=$(CPP_FLAGS) /D TARGET_OS_FAMILY_windows
-CPP_FLAGS=$(CPP_FLAGS) /D TARGET_ARCH_$(Platform_arch)
-CPP_FLAGS=$(CPP_FLAGS) /D TARGET_ARCH_MODEL_$(Platform_arch_model)
-CPP_FLAGS=$(CPP_FLAGS) /D TARGET_OS_ARCH_windows_$(Platform_arch)
-CPP_FLAGS=$(CPP_FLAGS) /D TARGET_OS_ARCH_MODEL_windows_$(Platform_arch_model)
-CPP_FLAGS=$(CPP_FLAGS) /D TARGET_COMPILER_visCPP
+CXX_FLAGS=$(CXX_FLAGS) /D TARGET_OS_FAMILY_windows
+CXX_FLAGS=$(CXX_FLAGS) /D TARGET_ARCH_$(Platform_arch)
+CXX_FLAGS=$(CXX_FLAGS) /D TARGET_ARCH_MODEL_$(Platform_arch_model)
+CXX_FLAGS=$(CXX_FLAGS) /D TARGET_OS_ARCH_windows_$(Platform_arch)
+CXX_FLAGS=$(CXX_FLAGS) /D TARGET_OS_ARCH_MODEL_windows_$(Platform_arch_model)
+CXX_FLAGS=$(CXX_FLAGS) /D TARGET_COMPILER_visCPP
 
 
 # MSC_VER is a 4 digit number that tells us what compiler is being used
@@ -150,14 +150,14 @@
 # Always add the _STATIC_CPPLIB flag
 STATIC_CPPLIB_OPTION = /D _STATIC_CPPLIB /D _DISABLE_DEPRECATE_STATIC_CPPLIB
 MS_RUNTIME_OPTION = $(MS_RUNTIME_OPTION) $(STATIC_CPPLIB_OPTION)
-CPP_FLAGS=$(CPP_FLAGS) $(MS_RUNTIME_OPTION)
+CXX_FLAGS=$(CXX_FLAGS) $(MS_RUNTIME_OPTION)
 
 # How /GX option is spelled
 GX_OPTION = /GX
 
 # Optimization settings for various versions of the compilers and types of
 #    builds. Three basic sets of settings: product, fastdebug, and debug.
-#    These get added into CPP_FLAGS as needed by other makefiles.
+#    These get added into CXX_FLAGS as needed by other makefiles.
 !if "$(COMPILER_NAME)" == "VC6"
 PRODUCT_OPT_OPTION   = /Ox /Os /Gy /GF
 FASTDEBUG_OPT_OPTION = /Ox /Os /Gy /GF
@@ -180,7 +180,7 @@
 #    externals at link time. Even with /GS-, you need bufferoverflowU.lib.
 #    NOTE: Currently we decided to not use /GS-
 BUFFEROVERFLOWLIB = bufferoverflowU.lib
-LINK_FLAGS = /manifest $(LINK_FLAGS) $(BUFFEROVERFLOWLIB)
+LD_FLAGS = /manifest $(LD_FLAGS) $(BUFFEROVERFLOWLIB)
 # Manifest Tool - used in VS2005 and later to adjust manifests stored
 # as resources inside build artifacts.
 MT=mt.exe
@@ -191,7 +191,7 @@
 FASTDEBUG_OPT_OPTION = /O2 /Oy-
 DEBUG_OPT_OPTION     = /Od
 GX_OPTION = /EHsc
-LINK_FLAGS = /manifest $(LINK_FLAGS)
+LD_FLAGS = /manifest $(LD_FLAGS)
 # Manifest Tool - used in VS2005 and later to adjust manifests stored
 # as resources inside build artifacts.
 MT=mt.exe
@@ -202,12 +202,12 @@
 FASTDEBUG_OPT_OPTION = /O2 /Oy-
 DEBUG_OPT_OPTION     = /Od
 GX_OPTION = /EHsc
-LINK_FLAGS = /manifest $(LINK_FLAGS)
+LD_FLAGS = /manifest $(LD_FLAGS)
 # Manifest Tool - used in VS2005 and later to adjust manifests stored
 # as resources inside build artifacts.
 MT=mt.exe
 !if "$(BUILDARCH)" == "i486"
-LINK_FLAGS = /SAFESEH $(LINK_FLAGS)
+LD_FLAGS = /SAFESEH $(LD_FLAGS)
 !endif
 !endif
 
@@ -225,15 +225,15 @@
 !endif
 
 # Generic linker settings
-LINK=link.exe
-LINK_FLAGS= $(LINK_FLAGS) kernel32.lib user32.lib gdi32.lib winspool.lib \
+LD=link.exe
+LD_FLAGS= $(LD_FLAGS) kernel32.lib user32.lib gdi32.lib winspool.lib \
  comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib \
  uuid.lib Wsock32.lib winmm.lib /nologo /machine:$(MACHINE) /opt:REF \
  /opt:ICF,8 /map /debug
 
 
 !if $(MSC_VER) >= 1600 
-LINK_FLAGS= $(LINK_FLAGS) psapi.lib
+LD_FLAGS= $(LD_FLAGS) psapi.lib
 !endif
 
 # Resource compiler settings
@@ -250,7 +250,7 @@
 	 /D "HS_INTERNAL_NAME=$(HS_INTERNAL_NAME)" \
 	 /D "HS_NAME=$(HS_NAME)"
 
-# Need this to match the CPP_FLAGS settings
+# Need this to match the CXX_FLAGS settings
 !if "$(MFC_DEBUG)" == "true"
 RC_FLAGS = $(RC_FLAGS) /D "_DEBUG"
 !endif
--- a/hotspot/make/windows/makefiles/debug.make	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/make/windows/makefiles/debug.make	Mon Feb 13 14:31:32 2012 +0000
@@ -38,7 +38,7 @@
 !include ../local.make
 !include compile.make
 
-CPP_FLAGS=$(CPP_FLAGS) $(DEBUG_OPT_OPTION)
+CXX_FLAGS=$(CXX_FLAGS) $(DEBUG_OPT_OPTION)
 
 !include $(WorkSpace)/make/windows/makefiles/vm.make
 !include local.make
@@ -52,8 +52,8 @@
 	sh $(WorkSpace)/make/windows/build_vm_def.sh
 
 $(AOUT): $(Res_Files) $(Obj_Files) vm.def
-	$(LINK) @<<
-  $(LINK_FLAGS) /out:$@ /implib:$*.lib /def:vm.def $(Obj_Files) $(Res_Files)
+	$(LD) @<<
+  $(LD_FLAGS) /out:$@ /implib:$*.lib /def:vm.def $(Obj_Files) $(Res_Files)
 <<
 !if "$(MT)" != ""
 # The previous link command created a .manifest file that we want to
--- a/hotspot/make/windows/makefiles/fastdebug.make	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/make/windows/makefiles/fastdebug.make	Mon Feb 13 14:31:32 2012 +0000
@@ -38,7 +38,7 @@
 !include ../local.make
 !include compile.make
 
-CPP_FLAGS=$(CPP_FLAGS) $(FASTDEBUG_OPT_OPTION)
+CXX_FLAGS=$(CXX_FLAGS) $(FASTDEBUG_OPT_OPTION)
 
 !include $(WorkSpace)/make/windows/makefiles/vm.make
 !include local.make
@@ -52,8 +52,8 @@
 	sh $(WorkSpace)/make/windows/build_vm_def.sh
 
 $(AOUT): $(Res_Files) $(Obj_Files) vm.def
-	$(LINK) @<<
-  $(LINK_FLAGS) /out:$@ /implib:$*.lib /def:vm.def $(Obj_Files) $(Res_Files)
+	$(LD) @<<
+  $(LD_FLAGS) /out:$@ /implib:$*.lib /def:vm.def $(Obj_Files) $(Res_Files)
 <<
 !if "$(MT)" != ""
 # The previous link command created a .manifest file that we want to
--- a/hotspot/make/windows/makefiles/launcher.make	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/make/windows/makefiles/launcher.make	Mon Feb 13 14:31:32 2012 +0000
@@ -23,7 +23,7 @@
 #
 
 
-LAUNCHER_FLAGS=$(CPP_FLAGS) $(ARCHFLAG) \
+LAUNCHER_FLAGS=$(CXX_FLAGS) $(ARCHFLAG) \
 	/D FULL_VERSION=\"$(HOTSPOT_RELEASE_VERSION)\" \
 	/D JDK_MAJOR_VERSION=\"$(JDK_MAJOR_VERSION)\" \
 	/D JDK_MINOR_VERSION=\"$(JDK_MINOR_VERSION)\" \
@@ -39,18 +39,18 @@
 	/I $(WorkSpace)\src\cpu\$(Platform_arch)\vm \
 	/I $(WorkSpace)\src\os\windows\vm
 
-LINK_FLAGS=/manifest $(HS_INTERNAL_NAME).lib kernel32.lib user32.lib /nologo /machine:$(MACHINE) /map /debug /subsystem:console 
+LD_FLAGS=/manifest $(HS_INTERNAL_NAME).lib kernel32.lib user32.lib /nologo /machine:$(MACHINE) /map /debug /subsystem:console 
 
 !if "$(COMPILER_NAME)" == "VS2005"
 # This VS2005 compiler has /GS as a default and requires bufferoverflowU.lib
 #    on the link command line, otherwise we get missing __security_check_cookie
 #    externals at link time. Even with /GS-, you need bufferoverflowU.lib.
 BUFFEROVERFLOWLIB = bufferoverflowU.lib
-LINK_FLAGS = $(LINK_FLAGS) $(BUFFEROVERFLOWLIB)
+LD_FLAGS = $(LD_FLAGS) $(BUFFEROVERFLOWLIB)
 !endif
 
 !if "$(COMPILER_NAME)" == "VS2010" && "$(BUILDARCH)" == "i486"
-LINK_FLAGS = /SAFESEH $(LINK_FLAGS)
+LD_FLAGS = /SAFESEH $(LD_FLAGS)
 !endif
 
 LAUNCHERDIR = $(WorkSpace)/src/os/windows/launcher
@@ -60,14 +60,14 @@
 
 {$(LAUNCHERDIR)}.c{$(OUTDIR)}.obj:
 	-mkdir $(OUTDIR) 2>NUL >NUL
-        $(CPP) $(LAUNCHER_FLAGS) /c /Fo$@ $<
+        $(CXX) $(LAUNCHER_FLAGS) /c /Fo$@ $<
 
 {$(LAUNCHERDIR_SHARE)}.c{$(OUTDIR)}.obj:
 	-mkdir $(OUTDIR) 2>NUL >NUL
-        $(CPP) $(LAUNCHER_FLAGS) /c /Fo$@ $<
+        $(CXX) $(LAUNCHER_FLAGS) /c /Fo$@ $<
 
 $(OUTDIR)\*.obj: $(LAUNCHERDIR)\*.c $(LAUNCHERDIR)\*.h $(LAUNCHERDIR_SHARE)\*.c $(LAUNCHERDIR_SHARE)\*.h
 
 launcher: $(OUTDIR)\java.obj $(OUTDIR)\java_md.obj $(OUTDIR)\jli_util.obj
 	echo $(JAVA_HOME) > jdkpath.txt  
-	$(LINK) $(LINK_FLAGS) /out:hotspot.exe $**
+	$(LD) $(LD_FLAGS) /out:hotspot.exe $**
--- a/hotspot/make/windows/makefiles/product.make	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/make/windows/makefiles/product.make	Mon Feb 13 14:31:32 2012 +0000
@@ -37,7 +37,7 @@
 !include ../local.make
 !include compile.make
 
-CPP_FLAGS=$(CPP_FLAGS) $(PRODUCT_OPT_OPTION)
+CXX_FLAGS=$(CXX_FLAGS) $(PRODUCT_OPT_OPTION)
 
 RELEASE=
 
@@ -54,16 +54,16 @@
 # Kernel doesn't need exported vtbl symbols.
 !if "$(Variant)" == "kernel"
 $(AOUT): $(Res_Files) $(Obj_Files)
-	$(LINK) @<<
-  $(LINK_FLAGS) /out:$@ /implib:$*.lib $(Obj_Files) $(Res_Files)
+	$(LD) @<<
+  $(LD_FLAGS) /out:$@ /implib:$*.lib $(Obj_Files) $(Res_Files)
 <<
 !else
 vm.def: $(Obj_Files)
 	sh $(WorkSpace)/make/windows/build_vm_def.sh
 
 $(AOUT): $(Res_Files) $(Obj_Files) vm.def
-	$(LINK) @<<
-  $(LINK_FLAGS) /out:$@ /implib:$*.lib /def:vm.def $(Obj_Files) $(Res_Files)
+	$(LD) @<<
+  $(LD_FLAGS) /out:$@ /implib:$*.lib /def:vm.def $(Obj_Files) $(Res_Files)
 <<
 !endif
 !if "$(MT)" != ""
--- a/hotspot/make/windows/makefiles/projectcreator.make	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/make/windows/makefiles/projectcreator.make	Mon Feb 13 14:31:32 2012 +0000
@@ -89,7 +89,7 @@
         -jdkTargetRoot $(HOTSPOTJDKDIST) \
         -define ALIGN_STACK_FRAMES \
         -define VM_LITTLE_ENDIAN \
-        -prelink  "" "Generating vm.def..." "cd $(HOTSPOTBUILDSPACE)\%f\%b	set HOTSPOTMKSHOME=$(HOTSPOTMKSHOME)	set JAVA_HOME=$(HOTSPOTJDKDIST)	$(HOTSPOTMKSHOME)\sh $(HOTSPOTWORKSPACE)\make\windows\build_vm_def.sh $(LINK_VER)" \
+        -prelink  "" "Generating vm.def..." "cd $(HOTSPOTBUILDSPACE)\%f\%b	set HOTSPOTMKSHOME=$(HOTSPOTMKSHOME)	set JAVA_HOME=$(HOTSPOTJDKDIST)	$(HOTSPOTMKSHOME)\sh $(HOTSPOTWORKSPACE)\make\windows\build_vm_def.sh $(LD_VER)" \
         -postbuild "" "Building hotspot.exe..." "cd $(HOTSPOTBUILDSPACE)\%f\%b	set HOTSPOTMKSHOME=$(HOTSPOTMKSHOME)	nmake -f $(HOTSPOTWORKSPACE)\make\windows\projectfiles\common\Makefile LOCAL_MAKE=$(HOTSPOTBUILDSPACE)\%f\local.make JAVA_HOME=$(HOTSPOTJDKDIST) launcher" \
         -ignoreFile jsig.c \
         -ignoreFile jvmtiEnvRecommended.cpp \
--- a/hotspot/make/windows/makefiles/sa.make	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/make/windows/makefiles/sa.make	Mon Feb 13 14:31:32 2012 +0000
@@ -91,16 +91,16 @@
 !if "$(COMPILER_NAME)" == "VS2005"
 # On amd64, VS2005 compiler requires bufferoverflowU.lib on the link command line, 
 # otherwise we get missing __security_check_cookie externals at link time. 
-SA_LINK_FLAGS = bufferoverflowU.lib
+SA_LD_FLAGS = bufferoverflowU.lib
 !endif
 !else
 SA_CFLAGS = /nologo $(MS_RUNTIME_OPTION) /W3 /Gm $(GX_OPTION) /ZI /Od /D "WIN32" /D "_WINDOWS" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
 !endif
 !if "$(MT)" != ""
-SA_LINK_FLAGS = /manifest $(SA_LINK_FLAGS)
+SA_LD_FLAGS = /manifest $(SA_LD_FLAGS)
 !endif
 SASRCFILE = $(AGENT_DIR)/src/os/win32/windbg/sawindbg.cpp
-SA_LFLAGS = $(SA_LINK_FLAGS) /nologo /subsystem:console /map /debug /machine:$(MACHINE)
+SA_LFLAGS = $(SA_LD_FLAGS) /nologo /subsystem:console /map /debug /machine:$(MACHINE)
 
 # Note that we do not keep sawindbj.obj around as it would then
 # get included in the dumpbin command in build_vm_def.sh
@@ -110,14 +110,14 @@
 # Use ";#2" for .dll and ";#1" for .exe in the MT command below:
 $(SAWINDBG): $(SASRCFILE)
 	set INCLUDE=$(SA_INCLUDE)$(INCLUDE)
-	$(CPP) @<<
+	$(CXX) @<<
 	  /I"$(BootStrapDir)/include" /I"$(BootStrapDir)/include/win32" 
 	  /I"$(GENERATED)" $(SA_CFLAGS)
 	  $(SASRCFILE)
 	  /out:sawindbg.obj
 <<
 	set LIB=$(SA_LIB)$(LIB)
-	$(LINK) /out:$@ /DLL sawindbg.obj dbgeng.lib $(SA_LFLAGS)
+	$(LD) /out:$@ /DLL sawindbg.obj dbgeng.lib $(SA_LFLAGS)
 !if "$(MT)" != ""
 	$(MT) /manifest $(@F).manifest /outputresource:$(@F);#2
 !endif
--- a/hotspot/make/windows/makefiles/sanity.make	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/make/windows/makefiles/sanity.make	Mon Feb 13 14:31:32 2012 +0000
@@ -31,5 +31,5 @@
 	echo *** WARNING *** unrecognized cl.exe version $(MSC_VER) ($(RAW_MSC_VER)).  Use FORCE_MSC_VER to override automatic detection.
 
 checkLink:
-	@ if "$(LINK_VER)" NEQ "710" if "$(LINK_VER)" NEQ "800" if "$(LINK_VER)" NEQ "900" if "$(LINK_VER)" NEQ "1000" \
-	echo *** WARNING *** unrecognized link.exe version $(LINK_VER) ($(RAW_LINK_VER)).  Use FORCE_LINK_VER to override automatic detection.
+	@ if "$(LD_VER)" NEQ "710" if "$(LD_VER)" NEQ "800" if "$(LD_VER)" NEQ "900" if "$(LD_VER)" NEQ "1000" \
+	echo *** WARNING *** unrecognized link.exe version $(LD_VER) ($(RAW_LD_VER)).  Use FORCE_LD_VER to override automatic detection.
--- a/hotspot/make/windows/makefiles/shared.make	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/make/windows/makefiles/shared.make	Mon Feb 13 14:31:32 2012 +0000
@@ -30,8 +30,8 @@
 DIR=.
 !endif
 
-!ifndef CPP
-CPP=cl.exe
+!ifndef CXX
+CXX=cl.exe
 !endif
 
 
--- a/hotspot/make/windows/makefiles/vm.make	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/make/windows/makefiles/vm.make	Mon Feb 13 14:31:32 2012 +0000
@@ -32,12 +32,12 @@
 
 !ifdef RELEASE
 !ifdef DEVELOP
-CPP_FLAGS=$(CPP_FLAGS) /D "DEBUG"
+CXX_FLAGS=$(CXX_FLAGS) /D "DEBUG"
 !else
-CPP_FLAGS=$(CPP_FLAGS) /D "PRODUCT"
+CXX_FLAGS=$(CXX_FLAGS) /D "PRODUCT"
 !endif
 !else
-CPP_FLAGS=$(CPP_FLAGS) /D "ASSERT"
+CXX_FLAGS=$(CXX_FLAGS) /D "ASSERT"
 !endif
 
 !if "$(Variant)" == "core"
@@ -45,19 +45,19 @@
 !endif
 
 !if "$(Variant)" == "kernel"
-CPP_FLAGS=$(CPP_FLAGS) /D "KERNEL"
+CXX_FLAGS=$(CXX_FLAGS) /D "KERNEL"
 !endif
 
 !if "$(Variant)" == "compiler1"
-CPP_FLAGS=$(CPP_FLAGS) /D "COMPILER1"
+CXX_FLAGS=$(CXX_FLAGS) /D "COMPILER1"
 !endif
 
 !if "$(Variant)" == "compiler2"
-CPP_FLAGS=$(CPP_FLAGS) /D "COMPILER2"
+CXX_FLAGS=$(CXX_FLAGS) /D "COMPILER2"
 !endif
 
 !if "$(Variant)" == "tiered"
-CPP_FLAGS=$(CPP_FLAGS) /D "COMPILER1" /D "COMPILER2"
+CXX_FLAGS=$(CXX_FLAGS) /D "COMPILER1" /D "COMPILER2"
 !endif
 
 !if "$(BUILDARCH)" == "i486"
@@ -67,21 +67,21 @@
 !endif
 
 # The following variables are defined in the generated local.make file.
-CPP_FLAGS=$(CPP_FLAGS) /D "HOTSPOT_RELEASE_VERSION=\"$(HS_BUILD_VER)\""
-CPP_FLAGS=$(CPP_FLAGS) /D "JRE_RELEASE_VERSION=\"$(JRE_RELEASE_VER)\""
-CPP_FLAGS=$(CPP_FLAGS) /D "HOTSPOT_LIB_ARCH=\"$(HOTSPOT_LIB_ARCH)\""
-CPP_FLAGS=$(CPP_FLAGS) /D "HOTSPOT_BUILD_TARGET=\"$(BUILD_FLAVOR)\""
-CPP_FLAGS=$(CPP_FLAGS) /D "HOTSPOT_BUILD_USER=\"$(BuildUser)\""
-CPP_FLAGS=$(CPP_FLAGS) /D "HOTSPOT_VM_DISTRO=\"$(HOTSPOT_VM_DISTRO)\""
+CXX_FLAGS=$(CXX_FLAGS) /D "HOTSPOT_RELEASE_VERSION=\"$(HS_BUILD_VER)\""
+CXX_FLAGS=$(CXX_FLAGS) /D "JRE_RELEASE_VERSION=\"$(JRE_RELEASE_VER)\""
+CXX_FLAGS=$(CXX_FLAGS) /D "HOTSPOT_LIB_ARCH=\"$(HOTSPOT_LIB_ARCH)\""
+CXX_FLAGS=$(CXX_FLAGS) /D "HOTSPOT_BUILD_TARGET=\"$(BUILD_FLAVOR)\""
+CXX_FLAGS=$(CXX_FLAGS) /D "HOTSPOT_BUILD_USER=\"$(BuildUser)\""
+CXX_FLAGS=$(CXX_FLAGS) /D "HOTSPOT_VM_DISTRO=\"$(HOTSPOT_VM_DISTRO)\""
 
 !ifndef JAVASE_EMBEDDED
-CPP_FLAGS=$(CPP_FLAGS) /D "INCLUDE_TRACE"
+CXX_FLAGS=$(CXX_FLAGS) /D "INCLUDE_TRACE"
 !endif
 
-CPP_FLAGS=$(CPP_FLAGS) $(CPP_INCLUDE_DIRS)
+CXX_FLAGS=$(CXX_FLAGS) $(CXX_INCLUDE_DIRS)
 
 # Define that so jni.h is on correct side
-CPP_FLAGS=$(CPP_FLAGS) /D "_JNI_IMPLEMENTATION_"
+CXX_FLAGS=$(CXX_FLAGS) /D "_JNI_IMPLEMENTATION_"
 
 !if "$(BUILDARCH)" == "ia64"
 STACK_SIZE="/STACK:1048576,262144"
@@ -102,7 +102,7 @@
 
 # If you modify exports below please do the corresponding changes in
 # src/share/tools/ProjectCreator/WinGammaPlatformVC7.java
-LINK_FLAGS=$(LINK_FLAGS) $(STACK_SIZE) /subsystem:windows /dll /base:0x8000000 \
+LD_FLAGS=$(LD_FLAGS) $(STACK_SIZE) /subsystem:windows /dll /base:0x8000000 \
   /export:JNI_GetDefaultJavaVMInitArgs       \
   /export:JNI_CreateJavaVM                   \
   /export:JVM_FindClassFromBootLoader        \
@@ -118,25 +118,25 @@
   /export:JVM_GetThreadStateValues           \
   /export:JVM_InitAgentProperties
 
-CPP_INCLUDE_DIRS=/I "..\generated"
+CXX_INCLUDE_DIRS=/I "..\generated"
 
 !if exists($(ALTSRC)\share\vm)
-CPP_INCLUDE_DIRS=$(CPP_INCLUDE_DIRS) /I "$(ALTSRC)\share\vm"
+CXX_INCLUDE_DIRS=$(CXX_INCLUDE_DIRS) /I "$(ALTSRC)\share\vm"
 !endif
 
 !if exists($(ALTSRC)\os\windows\vm)
-CPP_INCLUDE_DIRS=$(CPP_INCLUDE_DIRS) /I "$(ALTSRC)\os\windows\vm"
+CXX_INCLUDE_DIRS=$(CXX_INCLUDE_DIRS) /I "$(ALTSRC)\os\windows\vm"
 !endif
 
 !if exists($(ALTSRC)\os_cpu\windows_$(Platform_arch)\vm)
-CPP_INCLUDE_DIRS=$(CPP_INCLUDE_DIRS) /I "$(ALTSRC)\os_cpu\windows_$(Platform_arch)\vm"
+CXX_INCLUDE_DIRS=$(CXX_INCLUDE_DIRS) /I "$(ALTSRC)\os_cpu\windows_$(Platform_arch)\vm"
 !endif
 
 !if exists($(ALTSRC)\cpu\$(Platform_arch)\vm)
-CPP_INCLUDE_DIRS=$(CPP_INCLUDE_DIRS) /I "$(ALTSRC)\cpu\$(Platform_arch)\vm"
+CXX_INCLUDE_DIRS=$(CXX_INCLUDE_DIRS) /I "$(ALTSRC)\cpu\$(Platform_arch)\vm"
 !endif
 
-CPP_INCLUDE_DIRS=$(CPP_INCLUDE_DIRS) \
+CXX_INCLUDE_DIRS=$(CXX_INCLUDE_DIRS) \
   /I "$(COMMONSRC)\share\vm" \
   /I "$(COMMONSRC)\share\vm\precompiled" \
   /I "$(COMMONSRC)\share\vm\prims" \
@@ -144,12 +144,12 @@
   /I "$(COMMONSRC)\os_cpu\windows_$(Platform_arch)\vm" \
   /I "$(COMMONSRC)\cpu\$(Platform_arch)\vm"
 
-CPP_DONT_USE_PCH=/D DONT_USE_PRECOMPILED_HEADER
+CXX_DONT_USE_PCH=/D DONT_USE_PRECOMPILED_HEADER
 
 !if "$(USE_PRECOMPILED_HEADER)" != "0"
-CPP_USE_PCH=/Fp"vm.pch" /Yu"precompiled.hpp"
+CXX_USE_PCH=/Fp"vm.pch" /Yu"precompiled.hpp"
 !else
-CPP_USE_PCH=$(CPP_DONT_USE_PCH)
+CXX_USE_PCH=$(CXX_DONT_USE_PCH)
 !endif
 
 # Where to find the source code for the virtual machine (is this used?)
@@ -194,101 +194,101 @@
 # Special case files not using precompiled header files.
 
 c1_RInfo_$(Platform_arch).obj: $(WorkSpace)\src\cpu\$(Platform_arch)\vm\c1_RInfo_$(Platform_arch).cpp 
-	 $(CPP) $(CPP_FLAGS) $(CPP_DONT_USE_PCH) /c $(WorkSpace)\src\cpu\$(Platform_arch)\vm\c1_RInfo_$(Platform_arch).cpp
+	 $(CXX) $(CXX_FLAGS) $(CXX_DONT_USE_PCH) /c $(WorkSpace)\src\cpu\$(Platform_arch)\vm\c1_RInfo_$(Platform_arch).cpp
 
 os_windows.obj: $(WorkSpace)\src\os\windows\vm\os_windows.cpp
-        $(CPP) $(CPP_FLAGS) $(CPP_DONT_USE_PCH) /c $(WorkSpace)\src\os\windows\vm\os_windows.cpp
+        $(CXX) $(CXX_FLAGS) $(CXX_DONT_USE_PCH) /c $(WorkSpace)\src\os\windows\vm\os_windows.cpp
 
 os_windows_$(Platform_arch).obj: $(WorkSpace)\src\os_cpu\windows_$(Platform_arch)\vm\os_windows_$(Platform_arch).cpp
-        $(CPP) $(CPP_FLAGS) $(CPP_DONT_USE_PCH) /c $(WorkSpace)\src\os_cpu\windows_$(Platform_arch)\vm\os_windows_$(Platform_arch).cpp
+        $(CXX) $(CXX_FLAGS) $(CXX_DONT_USE_PCH) /c $(WorkSpace)\src\os_cpu\windows_$(Platform_arch)\vm\os_windows_$(Platform_arch).cpp
 
 osThread_windows.obj: $(WorkSpace)\src\os\windows\vm\osThread_windows.cpp
-        $(CPP) $(CPP_FLAGS) $(CPP_DONT_USE_PCH) /c $(WorkSpace)\src\os\windows\vm\osThread_windows.cpp
+        $(CXX) $(CXX_FLAGS) $(CXX_DONT_USE_PCH) /c $(WorkSpace)\src\os\windows\vm\osThread_windows.cpp
 
 conditionVar_windows.obj: $(WorkSpace)\src\os\windows\vm\conditionVar_windows.cpp
-        $(CPP) $(CPP_FLAGS) $(CPP_DONT_USE_PCH) /c $(WorkSpace)\src\os\windows\vm\conditionVar_windows.cpp
+        $(CXX) $(CXX_FLAGS) $(CXX_DONT_USE_PCH) /c $(WorkSpace)\src\os\windows\vm\conditionVar_windows.cpp
 
 getThread_windows_$(Platform_arch).obj: $(WorkSpace)\src\os_cpu\windows_$(Platform_arch)\vm\getThread_windows_$(Platform_arch).cpp
-        $(CPP) $(CPP_FLAGS) $(CPP_DONT_USE_PCH) /c $(WorkSpace)\src\os_cpu\windows_$(Platform_arch)\vm\getThread_windows_$(Platform_arch).cpp
+        $(CXX) $(CXX_FLAGS) $(CXX_DONT_USE_PCH) /c $(WorkSpace)\src\os_cpu\windows_$(Platform_arch)\vm\getThread_windows_$(Platform_arch).cpp
 
 opcodes.obj: $(WorkSpace)\src\share\vm\opto\opcodes.cpp
-        $(CPP) $(CPP_FLAGS) $(CPP_DONT_USE_PCH) /c $(WorkSpace)\src\share\vm\opto\opcodes.cpp
+        $(CXX) $(CXX_FLAGS) $(CXX_DONT_USE_PCH) /c $(WorkSpace)\src\share\vm\opto\opcodes.cpp
 
 bytecodeInterpreter.obj: $(WorkSpace)\src\share\vm\interpreter\bytecodeInterpreter.cpp
-        $(CPP) $(CPP_FLAGS) $(CPP_DONT_USE_PCH) /c $(WorkSpace)\src\share\vm\interpreter\bytecodeInterpreter.cpp
+        $(CXX) $(CXX_FLAGS) $(CXX_DONT_USE_PCH) /c $(WorkSpace)\src\share\vm\interpreter\bytecodeInterpreter.cpp
 
 bytecodeInterpreterWithChecks.obj: ..\generated\jvmtifiles\bytecodeInterpreterWithChecks.cpp
-        $(CPP) $(CPP_FLAGS) $(CPP_DONT_USE_PCH) /c ..\generated\jvmtifiles\bytecodeInterpreterWithChecks.cpp
+        $(CXX) $(CXX_FLAGS) $(CXX_DONT_USE_PCH) /c ..\generated\jvmtifiles\bytecodeInterpreterWithChecks.cpp
 
 # Default rules for the Virtual Machine
 {$(COMMONSRC)\share\vm\c1}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {$(COMMONSRC)\share\vm\compiler}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {$(COMMONSRC)\share\vm\code}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {$(COMMONSRC)\share\vm\interpreter}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {$(COMMONSRC)\share\vm\ci}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {$(COMMONSRC)\share\vm\classfile}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {$(COMMONSRC)\share\vm\gc_implementation\parallelScavenge}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {$(COMMONSRC)\share\vm\gc_implementation\shared}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {$(COMMONSRC)\share\vm\gc_implementation\parNew}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {$(COMMONSRC)\share\vm\gc_implementation\concurrentMarkSweep}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {$(COMMONSRC)\share\vm\gc_implementation\g1}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {$(COMMONSRC)\share\vm\gc_interface}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {$(COMMONSRC)\share\vm\asm}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {$(COMMONSRC)\share\vm\memory}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {$(COMMONSRC)\share\vm\oops}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {$(COMMONSRC)\share\vm\prims}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {$(COMMONSRC)\share\vm\runtime}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {$(COMMONSRC)\share\vm\services}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {$(COMMONSRC)\share\vm\trace}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {$(COMMONSRC)\share\vm\utilities}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {$(COMMONSRC)\share\vm\libadt}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {$(COMMONSRC)\share\vm\opto}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {$(COMMONSRC)\os\windows\vm}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 # This guy should remain a single colon rule because
 # otherwise we can't specify the output filename.
@@ -296,113 +296,113 @@
         @$(RC) $(RC_FLAGS) /fo"$@" $<
 
 {$(COMMONSRC)\cpu\$(Platform_arch)\vm}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {$(COMMONSRC)\os_cpu\windows_$(Platform_arch)\vm}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {$(ALTSRC)\share\vm\c1}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {$(ALTSRC)\share\vm\compiler}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {$(ALTSRC)\share\vm\code}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {$(ALTSRC)\share\vm\interpreter}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {$(ALTSRC)\share\vm\ci}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {$(ALTSRC)\share\vm\classfile}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {$(ALTSRC)\share\vm\gc_implementation\parallelScavenge}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {$(ALTSRC)\share\vm\gc_implementation\shared}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {$(ALTSRC)\share\vm\gc_implementation\parNew}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {$(ALTSRC)\share\vm\gc_implementation\concurrentMarkSweep}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {$(ALTSRC)\share\vm\gc_implementation\g1}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {$(ALTSRC)\share\vm\gc_interface}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {$(ALTSRC)\share\vm\asm}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {$(ALTSRC)\share\vm\memory}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {$(ALTSRC)\share\vm\oops}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {$(ALTSRC)\share\vm\prims}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {$(ALTSRC)\share\vm\runtime}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {$(ALTSRC)\share\vm\services}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {$(ALTSRC)\share\vm\trace}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {$(ALTSRC)\share\vm\utilities}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {$(ALTSRC)\share\vm\libadt}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {$(ALTSRC)\share\vm\opto}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {$(ALTSRC)\os\windows\vm}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 # otherwise we can't specify the output filename.
 {$(ALTSRC)\os\windows\vm}.rc.res:
         @$(RC) $(RC_FLAGS) /fo"$@" $<
 
 {$(ALTSRC)\cpu\$(Platform_arch)\vm}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {$(ALTSRC)\os_cpu\windows_$(Platform_arch)\vm}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {..\generated\incls}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {..\generated\adfiles}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {..\generated\jvmtifiles}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {$(ALTSRC)\share\vm\jfr}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {$(ALTSRC)\share\vm\jfr\agent}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {$(ALTSRC)\share\vm\jfr\agent\isolated_deps\util}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 {$(ALTSRC)\share\vm\jfr\jvm}.cpp.obj::
-        $(CPP) $(CPP_FLAGS) $(CPP_USE_PCH) /c $<
+        $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $<
 
 default::
 
 _build_pch_file.obj:
         @echo #include "precompiled.hpp" > ../generated/_build_pch_file.cpp
-        $(CPP) $(CPP_FLAGS) /Fp"vm.pch" /Yc"precompiled.hpp" /c ../generated/_build_pch_file.cpp
+        $(CXX) $(CXX_FLAGS) /Fp"vm.pch" /Yc"precompiled.hpp" /c ../generated/_build_pch_file.cpp
--- a/hotspot/src/cpu/sparc/vm/assembler_sparc.hpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/cpu/sparc/vm/assembler_sparc.hpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -2134,6 +2134,7 @@
   // address pseudos: make these names unlike instruction names to avoid confusion
   inline intptr_t load_pc_address( Register reg, int bytes_to_skip );
   inline void load_contents(const AddressLiteral& addrlit, Register d, int offset = 0);
+  inline void load_bool_contents(const AddressLiteral& addrlit, Register d, int offset = 0);
   inline void load_ptr_contents(const AddressLiteral& addrlit, Register d, int offset = 0);
   inline void store_contents(Register s, const AddressLiteral& addrlit, Register temp, int offset = 0);
   inline void store_ptr_contents(Register s, const AddressLiteral& addrlit, Register temp, int offset = 0);
@@ -2249,7 +2250,7 @@
   // this platform we assume byte size
 
   inline void stbool(Register d, const Address& a) { stb(d, a); }
-  inline void ldbool(const Address& a, Register d) { ldsb(a, d); }
+  inline void ldbool(const Address& a, Register d) { ldub(a, d); }
   inline void movbool( bool boolconst, Register d) { mov( (int) boolconst, d); }
 
   // klass oop manipulations if compressed
--- a/hotspot/src/cpu/sparc/vm/assembler_sparc.inline.hpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/cpu/sparc/vm/assembler_sparc.inline.hpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -692,6 +692,17 @@
 }
 
 
+inline void MacroAssembler::load_bool_contents(const AddressLiteral& addrlit, Register d, int offset) {
+  assert_not_delayed();
+  if (ForceUnreachable) {
+    patchable_sethi(addrlit, d);
+  } else {
+    sethi(addrlit, d);
+  }
+  ldub(d, addrlit.low10() + offset, d);
+}
+
+
 inline void MacroAssembler::load_ptr_contents(const AddressLiteral& addrlit, Register d, int offset) {
   assert_not_delayed();
   if (ForceUnreachable) {
--- a/hotspot/src/cpu/sparc/vm/c1_CodeStubs_sparc.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/cpu/sparc/vm/c1_CodeStubs_sparc.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -472,7 +472,7 @@
   __ load_klass(src_reg, tmp_reg);
 
   Address ref_type_adr(tmp_reg, instanceKlass::reference_type_offset());
-  __ ld(ref_type_adr, tmp_reg);
+  __ ldub(ref_type_adr, tmp_reg);
 
   // _reference_type field is of type ReferenceType (enum)
   assert(REF_NONE == 0, "check this code");
--- a/hotspot/src/cpu/sparc/vm/c2_globals_sparc.hpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/cpu/sparc/vm/c2_globals_sparc.hpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -42,7 +42,7 @@
 #else
 define_pd_global(bool, ProfileInterpreter,           true);
 #endif // CC_INTERP
-define_pd_global(bool, TieredCompilation,            true);
+define_pd_global(bool, TieredCompilation,            trueInTiered);
 define_pd_global(intx, CompileThreshold,             10000);
 define_pd_global(intx, BackEdgeThreshold,            140000);
 
--- a/hotspot/src/cpu/sparc/vm/frame_sparc.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/cpu/sparc/vm/frame_sparc.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -28,6 +28,7 @@
 #include "oops/markOop.hpp"
 #include "oops/methodOop.hpp"
 #include "oops/oop.inline.hpp"
+#include "prims/methodHandles.hpp"
 #include "runtime/frame.inline.hpp"
 #include "runtime/handles.inline.hpp"
 #include "runtime/javaCalls.hpp"
--- a/hotspot/src/cpu/sparc/vm/sharedRuntime_sparc.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/cpu/sparc/vm/sharedRuntime_sparc.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -321,6 +321,16 @@
   return (r->reg2stack() + SharedRuntime::out_preserve_stack_slots()) * VMRegImpl::stack_slot_size;
 }
 
+static VMRegPair reg64_to_VMRegPair(Register r) {
+  VMRegPair ret;
+  if (wordSize == 8) {
+    ret.set2(r->as_VMReg());
+  } else {
+    ret.set_pair(r->successor()->as_VMReg(), r->as_VMReg());
+  }
+  return ret;
+}
+
 // ---------------------------------------------------------------------------
 // Read the array of BasicTypes from a signature, and compute where the
 // arguments should go.  Values in the VMRegPair regs array refer to 4-byte (VMRegImpl::stack_slot_size)
@@ -1444,6 +1454,25 @@
 }
 
 
+static void move_ptr(MacroAssembler* masm, VMRegPair src, VMRegPair dst) {
+  if (src.first()->is_stack()) {
+    if (dst.first()->is_stack()) {
+      // stack to stack
+      __ ld_ptr(FP, reg2offset(src.first()) + STACK_BIAS, L5);
+      __ st_ptr(L5, SP, reg2offset(dst.first()) + STACK_BIAS);
+    } else {
+      // stack to reg
+      __ ld_ptr(FP, reg2offset(src.first()) + STACK_BIAS, dst.first()->as_Register());
+    }
+  } else if (dst.first()->is_stack()) {
+    // reg to stack
+    __ st_ptr(src.first()->as_Register(), SP, reg2offset(dst.first()) + STACK_BIAS);
+  } else {
+    __ mov(src.first()->as_Register(), dst.first()->as_Register());
+  }
+}
+
+
 // An oop arg. Must pass a handle not the oop itself
 static void object_move(MacroAssembler* masm,
                         OopMap* map,
@@ -1748,6 +1777,166 @@
   }
 }
 
+
+static void save_or_restore_arguments(MacroAssembler* masm,
+                                      const int stack_slots,
+                                      const int total_in_args,
+                                      const int arg_save_area,
+                                      OopMap* map,
+                                      VMRegPair* in_regs,
+                                      BasicType* in_sig_bt) {
+  // if map is non-NULL then the code should store the values,
+  // otherwise it should load them.
+  if (map != NULL) {
+    // Fill in the map
+    for (int i = 0; i < total_in_args; i++) {
+      if (in_sig_bt[i] == T_ARRAY) {
+        if (in_regs[i].first()->is_stack()) {
+          int offset_in_older_frame = in_regs[i].first()->reg2stack() + SharedRuntime::out_preserve_stack_slots();
+          map->set_oop(VMRegImpl::stack2reg(offset_in_older_frame + stack_slots));
+        } else if (in_regs[i].first()->is_Register()) {
+          map->set_oop(in_regs[i].first());
+        } else {
+          ShouldNotReachHere();
+        }
+      }
+    }
+  }
+
+  // Save or restore double word values
+  int handle_index = 0;
+  for (int i = 0; i < total_in_args; i++) {
+    int slot = handle_index + arg_save_area;
+    int offset = slot * VMRegImpl::stack_slot_size;
+    if (in_sig_bt[i] == T_LONG && in_regs[i].first()->is_Register()) {
+      const Register reg = in_regs[i].first()->as_Register();
+      if (reg->is_global()) {
+        handle_index += 2;
+        assert(handle_index <= stack_slots, "overflow");
+        if (map != NULL) {
+          __ stx(reg, SP, offset + STACK_BIAS);
+        } else {
+          __ ldx(SP, offset + STACK_BIAS, reg);
+        }
+      }
+    } else if (in_sig_bt[i] == T_DOUBLE && in_regs[i].first()->is_FloatRegister()) {
+      handle_index += 2;
+      assert(handle_index <= stack_slots, "overflow");
+      if (map != NULL) {
+        __ stf(FloatRegisterImpl::D, in_regs[i].first()->as_FloatRegister(), SP, offset + STACK_BIAS);
+      } else {
+        __ ldf(FloatRegisterImpl::D, SP, offset + STACK_BIAS, in_regs[i].first()->as_FloatRegister());
+      }
+    }
+  }
+  // Save floats
+  for (int i = 0; i < total_in_args; i++) {
+    int slot = handle_index + arg_save_area;
+    int offset = slot * VMRegImpl::stack_slot_size;
+    if (in_sig_bt[i] == T_FLOAT && in_regs[i].first()->is_FloatRegister()) {
+      handle_index++;
+      assert(handle_index <= stack_slots, "overflow");
+      if (map != NULL) {
+        __ stf(FloatRegisterImpl::S, in_regs[i].first()->as_FloatRegister(), SP, offset + STACK_BIAS);
+      } else {
+        __ ldf(FloatRegisterImpl::S, SP, offset + STACK_BIAS, in_regs[i].first()->as_FloatRegister());
+      }
+    }
+  }
+
+}
+
+
+// Check GC_locker::needs_gc and enter the runtime if it's true.  This
+// keeps a new JNI critical region from starting until a GC has been
+// forced.  Save down any oops in registers and describe them in an
+// OopMap.
+static void check_needs_gc_for_critical_native(MacroAssembler* masm,
+                                               const int stack_slots,
+                                               const int total_in_args,
+                                               const int arg_save_area,
+                                               OopMapSet* oop_maps,
+                                               VMRegPair* in_regs,
+                                               BasicType* in_sig_bt) {
+  __ block_comment("check GC_locker::needs_gc");
+  Label cont;
+  AddressLiteral sync_state(GC_locker::needs_gc_address());
+  __ load_bool_contents(sync_state, G3_scratch);
+  __ cmp_zero_and_br(Assembler::equal, G3_scratch, cont);
+  __ delayed()->nop();
+
+  // Save down any values that are live in registers and call into the
+  // runtime to halt for a GC
+  OopMap* map = new OopMap(stack_slots * 2, 0 /* arg_slots*/);
+  save_or_restore_arguments(masm, stack_slots, total_in_args,
+                            arg_save_area, map, in_regs, in_sig_bt);
+
+  __ mov(G2_thread, L7_thread_cache);
+
+  __ set_last_Java_frame(SP, noreg);
+
+  __ block_comment("block_for_jni_critical");
+  __ call(CAST_FROM_FN_PTR(address, SharedRuntime::block_for_jni_critical), relocInfo::runtime_call_type);
+  __ delayed()->mov(L7_thread_cache, O0);
+  oop_maps->add_gc_map( __ offset(), map);
+
+  __ restore_thread(L7_thread_cache); // restore G2_thread
+  __ reset_last_Java_frame();
+
+  // Reload all the register arguments
+  save_or_restore_arguments(masm, stack_slots, total_in_args,
+                            arg_save_area, NULL, in_regs, in_sig_bt);
+
+  __ bind(cont);
+#ifdef ASSERT
+  if (StressCriticalJNINatives) {
+    // Stress register saving
+    OopMap* map = new OopMap(stack_slots * 2, 0 /* arg_slots*/);
+    save_or_restore_arguments(masm, stack_slots, total_in_args,
+                              arg_save_area, map, in_regs, in_sig_bt);
+    // Destroy argument registers
+    for (int i = 0; i < total_in_args; i++) {
+      if (in_regs[i].first()->is_Register()) {
+        const Register reg = in_regs[i].first()->as_Register();
+        if (reg->is_global()) {
+          __ mov(G0, reg);
+        }
+      } else if (in_regs[i].first()->is_FloatRegister()) {
+        __ fneg(FloatRegisterImpl::D, in_regs[i].first()->as_FloatRegister(), in_regs[i].first()->as_FloatRegister());
+      }
+    }
+
+    save_or_restore_arguments(masm, stack_slots, total_in_args,
+                              arg_save_area, NULL, in_regs, in_sig_bt);
+  }
+#endif
+}
+
+// Unpack an array argument into a pointer to the body and the length
+// if the array is non-null, otherwise pass 0 for both.
+static void unpack_array_argument(MacroAssembler* masm, VMRegPair reg, BasicType in_elem_type, VMRegPair body_arg, VMRegPair length_arg) {
+  // Pass the length, ptr pair
+  Label is_null, done;
+  if (reg.first()->is_stack()) {
+    VMRegPair tmp  = reg64_to_VMRegPair(L2);
+    // Load the arg up from the stack
+    move_ptr(masm, reg, tmp);
+    reg = tmp;
+  }
+  __ cmp(reg.first()->as_Register(), G0);
+  __ brx(Assembler::equal, false, Assembler::pt, is_null);
+  __ delayed()->add(reg.first()->as_Register(), arrayOopDesc::base_offset_in_bytes(in_elem_type), L4);
+  move_ptr(masm, reg64_to_VMRegPair(L4), body_arg);
+  __ ld(reg.first()->as_Register(), arrayOopDesc::length_offset_in_bytes(), L4);
+  move32_64(masm, reg64_to_VMRegPair(L4), length_arg);
+  __ ba_short(done);
+  __ bind(is_null);
+  // Pass zeros
+  move_ptr(masm, reg64_to_VMRegPair(G0), body_arg);
+  move32_64(masm, reg64_to_VMRegPair(G0), length_arg);
+  __ bind(done);
+}
+
 // ---------------------------------------------------------------------------
 // Generate a native wrapper for a given method.  The method takes arguments
 // in the Java compiled code convention, marshals them to the native
@@ -1762,6 +1951,13 @@
                                                 BasicType *in_sig_bt,
                                                 VMRegPair *in_regs,
                                                 BasicType ret_type) {
+  bool is_critical_native = true;
+  address native_func = method->critical_native_function();
+  if (native_func == NULL) {
+    native_func = method->native_function();
+    is_critical_native = false;
+  }
+  assert(native_func != NULL, "must have function");
 
   // Native nmethod wrappers never take possesion of the oop arguments.
   // So the caller will gc the arguments. The only thing we need an
@@ -1841,22 +2037,70 @@
   // we convert the java signature to a C signature by inserting
   // the hidden arguments as arg[0] and possibly arg[1] (static method)
 
-  int total_c_args = total_in_args + 1;
-  if (method->is_static()) {
-    total_c_args++;
+  int total_c_args = total_in_args;
+  int total_save_slots = 6 * VMRegImpl::slots_per_word;
+  if (!is_critical_native) {
+    total_c_args += 1;
+    if (method->is_static()) {
+      total_c_args++;
+    }
+  } else {
+    for (int i = 0; i < total_in_args; i++) {
+      if (in_sig_bt[i] == T_ARRAY) {
+        // These have to be saved and restored across the safepoint
+        total_c_args++;
+      }
+    }
   }
 
   BasicType* out_sig_bt = NEW_RESOURCE_ARRAY(BasicType, total_c_args);
-  VMRegPair  * out_regs   = NEW_RESOURCE_ARRAY(VMRegPair,   total_c_args);
+  VMRegPair* out_regs   = NEW_RESOURCE_ARRAY(VMRegPair, total_c_args);
+  BasicType* in_elem_bt = NULL;
 
   int argc = 0;
-  out_sig_bt[argc++] = T_ADDRESS;
-  if (method->is_static()) {
-    out_sig_bt[argc++] = T_OBJECT;
-  }
-
-  for (int i = 0; i < total_in_args ; i++ ) {
-    out_sig_bt[argc++] = in_sig_bt[i];
+  if (!is_critical_native) {
+    out_sig_bt[argc++] = T_ADDRESS;
+    if (method->is_static()) {
+      out_sig_bt[argc++] = T_OBJECT;
+    }
+
+    for (int i = 0; i < total_in_args ; i++ ) {
+      out_sig_bt[argc++] = in_sig_bt[i];
+    }
+  } else {
+    Thread* THREAD = Thread::current();
+    in_elem_bt = NEW_RESOURCE_ARRAY(BasicType, total_in_args);
+    SignatureStream ss(method->signature());
+    for (int i = 0; i < total_in_args ; i++ ) {
+      if (in_sig_bt[i] == T_ARRAY) {
+        // Arrays are passed as int, elem* pair
+        out_sig_bt[argc++] = T_INT;
+        out_sig_bt[argc++] = T_ADDRESS;
+        Symbol* atype = ss.as_symbol(CHECK_NULL);
+        const char* at = atype->as_C_string();
+        if (strlen(at) == 2) {
+          assert(at[0] == '[', "must be");
+          switch (at[1]) {
+            case 'B': in_elem_bt[i]  = T_BYTE; break;
+            case 'C': in_elem_bt[i]  = T_CHAR; break;
+            case 'D': in_elem_bt[i]  = T_DOUBLE; break;
+            case 'F': in_elem_bt[i]  = T_FLOAT; break;
+            case 'I': in_elem_bt[i]  = T_INT; break;
+            case 'J': in_elem_bt[i]  = T_LONG; break;
+            case 'S': in_elem_bt[i]  = T_SHORT; break;
+            case 'Z': in_elem_bt[i]  = T_BOOLEAN; break;
+            default: ShouldNotReachHere();
+          }
+        }
+      } else {
+        out_sig_bt[argc++] = in_sig_bt[i];
+        in_elem_bt[i] = T_VOID;
+      }
+      if (in_sig_bt[i] != T_VOID) {
+        assert(in_sig_bt[i] == ss.type(), "must match");
+        ss.next();
+      }
+    }
   }
 
   // Now figure out where the args must be stored and how much stack space
@@ -1866,6 +2110,35 @@
   int out_arg_slots;
   out_arg_slots = c_calling_convention(out_sig_bt, out_regs, total_c_args);
 
+  if (is_critical_native) {
+    // Critical natives may have to call out so they need a save area
+    // for register arguments.
+    int double_slots = 0;
+    int single_slots = 0;
+    for ( int i = 0; i < total_in_args; i++) {
+      if (in_regs[i].first()->is_Register()) {
+        const Register reg = in_regs[i].first()->as_Register();
+        switch (in_sig_bt[i]) {
+          case T_ARRAY:
+          case T_BOOLEAN:
+          case T_BYTE:
+          case T_SHORT:
+          case T_CHAR:
+          case T_INT:  assert(reg->is_in(), "don't need to save these"); break;
+          case T_LONG: if (reg->is_global()) double_slots++; break;
+          default:  ShouldNotReachHere();
+        }
+      } else if (in_regs[i].first()->is_FloatRegister()) {
+        switch (in_sig_bt[i]) {
+          case T_FLOAT:  single_slots++; break;
+          case T_DOUBLE: double_slots++; break;
+          default:  ShouldNotReachHere();
+        }
+      }
+    }
+    total_save_slots = double_slots * 2 + single_slots;
+  }
+
   // Compute framesize for the wrapper.  We need to handlize all oops in
   // registers. We must create space for them here that is disjoint from
   // the windowed save area because we have no control over when we might
@@ -1885,12 +2158,11 @@
 
   // Now the space for the inbound oop handle area
 
-  int oop_handle_offset = stack_slots;
-  stack_slots += 6*VMRegImpl::slots_per_word;
+  int oop_handle_offset = round_to(stack_slots, 2);
+  stack_slots += total_save_slots;
 
   // Now any space we need for handlizing a klass if static method
 
-  int oop_temp_slot_offset = 0;
   int klass_slot_offset = 0;
   int klass_offset = -1;
   int lock_slot_offset = 0;
@@ -1954,6 +2226,10 @@
 
   __ verify_thread();
 
+  if (is_critical_native) {
+    check_needs_gc_for_critical_native(masm, stack_slots,  total_in_args,
+                                       oop_handle_offset, oop_maps, in_regs, in_sig_bt);
+  }
 
   //
   // We immediately shuffle the arguments so that any vm call we have to
@@ -1982,7 +2258,6 @@
   // caller.
   //
   OopMap* map = new OopMap(stack_slots * 2, 0 /* arg_slots*/);
-  int c_arg = total_c_args - 1;
   // Record sp-based slot for receiver on stack for non-static methods
   int receiver_offset = -1;
 
@@ -2002,7 +2277,7 @@
 
 #endif /* ASSERT */
 
-  for ( int i = total_in_args - 1; i >= 0 ; i--, c_arg-- ) {
+  for ( int i = total_in_args - 1, c_arg = total_c_args - 1; i >= 0 ; i--, c_arg-- ) {
 
 #ifdef ASSERT
     if (in_regs[i].first()->is_Register()) {
@@ -2019,7 +2294,13 @@
 
     switch (in_sig_bt[i]) {
       case T_ARRAY:
+        if (is_critical_native) {
+          unpack_array_argument(masm, in_regs[i], in_elem_bt[i], out_regs[c_arg], out_regs[c_arg - 1]);
+          c_arg--;
+          break;
+        }
       case T_OBJECT:
+        assert(!is_critical_native, "no oop arguments");
         object_move(masm, map, oop_handle_offset, stack_slots, in_regs[i], out_regs[c_arg],
                     ((i == 0) && (!is_static)),
                     &receiver_offset);
@@ -2029,7 +2310,7 @@
 
       case T_FLOAT:
         float_move(masm, in_regs[i], out_regs[c_arg]);
-          break;
+        break;
 
       case T_DOUBLE:
         assert( i + 1 < total_in_args &&
@@ -2051,7 +2332,7 @@
 
   // Pre-load a static method's oop into O1.  Used both by locking code and
   // the normal JNI call code.
-  if (method->is_static()) {
+  if (method->is_static() && !is_critical_native) {
     __ set_oop_constant(JNIHandles::make_local(Klass::cast(method->method_holder())->java_mirror()), O1);
 
     // Now handlize the static class mirror in O1.  It's known not-null.
@@ -2064,13 +2345,13 @@
   const Register L6_handle = L6;
 
   if (method->is_synchronized()) {
+    assert(!is_critical_native, "unhandled");
     __ mov(O1, L6_handle);
   }
 
   // We have all of the arguments setup at this point. We MUST NOT touch any Oregs
   // except O6/O7. So if we must call out we must push a new frame. We immediately
   // push a new frame and flush the windows.
-
 #ifdef _LP64
   intptr_t thepc = (intptr_t) __ pc();
   {
@@ -2202,32 +2483,28 @@
   }
 
   // get JNIEnv* which is first argument to native
-
-  __ add(G2_thread, in_bytes(JavaThread::jni_environment_offset()), O0);
+  if (!is_critical_native) {
+    __ add(G2_thread, in_bytes(JavaThread::jni_environment_offset()), O0);
+  }
 
   // Use that pc we placed in O7 a while back as the current frame anchor
-
   __ set_last_Java_frame(SP, O7);
 
+  // We flushed the windows ages ago now mark them as flushed before transitioning.
+  __ set(JavaFrameAnchor::flushed, G3_scratch);
+  __ st(G3_scratch, G2_thread, JavaThread::frame_anchor_offset() + JavaFrameAnchor::flags_offset());
+
   // Transition from _thread_in_Java to _thread_in_native.
   __ set(_thread_in_native, G3_scratch);
-  __ st(G3_scratch, G2_thread, JavaThread::thread_state_offset());
-
-  // We flushed the windows ages ago now mark them as flushed
-
-  // mark windows as flushed
-  __ set(JavaFrameAnchor::flushed, G3_scratch);
-
-  Address flags(G2_thread, JavaThread::frame_anchor_offset() + JavaFrameAnchor::flags_offset());
 
 #ifdef _LP64
-  AddressLiteral dest(method->native_function());
+  AddressLiteral dest(native_func);
   __ relocate(relocInfo::runtime_call_type);
   __ jumpl_to(dest, O7, O7);
 #else
-  __ call(method->native_function(), relocInfo::runtime_call_type);
+  __ call(native_func, relocInfo::runtime_call_type);
 #endif
-  __ delayed()->st(G3_scratch, flags);
+  __ delayed()->st(G3_scratch, G2_thread, JavaThread::thread_state_offset());
 
   __ restore_thread(L7_thread_cache); // restore G2_thread
 
@@ -2259,6 +2536,7 @@
     ShouldNotReachHere();
   }
 
+  Label after_transition;
   // must we block?
 
   // Block, if necessary, before resuming in _thread_in_Java state.
@@ -2303,22 +2581,34 @@
     // a distinct one for this pc
     //
     save_native_result(masm, ret_type, stack_slots);
-    __ call_VM_leaf(L7_thread_cache,
-                    CAST_FROM_FN_PTR(address, JavaThread::check_special_condition_for_native_trans),
-                    G2_thread);
+    if (!is_critical_native) {
+      __ call_VM_leaf(L7_thread_cache,
+                      CAST_FROM_FN_PTR(address, JavaThread::check_special_condition_for_native_trans),
+                      G2_thread);
+    } else {
+      __ call_VM_leaf(L7_thread_cache,
+                      CAST_FROM_FN_PTR(address, JavaThread::check_special_condition_for_native_trans_and_transition),
+                      G2_thread);
+    }
 
     // Restore any method result value
     restore_native_result(masm, ret_type, stack_slots);
+
+    if (is_critical_native) {
+      // The call above performed the transition to thread_in_Java so
+      // skip the transition logic below.
+      __ ba(after_transition);
+      __ delayed()->nop();
+    }
+
     __ bind(no_block);
   }
 
   // thread state is thread_in_native_trans. Any safepoint blocking has already
   // happened so we can now change state to _thread_in_Java.
-
-
   __ set(_thread_in_Java, G3_scratch);
   __ st(G3_scratch, G2_thread, JavaThread::thread_state_offset());
-
+  __ bind(after_transition);
 
   Label no_reguard;
   __ ld(G2_thread, JavaThread::stack_guard_state_offset(), G3_scratch);
@@ -2416,12 +2706,14 @@
       __ verify_oop(I0);
   }
 
-  // reset handle block
-  __ ld_ptr(G2_thread, in_bytes(JavaThread::active_handles_offset()), L5);
-  __ st_ptr(G0, L5, JNIHandleBlock::top_offset_in_bytes());
-
-  __ ld_ptr(G2_thread, in_bytes(Thread::pending_exception_offset()), G3_scratch);
-  check_forward_pending_exception(masm, G3_scratch);
+  if (!is_critical_native) {
+    // reset handle block
+    __ ld_ptr(G2_thread, in_bytes(JavaThread::active_handles_offset()), L5);
+    __ st_ptr(G0, L5, JNIHandleBlock::top_offset_in_bytes());
+
+    __ ld_ptr(G2_thread, in_bytes(Thread::pending_exception_offset()), G3_scratch);
+    check_forward_pending_exception(masm, G3_scratch);
+  }
 
 
   // Return
@@ -2450,6 +2742,10 @@
                                             (is_static ? in_ByteSize(klass_offset) : in_ByteSize(receiver_offset)),
                                             in_ByteSize(lock_offset),
                                             oop_maps);
+
+  if (is_critical_native) {
+    nm->set_lazy_critical_native(true);
+  }
   return nm;
 
 }
@@ -2473,17 +2769,6 @@
 static int  fp_offset[ConcreteRegisterImpl::number_of_registers] = { 0 };
 static bool offsets_initialized = false;
 
-static VMRegPair reg64_to_VMRegPair(Register r) {
-  VMRegPair ret;
-  if (wordSize == 8) {
-    ret.set2(r->as_VMReg());
-  } else {
-    ret.set_pair(r->successor()->as_VMReg(), r->as_VMReg());
-  }
-  return ret;
-}
-
-
 nmethod *SharedRuntime::generate_dtrace_nmethod(
     MacroAssembler *masm, methodHandle method) {
 
--- a/hotspot/src/cpu/x86/vm/c1_CodeStubs_x86.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/cpu/x86/vm/c1_CodeStubs_x86.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -520,7 +520,7 @@
   __ load_klass(tmp_reg, src_reg);
 
   Address ref_type_adr(tmp_reg, instanceKlass::reference_type_offset());
-  __ cmpl(ref_type_adr, REF_NONE);
+  __ cmpb(ref_type_adr, REF_NONE);
   __ jcc(Assembler::equal, _continuation);
 
   // Is marking active?
--- a/hotspot/src/cpu/x86/vm/c2_globals_x86.hpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/cpu/x86/vm/c2_globals_x86.hpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -44,7 +44,7 @@
 #else
 define_pd_global(bool, ProfileInterpreter,           true);
 #endif // CC_INTERP
-define_pd_global(bool, TieredCompilation,            true);
+define_pd_global(bool, TieredCompilation,            trueInTiered);
 define_pd_global(intx, CompileThreshold,             10000);
 define_pd_global(intx, BackEdgeThreshold,            100000);
 
--- a/hotspot/src/cpu/x86/vm/frame_x86.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/cpu/x86/vm/frame_x86.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -28,6 +28,7 @@
 #include "oops/markOop.hpp"
 #include "oops/methodOop.hpp"
 #include "oops/oop.inline.hpp"
+#include "prims/methodHandles.hpp"
 #include "runtime/frame.inline.hpp"
 #include "runtime/handles.inline.hpp"
 #include "runtime/javaCalls.hpp"
--- a/hotspot/src/cpu/x86/vm/methodHandles_x86.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/cpu/x86/vm/methodHandles_x86.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -2364,23 +2364,19 @@
 
       // grab another temp
       Register rsi_temp = rsi;
-      { if (rsi_temp == saved_last_sp)  __ push(saved_last_sp); }
-      // (preceding push must be done after argslot address is taken!)
-#define UNPUSH_RSI \
-      { if (rsi_temp == saved_last_sp)  __ pop(saved_last_sp); }
 
       // arx_argslot points both to the array and to the first output arg
       vmarg = Address(rax_argslot, 0);
 
       // Get the array value.
-      Register  rsi_array       = rsi_temp;
+      Register  rdi_array       = rdi_temp;
       Register  rdx_array_klass = rdx_temp;
       BasicType elem_type = ek_adapter_opt_spread_type(ek);
       int       elem_slots = type2size[elem_type];  // 1 or 2
       int       array_slots = 1;  // array is always a T_OBJECT
       int       length_offset   = arrayOopDesc::length_offset_in_bytes();
       int       elem0_offset    = arrayOopDesc::base_offset_in_bytes(elem_type);
-      __ movptr(rsi_array, vmarg);
+      __ movptr(rdi_array, vmarg);
 
       Label L_array_is_empty, L_insert_arg_space, L_copy_args, L_args_done;
       if (length_can_be_zero) {
@@ -2391,12 +2387,30 @@
           __ testl(rbx_temp, rbx_temp);
           __ jcc(Assembler::notZero, L_skip);
         }
-        __ testptr(rsi_array, rsi_array);
-        __ jcc(Assembler::zero, L_array_is_empty);
+        __ testptr(rdi_array, rdi_array);
+        __ jcc(Assembler::notZero, L_skip);
+
+        // If 'rsi' contains the 'saved_last_sp' (this is only the
+        // case in a 32-bit version of the VM) we have to save 'rsi'
+        // on the stack because later on (at 'L_array_is_empty') 'rsi'
+        // will be overwritten.
+        { if (rsi_temp == saved_last_sp)  __ push(saved_last_sp); }
+        // Also prepare a handy macro which restores 'rsi' if required.
+#define UNPUSH_RSI                                                      \
+        { if (rsi_temp == saved_last_sp)  __ pop(saved_last_sp); }
+
+        __ jmp(L_array_is_empty);
         __ bind(L_skip);
       }
-      __ null_check(rsi_array, oopDesc::klass_offset_in_bytes());
-      __ load_klass(rdx_array_klass, rsi_array);
+      __ null_check(rdi_array, oopDesc::klass_offset_in_bytes());
+      __ load_klass(rdx_array_klass, rdi_array);
+
+      // Save 'rsi' if required (see comment above).  Do this only
+      // after the null check such that the exception handler which is
+      // called in the case of a null pointer exception will not be
+      // confused by the extra value on the stack (it expects the
+      // return pointer on top of the stack)
+      { if (rsi_temp == saved_last_sp)  __ push(saved_last_sp); }
 
       // Check the array type.
       Register rbx_klass = rbx_temp;
@@ -2404,18 +2418,18 @@
       load_klass_from_Class(_masm, rbx_klass);
 
       Label ok_array_klass, bad_array_klass, bad_array_length;
-      __ check_klass_subtype(rdx_array_klass, rbx_klass, rdi_temp, ok_array_klass);
+      __ check_klass_subtype(rdx_array_klass, rbx_klass, rsi_temp, ok_array_klass);
       // If we get here, the type check failed!
       __ jmp(bad_array_klass);
       __ BIND(ok_array_klass);
 
       // Check length.
       if (length_constant >= 0) {
-        __ cmpl(Address(rsi_array, length_offset), length_constant);
+        __ cmpl(Address(rdi_array, length_offset), length_constant);
       } else {
         Register rbx_vminfo = rbx_temp;
         load_conversion_vminfo(_masm, rbx_vminfo, rcx_amh_conversion);
-        __ cmpl(rbx_vminfo, Address(rsi_array, length_offset));
+        __ cmpl(rbx_vminfo, Address(rdi_array, length_offset));
       }
       __ jcc(Assembler::notEqual, bad_array_length);
 
@@ -2427,9 +2441,9 @@
         __ lea(rdx_argslot_limit, Address(rax_argslot, Interpreter::stackElementSize));
         // 'stack_move' is negative number of words to insert
         // This number already accounts for elem_slots.
-        Register rdi_stack_move = rdi_temp;
-        load_stack_move(_masm, rdi_stack_move, rcx_recv, true);
-        __ cmpptr(rdi_stack_move, 0);
+        Register rsi_stack_move = rsi_temp;
+        load_stack_move(_masm, rsi_stack_move, rcx_recv, true);
+        __ cmpptr(rsi_stack_move, 0);
         assert(stack_move_unit() < 0, "else change this comparison");
         __ jcc(Assembler::less, L_insert_arg_space);
         __ jcc(Assembler::equal, L_copy_args);
@@ -2440,12 +2454,12 @@
         __ jmp(L_args_done);  // no spreading to do
         __ BIND(L_insert_arg_space);
         // come here in the usual case, stack_move < 0 (2 or more spread arguments)
-        Register rsi_temp = rsi_array;  // spill this
-        insert_arg_slots(_masm, rdi_stack_move,
-                         rax_argslot, rbx_temp, rsi_temp);
+        Register rdi_temp = rdi_array;  // spill this
+        insert_arg_slots(_masm, rsi_stack_move,
+                         rax_argslot, rbx_temp, rdi_temp);
         // reload the array since rsi was killed
         // reload from rdx_argslot_limit since rax_argslot is now decremented
-        __ movptr(rsi_array, Address(rdx_argslot_limit, -Interpreter::stackElementSize));
+        __ movptr(rdi_array, Address(rdx_argslot_limit, -Interpreter::stackElementSize));
       } else if (length_constant >= 1) {
         int new_slots = (length_constant * elem_slots) - array_slots;
         insert_arg_slots(_masm, new_slots * stack_move_unit(),
@@ -2468,16 +2482,16 @@
       if (length_constant == -1) {
         // [rax_argslot, rdx_argslot_limit) is the area we are inserting into.
         // Array element [0] goes at rdx_argslot_limit[-wordSize].
-        Register rsi_source = rsi_array;
-        __ lea(rsi_source, Address(rsi_array, elem0_offset));
+        Register rdi_source = rdi_array;
+        __ lea(rdi_source, Address(rdi_array, elem0_offset));
         Register rdx_fill_ptr = rdx_argslot_limit;
         Label loop;
         __ BIND(loop);
         __ addptr(rdx_fill_ptr, -Interpreter::stackElementSize * elem_slots);
         move_typed_arg(_masm, elem_type, true,
-                       Address(rdx_fill_ptr, 0), Address(rsi_source, 0),
-                       rbx_temp, rdi_temp);
-        __ addptr(rsi_source, type2aelembytes(elem_type));
+                       Address(rdx_fill_ptr, 0), Address(rdi_source, 0),
+                       rbx_temp, rsi_temp);
+        __ addptr(rdi_source, type2aelembytes(elem_type));
         __ cmpptr(rdx_fill_ptr, rax_argslot);
         __ jcc(Assembler::above, loop);
       } else if (length_constant == 0) {
@@ -2488,8 +2502,8 @@
         for (int index = 0; index < length_constant; index++) {
           slot_offset -= Interpreter::stackElementSize * elem_slots;  // fill backward
           move_typed_arg(_masm, elem_type, true,
-                         Address(rax_argslot, slot_offset), Address(rsi_array, elem_offset),
-                         rbx_temp, rdi_temp);
+                         Address(rax_argslot, slot_offset), Address(rdi_array, elem_offset),
+                         rbx_temp, rsi_temp);
           elem_offset += type2aelembytes(elem_type);
         }
       }
--- a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1091,12 +1091,238 @@
   }
 }
 
+
+static void save_or_restore_arguments(MacroAssembler* masm,
+                                      const int stack_slots,
+                                      const int total_in_args,
+                                      const int arg_save_area,
+                                      OopMap* map,
+                                      VMRegPair* in_regs,
+                                      BasicType* in_sig_bt) {
+  // if map is non-NULL then the code should store the values,
+  // otherwise it should load them.
+  int handle_index = 0;
+  // Save down double word first
+  for ( int i = 0; i < total_in_args; i++) {
+    if (in_regs[i].first()->is_XMMRegister() && in_sig_bt[i] == T_DOUBLE) {
+      int slot = handle_index * VMRegImpl::slots_per_word + arg_save_area;
+      int offset = slot * VMRegImpl::stack_slot_size;
+      handle_index += 2;
+      assert(handle_index <= stack_slots, "overflow");
+      if (map != NULL) {
+        __ movdbl(Address(rsp, offset), in_regs[i].first()->as_XMMRegister());
+      } else {
+        __ movdbl(in_regs[i].first()->as_XMMRegister(), Address(rsp, offset));
+      }
+    }
+    if (in_regs[i].first()->is_Register() && in_sig_bt[i] == T_LONG) {
+      int slot = handle_index * VMRegImpl::slots_per_word + arg_save_area;
+      int offset = slot * VMRegImpl::stack_slot_size;
+      handle_index += 2;
+      assert(handle_index <= stack_slots, "overflow");
+      if (map != NULL) {
+        __ movl(Address(rsp, offset), in_regs[i].first()->as_Register());
+        if (in_regs[i].second()->is_Register()) {
+          __ movl(Address(rsp, offset + 4), in_regs[i].second()->as_Register());
+        }
+      } else {
+        __ movl(in_regs[i].first()->as_Register(), Address(rsp, offset));
+        if (in_regs[i].second()->is_Register()) {
+          __ movl(in_regs[i].second()->as_Register(), Address(rsp, offset + 4));
+        }
+      }
+    }
+  }
+  // Save or restore single word registers
+  for ( int i = 0; i < total_in_args; i++) {
+    if (in_regs[i].first()->is_Register()) {
+      int slot = handle_index++ * VMRegImpl::slots_per_word + arg_save_area;
+      int offset = slot * VMRegImpl::stack_slot_size;
+      assert(handle_index <= stack_slots, "overflow");
+      if (in_sig_bt[i] == T_ARRAY && map != NULL) {
+        map->set_oop(VMRegImpl::stack2reg(slot));;
+      }
+
+      // Value is in an input register pass we must flush it to the stack
+      const Register reg = in_regs[i].first()->as_Register();
+      switch (in_sig_bt[i]) {
+        case T_ARRAY:
+          if (map != NULL) {
+            __ movptr(Address(rsp, offset), reg);
+          } else {
+            __ movptr(reg, Address(rsp, offset));
+          }
+          break;
+        case T_BOOLEAN:
+        case T_CHAR:
+        case T_BYTE:
+        case T_SHORT:
+        case T_INT:
+          if (map != NULL) {
+            __ movl(Address(rsp, offset), reg);
+          } else {
+            __ movl(reg, Address(rsp, offset));
+          }
+          break;
+        case T_OBJECT:
+        default: ShouldNotReachHere();
+      }
+    } else if (in_regs[i].first()->is_XMMRegister()) {
+      if (in_sig_bt[i] == T_FLOAT) {
+        int slot = handle_index++ * VMRegImpl::slots_per_word + arg_save_area;
+        int offset = slot * VMRegImpl::stack_slot_size;
+        assert(handle_index <= stack_slots, "overflow");
+        if (map != NULL) {
+          __ movflt(Address(rsp, offset), in_regs[i].first()->as_XMMRegister());
+        } else {
+          __ movflt(in_regs[i].first()->as_XMMRegister(), Address(rsp, offset));
+        }
+      }
+    } else if (in_regs[i].first()->is_stack()) {
+      if (in_sig_bt[i] == T_ARRAY && map != NULL) {
+        int offset_in_older_frame = in_regs[i].first()->reg2stack() + SharedRuntime::out_preserve_stack_slots();
+        map->set_oop(VMRegImpl::stack2reg(offset_in_older_frame + stack_slots));
+      }
+    }
+  }
+}
+
+// Check GC_locker::needs_gc and enter the runtime if it's true.  This
+// keeps a new JNI critical region from starting until a GC has been
+// forced.  Save down any oops in registers and describe them in an
+// OopMap.
+static void check_needs_gc_for_critical_native(MacroAssembler* masm,
+                                               Register thread,
+                                               int stack_slots,
+                                               int total_c_args,
+                                               int total_in_args,
+                                               int arg_save_area,
+                                               OopMapSet* oop_maps,
+                                               VMRegPair* in_regs,
+                                               BasicType* in_sig_bt) {
+  __ block_comment("check GC_locker::needs_gc");
+  Label cont;
+  __ cmp8(ExternalAddress((address)GC_locker::needs_gc_address()), false);
+  __ jcc(Assembler::equal, cont);
+
+  // Save down any incoming oops and call into the runtime to halt for a GC
+
+  OopMap* map = new OopMap(stack_slots * 2, 0 /* arg_slots*/);
+
+  save_or_restore_arguments(masm, stack_slots, total_in_args,
+                            arg_save_area, map, in_regs, in_sig_bt);
+
+  address the_pc = __ pc();
+  oop_maps->add_gc_map( __ offset(), map);
+  __ set_last_Java_frame(thread, rsp, noreg, the_pc);
+
+  __ block_comment("block_for_jni_critical");
+  __ push(thread);
+  __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::block_for_jni_critical)));
+  __ increment(rsp, wordSize);
+
+  __ get_thread(thread);
+  __ reset_last_Java_frame(thread, false, true);
+
+  save_or_restore_arguments(masm, stack_slots, total_in_args,
+                            arg_save_area, NULL, in_regs, in_sig_bt);
+
+  __ bind(cont);
+#ifdef ASSERT
+  if (StressCriticalJNINatives) {
+    // Stress register saving
+    OopMap* map = new OopMap(stack_slots * 2, 0 /* arg_slots*/);
+    save_or_restore_arguments(masm, stack_slots, total_in_args,
+                              arg_save_area, map, in_regs, in_sig_bt);
+    // Destroy argument registers
+    for (int i = 0; i < total_in_args - 1; i++) {
+      if (in_regs[i].first()->is_Register()) {
+        const Register reg = in_regs[i].first()->as_Register();
+        __ xorptr(reg, reg);
+      } else if (in_regs[i].first()->is_XMMRegister()) {
+        __ xorpd(in_regs[i].first()->as_XMMRegister(), in_regs[i].first()->as_XMMRegister());
+      } else if (in_regs[i].first()->is_FloatRegister()) {
+        ShouldNotReachHere();
+      } else if (in_regs[i].first()->is_stack()) {
+        // Nothing to do
+      } else {
+        ShouldNotReachHere();
+      }
+      if (in_sig_bt[i] == T_LONG || in_sig_bt[i] == T_DOUBLE) {
+        i++;
+      }
+    }
+
+    save_or_restore_arguments(masm, stack_slots, total_in_args,
+                              arg_save_area, NULL, in_regs, in_sig_bt);
+  }
+#endif
+}
+
+// Unpack an array argument into a pointer to the body and the length
+// if the array is non-null, otherwise pass 0 for both.
+static void unpack_array_argument(MacroAssembler* masm, VMRegPair reg, BasicType in_elem_type, VMRegPair body_arg, VMRegPair length_arg) {
+  Register tmp_reg = rax;
+  assert(!body_arg.first()->is_Register() || body_arg.first()->as_Register() != tmp_reg,
+         "possible collision");
+  assert(!length_arg.first()->is_Register() || length_arg.first()->as_Register() != tmp_reg,
+         "possible collision");
+
+  // Pass the length, ptr pair
+  Label is_null, done;
+  VMRegPair tmp(tmp_reg->as_VMReg());
+  if (reg.first()->is_stack()) {
+    // Load the arg up from the stack
+    simple_move32(masm, reg, tmp);
+    reg = tmp;
+  }
+  __ testptr(reg.first()->as_Register(), reg.first()->as_Register());
+  __ jccb(Assembler::equal, is_null);
+  __ lea(tmp_reg, Address(reg.first()->as_Register(), arrayOopDesc::base_offset_in_bytes(in_elem_type)));
+  simple_move32(masm, tmp, body_arg);
+  // load the length relative to the body.
+  __ movl(tmp_reg, Address(tmp_reg, arrayOopDesc::length_offset_in_bytes() -
+                           arrayOopDesc::base_offset_in_bytes(in_elem_type)));
+  simple_move32(masm, tmp, length_arg);
+  __ jmpb(done);
+  __ bind(is_null);
+  // Pass zeros
+  __ xorptr(tmp_reg, tmp_reg);
+  simple_move32(masm, tmp, body_arg);
+  simple_move32(masm, tmp, length_arg);
+  __ bind(done);
+}
+
+
 // ---------------------------------------------------------------------------
 // Generate a native wrapper for a given method.  The method takes arguments
 // in the Java compiled code convention, marshals them to the native
 // convention (handlizes oops, etc), transitions to native, makes the call,
 // returns to java state (possibly blocking), unhandlizes any result and
 // returns.
+//
+// Critical native functions are a shorthand for the use of
+// GetPrimtiveArrayCritical and disallow the use of any other JNI
+// functions.  The wrapper is expected to unpack the arguments before
+// passing them to the callee and perform checks before and after the
+// native call to ensure that they GC_locker
+// lock_critical/unlock_critical semantics are followed.  Some other
+// parts of JNI setup are skipped like the tear down of the JNI handle
+// block and the check for pending exceptions it's impossible for them
+// to be thrown.
+//
+// They are roughly structured like this:
+//    if (GC_locker::needs_gc())
+//      SharedRuntime::block_for_jni_critical();
+//    tranistion to thread_in_native
+//    unpack arrray arguments and call native entry point
+//    check for safepoint in progress
+//    check if any thread suspend flags are set
+//      call into JVM and possible unlock the JNI critical
+//      if a GC was suppressed while in the critical native.
+//    transition back to thread_in_Java
+//    return to caller
+//
 nmethod *SharedRuntime::generate_native_wrapper(MacroAssembler *masm,
                                                 methodHandle method,
                                                 int compile_id,
@@ -1105,6 +1331,13 @@
                                                 BasicType *in_sig_bt,
                                                 VMRegPair *in_regs,
                                                 BasicType ret_type) {
+  bool is_critical_native = true;
+  address native_func = method->critical_native_function();
+  if (native_func == NULL) {
+    native_func = method->native_function();
+    is_critical_native = false;
+  }
+  assert(native_func != NULL, "must have function");
 
   // An OopMap for lock (and class if static)
   OopMapSet *oop_maps = new OopMapSet();
@@ -1115,30 +1348,72 @@
   // we convert the java signature to a C signature by inserting
   // the hidden arguments as arg[0] and possibly arg[1] (static method)
 
-  int total_c_args = total_in_args + 1;
-  if (method->is_static()) {
-    total_c_args++;
+  int total_c_args = total_in_args;
+  if (!is_critical_native) {
+    total_c_args += 1;
+    if (method->is_static()) {
+      total_c_args++;
+    }
+  } else {
+    for (int i = 0; i < total_in_args; i++) {
+      if (in_sig_bt[i] == T_ARRAY) {
+        total_c_args++;
+      }
+    }
   }
 
   BasicType* out_sig_bt = NEW_RESOURCE_ARRAY(BasicType, total_c_args);
-  VMRegPair* out_regs   = NEW_RESOURCE_ARRAY(VMRegPair,   total_c_args);
+  VMRegPair* out_regs   = NEW_RESOURCE_ARRAY(VMRegPair, total_c_args);
+  BasicType* in_elem_bt = NULL;
 
   int argc = 0;
-  out_sig_bt[argc++] = T_ADDRESS;
-  if (method->is_static()) {
-    out_sig_bt[argc++] = T_OBJECT;
+  if (!is_critical_native) {
+    out_sig_bt[argc++] = T_ADDRESS;
+    if (method->is_static()) {
+      out_sig_bt[argc++] = T_OBJECT;
+    }
+
+    for (int i = 0; i < total_in_args ; i++ ) {
+      out_sig_bt[argc++] = in_sig_bt[i];
+    }
+  } else {
+    Thread* THREAD = Thread::current();
+    in_elem_bt = NEW_RESOURCE_ARRAY(BasicType, total_in_args);
+    SignatureStream ss(method->signature());
+    for (int i = 0; i < total_in_args ; i++ ) {
+      if (in_sig_bt[i] == T_ARRAY) {
+        // Arrays are passed as int, elem* pair
+        out_sig_bt[argc++] = T_INT;
+        out_sig_bt[argc++] = T_ADDRESS;
+        Symbol* atype = ss.as_symbol(CHECK_NULL);
+        const char* at = atype->as_C_string();
+        if (strlen(at) == 2) {
+          assert(at[0] == '[', "must be");
+          switch (at[1]) {
+            case 'B': in_elem_bt[i]  = T_BYTE; break;
+            case 'C': in_elem_bt[i]  = T_CHAR; break;
+            case 'D': in_elem_bt[i]  = T_DOUBLE; break;
+            case 'F': in_elem_bt[i]  = T_FLOAT; break;
+            case 'I': in_elem_bt[i]  = T_INT; break;
+            case 'J': in_elem_bt[i]  = T_LONG; break;
+            case 'S': in_elem_bt[i]  = T_SHORT; break;
+            case 'Z': in_elem_bt[i]  = T_BOOLEAN; break;
+            default: ShouldNotReachHere();
+          }
+        }
+      } else {
+        out_sig_bt[argc++] = in_sig_bt[i];
+        in_elem_bt[i] = T_VOID;
+      }
+      if (in_sig_bt[i] != T_VOID) {
+        assert(in_sig_bt[i] == ss.type(), "must match");
+        ss.next();
+      }
+    }
   }
 
-  int i;
-  for (i = 0; i < total_in_args ; i++ ) {
-    out_sig_bt[argc++] = in_sig_bt[i];
-  }
-
-
   // Now figure out where the args must be stored and how much stack space
-  // they require (neglecting out_preserve_stack_slots but space for storing
-  // the 1st six register arguments). It's weird see int_stk_helper.
-  //
+  // they require.
   int out_arg_slots;
   out_arg_slots = c_calling_convention(out_sig_bt, out_regs, total_c_args);
 
@@ -1151,9 +1426,44 @@
   int stack_slots = SharedRuntime::out_preserve_stack_slots() + out_arg_slots;
 
   // Now the space for the inbound oop handle area
+  int total_save_slots = 2 * VMRegImpl::slots_per_word; // 2 arguments passed in registers
+  if (is_critical_native) {
+    // Critical natives may have to call out so they need a save area
+    // for register arguments.
+    int double_slots = 0;
+    int single_slots = 0;
+    for ( int i = 0; i < total_in_args; i++) {
+      if (in_regs[i].first()->is_Register()) {
+        const Register reg = in_regs[i].first()->as_Register();
+        switch (in_sig_bt[i]) {
+          case T_ARRAY:
+          case T_BOOLEAN:
+          case T_BYTE:
+          case T_SHORT:
+          case T_CHAR:
+          case T_INT:  single_slots++; break;
+          case T_LONG: double_slots++; break;
+          default:  ShouldNotReachHere();
+        }
+      } else if (in_regs[i].first()->is_XMMRegister()) {
+        switch (in_sig_bt[i]) {
+          case T_FLOAT:  single_slots++; break;
+          case T_DOUBLE: double_slots++; break;
+          default:  ShouldNotReachHere();
+        }
+      } else if (in_regs[i].first()->is_FloatRegister()) {
+        ShouldNotReachHere();
+      }
+    }
+    total_save_slots = double_slots * 2 + single_slots;
+    // align the save area
+    if (double_slots != 0) {
+      stack_slots = round_to(stack_slots, 2);
+    }
+  }
 
   int oop_handle_offset = stack_slots;
-  stack_slots += 2*VMRegImpl::slots_per_word;
+  stack_slots += total_save_slots;
 
   // Now any space we need for handlizing a klass if static method
 
@@ -1161,7 +1471,6 @@
   int klass_offset = -1;
   int lock_slot_offset = 0;
   bool is_static = false;
-  int oop_temp_slot_offset = 0;
 
   if (method->is_static()) {
     klass_slot_offset = stack_slots;
@@ -1221,7 +1530,7 @@
   // First thing make an ic check to see if we should even be here
 
   // We are free to use all registers as temps without saving them and
-  // restoring them except rbp,. rbp, is the only callee save register
+  // restoring them except rbp. rbp is the only callee save register
   // as far as the interpreter and the compiler(s) are concerned.
 
 
@@ -1230,7 +1539,6 @@
   Label hit;
   Label exception_pending;
 
-
   __ verify_oop(receiver);
   __ cmpptr(ic_reg, Address(receiver, oopDesc::klass_offset_in_bytes()));
   __ jcc(Assembler::equal, hit);
@@ -1292,11 +1600,10 @@
 
   // Generate a new frame for the wrapper.
   __ enter();
-  // -2 because return address is already present and so is saved rbp,
+  // -2 because return address is already present and so is saved rbp
   __ subptr(rsp, stack_size - 2*wordSize);
 
-  // Frame is now completed as far a size and linkage.
-
+  // Frame is now completed as far as size and linkage.
   int frame_complete = ((intptr_t)__ pc()) - start;
 
   // Calculate the difference between rsp and rbp,. We need to know it
@@ -1319,7 +1626,6 @@
   // Compute the rbp, offset for any slots used after the jni call
 
   int lock_slot_rbp_offset = (lock_slot_offset*VMRegImpl::stack_slot_size) - fp_adjustment;
-  int oop_temp_slot_rbp_offset = (oop_temp_slot_offset*VMRegImpl::stack_slot_size) - fp_adjustment;
 
   // We use rdi as a thread pointer because it is callee save and
   // if we load it once it is usable thru the entire wrapper
@@ -1332,6 +1638,10 @@
 
   __ get_thread(thread);
 
+  if (is_critical_native) {
+    check_needs_gc_for_critical_native(masm, thread, stack_slots, total_c_args, total_in_args,
+                                       oop_handle_offset, oop_maps, in_regs, in_sig_bt);
+  }
 
   //
   // We immediately shuffle the arguments so that any vm call we have to
@@ -1353,7 +1663,7 @@
   // vectors we have in our possession. We simply walk the java vector to
   // get the source locations and the c vector to get the destinations.
 
-  int c_arg = method->is_static() ? 2 : 1 ;
+  int c_arg = is_critical_native ? 0 : (method->is_static() ? 2 : 1 );
 
   // Record rsp-based slot for receiver on stack for non-static methods
   int receiver_offset = -1;
@@ -1373,10 +1683,16 @@
   // Are free to temporaries if we have to do  stack to steck moves.
   // All inbound args are referenced based on rbp, and all outbound args via rsp.
 
-  for (i = 0; i < total_in_args ; i++, c_arg++ ) {
+  for (int i = 0; i < total_in_args ; i++, c_arg++ ) {
     switch (in_sig_bt[i]) {
       case T_ARRAY:
+        if (is_critical_native) {
+          unpack_array_argument(masm, in_regs[i], in_elem_bt[i], out_regs[c_arg + 1], out_regs[c_arg]);
+          c_arg++;
+          break;
+        }
       case T_OBJECT:
+        assert(!is_critical_native, "no oop arguments");
         object_move(masm, map, oop_handle_offset, stack_slots, in_regs[i], out_regs[c_arg],
                     ((i == 0) && (!is_static)),
                     &receiver_offset);
@@ -1408,7 +1724,7 @@
 
   // Pre-load a static method's oop into rsi.  Used both by locking code and
   // the normal JNI call code.
-  if (method->is_static()) {
+  if (method->is_static() && !is_critical_native) {
 
     //  load opp into a register
     __ movoop(oop_handle_reg, JNIHandles::make_local(Klass::cast(method->method_holder())->java_mirror()));
@@ -1463,6 +1779,7 @@
 
   // Lock a synchronized method
   if (method->is_synchronized()) {
+    assert(!is_critical_native, "unhandled");
 
 
     const int mark_word_offset = BasicLock::displaced_header_offset_in_bytes();
@@ -1529,14 +1846,15 @@
 
 
   // get JNIEnv* which is first argument to native
-
-  __ lea(rdx, Address(thread, in_bytes(JavaThread::jni_environment_offset())));
-  __ movptr(Address(rsp, 0), rdx);
+  if (!is_critical_native) {
+    __ lea(rdx, Address(thread, in_bytes(JavaThread::jni_environment_offset())));
+    __ movptr(Address(rsp, 0), rdx);
+  }
 
   // Now set thread in native
   __ movl(Address(thread, JavaThread::thread_state_offset()), _thread_in_native);
 
-  __ call(RuntimeAddress(method->native_function()));
+  __ call(RuntimeAddress(native_func));
 
   // WARNING - on Windows Java Natives use pascal calling convention and pop the
   // arguments off of the stack. We could just re-adjust the stack pointer here
@@ -1591,6 +1909,8 @@
     __ fldcw(ExternalAddress(StubRoutines::addr_fpu_cntrl_wrd_std()));
   }
 
+  Label after_transition;
+
   // check for safepoint operation in progress and/or pending suspend requests
   { Label Continue;
 
@@ -1611,17 +1931,29 @@
     //
     save_native_result(masm, ret_type, stack_slots);
     __ push(thread);
-    __ call(RuntimeAddress(CAST_FROM_FN_PTR(address,
-                                            JavaThread::check_special_condition_for_native_trans)));
+    if (!is_critical_native) {
+      __ call(RuntimeAddress(CAST_FROM_FN_PTR(address,
+                                              JavaThread::check_special_condition_for_native_trans)));
+    } else {
+      __ call(RuntimeAddress(CAST_FROM_FN_PTR(address,
+                                              JavaThread::check_special_condition_for_native_trans_and_transition)));
+    }
     __ increment(rsp, wordSize);
     // Restore any method result value
     restore_native_result(masm, ret_type, stack_slots);
 
+    if (is_critical_native) {
+      // The call above performed the transition to thread_in_Java so
+      // skip the transition logic below.
+      __ jmpb(after_transition);
+    }
+
     __ bind(Continue);
   }
 
   // change thread state
   __ movl(Address(thread, JavaThread::thread_state_offset()), _thread_in_Java);
+  __ bind(after_transition);
 
   Label reguard;
   Label reguard_done;
@@ -1710,15 +2042,15 @@
       __ verify_oop(rax);
   }
 
-  // reset handle block
-  __ movptr(rcx, Address(thread, JavaThread::active_handles_offset()));
-
-  __ movptr(Address(rcx, JNIHandleBlock::top_offset_in_bytes()), NULL_WORD);
-
-  // Any exception pending?
-  __ cmpptr(Address(thread, in_bytes(Thread::pending_exception_offset())), (int32_t)NULL_WORD);
-  __ jcc(Assembler::notEqual, exception_pending);
-
+  if (!is_critical_native) {
+    // reset handle block
+    __ movptr(rcx, Address(thread, JavaThread::active_handles_offset()));
+    __ movptr(Address(rcx, JNIHandleBlock::top_offset_in_bytes()), NULL_WORD);
+
+    // Any exception pending?
+    __ cmpptr(Address(thread, in_bytes(Thread::pending_exception_offset())), (int32_t)NULL_WORD);
+    __ jcc(Assembler::notEqual, exception_pending);
+  }
 
   // no exception, we're almost done
 
@@ -1829,16 +2161,18 @@
 
   // BEGIN EXCEPTION PROCESSING
 
-  // Forward  the exception
-  __ bind(exception_pending);
-
-  // remove possible return value from FPU register stack
-  __ empty_FPU_stack();
-
-  // pop our frame
-  __ leave();
-  // and forward the exception
-  __ jump(RuntimeAddress(StubRoutines::forward_exception_entry()));
+  if (!is_critical_native) {
+    // Forward  the exception
+    __ bind(exception_pending);
+
+    // remove possible return value from FPU register stack
+    __ empty_FPU_stack();
+
+    // pop our frame
+    __ leave();
+    // and forward the exception
+    __ jump(RuntimeAddress(StubRoutines::forward_exception_entry()));
+  }
 
   __ flush();
 
@@ -1851,6 +2185,11 @@
                                             (is_static ? in_ByteSize(klass_offset) : in_ByteSize(receiver_offset)),
                                             in_ByteSize(lock_slot_offset*VMRegImpl::stack_slot_size),
                                             oop_maps);
+
+  if (is_critical_native) {
+    nm->set_lazy_critical_native(true);
+  }
+
   return nm;
 
 }
--- a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -938,6 +938,25 @@
   }
 }
 
+static void move_ptr(MacroAssembler* masm, VMRegPair src, VMRegPair dst) {
+  if (src.first()->is_stack()) {
+    if (dst.first()->is_stack()) {
+      // stack to stack
+      __ movq(rax, Address(rbp, reg2offset_in(src.first())));
+      __ movq(Address(rsp, reg2offset_out(dst.first())), rax);
+    } else {
+      // stack to reg
+      __ movq(dst.first()->as_Register(), Address(rbp, reg2offset_in(src.first())));
+    }
+  } else if (dst.first()->is_stack()) {
+    // reg to stack
+    __ movq(Address(rsp, reg2offset_out(dst.first())), src.first()->as_Register());
+  } else {
+    if (dst.first() != src.first()) {
+      __ movq(dst.first()->as_Register(), src.first()->as_Register());
+    }
+  }
+}
 
 // An oop arg. Must pass a handle not the oop itself
 static void object_move(MacroAssembler* masm,
@@ -1152,6 +1171,203 @@
     }
 }
 
+
+static void save_or_restore_arguments(MacroAssembler* masm,
+                                      const int stack_slots,
+                                      const int total_in_args,
+                                      const int arg_save_area,
+                                      OopMap* map,
+                                      VMRegPair* in_regs,
+                                      BasicType* in_sig_bt) {
+  // if map is non-NULL then the code should store the values,
+  // otherwise it should load them.
+  int handle_index = 0;
+  // Save down double word first
+  for ( int i = 0; i < total_in_args; i++) {
+    if (in_regs[i].first()->is_XMMRegister() && in_sig_bt[i] == T_DOUBLE) {
+      int slot = handle_index * VMRegImpl::slots_per_word + arg_save_area;
+      int offset = slot * VMRegImpl::stack_slot_size;
+      handle_index += 2;
+      assert(handle_index <= stack_slots, "overflow");
+      if (map != NULL) {
+        __ movdbl(Address(rsp, offset), in_regs[i].first()->as_XMMRegister());
+      } else {
+        __ movdbl(in_regs[i].first()->as_XMMRegister(), Address(rsp, offset));
+      }
+    }
+    if (in_regs[i].first()->is_Register() &&
+        (in_sig_bt[i] == T_LONG || in_sig_bt[i] == T_ARRAY)) {
+      int slot = handle_index * VMRegImpl::slots_per_word + arg_save_area;
+      int offset = slot * VMRegImpl::stack_slot_size;
+      handle_index += 2;
+      assert(handle_index <= stack_slots, "overflow");
+      if (map != NULL) {
+        __ movq(Address(rsp, offset), in_regs[i].first()->as_Register());
+        if (in_sig_bt[i] == T_ARRAY) {
+          map->set_oop(VMRegImpl::stack2reg(slot));;
+        }
+      } else {
+        __ movq(in_regs[i].first()->as_Register(), Address(rsp, offset));
+      }
+    }
+  }
+  // Save or restore single word registers
+  for ( int i = 0; i < total_in_args; i++) {
+    if (in_regs[i].first()->is_Register()) {
+      int slot = handle_index++ * VMRegImpl::slots_per_word + arg_save_area;
+      int offset = slot * VMRegImpl::stack_slot_size;
+      assert(handle_index <= stack_slots, "overflow");
+
+      // Value is in an input register pass we must flush it to the stack
+      const Register reg = in_regs[i].first()->as_Register();
+      switch (in_sig_bt[i]) {
+        case T_BOOLEAN:
+        case T_CHAR:
+        case T_BYTE:
+        case T_SHORT:
+        case T_INT:
+          if (map != NULL) {
+            __ movl(Address(rsp, offset), reg);
+          } else {
+            __ movl(reg, Address(rsp, offset));
+          }
+          break;
+        case T_ARRAY:
+        case T_LONG:
+          // handled above
+          break;
+        case T_OBJECT:
+        default: ShouldNotReachHere();
+      }
+    } else if (in_regs[i].first()->is_XMMRegister()) {
+      if (in_sig_bt[i] == T_FLOAT) {
+        int slot = handle_index++ * VMRegImpl::slots_per_word + arg_save_area;
+        int offset = slot * VMRegImpl::stack_slot_size;
+        assert(handle_index <= stack_slots, "overflow");
+        if (map != NULL) {
+          __ movflt(Address(rsp, offset), in_regs[i].first()->as_XMMRegister());
+        } else {
+          __ movflt(in_regs[i].first()->as_XMMRegister(), Address(rsp, offset));
+        }
+      }
+    } else if (in_regs[i].first()->is_stack()) {
+      if (in_sig_bt[i] == T_ARRAY && map != NULL) {
+        int offset_in_older_frame = in_regs[i].first()->reg2stack() + SharedRuntime::out_preserve_stack_slots();
+        map->set_oop(VMRegImpl::stack2reg(offset_in_older_frame + stack_slots));
+      }
+    }
+  }
+}
+
+
+// Check GC_locker::needs_gc and enter the runtime if it's true.  This
+// keeps a new JNI critical region from starting until a GC has been
+// forced.  Save down any oops in registers and describe them in an
+// OopMap.
+static void check_needs_gc_for_critical_native(MacroAssembler* masm,
+                                               int stack_slots,
+                                               int total_c_args,
+                                               int total_in_args,
+                                               int arg_save_area,
+                                               OopMapSet* oop_maps,
+                                               VMRegPair* in_regs,
+                                               BasicType* in_sig_bt) {
+  __ block_comment("check GC_locker::needs_gc");
+  Label cont;
+  __ cmp8(ExternalAddress((address)GC_locker::needs_gc_address()), false);
+  __ jcc(Assembler::equal, cont);
+
+  // Save down any incoming oops and call into the runtime to halt for a GC
+
+  OopMap* map = new OopMap(stack_slots * 2, 0 /* arg_slots*/);
+  save_or_restore_arguments(masm, stack_slots, total_in_args,
+                            arg_save_area, map, in_regs, in_sig_bt);
+
+  address the_pc = __ pc();
+  oop_maps->add_gc_map( __ offset(), map);
+  __ set_last_Java_frame(rsp, noreg, the_pc);
+
+  __ block_comment("block_for_jni_critical");
+  __ movptr(c_rarg0, r15_thread);
+  __ mov(r12, rsp); // remember sp
+  __ subptr(rsp, frame::arg_reg_save_area_bytes); // windows
+  __ andptr(rsp, -16); // align stack as required by ABI
+  __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::block_for_jni_critical)));
+  __ mov(rsp, r12); // restore sp
+  __ reinit_heapbase();
+
+  __ reset_last_Java_frame(false, true);
+
+  save_or_restore_arguments(masm, stack_slots, total_in_args,
+                            arg_save_area, NULL, in_regs, in_sig_bt);
+
+  __ bind(cont);
+#ifdef ASSERT
+  if (StressCriticalJNINatives) {
+    // Stress register saving
+    OopMap* map = new OopMap(stack_slots * 2, 0 /* arg_slots*/);
+    save_or_restore_arguments(masm, stack_slots, total_in_args,
+                              arg_save_area, map, in_regs, in_sig_bt);
+    // Destroy argument registers
+    for (int i = 0; i < total_in_args - 1; i++) {
+      if (in_regs[i].first()->is_Register()) {
+        const Register reg = in_regs[i].first()->as_Register();
+        __ xorptr(reg, reg);
+      } else if (in_regs[i].first()->is_XMMRegister()) {
+        __ xorpd(in_regs[i].first()->as_XMMRegister(), in_regs[i].first()->as_XMMRegister());
+      } else if (in_regs[i].first()->is_FloatRegister()) {
+        ShouldNotReachHere();
+      } else if (in_regs[i].first()->is_stack()) {
+        // Nothing to do
+      } else {
+        ShouldNotReachHere();
+      }
+      if (in_sig_bt[i] == T_LONG || in_sig_bt[i] == T_DOUBLE) {
+        i++;
+      }
+    }
+
+    save_or_restore_arguments(masm, stack_slots, total_in_args,
+                              arg_save_area, NULL, in_regs, in_sig_bt);
+  }
+#endif
+}
+
+// Unpack an array argument into a pointer to the body and the length
+// if the array is non-null, otherwise pass 0 for both.
+static void unpack_array_argument(MacroAssembler* masm, VMRegPair reg, BasicType in_elem_type, VMRegPair body_arg, VMRegPair length_arg) {
+  Register tmp_reg = rax;
+  assert(!body_arg.first()->is_Register() || body_arg.first()->as_Register() != tmp_reg,
+         "possible collision");
+  assert(!length_arg.first()->is_Register() || length_arg.first()->as_Register() != tmp_reg,
+         "possible collision");
+
+  // Pass the length, ptr pair
+  Label is_null, done;
+  VMRegPair tmp;
+  tmp.set_ptr(tmp_reg->as_VMReg());
+  if (reg.first()->is_stack()) {
+    // Load the arg up from the stack
+    move_ptr(masm, reg, tmp);
+    reg = tmp;
+  }
+  __ testptr(reg.first()->as_Register(), reg.first()->as_Register());
+  __ jccb(Assembler::equal, is_null);
+  __ lea(tmp_reg, Address(reg.first()->as_Register(), arrayOopDesc::base_offset_in_bytes(in_elem_type)));
+  move_ptr(masm, tmp, body_arg);
+  // load the length relative to the body.
+  __ movl(tmp_reg, Address(tmp_reg, arrayOopDesc::length_offset_in_bytes() -
+                           arrayOopDesc::base_offset_in_bytes(in_elem_type)));
+  move32_64(masm, tmp, length_arg);
+  __ jmpb(done);
+  __ bind(is_null);
+  // Pass zeros
+  __ xorptr(tmp_reg, tmp_reg);
+  move_ptr(masm, tmp, body_arg);
+  move32_64(masm, tmp, length_arg);
+  __ bind(done);
+}
+
 // ---------------------------------------------------------------------------
 // Generate a native wrapper for a given method.  The method takes arguments
 // in the Java compiled code convention, marshals them to the native
@@ -1166,10 +1382,14 @@
                                                 BasicType *in_sig_bt,
                                                 VMRegPair *in_regs,
                                                 BasicType ret_type) {
-  // Native nmethod wrappers never take possesion of the oop arguments.
-  // So the caller will gc the arguments. The only thing we need an
-  // oopMap for is if the call is static
-  //
+  bool is_critical_native = true;
+  address native_func = method->critical_native_function();
+  if (native_func == NULL) {
+    native_func = method->native_function();
+    is_critical_native = false;
+  }
+  assert(native_func != NULL, "must have function");
+
   // An OopMap for lock (and class if static)
   OopMapSet *oop_maps = new OopMapSet();
   intptr_t start = (intptr_t)__ pc();
@@ -1180,27 +1400,72 @@
   // we convert the java signature to a C signature by inserting
   // the hidden arguments as arg[0] and possibly arg[1] (static method)
 
-  int total_c_args = total_in_args + 1;
-  if (method->is_static()) {
-    total_c_args++;
+  int total_c_args = total_in_args;
+  if (!is_critical_native) {
+    total_c_args += 1;
+    if (method->is_static()) {
+      total_c_args++;
+    }
+  } else {
+    for (int i = 0; i < total_in_args; i++) {
+      if (in_sig_bt[i] == T_ARRAY) {
+        total_c_args++;
+      }
+    }
   }
 
   BasicType* out_sig_bt = NEW_RESOURCE_ARRAY(BasicType, total_c_args);
-  VMRegPair* out_regs   = NEW_RESOURCE_ARRAY(VMRegPair,   total_c_args);
+  VMRegPair* out_regs   = NEW_RESOURCE_ARRAY(VMRegPair, total_c_args);
+  BasicType* in_elem_bt = NULL;
 
   int argc = 0;
-  out_sig_bt[argc++] = T_ADDRESS;
-  if (method->is_static()) {
-    out_sig_bt[argc++] = T_OBJECT;
-  }
-
-  for (int i = 0; i < total_in_args ; i++ ) {
-    out_sig_bt[argc++] = in_sig_bt[i];
+  if (!is_critical_native) {
+    out_sig_bt[argc++] = T_ADDRESS;
+    if (method->is_static()) {
+      out_sig_bt[argc++] = T_OBJECT;
+    }
+
+    for (int i = 0; i < total_in_args ; i++ ) {
+      out_sig_bt[argc++] = in_sig_bt[i];
+    }
+  } else {
+    Thread* THREAD = Thread::current();
+    in_elem_bt = NEW_RESOURCE_ARRAY(BasicType, total_in_args);
+    SignatureStream ss(method->signature());
+    for (int i = 0; i < total_in_args ; i++ ) {
+      if (in_sig_bt[i] == T_ARRAY) {
+        // Arrays are passed as int, elem* pair
+        out_sig_bt[argc++] = T_INT;
+        out_sig_bt[argc++] = T_ADDRESS;
+        Symbol* atype = ss.as_symbol(CHECK_NULL);
+        const char* at = atype->as_C_string();
+        if (strlen(at) == 2) {
+          assert(at[0] == '[', "must be");
+          switch (at[1]) {
+            case 'B': in_elem_bt[i]  = T_BYTE; break;
+            case 'C': in_elem_bt[i]  = T_CHAR; break;
+            case 'D': in_elem_bt[i]  = T_DOUBLE; break;
+            case 'F': in_elem_bt[i]  = T_FLOAT; break;
+            case 'I': in_elem_bt[i]  = T_INT; break;
+            case 'J': in_elem_bt[i]  = T_LONG; break;
+            case 'S': in_elem_bt[i]  = T_SHORT; break;
+            case 'Z': in_elem_bt[i]  = T_BOOLEAN; break;
+            default: ShouldNotReachHere();
+          }
+        }
+      } else {
+        out_sig_bt[argc++] = in_sig_bt[i];
+        in_elem_bt[i] = T_VOID;
+      }
+      if (in_sig_bt[i] != T_VOID) {
+        assert(in_sig_bt[i] == ss.type(), "must match");
+        ss.next();
+      }
+    }
   }
 
   // Now figure out where the args must be stored and how much stack space
   // they require.
-  //
   int out_arg_slots;
   out_arg_slots = c_calling_convention(out_sig_bt, out_regs, total_c_args);
 
@@ -1213,13 +1478,47 @@
   int stack_slots = SharedRuntime::out_preserve_stack_slots() + out_arg_slots;
 
   // Now the space for the inbound oop handle area
+  int total_save_slots = 6 * VMRegImpl::slots_per_word;  // 6 arguments passed in registers
+  if (is_critical_native) {
+    // Critical natives may have to call out so they need a save area
+    // for register arguments.
+    int double_slots = 0;
+    int single_slots = 0;
+    for ( int i = 0; i < total_in_args; i++) {
+      if (in_regs[i].first()->is_Register()) {
+        const Register reg = in_regs[i].first()->as_Register();
+        switch (in_sig_bt[i]) {
+          case T_ARRAY:
+          case T_BOOLEAN:
+          case T_BYTE:
+          case T_SHORT:
+          case T_CHAR:
+          case T_INT:  single_slots++; break;
+          case T_LONG: double_slots++; break;
+          default:  ShouldNotReachHere();
+        }
+      } else if (in_regs[i].first()->is_XMMRegister()) {
+        switch (in_sig_bt[i]) {
+          case T_FLOAT:  single_slots++; break;
+          case T_DOUBLE: double_slots++; break;
+          default:  ShouldNotReachHere();
+        }
+      } else if (in_regs[i].first()->is_FloatRegister()) {
+        ShouldNotReachHere();
+      }
+    }
+    total_save_slots = double_slots * 2 + single_slots;
+    // align the save area
+    if (double_slots != 0) {
+      stack_slots = round_to(stack_slots, 2);
+    }
+  }
 
   int oop_handle_offset = stack_slots;
-  stack_slots += 6*VMRegImpl::slots_per_word;
+  stack_slots += total_save_slots;
 
   // Now any space we need for handlizing a klass if static method
 
-  int oop_temp_slot_offset = 0;
   int klass_slot_offset = 0;
   int klass_offset = -1;
   int lock_slot_offset = 0;
@@ -1272,7 +1571,6 @@
 
   int stack_size = stack_slots * VMRegImpl::stack_slot_size;
 
-
   // First thing make an ic check to see if we should even be here
 
   // We are free to use all registers as temps without saving them and
@@ -1283,22 +1581,22 @@
   const Register ic_reg = rax;
   const Register receiver = j_rarg0;
 
-  Label ok;
+  Label hit;
   Label exception_pending;
 
   assert_different_registers(ic_reg, receiver, rscratch1);
   __ verify_oop(receiver);
   __ load_klass(rscratch1, receiver);
   __ cmpq(ic_reg, rscratch1);
-  __ jcc(Assembler::equal, ok);
+  __ jcc(Assembler::equal, hit);
 
   __ jump(RuntimeAddress(SharedRuntime::get_ic_miss_stub()));
 
-  __ bind(ok);
-
   // Verified entry point must be aligned
   __ align(8);
 
+  __ bind(hit);
+
   int vep_offset = ((intptr_t)__ pc()) - start;
 
   // The instruction at the verified entry point must be 5 bytes or longer
@@ -1319,9 +1617,8 @@
   // -2 because return address is already present and so is saved rbp
   __ subptr(rsp, stack_size - 2*wordSize);
 
-    // Frame is now completed as far as size and linkage.
-
-    int frame_complete = ((intptr_t)__ pc()) - start;
+  // Frame is now completed as far as size and linkage.
+  int frame_complete = ((intptr_t)__ pc()) - start;
 
 #ifdef ASSERT
     {
@@ -1341,7 +1638,10 @@
 
   const Register oop_handle_reg = r14;
 
-
+  if (is_critical_native) {
+    check_needs_gc_for_critical_native(masm, stack_slots, total_c_args, total_in_args,
+                                       oop_handle_offset, oop_maps, in_regs, in_sig_bt);
+  }
 
   //
   // We immediately shuffle the arguments so that any vm call we have to
@@ -1390,9 +1690,36 @@
 
 #endif /* ASSERT */
 
-
+  if (is_critical_native) {
+    // The mapping of Java and C arguments passed in registers are
+    // rotated by one, which helps when passing arguments to regular
+    // Java method but for critical natives that creates a cycle which
+    // can cause arguments to be killed before they are used.  Break
+    // the cycle by moving the first argument into a temporary
+    // register.
+    for (int i = 0; i < total_c_args; i++) {
+      if (in_regs[i].first()->is_Register() &&
+          in_regs[i].first()->as_Register() == rdi) {
+        __ mov(rbx, rdi);
+        in_regs[i].set1(rbx->as_VMReg());
+      }
+    }
+  }
+
+  // This may iterate in two different directions depending on the
+  // kind of native it is.  The reason is that for regular JNI natives
+  // the incoming and outgoing registers are offset upwards and for
+  // critical natives they are offset down.
   int c_arg = total_c_args - 1;
-  for ( int i = total_in_args - 1; i >= 0 ; i--, c_arg-- ) {
+  int stride = -1;
+  int init = total_in_args - 1;
+  if (is_critical_native) {
+    // stride forwards
+    c_arg = 0;
+    stride = 1;
+    init = 0;
+  }
+  for (int i = init, count = 0; count < total_in_args; i += stride, c_arg += stride, count++ ) {
 #ifdef ASSERT
     if (in_regs[i].first()->is_Register()) {
       assert(!reg_destroyed[in_regs[i].first()->as_Register()->encoding()], "destroyed reg!");
@@ -1407,7 +1734,20 @@
 #endif /* ASSERT */
     switch (in_sig_bt[i]) {
       case T_ARRAY:
+        if (is_critical_native) {
+          unpack_array_argument(masm, in_regs[i], in_elem_bt[i], out_regs[c_arg + 1], out_regs[c_arg]);
+          c_arg++;
+#ifdef ASSERT
+          if (out_regs[c_arg].first()->is_Register()) {
+            reg_destroyed[out_regs[c_arg].first()->as_Register()->encoding()] = true;
+          } else if (out_regs[c_arg].first()->is_XMMRegister()) {
+            freg_destroyed[out_regs[c_arg].first()->as_XMMRegister()->encoding()] = true;
+          }
+#endif
+          break;
+        }
       case T_OBJECT:
+        assert(!is_critical_native, "no oop arguments");
         object_move(masm, map, oop_handle_offset, stack_slots, in_regs[i], out_regs[c_arg],
                     ((i == 0) && (!is_static)),
                     &receiver_offset);
@@ -1443,7 +1783,7 @@
 
   // Pre-load a static method's oop into r14.  Used both by locking code and
   // the normal JNI call code.
-  if (method->is_static()) {
+  if (method->is_static() && !is_critical_native) {
 
     //  load oop into a register
     __ movoop(oop_handle_reg, JNIHandles::make_local(Klass::cast(method->method_holder())->java_mirror()));
@@ -1509,6 +1849,7 @@
   Label lock_done;
 
   if (method->is_synchronized()) {
+    assert(!is_critical_native, "unhandled");
 
 
     const int mark_word_offset = BasicLock::displaced_header_offset_in_bytes();
@@ -1572,13 +1913,14 @@
 
 
   // get JNIEnv* which is first argument to native
-
-  __ lea(c_rarg0, Address(r15_thread, in_bytes(JavaThread::jni_environment_offset())));
+  if (!is_critical_native) {
+    __ lea(c_rarg0, Address(r15_thread, in_bytes(JavaThread::jni_environment_offset())));
+  }
 
   // Now set thread in native
   __ movl(Address(r15_thread, JavaThread::thread_state_offset()), _thread_in_native);
 
-  __ call(RuntimeAddress(method->native_function()));
+  __ call(RuntimeAddress(native_func));
 
     // Either restore the MXCSR register after returning from the JNI Call
     // or verify that it wasn't changed.
@@ -1634,6 +1976,7 @@
     }
   }
 
+  Label after_transition;
 
   // check for safepoint operation in progress and/or pending suspend requests
   {
@@ -1659,16 +2002,28 @@
     __ mov(r12, rsp); // remember sp
     __ subptr(rsp, frame::arg_reg_save_area_bytes); // windows
     __ andptr(rsp, -16); // align stack as required by ABI
-    __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, JavaThread::check_special_condition_for_native_trans)));
+    if (!is_critical_native) {
+      __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, JavaThread::check_special_condition_for_native_trans)));
+    } else {
+      __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, JavaThread::check_special_condition_for_native_trans_and_transition)));
+    }
     __ mov(rsp, r12); // restore sp
     __ reinit_heapbase();
     // Restore any method result value
     restore_native_result(masm, ret_type, stack_slots);
+
+    if (is_critical_native) {
+      // The call above performed the transition to thread_in_Java so
+      // skip the transition logic below.
+      __ jmpb(after_transition);
+    }
+
     __ bind(Continue);
   }
 
   // change thread state
   __ movl(Address(r15_thread, JavaThread::thread_state_offset()), _thread_in_Java);
+  __ bind(after_transition);
 
   Label reguard;
   Label reguard_done;
@@ -1746,17 +2101,21 @@
       __ verify_oop(rax);
   }
 
-  // reset handle block
-  __ movptr(rcx, Address(r15_thread, JavaThread::active_handles_offset()));
-  __ movptr(Address(rcx, JNIHandleBlock::top_offset_in_bytes()), (int32_t)NULL_WORD);
+  if (!is_critical_native) {
+    // reset handle block
+    __ movptr(rcx, Address(r15_thread, JavaThread::active_handles_offset()));
+    __ movptr(Address(rcx, JNIHandleBlock::top_offset_in_bytes()), (int32_t)NULL_WORD);
+  }
 
   // pop our frame
 
   __ leave();
 
-  // Any exception pending?
-  __ cmpptr(Address(r15_thread, in_bytes(Thread::pending_exception_offset())), (int32_t)NULL_WORD);
-  __ jcc(Assembler::notEqual, exception_pending);
+  if (!is_critical_native) {
+    // Any exception pending?
+    __ cmpptr(Address(r15_thread, in_bytes(Thread::pending_exception_offset())), (int32_t)NULL_WORD);
+    __ jcc(Assembler::notEqual, exception_pending);
+  }
 
   // Return
 
@@ -1764,12 +2123,13 @@
 
   // Unexpected paths are out of line and go here
 
-  // forward the exception
-  __ bind(exception_pending);
-
-  // and forward the exception
-  __ jump(RuntimeAddress(StubRoutines::forward_exception_entry()));
-
+  if (!is_critical_native) {
+    // forward the exception
+    __ bind(exception_pending);
+
+    // and forward the exception
+    __ jump(RuntimeAddress(StubRoutines::forward_exception_entry()));
+  }
 
   // Slow path locking & unlocking
   if (method->is_synchronized()) {
@@ -1876,6 +2236,11 @@
                                             (is_static ? in_ByteSize(klass_offset) : in_ByteSize(receiver_offset)),
                                             in_ByteSize(lock_slot_offset*VMRegImpl::stack_slot_size),
                                             oop_maps);
+
+  if (is_critical_native) {
+    nm->set_lazy_critical_native(true);
+  }
+
   return nm;
 
 }
--- a/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -2978,7 +2978,9 @@
     int frame_complete = __ pc() - start;
 
     // Set up last_Java_sp and last_Java_fp
-    __ set_last_Java_frame(rsp, rbp, NULL);
+    address the_pc = __ pc();
+    __ set_last_Java_frame(rsp, rbp, the_pc);
+    __ andptr(rsp, -(StackAlignmentInBytes));    // Align stack
 
     // Call runtime
     if (arg1 != noreg) {
@@ -2997,7 +2999,7 @@
 
     oop_maps->add_gc_map(__ pc() - start, map);
 
-    __ reset_last_Java_frame(true, false);
+    __ reset_last_Java_frame(true, true);
 
     __ leave(); // required for proper stackwalking of RuntimeStub frame
 
--- a/hotspot/src/os/solaris/vm/os_solaris.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/os/solaris/vm/os_solaris.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -4007,7 +4007,6 @@
     iaInfo->ia_uprilim = cur_class == new_class
                            ? IA_NOCHANGE : (pri_t)iaLimits.maxPrio;
     iaInfo->ia_mode    = IA_NOCHANGE;
-    iaInfo->ia_nice    = cur_class == new_class ? IA_NOCHANGE : NZERO;
     if (ThreadPriorityVerbose) {
       tty->print_cr("IA: [%d...%d] %d->%d\n",
                     iaLimits.minPrio, maxClamped, newPrio, iaInfo->ia_upri);
--- a/hotspot/src/os/windows/vm/os_windows.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/os/windows/vm/os_windows.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -2088,7 +2088,6 @@
 #elif _M_AMD64
   PCONTEXT ctx = exceptionInfo->ContextRecord;
   address pc = (address)ctx->Rip;
-  NOT_PRODUCT(Events::log("idiv overflow exception at " INTPTR_FORMAT , pc));
   assert(pc[0] == 0xF7, "not an idiv opcode");
   assert((pc[1] & ~0x7) == 0xF8, "cannot handle non-register operands");
   assert(ctx->Rax == min_jint, "unexpected idiv exception");
@@ -2100,7 +2099,6 @@
 #else
   PCONTEXT ctx = exceptionInfo->ContextRecord;
   address pc = (address)ctx->Eip;
-  NOT_PRODUCT(Events::log("idiv overflow exception at " INTPTR_FORMAT , pc));
   assert(pc[0] == 0xF7, "not an idiv opcode");
   assert((pc[1] & ~0x7) == 0xF8, "cannot handle non-register operands");
   assert(ctx->Eax == min_jint, "unexpected idiv exception");
@@ -5336,4 +5334,3 @@
 }
 
 #endif
-
--- a/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -362,7 +362,7 @@
 }
 
 intptr_t* _get_previous_fp() {
-#if defined(SPARC_WORKS) || defined(__clang__)
+#if defined(SPARC_WORKS) || defined(__clang__) || defined(__llvm__)
   register intptr_t **ebp;
   __asm__("mov %%"SPELL_REG_FP", %0":"=r"(ebp));
 #else
--- a/hotspot/src/share/tools/ProjectCreator/BuildConfig.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/tools/ProjectCreator/BuildConfig.java	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -243,6 +243,7 @@
         sysDefines.add("_WINDOWS");
         sysDefines.add("HOTSPOT_BUILD_USER=\\\""+System.getProperty("user.name")+"\\\"");
         sysDefines.add("HOTSPOT_BUILD_TARGET=\\\""+get("Build")+"\\\"");
+        sysDefines.add("INCLUDE_TRACE");
         sysDefines.add("_JNI_IMPLEMENTATION_");
         if (vars.get("PlatformName").equals("Win32")) {
             sysDefines.add("HOTSPOT_LIB_ARCH=\\\"i386\\\"");
--- a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1592,6 +1592,7 @@
   // this happened while running the JCK invokevirtual tests under doit.  TKR
   ciMethod* cha_monomorphic_target = NULL;
   ciMethod* exact_target = NULL;
+  Value better_receiver = NULL;
   if (UseCHA && DeoptC1 && klass->is_loaded() && target->is_loaded() &&
       !target->is_method_handle_invoke()) {
     Value receiver = NULL;
@@ -1653,6 +1654,18 @@
       ciInstanceKlass* singleton = NULL;
       if (target->holder()->nof_implementors() == 1) {
         singleton = target->holder()->implementor(0);
+
+        assert(holder->is_interface(), "invokeinterface to non interface?");
+        ciInstanceKlass* decl_interface = (ciInstanceKlass*)holder;
+        // the number of implementors for decl_interface is less or
+        // equal to the number of implementors for target->holder() so
+        // if number of implementors of target->holder() == 1 then
+        // number of implementors for decl_interface is 0 or 1. If
+        // it's 0 then no class implements decl_interface and there's
+        // no point in inlining.
+        if (!holder->is_loaded() || decl_interface->nof_implementors() != 1) {
+          singleton = NULL;
+        }
       }
       if (singleton) {
         cha_monomorphic_target = target->find_monomorphic_target(calling_klass, target->holder(), singleton);
@@ -1667,7 +1680,9 @@
           CheckCast* c = new CheckCast(klass, receiver, copy_state_for_exception());
           c->set_incompatible_class_change_check();
           c->set_direct_compare(klass->is_final());
-          append_split(c);
+          // pass the result of the checkcast so that the compiler has
+          // more accurate type info in the inlinee
+          better_receiver = append_split(c);
         }
       }
     }
@@ -1709,7 +1724,7 @@
       }
       if (!success) {
         // static binding => check if callee is ok
-        success = try_inline(inline_target, (cha_monomorphic_target != NULL) || (exact_target != NULL));
+        success = try_inline(inline_target, (cha_monomorphic_target != NULL) || (exact_target != NULL), better_receiver);
       }
       CHECK_BAILOUT();
 
@@ -3034,7 +3049,7 @@
 }
 
 
-bool GraphBuilder::try_inline(ciMethod* callee, bool holder_known) {
+bool GraphBuilder::try_inline(ciMethod* callee, bool holder_known, Value receiver) {
   // Clear out any existing inline bailout condition
   clear_inline_bailout();
 
@@ -3056,7 +3071,7 @@
   } else if (callee->is_abstract()) {
     INLINE_BAILOUT("abstract")
   } else {
-    return try_inline_full(callee, holder_known);
+    return try_inline_full(callee, holder_known, NULL, receiver);
   }
 }
 
@@ -3405,7 +3420,7 @@
 }
 
 
-bool GraphBuilder::try_inline_full(ciMethod* callee, bool holder_known, BlockBegin* cont_block) {
+bool GraphBuilder::try_inline_full(ciMethod* callee, bool holder_known, BlockBegin* cont_block, Value receiver) {
   assert(!callee->is_native(), "callee must not be native");
   if (CompilationPolicy::policy()->should_not_inline(compilation()->env(), callee)) {
     INLINE_BAILOUT("inlining prohibited by policy");
@@ -3541,6 +3556,9 @@
       Value  arg = caller_state->stack_at_inc(i);
       // NOTE: take base() of arg->type() to avoid problems storing
       // constants
+      if (receiver != NULL && par_no == 0) {
+        arg = receiver;
+      }
       store_local(callee_state, arg, arg->type()->base(), par_no);
     }
   }
@@ -3683,56 +3701,61 @@
       // Get the two MethodHandle inputs from the Phi.
       Value op1 = phi->operand_at(0);
       Value op2 = phi->operand_at(1);
-      ciMethodHandle* mh1 = op1->type()->as_ObjectType()->constant_value()->as_method_handle();
-      ciMethodHandle* mh2 = op2->type()->as_ObjectType()->constant_value()->as_method_handle();
-
-      // Set the callee to have access to the class and signature in
-      // the MethodHandleCompiler.
-      mh1->set_callee(callee);
-      mh1->set_caller(method());
-      mh2->set_callee(callee);
-      mh2->set_caller(method());
-
-      // Get adapters for the MethodHandles.
-      ciMethod* mh1_adapter = mh1->get_method_handle_adapter();
-      ciMethod* mh2_adapter = mh2->get_method_handle_adapter();
-
-      if (mh1_adapter != NULL && mh2_adapter != NULL) {
-        set_inline_cleanup_info();
-
-        // Build the If guard
-        BlockBegin* one = new BlockBegin(next_bci());
-        BlockBegin* two = new BlockBegin(next_bci());
-        BlockBegin* end = new BlockBegin(next_bci());
-        Instruction* iff = append(new If(phi, If::eql, false, op1, one, two, NULL, false));
-        block()->set_end(iff->as_BlockEnd());
-
-        // Connect up the states
-        one->merge(block()->end()->state());
-        two->merge(block()->end()->state());
-
-        // Save the state for the second inlinee
-        ValueStack* state_before = copy_state_before();
-
-        // Parse first adapter
-        _last = _block = one;
-        if (!try_inline_full(mh1_adapter, /*holder_known=*/ true, end)) {
-          restore_inline_cleanup_info();
-          block()->clear_end();  // remove appended iff
-          return false;
+      ObjectType* op1type = op1->type()->as_ObjectType();
+      ObjectType* op2type = op2->type()->as_ObjectType();
+
+      if (op1type->is_constant() && op2type->is_constant()) {
+        ciMethodHandle* mh1 = op1type->constant_value()->as_method_handle();
+        ciMethodHandle* mh2 = op2type->constant_value()->as_method_handle();
+
+        // Set the callee to have access to the class and signature in
+        // the MethodHandleCompiler.
+        mh1->set_callee(callee);
+        mh1->set_caller(method());
+        mh2->set_callee(callee);
+        mh2->set_caller(method());
+
+        // Get adapters for the MethodHandles.
+        ciMethod* mh1_adapter = mh1->get_method_handle_adapter();
+        ciMethod* mh2_adapter = mh2->get_method_handle_adapter();
+
+        if (mh1_adapter != NULL && mh2_adapter != NULL) {
+          set_inline_cleanup_info();
+
+          // Build the If guard
+          BlockBegin* one = new BlockBegin(next_bci());
+          BlockBegin* two = new BlockBegin(next_bci());
+          BlockBegin* end = new BlockBegin(next_bci());
+          Instruction* iff = append(new If(phi, If::eql, false, op1, one, two, NULL, false));
+          block()->set_end(iff->as_BlockEnd());
+
+          // Connect up the states
+          one->merge(block()->end()->state());
+          two->merge(block()->end()->state());
+
+          // Save the state for the second inlinee
+          ValueStack* state_before = copy_state_before();
+
+          // Parse first adapter
+          _last = _block = one;
+          if (!try_inline_full(mh1_adapter, /*holder_known=*/ true, end, NULL)) {
+            restore_inline_cleanup_info();
+            block()->clear_end();  // remove appended iff
+            return false;
+          }
+
+          // Parse second adapter
+          _last = _block = two;
+          _state = state_before;
+          if (!try_inline_full(mh2_adapter, /*holder_known=*/ true, end, NULL)) {
+            restore_inline_cleanup_info();
+            block()->clear_end();  // remove appended iff
+            return false;
+          }
+
+          connect_to_end(end);
+          return true;
         }
-
-        // Parse second adapter
-        _last = _block = two;
-        _state = state_before;
-        if (!try_inline_full(mh2_adapter, /*holder_known=*/ true, end)) {
-          restore_inline_cleanup_info();
-          block()->clear_end();  // remove appended iff
-          return false;
-        }
-
-        connect_to_end(end);
-        return true;
       }
     }
   }
--- a/hotspot/src/share/vm/c1/c1_GraphBuilder.hpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.hpp	Mon Feb 13 14:31:32 2012 +0000
@@ -337,9 +337,9 @@
   void fill_sync_handler(Value lock, BlockBegin* sync_handler, bool default_handler = false);
 
   // inliners
-  bool try_inline(           ciMethod* callee, bool holder_known);
+  bool try_inline(           ciMethod* callee, bool holder_known, Value receiver = NULL);
   bool try_inline_intrinsics(ciMethod* callee);
-  bool try_inline_full(      ciMethod* callee, bool holder_known, BlockBegin* cont_block = NULL);
+  bool try_inline_full(      ciMethod* callee, bool holder_known, BlockBegin* cont_block, Value receiver);
   bool try_inline_jsr(int jsr_dest_bci);
 
   // JSR 292 support
--- a/hotspot/src/share/vm/c1/c1_Runtime1.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/c1/c1_Runtime1.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -597,7 +597,6 @@
 
 JRT_ENTRY(void, Runtime1::throw_range_check_exception(JavaThread* thread, int index))
   NOT_PRODUCT(_throw_range_check_exception_count++;)
-  Events::log("throw_range_check");
   char message[jintAsStringSize];
   sprintf(message, "%d", index);
   SharedRuntime::throw_and_post_jvmti_exception(thread, vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), message);
@@ -606,7 +605,6 @@
 
 JRT_ENTRY(void, Runtime1::throw_index_exception(JavaThread* thread, int index))
   NOT_PRODUCT(_throw_index_exception_count++;)
-  Events::log("throw_index");
   char message[16];
   sprintf(message, "%d", index);
   SharedRuntime::throw_and_post_jvmti_exception(thread, vmSymbols::java_lang_IndexOutOfBoundsException(), message);
@@ -804,11 +802,7 @@
   // Note also that in the presence of inlining it is not guaranteed
   // that caller_method() == caller_code->method()
 
-
   int bci = vfst.bci();
-
-  Events::log("patch_code @ " INTPTR_FORMAT , caller_frame.pc());
-
   Bytecodes::Code code = caller_method()->java_code_at(bci);
 
 #ifndef PRODUCT
--- a/hotspot/src/share/vm/c1/c1_ValueMap.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/c1/c1_ValueMap.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -125,6 +125,7 @@
             // otherwise it is possible that they are not evaluated
             f->pin(Instruction::PinGlobalValueNumbering);
           }
+          assert(x->type()->tag() == f->type()->tag(), "should have same type");
 
           return f;
 
--- a/hotspot/src/share/vm/ci/bcEscapeAnalyzer.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/ci/bcEscapeAnalyzer.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -359,7 +359,7 @@
       case Bytecodes::_nop:
         break;
       case Bytecodes::_aconst_null:
-        state.apush(empty_map);
+        state.apush(unknown_obj);
         break;
       case Bytecodes::_iconst_m1:
       case Bytecodes::_iconst_0:
@@ -392,6 +392,8 @@
         if (tag.is_long() || tag.is_double()) {
           // Only longs and doubles use 2 stack slots.
           state.lpush();
+        } else if (tag.basic_type() == T_OBJECT) {
+          state.apush(unknown_obj);
         } else {
           state.spush();
         }
--- a/hotspot/src/share/vm/ci/ciEnv.hpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/ci/ciEnv.hpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -284,6 +284,20 @@
   // Return state of appropriate compilability
   int compilable() { return _compilable; }
 
+  const char* retry_message() const {
+    switch (_compilable) {
+      case ciEnv::MethodCompilable_not_at_tier:
+        return "retry at different tier";
+      case ciEnv::MethodCompilable_never:
+        return "not retryable";
+      case ciEnv::MethodCompilable:
+        return NULL;
+      default:
+        ShouldNotReachHere();
+        return NULL;
+    }
+  }
+
   bool break_at_compile() { return _break_at_compile; }
   void set_break_at_compile(bool z) { _break_at_compile = z; }
 
--- a/hotspot/src/share/vm/classfile/dictionary.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/classfile/dictionary.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -618,7 +618,8 @@
   ResourceMark rm;
   HandleMark   hm;
 
-  tty->print_cr("Java system dictionary (classes=%d)", number_of_entries());
+  tty->print_cr("Java system dictionary (table_size=%d, classes=%d)",
+                 table_size(), number_of_entries());
   tty->print_cr("^ indicates that initiating loader is different from "
                 "defining loader");
 
--- a/hotspot/src/share/vm/classfile/systemDictionary.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/classfile/systemDictionary.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -64,6 +64,9 @@
 
 
 int         SystemDictionary::_number_of_modifications = 0;
+int         SystemDictionary::_sdgeneration               = 0;
+const int   SystemDictionary::_primelist[_prime_array_size] = {1009,2017,4049,5051,10103,
+              20201,40423,99991};
 
 oop         SystemDictionary::_system_loader_lock_obj     =  NULL;
 
@@ -1178,8 +1181,8 @@
 
 klassOop SystemDictionary::find_shared_class(Symbol* class_name) {
   if (shared_dictionary() != NULL) {
-    unsigned int d_hash = dictionary()->compute_hash(class_name, Handle());
-    int d_index = dictionary()->hash_to_index(d_hash);
+    unsigned int d_hash = shared_dictionary()->compute_hash(class_name, Handle());
+    int d_index = shared_dictionary()->hash_to_index(d_hash);
     return shared_dictionary()->find_shared_class(d_index, d_hash, class_name);
   } else {
     return NULL;
@@ -1750,7 +1753,21 @@
   placeholders()->oops_do(blk);
 }
 
-
+// Calculate a "good" systemdictionary size based
+// on predicted or current loaded classes count
+int SystemDictionary::calculate_systemdictionary_size(int classcount) {
+  int newsize = _old_default_sdsize;
+  if ((classcount > 0)  && !DumpSharedSpaces) {
+    int desiredsize = classcount/_average_depth_goal;
+    for (newsize = _primelist[_sdgeneration]; _sdgeneration < _prime_array_size -1;
+         newsize = _primelist[++_sdgeneration]) {
+      if (desiredsize <=  newsize) {
+        break;
+      }
+    }
+  }
+  return newsize;
+}
 bool SystemDictionary::do_unloading(BoolObjectClosure* is_alive) {
   bool result = dictionary()->do_unloading(is_alive);
   constraints()->purge_loader_constraints(is_alive);
@@ -1873,7 +1890,8 @@
   // Allocate arrays
   assert(dictionary() == NULL,
          "SystemDictionary should only be initialized once");
-  _dictionary          = new Dictionary(_nof_buckets);
+  _sdgeneration        = 0;
+  _dictionary          = new Dictionary(calculate_systemdictionary_size(PredictedLoadedClassCount));
   _placeholders        = new PlaceholderTable(_nof_buckets);
   _number_of_modifications = 0;
   _loader_constraints  = new LoaderConstraintTable(_loader_constraint_size);
--- a/hotspot/src/share/vm/classfile/systemDictionary.hpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/classfile/systemDictionary.hpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -346,6 +346,8 @@
   // loaders.  Returns "true" iff something was unloaded.
   static bool do_unloading(BoolObjectClosure* is_alive);
 
+  static int calculate_systemdictionary_size(int loadedclasses);
+
   // Applies "f->do_oop" to all root oops in the system dictionary.
   static void oops_do(OopClosure* f);
 
@@ -538,12 +540,20 @@
     _loader_constraint_size = 107,                     // number of entries in constraint table
     _resolution_error_size  = 107,                     // number of entries in resolution error table
     _invoke_method_size     = 139,                     // number of entries in invoke method table
-    _nof_buckets            = 1009                     // number of buckets in hash table
+    _nof_buckets            = 1009,                    // number of buckets in hash table for placeholders
+    _old_default_sdsize     = 1009,                    // backward compat for system dictionary size
+    _prime_array_size       = 8,                       // array of primes for system dictionary size
+    _average_depth_goal     = 3                        // goal for lookup length
   };
 
 
   // Static variables
 
+  // hashtable sizes for system dictionary to allow growth
+  // prime numbers for system dictionary size
+  static int                     _sdgeneration;
+  static const int               _primelist[_prime_array_size];
+
   // Hashtable holding loaded classes.
   static Dictionary*            _dictionary;
 
--- a/hotspot/src/share/vm/code/compiledIC.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/code/compiledIC.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -165,7 +165,6 @@
                    instruction_address(), method->print_value_string(), entry);
   }
 
-  Events::log("compiledIC " INTPTR_FORMAT " --> megamorphic " INTPTR_FORMAT, this, (address)method());
   // We can't check this anymore. With lazy deopt we could have already
   // cleaned this IC entry before we even return. This is possible if
   // we ran out of space in the inline cache buffer trying to do the
--- a/hotspot/src/share/vm/code/nmethod.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/code/nmethod.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -462,6 +462,7 @@
   _speculatively_disconnected = 0;
   _has_unsafe_access          = 0;
   _has_method_handle_invokes  = 0;
+  _lazy_critical_native       = 0;
   _marked_for_deoptimization  = 0;
   _lock_count                 = 0;
   _stack_traversal_mark       = 0;
@@ -704,7 +705,6 @@
       xtty->tail("print_native_nmethod");
     }
   }
-  Events::log("Create nmethod " INTPTR_FORMAT, this);
 }
 
 // For dtrace wrappers
@@ -781,7 +781,6 @@
       xtty->tail("print_dtrace_nmethod");
     }
   }
-  Events::log("Create nmethod " INTPTR_FORMAT, this);
 }
 #endif // def HAVE_DTRACE_H
 
@@ -889,13 +888,6 @@
   if (printnmethods || PrintDebugInfo || PrintRelocations || PrintDependencies || PrintExceptionHandlers) {
     print_nmethod(printnmethods);
   }
-
-  // Note: Do not verify in here as the CodeCache_lock is
-  //       taken which would conflict with the CompiledIC_lock
-  //       which taken during the verification of call sites.
-  //       (was bug - gri 10/25/99)
-
-  Events::log("Create nmethod " INTPTR_FORMAT, this);
 }
 
 
@@ -1386,7 +1378,7 @@
   assert_locked_or_safepoint(CodeCache_lock);
 
   // completely deallocate this method
-  EventMark m("flushing nmethod " INTPTR_FORMAT " %s", this, "");
+  Events::log(JavaThread::current(), "flushing nmethod " INTPTR_FORMAT, this);
   if (PrintMethodFlushing) {
     tty->print_cr("*flushing nmethod %3d/" INTPTR_FORMAT ". Live blobs:" UINT32_FORMAT "/Free CodeCache:" SIZE_FORMAT "Kb",
         _compile_id, this, CodeCache::nof_blobs(), CodeCache::unallocated_capacity()/1024);
--- a/hotspot/src/share/vm/code/nmethod.hpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/code/nmethod.hpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -175,6 +175,7 @@
   // set during construction
   unsigned int _has_unsafe_access:1;         // May fault due to unsafe access.
   unsigned int _has_method_handle_invokes:1; // Has this method MethodHandle invokes?
+  unsigned int _lazy_critical_native:1;      // Lazy JNI critical native
 
   // Protected by Patching_lock
   unsigned char _state;                      // {alive, not_entrant, zombie, unloaded}
@@ -430,7 +431,10 @@
   void  set_has_method_handle_invokes(bool z)     { _has_method_handle_invokes = z; }
 
   bool  is_speculatively_disconnected() const     { return _speculatively_disconnected; }
-  void  set_speculatively_disconnected(bool z)     { _speculatively_disconnected = z; }
+  void  set_speculatively_disconnected(bool z)    { _speculatively_disconnected = z; }
+
+  bool  is_lazy_critical_native() const           { return _lazy_critical_native; }
+  void  set_lazy_critical_native(bool z)          { _lazy_critical_native = z; }
 
   int   comp_level() const                        { return _comp_level; }
 
--- a/hotspot/src/share/vm/compiler/compileBroker.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/compiler/compileBroker.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -44,6 +44,7 @@
 #include "runtime/sharedRuntime.hpp"
 #include "runtime/sweeper.hpp"
 #include "utilities/dtrace.hpp"
+#include "utilities/events.hpp"
 #ifdef COMPILER1
 #include "c1/c1_Compiler.hpp"
 #endif
@@ -189,6 +190,43 @@
 GrowableArray<CompilerThread*>* CompileBroker::_method_threads = NULL;
 
 
+class CompilationLog : public StringEventLog {
+ public:
+  CompilationLog() : StringEventLog("Compilation events") {
+  }
+
+  void log_compile(JavaThread* thread, CompileTask* task) {
+    StringLogMessage lm;
+    stringStream msg = lm.stream();
+    // msg.time_stamp().update_to(tty->time_stamp().ticks());
+    task->print_compilation(&msg, true);
+    log(thread, "%s", (const char*)lm);
+  }
+
+  void log_nmethod(JavaThread* thread, nmethod* nm) {
+    log(thread, "nmethod " INTPTR_FORMAT " code ["INTPTR_FORMAT ", " INTPTR_FORMAT "]",
+        nm, nm->code_begin(), nm->code_end());
+  }
+
+  void log_failure(JavaThread* thread, CompileTask* task, const char* reason, const char* retry_message) {
+    StringLogMessage lm;
+    lm.print("%4d   COMPILE SKIPPED: %s", task->compile_id(), reason);
+    if (retry_message != NULL) {
+      lm.append(" (%s)", retry_message);
+    }
+    lm.print("\n");
+    log(thread, "%s", (const char*)lm);
+  }
+};
+
+static CompilationLog* _compilation_log = NULL;
+
+void compileBroker_init() {
+  if (LogEvents) {
+    _compilation_log = new CompilationLog();
+  }
+}
+
 CompileTaskWrapper::CompileTaskWrapper(CompileTask* task) {
   CompilerThread* thread = CompilerThread::current();
   thread->set_task(task);
@@ -326,8 +364,12 @@
 
 // ------------------------------------------------------------------
 // CompileTask::print_compilation_impl
-void CompileTask::print_compilation_impl(outputStream* st, methodOop method, int compile_id, int comp_level, bool is_osr_method, int osr_bci, bool is_blocking, const char* msg) {
-  st->print("%7d ", (int) st->time_stamp().milliseconds());  // print timestamp
+void CompileTask::print_compilation_impl(outputStream* st, methodOop method, int compile_id, int comp_level,
+                                         bool is_osr_method, int osr_bci, bool is_blocking,
+                                         const char* msg, bool short_form) {
+  if (!short_form) {
+    st->print("%7d ", (int) st->time_stamp().milliseconds());  // print timestamp
+  }
   st->print("%4d ", compile_id);    // print compilation number
 
   // For unloaded methods the transition to zombie occurs after the
@@ -370,7 +412,9 @@
   if (msg != NULL) {
     st->print("   %s", msg);
   }
-  st->cr();
+  if (!short_form) {
+    st->cr();
+  }
 }
 
 // ------------------------------------------------------------------
@@ -426,12 +470,12 @@
 
 // ------------------------------------------------------------------
 // CompileTask::print_compilation
-void CompileTask::print_compilation(outputStream* st) {
+void CompileTask::print_compilation(outputStream* st, bool short_form) {
   oop rem = JNIHandles::resolve(method_handle());
   assert(rem != NULL && rem->is_method(), "must be");
   methodOop method = (methodOop) rem;
   bool is_osr_method = osr_bci() != InvocationEntryBci;
-  print_compilation_impl(st, method, compile_id(), comp_level(), is_osr_method, osr_bci(), is_blocking());
+  print_compilation_impl(st, method, compile_id(), comp_level(), is_osr_method, osr_bci(), is_blocking(), NULL, short_form);
 }
 
 // ------------------------------------------------------------------
@@ -1649,6 +1693,10 @@
   CompilerThread* thread = CompilerThread::current();
   ResourceMark rm(thread);
 
+  if (LogEvents) {
+    _compilation_log->log_compile(thread, task);
+  }
+
   // Common flags.
   uint compile_id = task->compile_id();
   int osr_bci = task->osr_bci();
@@ -1717,22 +1765,30 @@
       ci_env.record_method_not_compilable("compile failed", !TieredCompilation);
     }
 
+    // Copy this bit to the enclosing block:
+    compilable = ci_env.compilable();
+
     if (ci_env.failing()) {
-      // Copy this bit to the enclosing block:
-      compilable = ci_env.compilable();
+      const char* retry_message = ci_env.retry_message();
+      if (_compilation_log != NULL) {
+        _compilation_log->log_failure(thread, task, ci_env.failure_reason(), retry_message);
+      }
       if (PrintCompilation) {
-        const char* reason = ci_env.failure_reason();
-        if (compilable == ciEnv::MethodCompilable_not_at_tier) {
-          tty->print_cr("%4d   COMPILE SKIPPED: %s (retry at different tier)", compile_id, reason);
-        } else if (compilable == ciEnv::MethodCompilable_never) {
-          tty->print_cr("%4d   COMPILE SKIPPED: %s (not retryable)", compile_id, reason);
-        } else if (compilable == ciEnv::MethodCompilable) {
-          tty->print_cr("%4d   COMPILE SKIPPED: %s", compile_id, reason);
+        tty->print("%4d   COMPILE SKIPPED: %s", compile_id, ci_env.failure_reason());
+        if (retry_message != NULL) {
+          tty->print(" (%s)", retry_message);
         }
+        tty->cr();
       }
     } else {
       task->mark_success();
       task->set_num_inlined_bytecodes(ci_env.num_inlined_bytecodes());
+      if (_compilation_log != NULL) {
+        nmethod* code = task->code();
+        if (code != NULL) {
+          _compilation_log->log_nmethod(thread, code);
+        }
+      }
     }
   }
   pop_jni_handle_block();
--- a/hotspot/src/share/vm/compiler/compileBroker.hpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/compiler/compileBroker.hpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -98,12 +98,16 @@
   void         set_prev(CompileTask* prev)       { _prev = prev; }
 
 private:
-  static void  print_compilation_impl(outputStream* st, methodOop method, int compile_id, int comp_level, bool is_osr_method = false, int osr_bci = -1, bool is_blocking = false, const char* msg = NULL);
+  static void  print_compilation_impl(outputStream* st, methodOop method, int compile_id, int comp_level,
+                                      bool is_osr_method = false, int osr_bci = -1, bool is_blocking = false,
+                                      const char* msg = NULL, bool short_form = false);
 
 public:
-  void         print_compilation(outputStream* st = tty);
+  void         print_compilation(outputStream* st = tty, bool short_form = false);
   static void  print_compilation(outputStream* st, const nmethod* nm, const char* msg = NULL) {
-    print_compilation_impl(st, nm->method(), nm->compile_id(), nm->comp_level(), nm->is_osr_method(), nm->is_osr_method() ? nm->osr_entry_bci() : -1, /*is_blocking*/ false, msg);
+    print_compilation_impl(st, nm->method(), nm->compile_id(), nm->comp_level(),
+                           nm->is_osr_method(), nm->is_osr_method() ? nm->osr_entry_bci() : -1, /*is_blocking*/ false,
+                           msg);
   }
 
   static void  print_inlining(outputStream* st, ciMethod* method, int inline_level, int bci, const char* msg = NULL);
--- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -5594,6 +5594,7 @@
     GenCollectedHeap::StrongRootsScope srs(gch);
     workers->run_task(&tsk);
   } else {
+    ReferenceProcessorMTDiscoveryMutator mt(ref_processor(), false);
     GenCollectedHeap::StrongRootsScope srs(gch);
     tsk.work(0);
   }
@@ -5608,6 +5609,8 @@
   ResourceMark rm;
   HandleMark   hm;
   GenCollectedHeap* gch = GenCollectedHeap::heap();
+  ReferenceProcessorMTDiscoveryMutator mt(ref_processor(), false);
+
   MarkRefsIntoAndScanClosure
     mrias_cl(_span, ref_processor(), &_markBitMap, &_modUnionTable,
              &_markStack, &_revisitStack, this,
--- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1238,9 +1238,7 @@
   SvcGCMarker sgcm(SvcGCMarker::FULL);
   ResourceMark rm;
 
-  if (PrintHeapAtGC) {
-    Universe::print_heap_before_gc();
-  }
+  print_heap_before_gc();
 
   HRSPhaseSetter x(HRSPhaseFullGC);
   verify_region_sets_optional();
@@ -1492,9 +1490,7 @@
   _hrs.verify_optional();
   verify_region_sets_optional();
 
-  if (PrintHeapAtGC) {
-    Universe::print_heap_after_gc();
-  }
+  print_heap_after_gc();
   g1mm()->update_sizes();
   post_full_gc_dump();
 
@@ -3560,9 +3556,7 @@
   SvcGCMarker sgcm(SvcGCMarker::MINOR);
   ResourceMark rm;
 
-  if (PrintHeapAtGC) {
-    Universe::print_heap_before_gc();
-  }
+  print_heap_before_gc();
 
   HRSPhaseSetter x(HRSPhaseEvacuation);
   verify_region_sets_optional();
@@ -3937,9 +3931,7 @@
   TASKQUEUE_STATS_ONLY(if (ParallelGCVerbose) print_taskqueue_stats());
   TASKQUEUE_STATS_ONLY(reset_taskqueue_stats());
 
-  if (PrintHeapAtGC) {
-    Universe::print_heap_after_gc();
-  }
+  print_heap_after_gc();
   g1mm()->update_sizes();
 
   if (G1SummarizeRSetStats &&
--- a/hotspot/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -126,7 +126,6 @@
 void G1MarkSweep::mark_sweep_phase1(bool& marked_for_unloading,
                                     bool clear_all_softrefs) {
   // Recursively traverse all live objects and mark them
-  EventMark m("1 mark object");
   TraceTime tm("phase 1", PrintGC && Verbose, true, gclog_or_tty);
   GenMarkSweep::trace(" 1");
 
@@ -292,7 +291,6 @@
   G1CollectedHeap* g1h = G1CollectedHeap::heap();
   Generation* pg = g1h->perm_gen();
 
-  EventMark m("2 compute new addresses");
   TraceTime tm("phase 2", PrintGC && Verbose, true, gclog_or_tty);
   GenMarkSweep::trace("2");
 
@@ -337,7 +335,6 @@
   Generation* pg = g1h->perm_gen();
 
   // Adjust the pointers to reflect the new locations
-  EventMark m("3 adjust pointers");
   TraceTime tm("phase 3", PrintGC && Verbose, true, gclog_or_tty);
   GenMarkSweep::trace("3");
 
@@ -402,7 +399,6 @@
   G1CollectedHeap* g1h = G1CollectedHeap::heap();
   Generation* pg = g1h->perm_gen();
 
-  EventMark m("4 compact heap");
   TraceTime tm("phase 4", PrintGC && Verbose, true, gclog_or_tty);
   GenMarkSweep::trace("4");
 
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -132,9 +132,7 @@
 
   AdaptiveSizePolicyOutput(size_policy, heap->total_collections());
 
-  if (PrintHeapAtGC) {
-    Universe::print_heap_before_gc();
-  }
+  heap->print_heap_before_gc();
 
   // Fill in TLABs
   heap->accumulate_statistics_all_tlabs();
@@ -377,9 +375,7 @@
 
   NOT_PRODUCT(ref_processor()->verify_no_references_recorded());
 
-  if (PrintHeapAtGC) {
-    Universe::print_heap_after_gc();
-  }
+  heap->print_heap_after_gc();
 
   heap->post_full_gc_dump();
 
@@ -504,7 +500,6 @@
 
 void PSMarkSweep::mark_sweep_phase1(bool clear_all_softrefs) {
   // Recursively traverse all live objects and mark them
-  EventMark m("1 mark object");
   TraceTime tm("phase 1", PrintGCDetails && Verbose, true, gclog_or_tty);
   trace(" 1");
 
@@ -563,7 +558,6 @@
 
 
 void PSMarkSweep::mark_sweep_phase2() {
-  EventMark m("2 compute new addresses");
   TraceTime tm("phase 2", PrintGCDetails && Verbose, true, gclog_or_tty);
   trace("2");
 
@@ -608,7 +602,6 @@
 
 void PSMarkSweep::mark_sweep_phase3() {
   // Adjust the pointers to reflect the new locations
-  EventMark m("3 adjust pointers");
   TraceTime tm("phase 3", PrintGCDetails && Verbose, true, gclog_or_tty);
   trace("3");
 
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -983,9 +983,7 @@
   // We need to track unique mark sweep invocations as well.
   _total_invocations++;
 
-  if (PrintHeapAtGC) {
-    Universe::print_heap_before_gc();
-  }
+  heap->print_heap_before_gc();
 
   // Fill in TLABs
   heap->accumulate_statistics_all_tlabs();
@@ -1838,7 +1836,6 @@
 void PSParallelCompact::summary_phase(ParCompactionManager* cm,
                                       bool maximum_compaction)
 {
-  EventMark m("2 summarize");
   TraceTime tm("summary phase", print_phases(), true, gclog_or_tty);
   // trace("2");
 
@@ -2237,9 +2234,7 @@
 
   collection_exit.update();
 
-  if (PrintHeapAtGC) {
-    Universe::print_heap_after_gc();
-  }
+  heap->print_heap_after_gc();
   if (PrintGCTaskTimeStamps) {
     gclog_or_tty->print_cr("VM-Thread " INT64_FORMAT " " INT64_FORMAT " "
                            INT64_FORMAT,
@@ -2352,7 +2347,6 @@
 void PSParallelCompact::marking_phase(ParCompactionManager* cm,
                                       bool maximum_heap_compaction) {
   // Recursively traverse all live objects and mark them
-  EventMark m("1 mark object");
   TraceTime tm("marking phase", print_phases(), true, gclog_or_tty);
 
   ParallelScavengeHeap* heap = gc_heap();
@@ -2438,7 +2432,6 @@
 
 void PSParallelCompact::adjust_roots() {
   // Adjust the pointers to reflect the new locations
-  EventMark m("3 adjust roots");
   TraceTime tm("adjust roots", print_phases(), true, gclog_or_tty);
 
   // General strong roots.
@@ -2469,7 +2462,6 @@
 }
 
 void PSParallelCompact::compact_perm(ParCompactionManager* cm) {
-  EventMark m("4 compact perm");
   TraceTime tm("compact perm gen", print_phases(), true, gclog_or_tty);
   // trace("4");
 
@@ -2647,7 +2639,6 @@
 }
 
 void PSParallelCompact::compact() {
-  EventMark m("5 compact");
   // trace("5");
   TraceTime tm("compaction phase", print_phases(), true, gclog_or_tty);
 
@@ -3502,4 +3493,3 @@
   _updated_int_array_klass_obj = (klassOop)
     summary_data().calc_new_pointer(Universe::intArrayKlassObj());
 }
-
--- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -295,9 +295,7 @@
     heap->record_gen_tops_before_GC();
   }
 
-  if (PrintHeapAtGC) {
-    Universe::print_heap_before_gc();
-  }
+  heap->print_heap_before_gc();
 
   assert(!NeverTenure || _tenuring_threshold == markOopDesc::max_age + 1, "Sanity");
   assert(!AlwaysTenure || _tenuring_threshold == 0, "Sanity");
@@ -643,9 +641,7 @@
     Universe::verify(false);
   }
 
-  if (PrintHeapAtGC) {
-    Universe::print_heap_after_gc();
-  }
+  heap->print_heap_after_gc();
 
   if (ZapUnusedHeapArea) {
     young_gen->eden_space()->check_mangled_unused_area_complete();
--- a/hotspot/src/share/vm/gc_interface/collectedHeap.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/gc_interface/collectedHeap.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -51,6 +51,31 @@
 
 size_t CollectedHeap::_filler_array_max_size = 0;
 
+template <>
+void EventLogBase<GCMessage>::print(outputStream* st, GCMessage& m) {
+  st->print_cr("GC heap %s", m.is_before ? "before" : "after");
+  st->print_raw(m);
+}
+
+void GCHeapLog::log_heap(bool before) {
+  if (!should_log()) {
+    return;
+  }
+
+  jlong timestamp = os::javaTimeNanos() / NANOSECS_PER_MILLISEC;
+  MutexLockerEx ml(&_mutex, Mutex::_no_safepoint_check_flag);
+  int index = compute_log_index();
+  _records[index].thread = NULL; // Its the GC thread so it's not that interesting.
+  _records[index].timestamp = timestamp;
+  _records[index].data.is_before = before;
+  stringStream st(_records[index].data.buffer(), _records[index].data.size());
+  if (before) {
+    Universe::print_heap_before_gc(&st);
+  } else {
+    Universe::print_heap_after_gc(&st);
+  }
+}
+
 // Memory state functions.
 
 
@@ -81,6 +106,12 @@
                              80, GCCause::to_string(_gc_lastcause), CHECK);
   }
   _defer_initial_card_mark = false; // strengthened by subclass in pre_initialize() below.
+  // Create the ring log
+  if (LogEvents) {
+    _gc_heap_log = new GCHeapLog();
+  } else {
+    _gc_heap_log = NULL;
+  }
 }
 
 void CollectedHeap::pre_initialize() {
--- a/hotspot/src/share/vm/gc_interface/collectedHeap.hpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/gc_interface/collectedHeap.hpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,6 +31,7 @@
 #include "runtime/handles.hpp"
 #include "runtime/perfData.hpp"
 #include "runtime/safepoint.hpp"
+#include "utilities/events.hpp"
 
 // A "CollectedHeap" is an implementation of a java heap for HotSpot.  This
 // is an abstract class: there may be many different kinds of heaps.  This
@@ -43,6 +44,29 @@
 class Thread;
 class CollectorPolicy;
 
+class GCMessage : public FormatBuffer<1024> {
+ public:
+  bool is_before;
+
+ public:
+  GCMessage() {}
+};
+
+class GCHeapLog : public EventLogBase<GCMessage> {
+ private:
+  void log_heap(bool before);
+
+ public:
+  GCHeapLog() : EventLogBase<GCMessage>("GC Heap History") {}
+
+  void log_heap_before() {
+    log_heap(true);
+  }
+  void log_heap_after() {
+    log_heap(false);
+  }
+};
+
 //
 // CollectedHeap
 //   SharedHeap
@@ -62,6 +86,8 @@
   // Used for filler objects (static, but initialized in ctor).
   static size_t _filler_array_max_size;
 
+  GCHeapLog* _gc_heap_log;
+
   // Used in support of ReduceInitialCardMarks; only consulted if COMPILER2 is being used
   bool _defer_initial_card_mark;
 
@@ -618,6 +644,27 @@
   // Default implementation does nothing.
   virtual void print_tracing_info() const = 0;
 
+  // If PrintHeapAtGC is set call the appropriate routi
+  void print_heap_before_gc() {
+    if (PrintHeapAtGC) {
+      Universe::print_heap_before_gc();
+    }
+    if (_gc_heap_log != NULL) {
+      _gc_heap_log->log_heap_before();
+    }
+  }
+  void print_heap_after_gc() {
+    if (PrintHeapAtGC) {
+      Universe::print_heap_after_gc();
+    }
+    if (_gc_heap_log != NULL) {
+      _gc_heap_log->log_heap_after();
+    }
+  }
+
+  // Allocate GCHeapLog during VM startup
+  static void initialize_heap_log();
+
   // Heap verification
   virtual void verify(bool allow_dirty, bool silent, VerifyOption option) = 0;
 
--- a/hotspot/src/share/vm/memory/gcLocker.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/memory/gcLocker.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,38 +31,93 @@
 volatile jint GC_locker::_lock_count     = 0;
 volatile bool GC_locker::_needs_gc       = false;
 volatile bool GC_locker::_doing_gc       = false;
+jlong GC_locker::_wait_begin = 0;
+
+#ifdef ASSERT
+volatile jint GC_locker::_debug_jni_lock_count = 0;
+#endif
+
+
+#ifdef ASSERT
+void GC_locker::verify_critical_count() {
+  if (SafepointSynchronize::is_at_safepoint()) {
+    assert(!needs_gc() || _debug_jni_lock_count == _jni_lock_count, "must agree");
+    int count = 0;
+    // Count the number of threads with critical operations in progress
+    for (JavaThread* thr = Threads::first(); thr; thr = thr->next()) {
+      if (thr->in_critical()) {
+        count++;
+      }
+    }
+    if (_jni_lock_count != count) {
+      tty->print_cr("critical counts don't match: %d != %d", _jni_lock_count, count);
+      for (JavaThread* thr = Threads::first(); thr; thr = thr->next()) {
+        if (thr->in_critical()) {
+          tty->print_cr(INTPTR_FORMAT " in_critical %d", thr, thr->in_critical());
+        }
+      }
+    }
+    assert(_jni_lock_count == count, "must be equal");
+  }
+}
+#endif
+
+bool GC_locker::check_active_before_gc() {
+  assert(SafepointSynchronize::is_at_safepoint(), "only read at safepoint");
+  if (is_active() && !_needs_gc) {
+    verify_critical_count();
+    _needs_gc = true;
+    if (PrintJNIGCStalls && PrintGCDetails) {
+      ResourceMark rm; // JavaThread::name() allocates to convert to UTF8
+      _wait_begin = os::javaTimeNanos() / NANOSECS_PER_MILLISEC;
+      gclog_or_tty->print_cr(INT64_FORMAT ": Setting _needs_gc. Thread \"%s\" %d locked.",
+                             _wait_begin, Thread::current()->name(), _jni_lock_count);
+    }
+
+  }
+  return is_active();
+}
 
 void GC_locker::stall_until_clear() {
   assert(!JavaThread::current()->in_critical(), "Would deadlock");
-  if (PrintJNIGCStalls && PrintGCDetails) {
-    ResourceMark rm; // JavaThread::name() allocates to convert to UTF8
-    gclog_or_tty->print_cr(
-      "Allocation failed. Thread \"%s\" is stalled by JNI critical section.",
-      JavaThread::current()->name());
+  MutexLocker   ml(JNICritical_lock);
+
+  if (needs_gc()) {
+    if (PrintJNIGCStalls && PrintGCDetails) {
+      ResourceMark rm; // JavaThread::name() allocates to convert to UTF8
+      gclog_or_tty->print_cr(INT64_FORMAT ": Allocation failed. Thread \"%s\" is stalled by JNI critical section, %d locked.",
+                             (os::javaTimeNanos() / NANOSECS_PER_MILLISEC) - _wait_begin, Thread::current()->name(), _jni_lock_count);
+    }
   }
-  MutexLocker   ml(JNICritical_lock);
+
   // Wait for _needs_gc  to be cleared
-  while (GC_locker::needs_gc()) {
+  while (needs_gc()) {
     JNICritical_lock->wait();
   }
 }
 
-void GC_locker::jni_lock_slow() {
+void GC_locker::jni_lock(JavaThread* thread) {
+  assert(!thread->in_critical(), "shouldn't currently be in a critical region");
   MutexLocker mu(JNICritical_lock);
   // Block entering threads if we know at least one thread is in a
   // JNI critical region and we need a GC.
   // We check that at least one thread is in a critical region before
   // blocking because blocked threads are woken up by a thread exiting
   // a JNI critical region.
-  while ((is_jni_active() && needs_gc()) || _doing_gc) {
+  while ((needs_gc() && is_jni_active()) || _doing_gc) {
     JNICritical_lock->wait();
   }
-  jni_lock();
+  thread->enter_critical();
+  _jni_lock_count++;
+  increment_debug_jni_lock_count();
 }
 
-void GC_locker::jni_unlock_slow() {
+void GC_locker::jni_unlock(JavaThread* thread) {
+  assert(thread->in_last_critical(), "should be exiting critical region");
   MutexLocker mu(JNICritical_lock);
-  jni_unlock();
+  _jni_lock_count--;
+  decrement_debug_jni_lock_count();
+  thread->exit_critical();
   if (needs_gc() && !is_jni_active()) {
     // We're the last thread out. Cause a GC to occur.
     // GC will also check is_active, so this check is not
@@ -74,11 +129,17 @@
       {
         // Must give up the lock while at a safepoint
         MutexUnlocker munlock(JNICritical_lock);
+        if (PrintJNIGCStalls && PrintGCDetails) {
+          ResourceMark rm; // JavaThread::name() allocates to convert to UTF8
+          gclog_or_tty->print_cr(INT64_FORMAT ": Thread \"%s\" is performing GC after exiting critical section, %d locked",
+                                 (os::javaTimeNanos() / NANOSECS_PER_MILLISEC) - _wait_begin, Thread::current()->name(), _jni_lock_count);
+        }
         Universe::heap()->collect(GCCause::_gc_locker);
       }
       _doing_gc = false;
     }
-    clear_needs_gc();
+
+    _needs_gc = false;
     JNICritical_lock->notify_all();
   }
 }
--- a/hotspot/src/share/vm/memory/gcLocker.hpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/memory/gcLocker.hpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -51,53 +51,70 @@
 
 class GC_locker: public AllStatic {
  private:
-  static volatile jint _jni_lock_count;  // number of jni active instances
+  // The _jni_lock_count keeps track of the number of threads that are
+  // currently in a critical region.  It's only kept up to date when
+  // _needs_gc is true.  The current value is computed during
+  // safepointing and decremented during the slow path of GC_locker
+  // unlocking.
+  static volatile jint _jni_lock_count;  // number of jni active instances.
+
   static volatile jint _lock_count;      // number of other active instances
   static volatile bool _needs_gc;        // heap is filling, we need a GC
                                          // note: bool is typedef'd as jint
   static volatile bool _doing_gc;        // unlock_critical() is doing a GC
 
+  static jlong         _wait_begin;      // Timestamp for the setting of _needs_gc.
+                                         // Used only by printing code.
+
+#ifdef ASSERT
+  // This lock count is updated for all operations and is used to
+  // validate the jni_lock_count that is computed during safepoints.
+  static volatile jint _debug_jni_lock_count;
+#endif
+
   // Accessors
   static bool is_jni_active() {
+    assert(_needs_gc, "only valid when _needs_gc is set");
     return _jni_lock_count > 0;
   }
 
-  static void set_needs_gc() {
-    assert(SafepointSynchronize::is_at_safepoint(),
-      "needs_gc is only set at a safepoint");
-    _needs_gc = true;
-  }
-
-  static void clear_needs_gc() {
-    assert_lock_strong(JNICritical_lock);
-    _needs_gc = false;
-  }
+  // At a safepoint, visit all threads and count the number of active
+  // critical sections.  This is used to ensure that all active
+  // critical sections are exited before a new one is started.
+  static void verify_critical_count() NOT_DEBUG_RETURN;
 
-  static void jni_lock() {
-    Atomic::inc(&_jni_lock_count);
-    CHECK_UNHANDLED_OOPS_ONLY(
-      if (CheckUnhandledOops) { Thread::current()->_gc_locked_out_count++; })
-    assert(Universe::heap() == NULL || !Universe::heap()->is_gc_active(),
-           "locking failed");
-  }
-
-  static void jni_unlock() {
-    Atomic::dec(&_jni_lock_count);
-    CHECK_UNHANDLED_OOPS_ONLY(
-      if (CheckUnhandledOops) { Thread::current()->_gc_locked_out_count--; })
-  }
-
-  static void jni_lock_slow();
-  static void jni_unlock_slow();
+  static void jni_lock(JavaThread* thread);
+  static void jni_unlock(JavaThread* thread);
 
  public:
   // Accessors
   static bool is_active();
   static bool needs_gc()       { return _needs_gc;                        }
+
   // Shorthand
-  static bool is_active_and_needs_gc() { return is_active() && needs_gc();}
+  static bool is_active_and_needs_gc() { return needs_gc() && is_active(); }
 
-  // Calls set_needs_gc() if is_active() is true. Returns is_active().
+  // In debug mode track the locking state at all times
+  static void increment_debug_jni_lock_count() {
+#ifdef ASSERT
+    assert(_debug_jni_lock_count >= 0, "bad value");
+    Atomic::inc(&_debug_jni_lock_count);
+#endif
+  }
+  static void decrement_debug_jni_lock_count() {
+#ifdef ASSERT
+    assert(_debug_jni_lock_count > 0, "bad value");
+    Atomic::dec(&_debug_jni_lock_count);
+#endif
+  }
+
+  // Set the current lock count
+  static void set_jni_lock_count(int count) {
+    _jni_lock_count = count;
+    verify_critical_count();
+  }
+
+  // Sets _needs_gc if is_active() is true. Returns is_active().
   static bool check_active_before_gc();
 
   // Stalls the caller (who should not be in a jni critical section)
@@ -131,22 +148,24 @@
   // JNI critical regions are the only participants in this scheme
   // because they are, by spec, well bounded while in a critical region.
   //
-  // Each of the following two method is split into a fast path and a slow
-  // path. JNICritical_lock is only grabbed in the slow path.
+  // Each of the following two method is split into a fast path and a
+  // slow path. JNICritical_lock is only grabbed in the slow path.
   // _needs_gc is initially false and every java thread will go
-  // through the fast path (which does the same thing as the slow path
-  // when _needs_gc is false). When GC happens at a safepoint,
-  // GC_locker::is_active() is checked. Since there is no safepoint in the
-  // fast path of lock_critical() and unlock_critical(), there is no race
-  // condition between the fast path and GC. After _needs_gc is set at a
-  // safepoint, every thread will go through the slow path after the safepoint.
-  // Since after a safepoint, each of the following two methods is either
-  // entered from the method entry and falls into the slow path, or is
-  // resumed from the safepoints in the method, which only exist in the slow
-  // path. So when _needs_gc is set, the slow path is always taken, till
-  // _needs_gc is cleared.
+  // through the fast path, which simply increments or decrements the
+  // current thread's critical count.  When GC happens at a safepoint,
+  // GC_locker::is_active() is checked. Since there is no safepoint in
+  // the fast path of lock_critical() and unlock_critical(), there is
+  // no race condition between the fast path and GC. After _needs_gc
+  // is set at a safepoint, every thread will go through the slow path
+  // after the safepoint.  Since after a safepoint, each of the
+  // following two methods is either entered from the method entry and
+  // falls into the slow path, or is resumed from the safepoints in
+  // the method, which only exist in the slow path. So when _needs_gc
+  // is set, the slow path is always taken, till _needs_gc is cleared.
   static void lock_critical(JavaThread* thread);
   static void unlock_critical(JavaThread* thread);
+
+  static address needs_gc_address() { return (address) &_needs_gc; }
 };
 
 
--- a/hotspot/src/share/vm/memory/gcLocker.inline.hpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/memory/gcLocker.inline.hpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,16 +28,11 @@
 #include "memory/gcLocker.hpp"
 
 inline bool GC_locker::is_active() {
+  assert(_needs_gc || SafepointSynchronize::is_at_safepoint(), "only read at safepoint");
+  verify_critical_count();
   return _lock_count > 0 || _jni_lock_count > 0;
 }
 
-inline bool GC_locker::check_active_before_gc() {
-  if (is_active()) {
-    set_needs_gc();
-  }
-  return is_active();
-}
-
 inline void GC_locker::lock() {
   // cast away volatile
   Atomic::inc(&_lock_count);
@@ -56,24 +51,28 @@
 
 inline void GC_locker::lock_critical(JavaThread* thread) {
   if (!thread->in_critical()) {
-    if (!needs_gc()) {
-      jni_lock();
-    } else {
-      jni_lock_slow();
+    if (needs_gc()) {
+      // jni_lock call calls enter_critical under the lock so that the
+      // global lock count and per thread count are in agreement.
+      jni_lock(thread);
+      return;
     }
+    increment_debug_jni_lock_count();
   }
   thread->enter_critical();
 }
 
 inline void GC_locker::unlock_critical(JavaThread* thread) {
+  if (thread->in_last_critical()) {
+    if (needs_gc()) {
+      // jni_unlock call calls exit_critical under the lock so that
+      // the global lock count and per thread count are in agreement.
+      jni_unlock(thread);
+      return;
+    }
+    decrement_debug_jni_lock_count();
+  }
   thread->exit_critical();
-  if (!thread->in_critical()) {
-    if (!needs_gc()) {
-      jni_unlock();
-    } else {
-      jni_unlock_slow();
-    }
-  }
 }
 
 #endif // SHARE_VM_MEMORY_GCLOCKER_INLINE_HPP
--- a/hotspot/src/share/vm/memory/genCollectedHeap.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/memory/genCollectedHeap.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -479,11 +479,9 @@
 
   const size_t perm_prev_used = perm_gen()->used();
 
-  if (PrintHeapAtGC) {
-    Universe::print_heap_before_gc();
-    if (Verbose) {
-      gclog_or_tty->print_cr("GC Cause: %s", GCCause::to_string(gc_cause()));
-    }
+  print_heap_before_gc();
+  if (Verbose) {
+    gclog_or_tty->print_cr("GC Cause: %s", GCCause::to_string(gc_cause()));
   }
 
   {
@@ -685,9 +683,7 @@
   AdaptiveSizePolicy* sp = gen_policy()->size_policy();
   AdaptiveSizePolicyOutput(sp, total_collections());
 
-  if (PrintHeapAtGC) {
-    Universe::print_heap_after_gc();
-  }
+  print_heap_after_gc();
 
 #ifdef TRACESPINNING
   ParallelTaskTerminator::print_termination_counts();
--- a/hotspot/src/share/vm/memory/genMarkSweep.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/memory/genMarkSweep.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -254,7 +254,6 @@
 void GenMarkSweep::mark_sweep_phase1(int level,
                                   bool clear_all_softrefs) {
   // Recursively traverse all live objects and mark them
-  EventMark m("1 mark object");
   TraceTime tm("phase 1", PrintGC && Verbose, true, gclog_or_tty);
   trace(" 1");
 
@@ -325,7 +324,6 @@
   GenCollectedHeap* gch = GenCollectedHeap::heap();
   Generation* pg = gch->perm_gen();
 
-  EventMark m("2 compute new addresses");
   TraceTime tm("phase 2", PrintGC && Verbose, true, gclog_or_tty);
   trace("2");
 
@@ -350,7 +348,6 @@
   Generation* pg = gch->perm_gen();
 
   // Adjust the pointers to reflect the new locations
-  EventMark m("3 adjust pointers");
   TraceTime tm("phase 3", PrintGC && Verbose, true, gclog_or_tty);
   trace("3");
 
@@ -411,7 +408,6 @@
   GenCollectedHeap* gch = GenCollectedHeap::heap();
   Generation* pg = gch->perm_gen();
 
-  EventMark m("4 compact heap");
   TraceTime tm("phase 4", PrintGC && Verbose, true, gclog_or_tty);
   trace("4");
 
--- a/hotspot/src/share/vm/oops/arrayOop.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/oops/arrayOop.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,7 @@
 #ifndef PRODUCT
 
 #include "oops/arrayOop.hpp"
+#include "oops/oop.inline.hpp"
 #include "utilities/globalDefinitions.hpp"
 
 bool arrayOopDesc::check_max_length_overflow(BasicType type) {
--- a/hotspot/src/share/vm/oops/constantPoolOop.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/oops/constantPoolOop.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -269,7 +269,7 @@
 methodOop constantPoolOopDesc::method_at_if_loaded(constantPoolHandle cpool,
                                                    int which, Bytecodes::Code invoke_code) {
   assert(!constantPoolCacheOopDesc::is_secondary_index(which), "no indy instruction here");
-  if (cpool->cache() == NULL)  return false;  // nothing to load yet
+  if (cpool->cache() == NULL)  return NULL;  // nothing to load yet
   int cache_index = which - CPCACHE_INDEX_TAG;
   if (!(cache_index >= 0 && cache_index < cpool->cache()->length())) {
     if (PrintMiscellaneous && (Verbose||WizardMode)) {
--- a/hotspot/src/share/vm/oops/instanceKlass.hpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/oops/instanceKlass.hpp	Mon Feb 13 14:31:32 2012 +0000
@@ -240,7 +240,6 @@
   Thread*         _init_thread;          // Pointer to current thread doing initialization (to handle recusive initialization)
   int             _vtable_len;           // length of Java vtable (in words)
   int             _itable_len;           // length of Java itable (in words)
-  ReferenceType   _reference_type;       // reference type
   OopMapCache*    volatile _oop_map_cache;   // OopMapCache for all methods in the klass (allocated lazily)
   JNIid*          _jni_ids;              // First JNI identifier for static fields in this class
   jmethodID*      _methods_jmethod_ids;  // jmethodIDs corresponding to method_idnum, or NULL if none
@@ -265,6 +264,8 @@
   // _idnum_allocated_count.
   u1              _init_state;                    // state of class
 
+  u1              _reference_type;                // reference type
+
   // embedded Java vtable follows here
   // embedded Java itables follows here
   // embedded static fields follows here
@@ -407,8 +408,11 @@
   void eager_initialize(Thread *thread);
 
   // reference type
-  ReferenceType reference_type() const     { return _reference_type; }
-  void set_reference_type(ReferenceType t) { _reference_type = t; }
+  ReferenceType reference_type() const     { return (ReferenceType)_reference_type; }
+  void set_reference_type(ReferenceType t) {
+    assert(t == (u1)t, "overflow");
+    _reference_type = (u1)t;
+  }
 
   static ByteSize reference_type_offset() { return in_ByteSize(sizeof(klassOopDesc) + offset_of(instanceKlass, _reference_type)); }
 
@@ -570,9 +574,9 @@
   void set_method_annotations_of(int idnum, typeArrayOop anno)
                                                 { set_methods_annotations_of(idnum, anno, &_methods_annotations); }
   void set_method_parameter_annotations_of(int idnum, typeArrayOop anno)
-                                                { set_methods_annotations_of(idnum, anno, &_methods_annotations); }
+                                                { set_methods_annotations_of(idnum, anno, &_methods_parameter_annotations); }
   void set_method_default_annotations_of(int idnum, typeArrayOop anno)
-                                                { set_methods_annotations_of(idnum, anno, &_methods_annotations); }
+                                                { set_methods_annotations_of(idnum, anno, &_methods_default_annotations); }
 
   // allocation
   DEFINE_ALLOCATE_PERMANENT(instanceKlass);
--- a/hotspot/src/share/vm/oops/klass.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/oops/klass.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -158,9 +158,7 @@
   kl->set_next_sibling(NULL);
   kl->set_alloc_count(0);
   kl->set_alloc_size(0);
-#ifdef TRACE_SET_KLASS_TRACE_ID
   TRACE_SET_KLASS_TRACE_ID(kl, 0);
-#endif
 
   kl->set_prototype_header(markOopDesc::prototype());
   kl->set_biased_lock_revocation_count(0);
--- a/hotspot/src/share/vm/oops/klass.hpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/oops/klass.hpp	Mon Feb 13 14:31:32 2012 +0000
@@ -265,9 +265,7 @@
   markOop  _prototype_header;   // Used when biased locking is both enabled and disabled for this type
   jint     _biased_lock_revocation_count;
 
-#ifdef TRACE_DEFINE_KLASS_TRACE_ID
   TRACE_DEFINE_KLASS_TRACE_ID;
-#endif
  public:
 
   // returns the enclosing klassOop
@@ -688,9 +686,7 @@
   jlong last_biased_lock_bulk_revocation_time() { return _last_biased_lock_bulk_revocation_time; }
   void  set_last_biased_lock_bulk_revocation_time(jlong cur_time) { _last_biased_lock_bulk_revocation_time = cur_time; }
 
-#ifdef TRACE_DEFINE_KLASS_METHODS
   TRACE_DEFINE_KLASS_METHODS;
-#endif
 
   // garbage collection support
   virtual void follow_weak_klass_links(
--- a/hotspot/src/share/vm/oops/methodOop.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/oops/methodOop.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -596,6 +596,11 @@
   clear_code();
 }
 
+address methodOopDesc::critical_native_function() {
+  methodHandle mh(this);
+  return NativeLookup::lookup_critical_entry(mh);
+}
+
 
 void methodOopDesc::set_signature_handler(address handler) {
   address* signature_handler =  signature_handler_addr();
--- a/hotspot/src/share/vm/oops/methodOop.hpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/oops/methodOop.hpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -403,6 +403,8 @@
     native_bind_event_is_interesting = true
   };
   address native_function() const                { return *(native_function_addr()); }
+  address critical_native_function();
+
   // Must specify a real function (not NULL).
   // Use clear_native_function() to unregister.
   void set_native_function(address function, bool post_event_flag);
--- a/hotspot/src/share/vm/opto/graphKit.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/opto/graphKit.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1522,6 +1522,11 @@
                           const TypeOopPtr* val_type,
                           BasicType bt,
                           bool use_precise) {
+  // Transformation of a value which could be NULL pointer (CastPP #NULL)
+  // could be delayed during Parse (for example, in adjust_map_after_if()).
+  // Execute transformation here to avoid barrier generation in such case.
+  if (_gvn.type(val) == TypePtr::NULL_PTR)
+    val = _gvn.makecon(TypePtr::NULL_PTR);
 
   set_control(ctl);
   if (stopped()) return top(); // Dead path ?
--- a/hotspot/src/share/vm/opto/library_call.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/opto/library_call.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -2153,7 +2153,7 @@
   //
   // if (offset == java_lang_ref_Reference::_reference_offset) {
   //   if (base != null) {
-  //     if (klass(base)->reference_type() != REF_NONE)) {
+  //     if (instance_of(base, java.lang.ref.Reference)) {
   //       pre_barrier(_, pre_val, ...);
   //     }
   //   }
@@ -2165,8 +2165,6 @@
   IdealKit ideal(this);
 #define __ ideal.
 
-  const int reference_type_offset = in_bytes(instanceKlass::reference_type_offset());
-
   Node* referent_off = __ ConX(java_lang_ref_Reference::referent_offset);
 
   __ if_then(offset, BoolTest::eq, referent_off, unlikely); {
@@ -2678,7 +2676,13 @@
     cas = _gvn.transform(new (C, 5) CompareAndSwapLNode(control(), mem, adr, newval, oldval));
     break;
   case T_OBJECT:
-     // reference stores need a store barrier.
+    // Transformation of a value which could be NULL pointer (CastPP #NULL)
+    // could be delayed during Parse (for example, in adjust_map_after_if()).
+    // Execute transformation here to avoid barrier generation in such case.
+    if (_gvn.type(newval) == TypePtr::NULL_PTR)
+      newval = _gvn.makecon(TypePtr::NULL_PTR);
+
+    // Reference stores need a store barrier.
     // (They don't if CAS fails, but it isn't worth checking.)
     pre_barrier(true /* do_load*/,
                 control(), base, adr, alias_idx, newval, value_type->make_oopptr(),
--- a/hotspot/src/share/vm/opto/loopnode.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/opto/loopnode.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -898,7 +898,7 @@
 Node* CountedLoopNode::match_incr_with_optional_truncation(
                       Node* expr, Node** trunc1, Node** trunc2, const TypeInt** trunc_type) {
   // Quick cutouts:
-  if (expr == NULL || expr->req() != 3)  return false;
+  if (expr == NULL || expr->req() != 3)  return NULL;
 
   Node *t1 = NULL;
   Node *t2 = NULL;
--- a/hotspot/src/share/vm/opto/macro.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/opto/macro.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -234,11 +234,20 @@
     }
   } else {
     // G1 pre/post barriers
-    assert(p2x->outcnt() == 2, "expects 2 users: Xor and URShift nodes");
+    assert(p2x->outcnt() <= 2, "expects 1 or 2 users: Xor and URShift nodes");
     // It could be only one user, URShift node, in Object.clone() instrinsic
     // but the new allocation is passed to arraycopy stub and it could not
     // be scalar replaced. So we don't check the case.
 
+    // An other case of only one user (Xor) is when the value check for NULL
+    // in G1 post barrier is folded after CCP so the code which used URShift
+    // is removed.
+
+    // Take Region node before eliminating post barrier since it also
+    // eliminates CastP2X node when it has only one user.
+    Node* this_region = p2x->in(0);
+    assert(this_region != NULL, "");
+
     // Remove G1 post barrier.
 
     // Search for CastP2X->Xor->URShift->Cmp path which
@@ -263,8 +272,6 @@
     // Remove G1 pre barrier.
 
     // Search "if (marking != 0)" check and set it to "false".
-    Node* this_region = p2x->in(0);
-    assert(this_region != NULL, "");
     // There is no G1 pre barrier if previous stored value is NULL
     // (for example, after initialization).
     if (this_region->is_Region() && this_region->req() == 3) {
@@ -292,7 +299,7 @@
     }
     // Now CastP2X can be removed since it is used only on dead path
     // which currently still alive until igvn optimize it.
-    assert(p2x->unique_out()->Opcode() == Op_URShiftX, "");
+    assert(p2x->outcnt() == 0 || p2x->unique_out()->Opcode() == Op_URShiftX, "");
     _igvn.replace_node(p2x, top());
   }
 }
--- a/hotspot/src/share/vm/prims/jvm.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/prims/jvm.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -2716,7 +2716,9 @@
   }
   oop java_thread = JNIHandles::resolve_non_null(jthread);
   JavaThread* receiver = java_lang_Thread::thread(java_thread);
-  Events::log("JVM_StopThread thread JavaThread " INTPTR_FORMAT " as oop " INTPTR_FORMAT " [exception " INTPTR_FORMAT "]", receiver, (address)java_thread, throwable);
+  Events::log_exception(JavaThread::current(),
+                        "JVM_StopThread thread JavaThread " INTPTR_FORMAT " as oop " INTPTR_FORMAT " [exception " INTPTR_FORMAT "]",
+                        receiver, (address)java_thread, throwable);
   // First check if thread is alive
   if (receiver != NULL) {
     // Check if exception is getting thrown at self (use oop equality, since the
--- a/hotspot/src/share/vm/prims/nativeLookup.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/prims/nativeLookup.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -91,6 +91,19 @@
 }
 
 
+char* NativeLookup::critical_jni_name(methodHandle method) {
+  stringStream st;
+  // Prefix
+  st.print("JavaCritical_");
+  // Klass name
+  mangle_name_on(&st, method->klass_name());
+  st.print("_");
+  // Method name
+  mangle_name_on(&st, method->name());
+  return st.as_string();
+}
+
+
 char* NativeLookup::long_jni_name(methodHandle method) {
   // Signature ignore the wrapping parenteses and the trailing return type
   stringStream st;
@@ -193,6 +206,34 @@
 }
 
 
+address NativeLookup::lookup_critical_style(methodHandle method, char* pure_name, const char* long_name, int args_size, bool os_style) {
+  if (!method->has_native_function()) {
+    return NULL;
+  }
+
+  address current_entry = method->native_function();
+
+  char dll_name[JVM_MAXPATHLEN];
+  int offset;
+  if (os::dll_address_to_library_name(current_entry, dll_name, sizeof(dll_name), &offset)) {
+    char ebuf[32];
+    void* dll = os::dll_load(dll_name, ebuf, sizeof(ebuf));
+    if (dll != NULL) {
+      // Compute complete JNI name for style
+      stringStream st;
+      if (os_style) os::print_jni_name_prefix_on(&st, args_size);
+      st.print_raw(pure_name);
+      st.print_raw(long_name);
+      if (os_style) os::print_jni_name_suffix_on(&st, args_size);
+      char* jni_name = st.as_string();
+      return (address)os::dll_lookup(dll, jni_name);
+    }
+  }
+
+  return NULL;
+}
+
+
 // Check all the formats of native implementation name to see if there is one
 // for the specified method.
 address NativeLookup::lookup_entry(methodHandle method, bool& in_base_library, TRAPS) {
@@ -228,6 +269,58 @@
   return entry; // NULL indicates not found
 }
 
+// Check all the formats of native implementation name to see if there is one
+// for the specified method.
+address NativeLookup::lookup_critical_entry(methodHandle method) {
+  if (!CriticalJNINatives) return NULL;
+
+  if (method->is_synchronized() ||
+      !method->is_static()) {
+    // Only static non-synchronized methods are allowed
+    return NULL;
+  }
+
+  ResourceMark rm;
+  address entry = NULL;
+
+  Symbol* signature = method->signature();
+  for (int end = 0; end < signature->utf8_length(); end++) {
+    if (signature->byte_at(end) == 'L') {
+      // Don't allow object types
+      return NULL;
+    }
+  }
+
+  // Compute critical name
+  char* critical_name = critical_jni_name(method);
+
+  // Compute argument size
+  int args_size = 1                             // JNIEnv
+                + (method->is_static() ? 1 : 0) // class for static methods
+                + method->size_of_parameters(); // actual parameters
+
+
+  // 1) Try JNI short style
+  entry = lookup_critical_style(method, critical_name, "",        args_size, true);
+  if (entry != NULL) return entry;
+
+  // Compute long name
+  char* long_name = long_jni_name(method);
+
+  // 2) Try JNI long style
+  entry = lookup_critical_style(method, critical_name, long_name, args_size, true);
+  if (entry != NULL) return entry;
+
+  // 3) Try JNI short style without os prefix/suffix
+  entry = lookup_critical_style(method, critical_name, "",        args_size, false);
+  if (entry != NULL) return entry;
+
+  // 4) Try JNI long style without os prefix/suffix
+  entry = lookup_critical_style(method, critical_name, long_name, args_size, false);
+
+  return entry; // NULL indicates not found
+}
+
 // Check if there are any JVM TI prefixes which have been applied to the native method name.
 // If any are found, remove them before attemping the look up of the
 // native implementation again.
--- a/hotspot/src/share/vm/prims/nativeLookup.hpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/prims/nativeLookup.hpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,15 +36,18 @@
   // JNI name computation
   static char* pure_jni_name(methodHandle method);
   static char* long_jni_name(methodHandle method);
+  static char* critical_jni_name(methodHandle method);
 
   // Style specific lookup
   static address lookup_style(methodHandle method, char* pure_name, const char* long_name, int args_size, bool os_style, bool& in_base_library, TRAPS);
+  static address lookup_critical_style(methodHandle method, char* pure_name, const char* long_name, int args_size, bool os_style);
   static address lookup_base (methodHandle method, bool& in_base_library, TRAPS);
   static address lookup_entry(methodHandle method, bool& in_base_library, TRAPS);
   static address lookup_entry_prefixed(methodHandle method, bool& in_base_library, TRAPS);
  public:
   // Lookup native function. May throw UnsatisfiedLinkError.
   static address lookup(methodHandle method, bool& in_base_library, TRAPS);
+  static address lookup_critical_entry(methodHandle method);
 
   // Lookup native functions in base library.
   static address base_library_lookup(const char* class_name, const char* method_name, const char* signature);
--- a/hotspot/src/share/vm/runtime/arguments.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/runtime/arguments.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1400,10 +1400,11 @@
 
 void Arguments::set_parallel_gc_flags() {
   assert(UseParallelGC || UseParallelOldGC, "Error");
-  // If parallel old was requested, automatically enable parallel scavenge.
-  if (UseParallelOldGC && !UseParallelGC && FLAG_IS_DEFAULT(UseParallelGC)) {
-    FLAG_SET_DEFAULT(UseParallelGC, true);
+  // Enable ParallelOld unless it was explicitly disabled (cmd line or rc file).
+  if (FLAG_IS_DEFAULT(UseParallelOldGC)) {
+    FLAG_SET_DEFAULT(UseParallelOldGC, true);
   }
+  FLAG_SET_DEFAULT(UseParallelGC, true);
 
   // If no heap maximum was requested explicitly, use some reasonable fraction
   // of the physical memory, up to a maximum of 1GB.
--- a/hotspot/src/share/vm/runtime/deoptimization.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/runtime/deoptimization.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -339,7 +339,6 @@
 
 #ifdef ASSERT
   assert(cb->is_deoptimization_stub() || cb->is_uncommon_trap_stub(), "just checking");
-  Events::log("fetch unroll sp " INTPTR_FORMAT, unpack_sp);
 #endif
 #else
   intptr_t* unpack_sp = stub_frame.sender(&dummy_map).unextended_sp();
@@ -577,6 +576,8 @@
     tty->print_cr("DEOPT UNPACKING thread " INTPTR_FORMAT " vframeArray " INTPTR_FORMAT " mode %d", thread, array, exec_mode);
   }
 #endif
+  Events::log(thread, "DEOPT UNPACKING pc=" INTPTR_FORMAT " sp=" INTPTR_FORMAT " mode %d",
+              stub_frame.pc(), stub_frame.sp(), exec_mode);
 
   UnrollBlock* info = array->unroll_block();
 
@@ -981,6 +982,7 @@
 #endif // COMPILER2
 
 vframeArray* Deoptimization::create_vframeArray(JavaThread* thread, frame fr, RegisterMap *reg_map, GrowableArray<compiledVFrame*>* chunk) {
+  Events::log(thread, "DEOPT PACKING pc=" INTPTR_FORMAT " sp=" INTPTR_FORMAT, fr.pc(), fr.sp());
 
 #ifndef PRODUCT
   if (TraceDeoptimization) {
@@ -1026,7 +1028,6 @@
 
   // Compare the vframeArray to the collected vframes
   assert(array->structural_compare(thread, chunk), "just checking");
-  Events::log("# vframes = %d", (intptr_t)chunk->length());
 
 #ifndef PRODUCT
   if (TraceDeoptimization) {
@@ -1124,8 +1125,6 @@
 
   gather_statistics(Reason_constraint, Action_none, Bytecodes::_illegal);
 
-  EventMark m("Deoptimization (pc=" INTPTR_FORMAT ", sp=" INTPTR_FORMAT ")", fr.pc(), fr.id());
-
   // Patch the nmethod so that when execution returns to it we will
   // deopt the execution state and return to the interpreter.
   fr.deoptimize(thread);
@@ -1239,6 +1238,10 @@
   // before we are done with it.
   nmethodLocker nl(fr.pc());
 
+  // Log a message
+  Events::log_deopt_message(thread, "Uncommon trap %d fr.pc " INTPTR_FORMAT,
+                            trap_request, fr.pc());
+
   {
     ResourceMark rm;
 
@@ -1249,7 +1252,6 @@
     DeoptAction action = trap_request_action(trap_request);
     jint unloaded_class_index = trap_request_index(trap_request); // CP idx or -1
 
-    Events::log("Uncommon trap occurred @" INTPTR_FORMAT " unloaded_class_index = %d", fr.pc(), (int) trap_request);
     vframe*  vf  = vframe::new_vframe(&fr, &reg_map, thread);
     compiledVFrame* cvf = compiledVFrame::cast(vf);
 
--- a/hotspot/src/share/vm/runtime/frame.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/runtime/frame.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -570,7 +570,7 @@
     InterpreterCodelet* desc = Interpreter::codelet_containing(pc());
     if (desc != NULL) {
       st->print("~");
-      desc->print();
+      desc->print_on(st);
       NOT_PRODUCT(begin = desc->code_begin(); end = desc->code_end();)
     } else {
       st->print("~interpreter");
--- a/hotspot/src/share/vm/runtime/globals.hpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/runtime/globals.hpp	Mon Feb 13 14:31:32 2012 +0000
@@ -26,6 +26,17 @@
 #define SHARE_VM_RUNTIME_GLOBALS_HPP
 
 #include "utilities/debug.hpp"
+
+// use this for flags that are true per default in the tiered build
+// but false in non-tiered builds, and vice versa
+#ifdef TIERED
+#define  trueInTiered true
+#define falseInTiered false
+#else
+#define  trueInTiered false
+#define falseInTiered true
+#endif
+
 #ifdef TARGET_ARCH_x86
 # include "globals_x86.hpp"
 #endif
@@ -353,16 +364,6 @@
 #define falseInProduct true
 #endif
 
-// use this for flags that are true per default in the tiered build
-// but false in non-tiered builds, and vice versa
-#ifdef TIERED
-#define  trueInTiered true
-#define falseInTiered false
-#else
-#define  trueInTiered false
-#define falseInTiered true
-#endif
-
 #ifdef JAVASE_EMBEDDED
 #define falseInEmbedded false
 #else
@@ -658,6 +659,12 @@
   develop(bool, SpecialArraysEquals, true,                                  \
           "special version of Arrays.equals(char[],char[])")                \
                                                                             \
+  product(bool, CriticalJNINatives, true,                                   \
+          "check for critical JNI entry points")                            \
+                                                                            \
+  notproduct(bool, StressCriticalJNINatives, false,                         \
+            "Exercise register saving code in critical natives")            \
+                                                                            \
   product(bool, UseSSE42Intrinsics, false,                                  \
           "SSE4.2 versions of intrinsics")                                  \
                                                                             \
@@ -735,8 +742,11 @@
   product(bool, MaxFDLimit, true,                                           \
           "Bump the number of file descriptors to max in solaris.")         \
                                                                             \
-  notproduct(bool, LogEvents, trueInDebug,                                  \
-          "Enable Event log")                                               \
+  diagnostic(bool, LogEvents, true,                                         \
+             "Enable the various ring buffer event logs")                   \
+                                                                            \
+  diagnostic(intx, LogEventsBufferEntries, 10,                              \
+             "Enable the various ring buffer event logs")                   \
                                                                             \
   product(bool, BytecodeVerificationRemote, true,                           \
           "Enables the Java bytecode verifier for remote classes")          \
@@ -1042,6 +1052,9 @@
   notproduct(bool, PrintSystemDictionaryAtExit, false,                      \
           "Prints the system dictionary at exit")                           \
                                                                             \
+  experimental(intx, PredictedLoadedClassCount, 0,                          \
+          "Experimental: Tune loaded class cache starting size.")           \
+                                                                            \
   diagnostic(bool, UnsyncloadClass, false,                                  \
           "Unstable: VM calls loadClass unsynchronized. Custom "            \
           "class loader  must call VM synchronized for findClass "          \
--- a/hotspot/src/share/vm/runtime/init.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/runtime/init.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -65,7 +65,7 @@
 void InlineCacheBuffer_init();
 void compilerOracle_init();
 void compilationPolicy_init();
-
+void compileBroker_init();
 
 // Initialization after compiler initialization
 bool universe_post_init();  // must happen after compiler_init
@@ -120,6 +120,7 @@
   InlineCacheBuffer_init();
   compilerOracle_init();
   compilationPolicy_init();
+  compileBroker_init();
   VMRegImpl::set_regName();
 
   if (!universe_post_init()) {
--- a/hotspot/src/share/vm/runtime/mutex.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/runtime/mutex.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,6 +1,6 @@
 
 /*
- * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1296,10 +1296,6 @@
 
       assert(this->rank() >= 0, "bad lock rank");
 
-      if (LogMultipleMutexLocking && locks != NULL) {
-        Events::log("thread " INTPTR_FORMAT " locks %s, already owns %s", new_owner, name(), locks->name());
-      }
-
       // Deadlock avoidance rules require us to acquire Mutexes only in
       // a global total order. For example m1 is the lowest ranked mutex
       // that the thread holds and m2 is the mutex the thread is trying
@@ -1343,10 +1339,6 @@
     #ifdef ASSERT
       Monitor *locks = old_owner->owned_locks();
 
-      if (LogMultipleMutexLocking && locks != this) {
-        Events::log("thread " INTPTR_FORMAT " unlocks %s, still owns %s", old_owner, this->name(), locks->name());
-      }
-
       // remove "this" from the owned locks list
 
       Monitor *prev = NULL;
--- a/hotspot/src/share/vm/runtime/safepoint.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/runtime/safepoint.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -95,6 +95,7 @@
 SafepointSynchronize::SynchronizeState volatile SafepointSynchronize::_state = SafepointSynchronize::_not_synchronized;
 volatile int  SafepointSynchronize::_waiting_to_block = 0;
 volatile int SafepointSynchronize::_safepoint_counter = 0;
+int SafepointSynchronize::_current_jni_active_count = 0;
 long  SafepointSynchronize::_end_of_last_safepoint = 0;
 static volatile int PageArmed = 0 ;        // safepoint polling page is RO|RW vs PROT_NONE
 static volatile int TryingToBlock = 0 ;    // proximate value -- for advisory use only
@@ -135,9 +136,11 @@
 
   RuntimeService::record_safepoint_begin();
 
-  {
   MutexLocker mu(Safepoint_lock);
 
+  // Reset the count of active JNI critical threads
+  _current_jni_active_count = 0;
+
   // Set number of threads to wait for, before we initiate the callbacks
   _waiting_to_block = nof_threads;
   TryingToBlock     = 0 ;
@@ -375,6 +378,9 @@
 
   OrderAccess::fence();
 
+  // Update the count of active JNI critical regions
+  GC_locker::set_jni_lock_count(_current_jni_active_count);
+
   if (TraceSafepoint) {
     VM_Operation *op = VMThread::vm_operation();
     tty->print_cr("Entering safepoint region: %s", (op != NULL) ? op->name() : "no vm operation");
@@ -392,7 +398,6 @@
     // Record how much time spend on the above cleanup tasks
     update_statistics_on_cleanup_end(os::javaTimeNanos());
   }
-  }
 }
 
 // Wake up all threads, so they are ready to resume execution after the safepoint
@@ -539,6 +544,42 @@
 }
 
 
+// See if the thread is running inside a lazy critical native and
+// update the thread critical count if so.  Also set a suspend flag to
+// cause the native wrapper to return into the JVM to do the unlock
+// once the native finishes.
+void SafepointSynchronize::check_for_lazy_critical_native(JavaThread *thread, JavaThreadState state) {
+  if (state == _thread_in_native &&
+      thread->has_last_Java_frame() &&
+      thread->frame_anchor()->walkable()) {
+    // This thread might be in a critical native nmethod so look at
+    // the top of the stack and increment the critical count if it
+    // is.
+    frame wrapper_frame = thread->last_frame();
+    CodeBlob* stub_cb = wrapper_frame.cb();
+    if (stub_cb != NULL &&
+        stub_cb->is_nmethod() &&
+        stub_cb->as_nmethod_or_null()->is_lazy_critical_native()) {
+      // A thread could potentially be in a critical native across
+      // more than one safepoint, so only update the critical state on
+      // the first one.  When it returns it will perform the unlock.
+      if (!thread->do_critical_native_unlock()) {
+#ifdef ASSERT
+        if (!thread->in_critical()) {
+          GC_locker::increment_debug_jni_lock_count();
+        }
+#endif
+        thread->enter_critical();
+        // Make sure the native wrapper calls back on return to
+        // perform the needed critical unlock.
+        thread->set_critical_native_unlock();
+      }
+    }
+  }
+}
+
+
+
 // -------------------------------------------------------------------------------------------------------
 // Implementation of Safepoint callback point
 
@@ -585,6 +626,11 @@
         _waiting_to_block--;
         thread->safepoint_state()->set_has_called_back(true);
 
+        if (thread->in_critical()) {
+          // Notice that this thread is in a critical section
+          increment_jni_active_count();
+        }
+
         // Consider (_waiting_to_block < 2) to pipeline the wakeup of the VM thread
         if (_waiting_to_block == 0) {
           Safepoint_lock->notify_all();
@@ -861,8 +907,13 @@
   // running, but are actually at a safepoint. We will happily
   // agree and update the safepoint state here.
   if (SafepointSynchronize::safepoint_safe(_thread, state)) {
-      roll_forward(_at_safepoint);
-      return;
+    roll_forward(_at_safepoint);
+    SafepointSynchronize::check_for_lazy_critical_native(_thread, state);
+    if (_thread->in_critical()) {
+      // Notice that this thread is in a critical section
+      SafepointSynchronize::increment_jni_active_count();
+    }
+    return;
   }
 
   if (state == _thread_in_vm) {
--- a/hotspot/src/share/vm/runtime/safepoint.hpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/runtime/safepoint.hpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,7 @@
 #include "code/nmethod.hpp"
 #include "memory/allocation.hpp"
 #include "runtime/extendedPC.hpp"
+#include "runtime/mutexLocker.hpp"
 #include "runtime/os.hpp"
 #include "utilities/ostream.hpp"
 
@@ -92,6 +93,7 @@
  private:
   static volatile SynchronizeState _state;     // Threads might read this flag directly, without acquireing the Threads_lock
   static volatile int _waiting_to_block;       // number of threads we are waiting for to block
+  static int _current_jni_active_count;        // Counts the number of active critical natives during the safepoint
 
   // This counter is used for fast versions of jni_Get<Primitive>Field.
   // An even value means there is no ongoing safepoint operations.
@@ -138,6 +140,8 @@
 
   static bool safepoint_safe(JavaThread *thread, JavaThreadState state);
 
+  static void check_for_lazy_critical_native(JavaThread *thread, JavaThreadState state);
+
   // Query
   inline static bool is_at_safepoint()   { return _state == _synchronized;  }
   inline static bool is_synchronizing()  { return _state == _synchronizing;  }
@@ -146,6 +150,11 @@
     return (_state != _not_synchronized);
   }
 
+  inline static void increment_jni_active_count() {
+    assert_locked_or_safepoint(Safepoint_lock);
+    _current_jni_active_count++;
+  }
+
   // Called when a thread volantary blocks
   static void   block(JavaThread *thread);
   static void   signal_thread_at_safepoint()              { _waiting_to_block--; }
--- a/hotspot/src/share/vm/runtime/sharedRuntime.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/runtime/sharedRuntime.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -886,9 +886,9 @@
     // for AbortVMOnException flag
     NOT_PRODUCT(Exceptions::debug_check_abort("java.lang.NullPointerException"));
     if (exception_kind == IMPLICIT_NULL) {
-      Events::log("Implicit null exception at " INTPTR_FORMAT " to " INTPTR_FORMAT, pc, target_pc);
+      Events::log_exception(thread, "Implicit null exception at " INTPTR_FORMAT " to " INTPTR_FORMAT, pc, target_pc);
     } else {
-      Events::log("Implicit division by zero exception at " INTPTR_FORMAT " to " INTPTR_FORMAT, pc, target_pc);
+      Events::log_exception(thread, "Implicit division by zero exception at " INTPTR_FORMAT " to " INTPTR_FORMAT, pc, target_pc);
     }
     return target_pc;
   }
@@ -1541,7 +1541,6 @@
   if (caller.is_compiled_frame() && !caller.is_deoptimized_frame()) {
 
     address pc = caller.pc();
-    Events::log("update call-site at pc " INTPTR_FORMAT, pc);
 
     // Default call_addr is the location of the "basic" call.
     // Determine the address of the call we a reresolving. With
@@ -2679,6 +2678,20 @@
   return nm;
 }
 
+JRT_ENTRY_NO_ASYNC(void, SharedRuntime::block_for_jni_critical(JavaThread* thread))
+  assert(thread == JavaThread::current(), "must be");
+  // The code is about to enter a JNI lazy critical native method and
+  // _needs_gc is true, so if this thread is already in a critical
+  // section then just return, otherwise this thread should block
+  // until needs_gc has been cleared.
+  if (thread->in_critical()) {
+    return;
+  }
+  // Lock and unlock a critical section to give the system a chance to block
+  GC_locker::lock_critical(thread);
+  GC_locker::unlock_critical(thread);
+JRT_END
+
 #ifdef HAVE_DTRACE_H
 // Create a dtrace nmethod for this method.  The wrapper converts the
 // java compiled calling convention to the native convention, makes a dummy call
--- a/hotspot/src/share/vm/runtime/sharedRuntime.hpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/runtime/sharedRuntime.hpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -462,6 +462,9 @@
                                           VMRegPair *regs,
                                           BasicType ret_type );
 
+  // Block before entering a JNI critical method
+  static void block_for_jni_critical(JavaThread* thread);
+
 #ifdef HAVE_DTRACE_H
   // Generate a dtrace wrapper for a given method.  The method takes arguments
   // in the Java compiled code convention, marshals them to the native
--- a/hotspot/src/share/vm/runtime/thread.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/runtime/thread.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,6 +33,7 @@
 #include "interpreter/linkResolver.hpp"
 #include "interpreter/oopMapCache.hpp"
 #include "jvmtifiles/jvmtiEnv.hpp"
+#include "memory/gcLocker.inline.hpp"
 #include "memory/oopFactory.hpp"
 #include "memory/universe.inline.hpp"
 #include "oops/instanceKlass.hpp"
@@ -1600,8 +1601,6 @@
     // java.lang.Thread.dispatchUncaughtException
     if (uncaught_exception.not_null()) {
       Handle group(this, java_lang_Thread::threadGroup(threadObj()));
-      Events::log("uncaught exception INTPTR_FORMAT " " INTPTR_FORMAT " " INTPTR_FORMAT",
-        (address)uncaught_exception(), (address)threadObj(), (address)group());
       {
         EXCEPTION_MARK;
         // Check if the method Thread.dispatchUncaughtException() exists. If so
@@ -2280,6 +2279,26 @@
   }
 }
 
+// This is a variant of the normal
+// check_special_condition_for_native_trans with slightly different
+// semantics for use by critical native wrappers.  It does all the
+// normal checks but also performs the transition back into
+// thread_in_Java state.  This is required so that critical natives
+// can potentially block and perform a GC if they are the last thread
+// exiting the GC_locker.
+void JavaThread::check_special_condition_for_native_trans_and_transition(JavaThread *thread) {
+  check_special_condition_for_native_trans(thread);
+
+  // Finish the transition
+  thread->set_thread_state(_thread_in_Java);
+
+  if (thread->do_critical_native_unlock()) {
+    ThreadInVMfromJavaNoAsyncException tiv(thread);
+    GC_locker::unlock_critical(thread);
+    thread->clear_critical_native_unlock();
+  }
+}
+
 // We need to guarantee the Threads_lock here, since resumes are not
 // allowed during safepoint synchronization
 // Can only resume from an external suspension
@@ -3885,7 +3904,7 @@
   ThreadService::add_thread(p, daemon);
 
   // Possible GC point.
-  Events::log("Thread added: " INTPTR_FORMAT, p);
+  Events::log(p, "Thread added: " INTPTR_FORMAT, p);
 }
 
 void Threads::remove(JavaThread* p) {
@@ -3930,7 +3949,7 @@
   } // unlock Threads_lock
 
   // Since Events::log uses a lock, we grab it outside the Threads_lock
-  Events::log("Thread exited: " INTPTR_FORMAT, p);
+  Events::log(p, "Thread exited: " INTPTR_FORMAT, p);
 }
 
 // Threads_lock must be held when this is called (or must be called during a safepoint)
--- a/hotspot/src/share/vm/runtime/thread.hpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/runtime/thread.hpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -182,7 +182,8 @@
     _ext_suspended          = 0x40000000U, // thread has self-suspended
     _deopt_suspend          = 0x10000000U, // thread needs to self suspend for deopt
 
-    _has_async_exception    = 0x00000001U  // there is a pending async exception
+    _has_async_exception    = 0x00000001U, // there is a pending async exception
+    _critical_native_unlock = 0x00000002U  // Must call back to unlock JNI critical lock
   };
 
   // various suspension related flags - atomically updated
@@ -350,6 +351,15 @@
     clear_suspend_flag(_has_async_exception);
   }
 
+  bool do_critical_native_unlock() const { return (_suspend_flags & _critical_native_unlock) != 0; }
+
+  void set_critical_native_unlock() {
+    set_suspend_flag(_critical_native_unlock);
+  }
+  void clear_critical_native_unlock() {
+    clear_suspend_flag(_critical_native_unlock);
+  }
+
   // Support for Unhandled Oop detection
 #ifdef CHECK_UNHANDLED_OOPS
  private:
@@ -1038,6 +1048,11 @@
   // Check for async exception in addition to safepoint and suspend request.
   static void check_special_condition_for_native_trans(JavaThread *thread);
 
+  // Same as check_special_condition_for_native_trans but finishes the
+  // transition into thread_in_Java mode so that it can potentially
+  // block.
+  static void check_special_condition_for_native_trans_and_transition(JavaThread *thread);
+
   bool is_ext_suspend_completed(bool called_by_wait, int delay, uint32_t *bits);
   bool is_ext_suspend_completed_with_lock(uint32_t *bits) {
     MutexLockerEx ml(SR_lock(), Mutex::_no_safepoint_check_flag);
@@ -1310,8 +1325,10 @@
 
   // JNI critical regions. These can nest.
   bool in_critical()    { return _jni_active_critical > 0; }
-  void enter_critical() { assert(Thread::current() == this,
-                                 "this must be current thread");
+  bool in_last_critical()  { return _jni_active_critical == 1; }
+  void enter_critical() { assert(Thread::current() == this ||
+                                 Thread::current()->is_VM_thread() && SafepointSynchronize::is_synchronizing(),
+                                 "this must be current thread or synchronizing");
                           _jni_active_critical++; }
   void exit_critical()  { assert(Thread::current() == this,
                                  "this must be current thread");
--- a/hotspot/src/share/vm/runtime/vmStructs.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/runtime/vmStructs.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -314,7 +314,7 @@
   nonstatic_field(instanceKlass,               _init_thread,                                  Thread*)                               \
   nonstatic_field(instanceKlass,               _vtable_len,                                   int)                                   \
   nonstatic_field(instanceKlass,               _itable_len,                                   int)                                   \
-  nonstatic_field(instanceKlass,               _reference_type,                               ReferenceType)                         \
+  nonstatic_field(instanceKlass,               _reference_type,                               u1)                                    \
   volatile_nonstatic_field(instanceKlass,      _oop_map_cache,                                OopMapCache*)                          \
   nonstatic_field(instanceKlass,               _jni_ids,                                      JNIid*)                                \
   nonstatic_field(instanceKlass,               _osr_nmethods_head,                            nmethod*)                              \
@@ -2261,13 +2261,6 @@
                                                                           \
   declare_constant(SymbolTable::symbol_table_size)                        \
                                                                           \
-  /********************/                                                  \
-  /* SystemDictionary */                                                  \
-  /********************/                                                  \
-                                                                          \
-  declare_constant(SystemDictionary::_loader_constraint_size)             \
-  declare_constant(SystemDictionary::_nof_buckets)                        \
-                                                                          \
   /***********************************/                                   \
   /* LoaderConstraintTable constants */                                   \
   /***********************************/                                   \
--- a/hotspot/src/share/vm/runtime/vm_version.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/runtime/vm_version.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -165,6 +165,13 @@
   return VM_RELEASE;
 }
 
+// NOTE: do *not* use stringStream. this function is called by
+//       fatal error handlers. if the crash is in native thread,
+//       stringStream cannot get resource allocated and will SEGV.
+const char* Abstract_VM_Version::jre_release_version() {
+  return JRE_RELEASE_VERSION;
+}
+
 #define OS       LINUX_ONLY("linux")             \
                  WINDOWS_ONLY("windows")         \
                  SOLARIS_ONLY("solaris")         \
--- a/hotspot/src/share/vm/runtime/vm_version.hpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/runtime/vm_version.hpp	Mon Feb 13 14:31:32 2012 +0000
@@ -71,6 +71,7 @@
 
   // Internal version providing additional build information
   static const char* internal_vm_info_string();
+  static const char* jre_release_version();
 
   // does HW support an 8-byte compare-exchange operation?
   static bool supports_cx8()  {return _supports_cx8;}
--- a/hotspot/src/share/vm/trace/traceMacros.hpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/trace/traceMacros.hpp	Mon Feb 13 14:31:32 2012 +0000
@@ -40,4 +40,8 @@
 #define TRACE_START() true
 #define TRACE_INITIALIZE() 0
 
+#define TRACE_SET_KLASS_TRACE_ID(x1, x2) do { } while (0)
+#define TRACE_DEFINE_KLASS_METHODS typedef int ___IGNORED_hs_trace_type1
+#define TRACE_DEFINE_KLASS_TRACE_ID typedef int ___IGNORED_hs_trace_type2
+
 #endif
--- a/hotspot/src/share/vm/utilities/debug.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/utilities/debug.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -601,18 +601,6 @@
 }
 
 
-extern "C" void events() {
-  Command c("events");
-  Events::print_last(tty, 50);
-}
-
-
-extern "C" void nevents(int n) {
-  Command c("events");
-  Events::print_last(tty, n);
-}
-
-
 // Given a heap address that was valid before the most recent GC, if
 // the oop that used to contain it is still live, prints the new
 // location of the oop and the address. Useful for tracking down
--- a/hotspot/src/share/vm/utilities/debug.hpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/utilities/debug.hpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,16 +33,23 @@
 // Simple class to format the ctor arguments into a fixed-sized buffer.
 template <size_t bufsz = 256>
 class FormatBuffer {
-public:
+ public:
   inline FormatBuffer(const char * format, ...);
   inline void append(const char* format, ...);
+  inline void print(const char* format, ...);
+  inline void printv(const char* format, va_list ap);
   operator const char *() const { return _buf; }
 
-private:
+  char* buffer() { return _buf; }
+  int size() { return bufsz; }
+
+ private:
   FormatBuffer(const FormatBuffer &); // prevent copies
 
-private:
+ protected:
   char _buf[bufsz];
+
+  inline FormatBuffer();
 };
 
 template <size_t bufsz>
@@ -54,6 +61,24 @@
 }
 
 template <size_t bufsz>
+FormatBuffer<bufsz>::FormatBuffer() {
+  _buf[0] = '\0';
+}
+
+template <size_t bufsz>
+void FormatBuffer<bufsz>::print(const char * format, ...) {
+  va_list argp;
+  va_start(argp, format);
+  jio_vsnprintf(_buf, bufsz, format, argp);
+  va_end(argp);
+}
+
+template <size_t bufsz>
+void FormatBuffer<bufsz>::printv(const char * format, va_list argp) {
+  jio_vsnprintf(_buf, bufsz, format, argp);
+}
+
+template <size_t bufsz>
 void FormatBuffer<bufsz>::append(const char* format, ...) {
   // Given that the constructor does a vsnprintf we can assume that
   // _buf is already initialized.
--- a/hotspot/src/share/vm/utilities/events.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/utilities/events.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
 #include "memory/allocation.inline.hpp"
 #include "runtime/mutexLocker.hpp"
 #include "runtime/osThread.hpp"
+#include "runtime/threadCritical.hpp"
 #include "runtime/threadLocalStorage.hpp"
 #include "runtime/timer.hpp"
 #include "utilities/events.hpp"
@@ -43,184 +44,40 @@
 #endif
 
 
-#ifndef PRODUCT
-
-////////////////////////////////////////////////////////////////////////////
-// Event
-
-typedef u4 EventID;
-
-class Event VALUE_OBJ_CLASS_SPEC  {
- private:
-  jlong       _time_tick;
-  intx        _thread_id;
-  const char* _format;
-  int         _indent;
-  intptr_t    _arg_1;
-  intptr_t    _arg_2;
-  intptr_t    _arg_3;
-
-  // only EventBuffer::add_event() can assign event id
-  friend class EventBuffer;
-  EventID     _id;
-
- public:
-
-  void clear() { _format = NULL; }
-
-  EventID id() const { return _id; }
-
-  void fill(int indent, const char* format, intptr_t arg_1, intptr_t arg_2, intptr_t arg_3) {
-    _format = format;
-    _arg_1  = arg_1;
-    _arg_2  = arg_2;
-    _arg_3  = arg_3;
-
-    _indent = indent;
-
-    _thread_id = os::current_thread_id();
-    _time_tick = os::elapsed_counter();
-  }
-
-  void print_on(outputStream *st) {
-    if (_format == NULL) return;
-    st->print("  %d", _thread_id);
-    st->print("  %3.2g   ", (double)_time_tick / os::elapsed_frequency());
-    st->fill_to(20);
-    for (int index = 0; index < _indent; index++) {
-      st->print("| ");
-    }
-    st->print_cr(_format, _arg_1, _arg_2, _arg_3);
-  }
-};
-
-////////////////////////////////////////////////////////////////////////////
-// EventBuffer
-//
-// Simple lock-free event queue. Every event has a unique 32-bit id.
-// It's fine if two threads add events at the same time, because they
-// will get different event id, and then write to different buffer location.
-// However, it is assumed that add_event() is quick enough (or buffer size
-// is big enough), so when one thread is adding event, there can't be more
-// than "size" events created by other threads; otherwise we'll end up having
-// two threads writing to the same location.
-
-class EventBuffer : AllStatic {
- private:
-  static Event* buffer;
-  static int    size;
-  static jint   indent;
-  static volatile EventID _current_event_id;
-
-  static EventID get_next_event_id() {
-    return (EventID)Atomic::add(1, (jint*)&_current_event_id);
-  }
-
- public:
-  static void inc_indent() { Atomic::inc(&indent); }
-  static void dec_indent() { Atomic::dec(&indent); }
+EventLog* Events::_logs = NULL;
+StringEventLog* Events::_messages = NULL;
+StringEventLog* Events::_exceptions = NULL;
+StringEventLog* Events::_deopt_messages = NULL;
 
-  static bool get_event(EventID id, Event* event) {
-    int index = (int)(id % size);
-    if (buffer[index].id() == id) {
-      memcpy(event, &buffer[index], sizeof(Event));
-      // check id again; if buffer[index] is being updated by another thread,
-      // event->id() will contain different value.
-      return (event->id() == id);
-    } else {
-      // id does not match - id is invalid, or event is overwritten
-      return false;
-    }
-  }
-
-  // add a new event to the queue; if EventBuffer is full, this call will
-  // overwrite the oldest event in the queue
-  static EventID add_event(const char* format,
-                           intptr_t arg_1, intptr_t arg_2, intptr_t arg_3) {
-    // assign a unique id
-    EventID id = get_next_event_id();
-
-    // event will be copied to buffer[index]
-    int index = (int)(id % size);
-
-    // first, invalidate id, buffer[index] can't have event with id = index + 2
-    buffer[index]._id = index + 2;
-
-    // make sure everyone has seen that buffer[index] is invalid
-    OrderAccess::fence();
-
-    // ... before updating its value
-    buffer[index].fill(indent, format, arg_1, arg_2, arg_3);
-
-    // finally, set up real event id, now buffer[index] contains valid event
-    OrderAccess::release_store(&(buffer[index]._id), id);
-
-    return id;
-  }
-
-  static void print_last(outputStream *st, int number) {
-    st->print_cr("[Last %d events in the event buffer]", number);
-    st->print_cr("-<thd>-<elapsed sec>-<description>---------------------");
+EventLog::EventLog() {
+  // This normally done during bootstrap when we're only single
+  // threaded but use a ThreadCritical to ensure inclusion in case
+  // some are created slightly late.
+  ThreadCritical tc;
+  _next = Events::_logs;
+  Events::_logs = this;
+}
 
-    int count = 0;
-    EventID id = _current_event_id;
-    while (count < number) {
-      Event event;
-      if (get_event(id, &event)) {
-         event.print_on(st);
-      }
-      id--;
-      count++;
-    }
-  }
-
-  static void print_all(outputStream* st) {
-    print_last(st, size);
-  }
-
-  static void init() {
-    // Allocate the event buffer
-    size   = EventLogLength;
-    buffer = NEW_C_HEAP_ARRAY(Event, size);
-
-    _current_event_id = 0;
-
-    // Clear the event buffer
-    for (int index = 0; index < size; index++) {
-      buffer[index]._id = index + 1;       // index + 1 is invalid id
-      buffer[index].clear();
-    }
-  }
-};
-
-Event*           EventBuffer::buffer;
-int              EventBuffer::size;
-volatile EventID EventBuffer::_current_event_id;
-int              EventBuffer::indent;
-
-////////////////////////////////////////////////////////////////////////////
-// Events
-
-// Events::log() is safe for signal handlers
-void Events::log(const char* format, ...) {
-  if (LogEvents) {
-    va_list ap;
-    va_start(ap, format);
-    intptr_t arg_1 = va_arg(ap, intptr_t);
-    intptr_t arg_2 = va_arg(ap, intptr_t);
-    intptr_t arg_3 = va_arg(ap, intptr_t);
-    va_end(ap);
-
-    EventBuffer::add_event(format, arg_1, arg_2, arg_3);
+// For each registered event logger, print out the current contents of
+// the buffer.  This is normally called when the JVM is crashing.
+void Events::print_all(outputStream* out) {
+  EventLog* log = _logs;
+  while (log != NULL) {
+    log->print_log_on(out);
+    log = log->next();
   }
 }
 
-void Events::print_all(outputStream *st) {
-  EventBuffer::print_all(st);
+void Events::init() {
+  if (LogEvents) {
+    _messages = new StringEventLog("Events");
+    _exceptions = new StringEventLog("Internal exceptions");
+    _deopt_messages = new StringEventLog("Deoptimization events");
+  }
 }
 
-void Events::print_last(outputStream *st, int number) {
-  EventBuffer::print_last(st, number);
+void eventlog_init() {
+  Events::init();
 }
 
 ///////////////////////////////////////////////////////////////////////////
@@ -230,37 +87,17 @@
   if (LogEvents) {
     va_list ap;
     va_start(ap, format);
-    intptr_t arg_1 = va_arg(ap, intptr_t);
-    intptr_t arg_2 = va_arg(ap, intptr_t);
-    intptr_t arg_3 = va_arg(ap, intptr_t);
+    // Save a copy of begin message and log it.
+    _buffer.printv(format, ap);
+    Events::log(NULL, _buffer);
     va_end(ap);
-
-    EventBuffer::add_event(format, arg_1, arg_2, arg_3);
-    EventBuffer::inc_indent();
   }
 }
 
 EventMark::~EventMark() {
   if (LogEvents) {
-    EventBuffer::dec_indent();
-    EventBuffer::add_event("done", 0, 0, 0);
+    // Append " done" to the begin message and log it
+    _buffer.append(" done");
+    Events::log(NULL, _buffer);
   }
 }
-
-///////////////////////////////////////////////////////////////////////////
-
-void eventlog_init() {
-  EventBuffer::init();
-}
-
-int print_all_events(outputStream *st) {
-  EventBuffer::print_all(st);
-  return 1;
-}
-
-#else
-
-void eventlog_init() {}
-int print_all_events(outputStream *st) { return 0; }
-
-#endif // PRODUCT
--- a/hotspot/src/share/vm/utilities/events.hpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/utilities/events.hpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,10 @@
 #define SHARE_VM_UTILITIES_EVENTS_HPP
 
 #include "memory/allocation.hpp"
+#include "runtime/mutexLocker.hpp"
+#include "runtime/thread.hpp"
 #include "utilities/top.hpp"
+#include "utilities/vmError.hpp"
 
 // Events and EventMark provide interfaces to log events taking place in the vm.
 // This facility is extremly useful for post-mortem debugging. The eventlog
@@ -47,26 +50,246 @@
 //   Max 3 arguments are saved for each logged event.
 //
 
-class Events : AllStatic {
+// The base event log dumping class that is registered for dumping at
+// crash time.  This is a very generic interface that is mainly here
+// for completeness.  Normally the templated EventLogBase would be
+// subclassed to provide different log types.
+class EventLog : public CHeapObj {
+  friend class Events;
+
+ private:
+  EventLog* _next;
+
+  EventLog* next() const { return _next; }
+
  public:
-  // Logs an event, format as printf
-  static void log(const char* format, ...) PRODUCT_RETURN;
+  // Automatically registers the log so that it will be printed during
+  // crashes.
+  EventLog();
+
+  virtual void print_log_on(outputStream* out) = 0;
+};
+
+
+// A templated subclass of EventLog that provides basic ring buffer
+// functionality.  Most event loggers should subclass this, possibly
+// providing a more featureful log function if the existing copy
+// semantics aren't appropriate.  The name is used as the label of the
+// log when it is dumped during a crash.
+template <class T> class EventLogBase : public EventLog {
+  template <class X> class EventRecord {
+   public:
+    jlong   timestamp;
+    Thread* thread;
+    X       data;
+  };
+
+ protected:
+  Mutex           _mutex;
+  const char*     _name;
+  int             _length;
+  int             _index;
+  int             _count;
+  EventRecord<T>* _records;
+
+ public:
+  EventLogBase<T>(const char* name, int length = LogEventsBufferEntries):
+    _name(name),
+    _length(length),
+    _count(0),
+    _index(0),
+    _mutex(Mutex::event, name) {
+    _records = new EventRecord<T>[length];
+  }
 
-  // Prints all events in the buffer
-  static void print_all(outputStream* st) PRODUCT_RETURN;
+  // move the ring buffer to next open slot and return the index of
+  // the slot to use for the current message.  Should only be called
+  // while mutex is held.
+  int compute_log_index() {
+    int index = _index;
+    if (_count < _length) _count++;
+    _index++;
+    if (_index >= _length) _index = 0;
+    return index;
+  }
+
+  bool should_log() {
+    // Don't bother adding new entries when we're crashing.  This also
+    // avoids mutating the ring buffer when printing the log.
+    return !VMError::fatal_error_in_progress();
+  }
+
+  // Print the contents of the log
+  void print_log_on(outputStream* out);
+
+ private:
+  void print_log_impl(outputStream* out);
+
+  // Print a single element.  A templated implementation might need to
+  // be declared by subclasses.
+  void print(outputStream* out, T& e);
 
-  // Prints last number events from the event buffer
-  static void print_last(outputStream *st, int number) PRODUCT_RETURN;
+  void print(outputStream* out, EventRecord<T>& e) {
+    out->print("Event: " INT64_FORMAT " ", e.timestamp);
+    if (e.thread != NULL) {
+      out->print("Thread " INTPTR_FORMAT " ", e.thread);
+    }
+    print(out, e.data);
+  }
+};
+
+// A simple wrapper class for fixed size text messages.
+class StringLogMessage : public FormatBuffer<132> {
+ public:
+  // Wrap this buffer in a stringStream.
+  stringStream stream() {
+    return stringStream(_buf, sizeof(_buf));
+  }
+};
+
+// A simple ring buffer of fixed size text messages.
+class StringEventLog : public EventLogBase<StringLogMessage> {
+ public:
+  StringEventLog(const char* name, int count = LogEventsBufferEntries) : EventLogBase<StringLogMessage>(name, count) {}
+
+  void logv(Thread* thread, const char* format, va_list ap) {
+    if (!should_log()) return;
+
+    jlong timestamp = os::javaTimeNanos() / NANOSECS_PER_MILLISEC;
+    MutexLockerEx ml(&_mutex, Mutex::_no_safepoint_check_flag);
+    int index = compute_log_index();
+    _records[index].thread = thread;
+    _records[index].timestamp = timestamp;
+    _records[index].data.printv(format, ap);
+  }
+
+  void log(Thread* thread, const char* format, ...) {
+    va_list ap;
+    va_start(ap, format);
+    logv(thread, format, ap);
+    va_end(ap);
+  }
+
 };
 
+
+
+class Events : AllStatic {
+  friend class EventLog;
+
+ private:
+  static EventLog* _logs;
+
+  // A log for generic messages that aren't well categorized.
+  static StringEventLog* _messages;
+
+  // A log for internal exception related messages, like internal
+  // throws and implicit exceptions.
+  static StringEventLog* _exceptions;
+
+  // Deoptization related messages
+  static StringEventLog* _deopt_messages;
+
+ public:
+  static void print_all(outputStream* out);
+
+  static void print() {
+    print_all(tty);
+  }
+
+  // Logs a generic message with timestamp and format as printf.
+  static void log(Thread* thread, const char* format, ...);
+
+  // Log exception related message
+  static void log_exception(Thread* thread, const char* format, ...);
+
+  static void log_deopt_message(Thread* thread, const char* format, ...);
+
+  // Register default loggers
+  static void init();
+};
+
+
+inline void Events::log(Thread* thread, const char* format, ...) {
+  if (LogEvents) {
+    va_list ap;
+    va_start(ap, format);
+    _messages->logv(thread, format, ap);
+    va_end(ap);
+  }
+}
+
+inline void Events::log_exception(Thread* thread, const char* format, ...) {
+  if (LogEvents) {
+    va_list ap;
+    va_start(ap, format);
+    _exceptions->logv(thread, format, ap);
+    va_end(ap);
+  }
+}
+
+inline void Events::log_deopt_message(Thread* thread, const char* format, ...) {
+  if (LogEvents) {
+    va_list ap;
+    va_start(ap, format);
+    _deopt_messages->logv(thread, format, ap);
+    va_end(ap);
+  }
+}
+
+
+template <class T>
+inline void EventLogBase<T>::print_log_on(outputStream* out) {
+  if (ThreadLocalStorage::get_thread_slow() == NULL) {
+    // Not a regular Java thread so don't bother locking
+    print_log_impl(out);
+  } else {
+    MutexLockerEx ml(&_mutex, Mutex::_no_safepoint_check_flag);
+    print_log_impl(out);
+  }
+}
+
+// Dump the ring buffer entries that current have entries.
+template <class T>
+inline void EventLogBase<T>::print_log_impl(outputStream* out) {
+  out->print_cr("%s (%d events):", _name, _count);
+  if (_count == 0) {
+    out->print_cr("No events");
+    return;
+  }
+
+  if (_count < _length) {
+    for (int i = 0; i < _count; i++) {
+      print(out, _records[i]);
+    }
+  } else {
+    for (int i = _index; i < _length; i++) {
+      print(out, _records[i]);
+    }
+    for (int i = 0; i < _index; i++) {
+      print(out, _records[i]);
+    }
+  }
+  out->cr();
+}
+
+// Implement a printing routine for the StringLogMessage
+template <>
+inline void EventLogBase<StringLogMessage>::print(outputStream* out, StringLogMessage& lm) {
+  out->print_raw(lm);
+  out->cr();
+}
+
+// Place markers for the beginning and end up of a set of events.
+// These end up in the default log.
 class EventMark : public StackObj {
+  StringLogMessage _buffer;
+
  public:
   // log a begin event, format as printf
-  EventMark(const char* format, ...) PRODUCT_RETURN;
+  EventMark(const char* format, ...);
   // log an end event
-  ~EventMark() PRODUCT_RETURN;
+  ~EventMark();
 };
 
-int print_all_events(outputStream *st);
-
 #endif // SHARE_VM_UTILITIES_EVENTS_HPP
--- a/hotspot/src/share/vm/utilities/exceptions.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/utilities/exceptions.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -160,7 +160,7 @@
   thread->set_pending_exception(h_exception(), file, line);
 
   // vm log
-  Events::log("throw_exception " INTPTR_FORMAT, (address)h_exception());
+  Events::log_exception(thread, "Threw " INTPTR_FORMAT " at %s:%d", (address)h_exception(), file, line);
 }
 
 
--- a/hotspot/src/share/vm/utilities/hashtable.hpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/utilities/hashtable.hpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -183,7 +183,6 @@
 
   // Accessor
   int entry_size() const { return _entry_size; }
-  int table_size() { return _table_size; }
 
   // The following method is MT-safe and may be used with caution.
   BasicHashtableEntry* bucket(int i);
@@ -195,6 +194,7 @@
   BasicHashtableEntry* new_entry(unsigned int hashValue);
 
 public:
+  int table_size() { return _table_size; }
   void set_entry(int index, BasicHashtableEntry* entry);
 
   void add_entry(int index, BasicHashtableEntry* entry);
--- a/hotspot/src/share/vm/utilities/vmError.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/utilities/vmError.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,6 +36,7 @@
 #include "utilities/decoder.hpp"
 #include "utilities/defaultStream.hpp"
 #include "utilities/errorReporter.hpp"
+#include "utilities/events.hpp"
 #include "utilities/top.hpp"
 #include "utilities/vmError.hpp"
 
@@ -693,7 +694,14 @@
        st->cr();
      }
 
-  STEP(200, "(printing dynamic libraries)" )
+  STEP(200, "(printing ring buffers)" )
+
+     if (_verbose) {
+       Events::print_all(st);
+       st->cr();
+     }
+
+  STEP(205, "(printing dynamic libraries)" )
 
      if (_verbose) {
        // dynamic libraries, or memory map
--- a/hotspot/src/share/vm/utilities/xmlstream.cpp	Mon Feb 13 14:26:25 2012 +0000
+++ b/hotspot/src/share/vm/utilities/xmlstream.cpp	Mon Feb 13 14:31:32 2012 +0000
@@ -192,8 +192,11 @@
     _element_close_stack_ptr = cur_tag + strlen(cur_tag) + 1;
     _element_depth -= 1;
   }
-  if (bad_tag && !VMThread::should_terminate() && !is_error_reported())
+  if (bad_tag && !VMThread::should_terminate() && !VM_Exit::vm_exited() &&
+      !is_error_reported())
+  {
     assert(false, "bad tag in log");
+  }
 }
 #endif
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/7090976/Test7090976.java	Mon Feb 13 14:31:32 2012 +0000
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+/**
+ * @test
+ * @bug 7090976
+ * @summary Eclipse/CDT causes a JVM crash while indexing C++ code
+ *
+ * @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacement Test7090976
+ */
+
+public class Test7090976 {
+
+    static interface I1 {
+        public void m1();
+    };
+
+    static interface I2 {
+        public void m2();
+    };
+
+    static interface I extends I1,I2 {
+    }
+
+    static class A implements I1 {
+        int v = 0;
+        int v2;
+
+        public void m1() {
+            v2 = v;
+        }
+    }
+
+    static class B implements I2 {
+        Object v = new Object();
+        Object v2;
+
+        public void m2() {
+            v2 = v;
+        }
+    }
+
+    private void test(A a)
+    {
+        if (a instanceof I) {
+            I i = (I)a;
+            i.m1();
+            i.m2();
+        }
+    }
+
+    public static void main(String[] args)
+    {
+        Test7090976 t = new Test7090976();
+        A a = new A();
+        B b = new B();
+        for (int i = 0; i < 10000; i++) {
+            t.test(a);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/7141637/SpreadNullArg.java	Mon Feb 13 14:31:32 2012 +0000
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2011 SAP AG.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test SpreadNullArg
+ * @bug 7141637
+ * @summary  verifies that the MethodHandle spread adapter can gracefully handle null arguments.
+ * @run main SpreadNullArg
+ * @author volker.simonis@gmail.com
+ */
+
+import java.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodHandles;
+import java.lang.invoke.MethodType;
+
+public class SpreadNullArg {
+
+  public static void main(String args[]) {
+
+    MethodType mt_ref_arg = MethodType.methodType(int.class, Integer.class);
+    MethodHandle mh_spreadInvoker = MethodHandles.spreadInvoker(mt_ref_arg, 0);
+    MethodHandle mh_spread_target;
+    int result = 42;
+
+    try {
+      mh_spread_target =
+        MethodHandles.lookup().findStatic(SpreadNullArg.class, "target_spread_arg", mt_ref_arg);
+      result = (int) mh_spreadInvoker.invokeExact(mh_spread_target, (Object[]) null);
+    } catch(NullPointerException e) {
+      // Expected exception - do nothing!
+    } catch(Throwable e) {
+      throw new Error(e);
+    }
+
+    if (result != 42) throw new Error("Expected NullPointerException was not thrown");
+  }
+
+  public static int target_spread_arg(Integer i1) {
+    return i1.intValue();
+  }
+
+}
--- a/jaxp/.hgtags	Mon Feb 13 14:26:25 2012 +0000
+++ b/jaxp/.hgtags	Mon Feb 13 14:31:32 2012 +0000
@@ -145,3 +145,5 @@
 d41eeadf5c1344b88c5051a997aec9e1ad7ce1db jdk8-b21
 cf9d6ec44f891236ad18451021d6dcd57dc82f7b jdk8-b22
 95102fd334183d15dc98a95dd0d749527b6c7300 jdk8-b23
+7836655e2495646c462f13de73dcc3ada197b64f jdk8-b24
+bb694c151fc7b5c8f9edc8af6a80738530feacaf jdk8-b25
--- a/jaxws/.hgtags	Mon Feb 13 14:26:25 2012 +0000
+++ b/jaxws/.hgtags	Mon Feb 13 14:31:32 2012 +0000
@@ -145,3 +145,5 @@
 c266cab0e3fff05f2048c23046c14d60f7102175 jdk8-b21
 8d3df89b0f2d3c603b2edb0f5e24af1245397cc6 jdk8-b22
 25ce7a0004874273f6aeda14e7c3538cba34bdf1 jdk8-b23
+e0d90803439b174fe0b0033e09d50444ba12498f jdk8-b24
+b376d901e006cd9e0c59733c84e190aace23eec6 jdk8-b25
--- a/jdk/.hgtags	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/.hgtags	Mon Feb 13 14:31:32 2012 +0000
@@ -145,3 +145,5 @@
 664fa4fb0ee411ef048903c479f8b962fcdb2f4b jdk8-b21
 dda27c73d8db4a9c7a23872b6f0c5106edcb2021 jdk8-b22
 54202e0148ec7d4570cab5bc9b00d216a7677569 jdk8-b23
+34029a0c69bba882264a29fc822f8283fd15f104 jdk8-b24
+ec17fbe5b8fbc52da070eec43b4711d9354b2ab8 jdk8-b25
--- a/jdk/make/com/sun/Makefile	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/make/com/sun/Makefile	Mon Feb 13 14:31:32 2012 +0000
@@ -47,7 +47,6 @@
                      org rowset net/httpserver
 SUBDIRS_misc       = $(SCRIPT_SUBDIR) tracing servicetag nio demo
 
-# Omit mirror since it's built with the apt tool.
 SUBDIRS_tools      = tools
 
 include $(BUILDDIR)/common/Subdirs.gmk
--- a/jdk/make/com/sun/nio/sctp/Exportedfiles.gmk	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/make/com/sun/nio/sctp/Exportedfiles.gmk	Mon Feb 13 14:31:32 2012 +0000
@@ -29,11 +29,11 @@
 
 ifneq ($(PLATFORM), windows)
 FILES_export = \
-    sun/nio/ch/SctpAssocChange.java \
-    sun/nio/ch/SctpChannelImpl.java \
-    sun/nio/ch/SctpNet.java \
-    sun/nio/ch/SctpPeerAddrChange.java \
-    sun/nio/ch/SctpResultContainer.java \
-    sun/nio/ch/SctpServerChannelImpl.java \
-    sun/nio/ch/SctpStdSocketOption.java
+    sun/nio/ch/sctp/AssociationChange.java \
+    sun/nio/ch/sctp/SctpChannelImpl.java \
+    sun/nio/ch/sctp/SctpNet.java \
+    sun/nio/ch/sctp/PeerAddrChange.java \
+    sun/nio/ch/sctp/ResultContainer.java \
+    sun/nio/ch/sctp/SctpServerChannelImpl.java \
+    sun/nio/ch/sctp/SctpStdSocketOption.java
 endif
--- a/jdk/make/com/sun/nio/sctp/FILES_java.gmk	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/make/com/sun/nio/sctp/FILES_java.gmk	Mon Feb 13 14:31:32 2012 +0000
@@ -42,25 +42,25 @@
 	com/sun/nio/sctp/SendFailedNotification.java \
 	com/sun/nio/sctp/ShutdownNotification.java \
 	\
-	sun/nio/ch/SctpMessageInfoImpl.java \
-	sun/nio/ch/SctpStdSocketOption.java
+	sun/nio/ch/sctp/MessageInfoImpl.java \
+	sun/nio/ch/sctp/SctpStdSocketOption.java
 
 ifneq ($(PLATFORM), windows)
 FILES_java += \
-	sun/nio/ch/SctpAssocChange.java \
-	sun/nio/ch/SctpAssociationImpl.java \
-	sun/nio/ch/SctpChannelImpl.java \
-	sun/nio/ch/SctpMultiChannelImpl.java \
-	sun/nio/ch/SctpNet.java \
-	sun/nio/ch/SctpNotification.java \
-	sun/nio/ch/SctpPeerAddrChange.java \
-	sun/nio/ch/SctpResultContainer.java \
-	sun/nio/ch/SctpSendFailed.java \
-	sun/nio/ch/SctpServerChannelImpl.java \
-	sun/nio/ch/SctpShutdown.java
+	sun/nio/ch/sctp/AssociationChange.java \
+	sun/nio/ch/sctp/AssociationImpl.java \
+	sun/nio/ch/sctp/PeerAddrChange.java \
+	sun/nio/ch/sctp/ResultContainer.java \
+	sun/nio/ch/sctp/SctpChannelImpl.java \
+	sun/nio/ch/sctp/SctpMultiChannelImpl.java \
+	sun/nio/ch/sctp/SctpNet.java \
+	sun/nio/ch/sctp/SctpNotification.java \
+	sun/nio/ch/sctp/SctpServerChannelImpl.java \
+	sun/nio/ch/sctp/SendFailed.java \
+	sun/nio/ch/sctp/Shutdown.java
 else
 FILES_java += \
-	sun/nio/ch/SctpChannelImpl.java \
-	sun/nio/ch/SctpMultiChannelImpl.java \
-	sun/nio/ch/SctpServerChannelImpl.java
+	sun/nio/ch/sctp/SctpChannelImpl.java \
+	sun/nio/ch/sctp/SctpMultiChannelImpl.java \
+	sun/nio/ch/sctp/SctpServerChannelImpl.java
 endif
--- a/jdk/make/com/sun/nio/sctp/Makefile	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/make/com/sun/nio/sctp/Makefile	Mon Feb 13 14:31:32 2012 +0000
@@ -47,14 +47,16 @@
 #
 # Find platform-specific C source files
 #
-vpath %.c $(PLATFORM_SRC)/native/sun/nio/ch
+vpath %.c $(PLATFORM_SRC)/native/sun/nio/ch/sctp
 
 #
 # Include nio.h, net_util.h, sun_nio_ch_IOStatus.h, etc
 #
 OTHER_INCLUDES += \
   -I$(SHARE_SRC)/native/sun/nio/ch \
+  -I$(SHARE_SRC)/native/sun/nio/ch/sctp \
   -I$(SHARE_SRC)/native/java/net \
+  -I$(PLATFORM_SRC)/native/sun/nio/ch \
   -I$(PLATFORM_SRC)/native/java/net \
   -I$(CLASSHDRDIR)/../../../../java/java.nio/nio/CClassHeaders
 
@@ -75,5 +77,5 @@
 
 clean clobber::
 	$(RM) -r $(CLASSDESTDIR)/com/sun/nio/sctp
-	$(RM) -r $(CLASSDESTDIR)/sun/nio/ch
+	$(RM) -r $(CLASSDESTDIR)/sun/nio/ch/sctp
 
--- a/jdk/make/com/sun/nio/sctp/mapfile-vers	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/make/com/sun/nio/sctp/mapfile-vers	Mon Feb 13 14:31:32 2012 +0000
@@ -25,30 +25,30 @@
 
 SUNWprivate_1.1 {
 	global:
-		Java_sun_nio_ch_SctpNet_init;
-		Java_sun_nio_ch_SctpNet_socket0;
-		Java_sun_nio_ch_SctpNet_bindx;
-		Java_sun_nio_ch_SctpNet_branch0;
-		Java_sun_nio_ch_SctpNet_listen0;
-		Java_sun_nio_ch_SctpNet_connect0;
-		Java_sun_nio_ch_SctpNet_close0;
-		Java_sun_nio_ch_SctpNet_preClose0;
-		Java_sun_nio_ch_SctpNet_getLocalAddresses0;
-		Java_sun_nio_ch_SctpNet_getRemoteAddresses0;
-		Java_sun_nio_ch_SctpNet_getPrimAddrOption0;
-		Java_sun_nio_ch_SctpNet_setPrimAddrOption0;
-		Java_sun_nio_ch_SctpNet_setPeerPrimAddrOption0;
-		Java_sun_nio_ch_SctpNet_getInitMsgOption0;
-		Java_sun_nio_ch_SctpNet_setInitMsgOption0;
-		Java_sun_nio_ch_SctpNet_getIntOption0;
-		Java_sun_nio_ch_SctpNet_setIntOption0;
-		Java_sun_nio_ch_SctpNet_shutdown0;
-		Java_sun_nio_ch_SctpChannelImpl_initIDs;
-		Java_sun_nio_ch_SctpChannelImpl_checkConnect;
-		Java_sun_nio_ch_SctpChannelImpl_receive0;
-		Java_sun_nio_ch_SctpChannelImpl_send0;
-		Java_sun_nio_ch_SctpServerChannelImpl_initIDs;
-		Java_sun_nio_ch_SctpServerChannelImpl_accept0;
+		Java_sun_nio_ch_sctp_SctpNet_init;
+		Java_sun_nio_ch_sctp_SctpNet_socket0;
+		Java_sun_nio_ch_sctp_SctpNet_bindx;
+		Java_sun_nio_ch_sctp_SctpNet_branch0;
+		Java_sun_nio_ch_sctp_SctpNet_listen0;
+		Java_sun_nio_ch_sctp_SctpNet_connect0;
+		Java_sun_nio_ch_sctp_SctpNet_close0;
+		Java_sun_nio_ch_sctp_SctpNet_preClose0;
+		Java_sun_nio_ch_sctp_SctpNet_getLocalAddresses0;
+		Java_sun_nio_ch_sctp_SctpNet_getRemoteAddresses0;
+		Java_sun_nio_ch_sctp_SctpNet_getPrimAddrOption0;
+		Java_sun_nio_ch_sctp_SctpNet_setPrimAddrOption0;
+		Java_sun_nio_ch_sctp_SctpNet_setPeerPrimAddrOption0;
+		Java_sun_nio_ch_sctp_SctpNet_getInitMsgOption0;
+		Java_sun_nio_ch_sctp_SctpNet_setInitMsgOption0;
+		Java_sun_nio_ch_sctp_SctpNet_getIntOption0;
+		Java_sun_nio_ch_sctp_SctpNet_setIntOption0;
+		Java_sun_nio_ch_sctp_SctpNet_shutdown0;
+		Java_sun_nio_ch_sctp_SctpChannelImpl_initIDs;
+		Java_sun_nio_ch_sctp_SctpChannelImpl_checkConnect;
+		Java_sun_nio_ch_sctp_SctpChannelImpl_receive0;
+		Java_sun_nio_ch_sctp_SctpChannelImpl_send0;
+		Java_sun_nio_ch_sctp_SctpServerChannelImpl_initIDs;
+		Java_sun_nio_ch_sctp_SctpServerChannelImpl_accept0;
                 JNI_OnLoad;
 	local:
 		*;
--- a/jdk/make/common/Release-embedded.gmk	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/make/common/Release-embedded.gmk	Mon Feb 13 14:31:32 2012 +0000
@@ -189,7 +189,7 @@
 	$(RM) -r $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/audio
 	$(RM) -fr $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/applet
 	$(RM)  $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/$(LIBARCH)/awt_robot
-	$(RM) -r $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/$(LIBARCH)/xawt
+	$(RM)  $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/$(LIBARCH)/libawt_xawt.so
 	$(RM) -r $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/$(LIBARCH)/libsplashscreen.so
 	@# Remove oblique fonts and reduce font support to LucidaSansRegular only
 	$(RM) -fr $(JRE_REDUCED_HEADLESS_IMAGE_DIR)/lib/oblique-fonts
--- a/jdk/make/common/Release.gmk	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/make/common/Release.gmk	Mon Feb 13 14:31:32 2012 +0000
@@ -132,7 +132,6 @@
 JDK_MAN_PAGES =            \
 	$(JRE_MAN_PAGES)   \
 	appletviewer.1     \
-        apt.1              \
 	extcheck.1         \
 	idlj.1             \
 	jar.1              \
@@ -264,7 +263,6 @@
 	com/sun/java/swing		\
 	com/sun/javadoc			\
 	com/sun/jmx			\
-	com/sun/mirror			\
 	com/sun/source			\
 	com/sun/naming			\
 	com/sun/security/auth		\
@@ -346,7 +344,6 @@
 	com/sun/javadoc		\
 	com/sun/jdi		\
 	com/sun/jarsigner	\
-	com/sun/mirror		\
 	com/sun/source          \
 	com/sun/tools/classfile \
 	com/sun/tools/doclets   \
@@ -356,16 +353,16 @@
 	com/sun/tools/hat       \
 	com/sun/tools/javac     \
 	com/sun/tools/javadoc   \
-	com/sun/tools/apt       \
 	com/sun/tools/javah     \
 	com/sun/tools/javap     \
 	com/sun/tools/corba     \
 	com/sun/tools/internal/xjc       \
 	com/sun/tools/internal/ws       \
-	META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory \
-	META-INF/services/com.sun.tools.xjc.Plugin \
+	META-INF/services/com.sun.tools.internal.ws.wscompile.Plugin \
+	META-INF/services/com.sun.tools.internal.xjc.Plugin \
 	com/sun/istack/internal/tools       \
-	com/sun/istack/internal/ws       \
+	com/sun/tools/internal/jxc/ap   \
+	com/sun/tools/internal/ws/wscompile/plugin/at_generated \
         com/sun/codemodel       \
         com/sun/tools/internal/jxc             \
         com/sun/xml/internal/rngom       \
@@ -438,7 +435,6 @@
 	java-rmi.cgi \
 	javac$(EXE_SUFFIX) \
 	javadoc$(EXE_SUFFIX) \
-	apt$(EXE_SUFFIX) \
 	javah$(EXE_SUFFIX) \
 	javap$(EXE_SUFFIX) \
 	jcmd$(EXE_SUFFIX) \
@@ -525,13 +521,10 @@
 	$(ECHO) "com/sun/javadoc/" >> $@
 	$(ECHO) "com/sun/jdi/" >> $@
 	$(ECHO) "com/sun/jarsigner/" >> $@
-	$(ECHO) "com/sun/mirror/" >> $@
 	$(ECHO) "com/sun/source/" >> $@
 	$(ECHO) "com/sun/istack/internal/tools/" >> $@
-	$(ECHO) "com/sun/istack/internal/ws/" >> $@
 	$(ECHO) "META-INF/services/com.sun.jdi.connect.Connector" >> $@
 	$(ECHO) "META-INF/services/com.sun.jdi.connect.spi.TransportService" >> $@
-	$(ECHO) "META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory" >> $@
 	$(ECHO) "META-INF/services/com.sun.tools.xjc.Plugin" >> $@
 	$(ECHO) "com/sun/tools/" >> $@
 	$(ECHO) "sun/jvmstat/" >> $@
@@ -1000,7 +993,7 @@
 	@#
 	@# files that might not exist need to be touched.
 	@#
-	$(TOUCH) $(CLASSBINDIR)/META-INF/services/com.sun.tools.xjc.Plugin
+	$(TOUCH) $(CLASSBINDIR)/META-INF/services/com.sun.tools.internal.xjc.Plugin
 	@#
 	@# lib/tools.jar
 	@#
--- a/jdk/make/common/internal/Defs-jaxws.gmk	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/make/common/internal/Defs-jaxws.gmk	Mon Feb 13 14:31:32 2012 +0000
@@ -34,7 +34,6 @@
      javax/xml/ws \
      javax/jws \
      javax/annotation \
-     com/sun/istack/internal \
      com/sun/xml/internal/bind \
      com/sun/xml/internal/fastinfoset \
      com/sun/xml/internal/messaging \
@@ -42,13 +41,13 @@
      com/sun/xml/internal/txw2 \
      com/sun/xml/internal/ws \
      com/sun/xml/internal/stream/buffer
+
 NOT_USED_PACKAGES += \
      com/sun/tools/internal/txw2
 
 IMPORT_TOOLS_PACKAGES += \
      com/sun/codemodel \
      com/sun/istack/internal/tools \
-     com/sun/istack/internal/ws \
      com/sun/xml/internal/rngom \
      com/sun/xml/internal/xsom \
      com/sun/xml/internal/dtdparser \
@@ -56,6 +55,9 @@
      com/sun/tools/internal/ws \
      com/sun/tools/internal/jxc \
      org/relaxng \
-     META-INF/services/com.sun.mirror.apt.AnnotationProcessorFactory \
-     META-INF/services/com.sun.tools.internal.xjc.Plugin
+     META-INF/services/com.sun.tools.internal.ws.wscompile.Plugin \
+     META-INF/services/com.sun.tools.internal.xjc.Plugin \
+     com/sun/tools/internal/jxc/ap \
+     com/sun/tools/internal/ws/wscompile/plugin/at_generated
 
+
--- a/jdk/make/common/internal/Defs-langtools.gmk	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/make/common/internal/Defs-langtools.gmk	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -32,9 +32,7 @@
 
 IMPORT_TOOLS_PACKAGES +=            \
       com/sun/javadoc               \
-      com/sun/mirror                \
       com/sun/source                \
-      com/sun/tools/apt             \
       com/sun/tools/classfile       \
       com/sun/tools/doclets         \
       com/sun/tools/javac           \
--- a/jdk/make/docs/Makefile	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/make/docs/Makefile	Mon Feb 13 14:31:32 2012 +0000
@@ -1,4 +1,4 @@
-# Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -358,64 +358,6 @@
 
 #############################################################
 #
-# mirrordocs
-#
-
-# Part of langtools
-ifdef LANGTOOLS_DIST
-  ALL_OTHER_TARGETS += mirrordocs
-endif
-
-MIRROR_DOCDIR      := $(JDK_API_DOCSDIR)/apt/mirror
-MIRROR2COREAPI     := ../../$(JDKJRE2COREAPI)
-MIRROR_DOCTITLE    := Mirror API
-MIRROR_WINDOWTITLE := Mirror API
-MIRROR_HEADER      := <strong>Mirror API</strong>
-MIRROR_BOTTOM      := $(call CommonBottom,$(MIRROR_FIRST_COPYRIGHT_YEAR))
-MIRROR_GROUPNAME   := Packages
-MIRROR_OVERVIEW    := $(IMPORTSRCDIR)/com/sun/mirror/overview.html
-MIRROR_REGEXP      := com.sun.mirror.*
-# MIRROR_PKGS is located in NON_CORE_PKGS.gmk
-
-# The index.html, options, and packages files
-MIRROR_INDEX_FILE    = $(MIRROR_DOCDIR)/index.html
-MIRROR_OPTIONS_FILE  = $(DOCSTMPDIR)/mirror.options
-MIRROR_PACKAGES_FILE = $(DOCSTMPDIR)/mirror.packages
-
-mirrordocs: $(MIRROR_INDEX_FILE)
-
-# Set relative location to core api document root
-$(MIRROR_INDEX_FILE): GET2DOCSDIR=$(MIRROR2COREAPI)/..
-
-# Run javadoc if the index file is out of date or missing
-$(MIRROR_INDEX_FILE): $(MIRROR_OPTIONS_FILE) $(MIRROR_PACKAGES_FILE)
-	$(prep-javadoc)
-	$(call JavadocSummary,$(MIRROR_OPTIONS_FILE),$(MIRROR_PACKAGES_FILE))
-	$(JAVADOC_CMD) $(JAVADOC_VM_MEMORY_FLAGS) -d $(@D) \
-	  @$(MIRROR_OPTIONS_FILE) @$(MIRROR_PACKAGES_FILE)
-
-# Create file with javadoc options in it
-$(MIRROR_OPTIONS_FILE): $(MIRROR_OVERVIEW)
-	$(prep-target)
-	@($(call OptionOnly,$(COMMON_JAVADOCFLAGS))			; \
-	  $(call OptionPair,-sourcepath,$(RELEASEDOCS_SOURCEPATH))	; \
-	  $(call OptionPair,-encoding,ascii)				; \
-	  $(call OptionPair,-overview,$(MIRROR_OVERVIEW))		; \
-	  $(call OptionPair,-doctitle,$(MIRROR_DOCTITLE))		; \
-	  $(call OptionPair,-windowtitle,$(MIRROR_WINDOWTITLE) $(DRAFT_WINTITLE));\
-	  $(call OptionPair,-header,$(MIRROR_HEADER)$(DRAFT_HEADER))	; \
-	  $(call OptionPair,-bottom,$(MIRROR_BOTTOM)$(DRAFT_BOTTOM)) 	; \
-	  $(call OptionTrip,-group,$(MIRROR_GROUPNAME),$(MIRROR_REGEXP)); \
-	  $(call OptionTrip,-linkoffline,$(MIRROR2COREAPI),$(COREAPI_DOCSDIR)); \
-        ) >> $@
-
-# Create a file with the package names in it
-$(MIRROR_PACKAGES_FILE): $(DIRECTORY_CACHE) $(call PackageDependencies,$(MIRROR_PKGS))
-	$(prep-target)
-	$(call PackageFilter,$(MIRROR_PKGS))
-
-#############################################################
-#
 # docletapidocs
 #
 
--- a/jdk/make/docs/NON_CORE_PKGS.gmk	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/make/docs/NON_CORE_PKGS.gmk	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -71,11 +71,6 @@
 
 TAGLETAPI_FILE   = com/sun/tools/doclets/Taglet.java
 
-MIRROR_PKGS      = com.sun.mirror.apt           \
-                   com.sun.mirror.declaration   \
-                   com.sun.mirror.type          \
-                   com.sun.mirror.util
-
 ATTACH_PKGS      = com.sun.tools.attach         \
                    com.sun.tools.attach.spi
 
--- a/jdk/make/launchers/Makefile	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/make/launchers/Makefile	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -55,7 +55,6 @@
 
 define make-all-launchers
 $(make-appletviewer)
-$(call make-launcher, apt, com.sun.tools.apt.Main, , )
 $(call make-launcher, extcheck, com.sun.tools.extcheck.Main, , )
 $(call make-launcher, idlj, com.sun.tools.corba.se.idl.toJavaPortable.Compile, , )
 $(call make-launcher, jar, sun.tools.jar.Main, , )
--- a/jdk/make/launchers/Makefile.launcher	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/make/launchers/Makefile.launcher	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, 2005, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -47,10 +47,6 @@
 endif
 
 # Some tools need the wildcard expansion option
-ifeq ($(PROGRAM),apt)
-  WILDCARDS=true
-  NEVER_ACT_AS_SERVER_CLASS_MACHINE=true
-endif
 ifeq ($(PROGRAM),javac)
   WILDCARDS=true
   MAIN_JAVA_ARGS += -J-Xss4m -J-ea:com.sun.tools...
--- a/jdk/make/sun/font/Makefile	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/make/sun/font/Makefile	Mon Feb 13 14:31:32 2012 +0000
@@ -175,7 +175,7 @@
 ifeq ($(PLATFORM), solaris)
   # Note that on Solaris, fontmanager is built against the headless library.
   LDFLAGS      += -L$(LIBDIR)/$(LIBARCH)/headless
-  OTHER_LDLIBS += -lawt -L$(LIBDIR)/$(LIBARCH)/xawt -lmawt -lc $(LIBM) $(LIBCXX)
+  OTHER_LDLIBS += -lawt -lawt_xawt -lc $(LIBM) $(LIBCXX)
 else # PLATFORM is linux
  OTHER_LDLIBS  += -lawt $(LIBM) $(LIBCXX)
   ifeq ("$(CC_VER_MAJOR)", "3")
--- a/jdk/make/sun/font/t2k/Makefile	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/make/sun/font/t2k/Makefile	Mon Feb 13 14:31:32 2012 +0000
@@ -99,7 +99,7 @@
     endif                           
   else
     ifeq ($(PLATFORM), solaris)
-      OTHER_LDLIBS += -lawt -L$(LIBDIR)/$(LIBARCH)/xawt -lmawt
+      OTHER_LDLIBS += -lawt -lawt_xawt
     endif
   endif
 endif
--- a/jdk/make/sun/headless/Makefile	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/make/sun/headless/Makefile	Mon Feb 13 14:31:32 2012 +0000
@@ -28,11 +28,9 @@
 NO_ROBOT = true
 MOTIF_VERSION = none
 MOTIF_VERSION_STRING=none
-LIB_LOCATION = $(LIBDIR)/$(LIBARCH)/headless
 
 PACKAGE = sun.awt
-LIBRARY = mawt
-LIBRARY_OUTPUT = headless
+LIBRARY = awt_headless
 PRODUCT = sun
 
 include $(BUILDDIR)/common/Defs.gmk
--- a/jdk/make/sun/jawt/Makefile	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/make/sun/jawt/Makefile	Mon Feb 13 14:31:32 2012 +0000
@@ -113,17 +113,17 @@
 #
 ifeq ($(PLATFORM), solaris)
   ifndef BUILD_HEADLESS_ONLY
-    OTHER_LDLIBS = -L$(LIBDIR)/$(LIBARCH) -L$(OPENWIN_LIB) -L$(LIBDIR)/$(LIBARCH)/xawt -lmawt -L/usr/openwin/sfw/lib$(ISA_DIR) -lXrender
+    OTHER_LDLIBS = -L$(LIBDIR)/$(LIBARCH) -L$(OPENWIN_LIB) -lawt_xawt -L/usr/openwin/sfw/lib$(ISA_DIR) -lXrender
   else
-    OTHER_LDLIBS = -L$(LIBDIR)/$(LIBARCH) -L$(OPENWIN_LIB) -L$(LIBDIR)/$(LIBARCH)/headless -lmawt -L/usr/openwin/sfw/lib$(ISA_DIR) -lXrender
+    OTHER_LDLIBS = -L$(LIBDIR)/$(LIBARCH) -L$(OPENWIN_LIB) -lawt_headless -L/usr/openwin/sfw/lib$(ISA_DIR) -lXrender
   endif
 endif # PLATFORM
 
 ifeq ($(PLATFORM), linux)
   ifndef BUILD_HEADLESS_ONLY
-    OTHER_LDLIBS = -L$(LIBDIR)/$(LIBARCH) -lawt -L$(LIBDIR)/$(LIBARCH)/xawt -lmawt
+    OTHER_LDLIBS = -L$(LIBDIR)/$(LIBARCH) -lawt -lawt_xawt
   else
-    OTHER_LDLIBS = -L$(LIBDIR)/$(LIBARCH) -lawt -L$(LIBDIR)/$(LIBARCH)/headless -lmawt
+    OTHER_LDLIBS = -L$(LIBDIR)/$(LIBARCH) -lawt -lawt_headless
     CFLAGS += -DHEADLESS
   endif
 endif # PLATFORM
--- a/jdk/make/sun/xawt/Makefile	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/make/sun/xawt/Makefile	Mon Feb 13 14:31:32 2012 +0000
@@ -25,9 +25,7 @@
 
 BUILDDIR = ../..
 PACKAGE = sun.awt.X11
-LIBRARY = mawt
-LIBRARY_OUTPUT = xawt
-LIB_LOCATION = $(LIBDIR)/$(LIBARCH)/xawt
+LIBRARY = awt_xawt
 PRODUCT = sun
 
 include $(BUILDDIR)/common/Defs.gmk
--- a/jdk/src/linux/doc/man/apt.1	Mon Feb 13 14:26:25 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,153 +0,0 @@
-." Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
-." DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-."
-." This code is free software; you can redistribute it and/or modify it
-." under the terms of the GNU General Public License version 2 only, as
-." published by the Free Software Foundation.
-."
-." This code is distributed in the hope that it will be useful, but WITHOUT
-." ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-." FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-." version 2 for more details (a copy is included in the LICENSE file that
-." accompanied this code).
-."
-." You should have received a copy of the GNU General Public License version
-." 2 along with this work; if not, write to the Free Software Foundation,
-." Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-."
-." Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-." or visit www.oracle.com if you need additional information or have any
-." questions.
-."
-.TH apt 1 "10 May 2011"
-
-.LP
-.SH "NAME"
-.LP
-.LP
-\f2apt\fP \- annotation processing tool
-.LP
-.SH "SYNOPSIS"
-.LP
-.LP
-\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]
-.LP
-.SH "PARAMETERS"
-.LP
-.LP
-Options may be in any order. For a discussion of parameters which apply to a specific option, see OPTIONS below.
-.LP
-.RS 3
-.TP 3
-sourcefiles 
-Zero or more source files to be processed. 
-.TP 3
-@files 
-One or more files that list source files or other options 
-.RE
-
-.LP
-.SH "DESCRIPTION"
-.LP
-.LP
-\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.
-.LP
-.LP
-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.
-.LP
-.LP
-A fuller discussion of how the tool operates as well as instructions for developing with \f2apt\fP are in 
-.na
-\f4Getting Started with \fP\f4apt\fP. @
-.fi
-http://download.oracle.com/javase/7/docs/technotes/guides/apt/GettingStarted.html
-.LP
-.SH "OPTIONS"
-.LP
-.SS 
-apt specific options
-.LP
-.RS 3
-.TP 3
-\-s dir 
-Specify the directory root under which processor\-generated source files will be placed; files are placed in subdirectories based on package namespace. 
-.TP 3
-\-nocompile 
-Do not compile source files to class files. 
-.TP 3
-\-print 
-Print out textual representation of specified types; perform no annotation processing or compilation. 
-.TP 3
-\-A[key[=val]] 
-Options to pass to annotation processors \-\- these are not interpreted by \f2apt\fP directly, but are made available for use by individual processors 
-.TP 3
-\-factorypath path 
-Specify where to find annotation processor factories; if this option is used, the classpath is \f2not\fP searched for factories. 
-.TP 3
-\-factory classname 
-Name of annotation processor factory to use; bypasses default discovery process 
-.TP 3
-\-version 
-Print version information. 
-.TP 3
-\-X 
-Display information about non\-standard options. 
-.RE
-
-.LP
-.SS 
-Options shared with javac
-.LP
-.RS 3
-.TP 3
-\-d dir 
-Specify where to place processor and javac generated class files 
-.TP 3
-\-cp path or \-classpath path 
-Specify where to find user class files and annotation processor factories. If \f2\-factorypath\fP is given, the classpath is not searched for factories. 
-.RE
-
-.LP
-.LP
-Consult the javac(1) man page for information on \f2javac\fP options.
-.LP
-.SS 
-Non\-Standard Options
-.LP
-.RS 3
-.TP 3
-\-XListAnnotationTypes 
-List found annotation types. 
-.TP 3
-\-XListDeclarations 
-List specified and included declarations. 
-.TP 3
-\-XPrintAptRounds 
-Print information about initial and recursive \f2apt\fP rounds. 
-.TP 3
-\-XPrintFactoryInfo 
-Print information about which annotations a factory is asked to process. 
-.TP 3
-\-XclassesAsDecls 
-Treat both class and source files as declarations to process. 
-.RE
-
-.LP
-.LP
-\f3Note\fP: Because these options are non\-standard, they are subject to change without notice.
-.LP
-.SH "NOTES"
-.LP
-.LP
-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.
-.LP
-.SH "SEE ALSO"
-.LP
-.RS 3
-.TP 2
-o
-javac(1), java(1) 
-.RE
-
-.LP
- 
--- a/jdk/src/linux/doc/man/ja/apt.1	Mon Feb 13 14:26:25 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,153 +0,0 @@
-." Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
-." DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-."
-." This code is free software; you can redistribute it and/or modify it
-." under the terms of the GNU General Public License version 2 only, as
-." published by the Free Software Foundation.
-."
-." This code is distributed in the hope that it will be useful, but WITHOUT
-." ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-." FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-." version 2 for more details (a copy is included in the LICENSE file that
-." accompanied this code).
-."
-." You should have received a copy of the GNU General Public License version
-." 2 along with this work; if not, write to the Free Software Foundation,
-." Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-."
-." Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-." or visit www.oracle.com if you need additional information or have any
-." questions.
-."
-.TH apt 1 "07 May 2011"
-
-.LP
-.SH "NAME"
-.LP
-.LP
-\f2apt\fP \- Ãí¼á½èÍý¥Ä¡¼¥ë
-.LP
-.SH "·Á¼°"
-.LP
-.LP
-\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]
-.LP
-.SH "¥Ñ¥é¥á¡¼¥¿"
-.LP
-.LP
-¥ª¥×¥·¥ç¥ó¤Î»ØÄê½ç½ø¤Ë·è¤Þ¤ê¤Ï¤¢¤ê¤Þ¤»¤ó¡£ÆÃÄê¤Î¥ª¥×¥·¥ç¥ó¤ËŬÍѤµ¤ì¤ë¥Ñ¥é¥á¡¼¥¿¤Ë¤Ä¤¤¤Æ¤Ï¡¢²¼µ­¤Î¡Ö¥ª¥×¥·¥ç¥ó¡×¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£
-.LP
-.RS 3
-.TP 3
-sourcefiles 
-¥¼¥í¡¢1 ¤Ä¡¢¤Þ¤¿¤ÏÊ£¿ô¤Î½èÍýÂоݤΥ½¡¼¥¹¥Õ¥¡¥¤¥ë 
-.TP 3
-@files 
-¥½¡¼¥¹¥Õ¥¡¥¤¥ë¤Þ¤¿¤Ï¾¤Î¥ª¥×¥·¥ç¥ó¤ò°ìÍ÷ɽ¼¨¤¹¤ë 1 ¤Ä¤Þ¤¿¤ÏÊ£¿ô¤Î¥Õ¥¡¥¤¥ë 
-.RE
-
-.LP
-.SH "ÀâÌÀ"
-.LP
-.LP
-\f3Ãí\fP: \f2apt\fP ¥Ä¡¼¥ë¤È¡¢¥Ñ¥Ã¥±¡¼¥¸ \f2com.sun.mirror\fP ¤Ë´Þ¤Þ¤ì¤Æ¤¤¤ë¤½¤ì¤Ë´ØÏ¢¤·¤¿ API ¤Ï¡¢JDK 7 °Ê¹ßÈó¿ä¾©¤Ë¤Ê¤Ã¤Æ¤ª¤ê¡¢JDK ¤Î¼¡¤Î¥á¥¸¥ã¡¼¥ê¥ê¡¼¥¹¤Çºï½ü¤µ¤ì¤ëͽÄê¤Ç¤¹¡£\f2javac(1)\fP ¥Ä¡¼¥ë¤ÇÍøÍѲÄǽ¤Ê¥ª¥×¥·¥ç¥ó¤È¡¢¥Ñ¥Ã¥±¡¼¥¸ \f2javax.annotation.processing\fP ¤ª¤è¤Ó \f2javax.lang.model\fP ¤Ë´Þ¤Þ¤ì¤Æ¤¤¤ë API ¤ò»ÈÍѤ·¤Æ¡¢Ãí¼á¤ò½èÍý¤·¤Æ¤¯¤À¤µ¤¤¡£
-.LP
-.LP
-Ãí¼á½èÍý¥Ä¡¼¥ë \f2apt\fP ¤Ï¡¢¥ê¥Õ¥ì¥¯¥È API ¤È¥µ¥Ý¡¼¥È¥¤¥ó¥Õ¥é¥¹¥È¥é¥¯¥Á¥ã¡¼¤«¤é¹½À®¤µ¤ì¡¢¥×¥í¥°¥é¥àÃí¼á¤ò½èÍý¤·¤Þ¤¹¡£\f2apt\fP ¥ê¥Õ¥ì¥¯¥È API ¤Ï¡¢ ¹½ÃÛ»þ¤Î¥½¡¼¥¹¥Ù¡¼¥¹¤Ç¡¢¥×¥í¥°¥é¥à¹½Â¤¤Ë´Ø¤¹¤ëÆɤ߼è¤êÀìÍѥӥ塼¤òÄ󶡤·¤Þ¤¹¡£¤³¤ì¤é¤Î¥ê¥Õ¥ì¥¯¥È API ¤Ï¡¢Áí¾Î¤òÄɲä·¤¿¸å¤Ë¡¢Java(TM) ¥×¥í¥°¥é¥ß¥ó¥°¸À¸ì¤Î·¿¥·¥¹¥Æ¥à¤òÀµ¤·¤¯¥â¥Ç¥ë²½¤¹¤ë¤è¤¦¤ËÀ߷פµ¤ì¤Æ¤¤¤Þ¤¹¡£ºÇ½é¤Ë¡¢\f2apt\fP ¤Ï¡¢¿·¤·¤¤¥½¡¼¥¹¥³¡¼¥É¤È¾¤Î¥Õ¥¡¥¤¥ë¤òºîÀ®¤¹¤ëÃí¼á¥×¥í¥»¥Ã¥µ¤ò¼Â¹Ô¤·¤Þ¤¹¡£¼¡¤Ë¡¢\f2apt\fP ¤Ï¡¢¸µ¤Î¥½¡¼¥¹¥Õ¥¡¥¤¥ë¤ÈÀ¸À®¤·¤¿¥½¡¼¥¹¥Õ¥¡¥¤¥ë¤ÎξÊý¤ò¥³¥ó¥Ñ¥¤¥ë¤¹¤ë¤¿¤á¡¢³«È¯¤¬³Ú¤Ë¤Ê¤ê¤Þ¤¹¡£¥Ä¡¼¥ë¤È¤Î¥¤¥ó¥¿¥Õ¥§¡¼¥¹¤Ë»ÈÍѤµ¤ì¤ë¥ê¥Õ¥ì¥¯¥È API ¤Ê¤É¤Î API ¤Ï¡¢\f2com.sun.mirror\fP ¤Î¥µ¥Ö¥Ñ¥Ã¥±¡¼¥¸¤Ç¤¹¡£
-.LP
-.LP
-¥Ä¡¼¥ë¤Îµ¡Ç½¤Ë´Ø¤¹¤ë¾ÜºÙ¤È¡¢\f2apt\fP ¤ò»ÈÍѤ·¤¿³«È¯ÊýË¡¤Ë¤Ä¤¤¤Æ¤Ï¡¢
-.na
-\f4¡Öapt ÆþÌç¡×\fP @
-.fi
-http://java.sun.com/javase/6/docs/technotes/guides/apt/GettingStarted.html¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£
-.LP
-.SH "¥ª¥×¥·¥ç¥ó"
-.LP
-.SS 
-apt ¸ÇÍ­¤Î¥ª¥×¥·¥ç¥ó
-.LP
-.RS 3
-.TP 3
-\-s dir 
-¥×¥í¥»¥Ã¥µ¤ÎÀ¸À®¤¹¤ë¥½¡¼¥¹¥Õ¥¡¥¤¥ë¤òÃÖ¤¯¥Ç¥£¥ì¥¯¥È¥ê¥ë¡¼¥È¤ò»ØÄꤷ¤Þ¤¹¡£ ¥Õ¥¡¥¤¥ë¤Ï¡¢¥Ñ¥Ã¥±¡¼¥¸¤Î̾Á°¶õ´Ö¤Ë´ð¤Å¤¤¤Æ¥µ¥Ö¥Ç¥£¥ì¥¯¥È¥ê¤ËÃÖ¤«¤ì¤Þ¤¹¡£ 
-.TP 3
-\-nocompile 
-¥½¡¼¥¹¥Õ¥¡¥¤¥ë¤ò¥¯¥é¥¹¥Õ¥¡¥¤¥ë¤Ë¥³¥ó¥Ñ¥¤¥ë¤·¤Þ¤»¤ó¡£ 
-.TP 3
-\-print 
-»ØÄꤷ¤¿¥¿¥¤¥×¤Î¥Æ¥­¥¹¥Èɽ¸½¤ò½ÐÎϤ·¤Þ¤¹¡£ Ãí¼á½èÍý¤Þ¤¿¤Ï¥³¥ó¥Ñ¥¤¥ë¤Ï¹Ô¤¤¤Þ¤»¤ó¡£ 
-.TP 3
-\-A[key[=val]] 
-Ãí¼á¥×¥í¥»¥Ã¥µ¤ØÅϤ¹¥ª¥×¥·¥ç¥ó¤Ç¤¹¡£ ¤³¤Î¥ª¥×¥·¥ç¥ó¤Ï¡¢\f2apt\fP ¤¬Ä¾Àܲò¼á¤¹¤ë¤Î¤Ç¤Ï¤Ê¤¯¡¢¤½¤ì¤¾¤ì¤Î¥×¥í¥»¥Ã¥µ¤Ë¤è¤Ã¤Æ»ÈÍѤǤ­¤ë¤è¤¦¤ËÊѤ¨¤é¤ì¤Þ¤¹¡£ 
-.TP 3
-\-factorypath path 
-Ãí¼á¥×¥í¥»¥Ã¥µ¥Õ¥¡¥¯¥È¥ê¤ò¸¡º÷¤¹¤ë¾ì½ê¤ò»ØÄꤷ¤Þ¤¹¡£ ¤³¤Î¥ª¥×¥·¥ç¥ó¤ò»ÈÍѤ¹¤ë¾ì¹ç¡¢¥¯¥é¥¹¥Ñ¥¹¤Î¥Õ¥¡¥¯¥È¥ê¤Ï¸¡º÷¤µ¤ì¤Þ¤»¤ó¡£ 
-.TP 3
-\-factory classname 
-»ÈÍѤ¹¤ëÃí¼á¥×¥í¥»¥Ã¥µ¥Õ¥¡¥¯¥È¥ê¤Î̾Á°¤Ç¤¹¡£ ¥Ç¥Õ¥©¥ë¥È¤Î¸¡½Ð¥×¥í¥»¥¹¤ò¾Êά¤·¤Þ¤¹¡£ 
-.TP 3
-\-version 
-¥Ð¡¼¥¸¥ç¥ó¾ðÊó¤ò½ÐÎϤ·¤Þ¤¹¡£ 
-.TP 3
-\-X 
-Èóɸ½à¥ª¥×¥·¥ç¥ó¤Ë´Ø¤¹¤ë¾ðÊó¤òɽ¼¨¤·¤Þ¤¹¡£ 
-.RE
-
-.LP
-.SS 
-javac ¤È¶¦ÍѤ¹¤ë¥ª¥×¥·¥ç¥ó
-.LP
-.RS 3
-.TP 3
-\-d dir 
-¥×¥í¥»¥Ã¥µ¤È javac À¸À®¤Î¥¯¥é¥¹¥Õ¥¡¥¤¥ë¤òÃÖ¤¯¾ì½ê¤ò»ØÄꤷ¤Þ¤¹¡£ 
-.TP 3
-\-cp path ¤Þ¤¿¤Ï \-classpath path 
-¥æ¡¼¥¶¡¼¥¯¥é¥¹¥Õ¥¡¥¤¥ë¤ÈÃí¼á¥×¥í¥»¥Ã¥µ¥Õ¥¡¥¯¥È¥ê¤ò¸¡º÷¤¹¤ë¾ì½ê¤ò»ØÄꤷ¤Þ¤¹¡£\f2\-factorypath\fP ¤¬»ØÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¡¢¥¯¥é¥¹¥Ñ¥¹¤Î¥Õ¥¡¥¯¥È¥ê¤Ï¸¡º÷¤µ¤ì¤Þ¤»¤ó¡£ 
-.RE
-
-.LP
-.LP
-\f2javac\fP ¥ª¥×¥·¥ç¥ó¤Î¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï¡¢javac(1) ¤Î¥Þ¥Ë¥å¥¢¥ë¥Ú¡¼¥¸¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£
-.LP
-.SS 
-Èóɸ½à¥ª¥×¥·¥ç¥ó
-.LP
-.RS 3
-.TP 3
-\-XListAnnotationTypes 
-Ãí¼á¤Î·¿¤Ë¸¡½Ð¤µ¤ì¤ë¥ê¥¹¥È. 
-.TP 3
-\-XListDeclarations 
-»ØÄꤪ¤è¤ÓÀë¸À¤¬¥¤¥ó¥¯¥ë¡¼¥É¤µ¤ì¤ë¥ê¥¹¥È. 
-.TP 3
-\-XPrintAptRounds 
-½é´ü¤ª¤è¤ÓºÆµ¢Åª¤Ê \f2apt\fP ¥é¥¦¥ó¥É¤Ë´Ø¤¹¤ë¾ðÊó¤ò½ÐÎϤ¹¤ë. 
-.TP 3
-\-XPrintFactoryInfo 
-½èÍý¤òÍ׵᤹¤ë¥Õ¥¡¥¯¥È¥ê¤ÎÃí¼á¤Ë´Ø¤¹¤ë¾ðÊó¤ò½ÐÎϤ¹¤ë. 
-.TP 3
-\-XclassesAsDecls 
-¥¯¥é¥¹¥Õ¥¡¥¤¥ë¤È¥½¡¼¥¹¥Õ¥¡¥¤¥ë¤ÎξÊý¤ò¡¢½èÍýÂоݤÎÀë¸À¤È¤·¤Æ½èÍý¤·¤Þ¤¹¡£ 
-.RE
-
-.LP
-.LP
-\f3Ãí\fP: ¤³¤ì¤é¤ÏÈóɸ½à¥ª¥×¥·¥ç¥ó¤Ê¤Î¤Ç¡¢Í½¹ð¤Ê¤¯Êѹ¹¤µ¤ì¤ë²ÄǽÀ­¤¬¤¢¤ê¤Þ¤¹¡£
-.LP
-.SH "Ãí"
-.LP
-.LP
-\f2apt\fP ¥Ä¡¼¥ë¤È¡¢¥Ñ¥Ã¥±¡¼¥¸ \f2com.sun.mirror\fP ¤Ë´Þ¤Þ¤ì¤Æ¤¤¤ë¤½¤ì¤Ë´ØÏ¢¤·¤¿ API ¤Ï¡¢JDK 7 °Ê¹ßÈó¿ä¾©¤Ë¤Ê¤Ã¤Æ¤ª¤ê¡¢JDK ¤Î¼¡¤Î¥á¥¸¥ã¡¼¥ê¥ê¡¼¥¹¤Çºï½ü¤µ¤ì¤ëͽÄê¤Ç¤¹¡£\f2javac(1)\fP ¥Ä¡¼¥ë¤ÇÍøÍѲÄǽ¤Ê¥ª¥×¥·¥ç¥ó¤È¡¢¥Ñ¥Ã¥±¡¼¥¸ \f2javax.annotation.processing\fP ¤ª¤è¤Ó \f2javax.lang.model\fP ¤Ë´Þ¤Þ¤ì¤Æ¤¤¤ë API ¤ò»ÈÍѤ·¤Æ¡¢Ãí¼á¤ò½èÍý¤·¤Æ¤¯¤À¤µ¤¤¡£
-.LP
-.SH "´ØÏ¢¹àÌÜ"
-.LP
-.RS 3
-.TP 2
-o
-javac(1), java(1) 
-.RE
-
-.LP
- 
--- a/jdk/src/share/classes/com/sun/crypto/provider/PBEKey.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/share/classes/com/sun/crypto/provider/PBEKey.java	Mon Feb 13 14:31:32 2012 +0000
@@ -55,9 +55,12 @@
             // Should allow an empty password.
             passwd = new char[0];
         }
-        for (int i=0; i<passwd.length; i++) {
-            if ((passwd[i] < '\u0020') || (passwd[i] > '\u007E')) {
-                throw new InvalidKeySpecException("Password is not ASCII");
+        // Accept "\0" to signify "zero-length password with no terminator".
+        if (!(passwd.length == 1 && passwd[0] == 0)) {
+            for (int i=0; i<passwd.length; i++) {
+                if ((passwd[i] < '\u0020') || (passwd[i] > '\u007E')) {
+                    throw new InvalidKeySpecException("Password is not ASCII");
+                }
             }
         }
         this.key = new byte[passwd.length];
--- a/jdk/src/share/classes/com/sun/crypto/provider/PKCS12PBECipherCore.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/share/classes/com/sun/crypto/provider/PKCS12PBECipherCore.java	Mon Feb 13 14:31:32 2012 +0000
@@ -60,11 +60,16 @@
 
     static byte[] derive(char[] chars, byte[] salt,
                          int ic, int n, int type) {
-        // Add in trailing NULL terminator.
+        // Add in trailing NULL terminator.  Special case:
+        // no terminator if password is "\0".
         int length = chars.length*2;
-        if (length != 0) {
+        if (length == 2 && chars[0] == 0) {
+            chars = new char[0];
+            length = 0;
+        } else {
             length += 2;
         }
+
         byte[] passwd = new byte[length];
         for (int i = 0, j = 0; i < chars.length; i++, j+=2) {
             passwd[j] = (byte) ((chars[i] >>> 8) & 0xFF);
@@ -133,6 +138,9 @@
     }
 
     private static void concat(byte[] src, byte[] dst, int start, int len) {
+        if (src.length == 0) {
+            return;
+        }
         int loop = len / src.length;
         int off, i;
         for (i = 0, off = 0; i < loop; i++, off += src.length)
--- a/jdk/src/share/classes/com/sun/nio/sctp/MessageInfo.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/share/classes/com/sun/nio/sctp/MessageInfo.java	Mon Feb 13 14:31:32 2012 +0000
@@ -94,7 +94,7 @@
         if (streamNumber < 0 || streamNumber > 65536)
             throw new IllegalArgumentException("Invalid stream number");
 
-        return new sun.nio.ch.SctpMessageInfoImpl(null, address, streamNumber);
+        return new sun.nio.ch.sctp.MessageInfoImpl(null, address, streamNumber);
     }
     /**
      * Creates a {@code MessageInfo} instance suitable for use when
@@ -133,8 +133,8 @@
         if (streamNumber < 0 || streamNumber > 65536)
             throw new IllegalArgumentException("Invalid stream number");
 
-        return new sun.nio.ch.SctpMessageInfoImpl(association, address,
-                streamNumber);
+        return new sun.nio.ch.sctp.MessageInfoImpl(association,
+                                                   address, streamNumber);
     }
 
     /**
--- a/jdk/src/share/classes/com/sun/nio/sctp/SctpChannel.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/share/classes/com/sun/nio/sctp/SctpChannel.java	Mon Feb 13 14:31:32 2012 +0000
@@ -162,7 +162,7 @@
      */
     public static SctpChannel open() throws
         IOException {
-        return new sun.nio.ch.SctpChannelImpl((SelectorProvider)null);
+        return new sun.nio.ch.sctp.SctpChannelImpl((SelectorProvider)null);
     }
 
     /**
--- a/jdk/src/share/classes/com/sun/nio/sctp/SctpMultiChannel.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/share/classes/com/sun/nio/sctp/SctpMultiChannel.java	Mon Feb 13 14:31:32 2012 +0000
@@ -162,7 +162,7 @@
      */
     public static SctpMultiChannel open() throws
         IOException {
-        return new sun.nio.ch.SctpMultiChannelImpl((SelectorProvider)null);
+        return new sun.nio.ch.sctp.SctpMultiChannelImpl((SelectorProvider)null);
     }
 
     /**
--- a/jdk/src/share/classes/com/sun/nio/sctp/SctpServerChannel.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/share/classes/com/sun/nio/sctp/SctpServerChannel.java	Mon Feb 13 14:31:32 2012 +0000
@@ -98,7 +98,7 @@
      */
     public static SctpServerChannel open() throws
         IOException {
-        return new sun.nio.ch.SctpServerChannelImpl((SelectorProvider)null);
+        return new sun.nio.ch.sctp.SctpServerChannelImpl((SelectorProvider)null);
     }
 
     /**
--- a/jdk/src/share/classes/com/sun/nio/sctp/SctpStandardSocketOptions.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/share/classes/com/sun/nio/sctp/SctpStandardSocketOptions.java	Mon Feb 13 14:31:32 2012 +0000
@@ -25,7 +25,7 @@
 package com.sun.nio.sctp;
 
 import java.net.SocketAddress;
-import sun.nio.ch.SctpStdSocketOption;
+import sun.nio.ch.sctp.SctpStdSocketOption;
 
 /**
  * SCTP channels supports the socket options defined by this class
@@ -50,7 +50,7 @@
      */
     public static final SctpSocketOption<Boolean> SCTP_DISABLE_FRAGMENTS = new
         SctpStdSocketOption<Boolean>("SCTP_DISABLE_FRAGMENTS", Boolean.class,
-        sun.nio.ch.SctpStdSocketOption.SCTP_DISABLE_FRAGMENTS);
+        sun.nio.ch.sctp.SctpStdSocketOption.SCTP_DISABLE_FRAGMENTS);
 
     /**
      * Enables or disables explicit message completion.
@@ -69,7 +69,7 @@
      */
     public static final SctpSocketOption<Boolean> SCTP_EXPLICIT_COMPLETE = new
         SctpStdSocketOption<Boolean>("SCTP_EXPLICIT_COMPLETE", Boolean.class,
-        sun.nio.ch.SctpStdSocketOption.SCTP_EXPLICIT_COMPLETE);
+        sun.nio.ch.sctp.SctpStdSocketOption.SCTP_EXPLICIT_COMPLETE);
 
     /**
      * Fragmented interleave controls how the presentation of messages occur
@@ -120,7 +120,7 @@
     public static final SctpSocketOption<Integer> SCTP_FRAGMENT_INTERLEAVE =
             new SctpStdSocketOption<Integer>("SCTP_FRAGMENT_INTERLEAVE",
                   Integer.class,
-                  sun.nio.ch.SctpStdSocketOption.SCTP_FRAGMENT_INTERLEAVE);
+                  sun.nio.ch.sctp.SctpStdSocketOption.SCTP_FRAGMENT_INTERLEAVE);
 
     /**
      * The maximum number of streams requested by the local endpoint during
@@ -171,7 +171,7 @@
      */
     public static final SctpSocketOption<Boolean> SCTP_NODELAY =
         new SctpStdSocketOption<Boolean>("SCTP_NODELAY", Boolean.class,
-        sun.nio.ch.SctpStdSocketOption.SCTP_NODELAY);
+        sun.nio.ch.sctp.SctpStdSocketOption.SCTP_NODELAY);
 
     /**
      * Requests that the local SCTP stack use the given peer address as
@@ -246,7 +246,7 @@
      */
     public static final SctpSocketOption<Integer> SO_SNDBUF =
         new SctpStdSocketOption<Integer>("SO_SNDBUF", Integer.class,
-        sun.nio.ch.SctpStdSocketOption.SO_SNDBUF);
+        sun.nio.ch.sctp.SctpStdSocketOption.SO_SNDBUF);
 
     /**
      * The size of the socket receive buffer.
@@ -273,7 +273,7 @@
      */
     public static final SctpSocketOption<Integer> SO_RCVBUF =
         new SctpStdSocketOption<Integer>("SO_RCVBUF", Integer.class,
-        sun.nio.ch.SctpStdSocketOption.SO_RCVBUF);
+        sun.nio.ch.sctp.SctpStdSocketOption.SO_RCVBUF);
 
     /**
      * Linger on close if data is present.
@@ -304,7 +304,7 @@
      */
     public static final SctpSocketOption<Integer> SO_LINGER =
         new SctpStdSocketOption<Integer>("SO_LINGER", Integer.class,
-        sun.nio.ch.SctpStdSocketOption.SO_LINGER);
+        sun.nio.ch.sctp.SctpStdSocketOption.SO_LINGER);
 
     /**
      * This class is used to set the maximum number of inbound/outbound streams
--- a/jdk/src/share/classes/java/awt/datatransfer/MimeType.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/share/classes/java/awt/datatransfer/MimeType.java	Mon Feb 13 14:31:32 2012 +0000
@@ -30,6 +30,7 @@
 import java.io.ObjectInput;
 import java.io.IOException;
 import java.util.Enumeration;
+import java.util.Locale;
 
 
 /**
@@ -93,14 +94,14 @@
 MimeTypeParseException {
         //    check to see if primary is valid
         if(isValidToken(primary)) {
-            primaryType = primary.toLowerCase();
+            primaryType = primary.toLowerCase(Locale.ENGLISH);
         } else {
             throw new MimeTypeParseException("Primary type is invalid.");
         }
 
         //    check to see if sub is valid
         if(isValidToken(sub)) {
-            subType = sub.toLowerCase();
+            subType = sub.toLowerCase(Locale.ENGLISH);
         } else {
             throw new MimeTypeParseException("Sub type is invalid.");
         }
@@ -158,17 +159,17 @@
             throw new MimeTypeParseException("Unable to find a sub type.");
         } else if((slashIndex >= 0) && (semIndex < 0)) {
             //    we have a primary and sub type but no parameter list
-            primaryType = rawdata.substring(0,
-slashIndex).trim().toLowerCase();
-            subType = rawdata.substring(slashIndex +
-1).trim().toLowerCase();
+            primaryType = rawdata.substring(0,slashIndex).
+                trim().toLowerCase(Locale.ENGLISH);
+            subType = rawdata.substring(slashIndex + 1).
+                trim().toLowerCase(Locale.ENGLISH);
             parameters = new MimeTypeParameterList();
         } else if (slashIndex < semIndex) {
             //    we have all three items in the proper sequence
-            primaryType = rawdata.substring(0,
-slashIndex).trim().toLowerCase();
+            primaryType = rawdata.substring(0, slashIndex).
+                trim().toLowerCase(Locale.ENGLISH);
             subType = rawdata.substring(slashIndex + 1,
-semIndex).trim().toLowerCase();
+                semIndex).trim().toLowerCase(Locale.ENGLISH);
             parameters = new
 MimeTypeParameterList(rawdata.substring(semIndex));
         } else {
--- a/jdk/src/share/classes/java/awt/event/MouseEvent.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/share/classes/java/awt/event/MouseEvent.java	Mon Feb 13 14:31:32 2012 +0000
@@ -758,7 +758,6 @@
 
             if (getModifiersEx() != 0) { //There is at least one more button in a pressed state.
                 if (id == MouseEvent.MOUSE_RELEASED || id == MouseEvent.MOUSE_CLICKED){
-                    System.out.println("MEvent. CASE!");
                     shouldExcludeButtonFromExtModifiers = true;
                 }
             }
--- a/jdk/src/share/classes/java/beans/BeanInfo.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/share/classes/java/beans/BeanInfo.java	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 1999, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,134 +25,134 @@
 
 package java.beans;
 
+import java.awt.Image;
+
 /**
- * A bean implementor who wishes to provide explicit information about
- * their bean may provide a BeanInfo class that implements this BeanInfo
- * interface and provides explicit information about the methods,
- * properties, events, etc, of their  bean.
- * <p>
- * A bean implementor doesn't need to provide a complete set of
- * explicit information.  You can pick and choose which information
- * you want to provide and the rest will be obtained by automatic
- * analysis using low-level reflection of the bean classes' methods
- * and applying standard design patterns.
+ * Use the {@code BeanInfo} interface
+ * to create a {@code BeanInfo} class
+ * and provide explicit information about the methods,
+ * properties, events, and other features of your beans.
  * <p>
- * You get the opportunity to provide lots and lots of different
- * information as part of the various XyZDescriptor classes.  But
- * don't panic, you only really need to provide the minimal core
- * information required by the various constructors.
- * <P>
- * See also the SimpleBeanInfo class which provides a convenient
- * "noop" base class for BeanInfo classes, which you can override
- * for those specific places where you want to return explicit info.
- * <P>
- * To learn about all the behaviour of a bean see the Introspector class.
+ * When developing your bean, you can implement
+ * the bean features required for your application task
+ * omitting the rest of the {@code BeanInfo} features.
+ * They will be obtained through the automatic analysis
+ * by using the low-level reflection of the bean methods
+ * and applying standard design patterns.
+ * You have an opportunity to provide additional bean information
+ * through various descriptor classes.
+ * <p>
+ * See the {@link SimpleBeanInfo} class that is
+ * a convenient basic class for {@code BeanInfo} classes.
+ * You can override the methods and properties of
+ * the {@code SimpleBeanInfo} class to define specific information.
+ * <p>
+ * See also the {@link Introspector} class to learn more about bean behavior.
  */
-
 public interface BeanInfo {
 
     /**
-     * Gets the beans <code>BeanDescriptor</code>.
+     * Returns the bean descriptor
+     * that provides overall information about the bean,
+     * such as its display name or its customizer.
      *
-     * @return  A BeanDescriptor providing overall information about
-     * the bean, such as its displayName, its customizer, etc.  May
-     * return null if the information should be obtained by automatic
-     * analysis.
+     * @return  a {@link BeanDescriptor} object,
+     *          or {@code null} if the information is to
+     *          be obtained through the automatic analysis
      */
     BeanDescriptor getBeanDescriptor();
 
     /**
-     * Gets the beans <code>EventSetDescriptor</code>s.
+     * Returns the event descriptors of the bean
+     * that define the types of events fired by this bean.
      *
-     * @return  An array of EventSetDescriptors describing the kinds of
-     * events fired by this bean.  May return null if the information
-     * should be obtained by automatic analysis.
+     * @return  an array of {@link EventSetDescriptor} objects,
+     *          or {@code null} if the information is to
+     *          be obtained through the automatic analysis
      */
     EventSetDescriptor[] getEventSetDescriptors();
 
     /**
-     * A bean may have a "default" event that is the event that will
-     * mostly commonly be used by humans when using the bean.
-     * @return Index of default event in the EventSetDescriptor array
-     *          returned by getEventSetDescriptors.
-     * <P>      Returns -1 if there is no default event.
+     * A bean may have a default event typically applied when this bean is used.
+     *
+     * @return  index of the default event in the {@code EventSetDescriptor} array
+     *          returned by the {@code getEventSetDescriptors} method,
+     *          or -1 if there is no default event
      */
     int getDefaultEventIndex();
 
     /**
      * Returns descriptors for all properties of the bean.
-     * May return {@code null} if the information
-     * should be obtained by automatic analysis.
      * <p>
      * If a property is indexed, then its entry in the result array
-     * will belong to the {@link IndexedPropertyDescriptor} subclass
+     * belongs to the {@link IndexedPropertyDescriptor} subclass
      * of the {@link PropertyDescriptor} class.
      * A client of the {@code getPropertyDescriptors} method
-     * can use "{@code instanceof}" to check
+     * can use the {@code instanceof} operator to check
      * whether a given {@code PropertyDescriptor}
      * is an {@code IndexedPropertyDescriptor}.
      *
-     * @return an array of {@code PropertyDescriptor}s
-     *         describing all properties supported by the bean
-     *         or {@code null}
+     * @return  an array of {@code PropertyDescriptor} objects,
+     *          or {@code null} if the information is to
+     *          be obtained through the automatic analysis
      */
     PropertyDescriptor[] getPropertyDescriptors();
 
     /**
-     * A bean may have a "default" property that is the property that will
-     * mostly commonly be initially chosen for update by human's who are
-     * customizing the bean.
-     * @return  Index of default property in the PropertyDescriptor array
-     *          returned by getPropertyDescriptors.
-     * <P>      Returns -1 if there is no default property.
+     * A bean may have a default property commonly updated when this bean is customized.
+     *
+     * @return  index of the default property in the {@code PropertyDescriptor} array
+     *          returned by the {@code getPropertyDescriptors} method,
+     *          or -1 if there is no default property
      */
     int getDefaultPropertyIndex();
 
     /**
-     * Gets the beans <code>MethodDescriptor</code>s.
+     * Returns the method descriptors of the bean
+     * that define the externally visible methods supported by this bean.
      *
-     * @return An array of MethodDescriptors describing the externally
-     * visible methods supported by this bean.  May return null if
-     * the information should be obtained by automatic analysis.
+     * @return  an array of {@link MethodDescriptor} objects,
+     *          or {@code null} if the information is to
+     *          be obtained through the automatic analysis
      */
     MethodDescriptor[] getMethodDescriptors();
 
     /**
-     * This method allows a BeanInfo object to return an arbitrary collection
-     * of other BeanInfo objects that provide additional information on the
-     * current bean.
-     * <P>
-     * If there are conflicts or overlaps between the information provided
-     * by different BeanInfo objects, then the current BeanInfo takes precedence
-     * over the getAdditionalBeanInfo objects, and later elements in the array
-     * take precedence over earlier ones.
+     * This method enables the current {@code BeanInfo} object
+     * to return an arbitrary collection of other {@code BeanInfo} objects
+     * that provide additional information about the current bean.
+     * <p>
+     * If there are conflicts or overlaps between the information
+     * provided by different {@code BeanInfo} objects,
+     * the current {@code BeanInfo} object takes priority
+     * over the additional {@code BeanInfo} objects.
+     * Array elements with higher indices take priority
+     * over the elements with lower indices.
      *
-     * @return an array of BeanInfo objects.  May return null.
+     * @return  an array of {@code BeanInfo} objects,
+     *          or {@code null} if there are no additional {@code BeanInfo} objects
      */
     BeanInfo[] getAdditionalBeanInfo();
 
     /**
-     * This method returns an image object that can be used to
-     * represent the bean in toolboxes, toolbars, etc.   Icon images
-     * will typically be GIFs, but may in future include other formats.
-     * <p>
-     * Beans aren't required to provide icons and may return null from
-     * this method.
-     * <p>
-     * There are four possible flavors of icons (16x16 color,
-     * 32x32 color, 16x16 mono, 32x32 mono).  If a bean choses to only
-     * support a single icon we recommend supporting 16x16 color.
+     * Returns an image that can be used to represent the bean in toolboxes or toolbars.
      * <p>
-     * We recommend that icons have a "transparent" background
-     * so they can be rendered onto an existing background.
+     * There are four possible types of icons:
+     * 16 x 16 color, 32 x 32 color, 16 x 16 mono, and 32 x 32 mono.
+     * If you implement a bean so that it supports a single icon,
+     * it is recommended to use 16 x 16 color.
+     * Another recommendation is to set a transparent background for the icons.
      *
-     * @param  iconKind  The kind of icon requested.  This should be
-     *    one of the constant values ICON_COLOR_16x16, ICON_COLOR_32x32,
-     *    ICON_MONO_16x16, or ICON_MONO_32x32.
-     * @return  An image object representing the requested icon.  May
-     *    return null if no suitable icon is available.
+     * @param  iconKind  the kind of icon requested
+     * @return           an image object representing the requested icon,
+     *                   or {@code null} if no suitable icon is available
+     *
+     * @see #ICON_COLOR_16x16
+     * @see #ICON_COLOR_32x32
+     * @see #ICON_MONO_16x16
+     * @see #ICON_MONO_32x32
      */
-    java.awt.Image getIcon(int iconKind);
+    Image getIcon(int iconKind);
 
     /**
      * Constant to indicate a 16 x 16 color icon.
--- a/jdk/src/share/classes/java/beans/Introspector.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/share/classes/java/beans/Introspector.java	Mon Feb 13 14:31:32 2012 +0000
@@ -473,7 +473,7 @@
             // Now analyze each method.
             for (int i = 0; i < methodList.length; i++) {
                 Method method = methodList[i];
-                if (method == null || method.isSynthetic()) {
+                if (method == null) {
                     continue;
                 }
                 // skip static methods.
--- a/jdk/src/share/classes/java/beans/PropertyDescriptor.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/share/classes/java/beans/PropertyDescriptor.java	Mon Feb 13 14:31:32 2012 +0000
@@ -559,7 +559,7 @@
 
         // Normally give priority to y's readMethod.
         try {
-            if (yr != null && yr.getDeclaringClass() == getClass0()) {
+            if (isAssignable(xr, yr)) {
                 setReadMethod(yr);
             } else {
                 setReadMethod(xr);
@@ -713,4 +713,37 @@
         appendTo(sb, "readMethod", this.readMethodRef);
         appendTo(sb, "writeMethod", this.writeMethodRef);
     }
+
+    private boolean isAssignable(Method m1, Method m2) {
+        if (m1 == null) {
+            return true; // choose second method
+        }
+        if (m2 == null) {
+            return false; // choose first method
+        }
+        if (!m1.getName().equals(m2.getName())) {
+            return true; // choose second method by default
+        }
+        Class<?> type1 = m1.getDeclaringClass();
+        Class<?> type2 = m2.getDeclaringClass();
+        if (!type1.isAssignableFrom(type2)) {
+            return false; // choose first method: it declared later
+        }
+        type1 = getReturnType(getClass0(), m1);
+        type2 = getReturnType(getClass0(), m2);
+        if (!type1.isAssignableFrom(type2)) {
+            return false; // choose first method: it overrides return type
+        }
+        Class<?>[] args1 = getParameterTypes(getClass0(), m1);
+        Class<?>[] args2 = getParameterTypes(getClass0(), m2);
+        if (args1.length != args2.length) {
+            return true; // choose second method by default
+        }
+        for (int i = 0; i < args1.length; i++) {
+            if (!args1[i].isAssignableFrom(args2[i])) {
+                return false; // choose first method: it overrides parameter
+            }
+        }
+        return true; // choose second method
+    }
 }
--- a/jdk/src/share/classes/java/util/CurrencyData.properties	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/share/classes/java/util/CurrencyData.properties	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -29,7 +29,7 @@
 # It is a serial number that accompanies with each amendment, such as 
 # 'MAxxx.doc'
 
-dataVersion=151
+dataVersion=153
 
 # List of all valid ISO 4217 currency codes.
 # To ensure compatibility, do not remove codes.
@@ -583,7 +583,7 @@
 minor0=\
     ADP-BEF-BIF-BYB-BYR-CLF-CLP-DJF-ESP-GNF-\
     GRD-ISK-ITL-JPY-KMF-KRW-LUF-MGF-PYG-PTE-RWF-\
-    TPE-TRL-VUV-XAF-XOF-XPF
+    TPE-TRL-VND-VUV-XAF-XOF-XPF
 minor1=
 minor3=\
     BHD-IQD-JOD-KWD-LYD-OMR-TND
--- a/jdk/src/share/classes/java/util/jar/Attributes.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/share/classes/java/util/jar/Attributes.java	Mon Feb 13 14:31:32 2012 +0000
@@ -71,7 +71,7 @@
      * @param size the initial number of attributes
      */
     public Attributes(int size) {
-        map = new HashMap(size);
+        map = new HashMap<>(size);
     }
 
     /**
@@ -81,7 +81,7 @@
      * @param attr the specified Attributes
      */
     public Attributes(Attributes attr) {
-        map = new HashMap(attr);
+        map = new HashMap<>(attr);
     }
 
 
@@ -296,9 +296,9 @@
      * XXX Need to handle UTF8 values and break up lines longer than 72 bytes
      */
      void write(DataOutputStream os) throws IOException {
-        Iterator it = entrySet().iterator();
+        Iterator<Map.Entry<Object, Object>> it = entrySet().iterator();
         while (it.hasNext()) {
-            Map.Entry e = (Map.Entry)it.next();
+            Map.Entry<Object, Object> e = it.next();
             StringBuffer buffer = new StringBuffer(
                                         ((Name)e.getKey()).toString());
             buffer.append(": ");
@@ -340,9 +340,9 @@
 
         // write out all attributes except for the version
         // we wrote out earlier
-        Iterator it = entrySet().iterator();
+        Iterator<Map.Entry<Object, Object>> it = entrySet().iterator();
         while (it.hasNext()) {
-            Map.Entry e = (Map.Entry)it.next();
+            Map.Entry<Object, Object> e = it.next();
             String name = ((Name)e.getKey()).toString();
             if ((version != null) && ! (name.equalsIgnoreCase(vername))) {
 
@@ -499,7 +499,7 @@
          */
         public boolean equals(Object o) {
             if (o instanceof Name) {
-                Comparator c = ASCIICaseInsensitiveComparator.CASE_INSENSITIVE_ORDER;
+                Comparator<String> c = ASCIICaseInsensitiveComparator.CASE_INSENSITIVE_ORDER;
                 return c.compare(name, ((Name)o).name) == 0;
             } else {
                 return false;
--- a/jdk/src/share/classes/java/util/jar/JarOutputStream.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/share/classes/java/util/jar/JarOutputStream.java	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -135,7 +135,7 @@
      * The bytes are assumed to be in Intel (little-endian) byte order.
      */
     private static int get16(byte[] b, int off) {
-        return (b[off] & 0xff) | ((b[off+1] & 0xff) << 8);
+        return Byte.toUnsignedInt(b[off]) | ( Byte.toUnsignedInt(b[off+1]) << 8);
     }
 
     /*
--- a/jdk/src/share/classes/java/util/jar/JarVerifier.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/share/classes/java/util/jar/JarVerifier.java	Mon Feb 13 14:31:32 2012 +0000
@@ -48,21 +48,21 @@
 
     /* a table mapping names to code signers, for jar entries that have
        had their actual hashes verified */
-    private Hashtable verifiedSigners;
+    private Hashtable<String, CodeSigner[]> verifiedSigners;
 
     /* a table mapping names to code signers, for jar entries that have
        passed the .SF/.DSA/.EC -> MANIFEST check */
-    private Hashtable sigFileSigners;
+    private Hashtable<String, CodeSigner[]> sigFileSigners;
 
     /* a hash table to hold .SF bytes */
-    private Hashtable sigFileData;
+    private Hashtable<String, byte[]> sigFileData;
 
     /** "queue" of pending PKCS7 blocks that we couldn't parse
      *  until we parsed the .SF file */
-    private ArrayList pendingBlocks;
+    private ArrayList<SignatureFileVerifier> pendingBlocks;
 
     /* cache of CodeSigner objects */
-    private ArrayList signerCache;
+    private ArrayList<CodeSigner[]> signerCache;
 
     /* Are we parsing a block? */
     private boolean parsingBlockOrSF = false;
@@ -94,10 +94,10 @@
 
     public JarVerifier(byte rawBytes[]) {
         manifestRawBytes = rawBytes;
-        sigFileSigners = new Hashtable();
-        verifiedSigners = new Hashtable();
-        sigFileData = new Hashtable(11);
-        pendingBlocks = new ArrayList();
+        sigFileSigners = new Hashtable<>();
+        verifiedSigners = new Hashtable<>();
+        sigFileData = new Hashtable<>(11);
+        pendingBlocks = new ArrayList<>();
         baos = new ByteArrayOutputStream();
         manifestDigests = new ArrayList<>();
     }
@@ -248,10 +248,9 @@
                     sigFileData.put(key, bytes);
                     // check pending blocks, we can now process
                     // anyone waiting for this .SF file
-                    Iterator it = pendingBlocks.iterator();
+                    Iterator<SignatureFileVerifier> it = pendingBlocks.iterator();
                     while (it.hasNext()) {
-                        SignatureFileVerifier sfv =
-                            (SignatureFileVerifier) it.next();
+                        SignatureFileVerifier sfv = it.next();
                         if (sfv.needSignatureFile(key)) {
                             if (debug != null) {
                                 debug.println(
@@ -270,7 +269,7 @@
                 String key = uname.substring(0, uname.lastIndexOf("."));
 
                 if (signerCache == null)
-                    signerCache = new ArrayList();
+                    signerCache = new ArrayList<>();
 
                 if (manDig == null) {
                     synchronized(manifestRawBytes) {
@@ -287,7 +286,7 @@
 
                 if (sfv.needSignatureFileBytes()) {
                     // see if we have already parsed an external .SF file
-                    byte[] bytes = (byte[]) sigFileData.get(key);
+                    byte[] bytes = sigFileData.get(key);
 
                     if (bytes == null) {
                         // put this block on queue for later processing
@@ -343,7 +342,7 @@
      */
     public CodeSigner[] getCodeSigners(String name)
     {
-        return (CodeSigner[])verifiedSigners.get(name);
+        return verifiedSigners.get(name);
     }
 
     public CodeSigner[] getCodeSigners(JarFile jar, JarEntry entry)
@@ -376,15 +375,14 @@
         CodeSigner[] signers) {
 
         if (signers != null) {
-            ArrayList certChains = new ArrayList();
+            ArrayList<java.security.cert.Certificate> certChains = new ArrayList<>();
             for (int i = 0; i < signers.length; i++) {
                 certChains.addAll(
                     signers[i].getSignerCertPath().getCertificates());
             }
 
             // Convert into a Certificate[]
-            return (java.security.cert.Certificate[])
-                certChains.toArray(
+            return certChains.toArray(
                     new java.security.cert.Certificate[certChains.size()]);
         }
         return null;
@@ -418,8 +416,8 @@
         // MANIFEST.MF is always treated as signed and verified,
         // move its signers from sigFileSigners to verifiedSigners.
         if (sigFileSigners.containsKey(JarFile.MANIFEST_NAME)) {
-            verifiedSigners.put(JarFile.MANIFEST_NAME,
-                    sigFileSigners.remove(JarFile.MANIFEST_NAME));
+            CodeSigner[] codeSigners = sigFileSigners.remove(JarFile.MANIFEST_NAME);
+            verifiedSigners.put(JarFile.MANIFEST_NAME, codeSigners);
         }
     }
 
@@ -493,10 +491,10 @@
 
     // Extended JavaUtilJarAccess CodeSource API Support
 
-    private Map urlToCodeSourceMap = new HashMap();
-    private Map signerToCodeSource = new HashMap();
+    private Map<URL, Map<CodeSigner[], CodeSource>> urlToCodeSourceMap = new HashMap<>();
+    private Map<CodeSigner[], CodeSource> signerToCodeSource = new HashMap<>();
     private URL lastURL;
-    private Map lastURLMap;
+    private Map<CodeSigner[], CodeSource> lastURLMap;
 
     /*
      * Create a unique mapping from codeSigner cache entries to CodeSource.
@@ -504,19 +502,19 @@
      * and shared JAR file although in practice there will be a single URL in use.
      */
     private synchronized CodeSource mapSignersToCodeSource(URL url, CodeSigner[] signers) {
-        Map map;
+        Map<CodeSigner[], CodeSource> map;
         if (url == lastURL) {
             map = lastURLMap;
         } else {
-            map = (Map) urlToCodeSourceMap.get(url);
+            map = urlToCodeSourceMap.get(url);
             if (map == null) {
-                map = new HashMap();
+                map = new HashMap<>();
                 urlToCodeSourceMap.put(url, map);
             }
             lastURLMap = map;
             lastURL = url;
         }
-        CodeSource cs = (CodeSource) map.get(signers);
+        CodeSource cs = map.get(signers);
         if (cs == null) {
             cs = new VerifierCodeSource(csdomain, url, signers);
             signerToCodeSource.put(signers, cs);
@@ -524,16 +522,16 @@
         return cs;
     }
 
-    private CodeSource[] mapSignersToCodeSources(URL url, List signers, boolean unsigned) {
-        List sources = new ArrayList();
+    private CodeSource[] mapSignersToCodeSources(URL url, List<CodeSigner[]> signers, boolean unsigned) {
+        List<CodeSource> sources = new ArrayList<>();
 
         for (int i = 0; i < signers.size(); i++) {
-            sources.add(mapSignersToCodeSource(url, (CodeSigner[]) signers.get(i)));
+            sources.add(mapSignersToCodeSource(url, signers.get(i)));
         }
         if (unsigned) {
             sources.add(mapSignersToCodeSource(url, null));
         }
-        return (CodeSource[]) sources.toArray(new CodeSource[sources.size()]);
+        return sources.toArray(new CodeSource[sources.size()]);
     }
     private CodeSigner[] emptySigner = new CodeSigner[0];
 
@@ -553,7 +551,7 @@
          * but this handles a CodeSource of any type, just in case.
          */
         CodeSource[] sources = mapSignersToCodeSources(cs.getLocation(), getJarCodeSigners(), true);
-        List sourceList = new ArrayList();
+        List<CodeSource> sourceList = new ArrayList<>();
         for (int i = 0; i < sources.length; i++) {
             sourceList.add(sources[i]);
         }
@@ -574,6 +572,7 @@
      * signing data that can be compared by object reference identity.
      */
     private static class VerifierCodeSource extends CodeSource {
+        private static final long serialVersionUID = -9047366145967768825L;
 
         URL vlocation;
         CodeSigner[] vsigners;
@@ -641,16 +640,16 @@
             return vcerts;
         }
     }
-    private Map signerMap;
+    private Map<String, CodeSigner[]> signerMap;
 
-    private synchronized Map signerMap() {
+    private synchronized Map<String, CodeSigner[]> signerMap() {
         if (signerMap == null) {
             /*
              * Snapshot signer state so it doesn't change on us. We care
              * only about the asserted signatures. Verification of
              * signature validity happens via the JarEntry apis.
              */
-            signerMap = new HashMap(verifiedSigners.size() + sigFileSigners.size());
+            signerMap = new HashMap<>(verifiedSigners.size() + sigFileSigners.size());
             signerMap.putAll(verifiedSigners);
             signerMap.putAll(sigFileSigners);
         }
@@ -658,15 +657,15 @@
     }
 
     public synchronized Enumeration<String> entryNames(JarFile jar, final CodeSource[] cs) {
-        final Map map = signerMap();
-        final Iterator itor = map.entrySet().iterator();
+        final Map<String, CodeSigner[]> map = signerMap();
+        final Iterator<Map.Entry<String, CodeSigner[]>> itor = map.entrySet().iterator();
         boolean matchUnsigned = false;
 
         /*
          * Grab a single copy of the CodeSigner arrays. Check
          * to see if we can optimize CodeSigner equality test.
          */
-        List req = new ArrayList(cs.length);
+        List<CodeSigner[]> req = new ArrayList<>(cs.length);
         for (int i = 0; i < cs.length; i++) {
             CodeSigner[] match = findMatchingSigners(cs[i]);
             if (match != null) {
@@ -678,8 +677,8 @@
             }
         }
 
-        final List signersReq = req;
-        final Enumeration enum2 = (matchUnsigned) ? unsignedEntryNames(jar) : emptyEnumeration;
+        final List<CodeSigner[]> signersReq = req;
+        final Enumeration<String> enum2 = (matchUnsigned) ? unsignedEntryNames(jar) : emptyEnumeration;
 
         return new Enumeration<String>() {
 
@@ -691,14 +690,14 @@
                 }
 
                 while (itor.hasNext()) {
-                    Map.Entry e = (Map.Entry) itor.next();
-                    if (signersReq.contains((CodeSigner[]) e.getValue())) {
-                        name = (String) e.getKey();
+                    Map.Entry<String, CodeSigner[]> e = itor.next();
+                    if (signersReq.contains(e.getValue())) {
+                        name = e.getKey();
                         return true;
                     }
                 }
                 while (enum2.hasMoreElements()) {
-                    name = (String) enum2.nextElement();
+                    name = enum2.nextElement();
                     return true;
                 }
                 return false;
@@ -719,13 +718,13 @@
      * Like entries() but screens out internal JAR mechanism entries
      * and includes signed entries with no ZIP data.
      */
-    public Enumeration<JarEntry> entries2(final JarFile jar, Enumeration e) {
-        final Map map = new HashMap();
+    public Enumeration<JarEntry> entries2(final JarFile jar, Enumeration<? extends ZipEntry> e) {
+        final Map<String, CodeSigner[]> map = new HashMap<>();
         map.putAll(signerMap());
-        final Enumeration enum_ = e;
+        final Enumeration<? extends ZipEntry> enum_ = e;
         return new Enumeration<JarEntry>() {
 
-            Enumeration signers = null;
+            Enumeration<String> signers = null;
             JarEntry entry;
 
             public boolean hasMoreElements() {
@@ -733,7 +732,7 @@
                     return true;
                 }
                 while (enum_.hasMoreElements()) {
-                    ZipEntry ze = (ZipEntry) enum_.nextElement();
+                    ZipEntry ze = enum_.nextElement();
                     if (JarVerifier.isSigningRelated(ze.getName())) {
                         continue;
                     }
@@ -744,7 +743,7 @@
                     signers = Collections.enumeration(map.keySet());
                 }
                 while (signers.hasMoreElements()) {
-                    String name = (String) signers.nextElement();
+                    String name = signers.nextElement();
                     entry = jar.newEntry(new ZipEntry(name));
                     return true;
                 }
@@ -764,7 +763,7 @@
             }
         };
     }
-    private Enumeration emptyEnumeration = new Enumeration<String>() {
+    private Enumeration<String> emptyEnumeration = new Enumeration<String>() {
 
         public boolean hasMoreElements() {
             return false;
@@ -797,8 +796,8 @@
     }
 
     private Enumeration<String> unsignedEntryNames(JarFile jar) {
-        final Map map = signerMap();
-        final Enumeration entries = jar.entries();
+        final Map<String, CodeSigner[]> map = signerMap();
+        final Enumeration<JarEntry> entries = jar.entries();
         return new Enumeration<String>() {
 
             String name;
@@ -813,7 +812,7 @@
                 }
                 while (entries.hasMoreElements()) {
                     String value;
-                    ZipEntry e = (ZipEntry) entries.nextElement();
+                    ZipEntry e = entries.nextElement();
                     value = e.getName();
                     if (e.isDirectory() || isSigningRelated(value)) {
                         continue;
@@ -836,14 +835,14 @@
             }
         };
     }
-    private List jarCodeSigners;
+    private List<CodeSigner[]> jarCodeSigners;
 
-    private synchronized List getJarCodeSigners() {
+    private synchronized List<CodeSigner[]> getJarCodeSigners() {
         CodeSigner[] signers;
         if (jarCodeSigners == null) {
-            HashSet set = new HashSet();
+            HashSet<CodeSigner[]> set = new HashSet<>();
             set.addAll(signerMap().values());
-            jarCodeSigners = new ArrayList();
+            jarCodeSigners = new ArrayList<>();
             jarCodeSigners.addAll(set);
         }
         return jarCodeSigners;
@@ -858,7 +857,7 @@
     public CodeSource getCodeSource(URL url, String name) {
         CodeSigner[] signers;
 
-        signers = (CodeSigner[]) signerMap().get(name);
+        signers = signerMap().get(name);
         return mapSignersToCodeSource(url, signers);
     }
 
--- a/jdk/src/share/classes/java/util/jar/Manifest.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/share/classes/java/util/jar/Manifest.java	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -339,7 +339,7 @@
                     return -1;
                 }
             }
-            return buf[pos++] & 0xff;
+            return Byte.toUnsignedInt(buf[pos++]);
         }
 
         public int read(byte[] b, int off, int len) throws IOException {
--- a/jdk/src/share/classes/java/util/zip/InflaterInputStream.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/share/classes/java/util/zip/InflaterInputStream.java	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -119,7 +119,7 @@
      */
     public int read() throws IOException {
         ensureOpen();
-        return read(singleByteBuf, 0, 1) == -1 ? -1 : singleByteBuf[0] & 0xff;
+        return read(singleByteBuf, 0, 1) == -1 ? -1 : Byte.toUnsignedInt(singleByteBuf[0]);
     }
 
     /**
--- a/jdk/src/share/classes/java/util/zip/ZipInputStream.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/share/classes/java/util/zip/ZipInputStream.java	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -435,7 +435,7 @@
      * The bytes are assumed to be in Intel (little-endian) byte order.
      */
     private static final int get16(byte b[], int off) {
-        return (b[off] & 0xff) | ((b[off+1] & 0xff) << 8);
+        return Byte.toUnsignedInt(b[off]) | (Byte.toUnsignedInt(b[off+1]) << 8);
     }
 
     /*
--- a/jdk/src/share/classes/javax/crypto/CipherSpi.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/share/classes/javax/crypto/CipherSpi.java	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -775,7 +775,7 @@
             int outOfs = output.arrayOffset() + outPos;
             byte[] inArray = new byte[getTempArraySize(inLen)];
             int total = 0;
-            while (inLen > 0) {
+            do {
                 int chunk = Math.min(inLen, inArray.length);
                 input.get(inArray, 0, chunk);
                 int n;
@@ -787,7 +787,7 @@
                 total += n;
                 outOfs += n;
                 inLen -= chunk;
-            }
+            } while (inLen > 0);
             output.position(outPos + total);
             return total;
         } else { // output is not backed by an accessible byte[]
@@ -804,7 +804,7 @@
             int outSize = outArray.length;
             int total = 0;
             boolean resized = false;
-            while (inLen > 0) {
+            do {
                 int chunk = Math.min(inLen, outSize);
                 if ((a1 == false) && (resized == false)) {
                     input.get(inArray, 0, chunk);
@@ -834,7 +834,7 @@
                     int newOut = engineGetOutputSize(chunk);
                     outArray = new byte[newOut];
                 }
-            }
+            } while (inLen > 0);
             input.position(inLimit);
             return total;
         }
--- a/jdk/src/share/classes/javax/net/ssl/ExtendedSSLSession.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/share/classes/javax/net/ssl/ExtendedSSLSession.java	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -43,7 +43,7 @@
      * The signature algorithm name must be a standard Java Security
      * name (such as "SHA1withRSA", "SHA256withECDSA", and so on).
      * See Appendix A in the <a href=
-     * "../../../technotes/guides/security/crypto/CryptoSpec.html#AppA">
+     * "{@docRoot}/../technotes/guides/security/crypto/CryptoSpec.html#AppA">
      * Java Cryptography Architecture API Specification &amp; Reference </a>
      * for information about standard algorithm names.
      * <p>
@@ -71,7 +71,7 @@
      * The signature algorithm name must be a standard Java Security
      * name (such as "SHA1withRSA", "SHA256withECDSA", and so on).
      * See Appendix A in the <a href=
-     * "../../../technotes/guides/security/crypto/CryptoSpec.html#AppA">
+     * "{@docRoot}/../technotes/guides/security/crypto/CryptoSpec.html#AppA">
      * Java Cryptography Architecture API Specification &amp; Reference </a>
      * for information about standard algorithm names.
      *
--- a/jdk/src/share/classes/javax/net/ssl/SSLParameters.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/share/classes/javax/net/ssl/SSLParameters.java	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -242,7 +242,7 @@
      *
      * @param algorithm The standard string name of the endpoint
      *     identification algorithm (or null).  See Appendix A in the <a href=
-     *     "../../../technotes/guides/security/crypto/CryptoSpec.html#AppA">
+     *   "{@docRoot}/../technotes/guides/security/crypto/CryptoSpec.html#AppA">
      *     Java Cryptography Architecture API Specification &amp; Reference </a>
      *     for information about standard algorithm names.
      *
--- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicTabbedPaneUI.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicTabbedPaneUI.java	Mon Feb 13 14:31:32 2012 +0000
@@ -1115,9 +1115,8 @@
 
     protected int getTabLabelShiftY(int tabPlacement, int tabIndex, boolean isSelected) {
         Rectangle tabRect = rects[tabIndex];
-        String propKey = (isSelected ? "selectedLabelShift" : "labelShift");
-        int nudge = DefaultLookup.getInt(
-                tabPane, this, "TabbedPane." + propKey, 1);
+        int nudge = (isSelected ? DefaultLookup.getInt(tabPane, this, "TabbedPane.selectedLabelShift", -1) :
+                DefaultLookup.getInt(tabPane, this, "TabbedPane.labelShift", 1));
 
         switch (tabPlacement) {
             case BOTTOM:
--- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthComboBoxUI.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthComboBoxUI.java	Mon Feb 13 14:31:32 2012 +0000
@@ -447,11 +447,21 @@
     private class SynthComboBoxRenderer extends JLabel implements ListCellRenderer<Object>, UIResource {
         public SynthComboBoxRenderer() {
             super();
-            setName("ComboBox.renderer");
             setText(" ");
         }
 
         @Override
+        public String getName() {
+            // SynthComboBoxRenderer should have installed Name while constructor is working.
+            // The setName invocation in the SynthComboBoxRenderer() constructor doesn't work
+            // because of the opaque property is installed in the constructor based on the
+            // component name (see GTKStyle.isOpaque())
+            String name = super.getName();
+
+            return name == null ? "ComboBox.renderer" : name;
+        }
+
+        @Override
         public Component getListCellRendererComponent(JList<?> list, Object value,
                          int index, boolean isSelected, boolean cellHasFocus) {
             setName("ComboBox.listRenderer");
--- a/jdk/src/share/classes/sun/awt/OSInfo.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/share/classes/sun/awt/OSInfo.java	Mon Feb 13 14:31:32 2012 +0000
@@ -39,6 +39,7 @@
         WINDOWS,
         LINUX,
         SOLARIS,
+        MACOSX,
         UNKNOWN
     }
 
@@ -100,6 +101,10 @@
                 return SOLARIS;
             }
 
+            if (osName.startsWith("Mac OS X")) {
+                return MACOSX;
+            }
+
             // determine another OS here
         }
 
--- a/jdk/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java	Mon Feb 13 14:31:32 2012 +0000
@@ -270,7 +270,7 @@
     protected Proxy instProxy;
 
     private CookieHandler cookieHandler;
-    private ResponseCache cacheHandler;
+    private final ResponseCache cacheHandler;
 
     // the cached response, and cached response headers and body
     protected CacheResponse cachedResponse;
@@ -1579,7 +1579,7 @@
 
                 if (respCode == 200 || respCode == 203 || respCode == 206 ||
                     respCode == 300 || respCode == 301 || respCode == 410) {
-                    if (cacheHandler != null) {
+                    if (cacheHandler != null && getUseCaches()) {
                         // give cache a chance to save response in cache
                         URI uri = ParseUtil.toURI(url);
                         if (uri != null) {
--- a/jdk/src/share/classes/sun/nio/ch/AbstractPollArrayWrapper.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/share/classes/sun/nio/ch/AbstractPollArrayWrapper.java	Mon Feb 13 14:31:32 2012 +0000
@@ -35,15 +35,15 @@
  * @since 1.4
  */
 
-abstract class AbstractPollArrayWrapper {
+public abstract class AbstractPollArrayWrapper {
 
     // Event masks
-    static final short POLLIN       = 0x0001;
-    static final short POLLOUT      = 0x0004;
-    static final short POLLERR      = 0x0008;
-    static final short POLLHUP      = 0x0010;
-    static final short POLLNVAL     = 0x0020;
-    static final short POLLREMOVE   = 0x0800;
+    public static final short POLLIN       = 0x0001;
+    public static final short POLLOUT      = 0x0004;
+    public static final short POLLERR      = 0x0008;
+    public static final short POLLHUP      = 0x0010;
+    public static final short POLLNVAL     = 0x0020;
+    public static final short POLLREMOVE   = 0x0800;
 
     // Miscellaneous constants
     static final short SIZE_POLLFD   = 8;
--- a/jdk/src/share/classes/sun/nio/ch/AbstractPollSelectorImpl.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/share/classes/sun/nio/ch/AbstractPollSelectorImpl.java	Mon Feb 13 14:31:32 2012 +0000
@@ -67,7 +67,7 @@
         this.channelOffset = offset;
     }
 
-    void putEventOps(SelectionKeyImpl sk, int ops) {
+    public void putEventOps(SelectionKeyImpl sk, int ops) {
         synchronized (closeLock) {
             if (closed)
                 throw new ClosedSelectorException();
--- a/jdk/src/share/classes/sun/nio/ch/IOStatus.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/share/classes/sun/nio/ch/IOStatus.java	Mon Feb 13 14:31:32 2012 +0000
@@ -28,16 +28,16 @@
 
 // Constants for reporting I/O status
 
-final class IOStatus {
+public final class IOStatus {
 
     private IOStatus() { }
 
-    static final int EOF = -1;              // End of file
-    static final int UNAVAILABLE = -2;      // Nothing available (non-blocking)
-    static final int INTERRUPTED = -3;      // System call interrupted
-    static final int UNSUPPORTED = -4;      // Operation not supported
-    static final int THROWN = -5;           // Exception thrown in JNI code
-    static final int UNSUPPORTED_CASE = -6; // This case not supported
+    public static final int EOF = -1;              // End of file
+    public static final int UNAVAILABLE = -2;      // Nothing available (non-blocking)
+    public static final int INTERRUPTED = -3;      // System call interrupted
+    public static final int UNSUPPORTED = -4;      // Operation not supported
+    public static final int THROWN = -5;           // Exception thrown in JNI code
+    public static final int UNSUPPORTED_CASE = -6; // This case not supported
 
     // The following two methods are for use in try/finally blocks where a
     // status value needs to be normalized before being returned to the invoker
@@ -55,28 +55,28 @@
     //     }
     //
 
-    static int normalize(int n) {
+    public static int normalize(int n) {
         if (n == UNAVAILABLE)
             return 0;
         return n;
     }
 
-    static boolean check(int n) {
+    public static boolean check(int n) {
         return (n >= UNAVAILABLE);
     }
 
-    static long normalize(long n) {
+    public static long normalize(long n) {
         if (n == UNAVAILABLE)
             return 0;
         return n;
     }
 
-    static boolean check(long n) {
+    public static boolean check(long n) {
         return (n >= UNAVAILABLE);
     }
 
     // Return true iff n is not one of the IOStatus values
-    static boolean checkAll(long n) {
+    public static boolean checkAll(long n) {
         return ((n > EOF) || (n < UNSUPPORTED_CASE));
     }
 
--- a/jdk/src/share/classes/sun/nio/ch/IOUtil.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/share/classes/sun/nio/ch/IOUtil.java	Mon Feb 13 14:31:32 2012 +0000
@@ -34,7 +34,7 @@
  * File-descriptor based I/O utilities that are shared by NIO classes.
  */
 
-class IOUtil {
+public class IOUtil {
 
     private IOUtil() { }                // No instantiation
 
@@ -309,7 +309,7 @@
         }
     }
 
-    static FileDescriptor newFD(int i) {
+    public static FileDescriptor newFD(int i) {
         FileDescriptor fd = new FileDescriptor();
         setfdVal(fd, i);
         return fd;
@@ -326,10 +326,11 @@
 
     static native boolean drain(int fd) throws IOException;
 
-    static native void configureBlocking(FileDescriptor fd, boolean blocking)
+    public static native void configureBlocking(FileDescriptor fd,
+                                                boolean blocking)
         throws IOException;
 
-    static native int fdVal(FileDescriptor fd);
+    public static native int fdVal(FileDescriptor fd);
 
     static native void setfdVal(FileDescriptor fd, int value);
 
--- a/jdk/src/share/classes/sun/nio/ch/Net.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/share/classes/sun/nio/ch/Net.java	Mon Feb 13 14:31:32 2012 +0000
@@ -33,7 +33,7 @@
 import java.security.PrivilegedAction;
 
 
-class Net {                                             // package-private
+public class Net {
 
     private Net() { }
 
@@ -75,7 +75,7 @@
         return canJoin6WithIPv4Group0();
     }
 
-    static InetSocketAddress checkAddress(SocketAddress sa) {
+    public static InetSocketAddress checkAddress(SocketAddress sa) {
         if (sa == null)
             throw new NullPointerException();
         if (!(sa instanceof InetSocketAddress))
@@ -330,7 +330,7 @@
     // Due to oddities SO_REUSEADDR on windows reuse is ignored
     private static native int socket0(boolean preferIPv6, boolean stream, boolean reuse);
 
-    static void bind(FileDescriptor fd, InetAddress addr, int port)
+    public static void bind(FileDescriptor fd, InetAddress addr, int port)
         throws IOException
     {
         bind(UNSPEC, fd, addr, port);
@@ -383,7 +383,7 @@
     private static native InetAddress localInetAddress(FileDescriptor fd)
         throws IOException;
 
-    static InetSocketAddress localAddress(FileDescriptor fd)
+    public static InetSocketAddress localAddress(FileDescriptor fd)
         throws IOException
     {
         return new InetSocketAddress(localInetAddress(fd), localPort(fd));
--- a/jdk/src/share/classes/sun/nio/ch/SctpMessageInfoImpl.java	Mon Feb 13 14:26:25 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,170 +0,0 @@
-/*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package sun.nio.ch;
-
-import java.net.SocketAddress;
-import com.sun.nio.sctp.MessageInfo;
-import com.sun.nio.sctp.Association;
-
-/**
- * An implementation of a MessageInfo.
- */
-public class SctpMessageInfoImpl extends MessageInfo {
-    private final SocketAddress address;
-    private final int bytes;          /* 0 */
-
-    private Association association;
-    private int assocId;
-    private int streamNumber;
-    private boolean complete = true;
-    private boolean unordered;  /* false */
-    private long timeToLive;    /* 0L */
-    private int ppid;           /* 0 */
-
-    public SctpMessageInfoImpl(Association association,
-                               SocketAddress address,
-                               int streamNumber) {
-        this.association = association;
-        this.address = address;
-        this.streamNumber = streamNumber;
-        bytes = 0;
-    }
-
-    /* Invoked from native */
-    private SctpMessageInfoImpl(int assocId,
-                                SocketAddress address,
-                                int bytes,
-                                int streamNumber,
-                                boolean complete,
-                                boolean unordered,
-                                int ppid) {
-        this.assocId = assocId;
-        this.address = address;
-        this.bytes = bytes;
-        this.streamNumber = streamNumber;
-        this.complete = complete;
-        this.unordered = unordered;
-        this.ppid = ppid;
-    }
-
-    @Override
-    public Association association() {
-        return association;
-    }
-
-    /**
-     * SctpMessageInfoImpl instances created from native will need to have their
-     * association set from the channel.
-     */
-    void setAssociation(Association association) {
-        this.association = association;
-    }
-
-    int associationID() {
-        return assocId;
-    }
-
-    @Override
-    public SocketAddress address() {
-        return address;
-    }
-
-    @Override
-    public int bytes() {
-        return bytes;
-    }
-
-    @Override
-    public int streamNumber() {
-        return streamNumber;
-    }
-
-    @Override
-    public MessageInfo streamNumber(int streamNumber) {
-        if (streamNumber < 0 || streamNumber > 65536)
-            throw new IllegalArgumentException("Invalid stream number");
-
-        this.streamNumber = streamNumber;
-        return this;
-    }
-
-    @Override
-    public int payloadProtocolID() {
-        return ppid;
-    }
-
-    @Override
-    public MessageInfo payloadProtocolID(int ppid) {
-        this.ppid = ppid;
-        return this;
-    }
-
-    @Override
-    public boolean isComplete() {
-        return complete;
-    }
-
-    @Override
-    public MessageInfo complete(boolean complete) {
-        this.complete = complete;
-        return this;
-    }
-
-    @Override
-    public boolean isUnordered() {
-        return unordered;
-    }
-
-    @Override
-    public MessageInfo unordered(boolean unordered) {
-        this.unordered = unordered;
-        return this;
-    }
-
-    @Override
-    public long timeToLive() {
-        return timeToLive;
-    }
-
-    @Override
-    public MessageInfo timeToLive(long millis) {
-        timeToLive = millis;
-        return this;
-    }
-
-    @Override
-    public String toString() {
-        StringBuilder sb = new StringBuilder(super.toString());
-        sb.append( "[Address: ").append(address)
-          .append(", Association: ").append(association)
-          .append(", Assoc ID: ").append(assocId)
-          .append(", Bytes: ").append(bytes)
-          .append(", Stream Number: ").append(streamNumber)
-          .append(", Complete: ").append(complete)
-          .append(", isUnordered: ").append(unordered)
-          .append("]");
-        return sb.toString();
-    }
-}
--- a/jdk/src/share/classes/sun/nio/ch/SctpStdSocketOption.java	Mon Feb 13 14:26:25 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +0,0 @@
-/*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package sun.nio.ch;
-
-import com.sun.nio.sctp.SctpSocketOption;
-
-public class SctpStdSocketOption<T>
-    implements SctpSocketOption<T>
-{
-    /* for native mapping of int options */
-    public static final int SCTP_DISABLE_FRAGMENTS = 1;
-    public static final int SCTP_EXPLICIT_COMPLETE = 2;
-    public static final int SCTP_FRAGMENT_INTERLEAVE = 3;
-    public static final int SCTP_NODELAY = 4;
-    public static final int SO_SNDBUF = 5;
-    public static final int SO_RCVBUF = 6;
-    public static final int SO_LINGER = 7;
-
-    private final String name;
-    private final Class<T> type;
-
-    /* for native mapping of int options */
-    private int constValue;
-
-    public SctpStdSocketOption(String name, Class<T> type) {
-        this.name = name;
-        this.type = type;
-    }
-
-    public SctpStdSocketOption(String name, Class<T> type, int constValue) {
-        this.name = name;
-        this.type = type;
-        this.constValue = constValue;
-    }
-
-    @Override
-    public String name() {
-        return name;
-    }
-
-    @Override
-    public Class<T> type() {
-        return type;
-    }
-
-    @Override
-    public String toString() {
-        return name;
-    }
-
-    int constValue() {
-        return constValue;
-    }
-}
--- a/jdk/src/share/classes/sun/nio/ch/SelChImpl.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/share/classes/sun/nio/ch/SelChImpl.java	Mon Feb 13 14:31:32 2012 +0000
@@ -36,7 +36,7 @@
  * @since 1.4
  */
 
-interface SelChImpl extends Channel {
+public interface SelChImpl extends Channel {
 
     FileDescriptor getFD();
 
--- a/jdk/src/share/classes/sun/nio/ch/SelectionKeyImpl.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/share/classes/sun/nio/ch/SelectionKeyImpl.java	Mon Feb 13 14:31:32 2012 +0000
@@ -34,12 +34,12 @@
  * An implementation of SelectionKey for Solaris.
  */
 
-class SelectionKeyImpl
+public class SelectionKeyImpl
     extends AbstractSelectionKey
 {
 
     final SelChImpl channel;                            // package-private
-    final SelectorImpl selector;                        // package-private
+    public final SelectorImpl selector;
 
     // Index for a pollfd array in Selector that this key is registered with
     private int index;
@@ -91,15 +91,15 @@
     // The nio versions of these operations do not care if a key
     // has been invalidated. They are for internal use by nio code.
 
-    void nioReadyOps(int ops) {                 // package-private
+    public void nioReadyOps(int ops) {
         readyOps = ops;
     }
 
-    int nioReadyOps() {                         // package-private
+    public int nioReadyOps() {
         return readyOps;
     }
 
-    SelectionKey nioInterestOps(int ops) {      // package-private
+    public SelectionKey nioInterestOps(int ops) {
         if ((ops & ~channel().validOps()) != 0)
             throw new IllegalArgumentException();
         channel.translateAndSetInterestOps(ops, this);
@@ -107,7 +107,7 @@
         return this;
     }
 
-    int nioInterestOps() {                       // package-private
+    public int nioInterestOps() {
         return interestOps;
     }
 
--- a/jdk/src/share/classes/sun/nio/ch/SelectorImpl.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/share/classes/sun/nio/ch/SelectorImpl.java	Mon Feb 13 14:31:32 2012 +0000
@@ -36,7 +36,7 @@
  * Base Selector implementation class.
  */
 
-abstract class SelectorImpl
+public abstract class SelectorImpl
     extends AbstractSelector
 {
 
@@ -118,7 +118,7 @@
 
     protected abstract void implClose() throws IOException;
 
-    void putEventOps(SelectionKeyImpl sk, int ops) { }
+    public void putEventOps(SelectionKeyImpl sk, int ops) { }
 
     protected final SelectionKey register(AbstractSelectableChannel ch,
                                           int ops,
--- a/jdk/src/share/classes/sun/nio/ch/Util.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/share/classes/sun/nio/ch/Util.java	Mon Feb 13 14:31:32 2012 +0000
@@ -40,7 +40,7 @@
 import sun.security.action.GetPropertyAction;
 
 
-class Util {
+public class Util {
 
     // -- Caches --
 
@@ -158,7 +158,7 @@
     /**
      * Returns a temporary buffer of at least the given size
      */
-    static ByteBuffer getTemporaryDirectBuffer(int size) {
+    public static ByteBuffer getTemporaryDirectBuffer(int size) {
         BufferCache cache = bufferCache.get();
         ByteBuffer buf = cache.get(size);
         if (buf != null) {
@@ -178,7 +178,7 @@
     /**
      * Releases a temporary buffer by returning to the cache or freeing it.
      */
-    static void releaseTemporaryDirectBuffer(ByteBuffer buf) {
+    public static void releaseTemporaryDirectBuffer(ByteBuffer buf) {
         offerFirstTemporaryDirectBuffer(buf);
     }
 
@@ -467,7 +467,7 @@
 
     private static boolean loaded = false;
 
-    static void load() {
+    public static void load() {
         synchronized (Util.class) {
             if (loaded)
                 return;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/sun/nio/ch/sctp/MessageInfoImpl.java	Mon Feb 13 14:31:32 2012 +0000
@@ -0,0 +1,170 @@
+/*
+ * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package sun.nio.ch.sctp;
+
+import java.net.SocketAddress;
+import com.sun.nio.sctp.MessageInfo;
+import com.sun.nio.sctp.Association;
+
+/**
+ * An implementation of a MessageInfo.
+ */
+public class MessageInfoImpl extends MessageInfo {
+    private final SocketAddress address;
+    private final int bytes;          /* 0 */
+
+    private Association association;
+    private int assocId;
+    private int streamNumber;
+    private boolean complete = true;
+    private boolean unordered;  /* false */
+    private long timeToLive;    /* 0L */
+    private int ppid;           /* 0 */
+
+    public MessageInfoImpl(Association association,
+                           SocketAddress address,
+                           int streamNumber) {
+        this.association = association;
+        this.address = address;
+        this.streamNumber = streamNumber;
+        bytes = 0;
+    }
+
+    /* Invoked from native */
+    private MessageInfoImpl(int assocId,
+                            SocketAddress address,
+                            int bytes,
+                            int streamNumber,
+                            boolean complete,
+                            boolean unordered,
+                            int ppid) {
+        this.assocId = assocId;
+        this.address = address;
+        this.bytes = bytes;
+        this.streamNumber = streamNumber;
+        this.complete = complete;
+        this.unordered = unordered;
+        this.ppid = ppid;
+    }
+
+    @Override
+    public Association association() {
+        return association;
+    }
+
+    /**
+     * MessageInfoImpl instances created from native will need to have their
+     * association set from the channel.
+     */
+    void setAssociation(Association association) {
+        this.association = association;
+    }
+
+    int associationID() {
+        return assocId;
+    }
+
+    @Override
+    public SocketAddress address() {
+        return address;
+    }
+
+    @Override
+    public int bytes() {
+        return bytes;
+    }
+
+    @Override
+    public int streamNumber() {
+        return streamNumber;
+    }
+
+    @Override
+    public MessageInfo streamNumber(int streamNumber) {
+        if (streamNumber < 0 || streamNumber > 65536)
+            throw new IllegalArgumentException("Invalid stream number");
+
+        this.streamNumber = streamNumber;
+        return this;
+    }
+
+    @Override
+    public int payloadProtocolID() {
+        return ppid;
+    }
+
+    @Override
+    public MessageInfo payloadProtocolID(int ppid) {
+        this.ppid = ppid;
+        return this;
+    }
+
+    @Override
+    public boolean isComplete() {
+        return complete;
+    }
+
+    @Override
+    public MessageInfo complete(boolean complete) {
+        this.complete = complete;
+        return this;
+    }
+
+    @Override
+    public boolean isUnordered() {
+        return unordered;
+    }
+
+    @Override
+    public MessageInfo unordered(boolean unordered) {
+        this.unordered = unordered;
+        return this;
+    }
+
+    @Override
+    public long timeToLive() {
+        return timeToLive;
+    }
+
+    @Override
+    public MessageInfo timeToLive(long millis) {
+        timeToLive = millis;
+        return this;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder(super.toString());
+        sb.append( "[Address: ").append(address)
+          .append(", Association: ").append(association)
+          .append(", Assoc ID: ").append(assocId)
+          .append(", Bytes: ").append(bytes)
+          .append(", Stream Number: ").append(streamNumber)
+          .append(", Complete: ").append(complete)
+          .append(", isUnordered: ").append(unordered)
+          .append("]");
+        return sb.toString();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/sun/nio/ch/sctp/SctpStdSocketOption.java	Mon Feb 13 14:31:32 2012 +0000
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package sun.nio.ch.sctp;
+
+import com.sun.nio.sctp.SctpSocketOption;
+
+public class SctpStdSocketOption<T>
+    implements SctpSocketOption<T>
+{
+    /* for native mapping of int options */
+    public static final int SCTP_DISABLE_FRAGMENTS = 1;
+    public static final int SCTP_EXPLICIT_COMPLETE = 2;
+    public static final int SCTP_FRAGMENT_INTERLEAVE = 3;
+    public static final int SCTP_NODELAY = 4;
+    public static final int SO_SNDBUF = 5;
+    public static final int SO_RCVBUF = 6;
+    public static final int SO_LINGER = 7;
+
+    private final String name;
+    private final Class<T> type;
+
+    /* for native mapping of int options */
+    private int constValue;
+
+    public SctpStdSocketOption(String name, Class<T> type) {
+        this.name = name;
+        this.type = type;
+    }
+
+    public SctpStdSocketOption(String name, Class<T> type, int constValue) {
+        this.name = name;
+        this.type = type;
+        this.constValue = constValue;
+    }
+
+    @Override
+    public String name() {
+        return name;
+    }
+
+    @Override
+    public Class<T> type() {
+        return type;
+    }
+
+    @Override
+    public String toString() {
+        return name;
+    }
+
+    int constValue() {
+        return constValue;
+    }
+}
--- a/jdk/src/share/classes/sun/security/pkcs12/PKCS12KeyStore.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/share/classes/sun/security/pkcs12/PKCS12KeyStore.java	Mon Feb 13 14:31:32 2012 +0000
@@ -253,11 +253,25 @@
         }
 
         try {
-            // Use JCE
-            SecretKey skey = getPBEKey(password);
-            Cipher cipher = Cipher.getInstance(algOid.toString());
-            cipher.init(Cipher.DECRYPT_MODE, skey, algParams);
-            byte[] privateKeyInfo = cipher.doFinal(encryptedKey);
+            byte[] privateKeyInfo;
+            while (true) {
+                try {
+                    // Use JCE
+                    SecretKey skey = getPBEKey(password);
+                    Cipher cipher = Cipher.getInstance(algOid.toString());
+                    cipher.init(Cipher.DECRYPT_MODE, skey, algParams);
+                    privateKeyInfo = cipher.doFinal(encryptedKey);
+                    break;
+                } catch (Exception e) {
+                    if (password.length == 0) {
+                        // Retry using an empty password
+                        // without a NULL terminator.
+                        password = new char[1];
+                        continue;
+                    }
+                    throw e;
+                }
+            }
 
             PKCS8EncodedKeySpec kspec = new PKCS8EncodedKeySpec(privateKeyInfo);
 
@@ -1251,16 +1265,24 @@
                 ObjectIdentifier algOid = in.getOID();
                 AlgorithmParameters algParams = parseAlgParameters(in);
 
-                try {
-                    // Use JCE
-                    SecretKey skey = getPBEKey(password);
-                    Cipher cipher = Cipher.getInstance(algOid.toString());
-                    cipher.init(Cipher.DECRYPT_MODE, skey, algParams);
-                    safeContentsData = cipher.doFinal(safeContentsData);
-
-                } catch (Exception e) {
-                    throw new IOException("failed to decrypt safe"
-                            + " contents entry: " + e, e);
+                while (true) {
+                    try {
+                        // Use JCE
+                        SecretKey skey = getPBEKey(password);
+                        Cipher cipher = Cipher.getInstance(algOid.toString());
+                        cipher.init(Cipher.DECRYPT_MODE, skey, algParams);
+                        safeContentsData = cipher.doFinal(safeContentsData);
+                        break;
+                    } catch (Exception e) {
+                        if (password.length == 0) {
+                            // Retry using an empty password
+                            // without a NULL terminator.
+                            password = new char[1];
+                            continue;
+                        }
+                        throw new IOException(
+                                "failed to decrypt safe contents entry: " + e, e);
+                    }
                 }
             } else {
                 throw new IOException("public key protected PKCS12" +
--- a/jdk/src/share/classes/sun/tools/jar/CommandLine.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/share/classes/sun/tools/jar/CommandLine.java	Mon Feb 13 14:31:32 2012 +0000
@@ -55,7 +55,7 @@
     public static String[] parse(String[] args)
         throws IOException
     {
-        ArrayList newArgs = new ArrayList(args.length);
+        List<String> newArgs = new ArrayList<>(args.length);
         for (int i = 0; i < args.length; i++) {
             String arg = args[i];
             if (arg.length() > 1 && arg.charAt(0) == '@') {
@@ -69,10 +69,10 @@
                 newArgs.add(arg);
             }
         }
-        return (String[])newArgs.toArray(new String[newArgs.size()]);
+        return newArgs.toArray(new String[newArgs.size()]);
     }
 
-    private static void loadCmdFile(String name, List args)
+    private static void loadCmdFile(String name, List<String> args)
         throws IOException
     {
         Reader r = new BufferedReader(new FileReader(name));
@@ -83,7 +83,7 @@
         st.commentChar('#');
         st.quoteChar('"');
         st.quoteChar('\'');
-        while (st.nextToken() != st.TT_EOF) {
+        while (st.nextToken() != StreamTokenizer.TT_EOF) {
             args.add(st.sval);
         }
         r.close();
--- a/jdk/src/share/classes/sun/tools/jar/Manifest.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/share/classes/sun/tools/jar/Manifest.java	Mon Feb 13 14:31:32 2012 +0000
@@ -47,10 +47,10 @@
     /* list of headers that all pertain to a particular
      * file in the archive
      */
-    private Vector entries = new Vector();
+    private Vector<MessageHeader> entries = new Vector<>();
     private byte[] tmpbuf = new byte[512];
     /* a hashtable of entries, for fast lookup */
-    private Hashtable tableEntries = new Hashtable();
+    private Hashtable<String, MessageHeader> tableEntries = new Hashtable<>();
 
     static final String[] hashes = {"SHA"};
     static final byte[] EOL = {(byte)'\r', (byte)'\n'};
@@ -115,14 +115,14 @@
     }
 
     public MessageHeader getEntry(String name) {
-        return (MessageHeader) tableEntries.get(name);
+        return tableEntries.get(name);
     }
 
     public MessageHeader entryAt(int i) {
-        return (MessageHeader) entries.elementAt(i);
+        return entries.elementAt(i);
     }
 
-    public Enumeration entries() {
+    public Enumeration<MessageHeader> entries() {
         return entries.elements();
     }
 
@@ -214,7 +214,7 @@
         /* the first header in the file should be the global one.
          * It should say "Manifest-Version: x.x"; if not add it
          */
-        MessageHeader globals = (MessageHeader) entries.elementAt(0);
+        MessageHeader globals = entries.elementAt(0);
 
         if (globals.findValue("Manifest-Version") == null) {
             /* Assume this is a user-defined manifest.  If it has a Name: <..>
@@ -238,7 +238,7 @@
         globals.print(ps);
 
         for (int i = 1; i < entries.size(); ++i) {
-            MessageHeader mh = (MessageHeader) entries.elementAt(i);
+            MessageHeader mh = entries.elementAt(i);
             mh.print(ps);
         }
     }
--- a/jdk/src/share/classes/sun/tools/jar/SignatureFile.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/share/classes/sun/tools/jar/SignatureFile.java	Mon Feb 13 14:31:32 2012 +0000
@@ -47,7 +47,7 @@
  *
  * <p>Each entry section contains the name of an entry (which must
  * have a counterpart in the manifest). Like the manifest it contains
- * a hash, the hash of the manifest section correspondind to the
+ * a hash, the hash of the manifest section corresponding to the
  * name. Since the manifest entry contains the hash of the data, this
  * is equivalent to a signature of the data, plus the attributes of
  * the manifest entry.
@@ -66,7 +66,7 @@
 
     /* list of headers that all pertain to a particular file in the
      * archive */
-    private Vector entries = new Vector();
+    private Vector<MessageHeader> entries = new Vector<>();
 
     /* Right now we only support SHA hashes */
     static final String[] hashes = {"SHA"};
@@ -98,7 +98,7 @@
      * character in length.  */
     private SignatureFile(String name) throws JarException {
 
-        entries = new Vector();
+        entries = new Vector<>();
 
         if (name != null) {
             if (name.length() > 8 || name.indexOf('.') != -1) {
@@ -142,9 +142,9 @@
         this(name, true);
 
         this.manifest = manifest;
-        Enumeration enum_ = manifest.entries();
+        Enumeration<MessageHeader> enum_ = manifest.entries();
         while (enum_.hasMoreElements()) {
-            MessageHeader mh = (MessageHeader)enum_.nextElement();
+            MessageHeader mh = enum_.nextElement();
             String entryName = mh.findValue("Name");
             if (entryName != null) {
                 add(entryName);
@@ -269,9 +269,9 @@
      *the entry does not exist.
      */
     public MessageHeader getEntry(String name) {
-        Enumeration enum_ = entries();
+        Enumeration<MessageHeader> enum_ = entries();
         while(enum_.hasMoreElements()) {
-            MessageHeader mh = (MessageHeader)enum_.nextElement();
+            MessageHeader mh = enum_.nextElement();
             if (name.equals(mh.findValue("Name"))) {
                 return mh;
             }
@@ -282,13 +282,13 @@
     /**
      * Returns the n-th entry. The global header is a entry 0.  */
     public MessageHeader entryAt(int n) {
-        return (MessageHeader) entries.elementAt(n);
+        return entries.elementAt(n);
     }
 
     /**
      * Returns an enumeration of the entries.
      */
-    public Enumeration entries() {
+    public Enumeration<MessageHeader> entries() {
         return entries.elements();
     }
 
@@ -322,11 +322,11 @@
         }
     }
 
-    private Hashtable digests = new Hashtable();
+    private Hashtable<String, MessageDigest> digests = new Hashtable<>();
 
     private MessageDigest getDigest(String algorithm)
     throws NoSuchAlgorithmException {
-        MessageDigest dig = (MessageDigest)digests.get(algorithm);
+        MessageDigest dig = digests.get(algorithm);
         if (dig == null) {
             dig = MessageDigest.getInstance(algorithm);
             digests.put(algorithm, dig);
@@ -344,7 +344,7 @@
         /* the first header in the file should be the global one.
          * It should say "SignatureFile-Version: x.x"; barf if not
          */
-        MessageHeader globals = (MessageHeader) entries.elementAt(0);
+        MessageHeader globals = entries.elementAt(0);
         if (globals.findValue("Signature-Version") == null) {
             throw new JarException("Signature file requires " +
                             "Signature-Version: 1.0 in 1st header");
@@ -354,7 +354,7 @@
         globals.print(ps);
 
         for (int i = 1; i < entries.size(); ++i) {
-            MessageHeader mh = (MessageHeader) entries.elementAt(i);
+            MessageHeader mh = entries.elementAt(i);
             mh.print(ps);
         }
     }
--- a/jdk/src/share/demo/management/MemoryMonitor/MemoryMonitor.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/share/demo/management/MemoryMonitor/MemoryMonitor.java	Mon Feb 13 14:31:32 2012 +0000
@@ -213,10 +213,10 @@
 
             // Calculate remaining size
             float ssH = ascent + descent;
-            float remainingHeight = (float) (y2 - (ssH*2) - 0.5f);
+            float remainingHeight = y2 - (ssH*2) - 0.5f;
             float blockHeight = remainingHeight/10;
             float blockWidth = 20.0f;
-            float remainingWidth = (float) (x2 - blockWidth - 10);
+            float remainingWidth = x2 - blockWidth - 10;
 
             // .. Memory Free ..
             big.setColor(mfColor);
@@ -224,7 +224,7 @@
             int i = 0;
             for ( ; i < MemUsage ; i++) {
                 mfRect.setRect(x1+5,(float) y1+ssH+i*blockHeight,
-                                blockWidth,(float) blockHeight-1);
+                                blockWidth, blockHeight-1);
                 big.fill(mfRect);
             }
 
@@ -232,13 +232,13 @@
             big.setColor(Color.green);
             for ( ; i < 10; i++)  {
                 muRect.setRect(x1+5,(float) y1 + ssH+i*blockHeight,
-                                blockWidth,(float) blockHeight-1);
+                                blockWidth, blockHeight-1);
                 big.fill(muRect);
             }
 
             // .. Draw History Graph ..
             if (remainingWidth <= 30) remainingWidth = (float)30;
-            if (remainingHeight <= ssH) remainingHeight = (float)ssH;
+            if (remainingHeight <= ssH) remainingHeight = ssH;
             big.setColor(graphColor);
             int graphX = x1+30;
             int graphY = y1 + (int) ssH;
@@ -347,8 +347,8 @@
                     big = bimg.createGraphics();
                     big.setFont(font);
                     FontMetrics fm = big.getFontMetrics(font);
-                    ascent = (int) fm.getAscent();
-                    descent = (int) fm.getDescent();
+                    ascent = fm.getAscent();
+                    descent = fm.getDescent();
                 }
                 repaint();
                 try {
--- a/jdk/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipConstants.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipConstants.java	Mon Feb 13 14:31:32 2012 +0000
@@ -185,11 +185,11 @@
      */
     ///////////////////////////////////////////////////////
     static final int CH(byte[] b, int n) {
-       return b[n] & 0xff;
+        return Byte.toUnsignedInt(b[n]);
     }
 
     static final int SH(byte[] b, int n) {
-        return (b[n] & 0xff) | ((b[n + 1] & 0xff) << 8);
+        return Byte.toUnsignedInt(b[n]) | (Byte.toUnsignedInt(b[n + 1]) << 8);
     }
 
     static final long LG(byte[] b, int n) {
--- a/jdk/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileStore.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileStore.java	Mon Feb 13 14:31:32 2012 +0000
@@ -61,7 +61,7 @@
     private final ZipFileSystem zfs;
 
     ZipFileStore(ZipPath zpath) {
-        this.zfs = (ZipFileSystem)zpath.getFileSystem();
+        this.zfs = zpath.getFileSystem();
     }
 
     @Override
--- a/jdk/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileSystem.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileSystem.java	Mon Feb 13 14:31:32 2012 +0000
@@ -1609,7 +1609,7 @@
         synchronized (inflaters) {
             int size = inflaters.size();
             if (size > 0) {
-                Inflater inf = (Inflater)inflaters.remove(size - 1);
+                Inflater inf = inflaters.remove(size - 1);
                 return inf;
             } else {
                 return new Inflater(true);
@@ -1638,7 +1638,7 @@
         synchronized (deflaters) {
             int size = deflaters.size();
             if (size > 0) {
-                Deflater def = (Deflater)deflaters.remove(size - 1);
+                Deflater def = deflaters.remove(size - 1);
                 return def;
             } else {
                 return new Deflater(Deflater.DEFAULT_COMPRESSION, true);
--- a/jdk/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileSystemProvider.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileSystemProvider.java	Mon Feb 13 14:31:32 2012 +0000
@@ -211,7 +211,7 @@
     public <V extends FileAttributeView> V
         getFileAttributeView(Path path, Class<V> type, LinkOption... options)
     {
-        return (V)ZipFileAttributeView.get(toZipPath(path), type);
+        return ZipFileAttributeView.get(toZipPath(path), type);
     }
 
     @Override
--- a/jdk/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipInfo.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipInfo.java	Mon Feb 13 14:31:32 2012 +0000
@@ -78,12 +78,12 @@
                 // twice
                 long len = LOCHDR + CENNAM(cen, pos) + CENEXT(cen, pos) + CENHDR;
                 if (zfs.readFullyAt(buf, 0, len, locoff(cen, pos)) != len)
-                    zfs.zerror("read loc header failed");
+                    ZipFileSystem.zerror("read loc header failed");
                 if (LOCEXT(buf) > CENEXT(cen, pos) + CENHDR) {
                     // have to read the second time;
                     len = LOCHDR + LOCNAM(buf) + LOCEXT(buf);
                     if (zfs.readFullyAt(buf, 0, len, locoff(cen, pos)) != len)
-                        zfs.zerror("read loc header failed");
+                        ZipFileSystem.zerror("read loc header failed");
                 }
                 printLOC(buf);
                 pos += CENHDR + CENNAM(cen, pos) + CENEXT(cen, pos) + CENCOM(cen, pos);
--- a/jdk/src/solaris/classes/sun/awt/X11/XWindowPeer.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/solaris/classes/sun/awt/X11/XWindowPeer.java	Mon Feb 13 14:31:32 2012 +0000
@@ -255,6 +255,21 @@
             }
         }
 
+        if (owner != null || isSimpleWindow()) {
+            XNETProtocol protocol = XWM.getWM().getNETProtocol();
+            if (protocol != null && protocol.active()) {
+                XToolkit.awtLock();
+                try {
+                    XAtomList net_wm_state = getNETWMState();
+                    net_wm_state.add(protocol.XA_NET_WM_STATE_SKIP_TASKBAR);
+                    setNETWMState(net_wm_state);
+                } finally {
+                    XToolkit.awtUnlock();
+                }
+
+            }
+        }
+
          // Init warning window(for applets)
         if (((Window)target).getWarningString() != null) {
             // accessSystemTray permission allows to display TrayIcon, TrayIcon tooltip
@@ -480,14 +495,6 @@
                              bounds.x, bounds.y, bounds.width, bounds.height);
             XWM.setMotifDecor(this, false, 0, 0);
 
-            XNETProtocol protocol = XWM.getWM().getNETProtocol();
-            if (protocol != null && protocol.active()) {
-                XAtomList net_wm_state = getNETWMState();
-                net_wm_state.add(protocol.XA_NET_WM_STATE_SKIP_TASKBAR);
-                setNETWMState(net_wm_state);
-            }
-
-
             boolean isResized = !bounds.getSize().equals(oldBounds.getSize());
             boolean isMoved = !bounds.getLocation().equals(oldBounds.getLocation());
             if (isMoved || isResized) {
--- a/jdk/src/solaris/classes/sun/nio/ch/DevPollSelectorImpl.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/solaris/classes/sun/nio/ch/DevPollSelectorImpl.java	Mon Feb 13 14:31:32 2012 +0000
@@ -180,7 +180,7 @@
             ((SelChImpl)selch).kill();
     }
 
-    void putEventOps(SelectionKeyImpl sk, int ops) {
+    public void putEventOps(SelectionKeyImpl sk, int ops) {
         if (closed)
             throw new ClosedSelectorException();
         int fd = IOUtil.fdVal(sk.channel.getFD());
--- a/jdk/src/solaris/classes/sun/nio/ch/EPollSelectorImpl.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/solaris/classes/sun/nio/ch/EPollSelectorImpl.java	Mon Feb 13 14:31:32 2012 +0000
@@ -181,7 +181,7 @@
             ((SelChImpl)selch).kill();
     }
 
-    void putEventOps(SelectionKeyImpl sk, int ops) {
+    public void putEventOps(SelectionKeyImpl sk, int ops) {
         if (closed)
             throw new ClosedSelectorException();
         pollWrapper.setInterest(sk.channel, ops);
--- a/jdk/src/solaris/classes/sun/nio/ch/NativeThread.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/solaris/classes/sun/nio/ch/NativeThread.java	Mon Feb 13 14:31:32 2012 +0000
@@ -37,21 +37,21 @@
 // always returns -1 and the signal(long) method has no effect.
 
 
-class NativeThread {
+public class NativeThread {
 
     // Returns an opaque token representing the native thread underlying the
     // invoking Java thread.  On systems that do not require signalling, this
     // method always returns -1.
     //
-    static native long current();
+    public static native long current();
 
     // Signals the given native thread so as to release it from a blocking I/O
     // operation.  On systems that do not require signalling, this method has
     // no effect.
     //
-    static native void signal(long nt);
+    public static native void signal(long nt);
 
-    static native void init();
+    private static native void init();
 
     static {
         Util.load();
--- a/jdk/src/solaris/classes/sun/nio/ch/PollArrayWrapper.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/solaris/classes/sun/nio/ch/PollArrayWrapper.java	Mon Feb 13 14:31:32 2012 +0000
@@ -41,9 +41,9 @@
  * @since 1.4
  */
 
-class PollArrayWrapper extends AbstractPollArrayWrapper {
+public class PollArrayWrapper extends AbstractPollArrayWrapper {
 
-    static final short POLLCONN = POLLOUT;
+    public static final short POLLCONN = POLLOUT;
 
     // File descriptor to write for interrupt
     int interruptFD;
--- a/jdk/src/solaris/classes/sun/nio/ch/SctpAssocChange.java	Mon Feb 13 14:26:25 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,120 +0,0 @@
-/*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package sun.nio.ch;
-
-import com.sun.nio.sctp.Association;
-import com.sun.nio.sctp.AssociationChangeNotification;
-
-/**
- * An implementation of AssociationChangeNotification
- */
-public class SctpAssocChange extends AssociationChangeNotification
-    implements SctpNotification
-{
-    /* static final ints so that they can be referenced from native */
-    private final static int SCTP_COMM_UP = 1;
-    private final static int SCTP_COMM_LOST = 2;
-    private final static int SCTP_RESTART = 3;
-    private final static int SCTP_SHUTDOWN = 4;
-    private final static int SCTP_CANT_START = 5;
-
-    private Association association;
-
-    /* assocId is used to lookup the association before the notification is
-     * returned to user code */
-    private int assocId;
-    private AssocChangeEvent event;
-    private int maxOutStreams;
-    private int maxInStreams;
-
-    /* Invoked from native */
-    private SctpAssocChange(int assocId,
-                            int intEvent,
-                            int maxOutStreams,
-                            int maxInStreams) {
-        switch (intEvent) {
-            case SCTP_COMM_UP :
-                this.event = AssocChangeEvent.COMM_UP;
-                break;
-            case SCTP_COMM_LOST :
-                this.event = AssocChangeEvent.COMM_LOST;
-                break;
-            case SCTP_RESTART :
-                this.event = AssocChangeEvent.RESTART;
-                break;
-            case SCTP_SHUTDOWN :
-                this.event = AssocChangeEvent.SHUTDOWN;
-                break;
-            case SCTP_CANT_START :
-                this.event = AssocChangeEvent.CANT_START;
-                break;
-            default :
-                throw new AssertionError(
-                      "Unknown Association Change Event type: " + intEvent);
-        }
-
-        this.assocId = assocId;
-        this.maxOutStreams = maxOutStreams;
-        this.maxInStreams = maxInStreams;
-    }
-
-    @Override
-    public int assocId() {
-        return assocId;
-    }
-
-    @Override
-    public void setAssociation(Association association) {
-        this.association = association;
-    }
-
-    @Override
-    public Association association() {
-        assert association != null;
-        return association;
-    }
-
-    @Override
-    public AssocChangeEvent event() {
-        return event;
-    }
-
-    int maxOutStreams() {
-        return maxOutStreams;
-    }
-
-    int maxInStreams() {
-        return maxInStreams;
-    }
-
-    @Override
-    public String toString() {
-        StringBuilder sb = new StringBuilder();
-        sb.append(super.toString()).append(" [");
-        sb.append("Association:").append(association);
-        sb.append(", Event: ").append(event).append("]");
-        return sb.toString();
-    }
-}
--- a/jdk/src/solaris/classes/sun/nio/ch/SctpAssociationImpl.java	Mon Feb 13 14:26:25 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package sun.nio.ch;
-
-import com.sun.nio.sctp.Association;
-
-/**
- * An implementation of Association
- */
-public class SctpAssociationImpl extends Association {
-    public SctpAssociationImpl(int associationID,
-                               int maxInStreams,
-                               int maxOutStreams) {
-        super(associationID, maxInStreams, maxOutStreams);
-    }
-
-    @Override
-    public String toString() {
-        StringBuffer sb = new StringBuffer(super.toString());
-        return sb.append("[associationID:")
-                 .append(associationID())
-                 .append(", maxIn:")
-                 .append(maxInboundStreams())
-                 .append(", maxOut:")
-                 .append(maxOutboundStreams())
-                 .append("]")
-                 .toString();
-    }
-}
-
--- a/jdk/src/solaris/classes/sun/nio/ch/SctpChannelImpl.java	Mon Feb 13 14:26:25 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1097 +0,0 @@
-/*
- * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package sun.nio.ch;
-
-import java.net.InetAddress;
-import java.net.SocketAddress;
-import java.net.SocketException;
-import java.net.InetSocketAddress;
-import java.io.FileDescriptor;
-import java.io.IOException;
-import java.util.Collections;
-import java.util.Set;
-import java.util.HashSet;
-import java.nio.ByteBuffer;
-import java.nio.channels.SelectionKey;
-import java.nio.channels.ClosedChannelException;
-import java.nio.channels.ConnectionPendingException;
-import java.nio.channels.NoConnectionPendingException;
-import java.nio.channels.AlreadyConnectedException;
-import java.nio.channels.NotYetBoundException;
-import java.nio.channels.NotYetConnectedException;
-import java.nio.channels.spi.SelectorProvider;
-import com.sun.nio.sctp.AbstractNotificationHandler;
-import com.sun.nio.sctp.Association;
-import com.sun.nio.sctp.AssociationChangeNotification;
-import com.sun.nio.sctp.HandlerResult;
-import com.sun.nio.sctp.IllegalReceiveException;
-import com.sun.nio.sctp.InvalidStreamException;
-import com.sun.nio.sctp.IllegalUnbindException;
-import com.sun.nio.sctp.MessageInfo;
-import com.sun.nio.sctp.NotificationHandler;
-import com.sun.nio.sctp.SctpChannel;
-import com.sun.nio.sctp.SctpSocketOption;
-import static com.sun.nio.sctp.SctpStandardSocketOptions.*;
-import static sun.nio.ch.SctpResultContainer.SEND_FAILED;
-import static sun.nio.ch.SctpResultContainer.ASSOCIATION_CHANGED;
-import static sun.nio.ch.SctpResultContainer.PEER_ADDRESS_CHANGED;
-import static sun.nio.ch.SctpResultContainer.SHUTDOWN;
-
-/**
- * An implementation of an SctpChannel
- */
-public class SctpChannelImpl extends SctpChannel
-    implements SelChImpl
-{
-    private final FileDescriptor fd;
-
-    private final int fdVal;
-
-    /* IDs of native threads doing send and receivess, for signalling */
-    private volatile long receiverThread = 0;
-    private volatile long senderThread = 0;
-
-    /* Lock held by current receiving or connecting thread */
-    private final Object receiveLock = new Object();
-
-    /* Lock held by current sending or connecting thread */
-    private final Object sendLock = new Object();
-
-    private final ThreadLocal<Boolean> receiveInvoked =
-        new ThreadLocal<Boolean>() {
-             @Override protected Boolean initialValue() {
-                 return Boolean.FALSE;
-            }
-    };
-
-    /* Lock held by any thread that modifies the state fields declared below
-       DO NOT invoke a blocking I/O operation while holding this lock! */
-    private final Object stateLock = new Object();
-
-    private enum ChannelState {
-        UNINITIALIZED,
-        UNCONNECTED,
-        PENDING,
-        CONNECTED,
-        KILLPENDING,
-        KILLED,
-    }
-    /* -- The following fields are protected by stateLock -- */
-    private ChannelState state = ChannelState.UNINITIALIZED;
-
-    /* Binding; Once bound the port will remain constant. */
-    int port = -1;
-    private HashSet<InetSocketAddress> localAddresses = new HashSet<InetSocketAddress>();
-    /* Has the channel been bound to the wildcard address */
-    private boolean wildcard; /* false */
-    //private InetSocketAddress remoteAddress = null;
-
-    /* Input/Output open */
-    private boolean readyToConnect;
-
-    /* Shutdown */
-    private boolean isShutdown;
-
-    private Association association;
-
-    private Set<SocketAddress> remoteAddresses = Collections.emptySet();
-
-    /* -- End of fields protected by stateLock -- */
-
-    /**
-     * Constructor for normal connecting sockets
-     */
-    public SctpChannelImpl(SelectorProvider provider) throws IOException {
-        //TODO: update provider remove public modifier
-        super(provider);
-        this.fd = SctpNet.socket(true);
-        this.fdVal = IOUtil.fdVal(fd);
-        this.state = ChannelState.UNCONNECTED;
-    }
-
-    /**
-     * Constructor for sockets obtained from server sockets
-     */
-    public SctpChannelImpl(SelectorProvider provider, FileDescriptor fd)
-         throws IOException {
-        this(provider, fd, null);
-    }
-
-    /**
-     * Constructor for sockets obtained from branching
-     */
-    public SctpChannelImpl(SelectorProvider provider,
-                           FileDescriptor fd,
-                           Association association)
-            throws IOException {
-        super(provider);
-        this.fd = fd;
-        this.fdVal = IOUtil.fdVal(fd);
-        this.state = ChannelState.CONNECTED;
-        port = (Net.localAddress(fd)).getPort();
-
-        if (association != null) { /* branched */
-            this.association = association;
-        } else { /* obtained from server channel */
-            /* Receive COMM_UP */
-            ByteBuffer buf = Util.getTemporaryDirectBuffer(50);
-            try {
-                receive(buf, null, null, true);
-            } finally {
-                Util.releaseTemporaryDirectBuffer(buf);
-            }
-        }
-    }
-
-    /**
-     * Binds the channel's socket to a local address.
-     */
-    @Override
-    public SctpChannel bind(SocketAddress local) throws IOException {
-        synchronized (receiveLock) {
-            synchronized (sendLock) {
-                synchronized (stateLock) {
-                    ensureOpenAndUnconnected();
-                    if (isBound())
-                        SctpNet.throwAlreadyBoundException();
-                    InetSocketAddress isa = (local == null) ?
-                        new InetSocketAddress(0) : Net.checkAddress(local);
-                    Net.bind(fd, isa.getAddress(), isa.getPort());
-                    InetSocketAddress boundIsa = Net.localAddress(fd);
-                    port = boundIsa.getPort();
-                    localAddresses.add(isa);
-                    if (isa.getAddress().isAnyLocalAddress())
-                        wildcard = true;
-                }
-            }
-        }
-        return this;
-    }
-
-    @Override
-    public SctpChannel bindAddress(InetAddress address)
-            throws IOException {
-        bindUnbindAddress(address, true);
-        localAddresses.add(new InetSocketAddress(address, port));
-        return this;
-    }
-
-    @Override
-    public SctpChannel unbindAddress(InetAddress address)
-            throws IOException {
-        bindUnbindAddress(address, false);
-        localAddresses.remove(new InetSocketAddress(address, port));
-        return this;
-    }
-
-    private SctpChannel bindUnbindAddress(InetAddress address, boolean add)
-            throws IOException {
-        if (address == null)
-            throw new IllegalArgumentException();
-
-        synchronized (receiveLock) {
-            synchronized (sendLock) {
-                synchronized (stateLock) {
-                    if (!isOpen())
-                        throw new ClosedChannelException();
-                    if (!isBound())
-                        throw new NotYetBoundException();
-                    if (wildcard)
-                        throw new IllegalStateException(
-                                "Cannot add or remove addresses from a channel that is bound to the wildcard address");
-                    if (address.isAnyLocalAddress())
-                        throw new IllegalArgumentException(
-                                "Cannot add or remove the wildcard address");
-                    if (add) {
-                        for (InetSocketAddress addr : localAddresses) {
-                            if (addr.getAddress().equals(address)) {
-                                SctpNet.throwAlreadyBoundException();
-                            }
-                        }
-                    } else { /*removing */
-                        /* Verify that there is more than one address
-                         * and that address is already bound */
-                        if (localAddresses.size() <= 1)
-                            throw new IllegalUnbindException("Cannot remove address from a channel with only one address bound");
-                        boolean foundAddress = false;
-                        for (InetSocketAddress addr : localAddresses) {
-                            if (addr.getAddress().equals(address)) {
-                                foundAddress = true;
-                                break;
-                            }
-                        }
-                        if (!foundAddress )
-                            throw new IllegalUnbindException("Cannot remove address from a channel that is not bound to that address");
-                    }
-
-                    SctpNet.bindx(fdVal, new InetAddress[]{address}, port, add);
-
-                    /* Update our internal Set to reflect the addition/removal */
-                    if (add)
-                        localAddresses.add(new InetSocketAddress(address, port));
-                    else {
-                        for (InetSocketAddress addr : localAddresses) {
-                            if (addr.getAddress().equals(address)) {
-                                localAddresses.remove(addr);
-                                break;
-                            }
-                        }
-                    }
-                }
-            }
-        }
-        return this;
-    }
-
-    private boolean isBound() {
-        synchronized (stateLock) {
-            return port == -1 ? false : true;
-        }
-    }
-
-    private boolean isConnected() {
-        synchronized (stateLock) {
-            return (state == ChannelState.CONNECTED);
-        }
-    }
-
-    private void ensureOpenAndUnconnected() throws IOException {
-        synchronized (stateLock) {
-            if (!isOpen())
-                throw new ClosedChannelException();
-            if (isConnected())
-                throw new AlreadyConnectedException();
-            if (state == ChannelState.PENDING)
-                throw new ConnectionPendingException();
-        }
-    }
-
-    private boolean ensureReceiveOpen() throws ClosedChannelException {
-        synchronized (stateLock) {
-            if (!isOpen())
-                throw new ClosedChannelException();
-            if (!isConnected())
-                throw new NotYetConnectedException();
-            else
-                return true;
-        }
-    }
-
-    private void ensureSendOpen() throws ClosedChannelException {
-        synchronized (stateLock) {
-            if (!isOpen())
-                throw new ClosedChannelException();
-            if (isShutdown)
-                throw new ClosedChannelException();
-            if (!isConnected())
-                throw new NotYetConnectedException();
-        }
-    }
-
-    private void receiverCleanup() throws IOException {
-        synchronized (stateLock) {
-            receiverThread = 0;
-            if (state == ChannelState.KILLPENDING)
-                kill();
-        }
-    }
-
-    private void senderCleanup() throws IOException {
-        synchronized (stateLock) {
-            senderThread = 0;
-            if (state == ChannelState.KILLPENDING)
-                kill();
-        }
-    }
-
-    @Override
-    public Association association() throws ClosedChannelException {
-        synchronized (stateLock) {
-            if (!isOpen())
-                throw new ClosedChannelException();
-            if (!isConnected())
-                return null;
-
-            return association;
-        }
-    }
-
-    @Override
-    public boolean connect(SocketAddress endpoint) throws IOException {
-        synchronized (receiveLock) {
-            synchronized (sendLock) {
-                ensureOpenAndUnconnected();
-                InetSocketAddress isa = Net.checkAddress(endpoint);
-                SecurityManager sm = System.getSecurityManager();
-                if (sm != null)
-                    sm.checkConnect(isa.getAddress().getHostAddress(),
-                                    isa.getPort());
-                synchronized (blockingLock()) {
-                    int n = 0;
-                    try {
-                        try {
-                            begin();
-                            synchronized (stateLock) {
-                                if (!isOpen()) {
-                                    return false;
-                                }
-                                receiverThread = NativeThread.current();
-                            }
-                            for (;;) {
-                                InetAddress ia = isa.getAddress();
-                                if (ia.isAnyLocalAddress())
-                                    ia = InetAddress.getLocalHost();
-                                n = SctpNet.connect(fdVal, ia, isa.getPort());
-                                if (  (n == IOStatus.INTERRUPTED)
-                                      && isOpen())
-                                    continue;
-                                break;
-                            }
-                        } finally {
-                            receiverCleanup();
-                            end((n > 0) || (n == IOStatus.UNAVAILABLE));
-                            assert IOStatus.check(n);
-                        }
-                    } catch (IOException x) {
-                        /* If an exception was thrown, close the channel after
-                         * invoking end() so as to avoid bogus
-                         * AsynchronousCloseExceptions */
-                        close();
-                        throw x;
-                    }
-
-                    if (n > 0) {
-                        synchronized (stateLock) {
-                            /* Connection succeeded */
-                            state = ChannelState.CONNECTED;
-                            if (!isBound()) {
-                                InetSocketAddress boundIsa =
-                                        Net.localAddress(fd);
-                                port = boundIsa.getPort();
-                            }
-
-                            /* Receive COMM_UP */
-                            ByteBuffer buf = Util.getTemporaryDirectBuffer(50);
-                            try {
-                                receive(buf, null, null, true);
-                            } finally {
-                                Util.releaseTemporaryDirectBuffer(buf);
-                            }
-
-                            /* cache remote addresses */
-                            try {
-                                remoteAddresses = getRemoteAddresses();
-                            } catch (IOException unused) { /* swallow exception */ }
-
-                            return true;
-                        }
-                    } else  {
-                        synchronized (stateLock) {
-                            /* If nonblocking and no exception then connection
-                             * pending; disallow another invocation */
-                            if (!isBlocking())
-                                state = ChannelState.PENDING;
-                            else
-                                assert false;
-                        }
-                    }
-                }
-                return false;
-            }
-        }
-    }
-
-    @Override
-    public boolean connect(SocketAddress endpoint,
-                           int maxOutStreams,
-                           int maxInStreams)
-            throws IOException {
-        ensureOpenAndUnconnected();
-        return setOption(SCTP_INIT_MAXSTREAMS, InitMaxStreams.
-                create(maxInStreams, maxOutStreams)).connect(endpoint);
-
-    }
-
-    @Override
-    public boolean isConnectionPending() {
-        synchronized (stateLock) {
-            return (state == ChannelState.PENDING);
-        }
-    }
-
-    @Override
-    public boolean finishConnect() throws IOException {
-        synchronized (receiveLock) {
-            synchronized (sendLock) {
-                synchronized (stateLock) {
-                    if (!isOpen())
-                        throw new ClosedChannelException();
-                    if (isConnected())
-                        return true;
-                    if (state != ChannelState.PENDING)
-                        throw new NoConnectionPendingException();
-                }
-                int n = 0;
-                try {
-                    try {
-                        begin();
-                        synchronized (blockingLock()) {
-                            synchronized (stateLock) {
-                                if (!isOpen()) {
-                                    return false;
-                                }
-                                receiverThread = NativeThread.current();
-                            }
-                            if (!isBlocking()) {
-                                for (;;) {
-                                    n = checkConnect(fd, false, readyToConnect);
-                                    if (  (n == IOStatus.INTERRUPTED)
-                                          && isOpen())
-                                        continue;
-                                    break;
-                                }
-                            } else {
-                                for (;;) {
-                                    n = checkConnect(fd, true, readyToConnect);
-                                    if (n == 0) {
-                                        // Loop in case of
-                                        // spurious notifications
-                                        continue;
-                                    }
-                                    if (  (n == IOStatus.INTERRUPTED)
-                                          && isOpen())
-                                        continue;
-                                    break;
-                                }
-                            }
-                        }
-                    } finally {
-                        synchronized (stateLock) {
-                            receiverThread = 0;
-                            if (state == ChannelState.KILLPENDING) {
-                                kill();
-                                /* poll()/getsockopt() does not report
-                                 * error (throws exception, with n = 0)
-                                 * on Linux platform after dup2 and
-                                 * signal-wakeup. Force n to 0 so the
-                                 * end() can throw appropriate exception */
-                                n = 0;
-                            }
-                        }
-                        end((n > 0) || (n == IOStatus.UNAVAILABLE));
-                        assert IOStatus.check(n);
-                    }
-                } catch (IOException x) {
-                    /* If an exception was thrown, close the channel after
-                     * invoking end() so as to avoid bogus
-                     * AsynchronousCloseExceptions */
-                    close();
-                    throw x;
-                }
-
-                if (n > 0) {
-                    synchronized (stateLock) {
-                        state = ChannelState.CONNECTED;
-                        if (!isBound()) {
-                            InetSocketAddress boundIsa =
-                                    Net.localAddress(fd);
-                            port = boundIsa.getPort();
-                        }
-
-                        /* Receive COMM_UP */
-                        ByteBuffer buf = Util.getTemporaryDirectBuffer(50);
-                        try {
-                            receive(buf, null, null, true);
-                        } finally {
-                            Util.releaseTemporaryDirectBuffer(buf);
-                        }
-
-                        /* cache remote addresses */
-                        try {
-                            remoteAddresses = getRemoteAddresses();
-                        } catch (IOException unused) { /* swallow exception */ }
-
-                        return true;
-                    }
-                }
-            }
-        }
-        return false;
-    }
-
-    @Override
-    protected void implConfigureBlocking(boolean block) throws IOException {
-        IOUtil.configureBlocking(fd, block);
-    }
-
-    @Override
-    public void implCloseSelectableChannel() throws IOException {
-        synchronized (stateLock) {
-            SctpNet.preClose(fdVal);
-
-            if (receiverThread != 0)
-                NativeThread.signal(receiverThread);
-
-            if (senderThread != 0)
-                NativeThread.signal(senderThread);
-
-            if (!isRegistered())
-                kill();
-        }
-    }
-
-    @Override
-    public FileDescriptor getFD() {
-        return fd;
-    }
-
-    @Override
-    public int getFDVal() {
-        return fdVal;
-    }
-
-    /**
-     * Translates native poll revent ops into a ready operation ops
-     */
-    private boolean translateReadyOps(int ops, int initialOps, SelectionKeyImpl sk) {
-        int intOps = sk.nioInterestOps();
-        int oldOps = sk.nioReadyOps();
-        int newOps = initialOps;
-
-        if ((ops & PollArrayWrapper.POLLNVAL) != 0) {
-            /* This should only happen if this channel is pre-closed while a
-             * selection operation is in progress
-             * ## Throw an error if this channel has not been pre-closed */
-            return false;
-        }
-
-        if ((ops & (PollArrayWrapper.POLLERR
-                    | PollArrayWrapper.POLLHUP)) != 0) {
-            newOps = intOps;
-            sk.nioReadyOps(newOps);
-            /* No need to poll again in checkConnect,
-             * the error will be detected there */
-            readyToConnect = true;
-            return (newOps & ~oldOps) != 0;
-        }
-
-        if (((ops & PollArrayWrapper.POLLIN) != 0) &&
-            ((intOps & SelectionKey.OP_READ) != 0) &&
-            isConnected())
-            newOps |= SelectionKey.OP_READ;
-
-        if (((ops & PollArrayWrapper.POLLCONN) != 0) &&
-            ((intOps & SelectionKey.OP_CONNECT) != 0) &&
-            ((state == ChannelState.UNCONNECTED) || (state == ChannelState.PENDING))) {
-            newOps |= SelectionKey.OP_CONNECT;
-            readyToConnect = true;
-        }
-
-        if (((ops & PollArrayWrapper.POLLOUT) != 0) &&
-            ((intOps & SelectionKey.OP_WRITE) != 0) &&
-            isConnected())
-            newOps |= SelectionKey.OP_WRITE;
-
-        sk.nioReadyOps(newOps);
-        return (newOps & ~oldOps) != 0;
-    }
-
-    @Override
-    public boolean translateAndUpdateReadyOps(int ops, SelectionKeyImpl sk) {
-        return translateReadyOps(ops, sk.nioReadyOps(), sk);
-    }
-
-    @Override
-    @SuppressWarnings("all")
-    public boolean translateAndSetReadyOps(int ops, SelectionKeyImpl sk) {
-        return translateReadyOps(ops, 0, sk);
-    }
-
-    @Override
-    public void translateAndSetInterestOps(int ops, SelectionKeyImpl sk) {
-        int newOps = 0;
-        if ((ops & SelectionKey.OP_READ) != 0)
-            newOps |= PollArrayWrapper.POLLIN;
-        if ((ops & SelectionKey.OP_WRITE) != 0)
-            newOps |= PollArrayWrapper.POLLOUT;
-        if ((ops & SelectionKey.OP_CONNECT) != 0)
-            newOps |= PollArrayWrapper.POLLCONN;
-        sk.selector.putEventOps(sk, newOps);
-    }
-
-    @Override
-    public void kill() throws IOException {
-        synchronized (stateLock) {
-            if (state == ChannelState.KILLED)
-                return;
-            if (state == ChannelState.UNINITIALIZED) {
-                state = ChannelState.KILLED;
-                return;
-            }
-            assert !isOpen() && !isRegistered();
-
-            /* Postpone the kill if there is a waiting reader
-             * or writer thread. */
-            if (receiverThread == 0 && senderThread == 0) {
-                SctpNet.close(fdVal);
-                state = ChannelState.KILLED;
-            } else {
-                state = ChannelState.KILLPENDING;
-            }
-        }
-    }
-
-    @Override
-    public <T> SctpChannel setOption(SctpSocketOption<T> name, T value)
-            throws IOException {
-        if (name == null)
-            throw new NullPointerException();
-        if (!supportedOptions().contains(name))
-            throw new UnsupportedOperationException("'" + name + "' not supported");
-
-        synchronized (stateLock) {
-            if (!isOpen())
-                throw new ClosedChannelException();
-
-            SctpNet.setSocketOption(fdVal, name, value, 0 /*oneToOne*/);
-        }
-        return this;
-    }
-
-    @Override
-    @SuppressWarnings("unchecked")
-    public <T> T getOption(SctpSocketOption<T> name) throws IOException {
-        if (name == null)
-            throw new NullPointerException();
-        if (!supportedOptions().contains(name))
-            throw new UnsupportedOperationException("'" + name + "' not supported");
-
-        synchronized (stateLock) {
-            if (!isOpen())
-                throw new ClosedChannelException();
-
-            return (T)SctpNet.getSocketOption(fdVal, name, 0 /*oneToOne*/);
-        }
-    }
-
-    private static class DefaultOptionsHolder {
-        static final Set<SctpSocketOption<?>> defaultOptions = defaultOptions();
-
-        private static Set<SctpSocketOption<?>> defaultOptions() {
-            HashSet<SctpSocketOption<?>> set = new HashSet<SctpSocketOption<?>>(10);
-            set.add(SCTP_DISABLE_FRAGMENTS);
-            set.add(SCTP_EXPLICIT_COMPLETE);
-            set.add(SCTP_FRAGMENT_INTERLEAVE);
-            set.add(SCTP_INIT_MAXSTREAMS);
-            set.add(SCTP_NODELAY);
-            set.add(SCTP_PRIMARY_ADDR);
-            set.add(SCTP_SET_PEER_PRIMARY_ADDR);
-            set.add(SO_SNDBUF);
-            set.add(SO_RCVBUF);
-            set.add(SO_LINGER);
-            return Collections.unmodifiableSet(set);
-        }
-    }
-
-    @Override
-    public final Set<SctpSocketOption<?>> supportedOptions() {
-        return DefaultOptionsHolder.defaultOptions;
-    }
-
-    @Override
-    public <T> MessageInfo receive(ByteBuffer buffer,
-                                   T attachment,
-                                   NotificationHandler<T> handler)
-            throws IOException {
-        return receive(buffer, attachment, handler, false);
-    }
-
-    private <T> MessageInfo receive(ByteBuffer buffer,
-                                    T attachment,
-                                    NotificationHandler<T> handler,
-                                    boolean fromConnect)
-            throws IOException {
-        if (buffer == null)
-            throw new IllegalArgumentException("buffer cannot be null");
-
-        if (buffer.isReadOnly())
-            throw new IllegalArgumentException("Read-only buffer");
-
-        if (receiveInvoked.get())
-            throw new IllegalReceiveException(
-                    "cannot invoke receive from handler");
-        receiveInvoked.set(Boolean.TRUE);
-
-        try {
-            SctpResultContainer resultContainer = new SctpResultContainer();
-            do {
-                resultContainer.clear();
-                synchronized (receiveLock) {
-                    if (!ensureReceiveOpen())
-                        return null;
-
-                    int n = 0;
-                    try {
-                        begin();
-
-                        synchronized (stateLock) {
-                            if(!isOpen())
-                                return null;
-                            receiverThread = NativeThread.current();
-                        }
-
-                        do {
-                            n = receive(fdVal, buffer, resultContainer, fromConnect);
-                        } while ((n == IOStatus.INTERRUPTED) && isOpen());
-                    } finally {
-                        receiverCleanup();
-                        end((n > 0) || (n == IOStatus.UNAVAILABLE));
-                        assert IOStatus.check(n);
-                    }
-
-                    if (!resultContainer.isNotification()) {
-                        /* message or nothing */
-                        if (resultContainer.hasSomething()) {
-                            /* Set the association before returning */
-                            SctpMessageInfoImpl info =
-                                    resultContainer.getMessageInfo();
-                            synchronized (stateLock) {
-                                assert association != null;
-                                info.setAssociation(association);
-                            }
-                            return info;
-                        } else
-                            /* Non-blocking may return null if nothing available*/
-                            return null;
-                    } else { /* notification */
-                        synchronized (stateLock) {
-                            handleNotificationInternal(
-                                    resultContainer);
-                        }
-                    }
-
-                    if (fromConnect)  {
-                        /* If we reach here, then it was connect that invoked
-                         * receive and received the COMM_UP. We have already
-                         * handled the COMM_UP with the internal notification
-                         * handler. Simply return. */
-                        return null;
-                    }
-                }  /* receiveLock */
-            } while (handler == null ? true :
-                (invokeNotificationHandler(resultContainer, handler, attachment)
-                 == HandlerResult.CONTINUE));
-
-            return null;
-        } finally {
-            receiveInvoked.set(Boolean.FALSE);
-        }
-    }
-
-    private int receive(int fd,
-                        ByteBuffer dst,
-                        SctpResultContainer resultContainer,
-                        boolean peek)
-            throws IOException {
-        int pos = dst.position();
-        int lim = dst.limit();
-        assert (pos <= lim);
-        int rem = (pos <= lim ? lim - pos : 0);
-        if (dst instanceof DirectBuffer && rem > 0)
-            return receiveIntoNativeBuffer(fd, resultContainer, dst, rem, pos, peek);
-
-        /* Substitute a native buffer */
-        int newSize = Math.max(rem, 1);
-        ByteBuffer bb = Util.getTemporaryDirectBuffer(newSize);
-        try {
-            int n = receiveIntoNativeBuffer(fd, resultContainer, bb, newSize, 0, peek);
-            bb.flip();
-            if (n > 0 && rem > 0)
-                dst.put(bb);
-            return n;
-        } finally {
-            Util.releaseTemporaryDirectBuffer(bb);
-        }
-    }
-
-    private int receiveIntoNativeBuffer(int fd,
-                                        SctpResultContainer resultContainer,
-                                        ByteBuffer bb,
-                                        int rem,
-                                        int pos,
-                                        boolean peek)
-        throws IOException
-    {
-        int n = receive0(fd, resultContainer, ((DirectBuffer)bb).address() + pos, rem, peek);
-
-        if (n > 0)
-            bb.position(pos + n);
-        return n;
-    }
-
-    private InternalNotificationHandler internalNotificationHandler =
-            new InternalNotificationHandler();
-
-    private void handleNotificationInternal(SctpResultContainer resultContainer)
-    {
-        invokeNotificationHandler(resultContainer,
-                internalNotificationHandler, null);
-    }
-
-    private class InternalNotificationHandler
-            extends AbstractNotificationHandler<Object>
-    {
-        @Override
-        public HandlerResult handleNotification(
-                AssociationChangeNotification not, Object unused) {
-            if (not.event().equals(
-                    AssociationChangeNotification.AssocChangeEvent.COMM_UP) &&
-                    association == null) {
-                SctpAssocChange sac = (SctpAssocChange) not;
-                association = new SctpAssociationImpl
-                       (sac.assocId(), sac.maxInStreams(), sac.maxOutStreams());
-            }
-            return HandlerResult.CONTINUE;
-        }
-    }
-
-    private <T> HandlerResult invokeNotificationHandler
-                                 (SctpResultContainer resultContainer,
-                                  NotificationHandler<T> handler,
-                                  T attachment) {
-        SctpNotification notification = resultContainer.notification();
-        synchronized (stateLock) {
-            notification.setAssociation(association);
-        }
-
-        if (!(handler instanceof AbstractNotificationHandler)) {
-            return handler.handleNotification(notification, attachment);
-        }
-
-        /* AbstractNotificationHandler */
-        AbstractNotificationHandler<T> absHandler =
-                (AbstractNotificationHandler<T>)handler;
-        switch(resultContainer.type()) {
-            case ASSOCIATION_CHANGED :
-                return absHandler.handleNotification(
-                        resultContainer.getAssociationChanged(), attachment);
-            case PEER_ADDRESS_CHANGED :
-                return absHandler.handleNotification(
-                        resultContainer.getPeerAddressChanged(), attachment);
-            case SEND_FAILED :
-                return absHandler.handleNotification(
-                        resultContainer.getSendFailed(), attachment);
-            case SHUTDOWN :
-                return absHandler.handleNotification(
-                        resultContainer.getShutdown(), attachment);
-            default :
-                /* implementation specific handlers */
-                return absHandler.handleNotification(
-                        resultContainer.notification(), attachment);
-        }
-    }
-
-    private void checkAssociation(Association sendAssociation) {
-        synchronized (stateLock) {
-            if (sendAssociation != null && !sendAssociation.equals(association)) {
-                throw new IllegalArgumentException(
-                        "Cannot send to another association");
-            }
-        }
-    }
-
-    private void checkStreamNumber(int streamNumber) {
-        synchronized (stateLock) {
-            if (association != null) {
-                if (streamNumber < 0 ||
-                      streamNumber >= association.maxOutboundStreams())
-                    throw new InvalidStreamException();
-            }
-        }
-    }
-
-    /* TODO: Add support for ttl and isComplete to both 121 12M
-     *       SCTP_EOR not yet supported on reference platforms
-     *       TTL support limited...
-     */
-    @Override
-    public int send(ByteBuffer buffer, MessageInfo messageInfo)
-            throws IOException {
-        if (buffer == null)
-            throw new IllegalArgumentException("buffer cannot be null");
-
-        if (messageInfo == null)
-            throw new IllegalArgumentException("messageInfo cannot be null");
-
-        checkAssociation(messageInfo.association());
-        checkStreamNumber(messageInfo.streamNumber());
-
-        synchronized (sendLock) {
-            ensureSendOpen();
-
-            int n = 0;
-            try {
-                begin();
-
-                synchronized (stateLock) {
-                    if(!isOpen())
-                        return 0;
-                    senderThread = NativeThread.current();
-                }
-
-                do {
-                    n = send(fdVal, buffer, messageInfo);
-                } while ((n == IOStatus.INTERRUPTED) && isOpen());
-
-                return IOStatus.normalize(n);
-            } finally {
-                senderCleanup();
-                end((n > 0) || (n == IOStatus.UNAVAILABLE));
-                assert IOStatus.check(n);
-            }
-        }
-    }
-
-    private int send(int fd, ByteBuffer src, MessageInfo messageInfo)
-            throws IOException {
-        int streamNumber = messageInfo.streamNumber();
-        SocketAddress target = messageInfo.address();
-        boolean unordered = messageInfo.isUnordered();
-        int ppid = messageInfo.payloadProtocolID();
-
-        if (src instanceof DirectBuffer)
-            return sendFromNativeBuffer(fd, src, target, streamNumber,
-                    unordered, ppid);
-
-        /* Substitute a native buffer */
-        int pos = src.position();
-        int lim = src.limit();
-        assert (pos <= lim && streamNumber >= 0);
-
-        int rem = (pos <= lim ? lim - pos : 0);
-        ByteBuffer bb = Util.getTemporaryDirectBuffer(rem);
-        try {
-            bb.put(src);
-            bb.flip();
-            /* Do not update src until we see how many bytes were written */
-            src.position(pos);
-
-            int n = sendFromNativeBuffer(fd, bb, target, streamNumber,
-                    unordered, ppid);
-            if (n > 0) {
-                /* now update src */
-                src.position(pos + n);
-            }
-            return n;
-        } finally {
-            Util.releaseTemporaryDirectBuffer(bb);
-        }
-    }
-
-    private int sendFromNativeBuffer(int fd,
-                                     ByteBuffer bb,
-                                     SocketAddress target,
-                                     int streamNumber,
-                                     boolean unordered,
-                                     int ppid)
-            throws IOException {
-        int pos = bb.position();
-        int lim = bb.limit();
-        assert (pos <= lim);
-        int rem = (pos <= lim ? lim - pos : 0);
-
-        int written = send0(fd, ((DirectBuffer)bb).address() + pos,
-                            rem, target, -1 /*121*/, streamNumber, unordered, ppid);
-        if (written > 0)
-            bb.position(pos + written);
-        return written;
-    }
-
-    @Override
-    public SctpChannel shutdown() throws IOException {
-        synchronized(stateLock) {
-            if (isShutdown)
-                return this;
-
-            ensureSendOpen();
-            SctpNet.shutdown(fdVal, -1);
-            if (senderThread != 0)
-                NativeThread.signal(senderThread);
-            isShutdown = true;
-        }
-        return this;
-    }
-
-    @Override
-    public Set<SocketAddress> getAllLocalAddresses()
-            throws IOException {
-        synchronized (stateLock) {
-            if (!isOpen())
-                throw new ClosedChannelException();
-            if (!isBound())
-                return Collections.emptySet();
-
-            return SctpNet.getLocalAddresses(fdVal);
-        }
-    }
-
-    @Override
-    public Set<SocketAddress> getRemoteAddresses()
-            throws IOException {
-        synchronized (stateLock) {
-            if (!isOpen())
-                throw new ClosedChannelException();
-            if (!isConnected() || isShutdown)
-                return Collections.emptySet();
-
-            try {
-                return SctpNet.getRemoteAddresses(fdVal, 0/*unused*/);
-            } catch (SocketException unused) {
-                /* an open connected channel should always have remote addresses */
-                return remoteAddresses;
-            }
-        }
-    }
-
-    /* Native */
-    private static native void initIDs();
-
-    static native int receive0(int fd, SctpResultContainer resultContainer,
-            long address, int length, boolean peek) throws IOException;
-
-    static native int send0(int fd, long address, int length,
-            SocketAddress target, int assocId, int streamNumber,
-            boolean unordered, int ppid) throws IOException;
-
-    private static native int checkConnect(FileDescriptor fd, boolean block,
-            boolean ready) throws IOException;
-
-    static {
-        Util.load();   /* loads nio & net native libraries */
-        java.security.AccessController.doPrivileged(
-                new sun.security.action.LoadLibraryAction("sctp"));
-        initIDs();
-    }
-}
--- a/jdk/src/solaris/classes/sun/nio/ch/SctpMultiChannelImpl.java	Mon Feb 13 14:26:25 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,985 +0,0 @@
-/*
- * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package sun.nio.ch;
-
-import java.net.InetAddress;
-import java.net.SocketAddress;
-import java.net.SocketException;
-import java.net.InetSocketAddress;
-import java.io.FileDescriptor;
-import java.io.IOException;
-import java.util.Collections;
-import java.util.Map.Entry;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.HashSet;
-import java.util.HashMap;
-import java.nio.ByteBuffer;
-import java.nio.channels.SelectionKey;
-import java.nio.channels.ClosedChannelException;
-import java.nio.channels.NotYetBoundException;
-import java.nio.channels.spi.SelectorProvider;
-import com.sun.nio.sctp.AbstractNotificationHandler;
-import com.sun.nio.sctp.Association;
-import com.sun.nio.sctp.AssociationChangeNotification;
-import com.sun.nio.sctp.HandlerResult;
-import com.sun.nio.sctp.IllegalReceiveException;
-import com.sun.nio.sctp.InvalidStreamException;
-import com.sun.nio.sctp.IllegalUnbindException;
-import com.sun.nio.sctp.NotificationHandler;
-import com.sun.nio.sctp.MessageInfo;
-import com.sun.nio.sctp.SctpChannel;
-import com.sun.nio.sctp.SctpMultiChannel;
-import com.sun.nio.sctp.SctpSocketOption;
-import static com.sun.nio.sctp.SctpStandardSocketOptions.*;
-import static sun.nio.ch.SctpResultContainer.*;
-
-/**
- * An implementation of SctpMultiChannel
- */
-public class SctpMultiChannelImpl extends SctpMultiChannel
-    implements SelChImpl
-{
-    private final FileDescriptor fd;
-
-    private final int fdVal;
-
-    /* IDs of native threads doing send and receives, for signalling */
-    private volatile long receiverThread = 0;
-    private volatile long senderThread = 0;
-
-    /* Lock held by current receiving thread */
-    private final Object receiveLock = new Object();
-
-    /* Lock held by current sending thread */
-    private final Object sendLock = new Object();
-
-    /* Lock held by any thread that modifies the state fields declared below
-     * DO NOT invoke a blocking I/O operation while holding this lock! */
-    private final Object stateLock = new Object();
-
-    private enum ChannelState {
-        UNINITIALIZED,
-        KILLPENDING,
-        KILLED,
-    }
-
-    /* -- The following fields are protected by stateLock -- */
-    private ChannelState state = ChannelState.UNINITIALIZED;
-
-    /* Binding: Once bound the port will remain constant. */
-    int port = -1;
-    private HashSet<InetSocketAddress> localAddresses = new HashSet<InetSocketAddress>();
-    /* Has the channel been bound to the wildcard address */
-    private boolean wildcard; /* false */
-
-    /* Keeps a map of addresses to association, and visa versa */
-    private HashMap<SocketAddress, Association> addressMap =
-                         new HashMap<SocketAddress, Association>();
-    private HashMap<Association, Set<SocketAddress>> associationMap =
-                         new HashMap<Association, Set<SocketAddress>>();
-
-    /* -- End of fields protected by stateLock -- */
-
-    /* If an association has been shutdown mark it for removal after
-     * the user handler has been invoked */
-    private final ThreadLocal<Association> associationToRemove =
-        new ThreadLocal<Association>() {
-             @Override protected Association initialValue() {
-                 return null;
-            }
-    };
-
-    /* A notification handler cannot invoke receive */
-    private final ThreadLocal<Boolean> receiveInvoked =
-        new ThreadLocal<Boolean>() {
-             @Override protected Boolean initialValue() {
-                 return Boolean.FALSE;
-            }
-    };
-
-    public SctpMultiChannelImpl(SelectorProvider provider)
-            throws IOException {
-        //TODO: update provider, remove public modifier
-        super(provider);
-        this.fd = SctpNet.socket(false /*one-to-many*/);
-        this.fdVal = IOUtil.fdVal(fd);
-    }
-
-    @Override
-    public SctpMultiChannel bind(SocketAddress local, int backlog)
-            throws IOException {
-        synchronized (receiveLock) {
-            synchronized (sendLock) {
-                synchronized (stateLock) {
-                    ensureOpen();
-                    if (isBound())
-                        SctpNet.throwAlreadyBoundException();
-                    InetSocketAddress isa = (local == null) ?
-                        new InetSocketAddress(0) : Net.checkAddress(local);
-
-                    SecurityManager sm = System.getSecurityManager();
-                    if (sm != null)
-                        sm.checkListen(isa.getPort());
-                    Net.bind(fd, isa.getAddress(), isa.getPort());
-
-                    InetSocketAddress boundIsa = Net.localAddress(fd);
-                    port = boundIsa.getPort();
-                    localAddresses.add(isa);
-                    if (isa.getAddress().isAnyLocalAddress())
-                        wildcard = true;
-
-                    SctpNet.listen(fdVal, backlog < 1 ? 50 : backlog);
-                }
-            }
-        }
-        return this;
-    }
-
-    @Override
-    public SctpMultiChannel bindAddress(InetAddress address)
-            throws IOException {
-        return bindUnbindAddress(address, true);
-    }
-
-    @Override
-    public SctpMultiChannel unbindAddress(InetAddress address)
-            throws IOException {
-        return bindUnbindAddress(address, false);
-    }
-
-    private SctpMultiChannel bindUnbindAddress(InetAddress address,
-                                               boolean add)
-            throws IOException {
-        if (address == null)
-            throw new IllegalArgumentException();
-
-        synchronized (receiveLock) {
-            synchronized (sendLock) {
-                synchronized (stateLock) {
-                    if (!isOpen())
-                        throw new ClosedChannelException();
-                    if (!isBound())
-                        throw new NotYetBoundException();
-                    if (wildcard)
-                        throw new IllegalStateException(
-                                "Cannot add or remove addresses from a channel that is bound to the wildcard address");
-                    if (address.isAnyLocalAddress())
-                        throw new IllegalArgumentException(
-                                "Cannot add or remove the wildcard address");
-                    if (add) {
-                        for (InetSocketAddress addr : localAddresses) {
-                            if (addr.getAddress().equals(address)) {
-                                SctpNet.throwAlreadyBoundException();
-                            }
-                        }
-                    } else { /*removing */
-                        /* Verify that there is more than one address
-                         * and that address is already bound */
-                        if (localAddresses.size() <= 1)
-                            throw new IllegalUnbindException("Cannot remove address from a channel with only one address bound");
-                        boolean foundAddress = false;
-                        for (InetSocketAddress addr : localAddresses) {
-                            if (addr.getAddress().equals(address)) {
-                                foundAddress = true;
-                                break;
-                            }
-                        }
-                        if (!foundAddress )
-                            throw new IllegalUnbindException("Cannot remove address from a channel that is not bound to that address");
-                    }
-
-                    SctpNet.bindx(fdVal, new InetAddress[]{address}, port, add);
-
-                    /* Update our internal Set to reflect the addition/removal */
-                    if (add)
-                        localAddresses.add(new InetSocketAddress(address, port));
-                    else {
-                        for (InetSocketAddress addr : localAddresses) {
-                            if (addr.getAddress().equals(address)) {
-                                localAddresses.remove(addr);
-                                break;
-                            }
-                        }
-                    }
-                }
-            }
-        }
-        return this;
-    }
-
-    @Override
-    public Set<Association> associations()
-            throws ClosedChannelException, NotYetBoundException {
-        synchronized (stateLock) {
-            if (!isOpen())
-                throw new ClosedChannelException();
-            if (!isBound())
-                throw new NotYetBoundException();
-
-            return Collections.unmodifiableSet(associationMap.keySet());
-        }
-    }
-
-    private boolean isBound() {
-        synchronized (stateLock) {
-            return port == -1 ? false : true;
-        }
-    }
-
-    private void ensureOpen() throws IOException {
-        synchronized (stateLock) {
-            if (!isOpen())
-                throw new ClosedChannelException();
-        }
-    }
-
-    private void receiverCleanup() throws IOException {
-        synchronized (stateLock) {
-            receiverThread = 0;
-            if (state == ChannelState.KILLPENDING)
-                kill();
-        }
-    }
-
-    private void senderCleanup() throws IOException {
-        synchronized (stateLock) {
-            senderThread = 0;
-            if (state == ChannelState.KILLPENDING)
-                kill();
-        }
-    }
-
-    @Override
-    protected void implConfigureBlocking(boolean block) throws IOException {
-        IOUtil.configureBlocking(fd, block);
-    }
-
-    @Override
-    public void implCloseSelectableChannel() throws IOException {
-        synchronized (stateLock) {
-            SctpNet.preClose(fdVal);
-
-            if (receiverThread != 0)
-                NativeThread.signal(receiverThread);
-
-            if (senderThread != 0)
-                NativeThread.signal(senderThread);
-
-            if (!isRegistered())
-                kill();
-        }
-    }
-
-    @Override
-    public FileDescriptor getFD() {
-        return fd;
-    }
-
-    @Override
-    public int getFDVal() {
-        return fdVal;
-    }
-
-    /**
-     * Translates native poll revent ops into a ready operation ops
-     */
-    private boolean translateReadyOps(int ops, int initialOps,
-                                      SelectionKeyImpl sk) {
-        int intOps = sk.nioInterestOps();
-        int oldOps = sk.nioReadyOps();
-        int newOps = initialOps;
-
-        if ((ops & PollArrayWrapper.POLLNVAL) != 0) {
-            /* This should only happen if this channel is pre-closed while a
-             * selection operation is in progress
-             * ## Throw an error if this channel has not been pre-closed */
-            return false;
-        }
-
-        if ((ops & (PollArrayWrapper.POLLERR
-                    | PollArrayWrapper.POLLHUP)) != 0) {
-            newOps = intOps;
-            sk.nioReadyOps(newOps);
-            return (newOps & ~oldOps) != 0;
-        }
-
-        if (((ops & PollArrayWrapper.POLLIN) != 0) &&
-            ((intOps & SelectionKey.OP_READ) != 0))
-            newOps |= SelectionKey.OP_READ;
-
-        if (((ops & PollArrayWrapper.POLLOUT) != 0) &&
-            ((intOps & SelectionKey.OP_WRITE) != 0))
-            newOps |= SelectionKey.OP_WRITE;
-
-        sk.nioReadyOps(newOps);
-        return (newOps & ~oldOps) != 0;
-    }
-
-    @Override
-    public boolean translateAndUpdateReadyOps(int ops, SelectionKeyImpl sk) {
-        return translateReadyOps(ops, sk.nioReadyOps(), sk);
-    }
-
-    @Override
-    public boolean translateAndSetReadyOps(int ops, SelectionKeyImpl sk) {
-        return translateReadyOps(ops, 0, sk);
-    }
-
-    @Override
-    public void translateAndSetInterestOps(int ops, SelectionKeyImpl sk) {
-        int newOps = 0;
-        if ((ops & SelectionKey.OP_READ) != 0)
-            newOps |= PollArrayWrapper.POLLIN;
-        if ((ops & SelectionKey.OP_WRITE) != 0)
-            newOps |= PollArrayWrapper.POLLOUT;
-        sk.selector.putEventOps(sk, newOps);
-    }
-
-    @Override
-    public void kill() throws IOException {
-        synchronized (stateLock) {
-            if (state == ChannelState.KILLED)
-                return;
-            if (state == ChannelState.UNINITIALIZED) {
-                state = ChannelState.KILLED;
-                return;
-            }
-            assert !isOpen() && !isRegistered();
-
-            /* Postpone the kill if there is a thread sending or receiving. */
-            if (receiverThread == 0 && senderThread == 0) {
-                SctpNet.close(fdVal);
-                state = ChannelState.KILLED;
-            } else {
-                state = ChannelState.KILLPENDING;
-            }
-        }
-    }
-
-    @Override
-    public <T> SctpMultiChannel setOption(SctpSocketOption<T> name,
-                                          T value,
-                                          Association association)
-            throws IOException {
-        if (name == null)
-            throw new NullPointerException();
-        if (!(supportedOptions().contains(name)))
-            throw new UnsupportedOperationException("'" + name + "' not supported");
-
-        synchronized (stateLock) {
-            if (association != null && (name.equals(SCTP_PRIMARY_ADDR) ||
-                    name.equals(SCTP_SET_PEER_PRIMARY_ADDR))) {
-                checkAssociation(association);
-            }
-            if (!isOpen())
-                throw new ClosedChannelException();
-
-            int assocId = association == null ? 0 : association.associationID();
-            SctpNet.setSocketOption(fdVal, name, value, assocId);
-        }
-        return this;
-    }
-
-    @Override
-    @SuppressWarnings("unchecked")
-    public <T> T getOption(SctpSocketOption<T> name, Association association)
-            throws IOException {
-        if (name == null)
-            throw new NullPointerException();
-        if (!supportedOptions().contains(name))
-            throw new UnsupportedOperationException("'" + name + "' not supported");
-
-        synchronized (stateLock) {
-            if (association != null && (name.equals(SCTP_PRIMARY_ADDR) ||
-                    name.equals(SCTP_SET_PEER_PRIMARY_ADDR))) {
-                checkAssociation(association);
-            }
-            if (!isOpen())
-                throw new ClosedChannelException();
-
-            int assocId = association == null ? 0 : association.associationID();
-            return (T)SctpNet.getSocketOption(fdVal, name, assocId);
-        }
-    }
-
-    private static class DefaultOptionsHolder {
-        static final Set<SctpSocketOption<?>> defaultOptions = defaultOptions();
-
-        private static Set<SctpSocketOption<?>> defaultOptions() {
-            HashSet<SctpSocketOption<?>> set = new HashSet<SctpSocketOption<?>>(10);
-            set.add(SCTP_DISABLE_FRAGMENTS);
-            set.add(SCTP_EXPLICIT_COMPLETE);
-            set.add(SCTP_FRAGMENT_INTERLEAVE);
-            set.add(SCTP_INIT_MAXSTREAMS);
-            set.add(SCTP_NODELAY);
-            set.add(SCTP_PRIMARY_ADDR);
-            set.add(SCTP_SET_PEER_PRIMARY_ADDR);
-            set.add(SO_SNDBUF);
-            set.add(SO_RCVBUF);
-            set.add(SO_LINGER);
-            return Collections.unmodifiableSet(set);
-        }
-    }
-
-    @Override
-    public final Set<SctpSocketOption<?>> supportedOptions() {
-        return DefaultOptionsHolder.defaultOptions;
-    }
-
-    @Override
-    public <T> MessageInfo receive(ByteBuffer buffer,
-                                   T attachment,
-                                   NotificationHandler<T> handler)
-            throws IOException {
-        if (buffer == null)
-            throw new IllegalArgumentException("buffer cannot be null");
-
-        if (buffer.isReadOnly())
-            throw new IllegalArgumentException("Read-only buffer");
-
-        if (receiveInvoked.get())
-            throw new IllegalReceiveException(
-                    "cannot invoke receive from handler");
-        receiveInvoked.set(Boolean.TRUE);
-
-        try {
-            SctpResultContainer resultContainer = new SctpResultContainer();
-            do {
-                resultContainer.clear();
-                synchronized (receiveLock) {
-                    ensureOpen();
-                    if (!isBound())
-                        throw new NotYetBoundException();
-
-                    int n = 0;
-                    try {
-                        begin();
-
-                        synchronized (stateLock) {
-                            if(!isOpen())
-                                return null;
-                            receiverThread = NativeThread.current();
-                        }
-
-                        do {
-                            n = receive(fdVal, buffer, resultContainer);
-                        } while ((n == IOStatus.INTERRUPTED) && isOpen());
-
-                    } finally {
-                        receiverCleanup();
-                        end((n > 0) || (n == IOStatus.UNAVAILABLE));
-                        assert IOStatus.check(n);
-                    }
-
-                    if (!resultContainer.isNotification()) {
-                        /* message or nothing */
-                        if (resultContainer.hasSomething()) {
-                            /* Set the association before returning */
-                            SctpMessageInfoImpl info =
-                                    resultContainer.getMessageInfo();
-                            info.setAssociation(lookupAssociation(info.
-                                    associationID()));
-                            SecurityManager sm = System.getSecurityManager();
-                            if (sm != null) {
-                                InetSocketAddress isa  = (InetSocketAddress)info.address();
-                                if (!addressMap.containsKey(isa)) {
-                                    /* must be a new association */
-                                    try {
-                                        sm.checkAccept(isa.getAddress().getHostAddress(),
-                                                       isa.getPort());
-                                    } catch (SecurityException se) {
-                                        buffer.clear();
-                                        throw se;
-                                    }
-                                }
-                            }
-
-                            assert info.association() != null;
-                            return info;
-                        } else  {
-                          /* Non-blocking may return null if nothing available*/
-                            return null;
-                        }
-                    } else { /* notification */
-                        synchronized (stateLock) {
-                            handleNotificationInternal(
-                                    resultContainer);
-                        }
-                    }
-                } /* receiveLock */
-            } while (handler == null ? true :
-                (invokeNotificationHandler(resultContainer, handler, attachment)
-                 == HandlerResult.CONTINUE));
-        } finally {
-            receiveInvoked.set(Boolean.FALSE);
-        }
-
-        return null;
-    }
-
-    private int receive(int fd,
-                        ByteBuffer dst,
-                        SctpResultContainer resultContainer)
-            throws IOException {
-        int pos = dst.position();
-        int lim = dst.limit();
-        assert (pos <= lim);
-        int rem = (pos <= lim ? lim - pos : 0);
-        if (dst instanceof DirectBuffer && rem > 0)
-            return receiveIntoNativeBuffer(fd, resultContainer, dst, rem, pos);
-
-        /* Substitute a native buffer. */
-        int newSize = Math.max(rem, 1);
-        ByteBuffer bb = Util.getTemporaryDirectBuffer(newSize);
-        try {
-            int n = receiveIntoNativeBuffer(fd, resultContainer, bb, newSize, 0);
-            bb.flip();
-            if (n > 0 && rem > 0)
-                dst.put(bb);
-            return n;
-        } finally {
-            Util.releaseTemporaryDirectBuffer(bb);
-        }
-    }
-
-    private int receiveIntoNativeBuffer(int fd,
-                                        SctpResultContainer resultContainer,
-                                        ByteBuffer bb,
-                                        int rem,
-                                        int pos)
-            throws IOException {
-        int n = receive0(fd, resultContainer, ((DirectBuffer)bb).address() + pos, rem);
-        if (n > 0)
-            bb.position(pos + n);
-        return n;
-    }
-
-    private InternalNotificationHandler internalNotificationHandler =
-            new InternalNotificationHandler();
-
-    private void handleNotificationInternal(SctpResultContainer resultContainer)
-    {
-        invokeNotificationHandler(resultContainer,
-                internalNotificationHandler, null);
-    }
-
-    private class InternalNotificationHandler
-            extends AbstractNotificationHandler<Object>
-    {
-        @Override
-        public HandlerResult handleNotification(
-                AssociationChangeNotification not, Object unused) {
-            SctpAssocChange sac = (SctpAssocChange) not;
-
-            /* Update map to reflect change in association */
-            switch (not.event()) {
-                case COMM_UP :
-                    Association newAssociation = new SctpAssociationImpl
-                       (sac.assocId(), sac.maxInStreams(), sac.maxOutStreams());
-                    addAssociation(newAssociation);
-                    break;
-                case SHUTDOWN :
-                case COMM_LOST :
-                //case RESTART: ???
-                    /* mark association for removal after user handler invoked*/
-                    associationToRemove.set(lookupAssociation(sac.assocId()));
-            }
-            return HandlerResult.CONTINUE;
-        }
-    }
-
-    private <T> HandlerResult invokeNotificationHandler(
-                                   SctpResultContainer resultContainer,
-                                   NotificationHandler<T> handler,
-                                   T attachment) {
-        HandlerResult result;
-        SctpNotification notification = resultContainer.notification();
-        notification.setAssociation(lookupAssociation(notification.assocId()));
-
-        if (!(handler instanceof AbstractNotificationHandler)) {
-            result = handler.handleNotification(notification, attachment);
-        } else { /* AbstractNotificationHandler */
-            AbstractNotificationHandler<T> absHandler =
-                    (AbstractNotificationHandler<T>)handler;
-            switch(resultContainer.type()) {
-                case ASSOCIATION_CHANGED :
-                    result = absHandler.handleNotification(
-                            resultContainer.getAssociationChanged(), attachment);
-                    break;
-                case PEER_ADDRESS_CHANGED :
-                    result = absHandler.handleNotification(
-                            resultContainer.getPeerAddressChanged(), attachment);
-                    break;
-                case SEND_FAILED :
-                    result = absHandler.handleNotification(
-                            resultContainer.getSendFailed(), attachment);
-                    break;
-                case SHUTDOWN :
-                    result =  absHandler.handleNotification(
-                            resultContainer.getShutdown(), attachment);
-                    break;
-                default :
-                    /* implementation specific handlers */
-                    result =  absHandler.handleNotification(
-                            resultContainer.notification(), attachment);
-            }
-        }
-
-        if (!(handler instanceof InternalNotificationHandler)) {
-            /* Only remove associations after user handler
-             * has finished with them */
-            Association assoc = associationToRemove.get();
-            if (assoc != null) {
-                removeAssociation(assoc);
-                associationToRemove.set(null);
-            }
-
-        }
-
-        return result;
-    }
-
-    private Association lookupAssociation(int assocId) {
-        /* Lookup the association in our internal map */
-        synchronized (stateLock) {
-            Set<Association> assocs = associationMap.keySet();
-            for (Association a : assocs) {
-                if (a.associationID() == assocId) {
-                    return a;
-                }
-            }
-        }
-        return null;
-    }
-
-    private void addAssociation(Association association) {
-        synchronized (stateLock) {
-            int assocId = association.associationID();
-            Set<SocketAddress> addresses = null;
-
-            try {
-                addresses = SctpNet.getRemoteAddresses(fdVal, assocId);
-            } catch (IOException unused) {
-                /* OK, determining connected addresses may not be possible
-                 * shutdown, connection lost, etc */
-            }
-
-            associationMap.put(association, addresses);
-            if (addresses != null) {
-                for (SocketAddress addr : addresses)
-                    addressMap.put(addr, association);
-            }
-        }
-    }
-
-    private void removeAssociation(Association association) {
-        synchronized (stateLock) {
-            int assocId = association.associationID();
-            Set<SocketAddress> addresses = null;
-
-             try {
-                addresses = SctpNet.getRemoteAddresses(fdVal, assocId);
-            } catch (IOException unused) {
-                /* OK, determining connected addresses may not be possible
-                 * shutdown, connection lost, etc */
-            }
-
-            Set<Association> assocs = associationMap.keySet();
-            for (Association a : assocs) {
-                if (a.associationID() == assocId) {
-                    associationMap.remove(a);
-                    break;
-                }
-            }
-            if (addresses != null) {
-                for (SocketAddress addr : addresses)
-                    addressMap.remove(addr);
-            } else {
-                /* We cannot determine the connected addresses */
-                Set<java.util.Map.Entry<SocketAddress, Association>> addrAssocs =
-                        addressMap.entrySet();
-                Iterator<Entry<SocketAddress, Association>> iterator = addrAssocs.iterator();
-                while (iterator.hasNext()) {
-                    Entry<SocketAddress, Association> entry = iterator.next();
-                    if (entry.getValue().equals(association)) {
-                        iterator.remove();
-                    }
-                }
-            }
-        }
-    }
-
-    /**
-     * @throws  IllegalArgumentException
-     *          If the given association is not controlled by this channel
-     *
-     * @return  {@code true} if, and only if, the given association is one
-     *          of the current associations controlled by this channel
-     */
-    private boolean checkAssociation(Association messageAssoc) {
-        synchronized (stateLock) {
-            for (Association association : associationMap.keySet()) {
-                if (messageAssoc.equals(association)) {
-                    return true;
-                }
-            }
-        }
-        throw new IllegalArgumentException(
-              "Given Association is not controlled by this channel");
-    }
-
-    private void checkStreamNumber(Association assoc, int streamNumber) {
-        synchronized (stateLock) {
-            if (streamNumber < 0 || streamNumber >= assoc.maxOutboundStreams())
-                throw new InvalidStreamException();
-        }
-    }
-
-    /* TODO: Add support for ttl and isComplete to both 121 12M
-     *       SCTP_EOR not yet supported on reference platforms
-     *       TTL support limited...
-     */
-    @Override
-    public int send(ByteBuffer buffer, MessageInfo messageInfo)
-            throws IOException {
-        if (buffer == null)
-            throw new IllegalArgumentException("buffer cannot be null");
-
-        if (messageInfo == null)
-            throw new IllegalArgumentException("messageInfo cannot be null");
-
-        synchronized (sendLock) {
-            ensureOpen();
-
-            if (!isBound())
-                bind(null, 0);
-
-            int n = 0;
-            try {
-                int assocId = -1;
-                SocketAddress address = null;
-                begin();
-
-                synchronized (stateLock) {
-                    if(!isOpen())
-                        return 0;
-                    senderThread = NativeThread.current();
-
-                    /* Determine what address or association to send to */
-                    Association assoc = messageInfo.association();
-                    InetSocketAddress addr = (InetSocketAddress)messageInfo.address();
-                    if (assoc != null) {
-                        checkAssociation(assoc);
-                        checkStreamNumber(assoc, messageInfo.streamNumber());
-                        assocId = assoc.associationID();
-                        /* have we also got a preferred address */
-                        if (addr != null) {
-                            if (!assoc.equals(addressMap.get(addr)))
-                                throw new IllegalArgumentException("given preferred address is not part of this association");
-                            address = addr;
-                        }
-                    } else if (addr != null) {
-                        address = addr;
-                        Association association = addressMap.get(addr);
-                        if (association != null) {
-                            checkStreamNumber(association, messageInfo.streamNumber());
-                            assocId = association.associationID();
-
-                        } else { /* must be new association */
-                            SecurityManager sm = System.getSecurityManager();
-                            if (sm != null)
-                                sm.checkConnect(addr.getAddress().getHostAddress(),
-                                                addr.getPort());
-                        }
-                    } else {
-                        throw new AssertionError(
-                            "Both association and address cannot be null");
-                    }
-                }
-
-                do {
-                    n = send(fdVal, buffer, assocId, address, messageInfo);
-                } while ((n == IOStatus.INTERRUPTED) && isOpen());
-
-                return IOStatus.normalize(n);
-            } finally {
-                senderCleanup();
-                end((n > 0) || (n == IOStatus.UNAVAILABLE));
-                assert IOStatus.check(n);
-            }
-        }
-    }
-
-    private int send(int fd,
-                     ByteBuffer src,
-                     int assocId,
-                     SocketAddress target,
-                     MessageInfo messageInfo)
-            throws IOException {
-        int streamNumber = messageInfo.streamNumber();
-        boolean unordered = messageInfo.isUnordered();
-        int ppid = messageInfo.payloadProtocolID();
-
-        if (src instanceof DirectBuffer)
-            return sendFromNativeBuffer(fd, src, target, assocId,
-                    streamNumber, unordered, ppid);
-
-        /* Substitute a native buffer */
-        int pos = src.position();
-        int lim = src.limit();
-        assert (pos <= lim && streamNumber >= 0);
-
-        int rem = (pos <= lim ? lim - pos : 0);
-        ByteBuffer bb = Util.getTemporaryDirectBuffer(rem);
-        try {
-            bb.put(src);
-            bb.flip();
-            /* Do not update src until we see how many bytes were written */
-            src.position(pos);
-
-            int n = sendFromNativeBuffer(fd, bb, target, assocId,
-                    streamNumber, unordered, ppid);
-            if (n > 0) {
-                /* now update src */
-                src.position(pos + n);
-            }
-            return n;
-        } finally {
-            Util.releaseTemporaryDirectBuffer(bb);
-        }
-    }
-
-    private int sendFromNativeBuffer(int fd,
-                                     ByteBuffer bb,
-                                     SocketAddress target,
-                                     int assocId,
-                                     int streamNumber,
-                                     boolean unordered,
-                                     int ppid)
-            throws IOException {
-        int pos = bb.position();
-        int lim = bb.limit();
-        assert (pos <= lim);
-        int rem = (pos <= lim ? lim - pos : 0);
-
-        int written = send0(fd, ((DirectBuffer)bb).address() + pos,
-                            rem, target, assocId, streamNumber, unordered, ppid);
-        if (written > 0)
-            bb.position(pos + written);
-        return written;
-    }
-
-    @Override
-    public SctpMultiChannel shutdown(Association association)
-            throws IOException {
-        synchronized (stateLock) {
-            checkAssociation(association);
-            if (!isOpen())
-                throw new ClosedChannelException();
-
-            SctpNet.shutdown(fdVal, association.associationID());
-        }
-        return this;
-    }
-
-    @Override
-    public Set<SocketAddress> getAllLocalAddresses()
-            throws IOException {
-        synchronized (stateLock) {
-            if (!isOpen())
-                throw new ClosedChannelException();
-            if (!isBound())
-                return Collections.emptySet();
-
-            return SctpNet.getLocalAddresses(fdVal);
-        }
-    }
-
-    @Override
-    public Set<SocketAddress> getRemoteAddresses(Association association)
-            throws IOException {
-        synchronized (stateLock) {
-            checkAssociation(association);
-            if (!isOpen())
-                throw new ClosedChannelException();
-
-            try {
-                return SctpNet.getRemoteAddresses(fdVal, association.associationID());
-            } catch (SocketException se) {
-                /* a valid association should always have remote addresses */
-                Set<SocketAddress> addrs = associationMap.get(association);
-                return addrs != null ? addrs : Collections.<SocketAddress>emptySet();
-            }
-        }
-    }
-
-    @Override
-    public SctpChannel branch(Association association)
-            throws IOException {
-        synchronized (stateLock) {
-            checkAssociation(association);
-            if (!isOpen())
-                throw new ClosedChannelException();
-
-            FileDescriptor bFd = SctpNet.branch(fdVal,
-                                                association.associationID());
-            /* successfully branched, we can now remove it from assoc list */
-            removeAssociation(association);
-
-            return new SctpChannelImpl(provider(), bFd, association);
-        }
-    }
-
-    /* Use common native implementation shared between
-     * one-to-one and one-to-many */
-    private static int receive0(int fd,
-                                SctpResultContainer resultContainer,
-                                long address,
-                                int length)
-            throws IOException{
-        return SctpChannelImpl.receive0(fd, resultContainer, address,
-                length, false /*peek */);
-    }
-
-    private static int send0(int fd,
-                             long address,
-                             int length,
-                             SocketAddress target,
-                             int assocId,
-                             int streamNumber,
-                             boolean unordered,
-                             int ppid)
-            throws IOException {
-        return SctpChannelImpl.send0(fd, address, length, target, assocId,
-                streamNumber, unordered, ppid);
-    }
-
-    static {
-        Util.load();   /* loads nio & net native libraries */
-        java.security.AccessController.doPrivileged(
-                new sun.security.action.LoadLibraryAction("sctp"));
-    }
-}
--- a/jdk/src/solaris/classes/sun/nio/ch/SctpNet.java	Mon Feb 13 14:26:25 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,313 +0,0 @@
-/*
- * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package sun.nio.ch;
-
-import java.io.FileDescriptor;
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.net.SocketAddress;
-import java.nio.channels.AlreadyBoundException;
-import java.util.Set;
-import java.util.HashSet;
-import java.security.AccessController;
-import sun.security.action.GetPropertyAction;
-import com.sun.nio.sctp.SctpSocketOption;
-import static com.sun.nio.sctp.SctpStandardSocketOptions.*;
-
-public class SctpNet {
-    static final String osName = AccessController.doPrivileged(
-                    new GetPropertyAction("os.name"));
-
-    /* -- Miscellaneous SCTP utilities -- */
-
-    private static boolean IPv4MappedAddresses() {
-        if ("SunOS".equals(osName)) {
-            /* Solaris supports IPv4Mapped Addresses with bindx */
-            return true;
-        } /* else {  //other OS/implementations  */
-
-        /* lksctp/linux requires Ipv4 addresses */
-        return false;
-    }
-
-    static boolean throwAlreadyBoundException() throws IOException {
-        throw new AlreadyBoundException();
-    }
-
-    static void listen(int fd, int backlog) throws IOException {
-        listen0(fd, backlog);
-    }
-
-    static int connect(int fd, InetAddress remote, int remotePort)
-            throws IOException {
-        return connect0(fd, remote, remotePort);
-    }
-
-    static void close(int fd) throws IOException {
-        close0(fd);
-    }
-
-    static void preClose(int fd) throws IOException {
-        preClose0(fd);
-    }
-
-    /**
-     * @param  oneToOne
-     *         if {@code true} returns a one-to-one sctp socket, otherwise
-     *         returns a one-to-many sctp socket
-     */
-    static FileDescriptor socket(boolean oneToOne) throws IOException {
-        int nativefd = socket0(oneToOne);
-        return IOUtil.newFD(nativefd);
-    }
-
-    static void bindx(int fd, InetAddress[] addrs, int port, boolean add)
-            throws IOException {
-        bindx(fd, addrs, port, addrs.length, add,
-                IPv4MappedAddresses());
-    }
-
-    static Set<SocketAddress> getLocalAddresses(int fd)
-            throws IOException {
-        HashSet<SocketAddress> set = null;
-        SocketAddress[] saa = getLocalAddresses0(fd);
-
-        if (saa != null) {
-            set = new HashSet<SocketAddress>(saa.length);
-            for (SocketAddress sa : saa)
-                set.add(sa);
-        }
-
-        return set;
-    }
-
-    static Set<SocketAddress> getRemoteAddresses(int fd, int assocId)
-            throws IOException {
-        HashSet<SocketAddress> set = null;
-        SocketAddress[] saa = getRemoteAddresses0(fd, assocId);
-
-        if (saa != null) {
-            set = new HashSet<SocketAddress>(saa.length);
-            for (SocketAddress sa : saa)
-                set.add(sa);
-        }
-
-        return set;
-    }
-
-    static <T> void setSocketOption(int fd,
-                                    SctpSocketOption<T> name,
-                                    T value,
-                                    int assocId)
-            throws IOException {
-        if (value == null)
-            throw new IllegalArgumentException("Invalid option value");
-
-        if (name.equals(SCTP_INIT_MAXSTREAMS)) {
-            InitMaxStreams maxStreamValue = (InitMaxStreams)value;
-            SctpNet.setInitMsgOption0(fd,
-                 maxStreamValue.maxInStreams(), maxStreamValue.maxOutStreams());
-        } else if (name.equals(SCTP_PRIMARY_ADDR) ||
-                   name.equals(SCTP_SET_PEER_PRIMARY_ADDR)) {
-
-            SocketAddress addr  = (SocketAddress) value;
-            if (addr == null)
-                throw new IllegalArgumentException("Invalid option value");
-
-            Net.checkAddress(addr);
-            InetSocketAddress netAddr = (InetSocketAddress)addr;
-
-            if (name.equals(SCTP_PRIMARY_ADDR)) {
-                setPrimAddrOption0(fd,
-                                   assocId,
-                                   netAddr.getAddress(),
-                                   netAddr.getPort());
-            } else {
-                setPeerPrimAddrOption0(fd,
-                                       assocId,
-                                       netAddr.getAddress(),
-                                       netAddr.getPort(),
-                                       IPv4MappedAddresses());
-            }
-        } else if (name.equals(SCTP_DISABLE_FRAGMENTS) ||
-            name.equals(SCTP_EXPLICIT_COMPLETE) ||
-            name.equals(SCTP_FRAGMENT_INTERLEAVE) ||
-            name.equals(SCTP_NODELAY) ||
-            name.equals(SO_SNDBUF) ||
-            name.equals(SO_RCVBUF) ||
-            name.equals(SO_LINGER)) {
-            setIntOption(fd, name, value);
-        } else {
-            throw new AssertionError("Unknown socket option");
-        }
-    }
-
-    static Object getSocketOption(int fd, SctpSocketOption<?> name, int assocId)
-             throws IOException {
-         if (name.equals(SCTP_SET_PEER_PRIMARY_ADDR)) {
-            throw new IllegalArgumentException(
-                    "SCTP_SET_PEER_PRIMARY_ADDR cannot be retrieved");
-        } else if (name.equals(SCTP_INIT_MAXSTREAMS)) {
-            /* container for holding maxIn/Out streams */
-            int[] values = new int[2];
-            SctpNet.getInitMsgOption0(fd, values);
-            return InitMaxStreams.create(values[0], values[1]);
-        } else if (name.equals(SCTP_PRIMARY_ADDR)) {
-            return getPrimAddrOption0(fd, assocId);
-        } else if (name.equals(SCTP_DISABLE_FRAGMENTS) ||
-            name.equals(SCTP_EXPLICIT_COMPLETE) ||
-            name.equals(SCTP_FRAGMENT_INTERLEAVE) ||
-            name.equals(SCTP_NODELAY) ||
-            name.equals(SO_SNDBUF) ||
-            name.equals(SO_RCVBUF) ||
-            name.equals(SO_LINGER)) {
-            return getIntOption(fd, name);
-        } else {
-            throw new AssertionError("Unknown socket option");
-        }
-    }
-
-    static void setIntOption(int fd, SctpSocketOption<?> name, Object value)
-            throws IOException {
-        if (value == null)
-            throw new IllegalArgumentException("Invalid option value");
-
-        Class<?> type = name.type();
-        if (type != Integer.class && type != Boolean.class)
-            throw new AssertionError("Should not reach here");
-
-        if (name == SO_RCVBUF ||
-            name == SO_SNDBUF)
-        {
-            int i = ((Integer)value).intValue();
-            if (i < 0)
-                throw new IllegalArgumentException(
-                        "Invalid send/receive buffer size");
-        } else if (name == SO_LINGER) {
-            int i = ((Integer)value).intValue();
-            if (i < 0)
-                value = Integer.valueOf(-1);
-            if (i > 65535)
-                value = Integer.valueOf(65535);
-        } else if (name.equals(SCTP_FRAGMENT_INTERLEAVE)) {
-            int i = ((Integer)value).intValue();
-            if (i < 0 || i > 2)
-                throw new IllegalArgumentException(
-                        "Invalid value for SCTP_FRAGMENT_INTERLEAVE");
-        }
-
-        int arg;
-        if (type == Integer.class) {
-            arg = ((Integer)value).intValue();
-        } else {
-            boolean b = ((Boolean)value).booleanValue();
-            arg = (b) ? 1 : 0;
-        }
-
-        setIntOption0(fd, ((SctpStdSocketOption)name).constValue(), arg);
-    }
-
-    static Object getIntOption(int fd, SctpSocketOption<?> name)
-            throws IOException {
-        Class<?> type = name.type();
-
-        if (type != Integer.class && type != Boolean.class)
-            throw new AssertionError("Should not reach here");
-
-        if (!(name instanceof SctpStdSocketOption))
-            throw new AssertionError("Should not reach here");
-
-        int value = getIntOption0(fd,
-                ((SctpStdSocketOption)name).constValue());
-
-        if (type == Integer.class) {
-            return Integer.valueOf(value);
-        } else {
-            return (value == 0) ? Boolean.FALSE : Boolean.TRUE;
-        }
-    }
-
-    static void shutdown(int fd, int assocId)
-            throws IOException {
-        shutdown0(fd, assocId);
-    }
-
-    static FileDescriptor branch(int fd, int assocId) throws IOException {
-        int nativefd = branch0(fd, assocId);
-        return IOUtil.newFD(nativefd);
-    }
-
-    /* Native Methods */
-    static native int socket0(boolean oneToOne) throws IOException;
-
-    static native void listen0(int fd, int backlog) throws IOException;
-
-    static native int connect0(int fd, InetAddress remote, int remotePort)
-        throws IOException;
-
-    static native void close0(int fd) throws IOException;
-
-    static native void preClose0(int fd) throws IOException;
-
-    static native void bindx(int fd, InetAddress[] addrs, int port, int length,
-            boolean add, boolean preferIPv6) throws IOException;
-
-    static native int getIntOption0(int fd, int opt) throws IOException;
-
-    static native void setIntOption0(int fd, int opt, int arg)
-        throws IOException;
-
-    static native SocketAddress[] getLocalAddresses0(int fd) throws IOException;
-
-    static native SocketAddress[] getRemoteAddresses0(int fd, int assocId)
-            throws IOException;
-
-    static native int branch0(int fd, int assocId) throws IOException;
-
-    static native void setPrimAddrOption0(int fd, int assocId, InetAddress ia,
-            int port) throws IOException;
-
-    static native void setPeerPrimAddrOption0(int fd, int assocId,
-            InetAddress ia, int port, boolean preferIPv6) throws IOException;
-
-    static native SocketAddress getPrimAddrOption0(int fd, int assocId)
-            throws IOException;
-
-    /* retVals [0] maxInStreams, [1] maxOutStreams */
-    static native void getInitMsgOption0(int fd, int[] retVals) throws IOException;
-
-    static native void setInitMsgOption0(int fd, int arg1, int arg2)
-            throws IOException;
-
-    static native void shutdown0(int fd, int assocId);
-
-    static native void init();
-
-    static {
-        init();
-    }
-}
-
--- a/jdk/src/solaris/classes/sun/nio/ch/SctpNotification.java	Mon Feb 13 14:26:25 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package sun.nio.ch;
-
-import com.sun.nio.sctp.Association;
-import com.sun.nio.sctp.Notification;
-
-/**
- * All Notification implemenations MUST implement this interface to provide
- * access to the native association identidier.
- */
-interface SctpNotification extends Notification {
-    int assocId();
-    void setAssociation(Association association);
-}
--- a/jdk/src/solaris/classes/sun/nio/ch/SctpPeerAddrChange.java	Mon Feb 13 14:26:25 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,119 +0,0 @@
-/*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package sun.nio.ch;
-
-import java.net.SocketAddress;
-import com.sun.nio.sctp.Association;
-import com.sun.nio.sctp.PeerAddressChangeNotification;
-
-/**
- * An implementation of PeerAddressChangeNotification
- */
-public class SctpPeerAddrChange extends PeerAddressChangeNotification
-    implements SctpNotification
-{
-    /* static final ints so that they can be referenced from native */
-    private final static int SCTP_ADDR_AVAILABLE = 1;
-    private final static int SCTP_ADDR_UNREACHABLE = 2;
-    private final static int SCTP_ADDR_REMOVED = 3;
-    private final static int SCTP_ADDR_ADDED = 4;
-    private final static int SCTP_ADDR_MADE_PRIM = 5;
-    private final static int SCTP_ADDR_CONFIRMED =6;
-
-    private Association association;
-
-    /* assocId is used to lookup the association before the notification is
-     * returned to user code */
-    private int assocId;
-    private SocketAddress address;
-    private AddressChangeEvent event;
-
-    /* Invoked from native */
-    private SctpPeerAddrChange(int assocId, SocketAddress address, int intEvent) {
-        switch (intEvent) {
-            case SCTP_ADDR_AVAILABLE :
-                this.event = AddressChangeEvent.ADDR_AVAILABLE;
-                break;
-            case SCTP_ADDR_UNREACHABLE :
-                this.event = AddressChangeEvent.ADDR_UNREACHABLE;
-                break;
-            case SCTP_ADDR_REMOVED :
-                this.event = AddressChangeEvent.ADDR_REMOVED;
-                break;
-            case SCTP_ADDR_ADDED :
-                this.event = AddressChangeEvent.ADDR_ADDED;
-                break;
-            case SCTP_ADDR_MADE_PRIM :
-                this.event = AddressChangeEvent.ADDR_MADE_PRIMARY;
-                break;
-            case SCTP_ADDR_CONFIRMED :
-                this.event = AddressChangeEvent.ADDR_CONFIRMED;
-                break;
-            default:
-                throw new AssertionError("Unknown event type");
-        }
-        this.assocId = assocId;
-        this.address = address;
-    }
-
-    @Override
-    public int assocId() {
-        return assocId;
-    }
-
-    @Override
-    public void setAssociation(Association association) {
-        this.association = association;
-    }
-
-    @Override
-    public SocketAddress address() {
-        assert address != null;
-        return address;
-    }
-
-    @Override
-    public Association association() {
-        assert association != null;
-        return association;
-    }
-
-    @Override
-    public AddressChangeEvent event() {
-        assert event != null;
-        return event;
-    }
-
-    @Override
-    public String toString() {
-        StringBuilder sb = new StringBuilder();
-        sb.append(super.toString()).append(" [");
-        sb.append("Address: ").append(address);
-        sb.append(", Association:").append(association);
-        sb.append(", Event: ").append(event).append("]");
-        return sb.toString();
-    }
-}
-
--- a/jdk/src/solaris/classes/sun/nio/ch/SctpResultContainer.java	Mon Feb 13 14:26:25 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,128 +0,0 @@
-/*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package sun.nio.ch;
-
-/**
- * Wraps the actual message or notification so that it can be
- * set and returned from the native receive implementation.
- */
-public class SctpResultContainer {
-    /* static final ints so that they can be referenced from native */
-    static final int NOTHING = 0;
-    static final int MESSAGE = 1;
-    static final int SEND_FAILED = 2;
-    static final int ASSOCIATION_CHANGED = 3;
-    static final int PEER_ADDRESS_CHANGED = 4;
-    static final int SHUTDOWN = 5;
-
-    private Object value;
-    private int type;
-
-    int type() {
-        return type;
-    }
-
-    boolean hasSomething() {
-        return type() != NOTHING;
-    }
-
-    boolean isNotification() {
-        return type() != MESSAGE && type() != NOTHING ? true : false;
-    }
-
-    void clear() {
-        type = NOTHING;
-        value = null;
-    }
-
-    SctpNotification notification() {
-        assert type() != MESSAGE && type() != NOTHING;
-
-        return (SctpNotification) value;
-    }
-
-    SctpMessageInfoImpl getMessageInfo() {
-        assert type() == MESSAGE;
-
-        if (value instanceof SctpMessageInfoImpl)
-            return (SctpMessageInfoImpl) value;
-
-        return null;
-    }
-
-    SctpSendFailed getSendFailed() {
-        assert type() == SEND_FAILED;
-
-        if (value instanceof SctpSendFailed)
-            return (SctpSendFailed) value;
-
-        return null;
-    }
-
-    SctpAssocChange getAssociationChanged() {
-        assert type() == ASSOCIATION_CHANGED;
-
-        if (value instanceof SctpAssocChange)
-            return (SctpAssocChange) value;
-
-        return null;
-    }
-
-    SctpPeerAddrChange getPeerAddressChanged() {
-        assert type() == PEER_ADDRESS_CHANGED;
-
-        if (value instanceof SctpPeerAddrChange)
-            return (SctpPeerAddrChange) value;
-
-        return null;
-    }
-
-    SctpShutdown getShutdown() {
-        assert type() == SHUTDOWN;
-
-        if (value instanceof SctpShutdown)
-            return (SctpShutdown) value;
-
-        return null;
-    }
-
-    @Override
-    public String toString() {
-        StringBuilder sb = new StringBuilder();
-        sb.append("Type: ");
-        switch (type) {
-            case NOTHING:              sb.append("NOTHING");             break;
-            case MESSAGE:              sb.append("MESSAGE");             break;
-            case SEND_FAILED:          sb.append("SEND FAILED");         break;
-            case ASSOCIATION_CHANGED:  sb.append("ASSOCIATION CHANGE");  break;
-            case PEER_ADDRESS_CHANGED: sb.append("PEER ADDRESS CHANGE"); break;
-            case SHUTDOWN:             sb.append("SHUTDOWN");            break;
-            default :                  sb.append("Unknown result type");
-        }
-        sb.append(", Value: ");
-        sb.append((value == null) ? "null" : value.toString());
-        return sb.toString();
-    }
-}
--- a/jdk/src/solaris/classes/sun/nio/ch/SctpSendFailed.java	Mon Feb 13 14:26:25 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,110 +0,0 @@
-/*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package sun.nio.ch;
-
-import java.nio.ByteBuffer;
-import java.net.SocketAddress;
-import com.sun.nio.sctp.Association;
-import com.sun.nio.sctp.SendFailedNotification;
-
-/**
- * An implementation of SendFailedNotification
- */
-public class SctpSendFailed extends SendFailedNotification
-    implements SctpNotification
-{
-    private Association association;
-    /* assocId is used to lookup the association before the notification is
-     * returned to user code */
-    private int assocId;
-    private SocketAddress address;
-    private ByteBuffer buffer;
-    private int errorCode;
-    private int streamNumber;
-
-    /* Invoked from native */
-    private SctpSendFailed(int assocId,
-                           SocketAddress address,
-                           ByteBuffer buffer,
-                           int errorCode,
-                           int streamNumber) {
-        this.assocId = assocId;
-        this.errorCode = errorCode;
-        this.streamNumber = streamNumber;
-        this.address = address;
-        this.buffer = buffer;
-    }
-
-    @Override
-    public int assocId() {
-        return assocId;
-    }
-
-    @Override
-    public void setAssociation(Association association) {
-        this.association = association;
-    }
-
-    @Override
-    public Association association() {
-        /* may be null */
-        return association;
-    }
-
-    @Override
-    public SocketAddress address() {
-        assert address != null;
-        return address;
-    }
-
-    @Override
-    public ByteBuffer buffer() {
-        assert buffer != null;
-        return buffer;
-    }
-
-    @Override
-    public int errorCode() {
-        return errorCode;
-    }
-
-    @Override
-    public int streamNumber() {
-        return streamNumber;
-    }
-
-    @Override
-    public String toString() {
-        StringBuilder sb = new StringBuilder();
-        sb.append(super.toString()).append(" [");
-        sb.append("Association:").append(association);
-        sb.append(", Address: ").append(address);
-        sb.append(", buffer: ").append(buffer);
-        sb.append(", errorCode: ").append(errorCode);
-        sb.append(", streamNumber: ").append(streamNumber);
-        sb.append("]");
-        return sb.toString();
-    }
-}
--- a/jdk/src/solaris/classes/sun/nio/ch/SctpServerChannelImpl.java	Mon Feb 13 14:26:25 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,425 +0,0 @@
-/*
- * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package sun.nio.ch;
-
-import java.net.SocketAddress;
-import java.net.InetSocketAddress;
-import java.net.InetAddress;
-import java.io.FileDescriptor;
-import java.io.IOException;
-import java.util.Collections;
-import java.util.Set;
-import java.util.HashSet;
-import java.nio.channels.SelectionKey;
-import java.nio.channels.ClosedChannelException;
-import java.nio.channels.NotYetBoundException;
-import java.nio.channels.spi.SelectorProvider;
-import com.sun.nio.sctp.IllegalUnbindException;
-import com.sun.nio.sctp.SctpChannel;
-import com.sun.nio.sctp.SctpServerChannel;
-import com.sun.nio.sctp.SctpSocketOption;
-import com.sun.nio.sctp.SctpStandardSocketOptions;
-
-/**
- * An implementation of SctpServerChannel
- */
-public class SctpServerChannelImpl extends SctpServerChannel
-    implements SelChImpl
-{
-    private final FileDescriptor fd;
-
-    private final int fdVal;
-
-    /* IDs of native thread doing accept, for signalling */
-    private volatile long thread = 0;
-
-    /* Lock held by thread currently blocked in this channel */
-    private final Object lock = new Object();
-
-    /* Lock held by any thread that modifies the state fields declared below
-     * DO NOT invoke a blocking I/O operation while holding this lock! */
-    private final Object stateLock = new Object();
-
-    private enum ChannelState {
-        UNINITIALIZED,
-        INUSE,
-        KILLPENDING,
-        KILLED,
-    }
-    /* -- The following fields are protected by stateLock -- */
-    private ChannelState state = ChannelState.UNINITIALIZED;
-
-    /* Binding: Once bound the port will remain constant. */
-    int port = -1;
-    private HashSet<InetSocketAddress> localAddresses = new HashSet<InetSocketAddress>();
-    /* Has the channel been bound to the wildcard address */
-    private boolean wildcard; /* false */
-
-    /* -- End of fields protected by stateLock -- */
-
-    /**
-     * Initializes a new instance of this class.
-     */
-    public SctpServerChannelImpl(SelectorProvider provider)
-            throws IOException {
-        //TODO: update provider remove public modifier
-        super(provider);
-        this.fd = SctpNet.socket(true);
-        this.fdVal = IOUtil.fdVal(fd);
-        this.state = ChannelState.INUSE;
-    }
-
-    @Override
-    public SctpServerChannel bind(SocketAddress local, int backlog)
-            throws IOException {
-        synchronized (lock) {
-            synchronized (stateLock) {
-                if (!isOpen())
-                    throw new ClosedChannelException();
-                if (isBound())
-                    SctpNet.throwAlreadyBoundException();
-
-                InetSocketAddress isa = (local == null) ?
-                    new InetSocketAddress(0) : Net.checkAddress(local);
-                SecurityManager sm = System.getSecurityManager();
-                if (sm != null)
-                    sm.checkListen(isa.getPort());
-                Net.bind(fd, isa.getAddress(), isa.getPort());
-
-                InetSocketAddress boundIsa = Net.localAddress(fd);
-                port = boundIsa.getPort();
-                localAddresses.add(isa);
-                    if (isa.getAddress().isAnyLocalAddress())
-                        wildcard = true;
-
-                SctpNet.listen(fdVal, backlog < 1 ? 50 : backlog);
-            }
-        }
-        return this;
-    }
-
-    @Override
-    public SctpServerChannel bindAddress(InetAddress address)
-            throws IOException {
-        return bindUnbindAddress(address, true);
-    }
-
-    @Override
-    public SctpServerChannel unbindAddress(InetAddress address)
-            throws IOException {
-        return bindUnbindAddress(address, false);
-    }
-
-    private SctpServerChannel bindUnbindAddress(InetAddress address, boolean add)
-            throws IOException {
-        if (address == null)
-            throw new IllegalArgumentException();
-
-        synchronized (lock) {
-            synchronized (stateLock) {
-                if (!isOpen())
-                    throw new ClosedChannelException();
-                if (!isBound())
-                    throw new NotYetBoundException();
-                if (wildcard)
-                    throw new IllegalStateException(
-                            "Cannot add or remove addresses from a channel that is bound to the wildcard address");
-                if (address.isAnyLocalAddress())
-                    throw new IllegalArgumentException(
-                            "Cannot add or remove the wildcard address");
-                if (add) {
-                    for (InetSocketAddress addr : localAddresses) {
-                        if (addr.getAddress().equals(address)) {
-                            SctpNet.throwAlreadyBoundException();
-                        }
-                    }
-                } else { /*removing */
-                    /* Verify that there is more than one address
-                     * and that address is already bound */
-                    if (localAddresses.size() <= 1)
-                        throw new IllegalUnbindException("Cannot remove address from a channel with only one address bound");
-                    boolean foundAddress = false;
-                    for (InetSocketAddress addr : localAddresses) {
-                        if (addr.getAddress().equals(address)) {
-                            foundAddress = true;
-                            break;
-                        }
-                    }
-                    if (!foundAddress )
-                        throw new IllegalUnbindException("Cannot remove address from a channel that is not bound to that address");
-                }
-
-                SctpNet.bindx(fdVal, new InetAddress[]{address}, port, add);
-
-                /* Update our internal Set to reflect the addition/removal */
-                if (add)
-                    localAddresses.add(new InetSocketAddress(address, port));
-                else {
-                    for (InetSocketAddress addr : localAddresses) {
-                        if (addr.getAddress().equals(address)) {
-                            localAddresses.remove(addr);
-                            break;
-                        }
-                    }
-                }
-            }
-        }
-        return this;
-    }
-
-    private boolean isBound() {
-        synchronized (stateLock) {
-            return port == -1 ? false : true;
-        }
-    }
-
-    private void acceptCleanup() throws IOException {
-        synchronized (stateLock) {
-            thread = 0;
-            if (state == ChannelState.KILLPENDING)
-                kill();
-        }
-    }
-
-    @Override
-    public SctpChannel accept() throws IOException {
-        synchronized (lock) {
-            if (!isOpen())
-                throw new ClosedChannelException();
-            if (!isBound())
-                throw new NotYetBoundException();
-            SctpChannel sc = null;
-
-            int n = 0;
-            FileDescriptor newfd = new FileDescriptor();
-            InetSocketAddress[] isaa = new InetSocketAddress[1];
-
-            try {
-                begin();
-                if (!isOpen())
-                    return null;
-                thread = NativeThread.current();
-                for (;;) {
-                    n = accept0(fd, newfd, isaa);
-                    if ((n == IOStatus.INTERRUPTED) && isOpen())
-                        continue;
-                    break;
-                }
-            } finally {
-                acceptCleanup();
-                end(n > 0);
-                assert IOStatus.check(n);
-            }
-
-            if (n < 1)
-                return null;
-
-            IOUtil.configureBlocking(newfd, true);
-            InetSocketAddress isa = isaa[0];
-            sc = new SctpChannelImpl(provider(), newfd);
-
-            SecurityManager sm = System.getSecurityManager();
-            if (sm != null)
-                sm.checkAccept(isa.getAddress().getHostAddress(),
-                               isa.getPort());
-
-            return sc;
-        }
-    }
-
-    @Override
-    protected void implConfigureBlocking(boolean block) throws IOException {
-        IOUtil.configureBlocking(fd, block);
-    }
-
-    @Override
-    public void implCloseSelectableChannel() throws IOException {
-        synchronized (stateLock) {
-            SctpNet.preClose(fdVal);
-            if (thread != 0)
-                NativeThread.signal(thread);
-            if (!isRegistered())
-                kill();
-        }
-    }
-
-    @Override
-    public void kill() throws IOException {
-        synchronized (stateLock) {
-            if (state == ChannelState.KILLED)
-                return;
-            if (state == ChannelState.UNINITIALIZED) {
-                state = ChannelState.KILLED;
-                return;
-            }
-            assert !isOpen() && !isRegistered();
-
-            // Postpone the kill if there is a thread in accept
-            if (thread == 0) {
-                SctpNet.close(fdVal);
-                state = ChannelState.KILLED;
-            } else {
-                state = ChannelState.KILLPENDING;
-            }
-        }
-    }
-
-    @Override
-    public FileDescriptor getFD() {
-        return fd;
-    }
-
-    @Override
-    public int getFDVal() {
-        return fdVal;
-    }
-
-    /**
-     * Translates native poll revent ops into a ready operation ops
-     */
-    private boolean translateReadyOps(int ops, int initialOps,
-                                     SelectionKeyImpl sk) {
-        int intOps = sk.nioInterestOps();
-        int oldOps = sk.nioReadyOps();
-        int newOps = initialOps;
-
-        if ((ops & PollArrayWrapper.POLLNVAL) != 0) {
-            /* This should only happen if this channel is pre-closed while a
-             * selection operation is in progress
-             * ## Throw an error if this channel has not been pre-closed */
-            return false;
-        }
-
-        if ((ops & (PollArrayWrapper.POLLERR
-                    | PollArrayWrapper.POLLHUP)) != 0) {
-            newOps = intOps;
-            sk.nioReadyOps(newOps);
-            return (newOps & ~oldOps) != 0;
-        }
-
-        if (((ops & PollArrayWrapper.POLLIN) != 0) &&
-            ((intOps & SelectionKey.OP_ACCEPT) != 0))
-                newOps |= SelectionKey.OP_ACCEPT;
-
-        sk.nioReadyOps(newOps);
-        return (newOps & ~oldOps) != 0;
-    }
-
-    @Override
-    public boolean translateAndUpdateReadyOps(int ops, SelectionKeyImpl sk) {
-        return translateReadyOps(ops, sk.nioReadyOps(), sk);
-    }
-
-    @Override
-    public boolean translateAndSetReadyOps(int ops, SelectionKeyImpl sk) {
-        return translateReadyOps(ops, 0, sk);
-    }
-
-    @Override
-    public void translateAndSetInterestOps(int ops, SelectionKeyImpl sk) {
-        int newOps = 0;
-
-        /* Translate ops */
-        if ((ops & SelectionKey.OP_ACCEPT) != 0)
-            newOps |= PollArrayWrapper.POLLIN;
-        /* Place ops into pollfd array */
-        sk.selector.putEventOps(sk, newOps);
-
-    }
-
-    @Override
-    public <T> SctpServerChannel setOption(SctpSocketOption<T> name, T value)
-            throws IOException {
-        if (name == null)
-            throw new NullPointerException();
-        if (!supportedOptions().contains(name))
-            throw new UnsupportedOperationException("'" + name + "' not supported");
-
-        synchronized (stateLock) {
-            if (!isOpen())
-                throw new ClosedChannelException();
-
-            SctpNet.setSocketOption(fdVal, name, value, 0 /*oneToOne*/);
-            return this;
-        }
-    }
-
-    @Override
-    @SuppressWarnings("unchecked")
-    public <T> T getOption(SctpSocketOption<T> name) throws IOException {
-        if (name == null)
-            throw new NullPointerException();
-        if (!supportedOptions().contains(name))
-            throw new UnsupportedOperationException("'" + name + "' not supported");
-
-        synchronized (stateLock) {
-            if (!isOpen())
-                throw new ClosedChannelException();
-
-            return (T) SctpNet.getSocketOption(fdVal, name, 0 /*oneToOne*/);
-        }
-    }
-
-    private static class DefaultOptionsHolder {
-        static final Set<SctpSocketOption<?>> defaultOptions = defaultOptions();
-
-        private static Set<SctpSocketOption<?>> defaultOptions() {
-            HashSet<SctpSocketOption<?>> set = new HashSet<SctpSocketOption<?>>(1);
-            set.add(SctpStandardSocketOptions.SCTP_INIT_MAXSTREAMS);
-            return Collections.unmodifiableSet(set);
-        }
-    }
-
-    @Override
-    public final Set<SctpSocketOption<?>> supportedOptions() {
-        return DefaultOptionsHolder.defaultOptions;
-    }
-
-    @Override
-    public Set<SocketAddress> getAllLocalAddresses()
-            throws IOException {
-        synchronized (stateLock) {
-            if (!isOpen())
-                throw new ClosedChannelException();
-            if (!isBound())
-                return Collections.emptySet();
-
-            return SctpNet.getLocalAddresses(fdVal);
-        }
-    }
-
-    /* Native */
-    private static native void initIDs();
-
-    private static native int accept0(FileDescriptor ssfd,
-        FileDescriptor newfd, InetSocketAddress[] isaa) throws IOException;
-
-    static {
-        Util.load();   // loads nio & net native libraries
-        java.security.AccessController.doPrivileged(
-                new sun.security.action.LoadLibraryAction("sctp"));
-        initIDs();
-    }
-}
--- a/jdk/src/solaris/classes/sun/nio/ch/SctpShutdown.java	Mon Feb 13 14:26:25 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package sun.nio.ch;
-
-import com.sun.nio.sctp.Association;
-import com.sun.nio.sctp.ShutdownNotification;
-
-/**
- * An implementation of ShutdownNotification
- */
-public class SctpShutdown extends ShutdownNotification
-    implements SctpNotification
-{
-    private Association association;
-    /* assocId is used to lookup the association before the notification is
-     * returned to user code */
-    private int assocId;
-
-    /* Invoked from native */
-    private SctpShutdown(int assocId) {
-        this.assocId = assocId;
-    }
-
-    @Override
-    public int assocId() {
-        return assocId;
-    }
-
-    @Override
-    public void setAssociation(Association association) {
-        this.association = association;
-    }
-
-    @Override
-    public Association association() {
-        assert association != null;
-        return association;
-    }
-
-    @Override
-    public String toString() {
-        StringBuilder sb = new StringBuilder();
-        sb.append(super.toString()).append(" [");
-        sb.append("Association:").append(association).append("]");
-        return sb.toString();
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/solaris/classes/sun/nio/ch/sctp/AssociationChange.java	Mon Feb 13 14:31:32 2012 +0000
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package sun.nio.ch.sctp;
+
+import com.sun.nio.sctp.Association;
+import com.sun.nio.sctp.AssociationChangeNotification;
+
+/**
+ * An implementation of AssociationChangeNotification
+ */
+public class AssociationChange extends AssociationChangeNotification
+    implements SctpNotification
+{
+    /* static final ints so that they can be referenced from native */
+    private final static int SCTP_COMM_UP = 1;
+    private final static int SCTP_COMM_LOST = 2;
+    private final static int SCTP_RESTART = 3;
+    private final static int SCTP_SHUTDOWN = 4;
+    private final static int SCTP_CANT_START = 5;
+
+    private Association association;
+
+    /* assocId is used to lookup the association before the notification is
+     * returned to user code */
+    private int assocId;
+    private AssocChangeEvent event;
+    private int maxOutStreams;
+    private int maxInStreams;
+
+    /* Invoked from native */
+    private AssociationChange(int assocId,
+                              int intEvent,
+                              int maxOutStreams,
+                              int maxInStreams) {
+        switch (intEvent) {
+            case SCTP_COMM_UP :
+                this.event = AssocChangeEvent.COMM_UP;
+                break;
+            case SCTP_COMM_LOST :
+                this.event = AssocChangeEvent.COMM_LOST;
+                break;
+            case SCTP_RESTART :
+                this.event = AssocChangeEvent.RESTART;
+                break;
+            case SCTP_SHUTDOWN :
+                this.event = AssocChangeEvent.SHUTDOWN;
+                break;
+            case SCTP_CANT_START :
+                this.event = AssocChangeEvent.CANT_START;
+                break;
+            default :
+                throw new AssertionError(
+                      "Unknown Association Change Event type: " + intEvent);
+        }
+
+        this.assocId = assocId;
+        this.maxOutStreams = maxOutStreams;
+        this.maxInStreams = maxInStreams;
+    }
+
+    @Override
+    public int assocId() {
+        return assocId;
+    }
+
+    @Override
+    public void setAssociation(Association association) {
+        this.association = association;
+    }
+
+    @Override
+    public Association association() {
+        assert association != null;
+        return association;
+    }
+
+    @Override
+    public AssocChangeEvent event() {
+        return event;
+    }
+
+    int maxOutStreams() {
+        return maxOutStreams;
+    }
+
+    int maxInStreams() {
+        return maxInStreams;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append(super.toString()).append(" [");
+        sb.append("Association:").append(association);
+        sb.append(", Event: ").append(event).append("]");
+        return sb.toString();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/solaris/classes/sun/nio/ch/sctp/AssociationImpl.java	Mon Feb 13 14:31:32 2012 +0000
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package sun.nio.ch.sctp;
+
+import com.sun.nio.sctp.Association;
+
+/**
+ * An implementation of Association
+ */
+public class AssociationImpl extends Association {
+    public AssociationImpl(int associationID,
+                           int maxInStreams,
+                           int maxOutStreams) {
+        super(associationID, maxInStreams, maxOutStreams);
+    }
+
+    @Override
+    public String toString() {
+        StringBuffer sb = new StringBuffer(super.toString());
+        return sb.append("[associationID:")
+                 .append(associationID())
+                 .append(", maxIn:")
+                 .append(maxInboundStreams())
+                 .append(", maxOut:")
+                 .append(maxOutboundStreams())
+                 .append("]")
+                 .toString();
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/solaris/classes/sun/nio/ch/sctp/PeerAddrChange.java	Mon Feb 13 14:31:32 2012 +0000
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package sun.nio.ch.sctp;
+
+import java.net.SocketAddress;
+import com.sun.nio.sctp.Association;
+import com.sun.nio.sctp.PeerAddressChangeNotification;
+
+/**
+ * An implementation of PeerAddressChangeNotification
+ */
+public class PeerAddrChange extends PeerAddressChangeNotification
+    implements SctpNotification
+{
+    /* static final ints so that they can be referenced from native */
+    private final static int SCTP_ADDR_AVAILABLE = 1;
+    private final static int SCTP_ADDR_UNREACHABLE = 2;
+    private final static int SCTP_ADDR_REMOVED = 3;
+    private final static int SCTP_ADDR_ADDED = 4;
+    private final static int SCTP_ADDR_MADE_PRIM = 5;
+    private final static int SCTP_ADDR_CONFIRMED =6;
+
+    private Association association;
+
+    /* assocId is used to lookup the association before the notification is
+     * returned to user code */
+    private int assocId;
+    private SocketAddress address;
+    private AddressChangeEvent event;
+
+    /* Invoked from native */
+    private PeerAddrChange(int assocId, SocketAddress address, int intEvent) {
+        switch (intEvent) {
+            case SCTP_ADDR_AVAILABLE :
+                this.event = AddressChangeEvent.ADDR_AVAILABLE;
+                break;
+            case SCTP_ADDR_UNREACHABLE :
+                this.event = AddressChangeEvent.ADDR_UNREACHABLE;
+                break;
+            case SCTP_ADDR_REMOVED :
+                this.event = AddressChangeEvent.ADDR_REMOVED;
+                break;
+            case SCTP_ADDR_ADDED :
+                this.event = AddressChangeEvent.ADDR_ADDED;
+                break;
+            case SCTP_ADDR_MADE_PRIM :
+                this.event = AddressChangeEvent.ADDR_MADE_PRIMARY;
+                break;
+            case SCTP_ADDR_CONFIRMED :
+                this.event = AddressChangeEvent.ADDR_CONFIRMED;
+                break;
+            default:
+                throw new AssertionError("Unknown event type");
+        }
+        this.assocId = assocId;
+        this.address = address;
+    }
+
+    @Override
+    public int assocId() {
+        return assocId;
+    }
+
+    @Override
+    public void setAssociation(Association association) {
+        this.association = association;
+    }
+
+    @Override
+    public SocketAddress address() {
+        assert address != null;
+        return address;
+    }
+
+    @Override
+    public Association association() {
+        assert association != null;
+        return association;
+    }
+
+    @Override
+    public AddressChangeEvent event() {
+        assert event != null;
+        return event;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append(super.toString()).append(" [");
+        sb.append("Address: ").append(address);
+        sb.append(", Association:").append(association);
+        sb.append(", Event: ").append(event).append("]");
+        return sb.toString();
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/solaris/classes/sun/nio/ch/sctp/ResultContainer.java	Mon Feb 13 14:31:32 2012 +0000
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package sun.nio.ch.sctp;
+
+/**
+ * Wraps the actual message or notification so that it can be
+ * set and returned from the native receive implementation.
+ */
+public class ResultContainer {
+    /* static final ints so that they can be referenced from native */
+    static final int NOTHING = 0;
+    static final int MESSAGE = 1;
+    static final int SEND_FAILED = 2;
+    static final int ASSOCIATION_CHANGED = 3;
+    static final int PEER_ADDRESS_CHANGED = 4;
+    static final int SHUTDOWN = 5;
+
+    private Object value;
+    private int type;
+
+    int type() {
+        return type;
+    }
+
+    boolean hasSomething() {
+        return type() != NOTHING;
+    }
+
+    boolean isNotification() {
+        return type() != MESSAGE && type() != NOTHING ? true : false;
+    }
+
+    void clear() {
+        type = NOTHING;
+        value = null;
+    }
+
+    SctpNotification notification() {
+        assert type() != MESSAGE && type() != NOTHING;
+
+        return (SctpNotification) value;
+    }
+
+    MessageInfoImpl getMessageInfo() {
+        assert type() == MESSAGE;
+
+        if (value instanceof MessageInfoImpl)
+            return (MessageInfoImpl) value;
+
+        return null;
+    }
+
+    SendFailed getSendFailed() {
+        assert type() == SEND_FAILED;
+
+        if (value instanceof SendFailed)
+            return (SendFailed) value;
+
+        return null;
+    }
+
+    AssociationChange getAssociationChanged() {
+        assert type() == ASSOCIATION_CHANGED;
+
+        if (value instanceof AssociationChange)
+            return (AssociationChange) value;
+
+        return null;
+    }
+
+    PeerAddrChange getPeerAddressChanged() {
+        assert type() == PEER_ADDRESS_CHANGED;
+
+        if (value instanceof PeerAddrChange)
+            return (PeerAddrChange) value;
+
+        return null;
+    }
+
+    Shutdown getShutdown() {
+        assert type() == SHUTDOWN;
+
+        if (value instanceof Shutdown)
+            return (Shutdown) value;
+
+        return null;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append("Type: ");
+        switch (type) {
+            case NOTHING:              sb.append("NOTHING");             break;
+            case MESSAGE:              sb.append("MESSAGE");             break;
+            case SEND_FAILED:          sb.append("SEND FAILED");         break;
+            case ASSOCIATION_CHANGED:  sb.append("ASSOCIATION CHANGE");  break;
+            case PEER_ADDRESS_CHANGED: sb.append("PEER ADDRESS CHANGE"); break;
+            case SHUTDOWN:             sb.append("SHUTDOWN");            break;
+            default :                  sb.append("Unknown result type");
+        }
+        sb.append(", Value: ");
+        sb.append((value == null) ? "null" : value.toString());
+        return sb.toString();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/solaris/classes/sun/nio/ch/sctp/SctpChannelImpl.java	Mon Feb 13 14:31:32 2012 +0000
@@ -0,0 +1,1106 @@
+/*
+ * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package sun.nio.ch.sctp;
+
+import java.net.InetAddress;
+import java.net.SocketAddress;
+import java.net.SocketException;
+import java.net.InetSocketAddress;
+import java.io.FileDescriptor;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Set;
+import java.util.HashSet;
+import java.nio.ByteBuffer;
+import java.nio.channels.SelectionKey;
+import java.nio.channels.ClosedChannelException;
+import java.nio.channels.ConnectionPendingException;
+import java.nio.channels.NoConnectionPendingException;
+import java.nio.channels.AlreadyConnectedException;
+import java.nio.channels.NotYetBoundException;
+import java.nio.channels.NotYetConnectedException;
+import java.nio.channels.spi.SelectorProvider;
+import com.sun.nio.sctp.AbstractNotificationHandler;
+import com.sun.nio.sctp.Association;
+import com.sun.nio.sctp.AssociationChangeNotification;
+import com.sun.nio.sctp.HandlerResult;
+import com.sun.nio.sctp.IllegalReceiveException;
+import com.sun.nio.sctp.InvalidStreamException;
+import com.sun.nio.sctp.IllegalUnbindException;
+import com.sun.nio.sctp.MessageInfo;
+import com.sun.nio.sctp.NotificationHandler;
+import com.sun.nio.sctp.SctpChannel;
+import com.sun.nio.sctp.SctpSocketOption;
+import sun.nio.ch.DirectBuffer;
+import sun.nio.ch.IOStatus;
+import sun.nio.ch.IOUtil;
+import sun.nio.ch.NativeThread;
+import sun.nio.ch.Net;
+import sun.nio.ch.PollArrayWrapper;
+import sun.nio.ch.SelChImpl;
+import sun.nio.ch.SelectionKeyImpl;
+import sun.nio.ch.Util;
+import static com.sun.nio.sctp.SctpStandardSocketOptions.*;
+import static sun.nio.ch.sctp.ResultContainer.SEND_FAILED;
+import static sun.nio.ch.sctp.ResultContainer.ASSOCIATION_CHANGED;
+import static sun.nio.ch.sctp.ResultContainer.PEER_ADDRESS_CHANGED;
+import static sun.nio.ch.sctp.ResultContainer.SHUTDOWN;
+
+/**
+ * An implementation of an SctpChannel
+ */
+public class SctpChannelImpl extends SctpChannel
+    implements SelChImpl
+{
+    private final FileDescriptor fd;
+
+    private final int fdVal;
+
+    /* IDs of native threads doing send and receivess, for signalling */
+    private volatile long receiverThread = 0;
+    private volatile long senderThread = 0;
+
+    /* Lock held by current receiving or connecting thread */
+    private final Object receiveLock = new Object();
+
+    /* Lock held by current sending or connecting thread */
+    private final Object sendLock = new Object();
+
+    private final ThreadLocal<Boolean> receiveInvoked =
+        new ThreadLocal<Boolean>() {
+             @Override protected Boolean initialValue() {
+                 return Boolean.FALSE;
+            }
+    };
+
+    /* Lock held by any thread that modifies the state fields declared below
+       DO NOT invoke a blocking I/O operation while holding this lock! */
+    private final Object stateLock = new Object();
+
+    private enum ChannelState {
+        UNINITIALIZED,
+        UNCONNECTED,
+        PENDING,
+        CONNECTED,
+        KILLPENDING,
+        KILLED,
+    }
+    /* -- The following fields are protected by stateLock -- */
+    private ChannelState state = ChannelState.UNINITIALIZED;
+
+    /* Binding; Once bound the port will remain constant. */
+    int port = -1;
+    private HashSet<InetSocketAddress> localAddresses = new HashSet<InetSocketAddress>();
+    /* Has the channel been bound to the wildcard address */
+    private boolean wildcard; /* false */
+    //private InetSocketAddress remoteAddress = null;
+
+    /* Input/Output open */
+    private boolean readyToConnect;
+
+    /* Shutdown */
+    private boolean isShutdown;
+
+    private Association association;
+
+    private Set<SocketAddress> remoteAddresses = Collections.emptySet();
+
+    /* -- End of fields protected by stateLock -- */
+
+    /**
+     * Constructor for normal connecting sockets
+     */
+    public SctpChannelImpl(SelectorProvider provider) throws IOException {
+        //TODO: update provider remove public modifier
+        super(provider);
+        this.fd = SctpNet.socket(true);
+        this.fdVal = IOUtil.fdVal(fd);
+        this.state = ChannelState.UNCONNECTED;
+    }
+
+    /**
+     * Constructor for sockets obtained from server sockets
+     */
+    public SctpChannelImpl(SelectorProvider provider, FileDescriptor fd)
+         throws IOException {
+        this(provider, fd, null);
+    }
+
+    /**
+     * Constructor for sockets obtained from branching
+     */
+    public SctpChannelImpl(SelectorProvider provider,
+                           FileDescriptor fd,
+                           Association association)
+            throws IOException {
+        super(provider);
+        this.fd = fd;
+        this.fdVal = IOUtil.fdVal(fd);
+        this.state = ChannelState.CONNECTED;
+        port = (Net.localAddress(fd)).getPort();
+
+        if (association != null) { /* branched */
+            this.association = association;
+        } else { /* obtained from server channel */
+            /* Receive COMM_UP */
+            ByteBuffer buf = Util.getTemporaryDirectBuffer(50);
+            try {
+                receive(buf, null, null, true);
+            } finally {
+                Util.releaseTemporaryDirectBuffer(buf);
+            }
+        }
+    }
+
+    /**
+     * Binds the channel's socket to a local address.
+     */
+    @Override
+    public SctpChannel bind(SocketAddress local) throws IOException {
+        synchronized (receiveLock) {
+            synchronized (sendLock) {
+                synchronized (stateLock) {
+                    ensureOpenAndUnconnected();
+                    if (isBound())
+                        SctpNet.throwAlreadyBoundException();
+                    InetSocketAddress isa = (local == null) ?
+                        new InetSocketAddress(0) : Net.checkAddress(local);
+                    Net.bind(fd, isa.getAddress(), isa.getPort());
+                    InetSocketAddress boundIsa = Net.localAddress(fd);
+                    port = boundIsa.getPort();
+                    localAddresses.add(isa);
+                    if (isa.getAddress().isAnyLocalAddress())
+                        wildcard = true;
+                }
+            }
+        }
+        return this;
+    }
+
+    @Override
+    public SctpChannel bindAddress(InetAddress address)
+            throws IOException {
+        bindUnbindAddress(address, true);
+        localAddresses.add(new InetSocketAddress(address, port));
+        return this;
+    }
+
+    @Override
+    public SctpChannel unbindAddress(InetAddress address)
+            throws IOException {
+        bindUnbindAddress(address, false);
+        localAddresses.remove(new InetSocketAddress(address, port));
+        return this;
+    }
+
+    private SctpChannel bindUnbindAddress(InetAddress address, boolean add)
+            throws IOException {
+        if (address == null)
+            throw new IllegalArgumentException();
+
+        synchronized (receiveLock) {
+            synchronized (sendLock) {
+                synchronized (stateLock) {
+                    if (!isOpen())
+                        throw new ClosedChannelException();
+                    if (!isBound())
+                        throw new NotYetBoundException();
+                    if (wildcard)
+                        throw new IllegalStateException(
+                                "Cannot add or remove addresses from a channel that is bound to the wildcard address");
+                    if (address.isAnyLocalAddress())
+                        throw new IllegalArgumentException(
+                                "Cannot add or remove the wildcard address");
+                    if (add) {
+                        for (InetSocketAddress addr : localAddresses) {
+                            if (addr.getAddress().equals(address)) {
+                                SctpNet.throwAlreadyBoundException();
+                            }
+                        }
+                    } else { /*removing */
+                        /* Verify that there is more than one address
+                         * and that address is already bound */
+                        if (localAddresses.size() <= 1)
+                            throw new IllegalUnbindException("Cannot remove address from a channel with only one address bound");
+                        boolean foundAddress = false;
+                        for (InetSocketAddress addr : localAddresses) {
+                            if (addr.getAddress().equals(address)) {
+                                foundAddress = true;
+                                break;
+                            }
+                        }
+                        if (!foundAddress )
+                            throw new IllegalUnbindException("Cannot remove address from a channel that is not bound to that address");
+                    }
+
+                    SctpNet.bindx(fdVal, new InetAddress[]{address}, port, add);
+
+                    /* Update our internal Set to reflect the addition/removal */
+                    if (add)
+                        localAddresses.add(new InetSocketAddress(address, port));
+                    else {
+                        for (InetSocketAddress addr : localAddresses) {
+                            if (addr.getAddress().equals(address)) {
+                                localAddresses.remove(addr);
+                                break;
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        return this;
+    }
+
+    private boolean isBound() {
+        synchronized (stateLock) {
+            return port == -1 ? false : true;
+        }
+    }
+
+    private boolean isConnected() {
+        synchronized (stateLock) {
+            return (state == ChannelState.CONNECTED);
+        }
+    }
+
+    private void ensureOpenAndUnconnected() throws IOException {
+        synchronized (stateLock) {
+            if (!isOpen())
+                throw new ClosedChannelException();
+            if (isConnected())
+                throw new AlreadyConnectedException();
+            if (state == ChannelState.PENDING)
+                throw new ConnectionPendingException();
+        }
+    }
+
+    private boolean ensureReceiveOpen() throws ClosedChannelException {
+        synchronized (stateLock) {
+            if (!isOpen())
+                throw new ClosedChannelException();
+            if (!isConnected())
+                throw new NotYetConnectedException();
+            else
+                return true;
+        }
+    }
+
+    private void ensureSendOpen() throws ClosedChannelException {
+        synchronized (stateLock) {
+            if (!isOpen())
+                throw new ClosedChannelException();
+            if (isShutdown)
+                throw new ClosedChannelException();
+            if (!isConnected())
+                throw new NotYetConnectedException();
+        }
+    }
+
+    private void receiverCleanup() throws IOException {
+        synchronized (stateLock) {
+            receiverThread = 0;
+            if (state == ChannelState.KILLPENDING)
+                kill();
+        }
+    }
+
+    private void senderCleanup() throws IOException {
+        synchronized (stateLock) {
+            senderThread = 0;
+            if (state == ChannelState.KILLPENDING)
+                kill();
+        }
+    }
+
+    @Override
+    public Association association() throws ClosedChannelException {
+        synchronized (stateLock) {
+            if (!isOpen())
+                throw new ClosedChannelException();
+            if (!isConnected())
+                return null;
+
+            return association;
+        }
+    }
+
+    @Override
+    public boolean connect(SocketAddress endpoint) throws IOException {
+        synchronized (receiveLock) {
+            synchronized (sendLock) {
+                ensureOpenAndUnconnected();
+                InetSocketAddress isa = Net.checkAddress(endpoint);
+                SecurityManager sm = System.getSecurityManager();
+                if (sm != null)
+                    sm.checkConnect(isa.getAddress().getHostAddress(),
+                                    isa.getPort());
+                synchronized (blockingLock()) {
+                    int n = 0;
+                    try {
+                        try {
+                            begin();
+                            synchronized (stateLock) {
+                                if (!isOpen()) {
+                                    return false;
+                                }
+                                receiverThread = NativeThread.current();
+                            }
+                            for (;;) {
+                                InetAddress ia = isa.getAddress();
+                                if (ia.isAnyLocalAddress())
+                                    ia = InetAddress.getLocalHost();
+                                n = SctpNet.connect(fdVal, ia, isa.getPort());
+                                if (  (n == IOStatus.INTERRUPTED)
+                                      && isOpen())
+                                    continue;
+                                break;
+                            }
+                        } finally {
+                            receiverCleanup();
+                            end((n > 0) || (n == IOStatus.UNAVAILABLE));
+                            assert IOStatus.check(n);
+                        }
+                    } catch (IOException x) {
+                        /* If an exception was thrown, close the channel after
+                         * invoking end() so as to avoid bogus
+                         * AsynchronousCloseExceptions */
+                        close();
+                        throw x;
+                    }
+
+                    if (n > 0) {
+                        synchronized (stateLock) {
+                            /* Connection succeeded */
+                            state = ChannelState.CONNECTED;
+                            if (!isBound()) {
+                                InetSocketAddress boundIsa =
+                                        Net.localAddress(fd);
+                                port = boundIsa.getPort();
+                            }
+
+                            /* Receive COMM_UP */
+                            ByteBuffer buf = Util.getTemporaryDirectBuffer(50);
+                            try {
+                                receive(buf, null, null, true);
+                            } finally {
+                                Util.releaseTemporaryDirectBuffer(buf);
+                            }
+
+                            /* cache remote addresses */
+                            try {
+                                remoteAddresses = getRemoteAddresses();
+                            } catch (IOException unused) { /* swallow exception */ }
+
+                            return true;
+                        }
+                    } else  {
+                        synchronized (stateLock) {
+                            /* If nonblocking and no exception then connection
+                             * pending; disallow another invocation */
+                            if (!isBlocking())
+                                state = ChannelState.PENDING;
+                            else
+                                assert false;
+                        }
+                    }
+                }
+                return false;
+            }
+        }
+    }
+
+    @Override
+    public boolean connect(SocketAddress endpoint,
+                           int maxOutStreams,
+                           int maxInStreams)
+            throws IOException {
+        ensureOpenAndUnconnected();
+        return setOption(SCTP_INIT_MAXSTREAMS, InitMaxStreams.
+                create(maxInStreams, maxOutStreams)).connect(endpoint);
+
+    }
+
+    @Override
+    public boolean isConnectionPending() {
+        synchronized (stateLock) {
+            return (state == ChannelState.PENDING);
+        }
+    }
+
+    @Override
+    public boolean finishConnect() throws IOException {
+        synchronized (receiveLock) {
+            synchronized (sendLock) {
+                synchronized (stateLock) {
+                    if (!isOpen())
+                        throw new ClosedChannelException();
+                    if (isConnected())
+                        return true;
+                    if (state != ChannelState.PENDING)
+                        throw new NoConnectionPendingException();
+                }
+                int n = 0;
+                try {
+                    try {
+                        begin();
+                        synchronized (blockingLock()) {
+                            synchronized (stateLock) {
+                                if (!isOpen()) {
+                                    return false;
+                                }
+                                receiverThread = NativeThread.current();
+                            }
+                            if (!isBlocking()) {
+                                for (;;) {
+                                    n = checkConnect(fd, false, readyToConnect);
+                                    if (  (n == IOStatus.INTERRUPTED)
+                                          && isOpen())
+                                        continue;
+                                    break;
+                                }
+                            } else {
+                                for (;;) {
+                                    n = checkConnect(fd, true, readyToConnect);
+                                    if (n == 0) {
+                                        // Loop in case of
+                                        // spurious notifications
+                                        continue;
+                                    }
+                                    if (  (n == IOStatus.INTERRUPTED)
+                                          && isOpen())
+                                        continue;
+                                    break;
+                                }
+                            }
+                        }
+                    } finally {
+                        synchronized (stateLock) {
+                            receiverThread = 0;
+                            if (state == ChannelState.KILLPENDING) {
+                                kill();
+                                /* poll()/getsockopt() does not report
+                                 * error (throws exception, with n = 0)
+                                 * on Linux platform after dup2 and
+                                 * signal-wakeup. Force n to 0 so the
+                                 * end() can throw appropriate exception */
+                                n = 0;
+                            }
+                        }
+                        end((n > 0) || (n == IOStatus.UNAVAILABLE));
+                        assert IOStatus.check(n);
+                    }
+                } catch (IOException x) {
+                    /* If an exception was thrown, close the channel after
+                     * invoking end() so as to avoid bogus
+                     * AsynchronousCloseExceptions */
+                    close();
+                    throw x;
+                }
+
+                if (n > 0) {
+                    synchronized (stateLock) {
+                        state = ChannelState.CONNECTED;
+                        if (!isBound()) {
+                            InetSocketAddress boundIsa =
+                                    Net.localAddress(fd);
+                            port = boundIsa.getPort();
+                        }
+
+                        /* Receive COMM_UP */
+                        ByteBuffer buf = Util.getTemporaryDirectBuffer(50);
+                        try {
+                            receive(buf, null, null, true);
+                        } finally {
+                            Util.releaseTemporaryDirectBuffer(buf);
+                        }
+
+                        /* cache remote addresses */
+                        try {
+                            remoteAddresses = getRemoteAddresses();
+                        } catch (IOException unused) { /* swallow exception */ }
+
+                        return true;
+                    }
+                }
+            }
+        }
+        return false;
+    }
+
+    @Override
+    protected void implConfigureBlocking(boolean block) throws IOException {
+        IOUtil.configureBlocking(fd, block);
+    }
+
+    @Override
+    public void implCloseSelectableChannel() throws IOException {
+        synchronized (stateLock) {
+            SctpNet.preClose(fdVal);
+
+            if (receiverThread != 0)
+                NativeThread.signal(receiverThread);
+
+            if (senderThread != 0)
+                NativeThread.signal(senderThread);
+
+            if (!isRegistered())
+                kill();
+        }
+    }
+
+    @Override
+    public FileDescriptor getFD() {
+        return fd;
+    }
+
+    @Override
+    public int getFDVal() {
+        return fdVal;
+    }
+
+    /**
+     * Translates native poll revent ops into a ready operation ops
+     */
+    private boolean translateReadyOps(int ops, int initialOps, SelectionKeyImpl sk) {
+        int intOps = sk.nioInterestOps();
+        int oldOps = sk.nioReadyOps();
+        int newOps = initialOps;
+
+        if ((ops & PollArrayWrapper.POLLNVAL) != 0) {
+            /* This should only happen if this channel is pre-closed while a
+             * selection operation is in progress
+             * ## Throw an error if this channel has not been pre-closed */
+            return false;
+        }
+
+        if ((ops & (PollArrayWrapper.POLLERR
+                    | PollArrayWrapper.POLLHUP)) != 0) {
+            newOps = intOps;
+            sk.nioReadyOps(newOps);
+            /* No need to poll again in checkConnect,
+             * the error will be detected there */
+            readyToConnect = true;
+            return (newOps & ~oldOps) != 0;
+        }
+
+        if (((ops & PollArrayWrapper.POLLIN) != 0) &&
+            ((intOps & SelectionKey.OP_READ) != 0) &&
+            isConnected())
+            newOps |= SelectionKey.OP_READ;
+
+        if (((ops & PollArrayWrapper.POLLCONN) != 0) &&
+            ((intOps & SelectionKey.OP_CONNECT) != 0) &&
+            ((state == ChannelState.UNCONNECTED) || (state == ChannelState.PENDING))) {
+            newOps |= SelectionKey.OP_CONNECT;
+            readyToConnect = true;
+        }
+
+        if (((ops & PollArrayWrapper.POLLOUT) != 0) &&
+            ((intOps & SelectionKey.OP_WRITE) != 0) &&
+            isConnected())
+            newOps |= SelectionKey.OP_WRITE;
+
+        sk.nioReadyOps(newOps);
+        return (newOps & ~oldOps) != 0;
+    }
+
+    @Override
+    public boolean translateAndUpdateReadyOps(int ops, SelectionKeyImpl sk) {
+        return translateReadyOps(ops, sk.nioReadyOps(), sk);
+    }
+
+    @Override
+    @SuppressWarnings("all")
+    public boolean translateAndSetReadyOps(int ops, SelectionKeyImpl sk) {
+        return translateReadyOps(ops, 0, sk);
+    }
+
+    @Override
+    public void translateAndSetInterestOps(int ops, SelectionKeyImpl sk) {
+        int newOps = 0;
+        if ((ops & SelectionKey.OP_READ) != 0)
+            newOps |= PollArrayWrapper.POLLIN;
+        if ((ops & SelectionKey.OP_WRITE) != 0)
+            newOps |= PollArrayWrapper.POLLOUT;
+        if ((ops & SelectionKey.OP_CONNECT) != 0)
+            newOps |= PollArrayWrapper.POLLCONN;
+        sk.selector.putEventOps(sk, newOps);
+    }
+
+    @Override
+    public void kill() throws IOException {
+        synchronized (stateLock) {
+            if (state == ChannelState.KILLED)
+                return;
+            if (state == ChannelState.UNINITIALIZED) {
+                state = ChannelState.KILLED;
+                return;
+            }
+            assert !isOpen() && !isRegistered();
+
+            /* Postpone the kill if there is a waiting reader
+             * or writer thread. */
+            if (receiverThread == 0 && senderThread == 0) {
+                SctpNet.close(fdVal);
+                state = ChannelState.KILLED;
+            } else {
+                state = ChannelState.KILLPENDING;
+            }
+        }
+    }
+
+    @Override
+    public <T> SctpChannel setOption(SctpSocketOption<T> name, T value)
+            throws IOException {
+        if (name == null)
+            throw new NullPointerException();
+        if (!supportedOptions().contains(name))
+            throw new UnsupportedOperationException("'" + name + "' not supported");
+
+        synchronized (stateLock) {
+            if (!isOpen())
+                throw new ClosedChannelException();
+
+            SctpNet.setSocketOption(fdVal, name, value, 0 /*oneToOne*/);
+        }
+        return this;
+    }
+
+    @Override
+    @SuppressWarnings("unchecked")
+    public <T> T getOption(SctpSocketOption<T> name) throws IOException {
+        if (name == null)
+            throw new NullPointerException();
+        if (!supportedOptions().contains(name))
+            throw new UnsupportedOperationException("'" + name + "' not supported");
+
+        synchronized (stateLock) {
+            if (!isOpen())
+                throw new ClosedChannelException();
+
+            return (T)SctpNet.getSocketOption(fdVal, name, 0 /*oneToOne*/);
+        }
+    }
+
+    private static class DefaultOptionsHolder {
+        static final Set<SctpSocketOption<?>> defaultOptions = defaultOptions();
+
+        private static Set<SctpSocketOption<?>> defaultOptions() {
+            HashSet<SctpSocketOption<?>> set = new HashSet<SctpSocketOption<?>>(10);
+            set.add(SCTP_DISABLE_FRAGMENTS);
+            set.add(SCTP_EXPLICIT_COMPLETE);
+            set.add(SCTP_FRAGMENT_INTERLEAVE);
+            set.add(SCTP_INIT_MAXSTREAMS);
+            set.add(SCTP_NODELAY);
+            set.add(SCTP_PRIMARY_ADDR);
+            set.add(SCTP_SET_PEER_PRIMARY_ADDR);
+            set.add(SO_SNDBUF);
+            set.add(SO_RCVBUF);
+            set.add(SO_LINGER);
+            return Collections.unmodifiableSet(set);
+        }
+    }
+
+    @Override
+    public final Set<SctpSocketOption<?>> supportedOptions() {
+        return DefaultOptionsHolder.defaultOptions;
+    }
+
+    @Override
+    public <T> MessageInfo receive(ByteBuffer buffer,
+                                   T attachment,
+                                   NotificationHandler<T> handler)
+            throws IOException {
+        return receive(buffer, attachment, handler, false);
+    }
+
+    private <T> MessageInfo receive(ByteBuffer buffer,
+                                    T attachment,
+                                    NotificationHandler<T> handler,
+                                    boolean fromConnect)
+            throws IOException {
+        if (buffer == null)
+            throw new IllegalArgumentException("buffer cannot be null");
+
+        if (buffer.isReadOnly())
+            throw new IllegalArgumentException("Read-only buffer");
+
+        if (receiveInvoked.get())
+            throw new IllegalReceiveException(
+                    "cannot invoke receive from handler");
+        receiveInvoked.set(Boolean.TRUE);
+
+        try {
+            ResultContainer resultContainer = new ResultContainer();
+            do {
+                resultContainer.clear();
+                synchronized (receiveLock) {
+                    if (!ensureReceiveOpen())
+                        return null;
+
+                    int n = 0;
+                    try {
+                        begin();
+
+                        synchronized (stateLock) {
+                            if(!isOpen())
+                                return null;
+                            receiverThread = NativeThread.current();
+                        }
+
+                        do {
+                            n = receive(fdVal, buffer, resultContainer, fromConnect);
+                        } while ((n == IOStatus.INTERRUPTED) && isOpen());
+                    } finally {
+                        receiverCleanup();
+                        end((n > 0) || (n == IOStatus.UNAVAILABLE));
+                        assert IOStatus.check(n);
+                    }
+
+                    if (!resultContainer.isNotification()) {
+                        /* message or nothing */
+                        if (resultContainer.hasSomething()) {
+                            /* Set the association before returning */
+                            MessageInfoImpl info =
+                                    resultContainer.getMessageInfo();
+                            synchronized (stateLock) {
+                                assert association != null;
+                                info.setAssociation(association);
+                            }
+                            return info;
+                        } else
+                            /* Non-blocking may return null if nothing available*/
+                            return null;
+                    } else { /* notification */
+                        synchronized (stateLock) {
+                            handleNotificationInternal(
+                                    resultContainer);
+                        }
+                    }
+
+                    if (fromConnect)  {
+                        /* If we reach here, then it was connect that invoked
+                         * receive and received the COMM_UP. We have already
+                         * handled the COMM_UP with the internal notification
+                         * handler. Simply return. */
+                        return null;
+                    }
+                }  /* receiveLock */
+            } while (handler == null ? true :
+                (invokeNotificationHandler(resultContainer, handler, attachment)
+                 == HandlerResult.CONTINUE));
+
+            return null;
+        } finally {
+            receiveInvoked.set(Boolean.FALSE);
+        }
+    }
+
+    private int receive(int fd,
+                        ByteBuffer dst,
+                        ResultContainer resultContainer,
+                        boolean peek)
+            throws IOException {
+        int pos = dst.position();
+        int lim = dst.limit();
+        assert (pos <= lim);
+        int rem = (pos <= lim ? lim - pos : 0);
+        if (dst instanceof DirectBuffer && rem > 0)
+            return receiveIntoNativeBuffer(fd, resultContainer, dst, rem, pos, peek);
+
+        /* Substitute a native buffer */
+        int newSize = Math.max(rem, 1);
+        ByteBuffer bb = Util.getTemporaryDirectBuffer(newSize);
+        try {
+            int n = receiveIntoNativeBuffer(fd, resultContainer, bb, newSize, 0, peek);
+            bb.flip();
+            if (n > 0 && rem > 0)
+                dst.put(bb);
+            return n;
+        } finally {
+            Util.releaseTemporaryDirectBuffer(bb);
+        }
+    }
+
+    private int receiveIntoNativeBuffer(int fd,
+                                        ResultContainer resultContainer,
+                                        ByteBuffer bb,
+                                        int rem,
+                                        int pos,
+                                        boolean peek)
+        throws IOException
+    {
+        int n = receive0(fd, resultContainer, ((DirectBuffer)bb).address() + pos, rem, peek);
+
+        if (n > 0)
+            bb.position(pos + n);
+        return n;
+    }
+
+    private InternalNotificationHandler internalNotificationHandler =
+            new InternalNotificationHandler();
+
+    private void handleNotificationInternal(ResultContainer resultContainer)
+    {
+        invokeNotificationHandler(resultContainer,
+                internalNotificationHandler, null);
+    }
+
+    private class InternalNotificationHandler
+            extends AbstractNotificationHandler<Object>
+    {
+        @Override
+        public HandlerResult handleNotification(
+                AssociationChangeNotification not, Object unused) {
+            if (not.event().equals(
+                    AssociationChangeNotification.AssocChangeEvent.COMM_UP) &&
+                    association == null) {
+                AssociationChange sac = (AssociationChange) not;
+                association = new AssociationImpl
+                       (sac.assocId(), sac.maxInStreams(), sac.maxOutStreams());
+            }
+            return HandlerResult.CONTINUE;
+        }
+    }
+
+    private <T> HandlerResult invokeNotificationHandler
+                                 (ResultContainer resultContainer,
+                                  NotificationHandler<T> handler,
+                                  T attachment) {
+        SctpNotification notification = resultContainer.notification();
+        synchronized (stateLock) {
+            notification.setAssociation(association);
+        }
+
+        if (!(handler instanceof AbstractNotificationHandler)) {
+            return handler.handleNotification(notification, attachment);
+        }
+
+        /* AbstractNotificationHandler */
+        AbstractNotificationHandler<T> absHandler =
+                (AbstractNotificationHandler<T>)handler;
+        switch(resultContainer.type()) {
+            case ASSOCIATION_CHANGED :
+                return absHandler.handleNotification(
+                        resultContainer.getAssociationChanged(), attachment);
+            case PEER_ADDRESS_CHANGED :
+                return absHandler.handleNotification(
+                        resultContainer.getPeerAddressChanged(), attachment);
+            case SEND_FAILED :
+                return absHandler.handleNotification(
+                        resultContainer.getSendFailed(), attachment);
+            case SHUTDOWN :
+                return absHandler.handleNotification(
+                        resultContainer.getShutdown(), attachment);
+            default :
+                /* implementation specific handlers */
+                return absHandler.handleNotification(
+                        resultContainer.notification(), attachment);
+        }
+    }
+
+    private void checkAssociation(Association sendAssociation) {
+        synchronized (stateLock) {
+            if (sendAssociation != null && !sendAssociation.equals(association)) {
+                throw new IllegalArgumentException(
+                        "Cannot send to another association");
+            }
+        }
+    }
+
+    private void checkStreamNumber(int streamNumber) {
+        synchronized (stateLock) {
+            if (association != null) {
+                if (streamNumber < 0 ||
+                      streamNumber >= association.maxOutboundStreams())
+                    throw new InvalidStreamException();
+            }
+        }
+    }
+
+    /* TODO: Add support for ttl and isComplete to both 121 12M
+     *       SCTP_EOR not yet supported on reference platforms
+     *       TTL support limited...
+     */
+    @Override
+    public int send(ByteBuffer buffer, MessageInfo messageInfo)
+            throws IOException {
+        if (buffer == null)
+            throw new IllegalArgumentException("buffer cannot be null");
+
+        if (messageInfo == null)
+            throw new IllegalArgumentException("messageInfo cannot be null");
+
+        checkAssociation(messageInfo.association());
+        checkStreamNumber(messageInfo.streamNumber());
+
+        synchronized (sendLock) {
+            ensureSendOpen();
+
+            int n = 0;
+            try {
+                begin();
+
+                synchronized (stateLock) {
+                    if(!isOpen())
+                        return 0;
+                    senderThread = NativeThread.current();
+                }
+
+                do {
+                    n = send(fdVal, buffer, messageInfo);
+                } while ((n == IOStatus.INTERRUPTED) && isOpen());
+
+                return IOStatus.normalize(n);
+            } finally {
+                senderCleanup();
+                end((n > 0) || (n == IOStatus.UNAVAILABLE));
+                assert IOStatus.check(n);
+            }
+        }
+    }
+
+    private int send(int fd, ByteBuffer src, MessageInfo messageInfo)
+            throws IOException {
+        int streamNumber = messageInfo.streamNumber();
+        SocketAddress target = messageInfo.address();
+        boolean unordered = messageInfo.isUnordered();
+        int ppid = messageInfo.payloadProtocolID();
+
+        if (src instanceof DirectBuffer)
+            return sendFromNativeBuffer(fd, src, target, streamNumber,
+                    unordered, ppid);
+
+        /* Substitute a native buffer */
+        int pos = src.position();
+        int lim = src.limit();
+        assert (pos <= lim && streamNumber >= 0);
+
+        int rem = (pos <= lim ? lim - pos : 0);
+        ByteBuffer bb = Util.getTemporaryDirectBuffer(rem);
+        try {
+            bb.put(src);
+            bb.flip();
+            /* Do not update src until we see how many bytes were written */
+            src.position(pos);
+
+            int n = sendFromNativeBuffer(fd, bb, target, streamNumber,
+                    unordered, ppid);
+            if (n > 0) {
+                /* now update src */
+                src.position(pos + n);
+            }
+            return n;
+        } finally {
+            Util.releaseTemporaryDirectBuffer(bb);
+        }
+    }
+
+    private int sendFromNativeBuffer(int fd,
+                                     ByteBuffer bb,
+                                     SocketAddress target,
+                                     int streamNumber,
+                                     boolean unordered,
+                                     int ppid)
+            throws IOException {
+        int pos = bb.position();
+        int lim = bb.limit();
+        assert (pos <= lim);
+        int rem = (pos <= lim ? lim - pos : 0);
+
+        int written = send0(fd, ((DirectBuffer)bb).address() + pos,
+                            rem, target, -1 /*121*/, streamNumber, unordered, ppid);
+        if (written > 0)
+            bb.position(pos + written);
+        return written;
+    }
+
+    @Override
+    public SctpChannel shutdown() throws IOException {
+        synchronized(stateLock) {
+            if (isShutdown)
+                return this;
+
+            ensureSendOpen();
+            SctpNet.shutdown(fdVal, -1);
+            if (senderThread != 0)
+                NativeThread.signal(senderThread);
+            isShutdown = true;
+        }
+        return this;
+    }
+
+    @Override
+    public Set<SocketAddress> getAllLocalAddresses()
+            throws IOException {
+        synchronized (stateLock) {
+            if (!isOpen())
+                throw new ClosedChannelException();
+            if (!isBound())
+                return Collections.emptySet();
+
+            return SctpNet.getLocalAddresses(fdVal);
+        }
+    }
+
+    @Override
+    public Set<SocketAddress> getRemoteAddresses()
+            throws IOException {
+        synchronized (stateLock) {
+            if (!isOpen())
+                throw new ClosedChannelException();
+            if (!isConnected() || isShutdown)
+                return Collections.emptySet();
+
+            try {
+                return SctpNet.getRemoteAddresses(fdVal, 0/*unused*/);
+            } catch (SocketException unused) {
+                /* an open connected channel should always have remote addresses */
+                return remoteAddresses;
+            }
+        }
+    }
+
+    /* Native */
+    private static native void initIDs();
+
+    static native int receive0(int fd, ResultContainer resultContainer,
+            long address, int length, boolean peek) throws IOException;
+
+    static native int send0(int fd, long address, int length,
+            SocketAddress target, int assocId, int streamNumber,
+            boolean unordered, int ppid) throws IOException;
+
+    private static native int checkConnect(FileDescriptor fd, boolean block,
+            boolean ready) throws IOException;
+
+    static {
+        Util.load();   /* loads nio & net native libraries */
+        java.security.AccessController.doPrivileged(
+                new sun.security.action.LoadLibraryAction("sctp"));
+        initIDs();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/solaris/classes/sun/nio/ch/sctp/SctpMultiChannelImpl.java	Mon Feb 13 14:31:32 2012 +0000
@@ -0,0 +1,994 @@
+/*
+ * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package sun.nio.ch.sctp;
+
+import java.net.InetAddress;
+import java.net.SocketAddress;
+import java.net.SocketException;
+import java.net.InetSocketAddress;
+import java.io.FileDescriptor;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Map.Entry;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.HashMap;
+import java.nio.ByteBuffer;
+import java.nio.channels.SelectionKey;
+import java.nio.channels.ClosedChannelException;
+import java.nio.channels.NotYetBoundException;
+import java.nio.channels.spi.SelectorProvider;
+import com.sun.nio.sctp.AbstractNotificationHandler;
+import com.sun.nio.sctp.Association;
+import com.sun.nio.sctp.AssociationChangeNotification;
+import com.sun.nio.sctp.HandlerResult;
+import com.sun.nio.sctp.IllegalReceiveException;
+import com.sun.nio.sctp.InvalidStreamException;
+import com.sun.nio.sctp.IllegalUnbindException;
+import com.sun.nio.sctp.NotificationHandler;
+import com.sun.nio.sctp.MessageInfo;
+import com.sun.nio.sctp.SctpChannel;
+import com.sun.nio.sctp.SctpMultiChannel;
+import com.sun.nio.sctp.SctpSocketOption;
+import sun.nio.ch.DirectBuffer;
+import sun.nio.ch.NativeThread;
+import sun.nio.ch.IOStatus;
+import sun.nio.ch.IOUtil;
+import sun.nio.ch.Net;
+import sun.nio.ch.PollArrayWrapper;
+import sun.nio.ch.SelChImpl;
+import sun.nio.ch.SelectionKeyImpl;
+import sun.nio.ch.Util;
+import static com.sun.nio.sctp.SctpStandardSocketOptions.*;
+import static sun.nio.ch.sctp.ResultContainer.*;
+
+/**
+ * An implementation of SctpMultiChannel
+ */
+public class SctpMultiChannelImpl extends SctpMultiChannel
+    implements SelChImpl
+{
+    private final FileDescriptor fd;
+
+    private final int fdVal;
+
+    /* IDs of native threads doing send and receives, for signalling */
+    private volatile long receiverThread = 0;
+    private volatile long senderThread = 0;
+
+    /* Lock held by current receiving thread */
+    private final Object receiveLock = new Object();
+
+    /* Lock held by current sending thread */
+    private final Object sendLock = new Object();
+
+    /* Lock held by any thread that modifies the state fields declared below
+     * DO NOT invoke a blocking I/O operation while holding this lock! */
+    private final Object stateLock = new Object();
+
+    private enum ChannelState {
+        UNINITIALIZED,
+        KILLPENDING,
+        KILLED,
+    }
+
+    /* -- The following fields are protected by stateLock -- */
+    private ChannelState state = ChannelState.UNINITIALIZED;
+
+    /* Binding: Once bound the port will remain constant. */
+    int port = -1;
+    private HashSet<InetSocketAddress> localAddresses = new HashSet<InetSocketAddress>();
+    /* Has the channel been bound to the wildcard address */
+    private boolean wildcard; /* false */
+
+    /* Keeps a map of addresses to association, and visa versa */
+    private HashMap<SocketAddress, Association> addressMap =
+                         new HashMap<SocketAddress, Association>();
+    private HashMap<Association, Set<SocketAddress>> associationMap =
+                         new HashMap<Association, Set<SocketAddress>>();
+
+    /* -- End of fields protected by stateLock -- */
+
+    /* If an association has been shutdown mark it for removal after
+     * the user handler has been invoked */
+    private final ThreadLocal<Association> associationToRemove =
+        new ThreadLocal<Association>() {
+             @Override protected Association initialValue() {
+                 return null;
+            }
+    };
+
+    /* A notification handler cannot invoke receive */
+    private final ThreadLocal<Boolean> receiveInvoked =
+        new ThreadLocal<Boolean>() {
+             @Override protected Boolean initialValue() {
+                 return Boolean.FALSE;
+            }
+    };
+
+    public SctpMultiChannelImpl(SelectorProvider provider)
+            throws IOException {
+        //TODO: update provider, remove public modifier
+        super(provider);
+        this.fd = SctpNet.socket(false /*one-to-many*/);
+        this.fdVal = IOUtil.fdVal(fd);
+    }
+
+    @Override
+    public SctpMultiChannel bind(SocketAddress local, int backlog)
+            throws IOException {
+        synchronized (receiveLock) {
+            synchronized (sendLock) {
+                synchronized (stateLock) {
+                    ensureOpen();
+                    if (isBound())
+                        SctpNet.throwAlreadyBoundException();
+                    InetSocketAddress isa = (local == null) ?
+                        new InetSocketAddress(0) : Net.checkAddress(local);
+
+                    SecurityManager sm = System.getSecurityManager();
+                    if (sm != null)
+                        sm.checkListen(isa.getPort());
+                    Net.bind(fd, isa.getAddress(), isa.getPort());
+
+                    InetSocketAddress boundIsa = Net.localAddress(fd);
+                    port = boundIsa.getPort();
+                    localAddresses.add(isa);
+                    if (isa.getAddress().isAnyLocalAddress())
+                        wildcard = true;
+
+                    SctpNet.listen(fdVal, backlog < 1 ? 50 : backlog);
+                }
+            }
+        }
+        return this;
+    }
+
+    @Override
+    public SctpMultiChannel bindAddress(InetAddress address)
+            throws IOException {
+        return bindUnbindAddress(address, true);
+    }
+
+    @Override
+    public SctpMultiChannel unbindAddress(InetAddress address)
+            throws IOException {
+        return bindUnbindAddress(address, false);
+    }
+
+    private SctpMultiChannel bindUnbindAddress(InetAddress address,
+                                               boolean add)
+            throws IOException {
+        if (address == null)
+            throw new IllegalArgumentException();
+
+        synchronized (receiveLock) {
+            synchronized (sendLock) {
+                synchronized (stateLock) {
+                    if (!isOpen())
+                        throw new ClosedChannelException();
+                    if (!isBound())
+                        throw new NotYetBoundException();
+                    if (wildcard)
+                        throw new IllegalStateException(
+                                "Cannot add or remove addresses from a channel that is bound to the wildcard address");
+                    if (address.isAnyLocalAddress())
+                        throw new IllegalArgumentException(
+                                "Cannot add or remove the wildcard address");
+                    if (add) {
+                        for (InetSocketAddress addr : localAddresses) {
+                            if (addr.getAddress().equals(address)) {
+                                SctpNet.throwAlreadyBoundException();
+                            }
+                        }
+                    } else { /*removing */
+                        /* Verify that there is more than one address
+                         * and that address is already bound */
+                        if (localAddresses.size() <= 1)
+                            throw new IllegalUnbindException("Cannot remove address from a channel with only one address bound");
+                        boolean foundAddress = false;
+                        for (InetSocketAddress addr : localAddresses) {
+                            if (addr.getAddress().equals(address)) {
+                                foundAddress = true;
+                                break;
+                            }
+                        }
+                        if (!foundAddress )
+                            throw new IllegalUnbindException("Cannot remove address from a channel that is not bound to that address");
+                    }
+
+                    SctpNet.bindx(fdVal, new InetAddress[]{address}, port, add);
+
+                    /* Update our internal Set to reflect the addition/removal */
+                    if (add)
+                        localAddresses.add(new InetSocketAddress(address, port));
+                    else {
+                        for (InetSocketAddress addr : localAddresses) {
+                            if (addr.getAddress().equals(address)) {
+                                localAddresses.remove(addr);
+                                break;
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        return this;
+    }
+
+    @Override
+    public Set<Association> associations()
+            throws ClosedChannelException, NotYetBoundException {
+        synchronized (stateLock) {
+            if (!isOpen())
+                throw new ClosedChannelException();
+            if (!isBound())
+                throw new NotYetBoundException();
+
+            return Collections.unmodifiableSet(associationMap.keySet());
+        }
+    }
+
+    private boolean isBound() {
+        synchronized (stateLock) {
+            return port == -1 ? false : true;
+        }
+    }
+
+    private void ensureOpen() throws IOException {
+        synchronized (stateLock) {
+            if (!isOpen())
+                throw new ClosedChannelException();
+        }
+    }
+
+    private void receiverCleanup() throws IOException {
+        synchronized (stateLock) {
+            receiverThread = 0;
+            if (state == ChannelState.KILLPENDING)
+                kill();
+        }
+    }
+
+    private void senderCleanup() throws IOException {
+        synchronized (stateLock) {
+            senderThread = 0;
+            if (state == ChannelState.KILLPENDING)
+                kill();
+        }
+    }
+
+    @Override
+    protected void implConfigureBlocking(boolean block) throws IOException {
+        IOUtil.configureBlocking(fd, block);
+    }
+
+    @Override
+    public void implCloseSelectableChannel() throws IOException {
+        synchronized (stateLock) {
+            SctpNet.preClose(fdVal);
+
+            if (receiverThread != 0)
+                NativeThread.signal(receiverThread);
+
+            if (senderThread != 0)
+                NativeThread.signal(senderThread);
+
+            if (!isRegistered())
+                kill();
+        }
+    }
+
+    @Override
+    public FileDescriptor getFD() {
+        return fd;
+    }
+
+    @Override
+    public int getFDVal() {
+        return fdVal;
+    }
+
+    /**
+     * Translates native poll revent ops into a ready operation ops
+     */
+    private boolean translateReadyOps(int ops, int initialOps,
+                                      SelectionKeyImpl sk) {
+        int intOps = sk.nioInterestOps();
+        int oldOps = sk.nioReadyOps();
+        int newOps = initialOps;
+
+        if ((ops & PollArrayWrapper.POLLNVAL) != 0) {
+            /* This should only happen if this channel is pre-closed while a
+             * selection operation is in progress
+             * ## Throw an error if this channel has not been pre-closed */
+            return false;
+        }
+
+        if ((ops & (PollArrayWrapper.POLLERR
+                    | PollArrayWrapper.POLLHUP)) != 0) {
+            newOps = intOps;
+            sk.nioReadyOps(newOps);
+            return (newOps & ~oldOps) != 0;
+        }
+
+        if (((ops & PollArrayWrapper.POLLIN) != 0) &&
+            ((intOps & SelectionKey.OP_READ) != 0))
+            newOps |= SelectionKey.OP_READ;
+
+        if (((ops & PollArrayWrapper.POLLOUT) != 0) &&
+            ((intOps & SelectionKey.OP_WRITE) != 0))
+            newOps |= SelectionKey.OP_WRITE;
+
+        sk.nioReadyOps(newOps);
+        return (newOps & ~oldOps) != 0;
+    }
+
+    @Override
+    public boolean translateAndUpdateReadyOps(int ops, SelectionKeyImpl sk) {
+        return translateReadyOps(ops, sk.nioReadyOps(), sk);
+    }
+
+    @Override
+    public boolean translateAndSetReadyOps(int ops, SelectionKeyImpl sk) {
+        return translateReadyOps(ops, 0, sk);
+    }
+
+    @Override
+    public void translateAndSetInterestOps(int ops, SelectionKeyImpl sk) {
+        int newOps = 0;
+        if ((ops & SelectionKey.OP_READ) != 0)
+            newOps |= PollArrayWrapper.POLLIN;
+        if ((ops & SelectionKey.OP_WRITE) != 0)
+            newOps |= PollArrayWrapper.POLLOUT;
+        sk.selector.putEventOps(sk, newOps);
+    }
+
+    @Override
+    public void kill() throws IOException {
+        synchronized (stateLock) {
+            if (state == ChannelState.KILLED)
+                return;
+            if (state == ChannelState.UNINITIALIZED) {
+                state = ChannelState.KILLED;
+                return;
+            }
+            assert !isOpen() && !isRegistered();
+
+            /* Postpone the kill if there is a thread sending or receiving. */
+            if (receiverThread == 0 && senderThread == 0) {
+                SctpNet.close(fdVal);
+                state = ChannelState.KILLED;
+            } else {
+                state = ChannelState.KILLPENDING;
+            }
+        }
+    }
+
+    @Override
+    public <T> SctpMultiChannel setOption(SctpSocketOption<T> name,
+                                          T value,
+                                          Association association)
+            throws IOException {
+        if (name == null)
+            throw new NullPointerException();
+        if (!(supportedOptions().contains(name)))
+            throw new UnsupportedOperationException("'" + name + "' not supported");
+
+        synchronized (stateLock) {
+            if (association != null && (name.equals(SCTP_PRIMARY_ADDR) ||
+                    name.equals(SCTP_SET_PEER_PRIMARY_ADDR))) {
+                checkAssociation(association);
+            }
+            if (!isOpen())
+                throw new ClosedChannelException();
+
+            int assocId = association == null ? 0 : association.associationID();
+            SctpNet.setSocketOption(fdVal, name, value, assocId);
+        }
+        return this;
+    }
+
+    @Override
+    @SuppressWarnings("unchecked")
+    public <T> T getOption(SctpSocketOption<T> name, Association association)
+            throws IOException {
+        if (name == null)
+            throw new NullPointerException();
+        if (!supportedOptions().contains(name))
+            throw new UnsupportedOperationException("'" + name + "' not supported");
+
+        synchronized (stateLock) {
+            if (association != null && (name.equals(SCTP_PRIMARY_ADDR) ||
+                    name.equals(SCTP_SET_PEER_PRIMARY_ADDR))) {
+                checkAssociation(association);
+            }
+            if (!isOpen())
+                throw new ClosedChannelException();
+
+            int assocId = association == null ? 0 : association.associationID();
+            return (T)SctpNet.getSocketOption(fdVal, name, assocId);
+        }
+    }
+
+    private static class DefaultOptionsHolder {
+        static final Set<SctpSocketOption<?>> defaultOptions = defaultOptions();
+
+        private static Set<SctpSocketOption<?>> defaultOptions() {
+            HashSet<SctpSocketOption<?>> set = new HashSet<SctpSocketOption<?>>(10);
+            set.add(SCTP_DISABLE_FRAGMENTS);
+            set.add(SCTP_EXPLICIT_COMPLETE);
+            set.add(SCTP_FRAGMENT_INTERLEAVE);
+            set.add(SCTP_INIT_MAXSTREAMS);
+            set.add(SCTP_NODELAY);
+            set.add(SCTP_PRIMARY_ADDR);
+            set.add(SCTP_SET_PEER_PRIMARY_ADDR);
+            set.add(SO_SNDBUF);
+            set.add(SO_RCVBUF);
+            set.add(SO_LINGER);
+            return Collections.unmodifiableSet(set);
+        }
+    }
+
+    @Override
+    public final Set<SctpSocketOption<?>> supportedOptions() {
+        return DefaultOptionsHolder.defaultOptions;
+    }
+
+    @Override
+    public <T> MessageInfo receive(ByteBuffer buffer,
+                                   T attachment,
+                                   NotificationHandler<T> handler)
+            throws IOException {
+        if (buffer == null)
+            throw new IllegalArgumentException("buffer cannot be null");
+
+        if (buffer.isReadOnly())
+            throw new IllegalArgumentException("Read-only buffer");
+
+        if (receiveInvoked.get())
+            throw new IllegalReceiveException(
+                    "cannot invoke receive from handler");
+        receiveInvoked.set(Boolean.TRUE);
+
+        try {
+            ResultContainer resultContainer = new ResultContainer();
+            do {
+                resultContainer.clear();
+                synchronized (receiveLock) {
+                    ensureOpen();
+                    if (!isBound())
+                        throw new NotYetBoundException();
+
+                    int n = 0;
+                    try {
+                        begin();
+
+                        synchronized (stateLock) {
+                            if(!isOpen())
+                                return null;
+                            receiverThread = NativeThread.current();
+                        }
+
+                        do {
+                            n = receive(fdVal, buffer, resultContainer);
+                        } while ((n == IOStatus.INTERRUPTED) && isOpen());
+
+                    } finally {
+                        receiverCleanup();
+                        end((n > 0) || (n == IOStatus.UNAVAILABLE));
+                        assert IOStatus.check(n);
+                    }
+
+                    if (!resultContainer.isNotification()) {
+                        /* message or nothing */
+                        if (resultContainer.hasSomething()) {
+                            /* Set the association before returning */
+                            MessageInfoImpl info =
+                                    resultContainer.getMessageInfo();
+                            info.setAssociation(lookupAssociation(info.
+                                    associationID()));
+                            SecurityManager sm = System.getSecurityManager();
+                            if (sm != null) {
+                                InetSocketAddress isa  = (InetSocketAddress)info.address();
+                                if (!addressMap.containsKey(isa)) {
+                                    /* must be a new association */
+                                    try {
+                                        sm.checkAccept(isa.getAddress().getHostAddress(),
+                                                       isa.getPort());
+                                    } catch (SecurityException se) {
+                                        buffer.clear();
+                                        throw se;
+                                    }
+                                }
+                            }
+
+                            assert info.association() != null;
+                            return info;
+                        } else  {
+                          /* Non-blocking may return null if nothing available*/
+                            return null;
+                        }
+                    } else { /* notification */
+                        synchronized (stateLock) {
+                            handleNotificationInternal(
+                                    resultContainer);
+                        }
+                    }
+                } /* receiveLock */
+            } while (handler == null ? true :
+                (invokeNotificationHandler(resultContainer, handler, attachment)
+                 == HandlerResult.CONTINUE));
+        } finally {
+            receiveInvoked.set(Boolean.FALSE);
+        }
+
+        return null;
+    }
+
+    private int receive(int fd,
+                        ByteBuffer dst,
+                        ResultContainer resultContainer)
+            throws IOException {
+        int pos = dst.position();
+        int lim = dst.limit();
+        assert (pos <= lim);
+        int rem = (pos <= lim ? lim - pos : 0);
+        if (dst instanceof DirectBuffer && rem > 0)
+            return receiveIntoNativeBuffer(fd, resultContainer, dst, rem, pos);
+
+        /* Substitute a native buffer. */
+        int newSize = Math.max(rem, 1);
+        ByteBuffer bb = Util.getTemporaryDirectBuffer(newSize);
+        try {
+            int n = receiveIntoNativeBuffer(fd, resultContainer, bb, newSize, 0);
+            bb.flip();
+            if (n > 0 && rem > 0)
+                dst.put(bb);
+            return n;
+        } finally {
+            Util.releaseTemporaryDirectBuffer(bb);
+        }
+    }
+
+    private int receiveIntoNativeBuffer(int fd,
+                                        ResultContainer resultContainer,
+                                        ByteBuffer bb,
+                                        int rem,
+                                        int pos)
+            throws IOException {
+        int n = receive0(fd, resultContainer, ((DirectBuffer)bb).address() + pos, rem);
+        if (n > 0)
+            bb.position(pos + n);
+        return n;
+    }
+
+    private InternalNotificationHandler internalNotificationHandler =
+            new InternalNotificationHandler();
+
+    private void handleNotificationInternal(ResultContainer resultContainer)
+    {
+        invokeNotificationHandler(resultContainer,
+                internalNotificationHandler, null);
+    }
+
+    private class InternalNotificationHandler
+            extends AbstractNotificationHandler<Object>
+    {
+        @Override
+        public HandlerResult handleNotification(
+                AssociationChangeNotification not, Object unused) {
+            AssociationChange sac = (AssociationChange) not;
+
+            /* Update map to reflect change in association */
+            switch (not.event()) {
+                case COMM_UP :
+                    Association newAssociation = new AssociationImpl
+                       (sac.assocId(), sac.maxInStreams(), sac.maxOutStreams());
+                    addAssociation(newAssociation);
+                    break;
+                case SHUTDOWN :
+                case COMM_LOST :
+                //case RESTART: ???
+                    /* mark association for removal after user handler invoked*/
+                    associationToRemove.set(lookupAssociation(sac.assocId()));
+            }
+            return HandlerResult.CONTINUE;
+        }
+    }
+
+    private <T> HandlerResult invokeNotificationHandler(
+                                   ResultContainer resultContainer,
+                                   NotificationHandler<T> handler,
+                                   T attachment) {
+        HandlerResult result;
+        SctpNotification notification = resultContainer.notification();
+        notification.setAssociation(lookupAssociation(notification.assocId()));
+
+        if (!(handler instanceof AbstractNotificationHandler)) {
+            result = handler.handleNotification(notification, attachment);
+        } else { /* AbstractNotificationHandler */
+            AbstractNotificationHandler<T> absHandler =
+                    (AbstractNotificationHandler<T>)handler;
+            switch(resultContainer.type()) {
+                case ASSOCIATION_CHANGED :
+                    result = absHandler.handleNotification(
+                            resultContainer.getAssociationChanged(), attachment);
+                    break;
+                case PEER_ADDRESS_CHANGED :
+                    result = absHandler.handleNotification(
+                            resultContainer.getPeerAddressChanged(), attachment);
+                    break;
+                case SEND_FAILED :
+                    result = absHandler.handleNotification(
+                            resultContainer.getSendFailed(), attachment);
+                    break;
+                case SHUTDOWN :
+                    result =  absHandler.handleNotification(
+                            resultContainer.getShutdown(), attachment);
+                    break;
+                default :
+                    /* implementation specific handlers */
+                    result =  absHandler.handleNotification(
+                            resultContainer.notification(), attachment);
+            }
+        }
+
+        if (!(handler instanceof InternalNotificationHandler)) {
+            /* Only remove associations after user handler
+             * has finished with them */
+            Association assoc = associationToRemove.get();
+            if (assoc != null) {
+                removeAssociation(assoc);
+                associationToRemove.set(null);
+            }
+
+        }
+
+        return result;
+    }
+
+    private Association lookupAssociation(int assocId) {
+        /* Lookup the association in our internal map */
+        synchronized (stateLock) {
+            Set<Association> assocs = associationMap.keySet();
+            for (Association a : assocs) {
+                if (a.associationID() == assocId) {
+                    return a;
+                }
+            }
+        }
+        return null;
+    }
+
+    private void addAssociation(Association association) {
+        synchronized (stateLock) {
+            int assocId = association.associationID();
+            Set<SocketAddress> addresses = null;
+
+            try {
+                addresses = SctpNet.getRemoteAddresses(fdVal, assocId);
+            } catch (IOException unused) {
+                /* OK, determining connected addresses may not be possible
+                 * shutdown, connection lost, etc */
+            }
+
+            associationMap.put(association, addresses);
+            if (addresses != null) {
+                for (SocketAddress addr : addresses)
+                    addressMap.put(addr, association);
+            }
+        }
+    }
+
+    private void removeAssociation(Association association) {
+        synchronized (stateLock) {
+            int assocId = association.associationID();
+            Set<SocketAddress> addresses = null;
+
+             try {
+                addresses = SctpNet.getRemoteAddresses(fdVal, assocId);
+            } catch (IOException unused) {
+                /* OK, determining connected addresses may not be possible
+                 * shutdown, connection lost, etc */
+            }
+
+            Set<Association> assocs = associationMap.keySet();
+            for (Association a : assocs) {
+                if (a.associationID() == assocId) {
+                    associationMap.remove(a);
+                    break;
+                }
+            }
+            if (addresses != null) {
+                for (SocketAddress addr : addresses)
+                    addressMap.remove(addr);
+            } else {
+                /* We cannot determine the connected addresses */
+                Set<java.util.Map.Entry<SocketAddress, Association>> addrAssocs =
+                        addressMap.entrySet();
+                Iterator<Entry<SocketAddress, Association>> iterator = addrAssocs.iterator();
+                while (iterator.hasNext()) {
+                    Entry<SocketAddress, Association> entry = iterator.next();
+                    if (entry.getValue().equals(association)) {
+                        iterator.remove();
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * @throws  IllegalArgumentException
+     *          If the given association is not controlled by this channel
+     *
+     * @return  {@code true} if, and only if, the given association is one
+     *          of the current associations controlled by this channel
+     */
+    private boolean checkAssociation(Association messageAssoc) {
+        synchronized (stateLock) {
+            for (Association association : associationMap.keySet()) {
+                if (messageAssoc.equals(association)) {
+                    return true;
+                }
+            }
+        }
+        throw new IllegalArgumentException(
+              "Given Association is not controlled by this channel");
+    }
+
+    private void checkStreamNumber(Association assoc, int streamNumber) {
+        synchronized (stateLock) {
+            if (streamNumber < 0 || streamNumber >= assoc.maxOutboundStreams())
+                throw new InvalidStreamException();
+        }
+    }
+
+    /* TODO: Add support for ttl and isComplete to both 121 12M
+     *       SCTP_EOR not yet supported on reference platforms
+     *       TTL support limited...
+     */
+    @Override
+    public int send(ByteBuffer buffer, MessageInfo messageInfo)
+            throws IOException {
+        if (buffer == null)
+            throw new IllegalArgumentException("buffer cannot be null");
+
+        if (messageInfo == null)
+            throw new IllegalArgumentException("messageInfo cannot be null");
+
+        synchronized (sendLock) {
+            ensureOpen();
+
+            if (!isBound())
+                bind(null, 0);
+
+            int n = 0;
+            try {
+                int assocId = -1;
+                SocketAddress address = null;
+                begin();
+
+                synchronized (stateLock) {
+                    if(!isOpen())
+                        return 0;
+                    senderThread = NativeThread.current();
+
+                    /* Determine what address or association to send to */
+                    Association assoc = messageInfo.association();
+                    InetSocketAddress addr = (InetSocketAddress)messageInfo.address();
+                    if (assoc != null) {
+                        checkAssociation(assoc);
+                        checkStreamNumber(assoc, messageInfo.streamNumber());
+                        assocId = assoc.associationID();
+                        /* have we also got a preferred address */
+                        if (addr != null) {
+                            if (!assoc.equals(addressMap.get(addr)))
+                                throw new IllegalArgumentException("given preferred address is not part of this association");
+                            address = addr;
+                        }
+                    } else if (addr != null) {
+                        address = addr;
+                        Association association = addressMap.get(addr);
+                        if (association != null) {
+                            checkStreamNumber(association, messageInfo.streamNumber());
+                            assocId = association.associationID();
+
+                        } else { /* must be new association */
+                            SecurityManager sm = System.getSecurityManager();
+                            if (sm != null)
+                                sm.checkConnect(addr.getAddress().getHostAddress(),
+                                                addr.getPort());
+                        }
+                    } else {
+                        throw new AssertionError(
+                            "Both association and address cannot be null");
+                    }
+                }
+
+                do {
+                    n = send(fdVal, buffer, assocId, address, messageInfo);
+                } while ((n == IOStatus.INTERRUPTED) && isOpen());
+
+                return IOStatus.normalize(n);
+            } finally {
+                senderCleanup();
+                end((n > 0) || (n == IOStatus.UNAVAILABLE));
+                assert IOStatus.check(n);
+            }
+        }
+    }
+
+    private int send(int fd,
+                     ByteBuffer src,
+                     int assocId,
+                     SocketAddress target,
+                     MessageInfo messageInfo)
+            throws IOException {
+        int streamNumber = messageInfo.streamNumber();
+        boolean unordered = messageInfo.isUnordered();
+        int ppid = messageInfo.payloadProtocolID();
+
+        if (src instanceof DirectBuffer)
+            return sendFromNativeBuffer(fd, src, target, assocId,
+                    streamNumber, unordered, ppid);
+
+        /* Substitute a native buffer */
+        int pos = src.position();
+        int lim = src.limit();
+        assert (pos <= lim && streamNumber >= 0);
+
+        int rem = (pos <= lim ? lim - pos : 0);
+        ByteBuffer bb = Util.getTemporaryDirectBuffer(rem);
+        try {
+            bb.put(src);
+            bb.flip();
+            /* Do not update src until we see how many bytes were written */
+            src.position(pos);
+
+            int n = sendFromNativeBuffer(fd, bb, target, assocId,
+                    streamNumber, unordered, ppid);
+            if (n > 0) {
+                /* now update src */
+                src.position(pos + n);
+            }
+            return n;
+        } finally {
+            Util.releaseTemporaryDirectBuffer(bb);
+        }
+    }
+
+    private int sendFromNativeBuffer(int fd,
+                                     ByteBuffer bb,
+                                     SocketAddress target,
+                                     int assocId,
+                                     int streamNumber,
+                                     boolean unordered,
+                                     int ppid)
+            throws IOException {
+        int pos = bb.position();
+        int lim = bb.limit();
+        assert (pos <= lim);
+        int rem = (pos <= lim ? lim - pos : 0);
+
+        int written = send0(fd, ((DirectBuffer)bb).address() + pos,
+                            rem, target, assocId, streamNumber, unordered, ppid);
+        if (written > 0)
+            bb.position(pos + written);
+        return written;
+    }
+
+    @Override
+    public SctpMultiChannel shutdown(Association association)
+            throws IOException {
+        synchronized (stateLock) {
+            checkAssociation(association);
+            if (!isOpen())
+                throw new ClosedChannelException();
+
+            SctpNet.shutdown(fdVal, association.associationID());
+        }
+        return this;
+    }
+
+    @Override
+    public Set<SocketAddress> getAllLocalAddresses()
+            throws IOException {
+        synchronized (stateLock) {
+            if (!isOpen())
+                throw new ClosedChannelException();
+            if (!isBound())
+                return Collections.emptySet();
+
+            return SctpNet.getLocalAddresses(fdVal);
+        }
+    }
+
+    @Override
+    public Set<SocketAddress> getRemoteAddresses(Association association)
+            throws IOException {
+        synchronized (stateLock) {
+            checkAssociation(association);
+            if (!isOpen())
+                throw new ClosedChannelException();
+
+            try {
+                return SctpNet.getRemoteAddresses(fdVal, association.associationID());
+            } catch (SocketException se) {
+                /* a valid association should always have remote addresses */
+                Set<SocketAddress> addrs = associationMap.get(association);
+                return addrs != null ? addrs : Collections.<SocketAddress>emptySet();
+            }
+        }
+    }
+
+    @Override
+    public SctpChannel branch(Association association)
+            throws IOException {
+        synchronized (stateLock) {
+            checkAssociation(association);
+            if (!isOpen())
+                throw new ClosedChannelException();
+
+            FileDescriptor bFd = SctpNet.branch(fdVal,
+                                                association.associationID());
+            /* successfully branched, we can now remove it from assoc list */
+            removeAssociation(association);
+
+            return new SctpChannelImpl(provider(), bFd, association);
+        }
+    }
+
+    /* Use common native implementation shared between
+     * one-to-one and one-to-many */
+    private static int receive0(int fd,
+                                ResultContainer resultContainer,
+                                long address,
+                                int length)
+            throws IOException{
+        return SctpChannelImpl.receive0(fd, resultContainer, address,
+                length, false /*peek */);
+    }
+
+    private static int send0(int fd,
+                             long address,
+                             int length,
+                             SocketAddress target,
+                             int assocId,
+                             int streamNumber,
+                             boolean unordered,
+                             int ppid)
+            throws IOException {
+        return SctpChannelImpl.send0(fd, address, length, target, assocId,
+                streamNumber, unordered, ppid);
+    }
+
+    static {
+        Util.load();   /* loads nio & net native libraries */
+        java.security.AccessController.doPrivileged(
+                new sun.security.action.LoadLibraryAction("sctp"));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/solaris/classes/sun/nio/ch/sctp/SctpNet.java	Mon Feb 13 14:31:32 2012 +0000
@@ -0,0 +1,315 @@
+/*
+ * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package sun.nio.ch.sctp;
+
+import java.io.FileDescriptor;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
+import java.nio.channels.AlreadyBoundException;
+import java.util.Set;
+import java.util.HashSet;
+import java.security.AccessController;
+import sun.security.action.GetPropertyAction;
+import sun.nio.ch.IOUtil;
+import sun.nio.ch.Net;
+import com.sun.nio.sctp.SctpSocketOption;
+import static com.sun.nio.sctp.SctpStandardSocketOptions.*;
+
+public class SctpNet {
+    static final String osName = AccessController.doPrivileged(
+                    new GetPropertyAction("os.name"));
+
+    /* -- Miscellaneous SCTP utilities -- */
+
+    private static boolean IPv4MappedAddresses() {
+        if ("SunOS".equals(osName)) {
+            /* Solaris supports IPv4Mapped Addresses with bindx */
+            return true;
+        } /* else {  //other OS/implementations  */
+
+        /* lksctp/linux requires Ipv4 addresses */
+        return false;
+    }
+
+    static boolean throwAlreadyBoundException() throws IOException {
+        throw new AlreadyBoundException();
+    }
+
+    static void listen(int fd, int backlog) throws IOException {
+        listen0(fd, backlog);
+    }
+
+    static int connect(int fd, InetAddress remote, int remotePort)
+            throws IOException {
+        return connect0(fd, remote, remotePort);
+    }
+
+    static void close(int fd) throws IOException {
+        close0(fd);
+    }
+
+    static void preClose(int fd) throws IOException {
+        preClose0(fd);
+    }
+
+    /**
+     * @param  oneToOne
+     *         if {@code true} returns a one-to-one sctp socket, otherwise
+     *         returns a one-to-many sctp socket
+     */
+    static FileDescriptor socket(boolean oneToOne) throws IOException {
+        int nativefd = socket0(oneToOne);
+        return IOUtil.newFD(nativefd);
+    }
+
+    static void bindx(int fd, InetAddress[] addrs, int port, boolean add)
+            throws IOException {
+        bindx(fd, addrs, port, addrs.length, add,
+                IPv4MappedAddresses());
+    }
+
+    static Set<SocketAddress> getLocalAddresses(int fd)
+            throws IOException {
+        HashSet<SocketAddress> set = null;
+        SocketAddress[] saa = getLocalAddresses0(fd);
+
+        if (saa != null) {
+            set = new HashSet<SocketAddress>(saa.length);
+            for (SocketAddress sa : saa)
+                set.add(sa);
+        }
+
+        return set;
+    }
+
+    static Set<SocketAddress> getRemoteAddresses(int fd, int assocId)
+            throws IOException {
+        HashSet<SocketAddress> set = null;
+        SocketAddress[] saa = getRemoteAddresses0(fd, assocId);
+
+        if (saa != null) {
+            set = new HashSet<SocketAddress>(saa.length);
+            for (SocketAddress sa : saa)
+                set.add(sa);
+        }
+
+        return set;
+    }
+
+    static <T> void setSocketOption(int fd,
+                                    SctpSocketOption<T> name,
+                                    T value,
+                                    int assocId)
+            throws IOException {
+        if (value == null)
+            throw new IllegalArgumentException("Invalid option value");
+
+        if (name.equals(SCTP_INIT_MAXSTREAMS)) {
+            InitMaxStreams maxStreamValue = (InitMaxStreams)value;
+            SctpNet.setInitMsgOption0(fd,
+                 maxStreamValue.maxInStreams(), maxStreamValue.maxOutStreams());
+        } else if (name.equals(SCTP_PRIMARY_ADDR) ||
+                   name.equals(SCTP_SET_PEER_PRIMARY_ADDR)) {
+
+            SocketAddress addr  = (SocketAddress) value;
+            if (addr == null)
+                throw new IllegalArgumentException("Invalid option value");
+
+            Net.checkAddress(addr);
+            InetSocketAddress netAddr = (InetSocketAddress)addr;
+
+            if (name.equals(SCTP_PRIMARY_ADDR)) {
+                setPrimAddrOption0(fd,
+                                   assocId,
+                                   netAddr.getAddress(),
+                                   netAddr.getPort());
+            } else {
+                setPeerPrimAddrOption0(fd,
+                                       assocId,
+                                       netAddr.getAddress(),
+                                       netAddr.getPort(),
+                                       IPv4MappedAddresses());
+            }
+        } else if (name.equals(SCTP_DISABLE_FRAGMENTS) ||
+            name.equals(SCTP_EXPLICIT_COMPLETE) ||
+            name.equals(SCTP_FRAGMENT_INTERLEAVE) ||
+            name.equals(SCTP_NODELAY) ||
+            name.equals(SO_SNDBUF) ||
+            name.equals(SO_RCVBUF) ||
+            name.equals(SO_LINGER)) {
+            setIntOption(fd, name, value);
+        } else {
+            throw new AssertionError("Unknown socket option");
+        }
+    }
+
+    static Object getSocketOption(int fd, SctpSocketOption<?> name, int assocId)
+             throws IOException {
+         if (name.equals(SCTP_SET_PEER_PRIMARY_ADDR)) {
+            throw new IllegalArgumentException(
+                    "SCTP_SET_PEER_PRIMARY_ADDR cannot be retrieved");
+        } else if (name.equals(SCTP_INIT_MAXSTREAMS)) {
+            /* container for holding maxIn/Out streams */
+            int[] values = new int[2];
+            SctpNet.getInitMsgOption0(fd, values);
+            return InitMaxStreams.create(values[0], values[1]);
+        } else if (name.equals(SCTP_PRIMARY_ADDR)) {
+            return getPrimAddrOption0(fd, assocId);
+        } else if (name.equals(SCTP_DISABLE_FRAGMENTS) ||
+            name.equals(SCTP_EXPLICIT_COMPLETE) ||
+            name.equals(SCTP_FRAGMENT_INTERLEAVE) ||
+            name.equals(SCTP_NODELAY) ||
+            name.equals(SO_SNDBUF) ||
+            name.equals(SO_RCVBUF) ||
+            name.equals(SO_LINGER)) {
+            return getIntOption(fd, name);
+        } else {
+            throw new AssertionError("Unknown socket option");
+        }
+    }
+
+    static void setIntOption(int fd, SctpSocketOption<?> name, Object value)
+            throws IOException {
+        if (value == null)
+            throw new IllegalArgumentException("Invalid option value");
+
+        Class<?> type = name.type();
+        if (type != Integer.class && type != Boolean.class)
+            throw new AssertionError("Should not reach here");
+
+        if (name == SO_RCVBUF ||
+            name == SO_SNDBUF)
+        {
+            int i = ((Integer)value).intValue();
+            if (i < 0)
+                throw new IllegalArgumentException(
+                        "Invalid send/receive buffer size");
+        } else if (name == SO_LINGER) {
+            int i = ((Integer)value).intValue();
+            if (i < 0)
+                value = Integer.valueOf(-1);
+            if (i > 65535)
+                value = Integer.valueOf(65535);
+        } else if (name.equals(SCTP_FRAGMENT_INTERLEAVE)) {
+            int i = ((Integer)value).intValue();
+            if (i < 0 || i > 2)
+                throw new IllegalArgumentException(
+                        "Invalid value for SCTP_FRAGMENT_INTERLEAVE");
+        }
+
+        int arg;
+        if (type == Integer.class) {
+            arg = ((Integer)value).intValue();
+        } else {
+            boolean b = ((Boolean)value).booleanValue();
+            arg = (b) ? 1 : 0;
+        }
+
+        setIntOption0(fd, ((SctpStdSocketOption)name).constValue(), arg);
+    }
+
+    static Object getIntOption(int fd, SctpSocketOption<?> name)
+            throws IOException {
+        Class<?> type = name.type();
+
+        if (type != Integer.class && type != Boolean.class)
+            throw new AssertionError("Should not reach here");
+
+        if (!(name instanceof SctpStdSocketOption))
+            throw new AssertionError("Should not reach here");
+
+        int value = getIntOption0(fd,
+                ((SctpStdSocketOption)name).constValue());
+
+        if (type == Integer.class) {
+            return Integer.valueOf(value);
+        } else {
+            return (value == 0) ? Boolean.FALSE : Boolean.TRUE;
+        }
+    }
+
+    static void shutdown(int fd, int assocId)
+            throws IOException {
+        shutdown0(fd, assocId);
+    }
+
+    static FileDescriptor branch(int fd, int assocId) throws IOException {
+        int nativefd = branch0(fd, assocId);
+        return IOUtil.newFD(nativefd);
+    }
+
+    /* Native Methods */
+    static native int socket0(boolean oneToOne) throws IOException;
+
+    static native void listen0(int fd, int backlog) throws IOException;
+
+    static native int connect0(int fd, InetAddress remote, int remotePort)
+        throws IOException;
+
+    static native void close0(int fd) throws IOException;
+
+    static native void preClose0(int fd) throws IOException;
+
+    static native void bindx(int fd, InetAddress[] addrs, int port, int length,
+            boolean add, boolean preferIPv6) throws IOException;
+
+    static native int getIntOption0(int fd, int opt) throws IOException;
+
+    static native void setIntOption0(int fd, int opt, int arg)
+        throws IOException;
+
+    static native SocketAddress[] getLocalAddresses0(int fd) throws IOException;
+
+    static native SocketAddress[] getRemoteAddresses0(int fd, int assocId)
+            throws IOException;
+
+    static native int branch0(int fd, int assocId) throws IOException;
+
+    static native void setPrimAddrOption0(int fd, int assocId, InetAddress ia,
+            int port) throws IOException;
+
+    static native void setPeerPrimAddrOption0(int fd, int assocId,
+            InetAddress ia, int port, boolean preferIPv6) throws IOException;
+
+    static native SocketAddress getPrimAddrOption0(int fd, int assocId)
+            throws IOException;
+
+    /* retVals [0] maxInStreams, [1] maxOutStreams */
+    static native void getInitMsgOption0(int fd, int[] retVals) throws IOException;
+
+    static native void setInitMsgOption0(int fd, int arg1, int arg2)
+            throws IOException;
+
+    static native void shutdown0(int fd, int assocId);
+
+    static native void init();
+
+    static {
+        init();
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/solaris/classes/sun/nio/ch/sctp/SctpNotification.java	Mon Feb 13 14:31:32 2012 +0000
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package sun.nio.ch.sctp;
+
+import com.sun.nio.sctp.Association;
+import com.sun.nio.sctp.Notification;
+
+/**
+ * All Notification implemenations MUST implement this interface to provide
+ * access to the native association identidier.
+ */
+interface SctpNotification extends Notification {
+    int assocId();
+    void setAssociation(Association association);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/solaris/classes/sun/nio/ch/sctp/SctpServerChannelImpl.java	Mon Feb 13 14:31:32 2012 +0000
@@ -0,0 +1,434 @@
+/*
+ * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package sun.nio.ch.sctp;
+
+import java.net.SocketAddress;
+import java.net.InetSocketAddress;
+import java.net.InetAddress;
+import java.io.FileDescriptor;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Set;
+import java.util.HashSet;
+import java.nio.channels.SelectionKey;
+import java.nio.channels.ClosedChannelException;
+import java.nio.channels.NotYetBoundException;
+import java.nio.channels.spi.SelectorProvider;
+import com.sun.nio.sctp.IllegalUnbindException;
+import com.sun.nio.sctp.SctpChannel;
+import com.sun.nio.sctp.SctpServerChannel;
+import com.sun.nio.sctp.SctpSocketOption;
+import com.sun.nio.sctp.SctpStandardSocketOptions;
+import sun.nio.ch.DirectBuffer;
+import sun.nio.ch.NativeThread;
+import sun.nio.ch.IOStatus;
+import sun.nio.ch.IOUtil;
+import sun.nio.ch.Net;
+import sun.nio.ch.PollArrayWrapper;
+import sun.nio.ch.SelChImpl;
+import sun.nio.ch.SelectionKeyImpl;
+import sun.nio.ch.Util;
+
+/**
+ * An implementation of SctpServerChannel
+ */
+public class SctpServerChannelImpl extends SctpServerChannel
+    implements SelChImpl
+{
+    private final FileDescriptor fd;
+
+    private final int fdVal;
+
+    /* IDs of native thread doing accept, for signalling */
+    private volatile long thread = 0;
+
+    /* Lock held by thread currently blocked in this channel */
+    private final Object lock = new Object();
+
+    /* Lock held by any thread that modifies the state fields declared below
+     * DO NOT invoke a blocking I/O operation while holding this lock! */
+    private final Object stateLock = new Object();
+
+    private enum ChannelState {
+        UNINITIALIZED,
+        INUSE,
+        KILLPENDING,
+        KILLED,
+    }
+    /* -- The following fields are protected by stateLock -- */
+    private ChannelState state = ChannelState.UNINITIALIZED;
+
+    /* Binding: Once bound the port will remain constant. */
+    int port = -1;
+    private HashSet<InetSocketAddress> localAddresses = new HashSet<InetSocketAddress>();
+    /* Has the channel been bound to the wildcard address */
+    private boolean wildcard; /* false */
+
+    /* -- End of fields protected by stateLock -- */
+
+    /**
+     * Initializes a new instance of this class.
+     */
+    public SctpServerChannelImpl(SelectorProvider provider)
+            throws IOException {
+        //TODO: update provider remove public modifier
+        super(provider);
+        this.fd = SctpNet.socket(true);
+        this.fdVal = IOUtil.fdVal(fd);
+        this.state = ChannelState.INUSE;
+    }
+
+    @Override
+    public SctpServerChannel bind(SocketAddress local, int backlog)
+            throws IOException {
+        synchronized (lock) {
+            synchronized (stateLock) {
+                if (!isOpen())
+                    throw new ClosedChannelException();
+                if (isBound())
+                    SctpNet.throwAlreadyBoundException();
+
+                InetSocketAddress isa = (local == null) ?
+                    new InetSocketAddress(0) : Net.checkAddress(local);
+                SecurityManager sm = System.getSecurityManager();
+                if (sm != null)
+                    sm.checkListen(isa.getPort());
+                Net.bind(fd, isa.getAddress(), isa.getPort());
+
+                InetSocketAddress boundIsa = Net.localAddress(fd);
+                port = boundIsa.getPort();
+                localAddresses.add(isa);
+                    if (isa.getAddress().isAnyLocalAddress())
+                        wildcard = true;
+
+                SctpNet.listen(fdVal, backlog < 1 ? 50 : backlog);
+            }
+        }
+        return this;
+    }
+
+    @Override
+    public SctpServerChannel bindAddress(InetAddress address)
+            throws IOException {
+        return bindUnbindAddress(address, true);
+    }
+
+    @Override
+    public SctpServerChannel unbindAddress(InetAddress address)
+            throws IOException {
+        return bindUnbindAddress(address, false);
+    }
+
+    private SctpServerChannel bindUnbindAddress(InetAddress address, boolean add)
+            throws IOException {
+        if (address == null)
+            throw new IllegalArgumentException();
+
+        synchronized (lock) {
+            synchronized (stateLock) {
+                if (!isOpen())
+                    throw new ClosedChannelException();
+                if (!isBound())
+                    throw new NotYetBoundException();
+                if (wildcard)
+                    throw new IllegalStateException(
+                            "Cannot add or remove addresses from a channel that is bound to the wildcard address");
+                if (address.isAnyLocalAddress())
+                    throw new IllegalArgumentException(
+                            "Cannot add or remove the wildcard address");
+                if (add) {
+                    for (InetSocketAddress addr : localAddresses) {
+                        if (addr.getAddress().equals(address)) {
+                            SctpNet.throwAlreadyBoundException();
+                        }
+                    }
+                } else { /*removing */
+                    /* Verify that there is more than one address
+                     * and that address is already bound */
+                    if (localAddresses.size() <= 1)
+                        throw new IllegalUnbindException("Cannot remove address from a channel with only one address bound");
+                    boolean foundAddress = false;
+                    for (InetSocketAddress addr : localAddresses) {
+                        if (addr.getAddress().equals(address)) {
+                            foundAddress = true;
+                            break;
+                        }
+                    }
+                    if (!foundAddress )
+                        throw new IllegalUnbindException("Cannot remove address from a channel that is not bound to that address");
+                }
+
+                SctpNet.bindx(fdVal, new InetAddress[]{address}, port, add);
+
+                /* Update our internal Set to reflect the addition/removal */
+                if (add)
+                    localAddresses.add(new InetSocketAddress(address, port));
+                else {
+                    for (InetSocketAddress addr : localAddresses) {
+                        if (addr.getAddress().equals(address)) {
+                            localAddresses.remove(addr);
+                            break;
+                        }
+                    }
+                }
+            }
+        }
+        return this;
+    }
+
+    private boolean isBound() {
+        synchronized (stateLock) {
+            return port == -1 ? false : true;
+        }
+    }
+
+    private void acceptCleanup() throws IOException {
+        synchronized (stateLock) {
+            thread = 0;
+            if (state == ChannelState.KILLPENDING)
+                kill();
+        }
+    }
+
+    @Override
+    public SctpChannel accept() throws IOException {
+        synchronized (lock) {
+            if (!isOpen())
+                throw new ClosedChannelException();
+            if (!isBound())
+                throw new NotYetBoundException();
+            SctpChannel sc = null;
+
+            int n = 0;
+            FileDescriptor newfd = new FileDescriptor();
+            InetSocketAddress[] isaa = new InetSocketAddress[1];
+
+            try {
+                begin();
+                if (!isOpen())
+                    return null;
+                thread = NativeThread.current();
+                for (;;) {
+                    n = accept0(fd, newfd, isaa);
+                    if ((n == IOStatus.INTERRUPTED) && isOpen())
+                        continue;
+                    break;
+                }
+            } finally {
+                acceptCleanup();
+                end(n > 0);
+                assert IOStatus.check(n);
+            }
+
+            if (n < 1)
+                return null;
+
+            IOUtil.configureBlocking(newfd, true);
+            InetSocketAddress isa = isaa[0];
+            sc = new SctpChannelImpl(provider(), newfd);
+
+            SecurityManager sm = System.getSecurityManager();
+            if (sm != null)
+                sm.checkAccept(isa.getAddress().getHostAddress(),
+                               isa.getPort());
+
+            return sc;
+        }
+    }
+
+    @Override
+    protected void implConfigureBlocking(boolean block) throws IOException {
+        IOUtil.configureBlocking(fd, block);
+    }
+
+    @Override
+    public void implCloseSelectableChannel() throws IOException {
+        synchronized (stateLock) {
+            SctpNet.preClose(fdVal);
+            if (thread != 0)
+                NativeThread.signal(thread);
+            if (!isRegistered())
+                kill();
+        }
+    }
+
+    @Override
+    public void kill() throws IOException {
+        synchronized (stateLock) {
+            if (state == ChannelState.KILLED)
+                return;
+            if (state == ChannelState.UNINITIALIZED) {
+                state = ChannelState.KILLED;
+                return;
+            }
+            assert !isOpen() && !isRegistered();
+
+            // Postpone the kill if there is a thread in accept
+            if (thread == 0) {
+                SctpNet.close(fdVal);
+                state = ChannelState.KILLED;
+            } else {
+                state = ChannelState.KILLPENDING;
+            }
+        }
+    }
+
+    @Override
+    public FileDescriptor getFD() {
+        return fd;
+    }
+
+    @Override
+    public int getFDVal() {
+        return fdVal;
+    }
+
+    /**
+     * Translates native poll revent ops into a ready operation ops
+     */
+    private boolean translateReadyOps(int ops, int initialOps,
+                                     SelectionKeyImpl sk) {
+        int intOps = sk.nioInterestOps();
+        int oldOps = sk.nioReadyOps();
+        int newOps = initialOps;
+
+        if ((ops & PollArrayWrapper.POLLNVAL) != 0) {
+            /* This should only happen if this channel is pre-closed while a
+             * selection operation is in progress
+             * ## Throw an error if this channel has not been pre-closed */
+            return false;
+        }
+
+        if ((ops & (PollArrayWrapper.POLLERR
+                    | PollArrayWrapper.POLLHUP)) != 0) {
+            newOps = intOps;
+            sk.nioReadyOps(newOps);
+            return (newOps & ~oldOps) != 0;
+        }
+
+        if (((ops & PollArrayWrapper.POLLIN) != 0) &&
+            ((intOps & SelectionKey.OP_ACCEPT) != 0))
+                newOps |= SelectionKey.OP_ACCEPT;
+
+        sk.nioReadyOps(newOps);
+        return (newOps & ~oldOps) != 0;
+    }
+
+    @Override
+    public boolean translateAndUpdateReadyOps(int ops, SelectionKeyImpl sk) {
+        return translateReadyOps(ops, sk.nioReadyOps(), sk);
+    }
+
+    @Override
+    public boolean translateAndSetReadyOps(int ops, SelectionKeyImpl sk) {
+        return translateReadyOps(ops, 0, sk);
+    }
+
+    @Override
+    public void translateAndSetInterestOps(int ops, SelectionKeyImpl sk) {
+        int newOps = 0;
+
+        /* Translate ops */
+        if ((ops & SelectionKey.OP_ACCEPT) != 0)
+            newOps |= PollArrayWrapper.POLLIN;
+        /* Place ops into pollfd array */
+        sk.selector.putEventOps(sk, newOps);
+
+    }
+
+    @Override
+    public <T> SctpServerChannel setOption(SctpSocketOption<T> name, T value)
+            throws IOException {
+        if (name == null)
+            throw new NullPointerException();
+        if (!supportedOptions().contains(name))
+            throw new UnsupportedOperationException("'" + name + "' not supported");
+
+        synchronized (stateLock) {
+            if (!isOpen())
+                throw new ClosedChannelException();
+
+            SctpNet.setSocketOption(fdVal, name, value, 0 /*oneToOne*/);
+            return this;
+        }
+    }
+
+    @Override
+    @SuppressWarnings("unchecked")
+    public <T> T getOption(SctpSocketOption<T> name) throws IOException {
+        if (name == null)
+            throw new NullPointerException();
+        if (!supportedOptions().contains(name))
+            throw new UnsupportedOperationException("'" + name + "' not supported");
+
+        synchronized (stateLock) {
+            if (!isOpen())
+                throw new ClosedChannelException();
+
+            return (T) SctpNet.getSocketOption(fdVal, name, 0 /*oneToOne*/);
+        }
+    }
+
+    private static class DefaultOptionsHolder {
+        static final Set<SctpSocketOption<?>> defaultOptions = defaultOptions();
+
+        private static Set<SctpSocketOption<?>> defaultOptions() {
+            HashSet<SctpSocketOption<?>> set = new HashSet<SctpSocketOption<?>>(1);
+            set.add(SctpStandardSocketOptions.SCTP_INIT_MAXSTREAMS);
+            return Collections.unmodifiableSet(set);
+        }
+    }
+
+    @Override
+    public final Set<SctpSocketOption<?>> supportedOptions() {
+        return DefaultOptionsHolder.defaultOptions;
+    }
+
+    @Override
+    public Set<SocketAddress> getAllLocalAddresses()
+            throws IOException {
+        synchronized (stateLock) {
+            if (!isOpen())
+                throw new ClosedChannelException();
+            if (!isBound())
+                return Collections.emptySet();
+
+            return SctpNet.getLocalAddresses(fdVal);
+        }
+    }
+
+    /* Native */
+    private static native void initIDs();
+
+    private static native int accept0(FileDescriptor ssfd,
+        FileDescriptor newfd, InetSocketAddress[] isaa) throws IOException;
+
+    static {
+        Util.load();   // loads nio & net native libraries
+        java.security.AccessController.doPrivileged(
+                new sun.security.action.LoadLibraryAction("sctp"));
+        initIDs();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/solaris/classes/sun/nio/ch/sctp/SendFailed.java	Mon Feb 13 14:31:32 2012 +0000
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package sun.nio.ch.sctp;
+
+import java.nio.ByteBuffer;
+import java.net.SocketAddress;
+import com.sun.nio.sctp.Association;
+import com.sun.nio.sctp.SendFailedNotification;
+
+/**
+ * An implementation of SendFailedNotification
+ */
+public class SendFailed extends SendFailedNotification
+    implements SctpNotification
+{
+    private Association association;
+    /* assocId is used to lookup the association before the notification is
+     * returned to user code */
+    private int assocId;
+    private SocketAddress address;
+    private ByteBuffer buffer;
+    private int errorCode;
+    private int streamNumber;
+
+    /* Invoked from native */
+    private SendFailed(int assocId,
+                       SocketAddress address,
+                       ByteBuffer buffer,
+                       int errorCode,
+                       int streamNumber) {
+        this.assocId = assocId;
+        this.errorCode = errorCode;
+        this.streamNumber = streamNumber;
+        this.address = address;
+        this.buffer = buffer;
+    }
+
+    @Override
+    public int assocId() {
+        return assocId;
+    }
+
+    @Override
+    public void setAssociation(Association association) {
+        this.association = association;
+    }
+
+    @Override
+    public Association association() {
+        /* may be null */
+        return association;
+    }
+
+    @Override
+    public SocketAddress address() {
+        assert address != null;
+        return address;
+    }
+
+    @Override
+    public ByteBuffer buffer() {
+        assert buffer != null;
+        return buffer;
+    }
+
+    @Override
+    public int errorCode() {
+        return errorCode;
+    }
+
+    @Override
+    public int streamNumber() {
+        return streamNumber;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append(super.toString()).append(" [");
+        sb.append("Association:").append(association);
+        sb.append(", Address: ").append(address);
+        sb.append(", buffer: ").append(buffer);
+        sb.append(", errorCode: ").append(errorCode);
+        sb.append(", streamNumber: ").append(streamNumber);
+        sb.append("]");
+        return sb.toString();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/solaris/classes/sun/nio/ch/sctp/Shutdown.java	Mon Feb 13 14:31:32 2012 +0000
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package sun.nio.ch.sctp;
+
+import com.sun.nio.sctp.Association;
+import com.sun.nio.sctp.ShutdownNotification;
+
+/**
+ * An implementation of ShutdownNotification
+ */
+public class Shutdown extends ShutdownNotification
+    implements SctpNotification
+{
+    private Association association;
+    /* assocId is used to lookup the association before the notification is
+     * returned to user code */
+    private int assocId;
+
+    /* Invoked from native */
+    private Shutdown(int assocId) {
+        this.assocId = assocId;
+    }
+
+    @Override
+    public int assocId() {
+        return assocId;
+    }
+
+    @Override
+    public void setAssociation(Association association) {
+        this.association = association;
+    }
+
+    @Override
+    public Association association() {
+        assert association != null;
+        return association;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append(super.toString()).append(" [");
+        sb.append("Association:").append(association).append("]");
+        return sb.toString();
+    }
+}
--- a/jdk/src/solaris/doc/sun/man/man1/apt.1	Mon Feb 13 14:26:25 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,153 +0,0 @@
-." Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
-." DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-."
-." This code is free software; you can redistribute it and/or modify it
-." under the terms of the GNU General Public License version 2 only, as
-." published by the Free Software Foundation.
-."
-." This code is distributed in the hope that it will be useful, but WITHOUT
-." ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-." FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-." version 2 for more details (a copy is included in the LICENSE file that
-." accompanied this code).
-."
-." You should have received a copy of the GNU General Public License version
-." 2 along with this work; if not, write to the Free Software Foundation,
-." Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-."
-." Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-." or visit www.oracle.com if you need additional information or have any
-." questions.
-."
-.TH apt 1 "10 May 2011"
-
-.LP
-.SH "NAME"
-.LP
-.LP
-\f2apt\fP \- annotation processing tool
-.LP
-.SH "SYNOPSIS"
-.LP
-.LP
-\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]
-.LP
-.SH "PARAMETERS"
-.LP
-.LP
-Options may be in any order. For a discussion of parameters which apply to a specific option, see OPTIONS below.
-.LP
-.RS 3
-.TP 3
-sourcefiles 
-Zero or more source files to be processed. 
-.TP 3
-@files 
-One or more files that list source files or other options 
-.RE
-
-.LP
-.SH "DESCRIPTION"
-.LP
-.LP
-\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.
-.LP
-.LP
-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.
-.LP
-.LP
-A fuller discussion of how the tool operates as well as instructions for developing with \f2apt\fP are in 
-.na
-\f4Getting Started with \fP\f4apt\fP. @
-.fi
-http://download.oracle.com/javase/7/docs/technotes/guides/apt/GettingStarted.html
-.LP
-.SH "OPTIONS"
-.LP
-.SS 
-apt specific options
-.LP
-.RS 3
-.TP 3
-\-s dir 
-Specify the directory root under which processor\-generated source files will be placed; files are placed in subdirectories based on package namespace. 
-.TP 3
-\-nocompile 
-Do not compile source files to class files. 
-.TP 3
-\-print 
-Print out textual representation of specified types; perform no annotation processing or compilation. 
-.TP 3
-\-A[key[=val]] 
-Options to pass to annotation processors \-\- these are not interpreted by \f2apt\fP directly, but are made available for use by individual processors 
-.TP 3
-\-factorypath path 
-Specify where to find annotation processor factories; if this option is used, the classpath is \f2not\fP searched for factories. 
-.TP 3
-\-factory classname 
-Name of annotation processor factory to use; bypasses default discovery process 
-.TP 3
-\-version 
-Print version information. 
-.TP 3
-\-X 
-Display information about non\-standard options. 
-.RE
-
-.LP
-.SS 
-Options shared with javac
-.LP
-.RS 3
-.TP 3
-\-d dir 
-Specify where to place processor and javac generated class files 
-.TP 3
-\-cp path or \-classpath path 
-Specify where to find user class files and annotation processor factories. If \f2\-factorypath\fP is given, the classpath is not searched for factories. 
-.RE
-
-.LP
-.LP
-Consult the javac(1) man page for information on \f2javac\fP options.
-.LP
-.SS 
-Non\-Standard Options
-.LP
-.RS 3
-.TP 3
-\-XListAnnotationTypes 
-List found annotation types. 
-.TP 3
-\-XListDeclarations 
-List specified and included declarations. 
-.TP 3
-\-XPrintAptRounds 
-Print information about initial and recursive \f2apt\fP rounds. 
-.TP 3
-\-XPrintFactoryInfo 
-Print information about which annotations a factory is asked to process. 
-.TP 3
-\-XclassesAsDecls 
-Treat both class and source files as declarations to process. 
-.RE
-
-.LP
-.LP
-\f3Note\fP: Because these options are non\-standard, they are subject to change without notice.
-.LP
-.SH "NOTES"
-.LP
-.LP
-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.
-.LP
-.SH "SEE ALSO"
-.LP
-.RS 3
-.TP 2
-o
-javac(1), java(1) 
-.RE
-
-.LP
- 
--- a/jdk/src/solaris/doc/sun/man/man1/ja/apt.1	Mon Feb 13 14:26:25 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,153 +0,0 @@
-." Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
-." DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-."
-." This code is free software; you can redistribute it and/or modify it
-." under the terms of the GNU General Public License version 2 only, as
-." published by the Free Software Foundation.
-."
-." This code is distributed in the hope that it will be useful, but WITHOUT
-." ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-." FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-." version 2 for more details (a copy is included in the LICENSE file that
-." accompanied this code).
-."
-." You should have received a copy of the GNU General Public License version
-." 2 along with this work; if not, write to the Free Software Foundation,
-." Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-."
-." Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-." or visit www.oracle.com if you need additional information or have any
-." questions.
-."
-.TH apt 1 "07 May 2011"
-
-.LP
-.SH "NAME"
-.LP
-.LP
-\f2apt\fP \- Ãí¼á½èÍý¥Ä¡¼¥ë
-.LP
-.SH "·Á¼°"
-.LP
-.LP
-\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]
-.LP
-.SH "¥Ñ¥é¥á¡¼¥¿"
-.LP
-.LP
-¥ª¥×¥·¥ç¥ó¤Î»ØÄê½ç½ø¤Ë·è¤Þ¤ê¤Ï¤¢¤ê¤Þ¤»¤ó¡£ÆÃÄê¤Î¥ª¥×¥·¥ç¥ó¤ËŬÍѤµ¤ì¤ë¥Ñ¥é¥á¡¼¥¿¤Ë¤Ä¤¤¤Æ¤Ï¡¢²¼µ­¤Î¡Ö¥ª¥×¥·¥ç¥ó¡×¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£
-.LP
-.RS 3
-.TP 3
-sourcefiles 
-¥¼¥í¡¢1 ¤Ä¡¢¤Þ¤¿¤ÏÊ£¿ô¤Î½èÍýÂоݤΥ½¡¼¥¹¥Õ¥¡¥¤¥ë 
-.TP 3
-@files 
-¥½¡¼¥¹¥Õ¥¡¥¤¥ë¤Þ¤¿¤Ï¾¤Î¥ª¥×¥·¥ç¥ó¤ò°ìÍ÷ɽ¼¨¤¹¤ë 1 ¤Ä¤Þ¤¿¤ÏÊ£¿ô¤Î¥Õ¥¡¥¤¥ë 
-.RE
-
-.LP
-.SH "ÀâÌÀ"
-.LP
-.LP
-\f3Ãí\fP: \f2apt\fP ¥Ä¡¼¥ë¤È¡¢¥Ñ¥Ã¥±¡¼¥¸ \f2com.sun.mirror\fP ¤Ë´Þ¤Þ¤ì¤Æ¤¤¤ë¤½¤ì¤Ë´ØÏ¢¤·¤¿ API ¤Ï¡¢JDK 7 °Ê¹ßÈó¿ä¾©¤Ë¤Ê¤Ã¤Æ¤ª¤ê¡¢JDK ¤Î¼¡¤Î¥á¥¸¥ã¡¼¥ê¥ê¡¼¥¹¤Çºï½ü¤µ¤ì¤ëͽÄê¤Ç¤¹¡£\f2javac(1)\fP ¥Ä¡¼¥ë¤ÇÍøÍѲÄǽ¤Ê¥ª¥×¥·¥ç¥ó¤È¡¢¥Ñ¥Ã¥±¡¼¥¸ \f2javax.annotation.processing\fP ¤ª¤è¤Ó \f2javax.lang.model\fP ¤Ë´Þ¤Þ¤ì¤Æ¤¤¤ë API ¤ò»ÈÍѤ·¤Æ¡¢Ãí¼á¤ò½èÍý¤·¤Æ¤¯¤À¤µ¤¤¡£
-.LP
-.LP
-Ãí¼á½èÍý¥Ä¡¼¥ë \f2apt\fP ¤Ï¡¢¥ê¥Õ¥ì¥¯¥È API ¤È¥µ¥Ý¡¼¥È¥¤¥ó¥Õ¥é¥¹¥È¥é¥¯¥Á¥ã¡¼¤«¤é¹½À®¤µ¤ì¡¢¥×¥í¥°¥é¥àÃí¼á¤ò½èÍý¤·¤Þ¤¹¡£\f2apt\fP ¥ê¥Õ¥ì¥¯¥È API ¤Ï¡¢ ¹½ÃÛ»þ¤Î¥½¡¼¥¹¥Ù¡¼¥¹¤Ç¡¢¥×¥í¥°¥é¥à¹½Â¤¤Ë´Ø¤¹¤ëÆɤ߼è¤êÀìÍѥӥ塼¤òÄ󶡤·¤Þ¤¹¡£¤³¤ì¤é¤Î¥ê¥Õ¥ì¥¯¥È API ¤Ï¡¢Áí¾Î¤òÄɲä·¤¿¸å¤Ë¡¢Java(TM) ¥×¥í¥°¥é¥ß¥ó¥°¸À¸ì¤Î·¿¥·¥¹¥Æ¥à¤òÀµ¤·¤¯¥â¥Ç¥ë²½¤¹¤ë¤è¤¦¤ËÀ߷פµ¤ì¤Æ¤¤¤Þ¤¹¡£ºÇ½é¤Ë¡¢\f2apt\fP ¤Ï¡¢¿·¤·¤¤¥½¡¼¥¹¥³¡¼¥É¤È¾¤Î¥Õ¥¡¥¤¥ë¤òºîÀ®¤¹¤ëÃí¼á¥×¥í¥»¥Ã¥µ¤ò¼Â¹Ô¤·¤Þ¤¹¡£¼¡¤Ë¡¢\f2apt\fP ¤Ï¡¢¸µ¤Î¥½¡¼¥¹¥Õ¥¡¥¤¥ë¤ÈÀ¸À®¤·¤¿¥½¡¼¥¹¥Õ¥¡¥¤¥ë¤ÎξÊý¤ò¥³¥ó¥Ñ¥¤¥ë¤¹¤ë¤¿¤á¡¢³«È¯¤¬³Ú¤Ë¤Ê¤ê¤Þ¤¹¡£¥Ä¡¼¥ë¤È¤Î¥¤¥ó¥¿¥Õ¥§¡¼¥¹¤Ë»ÈÍѤµ¤ì¤ë¥ê¥Õ¥ì¥¯¥È API ¤Ê¤É¤Î API ¤Ï¡¢\f2com.sun.mirror\fP ¤Î¥µ¥Ö¥Ñ¥Ã¥±¡¼¥¸¤Ç¤¹¡£
-.LP
-.LP
-¥Ä¡¼¥ë¤Îµ¡Ç½¤Ë´Ø¤¹¤ë¾ÜºÙ¤È¡¢\f2apt\fP ¤ò»ÈÍѤ·¤¿³«È¯ÊýË¡¤Ë¤Ä¤¤¤Æ¤Ï¡¢
-.na
-\f4¡Öapt ÆþÌç¡×\fP @
-.fi
-http://java.sun.com/javase/6/docs/technotes/guides/apt/GettingStarted.html¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£
-.LP
-.SH "¥ª¥×¥·¥ç¥ó"
-.LP
-.SS 
-apt ¸ÇÍ­¤Î¥ª¥×¥·¥ç¥ó
-.LP
-.RS 3
-.TP 3
-\-s dir 
-¥×¥í¥»¥Ã¥µ¤ÎÀ¸À®¤¹¤ë¥½¡¼¥¹¥Õ¥¡¥¤¥ë¤òÃÖ¤¯¥Ç¥£¥ì¥¯¥È¥ê¥ë¡¼¥È¤ò»ØÄꤷ¤Þ¤¹¡£ ¥Õ¥¡¥¤¥ë¤Ï¡¢¥Ñ¥Ã¥±¡¼¥¸¤Î̾Á°¶õ´Ö¤Ë´ð¤Å¤¤¤Æ¥µ¥Ö¥Ç¥£¥ì¥¯¥È¥ê¤ËÃÖ¤«¤ì¤Þ¤¹¡£ 
-.TP 3
-\-nocompile 
-¥½¡¼¥¹¥Õ¥¡¥¤¥ë¤ò¥¯¥é¥¹¥Õ¥¡¥¤¥ë¤Ë¥³¥ó¥Ñ¥¤¥ë¤·¤Þ¤»¤ó¡£ 
-.TP 3
-\-print 
-»ØÄꤷ¤¿¥¿¥¤¥×¤Î¥Æ¥­¥¹¥Èɽ¸½¤ò½ÐÎϤ·¤Þ¤¹¡£ Ãí¼á½èÍý¤Þ¤¿¤Ï¥³¥ó¥Ñ¥¤¥ë¤Ï¹Ô¤¤¤Þ¤»¤ó¡£ 
-.TP 3
-\-A[key[=val]] 
-Ãí¼á¥×¥í¥»¥Ã¥µ¤ØÅϤ¹¥ª¥×¥·¥ç¥ó¤Ç¤¹¡£ ¤³¤Î¥ª¥×¥·¥ç¥ó¤Ï¡¢\f2apt\fP ¤¬Ä¾Àܲò¼á¤¹¤ë¤Î¤Ç¤Ï¤Ê¤¯¡¢¤½¤ì¤¾¤ì¤Î¥×¥í¥»¥Ã¥µ¤Ë¤è¤Ã¤Æ»ÈÍѤǤ­¤ë¤è¤¦¤ËÊѤ¨¤é¤ì¤Þ¤¹¡£ 
-.TP 3
-\-factorypath path 
-Ãí¼á¥×¥í¥»¥Ã¥µ¥Õ¥¡¥¯¥È¥ê¤ò¸¡º÷¤¹¤ë¾ì½ê¤ò»ØÄꤷ¤Þ¤¹¡£ ¤³¤Î¥ª¥×¥·¥ç¥ó¤ò»ÈÍѤ¹¤ë¾ì¹ç¡¢¥¯¥é¥¹¥Ñ¥¹¤Î¥Õ¥¡¥¯¥È¥ê¤Ï¸¡º÷¤µ¤ì¤Þ¤»¤ó¡£ 
-.TP 3
-\-factory classname 
-»ÈÍѤ¹¤ëÃí¼á¥×¥í¥»¥Ã¥µ¥Õ¥¡¥¯¥È¥ê¤Î̾Á°¤Ç¤¹¡£ ¥Ç¥Õ¥©¥ë¥È¤Î¸¡½Ð¥×¥í¥»¥¹¤ò¾Êά¤·¤Þ¤¹¡£ 
-.TP 3
-\-version 
-¥Ð¡¼¥¸¥ç¥ó¾ðÊó¤ò½ÐÎϤ·¤Þ¤¹¡£ 
-.TP 3
-\-X 
-Èóɸ½à¥ª¥×¥·¥ç¥ó¤Ë´Ø¤¹¤ë¾ðÊó¤òɽ¼¨¤·¤Þ¤¹¡£ 
-.RE
-
-.LP
-.SS 
-javac ¤È¶¦ÍѤ¹¤ë¥ª¥×¥·¥ç¥ó
-.LP
-.RS 3
-.TP 3
-\-d dir 
-¥×¥í¥»¥Ã¥µ¤È javac À¸À®¤Î¥¯¥é¥¹¥Õ¥¡¥¤¥ë¤òÃÖ¤¯¾ì½ê¤ò»ØÄꤷ¤Þ¤¹¡£ 
-.TP 3
-\-cp path ¤Þ¤¿¤Ï \-classpath path 
-¥æ¡¼¥¶¡¼¥¯¥é¥¹¥Õ¥¡¥¤¥ë¤ÈÃí¼á¥×¥í¥»¥Ã¥µ¥Õ¥¡¥¯¥È¥ê¤ò¸¡º÷¤¹¤ë¾ì½ê¤ò»ØÄꤷ¤Þ¤¹¡£\f2\-factorypath\fP ¤¬»ØÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¡¢¥¯¥é¥¹¥Ñ¥¹¤Î¥Õ¥¡¥¯¥È¥ê¤Ï¸¡º÷¤µ¤ì¤Þ¤»¤ó¡£ 
-.RE
-
-.LP
-.LP
-\f2javac\fP ¥ª¥×¥·¥ç¥ó¤Î¾ÜºÙ¤Ë¤Ä¤¤¤Æ¤Ï¡¢javac(1) ¤Î¥Þ¥Ë¥å¥¢¥ë¥Ú¡¼¥¸¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£
-.LP
-.SS 
-Èóɸ½à¥ª¥×¥·¥ç¥ó
-.LP
-.RS 3
-.TP 3
-\-XListAnnotationTypes 
-Ãí¼á¤Î·¿¤Ë¸¡½Ð¤µ¤ì¤ë¥ê¥¹¥È. 
-.TP 3
-\-XListDeclarations 
-»ØÄꤪ¤è¤ÓÀë¸À¤¬¥¤¥ó¥¯¥ë¡¼¥É¤µ¤ì¤ë¥ê¥¹¥È. 
-.TP 3
-\-XPrintAptRounds 
-½é´ü¤ª¤è¤ÓºÆµ¢Åª¤Ê \f2apt\fP ¥é¥¦¥ó¥É¤Ë´Ø¤¹¤ë¾ðÊó¤ò½ÐÎϤ¹¤ë. 
-.TP 3
-\-XPrintFactoryInfo 
-½èÍý¤òÍ׵᤹¤ë¥Õ¥¡¥¯¥È¥ê¤ÎÃí¼á¤Ë´Ø¤¹¤ë¾ðÊó¤ò½ÐÎϤ¹¤ë. 
-.TP 3
-\-XclassesAsDecls 
-¥¯¥é¥¹¥Õ¥¡¥¤¥ë¤È¥½¡¼¥¹¥Õ¥¡¥¤¥ë¤ÎξÊý¤ò¡¢½èÍýÂоݤÎÀë¸À¤È¤·¤Æ½èÍý¤·¤Þ¤¹¡£ 
-.RE
-
-.LP
-.LP
-\f3Ãí\fP: ¤³¤ì¤é¤ÏÈóɸ½à¥ª¥×¥·¥ç¥ó¤Ê¤Î¤Ç¡¢Í½¹ð¤Ê¤¯Êѹ¹¤µ¤ì¤ë²ÄǽÀ­¤¬¤¢¤ê¤Þ¤¹¡£
-.LP
-.SH "Ãí"
-.LP
-.LP
-\f2apt\fP ¥Ä¡¼¥ë¤È¡¢¥Ñ¥Ã¥±¡¼¥¸ \f2com.sun.mirror\fP ¤Ë´Þ¤Þ¤ì¤Æ¤¤¤ë¤½¤ì¤Ë´ØÏ¢¤·¤¿ API ¤Ï¡¢JDK 7 °Ê¹ßÈó¿ä¾©¤Ë¤Ê¤Ã¤Æ¤ª¤ê¡¢JDK ¤Î¼¡¤Î¥á¥¸¥ã¡¼¥ê¥ê¡¼¥¹¤Çºï½ü¤µ¤ì¤ëͽÄê¤Ç¤¹¡£\f2javac(1)\fP ¥Ä¡¼¥ë¤ÇÍøÍѲÄǽ¤Ê¥ª¥×¥·¥ç¥ó¤È¡¢¥Ñ¥Ã¥±¡¼¥¸ \f2javax.annotation.processing\fP ¤ª¤è¤Ó \f2javax.lang.model\fP ¤Ë´Þ¤Þ¤ì¤Æ¤¤¤ë API ¤ò»ÈÍѤ·¤Æ¡¢Ãí¼á¤ò½èÍý¤·¤Æ¤¯¤À¤µ¤¤¡£
-.LP
-.SH "´ØÏ¢¹àÌÜ"
-.LP
-.RS 3
-.TP 2
-o
-javac(1), java(1) 
-.RE
-
-.LP
- 
--- a/jdk/src/solaris/native/java/lang/java_props_md.c	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/solaris/native/java/lang/java_props_md.c	Mon Feb 13 14:31:32 2012 +0000
@@ -310,7 +310,7 @@
 }
 
 #ifdef JAVASE_EMBEDDED
-/* Determine the default embedded toolkit based on whether lib/xawt/
+/* Determine the default embedded toolkit based on whether libawt_xawt
  * exists in the JRE. This can still be overridden by -Dawt.toolkit=XXX
  */
 static char* getEmbeddedToolkit() {
@@ -325,8 +325,8 @@
     realpath((char *)dlinfo.dli_fname, buf);
     len = strlen(buf);
     p = strrchr(buf, '/');
-    /* Default AWT Toolkit on Linux and Solaris is XAWT. */
-    strncpy(p, "/xawt/", MAXPATHLEN-len-1);
+    /* Default AWT Toolkit on Linux and Solaris is XAWT (libawt_xawt.so). */
+    strncpy(p, "/libawt_xawt.so", MAXPATHLEN-len-1);
     /* Check if it exists */
     if (stat(buf, &statbuf) == -1 && errno == ENOENT) {
         /* No - this is a reduced-headless-jre so use special HToolkit */
--- a/jdk/src/solaris/native/sun/awt/awt_LoadLibrary.c	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/solaris/native/sun/awt/awt_LoadLibrary.c	Mon Feb 13 14:31:32 2012 +0000
@@ -105,7 +105,7 @@
 
     /*
      * The code below is responsible for:
-     * 1. Loading appropriate awt library, i.e. xawt/libmawt or headless/libwawt
+     * 1. Loading appropriate awt library, i.e. libawt_xawt or libawt_headless
      * 2. Setting "awt.toolkit" system property to use the appropriate Java toolkit class,
      *    (if user has specified the toolkit in env varialble)
      */
@@ -130,10 +130,10 @@
 
     /* Calculate library name to load */
     if (AWTIsHeadless()) {
-        strncpy(p, "/headless/libmawt.so", MAXPATHLEN-len-1);
+        strncpy(p, "/libawt_headless.so", MAXPATHLEN-len-1);
     } else {
         /* Default AWT Toolkit on Linux and Solaris is XAWT. */
-        strncpy(p, "/xawt/libmawt.so", MAXPATHLEN-len-1);
+        strncpy(p, "/libawt_xawt.so", MAXPATHLEN-len-1);
     }
 
     if (toolkit) {
@@ -161,7 +161,7 @@
 /*
  * This entry point must remain in libawt.so as part of a contract
  * with the CDE variant of Java Media Framework. (sdtjmplay)
- * Reflect this call over to the correct libmawt.so.
+ * Reflect this call over to the correct libawt_<toolkit>.so.
  */
 JNIEXPORT void JNICALL
 Java_sun_awt_motif_XsessionWMcommand(JNIEnv *env, jobject this,
@@ -191,7 +191,7 @@
 /*
  * This entry point must remain in libawt.so as part of a contract
  * with the CDE variant of Java Media Framework. (sdtjmplay)
- * Reflect this call over to the correct libmawt.so.
+ * Reflect this call over to the correct libawt_<toolkit>.so.
  */
 JNIEXPORT void JNICALL
 Java_sun_awt_motif_XsessionWMcommand_New(JNIEnv *env, jobjectArray jargv)
@@ -250,7 +250,7 @@
 
 /*
  * These entry point must remain in libawt.so ***for Java Plugin ONLY***
- * Reflect this call over to the correct libmawt.so.
+ * Reflect this call over to the correct libawt_<toolkit>.so.
  */
 
 REFLECT_VOID_FUNCTION(getAwtLockFunctions,
--- a/jdk/src/solaris/native/sun/nio/ch/Sctp.h	Mon Feb 13 14:26:25 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,334 +0,0 @@
-/*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#ifndef SUN_NIO_CH_SCTP_H
-#define SUN_NIO_CH_SCTP_H
-
-#ifdef __solaris__
-
-#define _XPG4_2
-#define __EXTENSIONS__
-#include <sys/socket.h>
-#include <netinet/sctp.h>
-#include "jni.h"
-
-/* Current Solaris headers don't comply with draft rfc */
-#ifndef SCTP_EOF
-#define SCTP_EOF MSG_EOF
-#endif
-
-#ifndef SCTP_UNORDERED
-#define SCTP_UNORDERED MSG_UNORDERED
-#endif
-
-/* The current version of the socket API extension shipped with Solaris does
- * not define the following options that the Java API (optionally) supports */
-#ifndef SCTP_EXPLICIT_EOR
-#define SCTP_EXPLICIT_EOR -1
-#endif
-#ifndef SCTP_FRAGMENT_INTERLEAVE
-#define SCTP_FRAGMENT_INTERLEAVE -1
-#endif
-#ifndef SCTP_SET_PEER_PRIMARY_ADDR
-#define SCTP_SET_PEER_PRIMARY_ADDR -1
-#endif
-
-/* Function types to support dynamic linking of socket API extension functions
- * for SCTP. This is so that there is no linkage depandancy during build or
- * runtime for libsctp.*/
-typedef int sctp_getladdrs_func(int sock, sctp_assoc_t id, void **addrs);
-typedef int sctp_freeladdrs_func(void* addrs);
-typedef int sctp_getpaddrs_func(int sock, sctp_assoc_t id, void **addrs);
-typedef int sctp_freepaddrs_func(void *addrs);
-typedef int sctp_bindx_func(int sock, void *addrs, int addrcnt, int flags);
-typedef int sctp_peeloff_func(int sock, sctp_assoc_t id);
-
-
-
-#else /* __linux__ */
-#include <stdint.h>
-#include <linux/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include "jni.h"
-
-//Causes compiler error if not found, should make warning and uncomment
-/*#include <netinet/sctp.h>*/
-
-#ifndef IPPROTO_SCTP
-#define IPPROTO_SCTP    132
-#endif
-
-/* The current version of lksctp does
- * not define the following option that the Java API (optionally) supports */
-#ifndef SCTP_EXPLICIT_EOR
-#define SCTP_EXPLICIT_EOR -1
-#endif
-
-/* Definitions taken from lksctp-tools-1.0.8/src/include/netinet/sctp.h */
-#ifndef SCTP_INITMSG
-
-enum sctp_optname {
-        SCTP_RTOINFO,
-#define SCTP_RTOINFO SCTP_RTOINFO
-        SCTP_ASSOCINFO,
-#define SCTP_ASSOCINFO SCTP_ASSOCINFO
-        SCTP_INITMSG,
-#define SCTP_INITMSG SCTP_INITMSG
-        SCTP_NODELAY,   /* Get/set nodelay option. */
-#define SCTP_NODELAY    SCTP_NODELAY
-        SCTP_AUTOCLOSE,
-#define SCTP_AUTOCLOSE SCTP_AUTOCLOSE
-        SCTP_SET_PEER_PRIMARY_ADDR,
-#define SCTP_SET_PEER_PRIMARY_ADDR SCTP_SET_PEER_PRIMARY_ADDR
-        SCTP_PRIMARY_ADDR,
-#define SCTP_PRIMARY_ADDR SCTP_PRIMARY_ADDR
-        SCTP_ADAPTATION_LAYER,
-#define SCTP_ADAPTATION_LAYER SCTP_ADAPTATION_LAYER
-        SCTP_DISABLE_FRAGMENTS,
-#define SCTP_DISABLE_FRAGMENTS SCTP_DISABLE_FRAGMENTS
-        SCTP_PEER_ADDR_PARAMS,
-#define SCTP_PEER_ADDR_PARAMS SCTP_PEER_ADDR_PARAMS
-        SCTP_DEFAULT_SEND_PARAM,
-#define SCTP_DEFAULT_SEND_PARAM SCTP_DEFAULT_SEND_PARAM
-        SCTP_EVENTS,
-#define SCTP_EVENTS SCTP_EVENTS
-        SCTP_I_WANT_MAPPED_V4_ADDR,  /* Turn on/off mapped v4 addresses  */
-#define SCTP_I_WANT_MAPPED_V4_ADDR SCTP_I_WANT_MAPPED_V4_ADDR
-        SCTP_MAXSEG,    /* Get/set maximum fragment. */
-#define SCTP_MAXSEG     SCTP_MAXSEG
-        SCTP_STATUS,
-#define SCTP_STATUS SCTP_STATUS
-        SCTP_GET_PEER_ADDR_INFO,
-#define SCTP_GET_PEER_ADDR_INFO SCTP_GET_PEER_ADDR_INFO
-        SCTP_DELAYED_ACK_TIME,
-#define SCTP_DELAYED_ACK_TIME SCTP_DELAYED_ACK_TIME
-        SCTP_CONTEXT,   /* Receive Context */
-#define SCTP_CONTEXT SCTP_CONTEXT
-        SCTP_FRAGMENT_INTERLEAVE,
-#define SCTP_FRAGMENT_INTERLEAVE SCTP_FRAGMENT_INTERLEAVE
-        SCTP_PARTIAL_DELIVERY_POINT,    /* Set/Get partial delivery point */
-#define SCTP_PARTIAL_DELIVERY_POINT SCTP_PARTIAL_DELIVERY_POINT
-        SCTP_MAX_BURST,         /* Set/Get max burst */
-#define SCTP_MAX_BURST SCTP_MAX_BURST
-};
-
-enum sctp_sac_state {
-        SCTP_COMM_UP,
-        SCTP_COMM_LOST,
-        SCTP_RESTART,
-        SCTP_SHUTDOWN_COMP,
-        SCTP_CANT_STR_ASSOC,
-};
-
-enum sctp_spc_state {
-        SCTP_ADDR_AVAILABLE,
-        SCTP_ADDR_UNREACHABLE,
-        SCTP_ADDR_REMOVED,
-        SCTP_ADDR_ADDED,
-        SCTP_ADDR_MADE_PRIM,
-        SCTP_ADDR_CONFIRMED,
-};
-
-enum sctp_sinfo_flags {
-        SCTP_UNORDERED = 1,  /* Send/receive message unordered. */
-        SCTP_ADDR_OVER = 2,  /* Override the primary destination. */
-        SCTP_ABORT=4,        /* Send an ABORT message to the peer. */
-        SCTP_EOF=MSG_FIN,    /* Initiate graceful shutdown process. */
-};
-
-enum sctp_sn_type {
-        SCTP_SN_TYPE_BASE     = (1<<15),
-        SCTP_ASSOC_CHANGE,
-        SCTP_PEER_ADDR_CHANGE,
-        SCTP_SEND_FAILED,
-        SCTP_REMOTE_ERROR,
-        SCTP_SHUTDOWN_EVENT,
-        SCTP_PARTIAL_DELIVERY_EVENT,
-        SCTP_ADAPTATION_INDICATION,
-};
-
-typedef enum sctp_cmsg_type {
-        SCTP_INIT,              /* 5.2.1 SCTP Initiation Structure */
-#define SCTP_INIT SCTP_INIT
-        SCTP_SNDRCV,            /* 5.2.2 SCTP Header Information Structure */
-#define SCTP_SNDRCV SCTP_SNDRCV
-} sctp_cmsg_t;
-
-enum sctp_msg_flags {
-        MSG_NOTIFICATION = 0x8000,
-#define MSG_NOTIFICATION MSG_NOTIFICATION
-};
-
-#define SCTP_BINDX_ADD_ADDR 0x01
-#define SCTP_BINDX_REM_ADDR 0x02
-
-typedef __s32 sctp_assoc_t;
-
-struct sctp_initmsg {
-        __u16 sinit_num_ostreams;
-        __u16 sinit_max_instreams;
-        __u16 sinit_max_attempts;
-        __u16 sinit_max_init_timeo;
-};
-
-struct sctp_sndrcvinfo {
-        __u16 sinfo_stream;
-        __u16 sinfo_ssn;
-        __u16 sinfo_flags;
-        __u32 sinfo_ppid;
-        __u32 sinfo_context;
-        __u32 sinfo_timetolive;
-        __u32 sinfo_tsn;
-        __u32 sinfo_cumtsn;
-        sctp_assoc_t sinfo_assoc_id;
-};
-
-struct sctp_event_subscribe {
-        __u8 sctp_data_io_event;
-        __u8 sctp_association_event;
-        __u8 sctp_address_event;
-        __u8 sctp_send_failure_event;
-        __u8 sctp_peer_error_event;
-        __u8 sctp_shutdown_event;
-        __u8 sctp_partial_delivery_event;
-        __u8 sctp_adaptation_layer_event;
-};
-
-struct sctp_send_failed {
-        __u16 ssf_type;
-        __u16 ssf_flags;
-        __u32 ssf_length;
-        __u32 ssf_error;
-        struct sctp_sndrcvinfo ssf_info;
-        sctp_assoc_t ssf_assoc_id;
-        __u8 ssf_data[0];
-};
-
-struct sctp_assoc_change {
-        __u16 sac_type;
-        __u16 sac_flags;
-        __u32 sac_length;
-        __u16 sac_state;
-        __u16 sac_error;
-        __u16 sac_outbound_streams;
-        __u16 sac_inbound_streams;
-        sctp_assoc_t sac_assoc_id;
-        __u8 sac_info[0];
-};
-
-struct sctp_shutdown_event {
-        __u16 sse_type;
-        __u16 sse_flags;
-        __u32 sse_length;
-        sctp_assoc_t sse_assoc_id;
-};
-
-struct sctp_paddr_change {
-        __u16 spc_type;
-        __u16 spc_flags;
-        __u32 spc_length;
-        struct sockaddr_storage spc_aaddr;
-        int spc_state;
-        int spc_error;
-        sctp_assoc_t spc_assoc_id;
-} __attribute__((packed, aligned(4)));
-
-struct sctp_remote_error {
-        __u16 sre_type;
-        __u16 sre_flags;
-        __u32 sre_length;
-        __u16 sre_error;
-        sctp_assoc_t sre_assoc_id;
-        __u8 sre_data[0];
-};
-
-struct sctp_adaptation_event {
-        __u16 sai_type;
-        __u16 sai_flags;
-        __u32 sai_length;
-        __u32 sai_adaptation_ind;
-        sctp_assoc_t sai_assoc_id;
-};
-
-struct sctp_setprim {
-        sctp_assoc_t            ssp_assoc_id;
-        struct sockaddr_storage ssp_addr;
-} __attribute__((packed, aligned(4)));
-
-struct sctp_setpeerprim {
-        sctp_assoc_t            sspp_assoc_id;
-        struct sockaddr_storage sspp_addr;
-} __attribute__((packed, aligned(4)));
-
-
-struct sctp_pdapi_event {
-        __u16 pdapi_type;
-        __u16 pdapi_flags;
-        __u32 pdapi_length;
-        __u32 pdapi_indication;
-        sctp_assoc_t pdapi_assoc_id;
-};
-
-union sctp_notification {
-        struct {
-                __u16 sn_type;             /* Notification type. */
-                __u16 sn_flags;
-                __u32 sn_length;
-        } sn_header;
-        struct sctp_assoc_change sn_assoc_change;
-        struct sctp_paddr_change sn_paddr_change;
-        struct sctp_remote_error sn_remote_error;
-        struct sctp_send_failed sn_send_failed;
-        struct sctp_shutdown_event sn_shutdown_event;
-        struct sctp_adaptation_event sn_adaptation_event;
-        struct sctp_pdapi_event sn_pdapi_event;
-};
-
-#endif /* SCTP_INITMSG */
-
-/* Function types to support dynamic linking of socket API extension functions
- * for SCTP. This is so that there is no linkage depandancy during build or
- * runtime for libsctp.*/
-typedef int sctp_getladdrs_func(int sd, sctp_assoc_t id, struct sockaddr **addrs);
-typedef int sctp_freeladdrs_func(struct sockaddr *addrs);
-typedef int sctp_getpaddrs_func(int sd, sctp_assoc_t id, struct sockaddr **addrs);
-typedef int sctp_freepaddrs_func(struct sockaddr *addrs);
-typedef int sctp_bindx_func(int sd, struct sockaddr *addrs, int addrcnt, int flags);
-typedef int sctp_peeloff_func(int sock, sctp_assoc_t id);
-
-
-#endif /* __linux__ */
-
-sctp_getladdrs_func* nio_sctp_getladdrs;
-sctp_freeladdrs_func* nio_sctp_freeladdrs;
-sctp_getpaddrs_func* nio_sctp_getpaddrs;
-sctp_freepaddrs_func* nio_sctp_freepaddrs;
-sctp_bindx_func* nio_sctp_bindx;
-sctp_peeloff_func* nio_sctp_peeloff;
-
-jboolean loadSocketExtensionFuncs(JNIEnv* env);
-
-#endif /* !SUN_NIO_CH_SCTP_H */
--- a/jdk/src/solaris/native/sun/nio/ch/SctpChannelImpl.c	Mon Feb 13 14:26:25 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,594 +0,0 @@
-/*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include "Sctp.h"
-
-#include "jni.h"
-#include "nio_util.h"
-#include "nio.h"
-#include "net_util.h"
-#include "net_util_md.h"
-#include "sun_nio_ch_SctpNet.h"
-#include "sun_nio_ch_SctpChannelImpl.h"
-#include "sun_nio_ch_SctpAssocChange.h"
-#include "sun_nio_ch_SctpResultContainer.h"
-#include "sun_nio_ch_SctpPeerAddrChange.h"
-
-/* sizeof(union sctp_notification */
-#define NOTIFICATION_BUFFER_SIZE 280
-
-#define MESSAGE_IMPL_CLASS              "sun/nio/ch/SctpMessageInfoImpl"
-#define RESULT_CONTAINER_CLASS          "sun/nio/ch/SctpResultContainer"
-#define SEND_FAILED_CLASS               "sun/nio/ch/SctpSendFailed"
-#define ASSOC_CHANGE_CLASS              "sun/nio/ch/SctpAssocChange"
-#define PEER_CHANGE_CLASS               "sun/nio/ch/SctpPeerAddrChange"
-#define SHUTDOWN_CLASS                  "sun/nio/ch/SctpShutdown"
-
-struct controlData {
-    int assocId;
-    unsigned short streamNumber;
-    jboolean unordered;
-    unsigned int ppid;
-};
-
-static jclass    smi_class;    /* sun.nio.ch.SctpMessageInfoImpl            */
-static jmethodID smi_ctrID;    /* sun.nio.ch.SctpMessageInfoImpl.<init>     */
-static jfieldID  src_valueID;  /* sun.nio.ch.SctpResultContainer.value      */
-static jfieldID  src_typeID;   /* sun.nio.ch.SctpResultContainer.type       */
-static jclass    ssf_class;    /* sun.nio.ch.SctpSendFailed                 */
-static jmethodID ssf_ctrID;    /* sun.nio.ch.SctpSendFailed.<init>          */
-static jclass    sac_class;    /* sun.nio.ch.SctpAssociationChanged         */
-static jmethodID sac_ctrID;    /* sun.nio.ch.SctpAssociationChanged.<init>  */
-static jclass    spc_class;    /* sun.nio.ch.SctpPeerAddressChanged         */
-static jmethodID spc_ctrID;    /* sun.nio.ch.SctpPeerAddressChanged.<init>  */
-static jclass    ss_class;     /* sun.nio.ch.SctpShutdown                   */
-static jmethodID ss_ctrID;     /* sun.nio.ch.SctpShutdown.<init>            */
-static jfieldID  isa_addrID;   /* java.net.InetSocketAddress.addr           */
-static jfieldID  isa_portID;   /* java.net.InetSocketAddress.port           */
-
-/* defined in SctpNet.c */
-jobject SockAddrToInetSocketAddress(JNIEnv* env, struct sockaddr* addr);
-
-/* use SocketChannelImpl's checkConnect implementation */
-extern jint Java_sun_nio_ch_SocketChannelImpl_checkConnect(JNIEnv* env,
-    jobject this, jobject fdo, jboolean block, jboolean ready);
-
-/*
- * Class:     sun_nio_ch_SctpChannelImpl
- * Method:    initIDs
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_sun_nio_ch_SctpChannelImpl_initIDs
-  (JNIEnv *env, jclass klass) {
-    jclass cls;
-
-    /* SctpMessageInfoImpl */
-    cls = (*env)->FindClass(env, MESSAGE_IMPL_CLASS);
-    CHECK_NULL(cls);
-    smi_class = (*env)->NewGlobalRef(env, cls);
-    CHECK_NULL(smi_class);
-    smi_ctrID = (*env)->GetMethodID(env, cls, "<init>",
-            "(ILjava/net/SocketAddress;IIZZI)V");
-    CHECK_NULL(smi_ctrID);
-
-    /* SctpResultContainer */
-    cls = (*env)->FindClass(env, RESULT_CONTAINER_CLASS);
-    CHECK_NULL(cls);
-    src_valueID = (*env)->GetFieldID(env, cls, "value", "Ljava/lang/Object;");
-    CHECK_NULL(src_valueID);
-    src_typeID = (*env)->GetFieldID(env, cls, "type", "I");
-    CHECK_NULL(src_typeID);
-
-    /* SctpSendFailed */
-    cls = (*env)->FindClass(env, SEND_FAILED_CLASS);
-    CHECK_NULL(cls);
-    ssf_class = (*env)->NewGlobalRef(env, cls);
-    CHECK_NULL(ssf_class);
-    ssf_ctrID = (*env)->GetMethodID(env, cls, "<init>",
-        "(ILjava/net/SocketAddress;Ljava/nio/ByteBuffer;II)V");
-    CHECK_NULL(ssf_ctrID);
-
-    /* SctpAssocChange */
-    cls = (*env)->FindClass(env, ASSOC_CHANGE_CLASS);
-    CHECK_NULL(cls);
-    sac_class = (*env)->NewGlobalRef(env, cls);
-    CHECK_NULL(sac_class);
-    sac_ctrID = (*env)->GetMethodID(env, cls, "<init>", "(IIII)V");
-    CHECK_NULL(sac_ctrID);
-
-    /* SctpPeerAddrChange */
-    cls = (*env)->FindClass(env, PEER_CHANGE_CLASS);
-    CHECK_NULL(cls);
-    spc_class = (*env)->NewGlobalRef(env, cls);
-    CHECK_NULL(spc_class);
-    spc_ctrID = (*env)->GetMethodID(env, cls, "<init>",
-            "(ILjava/net/SocketAddress;I)V");
-    CHECK_NULL(spc_ctrID);
-
-    /* sun.nio.ch.SctpShutdown */
-    cls = (*env)->FindClass(env, SHUTDOWN_CLASS);
-    CHECK_NULL(cls);
-    ss_class = (*env)->NewGlobalRef(env, cls);
-    CHECK_NULL(ss_class);
-    ss_ctrID = (*env)->GetMethodID(env, cls, "<init>", "(I)V");
-    CHECK_NULL(ss_ctrID);
-
-    /* InetSocketAddress */
-    cls = (*env)->FindClass(env, "java/net/InetSocketAddress");
-    CHECK_NULL(cls);
-    isa_addrID = (*env)->GetFieldID(env, cls, "addr", "Ljava/net/InetAddress;");
-    CHECK_NULL(isa_addrID);
-    isa_portID = (*env)->GetFieldID(env, cls, "port", "I");
-}
-
-void getControlData
-  (struct msghdr* msg, struct controlData* cdata) {
-    struct cmsghdr* cmsg;
-
-    for (cmsg = CMSG_FIRSTHDR(msg); cmsg != NULL; cmsg = CMSG_NXTHDR(msg, cmsg)) {
-        if (cmsg->cmsg_level == IPPROTO_SCTP && cmsg->cmsg_type == SCTP_SNDRCV) {
-            struct sctp_sndrcvinfo *sri;
-
-            sri = (struct sctp_sndrcvinfo *) CMSG_DATA(cmsg);
-            cdata->assocId = sri->sinfo_assoc_id;
-            cdata->streamNumber = sri->sinfo_stream;
-            cdata->unordered = (sri->sinfo_flags & SCTP_UNORDERED) ? JNI_TRUE :
-                JNI_FALSE;
-            cdata->ppid = ntohl(sri->sinfo_ppid);
-
-            return;
-        }
-    }
-    return;
-}
-
-void setControlData
-  (struct msghdr* msg, struct controlData* cdata) {
-    struct cmsghdr* cmsg;
-    struct sctp_sndrcvinfo *sri;
-
-    cmsg = CMSG_FIRSTHDR(msg);
-    cmsg->cmsg_level = IPPROTO_SCTP;
-    cmsg->cmsg_type = SCTP_SNDRCV;
-    cmsg->cmsg_len = CMSG_LEN(sizeof(struct sctp_sndrcvinfo));
-
-    /* Initialize the payload */
-    sri = (struct sctp_sndrcvinfo*) CMSG_DATA(cmsg);
-    memset(sri, 0, sizeof (*sri));
-
-    if (cdata->streamNumber > 0) {
-        sri->sinfo_stream = cdata->streamNumber;
-    }
-    if (cdata->assocId > 0) {
-        sri->sinfo_assoc_id = cdata->assocId;
-    }
-    if (cdata->unordered == JNI_TRUE) {
-        sri->sinfo_flags = sri->sinfo_flags | SCTP_UNORDERED;
-    }
-
-    if (cdata->ppid > 0) {
-        sri->sinfo_ppid = htonl(cdata->ppid);
-    }
-
-    /* Sum of the length of all control messages in the buffer. */
-    msg->msg_controllen = cmsg->cmsg_len;
-}
-
-// TODO: test: can create send failed without any data? if so need to
-// update API so that buffer can be null if no data.
-void handleSendFailed
-  (JNIEnv* env, int fd, jobject resultContainerObj, struct sctp_send_failed *ssf,
-   int read, jboolean isEOR, struct sockaddr* sap) {
-    jobject bufferObj = NULL, resultObj, isaObj;
-    char *addressP;
-    struct sctp_sndrcvinfo *sri;
-    int remaining, dataLength;
-
-    /* the actual undelivered message data is directly after the ssf */
-    int dataOffset = sizeof(struct sctp_send_failed);
-
-    sri = (struct sctp_sndrcvinfo*) &ssf->ssf_info;
-
-    /* the number of bytes remaining to be read in the sctp_send_failed notif*/
-    remaining = ssf->ssf_length - read;
-
-    /* the size of the actual undelivered message */
-    dataLength = ssf->ssf_length - dataOffset;
-
-    /* retrieved address from sockaddr */
-    isaObj = SockAddrToInetSocketAddress(env, sap);
-
-    /* data retrieved from sff_data */
-    if (dataLength > 0) {
-        struct iovec iov[1];
-        struct msghdr msg[1];
-        int rv, alreadyRead;
-        char *dataP = (char*) ssf;
-        dataP += dataOffset;
-
-        if ((addressP = malloc(dataLength)) == NULL) {
-            JNU_ThrowOutOfMemoryError(env, "handleSendFailed");
-            return;
-        }
-
-        memset(msg, 0, sizeof (*msg));
-        msg->msg_iov = iov;
-        msg->msg_iovlen = 1;
-
-        bufferObj = (*env)->NewDirectByteBuffer(env, addressP, dataLength);
-        CHECK_NULL(bufferObj);
-
-        alreadyRead = read - dataOffset;
-        if (alreadyRead > 0) {
-            memcpy(addressP, /*ssf->ssf_data*/ dataP, alreadyRead);
-            iov->iov_base = addressP + alreadyRead;
-            iov->iov_len = dataLength - alreadyRead;
-        } else {
-            iov->iov_base = addressP;
-            iov->iov_len = dataLength;
-        }
-
-        if (remaining > 0) {
-            if ((rv = recvmsg(fd, msg, 0)) < 0) {
-                handleSocketError(env, errno);
-                return;
-            }
-
-            if (rv != (dataLength - alreadyRead) || !(msg->msg_flags & MSG_EOR)) {
-                //TODO: assert false: "should not reach here";
-                return;
-            }
-            // TODO: Set and document (in API) buffers position.
-        }
-    }
-
-    /* create SctpSendFailed */
-    resultObj = (*env)->NewObject(env, ssf_class, ssf_ctrID, ssf->ssf_assoc_id,
-            isaObj, bufferObj, ssf->ssf_error, sri->sinfo_stream);
-    CHECK_NULL(resultObj);
-    (*env)->SetObjectField(env, resultContainerObj, src_valueID, resultObj);
-    (*env)->SetIntField(env, resultContainerObj, src_typeID,
-            sun_nio_ch_SctpResultContainer_SEND_FAILED);
-}
-
-void handleAssocChange
-  (JNIEnv* env, jobject resultContainerObj, struct sctp_assoc_change *sac) {
-    jobject resultObj;
-    int state = 0;
-
-    switch (sac->sac_state) {
-        case SCTP_COMM_UP :
-            state = sun_nio_ch_SctpAssocChange_SCTP_COMM_UP;
-            break;
-        case SCTP_COMM_LOST :
-            state = sun_nio_ch_SctpAssocChange_SCTP_COMM_LOST;
-            break;
-        case SCTP_RESTART :
-            state = sun_nio_ch_SctpAssocChange_SCTP_RESTART;
-            break;
-        case SCTP_SHUTDOWN_COMP :
-            state = sun_nio_ch_SctpAssocChange_SCTP_SHUTDOWN;
-            break;
-        case SCTP_CANT_STR_ASSOC :
-            state = sun_nio_ch_SctpAssocChange_SCTP_CANT_START;
-    }
-
-    /* create SctpAssociationChanged */
-    resultObj = (*env)->NewObject(env, sac_class, sac_ctrID, sac->sac_assoc_id,
-        state, sac->sac_outbound_streams, sac->sac_inbound_streams);
-    CHECK_NULL(resultObj);
-    (*env)->SetObjectField(env, resultContainerObj, src_valueID, resultObj);
-    (*env)->SetIntField(env, resultContainerObj, src_typeID,
-            sun_nio_ch_SctpResultContainer_ASSOCIATION_CHANGED);
-}
-
-void handleShutdown
-  (JNIEnv* env, jobject resultContainerObj, struct sctp_shutdown_event* sse) {
-    /* create SctpShutdown */
-    jobject resultObj = (*env)->NewObject(env, ss_class, ss_ctrID, sse->sse_assoc_id);
-    CHECK_NULL(resultObj);
-    (*env)->SetObjectField(env, resultContainerObj, src_valueID, resultObj);
-    (*env)->SetIntField(env, resultContainerObj, src_typeID,
-            sun_nio_ch_SctpResultContainer_SHUTDOWN);
-}
-
-void handlePeerAddrChange
-  (JNIEnv* env, jobject resultContainerObj, struct sctp_paddr_change* spc) {
-    int event = 0;
-    jobject addressObj, resultObj;
-    unsigned int state = spc->spc_state;
-
-    switch (state) {
-        case SCTP_ADDR_AVAILABLE :
-            event = sun_nio_ch_SctpPeerAddrChange_SCTP_ADDR_AVAILABLE;
-            break;
-        case SCTP_ADDR_UNREACHABLE :
-            event = sun_nio_ch_SctpPeerAddrChange_SCTP_ADDR_UNREACHABLE;
-            break;
-        case SCTP_ADDR_REMOVED :
-            event = sun_nio_ch_SctpPeerAddrChange_SCTP_ADDR_REMOVED;
-            break;
-        case SCTP_ADDR_ADDED :
-            event = sun_nio_ch_SctpPeerAddrChange_SCTP_ADDR_ADDED;
-            break;
-        case SCTP_ADDR_MADE_PRIM :
-            event = sun_nio_ch_SctpPeerAddrChange_SCTP_ADDR_MADE_PRIM;
-#ifdef __linux__  /* Solaris currently doesn't support SCTP_ADDR_CONFIRMED */
-            break;
-        case SCTP_ADDR_CONFIRMED :
-            event = sun_nio_ch_SctpPeerAddrChange_SCTP_ADDR_CONFIRMED;
-#endif  /* __linux__ */
-    }
-
-    addressObj = SockAddrToInetSocketAddress(env, (struct sockaddr*)&spc->spc_aaddr);
-
-    /* create SctpPeerAddressChanged */
-    resultObj = (*env)->NewObject(env, spc_class, spc_ctrID, spc->spc_assoc_id,
-            addressObj, event);
-    CHECK_NULL(resultObj);
-    (*env)->SetObjectField(env, resultContainerObj, src_valueID, resultObj);
-    (*env)->SetIntField(env, resultContainerObj, src_typeID,
-            sun_nio_ch_SctpResultContainer_PEER_ADDRESS_CHANGED);
-}
-
-void handleUninteresting
-  (union sctp_notification *snp) {
-    //fprintf(stdout,"\nNative: handleUninterestingNotification: Receive notification type [%u]", snp->sn_header.sn_type);
-}
-
-/**
- * Handle notifications from the SCTP stack.
- * Returns JNI_TRUE if the notification is one that is of interest to the
- * Java API, otherwise JNI_FALSE.
- */
-jboolean handleNotification
-  (JNIEnv* env, int fd, jobject resultContainerObj, union sctp_notification* snp,
-   int read, jboolean isEOR, struct sockaddr* sap) {
-    switch (snp->sn_header.sn_type) {
-        case SCTP_SEND_FAILED:
-            handleSendFailed(env, fd, resultContainerObj, &snp->sn_send_failed,
-                    read, isEOR, sap);
-            return JNI_TRUE;
-        case SCTP_ASSOC_CHANGE:
-            handleAssocChange(env, resultContainerObj, &snp->sn_assoc_change);
-            return JNI_TRUE;
-        case SCTP_SHUTDOWN_EVENT:
-            handleShutdown(env, resultContainerObj, &snp->sn_shutdown_event);
-            return JNI_TRUE;
-        case SCTP_PEER_ADDR_CHANGE:
-            handlePeerAddrChange(env, resultContainerObj, &snp->sn_paddr_change);
-            return JNI_TRUE;
-        default :
-            /* the Java API is not interested in this event, maybe we are? */
-            handleUninteresting(snp);
-    }
-    return JNI_FALSE;
-}
-
-void handleMessage
-  (JNIEnv* env, jobject resultContainerObj, struct msghdr* msg,int read,
-   jboolean isEOR, struct sockaddr* sap) {
-    jobject isa, resultObj;
-    struct controlData cdata[1];
-
-    if (read == 0) {
-        /* we reached EOF */
-        read = -1;
-    }
-
-    isa = SockAddrToInetSocketAddress(env, sap);
-    getControlData(msg, cdata);
-
-    /* create SctpMessageInfoImpl */
-    resultObj = (*env)->NewObject(env, smi_class, smi_ctrID, cdata->assocId,
-                                  isa, read, cdata->streamNumber,
-                                  isEOR ? JNI_TRUE : JNI_FALSE,
-                                  cdata->unordered, cdata->ppid);
-    CHECK_NULL(resultObj);
-    (*env)->SetObjectField(env, resultContainerObj, src_valueID, resultObj);
-    (*env)->SetIntField(env, resultContainerObj, src_typeID,
-                        sun_nio_ch_SctpResultContainer_MESSAGE);
-}
-
-/*
- * Class:     sun_nio_ch_SctpChannelImpl
- * Method:    receive0
- * Signature: (ILsun/nio/ch/SctpResultContainer;JIZ)I
- */
-JNIEXPORT jint JNICALL Java_sun_nio_ch_SctpChannelImpl_receive0
-  (JNIEnv *env, jclass klass, jint fd, jobject resultContainerObj,
-   jlong address, jint length, jboolean peek) {
-    SOCKADDR sa;
-    int sa_len = sizeof(sa);
-    ssize_t rv = 0;
-    jlong *addr = jlong_to_ptr(address);
-    struct iovec iov[1];
-    struct msghdr msg[1];
-    char cbuf[CMSG_SPACE(sizeof (struct sctp_sndrcvinfo))];
-    int flags = peek == JNI_TRUE ? MSG_PEEK : 0;
-
-    /* Set up the msghdr structure for receiving */
-    memset(msg, 0, sizeof (*msg));
-    msg->msg_name = &sa;
-    msg->msg_namelen = sa_len;
-    iov->iov_base = addr;
-    iov->iov_len = length;
-    msg->msg_iov = iov;
-    msg->msg_iovlen = 1;
-    msg->msg_control = cbuf;
-    msg->msg_controllen = sizeof(cbuf);
-    msg->msg_flags = 0;
-
-    do {
-        if ((rv = recvmsg(fd, msg, flags)) < 0) {
-            if (errno == EWOULDBLOCK) {
-                return IOS_UNAVAILABLE;
-            } else if (errno == EINTR) {
-                return IOS_INTERRUPTED;
-
-#ifdef __linux__
-            } else if (errno == ENOTCONN) {
-                /* ENOTCONN when EOF reached */
-                rv = 0;
-                /* there will be no control data */
-                msg->msg_controllen = 0;
-#endif /* __linux__ */
-
-            } else {
-                handleSocketError(env, errno);
-                return 0;
-            }
-        }
-
-        if (msg->msg_flags & MSG_NOTIFICATION) {
-            char *bufp = (char*)addr;
-            union sctp_notification *snp;
-
-            if (!(msg->msg_flags & MSG_EOR) && length < NOTIFICATION_BUFFER_SIZE) {
-                char buf[NOTIFICATION_BUFFER_SIZE];
-                int rvSAVE = rv;
-                memcpy(buf, addr, rv);
-                iov->iov_base = buf + rv;
-                iov->iov_len = NOTIFICATION_BUFFER_SIZE - rv;
-                if ((rv = recvmsg(fd, msg, flags)) < 0) {
-                    handleSocketError(env, errno);
-                    return 0;
-                }
-                bufp = buf;
-                rv += rvSAVE;
-            }
-            snp = (union sctp_notification *) bufp;
-            if (handleNotification(env, fd, resultContainerObj, snp, rv,
-                                   (msg->msg_flags & MSG_EOR),
-                                   (struct sockaddr*)&sa ) == JNI_TRUE) {
-                /* We have received a notification that is of interest to
-                   to the Java API. The appropriate notification will be
-                   set in the result container. */
-                return 0;
-            }
-
-            // set iov back to addr, and reset msg_controllen
-            iov->iov_base = addr;
-            iov->iov_len = length;
-            msg->msg_control = cbuf;
-            msg->msg_controllen = sizeof(cbuf);
-        }
-    } while (msg->msg_flags & MSG_NOTIFICATION);
-
-    handleMessage(env, resultContainerObj, msg, rv,
-            (msg->msg_flags & MSG_EOR), (struct sockaddr*)&sa);
-    return rv;
-}
-
-/*
- * Class:     sun_nio_ch_SctpChannelImpl
- * Method:    send0
- * Signature: (IJILjava/net/SocketAddress;IIZI)I
- */
-JNIEXPORT jint JNICALL Java_sun_nio_ch_SctpChannelImpl_send0
-  (JNIEnv *env, jclass klass, jint fd, jlong address, jint length,
-   jobject saTarget, jint assocId, jint streamNumber, jboolean unordered,
-   jint ppid) {
-    SOCKADDR sa;
-    int sa_len = sizeof(sa);
-    ssize_t rv = 0;
-    jlong *addr = jlong_to_ptr(address);
-    struct iovec iov[1];
-    struct msghdr msg[1];
-    int cbuf_size = CMSG_SPACE(sizeof (struct sctp_sndrcvinfo));
-    char cbuf[CMSG_SPACE(sizeof (struct sctp_sndrcvinfo))];
-    struct controlData cdata[1];
-
-    /* SctpChannel:
-     *    saTarget may contain the preferred address or NULL to use primary,
-     *    assocId will always be -1
-     * SctpMultiChannell:
-     *    Setup new association, saTarget will contain address, assocId = -1
-     *    Association already existing, assocId != -1, saTarget = preferred addr
-     */
-    if (saTarget != NULL /*&& assocId <= 0*/) {
-
-        jobject targetAddress = (*env)->GetObjectField(env, saTarget, isa_addrID);
-        jint targetPort = (*env)->GetIntField(env, saTarget, isa_portID);
-
-        if (NET_InetAddressToSockaddr(env, targetAddress, targetPort,
-                                      (struct sockaddr *)&sa,
-                                      &sa_len, JNI_TRUE) != 0) {
-            return IOS_THROWN;
-        }
-    } else {
-        memset(&sa, '\x0', sa_len);
-        sa_len = 0;
-    }
-
-    /* Set up the msghdr structure for sending */
-    memset(msg, 0, sizeof (*msg));
-    memset(cbuf, 0, cbuf_size);
-    msg->msg_name = &sa;
-    msg->msg_namelen = sa_len;
-    iov->iov_base = addr;
-    iov->iov_len = length;
-    msg->msg_iov = iov;
-    msg->msg_iovlen = 1;
-    msg->msg_control = cbuf;
-    msg->msg_controllen = cbuf_size;
-    msg->msg_flags = 0;
-
-    cdata->streamNumber = streamNumber;
-    cdata->assocId = assocId;
-    cdata->unordered = unordered;
-    cdata->ppid = ppid;
-    setControlData(msg, cdata);
-
-    if ((rv = sendmsg(fd, msg, 0)) < 0) {
-        if (errno == EWOULDBLOCK) {
-            return IOS_UNAVAILABLE;
-        } else if (errno == EINTR) {
-            return IOS_INTERRUPTED;
-        } else if (errno == EPIPE) {
-            JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
-                            "Socket is shutdown for writing");
-        } else {
-            handleSocketError(env, errno);
-            return 0;
-        }
-    }
-
-    return rv;
-}
-
-/*
- * Class:     sun_nio_ch_SctpChannelImpl
- * Method:    checkConnect
- * Signature: (Ljava/io/FileDescriptor;ZZ)I
- */
-JNIEXPORT jint JNICALL Java_sun_nio_ch_SctpChannelImpl_checkConnect
-  (JNIEnv* env, jobject this, jobject fdo, jboolean block, jboolean ready) {
-    return Java_sun_nio_ch_SocketChannelImpl_checkConnect(env, this,
-                                                          fdo, block, ready);
-}
-
--- a/jdk/src/solaris/native/sun/nio/ch/SctpNet.c	Mon Feb 13 14:26:25 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,753 +0,0 @@
-/*
- * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <dlfcn.h>
-
-#include "Sctp.h"
-#include "jni.h"
-#include "jni_util.h"
-#include "nio_util.h"
-#include "nio.h"
-#include "net_util.h"
-#include "net_util_md.h"
-#include "sun_nio_ch_SctpNet.h"
-#include "sun_nio_ch_SctpStdSocketOption.h"
-
-static jclass isaCls = 0;
-static jmethodID isaCtrID = 0;
-
-static const char* nativeSctpLib = "libsctp.so.1";
-static jboolean funcsLoaded = JNI_FALSE;
-
-JNIEXPORT jint JNICALL JNI_OnLoad
-  (JavaVM *vm, void *reserved) {
-    return JNI_VERSION_1_2;
-}
-
-static int preCloseFD = -1;     /* File descriptor to which we dup other fd's
-                                   before closing them for real */
-
-/**
- * Loads the native sctp library that contains the socket extension
- * functions, as well as locating the individual functions.
- * There will be a pending exception if this method returns false.
- */
-jboolean loadSocketExtensionFuncs
-  (JNIEnv* env) {
-    if (dlopen(nativeSctpLib, RTLD_GLOBAL | RTLD_LAZY) == NULL) {
-        JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
-              dlerror());
-        return JNI_FALSE;
-    }
-
-    if ((nio_sctp_getladdrs = (sctp_getladdrs_func*)
-            dlsym(RTLD_DEFAULT, "sctp_getladdrs")) == NULL) {
-        JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
-              dlerror());
-        return JNI_FALSE;
-    }
-
-    if ((nio_sctp_freeladdrs = (sctp_freeladdrs_func*)
-            dlsym(RTLD_DEFAULT, "sctp_freeladdrs")) == NULL) {
-        JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
-              dlerror());
-        return JNI_FALSE;
-    }
-
-    if ((nio_sctp_getpaddrs = (sctp_getpaddrs_func*)
-            dlsym(RTLD_DEFAULT, "sctp_getpaddrs")) == NULL) {
-        JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
-              dlerror());
-        return JNI_FALSE;
-    }
-
-    if ((nio_sctp_freepaddrs = (sctp_freepaddrs_func*)
-            dlsym(RTLD_DEFAULT, "sctp_freepaddrs")) == NULL) {
-        JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
-              dlerror());
-        return JNI_FALSE;
-    }
-
-    if ((nio_sctp_bindx = (sctp_bindx_func*)
-            dlsym(RTLD_DEFAULT, "sctp_bindx")) == NULL) {
-        JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
-              dlerror());
-        return JNI_FALSE;
-    }
-
-    if ((nio_sctp_peeloff = (sctp_peeloff_func*)
-            dlsym(RTLD_DEFAULT, "sctp_peeloff")) == NULL) {
-        JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
-              dlerror());
-        return JNI_FALSE;
-    }
-
-    funcsLoaded = JNI_TRUE;
-    return JNI_TRUE;
-}
-
-jint
-handleSocketError(JNIEnv *env, jint errorValue)
-{
-    char *xn;
-    switch (errorValue) {
-        case EINPROGRESS:     /* Non-blocking connect */
-            return 0;
-        case EPROTO:
-            xn= JNU_JAVANETPKG "ProtocolException";
-            break;
-        case ECONNREFUSED:
-            xn = JNU_JAVANETPKG "ConnectException";
-            break;
-        case ETIMEDOUT:
-            xn = JNU_JAVANETPKG "ConnectException";
-            break;
-        case EHOSTUNREACH:
-            xn = JNU_JAVANETPKG "NoRouteToHostException";
-            break;
-        case EADDRINUSE:  /* Fall through */
-        case EADDRNOTAVAIL:
-            xn = JNU_JAVANETPKG "BindException";
-            break;
-        default:
-            xn = JNU_JAVANETPKG "SocketException";
-            break;
-    }
-    errno = errorValue;
-    JNU_ThrowByNameWithLastError(env, xn, "NioSocketError");
-    return IOS_THROWN;
-}
-
-/*
- * Class:     sun_nio_ch_SctpNet
- * Method:    init
- * Signature: ()V
- */
-JNIEXPORT void JNICALL
-Java_sun_nio_ch_SctpNet_init
-  (JNIEnv *env, jclass cl) {
-    int sp[2];
-    if (socketpair(PF_UNIX, SOCK_STREAM, 0, sp) < 0) {
-        JNU_ThrowIOExceptionWithLastError(env, "socketpair failed");
-        return;
-    }
-    preCloseFD = sp[0];
-    close(sp[1]);
-}
-
-/*
- * Class:     sun_nio_ch_SctpNet
- * Method:    socket0
- * Signature: (Z)I
- */
-JNIEXPORT jint JNICALL Java_sun_nio_ch_SctpNet_socket0
-  (JNIEnv *env, jclass klass, jboolean oneToOne) {
-    int fd;
-    struct sctp_event_subscribe event;
-#ifdef AF_INET6
-    int domain = ipv6_available() ? AF_INET6 : AF_INET;
-#else
-    int domain = AF_INET;
-#endif
-
-    /* Try to load the socket API extension functions */
-    if (!funcsLoaded && !loadSocketExtensionFuncs(env)) {
-        return 0;
-    }
-
-    fd = socket(domain, (oneToOne ? SOCK_STREAM : SOCK_SEQPACKET), IPPROTO_SCTP);
-
-    if (fd < 0) {
-        return handleSocketError(env, errno);
-    }
-
-    /* Enable events */
-    memset(&event, 0, sizeof(event));
-    event.sctp_data_io_event = 1;
-    event.sctp_association_event = 1;
-    event.sctp_address_event = 1;
-    event.sctp_send_failure_event = 1;
-    //event.sctp_peer_error_event = 1;
-    event.sctp_shutdown_event = 1;
-    //event.sctp_partial_delivery_event = 1;
-    //event.sctp_adaptation_layer_event = 1;
-    if (setsockopt(fd, IPPROTO_SCTP, SCTP_EVENTS, &event, sizeof(event)) != 0) {
-       handleSocketError(env, errno);
-    }
-    return fd;
-}
-
-/*
- * Class:     sun_nio_ch_SctpNet
- * Method:    bindx
- * Signature: (I[Ljava/net/InetAddress;IIZ)V
- */
-JNIEXPORT void JNICALL Java_sun_nio_ch_SctpNet_bindx
-  (JNIEnv *env, jclass klass, jint fd, jobjectArray addrs, jint port,
-   jint addrsLength, jboolean add, jboolean preferIPv6) {
-    SOCKADDR *sap, *tmpSap;
-    int i, sa_len = sizeof(SOCKADDR);
-    jobject ia;
-
-    if (addrsLength < 1)
-        return;
-
-    if ((sap = calloc(addrsLength,  sa_len)) == NULL) {
-          JNU_ThrowOutOfMemoryError(env, "heap allocation failure");
-        return;
-    }
-
-    tmpSap = sap;
-    for (i=0; i<addrsLength; i++) {
-        ia = (*env)->GetObjectArrayElement(env, addrs, i);
-        if (NET_InetAddressToSockaddr(env, ia, port, (struct sockaddr*)tmpSap,
-                                      &sa_len, preferIPv6) != 0) {
-            free(sap);
-            return;
-        }
-        tmpSap++;
-    }
-
-    if (nio_sctp_bindx(fd, (void*)sap, addrsLength, add ? SCTP_BINDX_ADD_ADDR :
-                       SCTP_BINDX_REM_ADDR) != 0) {
-        handleSocketError(env, errno);
-    }
-
-    free(sap);
-}
-
-/*
- * Class:     sun_nio_ch_SctpNet
- * Method:    listen0
- * Signature: (II)V
- */
-JNIEXPORT void JNICALL
-Java_sun_nio_ch_SctpNet_listen0
-  (JNIEnv *env, jclass cl, jint fd, jint backlog) {
-    if (listen(fd, backlog) < 0)
-        handleSocketError(env, errno);
-}
-
-/*
- * Class:     sun_nio_ch_SctpNet
- * Method:    connect0
- * Signature: (ILjava/net/InetAddress;I)I
- */
-JNIEXPORT jint JNICALL
-Java_sun_nio_ch_SctpNet_connect0
-  (JNIEnv *env, jclass clazz, int fd, jobject iao, jint port) {
-    SOCKADDR sa;
-    int sa_len = SOCKADDR_LEN;
-    int rv;
-
-    if (NET_InetAddressToSockaddr(env, iao, port, (struct sockaddr *) &sa,
-                                  &sa_len, JNI_TRUE) != 0) {
-        return IOS_THROWN;
-    }
-
-    rv = connect(fd, (struct sockaddr *)&sa, sa_len);
-    if (rv != 0) {
-        if (errno == EINPROGRESS) {
-            return IOS_UNAVAILABLE;
-        } else if (errno == EINTR) {
-            return IOS_INTERRUPTED;
-        }
-        return handleSocketError(env, errno);
-    }
-    return 1;
-}
-
-/*
- * Class:     sun_nio_ch_SctpNet
- * Method:    close0
- * Signature: (I)V
- */
-JNIEXPORT void JNICALL
-Java_sun_nio_ch_SctpNet_close0
-  (JNIEnv *env, jclass clazz, jint fd) {
-    if (fd != -1) {
-        int rv = close(fd);
-        if (rv < 0)
-            JNU_ThrowIOExceptionWithLastError(env, "Close failed");
-    }
-}
-
-/*
- * Class:     sun_nio_ch_SctpNet
- * Method:    preClose0
- * Signature: (I)V
- */
-JNIEXPORT void JNICALL
-Java_sun_nio_ch_SctpNet_preClose0
-  (JNIEnv *env, jclass clazz, jint fd) {
-    if (preCloseFD >= 0) {
-        if (dup2(preCloseFD, fd) < 0)
-            JNU_ThrowIOExceptionWithLastError(env, "dup2 failed");
-    }
-}
-
-void initializeISA
-  (JNIEnv* env) {
-    if (isaCls == 0) {
-        jclass c = (*env)->FindClass(env, "java/net/InetSocketAddress");
-        CHECK_NULL(c);
-        isaCls = (*env)->NewGlobalRef(env, c);
-        CHECK_NULL(isaCls);
-        (*env)->DeleteLocalRef(env, c);
-        isaCtrID = (*env)->GetMethodID(env, isaCls, "<init>",
-                                     "(Ljava/net/InetAddress;I)V");
-    }
-}
-
-jobject SockAddrToInetSocketAddress
-  (JNIEnv *env, struct sockaddr* sap) {
-    int port = 0;
-
-    jobject ia = NET_SockaddrToInetAddress(env, sap, &port);
-    if (ia == NULL)
-        return NULL;
-
-    if (isaCls == 0) {
-        initializeISA(env);
-        CHECK_NULL_RETURN(isaCls, NULL);
-    }
-
-    return (*env)->NewObject(env, isaCls, isaCtrID, ia, port);
-}
-
-/*
- * Class:     sun_nio_ch_SctpNet
- * Method:    getLocalAddresses0
- * Signature: (I)[Ljava/net/SocketAddress;
- */
-JNIEXPORT jobjectArray JNICALL Java_sun_nio_ch_SctpNet_getLocalAddresses0
-  (JNIEnv *env, jclass klass, jint fd) {
-    void *addr_buf, *laddr;
-    struct sockaddr* sap;
-    int i, addrCount;
-    jobjectArray isaa;
-
-#ifdef __solaris__
-    if ((addrCount = nio_sctp_getladdrs(fd, 0, (void **)&addr_buf)) == -1) {
-#else /* __linux__ */
-    if ((addrCount = nio_sctp_getladdrs(fd, 0, (struct sockaddr **)&addr_buf)) == -1) {
-#endif
-        handleSocketError(env, errno);
-        return NULL;
-    }
-
-    if (addrCount < 1)
-        return NULL;
-
-    if (isaCls == 0) {
-        initializeISA(env);
-        CHECK_NULL_RETURN(isaCls, NULL);
-    }
-
-    isaa = (*env)->NewObjectArray(env, addrCount, isaCls, NULL);
-    if (isaa == NULL) {
-        nio_sctp_freeladdrs(addr_buf);
-        return NULL;
-    }
-
-    laddr = addr_buf;
-    for (i=0; i<addrCount; i++) {
-        int port = 0;
-        jobject isa = NULL, ia;
-        sap = (struct sockaddr*)addr_buf;
-        ia = NET_SockaddrToInetAddress(env, sap, &port);
-        if (ia != NULL)
-            isa = (*env)->NewObject(env, isaCls, isaCtrID, ia, port);
-        if (isa != NULL)
-            (*env)->SetObjectArrayElement(env, isaa, i, isa);
-
-        if (sap->sa_family == AF_INET)
-            addr_buf = ((struct sockaddr_in*)addr_buf) + 1;
-        else
-            addr_buf = ((struct sockaddr_in6*)addr_buf) + 1;
-    }
-
-    nio_sctp_freeladdrs(laddr);
-    return isaa;
-}
-
-jobjectArray getRemoteAddresses
-  (JNIEnv *env, jint fd, sctp_assoc_t id) {
-    void *addr_buf, *paddr;
-    struct sockaddr* sap;
-    int i, addrCount;
-    jobjectArray isaa;
-
-#if __solaris__
-    if ((addrCount = nio_sctp_getpaddrs(fd, id, (void **)&addr_buf)) == -1) {
-#else /* __linux__ */
-    if ((addrCount = nio_sctp_getpaddrs(fd, id, (struct sockaddr**)&addr_buf)) == -1) {
-#endif
-        handleSocketError(env, errno);
-        return NULL;
-    }
-
-    if (addrCount < 1)
-        return NULL;
-
-    if (isaCls == 0) {
-        initializeISA(env);
-        CHECK_NULL_RETURN(isaCls, NULL);
-    }
-
-    isaa = (*env)->NewObjectArray(env, addrCount, isaCls, NULL);
-    if (isaa == NULL) {
-        nio_sctp_freepaddrs(addr_buf);
-        return NULL;
-    }
-
-    paddr = addr_buf;
-    for (i=0; i<addrCount; i++) {
-        jobject ia, isa = NULL;
-        int port;
-        sap = (struct sockaddr*)addr_buf;
-        ia = NET_SockaddrToInetAddress(env, sap, &port);
-        if (ia != NULL)
-            isa = (*env)->NewObject(env, isaCls, isaCtrID, ia, port);
-        if (isa != NULL)
-            (*env)->SetObjectArrayElement(env, isaa, i, isa);
-
-        if (sap->sa_family == AF_INET)
-            addr_buf = ((struct sockaddr_in*)addr_buf) + 1;
-        else
-            addr_buf = ((struct sockaddr_in6*)addr_buf) + 1;
-    }
-
-    nio_sctp_freepaddrs(paddr);
-
-    return isaa;
-}
-
- /*
- * Class:     sun_nio_ch_SctpNet
- * Method:    getRemoteAddresses0
- * Signature: (II)[Ljava/net/SocketAddress;
- */
-JNIEXPORT jobjectArray JNICALL Java_sun_nio_ch_SctpNet_getRemoteAddresses0
-  (JNIEnv *env, jclass klass, jint fd, jint assocId) {
-    return getRemoteAddresses(env, fd, assocId);
-}
-
-/* Map the Java level option to the native level */
-int mapSocketOption
-  (jint cmd, int *level, int *optname) {
-    static struct {
-        jint cmd;
-        int level;
-        int optname;
-    } const opts[] = {
-        { sun_nio_ch_SctpStdSocketOption_SCTP_DISABLE_FRAGMENTS,   IPPROTO_SCTP, SCTP_DISABLE_FRAGMENTS },
-        { sun_nio_ch_SctpStdSocketOption_SCTP_EXPLICIT_COMPLETE,   IPPROTO_SCTP, SCTP_EXPLICIT_EOR },
-        { sun_nio_ch_SctpStdSocketOption_SCTP_FRAGMENT_INTERLEAVE, IPPROTO_SCTP, SCTP_FRAGMENT_INTERLEAVE },
-        { sun_nio_ch_SctpStdSocketOption_SCTP_NODELAY,             IPPROTO_SCTP, SCTP_NODELAY },
-        { sun_nio_ch_SctpStdSocketOption_SO_SNDBUF,                SOL_SOCKET,   SO_SNDBUF },
-        { sun_nio_ch_SctpStdSocketOption_SO_RCVBUF,                SOL_SOCKET,   SO_RCVBUF },
-        { sun_nio_ch_SctpStdSocketOption_SO_LINGER,                SOL_SOCKET,   SO_LINGER } };
-
-    int i;
-    for (i=0; i<(int)(sizeof(opts) / sizeof(opts[0])); i++) {
-        if (cmd == opts[i].cmd) {
-            *level = opts[i].level;
-            *optname = opts[i].optname;
-            return 0;
-        }
-    }
-
-    /* not found */
-    return -1;
-}
-
-/*
- * Class:     sun_nio_ch_SctpNet
- * Method:    setIntOption0
- * Signature: (III)V
- */
-JNIEXPORT void JNICALL Java_sun_nio_ch_SctpNet_setIntOption0
-  (JNIEnv *env, jclass klass, jint fd, jint opt, int arg) {
-    int klevel, kopt;
-    int result;
-    struct linger linger;
-    void *parg;
-    int arglen;
-
-    if (mapSocketOption(opt, &klevel, &kopt) < 0) {
-        JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                     "Unsupported socket option");
-        return;
-    }
-
-    if (opt == sun_nio_ch_SctpStdSocketOption_SO_LINGER) {
-        parg = (void *)&linger;
-        arglen = sizeof(linger);
-        if (arg >= 0) {
-            linger.l_onoff = 1;
-            linger.l_linger = arg;
-        } else {
-            linger.l_onoff = 0;
-            linger.l_linger = 0;
-        }
-    } else {
-        parg = (void *)&arg;
-        arglen = sizeof(arg);
-    }
-
-    if (NET_SetSockOpt(fd, klevel, kopt, parg, arglen) < 0) {
-        JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                     "sun_nio_ch_SctpNet.setIntOption0");
-    }
-}
-
-/*
- * Class:     sun_nio_ch_SctpNet
- * Method:    getIntOption0
- * Signature: (II)I
- */
-JNIEXPORT int JNICALL Java_sun_nio_ch_SctpNet_getIntOption0
-  (JNIEnv *env, jclass klass, jint fd, jint opt) {
-    int klevel, kopt;
-    int result;
-    struct linger linger;
-    void *arg;
-    int arglen;
-
-    if (mapSocketOption(opt, &klevel, &kopt) < 0) {
-        JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                     "Unsupported socket option");
-        return -1;
-    }
-
-    if (opt == sun_nio_ch_SctpStdSocketOption_SO_LINGER) {
-        arg = (void *)&linger;
-        arglen = sizeof(linger);
-    } else {
-        arg = (void *)&result;
-        arglen = sizeof(result);
-    }
-
-    if (NET_GetSockOpt(fd, klevel, kopt, arg, &arglen) < 0) {
-        JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                     "sun.nio.ch.Net.getIntOption");
-        return -1;
-    }
-
-    if (opt == sun_nio_ch_SctpStdSocketOption_SO_LINGER)
-        return linger.l_onoff ? linger.l_linger : -1;
-    else
-        return result;
-}
-
-/*
- * Class:     sun_nio_ch_SctpNet
- * Method:    getPrimAddrOption0
- * Signature: (II)Ljava/net/SocketAddress;
- */
-JNIEXPORT jobject JNICALL Java_sun_nio_ch_SctpNet_getPrimAddrOption0
-  (JNIEnv *env, jclass klass, jint fd, jint assocId) {
-    struct sctp_setprim prim;
-    unsigned int prim_len = sizeof(prim);
-    struct sockaddr* sap = (struct sockaddr*)&prim.ssp_addr;
-
-    prim.ssp_assoc_id = assocId;
-
-    if (getsockopt(fd, IPPROTO_SCTP, SCTP_PRIMARY_ADDR, &prim, &prim_len) < 0) {
-        JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                     "sun.nio.ch.SctpNet.getPrimAddrOption0");
-        return NULL;
-    }
-
-    return SockAddrToInetSocketAddress(env, sap);
-}
-
-/*
- * Class:     sun_nio_ch_SctpNet
- * Method:    setPrimAddrOption0
- * Signature: (IILjava/net/InetAddress;I)V
- */
-JNIEXPORT void JNICALL Java_sun_nio_ch_SctpNet_setPrimAddrOption0
-  (JNIEnv *env, jclass klass, jint fd, jint assocId, jobject iaObj, jint port) {
-    struct sctp_setprim prim;
-    struct sockaddr* sap = (struct sockaddr*)&prim.ssp_addr;
-    int sap_len;
-
-    if (NET_InetAddressToSockaddr(env, iaObj, port, sap,
-                                  &sap_len, JNI_TRUE) != 0) {
-        return;
-    }
-
-    prim.ssp_assoc_id = assocId;
-
-    if (setsockopt(fd, IPPROTO_SCTP, SCTP_PRIMARY_ADDR, &prim, sizeof(prim)) < 0) {
-        JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                     "sun.nio.ch.SctpNet.setPrimAddrOption0");
-    }
-}
-
-/*
- * Class:     sun_nio_ch_SctpNet
- * Method:    setPeerPrimAddrOption0
- * Signature: (IILjava/net/InetAddress;I)V
- */
-JNIEXPORT void JNICALL Java_sun_nio_ch_SctpNet_setPeerPrimAddrOption0
-  (JNIEnv *env, jclass klass, jint fd, jint assocId,
-   jobject iaObj, jint port, jboolean preferIPv6) {
-    struct sctp_setpeerprim prim;
-    struct sockaddr* sap = (struct sockaddr*)&prim.sspp_addr;
-    int sap_len;
-
-    if (NET_InetAddressToSockaddr(env, iaObj, port, sap,
-                                  &sap_len, preferIPv6) != 0) {
-        return;
-    }
-
-    prim.sspp_assoc_id = assocId;
-
-    if (setsockopt(fd, IPPROTO_SCTP, SCTP_SET_PEER_PRIMARY_ADDR, &prim,
-            sizeof(prim)) < 0) {
-        JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                     "sun.nio.ch.SctpNet.setPeerPrimAddrOption0");
-    }
-}
-
-/*
- * Class:     sun_nio_ch_SctpNet
- * Method:    getInitMsgOption0
- * Signature: (I[I)V
- */
-JNIEXPORT void JNICALL Java_sun_nio_ch_SctpNet_getInitMsgOption0
-  (JNIEnv *env, jclass klass, jint fd, jintArray retVal) {
-    struct sctp_initmsg sctp_initmsg;
-    unsigned int sim_len = sizeof(sctp_initmsg);
-    int vals[2];
-
-    if (getsockopt(fd, IPPROTO_SCTP, SCTP_INITMSG, &sctp_initmsg,
-            &sim_len) < 0) {
-        JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                     "sun.nio.ch.SctpNet.getInitMsgOption0");
-        return;
-    }
-
-    vals[0] = sctp_initmsg.sinit_max_instreams;
-    vals[1] = sctp_initmsg.sinit_num_ostreams;
-    (*env)->SetIntArrayRegion(env, retVal, 0, 2, vals);
-}
-
-/*
- * Class:     sun_nio_ch_SctpNet
- * Method:    setInitMsgOption0
- * Signature: (III)V
- */
-JNIEXPORT void JNICALL Java_sun_nio_ch_SctpNet_setInitMsgOption0
-  (JNIEnv *env, jclass klass, jint fd, jint inArg, jint outArg) {
-    struct sctp_initmsg sctp_initmsg;
-
-    sctp_initmsg.sinit_max_instreams = (unsigned int)inArg;
-    sctp_initmsg.sinit_num_ostreams = (unsigned int)outArg;
-    sctp_initmsg.sinit_max_attempts = 0;  // default
-    sctp_initmsg.sinit_max_init_timeo = 0;  // default
-
-    if (setsockopt(fd, IPPROTO_SCTP, SCTP_INITMSG, &sctp_initmsg,
-          sizeof(sctp_initmsg)) < 0) {
-        JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
-                                     "sun.nio.ch.SctpNet.setInitMsgOption0");
-    }
-}
-
-/*
- * Class:     sun_nio_ch_SctpNet
- * Method:    shutdown0
- * Signature: (II)V
- */
-JNIEXPORT void JNICALL Java_sun_nio_ch_SctpNet_shutdown0
-  (JNIEnv *env, jclass klass, jint fd, jint assocId) {
-    int rv;
-    struct msghdr msg[1];
-    struct iovec iov[1];
-    int cbuf_size = CMSG_SPACE(sizeof (struct sctp_sndrcvinfo));
-    char cbuf[CMSG_SPACE(sizeof (struct sctp_sndrcvinfo))];
-    struct cmsghdr* cmsg;
-    struct sctp_sndrcvinfo *sri;
-
-    /* SctpSocketChannel */
-    if (assocId < 0) {
-        shutdown(fd, SHUT_WR);
-        return;
-    }
-
-    memset(msg, 0, sizeof (*msg));
-    memset(cbuf, 0, cbuf_size);
-    msg->msg_name = NULL;
-    msg->msg_namelen = 0;
-    iov->iov_base = NULL;
-    iov->iov_len = 0;
-    msg->msg_iov = iov;
-    msg->msg_iovlen = 1;
-    msg->msg_control = cbuf;
-    msg->msg_controllen = cbuf_size;
-    msg->msg_flags = 0;
-
-    cmsg = CMSG_FIRSTHDR(msg);
-    cmsg->cmsg_level = IPPROTO_SCTP;
-    cmsg->cmsg_type = SCTP_SNDRCV;
-    cmsg->cmsg_len = CMSG_LEN(sizeof(struct sctp_sndrcvinfo));
-
-    /* Initialize the payload: */
-    sri = (struct sctp_sndrcvinfo*) CMSG_DATA(cmsg);
-    memset(sri, 0, sizeof (*sri));
-
-    if (assocId > 0) {
-        sri->sinfo_assoc_id = assocId;
-    }
-
-    sri->sinfo_flags = sri->sinfo_flags | SCTP_EOF;
-
-    /* Sum of the length of all control messages in the buffer. */
-    msg->msg_controllen = cmsg->cmsg_len;
-
-    if ((rv = sendmsg(fd, msg, 0)) < 0) {
-        handleSocketError(env, errno);
-    }
-}
-
-/*
- * Class:     sun_nio_ch_SctpNet
- * Method:    branch
- * Signature: (II)I
- */
-JNIEXPORT int JNICALL Java_sun_nio_ch_SctpNet_branch0
-  (JNIEnv *env, jclass klass, jint fd, jint assocId) {
-    int newfd = 0;
-    if ((newfd = nio_sctp_peeloff(fd, assocId)) < 0) {
-        handleSocketError(env, errno);
-    }
-
-    return newfd;
-}
--- a/jdk/src/solaris/native/sun/nio/ch/SctpServerChannelImpl.c	Mon Feb 13 14:26:25 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#include "sun_nio_ch_SctpServerChannelImpl.h"
-
-extern void Java_sun_nio_ch_ServerSocketChannelImpl_initIDs(JNIEnv* env,
-    jclass c);
-
-extern jint Java_sun_nio_ch_ServerSocketChannelImpl_accept0(JNIEnv* env,
-    jobject this, jobject ssfdo, jobject newfdo, jobjectArray isaa);
-
-/*
- * Class:     sun_nio_ch_SctpServerChannelImpl
- * Method:    initIDs
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_sun_nio_ch_SctpServerChannelImpl_initIDs
-  (JNIEnv* env, jclass c) {
-    Java_sun_nio_ch_ServerSocketChannelImpl_initIDs(env, c);
-}
-
-/*
- * Class:     sun_nio_ch_SctpServerChannelImpl
- * Method:    accept0
- * Signature: (Ljava/io/FileDescriptor;Ljava/io/FileDescriptor;[Ljava/net/InetSocketAddress;)I
- */
-JNIEXPORT jint JNICALL Java_sun_nio_ch_SctpServerChannelImpl_accept0
-  (JNIEnv* env, jobject this, jobject ssfdo, jobject newfdo, jobjectArray isaa) {
-    return Java_sun_nio_ch_ServerSocketChannelImpl_accept0(env, this,
-                                                           ssfdo, newfdo, isaa);
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/solaris/native/sun/nio/ch/sctp/Sctp.h	Mon Feb 13 14:31:32 2012 +0000
@@ -0,0 +1,334 @@
+/*
+ * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#ifndef SUN_NIO_CH_SCTP_H
+#define SUN_NIO_CH_SCTP_H
+
+#ifdef __solaris__
+
+#define _XPG4_2
+#define __EXTENSIONS__
+#include <sys/socket.h>
+#include <netinet/sctp.h>
+#include "jni.h"
+
+/* Current Solaris headers don't comply with draft rfc */
+#ifndef SCTP_EOF
+#define SCTP_EOF MSG_EOF
+#endif
+
+#ifndef SCTP_UNORDERED
+#define SCTP_UNORDERED MSG_UNORDERED
+#endif
+
+/* The current version of the socket API extension shipped with Solaris does
+ * not define the following options that the Java API (optionally) supports */
+#ifndef SCTP_EXPLICIT_EOR
+#define SCTP_EXPLICIT_EOR -1
+#endif
+#ifndef SCTP_FRAGMENT_INTERLEAVE
+#define SCTP_FRAGMENT_INTERLEAVE -1
+#endif
+#ifndef SCTP_SET_PEER_PRIMARY_ADDR
+#define SCTP_SET_PEER_PRIMARY_ADDR -1
+#endif
+
+/* Function types to support dynamic linking of socket API extension functions
+ * for SCTP. This is so that there is no linkage depandancy during build or
+ * runtime for libsctp.*/
+typedef int sctp_getladdrs_func(int sock, sctp_assoc_t id, void **addrs);
+typedef int sctp_freeladdrs_func(void* addrs);
+typedef int sctp_getpaddrs_func(int sock, sctp_assoc_t id, void **addrs);
+typedef int sctp_freepaddrs_func(void *addrs);
+typedef int sctp_bindx_func(int sock, void *addrs, int addrcnt, int flags);
+typedef int sctp_peeloff_func(int sock, sctp_assoc_t id);
+
+
+
+#else /* __linux__ */
+#include <stdint.h>
+#include <linux/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include "jni.h"
+
+//Causes compiler error if not found, should make warning and uncomment
+/*#include <netinet/sctp.h>*/
+
+#ifndef IPPROTO_SCTP
+#define IPPROTO_SCTP    132
+#endif
+
+/* The current version of lksctp does
+ * not define the following option that the Java API (optionally) supports */
+#ifndef SCTP_EXPLICIT_EOR
+#define SCTP_EXPLICIT_EOR -1
+#endif
+
+/* Definitions taken from lksctp-tools-1.0.8/src/include/netinet/sctp.h */
+#ifndef SCTP_INITMSG
+
+enum sctp_optname {
+        SCTP_RTOINFO,
+#define SCTP_RTOINFO SCTP_RTOINFO
+        SCTP_ASSOCINFO,
+#define SCTP_ASSOCINFO SCTP_ASSOCINFO
+        SCTP_INITMSG,
+#define SCTP_INITMSG SCTP_INITMSG
+        SCTP_NODELAY,   /* Get/set nodelay option. */
+#define SCTP_NODELAY    SCTP_NODELAY
+        SCTP_AUTOCLOSE,
+#define SCTP_AUTOCLOSE SCTP_AUTOCLOSE
+        SCTP_SET_PEER_PRIMARY_ADDR,
+#define SCTP_SET_PEER_PRIMARY_ADDR SCTP_SET_PEER_PRIMARY_ADDR
+        SCTP_PRIMARY_ADDR,
+#define SCTP_PRIMARY_ADDR SCTP_PRIMARY_ADDR
+        SCTP_ADAPTATION_LAYER,
+#define SCTP_ADAPTATION_LAYER SCTP_ADAPTATION_LAYER
+        SCTP_DISABLE_FRAGMENTS,
+#define SCTP_DISABLE_FRAGMENTS SCTP_DISABLE_FRAGMENTS
+        SCTP_PEER_ADDR_PARAMS,
+#define SCTP_PEER_ADDR_PARAMS SCTP_PEER_ADDR_PARAMS
+        SCTP_DEFAULT_SEND_PARAM,
+#define SCTP_DEFAULT_SEND_PARAM SCTP_DEFAULT_SEND_PARAM
+        SCTP_EVENTS,
+#define SCTP_EVENTS SCTP_EVENTS
+        SCTP_I_WANT_MAPPED_V4_ADDR,  /* Turn on/off mapped v4 addresses  */
+#define SCTP_I_WANT_MAPPED_V4_ADDR SCTP_I_WANT_MAPPED_V4_ADDR
+        SCTP_MAXSEG,    /* Get/set maximum fragment. */
+#define SCTP_MAXSEG     SCTP_MAXSEG
+        SCTP_STATUS,
+#define SCTP_STATUS SCTP_STATUS
+        SCTP_GET_PEER_ADDR_INFO,
+#define SCTP_GET_PEER_ADDR_INFO SCTP_GET_PEER_ADDR_INFO
+        SCTP_DELAYED_ACK_TIME,
+#define SCTP_DELAYED_ACK_TIME SCTP_DELAYED_ACK_TIME
+        SCTP_CONTEXT,   /* Receive Context */
+#define SCTP_CONTEXT SCTP_CONTEXT
+        SCTP_FRAGMENT_INTERLEAVE,
+#define SCTP_FRAGMENT_INTERLEAVE SCTP_FRAGMENT_INTERLEAVE
+        SCTP_PARTIAL_DELIVERY_POINT,    /* Set/Get partial delivery point */
+#define SCTP_PARTIAL_DELIVERY_POINT SCTP_PARTIAL_DELIVERY_POINT
+        SCTP_MAX_BURST,         /* Set/Get max burst */
+#define SCTP_MAX_BURST SCTP_MAX_BURST
+};
+
+enum sctp_sac_state {
+        SCTP_COMM_UP,
+        SCTP_COMM_LOST,
+        SCTP_RESTART,
+        SCTP_SHUTDOWN_COMP,
+        SCTP_CANT_STR_ASSOC,
+};
+
+enum sctp_spc_state {
+        SCTP_ADDR_AVAILABLE,
+        SCTP_ADDR_UNREACHABLE,
+        SCTP_ADDR_REMOVED,
+        SCTP_ADDR_ADDED,
+        SCTP_ADDR_MADE_PRIM,
+        SCTP_ADDR_CONFIRMED,
+};
+
+enum sctp_sinfo_flags {
+        SCTP_UNORDERED = 1,  /* Send/receive message unordered. */
+        SCTP_ADDR_OVER = 2,  /* Override the primary destination. */
+        SCTP_ABORT=4,        /* Send an ABORT message to the peer. */
+        SCTP_EOF=MSG_FIN,    /* Initiate graceful shutdown process. */
+};
+
+enum sctp_sn_type {
+        SCTP_SN_TYPE_BASE     = (1<<15),
+        SCTP_ASSOC_CHANGE,
+        SCTP_PEER_ADDR_CHANGE,
+        SCTP_SEND_FAILED,
+        SCTP_REMOTE_ERROR,
+        SCTP_SHUTDOWN_EVENT,
+        SCTP_PARTIAL_DELIVERY_EVENT,
+        SCTP_ADAPTATION_INDICATION,
+};
+
+typedef enum sctp_cmsg_type {
+        SCTP_INIT,              /* 5.2.1 SCTP Initiation Structure */
+#define SCTP_INIT SCTP_INIT
+        SCTP_SNDRCV,            /* 5.2.2 SCTP Header Information Structure */
+#define SCTP_SNDRCV SCTP_SNDRCV
+} sctp_cmsg_t;
+
+enum sctp_msg_flags {
+        MSG_NOTIFICATION = 0x8000,
+#define MSG_NOTIFICATION MSG_NOTIFICATION
+};
+
+#define SCTP_BINDX_ADD_ADDR 0x01
+#define SCTP_BINDX_REM_ADDR 0x02
+
+typedef __s32 sctp_assoc_t;
+
+struct sctp_initmsg {
+        __u16 sinit_num_ostreams;
+        __u16 sinit_max_instreams;
+        __u16 sinit_max_attempts;
+        __u16 sinit_max_init_timeo;
+};
+
+struct sctp_sndrcvinfo {
+        __u16 sinfo_stream;
+        __u16 sinfo_ssn;
+        __u16 sinfo_flags;
+        __u32 sinfo_ppid;
+        __u32 sinfo_context;
+        __u32 sinfo_timetolive;
+        __u32 sinfo_tsn;
+        __u32 sinfo_cumtsn;
+        sctp_assoc_t sinfo_assoc_id;
+};
+
+struct sctp_event_subscribe {
+        __u8 sctp_data_io_event;
+        __u8 sctp_association_event;
+        __u8 sctp_address_event;
+        __u8 sctp_send_failure_event;
+        __u8 sctp_peer_error_event;
+        __u8 sctp_shutdown_event;
+        __u8 sctp_partial_delivery_event;
+        __u8 sctp_adaptation_layer_event;
+};
+
+struct sctp_send_failed {
+        __u16 ssf_type;
+        __u16 ssf_flags;
+        __u32 ssf_length;
+        __u32 ssf_error;
+        struct sctp_sndrcvinfo ssf_info;
+        sctp_assoc_t ssf_assoc_id;
+        __u8 ssf_data[0];
+};
+
+struct sctp_assoc_change {
+        __u16 sac_type;
+        __u16 sac_flags;
+        __u32 sac_length;
+        __u16 sac_state;
+        __u16 sac_error;
+        __u16 sac_outbound_streams;
+        __u16 sac_inbound_streams;
+        sctp_assoc_t sac_assoc_id;
+        __u8 sac_info[0];
+};
+
+struct sctp_shutdown_event {
+        __u16 sse_type;
+        __u16 sse_flags;
+        __u32 sse_length;
+        sctp_assoc_t sse_assoc_id;
+};
+
+struct sctp_paddr_change {
+        __u16 spc_type;
+        __u16 spc_flags;
+        __u32 spc_length;
+        struct sockaddr_storage spc_aaddr;
+        int spc_state;
+        int spc_error;
+        sctp_assoc_t spc_assoc_id;
+} __attribute__((packed, aligned(4)));
+
+struct sctp_remote_error {
+        __u16 sre_type;
+        __u16 sre_flags;
+        __u32 sre_length;
+        __u16 sre_error;
+        sctp_assoc_t sre_assoc_id;
+        __u8 sre_data[0];
+};
+
+struct sctp_adaptation_event {
+        __u16 sai_type;
+        __u16 sai_flags;
+        __u32 sai_length;
+        __u32 sai_adaptation_ind;
+        sctp_assoc_t sai_assoc_id;
+};
+
+struct sctp_setprim {
+        sctp_assoc_t            ssp_assoc_id;
+        struct sockaddr_storage ssp_addr;
+} __attribute__((packed, aligned(4)));
+
+struct sctp_setpeerprim {
+        sctp_assoc_t            sspp_assoc_id;
+        struct sockaddr_storage sspp_addr;
+} __attribute__((packed, aligned(4)));
+
+
+struct sctp_pdapi_event {
+        __u16 pdapi_type;
+        __u16 pdapi_flags;
+        __u32 pdapi_length;
+        __u32 pdapi_indication;
+        sctp_assoc_t pdapi_assoc_id;
+};
+
+union sctp_notification {
+        struct {
+                __u16 sn_type;             /* Notification type. */
+                __u16 sn_flags;
+                __u32 sn_length;
+        } sn_header;
+        struct sctp_assoc_change sn_assoc_change;
+        struct sctp_paddr_change sn_paddr_change;
+        struct sctp_remote_error sn_remote_error;
+        struct sctp_send_failed sn_send_failed;
+        struct sctp_shutdown_event sn_shutdown_event;
+        struct sctp_adaptation_event sn_adaptation_event;
+        struct sctp_pdapi_event sn_pdapi_event;
+};
+
+#endif /* SCTP_INITMSG */
+
+/* Function types to support dynamic linking of socket API extension functions
+ * for SCTP. This is so that there is no linkage depandancy during build or
+ * runtime for libsctp.*/
+typedef int sctp_getladdrs_func(int sd, sctp_assoc_t id, struct sockaddr **addrs);
+typedef int sctp_freeladdrs_func(struct sockaddr *addrs);
+typedef int sctp_getpaddrs_func(int sd, sctp_assoc_t id, struct sockaddr **addrs);
+typedef int sctp_freepaddrs_func(struct sockaddr *addrs);
+typedef int sctp_bindx_func(int sd, struct sockaddr *addrs, int addrcnt, int flags);
+typedef int sctp_peeloff_func(int sock, sctp_assoc_t id);
+
+
+#endif /* __linux__ */
+
+sctp_getladdrs_func* nio_sctp_getladdrs;
+sctp_freeladdrs_func* nio_sctp_freeladdrs;
+sctp_getpaddrs_func* nio_sctp_getpaddrs;
+sctp_freepaddrs_func* nio_sctp_freepaddrs;
+sctp_bindx_func* nio_sctp_bindx;
+sctp_peeloff_func* nio_sctp_peeloff;
+
+jboolean loadSocketExtensionFuncs(JNIEnv* env);
+
+#endif /* !SUN_NIO_CH_SCTP_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/solaris/native/sun/nio/ch/sctp/SctpChannelImpl.c	Mon Feb 13 14:31:32 2012 +0000
@@ -0,0 +1,596 @@
+/*
+ * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include "Sctp.h"
+
+#include "jni.h"
+#include "nio_util.h"
+#include "nio.h"
+#include "net_util.h"
+#include "net_util_md.h"
+#include "sun_nio_ch_sctp_SctpNet.h"
+#include "sun_nio_ch_sctp_SctpChannelImpl.h"
+#include "sun_nio_ch_sctp_AssociationChange.h"
+#include "sun_nio_ch_sctp_ResultContainer.h"
+#include "sun_nio_ch_sctp_PeerAddrChange.h"
+
+/* sizeof(union sctp_notification */
+#define NOTIFICATION_BUFFER_SIZE 280
+
+#define MESSAGE_IMPL_CLASS              "sun/nio/ch/sctp/MessageInfoImpl"
+#define RESULT_CONTAINER_CLASS          "sun/nio/ch/sctp/ResultContainer"
+#define SEND_FAILED_CLASS               "sun/nio/ch/sctp/SendFailed"
+#define ASSOC_CHANGE_CLASS              "sun/nio/ch/sctp/AssociationChange"
+#define PEER_CHANGE_CLASS               "sun/nio/ch/sctp/PeerAddrChange"
+#define SHUTDOWN_CLASS                  "sun/nio/ch/sctp/Shutdown"
+
+struct controlData {
+    int assocId;
+    unsigned short streamNumber;
+    jboolean unordered;
+    unsigned int ppid;
+};
+
+static jclass    smi_class;    /* sun.nio.ch.sctp.MessageInfoImpl            */
+static jmethodID smi_ctrID;    /* sun.nio.ch.sctp.MessageInfoImpl.<init>     */
+static jfieldID  src_valueID;  /* sun.nio.ch.sctp.ResultContainer.value      */
+static jfieldID  src_typeID;   /* sun.nio.ch.sctp.ResultContainer.type       */
+static jclass    ssf_class;    /* sun.nio.ch.sctp.SendFailed                 */
+static jmethodID ssf_ctrID;    /* sun.nio.ch.sctp.SendFailed.<init>          */
+static jclass    sac_class;    /* sun.nio.ch.sctp.AssociationChange          */
+static jmethodID sac_ctrID;    /* sun.nio.ch.sctp.AssociationChange.<init>   */
+static jclass    spc_class;    /* sun.nio.ch.sctp.PeerAddressChanged         */
+static jmethodID spc_ctrID;    /* sun.nio.ch.sctp.PeerAddressChanged.<init>  */
+static jclass    ss_class;     /* sun.nio.ch.sctp.Shutdown                   */
+static jmethodID ss_ctrID;     /* sun.nio.ch.sctp.Shutdown.<init>            */
+static jfieldID  isa_addrID;   /* java.net.InetSocketAddress.addr            */
+static jfieldID  isa_portID;   /* java.net.InetSocketAddress.port            */
+
+/* defined in SctpNet.c */
+jobject SockAddrToInetSocketAddress(JNIEnv* env, struct sockaddr* addr);
+
+jint handleSocketError(JNIEnv *env, jint errorValue);
+
+/* use SocketChannelImpl's checkConnect implementation */
+extern jint Java_sun_nio_ch_SocketChannelImpl_checkConnect(JNIEnv* env,
+    jobject this, jobject fdo, jboolean block, jboolean ready);
+
+/*
+ * Class:     sun_nio_ch_sctp_SctpChannelImpl
+ * Method:    initIDs
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_sun_nio_ch_sctp_SctpChannelImpl_initIDs
+  (JNIEnv *env, jclass klass) {
+    jclass cls;
+
+    /* MessageInfoImpl */
+    cls = (*env)->FindClass(env, MESSAGE_IMPL_CLASS);
+    CHECK_NULL(cls);
+    smi_class = (*env)->NewGlobalRef(env, cls);
+    CHECK_NULL(smi_class);
+    smi_ctrID = (*env)->GetMethodID(env, cls, "<init>",
+            "(ILjava/net/SocketAddress;IIZZI)V");
+    CHECK_NULL(smi_ctrID);
+
+    /* ResultContainer */
+    cls = (*env)->FindClass(env, RESULT_CONTAINER_CLASS);
+    CHECK_NULL(cls);
+    src_valueID = (*env)->GetFieldID(env, cls, "value", "Ljava/lang/Object;");
+    CHECK_NULL(src_valueID);
+    src_typeID = (*env)->GetFieldID(env, cls, "type", "I");
+    CHECK_NULL(src_typeID);
+
+    /* SendFailed */
+    cls = (*env)->FindClass(env, SEND_FAILED_CLASS);
+    CHECK_NULL(cls);
+    ssf_class = (*env)->NewGlobalRef(env, cls);
+    CHECK_NULL(ssf_class);
+    ssf_ctrID = (*env)->GetMethodID(env, cls, "<init>",
+        "(ILjava/net/SocketAddress;Ljava/nio/ByteBuffer;II)V");
+    CHECK_NULL(ssf_ctrID);
+
+    /* AssociationChange */
+    cls = (*env)->FindClass(env, ASSOC_CHANGE_CLASS);
+    CHECK_NULL(cls);
+    sac_class = (*env)->NewGlobalRef(env, cls);
+    CHECK_NULL(sac_class);
+    sac_ctrID = (*env)->GetMethodID(env, cls, "<init>", "(IIII)V");
+    CHECK_NULL(sac_ctrID);
+
+    /* PeerAddrChange */
+    cls = (*env)->FindClass(env, PEER_CHANGE_CLASS);
+    CHECK_NULL(cls);
+    spc_class = (*env)->NewGlobalRef(env, cls);
+    CHECK_NULL(spc_class);
+    spc_ctrID = (*env)->GetMethodID(env, cls, "<init>",
+            "(ILjava/net/SocketAddress;I)V");
+    CHECK_NULL(spc_ctrID);
+
+    /* Shutdown */
+    cls = (*env)->FindClass(env, SHUTDOWN_CLASS);
+    CHECK_NULL(cls);
+    ss_class = (*env)->NewGlobalRef(env, cls);
+    CHECK_NULL(ss_class);
+    ss_ctrID = (*env)->GetMethodID(env, cls, "<init>", "(I)V");
+    CHECK_NULL(ss_ctrID);
+
+    /* InetSocketAddress */
+    cls = (*env)->FindClass(env, "java/net/InetSocketAddress");
+    CHECK_NULL(cls);
+    isa_addrID = (*env)->GetFieldID(env, cls, "addr", "Ljava/net/InetAddress;");
+    CHECK_NULL(isa_addrID);
+    isa_portID = (*env)->GetFieldID(env, cls, "port", "I");
+}
+
+void getControlData
+  (struct msghdr* msg, struct controlData* cdata) {
+    struct cmsghdr* cmsg;
+
+    for (cmsg = CMSG_FIRSTHDR(msg); cmsg != NULL; cmsg = CMSG_NXTHDR(msg, cmsg)) {
+        if (cmsg->cmsg_level == IPPROTO_SCTP && cmsg->cmsg_type == SCTP_SNDRCV) {
+            struct sctp_sndrcvinfo *sri;
+
+            sri = (struct sctp_sndrcvinfo *) CMSG_DATA(cmsg);
+            cdata->assocId = sri->sinfo_assoc_id;
+            cdata->streamNumber = sri->sinfo_stream;
+            cdata->unordered = (sri->sinfo_flags & SCTP_UNORDERED) ? JNI_TRUE :
+                JNI_FALSE;
+            cdata->ppid = ntohl(sri->sinfo_ppid);
+
+            return;
+        }
+    }
+    return;
+}
+
+void setControlData
+  (struct msghdr* msg, struct controlData* cdata) {
+    struct cmsghdr* cmsg;
+    struct sctp_sndrcvinfo *sri;
+
+    cmsg = CMSG_FIRSTHDR(msg);
+    cmsg->cmsg_level = IPPROTO_SCTP;
+    cmsg->cmsg_type = SCTP_SNDRCV;
+    cmsg->cmsg_len = CMSG_LEN(sizeof(struct sctp_sndrcvinfo));
+
+    /* Initialize the payload */
+    sri = (struct sctp_sndrcvinfo*) CMSG_DATA(cmsg);
+    memset(sri, 0, sizeof (*sri));
+
+    if (cdata->streamNumber > 0) {
+        sri->sinfo_stream = cdata->streamNumber;
+    }
+    if (cdata->assocId > 0) {
+        sri->sinfo_assoc_id = cdata->assocId;
+    }
+    if (cdata->unordered == JNI_TRUE) {
+        sri->sinfo_flags = sri->sinfo_flags | SCTP_UNORDERED;
+    }
+
+    if (cdata->ppid > 0) {
+        sri->sinfo_ppid = htonl(cdata->ppid);
+    }
+
+    /* Sum of the length of all control messages in the buffer. */
+    msg->msg_controllen = cmsg->cmsg_len;
+}
+
+// TODO: test: can create send failed without any data? if so need to
+// update API so that buffer can be null if no data.
+void handleSendFailed
+  (JNIEnv* env, int fd, jobject resultContainerObj, struct sctp_send_failed *ssf,
+   int read, jboolean isEOR, struct sockaddr* sap) {
+    jobject bufferObj = NULL, resultObj, isaObj;
+    char *addressP;
+    struct sctp_sndrcvinfo *sri;
+    int remaining, dataLength;
+
+    /* the actual undelivered message data is directly after the ssf */
+    int dataOffset = sizeof(struct sctp_send_failed);
+
+    sri = (struct sctp_sndrcvinfo*) &ssf->ssf_info;
+
+    /* the number of bytes remaining to be read in the sctp_send_failed notif*/
+    remaining = ssf->ssf_length - read;
+
+    /* the size of the actual undelivered message */
+    dataLength = ssf->ssf_length - dataOffset;
+
+    /* retrieved address from sockaddr */
+    isaObj = SockAddrToInetSocketAddress(env, sap);
+
+    /* data retrieved from sff_data */
+    if (dataLength > 0) {
+        struct iovec iov[1];
+        struct msghdr msg[1];
+        int rv, alreadyRead;
+        char *dataP = (char*) ssf;
+        dataP += dataOffset;
+
+        if ((addressP = malloc(dataLength)) == NULL) {
+            JNU_ThrowOutOfMemoryError(env, "handleSendFailed");
+            return;
+        }
+
+        memset(msg, 0, sizeof (*msg));
+        msg->msg_iov = iov;
+        msg->msg_iovlen = 1;
+
+        bufferObj = (*env)->NewDirectByteBuffer(env, addressP, dataLength);
+        CHECK_NULL(bufferObj);
+
+        alreadyRead = read - dataOffset;
+        if (alreadyRead > 0) {
+            memcpy(addressP, /*ssf->ssf_data*/ dataP, alreadyRead);
+            iov->iov_base = addressP + alreadyRead;
+            iov->iov_len = dataLength - alreadyRead;
+        } else {
+            iov->iov_base = addressP;
+            iov->iov_len = dataLength;
+        }
+
+        if (remaining > 0) {
+            if ((rv = recvmsg(fd, msg, 0)) < 0) {
+                handleSocketError(env, errno);
+                return;
+            }
+
+            if (rv != (dataLength - alreadyRead) || !(msg->msg_flags & MSG_EOR)) {
+                //TODO: assert false: "should not reach here";
+                return;
+            }
+            // TODO: Set and document (in API) buffers position.
+        }
+    }
+
+    /* create SendFailed */
+    resultObj = (*env)->NewObject(env, ssf_class, ssf_ctrID, ssf->ssf_assoc_id,
+            isaObj, bufferObj, ssf->ssf_error, sri->sinfo_stream);
+    CHECK_NULL(resultObj);
+    (*env)->SetObjectField(env, resultContainerObj, src_valueID, resultObj);
+    (*env)->SetIntField(env, resultContainerObj, src_typeID,
+            sun_nio_ch_sctp_ResultContainer_SEND_FAILED);
+}
+
+void handleAssocChange
+  (JNIEnv* env, jobject resultContainerObj, struct sctp_assoc_change *sac) {
+    jobject resultObj;
+    int state = 0;
+
+    switch (sac->sac_state) {
+        case SCTP_COMM_UP :
+            state = sun_nio_ch_sctp_AssociationChange_SCTP_COMM_UP;
+            break;
+        case SCTP_COMM_LOST :
+            state = sun_nio_ch_sctp_AssociationChange_SCTP_COMM_LOST;
+            break;
+        case SCTP_RESTART :
+            state = sun_nio_ch_sctp_AssociationChange_SCTP_RESTART;
+            break;
+        case SCTP_SHUTDOWN_COMP :
+            state = sun_nio_ch_sctp_AssociationChange_SCTP_SHUTDOWN;
+            break;
+        case SCTP_CANT_STR_ASSOC :
+            state = sun_nio_ch_sctp_AssociationChange_SCTP_CANT_START;
+    }
+
+    /* create AssociationChange */
+    resultObj = (*env)->NewObject(env, sac_class, sac_ctrID, sac->sac_assoc_id,
+        state, sac->sac_outbound_streams, sac->sac_inbound_streams);
+    CHECK_NULL(resultObj);
+    (*env)->SetObjectField(env, resultContainerObj, src_valueID, resultObj);
+    (*env)->SetIntField(env, resultContainerObj, src_typeID,
+            sun_nio_ch_sctp_ResultContainer_ASSOCIATION_CHANGED);
+}
+
+void handleShutdown
+  (JNIEnv* env, jobject resultContainerObj, struct sctp_shutdown_event* sse) {
+    /* create Shutdown */
+    jobject resultObj = (*env)->NewObject(env, ss_class, ss_ctrID, sse->sse_assoc_id);
+    CHECK_NULL(resultObj);
+    (*env)->SetObjectField(env, resultContainerObj, src_valueID, resultObj);
+    (*env)->SetIntField(env, resultContainerObj, src_typeID,
+            sun_nio_ch_sctp_ResultContainer_SHUTDOWN);
+}
+
+void handlePeerAddrChange
+  (JNIEnv* env, jobject resultContainerObj, struct sctp_paddr_change* spc) {
+    int event = 0;
+    jobject addressObj, resultObj;
+    unsigned int state = spc->spc_state;
+
+    switch (state) {
+        case SCTP_ADDR_AVAILABLE :
+            event = sun_nio_ch_sctp_PeerAddrChange_SCTP_ADDR_AVAILABLE;
+            break;
+        case SCTP_ADDR_UNREACHABLE :
+            event = sun_nio_ch_sctp_PeerAddrChange_SCTP_ADDR_UNREACHABLE;
+            break;
+        case SCTP_ADDR_REMOVED :
+            event = sun_nio_ch_sctp_PeerAddrChange_SCTP_ADDR_REMOVED;
+            break;
+        case SCTP_ADDR_ADDED :
+            event = sun_nio_ch_sctp_PeerAddrChange_SCTP_ADDR_ADDED;
+            break;
+        case SCTP_ADDR_MADE_PRIM :
+            event = sun_nio_ch_sctp_PeerAddrChange_SCTP_ADDR_MADE_PRIM;
+#ifdef __linux__  /* Solaris currently doesn't support SCTP_ADDR_CONFIRMED */
+            break;
+        case SCTP_ADDR_CONFIRMED :
+            event = sun_nio_ch_sctp_PeerAddrChange_SCTP_ADDR_CONFIRMED;
+#endif  /* __linux__ */
+    }
+
+    addressObj = SockAddrToInetSocketAddress(env, (struct sockaddr*)&spc->spc_aaddr);
+
+    /* create PeerAddressChanged */
+    resultObj = (*env)->NewObject(env, spc_class, spc_ctrID, spc->spc_assoc_id,
+            addressObj, event);
+    CHECK_NULL(resultObj);
+    (*env)->SetObjectField(env, resultContainerObj, src_valueID, resultObj);
+    (*env)->SetIntField(env, resultContainerObj, src_typeID,
+            sun_nio_ch_sctp_ResultContainer_PEER_ADDRESS_CHANGED);
+}
+
+void handleUninteresting
+  (union sctp_notification *snp) {
+    //fprintf(stdout,"\nNative: handleUninterestingNotification: Receive notification type [%u]", snp->sn_header.sn_type);
+}
+
+/**
+ * Handle notifications from the SCTP stack.
+ * Returns JNI_TRUE if the notification is one that is of interest to the
+ * Java API, otherwise JNI_FALSE.
+ */
+jboolean handleNotification
+  (JNIEnv* env, int fd, jobject resultContainerObj, union sctp_notification* snp,
+   int read, jboolean isEOR, struct sockaddr* sap) {
+    switch (snp->sn_header.sn_type) {
+        case SCTP_SEND_FAILED:
+            handleSendFailed(env, fd, resultContainerObj, &snp->sn_send_failed,
+                    read, isEOR, sap);
+            return JNI_TRUE;
+        case SCTP_ASSOC_CHANGE:
+            handleAssocChange(env, resultContainerObj, &snp->sn_assoc_change);
+            return JNI_TRUE;
+        case SCTP_SHUTDOWN_EVENT:
+            handleShutdown(env, resultContainerObj, &snp->sn_shutdown_event);
+            return JNI_TRUE;
+        case SCTP_PEER_ADDR_CHANGE:
+            handlePeerAddrChange(env, resultContainerObj, &snp->sn_paddr_change);
+            return JNI_TRUE;
+        default :
+            /* the Java API is not interested in this event, maybe we are? */
+            handleUninteresting(snp);
+    }
+    return JNI_FALSE;
+}
+
+void handleMessage
+  (JNIEnv* env, jobject resultContainerObj, struct msghdr* msg,int read,
+   jboolean isEOR, struct sockaddr* sap) {
+    jobject isa, resultObj;
+    struct controlData cdata[1];
+
+    if (read == 0) {
+        /* we reached EOF */
+        read = -1;
+    }
+
+    isa = SockAddrToInetSocketAddress(env, sap);
+    getControlData(msg, cdata);
+
+    /* create MessageInfoImpl */
+    resultObj = (*env)->NewObject(env, smi_class, smi_ctrID, cdata->assocId,
+                                  isa, read, cdata->streamNumber,
+                                  isEOR ? JNI_TRUE : JNI_FALSE,
+                                  cdata->unordered, cdata->ppid);
+    CHECK_NULL(resultObj);
+    (*env)->SetObjectField(env, resultContainerObj, src_valueID, resultObj);
+    (*env)->SetIntField(env, resultContainerObj, src_typeID,
+                        sun_nio_ch_sctp_ResultContainer_MESSAGE);
+}
+
+/*
+ * Class:     sun_nio_ch_sctp_SctpChannelImpl
+ * Method:    receive0
+ * Signature: (ILsun/nio/ch/sctp/ResultContainer;JIZ)I
+ */
+JNIEXPORT jint JNICALL Java_sun_nio_ch_sctp_SctpChannelImpl_receive0
+  (JNIEnv *env, jclass klass, jint fd, jobject resultContainerObj,
+   jlong address, jint length, jboolean peek) {
+    SOCKADDR sa;
+    int sa_len = sizeof(sa);
+    ssize_t rv = 0;
+    jlong *addr = jlong_to_ptr(address);
+    struct iovec iov[1];
+    struct msghdr msg[1];
+    char cbuf[CMSG_SPACE(sizeof (struct sctp_sndrcvinfo))];
+    int flags = peek == JNI_TRUE ? MSG_PEEK : 0;
+
+    /* Set up the msghdr structure for receiving */
+    memset(msg, 0, sizeof (*msg));
+    msg->msg_name = &sa;
+    msg->msg_namelen = sa_len;
+    iov->iov_base = addr;
+    iov->iov_len = length;
+    msg->msg_iov = iov;
+    msg->msg_iovlen = 1;
+    msg->msg_control = cbuf;
+    msg->msg_controllen = sizeof(cbuf);
+    msg->msg_flags = 0;
+
+    do {
+        if ((rv = recvmsg(fd, msg, flags)) < 0) {
+            if (errno == EWOULDBLOCK) {
+                return IOS_UNAVAILABLE;
+            } else if (errno == EINTR) {
+                return IOS_INTERRUPTED;
+
+#ifdef __linux__
+            } else if (errno == ENOTCONN) {
+                /* ENOTCONN when EOF reached */
+                rv = 0;
+                /* there will be no control data */
+                msg->msg_controllen = 0;
+#endif /* __linux__ */
+
+            } else {
+                handleSocketError(env, errno);
+                return 0;
+            }
+        }
+
+        if (msg->msg_flags & MSG_NOTIFICATION) {
+            char *bufp = (char*)addr;
+            union sctp_notification *snp;
+
+            if (!(msg->msg_flags & MSG_EOR) && length < NOTIFICATION_BUFFER_SIZE) {
+                char buf[NOTIFICATION_BUFFER_SIZE];
+                int rvSAVE = rv;
+                memcpy(buf, addr, rv);
+                iov->iov_base = buf + rv;
+                iov->iov_len = NOTIFICATION_BUFFER_SIZE - rv;
+                if ((rv = recvmsg(fd, msg, flags)) < 0) {
+                    handleSocketError(env, errno);
+                    return 0;
+                }
+                bufp = buf;
+                rv += rvSAVE;
+            }
+            snp = (union sctp_notification *) bufp;
+            if (handleNotification(env, fd, resultContainerObj, snp, rv,
+                                   (msg->msg_flags & MSG_EOR),
+                                   (struct sockaddr*)&sa ) == JNI_TRUE) {
+                /* We have received a notification that is of interest to
+                   to the Java API. The appropriate notification will be
+                   set in the result container. */
+                return 0;
+            }
+
+            // set iov back to addr, and reset msg_controllen
+            iov->iov_base = addr;
+            iov->iov_len = length;
+            msg->msg_control = cbuf;
+            msg->msg_controllen = sizeof(cbuf);
+        }
+    } while (msg->msg_flags & MSG_NOTIFICATION);
+
+    handleMessage(env, resultContainerObj, msg, rv,
+            (msg->msg_flags & MSG_EOR), (struct sockaddr*)&sa);
+    return rv;
+}
+
+/*
+ * Class:     sun_nio_ch_sctp_SctpChannelImpl
+ * Method:    send0
+ * Signature: (IJILjava/net/SocketAddress;IIZI)I
+ */
+JNIEXPORT jint JNICALL Java_sun_nio_ch_sctp_SctpChannelImpl_send0
+  (JNIEnv *env, jclass klass, jint fd, jlong address, jint length,
+   jobject saTarget, jint assocId, jint streamNumber, jboolean unordered,
+   jint ppid) {
+    SOCKADDR sa;
+    int sa_len = sizeof(sa);
+    ssize_t rv = 0;
+    jlong *addr = jlong_to_ptr(address);
+    struct iovec iov[1];
+    struct msghdr msg[1];
+    int cbuf_size = CMSG_SPACE(sizeof (struct sctp_sndrcvinfo));
+    char cbuf[CMSG_SPACE(sizeof (struct sctp_sndrcvinfo))];
+    struct controlData cdata[1];
+
+    /* SctpChannel:
+     *    saTarget may contain the preferred address or NULL to use primary,
+     *    assocId will always be -1
+     * SctpMultiChannell:
+     *    Setup new association, saTarget will contain address, assocId = -1
+     *    Association already existing, assocId != -1, saTarget = preferred addr
+     */
+    if (saTarget != NULL /*&& assocId <= 0*/) {
+
+        jobject targetAddress = (*env)->GetObjectField(env, saTarget, isa_addrID);
+        jint targetPort = (*env)->GetIntField(env, saTarget, isa_portID);
+
+        if (NET_InetAddressToSockaddr(env, targetAddress, targetPort,
+                                      (struct sockaddr *)&sa,
+                                      &sa_len, JNI_TRUE) != 0) {
+            return IOS_THROWN;
+        }
+    } else {
+        memset(&sa, '\x0', sa_len);
+        sa_len = 0;
+    }
+
+    /* Set up the msghdr structure for sending */
+    memset(msg, 0, sizeof (*msg));
+    memset(cbuf, 0, cbuf_size);
+    msg->msg_name = &sa;
+    msg->msg_namelen = sa_len;
+    iov->iov_base = addr;
+    iov->iov_len = length;
+    msg->msg_iov = iov;
+    msg->msg_iovlen = 1;
+    msg->msg_control = cbuf;
+    msg->msg_controllen = cbuf_size;
+    msg->msg_flags = 0;
+
+    cdata->streamNumber = streamNumber;
+    cdata->assocId = assocId;
+    cdata->unordered = unordered;
+    cdata->ppid = ppid;
+    setControlData(msg, cdata);
+
+    if ((rv = sendmsg(fd, msg, 0)) < 0) {
+        if (errno == EWOULDBLOCK) {
+            return IOS_UNAVAILABLE;
+        } else if (errno == EINTR) {
+            return IOS_INTERRUPTED;
+        } else if (errno == EPIPE) {
+            JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
+                            "Socket is shutdown for writing");
+        } else {
+            handleSocketError(env, errno);
+            return 0;
+        }
+    }
+
+    return rv;
+}
+
+/*
+ * Class:     sun_nio_ch_sctp_SctpChannelImpl
+ * Method:    checkConnect
+ * Signature: (Ljava/io/FileDescriptor;ZZ)I
+ */
+JNIEXPORT jint JNICALL Java_sun_nio_ch_sctp_SctpChannelImpl_checkConnect
+  (JNIEnv* env, jobject this, jobject fdo, jboolean block, jboolean ready) {
+    return Java_sun_nio_ch_SocketChannelImpl_checkConnect(env, this,
+                                                          fdo, block, ready);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/solaris/native/sun/nio/ch/sctp/SctpNet.c	Mon Feb 13 14:31:32 2012 +0000
@@ -0,0 +1,753 @@
+/*
+ * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <dlfcn.h>
+
+#include "Sctp.h"
+#include "jni.h"
+#include "jni_util.h"
+#include "nio_util.h"
+#include "nio.h"
+#include "net_util.h"
+#include "net_util_md.h"
+#include "sun_nio_ch_sctp_SctpNet.h"
+#include "sun_nio_ch_sctp_SctpStdSocketOption.h"
+
+static jclass isaCls = 0;
+static jmethodID isaCtrID = 0;
+
+static const char* nativeSctpLib = "libsctp.so.1";
+static jboolean funcsLoaded = JNI_FALSE;
+
+JNIEXPORT jint JNICALL JNI_OnLoad
+  (JavaVM *vm, void *reserved) {
+    return JNI_VERSION_1_2;
+}
+
+static int preCloseFD = -1;     /* File descriptor to which we dup other fd's
+                                   before closing them for real */
+
+/**
+ * Loads the native sctp library that contains the socket extension
+ * functions, as well as locating the individual functions.
+ * There will be a pending exception if this method returns false.
+ */
+jboolean loadSocketExtensionFuncs
+  (JNIEnv* env) {
+    if (dlopen(nativeSctpLib, RTLD_GLOBAL | RTLD_LAZY) == NULL) {
+        JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
+              dlerror());
+        return JNI_FALSE;
+    }
+
+    if ((nio_sctp_getladdrs = (sctp_getladdrs_func*)
+            dlsym(RTLD_DEFAULT, "sctp_getladdrs")) == NULL) {
+        JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
+              dlerror());
+        return JNI_FALSE;
+    }
+
+    if ((nio_sctp_freeladdrs = (sctp_freeladdrs_func*)
+            dlsym(RTLD_DEFAULT, "sctp_freeladdrs")) == NULL) {
+        JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
+              dlerror());
+        return JNI_FALSE;
+    }
+
+    if ((nio_sctp_getpaddrs = (sctp_getpaddrs_func*)
+            dlsym(RTLD_DEFAULT, "sctp_getpaddrs")) == NULL) {
+        JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
+              dlerror());
+        return JNI_FALSE;
+    }
+
+    if ((nio_sctp_freepaddrs = (sctp_freepaddrs_func*)
+            dlsym(RTLD_DEFAULT, "sctp_freepaddrs")) == NULL) {
+        JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
+              dlerror());
+        return JNI_FALSE;
+    }
+
+    if ((nio_sctp_bindx = (sctp_bindx_func*)
+            dlsym(RTLD_DEFAULT, "sctp_bindx")) == NULL) {
+        JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
+              dlerror());
+        return JNI_FALSE;
+    }
+
+    if ((nio_sctp_peeloff = (sctp_peeloff_func*)
+            dlsym(RTLD_DEFAULT, "sctp_peeloff")) == NULL) {
+        JNU_ThrowByName(env, "java/lang/UnsupportedOperationException",
+              dlerror());
+        return JNI_FALSE;
+    }
+
+    funcsLoaded = JNI_TRUE;
+    return JNI_TRUE;
+}
+
+jint
+handleSocketError(JNIEnv *env, jint errorValue)
+{
+    char *xn;
+    switch (errorValue) {
+        case EINPROGRESS:     /* Non-blocking connect */
+            return 0;
+        case EPROTO:
+            xn= JNU_JAVANETPKG "ProtocolException";
+            break;
+        case ECONNREFUSED:
+            xn = JNU_JAVANETPKG "ConnectException";
+            break;
+        case ETIMEDOUT:
+            xn = JNU_JAVANETPKG "ConnectException";
+            break;
+        case EHOSTUNREACH:
+            xn = JNU_JAVANETPKG "NoRouteToHostException";
+            break;
+        case EADDRINUSE:  /* Fall through */
+        case EADDRNOTAVAIL:
+            xn = JNU_JAVANETPKG "BindException";
+            break;
+        default:
+            xn = JNU_JAVANETPKG "SocketException";
+            break;
+    }
+    errno = errorValue;
+    JNU_ThrowByNameWithLastError(env, xn, "NioSocketError");
+    return IOS_THROWN;
+}
+
+/*
+ * Class:     sun_nio_ch_sctp_SctpNet
+ * Method:    init
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL
+Java_sun_nio_ch_sctp_SctpNet_init
+  (JNIEnv *env, jclass cl) {
+    int sp[2];
+    if (socketpair(PF_UNIX, SOCK_STREAM, 0, sp) < 0) {
+        JNU_ThrowIOExceptionWithLastError(env, "socketpair failed");
+        return;
+    }
+    preCloseFD = sp[0];
+    close(sp[1]);
+}
+
+/*
+ * Class:     sun_nio_ch_sctp_SctpNet
+ * Method:    socket0
+ * Signature: (Z)I
+ */
+JNIEXPORT jint JNICALL Java_sun_nio_ch_sctp_SctpNet_socket0
+  (JNIEnv *env, jclass klass, jboolean oneToOne) {
+    int fd;
+    struct sctp_event_subscribe event;
+#ifdef AF_INET6
+    int domain = ipv6_available() ? AF_INET6 : AF_INET;
+#else
+    int domain = AF_INET;
+#endif
+
+    /* Try to load the socket API extension functions */
+    if (!funcsLoaded && !loadSocketExtensionFuncs(env)) {
+        return 0;
+    }
+
+    fd = socket(domain, (oneToOne ? SOCK_STREAM : SOCK_SEQPACKET), IPPROTO_SCTP);
+
+    if (fd < 0) {
+        return handleSocketError(env, errno);
+    }
+
+    /* Enable events */
+    memset(&event, 0, sizeof(event));
+    event.sctp_data_io_event = 1;
+    event.sctp_association_event = 1;
+    event.sctp_address_event = 1;
+    event.sctp_send_failure_event = 1;
+    //event.sctp_peer_error_event = 1;
+    event.sctp_shutdown_event = 1;
+    //event.sctp_partial_delivery_event = 1;
+    //event.sctp_adaptation_layer_event = 1;
+    if (setsockopt(fd, IPPROTO_SCTP, SCTP_EVENTS, &event, sizeof(event)) != 0) {
+       handleSocketError(env, errno);
+    }
+    return fd;
+}
+
+/*
+ * Class:     sun_nio_ch_sctp_SctpNet
+ * Method:    bindx
+ * Signature: (I[Ljava/net/InetAddress;IIZ)V
+ */
+JNIEXPORT void JNICALL Java_sun_nio_ch_sctp_SctpNet_bindx
+  (JNIEnv *env, jclass klass, jint fd, jobjectArray addrs, jint port,
+   jint addrsLength, jboolean add, jboolean preferIPv6) {
+    SOCKADDR *sap, *tmpSap;
+    int i, sa_len = sizeof(SOCKADDR);
+    jobject ia;
+
+    if (addrsLength < 1)
+        return;
+
+    if ((sap = calloc(addrsLength,  sa_len)) == NULL) {
+          JNU_ThrowOutOfMemoryError(env, "heap allocation failure");
+        return;
+    }
+
+    tmpSap = sap;
+    for (i=0; i<addrsLength; i++) {
+        ia = (*env)->GetObjectArrayElement(env, addrs, i);
+        if (NET_InetAddressToSockaddr(env, ia, port, (struct sockaddr*)tmpSap,
+                                      &sa_len, preferIPv6) != 0) {
+            free(sap);
+            return;
+        }
+        tmpSap++;
+    }
+
+    if (nio_sctp_bindx(fd, (void*)sap, addrsLength, add ? SCTP_BINDX_ADD_ADDR :
+                       SCTP_BINDX_REM_ADDR) != 0) {
+        handleSocketError(env, errno);
+    }
+
+    free(sap);
+}
+
+/*
+ * Class:     sun_nio_ch_sctp_SctpNet
+ * Method:    listen0
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL
+Java_sun_nio_ch_sctp_SctpNet_listen0
+  (JNIEnv *env, jclass cl, jint fd, jint backlog) {
+    if (listen(fd, backlog) < 0)
+        handleSocketError(env, errno);
+}
+
+/*
+ * Class:     sun_nio_ch_sctp_SctpNet
+ * Method:    connect0
+ * Signature: (ILjava/net/InetAddress;I)I
+ */
+JNIEXPORT jint JNICALL
+Java_sun_nio_ch_sctp_SctpNet_connect0
+  (JNIEnv *env, jclass clazz, int fd, jobject iao, jint port) {
+    SOCKADDR sa;
+    int sa_len = SOCKADDR_LEN;
+    int rv;
+
+    if (NET_InetAddressToSockaddr(env, iao, port, (struct sockaddr *) &sa,
+                                  &sa_len, JNI_TRUE) != 0) {
+        return IOS_THROWN;
+    }
+
+    rv = connect(fd, (struct sockaddr *)&sa, sa_len);
+    if (rv != 0) {
+        if (errno == EINPROGRESS) {
+            return IOS_UNAVAILABLE;
+        } else if (errno == EINTR) {
+            return IOS_INTERRUPTED;
+        }
+        return handleSocketError(env, errno);
+    }
+    return 1;
+}
+
+/*
+ * Class:     sun_nio_ch_sctp_SctpNet
+ * Method:    close0
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL
+Java_sun_nio_ch_sctp_SctpNet_close0
+  (JNIEnv *env, jclass clazz, jint fd) {
+    if (fd != -1) {
+        int rv = close(fd);
+        if (rv < 0)
+            JNU_ThrowIOExceptionWithLastError(env, "Close failed");
+    }
+}
+
+/*
+ * Class:     sun_nio_ch_sctp_SctpNet
+ * Method:    preClose0
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL
+Java_sun_nio_ch_sctp_SctpNet_preClose0
+  (JNIEnv *env, jclass clazz, jint fd) {
+    if (preCloseFD >= 0) {
+        if (dup2(preCloseFD, fd) < 0)
+            JNU_ThrowIOExceptionWithLastError(env, "dup2 failed");
+    }
+}
+
+void initializeISA
+  (JNIEnv* env) {
+    if (isaCls == 0) {
+        jclass c = (*env)->FindClass(env, "java/net/InetSocketAddress");
+        CHECK_NULL(c);
+        isaCls = (*env)->NewGlobalRef(env, c);
+        CHECK_NULL(isaCls);
+        (*env)->DeleteLocalRef(env, c);
+        isaCtrID = (*env)->GetMethodID(env, isaCls, "<init>",
+                                     "(Ljava/net/InetAddress;I)V");
+    }
+}
+
+jobject SockAddrToInetSocketAddress
+  (JNIEnv *env, struct sockaddr* sap) {
+    int port = 0;
+
+    jobject ia = NET_SockaddrToInetAddress(env, sap, &port);
+    if (ia == NULL)
+        return NULL;
+
+    if (isaCls == 0) {
+        initializeISA(env);
+        CHECK_NULL_RETURN(isaCls, NULL);
+    }
+
+    return (*env)->NewObject(env, isaCls, isaCtrID, ia, port);
+}
+
+/*
+ * Class:     sun_nio_ch_sctp_SctpNet
+ * Method:    getLocalAddresses0
+ * Signature: (I)[Ljava/net/SocketAddress;
+ */
+JNIEXPORT jobjectArray JNICALL Java_sun_nio_ch_sctp_SctpNet_getLocalAddresses0
+  (JNIEnv *env, jclass klass, jint fd) {
+    void *addr_buf, *laddr;
+    struct sockaddr* sap;
+    int i, addrCount;
+    jobjectArray isaa;
+
+#ifdef __solaris__
+    if ((addrCount = nio_sctp_getladdrs(fd, 0, (void **)&addr_buf)) == -1) {
+#else /* __linux__ */
+    if ((addrCount = nio_sctp_getladdrs(fd, 0, (struct sockaddr **)&addr_buf)) == -1) {
+#endif
+        handleSocketError(env, errno);
+        return NULL;
+    }
+
+    if (addrCount < 1)
+        return NULL;
+
+    if (isaCls == 0) {
+        initializeISA(env);
+        CHECK_NULL_RETURN(isaCls, NULL);
+    }
+
+    isaa = (*env)->NewObjectArray(env, addrCount, isaCls, NULL);
+    if (isaa == NULL) {
+        nio_sctp_freeladdrs(addr_buf);
+        return NULL;
+    }
+
+    laddr = addr_buf;
+    for (i=0; i<addrCount; i++) {
+        int port = 0;
+        jobject isa = NULL, ia;
+        sap = (struct sockaddr*)addr_buf;
+        ia = NET_SockaddrToInetAddress(env, sap, &port);
+        if (ia != NULL)
+            isa = (*env)->NewObject(env, isaCls, isaCtrID, ia, port);
+        if (isa != NULL)
+            (*env)->SetObjectArrayElement(env, isaa, i, isa);
+
+        if (sap->sa_family == AF_INET)
+            addr_buf = ((struct sockaddr_in*)addr_buf) + 1;
+        else
+            addr_buf = ((struct sockaddr_in6*)addr_buf) + 1;
+    }
+
+    nio_sctp_freeladdrs(laddr);
+    return isaa;
+}
+
+jobjectArray getRemoteAddresses
+  (JNIEnv *env, jint fd, sctp_assoc_t id) {
+    void *addr_buf, *paddr;
+    struct sockaddr* sap;
+    int i, addrCount;
+    jobjectArray isaa;
+
+#if __solaris__
+    if ((addrCount = nio_sctp_getpaddrs(fd, id, (void **)&addr_buf)) == -1) {
+#else /* __linux__ */
+    if ((addrCount = nio_sctp_getpaddrs(fd, id, (struct sockaddr**)&addr_buf)) == -1) {
+#endif
+        handleSocketError(env, errno);
+        return NULL;
+    }
+
+    if (addrCount < 1)
+        return NULL;
+
+    if (isaCls == 0) {
+        initializeISA(env);
+        CHECK_NULL_RETURN(isaCls, NULL);
+    }
+
+    isaa = (*env)->NewObjectArray(env, addrCount, isaCls, NULL);
+    if (isaa == NULL) {
+        nio_sctp_freepaddrs(addr_buf);
+        return NULL;
+    }
+
+    paddr = addr_buf;
+    for (i=0; i<addrCount; i++) {
+        jobject ia, isa = NULL;
+        int port;
+        sap = (struct sockaddr*)addr_buf;
+        ia = NET_SockaddrToInetAddress(env, sap, &port);
+        if (ia != NULL)
+            isa = (*env)->NewObject(env, isaCls, isaCtrID, ia, port);
+        if (isa != NULL)
+            (*env)->SetObjectArrayElement(env, isaa, i, isa);
+
+        if (sap->sa_family == AF_INET)
+            addr_buf = ((struct sockaddr_in*)addr_buf) + 1;
+        else
+            addr_buf = ((struct sockaddr_in6*)addr_buf) + 1;
+    }
+
+    nio_sctp_freepaddrs(paddr);
+
+    return isaa;
+}
+
+ /*
+ * Class:     sun_nio_ch_sctp_SctpNet
+ * Method:    getRemoteAddresses0
+ * Signature: (II)[Ljava/net/SocketAddress;
+ */
+JNIEXPORT jobjectArray JNICALL Java_sun_nio_ch_sctp_SctpNet_getRemoteAddresses0
+  (JNIEnv *env, jclass klass, jint fd, jint assocId) {
+    return getRemoteAddresses(env, fd, assocId);
+}
+
+/* Map the Java level option to the native level */
+int mapSocketOption
+  (jint cmd, int *level, int *optname) {
+    static struct {
+        jint cmd;
+        int level;
+        int optname;
+    } const opts[] = {
+        { sun_nio_ch_sctp_SctpStdSocketOption_SCTP_DISABLE_FRAGMENTS,   IPPROTO_SCTP, SCTP_DISABLE_FRAGMENTS },
+        { sun_nio_ch_sctp_SctpStdSocketOption_SCTP_EXPLICIT_COMPLETE,   IPPROTO_SCTP, SCTP_EXPLICIT_EOR },
+        { sun_nio_ch_sctp_SctpStdSocketOption_SCTP_FRAGMENT_INTERLEAVE, IPPROTO_SCTP, SCTP_FRAGMENT_INTERLEAVE },
+        { sun_nio_ch_sctp_SctpStdSocketOption_SCTP_NODELAY,             IPPROTO_SCTP, SCTP_NODELAY },
+        { sun_nio_ch_sctp_SctpStdSocketOption_SO_SNDBUF,                SOL_SOCKET,   SO_SNDBUF },
+        { sun_nio_ch_sctp_SctpStdSocketOption_SO_RCVBUF,                SOL_SOCKET,   SO_RCVBUF },
+        { sun_nio_ch_sctp_SctpStdSocketOption_SO_LINGER,                SOL_SOCKET,   SO_LINGER } };
+
+    int i;
+    for (i=0; i<(int)(sizeof(opts) / sizeof(opts[0])); i++) {
+        if (cmd == opts[i].cmd) {
+            *level = opts[i].level;
+            *optname = opts[i].optname;
+            return 0;
+        }
+    }
+
+    /* not found */
+    return -1;
+}
+
+/*
+ * Class:     sun_nio_ch_sctp_SctpNet
+ * Method:    setIntOption0
+ * Signature: (III)V
+ */
+JNIEXPORT void JNICALL Java_sun_nio_ch_sctp_SctpNet_setIntOption0
+  (JNIEnv *env, jclass klass, jint fd, jint opt, int arg) {
+    int klevel, kopt;
+    int result;
+    struct linger linger;
+    void *parg;
+    int arglen;
+
+    if (mapSocketOption(opt, &klevel, &kopt) < 0) {
+        JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
+                                     "Unsupported socket option");
+        return;
+    }
+
+    if (opt == sun_nio_ch_sctp_SctpStdSocketOption_SO_LINGER) {
+        parg = (void *)&linger;
+        arglen = sizeof(linger);
+        if (arg >= 0) {
+            linger.l_onoff = 1;
+            linger.l_linger = arg;
+        } else {
+            linger.l_onoff = 0;
+            linger.l_linger = 0;
+        }
+    } else {
+        parg = (void *)&arg;
+        arglen = sizeof(arg);
+    }
+
+    if (NET_SetSockOpt(fd, klevel, kopt, parg, arglen) < 0) {
+        JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
+                                     "sun_nio_ch_sctp_SctpNet.setIntOption0");
+    }
+}
+
+/*
+ * Class:     sun_nio_ch_sctp_SctpNet
+ * Method:    getIntOption0
+ * Signature: (II)I
+ */
+JNIEXPORT int JNICALL Java_sun_nio_ch_sctp_SctpNet_getIntOption0
+  (JNIEnv *env, jclass klass, jint fd, jint opt) {
+    int klevel, kopt;
+    int result;
+    struct linger linger;
+    void *arg;
+    int arglen;
+
+    if (mapSocketOption(opt, &klevel, &kopt) < 0) {
+        JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
+                                     "Unsupported socket option");
+        return -1;
+    }
+
+    if (opt == sun_nio_ch_sctp_SctpStdSocketOption_SO_LINGER) {
+        arg = (void *)&linger;
+        arglen = sizeof(linger);
+    } else {
+        arg = (void *)&result;
+        arglen = sizeof(result);
+    }
+
+    if (NET_GetSockOpt(fd, klevel, kopt, arg, &arglen) < 0) {
+        JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
+                                     "sun.nio.ch.Net.getIntOption");
+        return -1;
+    }
+
+    if (opt == sun_nio_ch_sctp_SctpStdSocketOption_SO_LINGER)
+        return linger.l_onoff ? linger.l_linger : -1;
+    else
+        return result;
+}
+
+/*
+ * Class:     sun_nio_ch_sctp_SctpNet
+ * Method:    getPrimAddrOption0
+ * Signature: (II)Ljava/net/SocketAddress;
+ */
+JNIEXPORT jobject JNICALL Java_sun_nio_ch_sctp_SctpNet_getPrimAddrOption0
+  (JNIEnv *env, jclass klass, jint fd, jint assocId) {
+    struct sctp_setprim prim;
+    unsigned int prim_len = sizeof(prim);
+    struct sockaddr* sap = (struct sockaddr*)&prim.ssp_addr;
+
+    prim.ssp_assoc_id = assocId;
+
+    if (getsockopt(fd, IPPROTO_SCTP, SCTP_PRIMARY_ADDR, &prim, &prim_len) < 0) {
+        JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
+                                     "sun.nio.ch.SctpNet.getPrimAddrOption0");
+        return NULL;
+    }
+
+    return SockAddrToInetSocketAddress(env, sap);
+}
+
+/*
+ * Class:     sun_nio_ch_sctp_SctpNet
+ * Method:    setPrimAddrOption0
+ * Signature: (IILjava/net/InetAddress;I)V
+ */
+JNIEXPORT void JNICALL Java_sun_nio_ch_sctp_SctpNet_setPrimAddrOption0
+  (JNIEnv *env, jclass klass, jint fd, jint assocId, jobject iaObj, jint port) {
+    struct sctp_setprim prim;
+    struct sockaddr* sap = (struct sockaddr*)&prim.ssp_addr;
+    int sap_len;
+
+    if (NET_InetAddressToSockaddr(env, iaObj, port, sap,
+                                  &sap_len, JNI_TRUE) != 0) {
+        return;
+    }
+
+    prim.ssp_assoc_id = assocId;
+
+    if (setsockopt(fd, IPPROTO_SCTP, SCTP_PRIMARY_ADDR, &prim, sizeof(prim)) < 0) {
+        JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
+                                     "sun.nio.ch.SctpNet.setPrimAddrOption0");
+    }
+}
+
+/*
+ * Class:     sun_nio_ch_sctp_SctpNet
+ * Method:    setPeerPrimAddrOption0
+ * Signature: (IILjava/net/InetAddress;I)V
+ */
+JNIEXPORT void JNICALL Java_sun_nio_ch_sctp_SctpNet_setPeerPrimAddrOption0
+  (JNIEnv *env, jclass klass, jint fd, jint assocId,
+   jobject iaObj, jint port, jboolean preferIPv6) {
+    struct sctp_setpeerprim prim;
+    struct sockaddr* sap = (struct sockaddr*)&prim.sspp_addr;
+    int sap_len;
+
+    if (NET_InetAddressToSockaddr(env, iaObj, port, sap,
+                                  &sap_len, preferIPv6) != 0) {
+        return;
+    }
+
+    prim.sspp_assoc_id = assocId;
+
+    if (setsockopt(fd, IPPROTO_SCTP, SCTP_SET_PEER_PRIMARY_ADDR, &prim,
+            sizeof(prim)) < 0) {
+        JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
+                                     "sun.nio.ch.SctpNet.setPeerPrimAddrOption0");
+    }
+}
+
+/*
+ * Class:     sun_nio_ch_sctp_SctpNet
+ * Method:    getInitMsgOption0
+ * Signature: (I[I)V
+ */
+JNIEXPORT void JNICALL Java_sun_nio_ch_sctp_SctpNet_getInitMsgOption0
+  (JNIEnv *env, jclass klass, jint fd, jintArray retVal) {
+    struct sctp_initmsg sctp_initmsg;
+    unsigned int sim_len = sizeof(sctp_initmsg);
+    int vals[2];
+
+    if (getsockopt(fd, IPPROTO_SCTP, SCTP_INITMSG, &sctp_initmsg,
+            &sim_len) < 0) {
+        JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
+                                     "sun.nio.ch.SctpNet.getInitMsgOption0");
+        return;
+    }
+
+    vals[0] = sctp_initmsg.sinit_max_instreams;
+    vals[1] = sctp_initmsg.sinit_num_ostreams;
+    (*env)->SetIntArrayRegion(env, retVal, 0, 2, vals);
+}
+
+/*
+ * Class:     sun_nio_ch_sctp_SctpNet
+ * Method:    setInitMsgOption0
+ * Signature: (III)V
+ */
+JNIEXPORT void JNICALL Java_sun_nio_ch_sctp_SctpNet_setInitMsgOption0
+  (JNIEnv *env, jclass klass, jint fd, jint inArg, jint outArg) {
+    struct sctp_initmsg sctp_initmsg;
+
+    sctp_initmsg.sinit_max_instreams = (unsigned int)inArg;
+    sctp_initmsg.sinit_num_ostreams = (unsigned int)outArg;
+    sctp_initmsg.sinit_max_attempts = 0;  // default
+    sctp_initmsg.sinit_max_init_timeo = 0;  // default
+
+    if (setsockopt(fd, IPPROTO_SCTP, SCTP_INITMSG, &sctp_initmsg,
+          sizeof(sctp_initmsg)) < 0) {
+        JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
+                                     "sun.nio.ch.SctpNet.setInitMsgOption0");
+    }
+}
+
+/*
+ * Class:     sun_nio_ch_sctp_SctpNet
+ * Method:    shutdown0
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL Java_sun_nio_ch_sctp_SctpNet_shutdown0
+  (JNIEnv *env, jclass klass, jint fd, jint assocId) {
+    int rv;
+    struct msghdr msg[1];
+    struct iovec iov[1];
+    int cbuf_size = CMSG_SPACE(sizeof (struct sctp_sndrcvinfo));
+    char cbuf[CMSG_SPACE(sizeof (struct sctp_sndrcvinfo))];
+    struct cmsghdr* cmsg;
+    struct sctp_sndrcvinfo *sri;
+
+    /* SctpSocketChannel */
+    if (assocId < 0) {
+        shutdown(fd, SHUT_WR);
+        return;
+    }
+
+    memset(msg, 0, sizeof (*msg));
+    memset(cbuf, 0, cbuf_size);
+    msg->msg_name = NULL;
+    msg->msg_namelen = 0;
+    iov->iov_base = NULL;
+    iov->iov_len = 0;
+    msg->msg_iov = iov;
+    msg->msg_iovlen = 1;
+    msg->msg_control = cbuf;
+    msg->msg_controllen = cbuf_size;
+    msg->msg_flags = 0;
+
+    cmsg = CMSG_FIRSTHDR(msg);
+    cmsg->cmsg_level = IPPROTO_SCTP;
+    cmsg->cmsg_type = SCTP_SNDRCV;
+    cmsg->cmsg_len = CMSG_LEN(sizeof(struct sctp_sndrcvinfo));
+
+    /* Initialize the payload: */
+    sri = (struct sctp_sndrcvinfo*) CMSG_DATA(cmsg);
+    memset(sri, 0, sizeof (*sri));
+
+    if (assocId > 0) {
+        sri->sinfo_assoc_id = assocId;
+    }
+
+    sri->sinfo_flags = sri->sinfo_flags | SCTP_EOF;
+
+    /* Sum of the length of all control messages in the buffer. */
+    msg->msg_controllen = cmsg->cmsg_len;
+
+    if ((rv = sendmsg(fd, msg, 0)) < 0) {
+        handleSocketError(env, errno);
+    }
+}
+
+/*
+ * Class:     sun_nio_ch_sctp_SctpNet
+ * Method:    branch
+ * Signature: (II)I
+ */
+JNIEXPORT int JNICALL Java_sun_nio_ch_sctp_SctpNet_branch0
+  (JNIEnv *env, jclass klass, jint fd, jint assocId) {
+    int newfd = 0;
+    if ((newfd = nio_sctp_peeloff(fd, assocId)) < 0) {
+        handleSocketError(env, errno);
+    }
+
+    return newfd;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/solaris/native/sun/nio/ch/sctp/SctpServerChannelImpl.c	Mon Feb 13 14:31:32 2012 +0000
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#include "sun_nio_ch_sctp_SctpServerChannelImpl.h"
+
+extern void Java_sun_nio_ch_ServerSocketChannelImpl_initIDs(JNIEnv* env,
+    jclass c);
+
+extern jint Java_sun_nio_ch_ServerSocketChannelImpl_accept0(JNIEnv* env,
+    jobject this, jobject ssfdo, jobject newfdo, jobjectArray isaa);
+
+/*
+ * Class:     sun_nio_ch_sctp_SctpServerChannelImpl
+ * Method:    initIDs
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_sun_nio_ch_sctp_SctpServerChannelImpl_initIDs
+  (JNIEnv* env, jclass c) {
+    Java_sun_nio_ch_ServerSocketChannelImpl_initIDs(env, c);
+}
+
+/*
+ * Class:     sun_nio_ch_sctp_SctpServerChannelImpl
+ * Method:    accept0
+ * Signature: (Ljava/io/FileDescriptor;Ljava/io/FileDescriptor;[Ljava/net/InetSocketAddress;)I
+ */
+JNIEXPORT jint JNICALL Java_sun_nio_ch_sctp_SctpServerChannelImpl_accept0
+  (JNIEnv* env, jobject this, jobject ssfdo, jobject newfdo, jobjectArray isaa) {
+    return Java_sun_nio_ch_ServerSocketChannelImpl_accept0(env, this,
+                                                           ssfdo, newfdo, isaa);
+}
--- a/jdk/src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c	Mon Feb 13 14:31:32 2012 +0000
@@ -605,9 +605,12 @@
 
 JNIEXPORT jbyteArray JNICALL
 Java_sun_nio_fs_UnixNativeDispatcher_readdir(JNIEnv* env, jclass this, jlong value) {
-    char entry[sizeof(struct dirent64) + PATH_MAX + 1];
-    struct dirent64* ptr = (struct dirent64*)&entry;
     struct dirent64* result;
+    struct {
+        struct dirent64 buf;
+        char name_extra[PATH_MAX + 1 - sizeof result->d_name];
+    } entry;
+    struct dirent64* ptr = &entry.buf;
     int res;
     DIR* dirp = jlong_to_ptr(value);
 
--- a/jdk/src/windows/classes/sun/nio/ch/SctpChannelImpl.java	Mon Feb 13 14:26:25 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,150 +0,0 @@
-/*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package sun.nio.ch;
-
-import java.net.SocketAddress;
-import java.net.InetAddress;
-import java.io.IOException;
-import java.util.Set;
-import java.nio.ByteBuffer;
-import java.nio.channels.spi.SelectorProvider;
-import com.sun.nio.sctp.Association;
-import com.sun.nio.sctp.MessageInfo;
-import com.sun.nio.sctp.NotificationHandler;
-import com.sun.nio.sctp.SctpChannel;
-import com.sun.nio.sctp.SctpSocketOption;
-
-/**
- * Unimplemented.
- */
-public class SctpChannelImpl extends SctpChannel
-{
-    private static final String message = "SCTP not supported on this platform";
-
-    public SctpChannelImpl(SelectorProvider provider) {
-        super(provider);
-        throw new UnsupportedOperationException(message);
-    }
-
-    @Override
-    public Association association() {
-        throw new UnsupportedOperationException(message);
-    }
-
-    @Override
-    public SctpChannel bind(SocketAddress local)
-                            throws IOException {
-        throw new UnsupportedOperationException(message);
-    }
-
-    @Override
-    public SctpChannel bindAddress(InetAddress address)
-         throws IOException {
-        throw new UnsupportedOperationException(message);
-    }
-
-    @Override
-    public SctpChannel unbindAddress(InetAddress address)
-         throws IOException {
-        throw new UnsupportedOperationException(message);
-    }
-
-    @Override
-    public boolean connect(SocketAddress remote) throws IOException {
-        throw new UnsupportedOperationException(message);
-    }
-
-    @Override
-    public boolean connect(SocketAddress remote, int maxOutStreams,
-       int maxInStreams) throws IOException {
-        throw new UnsupportedOperationException(message);
-    }
-
-    @Override
-    public boolean isConnectionPending() {
-        throw new UnsupportedOperationException(message);
-    }
-
-    @Override
-    public boolean finishConnect() throws IOException {
-        throw new UnsupportedOperationException(message);
-    }
-
-    @Override
-    public Set<SocketAddress> getAllLocalAddresses()
-            throws IOException {
-        throw new UnsupportedOperationException(message);
-    }
-
-    @Override
-    public Set<SocketAddress> getRemoteAddresses()
-            throws IOException {
-        throw new UnsupportedOperationException(message);
-    }
-
-    @Override
-    public SctpChannel shutdown() throws IOException {
-        throw new UnsupportedOperationException(message);
-    }
-
-    @Override
-    public <T> T getOption(SctpSocketOption<T> name)
-            throws IOException {
-        throw new UnsupportedOperationException(message);
-    }
-
-    @Override
-    public <T> SctpChannel setOption(SctpSocketOption<T> name, T value)
-        throws IOException {
-        throw new UnsupportedOperationException(message);
-    }
-
-    @Override
-    public Set<SctpSocketOption<?>> supportedOptions() {
-        throw new UnsupportedOperationException(message);
-    }
-
-    @Override
-    public <T> MessageInfo receive(ByteBuffer dst, T attachment,
-            NotificationHandler<T> handler) throws IOException {
-        throw new UnsupportedOperationException(message);
-    }
-
-    @Override
-    public int send(ByteBuffer src, MessageInfo messageInfo)
-            throws IOException {
-        throw new UnsupportedOperationException(message);
-    }
-
-    @Override
-    protected void implConfigureBlocking(boolean block) throws IOException {
-        throw new UnsupportedOperationException(message);
-    }
-
-    @Override
-    public void implCloseSelectableChannel() throws IOException {
-        throw new UnsupportedOperationException(message);
-    }
-}
--- a/jdk/src/windows/classes/sun/nio/ch/SctpMultiChannelImpl.java	Mon Feb 13 14:26:25 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,137 +0,0 @@
-/*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package sun.nio.ch;
-
-import java.net.SocketAddress;
-import java.net.InetAddress;
-import java.io.IOException;
-import java.util.Set;
-import java.nio.ByteBuffer;
-import java.nio.channels.spi.SelectorProvider;
-import com.sun.nio.sctp.Association;
-import com.sun.nio.sctp.SctpChannel;
-import com.sun.nio.sctp.MessageInfo;
-import com.sun.nio.sctp.NotificationHandler;
-import com.sun.nio.sctp.SctpMultiChannel;
-import com.sun.nio.sctp.SctpSocketOption;
-
-/**
- * Unimplemented.
- */
-public class SctpMultiChannelImpl extends SctpMultiChannel
-{
-    private static final String message = "SCTP not supported on this platform";
-
-    public SctpMultiChannelImpl(SelectorProvider provider) {
-        super(provider);
-        throw new UnsupportedOperationException(message);
-    }
-
-    @Override
-    public Set<Association> associations() {
-        throw new UnsupportedOperationException(message);
-    }
-
-    @Override
-    public SctpMultiChannel bind(SocketAddress local,
-            int backlog) throws IOException {
-        throw new UnsupportedOperationException(message);
-    }
-
-    @Override
-    public SctpMultiChannel bindAddress(InetAddress address)
-         throws IOException {
-        throw new UnsupportedOperationException(message);
-    }
-
-    @Override
-    public SctpMultiChannel unbindAddress(InetAddress address)
-         throws IOException {
-        throw new UnsupportedOperationException(message);
-    }
-
-    @Override
-    public Set<SocketAddress> getAllLocalAddresses()
-            throws IOException {
-        throw new UnsupportedOperationException(message);
-    }
-
-    @Override
-    public Set<SocketAddress> getRemoteAddresses
-            (Association association) throws IOException {
-        throw new UnsupportedOperationException(message);
-    }
-
-    @Override
-    public SctpMultiChannel shutdown(Association association)
-            throws IOException {
-        throw new UnsupportedOperationException(message);
-    }
-
-    @Override
-    public <T> T getOption(SctpSocketOption<T> name,
-            Association association) throws IOException {
-        throw new UnsupportedOperationException(message);
-    }
-
-    @Override
-    public <T> SctpMultiChannel setOption(SctpSocketOption<T> name,
-            T value, Association association) throws IOException {
-        throw new UnsupportedOperationException(message);
-    }
-
-    @Override
-    public Set<SctpSocketOption<?>> supportedOptions() {
-        throw new UnsupportedOperationException(message);
-    }
-
-    @Override
-    public <T> MessageInfo receive(ByteBuffer buffer, T attachment,
-            NotificationHandler<T> handler) throws IOException {
-        throw new UnsupportedOperationException(message);
-    }
-
-    @Override
-    public int send(ByteBuffer buffer, MessageInfo messageInfo)
-            throws IOException {
-        throw new UnsupportedOperationException(message);
-    }
-
-    @Override
-    public SctpChannel branch(Association association)
-            throws IOException {
-        throw new UnsupportedOperationException(message);
-    }
-
-    @Override
-    protected void implConfigureBlocking(boolean block) throws IOException {
-        throw new UnsupportedOperationException(message);
-    }
-
-    @Override
-    public void implCloseSelectableChannel() throws IOException {
-        throw new UnsupportedOperationException(message);
-    }
-}
--- a/jdk/src/windows/classes/sun/nio/ch/SctpServerChannelImpl.java	Mon Feb 13 14:26:25 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,102 +0,0 @@
-/*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package sun.nio.ch;
-
-import java.net.SocketAddress;
-import java.net.InetAddress;
-import java.io.IOException;
-import java.util.Set;
-import java.nio.channels.spi.SelectorProvider;
-import com.sun.nio.sctp.SctpChannel;
-import com.sun.nio.sctp.SctpServerChannel;
-import com.sun.nio.sctp.SctpSocketOption;
-
-/**
- * Unimplemented.
- */
-public class SctpServerChannelImpl extends SctpServerChannel
-{
-    private static final String message = "SCTP not supported on this platform";
-
-    public SctpServerChannelImpl(SelectorProvider provider) {
-        super(provider);
-        throw new UnsupportedOperationException(message);
-    }
-
-    @Override
-    public SctpChannel accept() throws IOException {
-        throw new UnsupportedOperationException(message);
-    }
-
-    @Override
-    public SctpServerChannel bind(SocketAddress local,
-            int backlog) throws IOException {
-        throw new UnsupportedOperationException(message);
-    }
-
-    @Override
-    public SctpServerChannel bindAddress(InetAddress address)
-         throws IOException {
-        throw new UnsupportedOperationException(message);
-    }
-
-    @Override
-    public SctpServerChannel unbindAddress(InetAddress address)
-         throws IOException {
-        throw new UnsupportedOperationException(message);
-    }
-
-    @Override
-    public Set<SocketAddress> getAllLocalAddresses()
-            throws IOException {
-        throw new UnsupportedOperationException(message);
-    }
-
-    @Override
-    public <T> T getOption(SctpSocketOption<T> name) throws IOException {
-        throw new UnsupportedOperationException(message);
-    }
-
-    @Override
-    public <T> SctpServerChannel setOption(SctpSocketOption<T> name,
-            T value) throws IOException {
-        throw new UnsupportedOperationException(message);
-    }
-
-    @Override
-    public Set<SctpSocketOption<?>> supportedOptions() {
-        throw new UnsupportedOperationException(message);
-    }
-
-    @Override
-    protected void implConfigureBlocking(boolean block) throws IOException {
-        throw new UnsupportedOperationException(message);
-    }
-
-    @Override
-    public void implCloseSelectableChannel() throws IOException {
-        throw new UnsupportedOperationException(message);
-    }
-}
--- a/jdk/src/windows/classes/sun/nio/ch/WindowsSelectorImpl.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/windows/classes/sun/nio/ch/WindowsSelectorImpl.java	Mon Feb 13 14:31:32 2012 +0000
@@ -585,7 +585,7 @@
             ((SelChImpl)selch).kill();
     }
 
-    void putEventOps(SelectionKeyImpl sk, int ops) {
+    public void putEventOps(SelectionKeyImpl sk, int ops) {
         synchronized (closeLock) {
             if (pollWrapper == null)
                 throw new ClosedSelectorException();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/windows/classes/sun/nio/ch/sctp/SctpChannelImpl.java	Mon Feb 13 14:31:32 2012 +0000
@@ -0,0 +1,150 @@
+/*
+ * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package sun.nio.ch.sctp;
+
+import java.net.SocketAddress;
+import java.net.InetAddress;
+import java.io.IOException;
+import java.util.Set;
+import java.nio.ByteBuffer;
+import java.nio.channels.spi.SelectorProvider;
+import com.sun.nio.sctp.Association;
+import com.sun.nio.sctp.MessageInfo;
+import com.sun.nio.sctp.NotificationHandler;
+import com.sun.nio.sctp.SctpChannel;
+import com.sun.nio.sctp.SctpSocketOption;
+
+/**
+ * Unimplemented.
+ */
+public class SctpChannelImpl extends SctpChannel
+{
+    private static final String message = "SCTP not supported on this platform";
+
+    public SctpChannelImpl(SelectorProvider provider) {
+        super(provider);
+        throw new UnsupportedOperationException(message);
+    }
+
+    @Override
+    public Association association() {
+        throw new UnsupportedOperationException(message);
+    }
+
+    @Override
+    public SctpChannel bind(SocketAddress local)
+                            throws IOException {
+        throw new UnsupportedOperationException(message);
+    }
+
+    @Override
+    public SctpChannel bindAddress(InetAddress address)
+         throws IOException {
+        throw new UnsupportedOperationException(message);
+    }
+
+    @Override
+    public SctpChannel unbindAddress(InetAddress address)
+         throws IOException {
+        throw new UnsupportedOperationException(message);
+    }
+
+    @Override
+    public boolean connect(SocketAddress remote) throws IOException {
+        throw new UnsupportedOperationException(message);
+    }
+
+    @Override
+    public boolean connect(SocketAddress remote, int maxOutStreams,
+       int maxInStreams) throws IOException {
+        throw new UnsupportedOperationException(message);
+    }
+
+    @Override
+    public boolean isConnectionPending() {
+        throw new UnsupportedOperationException(message);
+    }
+
+    @Override
+    public boolean finishConnect() throws IOException {
+        throw new UnsupportedOperationException(message);
+    }
+
+    @Override
+    public Set<SocketAddress> getAllLocalAddresses()
+            throws IOException {
+        throw new UnsupportedOperationException(message);
+    }
+
+    @Override
+    public Set<SocketAddress> getRemoteAddresses()
+            throws IOException {
+        throw new UnsupportedOperationException(message);
+    }
+
+    @Override
+    public SctpChannel shutdown() throws IOException {
+        throw new UnsupportedOperationException(message);
+    }
+
+    @Override
+    public <T> T getOption(SctpSocketOption<T> name)
+            throws IOException {
+        throw new UnsupportedOperationException(message);
+    }
+
+    @Override
+    public <T> SctpChannel setOption(SctpSocketOption<T> name, T value)
+        throws IOException {
+        throw new UnsupportedOperationException(message);
+    }
+
+    @Override
+    public Set<SctpSocketOption<?>> supportedOptions() {
+        throw new UnsupportedOperationException(message);
+    }
+
+    @Override
+    public <T> MessageInfo receive(ByteBuffer dst, T attachment,
+            NotificationHandler<T> handler) throws IOException {
+        throw new UnsupportedOperationException(message);
+    }
+
+    @Override
+    public int send(ByteBuffer src, MessageInfo messageInfo)
+            throws IOException {
+        throw new UnsupportedOperationException(message);
+    }
+
+    @Override
+    protected void implConfigureBlocking(boolean block) throws IOException {
+        throw new UnsupportedOperationException(message);
+    }
+
+    @Override
+    public void implCloseSelectableChannel() throws IOException {
+        throw new UnsupportedOperationException(message);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/windows/classes/sun/nio/ch/sctp/SctpMultiChannelImpl.java	Mon Feb 13 14:31:32 2012 +0000
@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package sun.nio.ch.sctp;
+
+import java.net.SocketAddress;
+import java.net.InetAddress;
+import java.io.IOException;
+import java.util.Set;
+import java.nio.ByteBuffer;
+import java.nio.channels.spi.SelectorProvider;
+import com.sun.nio.sctp.Association;
+import com.sun.nio.sctp.SctpChannel;
+import com.sun.nio.sctp.MessageInfo;
+import com.sun.nio.sctp.NotificationHandler;
+import com.sun.nio.sctp.SctpMultiChannel;
+import com.sun.nio.sctp.SctpSocketOption;
+
+/**
+ * Unimplemented.
+ */
+public class SctpMultiChannelImpl extends SctpMultiChannel
+{
+    private static final String message = "SCTP not supported on this platform";
+
+    public SctpMultiChannelImpl(SelectorProvider provider) {
+        super(provider);
+        throw new UnsupportedOperationException(message);
+    }
+
+    @Override
+    public Set<Association> associations() {
+        throw new UnsupportedOperationException(message);
+    }
+
+    @Override
+    public SctpMultiChannel bind(SocketAddress local,
+            int backlog) throws IOException {
+        throw new UnsupportedOperationException(message);
+    }
+
+    @Override
+    public SctpMultiChannel bindAddress(InetAddress address)
+         throws IOException {
+        throw new UnsupportedOperationException(message);
+    }
+
+    @Override
+    public SctpMultiChannel unbindAddress(InetAddress address)
+         throws IOException {
+        throw new UnsupportedOperationException(message);
+    }
+
+    @Override
+    public Set<SocketAddress> getAllLocalAddresses()
+            throws IOException {
+        throw new UnsupportedOperationException(message);
+    }
+
+    @Override
+    public Set<SocketAddress> getRemoteAddresses
+            (Association association) throws IOException {
+        throw new UnsupportedOperationException(message);
+    }
+
+    @Override
+    public SctpMultiChannel shutdown(Association association)
+            throws IOException {
+        throw new UnsupportedOperationException(message);
+    }
+
+    @Override
+    public <T> T getOption(SctpSocketOption<T> name,
+            Association association) throws IOException {
+        throw new UnsupportedOperationException(message);
+    }
+
+    @Override
+    public <T> SctpMultiChannel setOption(SctpSocketOption<T> name,
+            T value, Association association) throws IOException {
+        throw new UnsupportedOperationException(message);
+    }
+
+    @Override
+    public Set<SctpSocketOption<?>> supportedOptions() {
+        throw new UnsupportedOperationException(message);
+    }
+
+    @Override
+    public <T> MessageInfo receive(ByteBuffer buffer, T attachment,
+            NotificationHandler<T> handler) throws IOException {
+        throw new UnsupportedOperationException(message);
+    }
+
+    @Override
+    public int send(ByteBuffer buffer, MessageInfo messageInfo)
+            throws IOException {
+        throw new UnsupportedOperationException(message);
+    }
+
+    @Override
+    public SctpChannel branch(Association association)
+            throws IOException {
+        throw new UnsupportedOperationException(message);
+    }
+
+    @Override
+    protected void implConfigureBlocking(boolean block) throws IOException {
+        throw new UnsupportedOperationException(message);
+    }
+
+    @Override
+    public void implCloseSelectableChannel() throws IOException {
+        throw new UnsupportedOperationException(message);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/windows/classes/sun/nio/ch/sctp/SctpServerChannelImpl.java	Mon Feb 13 14:31:32 2012 +0000
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package sun.nio.ch.sctp;
+
+import java.net.SocketAddress;
+import java.net.InetAddress;
+import java.io.IOException;
+import java.util.Set;
+import java.nio.channels.spi.SelectorProvider;
+import com.sun.nio.sctp.SctpChannel;
+import com.sun.nio.sctp.SctpServerChannel;
+import com.sun.nio.sctp.SctpSocketOption;
+
+/**
+ * Unimplemented.
+ */
+public class SctpServerChannelImpl extends SctpServerChannel
+{
+    private static final String message = "SCTP not supported on this platform";
+
+    public SctpServerChannelImpl(SelectorProvider provider) {
+        super(provider);
+        throw new UnsupportedOperationException(message);
+    }
+
+    @Override
+    public SctpChannel accept() throws IOException {
+        throw new UnsupportedOperationException(message);
+    }
+
+    @Override
+    public SctpServerChannel bind(SocketAddress local,
+            int backlog) throws IOException {
+        throw new UnsupportedOperationException(message);
+    }
+
+    @Override
+    public SctpServerChannel bindAddress(InetAddress address)
+         throws IOException {
+        throw new UnsupportedOperationException(message);
+    }
+
+    @Override
+    public SctpServerChannel unbindAddress(InetAddress address)
+         throws IOException {
+        throw new UnsupportedOperationException(message);
+    }
+
+    @Override
+    public Set<SocketAddress> getAllLocalAddresses()
+            throws IOException {
+        throw new UnsupportedOperationException(message);
+    }
+
+    @Override
+    public <T> T getOption(SctpSocketOption<T> name) throws IOException {
+        throw new UnsupportedOperationException(message);
+    }
+
+    @Override
+    public <T> SctpServerChannel setOption(SctpSocketOption<T> name,
+            T value) throws IOException {
+        throw new UnsupportedOperationException(message);
+    }
+
+    @Override
+    public Set<SctpSocketOption<?>> supportedOptions() {
+        throw new UnsupportedOperationException(message);
+    }
+
+    @Override
+    protected void implConfigureBlocking(boolean block) throws IOException {
+        throw new UnsupportedOperationException(message);
+    }
+
+    @Override
+    public void implCloseSelectableChannel() throws IOException {
+        throw new UnsupportedOperationException(message);
+    }
+}
--- a/jdk/src/windows/native/sun/font/fontpath.c	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/src/windows/native/sun/font/fontpath.c	Mon Feb 13 14:31:32 2012 +0000
@@ -185,6 +185,12 @@
     return 0;
 }
 
+/* This HDC is initialised and released in the populate family map
+ * JNI entry point, and used within the call which would otherwise
+ * create many DCs.
+ */
+static HDC screenDC = NULL;
+
 static int DifferentFamily(wchar_t *family, wchar_t* fullName) {
     LOGFONTW lfw;
     CheckFamilyInfo info;
@@ -202,7 +208,7 @@
     memset(&lfw, 0, sizeof(lfw));
     wcscpy(lfw.lfFaceName, fullName);
     lfw.lfCharSet = DEFAULT_CHARSET;
-    EnumFontFamiliesExW(GetDC(NULL), &lfw,
+    EnumFontFamiliesExW(screenDC, &lfw,
                         (FONTENUMPROCW)CheckFontFamilyProcW,
                         (LPARAM)(&info), 0L);
 
@@ -299,7 +305,7 @@
     memset(&lfa, 0, sizeof(lfa));
     strcpy(lfa.lfFaceName, lpelfe->elfLogFont.lfFaceName);
     lfa.lfCharSet = lpelfe->elfLogFont.lfCharSet;
-    EnumFontFamiliesExA(GetDC(NULL), &lfa,
+    EnumFontFamiliesExA(screenDC, &lfa,
                         (FONTENUMPROCA)EnumFontFacesInFamilyProcA,
                         lParam, 0L);
     return 1;
@@ -353,7 +359,7 @@
     memset(&lfw, 0, sizeof(lfw));
     wcscpy(lfw.lfFaceName, lpelfe->elfLogFont.lfFaceName);
     lfw.lfCharSet = lpelfe->elfLogFont.lfCharSet;
-    EnumFontFamiliesExW(GetDC(NULL), &lfw,
+    EnumFontFamiliesExW(screenDC, &lfw,
                         (FONTENUMPROCW)EnumFontFacesInFamilyProcW,
                         lParam, 0L);
     return 1;
@@ -613,13 +619,17 @@
         return;
     }
 
+    screenDC = GetDC(NULL);
+    if (screenDC == NULL) {
+        return;
+    }
     /* Enumerate fonts via GDI to build maps of fonts and families */
     if (IS_NT) {
         LOGFONTW lfw;
         memset(&lfw, 0, sizeof(lfw));
         lfw.lfCharSet = DEFAULT_CHARSET;  /* all charsets */
         wcscpy(lfw.lfFaceName, L"");      /* one face per family (CHECK) */
-        EnumFontFamiliesExW(GetDC(NULL), &lfw,
+        EnumFontFamiliesExW(screenDC, &lfw,
                             (FONTENUMPROCW)EnumFamilyNamesW,
                             (LPARAM)(&fmi), 0L);
     } else {
@@ -627,7 +637,7 @@
         memset(&lfa, 0, sizeof(lfa));
         lfa.lfCharSet = DEFAULT_CHARSET; /* all charsets */
         strcpy(lfa.lfFaceName, "");      /* one face per family */
-        ret = EnumFontFamiliesExA(GetDC(NULL), &lfa,
+        ret = EnumFontFamiliesExA(screenDC, &lfa,
                             (FONTENUMPROCA)EnumFamilyNamesA,
                             (LPARAM)(&fmi), 0L);
     }
@@ -637,6 +647,8 @@
     ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
                        fontKeyName, 0L, KEY_READ, &hkeyFonts);
     if (ret != ERROR_SUCCESS) {
+        ReleaseDC(NULL, screenDC);
+        screenDC = NULL;
         return;
     }
 
@@ -653,6 +665,8 @@
         dwMaxValueNameLen >= MAX_BUFFER ||
         dwMaxValueDataLen >= MAX_BUFFER) {
         RegCloseKey(hkeyFonts);
+        ReleaseDC(NULL, screenDC);
+        screenDC = NULL;
         return;
     }
     for (nval = 0; nval < dwNumValues; nval++ ) {
@@ -692,4 +706,6 @@
         }
     }
     RegCloseKey(hkeyFonts);
+    ReleaseDC(NULL, screenDC);
+    screenDC = NULL;
 }
--- a/jdk/test/Makefile	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/test/Makefile	Mon Feb 13 14:31:32 2012 +0000
@@ -517,14 +517,14 @@
 JDK_ALL_TARGETS += jdk_nio2
 JDK_DEFAULT_TARGETS += jdk_nio2
 jdk_nio2: $(call TestDirs, java/nio/Buffer java/nio/ByteOrder \
-          java/nio/channels java/nio/MappedByteBuffer)
+          java/nio/channels java/nio/MappedByteBuffer sun/nio/ch)
 	$(call SharedLibraryPermissions,java/nio/channels)
 	$(call RunAgentvmBatch)
 
 # Stable agentvm testruns (minus items from PROBLEM_LIST)
 JDK_ALL_TARGETS += jdk_nio3
 JDK_DEFAULT_TARGETS += jdk_nio3
-jdk_nio3: $(call TestDirs, sun/nio)
+jdk_nio3: $(call TestDirs, java/nio/charset sun/nio/cs)
 	$(call RunAgentvmBatch)
 
 # All nio tests
--- a/jdk/test/ProblemList.txt	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/test/ProblemList.txt	Mon Feb 13 14:31:32 2012 +0000
@@ -211,78 +211,9 @@
 
 # jdk_management
 
-# Failing, bug was filed: 6959636
-javax/management/loading/LibraryLoader/LibraryLoaderTest.java   generic-all
-
-# Access denied messages on windows/mks, filed 6954450
-sun/management/jmxremote/bootstrap/RmiSslNoKeyStoreTest.sh      windows-all
-
-# Fails on linux: KO: StringMonitor notification missed or not emitted
-javax/management/monitor/NonComparableAttributeValueTest.java   generic-all
-
-# Port conflict? Fails with communication error
-sun/management/jmxremote/bootstrap/PasswordFilePermissionTest.sh generic-all
-
-# Fails on Windows 2000, Test failed for iiop java.lang.NullPointerException
-#  at org.omg.stub.javax.management.remote.rmi._RMIConnectionImpl_Tie._invoke(Unknown Source)
-#  at com.sun.corba.se.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:653)
-javax/management/remote/mandatory/connection/ReconnectTest.java generic-all
-
-# Solaris 10 sparc, NPE from org.omg.stub.javax.management.remote.rmi._RMIConnectionImpl_Tie._invoke
-javax/management/remote/mandatory/threads/ExecutorTest.java     generic-all
-
-# Linux 32bit Fedora 9, IllegalStateException
-javax/management/monitor/RuntimeExceptionTest.java              generic-all
-
-# Problems with rmi connection, othervm
-javax/management/remote/mandatory/subjectDelegation/SubjectDelegation2Test.java generic-all
-
-# Fails with port already in use
-sun/management/jmxremote/bootstrap/SSLConfigFilePermissionTest.sh generic-all
-
-# Fails with port already in use
-sun/management/jmxremote/bootstrap/RmiRegistrySslTest.sh        generic-all
-
-# Windows, connection can't last that long
-javax/management/eventService/LeaseTest.java                    generic-all
-
-# Linux othervm, X64, java.lang.Exception: Failed: ratio=102.4027795593753
-javax/management/remote/mandatory/notif/ListenerScaleTest.java  generic-all
-
-# Windows run seems to have triggered a hotspot gc error (see 6801625)
-com/sun/management/HotSpotDiagnosticMXBean/DumpHeap.sh          generic-all
-
-# rmi problem? othervm, java.lang.reflect.UndeclaredThrowableException
-javax/management/remote/mandatory/subjectDelegation/SubjectDelegation3Test.java generic-all
-
-# Linux Fedora 9 32bit NPE in rmi server somehere??? othervm
-javax/management/remote/mandatory/notif/NotificationBufferDeadlockTest.java generic-all
-
-# Times out on solaris sparc, with othervm
-javax/management/eventService/AddRemoveListenerTest.java        generic-all
-
-# Linux i586 and x64 -server, timed out waiting for threads to expire? othervm
-javax/management/eventService/EventClientThreadTest.java        generic-all
-
-# Linux i586 -server, Expected to receive 20, but got 21, othervm
-#   Fails on Linux X64 -server 20!=21
-javax/management/eventService/FetchingTest.java                 generic-all
-
-# NPE on windows 2000 i586 -client and -server
-javax/management/eventService/CustomForwarderTest.java          windows-all
-
-# Windows i586 failure, callback did not complete
-javax/management/eventService/LeaseManagerDeadlockTest.java     windows-all
-
-# Port already in use
-sun/management/jmxremote/bootstrap/LocalManagementTest.sh       generic-all
-
-# Failed to initialize connector (also overflowing jtreg io buffers)
-sun/management/jmxremote/bootstrap/RmiBootstrapTest.sh          generic-all
-sun/management/jmxremote/bootstrap/RmiSslBootstrapTest.sh       generic-all
-
-# Windows X64, java.lang.IllegalStateException
-javax/management/monitor/AttributeArbitraryDataTypeTest.java    generic-all
+# 7073626
+sun/management/jmxremote/bootstrap/RmiBootstrapTest.sh          windows-all
+sun/management/jmxremote/bootstrap/RmiSslBootstrapTest.sh       windows-all
 
 ############################################################################
 
@@ -410,71 +341,11 @@
 
 # jdk_rmi
 
-# Port already in use, fails on sparc, othervm
-java/rmi/reliability/benchmark/runRmiBench.sh                   generic-all
-
-# Already in use port issues? othervm solaris
-java/rmi/activation/rmidViaInheritedChannel/InheritedChannelNotServerSocket.java generic-all
-java/rmi/activation/rmidViaInheritedChannel/RmidViaInheritedChannel.java generic-all
-
-java/rmi/transport/rapidExportUnexport/RapidExportUnexport.java         generic-all
-java/rmi/transport/dgcDeadLock/TestImpl_Stub.java                       generic-all
-
-# Address already in use, othervm mode, solaris
-java/rmi/activation/Activatable/elucidateNoSuchMethod/ElucidateNoSuchMethod.java        generic-all
-java/rmi/activation/Activatable/forceLogSnapshot/ForceLogSnapshot.java  generic-all
-
-# Registry already running on port, solaris
-java/rmi/Naming/legalRegistryNames/LegalRegistryNames.java      generic-all
-
-# Fails on Linux 32 and 64bit -server?, impl not garbage collected???
-java/rmi/transport/pinLastArguments/PinLastArguments.java       generic-all
-
-# Times out on solaris sparc
-java/rmi/server/RemoteServer/AddrInUse.java                     generic-all
-
-# Connection error on Windows i586 -server
-#  Also connection errors in othervm on Solaris 10 sparc, same port???
-sun/rmi/transport/tcp/DeadCachedConnection.java                 generic-all
+# 7140992
+java/rmi/server/Unreferenced/finiteGCLatency/FiniteGCLatency.java generic-all
 
-# Connection errors in othervm on Solaris 10 sparc, same port???
-java/rmi/activation/Activatable/checkActivateRef/CheckActivateRef.java generic-all
-java/rmi/activation/Activatable/checkAnnotations/CheckAnnotations.java generic-all
-java/rmi/activation/Activatable/checkImplClassLoader/CheckImplClassLoader.java generic-all
-java/rmi/activation/Activatable/checkRegisterInLog/CheckRegisterInLog.java generic-all
-java/rmi/activation/Activatable/createPrivateActivable/CreatePrivateActivatable.java generic-all
-java/rmi/activation/Activatable/downloadParameterClass/DownloadParameterClass.java generic-all
-java/rmi/activation/Activatable/extLoadedImpl/ext.sh generic-all
-java/rmi/activation/Activatable/inactiveGroup/InactiveGroup.java generic-all
-java/rmi/activation/Activatable/lookupActivationSystem/LookupActivationSystem.java generic-all
-java/rmi/activation/Activatable/nestedActivate/NestedActivate.java generic-all
-java/rmi/activation/Activatable/restartCrashedService/RestartCrashedService.java generic-all
-java/rmi/activation/Activatable/restartLatecomer/RestartLatecomer.java generic-all
-java/rmi/activation/Activatable/shutdownGracefully/ShutdownGracefully.java generic-all
-java/rmi/activation/Activatable/unregisterInactive/UnregisterInactive.java generic-all
-java/rmi/activation/ActivateFailedException/activateFails/ActivateFails.java generic-all
-java/rmi/activation/ActivationGroup/downloadActivationGroup/DownloadActivationGroup.java generic-all
-java/rmi/activation/ActivationSystem/activeGroup/IdempotentActiveGroup.java generic-all
-java/rmi/reliability/juicer/AppleUserImpl.java generic-all
-java/rmi/server/RMISocketFactory/useSocketFactory/unicast/UseCustomSocketFactory.java generic-all
-java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/KeepAliveDuringCall.java generic-all
-java/rmi/transport/handshakeTimeout/HandshakeTimeout.java generic-all
-java/rmi/activation/Activatable/restartService/RestartService.java generic-all
-java/rmi/activation/ActivationSystem/modifyDescriptor/ModifyDescriptor.java generic-all
-java/rmi/activation/ActivationSystem/stubClassesPermitted/StubClassesPermitted.java generic-all
-java/rmi/activation/ActivationSystem/unregisterGroup/UnregisterGroup.java generic-all
-java/rmi/activation/CommandEnvironment/SetChildEnv.java generic-all
-java/rmi/registry/classPathCodebase/ClassPathCodebase.java generic-all
-java/rmi/registry/reexport/Reexport.java generic-all
-java/rmi/server/Unreferenced/finiteGCLatency/FiniteGCLatency.java generic-all
-java/rmi/server/Unreferenced/leaseCheckInterval/LeaseCheckInterval.java generic-all
-java/rmi/server/Unreferenced/unreferencedContext/UnreferencedContext.java generic-all
-java/rmi/server/useCustomRef/UseCustomRef.java generic-all
-java/rmi/transport/checkFQDN/CheckFQDN.java generic-all
-java/rmi/transport/checkLeaseInfoLeak/CheckLeaseLeak.java generic-all
-java/rmi/server/RMISocketFactory/useSocketFactory/activatable/UseCustomSocketFactory.java generic-all
-java/rmi/server/RMISocketFactory/useSocketFactory/registry/UseCustomSocketFactory.java generic-all
-java/rmi/server/UnicastRemoteObject/unexportObject/UnexportLeak.java generic-all
+# 6948101
+java/rmi/transport/pinLastArguments/PinLastArguments.java	generic-all
 
 # 7132247
 java/rmi/registry/readTest/readTest.sh				windows-all
@@ -557,6 +428,9 @@
 
 # jdk_tools
 
+# 6461635
+com/sun/tools/attach/BasicTests.sh                              generic-all
+
 # Filed 6952105
 com/sun/jdi/SuspendThreadTest.java                              generic-all
 
@@ -572,6 +446,9 @@
 # Filed 6402201
 com/sun/jdi/ProcessAttachTest.sh                                generic-all
 
+# 7144833
+sun/tools/jcmd/jcmd-Defaults.sh                                 generic-all
+
 # Filed 6986875
 sun/tools/jps/jps-Vvml.sh                                       generic-all
 
@@ -581,6 +458,10 @@
 # 7132203
 sun/jvmstat/monitor/MonitoredVm/CR6672135.java			generic-all
 
+# Tests take too long
+tools/pack200/CommandLineTests.java                         	generic-all
+tools/pack200/Pack200Test.java                              	generic-all
+
 ############################################################################
 
 # jdk_util
@@ -588,11 +469,6 @@
 # Filed 6933803
 java/util/concurrent/ThreadPoolExecutor/CoreThreadTimeOut.java  generic-all
 
-# Filed 7022325
-# Fails with assertion error on windows
-#   11 separate stacktraces created... file reuse problem?
-java/util/zip/ZipFile/ReadLongZipFileName.java                  generic-all
-
 # Filed 6772009
 java/util/concurrent/locks/ReentrantLock/CancelledLockLoops.java generic-all
 
--- a/jdk/test/TEST.ROOT	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/test/TEST.ROOT	Mon Feb 13 14:31:32 2012 +0000
@@ -4,3 +4,9 @@
 
 # The list of keywords supported in the entire test suite
 keys=2d dnd i18n
+
+# Tests that must run in othervm mode
+othervm.dirs=java/rmi sun/rmi javax/management
+
+# Tests that cannot run concurrently
+exclusiveAccess.dirs=java/rmi sun/rmi sun/management/jmxremote sun/tools/jstatd
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/beans/Introspector/7122138/Test7122138.java	Mon Feb 13 14:31:32 2012 +0000
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7122138
+ * @summary Tests generic methods reflection
+ * @author Sergey Malenkov
+ * @library ..
+ */
+
+import pack.Sub;
+
+public class Test7122138 {
+
+    public static void main(String[] args) throws Exception {
+        Class<Sub> type = Sub.class;
+        Sub object = type.newInstance();
+        String name = "name";
+        BeanUtils.getPropertyDescriptor(type, name).getWriteMethod().invoke(object, name);
+        if (!name.equals(object.getName())) {
+            throw new Error("name is not set");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/beans/Introspector/7122138/pack/Sub.java	Mon Feb 13 14:31:32 2012 +0000
@@ -0,0 +1,4 @@
+package pack;
+
+public class Sub<String> extends Super {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/beans/Introspector/7122138/pack/Super.java	Mon Feb 13 14:31:32 2012 +0000
@@ -0,0 +1,14 @@
+package pack;
+
+class Super<T> {
+
+    T name;
+
+    public void setName(T name) {
+        this.name = name;
+    }
+
+    public T getName() {
+        return name;
+    }
+}
--- a/jdk/test/java/nio/file/WatchService/Basic.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/test/java/nio/file/WatchService/Basic.java	Mon Feb 13 14:31:32 2012 +0000
@@ -25,7 +25,7 @@
  * @bug 4313887 6838333 7017446
  * @summary Unit test for java.nio.file.WatchService
  * @library ..
- * @run main/timeout=120 Basic
+ * @run main Basic
  */
 
 import java.nio.file.*;
@@ -281,11 +281,11 @@
 
             System.out.println("poll with timeout...");
             try {
-                long start = System.currentTimeMillis();
+                long start = System.nanoTime();
                 key = watcher.poll(3000, TimeUnit.MILLISECONDS);
                 if (key != null)
                     throw new RuntimeException("no keys registered");
-                long waited = System.currentTimeMillis() - start;
+                long waited = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start);
                 if (waited < 2900)
                     throw new RuntimeException("poll was too short");
             } catch (InterruptedException x) {
@@ -358,14 +358,14 @@
         }
 
         // assume that poll throws exception immediately
-        long start = System.currentTimeMillis();
+        long start = System.nanoTime();
         try {
             watcher.poll(10000, TimeUnit.MILLISECONDS);
             throw new RuntimeException("ClosedWatchServiceException not thrown");
         } catch (InterruptedException x) {
             throw new RuntimeException(x);
         } catch (ClosedWatchServiceException  x) {
-            long waited = System.currentTimeMillis() - start;
+            long waited = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start);
             if (waited > 5000)
                 throw new RuntimeException("poll was too long");
         }
--- a/jdk/test/java/nio/file/WatchService/SensitivityModifier.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/test/java/nio/file/WatchService/SensitivityModifier.java	Mon Feb 13 14:31:32 2012 +0000
@@ -23,9 +23,9 @@
 
 /* @test
  * @bug 4313887
- * @summary Sanity test for Sun-specific sensitivyt level watch event modifier
+ * @summary Sanity test for Sun-specific sensitivity level watch event modifier
  * @library ..
- * @run main/timeout=330 Basic
+ * @run main/timeout=240 SensitivityModifier
  */
 
 import java.nio.file.*;
@@ -96,6 +96,7 @@
 
             // drain events (to avoid interference)
             do {
+                key.pollEvents();
                 key.reset();
                 key = watcher.poll(1, TimeUnit.SECONDS);
             } while (key != null);
--- a/jdk/test/java/util/Currency/tablea1.txt	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/test/java/util/Currency/tablea1.txt	Mon Feb 13 14:31:32 2012 +0000
@@ -1,12 +1,12 @@
 #
 #
-# Based on BSi's ISO4217 data - "TABLE A1.doc" + amendments up until MA151.doc
-#   (As of 7 April 2011)
+# Based on BSi's ISO4217 data - "TABLE A1.doc" + amendments up until MA153.doc
+#   (As of 12 January 2012)
 #
 
 # Version
 FILEVERSION=1
-DATAVERSION=151
+DATAVERSION=153
 
 # ISO 4217 currency data
 AF	AFN	971	2
@@ -267,7 +267,7 @@
 UZ	UZS	860	2
 VU	VUV	548	0
 VE	VEF	937	2
-VN	VND	704	2
+VN	VND	704	0
 VG	USD	840	2
 VI	USD	840	2
 WF	XPF	953	0
--- a/jdk/test/java/util/concurrent/FutureTask/BlockingTaskExecutor.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/test/java/util/concurrent/FutureTask/BlockingTaskExecutor.java	Mon Feb 13 14:31:32 2012 +0000
@@ -75,10 +75,10 @@
             throw new Error("Executor stuck");
 
         // Wait for the invocation thread to complete.
-        thread.join(1000);
+        thread.join(5000);
         if (thread.isAlive()) {
             thread.interrupt();
-            thread.join(1000);
+            thread.join(5000);
             throw new Error("invokeAll stuck");
         }
     }
--- a/jdk/test/java/util/concurrent/ThreadPoolExecutor/Custom.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/test/java/util/concurrent/ThreadPoolExecutor/Custom.java	Mon Feb 13 14:31:32 2012 +0000
@@ -100,8 +100,8 @@
         equal(countExecutorThreads(), threadCount);
         equal(CustomTask.births.get(), threadCount);
         tpe.shutdown();
-        tpe.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
-        Thread.sleep(10);
+        tpe.awaitTermination(120, TimeUnit.SECONDS);
+        Thread.sleep(1000);
         equal(countExecutorThreads(), 0);
 
         CustomSTPE stpe = new CustomSTPE();
@@ -110,8 +110,8 @@
         equal(CustomSTPE.decorations.get(), threadCount);
         equal(countExecutorThreads(), threadCount);
         stpe.shutdown();
-        stpe.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
-        Thread.sleep(10);
+        stpe.awaitTermination(120, TimeUnit.SECONDS);
+        Thread.sleep(1000);
         equal(countExecutorThreads(), 0);
 
         System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
--- a/jdk/test/java/util/concurrent/locks/Lock/FlakyMutex.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/jdk/test/java/util/concurrent/locks/Lock/FlakyMutex.java	Mon Feb 13 14:31:32 2012 +0000
@@ -86,7 +86,7 @@
                 } catch (Throwable t) { unexpected(t); }}});}
         barrier.await();
         es.shutdown();
-        check(es.awaitTermination(10, TimeUnit.SECONDS));
+        check(es.awaitTermination(30, TimeUnit.SECONDS));
     }
 
     private static class FlakySync extends AbstractQueuedLongSynchronizer {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/crypto/CipherSpi/DirectBBRemaining.java	Mon Feb 13 14:31:32 2012 +0000
@@ -0,0 +1,181 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 7142509
+ * @summary Cipher.doFinal(ByteBuffer,ByteBuffer) fails to
+ *     process when in.remaining() == 0
+ */
+
+import java.nio.ByteBuffer;
+import java.security.SecureRandom;
+import java.util.Arrays;
+import java.util.Random;
+
+import javax.crypto.Cipher;
+import javax.crypto.SecretKey;
+import javax.crypto.spec.SecretKeySpec;
+
+/*
+ * Simple test case to show that Cipher.doFinal(ByteBuffer, ByteBuffer) fails to
+ * process the data internally buffered inBB the cipher when input.remaining()
+ * == 0 and at least one buffer is a direct buffer.
+ */
+public class DirectBBRemaining {
+
+    private static Random random = new SecureRandom();
+    private static int testSizes = 40;
+    private static int outputFrequency = 5;
+
+    public static void main(String args[]) throws Exception {
+        boolean failedOnce = false;
+        Exception failedReason = null;
+
+        byte[] keyBytes = new byte[8];
+        random.nextBytes(keyBytes);
+        SecretKey key = new SecretKeySpec(keyBytes, "DES");
+
+        Cipher cipher = Cipher.getInstance("DES/CBC/PKCS5Padding", "SunJCE");
+        cipher.init(Cipher.ENCRYPT_MODE, key);
+
+        /*
+         * Iterate through various sizes to make sure that the code does empty
+         * blocks, single partial blocks, 1 full block, full + partial blocks,
+         * multiple full blocks, etc. 5 blocks (using DES) is probably overkill
+         * but will feel more confident the fix isn't breaking anything.
+         */
+        System.out.println("Output test results for every "
+                + outputFrequency + " tests...");
+
+        for (int size = 0; size <= testSizes; size++) {
+            boolean output = (size % outputFrequency) == 0;
+            if (output) {
+                System.out.print("\nTesting buffer size: " + size + ":");
+            }
+
+            int outSize = cipher.getOutputSize(size);
+
+            try {
+                encrypt(cipher, size,
+                        ByteBuffer.allocate(size),
+                        ByteBuffer.allocate(outSize),
+                        ByteBuffer.allocateDirect(size),
+                        ByteBuffer.allocateDirect(outSize),
+                        output);
+            } catch (Exception e) {
+                System.out.print("\n    Failed with size " + size);
+                failedOnce = true;
+                failedReason = e;
+
+                // If we got an exception, let's be safe for future
+                // testing and reset the cipher to a known good state.
+                cipher.init(Cipher.ENCRYPT_MODE, key);
+            }
+        }
+        if (failedOnce) {
+            throw failedReason;
+        }
+        System.out.println("\nTest Passed...");
+    }
+
+    private enum TestVariant {
+
+        HEAP_HEAP, HEAP_DIRECT, DIRECT_HEAP, DIRECT_DIRECT
+    };
+
+    private static void encrypt(Cipher cipher, int size,
+            ByteBuffer heapIn, ByteBuffer heapOut,
+            ByteBuffer directIn, ByteBuffer directOut,
+            boolean output) throws Exception {
+
+        ByteBuffer inBB = null;
+        ByteBuffer outBB = null;
+
+        // Set up data and encrypt to known/expected values.
+        byte[] testdata = new byte[size];
+        random.nextBytes(testdata);
+        byte[] expected = cipher.doFinal(testdata);
+
+        for (TestVariant tv : TestVariant.values()) {
+            if (output) {
+                System.out.print(" " + tv);
+            }
+
+            switch (tv) {
+            case HEAP_HEAP:
+                inBB = heapIn;
+                outBB = heapOut;
+                break;
+            case HEAP_DIRECT:
+                inBB = heapIn;
+                outBB = directOut;
+                break;
+            case DIRECT_HEAP:
+                inBB = directIn;
+                outBB = heapOut;
+                break;
+            case DIRECT_DIRECT:
+                inBB = directIn;
+                outBB = directOut;
+                break;
+            }
+
+            inBB.clear();
+            outBB.clear();
+
+            inBB.put(testdata);
+            inBB.flip();
+
+            // Process all data in one shot, but don't call doFinal() yet.
+            // May store up to n-1 bytes (w/block size n) internally.
+            cipher.update(inBB, outBB);
+            if (inBB.hasRemaining()) {
+                throw new Exception("buffer not empty");
+            }
+
+            // finish encryption and process all data buffered
+            cipher.doFinal(inBB, outBB);
+            outBB.flip();
+
+            // validate output size
+            if (outBB.remaining() != expected.length) {
+                throw new Exception(
+                        "incomplete encryption output, expected "
+                        + expected.length + " bytes but was only "
+                        + outBB.remaining() + " bytes");
+            }
+
+            // validate output data
+            byte[] encrypted = new byte[outBB.remaining()];
+            outBB.get(encrypted);
+            if (!Arrays.equals(expected, encrypted)) {
+                throw new Exception("bad encryption output");
+            }
+
+            if (!Arrays.equals(cipher.doFinal(), cipher.doFinal())) {
+                throw new Exception("Internal buffers still held data!");
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JComboBox/7082443/bug7082443.java	Mon Feb 13 14:31:32 2012 +0000
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+ * @bug 7082443
+ * @summary JComboBox not backward compatible (with Java 6)
+ * @author Pavel Porvatov
+ */
+
+import javax.swing.*;
+import java.awt.*;
+
+public class bug7082443 {
+    public static final String GTK_LAF_CLASS = "GTKLookAndFeel";
+
+    public static void main(String[] args) throws Exception {
+        for (UIManager.LookAndFeelInfo lookAndFeelInfo : UIManager.getInstalledLookAndFeels()) {
+            if (lookAndFeelInfo.getClassName().contains(GTK_LAF_CLASS)) {
+                UIManager.setLookAndFeel(lookAndFeelInfo.getClassName());
+
+                SwingUtilities.invokeAndWait(new Runnable() {
+                    @Override
+                    public void run() {
+                        TestComboBox testComboBox = new TestComboBox();
+
+                        if (testComboBox.isOldRendererOpaque()) {
+                            System.out.println("Passed for " + GTK_LAF_CLASS);
+                        } else {
+                            throw new RuntimeException("Failed for " + GTK_LAF_CLASS);
+                        }
+                    }
+                });
+
+                return;
+            }
+        }
+
+        System.out.println(GTK_LAF_CLASS + " is not found. The test skipped");
+    }
+
+    private static class TestComboBox extends JComboBox {
+        private final ListCellRenderer renderer = new ListCellRenderer() {
+            @Override
+            public Component getListCellRendererComponent(JList list, Object value, int index,
+                                                          boolean isSelected, boolean cellHasFocus) {
+                return TestComboBox.super.getRenderer().getListCellRendererComponent(list, value, index,
+                        isSelected, cellHasFocus);
+            }
+        };
+
+        @Override
+        public ListCellRenderer getRenderer() {
+            return renderer;
+        }
+
+        public boolean isOldRendererOpaque() {
+            return ((JLabel) super.getRenderer()).isOpaque();
+        }
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JList/6462008/bug6462008.java	Mon Feb 13 14:31:32 2012 +0000
@@ -0,0 +1,415 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6462008
+ * @summary Tests that mouse/keyboard work properly on JList with lead < 0 or > list.getModel().getSize()
+ * @author Shannon Hickey
+ * @run main bug6462008
+ */
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+import java.util.*;
+import sun.awt.SunToolkit;
+
+public class bug6462008 {
+
+    private static final int DONT_CARE = -2;
+    private static int anchorLead;
+    private static boolean isAquaLAF;
+    private static int controlKey;
+    private static JList list;
+    private static SunToolkit toolkit;
+    private static Robot robot;
+
+    public static void main(String[] args) throws Exception {
+        toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+        robot = new Robot();
+        robot.setAutoDelay(100);
+
+        isAquaLAF = "Aqua".equals(UIManager.getLookAndFeel().getID());
+        controlKey = isAquaLAF ? KeyEvent.VK_META : KeyEvent.VK_CONTROL;
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                createAndShowGUI();
+            }
+        });
+
+        toolkit.realSync();
+
+        setAnchorLead(-1);
+        toolkit.realSync();
+
+        testListSelection();
+
+        setAnchorLead(100);
+        toolkit.realSync();
+
+        testListSelection();
+    }
+
+    public static void testListSelection() throws Exception {
+
+        // Space
+        robot.keyPress(KeyEvent.VK_SPACE);
+        robot.keyRelease(KeyEvent.VK_SPACE);
+
+        toolkit.realSync();
+        checkSelection();
+        resetList();
+        toolkit.realSync();
+
+        // Control + Space
+        robot.keyPress(KeyEvent.VK_CONTROL);
+        robot.keyPress(KeyEvent.VK_SPACE);
+        robot.keyRelease(KeyEvent.VK_SPACE);
+        robot.keyRelease(KeyEvent.VK_CONTROL);
+
+        toolkit.realSync();
+        checkSelection();
+        resetList();
+        toolkit.realSync();
+
+        // Shift + Space
+        robot.keyPress(KeyEvent.VK_SHIFT);
+        robot.keyPress(KeyEvent.VK_SPACE);
+        robot.keyRelease(KeyEvent.VK_SPACE);
+        robot.keyRelease(KeyEvent.VK_SHIFT);
+
+        toolkit.realSync();
+        checkSelection();
+        resetList();
+        toolkit.realSync();
+
+        // Control + Shift + Space
+        robot.keyPress(KeyEvent.VK_CONTROL);
+        robot.keyPress(KeyEvent.VK_SHIFT);
+        robot.keyPress(KeyEvent.VK_SPACE);
+        robot.keyRelease(KeyEvent.VK_SPACE);
+        robot.keyRelease(KeyEvent.VK_SHIFT);
+        robot.keyRelease(KeyEvent.VK_CONTROL);
+
+        toolkit.realSync();
+        checkSelection();
+        resetList();
+        toolkit.realSync();
+
+
+        // Control + A  Multiple Selection
+
+        robot.keyPress(controlKey);
+        robot.keyPress(KeyEvent.VK_A);
+        robot.keyRelease(KeyEvent.VK_A);
+        robot.keyRelease(controlKey);
+
+        toolkit.realSync();
+        checkSelectionAL(-1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
+        resetList();
+        setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+        toolkit.realSync();
+
+        // Control + A Single Selection
+        robot.keyPress(controlKey);
+        robot.keyPress(KeyEvent.VK_A);
+        robot.keyRelease(KeyEvent.VK_A);
+        robot.keyRelease(controlKey);
+
+        toolkit.realSync();
+        checkSelectionAL(0, 0, 0);
+        resetList();
+        setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+        setSelectionInterval(5, 5);
+        toolkit.realSync();
+
+
+        // Control + A Selection interval (5, 5)
+        robot.keyPress(controlKey);
+        robot.keyPress(KeyEvent.VK_A);
+        robot.keyRelease(KeyEvent.VK_A);
+        robot.keyRelease(controlKey);
+
+        toolkit.realSync();
+        checkSelection(5);
+        resetList();
+        toolkit.realSync();
+
+        // Page Down
+        // Not applicable for the Aqua L&F
+        if (!isAquaLAF) {
+            robot.keyPress(KeyEvent.VK_PAGE_DOWN);
+            robot.keyRelease(KeyEvent.VK_PAGE_DOWN);
+
+            toolkit.realSync();
+            checkSelection(9, 9, 9);
+            resetList();
+            toolkit.realSync();
+        }
+
+        // Shift + Page Down
+        /*
+         * We really want to use robot here, but there seems to be a bug in AWT's
+         * robot implementation (see 6463168). For now, we'll invoke the action
+         * directly instead. When the bug is fixed, we'll use the following four
+         * lines instead:
+         *     robot.keyPress(KeyEvent.VK_SHIFT);
+         *     robot.keyPress(KeyEvent.VK_PAGE_DOWN);
+         *     robot.keyRelease(KeyEvent.VK_PAGE_DOWN);
+         *     robot.keyRelease(KeyEvent.VK_SHIFT);
+         */
+
+        scrollDownExtendSelection();
+
+        toolkit.realSync();
+        checkSelection(0, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
+        resetList();
+        toolkit.realSync();
+
+        // Down
+        robot.keyPress(KeyEvent.VK_DOWN);
+        robot.keyRelease(KeyEvent.VK_DOWN);
+
+        toolkit.realSync();
+        checkSelectionAL(0, 0, 0);
+        resetList();
+        toolkit.realSync();
+
+        // L
+        robot.keyPress(KeyEvent.VK_L);
+        robot.keyRelease(KeyEvent.VK_L);
+
+        toolkit.realSync();
+        checkSelectionAL(0, 0, 0);
+        resetList();
+        toolkit.realSync();
+
+        // Click item 4
+        Point p = clickItem4();
+        robot.mouseMove(p.x, p.y);
+        robot.mousePress(InputEvent.BUTTON1_MASK);
+        robot.mouseRelease(InputEvent.BUTTON1_MASK);
+
+
+        toolkit.realSync();
+        checkSelectionAL(4, 4, 4);
+        resetList();
+        toolkit.realSync();
+
+
+        // Control + Click item 4
+        robot.keyPress(controlKey);
+        p = clickItem4();
+        robot.mouseMove(p.x, p.y);
+        robot.mousePress(InputEvent.BUTTON1_MASK);
+        robot.mouseRelease(InputEvent.BUTTON1_MASK);
+        robot.keyRelease(controlKey);
+
+
+        toolkit.realSync();
+        checkSelectionAL(4, 4, 4);
+        resetList();
+        toolkit.realSync();
+
+        // Shift + Click item 4
+        robot.keyPress(KeyEvent.VK_SHIFT);
+        p = clickItem4();
+        robot.mouseMove(p.x, p.y);
+        robot.mousePress(InputEvent.BUTTON1_MASK);
+        robot.mouseRelease(InputEvent.BUTTON1_MASK);
+        robot.keyRelease(KeyEvent.VK_SHIFT);
+
+
+        toolkit.realSync();
+        checkSelectionAL(0, 4, 0, 1, 2, 3, 4);
+        resetList();
+        toolkit.realSync();
+
+
+        // Control + Shift + Click item 4
+        robot.keyPress(controlKey);
+        robot.keyPress(KeyEvent.VK_SHIFT);
+        p = clickItem4();
+        robot.mouseMove(p.x, p.y);
+        robot.mousePress(InputEvent.BUTTON1_MASK);
+        robot.mouseRelease(InputEvent.BUTTON1_MASK);
+        robot.keyRelease(KeyEvent.VK_SHIFT);
+        robot.keyRelease(controlKey);
+
+        toolkit.realSync();
+        checkSelectionAL(0, 4);
+        resetList();
+        toolkit.realSync();
+    }
+
+    private static DefaultListModel getModel() {
+        DefaultListModel listModel = new DefaultListModel();
+        for (int i = 0; i < 10; i++) {
+            listModel.addElement("List Item " + i);
+        }
+        return listModel;
+    }
+
+    private static Point clickItem4() throws Exception {
+
+        final Point[] result = new Point[1];
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                Rectangle r = list.getCellBounds(4, 4);
+                Point p = new Point(r.x + r.width / 2, r.y + r.height / 2);
+                SwingUtilities.convertPointToScreen(p, list);
+                result[0] = p;
+            }
+        });
+
+        return result[0];
+    }
+
+    private static void resetList() throws Exception {
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                list.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
+                list.getSelectionModel().clearSelection();
+                setAnchorLeadNonThreadSafe();
+            }
+        });
+    }
+
+    private static void scrollDownExtendSelection() throws Exception {
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                list.getActionMap().get("scrollDownExtendSelection").
+                        actionPerformed(new ActionEvent(list,
+                        ActionEvent.ACTION_PERFORMED, null));
+            }
+        });
+    }
+
+    private static void setSelectionMode(final int selectionMode) throws Exception {
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                list.getSelectionModel().setSelectionMode(selectionMode);
+                setAnchorLeadNonThreadSafe();
+            }
+        });
+    }
+
+    private static void setSelectionInterval(final int index0, final int index1) throws Exception {
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                list.getSelectionModel().setSelectionInterval(index0, index1);
+                setAnchorLeadNonThreadSafe();
+            }
+        });
+    }
+
+    private static void setAnchorLead(final int anchorLeadValue) throws Exception {
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                anchorLead = anchorLeadValue;
+                setAnchorLeadNonThreadSafe();
+            }
+        });
+    }
+
+    private static void setAnchorLeadNonThreadSafe() {
+        list.getSelectionModel().setAnchorSelectionIndex(anchorLead);
+        ((DefaultListSelectionModel) list.getSelectionModel()).moveLeadSelectionIndex(anchorLead);
+    }
+
+    private static void createAndShowGUI() {
+        JFrame frame = new JFrame("bug6462008");
+        frame.setSize(200, 500);
+        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+        list = new JList(getModel());
+        JPanel panel = new JPanel(new BorderLayout());
+        panel.add(list);
+        frame.getContentPane().add(panel);
+
+        frame.setVisible(true);
+    }
+
+    private static void checkSelection(int... sels) throws Exception {
+        checkSelectionAL(DONT_CARE, DONT_CARE, sels);
+    }
+
+    private static void checkSelectionAL(final int anchor, final int lead, final int... sels) throws Exception {
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                checkSelectionNonThreadSafe(anchor, lead, sels);
+            }
+        });
+    }
+
+    private static void checkSelectionNonThreadSafe(int anchor, int lead, int... sels) {
+        ListSelectionModel lsm = list.getSelectionModel();
+
+        int actualAnchor = lsm.getAnchorSelectionIndex();
+        int actualLead = lsm.getLeadSelectionIndex();
+
+        if (anchor != DONT_CARE && actualAnchor != anchor) {
+            throw new RuntimeException("anchor is " + actualAnchor + ", should be " + anchor);
+        }
+
+        if (lead != DONT_CARE && actualLead != lead) {
+            throw new RuntimeException("lead is " + actualLead + ", should be " + lead);
+        }
+
+        Arrays.sort(sels);
+        boolean[] checks = new boolean[list.getModel().getSize()];
+        for (int i : sels) {
+            checks[i] = true;
+        }
+
+        int index0 = Math.min(lsm.getMinSelectionIndex(), 0);
+        int index1 = Math.max(lsm.getMaxSelectionIndex(), list.getModel().getSize() - 1);
+
+        for (int i = index0; i <= index1; i++) {
+            if (lsm.isSelectedIndex(i)) {
+                if (i < 0 || i >= list.getModel().getSize() || !checks[i]) {
+                    throw new RuntimeException(i + " is selected when it should not be");
+                }
+            } else if (i >= 0 && i < list.getModel().getSize() && checks[i]) {
+                throw new RuntimeException(i + " is supposed to be selected");
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JPopupMenu/4966112/bug4966112.java	Mon Feb 13 14:31:32 2012 +0000
@@ -0,0 +1,312 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 4966112
+ * @summary Some Composite components does not show the Context Popup.
+ * @library ../../regtesthelpers
+ * @build Util
+ * @author Alexander Zuev
+ * @run main bug4966112
+ */
+import javax.swing.*;
+import javax.swing.event.PopupMenuListener;
+import javax.swing.event.PopupMenuEvent;
+import java.awt.*;
+import java.awt.event.*;
+import sun.awt.SunToolkit;
+
+public class bug4966112 {
+
+    private static final int NO_MOUSE_BUTTON = -1;
+    private static volatile boolean shown = false;
+    private static volatile int popupButton = NO_MOUSE_BUTTON;
+    private static volatile JButton testButton;
+    private static volatile JSplitPane jsp;
+    private static volatile JSpinner spin;
+    private static volatile JFileChooser filec;
+    private static int buttonMask;
+    private static Robot robot;
+
+    public static void main(String[] args) throws Exception {
+        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+        robot = new Robot();
+        robot.setAutoDelay(100);
+
+        createAndShowButton();
+        toolkit.realSync();
+
+        setClickPoint(testButton);
+        clickMouse(InputEvent.BUTTON1_MASK);
+        clickMouse(InputEvent.BUTTON2_MASK);
+        clickMouse(InputEvent.BUTTON3_MASK);
+
+        toolkit.realSync();
+        closeFrame();
+
+        if (popupButton == NO_MOUSE_BUTTON) {
+            System.out.println("Test can't identify the popup trigger button. Test skipped");
+            return;
+        }
+
+        setButtonMask();
+
+        // Test Split Pane
+        createAndShowSplitPane();
+        toolkit.realSync();
+
+        clickMouse(jsp);
+        toolkit.realSync();
+        closeFrame();
+
+        if (!shown) {
+            throw new RuntimeException("Popup was not shown on splitpane");
+        }
+
+        // Test Spinner
+        createAndShowSpinner();
+        toolkit.realSync();
+
+        clickMouse(spin);
+        toolkit.realSync();
+        closeFrame();
+
+        if (!shown) {
+            throw new RuntimeException("Popup was not shown on spinner");
+        }
+
+        // Test File Chooser
+        createAndShowFileChooser();
+        toolkit.realSync();
+
+        clickMouse(filec);
+        toolkit.realSync();
+
+        Util.hitKeys(robot, KeyEvent.VK_ESCAPE);
+        toolkit.realSync();
+
+        Util.hitKeys(robot, KeyEvent.VK_ESCAPE);
+        toolkit.realSync();
+        closeFrame();
+
+        if (!shown) {
+            throw new RuntimeException("Popup was not shown on filechooser");
+        }
+    }
+
+    private static void clickMouse(JComponent c) throws Exception {
+        setClickPoint(c);
+        clickMouse(buttonMask);
+    }
+
+    private static void clickMouse(int buttons) {
+        robot.mousePress(buttons);
+        robot.mouseRelease(buttons);
+    }
+
+    private static void setButtonMask() {
+        switch (popupButton) {
+            case MouseEvent.BUTTON1:
+                buttonMask = InputEvent.BUTTON1_MASK;
+                break;
+            case MouseEvent.BUTTON2:
+                buttonMask = InputEvent.BUTTON2_MASK;
+                break;
+            case MouseEvent.BUTTON3:
+                buttonMask = InputEvent.BUTTON3_MASK;
+                break;
+        }
+    }
+
+    private static void setClickPoint(final JComponent c) throws Exception {
+        final Point[] result = new Point[1];
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                Point p = c.getLocationOnScreen();
+                Dimension size = c.getSize();
+                result[0] = new Point(p.x + size.width / 2, p.y + size.height / 2);
+            }
+        });
+
+        robot.mouseMove(result[0].x, result[0].y);
+    }
+
+    private static JPopupMenu createJPopupMenu() {
+        JPopupMenu jpm = new JPopupMenu();
+        jpm.add("One");
+        jpm.add("Two");
+        jpm.add("Three");
+        jpm.addPopupMenuListener(new PopupMenuListener() {
+
+            public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
+                shown = true;
+            }
+
+            public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
+            }
+
+            public void popupMenuCanceled(PopupMenuEvent e) {
+            }
+        });
+
+        AutoClosable.INSTANCE.setPopup(jpm);
+        return jpm;
+    }
+
+    private static void createAndShowButton() throws Exception {
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                JFrame frame = new JFrame("Button Frame");
+                frame.setLayout(new BorderLayout());
+                testButton = new JButton("Popup Tester");
+
+                testButton.addMouseListener(new MouseAdapter() {
+
+                    void setPopupTrigger(MouseEvent e) {
+                        if (e.isPopupTrigger()) {
+                            popupButton = e.getButton();
+                        }
+                    }
+
+                    public void mouseClicked(MouseEvent e) {
+                        setPopupTrigger(e);
+                    }
+
+                    public void mousePressed(MouseEvent e) {
+                        setPopupTrigger(e);
+                    }
+
+                    public void mouseReleased(MouseEvent e) {
+                        setPopupTrigger(e);
+                    }
+                });
+
+                frame.add(testButton, BorderLayout.CENTER);
+                frame.pack();
+                frame.setVisible(true);
+                AutoClosable.INSTANCE.setFrame(frame);
+            }
+        });
+    }
+
+    private static void createAndShowSplitPane() throws Exception {
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                JFrame frame = new JFrame("Test SplitPane");
+                frame.setSize(250, 200);
+                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+                frame.setLayout(new BorderLayout());
+
+                shown = false;
+                jsp = new JSplitPane();
+                jsp.setRightComponent(new JPanel());
+                jsp.setLeftComponent(new JPanel());
+                jsp.setComponentPopupMenu(createJPopupMenu());
+
+                frame.add(jsp, BorderLayout.CENTER);
+
+                jsp.setDividerLocation(150);
+
+                frame.setLocation(400, 300);
+                frame.setVisible(true);
+                AutoClosable.INSTANCE.setFrame(frame);
+            }
+        });
+    }
+
+    private static void createAndShowSpinner() throws Exception {
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                JFrame frame = new JFrame("JSpinner Test");
+                frame.setLayout(new BorderLayout());
+                frame.setSize(200, 100);
+                shown = false;
+                spin = new JSpinner();
+                spin.setComponentPopupMenu(createJPopupMenu());
+                frame.add(spin, BorderLayout.CENTER);
+                frame.setVisible(true);
+                AutoClosable.INSTANCE.setFrame(frame);
+            }
+        });
+    }
+
+    private static void createAndShowFileChooser() throws Exception {
+        SwingUtilities.invokeLater(new Runnable() {
+
+            @Override
+            public void run() {
+                JFrame frame = new JFrame("FileChooser test dialog");
+                frame.setSize(100, 100);
+
+                shown = false;
+                filec = new JFileChooser();
+                filec.setComponentPopupMenu(createJPopupMenu());
+                filec.showOpenDialog(frame);
+
+                frame.setVisible(true);
+                AutoClosable.INSTANCE.setFrame(frame);
+            }
+        });
+    }
+
+    private static void closeFrame() {
+        SwingUtilities.invokeLater(new Runnable() {
+
+            @Override
+            public void run() {
+                AutoClosable.INSTANCE.close();
+            }
+        });
+    }
+
+    private static class AutoClosable {
+
+        static final AutoClosable INSTANCE = new AutoClosable();
+        private JFrame frame;
+        private JPopupMenu popup;
+
+        public void setFrame(JFrame frame) {
+            this.frame = frame;
+        }
+
+        public void setPopup(JPopupMenu popup) {
+            this.popup = popup;
+        }
+
+        public void close() {
+            frame.dispose();
+            if (popup != null) {
+                popup.setVisible(false);
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JPopupMenu/6827786/bug6827786.java	Mon Feb 13 14:31:32 2012 +0000
@@ -0,0 +1,145 @@
+/*
+ * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6827786
+ * @summary Tests duplicate mnemonics
+ * @author Peter Zhelezniakov
+ * @library ../../regtesthelpers
+ * @build Util
+ * @run main bug6827786
+ */
+import java.awt.*;
+import java.awt.event.KeyEvent;
+import javax.swing.*;
+import sun.awt.SunToolkit;
+
+public class bug6827786 {
+
+    private static JMenu menu;
+    private static Component focusable;
+
+    public static void main(String[] args) throws Exception {
+        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+        Robot robot = new Robot();
+        robot.setAutoDelay(50);
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            public void run() {
+                createAndShowGUI();
+            }
+        });
+
+        toolkit.realSync();
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            public void run() {
+                focusable.requestFocus();
+            }
+        });
+
+        toolkit.realSync();
+        checkfocus();
+
+        // select menu
+        Util.hitKeys(robot, KeyEvent.VK_ALT, KeyEvent.VK_F);
+        // select submenu
+        Util.hitKeys(robot, KeyEvent.VK_S);
+        toolkit.realSync();
+        // verify submenu is selected
+        verify(1);
+
+        Util.hitKeys(robot, KeyEvent.VK_S);
+        toolkit.realSync();
+        // verify last item is selected
+        verify(2);
+
+        Util.hitKeys(robot, KeyEvent.VK_S);
+        toolkit.realSync();
+        // selection should wrap to first item
+        verify(0);
+
+        System.out.println("PASSED");
+
+    }
+
+    private static void checkfocus() throws Exception {
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            public void run() {
+                if (!focusable.isFocusOwner()) {
+                    throw new RuntimeException("Button is not the focus owner.");
+                }
+            }
+        });
+    }
+
+    private static void verify(final int index) throws Exception {
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                MenuElement[] path =
+                        MenuSelectionManager.defaultManager().getSelectedPath();
+                MenuElement item = path[3];
+                if (item != menu.getMenuComponent(index)) {
+                    System.err.println("Selected: " + item);
+                    System.err.println("Should be: "
+                            + menu.getMenuComponent(index));
+                    throw new RuntimeException("Test Failed");
+                }
+            }
+        });
+    }
+
+    private static JMenuBar createMenuBar() {
+        menu = new JMenu("File");
+        menu.setMnemonic('F');
+
+        menu.add(new JMenuItem("Save", 'S'));
+
+        JMenu sub = new JMenu("Submenu");
+        sub.setMnemonic('S');
+        sub.add(new JMenuItem("Sub Item"));
+        menu.add(sub);
+
+        menu.add(new JMenuItem("Special", 'S'));
+
+        JMenuBar bar = new JMenuBar();
+        bar.add(menu);
+        return bar;
+    }
+
+    private static void createAndShowGUI() {
+        JFrame frame = new JFrame("bug6827786");
+        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+        frame.setJMenuBar(createMenuBar());
+        focusable = new JButton("Set Focus Here");
+        frame.add(focusable);
+        frame.pack();
+        frame.setVisible(true);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JTabbedPane/7010561/bug7010561.java	Mon Feb 13 14:31:32 2012 +0000
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import javax.swing.*;
+import javax.swing.plaf.basic.BasicTabbedPaneUI;
+import javax.swing.plaf.synth.SynthLookAndFeel;
+import java.lang.reflect.Method;
+
+/* @test
+   @bug 7010561
+   @summary Tab text position with Synth based LaF is different to Java 5/6
+   @author Pavel Porvatov
+*/
+public class bug7010561 {
+    private static int[] TAB_PLACEMENT = {
+            SwingConstants.BOTTOM,
+            SwingConstants.BOTTOM,
+            SwingConstants.TOP,
+            SwingConstants.TOP,
+
+    };
+
+    private static boolean[] IS_SELECTED = {
+            false,
+            true,
+            false,
+            true
+    };
+
+    private static int[] RETURN_VALUE = {
+            -1,
+            1,
+            1,
+            -1
+    };
+
+    public static void main(String[] args) throws Exception {
+        UIManager.setLookAndFeel(new SynthLookAndFeel());
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
+            public void run() {
+                JTabbedPane tabbedPane = new JTabbedPane();
+
+                tabbedPane.addTab("Tab 1", new JLabel("Tab 1"));
+
+                // Ensure internal TabbedPane fields are initialized
+                tabbedPane.doLayout();
+
+                BasicTabbedPaneUI basicTabbedPaneUI = (BasicTabbedPaneUI) tabbedPane.getUI();
+
+                try {
+                    Method method = BasicTabbedPaneUI.class.getDeclaredMethod("getTabLabelShiftY", int.class,
+                            int.class, boolean.class);
+
+                    method.setAccessible(true);
+
+                    for (int i = 0; i < 4; i++) {
+                        int res = ((Integer) method.invoke(basicTabbedPaneUI, TAB_PLACEMENT[i], 0,
+                                IS_SELECTED[i])).intValue();
+
+                        if (res != RETURN_VALUE[i]) {
+                            throw new RuntimeException("Test bug7010561 failed on index " + i);
+                        }
+                    }
+                } catch (Exception e) {
+                    throw new RuntimeException(e);
+                }
+
+                System.out.println("Test bug7010561 passed");
+            }
+        });
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JTree/6263446/bug6263446.java	Mon Feb 13 14:31:32 2012 +0000
@@ -0,0 +1,272 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6263446
+ * @summary Tests that double-clicking to edit a cell doesn't select the content.
+ * @author Shannon Hickey
+ * @run main bug6263446
+ */
+import java.awt.*;
+import java.awt.event.InputEvent;
+import java.lang.reflect.Field;
+import javax.swing.*;
+import javax.swing.tree.*;
+import sun.awt.SunToolkit;
+
+public class bug6263446 {
+
+    private static final String FIRST = "AAAAAAAAAAA";
+    private static final String SECOND = "BB";
+    private static final String ALL = FIRST + " " + SECOND;
+    private static JTree tree;
+    private static Robot robot;
+    private static SunToolkit toolkit;
+
+    public static void main(String[] args) throws Exception {
+        toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+        robot = new Robot();
+        robot.setAutoDelay(50);
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            public void run() {
+                createAndShowGUI();
+            }
+        });
+
+        toolkit.realSync();
+
+        Point point = getClickPoint();
+        robot.mouseMove(point.x, point.y);
+
+        // click count 3
+        click(1);
+        assertNotEditing();
+
+        click(2);
+        assertNotEditing();
+
+        click(3);
+        assertEditing();
+        cancelCellEditing();
+        assertNotEditing();
+
+        click(4);
+        checkSelectedText(FIRST);
+
+        click(5);
+        checkSelectedText(ALL);
+
+        // click count 4
+        setClickCountToStart(4);
+
+        click(1);
+        assertNotEditing();
+
+        click(2);
+        assertNotEditing();
+
+        click(3);
+        assertNotEditing();
+
+        click(4);
+        assertEditing();
+        cancelCellEditing();
+        assertNotEditing();
+
+        click(5);
+        checkSelectedText(FIRST);
+
+        click(6);
+        checkSelectedText(ALL);
+
+        // start path editing
+        startPathEditing();
+        assertEditing();
+
+        click(1);
+        checkSelection(null);
+
+        click(2);
+        checkSelection(FIRST);
+
+        click(3);
+        checkSelection(ALL);
+    }
+
+    private static void click(int times) {
+        robot.delay(500);
+        for (int i = 0; i < times; i++) {
+            robot.mousePress(InputEvent.BUTTON1_MASK);
+            robot.mouseRelease(InputEvent.BUTTON1_MASK);
+        }
+    }
+
+    private static Point getClickPoint() throws Exception {
+        final Point[] result = new Point[1];
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                Rectangle rect = tree.getRowBounds(0);
+                // UPDATE !!!
+                Point p = new Point(rect.x + rect.width / 2, rect.y + 2);
+                SwingUtilities.convertPointToScreen(p, tree);
+                result[0] = p;
+
+            }
+        });
+
+        return result[0];
+    }
+
+    private static TreeModel createTreeModel() {
+        return new DefaultTreeModel(new DefaultMutableTreeNode(ALL));
+    }
+
+    private static void createAndShowGUI() {
+
+        JFrame frame = new JFrame();
+        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+        tree = new JTree(createTreeModel());
+        tree.setRootVisible(true);
+        tree.setEditable(true);
+
+
+        frame.getContentPane().add(tree);
+        frame.pack();
+        frame.setVisible(true);
+    }
+
+    private static void setClickCountToStart(final int clicks) throws Exception {
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                try {
+                    DefaultTreeCellEditor editor =
+                            (DefaultTreeCellEditor) tree.getCellEditor();
+                    Field field = DefaultTreeCellEditor.class.getDeclaredField("realEditor");
+                    field.setAccessible(true);
+                    DefaultCellEditor ce = (DefaultCellEditor) field.get(editor);
+                    ce.setClickCountToStart(clicks);
+                } catch (IllegalAccessException e) {
+                    throw new RuntimeException(e);
+                } catch (NoSuchFieldException e) {
+                    throw new RuntimeException(e);
+                }
+            }
+        });
+
+        toolkit.realSync();
+
+    }
+
+    private static void startPathEditing() throws Exception {
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                tree.startEditingAtPath(tree.getPathForRow(0));
+            }
+        });
+    }
+
+    private static void cancelCellEditing() throws Exception {
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                tree.getCellEditor().cancelCellEditing();
+            }
+        });
+    }
+
+    private static void checkSelection(final String sel) throws Exception {
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                try {
+                    DefaultTreeCellEditor editor =
+                            (DefaultTreeCellEditor) tree.getCellEditor();
+                    Field field = DefaultTreeCellEditor.class.getDeclaredField("realEditor");
+                    field.setAccessible(true);
+                    DefaultCellEditor ce = (DefaultCellEditor) field.get(editor);
+                    JTextField tf = (JTextField) ce.getComponent();
+                    String text = tf.getSelectedText();
+
+                    if (sel == null) {
+                        if (text != null && text.length() != 0) {
+                            throw new RuntimeException("Nothing should be selected, but \"" + text + "\" is selected.");
+                        }
+                    } else if (!sel.equals(text)) {
+                        throw new RuntimeException("\"" + sel + "\" should be selected, but \"" + text + "\" is selected.");
+                    }
+                } catch (IllegalAccessException e) {
+                    throw new RuntimeException(e);
+                } catch (NoSuchFieldException e) {
+                    throw new RuntimeException(e);
+                }
+            }
+        });
+    }
+
+    private static void checkSelectedText(String sel) throws Exception {
+        assertEditing();
+        checkSelection(sel);
+        cancelCellEditing();
+        assertNotEditing();
+    }
+
+    private static void assertEditing() throws Exception {
+        assertEditingNoTreeLock(true);
+    }
+
+    private static void assertNotEditing() throws Exception {
+        assertEditingNoTreeLock(false);
+    }
+
+    private static void assertEditingNoTreeLock(final boolean editing) throws Exception {
+        toolkit.realSync();
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                if (editing && !tree.isEditing()) {
+                    throw new RuntimeException("Tree should be editing");
+                }
+                if (!editing && tree.isEditing()) {
+                    throw new RuntimeException("Tree should not be editing");
+                }
+            }
+        });
+
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/SwingUtilities/4917669/bug4917669.java	Mon Feb 13 14:31:32 2012 +0000
@@ -0,0 +1,106 @@
+
+/*
+ * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 4917669
+ * @summary 1.4 REGRESSION: MenuItem accelerator doesn't work if parent menu is in JDialog
+ * @author Alexander Zuev
+ * @library ../../regtesthelpers
+ * @run main bug4917669
+ */
+
+import javax.swing.*;
+import java.awt.event.*;
+import java.awt.*;
+import sun.awt.SunToolkit;
+
+public class bug4917669 {
+
+    private static volatile boolean passed = false;
+    private static JFrame mainFrame;
+
+    public static void main(String[] args) throws Exception {
+        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+        Robot robot = new Robot();
+        robot.setAutoDelay(500);
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                createAndShowGUI();
+            }
+        });
+
+        toolkit.realSync();
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                createAndShowDialog();
+            }
+        });
+
+        toolkit.realSync();
+
+        Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_O);
+        toolkit.realSync();
+
+        if (!passed) {
+            throw new RuntimeException("Action did not received by menu item.");
+        }
+    }
+
+    private static void createAndShowDialog() {
+        JDialog dialog = new JDialog(mainFrame, "Test Dialog", false);
+        JMenuBar mb = new JMenuBar();
+        JMenu file = new JMenu("File");
+        JMenuItem menuItem = new JMenuItem("Open");
+        menuItem.setAccelerator(KeyStroke.getKeyStroke("control O"));
+        menuItem.addActionListener(new ActionListener() {
+
+            public void actionPerformed(ActionEvent e) {
+                passed = true;
+            }
+        });
+        file.add(menuItem);
+        mb.add(file);
+        dialog.setJMenuBar(mb);
+
+        dialog.setSize(100, 100);
+        dialog.setLocation(200, 200);
+        dialog.setVisible(true);
+    }
+
+    private static void createAndShowGUI() {
+        mainFrame = new JFrame("Bug4917669");
+        mainFrame.setLayout(new BorderLayout());
+        mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+        mainFrame.setSize(50, 50);
+        mainFrame.setVisible(true);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/UITest/UITest.java	Mon Feb 13 14:31:32 2012 +0000
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 4843282 4886871
+ * @summary Makes sure windows is only listed on Windows platform, and
+ *          GTK is not on Windows and Mac.
+ * added as tabs
+ * @author Scott Violet
+ */
+import javax.swing.*;
+import javax.swing.UIManager.LookAndFeelInfo;
+import sun.awt.OSInfo;
+import sun.awt.OSInfo.OSType;
+
+public class UITest {
+
+    public static void main(String[] args) {
+        OSType os = OSInfo.getOSType();
+        LookAndFeelInfo[] lafInfo = UIManager.getInstalledLookAndFeels();
+
+        switch (os) {
+            case WINDOWS:
+
+                // Make sure we don't have GTK.
+                if (hasLAF("gtk", lafInfo)) {
+                    throw new RuntimeException("On windows, but GTK is present");
+                }
+
+                // Make sure we don't have Aqua.
+                if (hasLAF("mac", lafInfo)) {
+                    throw new RuntimeException("On windows, but Aqua is present");
+                }
+
+                // Make sure we have Windows.
+                if (!hasLAF("windows", lafInfo)) {
+                    throw new RuntimeException("On windows and don't have Windows");
+                }
+
+                break;
+
+            case MACOSX:
+
+                // Make sure we don't have GTK.
+                if (hasLAF("gtk", lafInfo)) {
+                    throw new RuntimeException("On mac, but GTK is present");
+                }
+
+                // Make sure we don't have Windows.
+                if (hasLAF("windows", lafInfo)) {
+                    throw new RuntimeException("On mac, but Windows is present");
+                }
+
+                // Make sure we have Aqua.
+                if (!hasLAF("mac", lafInfo)) {
+                    throw new RuntimeException("On mac and don't have Aqua");
+                }
+
+                break;
+
+            default:
+                // Not windows and mac
+
+                // Make sure we don't have Windows.
+                if (hasLAF("windows", lafInfo)) {
+                    throw new RuntimeException("Not on windows and have Windows");
+                }
+
+                // Make sure we don't have Aqua.
+                if (hasLAF("mac", lafInfo)) {
+                    throw new RuntimeException("Not on mac and have Aqua");
+                }
+
+                // Make sure we have GTK.
+                if (!hasLAF("gtk", lafInfo)) {
+                    throw new RuntimeException(
+                            "Not on Windows and Mac and don't have GTK!");
+                }
+        }
+
+    }
+
+    public static boolean hasLAF(String name, LookAndFeelInfo[] lafInfo) {
+
+        for (int counter = 0; counter < lafInfo.length; counter++) {
+            if (lafInfo[counter].getName().toLowerCase().indexOf(name) != -1) {
+                return true;
+            }
+        }
+        return false;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/plaf/basic/BasicHTML/4251579/bug4251579.java	Mon Feb 13 14:31:32 2012 +0000
@@ -0,0 +1,100 @@
+
+/*
+ * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 4251579
+ * @summary  Tests if style sheets are working in JLabel
+ * @author Denis Sharypov
+ * @run main bug4251579
+ */
+import java.awt.*;
+import javax.swing.*;
+
+import sun.awt.SunToolkit;
+
+public class bug4251579 {
+
+    private static JLabel htmlComponent;
+
+    public static void main(String[] args) throws Exception {
+        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+        final Robot robot = new Robot();
+        robot.setAutoDelay(50);
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                createAndShowGUI();
+            }
+        });
+
+        toolkit.realSync();
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                boolean passed = false;
+
+                Point p = htmlComponent.getLocationOnScreen();
+                Dimension d = htmlComponent.getSize();
+                int x0 = p.x;
+                int y = p.y + d.height / 2;
+
+                for (int x = x0; x < x0 + d.width; x++) {
+                    if (robot.getPixelColor(x, y).equals(Color.blue)) {
+                        passed = true;
+                        break;
+                    }
+                }
+
+                if (!passed) {
+                    throw new RuntimeException("Test failed.");
+                }
+
+            }
+        });
+    }
+
+    private static void createAndShowGUI() {
+
+        String htmlText =
+                "<html>"
+                + "<head><style> .blue{ color:blue; } </style></head>"
+                + "<body"
+                + "<P class=\"blue\"> should be rendered with BLUE class definition</P>"
+                + "</body>";
+
+        JFrame mainFrame = new JFrame("bug4251579");
+        mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+        htmlComponent = new JLabel(htmlText);
+        mainFrame.getContentPane().add(htmlComponent);
+
+        mainFrame.pack();
+        mainFrame.setVisible(true);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/text/html/CSS/4530474/bug4530474.java	Mon Feb 13 14:31:32 2012 +0000
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 4530474
+ * @summary  Tests if background-color CSS attribute in HTML font tag in class attribute
+ * @author Denis Sharypov
+ * @run main bug4530474
+ */
+
+import java.awt.*;
+import javax.swing.*;
+
+import java.io.*;
+
+import sun.awt.SunToolkit;
+
+public class bug4530474 {
+
+    private static final Color TEST_COLOR = Color.BLUE;
+    private static JEditorPane jep;
+
+    public static void main(String args[]) throws Exception {
+
+        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+        final Robot robot = new Robot();
+        robot.setAutoDelay(50);
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                createAndShowGUI();
+            }
+        });
+
+        toolkit.realSync();
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+
+                boolean passed = false;
+
+                Point p = jep.getLocationOnScreen();
+                Dimension d = jep.getSize();
+                int x0 = p.x;
+                int y = p.y + d.height / 3;
+
+                StringBuilder builder = new StringBuilder("Test color: ");
+                builder.append(TEST_COLOR.toString());
+                builder.append(" resut colors: ");
+
+                for (int x = x0; x < x0 + d.width; x++) {
+                    Color color = robot.getPixelColor(x, y);
+                    builder.append(color);
+
+                    if (TEST_COLOR.equals(color)) {
+                        passed = true;
+                        break;
+                    }
+                }
+
+                if (!passed) {
+                    throw new RuntimeException("Test Fail. " + builder.toString());
+                }
+            }
+        });
+
+    }
+
+    private static void createAndShowGUI() {
+
+        JFrame mainFrame = new JFrame("bug4530474");
+        mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+        jep = new JEditorPane();
+
+        try {
+            File file = new File(System.getProperty("test.src", "."), "test.html");
+            jep.setPage(file.toURL());
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+
+        mainFrame.getContentPane().add(jep);
+
+        mainFrame.pack();
+        mainFrame.setVisible(true);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/text/html/CSS/4530474/test.css	Mon Feb 13 14:31:32 2012 +0000
@@ -0,0 +1,4 @@
+font.blackwhite { 
+  background-color: blue; 
+  color: #FFFFFF; 
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/text/html/CSS/4530474/test.html	Mon Feb 13 14:31:32 2012 +0000
@@ -0,0 +1,7 @@
+<html>
+<head>
+<LINK REL="StyleSheet" type="text/css" HREF=test.css>
+<body>
+ <font class="blackwhite">www</font>
+</body>
+</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/net/www/protocol/http/NoCache.java	Mon Feb 13 14:31:32 2012 +0000
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7133367
+ * @summary ResponseCache.put should not be called when setUseCaches(false)
+ */
+
+import java.net.*;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+import com.sun.net.httpserver.HttpExchange;
+import com.sun.net.httpserver.HttpHandler;
+import com.sun.net.httpserver.HttpServer;
+
+public class NoCache
+{
+    public static void main(String[] args) throws IOException {
+        ResponseCache.setDefault(new ThrowingCache());
+
+        HttpServer server = startHttpServer();
+        try {
+            URL url = new URL("http://" + InetAddress.getLocalHost().getHostAddress()
+                          + ":" + server.getAddress().getPort() + "/NoCache/");
+            URLConnection uc = url.openConnection();
+            uc.setUseCaches(false);
+            uc.getInputStream().close();
+        } finally {
+            server.stop(0);
+            // clear the system-wide cache handler, samevm/agentvm mode
+            ResponseCache.setDefault(null);
+        }
+    }
+
+    static class ThrowingCache extends ResponseCache {
+        @Override
+        public CacheResponse get(URI uri, String rqstMethod,
+                                 Map<String,List<String>> rqstHeaders) {
+            throw new RuntimeException("ResponseCache.get should not be called");
+        }
+
+        @Override
+        public CacheRequest put(URI uri, URLConnection conn) {
+            throw new RuntimeException("ResponseCache.put should not be called");
+        }
+    }
+
+    // HTTP Server
+    static HttpServer startHttpServer() throws IOException {
+        HttpServer httpServer = HttpServer.create(new InetSocketAddress(0), 0);
+        httpServer.createContext("/NoCache/", new SimpleHandler());
+        httpServer.start();
+        return httpServer;
+    }
+
+    static class SimpleHandler implements HttpHandler {
+        @Override
+        public void handle(HttpExchange t) throws IOException {
+            t.sendResponseHeaders(200, -1);
+            t.close();
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/krb5/auto/EmptyPassword.java	Mon Feb 13 14:31:32 2012 +0000
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6879540
+ * @summary enable empty password for kerberos 5
+ * @compile -XDignore.symbol.file EmptyPassword.java
+ * @run main/othervm EmptyPassword
+ */
+
+public class EmptyPassword {
+
+    public static void main(String[] args)
+            throws Exception {
+
+        OneKDC kdc = new OneKDC("aes128-cts");
+        kdc.addPrincipal("empty", "".toCharArray());
+
+        Context c = Context.fromUserPass("empty", "".toCharArray(), false);
+        c.status();
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/pkcs12/Bug6415637.java	Mon Feb 13 14:31:32 2012 +0000
@@ -0,0 +1,313 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6415637
+ * @summary Support PKCS#12 key stores protected with an empty password
+ */
+
+import java.io.ByteArrayInputStream;
+import java.math.BigInteger;
+import java.security.KeyStore;
+import java.security.cert.X509Certificate;
+import java.security.interfaces.RSAPrivateCrtKey;
+
+public class Bug6415637 {
+
+    public static void main(String[] args) throws Exception {
+        check(WITH_NULL);
+        check(WITHOUT_NULL);
+    }
+
+    private static void check(String encodedBlob) throws Exception {
+        byte[] blob = new byte[encodedBlob.length() * 2];
+        for (int i = 0; i < blob.length; ) {
+            final char ch = encodedBlob.charAt(i / 2);
+            blob[i++] = (byte) (ch >> 8);
+            blob[i++] = (byte) ch;
+        }
+        KeyStore store = KeyStore.getInstance("PKCS12");
+        store.load(new ByteArrayInputStream(blob), new char[0]);
+        if (!store.aliases().nextElement().equals("test"))
+            throw new Exception("test alias not found");
+        KeyStore.PrivateKeyEntry e =
+            (KeyStore.PrivateKeyEntry) store.getEntry("test",
+                    new KeyStore.PasswordProtection(new char[0]));
+        X509Certificate cert = (X509Certificate) e.getCertificateChain()[0];
+        if (!cert.getSubjectDN().toString().equals("CN=Test Key"))
+            throw new Exception("invalid certificate subject DN");
+        RSAPrivateCrtKey key = (RSAPrivateCrtKey) e.getPrivateKey();
+        if (!key.getPublicExponent().equals(BigInteger.valueOf(65537)))
+            throw new Exception("invalid public exponent");
+    }
+
+    private static final String WITH_NULL =
+        "\u3082\u097c\u0201\u0330\u8209\u3606\u092a\u8648\u86f7\u0d01" +
+        "\u0701\ua082\u0927\u0482\u0923\u3082\u091f\u3082\u0564\u0609" +
+        "\u2a86\u4886\uf70d\u0107\u01a0\u8205\u5504\u8205\u5130\u8205" +
+        "\u4d30\u8205\u4906\u0b2a\u8648\u86f7\u0d01\u0c0a\u0102\ua082" +
+        "\u04fa\u3082\u04f6\u3028\u060a\u2a86\u4886\uf70d\u010c\u0103" +
+        "\u301a\u0414\u8317\ucfd6\u89ab\uc03b\u79d6\u4c45\u1b10\uc3bd" +
+        "\u3923\ub806\u0202\u0400\u0482\u04c8\ud51d\uf953\ud79e\u92c6" +
+        "\u83c0\u92dc\ucd05\u69ab\ucc1b\ud538\u2ed9\u7796\ua426\uc14e" +
+        "\udcbf\ue541\u40be\ud264\u3b5b\uf51f\u8e1a\u892f\u2813\ucdd6" +
+        "\uf72e\uef55\u35ef\u4620\ude18\ued5e\ufae0\ubed4\uf84e\u276b" +
+        "\u3596\uc33f\ub251\ue617\u6e00\ua80f\u6c82\u4acd\u7303\u26be" +
+        "\uffb5\u1e49\u5fb1\uf87c\ua873\ue60a\u7415\u655c\u39f1\ucf16" +
+        "\u8f5c\u85c6\u4100\u4130\u565b\u649a\u60d6\u6054\u868d\u7267" +
+        "\u97a8\u8492\uc5a0\udb5e\u2880\udf55\ub0ee\ua641\u8224\u76d2" +
+        "\u9b1e\u2a67\u1e32\ue1fc\u0a77\u435b\u669f\ued00\u6c30\u963f" +
+        "\u7ee3\uc5c8\u198f\u8ede\u30e1\u015d\u1195\uc850\u3371\ub9e5" +
+        "\u6968\u84c3\ub0e4\u22b7\u2a08\u4a9d\u9166\ua9ba\ud945\u0529" +
+        "\ue1e7\u8aba\ub4ef\u7445\udc9a\ucf73\ud77b\ufafe\ue1df\u3180" +
+        "\u9585\ued73\uca40\u06b0\ufdee\u95ba\u1aa3\ubd67\ua5c1\u84b4" +
+        "\u4b50\uc1e1\u4547\ud837\u21bc\uac0d\u0a65\uebb5\u7281\ud9bc" +
+        "\u2e2c\ua9bc\u7714\u0fc0\uab41\uce09\ud5e8\u5f8c\uc35d\uba6e" +
+        "\u98a2\u95c3\u87ff\uba8c\u056a\udc9f\uf254\u3d38\uf40a\u77dd" +
+        "\u4e30\u01de\ubef7\ud288\ue59c\ua143\ub30b\ud0ae\u63b9\u138b" +
+        "\uc793\u3474\u18ca\udeed\u78d9\u2ae8\u63cc\ua5d1\u6779\u0229" +
+        "\u7b72\ucfd4\ueecb\ue167\u08c0\u7556\u181d\u8d62\uc401\ub092" +
+        "\u8cf5\ued71\uf29f\u843e\u13e1\u7e7b\uf589\u0329\u92bd\ud0e3" +
+        "\u8dcc\u7541\uf195\ueef2\u3f3a\ueb01\uf5b0\u1869\u2216\uf351" +
+        "\u488d\udffb\u6243\u1121\u9447\u8a3a\u006f\u008c\ue2b3\ued31" +
+        "\u7f57\u6492\ue02f\u6f68\u387d\u58c0\uaadf\u2ee3\uf304\u3de9" +
+        "\u9741\u47fa\udde8\ufe8a\u679a\u597d\u8c7c\u9c71\u570e\u1dbd" +
+        "\ud555\ue853\uff63\u0fcb\u4b28\u3691\u33c8\uc31f\uc510\u6cba" +
+        "\ud92c\u6462\u733a\u739e\uc792\ud861\u743e\u3bd3\u006b\u2276" +
+        "\u9fb3\u0a31\u1eb3\ub97e\u4a80\uc076\uaabc\u35a0\u678d\u17c3" +
+        "\ua225\ua77c\u7d9c\uef2d\u83e2\u6996\uba70\uf6f8\u79a1\u9399" +
+        "\uc86b\u1cc5\ub2a5\u02c1\ud676\ua274\u4933\u6c60\u6832\ub0be" +
+        "\u5354\u5af9\uae23\u0963\u722d\u9ad2\u4461\ub768\u2068\u0ccb" +
+        "\u94fd\u88ac\u0f58\u3bc0\u212d\u30c8\u8860\uf7c9\u1dde\ub6b4" +
+        "\u3549\u5bcd\ucf83\u9420\u3a40\u16ad\uc4d7\ucd87\ue73a\ue1c7" +
+        "\u21df\u7f4f\u8659\u9f79\u5b36\uf206\uac66\uc9f3\u6336\u164d" +
+        "\u9046\uf4d5\u285d\ufcd8\ubd55\u1fb9\ua533\u9101\u1e87\uc7b0" +
+        "\u64e9\u3817\u216c\u8d41\uba51\u743a\uc74e\ue4ab\u2820\u972f" +
+        "\ue191\u85b4\u0ea7\ud896\u23cf\u7df5\u1653\ua9f3\ub724\ucbc9" +
+        "\u9738\ud2f8\u464e\ucf12\u99b8\u64e0\uf03b\u8d02\u85a8\uab52" +
+        "\u8da3\uea34\ube99\ue5f8\u2b38\ub082\u399d\ue61e\u64a1\u7f90" +
+        "\u26e9\ueb74\u6107\ufe2f\u82ca\u87a5\u3028\u8e1f\ue859\u61d4" +
+        "\ud26d\u23a9\uaadc\u02a7\u8ab2\u43d4\uf6b9\udf7a\u8935\u45a4" +
+        "\ufad6\ue7e4\u92b7\u35d7\u1044\u8ed3\u74ef\uaaa9\u713f\u6ebc" +
+        "\u1158\u5e5c\u7522\ufe17\ua515\u59a1\u75dd\ue7ac\uafd9\u16a9" +
+        "\u190e\u18fc\uc041\ufc9e\u3e16\u60c4\ufe51\u6d53\ufa52\u4c08" +
+        "\uce2a\ue546\u017b\ud96b\ube18\u8cb9\udd50\ued40\u14b0\u7da1" +
+        "\u2f2c\ubf9d\uc7c7\u1b73\ua155\ucaf8\ue54d\uebb0\u160a\ubd64" +
+        "\u5ef7\ue1cf\u4633\u86c1\ubc91\u839d\ub148\u9f31\uf2b1\ud133" +
+        "\u168f\u9374\u4667\u6aa9\u0482\ua2a6\ub5c0\ud9b7\ua070\uf6bd" +
+        "\u16fe\u0f41\u986b\u3d33\u7cb9\u291d\u24f0\u704a\uc946\u10a2" +
+        "\udbcf\u6c5f\u5a83\u5507\u036e\ube9f\uf60a\u9da8\u72dd\u23c9" +
+        "\u8878\udd67\uf486\u1384\u751f\u4694\uee3c\udc2e\ud5d7\ud99a" +
+        "\u5ee2\u5455\ub82d\u1837\u336d\u5724\u635b\ubd0b\u2e7c\u92be" +
+        "\u2110\u9c0e\u1662\u43f6\u62ae\u32e3\uaea4\u1cc5\uadc0\u7511" +
+        "\u6ad4\u0228\ue399\u5741\u2050\ue31a\u7dc8\uf6db\u67bb\u994a" +
+        "\u5b5a\uaac6\u2210\u95b0\u462e\u0684\u335e\uac36\u7ab9\uab1e" +
+        "\u0b75\u0f05\u74c5\ufcb3\ua0a5\ube7e\u45f8\u92d5\u3399\u7dd6" +
+        "\uf96e\u7e01\u7823\u6690\u231c\u4c47\u2d10\u7e7f\u5eb8\u70dd" +
+        "\u98d2\u6204\u3a92\u3990\u502b\u7cdb\u952a\ufa97\uea3b\ud990" +
+        "\u436f\uf33a\u070d\u2aff\u7497\u2591\u37e4\ua590\ue7ba\u2c1e" +
+        "\u53d9\u73fa\udc53\u944f\ua3a5\u5093\u33a4\uf080\u1193\u37f2" +
+        "\u7642\ub033\u7f90\u9b44\uff89\ue6ef\u81be\u9e6e\u68a4\u5a00" +
+        "\u9232\u4372\u40aa\u2748\u229d\u534d\u316b\u6e89\ufcb7\uff2e" +
+        "\ub654\u1649\ucb13\u3c28\u4940\u43aa\uc07d\u247c\u313c\u3017" +
+        "\u0609\u2a86\u4886\uf70d\u0109\u1431\u0a1e\u0800\u7400\u6500" +
+        "\u7300\u7430\u2106\u092a\u8648\u86f7\u0d01\u0915\u3114\u0412" +
+        "\u5469\u6d65\u2031\u3330\u3833\u3132\u3234\u3236\u3437\u3082" +
+        "\u03b3\u0609\u2a86\u4886\uf70d\u0107\u06a0\u8203\ua430\u8203" +
+        "\ua002\u0100\u3082\u0399\u0609\u2a86\u4886\uf70d\u0107\u0130" +
+        "\u2806\u0a2a\u8648\u86f7\u0d01\u0c01\u0630\u1a04\u14de\ud8d8" +
+        "\ua792\uf9d9\u6875\ua51d\u98ec\udf03\uc2b6\u5100\u8a02\u0204" +
+        "\u0080\u8203\u6074\ub909\u3c60\ua522\ue4ac\u0f60\u2396\u7baa" +
+        "\ud208\ub76c\u89a5\ue4ef\u205d\u2062\u4a5b\ua684\uceae\u01b9" +
+        "\u1e7a\u6e03\ud996\u555a\u615b\uba70\u406f\u80a9\u901e\ua947" +
+        "\u5b8f\u73f3\udea3\ud8b1\u9782\uac87\u231a\udcd2\u3ef0\u3a17" +
+        "\u4092\u509f\u0e79\u4cd7\u8516\u5111\uebe1\u86e0\uc548\u5ffc" +
+        "\u9a99\u11ed\uef13\u17af\u2707\u8984\u8770\u7064\u1943\u1dd3" +
+        "\u45cf\u9f80\u65f8\u9b3e\u1f70\u6bd0\uc726\u5506\ufb20\u6bdc" +
+        "\uba8c\u0b19\ucd01\ud0f0\u7040\udf63\u48a5\udf5f\u6559\u1b33" +
+        "\ubdae\u8183\uc13f\ued10\ud6dc\ud0f0\u6a7f\ubc36\uc7ca\u320f" +
+        "\u50b8\ud422\ufd99\u8843\u65e8\ue201\u843b\u64ee\ub891\u3ba2" +
+        "\uecae\ufda0\u72d6\u8394\u2551\ufc44\u3778\u27c3\u061a\u6d3b" +
+        "\ubd80\ue010\u06df\u39e7\u3d6a\u5ae2\u93fa\u4de4\u938f\u6f27" +
+        "\ufd39\u4380\u60da\uf215\u79d4\uf6f1\ua02f\u959a\ua0ea\u1c38" +
+        "\u80e3\u2744\u7506\u54b3\u77ad\u18ce\ucfec\u555e\u7bbe\u2e2f" +
+        "\u9900\ub2ef\ua5b9\ubdf0\u5e15\ua681\u92c7\u4f86\u2e1a\ub893" +
+        "\u01fc\u01d2\ub674\uff19\u04c3\ua1a0\u2cea\u72e0\ua8f1\u1358" +
+        "\ube79\u7caa\u269d\u728a\ue435\u37bd\u6495\uc106\u8830\u9b17" +
+        "\ue16d\uef78\uae2b\u5313\u1c96\uc0ee\u3098\ud743\ucd1c\u7407" +
+        "\uf4f9\uee72\ub95e\u31e7\u6435\u0173\u0336\u93c5\u8a1b\u05b4" +
+        "\u4359\uc4be\ud92b\u8d21\u83a9\u32b7\u6433\ua9bc\u27c2\ud842" +
+        "\ua4f2\u81c5\ua86c\u2fd2\uba30\u53bd\uc277\u659f\u203b\u60e5" +
+        "\u37f7\u0984\u31c2\u838a\u2107\u5840\u6411\u1b8d\u044e\ub0b6" +
+        "\uf558\ue6d3\u62bb\u5464\uf83a\u4d5b\uf153\u9e18\ua353\ubd05" +
+        "\uf204\ud543\u037d\ue5aa\u473a\ueb13\uac19\u0494\ua08e\u76c3" +
+        "\ufbd7\u9f1c\u8ca9\u57ad\ud218\uc018\u67ac\u0ae9\ub559\ufe38" +
+        "\u5641\uec0c\ue0ee\u606c\u1989\ue5a2\uff09\u8c61\u1386\ueb51" +
+        "\u7cbd\u95cd\u80c5\u3532\u8605\u596d\u4cfd\u7797\u1e82\ud2fe" +
+        "\uad6b\ua16e\ub6cf\u8fce\ud5a9\u207f\u1d0a\udabe\uc3a6\u5633" +
+        "\u2023\u925f\u809f\uee7c\u5362\u5fd9\u8dfc\u6b5f\uc95b\u0ae9" +
+        "\u7b26\u9e5b\u97e8\u9d6e\uaf91\u6d1a\u1d19\ufc27\u0815\uccbc" +
+        "\u83d4\u2ce2\ue06e\u21a1\u88da\u09af\u9671\uc510\uac23\u398d" +
+        "\ubea2\ua9a1\uf0d3\u490d\ub94b\u7ff7\u6636\ub1fa\u9b10\u1be3" +
+        "\u179b\u6a8a\u4a6c\ude1f\u5da7\u7c02\u96ec\u70ac\u5045\udd2c" +
+        "\u9f6d\uc37d\u5ba6\u4895\ue142\u0db9\uf2dc\uba2e\ud054\ud33e" +
+        "\u1ed9\u144b\u5d85\u9156\u3a90\ue8cd\u0a01\u67f5\ua81b\u4f56" +
+        "\u99dd\u4950\ua551\uacdb\udf31\u1f05\u7169\u3231\u0071\u80ec" +
+        "\ua4e9\ud74e\u62cf\u8931\u11f1\uc925\u0319\uabd4\ufb86\u73c2" +
+        "\u1479\u005b\uf05d\u4f8d\u44e4\u942b\ud338\ud05d\u2b3b\uf6f5" +
+        "\udc0d\uf741\u798b\ud8e9\u36a5\u577b\u8a95\ud773\uffcb\u17b3" +
+        "\u7174\u9616\u9b5e\ua577\u983c\u6e7a\u6cc8\u4a04\u042b\u503e" +
+        "\ud744\ub65e\ue5de\ufa24\u8c71\u1127\ud47f\ud290\ufd4c\u5cbb" +
+        "\u0e21\u77fd\u6553\ub82b\ucb49\u41e7\u8e3d\u4539\u925d\u6ba9" +
+        "\uae47\u391c\ua79e\ub6e2\u7142\u7cb3\u02f5\u6495\u7a85\u2dea" +
+        "\u787b\u22b7\u6ec2\uea8d\uf930\u3d30\u2130\u0906\u052b\u0e03" +
+        "\u021a\u0500\u0414\ubfef\u99f5\u0bb0\uc9b3\uf96a\ue267\u6bc0" +
+        "\u0202\u6d78\ub923\u0414\u5500\u095a\u2a04\u2d7e\u708d\u9779" +
+        "\u9bdb\u2c4f\u82f2\uf89f\u0202\u0400";
+
+    private static final String WITHOUT_NULL =
+        "\u3082\u097c\u0201\u0330\u8209\u3606\u092a\u8648\u86f7\u0d01" +
+        "\u0701\ua082\u0927\u0482\u0923\u3082\u091f\u3082\u0564\u0609" +
+        "\u2a86\u4886\uf70d\u0107\u01a0\u8205\u5504\u8205\u5130\u8205" +
+        "\u4d30\u8205\u4906\u0b2a\u8648\u86f7\u0d01\u0c0a\u0102\ua082" +
+        "\u04fa\u3082\u04f6\u3028\u060a\u2a86\u4886\uf70d\u010c\u0103" +
+        "\u301a\u0414\ud258\ubbe7\ub641\ud196\u4969\u3c88\u70f1\u8c97" +
+        "\u95b1\u8bf3\u0202\u0400\u0482\u04c8\u096a\u4686\uf519\u61da" +
+        "\u1b3b\uebfd\u89b1\u044b\u3bd8\u79a7\ud022\ud880\ud173\ucde1" +
+        "\ud2c1\u2c5d\u8ebb\u6bd4\u46db\ub90b\u04b9\ub091\ud1f3\ud468" +
+        "\u3e93\u2c88\uca5a\u1c54\u5342\u1eca\u8565\ubbbd\ua022\u1ead" +
+        "\ud0bb\u1a8c\u69cf\uf0f4\ucbfb\u488a\ube99\uf190\ue01c\ud87d" +
+        "\u78ca\u9e5c\u82f9\u76ad\u811f\u37d0\u272b\u0481\u500c\u0a27" +
+        "\u08d3\ub637\u3e39\u6db1\ubcba\ue354\u6924\ua9d5\u3555\u20d6" +
+        "\u4c6b\u3189\u5f91\u382c\uf351\u4de2\ubade\u2a14\uea84\u16b6" +
+        "\uf7f7\u36de\ubba6\ue952\u5f5d\u8243\u2318\ucf3d\u8ac8\u33d3" +
+        "\u706c\ue3db\u6619\u7935\u7300\u89b3\u0bcd\uca9f\u0333\ua450" +
+        "\u1be1\u3e42\ub465\uced5\ub055\u5843\uf40f\ua0f2\u6fea\u94fa" +
+        "\ua51e\u4b5d\u93c9\ucb2e\u977e\uafd9\u2a2f\u784b\u0320\u5550" +
+        "\u273f\u469f\uc42b\u2ce7\uedea\u4e0d\u54a5\u1a25\u4fac\ue346" +
+        "\u2102\u7ab6\uea86\u554f\u7706\u8a80\uf6dd\u04f8\u3b37\u005a" +
+        "\u4562\u2ef8\u59f9\u32b7\u31c0\ue7dc\ucbde\ue0e1\u2fd9\u0960" +
+        "\u3e7a\ub4e5\u2a58\u1e2b\uef14\u9a44\u5444\u806d\uc475\u12ab" +
+        "\ucc3d\ua03b\ubd52\ubf1c\ua9a6\u58aa\uee8b\u96c2\ud0c9\ua029" +
+        "\u1db4\ub118\u4807\uecaa\ue182\uabb7\ud9ed\u66c5\u2c80\uc6a6" +
+        "\u3f54\ubc73\u2632\ue1b0\u0d74\u001c\u5740\uc74b\ufadb\u25b4" +
+        "\ua10e\u3191\u69e6\u0861\u452b\u955c\uac56\ud3c4\u86b7\u45f8" +
+        "\u777a\uc336\u8cc7\ud471\u76b6\u11d8\ueb84\u14e4\uf44f\uc9ff" +
+        "\u8929\u0d84\ubcfe\u8cc2\u9d07\u94e6\u1cf9\u19b5\u773a\u012d" +
+        "\u0453\u4ff3\u40f2\ub144\ufc80\u571c\u0e13\uf890\u9fed\u2045" +
+        "\u7baf\ufd88\u4920\u2b86\u491d\uecf8\ua5d9\u1e12\u48c7\u2c84" +
+        "\u3fbe\u4df5\u11ce\u7b81\u83fc\u3efa\u697d\u1f3d\u8d81\u01b0" +
+        "\u0bf1\u9012\u697f\u3b25\u3574\u5286\udded\u5be0\u7e92\u0a02" +
+        "\ua486\ud19b\ue0b5\ua05c\u5ac2\u0ad5\u0d04\ua763\ub5c8\uf7e6" +
+        "\u6e77\u2df3\ub9e7\uda30\ufccb\u7642\u5dc1\udf1f\uc922\uff69" +
+        "\u4471\u4749\u937a\ud77d\u7c0d\u917c\uf2ef\u122c\u13b2\u8943" +
+        "\u33aa\uad59\u86e8\u21c4\ueaa0\uf200\ue5f3\u6da0\ue8ef\uce7e" +
+        "\u37b2\u3ddf\u0480\u08fc\uf89a\ud927\u3f5b\u75d3\ubdfe\u6ebd" +
+        "\ufab1\u9f54\u1c20\u625b\u1391\u2af0\u43ba\u4395\udf22\u299e" +
+        "\uf3bf\u7750\u5f68\u0120\u0ee0\u6960\ud939\u621f\uf845\u0025" +
+        "\ue33c\u7ed9\ueadf\u0005\u6306\u7274\u5e67\ucf7a\uf3c6\u7371" +
+        "\u487b\u79d7\u2142\ubc1a\ubfe4\u3536\u15db\ufe23\u4352\u6321" +
+        "\u329d\uc251\u84c8\ufc0e\uc0ca\u5be6\uf530\u0177\ud9cb\ud132" +
+        "\uf752\u3f26\uda90\ud9cf\u2e46\u3e09\u5d9a\u6902\udb3e\ub06c" +
+        "\u722d\uf498\u3e93\u6cae\u43b5\u535a\u1cd1\uf0b2\u8d80\u9e53" +
+        "\ue02e\uf782\u01ce\u5063\u73d1\u5571\uf0e7\ufa22\u7e48\u0c31" +
+        "\u4642\u29fd\udcab\ue8d4\u7a77\u0880\u4855\u88c7\u7aa5\u0d9c" +
+        "\uf8b7\uc91c\u127d\u2dd7\ude53\u9d3f\u132b\u965c\ubc80\udd97" +
+        "\u87bf\ua0e8\ub2a2\u4e1f\u98fd\u72f3\u16ea\uc415\u5be3\ue8df" +
+        "\u5681\u1f11\u4e3a\uac5d\u1684\u6602\ueb14\u0a96\ufcef\uaebf" +
+        "\u1f2e\ud1a9\u435c\uf4e5\ub6b4\uaae2\u8244\u96a4\u0d3a\u752f" +
+        "\uce21\u1bc9\u219e\uf17b\ud95e\ucd12\u1b0a\ucb85\ub0cd\u4ecb" +
+        "\u6bb4\u5f7c\u2a93\ubb24\u9d7c\u6822\u80cd\u3f54\u78ad\u4fde" +
+        "\ud57f\uec1d\ub54c\u0d78\u5946\u84c1\ua9ad\u0dea\u0292\ub279" +
+        "\u1c76\u817e\ub910\ub1fa\ub1c0\u839d\u9eca\u6f83\u8211\u4112" +
+        "\u440c\u4fbd\u6ef2\u897d\udfa9\ude9e\u1aef\u0f21\u26fb\uaca4" +
+        "\u637e\ub072\u264f\ud24d\u9357\uc801\u0b84\u2d34\ueddf\u6063" +
+        "\udc5d\u90dd\u5c62\ufb48\u8c5e\u7c4e\u3bdb\ub590\u7a75\udbd1" +
+        "\udd78\uc8be\u5915\u7c8b\u8874\u578d\u3116\ub65a\uab8e\ud2ef" +
+        "\u5d35\ubf8b\u2828\u8983\ua790\uedcf\u9698\ue023\u5786\u627b" +
+        "\u9037\u1db7\u900e\u1f45\u0001\u7cf8\u14fd\ue437\u0dfd\ucacc" +
+        "\u5edf\u1742\u7f6e\u612a\ud57d\udca0\u73a4\ud601\uc7f0\uca0e" +
+        "\u5a44\u00b4\u233a\u84f2\u95b5\u5f16\uc291\u04fb\u369d\u6b99" +
+        "\ue127\u493f\u66be\u86e9\u9672\u2849\u64a7\u851b\ue420\u8491" +
+        "\ueb07\u6563\uc753\uc28e\ucad5\uec05\u6920\u8955\u5605\u25f6" +
+        "\u6193\ubee5\u7a1a\ub73d\ucc27\uc8ce\u7179\u57c1\u7a2a\u37c1" +
+        "\ua6c7\u2d8a\u4025\uc97d\u8c9d\u7b4b\u1ad5\uc6d7\u50fc\u246d" +
+        "\u91a9\ua55d\u677a\udc83\u04c7\u3e14\u9950\u420c\udf02\u749b" +
+        "\ude88\u5459\u2074\ua4ae\ud12d\uaf60\uba98\u630d\u313c\u3017" +
+        "\u0609\u2a86\u4886\uf70d\u0109\u1431\u0a1e\u0800\u7400\u6500" +
+        "\u7300\u7430\u2106\u092a\u8648\u86f7\u0d01\u0915\u3114\u0412" +
+        "\u5469\u6d65\u2031\u3330\u3833\u3132\u3431\u3138\u3238\u3082" +
+        "\u03b3\u0609\u2a86\u4886\uf70d\u0107\u06a0\u8203\ua430\u8203" +
+        "\ua002\u0100\u3082\u0399\u0609\u2a86\u4886\uf70d\u0107\u0130" +
+        "\u2806\u0a2a\u8648\u86f7\u0d01\u0c01\u0630\u1a04\u14af\ud4f5" +
+        "\u0ff4\u0ede\u0da0\u6cc5\ufd9d\u3502\uae5e\u4cef\u3102\u0204" +
+        "\u0080\u8203\u6028\ua7e6\u088b\u56b6\uf453\u9747\u68ec\uc064" +
+        "\u2254\u693f\u25c5\uaa39\u3d87\uc97c\uc558\u5194\u7553\ude3a" +
+        "\u4575\u9d85\ud843\u2bd0\ua2e8\u244f\u8593\uac84\u54b4\ubdc6" +
+        "\ucea6\uba1a\ud3da\ua510\uee9d\uaf31\ub5c2\u3329\u0fed\u0e08" +
+        "\u426b\u46fe\udcc5\u0979\ua9ed\u3123\u9a50\ud222\u3fc0\u771a" +
+        "\u6f55\u9664\ud56f\u6b03\u6020\u78a4\u63b2\ue35e\u0816\u43a7" +
+        "\u1909\u52e1\u8183\u1b8d\u9f5b\u19e4\uad73\u8461\ucc86\u3b49" +
+        "\u322e\ue9d9\u3c66\uea22\u091e\u6621\ua8bf\u0169\u72d0\u535e" +
+        "\u77dc\u1002\ubded\u7a91\u6cee\u58fa\uc295\uae8e\ue009\uabe9" +
+        "\u6638\ucaea\u8bbf\uca27\udef5\u2881\u72ec\u8aa5\u582b\u9d6e" +
+        "\u26bb\u3c70\u8bd6\uf5ec\u34ae\ua967\u5bb1\u22cb\u4b74\u0e50" +
+        "\u5062\uc6f7\u7cb4\u58a3\uf43d\u57c0\u9654\u2f9c\u9308\u4546" +
+        "\u6f4a\u37fe\u8d5d\u1465\u8621\u4cd8\u68d6\u0456\u96a4\ud3e2" +
+        "\u76d1\u2675\u7654\u7649\u10e9\u9d0e\u8b04\uffb6\u020a\u2eb4" +
+        "\uf24f\u150e\u7f0d\uf41b\u2c76\u538f\uc2df\u79dc\u0472\u1119" +
+        "\uc148\ue2e8\u1820\ucd45\u08a7\u6bcd\u6eb0\ubd0a\ufff4\uec28" +
+        "\u819b\u2adb\uefc8\ue8f7\ue233\u6535\uc938\u9771\u3681\u87cf" +
+        "\u3a24\u4c71\ue1df\u3e19\u259c\uae5b\u27ed\u8a67\uf3e6\u7af0" +
+        "\u48e1\uc542\uc471\ud8f4\ue317\u46e9\u0b4f\uec45\ua1d3\u2b88" +
+        "\u8a22\udda1\u7c1a\u273c\ua0f7\u8bac\u3771\u28d2\u6ef8\u28d2" +
+        "\ud83c\u196f\ue3fd\u9c79\u4305\u01b8\u3490\u0a91\ue4f3\uebc6" +
+        "\u25a2\u7dd2\u72db\u7531\ucfca\u432f\u2beb\uc649\uf9c5\uc533" +
+        "\u9f3a\ua611\u935c\ubca6\ud293\u54d6\u0dd1\u0aff\u82fb\u2d69" +
+        "\u3da0\u3b33\u0986\u45b3\u3353\ub968\u7348\u454f\u9117\ub3dc" +
+        "\ud7af\u06ca\ua34a\u9357\ue22f\uad3d\u4c76\ub386\ua8d7\u2a90" +
+        "\u6d17\u9321\u7b00\u21e4\u1994\u9d18\u6439\u04c8\u8282\ub269" +
+        "\uf786\u75c6\ua505\u983a\ua075\uffa0\ud662\u6ae5\ub126\u96d1" +
+        "\u9e5e\u346b\ub7ee\ub0a3\u4ee8\ud204\u77ec\u2325\u5da8\ua326" +
+        "\ua018\u0fd8\ue50e\u93cc\ucc40\u2d89\u2ffb\u54e0\u091a\u19fd" +
+        "\u45d7\uc0ab\u77a2\u66ae\u794b\u6644\u21c3\ud782\u1e9e\u53e5" +
+        "\u782e\u55e8\ud44e\u93e8\u379e\u5aa8\u353b\u95de\u7bc1\ucaf3" +
+        "\u5223\ub5e9\uacbb\ub86b\u6014\u0626\ue7ad\ufd93\ue43a\ud864" +
+        "\u1e6d\u14b2\ua12a\u94c5\u2ed9\ua7f7\u14f4\u0cbd\uca3b\u7c21" +
+        "\ua85a\uf834\u6c99\ue1aa\u3832\u2515\u8170\u3c93\u7def\u94fe" +
+        "\u9c3d\u4ab0\u73ed\u6c72\u8b94\ua407\uc719\uad1e\u6306\u4167" +
+        "\u921e\uae53\u3fd4\uf569\u6f0b\u82b0\u0ca6\ud61f\ud526\u23c9" +
+        "\u168d\u4baf\ucc4f\ud8a2\uc64a\ud649\u55e3\u7019\u8f20\u680c" +
+        "\u5581\u2cb1\ub3a4\u3e37\u5fd3\ua3ca\uc115\u979c\uf910\u3797" +
+        "\u05cb\u51d6\u74a4\uc5c0\u597b\uf27f\ud5e2\ue8ac\u4f3d\uc0c3" +
+        "\u9594\u7799\u6876\ub1a3\u059a\uff03\uc2ee\uc8c2\uf224\u3720" +
+        "\u9177\uabdb\u9202\u18d8\uffbe\u0516\u2a76\uedb5\ufe9e\u6d65" +
+        "\u4c35\ue4cb\u75aa\u02be\ud24c\ua482\ufc67\ue4f9\u70c7\u3567" +
+        "\ufc3f\uaa89\ue80a\u6507\u0a65\u4e18\uf919\u071d\u423c\u1756" +
+        "\u30e5\u37f3\u19b3\u10fb\u6c30\u3d30\u2130\u0906\u052b\u0e03" +
+        "\u021a\u0500\u0414\ufd05\u4444\ud347\u673c\u6da4\udb7c\u0733" +
+        "\ud7bf\ud263\uc6b2\u0414\udd17\u155e\u2d4c\u25cb\ua028\u1a23" +
+        "\ub8b0\uf6be\u925f\ude3a\u0202\u0400";
+
+}
--- a/langtools/.hgtags	Mon Feb 13 14:26:25 2012 +0000
+++ b/langtools/.hgtags	Mon Feb 13 14:31:32 2012 +0000
@@ -145,3 +145,5 @@
 bcb21abf1c4177baf4574f99709513dcd4474727 jdk8-b21
 390a7828ae18324030c0546b6452d51093ffa451 jdk8-b22
 601ffcc6551d5414ef871be306c3a26396cf16a7 jdk8-b23
+6c9d21ca92c41ff5fcfa76c5b7fafe0f042f4aef jdk8-b24
+520c30f85bb529a3daf5d7623764c2464f00fd19 jdk8-b25
--- a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java	Mon Feb 13 14:31:32 2012 +0000
@@ -70,6 +70,7 @@
     private JavaCompiler compiler;
     private Locale locale;
     private String[] args;
+    private String[] classNames;
     private Context context;
     private List<JavaFileObject> fileObjects;
     private Map<JavaFileObject, JCCompilationUnit> notYetEntered;
@@ -82,11 +83,13 @@
 
     JavacTaskImpl(Main compilerMain,
                 String[] args,
+                String[] classNames,
                 Context context,
                 List<JavaFileObject> fileObjects) {
         this.ccw = ClientCodeWrapper.instance(context);
         this.compilerMain = compilerMain;
         this.args = args;
+        this.classNames = classNames;
         this.context = context;
         this.fileObjects = fileObjects;
         setLocale(Locale.getDefault());
@@ -101,17 +104,14 @@
                 Context context,
                 Iterable<String> classes,
                 Iterable<? extends JavaFileObject> fileObjects) {
-        this(compilerMain, toArray(flags, classes), context, toList(fileObjects));
+        this(compilerMain, toArray(flags), toArray(classes), context, toList(fileObjects));
     }
 
-    static private String[] toArray(Iterable<String> flags, Iterable<String> classes) {
+    static private String[] toArray(Iterable<String> iter) {
         ListBuffer<String> result = new ListBuffer<String>();
-        if (flags != null)
-            for (String flag : flags)
-                result.append(flag);
-        if (classes != null)
-            for (String cls : classes)
-                result.append(cls);
+        if (iter != null)
+            for (String s : iter)
+                result.append(s);
         return result.toArray(new String[result.length()]);
     }
 
@@ -129,7 +129,7 @@
             initContext();
             notYetEntered = new HashMap<JavaFileObject, JCCompilationUnit>();
             compilerMain.setAPIMode(true);
-            result = compilerMain.compile(args, context, fileObjects, processors);
+            result = compilerMain.compile(args, classNames, context, fileObjects, processors);
             cleanup();
             return result.isOK();
         } else {
@@ -159,7 +159,7 @@
             initContext();
             compilerMain.setOptions(Options.instance(context));
             compilerMain.filenames = new LinkedHashSet<File>();
-            Collection<File> filenames = compilerMain.processArgs(CommandLine.parse(args));
+            Collection<File> filenames = compilerMain.processArgs(CommandLine.parse(args), classNames);
             if (!filenames.isEmpty())
                 throw new IllegalArgumentException("Malformed arguments " + toString(filenames, " "));
             compiler = JavaCompiler.instance(context);
@@ -174,6 +174,7 @@
             // endContext will be called when all classes have been generated
             // TODO: should handle the case after each phase if errors have occurred
             args = null;
+            classNames = null;
         }
     }
 
@@ -204,6 +205,7 @@
         compiler = null;
         compilerMain = null;
         args = null;
+        classNames = null;
         context = null;
         fileObjects = null;
         notYetEntered = null;
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java	Mon Feb 13 14:31:32 2012 +0000
@@ -34,6 +34,7 @@
 import com.sun.tools.javac.code.Type.*;
 import com.sun.tools.javac.code.Type.ForAll.ConstraintKind;
 import com.sun.tools.javac.code.Symbol.*;
+import com.sun.tools.javac.comp.Resolve.InapplicableMethodException;
 import com.sun.tools.javac.comp.Resolve.VerboseResolutionMode;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
 
@@ -84,7 +85,7 @@
 
     }
 
-    public static class InferenceException extends Resolve.InapplicableMethodException {
+    public static class InferenceException extends InapplicableMethodException {
         private static final long serialVersionUID = 0;
 
         InferenceException(JCDiagnostic.Factory diags) {
@@ -287,6 +288,18 @@
         }
     }
 
+    Type asUndetType(Type t, List<Type> undetvars) {
+        return types.subst(t, inferenceVars(undetvars), undetvars);
+    }
+
+    List<Type> inferenceVars(List<Type> undetvars) {
+        ListBuffer<Type> tvars = ListBuffer.lb();
+        for (Type uv : undetvars) {
+            tvars.append(((UndetVar)uv).qtype);
+        }
+        return tvars.toList();
+    }
+
 /***************************************************************************
  * Exported Methods
  ***************************************************************************/
@@ -372,62 +385,11 @@
                                   final Warner warn) throws InferenceException {
         //-System.err.println("instantiateMethod(" + tvars + ", " + mt + ", " + argtypes + ")"); //DEBUG
         List<Type> undetvars = Type.map(tvars, fromTypeVarFun);
-        List<Type> formals = mt.argtypes;
-        //need to capture exactly once - otherwise subsequent
-        //applicability checks might fail
-        final List<Type> capturedArgs = types.capture(argtypes);
-        List<Type> actuals = capturedArgs;
-        List<Type> actualsNoCapture = argtypes;
-        // instantiate all polymorphic argument types and
-        // set up lower bounds constraints for undetvars
-        Type varargsFormal = useVarargs ? formals.last() : null;
-        if (varargsFormal == null &&
-                actuals.size() != formals.size()) {
-            throw unambiguousNoInstanceException
-                .setMessage("infer.arg.length.mismatch");
-        }
-        while (actuals.nonEmpty() && formals.head != varargsFormal) {
-            Type formal = formals.head;
-            Type actual = actuals.head.baseType();
-            Type actualNoCapture = actualsNoCapture.head.baseType();
-            if (actual.tag == FORALL)
-                actual = instantiateArg((ForAll)actual, formal, tvars, warn);
-            Type undetFormal = types.subst(formal, tvars, undetvars);
-            boolean works = allowBoxing
-                ? types.isConvertible(actual, undetFormal, warn)
-                : types.isSubtypeUnchecked(actual, undetFormal, warn);
-            if (!works) {
-                throw unambiguousNoInstanceException
-                    .setMessage("infer.no.conforming.assignment.exists",
-                                tvars, actualNoCapture, formal);
-            }
-            formals = formals.tail;
-            actuals = actuals.tail;
-            actualsNoCapture = actualsNoCapture.tail;
-        }
+        //final List<Type> capturedArgs = types.capture(argtypes);
 
-        if (formals.head != varargsFormal) // not enough args
-            throw unambiguousNoInstanceException.setMessage("infer.arg.length.mismatch");
-
-        // for varargs arguments as well
-        if (useVarargs) {
-            Type elemType = types.elemtype(varargsFormal);
-            Type elemUndet = types.subst(elemType, tvars, undetvars);
-            while (actuals.nonEmpty()) {
-                Type actual = actuals.head.baseType();
-                Type actualNoCapture = actualsNoCapture.head.baseType();
-                if (actual.tag == FORALL)
-                    actual = instantiateArg((ForAll)actual, elemType, tvars, warn);
-                boolean works = types.isConvertible(actual, elemUndet, warn);
-                if (!works) {
-                    throw unambiguousNoInstanceException
-                        .setMessage("infer.no.conforming.assignment.exists",
-                                    tvars, actualNoCapture, elemType);
-                }
-                actuals = actuals.tail;
-                actualsNoCapture = actualsNoCapture.tail;
-            }
-        }
+        final List<Type> capturedArgs =
+                rs.checkRawArgumentsAcceptable(env, undetvars, argtypes, mt.getParameterTypes(),
+                    allowBoxing, useVarargs, warn, new InferenceCheckHandler(undetvars));
 
         // minimize as yet undetermined type variables
         for (Type t : undetvars)
@@ -503,6 +465,31 @@
     }
     //where
 
+        /** inference check handler **/
+        class InferenceCheckHandler implements Resolve.MethodCheckHandler {
+
+            List<Type> undetvars;
+
+            public InferenceCheckHandler(List<Type> undetvars) {
+                this.undetvars = undetvars;
+            }
+
+            public InapplicableMethodException arityMismatch() {
+                return unambiguousNoInstanceException.setMessage("infer.arg.length.mismatch");
+            }
+            public InapplicableMethodException argumentMismatch(boolean varargs, Type found, Type expected) {
+                String key = varargs ?
+                    "infer.varargs.argument.mismatch" :
+                    "infer.no.conforming.assignment.exists";
+                return unambiguousNoInstanceException.setMessage(key,
+                        inferenceVars(undetvars), found, expected);
+            }
+            public InapplicableMethodException inaccessibleVarargs(Symbol location, Type expected) {
+                return unambiguousNoInstanceException.setMessage("inaccessible.varargs.type",
+                        expected, Kinds.kindName(location), location);
+            }
+        }
+
         /**
          * A delegated type representing a partially uninferred method type.
          * The return type of a partially uninferred method type is a ForAll
@@ -572,7 +559,7 @@
                 rs.checkRawArgumentsAcceptable(env, actuals, formals,
                        allowBoxing, useVarargs, warn);
             }
-            catch (Resolve.InapplicableMethodException ex) {
+            catch (InapplicableMethodException ex) {
                 // inferred method is not applicable
                 throw invalidInstanceException.setMessage(ex.getDiagnostic());
             }
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Mon Feb 13 14:31:32 2012 +0000
@@ -44,6 +44,7 @@
 import static com.sun.tools.javac.code.Kinds.*;
 import static com.sun.tools.javac.code.TypeTags.*;
 import static com.sun.tools.javac.tree.JCTree.Tag.*;
+import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
 
 /** This is the second phase of Enter, in which classes are completed
@@ -142,7 +143,7 @@
                 JCDiagnostic msg = diags.fragment("fatal.err.no.java.lang");
                 throw new FatalError(msg);
             } else {
-                log.error(pos, "doesnt.exist", tsym);
+                log.error(DiagnosticFlag.RESOLVE_ERROR, pos, "doesnt.exist", tsym);
             }
         }
         env.toplevel.starImportScope.importAll(tsym.members());
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -474,52 +474,126 @@
             return false;
         }
     }
+    /**
+     * A check handler is used by the main method applicability routine in order
+     * to handle specific method applicability failures. It is assumed that a class
+     * implementing this interface should throw exceptions that are a subtype of
+     * InapplicableMethodException (see below). Such exception will terminate the
+     * method applicability check and propagate important info outwards (for the
+     * purpose of generating better diagnostics).
+     */
+    interface MethodCheckHandler {
+        /* The number of actuals and formals differ */
+        InapplicableMethodException arityMismatch();
+        /* An actual argument type does not conform to the corresponding formal type */
+        InapplicableMethodException argumentMismatch(boolean varargs, Type found, Type expected);
+        /* The element type of a varargs is not accessible in the current context */
+        InapplicableMethodException inaccessibleVarargs(Symbol location, Type expected);
+    }
+
+    /**
+     * Basic method check handler used within Resolve - all methods end up
+     * throwing InapplicableMethodException; a diagnostic fragment that describes
+     * the cause as to why the method is not applicable is set on the exception
+     * before it is thrown.
+     */
+    MethodCheckHandler resolveHandler = new MethodCheckHandler() {
+            public InapplicableMethodException arityMismatch() {
+                return inapplicableMethodException.setMessage("arg.length.mismatch");
+            }
+            public InapplicableMethodException argumentMismatch(boolean varargs, Type found, Type expected) {
+                String key = varargs ?
+                        "varargs.argument.mismatch" :
+                        "no.conforming.assignment.exists";
+                return inapplicableMethodException.setMessage(key,
+                        found, expected);
+            }
+            public InapplicableMethodException inaccessibleVarargs(Symbol location, Type expected) {
+                return inapplicableMethodException.setMessage("inaccessible.varargs.type",
+                        expected, Kinds.kindName(location), location);
+            }
+    };
+
     void checkRawArgumentsAcceptable(Env<AttrContext> env,
                                 List<Type> argtypes,
                                 List<Type> formals,
                                 boolean allowBoxing,
                                 boolean useVarargs,
                                 Warner warn) {
+        checkRawArgumentsAcceptable(env, List.<Type>nil(), argtypes, formals,
+                allowBoxing, useVarargs, warn, resolveHandler);
+    }
+
+    /**
+     * Main method applicability routine. Given a list of actual types A,
+     * a list of formal types F, determines whether the types in A are
+     * compatible (by method invocation conversion) with the types in F.
+     *
+     * Since this routine is shared between overload resolution and method
+     * type-inference, it is crucial that actual types are converted to the
+     * corresponding 'undet' form (i.e. where inference variables are replaced
+     * with undetvars) so that constraints can be propagated and collected.
+     *
+     * Moreover, if one or more types in A is a poly type, this routine calls
+     * Infer.instantiateArg in order to complete the poly type (this might involve
+     * deferred attribution).
+     *
+     * A method check handler (see above) is used in order to report errors.
+     */
+    List<Type> checkRawArgumentsAcceptable(Env<AttrContext> env,
+                                List<Type> undetvars,
+                                List<Type> argtypes,
+                                List<Type> formals,
+                                boolean allowBoxing,
+                                boolean useVarargs,
+                                Warner warn,
+                                MethodCheckHandler handler) {
         Type varargsFormal = useVarargs ? formals.last() : null;
+        ListBuffer<Type> checkedArgs = ListBuffer.lb();
+
         if (varargsFormal == null &&
                 argtypes.size() != formals.size()) {
-            throw inapplicableMethodException.setMessage("arg.length.mismatch"); // not enough args
+            throw handler.arityMismatch(); // not enough args
         }
 
         while (argtypes.nonEmpty() && formals.head != varargsFormal) {
-            boolean works = allowBoxing
-                ? types.isConvertible(argtypes.head, formals.head, warn)
-                : types.isSubtypeUnchecked(argtypes.head, formals.head, warn);
-            if (!works)
-                throw inapplicableMethodException.setMessage("no.conforming.assignment.exists",
-                        argtypes.head,
-                        formals.head);
+            Type undetFormal = infer.asUndetType(formals.head, undetvars);
+            Type capturedActual = types.capture(argtypes.head);
+            boolean works = allowBoxing ?
+                    types.isConvertible(capturedActual, undetFormal, warn) :
+                    types.isSubtypeUnchecked(capturedActual, undetFormal, warn);
+            if (!works) {
+                throw handler.argumentMismatch(false, argtypes.head, formals.head);
+            }
+            checkedArgs.append(capturedActual);
             argtypes = argtypes.tail;
             formals = formals.tail;
         }
 
-        if (formals.head != varargsFormal)
-            throw inapplicableMethodException.setMessage("arg.length.mismatch"); // not enough args
+        if (formals.head != varargsFormal) {
+            throw handler.arityMismatch(); // not enough args
+        }
 
         if (useVarargs) {
+            //note: if applicability check is triggered by most specific test,
+            //the last argument of a varargs is _not_ an array type (see JLS 15.12.2.5)
             Type elt = types.elemtype(varargsFormal);
+            Type eltUndet = infer.asUndetType(elt, undetvars);
             while (argtypes.nonEmpty()) {
-                if (!types.isConvertible(argtypes.head, elt, warn))
-                    throw inapplicableMethodException.setMessage("varargs.argument.mismatch",
-                            argtypes.head,
-                            elt);
+                Type capturedActual = types.capture(argtypes.head);
+                if (!types.isConvertible(capturedActual, eltUndet, warn)) {
+                    throw handler.argumentMismatch(true, argtypes.head, elt);
+                }
+                checkedArgs.append(capturedActual);
                 argtypes = argtypes.tail;
             }
             //check varargs element type accessibility
-            if (!isAccessible(env, elt)) {
+            if (undetvars.isEmpty() && !isAccessible(env, elt)) {
                 Symbol location = env.enclClass.sym;
-                throw inapplicableMethodException.setMessage("inaccessible.varargs.type",
-                            elt,
-                            Kinds.kindName(location),
-                            location);
+                throw handler.inaccessibleVarargs(location, elt);
             }
         }
-        return;
+        return checkedArgs.toList();
     }
     // where
         public static class InapplicableMethodException extends RuntimeException {
--- a/langtools/src/share/classes/com/sun/tools/javac/main/Main.java	Mon Feb 13 14:26:25 2012 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javac/main/Main.java	Mon Feb 13 14:31:32 2012 +0000
@@ -31,6 +31,7 @@
 import java.net.URL;
 import java.security.DigestInputStream;
 import java.security.MessageDigest;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.LinkedHashSet;
 import java.util.Set;
@@ -208,6 +209,10 @@
      *  @param flags    The array of command line arguments.
      */
     public Collection<File> processArgs(String[] flags) { // XXX sb protected
+        return processArgs(flags, null);
+    }
+
+    public Collection<File> processArgs(String[] flags, String[] classNames) { // XXX sb protected
         int ac = 0;
         while (ac < flags.length) {
             String flag = flags[ac];
@@ -248,6 +253,10 @@
             }
         }
 
+        if (this.classnames != null && classNames != null) {
+            this.classnames.addAll(Arrays.asList(classNames));
+        }
+
         if (!checkDirectory(D))
             return null;
         if (!checkDirectory(S))
@@ -346,6 +355,15 @@
                        List<JavaFileObject> fileObjects,
                        Iterable<? extends Processor> processors)
     {
+        return compile(args,  null, context, fileObjects, processors);
+    }
+
+    public Result compile(String[] args,
+                       String[] classNames,
+                       Context context,
+                       List<JavaFileObject> fileObjects,
+                       Iterable<? extends Processor> processors)
+    {
         context.put(Log.outKey, out);
         log = Log.instance(context);
 
@@ -361,14 +379,16 @@
          * into account.
          */
         try {
-            if (args.length == 0 && fileObjects.isEmpty()) {
+            if (args.length == 0
+                    && (classNames == null || classNames.length == 0)
+                    && fileObjects.isEmpty()) {
                 Option.HELP.process(optionHelper, "-help");
                 return Result.CMDERR;
             }
 
             Collection<File> files;
             try {
-                files = processArgs(CommandLine.parse(args));
+                files = processArgs(CommandLine.parse(args), classNames);
                 if (files == null) {
                     // null signals an error in options, abort
                     return Result.CMDERR;
--- a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Mon Feb 13 14:26:25 2012 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Mon Feb 13 14:31:32 2012 +0000
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -1620,6 +1620,10 @@
 compiler.misc.infer.arg.length.mismatch=\
     cannot instantiate from arguments because actual and formal argument lists differ in length
 
+# 0: list of type, 1: type, 2: type
+compiler.misc.infer.varargs.argument.mismatch=\
+    no instance(s) of type variable(s) {0} exist so that argument type {1} conforms to vararg element type {2}
+
 # 0: type, 1: list of type
 compiler.misc.inferred.do.not.conform.to.bounds=\
     inferred type does not conform to declared bound(s)\n\
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/7129225/Anno.java	Mon Feb 13 14:31:32 2012 +0000
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Target;
+
+@Target(ElementType.TYPE)
+public @interface Anno {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/7129225/AnnoProcessor.java	Mon Feb 13 14:31:32 2012 +0000
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.util.Set;
+import javax.annotation.processing.*;
+import javax.lang.model.SourceVersion;
+import javax.lang.model.element.TypeElement;
+import javax.tools.Diagnostic.Kind;
+
+@SupportedAnnotationTypes("Anno")
+public class AnnoProcessor extends JavacTestingAbstractProcessor {
+    @Override
+    public SourceVersion getSupportedSourceVersion() {
+        return SourceVersion.latest();
+    }
+
+    @Override
+    public boolean process(Set<? extends TypeElement> set, RoundEnvironment re) {
+        messager.printMessage(Kind.NOTE, "RUNNING - lastRound = " + re.processingOver());
+        return true;
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/7129225/NegTest.ref	Mon Feb 13 14:31:32 2012 +0000
@@ -0,0 +1,2 @@
+TestImportStar.java:39:1: compiler.err.doesnt.exist: xxx
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/7129225/TestImportStar.java	Mon Feb 13 14:31:32 2012 +0000
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+ * @bug 7129225
+ * @summary import xxx.* isn't handled correctly by annotation processing
+ * @library ../lib
+ * @build JavacTestingAbstractProcessor
+ * @compile/fail/ref=NegTest.ref -XDrawDiagnostics TestImportStar.java
+ * @compile Anno.java AnnoProcessor.java
+ * @compile/ref=TestImportStar.ref -XDrawDiagnostics -processor AnnoProcessor -proc:only TestImportStar.java
+ */
+
+ //The @compile/fail... verifies that the fix doesn't break the normal compilation of import xxx.*
+ //The @comple/ref... verifies the fix fixes the bug
+
+import xxx.*;
+
+@Anno
+public class TestImportStar {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/7129225/TestImportStar.ref	Mon Feb 13 14:31:32 2012 +0000
@@ -0,0 +1,3 @@
+- compiler.note.proc.messager: RUNNING - lastRound = false
+TestImportStar.java:39:1: compiler.err.doesnt.exist: xxx
+- compiler.note.proc.messager: RUNNING - lastRound = true
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/InferVarargsArgumentMismatch.java	Mon Feb 13 14:31:32 2012 +0000
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.cant.apply.symbol.1
+// key: compiler.misc.infer.varargs.argument.mismatch
+
+class InferVarargsArgumentMismatch {
+    <X> void m(X x1, String... xs) {}
+    { this.m("", 1); }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javah/T7126832/T7126832.java	Mon Feb 13 14:31:32 2012 +0000
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7126832
+ * @compile java.java
+ * @summary com.sun.tools.javac.api.ClientCodeWrapper$WrappedJavaFileManager cannot be cast
+ * @run main T7126832
+ */
+
+import java.io.*;
+import java.util.*;
+
+public class T7126832 {
+    public static void main(String... args) throws Exception {
+        new T7126832().run();
+    }
+
+    void run() throws Exception {
+        Locale prev = Locale.getDefault();
+        Locale.setDefault(Locale.ENGLISH);
+        try {
+            // Verify that a .java file is correctly diagnosed
+            File ff = writeFile(new File("JavahTest.java"), "class JavahTest {}");
+            test(Arrays.asList(ff.getPath()), 1, "Could not find class file for 'JavahTest.java'.");
+
+            // Verify that a class named 'xx.java' is accepted.
+            // Note that ./xx/java.class exists, so this should work ok
+            test(Arrays.asList("xx.java"), 0, null);
+
+            if (errors > 0) {
+                throw new Exception(errors + " errors occurred");
+            }
+        } finally {
+           Locale.setDefault(prev);
+        }
+    }
+
+    void test(List<String> args, int expectRC, String expectOut) {
+        System.err.println("Test: " + args
+                + " rc:" + expectRC
+                + ((expectOut != null) ? " out:" + expectOut : ""));
+
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        int rc = 0;
+        String out = null;
+        try {
+            rc = com.sun.tools.javah.Main.run(args.toArray(new String[args.size()]), pw);
+            out = sw.toString();
+        } catch(Exception ee) {
+            rc = 1;
+            out = ee.toString();;
+        }
+        pw.close();
+        if (!out.isEmpty()) {
+            System.err.println(out);
+        }
+        if (rc != expectRC) {
+            error("Unexpected exit code: " + rc + "; expected: " + expectRC);
+        }
+        if (expectOut != null && !out.contains(expectOut)) {
+            error("Expected string not found: " + expectOut);
+        }
+
+        System.err.println();
+    }
+
+    File writeFile(File ff, String ss) throws IOException {
+        if (ff.getParentFile() != null)
+            ff.getParentFile().mkdirs();
+
+        try (FileWriter out = new FileWriter(ff)) {
+            out.write(ss);
+        }
+        return ff;
+    }
+
+    void error(String msg) {
+        System.err.println(msg);
+        errors++;
+    }
+
+    int errors;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javah/T7126832/java.java	Mon Feb 13 14:31:32 2012 +0000
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package xx;
+class java {
+    int fred;
+}
--- a/make/jprt.properties	Mon Feb 13 14:26:25 2012 +0000
+++ b/make/jprt.properties	Mon Feb 13 14:31:32 2012 +0000
@@ -63,19 +63,33 @@
 
 # Default jdk test targets (testset=default)
 jprt.make.rule.default.test.targets=				\
-    ${jprt.my.test.target.set:TESTNAME=langtools_jtreg},	\
-    ${jprt.my.test.target.set:TESTNAME=jdk_beans1},		\
+    ${jprt.my.test.target.set:TESTNAME=langtools_jtreg},        \
+    ${jprt.my.test.target.set:TESTNAME=jdk_lang},               \
+    ${jprt.my.test.target.set:TESTNAME=jdk_math}
+
+# Default vm test targets (testset=core)
+jprt.vm.core.test.targets=                                      \
+    ${jprt.vm.default.test.targets}
+
+# Core jdk test targets (testset=core)
+jprt.make.rule.core.test.targets=                               \
+    ${jprt.make.rule.default.test.targets},                     \
+    ${jprt.my.test.target.set:TESTNAME=jdk_util},               \
     ${jprt.my.test.target.set:TESTNAME=jdk_io},			\
-    ${jprt.my.test.target.set:TESTNAME=jdk_lang},		\
-    ${jprt.my.test.target.set:TESTNAME=jdk_math},		\
-    ${jprt.my.test.target.set:TESTNAME=jdk_misc},		\
     ${jprt.my.test.target.set:TESTNAME=jdk_net},		\
     ${jprt.my.test.target.set:TESTNAME=jdk_nio1},		\
     ${jprt.my.test.target.set:TESTNAME=jdk_nio2},		\
     ${jprt.my.test.target.set:TESTNAME=jdk_nio3},		\
     ${jprt.my.test.target.set:TESTNAME=jdk_security1},		\
+    ${jprt.my.test.target.set:TESTNAME=jdk_security2},          \
+    ${jprt.my.test.target.set:TESTNAME=jdk_security3},          \
+    ${jprt.my.test.target.set:TESTNAME=jdk_rmi},                \
+    ${jprt.my.test.target.set:TESTNAME=jdk_management1},        \
+    ${jprt.my.test.target.set:TESTNAME=jdk_management2},        \
     ${jprt.my.test.target.set:TESTNAME=jdk_text},		\
-    ${jprt.my.test.target.set:TESTNAME=jdk_util}
+    ${jprt.my.test.target.set:TESTNAME=jdk_tools1},             \
+    ${jprt.my.test.target.set:TESTNAME=jdk_tools2},             \
+    ${jprt.my.test.target.set:TESTNAME=jdk_misc}
 
 # All vm test targets (testset=all)
 jprt.vm.all.test.targets=    					\
@@ -85,19 +99,13 @@
 
 # All jdk test targets (testset=all)
 jprt.make.rule.all.test.targets=    				\
-    ${jprt.make.rule.default.test.targets}, 			\
+    ${jprt.make.rule.core.test.targets}, 			\
     ${jprt.my.test.target.set:TESTNAME=jdk_awt},		\
+    ${jprt.my.test.target.set:TESTNAME=jdk_beans1},             \
     ${jprt.my.test.target.set:TESTNAME=jdk_beans2},		\
     ${jprt.my.test.target.set:TESTNAME=jdk_beans3},		\
-    ${jprt.my.test.target.set:TESTNAME=jdk_management1},	\
-    ${jprt.my.test.target.set:TESTNAME=jdk_management2},	\
-    ${jprt.my.test.target.set:TESTNAME=jdk_rmi},		\
-    ${jprt.my.test.target.set:TESTNAME=jdk_security2},		\
-    ${jprt.my.test.target.set:TESTNAME=jdk_security3},		\
     ${jprt.my.test.target.set:TESTNAME=jdk_sound},		\
-    ${jprt.my.test.target.set:TESTNAME=jdk_swing},		\
-    ${jprt.my.test.target.set:TESTNAME=jdk_tools1},		\
-    ${jprt.my.test.target.set:TESTNAME=jdk_tools2}
+    ${jprt.my.test.target.set:TESTNAME=jdk_swing}
 
 # JCK test targets in test/Makefile (no windows)
 jprt.my.jck.test.target.set=					\