Merge
diff --git a/jdk/make/common/Defs-embedded.gmk b/jdk/make/common/Defs-embedded.gmk
index de449f8..089fae9 100644
--- a/jdk/make/common/Defs-embedded.gmk
+++ b/jdk/make/common/Defs-embedded.gmk
@@ -65,5 +65,12 @@
   NIO_PLATFORM_CLASSES_ROOT_DIR = $(CLOSED_PLATFORM_SRC)/classes/
 endif
 
+# For ARM sflt we need to link to a library with improved FP accuracy
+# and it must be linked after fdlibm - this places it at the end after libc
+# -z muldefs avoids linker errors for duplicate symbols.
+ifeq ($(CROSS_COMPILE_ARCH), arm)
+  EXTRA_LIBS +=  $(EXT_LIBS_PATH)/sflt_glibc_jdk.a -Xlinker -z -Xlinker muldefs
+endif
+
 endif # JAVASE_EMBEDDED
 
diff --git a/jdk/make/common/Defs.gmk b/jdk/make/common/Defs.gmk
index 99d1ed1..5f8d911 100644
--- a/jdk/make/common/Defs.gmk
+++ b/jdk/make/common/Defs.gmk
@@ -202,7 +202,7 @@
 #
 # zlib version
 #
-ZLIB_VERSION = 1.2.3
+ZLIB_VERSION = 1.2.5
 
 
 #
diff --git a/jdk/make/common/Rules.gmk b/jdk/make/common/Rules.gmk
index 5072b33..041e1d2 100644
--- a/jdk/make/common/Rules.gmk
+++ b/jdk/make/common/Rules.gmk
@@ -233,13 +233,15 @@
 	@$(MKDIR) -p $(CLASSDESTDIR)
 	@$(RM) $<.filtered
 	@$(CAT) $< | $(NAWK) 'length>0' | $(SORT) -u > $<.filtered
-	@if [ `$(CAT) $<.filtered | $(WC) -l` -ge 1 ] ; then \
-	  $(ECHO) "# Java sources to be compiled: (listed in file $<)"; \
-	  $(CAT) $<.filtered; \
-	  $(ECHO) "# Running javac:"; \
-	  $(ECHO) $(JAVAC_CMD) -sourcepath "$(SOURCEPATH)" -d $(CLASSDESTDIR) @$<.filtered; \
-	  $(JAVAC_CMD) -sourcepath "$(SOURCEPATH)" -d $(CLASSDESTDIR) @$<.filtered; \
-	fi
+	@numfiles=`$(WC) -l < $<.filtered` ; \
+	  if [ $$numfiles -ge 1 ] ; then \
+	    $(ECHO) "# Java sources to be compiled: (listed in file $<)"; \
+	    $(CAT) $<.filtered; \
+	    $(ECHO) "# Running javac: $$numfiles files; in $(CURDIR)"; \
+	    $(ECHO) $(JAVAC_CMD) -sourcepath "$(SOURCEPATH)" -d $(CLASSDESTDIR) @$<.filtered; \
+	    $(JAVAC_CMD) -sourcepath "$(SOURCEPATH)" -d $(CLASSDESTDIR) @$<.filtered; \
+	    $(ECHO) "# javac finished"; \
+	  fi
 	@$(java-vm-cleanup)
 
 clobber clean::
diff --git a/jdk/make/java/zip/FILES_c.gmk b/jdk/make/java/zip/FILES_c.gmk
index 6664887..a1d5e93 100644
--- a/jdk/make/java/zip/FILES_c.gmk
+++ b/jdk/make/java/zip/FILES_c.gmk
@@ -32,7 +32,10 @@
 	zip_util.c \
 	compress.c \
 	deflate.c \
-	gzio.c \
+	gzclose.c \
+	gzlib.c \
+	gzread.c \
+	gzwrite.c \
 	infback.c \
 	inffast.c \
 	inflate.c \
diff --git a/jdk/make/java/zip/mapfile-vers b/jdk/make/java/zip/mapfile-vers
index fdcd5b6..3f95d47 100644
--- a/jdk/make/java/zip/mapfile-vers
+++ b/jdk/make/java/zip/mapfile-vers
@@ -30,8 +30,10 @@
 		Java_java_util_jar_JarFile_getMetaInfEntryNames;
 		Java_java_util_zip_Adler32_update;
 		Java_java_util_zip_Adler32_updateBytes;
+		Java_java_util_zip_Adler32_updateByteBuffer;
 		Java_java_util_zip_CRC32_update;
 		Java_java_util_zip_CRC32_updateBytes;
+		Java_java_util_zip_CRC32_updateByteBuffer;
 		Java_java_util_zip_Deflater_deflateBytes;
 		Java_java_util_zip_Deflater_end;
 		Java_java_util_zip_Deflater_getAdler;
diff --git a/jdk/make/sun/awt/FILES_c_unix.gmk b/jdk/make/sun/awt/FILES_c_unix.gmk
index 2d4f1fc..55a387e 100644
--- a/jdk/make/sun/awt/FILES_c_unix.gmk
+++ b/jdk/make/sun/awt/FILES_c_unix.gmk
@@ -140,71 +140,13 @@
 	debug_trace.c \
 	debug_util.c
 
-# These files rely on motif to be built, and should not be included
-# in a headless build.
-
-#FILES_MOTIF_c = \
-#keep	awt_AWTEvent.c \
-#	awt_Button.c \
-#	awt_Canvas.c \
-#	awt_Checkbox.c \
-#keep .h	awt_Component.c \
-#keep .h	awt_Cursor.c \
-#	awt_DataTransferer.c \
-#	awt_DrawingSurface.c \
-#	awt_Event.c \
-#	awt_FileDialog.c \
-#	awt_GlobalCursorManager.c \
-#	awt_GraphicsEnv.c \
-#	awt_InputMethod.c \
-#keep	awt_Insets.c \
-#	awt_KeyboardFocusManager.c \
-#	awt_Label.c \
-#	awt_List.c \
-#	awt_Menu.c \
-#	awt_MenuBar.c \
-#	awt_MenuComponent.c \
-#	awt_MenuItem.c \
-#	awt_motif.c \
-#	awt_Plugin.c \
-#	awt_PopupMenu.c \
-#	awt_Robot.c \
-#	awt_Scrollbar.c \
-#	awt_ScrollPane.c \
-#	awt_Selection.c \
-#	awt_UNIXToolkit.c \
-#	awt_TextArea.c \
-#	awt_TextField.c \
-#	awt_TopLevel.c \
-#	awt_mgrsel.c \
-#	awt_util.c \
-#	awt_wm.c \
-#	awt_XmDnD.c \
-#	awt_dnd.c \
-#	awt_dnd_ds.c \
-#	awt_dnd_dt.c \
-#	canvas.c \
-#	cursor.c \
-#	multi_font.c \
-#	robot_common.c \
-#        list.c \
-#        multiVis.c \
-#	XDrawingArea.c \
-#	MouseInfo.c \
-#	awt_xembed.c \
-#	awt_xembed_server.c \
-#        gtk2_interface.c \
-#        swing_GTKEngine.c \
-#        swing_GTKStyle.c
-
-
 # These files are required to be built, with or without motif.  Some of
 # these are only dependent on X11, and some contain native source that
 # is required, even in a headless build.
 
 FILES_NO_MOTIF_c = \
 	awt_Font.c \
-	awt_MToolkit.c \
+	HeadlessToolkit.c \
 	fontpath.c \
 	VDrawingArea.c \
 	X11Color.c \
diff --git a/jdk/make/sun/awt/FILES_export_unix.gmk b/jdk/make/sun/awt/FILES_export_unix.gmk
index 8fef6ce..5cd8a01 100644
--- a/jdk/make/sun/awt/FILES_export_unix.gmk
+++ b/jdk/make/sun/awt/FILES_export_unix.gmk
@@ -61,11 +61,8 @@
 	sun/awt/image/BufImgSurfaceData.java \
 	sun/awt/image/DataBufferNative.java \
 	\
-	sun/awt/motif/X11FontMetrics.java \
 	sun/awt/X11InputMethod.java \
 	sun/awt/motif/MFontConfiguration.java \
-	sun/awt/motif/MFontPeer.java \
-	sun/awt/motif/MToolkit.java \
         sun/awt/DebugSettings.java \
 	sun/awt/EmbeddedFrame.java \
 	sun/awt/PlatformFont.java \
@@ -93,7 +90,6 @@
         sun/java2d/cmm/ColorTransform.java \
         sun/awt/datatransfer/DataTransferer.java \
 	sun/awt/dnd/SunDragSourceContextPeer.java \
-	sun/awt/motif/MToolkitThreadBlockedHandler.java \
 	sun/java2d/opengl/OGLBlitLoops.java \
 	sun/java2d/opengl/OGLContext.java \
 	sun/java2d/opengl/OGLMaskFill.java \
diff --git a/jdk/make/sun/awt/mapfile-mawt-vers b/jdk/make/sun/awt/mapfile-mawt-vers
index d9315e0..6cc59bd 100644
--- a/jdk/make/sun/awt/mapfile-mawt-vers
+++ b/jdk/make/sun/awt/mapfile-mawt-vers
@@ -31,7 +31,6 @@
 	global:
 		JNI_OnLoad;
 
-                #Java_sun_awt_motif_MComponentPeer_restoreFocus;
 		Java_sun_awt_DefaultMouseInfoPeer_fillPointWithCoords;
 		Java_sun_awt_DefaultMouseInfoPeer_isWindowUnderMouse;
 		Java_java_awt_AWTEvent_nativeSetSource;
@@ -56,230 +55,11 @@
                 Java_sun_awt_UNIXToolkit_load_1stock_1icon;
                 Java_sun_awt_UNIXToolkit_load_1gtk_1icon;
 		Java_sun_awt_UNIXToolkit_nativeSync;
-		#Java_sun_awt_motif_MButtonPeer_create;
-		#Java_sun_awt_motif_MButtonPeer_setLabel;
-                #Java_sun_awt_motif_MPanelPeer_pEnsureIndex;
-                #Java_sun_awt_motif_MPanelPeer_pRestack;
-		#Java_sun_awt_motif_MCanvasPeer_create;
-		#Java_sun_awt_motif_MCanvasPeer_initIDs;
-		#Java_sun_awt_motif_MCanvasPeer_resetTargetGC;
-		#Java_sun_awt_motif_MCheckboxMenuItemPeer_pSetState;
-		#Java_sun_awt_motif_MCheckboxPeer_create;
-		#Java_sun_awt_motif_MCheckboxPeer_setCheckboxGroup;
-		#Java_sun_awt_motif_MCheckboxPeer_setLabel;
-		#Java_sun_awt_motif_MCheckboxPeer_pSetState;
-		#Java_sun_awt_motif_MCheckboxPeer_pGetState;
-		#Java_sun_awt_motif_MChoicePeer_addItem;
-		#Java_sun_awt_motif_MChoicePeer_appendItems;
-		#Java_sun_awt_motif_MChoicePeer_create;
-		#Java_sun_awt_motif_MChoicePeer_pReshape;
-		#Java_sun_awt_motif_MChoicePeer_remove;
-		#Java_sun_awt_motif_MChoicePeer_removeAll;
-		#Java_sun_awt_motif_MChoicePeer_setBackground;
-		#Java_sun_awt_motif_MChoicePeer_pSelect;
-		#Java_sun_awt_motif_MChoicePeer_setFont;
-		#Java_sun_awt_motif_MChoicePeer_setForeground;
-		#Java_sun_awt_motif_MComponentPeer_addNativeDropTarget;
-		#Java_sun_awt_motif_MComponentPeer_getNativeColor;
-		#Java_sun_awt_motif_MComponentPeer_getWindow;
-		#Java_sun_awt_motif_MComponentPeer_pDisable;
-		#Java_sun_awt_motif_MComponentPeer_pDispose;
-		#Java_sun_awt_motif_MComponentPeer_pEnable;
-		#Java_sun_awt_motif_MComponentPeer_pGetLocationOnScreen;
-		#Java_sun_awt_motif_MComponentPeer_pGetLocationOnScreen2;
-		#Java_sun_awt_motif_MComponentPeer_pHide;
-		#Java_sun_awt_motif_MComponentPeer_pInitialize;
-		#Java_sun_awt_motif_MComponentPeer_pMakeCursorVisible;
-		#Java_sun_awt_motif_MComponentPeer_pReshape;
-		#Java_sun_awt_motif_MComponentPeer_pShow;
-		#Java_sun_awt_motif_MComponentPeer_removeNativeDropTarget;
-		#Java_sun_awt_motif_MComponentPeer_pSetBackground;
-		#Java_sun_awt_motif_MComponentPeer_pSetFont;
-                #Java_sun_awt_motif_MComponentPeer_processSynchronousLightweightTransfer;
-                #Java_sun_awt_motif_MComponentPeer__1requestFocus;
-                #Java_sun_awt_motif_MComponentPeer_getNativeFocusedWindow;
-		#Java_sun_awt_motif_MCheckboxMenuItemPeer_getState;
-		#Java_sun_awt_motif_MComponentPeer_pSetForeground;
-		#Java_sun_awt_motif_MDragSourceContextPeer_startDrag;
-		#Java_sun_awt_motif_MDragSourceContextPeer_setNativeCursor;
-		#Java_sun_awt_motif_MDropTargetContextPeer_addTransfer;
-		#Java_sun_awt_motif_MDropTargetContextPeer_dropDone;
-		#Java_sun_awt_motif_MDropTargetContextPeer_startTransfer;
-		#Java_sun_awt_motif_X11DragSourceContextPeer_startDrag;
-		#Java_sun_awt_motif_X11DragSourceContextPeer_setNativeCursor;
-		#Java_sun_awt_motif_X11DropTargetContextPeer_sendResponse;
-		#Java_sun_awt_motif_X11DropTargetContextPeer_dropDone;
-		#Java_sun_awt_motif_X11DropTargetContextPeer_getData;
-		#Java_sun_awt_motif_MEmbeddedFramePeer_NEFcreate;
-		#Java_sun_awt_motif_MEmbeddedFramePeer_pShowImpl;
-		#Java_sun_awt_motif_MEmbeddedFramePeer_requestXEmbedFocus;
-		#Java_sun_awt_motif_MEmbeddedFramePeer_isXEmbedApplicationActive;
-		#Java_sun_awt_motif_MEmbeddedFramePeer_isXEmbedActive;
-                #Java_sun_awt_motif_MEmbeddedFramePeer_synthesizeFocusInOut;
-		#Java_sun_awt_motif_MEmbeddedFramePeer_pReshapePrivate;
-		#Java_sun_awt_motif_MEmbeddedFramePeer_getBoundsPrivate;
-		#Java_sun_awt_motif_MEmbeddedFrame_getWidget;
-		#Java_sun_awt_motif_MEmbeddedFrame_mapWidget;
-                #Java_sun_awt_motif_MEmbedCanvasPeer_forwardEventToEmbedded;       
-		#Java_sun_awt_motif_MFramePeer_pSetIconImage___3B_3I_3SII;
-		#Java_sun_awt_motif_MFileDialogPeer_create;
-		#Java_sun_awt_motif_MFileDialogPeer_pDispose;
-		#Java_sun_awt_motif_MFileDialogPeer_pHide;
-		#Java_sun_awt_motif_MFileDialogPeer_pReshape;
-		#Java_sun_awt_motif_MFileDialogPeer_pShow;
-		#Java_sun_awt_motif_MFileDialogPeer_setFileEntry;
-		#Java_sun_awt_motif_MFileDialogPeer_setFont;
-		#Java_sun_awt_motif_MFramePeer_pGetIconSize;
-		#Java_sun_awt_motif_MGlobalCursorManager_cacheInit;
-		#Java_sun_awt_motif_MGlobalCursorManager_findComponentAt;
-		#Java_sun_awt_motif_MGlobalCursorManager_findHeavyweightUnderCursor;
-		#Java_sun_awt_motif_MGlobalCursorManager_getCursorPos;
-		#Java_sun_awt_motif_MGlobalCursorManager_getLocationOnScreen;
-		#Java_sun_awt_motif_MLabelPeer_create;
-		#Java_sun_awt_motif_MLabelPeer_setAlignment;
-		#Java_sun_awt_motif_MLabelPeer_setText;
-		#Java_sun_awt_motif_MListPeer_addItem;
-		#Java_sun_awt_motif_MListPeer_create;
-		#Java_sun_awt_motif_MListPeer_delItems;
-		#Java_sun_awt_motif_MListPeer_deselect;
-		#Java_sun_awt_motif_MListPeer_isSelected;
-		#Java_sun_awt_motif_MListPeer_makeVisible;
-		#Java_sun_awt_motif_MListPeer_nativeHandleMouseWheel;
-		#Java_sun_awt_motif_MListPeer_select;
-		#Java_sun_awt_motif_MListPeer_setMultipleSelections;
-		#Java_sun_awt_motif_MMenuBarPeer_create;
-		#Java_sun_awt_motif_MMenuItemPeer_createMenuItem;
-		#Java_sun_awt_motif_MMenuItemPeer_pDisable;
-		#Java_sun_awt_motif_MMenuItemPeer_pDispose;
-		#Java_sun_awt_motif_MMenuItemPeer_pEnable;
-		#Java_sun_awt_motif_MMenuItemPeer_pSetLabel;
-		#Java_sun_awt_motif_MMenuPeer_createMenu;
-		#Java_sun_awt_motif_MMenuPeer_createSubMenu;
-		#Java_sun_awt_motif_MMenuPeer_pDispose;
-		#Java_sun_awt_motif_MPopupMenuPeer_createMenu;
-		#Java_sun_awt_motif_MPopupMenuPeer_pDispose;
-		#Java_sun_awt_motif_MPopupMenuPeer_pShow;
-		#Java_sun_awt_motif_MRobotPeer_getRGBPixelsImpl;
-		#Java_sun_awt_motif_MRobotPeer_keyPressImpl;
-		#Java_sun_awt_motif_MRobotPeer_keyReleaseImpl;
-		#Java_sun_awt_motif_MRobotPeer_mouseMoveImpl;
-		#Java_sun_awt_motif_MRobotPeer_mousePressImpl;
-		#Java_sun_awt_motif_MRobotPeer_mouseReleaseImpl;
-		#Java_sun_awt_motif_MRobotPeer_mouseWheelImpl;
-		#Java_sun_awt_motif_MRobotPeer_setup;
-		#Java_sun_awt_motif_MScrollbarPeer_create;
-		#Java_sun_awt_motif_MScrollbarPeer_setLineIncrement;
-		#Java_sun_awt_motif_MScrollbarPeer_setPageIncrement;
-		#Java_sun_awt_motif_MScrollbarPeer_pSetValues;
-		#Java_sun_awt_motif_MScrollPanePeer_create;
-		#Java_sun_awt_motif_MScrollPanePeer_pGetBlockIncrement;
-		#Java_sun_awt_motif_MScrollPanePeer_pGetScrollbarSpace;
-		#Java_sun_awt_motif_MScrollPanePeer_pGetShadow;
-		#Java_sun_awt_motif_MScrollPanePeer_pInsets;
-		#Java_sun_awt_motif_MScrollPanePeer_pSetIncrement;
-		#Java_sun_awt_motif_MScrollPanePeer_pSetScrollChild;
-		#Java_sun_awt_motif_MScrollPanePeer_setScrollPosition;
-		#Java_sun_awt_motif_MScrollPanePeer_setTypedValue;
-		#Java_sun_awt_motif_MTextAreaPeer_initIDs;
-		#Java_sun_awt_motif_MTextAreaPeer_pCreate;
-		#Java_sun_awt_motif_MTextAreaPeer_getCaretPosition;
-		#Java_sun_awt_motif_MTextAreaPeer_getExtraHeight;
-		#Java_sun_awt_motif_MTextAreaPeer_getExtraWidth;
-		#Java_sun_awt_motif_MTextAreaPeer_getSelectionEnd;
-		#Java_sun_awt_motif_MTextAreaPeer_getSelectionStart;
-		#Java_sun_awt_motif_MTextAreaPeer_getText;
-		#Java_sun_awt_motif_MTextAreaPeer_insert;
-		#Java_sun_awt_motif_MTextAreaPeer_nativeHandleMouseWheel;
-		#Java_sun_awt_motif_MTextAreaPeer_pMakeCursorVisible;
-		#Java_sun_awt_motif_MTextAreaPeer_pSetEditable;
-		#Java_sun_awt_motif_MTextAreaPeer_pShow2;
-		#Java_sun_awt_motif_MTextAreaPeer_replaceRange;
-		#Java_sun_awt_motif_MTextAreaPeer_select;
-                #Java_sun_awt_motif_MTextAreaPeer_setCaretPosition;
-		#Java_sun_awt_motif_MTextAreaPeer_setFont;
-		#Java_sun_awt_motif_MTextAreaPeer_setText;
-		#Java_sun_awt_motif_MTextAreaPeer_setTextBackground;
-		#Java_sun_awt_motif_MTextFieldPeer_initIDs;
-		#Java_sun_awt_motif_MTextFieldPeer_pCreate;
-		#Java_sun_awt_motif_MTextFieldPeer_getCaretPosition;
-		#Java_sun_awt_motif_MTextFieldPeer_getSelectionEnd;
-		#Java_sun_awt_motif_MTextFieldPeer_getSelectionStart;
-		#Java_sun_awt_motif_MTextFieldPeer_getText;
-		#Java_sun_awt_motif_MTextFieldPeer_insertReplaceText;
-		#Java_sun_awt_motif_MTextFieldPeer_preDispose;
-		#Java_sun_awt_motif_MTextFieldPeer_pSetEditable;
-		#Java_sun_awt_motif_MTextFieldPeer_select;
-		#Java_sun_awt_motif_MTextFieldPeer_setCaretPosition;
-		#Java_sun_awt_motif_MTextFieldPeer_setEchoChar;
-		#Java_sun_awt_motif_MTextFieldPeer_setFont;
-		#Java_sun_awt_motif_MTextFieldPeer_setText;
-		Java_sun_awt_motif_MToolkit_beep;
-		Java_sun_awt_motif_MToolkit_getLockingKeyStateNative;
-		Java_sun_awt_motif_MToolkit_getMulticlickTime;
-		Java_sun_awt_motif_MToolkit_getNumMouseButtons;
-		Java_sun_awt_motif_MToolkit_loadXSettings;
-		Java_sun_awt_motif_MToolkit_getScreenHeight;
-		Java_sun_awt_motif_MToolkit_getScreenResolution;
-		Java_sun_awt_motif_MToolkit_getScreenWidth;
-		Java_sun_awt_motif_MToolkit_init;
-		Java_sun_awt_motif_MToolkit_isDynamicLayoutSupportedNative;
-		Java_sun_awt_motif_MToolkit_isFrameStateSupported;
-		Java_sun_awt_motif_MToolkit_loadSystemColors;
-		Java_sun_awt_motif_MToolkit_makeColorModel;
-		Java_sun_awt_motif_MToolkit_run;
-                Java_sun_awt_motif_MToolkit_isAlwaysOnTopSupported;
-                Java_sun_awt_motif_MToolkit_getEventNumber;
-                Java_sun_awt_motif_MToolkit_updateSyncSelection;
-                Java_sun_awt_motif_MToolkit_isSyncUpdated;
-                Java_sun_awt_motif_MToolkit_isSyncFailed;
-                Java_sun_awt_motif_MToolkit_nativeUnGrab;
-                Java_sun_awt_motif_MToolkit_nativeGrab;
-                Java_sun_awt_motif_MToolkit_getWMName;
-		Java_sun_awt_motif_MWindowAttributes_initIDs;
-		#Java_sun_awt_motif_MWindowPeer_pDispose;
-		#Java_sun_awt_motif_MWindowPeer_pHide;
-		#Java_sun_awt_motif_MWindowPeer_pReshape;
-		#Java_sun_awt_motif_MWindowPeer_pSetTitle;
-		#Java_sun_awt_motif_MWindowPeer_pShow;
-		#Java_sun_awt_motif_MWindowPeer_setResizable;
-		#Java_sun_awt_motif_MWindowPeer_toBack;
-		#Java_sun_awt_motif_MWindowPeer_addTextComponentNative;
-		#Java_sun_awt_motif_MWindowPeer_getState;
-		#Java_sun_awt_motif_MWindowPeer_pSetIMMOption;
-		#Java_sun_awt_motif_MWindowPeer_pSetMenuBar;
-		#Java_sun_awt_motif_MWindowPeer_pShowModal;
-		#Java_sun_awt_motif_MWindowPeer_removeTextComponentNative;
-		#Java_sun_awt_motif_MWindowPeer_setSaveUnder;
-		#Java_sun_awt_motif_MWindowPeer_setState;
-		#Java_sun_awt_motif_MWindowPeer_resetTargetGC;
-		#Java_sun_awt_motif_MWindowPeer_registerX11DropTarget;
-		#Java_sun_awt_motif_MWindowPeer_unregisterX11DropTarget;
-		#Java_sun_awt_motif_MWindowPeer_updateAlwaysOnTop;
-                #Java_sun_awt_motif_MWindowPeer_setFocusableWindow;
-                #Java_sun_awt_motif_MWindowPeer_pToFront;
-		#Java_sun_awt_motif_MCustomCursor_cacheInit;
-		#Java_sun_awt_motif_MCustomCursor_createCursor;
-		#Java_sun_awt_motif_MCustomCursor_queryBestCursor;
-		Java_sun_awt_motif_X11FontMetrics_bytesWidth;
-		Java_sun_awt_motif_X11FontMetrics_getMFCharsWidth;
-		Java_sun_awt_motif_X11FontMetrics_init;
 		Java_sun_awt_X11InputMethod_disposeXIC;
 		Java_sun_awt_X11InputMethod_isCompositionEnabledNative;
 		Java_sun_awt_X11InputMethod_resetXIC;
 		Java_sun_awt_X11InputMethod_setCompositionEnabledNative;
 		Java_sun_awt_X11InputMethod_turnoffStatusWindow;
-		#Java_sun_awt_motif_MInputMethod_openXIMNative;
-		#Java_sun_awt_motif_MInputMethod_configureStatusAreaNative;
-		#Java_sun_awt_motif_MInputMethod_createXICNative;
-		#Java_sun_awt_motif_MInputMethod_reconfigureXICNative;
-		#Java_sun_awt_motif_MInputMethod_setXICFocusNative;
-		#Java_sun_awt_motif_X11Clipboard_getClipboardData;
-		#Java_sun_awt_motif_X11Clipboard_getClipboardFormats;
-		#Java_sun_awt_motif_X11Clipboard_registerClipboardViewer;
-		#Java_sun_awt_motif_X11Clipboard_unregisterClipboardViewer;
-		#Java_sun_awt_motif_X11Selection_init;
-		#Java_sun_awt_motif_X11Selection_pGetSelectionOwnership;
-		#Java_sun_awt_motif_X11Selection_clearNativeContext;
 		Java_sun_awt_SunToolkit_closeSplashScreen;
 		Java_sun_awt_PlatformFont_initIDs;
 		Java_sun_awt_X11GraphicsConfig_init;
@@ -313,25 +93,6 @@
 		Java_sun_awt_X11GraphicsEnvironment_pRunningXinerama;
 		Java_sun_awt_X11GraphicsEnvironment_getXineramaCenterPoint;
 		Java_sun_awt_X11GraphicsEnvironment_initXRender;
-                #Java_sun_awt_motif_MEmbedCanvasPeer_initXEmbedServer;
-                #Java_sun_awt_motif_MEmbedCanvasPeer_destroyXEmbedServer;
-                #Java_sun_awt_motif_MEmbedCanvasPeer_isXEmbedActive;
-                #Java_sun_awt_motif_MEmbedCanvasPeer_initDispatching;
-                #Java_sun_awt_motif_MEmbedCanvasPeer_endDispatching;
-                #Java_sun_awt_motif_MEmbedCanvasPeer_embedChild;
-                #Java_sun_awt_motif_MEmbedCanvasPeer_childDestroyed;
-                #Java_sun_awt_motif_MEmbedCanvasPeer_getEmbedPreferredSize;
-                #Java_sun_awt_motif_MEmbedCanvasPeer_getEmbedMinimumSize;
-                #Java_sun_awt_motif_MEmbedCanvasPeer_getClientBounds;
-                #Java_sun_awt_motif_MEmbedCanvasPeer_notifyChildEmbedded;
-                #Java_sun_awt_motif_MEmbedCanvasPeer_detachChild;
-                #Java_sun_awt_motif_MEmbedCanvasPeer_forwardKeyEvent;
-                #Java_sun_awt_motif_MEmbedCanvasPeer_getAWTKeyCodeForKeySym;
-                #Java_sun_awt_motif_MEmbedCanvasPeer_sendMessage__I;
-                #Java_sun_awt_motif_MEmbedCanvasPeer_sendMessage__IJJJ;
-                #Java_sun_awt_motif_MEmbedCanvasPeer_getWindow;       
-                #Java_sun_awt_motif_GrabbedKey_initKeySymAndModifiers;
-                #Java_sun_awt_motif_MEmbeddedFramePeer_traverseOut;
 		Java_java_awt_AWTEvent_initIDs;
 		Java_java_awt_Button_initIDs;
 		Java_java_awt_Container_initIDs;
@@ -345,41 +106,6 @@
 		Java_java_awt_Insets_initIDs;
 		Java_java_awt_TextField_initIDs;
 		Java_java_awt_Window_initIDs;
-		#Java_sun_awt_motif_MCheckboxPeer_getIndicatorSize;
-		#Java_sun_awt_motif_MCheckboxPeer_getSpacing;
-		#Java_sun_awt_motif_MChoicePeer_freeNativeData;
-		#Java_sun_awt_motif_MComponentPeer_getComponents_1NoClientCode;
-		#Java_sun_awt_motif_MComponentPeer_getParent_1NoClientCode;
-		#Java_sun_awt_motif_MComponentPeer_initIDs;
-		#Java_sun_awt_motif_MComponentPeer_nativeHandleEvent;
-		#Java_sun_awt_motif_MComponentPeer_pSetCursor;
-		#Java_sun_awt_motif_MComponentPeer_pSetInnerForeground;
-		#Java_sun_awt_motif_MComponentPeer_pSetScrollbarBackground;
-		#Java_sun_awt_motif_MComponentPeer_setTargetBackground;
-		#Java_sun_awt_motif_MDataTransferer_dragQueryFile;
-		#Java_sun_awt_motif_MDataTransferer_getAtomForTarget;
-		#Java_sun_awt_motif_MDataTransferer_getTargetNameForAtom;
-		#Java_sun_awt_motif_MFileDialogPeer_insertReplaceFileDialogText;
-		Java_sun_awt_motif_MFontPeer_initIDs;
-		#Java_sun_awt_motif_MListPeer_setBackground;
-		#Java_sun_awt_motif_MMenuBarPeer_initIDs;
-		#Java_sun_awt_motif_MMenuBarPeer_pDispose;
-		#Java_sun_awt_motif_MMenuItemPeer_getParent_1NoClientCode;
-		#Java_sun_awt_motif_MMenuItemPeer_initIDs;
-		#Java_sun_awt_motif_MMenuItemPeer_pSetShortcut;
-		#Java_sun_awt_motif_MPopupMenuPeer_initIDs;
-		#Java_sun_awt_motif_MScrollbarPeer_initIDs;
-		#Java_sun_awt_motif_MScrollPanePeer_initIDs;
-		#Java_sun_awt_motif_MTextAreaPeer_pSetCursor;
-		Java_sun_awt_motif_MToolkit_shutdown;
-		#Java_sun_awt_motif_MWindowPeer_initIDs;
-		#Java_sun_awt_motif_MWindowPeer_pCreate;
-		#Java_sun_awt_motif_MWindowPeer_wrapInSequenced;
-		Java_sun_awt_motif_X11FontMetrics_initIDs;
-		#Java_sun_awt_X11InputMethod_initIDs;
-		#Java_sun_awt_motif_X11Selection_initIDs;
-		Java_sun_awt_motif_MToolkitThreadBlockedHandler_enter;
-		Java_sun_awt_motif_MToolkitThreadBlockedHandler_exit;
 		Java_sun_awt_X11GraphicsConfig_init;
 		Java_sun_awt_X11GraphicsConfig_initIDs;
 		Java_sun_awt_X11GraphicsConfig_makeColorModel;
diff --git a/jdk/make/sun/awt/mapfile-vers-linux b/jdk/make/sun/awt/mapfile-vers-linux
index df80f4e..b7033b8 100644
--- a/jdk/make/sun/awt/mapfile-vers-linux
+++ b/jdk/make/sun/awt/mapfile-vers-linux
@@ -170,7 +170,6 @@
 		GrPrim_Sg2dGetPixel;
 		GrPrim_Sg2dGetLCDTextContrast;
 
-		#Java_sun_awt_motif_MComponentPeer_restoreFocus;
 		Java_sun_awt_DefaultMouseInfoPeer_fillPointWithCoords;
 		Java_sun_awt_DefaultMouseInfoPeer_isWindowUnderMouse;
 		Java_java_awt_AWTEvent_nativeSetSource;
@@ -189,216 +188,11 @@
 		Java_java_awt_ScrollPane_initIDs;
 		Java_java_awt_TextArea_initIDs;
 		Java_sun_awt_FontDescriptor_initIDs;
-		#Java_sun_awt_motif_MButtonPeer_create;
-		#Java_sun_awt_motif_MButtonPeer_setLabel;
-		#Java_sun_awt_motif_MCanvasPeer_create;
-		#Java_sun_awt_motif_MCanvasPeer_initIDs;
-		#Java_sun_awt_motif_MCanvasPeer_resetTargetGC;
-		#Java_sun_awt_motif_MCheckboxMenuItemPeer_pSetState;
-		#Java_sun_awt_motif_MCheckboxPeer_create;
-		#Java_sun_awt_motif_MCheckboxPeer_setCheckboxGroup;
-		#Java_sun_awt_motif_MCheckboxPeer_setLabel;
-		#Java_sun_awt_motif_MCheckboxPeer_pSetState;
-		#Java_sun_awt_motif_MCheckboxPeer_pGetState;
-		#Java_sun_awt_motif_MChoicePeer_addItem;
-		#Java_sun_awt_motif_MChoicePeer_appendItems;
-		#Java_sun_awt_motif_MChoicePeer_create;
-		#Java_sun_awt_motif_MChoicePeer_pReshape;
-		#Java_sun_awt_motif_MChoicePeer_remove;
-		#Java_sun_awt_motif_MChoicePeer_removeAll;
-		#Java_sun_awt_motif_MChoicePeer_setBackground;
-		#Java_sun_awt_motif_MChoicePeer_pSelect;
-		#Java_sun_awt_motif_MChoicePeer_setFont;
-		#Java_sun_awt_motif_MChoicePeer_setForeground;
-		#Java_sun_awt_motif_MComponentPeer_addNativeDropTarget;
-		#Java_sun_awt_motif_MComponentPeer_createBackBuffer;
-		#Java_sun_awt_motif_MComponentPeer_destroyBackBuffer;
-		#Java_sun_awt_motif_MComponentPeer_getNativeColor;
-		#Java_sun_awt_motif_MComponentPeer_getWindow;
-		#Java_sun_awt_motif_MComponentPeer_pDisable;
-		#Java_sun_awt_motif_MComponentPeer_pDispose;
-		#Java_sun_awt_motif_MComponentPeer_pEnable;
-		#Java_sun_awt_motif_MComponentPeer_pGetLocationOnScreen;
-		#Java_sun_awt_motif_MComponentPeer_pGetLocationOnScreen2;
-		#Java_sun_awt_motif_MComponentPeer_pHide;
-		#Java_sun_awt_motif_MComponentPeer_pInitialize;
-		#Java_sun_awt_motif_MComponentPeer_pMakeCursorVisible;
-		#Java_sun_awt_motif_MComponentPeer_pReshape;
-		#Java_sun_awt_motif_MComponentPeer_pShow;
-		#Java_sun_awt_motif_MComponentPeer_removeNativeDropTarget;
-		#Java_sun_awt_motif_MComponentPeer_swapBuffers;
-		#Java_sun_awt_motif_MComponentPeer_pSetBackground;
-		#Java_sun_awt_motif_MComponentPeer_pSetFont;
-                #Java_sun_awt_motif_MComponentPeer_processSynchronousLightweightTransfer;
-                #Java_sun_awt_motif_MComponentPeer__1requestFocus;
-		#Java_sun_awt_motif_MCheckboxMenuItemPeer_getState;
-		#Java_sun_awt_motif_MComponentPeer_pSetForeground;
-		#Java_sun_awt_motif_MDragSourceContextPeer_startDrag;
-		#Java_sun_awt_motif_MDragSourceContextPeer_setNativeCursor;
-		#Java_sun_awt_motif_MDropTargetContextPeer_addTransfer;
-		#Java_sun_awt_motif_MDropTargetContextPeer_dropDone;
-		#Java_sun_awt_motif_MDropTargetContextPeer_startTransfer;
-		#Java_sun_awt_motif_X11DragSourceContextPeer_startDrag;
-		#Java_sun_awt_motif_X11DragSourceContextPeer_setNativeCursor;
-		#Java_sun_awt_motif_X11DropTargetContextPeer_sendResponse;
-		#Java_sun_awt_motif_X11DropTargetContextPeer_dropDone;
-		#Java_sun_awt_motif_X11DropTargetContextPeer_getData;
-		#Java_sun_awt_motif_MEmbeddedFramePeer_NEFcreate;
-		#Java_sun_awt_motif_MEmbeddedFramePeer_pShowImpl;
-		#Java_sun_awt_motif_MEmbeddedFramePeer_pReshapePrivate;
-		#Java_sun_awt_motif_MEmbeddedFramePeer_getBoundsPrivate;
-		#Java_sun_awt_motif_MFramePeer_pSetIconImage___3B_3I_3SII;
-		#Java_sun_awt_motif_MEmbeddedFramePeer_requestXEmbedFocus;
-		#Java_sun_awt_motif_MEmbeddedFramePeer_isXEmbedApplicationActive;
-		#Java_sun_awt_motif_MEmbeddedFramePeer_isXEmbedActive;
-		#Java_sun_awt_motif_MEmbeddedFrame_getWidget;
-		#Java_sun_awt_motif_MEmbeddedFrame_mapWidget;
-		#Java_sun_awt_motif_MFileDialogPeer_create;
-		#Java_sun_awt_motif_MFileDialogPeer_pDispose;
-		#Java_sun_awt_motif_MFileDialogPeer_pHide;
-		#Java_sun_awt_motif_MFileDialogPeer_pReshape;
-		#Java_sun_awt_motif_MFileDialogPeer_pShow;
-		#Java_sun_awt_motif_MFileDialogPeer_setFileEntry;
-		#Java_sun_awt_motif_MFileDialogPeer_setFont;
-		#Java_sun_awt_motif_MFramePeer_pGetIconSize;
-		#Java_sun_awt_motif_MGlobalCursorManager_cacheInit;
-		#Java_sun_awt_motif_MGlobalCursorManager_findComponentAt;
-		#Java_sun_awt_motif_MGlobalCursorManager_findHeavyweightUnderCursor;
-		#Java_sun_awt_motif_MGlobalCursorManager_getCursorPos;
-		#Java_sun_awt_motif_MGlobalCursorManager_getLocationOnScreen;
-		#Java_sun_awt_motif_MLabelPeer_create;
-		#Java_sun_awt_motif_MLabelPeer_setAlignment;
-		#Java_sun_awt_motif_MLabelPeer_setText;
-		#Java_sun_awt_motif_MListPeer_addItem;
-		#Java_sun_awt_motif_MListPeer_create;
-		#Java_sun_awt_motif_MListPeer_delItems;
-		#Java_sun_awt_motif_MListPeer_deselect;
-		#Java_sun_awt_motif_MListPeer_isSelected;
-		#Java_sun_awt_motif_MListPeer_makeVisible;
-		#Java_sun_awt_motif_MListPeer_select;
-		#Java_sun_awt_motif_MListPeer_setMultipleSelections;
-		#Java_sun_awt_motif_MMenuBarPeer_create;
-		#Java_sun_awt_motif_MMenuItemPeer_createMenuItem;
-		#Java_sun_awt_motif_MMenuItemPeer_pDisable;
-		#Java_sun_awt_motif_MMenuItemPeer_pDispose;
-		#Java_sun_awt_motif_MMenuItemPeer_pEnable;
-		#Java_sun_awt_motif_MMenuItemPeer_pSetLabel;
-		#Java_sun_awt_motif_MMenuPeer_createMenu;
-		#Java_sun_awt_motif_MMenuPeer_createSubMenu;
-		#Java_sun_awt_motif_MMenuPeer_pDispose;
-		#Java_sun_awt_motif_MPopupMenuPeer_createMenu;
-		#Java_sun_awt_motif_MPopupMenuPeer_pDispose;
-		#Java_sun_awt_motif_MPopupMenuPeer_pShow;
-		#Java_sun_awt_motif_MRobotPeer_getRGBPixelsImpl;
-		#Java_sun_awt_motif_MRobotPeer_keyPressImpl;
-		#Java_sun_awt_motif_MRobotPeer_keyReleaseImpl;
-		#Java_sun_awt_motif_MRobotPeer_mouseMoveImpl;
-		#Java_sun_awt_motif_MRobotPeer_mousePressImpl;
-		#Java_sun_awt_motif_MRobotPeer_mouseReleaseImpl;
-		#Java_sun_awt_motif_MRobotPeer_mouseWheelImpl;
-		#Java_sun_awt_motif_MRobotPeer_setup;
-		#Java_sun_awt_motif_MScrollbarPeer_create;
-		#Java_sun_awt_motif_MScrollbarPeer_setLineIncrement;
-		#Java_sun_awt_motif_MScrollbarPeer_setPageIncrement;
-		#Java_sun_awt_motif_MScrollbarPeer_pSetValues;
-		#Java_sun_awt_motif_MScrollPanePeer_create;
-		#Java_sun_awt_motif_MScrollPanePeer_pGetBlockIncrement;
-		#Java_sun_awt_motif_MScrollPanePeer_pGetScrollbarSpace;
-		#Java_sun_awt_motif_MScrollPanePeer_pGetShadow;
-		#Java_sun_awt_motif_MScrollPanePeer_pInsets;
-		#Java_sun_awt_motif_MScrollPanePeer_pSetIncrement;
-		#Java_sun_awt_motif_MScrollPanePeer_pSetScrollChild;
-		#Java_sun_awt_motif_MScrollPanePeer_setScrollPosition;
-		#Java_sun_awt_motif_MTextAreaPeer_initIDs;
-		#Java_sun_awt_motif_MTextAreaPeer_pCreate;
-		#Java_sun_awt_motif_MTextAreaPeer_getCaretPosition;
-		#Java_sun_awt_motif_MTextAreaPeer_getExtraHeight;
-		#Java_sun_awt_motif_MTextAreaPeer_getExtraWidth;
-		#Java_sun_awt_motif_MTextAreaPeer_getSelectionEnd;
-		#Java_sun_awt_motif_MTextAreaPeer_getSelectionStart;
-		#Java_sun_awt_motif_MTextAreaPeer_getText;
-		#Java_sun_awt_motif_MTextAreaPeer_insert;
-		#Java_sun_awt_motif_MTextAreaPeer_pMakeCursorVisible;
-		#Java_sun_awt_motif_MTextAreaPeer_pSetEditable;
-		#Java_sun_awt_motif_MTextAreaPeer_pShow2;
-		#Java_sun_awt_motif_MTextAreaPeer_replaceRange;
-		#Java_sun_awt_motif_MTextAreaPeer_select;
-		#Java_sun_awt_motif_MTextAreaPeer_setCaretPosition;
-		#Java_sun_awt_motif_MTextAreaPeer_setFont;
-		#Java_sun_awt_motif_MTextAreaPeer_setText;
-		#Java_sun_awt_motif_MTextAreaPeer_setTextBackground;
-		#Java_sun_awt_motif_MTextFieldPeer_initIDs;
-		#Java_sun_awt_motif_MTextFieldPeer_pCreate;
-		#Java_sun_awt_motif_MTextFieldPeer_getCaretPosition;
-		#Java_sun_awt_motif_MTextFieldPeer_getSelectionEnd;
-		#Java_sun_awt_motif_MTextFieldPeer_getSelectionStart;
-		#Java_sun_awt_motif_MTextFieldPeer_getText;
-		#Java_sun_awt_motif_MTextFieldPeer_insertReplaceText;
-		#Java_sun_awt_motif_MTextFieldPeer_preDispose;
-		#Java_sun_awt_motif_MTextFieldPeer_pSetEditable;
-		#Java_sun_awt_motif_MTextFieldPeer_select;
-		#Java_sun_awt_motif_MTextFieldPeer_setCaretPosition;
-		#Java_sun_awt_motif_MTextFieldPeer_setEchoChar;
-		#Java_sun_awt_motif_MTextFieldPeer_setFont;
-		#Java_sun_awt_motif_MTextFieldPeer_setText;
-		Java_sun_awt_motif_MToolkit_beep;
-		Java_sun_awt_motif_MToolkit_getLockingKeyStateNative;
-		Java_sun_awt_motif_MToolkit_getMulticlickTime;
-                Java_sun_awt_motif_MToolkit_getNumMouseButtons;
-		Java_sun_awt_motif_MToolkit_getScreenHeight;
-		Java_sun_awt_motif_MToolkit_getScreenResolution;
-		Java_sun_awt_motif_MToolkit_getScreenWidth;
-		Java_sun_awt_motif_MToolkit_init;
-		Java_sun_awt_motif_MToolkit_isDynamicLayoutSupportedNative;
-		Java_sun_awt_motif_MToolkit_isFrameStateSupported;
-		Java_sun_awt_motif_MToolkit_loadSystemColors;
-		Java_sun_awt_motif_MToolkit_makeColorModel;
-		Java_sun_awt_motif_MToolkit_run;
-		Java_sun_awt_motif_MToolkit_sync;
-                Java_sun_awt_motif_MToolkit_isAlwaysOnTopSupported;
-		Java_sun_awt_motif_MWindowAttributes_initIDs;
-		#Java_sun_awt_motif_MWindowPeer_pDispose;
-		#Java_sun_awt_motif_MWindowPeer_pHide;
-		#Java_sun_awt_motif_MWindowPeer_pReshape;
-		#Java_sun_awt_motif_MWindowPeer_pSetTitle;
-		#Java_sun_awt_motif_MWindowPeer_pShow;
-		#Java_sun_awt_motif_MWindowPeer_setResizable;
-		#Java_sun_awt_motif_MWindowPeer_toBack;
-		#Java_sun_awt_motif_MWindowPeer_addTextComponentNative;
-		#Java_sun_awt_motif_MWindowPeer_getState;
-		#Java_sun_awt_motif_MWindowPeer_pSetIMMOption;
-		#Java_sun_awt_motif_MWindowPeer_pSetMenuBar;
-		#Java_sun_awt_motif_MWindowPeer_pShowModal;
-		#Java_sun_awt_motif_MWindowPeer_removeTextComponentNative;
-		#Java_sun_awt_motif_MWindowPeer_setSaveUnder;
-		#Java_sun_awt_motif_MWindowPeer_setState;
-		#Java_sun_awt_motif_MWindowPeer_resetTargetGC;
-		#Java_sun_awt_motif_MWindowPeer_registerX11DropTarget;
-		#Java_sun_awt_motif_MWindowPeer_unregisterX11DropTarget;
-                #Java_sun_awt_motif_MWindowPeer_updateAlwaysOnTop;
-		#Java_sun_awt_motif_X11CustomCursor_cacheInit;
-		#Java_sun_awt_motif_X11CustomCursor_createCursor;
-		#Java_sun_awt_motif_X11CustomCursor_queryBestCursor;
-		Java_sun_awt_motif_X11FontMetrics_bytesWidth;
-		Java_sun_awt_motif_X11FontMetrics_getMFCharsWidth;
-		Java_sun_awt_motif_X11FontMetrics_init;
 		Java_sun_awt_X11InputMethod_disposeXIC;
 		Java_sun_awt_X11InputMethod_isCompositionEnabledNative;
 		Java_sun_awt_X11InputMethod_resetXIC;
 		Java_sun_awt_X11InputMethod_setCompositionEnabledNative;
 		Java_sun_awt_X11InputMethod_turnoffStatusWindow;
-		#Java_sun_awt_motif_MInputMethod_openXIMNative;
-		#Java_sun_awt_motif_MInputMethod_configureStatusAreaNative;
-		#Java_sun_awt_motif_MInputMethod_createXICNative;
-		#Java_sun_awt_motif_MInputMethod_reconfigureXICNative;
-		#Java_sun_awt_motif_MInputMethod_setXICFocusNative;
-		#Java_sun_awt_motif_X11Clipboard_getClipboardData;
-		#Java_sun_awt_motif_X11Clipboard_getClipboardFormats;
-		#Java_sun_awt_motif_X11Clipboard_registerClipboardViewer;
-		#Java_sun_awt_motif_X11Clipboard_unregisterClipboardViewer;
-		#Java_sun_awt_motif_X11Selection_init;
-		#Java_sun_awt_motif_X11Selection_pGetSelectionOwnership;
-		#Java_sun_awt_motif_X11Selection_clearNativeContext;
 		Java_sun_awt_SunToolkit_closeSplashScreen;
 		Java_sun_awt_PlatformFont_initIDs;
 		Java_sun_awt_X11GraphicsConfig_init;
@@ -444,42 +238,7 @@
 		Java_java_awt_Insets_initIDs;
 		Java_java_awt_TextField_initIDs;
 		Java_java_awt_Window_initIDs;
-		#Java_sun_awt_motif_MCheckboxPeer_getIndicatorSize;
-		#Java_sun_awt_motif_MCheckboxPeer_getSpacing;
-		#Java_sun_awt_motif_MChoicePeer_freeNativeData;
-		#Java_sun_awt_motif_MComponentPeer_getComponents_1NoClientCode;
-		#Java_sun_awt_motif_MComponentPeer_getParent_1NoClientCode;
-		#Java_sun_awt_motif_MComponentPeer_initIDs;
-		#Java_sun_awt_motif_MComponentPeer_nativeHandleEvent;
-		#Java_sun_awt_motif_MComponentPeer_pSetCursor;
-		#Java_sun_awt_motif_MComponentPeer_pSetInnerForeground;
-		#Java_sun_awt_motif_MComponentPeer_pSetScrollbarBackground;
-		#Java_sun_awt_motif_MComponentPeer_setTargetBackground;
-		#Java_sun_awt_motif_MDataTransferer_dragQueryFile;
-		#Java_sun_awt_motif_MDataTransferer_getAtomForTarget;
-		#Java_sun_awt_motif_MDataTransferer_getTargetNameForAtom;
-		#Java_sun_awt_motif_MFileDialogPeer_insertReplaceFileDialogText;
-		Java_sun_awt_motif_MFontPeer_initIDs;
-		#Java_sun_awt_motif_MListPeer_setBackground;
-		#Java_sun_awt_motif_MMenuBarPeer_initIDs;
-		#Java_sun_awt_motif_MMenuBarPeer_pDispose;
-		#Java_sun_awt_motif_MMenuItemPeer_getParent_1NoClientCode;
-		#Java_sun_awt_motif_MMenuItemPeer_initIDs;
-		#Java_sun_awt_motif_MMenuItemPeer_pSetShortcut;
-		#Java_sun_awt_motif_MPopupMenuPeer_initIDs;
-		#Java_sun_awt_motif_MScrollbarPeer_initIDs;
-		#Java_sun_awt_motif_MScrollPanePeer_initIDs;
-		#Java_sun_awt_motif_MTextAreaPeer_pSetCursor;
-		Java_sun_awt_motif_MToolkit_shutdown;
-		#Java_sun_awt_motif_MWindowPeer_initIDs;
-		#Java_sun_awt_motif_MWindowPeer_pCreate;
-		#Java_sun_awt_motif_MWindowPeer_wrapInSequenced;
-		Java_sun_awt_motif_X11FontMetrics_initIDs;
-		#Java_sun_awt_X11InputMethod_initIDs;
 		Java_sun_awt_motif_X11OffScreenImage_updateBitmask;
-		#Java_sun_awt_motif_X11Selection_initIDs;
-		Java_sun_awt_motif_MToolkitThreadBlockedHandler_enter;
-		Java_sun_awt_motif_MToolkitThreadBlockedHandler_exit;
 		Java_sun_awt_X11GraphicsConfig_init;
 		Java_sun_awt_X11GraphicsConfig_initIDs;
 		Java_sun_awt_X11GraphicsConfig_makeColorModel;
@@ -505,26 +264,6 @@
 		Java_sun_awt_X11SurfaceData_isDgaAvailable;
 		Java_sun_awt_X11SurfaceData_setInvalid;
 		Java_sun_awt_X11SurfaceData_flushNativeSurface;
-                #Java_sun_awt_motif_MEmbedCanvasPeer_initXEmbedServer;
-                #Java_sun_awt_motif_MEmbedCanvasPeer_destroyXEmbedServer;
-                #Java_sun_awt_motif_MEmbedCanvasPeer_isXEmbedActive;
-                #Java_sun_awt_motif_MEmbedCanvasPeer_initDispatching;
-                #Java_sun_awt_motif_MEmbedCanvasPeer_endDispatching;
-                #Java_sun_awt_motif_MEmbedCanvasPeer_embedChild;
-                #Java_sun_awt_motif_MEmbedCanvasPeer_childDestroyed;
-                #Java_sun_awt_motif_MEmbedCanvasPeer_getEmbedPreferredSize;
-                #Java_sun_awt_motif_MEmbedCanvasPeer_getEmbedMinimumSize;
-                #Java_sun_awt_motif_MEmbedCanvasPeer_getClientBounds;
-                #Java_sun_awt_motif_MEmbedCanvasPeer_notifyChildEmbedded;
-                #Java_sun_awt_motif_MEmbedCanvasPeer_detachChild;
-                #Java_sun_awt_motif_MEmbedCanvasPeer_forwardKeyEvent;
-                #Java_sun_awt_motif_MEmbedCanvasPeer_getAWTKeyCodeForKeySym;
-                #Java_sun_awt_motif_MEmbedCanvasPeer_sendMessage__I;
-                #Java_sun_awt_motif_MEmbedCanvasPeer_sendMessage__IJJJ;
-                #Java_sun_awt_motif_MEmbedCanvasPeer_getWindow;       
-                #Java_sun_awt_motif_MEmbedCanvasPeer_forwardEventToEmbedded;       
-                #Java_sun_awt_motif_GrabbedKey_initKeySymAndModifiers;
-                #Java_sun_awt_motif_MEmbeddedFramePeer_traverseOut;
 		awt_display;
 		awt_lock;
 		awt_Lock;
diff --git a/jdk/make/sun/awt/mawt.gmk b/jdk/make/sun/awt/mawt.gmk
index f8160ee..cdb740b 100644
--- a/jdk/make/sun/awt/mawt.gmk
+++ b/jdk/make/sun/awt/mawt.gmk
@@ -41,13 +41,7 @@
 # Check which C files should be built.  Headless uses only
 # non-motif files.  Also, a version-specific motif file is
 # compiled based on the motif version.
-ifdef HEADLESS
-  FILES_c = $(FILES_NO_MOTIF_c)
-else
-#  FILES_c = $(FILES_MOTIF_c) $(FILES_NO_MOTIF_c)
-#  XXX if in FILES_MOTIF_c there are unrelated to motif stuff, create a separate list!
-  FILES_c = $(FILES_NO_MOTIF_c)
-endif
+FILES_c = $(FILES_NO_MOTIF_c)
 
 ifeq ($(PLATFORM), solaris)
   ifneq ($(ARCH), amd64)
@@ -116,32 +110,6 @@
 CPPFLAGS += -DHEADLESS=$(HEADLESS)
 OTHER_LDLIBS =
 else
-#CFLAGS += -DMOTIF_VERSION=$(MOTIF_VERSION)
-
-#ifeq ($(STATIC_MOTIF),true)
-#    LIBXM = $(MOTIF_LIB)/libXm.a -lXp -lXmu
-#    ifeq ($(PLATFORM), linux)
-#	ifeq ($(ARCH_DATA_MODEL), 64)
-#            LIBXT = -lXt
-#        else
-#        # Allows for builds on Debian GNU Linux, X11 is in a different place 
-#	    LIBXT = $(firstword $(wildcard /usr/X11R6/lib/libXt.a) \
-#                            $(wildcard /usr/lib/libXt.a))
-#	    LIBSM = $(firstword $(wildcard /usr/X11R6/lib/libSM.a) \
-#                            $(wildcard /usr/lib/libSM.a))
-#	    LIBICE = $(firstword $(wildcard /usr/X11R6/lib/libICE.a) \
-#                             $(wildcard /usr/lib/libICE.a))
-#	endif
-#    endif
-#else
-#    LIBXM = -L$(MOTIF_LIB) -lXm -lXp
-#    ifeq ($(PLATFORM), linux)
-#	LIBXT = -lXt
-#	LIBSM = 
-#	LIBICE = 
-#    endif
-#endif
-
 LIBXTST = -lXtst
 ifeq ($(PLATFORM), linux)
    ifeq ($(ARCH_DATA_MODEL), 64)
diff --git a/jdk/make/sun/motif12/reorder-i586 b/jdk/make/sun/motif12/reorder-i586
deleted file mode 100644
index 9cbfe97..0000000
--- a/jdk/make/sun/motif12/reorder-i586
+++ /dev/null
@@ -1,216 +0,0 @@
-data = R0x2000;
-text = LOAD ?RXO;
-# Test Null
-# Test Exit
-# Test Hello
-# Test Sleep
-# Test IntToString
-# Test LoadToolkit
-text: .text%JNI_OnLoad;
-text: .text%awt_util_debug_init;
-text: .text%Java_sun_awt_X11GraphicsEnvironment_initDisplay;
-text: .text%awt_init_Display;
-text: .text%makeDefaultConfig: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_GraphicsEnv.o;
-text: .text%awt_allocate_colors;
-text: .text%alloc_col: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/X11Color.o;
-text: .text%getVirtCubeSize;
-text: .text%uname: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/X11Color.o;
-text: .text%Java_sun_awt_font_NativeFontWrapper_getFontPath;
-text: .text%getPlatformFontPathChars: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/fontpath.o;
-text: .text%getSolarisFontLocations: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/fontpath.o;
-text: .text%fstat: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/fontpath.o;
-text: .text%AppendFont: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/fontpath.o;
-text: .text%freePlatformFontPathChars: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/fontpath.o;
-text: .text%checkFont: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_Font.o;
-text: .text%Java_sun_awt_X11GraphicsEnvironment_getNativeFonts;
-text: .text%Java_sun_awt_font_NativeFontWrapper_setNativeFontPath;
-text: .text%isDisplayLocal;
-text: .text%Java_sun_awt_X11GraphicsEnvironment_checkShmExt;
-text: .text%TryInitMITShm: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_GraphicsEnv.o;
-text: .text%awt_output_flush;
-text: .text%awtJNI_TimeMillis: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_MToolkit.o;
-text: .text%AddFontsToX11FontPath: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/fontpath.o;
-text: .text%Java_sun_awt_X11GraphicsEnvironment_getNumScreens;
-text: .text%Java_sun_awt_X11GraphicsEnvironment_getDefaultScreenNum;
-text: .text%Java_sun_awt_X11GraphicsDevice_getConfigVisualId;
-text: .text%Java_sun_awt_X11GraphicsDevice_isDBESupported;
-text: .text%Java_sun_awt_X11GraphicsDevice_getDoubleBufferVisuals;
-text: .text%Java_sun_awt_X11GraphicsConfig_initIDs;
-text: .text%Java_sun_awt_X11GraphicsConfig_init;
-text: .text%getAllConfigs: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_GraphicsEnv.o;
-text: .text%Java_sun_awt_motif_MToolkit_init;
-text: .text%getDefaultConfig;
-text: .text%getScreenData;
-text: .text%Java_sun_awt_PlatformFont_initIDs;
-text: .text%Java_sun_awt_motif_MFontPeer_initIDs;
-text: .text%awt_wm_init;
-text: .text%awt_wm_initAtoms: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_getRunningWM;
-text: .text%xerror_detect_wm: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_prepareIsIceWM: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_isNetSupporting: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_checkAnchor: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_getProperty32: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_isWinSupporting: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_isIceWM: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_isEnlightenment: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_getECommsWindowIDProperty: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_isSawfish: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_isNetWMName: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_isKDE2: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_isCDE: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_color_match;
-text: .text%setup_modifier_map: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_MToolkit.o;
-text: .text%set_mod_mask: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_MToolkit.o;
-text: .text%awt_initialize_DataTransferer;
-text: .text%awt_initialize_Xm_DnD;
-text: .text%cacheDropDone: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_XmDnD.o;
-text: .text%awt_motif_enableSingleDragInitiator;
-text: .text%Java_java_awt_Cursor_initIDs;
-text: .text%Java_sun_awt_motif_X11CustomCursor_cacheInit;
-text: .text%Java_sun_awt_motif_MToolkit_run;
-text: .text%awtJNI_GetCurrentThread;
-text: .text%awt_MToolkit_loop: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_MToolkit.o;
-text: .text%awt_pipe_init: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_MToolkit.o;
-text: .text%awt_set_poll_timeout: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_MToolkit.o;
-text: .text%awt_events_pending: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_MToolkit.o;
-text: .text%processOneEvent: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_MToolkit.o;
-text: .text%set_toolkit_busy;
-text: .text%waitForEvents;
-text: .text%performPoll: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_MToolkit.o;
-text: .text%awt_get_poll_timeout: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_MToolkit.o;
-text: .text%awtJNI_CleanupGlobalRefs;
-text: .text%Java_java_awt_AWTEvent_initIDs;
-text: .text%Java_sun_awt_SunToolkit_wakeupEventQueue;
-text: .text%Java_sun_awt_motif_MToolkit_shutdown;
-text: .text%X11SD_LibDispose;
-text: .text%LibDisposeStub: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/X11SurfaceData.o;
-# Test LoadFrame
-text: .text%Java_java_awt_Component_initIDs;
-text: .text%Java_java_awt_Container_initIDs;
-text: .text%Java_java_awt_Window_initIDs;
-text: .text%Java_java_awt_Frame_initIDs;
-text: .text%Java_sun_awt_SunToolkit_getPrivateKey;
-text: .text%Java_java_awt_MenuComponent_initIDs;
-text: .text%Java_sun_awt_X11GraphicsConfig_pGetBounds;
-text: .text%Java_java_awt_Insets_initIDs;
-text: .text%Java_sun_awt_motif_MComponentPeer_initIDs;
-text: .text%Java_sun_awt_motif_MWindowPeer_initIDs;
-text: .text%Java_sun_awt_motif_MWindowAttributes_initIDs;
-text: .text%Java_sun_awt_motif_MWindowPeer_pCreate;
-text: .text%awtJNI_CreateAndSetGlobalRef;
-text: .text%copyGraphicsConfigToPeer;
-text: .text%awt_Frame_guessInsets;
-text: .text%awtJNI_ChangeInsets: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_TopLevel.o;
-text: .text%getMotifFontList;
-text: .text%getMotifFontStruct;
-text: .text%setDeleteCallback: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_TopLevel.o;
-text: .text%awt_canvas_create;
-text: .text%awt_util_show;
-text: .text%addTopLevel;
-text: .text%Java_sun_awt_motif_MWindowPeer_pHide;
-text: .text%Java_sun_awt_motif_MComponentPeer_pInitialize;
-text: .text%awt_addWidget;
-text: .text%Java_sun_awt_motif_MComponentPeer_pSetCursor;
-text: .text%getCursor;
-text: .text%awt_util_setCursor;
-text: .text%Java_sun_awt_motif_MComponentPeer_getParent_1NoClientCode;
-text: .text%Java_sun_awt_motif_MWindowPeer_pReshape;
-text: .text%reshape: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_TopLevel.o;
-text: .text%awtJNI_setMbAndWwHeightAndOffsets: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_TopLevel.o;
-text: .text%awt_wm_configureGravityBuggy;
-text: .text%Java_sun_awt_X11SurfaceData_initIDs;
-text: .text%Java_sun_awt_motif_MToolkit_loadSystemColors;
-text: .text%colorToRGB: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_MToolkit.o;
-text: .text%awt_allocate_systemcolors;
-text: .text%Java_sun_awt_X11GraphicsConfig_makeColorModel;
-text: .text%awtJNI_GetColorModel;
-text: .text%Java_sun_awt_X11SurfaceData_initOps;
-text: .text%Java_sun_awt_motif_MWindowPeer_pSetTitle;
-text: .text%Java_sun_awt_motif_MWindowPeer_setResizable;
-text: .text%Java_java_awt_Font_initIDs;
-text: .text%Java_sun_awt_motif_MComponentPeer_pSetFont;
-text: .text%awt_util_mapChildren;
-text: .text%changeFont: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_Component.o;
-text: .text%Java_sun_awt_motif_MComponentPeer_pSetBackground;
-text: .text%getGraphicsConfigFromComponentPeer;
-text: .text%awtJNI_GetColorForVis;
-text: .text%ColorProc;
-text: .text%Java_sun_awt_motif_MComponentPeer_pSetForeground;
-text: .text%Java_sun_awt_motif_MWindowPeer_pShow;
-text: .text%Java_sun_awt_motif_MWindowPeer_pShowModal;
-text: .text%awt_wm_setExtendedState;
-text: .text%awt_wm_doStateProtocolNet: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_doStateProtocolWin: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_setShellDecor;
-text: .text%awt_wm_setMotifDecor: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_setOLDecor: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_normalizeMotifDecor: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_removeSizeHints;
-text: .text%shellEH: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_TopLevel.o;
-text: .text%awt_wm_isStateChange;
-text: .text%awt_wm_getWMState;
-text: .text%Java_sun_awt_motif_MGlobalCursorManager_cacheInit;
-text: .text%innerCanvasEH: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_TopLevel.o;
-text: .text%reconfigureOuterCanvas: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_TopLevel.o;
-text: .text%outerCanvasResizeCB: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_TopLevel.o;
-text: .text%Java_sun_awt_motif_MGlobalCursorManager_findHeavyweightUnderCursor;
-text: .text%awt_wm_getInsetsFromProp;
-text: .text%syncTopLevelPos;
-text: .text%raiseInputMethodWindow;
-text: .text%awt_wm_getExtendedState: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_canvas_event_handler;
-text: .text%awt_canvas_handleEvent;
-text: .text%HandleExposeEvent: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/canvas.o;
-text: .text%checkForExpose: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/canvas.o;
-text: .text%expandDamageRect: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/canvas.o;
-text: .text%getCurComponent;
-text: .text%Java_java_awt_KeyboardFocusManager_initIDs;
-text: .text%Java_java_awt_event_InputEvent_initIDs;
-text: .text%Java_java_awt_event_KeyEvent_initIDs;
-text: .text%Java_java_awt_AWTKeyStroke_allocateNewInstance;
-text: .text%Java_sun_awt_motif_MComponentPeer_nativeHandleEvent;
-text: .text%Java_java_awt_Event_initIDs;
-# Test LoadJFrame
-text: .text%Java_sun_awt_motif_MToolkit_getScreenWidth;
-text: .text%Java_sun_awt_motif_MToolkit_getScreenHeight;
-text: .text%X11SD_Lock: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/X11SurfaceData.o;
-text: .text%X11SD_InitWindow: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/X11SurfaceData.o;
-text: .text%GetLockStub: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/X11SurfaceData.o;
-text: .text%X11SD_GetRasInfo: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/X11SurfaceData.o;
-text: .text%X11SD_Unlock: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/X11SurfaceData.o;
-text: .text%X11SD_InitClip: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/X11SurfaceData.o;
-text: .text%XRequestSentStub: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/X11SurfaceData.o;
-# Test JHello
-text: .text%AWTLoadFont;
-text: .text%AWTFontMaxByte1;
-text: .text%AWTFontMaxCharOrByte2;
-text: .text%AWTFontMaxBounds;
-text: .text%AWTCharAscent;
-text: .text%AWTCharDescent;
-text: .text%AWTCharWidth;
-text: .text%AWTFontMinByte1;
-text: .text%AWTFontMinCharOrByte2;
-text: .text%AWTFontPerChar;
-text: .text%AWTCharRBearing;
-text: .text%AWTCharLBearing;
-text: .text%Java_sun_awt_X11SurfaceData_setInvalid;
-text: .text%Java_sun_awt_X11SurfaceData_nativeDispose;
-text: .text%X11SurfaceData_GetOps;
-# SwingSet
-text: .text%Java_sun_awt_motif_MWindowPeer_setSaveUnder;
-text: .text%Java_sun_awt_motif_MCanvasPeer_create;
-text: .text%awt_util_insertCallback;
-text: .text%Java_sun_awt_motif_MComponentPeer_getComponents_1NoClientCode;
-text: .text%Java_sun_awt_motif_MComponentPeer_pReshape;
-text: .text%awt_util_reshape;
-text: .text%Java_sun_awt_motif_MComponentPeer_pShow;
-text: .text%Java_sun_awt_motif_MDataTransferer_getAtomForTarget;
-text: .text%Java_sun_awt_motif_MComponentPeer_addNativeDropTarget;
-text: .text%register_drop_site;
-text: .text%update_drop_site_hierarchy: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_XmDnD.o;
-text: .text%AWTFontDefaultChar;
-text: .text%AWTFontGenerateImage;
-text: .text%CreatePixmapAndGC;
-text: .text%isAncestor;
-text: .text%xerror_handler;
diff --git a/jdk/make/sun/motif12/reorder-sparc b/jdk/make/sun/motif12/reorder-sparc
deleted file mode 100644
index 8ac5471..0000000
--- a/jdk/make/sun/motif12/reorder-sparc
+++ /dev/null
@@ -1,212 +0,0 @@
-data = R0x2000;
-text = LOAD ?RXO;
-# Test Null
-# Test Exit
-# Test Hello
-# Test Sleep
-# Test IntToString
-# Test LoadToolkit
-text: .text%JNI_OnLoad;
-text: .text%awt_util_debug_init;
-text: .text%Java_sun_awt_X11GraphicsEnvironment_initDisplay;
-text: .text%awt_init_Display;
-text: .text%makeDefaultConfig: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_GraphicsEnv.o;
-text: .text%awt_allocate_colors;
-text: .text%Java_sun_awt_font_NativeFontWrapper_getFontPath;
-text: .text%getPlatformFontPathChars: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/fontpath.o;
-text: .text%getSolarisFontLocations: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/fontpath.o;
-text: .text%AppendFont: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/fontpath.o;
-text: .text%freePlatformFontPathChars: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/fontpath.o;
-text: .text%checkFont: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_Font.o;
-text: .text%Java_sun_awt_X11GraphicsEnvironment_getNativeFonts;
-text: .text%Java_sun_awt_font_NativeFontWrapper_setNativeFontPath;
-text: .text%isDisplayLocal;
-text: .text%Java_sun_awt_X11GraphicsEnvironment_checkShmExt;
-text: .text%TryInitMITShm: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_GraphicsEnv.o;
-text: .text%awt_output_flush;
-text: .text%awtJNI_TimeMillis: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_MToolkit.o;
-text: .text%AddFontsToX11FontPath: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/fontpath.o;
-text: .text%Java_sun_awt_X11GraphicsEnvironment_getNumScreens;
-text: .text%Java_sun_awt_X11GraphicsEnvironment_getDefaultScreenNum;
-text: .text%Java_sun_awt_X11GraphicsDevice_getConfigVisualId;
-text: .text%Java_sun_awt_X11GraphicsDevice_isDBESupported;
-text: .text%Java_sun_awt_X11GraphicsDevice_getDoubleBufferVisuals;
-text: .text%Java_sun_awt_X11GraphicsConfig_initIDs;
-text: .text%Java_sun_awt_X11GraphicsConfig_init;
-text: .text%getAllConfigs: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_GraphicsEnv.o;
-text: .text%Java_sun_awt_motif_MToolkit_init;
-text: .text%getDefaultConfig;
-text: .text%getScreenData;
-text: .text%Java_sun_awt_PlatformFont_initIDs;
-text: .text%Java_sun_awt_motif_MFontPeer_initIDs;
-text: .text%awt_wm_init;
-text: .text%awt_wm_initAtoms: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_getRunningWM;
-text: .text%xerror_detect_wm: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_prepareIsIceWM: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_isNetSupporting: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_checkAnchor: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_getProperty32: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_isWinSupporting: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_isIceWM: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_isEnlightenment: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_getECommsWindowIDProperty: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_isSawfish: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_isNetWMName: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_isKDE2: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_isCDE: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_color_matchTC;
-text: .text%setup_modifier_map: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_MToolkit.o;
-text: .text%set_mod_mask: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_MToolkit.o;
-text: .text%awt_initialize_DataTransferer;
-text: .text%awt_initialize_Xm_DnD;
-text: .text%cacheDropDone: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_XmDnD.o;
-text: .text%awt_motif_enableSingleDragInitiator;
-text: .text%Java_java_awt_Cursor_initIDs;
-text: .text%Java_sun_awt_motif_X11CustomCursor_cacheInit;
-text: .text%Java_sun_awt_motif_MToolkit_run;
-text: .text%awtJNI_GetCurrentThread;
-text: .text%awt_MToolkit_loop: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_MToolkit.o;
-text: .text%awt_pipe_init: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_MToolkit.o;
-text: .text%awt_set_poll_timeout: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_MToolkit.o;
-text: .text%awt_events_pending: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_MToolkit.o;
-text: .text%processOneEvent: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_MToolkit.o;
-text: .text%set_toolkit_busy;
-text: .text%waitForEvents;
-text: .text%performPoll: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_MToolkit.o;
-text: .text%awt_get_poll_timeout: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_MToolkit.o;
-text: .text%awtJNI_CleanupGlobalRefs;
-text: .text%Java_java_awt_AWTEvent_initIDs;
-text: .text%Java_sun_awt_SunToolkit_wakeupEventQueue;
-text: .text%Java_sun_awt_motif_MToolkit_shutdown;
-text: .text%X11SD_LibDispose;
-text: .text%LibDisposeStub: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/X11SurfaceData.o;
-# Test LoadFrame
-text: .text%Java_java_awt_Component_initIDs;
-text: .text%Java_java_awt_Container_initIDs;
-text: .text%Java_java_awt_Window_initIDs;
-text: .text%Java_java_awt_Frame_initIDs;
-text: .text%Java_sun_awt_SunToolkit_getPrivateKey;
-text: .text%Java_java_awt_MenuComponent_initIDs;
-text: .text%Java_sun_awt_X11GraphicsConfig_pGetBounds;
-text: .text%Java_java_awt_Insets_initIDs;
-text: .text%Java_sun_awt_motif_MComponentPeer_initIDs;
-text: .text%Java_sun_awt_motif_MWindowPeer_initIDs;
-text: .text%Java_sun_awt_motif_MWindowAttributes_initIDs;
-text: .text%Java_sun_awt_motif_MWindowPeer_pCreate;
-text: .text%awtJNI_CreateAndSetGlobalRef;
-text: .text%copyGraphicsConfigToPeer;
-text: .text%awt_Frame_guessInsets;
-text: .text%awtJNI_ChangeInsets: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_TopLevel.o;
-text: .text%getMotifFontList;
-text: .text%getMotifFontStruct;
-text: .text%setDeleteCallback: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_TopLevel.o;
-text: .text%ColorProc;
-text: .text%awt_canvas_create;
-text: .text%awt_util_show;
-text: .text%addTopLevel;
-text: .text%Java_sun_awt_motif_MWindowPeer_pHide;
-text: .text%Java_sun_awt_motif_MComponentPeer_pInitialize;
-text: .text%awt_addWidget;
-text: .text%Java_sun_awt_motif_MComponentPeer_pSetCursor;
-text: .text%getCursor;
-text: .text%awt_util_setCursor;
-text: .text%Java_sun_awt_motif_MComponentPeer_getParent_1NoClientCode;
-text: .text%Java_sun_awt_motif_MWindowPeer_pReshape;
-text: .text%reshape: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_TopLevel.o;
-text: .text%awtJNI_setMbAndWwHeightAndOffsets: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_TopLevel.o;
-text: .text%awt_wm_configureGravityBuggy;
-text: .text%Java_sun_awt_X11SurfaceData_initIDs;
-text: .text%Java_sun_awt_motif_MToolkit_loadSystemColors;
-text: .text%colorToRGB: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_MToolkit.o;
-text: .text%Java_sun_awt_X11GraphicsConfig_makeColorModel;
-text: .text%awtJNI_GetColorModel;
-text: .text%Java_sun_awt_X11SurfaceData_initOps;
-text: .text%Java_sun_awt_motif_MWindowPeer_pSetTitle;
-text: .text%Java_sun_awt_motif_MWindowPeer_setResizable;
-text: .text%Java_java_awt_Font_initIDs;
-text: .text%Java_sun_awt_motif_MComponentPeer_pSetFont;
-text: .text%awt_util_mapChildren;
-text: .text%changeFont: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_Component.o;
-text: .text%Java_sun_awt_motif_MComponentPeer_pSetBackground;
-text: .text%getGraphicsConfigFromComponentPeer;
-text: .text%awtJNI_GetColorForVis;
-text: .text%Java_sun_awt_motif_MComponentPeer_pSetForeground;
-text: .text%Java_sun_awt_motif_MWindowPeer_pShow;
-text: .text%Java_sun_awt_motif_MWindowPeer_pShowModal;
-text: .text%awt_wm_setExtendedState;
-text: .text%awt_wm_doStateProtocolNet: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_doStateProtocolWin: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_setShellDecor;
-text: .text%awt_wm_setMotifDecor: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_setOLDecor: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_normalizeMotifDecor: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%awt_wm_removeSizeHints;
-text: .text%Java_sun_awt_motif_MGlobalCursorManager_cacheInit;
-text: .text%Java_sun_awt_motif_MGlobalCursorManager_findHeavyweightUnderCursor;
-text: .text%getCurComponent;
-text: .text%shellEH: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_TopLevel.o;
-text: .text%awt_wm_isStateChange;
-text: .text%awt_wm_getWMState;
-text: .text%innerCanvasEH: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_TopLevel.o;
-text: .text%reconfigureOuterCanvas: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_TopLevel.o;
-text: .text%outerCanvasResizeCB: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_TopLevel.o;
-text: .text%awt_wm_getInsetsFromProp;
-text: .text%syncTopLevelPos;
-text: .text%raiseInputMethodWindow;
-text: .text%awt_canvas_event_handler;
-text: .text%awt_canvas_handleEvent;
-text: .text%HandleExposeEvent: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/canvas.o;
-text: .text%checkForExpose: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/canvas.o;
-text: .text%awt_wm_getExtendedState: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_wm.o;
-text: .text%expandDamageRect: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/canvas.o;
-text: .text%Java_java_awt_KeyboardFocusManager_initIDs;
-text: .text%Java_java_awt_event_InputEvent_initIDs;
-text: .text%Java_java_awt_event_KeyEvent_initIDs;
-text: .text%Java_java_awt_AWTKeyStroke_allocateNewInstance;
-text: .text%Java_sun_awt_motif_MComponentPeer_nativeHandleEvent;
-text: .text%Java_java_awt_Event_initIDs;
-# Test LoadJFrame
-text: .text%awtJNI_ThreadYield;
-text: .text%Java_sun_awt_motif_MToolkit_getScreenWidth;
-text: .text%Java_sun_awt_motif_MToolkit_getScreenHeight;
-text: .text%X11SD_Lock: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/X11SurfaceData.o;
-text: .text%X11SD_InitWindow: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/X11SurfaceData.o;
-text: .text%GetLockStub: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/X11SurfaceData.o;
-text: .text%X11SD_GetRasInfo: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/X11SurfaceData.o;
-text: .text%X11SD_Unlock: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/X11SurfaceData.o;
-text: .text%X11SD_InitClip: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/X11SurfaceData.o;
-text: .text%XRequestSentStub: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/X11SurfaceData.o;
-# Test JHello
-text: .text%AWTLoadFont;
-text: .text%AWTFontMaxByte1;
-text: .text%AWTFontMaxCharOrByte2;
-text: .text%AWTFontMaxBounds;
-text: .text%AWTCharAscent;
-text: .text%AWTCharDescent;
-text: .text%AWTCharWidth;
-text: .text%AWTFontMinByte1;
-text: .text%AWTFontMinCharOrByte2;
-text: .text%AWTFontPerChar;
-text: .text%AWTCharRBearing;
-text: .text%AWTCharLBearing;
-text: .text%Java_sun_awt_X11SurfaceData_setInvalid;
-# SwingSet
-text: .text%Java_sun_awt_motif_MWindowPeer_setSaveUnder;
-text: .text%Java_sun_awt_X11SurfaceData_nativeDispose;
-text: .text%X11SurfaceData_GetOps;
-text: .text%Java_sun_awt_motif_MCanvasPeer_create;
-text: .text%awt_util_insertCallback;
-text: .text%Java_sun_awt_motif_MComponentPeer_getComponents_1NoClientCode;
-text: .text%Java_sun_awt_motif_MComponentPeer_pReshape;
-text: .text%awt_util_reshape;
-text: .text%Java_sun_awt_motif_MComponentPeer_pShow;
-text: .text%Java_sun_awt_motif_MDataTransferer_getAtomForTarget;
-text: .text%Java_sun_awt_motif_MComponentPeer_addNativeDropTarget;
-text: .text%register_drop_site;
-text: .text%update_drop_site_hierarchy: OUTPUTDIR/tmp/sun/sun.awt/motif12/obj/awt_XmDnD.o;
-text: .text%AWTFontDefaultChar;
-text: .text%isAncestor;
-text: .text%xerror_handler;
-text: .text%AWTFontGenerateImage;
-text: .text%CreatePixmapAndGC;
diff --git a/jdk/make/sun/motif12/reorder-sparcv9 b/jdk/make/sun/motif12/reorder-sparcv9
deleted file mode 100644
index 8542b6c..0000000
--- a/jdk/make/sun/motif12/reorder-sparcv9
+++ /dev/null
@@ -1,233 +0,0 @@
-data = R0x2000;
-text = LOAD ?RXO;
-# Test Null
-# Test Exit
-# Test Hello
-# Test Sleep
-# Test IntToString
-# Test LoadToolkit
-text: .text%JNI_OnLoad;
-text: .text%awt_util_debug_init;
-text: .text%Java_java_awt_Toolkit_initIDs;
-text: .text%Java_sun_awt_X11GraphicsEnvironment_initDisplay;
-text: .text%awt_init_Display;
-text: .text%makeDefaultConfig: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_GraphicsEnv.o;
-text: .text%awt_allocate_colors;
-text: .text%make_uns_ordered_dither_array;
-text: .text%checkFont: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_Font.o;
-text: .text%Java_sun_awt_X11GraphicsEnvironment_getNativeFonts;
-text: .text%Java_sun_awt_X11GraphicsEnvironment_getNumScreens;
-text: .text%Java_sun_awt_X11GraphicsEnvironment_getDefaultScreenNum;
-text: .text%Java_sun_awt_X11GraphicsDevice_getConfigVisualId;
-text: .text%Java_sun_awt_X11GraphicsConfig_initIDs;
-text: .text%Java_sun_awt_X11GraphicsConfig_init;
-text: .text%getAllConfigs: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_GraphicsEnv.o;
-text: .text%awt_output_flush;
-text: .text%awtJNI_TimeMillis: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_MToolkit.o;
-text: .text%Java_sun_awt_motif_MToolkit_init;
-text: .text%getDefaultConfig;
-text: .text%getScreenData;
-text: .text%Java_sun_awt_PlatformFont_initIDs;
-text: .text%Java_sun_awt_motif_MFontPeer_initIDs;
-text: .text%awt_color_matchTC;
-text: .text%setup_modifier_map: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_MToolkit.o;
-text: .text%set_mod_mask: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_MToolkit.o;
-text: .text%awt_initialize_Xm_DnD;
-text: .text%Java_java_awt_Cursor_initIDs;
-text: .text%Java_sun_awt_motif_X11CustomCursor_cacheInit;
-text: .text%Java_java_awt_Dimension_initIDs;
-text: .text%Java_sun_awt_motif_MToolkit_run;
-text: .text%awtJNI_GetCurrentThread;
-text: .text%awt_MToolkit_loop: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_MToolkit.o;
-text: .text%awt_pipe_init: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_MToolkit.o;
-text: .text%awt_set_poll_timeout: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_MToolkit.o;
-text: .text%awt_events_pending: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_MToolkit.o;
-text: .text%processOneEvent: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_MToolkit.o;
-text: .text%waitForEvents: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_MToolkit.o;
-text: .text%performPoll: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_MToolkit.o;
-text: .text%awt_get_poll_timeout: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_MToolkit.o;
-text: .text%awtJNI_CleanupGlobalRefs;
-# Test LoadFrame
-text: .text%Java_java_awt_Component_initIDs;
-text: .text%Java_java_awt_Container_initIDs;
-text: .text%Java_java_awt_Window_initIDs;
-text: .text%Java_java_awt_Frame_initIDs;
-text: .text%Java_sun_awt_SunToolkit_getPrivateKey;
-text: .text%Java_java_awt_MenuComponent_initIDs;
-text: .text%Java_sun_awt_X11GraphicsConfig_pGetBounds;
-text: .text%Java_java_awt_Rectangle_initIDs;
-text: .text%Java_sun_awt_motif_MComponentPeer_initIDs;
-text: .text%Java_sun_awt_motif_MWindowPeer_initIDs;
-text: .text%Java_java_awt_Insets_initIDs;
-text: .text%Java_sun_awt_motif_MWindowAttributes_initIDs;
-text: .text%Java_sun_awt_motif_MWindowPeer_create;
-text: .text%awtJNI_CreateAndSetGlobalRef;
-text: .text%copyGraphicsConfigToPeer;
-text: .text%awt_Frame_guessInsets;
-text: .text%awt_util_runningWindowManager;
-text: .text%awt_winmgrerr: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_util.o;
-text: .text%awtJNI_ChangeInsets: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_TopLevel.o;
-text: .text%getMotifFontList;
-text: .text%getMotifFontStruct;
-text: .text%setDeleteCallback: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_TopLevel.o;
-text: .text%ColorProc;
-text: .text%awt_canvas_create;
-text: .text%awt_util_show;
-text: .text%addTopLevel;
-text: .text%Java_sun_awt_motif_MWindowPeer_pHide;
-text: .text%Java_sun_awt_motif_MComponentPeer_pInitialize;
-text: .text%awt_addWidget;
-text: .text%Java_sun_awt_motif_MComponentPeer_setCursor;
-text: .text%getCursor;
-text: .text%awt_util_setCursor;
-text: .text%Java_sun_awt_motif_MComponentPeer_getParent_1NoClientCode;
-text: .text%Java_sun_awt_motif_MWindowPeer_pReshape;
-text: .text%reshape: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_TopLevel.o;
-text: .text%awtJNI_setMbAndWwHeightAndOffsets: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_TopLevel.o;
-text: .text%awt_util_wmPositionsShellXY;
-text: .text%Java_sun_awt_motif_MWindowPeer_pSetTitle;
-text: .text%Java_sun_awt_motif_MWindowPeer_setResizable;
-text: .text%Java_java_awt_Font_initIDs;
-text: .text%Java_sun_awt_motif_MComponentPeer_pSetFont;
-text: .text%awt_util_mapChildren;
-text: .text%changeFont: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_Component.o;
-text: .text%Java_java_awt_Color_initIDs;
-text: .text%Java_sun_awt_motif_MToolkit_loadSystemColors;
-text: .text%colorToRGB: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_MToolkit.o;
-text: .text%Java_sun_awt_motif_MComponentPeer_pSetBackground;
-text: .text%getGraphicsConfigFromComponentPeer;
-text: .text%awtJNI_GetColorForVis;
-text: .text%Java_sun_awt_motif_MComponentPeer_pSetForeground;
-text: .text%Java_sun_awt_motif_MWindowPeer_pShow;
-text: .text%Java_sun_awt_motif_MWindowPeer_pShowModal;
-text: .text%setStateHints: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_TopLevel.o;
-text: .text%awt_util_setMinMaxSizeProps;
-text: .text%innerCanvasEH: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_TopLevel.o;
-text: .text%reconfigureOuterCanvas: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_TopLevel.o;
-text: .text%Java_java_awt_AWTEvent_initIDs;
-text: .text%outerCanvasResizeCB: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_TopLevel.o;
-text: .text%Java_sun_awt_motif_MGlobalCursorManager_cacheInit;
-text: .text%shellEH: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_TopLevel.o;
-text: .text%Java_sun_awt_motif_MGlobalCursorManager_findHeavyweightUnderCursor;
-text: .text%getCurComponent;
-text: .text%get_awt_TopLevelInsetsProp;
-text: .text%syncTopLevelPos;
-text: .text%Java_sun_awt_motif_MComponentPeer_nativeHandleEvent;
-text: .text%raiseInputMethodWindow;
-text: .text%getWindowState: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_TopLevel.o;
-text: .text%awt_canvas_event_handler;
-text: .text%awt_canvas_handleEvent;
-text: .text%HandleExposeEvent: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/canvas.o;
-text: .text%checkForExpose: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/canvas.o;
-text: .text%Java_java_awt_Event_initIDs;
-text: .text%Java_java_awt_image_ColorModel_initIDs;
-text: .text%Java_sun_awt_motif_X11Graphics_cacheInit;
-text: .text%InitMITShm: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_Graphics.o;
-text: .text%Java_sun_java2d_loops_RasterOutputManager_getPlatformFontVar;
-text: .text%Java_sun_awt_motif_X11Graphics_createFromComponent;
-text: .text%Java_sun_awt_motif_X11Graphics_pSetForeground;
-text: .text%awt_init_gc;
-text: .text%Java_sun_awt_motif_X11Graphics_pSetFont;
-text: .text%awtJNI_GetFontData;
-text: .text%awtJNI_IsMultiFont;
-text: .text%Java_sun_awt_FontDescriptor_initIDs;
-text: .text%loadFont;
-text: .text%Java_sun_awt_motif_X11Graphics_setOrigin;
-text: .text%Java_sun_awt_motif_X11Graphics_setLineAttrs;
-text: .text%Java_sun_awt_motif_X11Graphics_changeClip;
-text: .text%Java_sun_awt_motif_X11Graphics_devClearRect;
-text: .text%Java_sun_awt_motif_X11Graphics_disposeImpl;
-# Test LoadJFrame
-text: .text%Java_java_awt_event_InputEvent_initIDs;
-text: .text%Java_java_awt_event_KeyEvent_initIDs;
-text: .text%expandDamageRect: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/canvas.o;
-text: .text%awtJNI_ThreadYield;
-text: .text%Java_sun_awt_motif_X11Graphics_createFromGraphics;
-text: .text%Java_sun_awt_motif_MToolkit_getScreenWidth;
-text: .text%Java_sun_awt_motif_MToolkit_getScreenHeight;
-text: .text%Java_sun_awt_X11GraphicsConfig_makeColorModel;
-text: .text%awtJNI_GetColorModel;
-text: .text%Java_java_awt_image_BufferedImage_initIDs;
-text: .text%Java_java_awt_image_Raster_initIDs;
-text: .text%Java_java_awt_image_SampleModel_initIDs;
-text: .text%Java_java_awt_image_SinglePixelPackedSampleModel_initIDs;
-text: .text%Java_sun_awt_image_IntegerComponentRaster_initIDs;
-text: .text%Java_sun_java2d_loops_ImageData_initIDs;
-text: .text%Java_sun_java2d_loops_IntDiscreteRenderer_devSetRect;
-text: .text%Java_sun_awt_motif_X11Graphics_X11LockViewResources;
-text: .text%X11DeferredLockViewResources: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_Graphics.o;
-text: .text%getLockMethod: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_Graphics.o;
-text: .text%DGA_DeferredLockViewResources;
-text: .text%setLockMethod: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_Graphics.o;
-text: .text%getPrimitiveType: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_Graphics.o;
-text: .text%Java_sun_awt_motif_X11Graphics_X11UnLockViewResources;
-text: .text%DGA_UnlockViewResources;
-text: .text%Java_sun_java2d_loops_DefaultComponent_IntIsomorphicCopy;
-text: .text%minImageWidths;
-text: .text%minImageRows;
-text: .text%getIntImageLockInfo;
-text: .text%lockIntImageData;
-text: .text%unlockIntImageData;
-# Test JHello
-text: .text%Java_java_awt_FontMetrics_initIDs;
-# SwingSet
-text: .text%Java_sun_awt_image_Image_initIDs;
-text: .text%Java_sun_awt_image_ImageRepresentation_initIDs;
-text: .text%Java_java_awt_image_IndexColorModel_initIDs;
-text: .text%Java_sun_awt_motif_MWindowPeer_setSaveUnder;
-text: .text%Java_java_awt_AWTEvent_freeNativeData;
-text: .text%Java_sun_java2d_loops_DefaultComponent_IntRgbToXbgr;
-text: .text%Java_sun_awt_motif_MCanvasPeer_create;
-text: .text%awt_util_insertCallback;
-text: .text%Java_sun_awt_motif_MComponentPeer_getComponents_1NoClientCode;
-text: .text%Java_sun_awt_motif_MComponentPeer_pReshape;
-text: .text%awt_util_reshape;
-text: .text%Java_sun_awt_motif_MComponentPeer_pShow;
-text: .text%Java_sun_java2d_loops_IntDiscreteRenderer_devDrawLine;
-text: .text%doDrawLine: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/IntDiscreteRenderer.o;
-text: .text%adjustLine: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/IntDiscreteRenderer.o;
-text: .text%Java_sun_awt_image_GifImageDecoder_initIDs;
-text: .text%Java_java_awt_image_ComponentSampleModel_initIDs;
-text: .text%Java_sun_awt_image_ByteComponentRaster_initIDs;
-text: .text%Java_sun_awt_image_GifImageDecoder_parseImage;
-text: .text%Java_sun_awt_image_ImageRepresentation_setBytePixels;
-text: .text%Java_sun_java2d_loops_IntDiscreteRenderer_devDrawRect;
-text: .text%outcode: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/IntDiscreteRenderer.o;
-text: .text%Java_sun_java2d_loops_ImageData_isAllOpaqueGrayICM;
-text: .text%Java_sun_java2d_loops_GIFAcceleratorLoops_LUTcopyTo32BitXBgr;
-text: .text%getByteIndexedImageLockInfo;
-text: .text%lockByteIndexedImageData;
-text: .text%unlockByteIndexedImageData;
-text: .text%Java_sun_java2d_loops_GIFAcceleratorLoops_LUTxparTo32BitXBgr;
-text: .text%shouldDispatchToWidget: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_MToolkit.o;
-text: .text%awtMenuIsActive;
-text: .text%awt_util_focusIsOnMenu;
-text: .text%awt_isModal;
-text: .text%findWidgetInfo: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_MToolkit.o;
-text: .text%awt_copyXEvent;
-text: .text%awt_post_java_mouse_event;
-text: .text%Java_java_awt_event_MouseEvent_initIDs;
-text: .text%sysTimeMillis;
-text: .text%updateCursor;
-text: .text%awt_setActivatedShell;
-text: .text%handleFocusEvent;
-text: .text%awt_post_java_focus_event;
-text: .text%getModifiers;
-text: .text%Java_java_awt_AWTEvent_copyDataFieldInto;
-text: .text%Java_sun_awt_motif_X11InputMethod_initIDs;
-text: .text%Java_sun_awt_motif_X11InputMethod_openXIM;
-text: .text%awt_put_back_event;
-text: .text%awt_get_next_put_back_event: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_MToolkit.o;
-text: .text%null_event_handler: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_MToolkit.o;
-text: .text%Java_sun_awt_motif_MGlobalCursorManager_getCursorPos;
-text: .text%Java_sun_awt_motif_MGlobalCursorManager_findComponentAt;
-text: .text%Java_sun_awt_motif_MWindowPeer_hasTextComponents;
-text: .text%Java_sun_awt_motif_X11InputMethod_createXICNative;
-text: .text%findClass: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_InputMethod.o;
-text: .text%createXIC: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_InputMethod.o;
-text: .text%Java_sun_awt_motif_X11InputMethod_setXICFocus;
-text: .text%setXICWindowFocus: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_InputMethod.o;
-text: .text%setXICFocus: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_InputMethod.o;
-text: .text%getAncestorShell;
-text: .text%Java_sun_awt_motif_X11InputMethod_turnoffStatusWindow;
-text: .text%Frame_quit: ../../../build/solaris-sparcv9/tmp/sun/sun.awt/motif12/obj64/awt_TopLevel.o;
diff --git a/jdk/make/sun/splashscreen/FILES_c.gmk b/jdk/make/sun/splashscreen/FILES_c.gmk
index a7684a2..b6e234f 100644
--- a/jdk/make/sun/splashscreen/FILES_c.gmk
+++ b/jdk/make/sun/splashscreen/FILES_c.gmk
@@ -51,7 +51,10 @@
 	gifalloc.c \
 	compress.c \
 	deflate.c \
-	gzio.c \
+	gzclose.c \
+	gzlib.c \
+	gzread.c \
+	gzwrite.c \
 	infback.c \
 	inffast.c \
 	inflate.c \
diff --git a/jdk/make/sun/xawt/mapfile-vers b/jdk/make/sun/xawt/mapfile-vers
index 8a12b69..5455530 100644
--- a/jdk/make/sun/xawt/mapfile-vers
+++ b/jdk/make/sun/xawt/mapfile-vers
@@ -256,8 +256,6 @@
 
         Java_sun_awt_X11_XToolkit_waitForEvents;
         Java_java_awt_Event_initIDs;
-        Java_sun_awt_motif_X11FontMetrics_initIDs;
-        Java_sun_awt_motif_X11FontMetrics_init;
         Java_sun_awt_X11_XWindow_x11inputMethodLookupString;
         Java_sun_awt_X11_XWindow_haveCurrentX11InputMethodInstance;
         Java_java_awt_AWTEvent_nativeSetSource;
@@ -265,7 +263,6 @@
         Java_sun_awt_PlatformFont_initIDs;
         Java_sun_awt_FontDescriptor_initIDs;
         Java_sun_awt_X11_XFontPeer_initIDs;
-        Java_sun_awt_motif_X11FontMetrics_getMFCharsWidth;
         Java_sun_awt_X11InputMethod_initIDs;
         Java_sun_awt_X11InputMethod_resetXIC;
         Java_sun_awt_X11InputMethod_disposeXIC;
@@ -322,6 +319,8 @@
         Java_sun_awt_X11_XlibWrapper_XSynchronize;
         Java_java_awt_FileDialog_initIDs;
         Java_sun_awt_X11_XWindow_initIDs;
+        Java_sun_awt_X11_XWindowPeer_getLocalHostname;
+        Java_sun_awt_X11_XWindowPeer_getJvmPID;
 
         Java_sun_java2d_opengl_OGLContext_getOGLIdString;
         Java_sun_java2d_opengl_OGLMaskFill_maskFill;
diff --git a/jdk/src/share/classes/com/sun/beans/finder/AbstractFinder.java b/jdk/src/share/classes/com/sun/beans/finder/AbstractFinder.java
index 217bb9a..8ec9ffb 100644
--- a/jdk/src/share/classes/com/sun/beans/finder/AbstractFinder.java
+++ b/jdk/src/share/classes/com/sun/beans/finder/AbstractFinder.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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
@@ -54,7 +54,7 @@
 
     /**
      * Returns an array of {@code Class} objects
-     * that represent the formal parameter types of the method
+     * that represent the formal parameter types of the method.
      * Returns an empty array if the method takes no parameters.
      *
      * @param method  the object that represents method
diff --git a/jdk/src/share/classes/com/sun/beans/finder/ConstructorFinder.java b/jdk/src/share/classes/com/sun/beans/finder/ConstructorFinder.java
index beb9bdc..cfc3a1c 100644
--- a/jdk/src/share/classes/com/sun/beans/finder/ConstructorFinder.java
+++ b/jdk/src/share/classes/com/sun/beans/finder/ConstructorFinder.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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
@@ -87,7 +87,7 @@
 
     /**
      * Returns an array of {@code Class} objects
-     * that represent the formal parameter types of the constructor
+     * that represent the formal parameter types of the constructor.
      * Returns an empty array if the constructor takes no parameters.
      *
      * @param constructor  the object that represents constructor
diff --git a/jdk/src/share/classes/com/sun/beans/finder/MethodFinder.java b/jdk/src/share/classes/com/sun/beans/finder/MethodFinder.java
index 7587c89..5fc97b2 100644
--- a/jdk/src/share/classes/com/sun/beans/finder/MethodFinder.java
+++ b/jdk/src/share/classes/com/sun/beans/finder/MethodFinder.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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
@@ -190,7 +190,7 @@
 
     /**
      * Returns an array of {@code Class} objects
-     * that represent the formal parameter types of the method
+     * that represent the formal parameter types of the method.
      * Returns an empty array if the method takes no parameters.
      *
      * @param method  the object that represents method
@@ -226,6 +226,6 @@
      */
     @Override
     protected boolean isValid(Method method) {
-        return Modifier.isPublic(method.getModifiers()) && method.getName().equals(this.name);
+        return !method.isBridge() && Modifier.isPublic(method.getModifiers()) && method.getName().equals(this.name);
     }
 }
diff --git a/jdk/src/share/classes/com/sun/media/sound/JSSecurityManager.java b/jdk/src/share/classes/com/sun/media/sound/JSSecurityManager.java
index c90578d..8e7928d 100644
--- a/jdk/src/share/classes/com/sun/media/sound/JSSecurityManager.java
+++ b/jdk/src/share/classes/com/sun/media/sound/JSSecurityManager.java
@@ -34,15 +34,13 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Properties;
+import java.util.ServiceLoader;
 
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 
 import javax.sound.sampled.AudioPermission;
 
-import sun.misc.Service;
-
-
 /** Managing security in the Java Sound implementation.
  * This class contains all code that uses and is used by
  * SecurityManager.doPrivileged().
@@ -80,8 +78,8 @@
         try {
             if (hasSecurityManager()) {
                 if(Printer.debug) Printer.debug("using security manager to load library");
-                PrivilegedAction action = new PrivilegedAction() {
-                        public Object run() {
+                PrivilegedAction<Void> action = new PrivilegedAction<Void>() {
+                        public Void run() {
                             System.loadLibrary(libName);
                             return null;
                         }
@@ -104,8 +102,8 @@
         if (hasSecurityManager()) {
             if(Printer.debug) Printer.debug("using JDK 1.2 security to get property");
             try{
-                PrivilegedAction action = new PrivilegedAction() {
-                        public Object run() {
+                PrivilegedAction<String> action = new PrivilegedAction<String>() {
+                        public String run() {
                             try {
                                 return System.getProperty(propertyName);
                             } catch (Throwable t) {
@@ -113,7 +111,7 @@
                             }
                         }
                     };
-                propertyValue = (String) AccessController.doPrivileged(action);
+                propertyValue = AccessController.doPrivileged(action);
             } catch( Exception e ) {
                 if(Printer.debug) Printer.debug("not using JDK 1.2 security to get properties");
                 propertyValue = System.getProperty(propertyName);
@@ -142,8 +140,8 @@
         if(hasSecurityManager()) {
             try {
                 // invoke the privileged action using 1.2 security
-                PrivilegedAction action = new PrivilegedAction() {
-                        public Object run() {
+                PrivilegedAction<Void> action = new PrivilegedAction<Void>() {
+                        public Void run() {
                             loadPropertiesImpl(properties, filename);
                             return null;
                         }
@@ -197,8 +195,8 @@
         if(hasSecurityManager()) {
             try {
                 // invoke the privileged action using 1.2 security
-                PrivilegedAction action = new PrivilegedAction() {
-                        public Object run() {
+                PrivilegedAction<ThreadGroup> action = new PrivilegedAction<ThreadGroup>() {
+                        public ThreadGroup run() {
                             try {
                                 return getTopmostThreadGroupImpl();
                             } catch (Throwable t) {
@@ -206,7 +204,7 @@
                             }
                         }
                     };
-                topmostThreadGroup = (ThreadGroup) AccessController.doPrivileged(action);
+                topmostThreadGroup = AccessController.doPrivileged(action);
                 if(Printer.debug)Printer.debug("Got topmost thread group with JDK 1.2 security");
             } catch (Exception e) {
                 if(Printer.debug)Printer.debug("Exception getting topmost thread group with JDK 1.2 security");
@@ -240,8 +238,8 @@
                                final boolean doStart) {
         Thread thread = null;
         if(hasSecurityManager()) {
-            PrivilegedAction action = new PrivilegedAction() {
-                    public Object run() {
+            PrivilegedAction<Thread> action = new PrivilegedAction<Thread>() {
+                    public Thread run() {
                         try {
                             return createThreadImpl(runnable, threadName,
                                                     isDaemon, priority,
@@ -251,7 +249,7 @@
                         }
                     }
                 };
-            thread = (Thread) AccessController.doPrivileged(action);
+            thread = AccessController.doPrivileged(action);
             if(Printer.debug) Printer.debug("created thread with JDK 1.2 security");
         } else {
             if(Printer.debug)Printer.debug("not using JDK 1.2 security");
@@ -282,11 +280,11 @@
     }
 
 
-    static List getProviders(final Class providerClass) {
-        List p = new ArrayList();
-        // Service.providers(Class) just creates "lazy" iterator instance,
-        // so it doesn't require do be called from privileged section
-        final Iterator ps = Service.providers(providerClass);
+    static <T> List<T> getProviders(final Class<T> providerClass) {
+        List<T> p = new ArrayList<>();
+        // ServiceLoader creates "lazy" iterator instance, so it doesn't,
+        // require do be called from privileged section
+        final Iterator<T> ps = ServiceLoader.load(providerClass).iterator();
 
         // the iterator's hasNext() method looks through classpath for
         // the provider class names, so it requires read permissions
@@ -301,7 +299,7 @@
                 // the iterator's next() method creates instances of the
                 // providers and it should be called in the current security
                 // context
-                Object provider = ps.next();
+                T provider = ps.next();
                 if (providerClass.isInstance(provider)) {
                     // $$mp 2003-08-22
                     // Always adding at the beginning reverses the
diff --git a/jdk/src/share/classes/com/sun/net/httpserver/spi/HttpServerProvider.java b/jdk/src/share/classes/com/sun/net/httpserver/spi/HttpServerProvider.java
index ec8b91c..7b5c053 100644
--- a/jdk/src/share/classes/com/sun/net/httpserver/spi/HttpServerProvider.java
+++ b/jdk/src/share/classes/com/sun/net/httpserver/spi/HttpServerProvider.java
@@ -25,50 +25,58 @@
 
 package com.sun.net.httpserver.spi;
 
-import java.io.FileDescriptor;
 import java.io.IOException;
 import java.net.*;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.util.Iterator;
-import sun.misc.Service;
-import sun.misc.ServiceConfigurationError;
-import sun.security.action.GetPropertyAction;
+import java.util.ServiceLoader;
+import java.util.ServiceConfigurationError;
 import com.sun.net.httpserver.*;
 
 /**
  * Service provider class for HttpServer.
- * Sub-classes of HttpServerProvider provide an implementation of {@link HttpServer} and
- * associated classes. Applications do not normally use this class.
- * See {@link #provider()} for how providers are found and loaded.
+ * Sub-classes of HttpServerProvider provide an implementation of
+ * {@link HttpServer} and associated classes. Applications do not normally use
+ * this class. See {@link #provider()} for how providers are found and loaded.
  */
 public abstract class HttpServerProvider {
 
     /**
      * creates a HttpServer from this provider
-     * @param addr the address to bind to. May be <code>null</code>
-     * @param backlog the socket backlog. A value of <code>zero</code> means the systems default
+     *
+     * @param  addr
+     *         the address to bind to. May be {@code null}
+     *
+     * @param  backlog
+     *         the socket backlog. A value of {@code zero} means the systems default
      */
-    public abstract HttpServer createHttpServer (InetSocketAddress addr, int backlog) throws IOException;
+    public abstract HttpServer createHttpServer(InetSocketAddress addr,
+                                                int backlog)
+        throws IOException;
 
     /**
      * creates a HttpsServer from this provider
-     * @param addr the address to bind to. May be <code>null</code>
-     * @param backlog the socket backlog. A value of <code>zero</code> means the systems default
+     *
+     * @param  addr
+     *         the address to bind to. May be {@code null}
+     *
+     * @param  backlog
+     *         the socket backlog. A value of {@code zero} means the systems default
      */
-    public abstract HttpsServer createHttpsServer (InetSocketAddress addr, int backlog) throws IOException;
-
-
+    public abstract HttpsServer createHttpsServer(InetSocketAddress addr,
+                                                  int backlog)
+        throws IOException;
 
     private static final Object lock = new Object();
     private static HttpServerProvider provider = null;
 
     /**
-     * Initializes a new instance of this class.  </p>
+     * Initializes a new instance of this class.
      *
      * @throws  SecurityException
      *          If a security manager has been installed and it denies
-     *          {@link RuntimePermission}<tt>("httpServerProvider")</tt>
+     *          {@link RuntimePermission}{@code("httpServerProvider")}
      */
     protected HttpServerProvider() {
         SecurityManager sm = System.getSecurityManager();
@@ -82,21 +90,22 @@
             return false;
         try {
             Class<?> c = Class.forName(cn, true,
-                                    ClassLoader.getSystemClassLoader());
+                                       ClassLoader.getSystemClassLoader());
             provider = (HttpServerProvider)c.newInstance();
             return true;
         } catch (ClassNotFoundException |
                  IllegalAccessException |
                  InstantiationException |
                  SecurityException x) {
-            throw new ServiceConfigurationError(x);
+            throw new ServiceConfigurationError(null, x);
         }
     }
 
     private static boolean loadProviderAsService() {
-        @SuppressWarnings("unchecked")
-        Iterator<HttpServerProvider> i = Service.providers(HttpServerProvider.class,
-                                       ClassLoader.getSystemClassLoader());
+        Iterator<HttpServerProvider> i =
+            ServiceLoader.load(HttpServerProvider.class,
+                               ClassLoader.getSystemClassLoader())
+                .iterator();
         for (;;) {
             try {
                 if (!i.hasNext())
@@ -123,19 +132,19 @@
      * <ol>
      *
      *   <li><p> If the system property
-     *   <tt>com.sun.net.httpserver.HttpServerProvider</tt> is defined then it is
-     *   taken to be the fully-qualified name of a concrete provider class.
+     *   {@code com.sun.net.httpserver.HttpServerProvider} is defined then it
+     *   is taken to be the fully-qualified name of a concrete provider class.
      *   The class is loaded and instantiated; if this process fails then an
      *   unspecified unchecked error or exception is thrown.  </p></li>
      *
      *   <li><p> If a provider class has been installed in a jar file that is
      *   visible to the system class loader, and that jar file contains a
      *   provider-configuration file named
-     *   <tt>com.sun.net.httpserver.HttpServerProvider</tt> in the resource
+     *   {@code com.sun.net.httpserver.HttpServerProvider} in the resource
      *   directory <tt>META-INF/services</tt>, then the first class name
      *   specified in that file is taken.  The class is loaded and
-     *   instantiated; if this process fails then an unspecified unchecked error or exception is
-     *   thrown.  </p></li>
+     *   instantiated; if this process fails then an unspecified unchecked error
+     *   or exception is thrown.  </p></li>
      *
      *   <li><p> Finally, if no provider has been specified by any of the above
      *   means then the system-default provider class is instantiated and the
diff --git a/jdk/src/share/classes/com/sun/rowset/CachedRowSetImpl.java b/jdk/src/share/classes/com/sun/rowset/CachedRowSetImpl.java
index 8008049..9b467055 100644
--- a/jdk/src/share/classes/com/sun/rowset/CachedRowSetImpl.java
+++ b/jdk/src/share/classes/com/sun/rowset/CachedRowSetImpl.java
@@ -357,7 +357,7 @@
 
         // set the Reader, this maybe overridden latter
         provider =
-        (SyncProvider)SyncFactory.getInstance(DEFAULT_SYNC_PROVIDER);
+        SyncFactory.getInstance(DEFAULT_SYNC_PROVIDER);
 
         if (!(provider instanceof RIOptimisticProvider)) {
             throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.invalidp").toString());
@@ -445,11 +445,10 @@
      * @param env a <code>Hashtable</code> object with a list of desired
      *        synchronization providers
      * @throws SQLException if the requested provider cannot be found by the
-     * synchonization factory
+     * synchronization factory
      * @see SyncProvider
      */
-
-    public CachedRowSetImpl(Hashtable env) throws SQLException {
+    public CachedRowSetImpl(@SuppressWarnings("rawtypes") Hashtable env) throws SQLException {
 
 
         try {
@@ -467,7 +466,7 @@
 
         // set the Reader, this maybe overridden latter
         provider =
-        (SyncProvider)SyncFactory.getInstance(providerName);
+        SyncFactory.getInstance(providerName);
 
         rowSetReader = provider.getRowSetReader();
         rowSetWriter = provider.getRowSetWriter();
@@ -525,7 +524,7 @@
 
         iMatchColumns = new Vector<Integer>(10);
         for(int i = 0; i < 10 ; i++) {
-           iMatchColumns.add(i,Integer.valueOf(-1));
+           iMatchColumns.add(i, -1);
         }
 
         strMatchColumns = new Vector<String>(10);
@@ -540,7 +539,7 @@
      */
     private void checkTransactionalWriter() {
         if (rowSetWriter != null) {
-            Class c = rowSetWriter.getClass();
+            Class<?> c = rowSetWriter.getClass();
             if (c != null) {
                 Class[] theInterfaces = c.getInterfaces();
                 for (int i = 0; i < theInterfaces.length; i++) {
@@ -685,7 +684,7 @@
                         obj = new SerialArray((java.sql.Array)obj);
                 }
 
-                ((Row)currentRow).initColumnObject(i, obj);
+                currentRow.initColumnObject(i, obj);
             }
             rowsFetched++;
             rvh.add(currentRow);
@@ -881,7 +880,7 @@
                 cursorPos = saveCursorPos;
             }
 
-            if ((tXWriter) && this.COMMIT_ON_ACCEPT_CHANGES) {
+            if (tXWriter) {
                 // do commit/rollback's here
                 if (!conflict) {
                     tWriter = (TransactionalWriter)rowSetWriter;
@@ -901,7 +900,7 @@
 
             if (success == true) {
                 setOriginal();
-            } else if (!(success) && !(this.COMMIT_ON_ACCEPT_CHANGES)) {
+            } else if (!(success) ) {
                 throw new SyncProviderException(resBundle.handleGetObject("cachedrowsetimpl.accfailed").toString());
             }
 
@@ -938,10 +937,8 @@
      * @see javax.sql.rowset.spi.SyncProvider
      */
     public void acceptChanges(Connection con) throws SyncProviderException{
-
       setConnection(con);
       acceptChanges();
-
     }
 
     /**
@@ -957,7 +954,7 @@
      */
     public void restoreOriginal() throws SQLException {
         Row currentRow;
-        for (Iterator i = rvh.iterator(); i.hasNext();) {
+        for (Iterator<?> i = rvh.iterator(); i.hasNext();) {
             currentRow = (Row)i.next();
             if (currentRow.getInserted() == true) {
                 i.remove();
@@ -1287,7 +1284,7 @@
         TreeMap<Integer, Object> tMap = new TreeMap<>();
 
         for (int i = 0; i<numRows; i++) {
-            tMap.put(Integer.valueOf(i), rvh.get(i));
+            tMap.put(i, rvh.get(i));
         }
 
         return (tMap.values());
@@ -1379,7 +1376,7 @@
      */
     public void setSyncProvider(String providerStr) throws SQLException {
         provider =
-        (SyncProvider)SyncFactory.getInstance(providerStr);
+        SyncFactory.getInstance(providerStr);
 
         rowSetReader = provider.getRowSetReader();
         rowSetWriter = provider.getRowSetWriter();
@@ -1880,7 +1877,7 @@
         // check for SQL NULL
         if (value == null) {
             setLastValueNull(true);
-            return (int)0;
+            return 0;
         }
 
         try {
@@ -2353,7 +2350,7 @@
             throw new SQLException(ex.getMessage());
         }
 
-        return (java.io.InputStream)asciiStream;
+        return asciiStream;
     }
 
     /**
@@ -2399,7 +2396,7 @@
 
         unicodeStream = new StringBufferInputStream(value.toString());
 
-        return (java.io.InputStream)unicodeStream;
+        return unicodeStream;
     }
 
     /**
@@ -2454,7 +2451,7 @@
 
         binaryStream = new ByteArrayInputStream((byte[])value);
 
-        return (java.io.InputStream)binaryStream;
+        return binaryStream;
 
     }
 
@@ -2958,7 +2955,7 @@
             Struct s = (Struct)value;
             map = getTypeMap();
             // look up the class in the map
-            Class c = (Class)map.get(s.getSQLTypeName());
+            Class<?> c = map.get(s.getSQLTypeName());
             if (c != null) {
                 // create new instance of the class
                 SQLData obj = null;
@@ -3091,7 +3088,7 @@
             throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.dtypemismt").toString());
         }
 
-        return (java.io.Reader)charStream;
+        return charStream;
     }
 
     /**
@@ -4006,7 +4003,7 @@
             switch (trgType) {
                 case java.sql.Types.BIT:
                     Integer i = Integer.valueOf(srcObj.toString().trim());
-                    return i.equals(Integer.valueOf((int)0)) ?
+                    return i.equals(0) ?
                     Boolean.valueOf(false) :
                         Boolean.valueOf(true);
                 case java.sql.Types.TINYINT:
@@ -4173,7 +4170,7 @@
             switch (trgType) {
                 case java.sql.Types.BIT:
                     Integer i = Integer.valueOf(srcObj.toString().trim());
-                    return i.equals(Integer.valueOf((int)0)) ?
+                    return i.equals(0) ?
                     Boolean.valueOf(false) :
                         Boolean.valueOf(true);
                 case java.sql.Types.BOOLEAN:
@@ -4358,7 +4355,7 @@
         checkIndex(columnIndex);
         // make sure the cursor is on a valid row
         checkCursor();
-        Object obj = convertNumeric(Integer.valueOf(x),
+        Object obj = convertNumeric(x,
         java.sql.Types.INTEGER,
         RowSetMD.getColumnType(columnIndex));
 
@@ -5709,7 +5706,7 @@
             Struct s = (Struct)value;
 
             // look up the class in the map
-            Class c = (Class)map.get(s.getSQLTypeName());
+            Class<?> c = map.get(s.getSQLTypeName());
             if (c != null) {
                 // create new instance of the class
                 SQLData obj = null;
@@ -6293,7 +6290,7 @@
         int colCount = RowSetMD.getColumnCount();
         Row orig;
 
-        for (Iterator i = rvh.iterator(); i.hasNext();) {
+        for (Iterator<?> i = rvh.iterator(); i.hasNext();) {
             orig = new Row(colCount, ((Row)i.next()).getOrigRow());
             crs.rvh.add(orig);
         }
@@ -6379,7 +6376,7 @@
      * @throws SQLException if an error occurs
      */
     public void setOriginal() throws SQLException {
-        for (Iterator i = rvh.iterator(); i.hasNext();) {
+        for (Iterator<?> i = rvh.iterator(); i.hasNext();) {
             Row row = (Row)i.next();
             makeRowOriginal(row);
             // remove deleted rows from the collection.
@@ -6930,7 +6927,7 @@
          }
 
          for( int i = 0;i < columnIdxes.length ;i++) {
-            iMatchColumns.set(i,Integer.valueOf(-1));
+            iMatchColumns.set(i, -1);
          }
     }
 
@@ -6998,7 +6995,7 @@
         int [] i_temp = new int[iMatchColumns.size()];
         int i_val;
 
-        i_val = ((Integer)iMatchColumns.get(0)).intValue();
+        i_val = iMatchColumns.get(0);
 
         if( i_val == -1 ) {
            throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.setmatchcols").toString());
@@ -7039,7 +7036,7 @@
            }
         }
         for(int i = 0 ;i < columnIdxes.length; i++) {
-           iMatchColumns.add(i,Integer.valueOf(columnIdxes[i]));
+           iMatchColumns.add(i,columnIdxes[i]);
         }
     }
 
@@ -7094,7 +7091,7 @@
             throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.matchcols1").toString());
         } else {
             // set iMatchColumn
-            iMatchColumns.set(0, Integer.valueOf(columnIdx));
+            iMatchColumns.set(0, columnIdx);
             //strMatchColumn = null;
         }
     }
@@ -7147,7 +7144,7 @@
             throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.unsetmatch1").toString());
         } else {
                 // that is, we are unsetting it.
-               iMatchColumns.set(0, Integer.valueOf(-1));
+               iMatchColumns.set(0, -1);
         }
     }
 
@@ -7171,7 +7168,7 @@
 
         if(!((strMatchColumns.get(0)).equals(columnName))) {
             throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.unsetmatch").toString());
-        } else if( ((Integer)(iMatchColumns.get(0))).intValue() > 0) {
+        } else if(iMatchColumns.get(0) > 0) {
             throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.unsetmatch2").toString());
         } else {
             strMatchColumns.set(0, null);   // that is, we are unsetting it.
@@ -7369,7 +7366,7 @@
                     obj = new SerialArray((java.sql.Array)obj, map);
                 }
 
-                ((Row)currentRow).initColumnObject(i, obj);
+                currentRow.initColumnObject(i, obj);
             }
             rowsFetched++;
             maxRowsreached++;
diff --git a/jdk/src/share/classes/com/sun/rowset/FilteredRowSetImpl.java b/jdk/src/share/classes/com/sun/rowset/FilteredRowSetImpl.java
index f21013c..a18c0ac 100644
--- a/jdk/src/share/classes/com/sun/rowset/FilteredRowSetImpl.java
+++ b/jdk/src/share/classes/com/sun/rowset/FilteredRowSetImpl.java
@@ -66,6 +66,7 @@
      * @param env a Hashtable containing a desired synchconizatation provider
      * name-value pair.
      */
+    @SuppressWarnings("rawtypes")
     public FilteredRowSetImpl(Hashtable env) throws SQLException {
         super(env);
     }
diff --git a/jdk/src/share/classes/com/sun/rowset/JdbcRowSetImpl.java b/jdk/src/share/classes/com/sun/rowset/JdbcRowSetImpl.java
index f29d7d9..f2a72f6 100644
--- a/jdk/src/share/classes/com/sun/rowset/JdbcRowSetImpl.java
+++ b/jdk/src/share/classes/com/sun/rowset/JdbcRowSetImpl.java
@@ -695,6 +695,7 @@
         return ps;
     }
 
+    @SuppressWarnings("deprecation")
     private void decodeParams(Object[] params, PreparedStatement ps)
     throws SQLException {
 
@@ -761,14 +762,17 @@
                             ps.setUnicodeStream(i + 1,
                                                 (java.io.InputStream)param[0],
                                                 ((Integer)param[1]).intValue());
+                            break;
                         case JdbcRowSetImpl.BINARY_STREAM_PARAM:
                             ps.setBinaryStream(i + 1,
                                                (java.io.InputStream)param[0],
                                                ((Integer)param[1]).intValue());
+                            break;
                         case JdbcRowSetImpl.ASCII_STREAM_PARAM:
                             ps.setAsciiStream(i + 1,
                                               (java.io.InputStream)param[0],
                                               ((Integer)param[1]).intValue());
+                            break;
                         default:
                             throw new SQLException(resBundle.handleGetObject("jdbcrowsetimpl.paramtype").toString());
                         }
@@ -3822,7 +3826,7 @@
         int [] i_temp = new int[iMatchColumns.size()];
         int i_val;
 
-        i_val = ((Integer)iMatchColumns.get(0)).intValue();
+        i_val = iMatchColumns.get(0);
 
         if( i_val == -1 ) {
            throw new SQLException(resBundle.handleGetObject("jdbcrowsetimpl.setmatchcols").toString());
@@ -3996,7 +4000,7 @@
 
         if(!((strMatchColumns.get(0)).equals(columnName))) {
             throw new SQLException(resBundle.handleGetObject("jdbcrowsetimpl.unsetmatch").toString());
-        } else if( ((Integer)(iMatchColumns.get(0))).intValue() > 0) {
+        } else if(iMatchColumns.get(0) > 0) {
             throw new SQLException(resBundle.handleGetObject("jdbcrowsetimpl.usecolid").toString());
         } else {
             strMatchColumns.set(0, null);   // that is, we are unsetting it.
diff --git a/jdk/src/share/classes/com/sun/rowset/JdbcRowSetResourceBundle.java b/jdk/src/share/classes/com/sun/rowset/JdbcRowSetResourceBundle.java
index acf7479..f699155 100644
--- a/jdk/src/share/classes/com/sun/rowset/JdbcRowSetResourceBundle.java
+++ b/jdk/src/share/classes/com/sun/rowset/JdbcRowSetResourceBundle.java
@@ -135,6 +135,7 @@
      * @return an enumeration of keys which have messages tranlated to
      * corresponding locales.
      */
+    @SuppressWarnings("rawtypes")
     public Enumeration getKeys() {
        return propResBundle.getKeys();
     }
diff --git a/jdk/src/share/classes/com/sun/rowset/JoinRowSetImpl.java b/jdk/src/share/classes/com/sun/rowset/JoinRowSetImpl.java
index 05feebc..0f712f9 100644
--- a/jdk/src/share/classes/com/sun/rowset/JoinRowSetImpl.java
+++ b/jdk/src/share/classes/com/sun/rowset/JoinRowSetImpl.java
@@ -233,7 +233,7 @@
               }
               int[] indexes = new int[indices.size()];
               for(int i=0; i<indices.size();i++)
-                  indexes[i] = ((Integer)indices.get(i)).intValue();
+                  indexes[i] = indices.get(i);
               cRowset.setMatchColumn(indexes);
               // Set the match column here because join will be
               // based on columnId,
@@ -413,6 +413,7 @@
      * @throws SQLException if an error occours generating a collection
      * of the originating RowSets contained within the JOIN.
      */
+    @SuppressWarnings("rawtypes")
     public Collection getRowSets() throws SQLException {
         return vecRowSetsInJOIN;
     }
@@ -893,7 +894,7 @@
 
        sz = vecRowSetsInJOIN.size();
        for(int i=0;i<sz; i++) {
-          crs = (CachedRowSetImpl)vecRowSetsInJOIN.get(i);
+          crs = vecRowSetsInJOIN.get(i);
           cols = crs.getMetaData().getColumnCount();
           tabName = tabName.concat(crs.getTableName());
           strTabName = strTabName.concat(tabName+", ");
@@ -928,7 +929,7 @@
         // rowset1.getMatchColumnName() == rowset2.getMatchColumnName()
          for(int i=0;i<sz; i++) {
              strWhereClause = strWhereClause.concat(
-               ((CachedRowSetImpl)vecRowSetsInJOIN.get(i)).getMatchColumnNames()[0]);
+               vecRowSetsInJOIN.get(i).getMatchColumnNames()[0]);
              if(i%2!=0) {
                strWhereClause = strWhereClause.concat("=");
              }  else {
@@ -4175,7 +4176,7 @@
             // Default JoinRowSet type
             this.setJoinType(JoinRowSet.INNER_JOIN);
         }
-        Integer i = (Integer)(vecJoinType.get(vecJoinType.size()-1));
+        Integer i = vecJoinType.get(vecJoinType.size()-1);
         return i.intValue();
     }
 
diff --git a/jdk/src/share/classes/com/sun/rowset/WebRowSetImpl.java b/jdk/src/share/classes/com/sun/rowset/WebRowSetImpl.java
index 5a62c78..a7afd4a 100644
--- a/jdk/src/share/classes/com/sun/rowset/WebRowSetImpl.java
+++ b/jdk/src/share/classes/com/sun/rowset/WebRowSetImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -101,6 +101,7 @@
      * synchronization providers for the relational and XML providers; or
      * if the Hashtanle is null
      */
+    @SuppressWarnings("rawtypes")
     public WebRowSetImpl(Hashtable env) throws SQLException {
 
         try {
@@ -117,7 +118,7 @@
             (String)env.get(javax.sql.rowset.spi.SyncFactory.ROWSET_SYNC_PROVIDER);
 
         // set the Reader, this maybe overridden latter
-        provider = (SyncProvider)SyncFactory.getInstance(providerName);
+        provider = SyncFactory.getInstance(providerName);
 
         // xmlReader = provider.getRowSetReader();
         // xmlWriter = provider.getRowSetWriter();
diff --git a/jdk/src/share/classes/com/sun/rowset/internal/CachedRowSetReader.java b/jdk/src/share/classes/com/sun/rowset/internal/CachedRowSetReader.java
index 3151002..2375a29 100644
--- a/jdk/src/share/classes/com/sun/rowset/internal/CachedRowSetReader.java
+++ b/jdk/src/share/classes/com/sun/rowset/internal/CachedRowSetReader.java
@@ -363,6 +363,7 @@
      *               the given parameters are to be set
      * @throws SQLException if an access error occurs
      */
+    @SuppressWarnings("deprecation")
     private void decodeParams(Object[] params,
                               PreparedStatement pstmt) throws SQLException {
     // There is a corresponding decodeParams in JdbcRowSetImpl
@@ -428,14 +429,17 @@
                             pstmt.setUnicodeStream(i + 1,
                                                 (java.io.InputStream)param[0],
                                                 ((Integer)param[1]).intValue());
+                            break;
                         case CachedRowSetImpl.BINARY_STREAM_PARAM:
                             pstmt.setBinaryStream(i + 1,
                                                (java.io.InputStream)param[0],
                                                ((Integer)param[1]).intValue());
+                            break;
                         case CachedRowSetImpl.ASCII_STREAM_PARAM:
                             pstmt.setAsciiStream(i + 1,
                                               (java.io.InputStream)param[0],
                                               ((Integer)param[1]).intValue());
+                            break;
                         default:
                             throw new SQLException(resBundle.handleGetObject("crsreader.paramtype").toString());
                         }
diff --git a/jdk/src/share/classes/com/sun/rowset/internal/CachedRowSetWriter.java b/jdk/src/share/classes/com/sun/rowset/internal/CachedRowSetWriter.java
index 784d0c0..4737fb3 100644
--- a/jdk/src/share/classes/com/sun/rowset/internal/CachedRowSetWriter.java
+++ b/jdk/src/share/classes/com/sun/rowset/internal/CachedRowSetWriter.java
@@ -183,7 +183,7 @@
 /**
  * This <code>ArrayList<code> will hold the values of SyncResolver.*
  */
-    private ArrayList status;
+    private ArrayList<Integer> status;
 
 /**
  * This will check whether the same field value has changed both
@@ -305,7 +305,7 @@
 
         iColCount = rsmdWrite.getColumnCount();
         int sz= crs.size()+1;
-        status = new ArrayList(sz);
+        status = new ArrayList<>(sz);
 
         status.add(0,null);
         rsmdResolv.setColumnCount(iColCount);
@@ -338,11 +338,11 @@
             if (crs.rowDeleted()) {
                 // The row has been deleted.
                 if (conflict = (deleteOriginalRow(crs, this.crsResolve)) == true) {
-                       status.add(rows, Integer.valueOf(SyncResolver.DELETE_ROW_CONFLICT));
+                       status.add(rows, SyncResolver.DELETE_ROW_CONFLICT);
                 } else {
                       // delete happened without any occurrence of conflicts
                       // so update status accordingly
-                       status.add(rows, Integer.valueOf(SyncResolver.NO_ROW_CONFLICT));
+                       status.add(rows, SyncResolver.NO_ROW_CONFLICT);
                 }
 
            } else if (crs.rowInserted()) {
@@ -350,20 +350,20 @@
 
                 pstmtIns = con.prepareStatement(insertCmd);
                 if ( (conflict = insertNewRow(crs, pstmtIns, this.crsResolve)) == true) {
-                          status.add(rows, Integer.valueOf(SyncResolver.INSERT_ROW_CONFLICT));
+                          status.add(rows, SyncResolver.INSERT_ROW_CONFLICT);
                 } else {
                       // insert happened without any occurrence of conflicts
                       // so update status accordingly
-                       status.add(rows, Integer.valueOf(SyncResolver.NO_ROW_CONFLICT));
+                       status.add(rows, SyncResolver.NO_ROW_CONFLICT);
                 }
             } else  if (crs.rowUpdated()) {
                   // The row has been updated.
                        if ( conflict = (updateOriginalRow(crs)) == true) {
-                             status.add(rows, Integer.valueOf(SyncResolver.UPDATE_ROW_CONFLICT));
+                             status.add(rows, SyncResolver.UPDATE_ROW_CONFLICT);
                } else {
                       // update happened without any occurrence of conflicts
                       // so update status accordingly
-                      status.add(rows, Integer.valueOf(SyncResolver.NO_ROW_CONFLICT));
+                      status.add(rows, SyncResolver.NO_ROW_CONFLICT);
                }
 
             } else {
@@ -375,7 +375,7 @@
                 *  that is fine.
                 **/
                 int icolCount = crs.getMetaData().getColumnCount();
-                status.add(rows, Integer.valueOf(SyncResolver.NO_ROW_CONFLICT));
+                status.add(rows, SyncResolver.NO_ROW_CONFLICT);
 
                 this.crsResolve.moveToInsertRow();
                 for(int cols=0;cols<iColCount;cols++) {
@@ -398,7 +398,7 @@
       boolean boolConf = false;
       for (int j=1;j<status.size();j++){
           // ignore status for index = 0 which is set to null
-          if(! ((status.get(j)).equals(Integer.valueOf(SyncResolver.NO_ROW_CONFLICT)))) {
+          if(! ((status.get(j)).equals(SyncResolver.NO_ROW_CONFLICT))) {
               // there is at least one conflict which needs to be resolved
               boolConf = true;
              break;
@@ -540,7 +540,7 @@
 
                 // how many fields need to be updated
                 int colsNotChanged = 0;
-                Vector cols = new Vector();
+                Vector<Integer> cols = new Vector<>();
                 String updateExec = updateCmd;
                 Object orig;
                 Object curr;
@@ -566,14 +566,14 @@
                  * into a CachedRowSet so that comparison of the column values
                  * from the ResultSet and CachedRowSet are possible
                  */
-                Map map = (crs.getTypeMap() == null)?con.getTypeMap():crs.getTypeMap();
+                Map<String, Class<?>> map = (crs.getTypeMap() == null)?con.getTypeMap():crs.getTypeMap();
                 if (rsval instanceof Struct) {
 
                     Struct s = (Struct)rsval;
 
                     // look up the class in the map
-                    Class c = null;
-                    c = (Class)map.get(s.getSQLTypeName());
+                    Class<?> c = null;
+                    c = map.get(s.getSQLTypeName());
                     if (c != null) {
                         // create new instance of the class
                         SQLData obj = null;
@@ -652,7 +652,7 @@
                           updateExec += ", ";
                          }
                         updateExec += crs.getMetaData().getColumnName(i);
-                        cols.add(Integer.valueOf(i));
+                        cols.add(i);
                         updateExec += " = ? ";
                         first = false;
 
@@ -698,7 +698,7 @@
                                     updateExec += ", ";
                                  }
                                 updateExec += crs.getMetaData().getColumnName(i);
-                                cols.add(Integer.valueOf(i));
+                                cols.add(i);
                                 updateExec += " = ? ";
                                 flag = false;
                              } else {
@@ -749,7 +749,7 @@
 
                 // Comments needed here
                 for (i = 0; i < cols.size(); i++) {
-                    Object obj = crs.getObject(((Integer)cols.get(i)).intValue());
+                    Object obj = crs.getObject(cols.get(i));
                     if (obj != null)
                         pstmt.setObject(i + 1, obj);
                     else
diff --git a/jdk/src/share/classes/com/sun/rowset/internal/Row.java b/jdk/src/share/classes/com/sun/rowset/internal/Row.java
index 7fa2eda..1fa4b76 100644
--- a/jdk/src/share/classes/com/sun/rowset/internal/Row.java
+++ b/jdk/src/share/classes/com/sun/rowset/internal/Row.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -27,9 +27,7 @@
 
 import java.sql.*;
 import java.io.*;
-import java.math.*;
 import java.lang.*;
-import java.lang.reflect.*;
 import java.util.*;
 
 /**
@@ -48,6 +46,8 @@
  */
 public class Row extends BaseRow implements Serializable, Cloneable {
 
+static final long serialVersionUID = 5047859032611314762L;
+
 /**
  * An array containing the current column values for this <code>Row</code>
  * object.
@@ -115,9 +115,7 @@
  */
     public Row(int numCols, Object[] vals) {
         origVals = new Object[numCols];
-        for (int i=0; i < numCols; i++) {
-            origVals[i] = vals[i];
-        }
+        System.arraycopy(vals, 0, origVals, 0, numCols);
         currentVals = new Object[numCols];
         colsChanged = new BitSet(numCols);
         this.numCols = numCols;
diff --git a/jdk/src/share/classes/com/sun/rowset/internal/SyncResolverImpl.java b/jdk/src/share/classes/com/sun/rowset/internal/SyncResolverImpl.java
index 10573ae..911b1d1 100644
--- a/jdk/src/share/classes/com/sun/rowset/internal/SyncResolverImpl.java
+++ b/jdk/src/share/classes/com/sun/rowset/internal/SyncResolverImpl.java
@@ -65,7 +65,7 @@
      *  This ArrayList will contain the status of a row
      *  from the SyncResolver.* values else it will be null.
      */
-    private ArrayList stats;
+    private ArrayList<?> stats;
 
     /**
      * The RowSetWriter associated with the original
@@ -429,6 +429,7 @@
      * This is used to set the status of each row
      * to either of the values SyncResolver.*_CONFLICT
      **/
+    @SuppressWarnings("rawtypes")
     void setStatus(ArrayList status){
              stats = status;
     }
@@ -856,6 +857,7 @@
      * @see #toCollection(String)
      * @see java.util.TreeMap
      */
+    @SuppressWarnings("rawtypes")
     public Collection toCollection() throws SQLException {
        throw new UnsupportedOperationException();
     }
@@ -878,6 +880,7 @@
      * @see #toCollection(String)
      * @see java.util.Vector
      */
+    @SuppressWarnings("rawtypes")
     public Collection toCollection(int column) throws SQLException {
        throw new UnsupportedOperationException();
     }
@@ -900,6 +903,7 @@
      * @see #toCollection(int)
      * @see java.util.Vector
      */
+    @SuppressWarnings("rawtypes")
     public Collection toCollection(String column) throws SQLException {
         throw new UnsupportedOperationException();
     }
diff --git a/jdk/src/share/classes/com/sun/rowset/internal/WebRowSetXmlWriter.java b/jdk/src/share/classes/com/sun/rowset/internal/WebRowSetXmlWriter.java
index 936c7f6..41737b7 100644
--- a/jdk/src/share/classes/com/sun/rowset/internal/WebRowSetXmlWriter.java
+++ b/jdk/src/share/classes/com/sun/rowset/internal/WebRowSetXmlWriter.java
@@ -55,7 +55,7 @@
      * object will use for storing the tags to be used for writing the calling
      * <code>WebRowSet</code> object as an XML document.
      */
-    private java.util.Stack stack;
+    private java.util.Stack<String> stack;
 
     private  JdbcRowSetResourceBundle resBundle;
 
@@ -94,7 +94,7 @@
     throws SQLException {
 
         // create a new stack for tag checking.
-        stack = new java.util.Stack();
+        stack = new java.util.Stack<>();
         writer = wrt;
         writeRowSet(caller);
     }
@@ -127,7 +127,7 @@
     throws SQLException {
 
         // create a new stack for tag checking.
-        stack = new java.util.Stack();
+        stack = new java.util.Stack<>();
         writer = new OutputStreamWriter(oStream);
         writeRowSet(caller);
     }
@@ -205,10 +205,10 @@
 
             //Changed to beginSection and endSection for maps for proper indentation
             beginSection("map");
-            java.util.Map typeMap = caller.getTypeMap();
+            java.util.Map<?,?> typeMap = caller.getTypeMap();
             if (typeMap != null) {
-                Iterator i = typeMap.keySet().iterator();
-                Class c;
+                Iterator<?> i = typeMap.keySet().iterator();
+                Class<?> c;
                 String type;
                 while (i.hasNext()) {
                     type = (String)i.next();
@@ -532,7 +532,7 @@
     }
 
     private String getTag() {
-        return (String)stack.pop();
+        return stack.pop();
     }
 
     private void writeNull() throws java.io.IOException {
diff --git a/jdk/src/share/classes/com/sun/rowset/internal/XmlReaderContentHandler.java b/jdk/src/share/classes/com/sun/rowset/internal/XmlReaderContentHandler.java
index 50cb7e3..2d36ac1 100644
--- a/jdk/src/share/classes/com/sun/rowset/internal/XmlReaderContentHandler.java
+++ b/jdk/src/share/classes/com/sun/rowset/internal/XmlReaderContentHandler.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -71,14 +71,14 @@
 
 public class XmlReaderContentHandler extends DefaultHandler {
 
-    private HashMap propMap;
-    private HashMap colDefMap;
-    private HashMap dataMap;
+    private HashMap <String, Integer> propMap;
+    private HashMap <String, Integer> colDefMap;
+    private HashMap <String, Integer> dataMap;
 
-    private HashMap typeMap;
+    private HashMap<String,Class<?>> typeMap;
 
-    private Vector updates;
-    private Vector keyCols;
+    private Vector<Object[]> updates;
+    private Vector<String> keyCols;
 
     private String columnValue;
     private String propertyValue;
@@ -438,7 +438,7 @@
         initMaps();
 
         // allocate the collection for the updates
-        updates = new Vector();
+        updates = new Vector<>();
 
         // start out with the empty string
         columnValue = "";
@@ -477,21 +477,21 @@
     private void initMaps() {
         int items, i;
 
-        propMap = new HashMap();
+        propMap = new HashMap<>();
         items = properties.length;
 
         for (i=0;i<items;i++) {
             propMap.put(properties[i], Integer.valueOf(i));
         }
 
-        colDefMap = new HashMap();
+        colDefMap = new HashMap<>();
         items = colDef.length;
 
         for (i=0;i<items;i++) {
             colDefMap.put(colDef[i], Integer.valueOf(i));
         }
 
-        dataMap = new HashMap();
+        dataMap = new HashMap<>();
         items = data.length;
 
         for (i=0;i<items;i++) {
@@ -499,7 +499,7 @@
         }
 
         //Initialize connection map here
-        typeMap = new HashMap();
+        typeMap = new HashMap<>();
     }
 
     public void startDocument() throws SAXException {
@@ -549,14 +549,14 @@
         case PROPERTIES:
 
             tempCommand = "";
-            tag = ((Integer)propMap.get(name)).intValue();
+            tag = propMap.get(name);
             if (tag == PropNullTag)
                setNullValue(true);
             else
                 setTag(tag);
             break;
         case METADATA:
-            tag = ((Integer)colDefMap.get(name)).intValue();
+            tag = colDefMap.get(name);
 
             if (tag == MetaNullTag)
                 setNullValue(true);
@@ -573,10 +573,10 @@
             tempUpdate = "";
             if(dataMap.get(name) == null) {
                 tag = NullTag;
-            } else if(((Integer)dataMap.get(name)).intValue() == EmptyStringTag) {
+            } else if(dataMap.get(name) == EmptyStringTag) {
                 tag = EmptyStringTag;
             } else {
-                 tag = ((Integer)dataMap.get(name)).intValue();
+                 tag = dataMap.get(name);
             }
 
             if (tag == NullTag) {
@@ -630,6 +630,7 @@
      *
      * @exception SAXException if a general SAX error occurs
      */
+    @SuppressWarnings("fallthrough")
     public void endElement(String uri, String lName, String qName) throws SAXException {
         int tag;
 
@@ -644,13 +645,13 @@
             }
 
             try {
-                tag = ((Integer)propMap.get(name)).intValue();
+                tag = propMap.get(name);
                 switch (tag) {
                 case KeycolsTag:
                     if (keyCols != null) {
                         int i[] = new int[keyCols.size()];
                         for (int j = 0; j < i.length; j++)
-                            i[j] = Integer.parseInt((String)keyCols.elementAt(j));
+                            i[j] = Integer.parseInt(keyCols.elementAt(j));
                         rs.setKeyColumns(i);
                     }
                     break;
@@ -723,7 +724,7 @@
             if(dataMap.get(name) == null) {
                 tag = NullTag;
             } else {
-                 tag = ((Integer)dataMap.get(name)).intValue();
+                 tag = dataMap.get(name);
             }
             switch (tag) {
             case ColTag:
@@ -820,7 +821,7 @@
         if (updates.size() > 0) {
             try {
                 Object upd[];
-                Iterator i = updates.iterator();
+                Iterator<?> i = updates.iterator();
                 while (i.hasNext()) {
                     upd = (Object [])i.next();
                     idx = ((Integer)upd[0]).intValue();
@@ -1075,7 +1076,7 @@
             break;
         case PropColumnTag:
             if (keyCols == null)
-                keyCols = new Vector();
+                keyCols = new Vector<>();
             keyCols.add(s);
             break;
         case MapTag:
diff --git a/jdk/src/share/classes/java/applet/Applet.java b/jdk/src/share/classes/java/applet/Applet.java
index 1abacab..4174029 100644
--- a/jdk/src/share/classes/java/applet/Applet.java
+++ b/jdk/src/share/classes/java/applet/Applet.java
@@ -117,7 +117,7 @@
                 s.checkPermission(new AWTPermission("setAppletStub"));
             }
         }
-        this.stub = (AppletStub)stub;
+        this.stub = stub;
     }
 
     /**
@@ -210,6 +210,7 @@
      * @param   width    the new requested width for the applet.
      * @param   height   the new requested height for the applet.
      */
+    @SuppressWarnings("deprecation")
     public void resize(int width, int height) {
         Dimension d = size();
         if ((d.width != width) || (d.height != height)) {
@@ -225,6 +226,7 @@
      *
      * @param   d   an object giving the new width and height.
      */
+    @SuppressWarnings("deprecation")
     public void resize(Dimension d) {
         resize(d.width, d.height);
     }
diff --git a/jdk/src/share/classes/java/awt/Component.java b/jdk/src/share/classes/java/awt/Component.java
index 09d745f..550ba76 100644
--- a/jdk/src/share/classes/java/awt/Component.java
+++ b/jdk/src/share/classes/java/awt/Component.java
@@ -666,9 +666,10 @@
      * can lead to a deadlock if client code also uses synchronization
      * by a component object. For every such situation revealed we should
      * consider possibility of replacing "this" with the package private
-     * objectLock object introduced below. So far there're 2 issues known:
+     * objectLock object introduced below. So far there're 3 issues known:
      * - CR 6708322 (the getName/setName methods);
-     * - CR 6608764 (the PropertyChangeListener machinery).
+     * - CR 6608764 (the PropertyChangeListener machinery);
+     * - CR 7108598 (the Container.paint/KeyboardFocusManager.clearMostRecentFocusOwner methods).
      *
      * Note: this field is considered final, though readObject() prohibits
      * initializing final fields.
@@ -1158,6 +1159,10 @@
     boolean updateGraphicsData(GraphicsConfiguration gc) {
         checkTreeLock();
 
+        if (graphicsConfig == gc) {
+            return false;
+        }
+
         graphicsConfig = gc;
 
         ComponentPeer peer = getPeer();
diff --git a/jdk/src/share/classes/java/awt/Container.java b/jdk/src/share/classes/java/awt/Container.java
index c59aa90..03b0f7f 100644
--- a/jdk/src/share/classes/java/awt/Container.java
+++ b/jdk/src/share/classes/java/awt/Container.java
@@ -1950,7 +1950,7 @@
      */
     public void paint(Graphics g) {
         if (isShowing()) {
-            synchronized (this) {
+            synchronized (getObjectLock()) {
                 if (printing) {
                     if (printingThreads.contains(Thread.currentThread())) {
                         return;
@@ -2004,7 +2004,7 @@
         if (isShowing()) {
             Thread t = Thread.currentThread();
             try {
-                synchronized (this) {
+                synchronized (getObjectLock()) {
                     if (printingThreads == null) {
                         printingThreads = new HashSet();
                     }
@@ -2013,7 +2013,7 @@
                 }
                 super.print(g);  // By default, Component.print() calls paint()
             } finally {
-                synchronized (this) {
+                synchronized (getObjectLock()) {
                     printingThreads.remove(t);
                     printing = !printingThreads.isEmpty();
                 }
diff --git a/jdk/src/share/classes/java/awt/font/StyledParagraph.java b/jdk/src/share/classes/java/awt/font/StyledParagraph.java
index 64ac10d..df231bf 100644
--- a/jdk/src/share/classes/java/awt/font/StyledParagraph.java
+++ b/jdk/src/share/classes/java/awt/font/StyledParagraph.java
@@ -34,6 +34,7 @@
 import java.awt.im.InputMethodHighlight;
 import java.text.Annotation;
 import java.text.AttributedCharacterIterator;
+import java.text.AttributedCharacterIterator.Attribute;
 import java.util.Vector;
 import java.util.HashMap;
 import java.util.Map;
@@ -65,7 +66,7 @@
     // If there are multiple Decorations in the paragraph, they are
     // stored in this Vector, in order.  Otherwise this vector and
     // the decorationStarts array are null.
-    private Vector decorations;
+    private Vector<Decoration> decorations;
     // If there are multiple Decorations in the paragraph,
     // decorationStarts[i] contains the index where decoration i
     // starts.  For convenience, there is an extra entry at the
@@ -76,7 +77,7 @@
     // they are
     // stored in this Vector, in order.  Otherwise this vector and
     // the fontStarts array are null.
-    private Vector fonts;
+    private Vector<Object> fonts;
     // If there are multiple Fonts/GraphicAttributes in the paragraph,
     // fontStarts[i] contains the index where decoration i
     // starts.  For convenience, there is an extra entry at the
@@ -104,7 +105,7 @@
             final int nextRunStart = aci.getRunLimit();
             final int localIndex = index-start;
 
-            Map attributes = aci.getAttributes();
+            Map<? extends Attribute, ?> attributes = aci.getAttributes();
             attributes = addInputMethodAttrs(attributes);
             Decoration d = Decoration.getDecoration(attributes);
             addDecoration(d, localIndex);
@@ -168,7 +169,8 @@
         char ch = aci.setIndex(insertPos);
         int relativePos = Math.max(insertPos - aci.getBeginIndex() - 1, 0);
 
-        Map attributes = addInputMethodAttrs(aci.getAttributes());
+        Map<? extends Attribute, ?> attributes =
+            addInputMethodAttrs(aci.getAttributes());
         Decoration d = Decoration.getDecoration(attributes);
         if (!oldParagraph.getDecorationAt(relativePos).equals(d)) {
             return new StyledParagraph(aci, chars);
@@ -297,7 +299,7 @@
             return decoration;
         }
         int run = findRunContaining(index, decorationStarts);
-        return (Decoration) decorations.elementAt(run);
+        return decorations.elementAt(run);
     }
 
     /**
@@ -339,6 +341,7 @@
      * starts array does not have room for the index, a
      * new array is created and returned.
      */
+    @SuppressWarnings({"rawtypes", "unchecked"})
     private static int[] addToVector(Object obj,
                                      int index,
                                      Vector v,
@@ -374,7 +377,7 @@
         }
         else {
             if (!decoration.equals(d)) {
-                decorations = new Vector(INITIAL_SIZE);
+                decorations = new Vector<Decoration>(INITIAL_SIZE);
                 decorations.addElement(decoration);
                 decorations.addElement(d);
                 decorationStarts = new int[INITIAL_SIZE];
@@ -398,7 +401,7 @@
         }
         else {
             if (!font.equals(f)) {
-                fonts = new Vector(INITIAL_SIZE);
+                fonts = new Vector<Object>(INITIAL_SIZE);
                 fonts.addElement(font);
                 fonts.addElement(f);
                 fontStarts = new int[INITIAL_SIZE];
@@ -412,7 +415,8 @@
      * Resolve the given chars into Fonts using FontResolver, then add
      * font runs for each.
      */
-    private void addFonts(char[] chars, Map attributes, int start, int limit) {
+    private void addFonts(char[] chars, Map<? extends Attribute, ?> attributes,
+                          int start, int limit) {
 
         FontResolver resolver = FontResolver.getInstance();
         CodePointIterator iter = CodePointIterator.create(chars, start, limit);
@@ -426,7 +430,8 @@
      * Return a Map with entries from oldStyles, as well as input
      * method entries, if any.
      */
-    static Map addInputMethodAttrs(Map oldStyles) {
+    static Map<? extends Attribute, ?>
+           addInputMethodAttrs(Map<? extends Attribute, ?> oldStyles) {
 
         Object value = oldStyles.get(TextAttribute.INPUT_METHOD_HIGHLIGHT);
 
@@ -439,7 +444,7 @@
                 InputMethodHighlight hl;
                 hl = (InputMethodHighlight) value;
 
-                Map imStyles = null;
+                Map<? extends Attribute, ?> imStyles = null;
                 try {
                     imStyles = hl.getStyle();
                 } catch (NoSuchMethodError e) {
@@ -451,7 +456,8 @@
                 }
 
                 if (imStyles != null) {
-                    HashMap newStyles = new HashMap(5, (float)0.9);
+                    HashMap<Attribute, Object>
+                        newStyles = new HashMap<>(5, (float)0.9);
                     newStyles.putAll(oldStyles);
 
                     newStyles.putAll(imStyles);
@@ -471,7 +477,8 @@
      * If attributes does not contain a GraphicAttribute, Font, or
      * Font family entry this method returns null.
      */
-    private static Object getGraphicOrFont(Map attributes) {
+    private static Object getGraphicOrFont(
+            Map<? extends Attribute, ?> attributes) {
 
         Object value = attributes.get(TextAttribute.CHAR_REPLACEMENT);
         if (value != null) {
diff --git a/jdk/src/share/classes/java/awt/font/TextAttribute.java b/jdk/src/share/classes/java/awt/font/TextAttribute.java
index 38808b7..50d47da 100644
--- a/jdk/src/share/classes/java/awt/font/TextAttribute.java
+++ b/jdk/src/share/classes/java/awt/font/TextAttribute.java
@@ -257,7 +257,8 @@
 public final class TextAttribute extends Attribute {
 
     // table of all instances in this class, used by readResolve
-    private static final Map instanceMap = new HashMap(29);
+    private static final Map<String, TextAttribute>
+            instanceMap = new HashMap<String, TextAttribute>(29);
 
     /**
      * Constructs a <code>TextAttribute</code> with the specified name.
@@ -280,7 +281,7 @@
                 "subclass didn't correctly implement readResolve");
         }
 
-        TextAttribute instance = (TextAttribute) instanceMap.get(getName());
+        TextAttribute instance = instanceMap.get(getName());
         if (instance != null) {
             return instance;
         } else {
diff --git a/jdk/src/share/classes/java/awt/font/TextLayout.java b/jdk/src/share/classes/java/awt/font/TextLayout.java
index 51b0dc6..c09afd7 100644
--- a/jdk/src/share/classes/java/awt/font/TextLayout.java
+++ b/jdk/src/share/classes/java/awt/font/TextLayout.java
@@ -55,6 +55,7 @@
 import java.text.AttributedString;
 import java.text.AttributedCharacterIterator;
 import java.text.AttributedCharacterIterator.Attribute;
+import java.text.CharacterIterator;
 import java.util.Map;
 import java.util.HashMap;
 import java.util.Hashtable;
@@ -382,7 +383,7 @@
             throw new IllegalArgumentException("Zero length string passed to TextLayout constructor.");
         }
 
-        Map attributes = null;
+        Map<? extends Attribute, ?> attributes = null;
         if (font.hasLayoutAttributes()) {
             attributes = font.getAttributes();
         }
@@ -451,7 +452,7 @@
     private static Font singleFont(char[] text,
                                    int start,
                                    int limit,
-                                   Map attributes) {
+                                   Map<? extends Attribute, ?> attributes) {
 
         if (attributes.get(TextAttribute.CHAR_REPLACEMENT) != null) {
             return null;
@@ -516,14 +517,17 @@
         text.first();
         char[] chars = new char[len];
         int n = 0;
-        for (char c = text.first(); c != text.DONE; c = text.next()) {
+        for (char c = text.first();
+             c != CharacterIterator.DONE;
+             c = text.next())
+        {
             chars[n++] = c;
         }
 
         text.first();
         if (text.getRunLimit() == limit) {
 
-            Map attributes = text.getAttributes();
+            Map<? extends Attribute, ?> attributes = text.getAttributes();
             Font font = singleFont(chars, 0, len, attributes);
             if (font != null) {
                 fastInit(chars, font, attributes, frc);
@@ -561,7 +565,9 @@
     /**
      * Initialize the paragraph-specific data.
      */
-    private void paragraphInit(byte aBaseline, CoreMetrics lm, Map paragraphAttrs, char[] text) {
+    private void paragraphInit(byte aBaseline, CoreMetrics lm,
+                               Map<? extends Attribute, ?> paragraphAttrs,
+                               char[] text) {
 
         baseline = aBaseline;
 
@@ -581,7 +587,10 @@
      * all renderable by one font (ie no embedded graphics)
      * all on one baseline
      */
-    private void fastInit(char[] chars, Font font, Map attrs, FontRenderContext frc) {
+    private void fastInit(char[] chars, Font font,
+                          Map<? extends Attribute, ?> attrs,
+                          FontRenderContext frc) {
+
         // Object vf = attrs.get(TextAttribute.ORIENTATION);
         // isVerticalLine = TextAttribute.ORIENTATION_VERTICAL.equals(vf);
         isVerticalLine = false;
@@ -619,7 +628,7 @@
             // and use it and its font to initialize the paragraph.
             // If not, use the first graphic to initialize.
 
-            Map paragraphAttrs = text.getAttributes();
+            Map<? extends Attribute, ?> paragraphAttrs = text.getAttributes();
 
             boolean haveFont = TextLine.advanceToFirstFont(text);
 
diff --git a/jdk/src/share/classes/java/awt/font/TextLine.java b/jdk/src/share/classes/java/awt/font/TextLine.java
index fd59d9f..3a4301e 100644
--- a/jdk/src/share/classes/java/awt/font/TextLine.java
+++ b/jdk/src/share/classes/java/awt/font/TextLine.java
@@ -43,6 +43,7 @@
 import java.awt.image.BufferedImage;
 import java.text.Annotation;
 import java.text.AttributedCharacterIterator;
+import java.text.AttributedCharacterIterator.Attribute;
 import java.text.Bidi;
 import java.text.CharacterIterator;
 import java.util.Hashtable;
@@ -318,7 +319,8 @@
             for (int i = 0, n = 0; i < fComponents.length; ++i, n += 2) {
                 tlc = fComponents[getComponentLogicalIndex(i)];
                 AffineTransform at = tlc.getBaselineTransform();
-                if (at != null && ((at.getType() & at.TYPE_TRANSLATION) != 0)) {
+                if (at != null &&
+                    ((at.getType() & AffineTransform.TYPE_TRANSLATION) != 0)) {
                     double dx = at.getTranslateX();
                     double dy = at.getTranslateY();
                     builder.moveTo(tx += dx, ty += dy);
@@ -903,7 +905,7 @@
                                               char[] chars,
                                               Font font,
                                               CoreMetrics lm,
-                                              Map attributes) {
+                                              Map<? extends Attribute, ?> attributes) {
 
         boolean isDirectionLTR = true;
         byte[] levels = null;
@@ -1250,7 +1252,10 @@
      */
     static boolean advanceToFirstFont(AttributedCharacterIterator aci) {
 
-        for (char ch = aci.first(); ch != aci.DONE; ch = aci.setIndex(aci.getRunLimit())) {
+        for (char ch = aci.first();
+             ch != CharacterIterator.DONE;
+             ch = aci.setIndex(aci.getRunLimit()))
+        {
 
             if (aci.getAttribute(TextAttribute.CHAR_REPLACEMENT) == null) {
                 return true;
diff --git a/jdk/src/share/classes/java/awt/font/TextMeasurer.java b/jdk/src/share/classes/java/awt/font/TextMeasurer.java
index ca052b3..b20afcd 100644
--- a/jdk/src/share/classes/java/awt/font/TextMeasurer.java
+++ b/jdk/src/share/classes/java/awt/font/TextMeasurer.java
@@ -43,6 +43,7 @@
 import java.awt.Font;
 
 import java.text.AttributedCharacterIterator;
+import java.text.AttributedCharacterIterator.Attribute;
 import java.text.AttributedString;
 import java.text.Bidi;
 import java.text.BreakIterator;
@@ -176,7 +177,7 @@
             throw new Error();
         }
         if (fComponents != null) {
-            other.fComponents = (TextLineComponent[]) fComponents.clone();
+            other.fComponents = fComponents.clone();
         }
         return other;
     }
@@ -199,7 +200,10 @@
         fChars = new char[text.getEndIndex() - fStart];
 
         int n = 0;
-        for (char c = text.first(); c != text.DONE; c = text.next()) {
+        for (char c = text.first();
+             c != CharacterIterator.DONE;
+             c = text.next())
+        {
             fChars[n++] = c;
         }
 
@@ -211,7 +215,7 @@
         }
 
         text.first();
-        Map paragraphAttrs = text.getAttributes();
+        Map<? extends Attribute, ?> paragraphAttrs = text.getAttributes();
         NumericShaper shaper = AttributeValues.getNumericShaping(paragraphAttrs);
         if (shaper != null) {
             shaper.shape(fChars, 0, fChars.length);
@@ -243,7 +247,8 @@
                 GraphicAttribute graphic = (GraphicAttribute)
                                 paragraphAttrs.get(TextAttribute.CHAR_REPLACEMENT);
                 fBaseline = TextLayout.getBaselineFromGraphic(graphic);
-                Font dummyFont = new Font(new Hashtable(5, (float)0.9));
+                Hashtable<Attribute, ?> fmap = new Hashtable<>(5, (float)0.9);
+                Font dummyFont = new Font(fmap);
                 LineMetrics lm = dummyFont.getLineMetrics(" ", 0, 1, fFrc);
                 fBaselineOffsets = lm.getBaselineOffsets();
             }
diff --git a/jdk/src/share/classes/java/awt/geom/Path2D.java b/jdk/src/share/classes/java/awt/geom/Path2D.java
index 39f7d99..3aae874 100644
--- a/jdk/src/share/classes/java/awt/geom/Path2D.java
+++ b/jdk/src/share/classes/java/awt/geom/Path2D.java
@@ -667,7 +667,8 @@
                         // Collapse out initial moveto/lineto
                         break;
                     }
-                    // NO BREAK;
+                    lineTo(coords[0], coords[1]);
+                    break;
                 case SEG_LINETO:
                     lineTo(coords[0], coords[1]);
                     break;
@@ -1392,7 +1393,8 @@
                         // Collapse out initial moveto/lineto
                         break;
                     }
-                    // NO BREAK;
+                    lineTo(coords[0], coords[1]);
+                    break;
                 case SEG_LINETO:
                     lineTo(coords[0], coords[1]);
                     break;
@@ -2456,7 +2458,7 @@
                 }
             }
         }
-        s.writeByte((byte) SERIAL_PATH_END);
+        s.writeByte(SERIAL_PATH_END);
     }
 
     final void readObject(java.io.ObjectInputStream s, boolean storedbl)
diff --git a/jdk/src/share/classes/java/awt/im/InputMethodHighlight.java b/jdk/src/share/classes/java/awt/im/InputMethodHighlight.java
index be610a1..ffa99df 100644
--- a/jdk/src/share/classes/java/awt/im/InputMethodHighlight.java
+++ b/jdk/src/share/classes/java/awt/im/InputMethodHighlight.java
@@ -190,6 +190,6 @@
     private boolean selected;
     private int state;
     private int variation;
-    private Map style;
+    private Map<TextAttribute, ?> style;
 
 };
diff --git a/jdk/src/share/classes/java/beans/BeanDescriptor.java b/jdk/src/share/classes/java/beans/BeanDescriptor.java
index 08d5b70..2e235c2 100644
--- a/jdk/src/share/classes/java/beans/BeanDescriptor.java
+++ b/jdk/src/share/classes/java/beans/BeanDescriptor.java
@@ -37,8 +37,8 @@
 
 public class BeanDescriptor extends FeatureDescriptor {
 
-    private Reference<Class> beanClassRef;
-    private Reference<Class> customizerClassRef;
+    private Reference<? extends Class<?>> beanClassRef;
+    private Reference<? extends Class<?>> customizerClassRef;
 
     /**
      * Create a BeanDescriptor for a bean that doesn't have a customizer.
@@ -59,8 +59,8 @@
      *          the bean's Customizer.  For example sun.beans.OurButtonCustomizer.class.
      */
     public BeanDescriptor(Class<?> beanClass, Class<?> customizerClass) {
-        this.beanClassRef = getWeakReference((Class)beanClass);
-        this.customizerClassRef = getWeakReference((Class)customizerClass);
+        this.beanClassRef = getWeakReference(beanClass);
+        this.customizerClassRef = getWeakReference(customizerClass);
 
         String name = beanClass.getName();
         while (name.indexOf('.') >= 0) {
diff --git a/jdk/src/share/classes/java/beans/Beans.java b/jdk/src/share/classes/java/beans/Beans.java
index b71a2ac..2183d22 100644
--- a/jdk/src/share/classes/java/beans/Beans.java
+++ b/jdk/src/share/classes/java/beans/Beans.java
@@ -32,7 +32,6 @@
 import java.applet.AppletStub;
 import java.applet.AudioClip;
 
-import java.awt.GraphicsEnvironment;
 import java.awt.Image;
 
 import java.beans.beancontext.BeanContext;
@@ -53,15 +52,11 @@
 import java.util.Iterator;
 import java.util.Vector;
 
-import sun.awt.AppContext;
-
 /**
  * This class provides some general purpose beans control methods.
  */
 
 public class Beans {
-    private static final Object DESIGN_TIME = new Object();
-    private static final Object GUI_AVAILABLE = new Object();
 
     /**
      * <p>
@@ -181,9 +176,9 @@
         // Try to find a serialized object with this name
         final String serName = beanName.replace('.','/').concat(".ser");
         final ClassLoader loader = cls;
-        ins = (InputStream)AccessController.doPrivileged
-            (new PrivilegedAction() {
-                public Object run() {
+        ins = AccessController.doPrivileged
+            (new PrivilegedAction<InputStream>() {
+                public InputStream run() {
                     if (loader == null)
                         return ClassLoader.getSystemResourceAsStream(serName);
                     else
@@ -213,7 +208,7 @@
 
         if (result == null) {
             // No serialized object, try just instantiating the class
-            Class cl;
+            Class<?> cl;
 
             try {
                 cl = ClassFinder.findClass(beanName, cls);
@@ -278,10 +273,10 @@
                     // Now get the URL correponding to the resource name.
 
                     final ClassLoader cloader = cls;
-                    objectUrl = (URL)
+                    objectUrl =
                         AccessController.doPrivileged
-                        (new PrivilegedAction() {
-                            public Object run() {
+                        (new PrivilegedAction<URL>() {
+                            public URL run() {
                                 if (cloader == null)
                                     return ClassLoader.getSystemResource
                                                                 (resourceName);
@@ -326,7 +321,7 @@
                 // now, if there is a BeanContext, add the bean, if applicable.
 
                 if (beanContext != null) {
-                    beanContext.add(result);
+                    unsafeBeanContextAdd(beanContext, result);
                 }
 
                 // If it was deserialized then it was already init-ed.
@@ -344,12 +339,16 @@
                   ((BeansAppletStub)stub).active = true;
                 } else initializer.activate(applet);
 
-            } else if (beanContext != null) beanContext.add(result);
+            } else if (beanContext != null) unsafeBeanContextAdd(beanContext, result);
         }
 
         return result;
     }
 
+    @SuppressWarnings("unchecked")
+    private static void unsafeBeanContextAdd(BeanContext beanContext, Object res) {
+        beanContext.add(res);
+    }
 
     /**
      * From a given bean, obtain an object representing a specified
@@ -395,8 +394,7 @@
      * @see DesignMode
      */
     public static boolean isDesignTime() {
-        Object value = AppContext.getAppContext().get(DESIGN_TIME);
-        return (value instanceof Boolean) && (Boolean) value;
+        return ThreadGroupContext.getContext().isDesignTime();
     }
 
     /**
@@ -413,8 +411,7 @@
      *
      */
     public static boolean isGuiAvailable() {
-        Object value = AppContext.getAppContext().get(GUI_AVAILABLE);
-        return (value instanceof Boolean) ? (Boolean) value : !GraphicsEnvironment.isHeadless();
+        return ThreadGroupContext.getContext().isGuiAvailable();
     }
 
     /**
@@ -440,7 +437,7 @@
         if (sm != null) {
             sm.checkPropertiesAccess();
         }
-        AppContext.getAppContext().put(DESIGN_TIME, Boolean.valueOf(isDesignTime));
+        ThreadGroupContext.getContext().setDesignTime(isDesignTime);
     }
 
     /**
@@ -466,7 +463,7 @@
         if (sm != null) {
             sm.checkPropertiesAccess();
         }
-        AppContext.getAppContext().put(GUI_AVAILABLE, Boolean.valueOf(isGuiAvailable));
+        ThreadGroupContext.getContext().setGuiAvailable(isGuiAvailable);
     }
 }
 
@@ -496,6 +493,7 @@
     /**
      * Use the given ClassLoader rather than using the system class
      */
+    @SuppressWarnings("rawtypes")
     protected Class resolveClass(ObjectStreamClass classDesc)
         throws IOException, ClassNotFoundException {
 
@@ -511,7 +509,7 @@
 
 class BeansAppletContext implements AppletContext {
     Applet target;
-    Hashtable imageCache = new Hashtable();
+    Hashtable<URL,Object> imageCache = new Hashtable<>();
 
     BeansAppletContext(Applet target) {
         this.target = target;
@@ -556,8 +554,8 @@
         return null;
     }
 
-    public Enumeration getApplets() {
-        Vector applets = new Vector();
+    public Enumeration<Applet> getApplets() {
+        Vector<Applet> applets = new Vector<>();
         applets.addElement(target);
         return applets.elements();
     }
@@ -583,7 +581,7 @@
         return null;
     }
 
-    public Iterator getStreamKeys(){
+    public Iterator<String> getStreamKeys(){
         // We do nothing.
         return null;
     }
diff --git a/jdk/src/share/classes/java/beans/ChangeListenerMap.java b/jdk/src/share/classes/java/beans/ChangeListenerMap.java
index 930c697..e623d9b 100644
--- a/jdk/src/share/classes/java/beans/ChangeListenerMap.java
+++ b/jdk/src/share/classes/java/beans/ChangeListenerMap.java
@@ -76,7 +76,7 @@
      */
     public final synchronized void add(String name, L listener) {
         if (this.map == null) {
-            this.map = new HashMap<String, L[]>();
+            this.map = new HashMap<>();
         }
         L[] array = this.map.get(name);
         int size = (array != null)
@@ -146,7 +146,7 @@
     public final void set(String name, L[] listeners) {
         if (listeners != null) {
             if (this.map == null) {
-                this.map = new HashMap<String, L[]>();
+                this.map = new HashMap<>();
             }
             this.map.put(name, listeners);
         }
@@ -167,7 +167,7 @@
         if (this.map == null) {
             return newArray(0);
         }
-        List<L> list = new ArrayList<L>();
+        List<L> list = new ArrayList<>();
 
         L[] listeners = this.map.get(null);
         if (listeners != null) {
@@ -239,6 +239,7 @@
      */
     public final L extract(L listener) {
         while (listener instanceof EventListenerProxy) {
+            @SuppressWarnings("unchecked")
             EventListenerProxy<L> proxy = (EventListenerProxy<L>) listener;
             listener = proxy.getListener();
         }
diff --git a/jdk/src/share/classes/java/beans/DefaultPersistenceDelegate.java b/jdk/src/share/classes/java/beans/DefaultPersistenceDelegate.java
index 951d972..db98785 100644
--- a/jdk/src/share/classes/java/beans/DefaultPersistenceDelegate.java
+++ b/jdk/src/share/classes/java/beans/DefaultPersistenceDelegate.java
@@ -95,7 +95,7 @@
         this.constructor = constructorPropertyNames;
     }
 
-    private static boolean definesEquals(Class type) {
+    private static boolean definesEquals(Class<?> type) {
         try {
             return type == type.getMethod("equals", Object.class).getDeclaringClass();
         }
@@ -153,7 +153,7 @@
      */
     protected Expression instantiate(Object oldInstance, Encoder out) {
         int nArgs = constructor.length;
-        Class type = oldInstance.getClass();
+        Class<?> type = oldInstance.getClass();
         Object[] constructorArgs = new Object[nArgs];
         for(int i = 0; i < nArgs; i++) {
             try {
@@ -167,7 +167,7 @@
         return new Expression(oldInstance, oldInstance.getClass(), "new", constructorArgs);
     }
 
-    private Method findMethod(Class type, String property) {
+    private Method findMethod(Class<?> type, String property) {
         if (property == null) {
             throw new IllegalArgumentException("Property name is null");
         }
@@ -182,7 +182,7 @@
         return method;
     }
 
-    private void doProperty(Class type, PropertyDescriptor pd, Object oldInstance, Object newInstance, Encoder out) throws Exception {
+    private void doProperty(Class<?> type, PropertyDescriptor pd, Object oldInstance, Object newInstance, Encoder out) throws Exception {
         Method getter = pd.getReadMethod();
         Method setter = pd.getWriteMethod();
 
@@ -218,7 +218,7 @@
     }
 
     // Write out the properties of this instance.
-    private void initBean(Class type, Object oldInstance, Object newInstance, Encoder out) {
+    private void initBean(Class<?> type, Object oldInstance, Object newInstance, Encoder out) {
         for (Field field : type.getFields()) {
             int mod = field.getModifiers();
             if (Modifier.isFinal(mod) || Modifier.isStatic(mod) || Modifier.isTransient(mod)) {
@@ -288,7 +288,7 @@
             if (d.isTransient()) {
                 continue;
             }
-            Class listenerType = d.getListenerType();
+            Class<?> listenerType = d.getListenerType();
 
 
             // The ComponentListener is added automatically, when
@@ -318,7 +318,7 @@
             }
             catch (Exception e2) {
                 try {
-                    Method m = type.getMethod("getListeners", new Class[]{Class.class});
+                    Method m = type.getMethod("getListeners", new Class<?>[]{Class.class});
                     oldL = (EventListener[])MethodUtil.invoke(m, oldInstance, new Object[]{listenerType});
                     newL = (EventListener[])MethodUtil.invoke(m, newInstance, new Object[]{listenerType});
                 }
@@ -401,7 +401,7 @@
         }
     }
 
-    private static PropertyDescriptor getPropertyDescriptor(Class type, String property) {
+    private static PropertyDescriptor getPropertyDescriptor(Class<?> type, String property) {
         try {
             for (PropertyDescriptor pd : Introspector.getBeanInfo(type).getPropertyDescriptors()) {
                 if (property.equals(pd.getName()))
diff --git a/jdk/src/share/classes/java/beans/Encoder.java b/jdk/src/share/classes/java/beans/Encoder.java
index 62cd8df..4a877f3 100644
--- a/jdk/src/share/classes/java/beans/Encoder.java
+++ b/jdk/src/share/classes/java/beans/Encoder.java
@@ -47,10 +47,10 @@
 
 public class Encoder {
     private final PersistenceDelegateFinder finder = new PersistenceDelegateFinder();
-    private Map bindings = new IdentityHashMap();
+    private Map<Object, Expression> bindings = new IdentityHashMap<>();
     private ExceptionListener exceptionListener;
     boolean executeStatements = true;
-    private Map attributes;
+    private Map<Object, Object> attributes;
 
     /**
      * Write the specified object to the output stream.
@@ -195,7 +195,13 @@
      */
     public PersistenceDelegate getPersistenceDelegate(Class<?> type) {
         PersistenceDelegate pd = this.finder.find(type);
-        return (pd != null) ? pd : MetaData.getPersistenceDelegate(type);
+        if (pd == null) {
+            pd = MetaData.getPersistenceDelegate(type);
+            if (pd != null) {
+                this.finder.register(type, pd);
+            }
+        }
+        return pd;
     }
 
     /**
@@ -221,7 +227,7 @@
      * @see #get
      */
     public Object remove(Object oldInstance) {
-        Expression exp = (Expression)bindings.remove(oldInstance);
+        Expression exp = bindings.remove(oldInstance);
         return getValue(exp);
     }
 
@@ -242,7 +248,7 @@
             oldInstance.getClass() == String.class) {
             return oldInstance;
         }
-        Expression exp = (Expression)bindings.get(oldInstance);
+        Expression exp = bindings.get(oldInstance);
         return getValue(exp);
     }
 
@@ -331,7 +337,7 @@
     // Package private method for setting an attributes table for the encoder
     void setAttribute(Object key, Object value) {
         if (attributes == null) {
-            attributes = new HashMap();
+            attributes = new HashMap<>();
         }
         attributes.put(key, value);
     }
diff --git a/jdk/src/share/classes/java/beans/EventHandler.java b/jdk/src/share/classes/java/beans/EventHandler.java
index 2853017..b7635c9 100644
--- a/jdk/src/share/classes/java/beans/EventHandler.java
+++ b/jdk/src/share/classes/java/beans/EventHandler.java
@@ -385,14 +385,14 @@
             if (target != null) {
                 getter = Statement.getMethod(target.getClass(),
                                       "get" + NameGenerator.capitalize(first),
-                                      new Class[]{});
+                                      new Class<?>[]{});
                 if (getter == null) {
                     getter = Statement.getMethod(target.getClass(),
                                    "is" + NameGenerator.capitalize(first),
-                                   new Class[]{});
+                                   new Class<?>[]{});
                 }
                 if (getter == null) {
-                    getter = Statement.getMethod(target.getClass(), first, new Class[]{});
+                    getter = Statement.getMethod(target.getClass(), first, new Class<?>[]{});
                 }
             }
             if (getter == null) {
@@ -450,12 +450,12 @@
 
             if (eventPropertyName == null) {     // Nullary method.
                 newArgs = new Object[]{};
-                argTypes = new Class[]{};
+                argTypes = new Class<?>[]{};
             }
             else {
                 Object input = applyGetters(arguments[0], getEventPropertyName());
                 newArgs = new Object[]{input};
-                argTypes = new Class[]{input == null ? null :
+                argTypes = new Class<?>[]{input == null ? null :
                                        input.getClass()};
             }
             try {
@@ -674,6 +674,7 @@
      *
      * @see EventHandler
      */
+    @SuppressWarnings("unchecked")
     public static <T> T create(Class<T> listenerInterface,
                                Object target, String action,
                                String eventPropertyName,
@@ -688,7 +689,7 @@
                           "listenerInterface must be non-null");
         }
         return (T)Proxy.newProxyInstance(target.getClass().getClassLoader(),
-                                         new Class[] {listenerInterface},
+                                         new Class<?>[] {listenerInterface},
                                          eventHandler);
     }
 }
diff --git a/jdk/src/share/classes/java/beans/EventSetDescriptor.java b/jdk/src/share/classes/java/beans/EventSetDescriptor.java
index 83b5e0d..46d4f54 100644
--- a/jdk/src/share/classes/java/beans/EventSetDescriptor.java
+++ b/jdk/src/share/classes/java/beans/EventSetDescriptor.java
@@ -45,7 +45,7 @@
     private MethodDescriptor getMethodDescriptor;
 
     private Reference<Method[]> listenerMethodsRef;
-    private Reference<Class> listenerTypeRef;
+    private Reference<? extends Class<?>> listenerTypeRef;
 
     private boolean unicast;
     private boolean inDefaultEventSet = true;
@@ -91,7 +91,7 @@
         }
     }
 
-    private static String getListenerClassName(Class cls) {
+    private static String getListenerClassName(Class<?> cls) {
         String className = cls.getName();
         return className.substring(className.lastIndexOf('.') + 1);
     }
@@ -182,7 +182,7 @@
         }
     }
 
-    private static Method getMethod(Class cls, String name, int args)
+    private static Method getMethod(Class<?> cls, String name, int args)
         throws IntrospectionException {
         if (name == null) {
             return null;
@@ -295,7 +295,7 @@
                 : null;
     }
 
-    private void setListenerType(Class cls) {
+    private void setListenerType(Class<?> cls) {
         this.listenerTypeRef = getWeakReference(cls);
     }
 
diff --git a/jdk/src/share/classes/java/beans/FeatureDescriptor.java b/jdk/src/share/classes/java/beans/FeatureDescriptor.java
index fcfc9d7..34c27e5 100644
--- a/jdk/src/share/classes/java/beans/FeatureDescriptor.java
+++ b/jdk/src/share/classes/java/beans/FeatureDescriptor.java
@@ -51,7 +51,7 @@
 public class FeatureDescriptor {
     private static final String TRANSIENT = "transient";
 
-    private Reference<Class> classRef;
+    private Reference<? extends Class<?>> classRef;
 
     /**
      * Constructs a <code>FeatureDescriptor</code>.
@@ -284,7 +284,7 @@
      */
     private Hashtable<String, Object> getTable() {
         if (this.table == null) {
-            this.table = new Hashtable<String, Object>();
+            this.table = new Hashtable<>();
         }
         return this.table;
     }
@@ -317,11 +317,11 @@
 
     // Package private methods for recreating the weak/soft referent
 
-    void setClass0(Class cls) {
+    void setClass0(Class<?> cls) {
         this.classRef = getWeakReference(cls);
     }
 
-    Class getClass0() {
+    Class<?> getClass0() {
         return (this.classRef != null)
                 ? this.classRef.get()
                 : null;
@@ -336,7 +336,7 @@
      */
     static <T> Reference<T> getSoftReference(T object) {
         return (object != null)
-                ? new SoftReference<T>(object)
+                ? new SoftReference<>(object)
                 : null;
     }
 
@@ -349,7 +349,7 @@
      */
     static <T> Reference<T> getWeakReference(T object) {
         return (object != null)
-                ? new WeakReference<T>(object)
+                ? new WeakReference<>(object)
                 : null;
     }
 
@@ -363,7 +363,7 @@
      * @see Method#getGenericReturnType
      * @see Method#getReturnType
      */
-    static Class getReturnType(Class base, Method method) {
+    static Class<?> getReturnType(Class<?> base, Method method) {
         if (base == null) {
             base = method.getDeclaringClass();
         }
@@ -380,7 +380,7 @@
      * @see Method#getGenericParameterTypes
      * @see Method#getParameterTypes
      */
-    static Class[] getParameterTypes(Class base, Method method) {
+    static Class<?>[] getParameterTypes(Class<?> base, Method method) {
         if (base == null) {
             base = method.getDeclaringClass();
         }
@@ -425,7 +425,7 @@
     void appendTo(StringBuilder sb) {
     }
 
-    static void appendTo(StringBuilder sb, String name, Reference reference) {
+    static void appendTo(StringBuilder sb, String name, Reference<?> reference) {
         if (reference != null) {
             appendTo(sb, name, reference.get());
         }
diff --git a/jdk/src/share/classes/java/beans/IndexedPropertyDescriptor.java b/jdk/src/share/classes/java/beans/IndexedPropertyDescriptor.java
index 5764bf4..096e94d 100644
--- a/jdk/src/share/classes/java/beans/IndexedPropertyDescriptor.java
+++ b/jdk/src/share/classes/java/beans/IndexedPropertyDescriptor.java
@@ -40,7 +40,7 @@
 
 public class IndexedPropertyDescriptor extends PropertyDescriptor {
 
-    private Reference<Class> indexedPropertyTypeRef;
+    private Reference<? extends Class<?>> indexedPropertyTypeRef;
     private Reference<Method> indexedReadMethodRef;
     private Reference<Method> indexedWriteMethodRef;
 
@@ -175,14 +175,14 @@
     public synchronized Method getIndexedReadMethod() {
         Method indexedReadMethod = getIndexedReadMethod0();
         if (indexedReadMethod == null) {
-            Class cls = getClass0();
+            Class<?> cls = getClass0();
             if (cls == null ||
                 (indexedReadMethodName == null && indexedReadMethodRef == null)) {
                 // the Indexed readMethod was explicitly set to null.
                 return null;
             }
             if (indexedReadMethodName == null) {
-                Class type = getIndexedPropertyType0();
+                Class<?> type = getIndexedPropertyType0();
                 if (type == boolean.class || type == null) {
                     indexedReadMethodName = Introspector.IS_PREFIX + getBaseName();
                 } else {
@@ -190,7 +190,7 @@
                 }
             }
 
-            Class[] args = { int.class };
+            Class<?>[] args = { int.class };
             indexedReadMethod = Introspector.findMethod(cls, indexedReadMethodName, 1, args);
             if (indexedReadMethod == null) {
                 // no "is" method, so look for a "get" method.
@@ -240,7 +240,7 @@
     public synchronized Method getIndexedWriteMethod() {
         Method indexedWriteMethod = getIndexedWriteMethod0();
         if (indexedWriteMethod == null) {
-            Class cls = getClass0();
+            Class<?> cls = getClass0();
             if (cls == null ||
                 (indexedWriteMethodName == null && indexedWriteMethodRef == null)) {
                 // the Indexed writeMethod was explicitly set to null.
@@ -250,14 +250,14 @@
             // We need the indexed type to ensure that we get the correct method.
             // Cannot use the getIndexedPropertyType method since that could
             // result in an infinite loop.
-            Class type = getIndexedPropertyType0();
+            Class<?> type = getIndexedPropertyType0();
             if (type == null) {
                 try {
                     type = findIndexedPropertyType(getIndexedReadMethod(), null);
                     setIndexedPropertyType(type);
                 } catch (IntrospectionException ex) {
                     // Set iprop type to be the classic type
-                    Class propType = getPropertyType();
+                    Class<?> propType = getPropertyType();
                     if (propType.isArray()) {
                         type = propType.getComponentType();
                     }
@@ -268,7 +268,7 @@
                 indexedWriteMethodName = Introspector.SET_PREFIX + getBaseName();
             }
 
-            Class[] args = (type == null) ? null : new Class[] { int.class, type };
+            Class<?>[] args = (type == null) ? null : new Class<?>[] { int.class, type };
             indexedWriteMethod = Introspector.findMethod(cls, indexedWriteMethodName, 2, args);
             if (indexedWriteMethod != null) {
                 if (!indexedWriteMethod.getReturnType().equals(void.class)) {
@@ -289,7 +289,7 @@
         throws IntrospectionException {
 
         // If the indexed property type has not been set, then set it.
-        Class type = findIndexedPropertyType(getIndexedReadMethod(),
+        Class<?> type = findIndexedPropertyType(getIndexedReadMethod(),
                                              writeMethod);
         setIndexedPropertyType(type);
         setIndexedWriteMethod0(writeMethod);
@@ -319,7 +319,7 @@
      *         or {@code null} if the type cannot be determined
      */
     public synchronized Class<?> getIndexedPropertyType() {
-        Class type = getIndexedPropertyType0();
+        Class<?> type = getIndexedPropertyType0();
         if (type == null) {
             try {
                 type = findIndexedPropertyType(getIndexedReadMethod(),
@@ -334,11 +334,11 @@
 
     // Private methods which set get/set the Reference objects
 
-    private void setIndexedPropertyType(Class type) {
+    private void setIndexedPropertyType(Class<?> type) {
         this.indexedPropertyTypeRef = getWeakReference(type);
     }
 
-    private Class getIndexedPropertyType0() {
+    private Class<?> getIndexedPropertyType0() {
         return (this.indexedPropertyTypeRef != null)
                 ? this.indexedPropertyTypeRef.get()
                 : null;
@@ -356,10 +356,10 @@
                 : null;
     }
 
-    private Class findIndexedPropertyType(Method indexedReadMethod,
+    private Class<?> findIndexedPropertyType(Method indexedReadMethod,
                                           Method indexedWriteMethod)
         throws IntrospectionException {
-        Class indexedPropertyType = null;
+        Class<?> indexedPropertyType = null;
 
         if (indexedReadMethod != null) {
             Class params[] = getParameterTypes(getClass0(), indexedReadMethod);
@@ -389,7 +389,7 @@
             }
             indexedPropertyType = params[1];
         }
-        Class propertyType = getPropertyType();
+        Class<?> propertyType = getPropertyType();
         if (propertyType != null && (!propertyType.isArray() ||
                                      propertyType.getComponentType() != indexedPropertyType)) {
             throw new IntrospectionException("type mismatch between indexed and non-indexed methods: "
diff --git a/jdk/src/share/classes/java/beans/Introspector.java b/jdk/src/share/classes/java/beans/Introspector.java
index 36ead72..5734208 100644
--- a/jdk/src/share/classes/java/beans/Introspector.java
+++ b/jdk/src/share/classes/java/beans/Introspector.java
@@ -26,7 +26,6 @@
 package java.beans;
 
 import com.sun.beans.WeakCache;
-import com.sun.beans.finder.BeanInfoFinder;
 import com.sun.beans.finder.ClassFinder;
 
 import java.awt.Component;
@@ -44,9 +43,7 @@
 import java.util.EventObject;
 import java.util.List;
 import java.util.TreeMap;
-import java.util.WeakHashMap;
 
-import sun.awt.AppContext;
 import sun.reflect.misc.ReflectUtil;
 
 /**
@@ -98,18 +95,15 @@
     public final static int IGNORE_ALL_BEANINFO        = 3;
 
     // Static Caches to speed up introspection.
-    private static WeakCache<Class<?>, Method[]> declaredMethodCache =
-            new WeakCache<Class<?>, Method[]>();
+    private static final WeakCache<Class<?>, Method[]> declaredMethodCache = new WeakCache<>();
 
-    private static final Object BEANINFO_CACHE = new Object();
-
-    private Class beanClass;
+    private Class<?> beanClass;
     private BeanInfo explicitBeanInfo;
     private BeanInfo superBeanInfo;
     private BeanInfo additionalBeanInfo[];
 
     private boolean propertyChangeSource = false;
-    private static Class eventListenerType = EventListener.class;
+    private static Class<EventListener> eventListenerType = EventListener.class;
 
     // These should be removed.
     private String defaultEventName;
@@ -117,14 +111,14 @@
     private int defaultEventIndex = -1;
     private int defaultPropertyIndex = -1;
 
-    // Methods maps from Method objects to MethodDescriptors
-    private Map methods;
+    // Methods maps from Method names to MethodDescriptors
+    private Map<String, MethodDescriptor> methods;
 
     // properties maps from String names to PropertyDescriptors
-    private Map properties;
+    private Map<String, PropertyDescriptor> properties;
 
     // events maps from String names to EventSetDescriptors
-    private Map events;
+    private Map<String, EventSetDescriptor> events;
 
     private final static EventSetDescriptor[] EMPTY_EVENTSETDESCRIPTORS = new EventSetDescriptor[0];
 
@@ -134,8 +128,6 @@
     static final String SET_PREFIX = "set";
     static final String IS_PREFIX = "is";
 
-    private static final Object FINDER_KEY = new Object();
-
     //======================================================================
     //                          Public methods
     //======================================================================
@@ -160,20 +152,15 @@
         if (!ReflectUtil.isPackageAccessible(beanClass)) {
             return (new Introspector(beanClass, null, USE_ALL_BEANINFO)).getBeanInfo();
         }
-        Map<Class<?>, BeanInfo> beanInfoCache;
+        ThreadGroupContext context = ThreadGroupContext.getContext();
         BeanInfo beanInfo;
-        synchronized (BEANINFO_CACHE) {
-            beanInfoCache = (Map<Class<?>, BeanInfo>) AppContext.getAppContext().get(BEANINFO_CACHE);
-            if (beanInfoCache == null) {
-                beanInfoCache = new WeakHashMap<Class<?>, BeanInfo>();
-                AppContext.getAppContext().put(BEANINFO_CACHE, beanInfoCache);
-            }
-            beanInfo = beanInfoCache.get(beanClass);
+        synchronized (declaredMethodCache) {
+            beanInfo = context.getBeanInfo(beanClass);
         }
         if (beanInfo == null) {
             beanInfo = new Introspector(beanClass, null, USE_ALL_BEANINFO).getBeanInfo();
-            synchronized (BEANINFO_CACHE) {
-                beanInfoCache.put(beanClass, beanInfo);
+            synchronized (declaredMethodCache) {
+                context.putBeanInfo(beanClass, beanInfo);
             }
         }
         return beanInfo;
@@ -306,7 +293,7 @@
      */
 
     public static String[] getBeanInfoSearchPath() {
-        return getFinder().getPackages();
+        return ThreadGroupContext.getContext().getBeanInfoFinder().getPackages();
     }
 
     /**
@@ -330,7 +317,7 @@
         if (sm != null) {
             sm.checkPropertiesAccess();
         }
-        getFinder().setPackages(path);
+        ThreadGroupContext.getContext().getBeanInfoFinder().setPackages(path);
     }
 
 
@@ -342,11 +329,8 @@
      */
 
     public static void flushCaches() {
-        synchronized (BEANINFO_CACHE) {
-            Map beanInfoCache = (Map) AppContext.getAppContext().get(BEANINFO_CACHE);
-            if (beanInfoCache != null) {
-                beanInfoCache.clear();
-            }
+        synchronized (declaredMethodCache) {
+            ThreadGroupContext.getContext().clearBeanInfoCache();
             declaredMethodCache.clear();
         }
     }
@@ -370,11 +354,8 @@
         if (clz == null) {
             throw new NullPointerException();
         }
-        synchronized (BEANINFO_CACHE) {
-            Map beanInfoCache = (Map) AppContext.getAppContext().get(BEANINFO_CACHE);
-            if (beanInfoCache != null) {
-                beanInfoCache.put(clz, null);
-            }
+        synchronized (declaredMethodCache) {
+            ThreadGroupContext.getContext().removeBeanInfo(clz);
             declaredMethodCache.put(clz, null);
         }
     }
@@ -383,14 +364,14 @@
     //                  Private implementation methods
     //======================================================================
 
-    private Introspector(Class beanClass, Class stopClass, int flags)
+    private Introspector(Class<?> beanClass, Class<?> stopClass, int flags)
                                             throws IntrospectionException {
         this.beanClass = beanClass;
 
         // Check stopClass is a superClass of startClass.
         if (stopClass != null) {
             boolean isSuper = false;
-            for (Class c = beanClass.getSuperclass(); c != null; c = c.getSuperclass()) {
+            for (Class<?> c = beanClass.getSuperclass(); c != null; c = c.getSuperclass()) {
                 if (c == stopClass) {
                     isSuper = true;
                 }
@@ -405,7 +386,7 @@
             explicitBeanInfo = findExplicitBeanInfo(beanClass);
         }
 
-        Class superClass = beanClass.getSuperclass();
+        Class<?> superClass = beanClass.getSuperclass();
         if (superClass != stopClass) {
             int newFlags = flags;
             if (newFlags == IGNORE_IMMEDIATE_BEANINFO) {
@@ -451,8 +432,8 @@
      * @param beanClass  the class type of the bean
      * @return Instance of an explicit BeanInfo class or null if one isn't found.
      */
-    private static BeanInfo findExplicitBeanInfo(Class beanClass) {
-        return getFinder().find(beanClass);
+    private static BeanInfo findExplicitBeanInfo(Class<?> beanClass) {
+        return ThreadGroupContext.getContext().getBeanInfoFinder().find(beanClass);
     }
 
     /**
@@ -501,8 +482,8 @@
                     continue;
                 }
                 String name = method.getName();
-                Class argTypes[] = method.getParameterTypes();
-                Class resultType = method.getReturnType();
+                Class<?>[] argTypes = method.getParameterTypes();
+                Class<?> resultType = method.getReturnType();
                 int argCount = argTypes.length;
                 PropertyDescriptor pd = null;
 
@@ -560,8 +541,8 @@
         processPropertyDescriptors();
 
         // Allocate and populate the result array.
-        PropertyDescriptor result[] = new PropertyDescriptor[properties.size()];
-        result = (PropertyDescriptor[])properties.values().toArray(result);
+        PropertyDescriptor result[] =
+                properties.values().toArray(new PropertyDescriptor[properties.size()]);
 
         // Set the default index.
         if (defaultPropertyName != null) {
@@ -575,16 +556,16 @@
         return result;
     }
 
-    private HashMap pdStore = new HashMap();
+    private HashMap<String, List<PropertyDescriptor>> pdStore = new HashMap<>();
 
     /**
      * Adds the property descriptor to the list store.
      */
     private void addPropertyDescriptor(PropertyDescriptor pd) {
         String propName = pd.getName();
-        List list = (List)pdStore.get(propName);
+        List<PropertyDescriptor> list = pdStore.get(propName);
         if (list == null) {
-            list = new ArrayList();
+            list = new ArrayList<>();
             pdStore.put(propName, list);
         }
         if (this.beanClass != pd.getClass0()) {
@@ -639,25 +620,25 @@
      */
     private void processPropertyDescriptors() {
         if (properties == null) {
-            properties = new TreeMap();
+            properties = new TreeMap<>();
         }
 
-        List list;
+        List<PropertyDescriptor> list;
 
         PropertyDescriptor pd, gpd, spd;
         IndexedPropertyDescriptor ipd, igpd, ispd;
 
-        Iterator it = pdStore.values().iterator();
+        Iterator<List<PropertyDescriptor>> it = pdStore.values().iterator();
         while (it.hasNext()) {
             pd = null; gpd = null; spd = null;
             ipd = null; igpd = null; ispd = null;
 
-            list = (List)it.next();
+            list = it.next();
 
             // First pass. Find the latest getter method. Merge properties
             // of previous getter methods.
             for (int i = 0; i < list.size(); i++) {
-                pd = (PropertyDescriptor)list.get(i);
+                pd = list.get(i);
                 if (pd instanceof IndexedPropertyDescriptor) {
                     ipd = (IndexedPropertyDescriptor)pd;
                     if (ipd.getIndexedReadMethod() != null) {
@@ -686,7 +667,7 @@
             // Second pass. Find the latest setter method which
             // has the same type as the getter method.
             for (int i = 0; i < list.size(); i++) {
-                pd = (PropertyDescriptor)list.get(i);
+                pd = list.get(i);
                 if (pd instanceof IndexedPropertyDescriptor) {
                     ipd = (IndexedPropertyDescriptor)pd;
                     if (ipd.getIndexedWriteMethod() != null) {
@@ -804,7 +785,7 @@
             // which does not have getter and setter methods.
             // See regression bug 4984912.
             if ( (pd == null) && (list.size() > 0) ) {
-                pd = (PropertyDescriptor) list.get(0);
+                pd = list.get(0);
             }
 
             if (pd != null) {
@@ -823,8 +804,8 @@
                                                        PropertyDescriptor pd) {
         PropertyDescriptor result = null;
 
-        Class propType = pd.getPropertyType();
-        Class ipropType = ipd.getIndexedPropertyType();
+        Class<?> propType = pd.getPropertyType();
+        Class<?> ipropType = ipd.getIndexedPropertyType();
 
         if (propType.isArray() && propType.getComponentType() == ipropType) {
             if (pd.getClass0().isAssignableFrom(ipd.getClass0())) {
@@ -858,7 +839,7 @@
                 if (write == null && read != null) {
                     write = findMethod(result.getClass0(),
                                        SET_PREFIX + NameGenerator.capitalize(result.getName()), 1,
-                                       new Class[] { FeatureDescriptor.getReturnType(result.getClass0(), read) });
+                                       new Class<?>[] { FeatureDescriptor.getReturnType(result.getClass0(), read) });
                     if (write != null) {
                         try {
                             result.setWriteMethod(write);
@@ -898,7 +879,7 @@
      */
     private EventSetDescriptor[] getTargetEventInfo() throws IntrospectionException {
         if (events == null) {
-            events = new HashMap();
+            events = new HashMap<>();
         }
 
         // Check if the bean has its own BeanInfo that will provide
@@ -949,9 +930,9 @@
             // Find all suitable "add", "remove" and "get" Listener methods
             // The name of the listener type is the key for these hashtables
             // i.e, ActionListener
-            Map adds = null;
-            Map removes = null;
-            Map gets = null;
+            Map<String, Method> adds = null;
+            Map<String, Method> removes = null;
+            Map<String, Method> gets = null;
 
             for (int i = 0; i < methodList.length; i++) {
                 Method method = methodList[i];
@@ -970,8 +951,8 @@
                     continue;
                 }
 
-                Class argTypes[] = FeatureDescriptor.getParameterTypes(beanClass, method);
-                Class resultType = FeatureDescriptor.getReturnType(beanClass, method);
+                Class<?>[] argTypes = FeatureDescriptor.getParameterTypes(beanClass, method);
+                Class<?> resultType = FeatureDescriptor.getReturnType(beanClass, method);
 
                 if (name.startsWith(ADD_PREFIX) && argTypes.length == 1 &&
                     resultType == Void.TYPE &&
@@ -980,7 +961,7 @@
                     if (listenerName.length() > 0 &&
                         argTypes[0].getName().endsWith(listenerName)) {
                         if (adds == null) {
-                            adds = new HashMap();
+                            adds = new HashMap<>();
                         }
                         adds.put(listenerName, method);
                     }
@@ -992,7 +973,7 @@
                     if (listenerName.length() > 0 &&
                         argTypes[0].getName().endsWith(listenerName)) {
                         if (removes == null) {
-                            removes = new HashMap();
+                            removes = new HashMap<>();
                         }
                         removes.put(listenerName, method);
                     }
@@ -1005,7 +986,7 @@
                     if (listenerName.length() > 0 &&
                         resultType.getComponentType().getName().endsWith(listenerName)) {
                         if (gets == null) {
-                            gets = new HashMap();
+                            gets = new HashMap<>();
                         }
                         gets.put(listenerName, method);
                     }
@@ -1015,26 +996,26 @@
             if (adds != null && removes != null) {
                 // Now look for matching addFooListener+removeFooListener pairs.
                 // Bonus if there is a matching getFooListeners method as well.
-                Iterator keys = adds.keySet().iterator();
+                Iterator<String> keys = adds.keySet().iterator();
                 while (keys.hasNext()) {
-                    String listenerName = (String) keys.next();
+                    String listenerName = keys.next();
                     // Skip any "add" which doesn't have a matching "remove" or
                     // a listener name that doesn't end with Listener
                     if (removes.get(listenerName) == null || !listenerName.endsWith("Listener")) {
                         continue;
                     }
                     String eventName = decapitalize(listenerName.substring(0, listenerName.length()-8));
-                    Method addMethod = (Method)adds.get(listenerName);
-                    Method removeMethod = (Method)removes.get(listenerName);
+                    Method addMethod = adds.get(listenerName);
+                    Method removeMethod = removes.get(listenerName);
                     Method getMethod = null;
                     if (gets != null) {
-                        getMethod = (Method)gets.get(listenerName);
+                        getMethod = gets.get(listenerName);
                     }
-                    Class argType = FeatureDescriptor.getParameterTypes(beanClass, addMethod)[0];
+                    Class<?> argType = FeatureDescriptor.getParameterTypes(beanClass, addMethod)[0];
 
                     // generate a list of Method objects for each of the target methods:
                     Method allMethods[] = getPublicDeclaredMethods(argType);
-                    List validMethods = new ArrayList(allMethods.length);
+                    List<Method> validMethods = new ArrayList<>(allMethods.length);
                     for (int i = 0; i < allMethods.length; i++) {
                         if (allMethods[i] == null) {
                             continue;
@@ -1044,7 +1025,7 @@
                             validMethods.add(allMethods[i]);
                         }
                     }
-                    Method[] methods = (Method[])validMethods.toArray(new Method[validMethods.size()]);
+                    Method[] methods = validMethods.toArray(new Method[validMethods.size()]);
 
                     EventSetDescriptor esd = new EventSetDescriptor(eventName, argType,
                                                                     methods, addMethod,
@@ -1067,7 +1048,7 @@
         } else {
             // Allocate and populate the result array.
             result = new EventSetDescriptor[events.size()];
-            result = (EventSetDescriptor[])events.values().toArray(result);
+            result = events.values().toArray(result);
 
             // Set the default index.
             if (defaultEventName != null) {
@@ -1086,7 +1067,7 @@
         if (esd.getName().equals("propertyChange")) {
             propertyChangeSource = true;
         }
-        EventSetDescriptor old = (EventSetDescriptor)events.get(key);
+        EventSetDescriptor old = events.get(key);
         if (old == null) {
             events.put(key, esd);
             return;
@@ -1101,7 +1082,7 @@
      */
     private MethodDescriptor[] getTargetMethodInfo() {
         if (methods == null) {
-            methods = new HashMap(100);
+            methods = new HashMap<>(100);
         }
 
         // Check if the bean has its own BeanInfo that will provide
@@ -1154,7 +1135,7 @@
 
         // Allocate and populate the result array.
         MethodDescriptor result[] = new MethodDescriptor[methods.size()];
-        result = (MethodDescriptor[])methods.values().toArray(result);
+        result = methods.values().toArray(result);
 
         return result;
     }
@@ -1165,7 +1146,7 @@
         // This method gets called a *lot, so we try to be efficient.
         String name = md.getName();
 
-        MethodDescriptor old = (MethodDescriptor)methods.get(name);
+        MethodDescriptor old = methods.get(name);
         if (old == null) {
             // This is the common case.
             methods.put(name, md);
@@ -1198,7 +1179,7 @@
         // This is very rare.
 
         String longKey = makeQualifiedMethodName(name, p1);
-        old = (MethodDescriptor)methods.get(longKey);
+        old = methods.get(longKey);
         if (old == null) {
             methods.put(longKey, md);
             return;
@@ -1269,13 +1250,13 @@
     /*
      * Internal method to return *public* methods within a class.
      */
-    private static Method[] getPublicDeclaredMethods(Class clz) {
+    private static Method[] getPublicDeclaredMethods(Class<?> clz) {
         // Looking up Class.getDeclaredMethods is relatively expensive,
         // so we cache the results.
         if (!ReflectUtil.isPackageAccessible(clz)) {
             return new Method[0];
         }
-        synchronized (BEANINFO_CACHE) {
+        synchronized (declaredMethodCache) {
             Method[] result = declaredMethodCache.get(clz);
             if (result == null) {
                 result = clz.getMethods();
@@ -1299,14 +1280,14 @@
      * Internal support for finding a target methodName with a given
      * parameter list on a given class.
      */
-    private static Method internalFindMethod(Class start, String methodName,
+    private static Method internalFindMethod(Class<?> start, String methodName,
                                                  int argCount, Class args[]) {
         // For overriden methods we need to find the most derived version.
         // So we start with the given class and walk up the superclass chain.
 
         Method method = null;
 
-        for (Class cl = start; cl != null; cl = cl.getSuperclass()) {
+        for (Class<?> cl = start; cl != null; cl = cl.getSuperclass()) {
             Method methods[] = getPublicDeclaredMethods(cl);
             for (int i = 0; i < methods.length; i++) {
                 method = methods[i];
@@ -1357,7 +1338,7 @@
     /**
      * Find a target methodName on a given class.
      */
-    static Method findMethod(Class cls, String methodName, int argCount) {
+    static Method findMethod(Class<?> cls, String methodName, int argCount) {
         return findMethod(cls, methodName, argCount, null);
     }
 
@@ -1373,7 +1354,7 @@
      * @param args Array of argument types for the method.
      * @return the method or null if not found
      */
-    static Method findMethod(Class cls, String methodName, int argCount,
+    static Method findMethod(Class<?> cls, String methodName, int argCount,
                              Class args[]) {
         if (methodName == null) {
             return null;
@@ -1387,7 +1368,7 @@
      * or "implements" b.
      * Note tht either or both "Class" objects may represent interfaces.
      */
-    static  boolean isSubclass(Class a, Class b) {
+    static  boolean isSubclass(Class<?> a, Class<?> b) {
         // We rely on the fact that for any given java class or
         // primtitive type there is a unqiue Class object, so
         // we can use object equivalence in the comparisons.
@@ -1397,12 +1378,12 @@
         if (a == null || b == null) {
             return false;
         }
-        for (Class x = a; x != null; x = x.getSuperclass()) {
+        for (Class<?> x = a; x != null; x = x.getSuperclass()) {
             if (x == b) {
                 return true;
             }
             if (b.isInterface()) {
-                Class interfaces[] = x.getInterfaces();
+                Class<?>[] interfaces = x.getInterfaces();
                 for (int i = 0; i < interfaces.length; i++) {
                     if (isSubclass(interfaces[i], b)) {
                         return true;
@@ -1416,7 +1397,7 @@
     /**
      * Return true iff the given method throws the given exception.
      */
-    private boolean throwsException(Method method, Class exception) {
+    private boolean throwsException(Method method, Class<?> exception) {
         Class exs[] = method.getExceptionTypes();
         for (int i = 0; i < exs.length; i++) {
             if (exs[i] == exception) {
@@ -1426,28 +1407,17 @@
         return false;
     }
 
-    private static BeanInfoFinder getFinder() {
-        AppContext context = AppContext.getAppContext();
-        Object object = context.get(FINDER_KEY);
-        if (object instanceof BeanInfoFinder) {
-            return (BeanInfoFinder) object;
-        }
-        BeanInfoFinder finder = new BeanInfoFinder();
-        context.put(FINDER_KEY, finder);
-        return finder;
-    }
-
     /**
      * Try to create an instance of a named class.
      * First try the classloader of "sibling", then try the system
      * classloader then the class loader of the current Thread.
      */
-    static Object instantiate(Class sibling, String className)
+    static Object instantiate(Class<?> sibling, String className)
                  throws InstantiationException, IllegalAccessException,
                                                 ClassNotFoundException {
         // First check with sibling's classloader (if any).
         ClassLoader cl = sibling.getClassLoader();
-        Class cls = ClassFinder.findClass(className, cl);
+        Class<?> cls = ClassFinder.findClass(className, cl);
         return cls.newInstance();
     }
 
@@ -1482,7 +1452,7 @@
         this.properties = properties;
         this.defaultProperty = defaultProperty;
         this.methods = methods;
-        this.targetBeanInfoRef = new SoftReference<BeanInfo>(targetBeanInfo);
+        this.targetBeanInfoRef = new SoftReference<>(targetBeanInfo);
     }
 
     /**
diff --git a/jdk/src/share/classes/java/beans/MetaData.java b/jdk/src/share/classes/java/beans/MetaData.java
index c4ab869..3e3f5d1 100644
--- a/jdk/src/share/classes/java/beans/MetaData.java
+++ b/jdk/src/share/classes/java/beans/MetaData.java
@@ -93,7 +93,7 @@
     }
 
     protected Expression instantiate(Object oldInstance, Encoder out) {
-        Enum e = (Enum) oldInstance;
+        Enum<?> e = (Enum<?>) oldInstance;
         return new Expression(e, Enum.class, "valueOf", new Object[]{e.getDeclaringClass(), e.name()});
     }
 }
@@ -118,7 +118,7 @@
 
     protected Expression instantiate(Object oldInstance, Encoder out) {
         // System.out.println("instantiate: " + type + " " + oldInstance);
-        Class oldClass = oldInstance.getClass();
+        Class<?> oldClass = oldInstance.getClass();
         return new Expression(oldInstance, Array.class, "newInstance",
                    new Object[]{oldClass.getComponentType(),
                                 new Integer(Array.getLength(oldInstance))});
@@ -152,14 +152,14 @@
 
 class ProxyPersistenceDelegate extends PersistenceDelegate {
     protected Expression instantiate(Object oldInstance, Encoder out) {
-        Class type = oldInstance.getClass();
+        Class<?> type = oldInstance.getClass();
         java.lang.reflect.Proxy p = (java.lang.reflect.Proxy)oldInstance;
         // This unappealing hack is not required but makes the
         // representation of EventHandlers much more concise.
         java.lang.reflect.InvocationHandler ih = java.lang.reflect.Proxy.getInvocationHandler(p);
         if (ih instanceof EventHandler) {
             EventHandler eh = (EventHandler)ih;
-            Vector args = new Vector();
+            Vector<Object> args = new Vector<>();
             args.add(type.getInterfaces()[0]);
             args.add(eh.getTarget());
             args.add(eh.getAction());
@@ -200,7 +200,7 @@
     }
 
     protected Expression instantiate(Object oldInstance, Encoder out) {
-        Class c = (Class)oldInstance;
+        Class<?> c = (Class)oldInstance;
         // As of 1.3 it is not possible to call Class.forName("int"),
         // so we have to generate different code for primitive types.
         // This is needed for arrays whose subtype may be primitive.
@@ -362,8 +362,8 @@
         if ((oldInstance instanceof List) || (oldInstance instanceof Set) || (oldInstance instanceof Map)) {
             return oldInstance.equals(newInstance);
         }
-        Collection oldC = (Collection) oldInstance;
-        Collection newC = (Collection) newInstance;
+        Collection<?> oldC = (Collection<?>) oldInstance;
+        Collection<?> newC = (Collection<?>) newInstance;
         return (oldC.size() == newC.size()) && oldC.containsAll(newC);
     }
 
@@ -387,21 +387,21 @@
 
     static final class SingletonList_PersistenceDelegate extends java_util_Collections {
         protected Expression instantiate(Object oldInstance, Encoder out) {
-            List list = (List) oldInstance;
+            List<?> list = (List<?>) oldInstance;
             return new Expression(oldInstance, Collections.class, "singletonList", new Object[]{list.get(0)});
         }
     }
 
     static final class SingletonSet_PersistenceDelegate extends java_util_Collections {
         protected Expression instantiate(Object oldInstance, Encoder out) {
-            Set set = (Set) oldInstance;
+            Set<?> set = (Set<?>) oldInstance;
             return new Expression(oldInstance, Collections.class, "singleton", new Object[]{set.iterator().next()});
         }
     }
 
     static final class SingletonMap_PersistenceDelegate extends java_util_Collections {
         protected Expression instantiate(Object oldInstance, Encoder out) {
-            Map map = (Map) oldInstance;
+            Map<?,?> map = (Map<?,?>) oldInstance;
             Object key = map.keySet().iterator().next();
             return new Expression(oldInstance, Collections.class, "singletonMap", new Object[]{key, map.get(key)});
         }
@@ -409,98 +409,98 @@
 
     static final class UnmodifiableCollection_PersistenceDelegate extends java_util_Collections {
         protected Expression instantiate(Object oldInstance, Encoder out) {
-            List list = new ArrayList((Collection) oldInstance);
+            List<?> list = new ArrayList<>((Collection<?>) oldInstance);
             return new Expression(oldInstance, Collections.class, "unmodifiableCollection", new Object[]{list});
         }
     }
 
     static final class UnmodifiableList_PersistenceDelegate extends java_util_Collections {
         protected Expression instantiate(Object oldInstance, Encoder out) {
-            List list = new LinkedList((Collection) oldInstance);
+            List<?> list = new LinkedList<>((Collection<?>) oldInstance);
             return new Expression(oldInstance, Collections.class, "unmodifiableList", new Object[]{list});
         }
     }
 
     static final class UnmodifiableRandomAccessList_PersistenceDelegate extends java_util_Collections {
         protected Expression instantiate(Object oldInstance, Encoder out) {
-            List list = new ArrayList((Collection) oldInstance);
+            List<?> list = new ArrayList<>((Collection<?>) oldInstance);
             return new Expression(oldInstance, Collections.class, "unmodifiableList", new Object[]{list});
         }
     }
 
     static final class UnmodifiableSet_PersistenceDelegate extends java_util_Collections {
         protected Expression instantiate(Object oldInstance, Encoder out) {
-            Set set = new HashSet((Set) oldInstance);
+            Set<?> set = new HashSet<>((Set<?>) oldInstance);
             return new Expression(oldInstance, Collections.class, "unmodifiableSet", new Object[]{set});
         }
     }
 
     static final class UnmodifiableSortedSet_PersistenceDelegate extends java_util_Collections {
         protected Expression instantiate(Object oldInstance, Encoder out) {
-            SortedSet set = new TreeSet((SortedSet) oldInstance);
+            SortedSet<?> set = new TreeSet<>((SortedSet<?>) oldInstance);
             return new Expression(oldInstance, Collections.class, "unmodifiableSortedSet", new Object[]{set});
         }
     }
 
     static final class UnmodifiableMap_PersistenceDelegate extends java_util_Collections {
         protected Expression instantiate(Object oldInstance, Encoder out) {
-            Map map = new HashMap((Map) oldInstance);
+            Map<?,?> map = new HashMap<>((Map<?,?>) oldInstance);
             return new Expression(oldInstance, Collections.class, "unmodifiableMap", new Object[]{map});
         }
     }
 
     static final class UnmodifiableSortedMap_PersistenceDelegate extends java_util_Collections {
         protected Expression instantiate(Object oldInstance, Encoder out) {
-            SortedMap map = new TreeMap((SortedMap) oldInstance);
+            SortedMap<?,?> map = new TreeMap<>((SortedMap<?,?>) oldInstance);
             return new Expression(oldInstance, Collections.class, "unmodifiableSortedMap", new Object[]{map});
         }
     }
 
     static final class SynchronizedCollection_PersistenceDelegate extends java_util_Collections {
         protected Expression instantiate(Object oldInstance, Encoder out) {
-            List list = new ArrayList((Collection) oldInstance);
+            List<?> list = new ArrayList<>((Collection<?>) oldInstance);
             return new Expression(oldInstance, Collections.class, "synchronizedCollection", new Object[]{list});
         }
     }
 
     static final class SynchronizedList_PersistenceDelegate extends java_util_Collections {
         protected Expression instantiate(Object oldInstance, Encoder out) {
-            List list = new LinkedList((Collection) oldInstance);
+            List<?> list = new LinkedList<>((Collection<?>) oldInstance);
             return new Expression(oldInstance, Collections.class, "synchronizedList", new Object[]{list});
         }
     }
 
     static final class SynchronizedRandomAccessList_PersistenceDelegate extends java_util_Collections {
         protected Expression instantiate(Object oldInstance, Encoder out) {
-            List list = new ArrayList((Collection) oldInstance);
+            List<?> list = new ArrayList<>((Collection<?>) oldInstance);
             return new Expression(oldInstance, Collections.class, "synchronizedList", new Object[]{list});
         }
     }
 
     static final class SynchronizedSet_PersistenceDelegate extends java_util_Collections {
         protected Expression instantiate(Object oldInstance, Encoder out) {
-            Set set = new HashSet((Set) oldInstance);
+            Set<?> set = new HashSet<>((Set<?>) oldInstance);
             return new Expression(oldInstance, Collections.class, "synchronizedSet", new Object[]{set});
         }
     }
 
     static final class SynchronizedSortedSet_PersistenceDelegate extends java_util_Collections {
         protected Expression instantiate(Object oldInstance, Encoder out) {
-            SortedSet set = new TreeSet((SortedSet) oldInstance);
+            SortedSet<?> set = new TreeSet<>((SortedSet<?>) oldInstance);
             return new Expression(oldInstance, Collections.class, "synchronizedSortedSet", new Object[]{set});
         }
     }
 
     static final class SynchronizedMap_PersistenceDelegate extends java_util_Collections {
         protected Expression instantiate(Object oldInstance, Encoder out) {
-            Map map = new HashMap((Map) oldInstance);
+            Map<?,?> map = new HashMap<>((Map<?,?>) oldInstance);
             return new Expression(oldInstance, Collections.class, "synchronizedMap", new Object[]{map});
         }
     }
 
     static final class SynchronizedSortedMap_PersistenceDelegate extends java_util_Collections {
         protected Expression instantiate(Object oldInstance, Encoder out) {
-            SortedMap map = new TreeMap((SortedMap) oldInstance);
+            SortedMap<?,?> map = new TreeMap<>((SortedMap<?,?>) oldInstance);
             return new Expression(oldInstance, Collections.class, "synchronizedSortedMap", new Object[]{map});
         }
     }
@@ -508,7 +508,7 @@
     static final class CheckedCollection_PersistenceDelegate extends java_util_Collections {
         protected Expression instantiate(Object oldInstance, Encoder out) {
             Object type = MetaData.getPrivateFieldValue(oldInstance, "java.util.Collections$CheckedCollection.type");
-            List list = new ArrayList((Collection) oldInstance);
+            List<?> list = new ArrayList<>((Collection<?>) oldInstance);
             return new Expression(oldInstance, Collections.class, "checkedCollection", new Object[]{list, type});
         }
     }
@@ -516,7 +516,7 @@
     static final class CheckedList_PersistenceDelegate extends java_util_Collections {
         protected Expression instantiate(Object oldInstance, Encoder out) {
             Object type = MetaData.getPrivateFieldValue(oldInstance, "java.util.Collections$CheckedCollection.type");
-            List list = new LinkedList((Collection) oldInstance);
+            List<?> list = new LinkedList<>((Collection<?>) oldInstance);
             return new Expression(oldInstance, Collections.class, "checkedList", new Object[]{list, type});
         }
     }
@@ -524,7 +524,7 @@
     static final class CheckedRandomAccessList_PersistenceDelegate extends java_util_Collections {
         protected Expression instantiate(Object oldInstance, Encoder out) {
             Object type = MetaData.getPrivateFieldValue(oldInstance, "java.util.Collections$CheckedCollection.type");
-            List list = new ArrayList((Collection) oldInstance);
+            List<?> list = new ArrayList<>((Collection<?>) oldInstance);
             return new Expression(oldInstance, Collections.class, "checkedList", new Object[]{list, type});
         }
     }
@@ -532,7 +532,7 @@
     static final class CheckedSet_PersistenceDelegate extends java_util_Collections {
         protected Expression instantiate(Object oldInstance, Encoder out) {
             Object type = MetaData.getPrivateFieldValue(oldInstance, "java.util.Collections$CheckedCollection.type");
-            Set set = new HashSet((Set) oldInstance);
+            Set<?> set = new HashSet<>((Set<?>) oldInstance);
             return new Expression(oldInstance, Collections.class, "checkedSet", new Object[]{set, type});
         }
     }
@@ -540,7 +540,7 @@
     static final class CheckedSortedSet_PersistenceDelegate extends java_util_Collections {
         protected Expression instantiate(Object oldInstance, Encoder out) {
             Object type = MetaData.getPrivateFieldValue(oldInstance, "java.util.Collections$CheckedCollection.type");
-            SortedSet set = new TreeSet((SortedSet) oldInstance);
+            SortedSet<?> set = new TreeSet<>((SortedSet<?>) oldInstance);
             return new Expression(oldInstance, Collections.class, "checkedSortedSet", new Object[]{set, type});
         }
     }
@@ -549,7 +549,7 @@
         protected Expression instantiate(Object oldInstance, Encoder out) {
             Object keyType   = MetaData.getPrivateFieldValue(oldInstance, "java.util.Collections$CheckedMap.keyType");
             Object valueType = MetaData.getPrivateFieldValue(oldInstance, "java.util.Collections$CheckedMap.valueType");
-            Map map = new HashMap((Map) oldInstance);
+            Map<?,?> map = new HashMap<>((Map<?,?>) oldInstance);
             return new Expression(oldInstance, Collections.class, "checkedMap", new Object[]{map, keyType, valueType});
         }
     }
@@ -558,7 +558,7 @@
         protected Expression instantiate(Object oldInstance, Encoder out) {
             Object keyType   = MetaData.getPrivateFieldValue(oldInstance, "java.util.Collections$CheckedMap.keyType");
             Object valueType = MetaData.getPrivateFieldValue(oldInstance, "java.util.Collections$CheckedMap.valueType");
-            SortedMap map = new TreeMap((SortedMap) oldInstance);
+            SortedMap<?,?> map = new TreeMap<>((SortedMap<?,?>) oldInstance);
             return new Expression(oldInstance, Collections.class, "checkedSortedMap", new Object[]{map, keyType, valueType});
         }
     }
@@ -605,13 +605,13 @@
 // Collection
 class java_util_Collection_PersistenceDelegate extends DefaultPersistenceDelegate {
     protected void initialize(Class<?> type, Object oldInstance, Object newInstance, Encoder out) {
-        java.util.Collection oldO = (java.util.Collection)oldInstance;
-        java.util.Collection newO = (java.util.Collection)newInstance;
+        java.util.Collection<?> oldO = (java.util.Collection)oldInstance;
+        java.util.Collection<?> newO = (java.util.Collection)newInstance;
 
         if (newO.size() != 0) {
             invokeStatement(oldInstance, "clear", new Object[]{}, out);
         }
-        for (Iterator i = oldO.iterator(); i.hasNext();) {
+        for (Iterator<?> i = oldO.iterator(); i.hasNext();) {
             invokeStatement(oldInstance, "add", new Object[]{i.next()}, out);
         }
     }
@@ -620,8 +620,8 @@
 // List
 class java_util_List_PersistenceDelegate extends DefaultPersistenceDelegate {
     protected void initialize(Class<?> type, Object oldInstance, Object newInstance, Encoder out) {
-        java.util.List oldO = (java.util.List)oldInstance;
-        java.util.List newO = (java.util.List)newInstance;
+        java.util.List<?> oldO = (java.util.List<?>)oldInstance;
+        java.util.List<?> newO = (java.util.List<?>)newInstance;
         int oldSize = oldO.size();
         int newSize = (newO == null) ? 0 : newO.size();
         if (oldSize < newSize) {
@@ -656,8 +656,8 @@
 class java_util_Map_PersistenceDelegate extends DefaultPersistenceDelegate {
     protected void initialize(Class<?> type, Object oldInstance, Object newInstance, Encoder out) {
         // System.out.println("Initializing: " + newInstance);
-        java.util.Map oldMap = (java.util.Map)oldInstance;
-        java.util.Map newMap = (java.util.Map)newInstance;
+        java.util.Map<?,?> oldMap = (java.util.Map)oldInstance;
+        java.util.Map<?,?> newMap = (java.util.Map)newInstance;
         // Remove the new elements.
         // Do this first otherwise we undo the adding work.
         if (newMap != null) {
@@ -746,9 +746,9 @@
         int style = Font.PLAIN;
         int size = 12;
 
-        Map basic = font.getAttributes();
-        Map clone = new HashMap(basic.size());
-        for (Object key : basic.keySet()) {
+        Map<TextAttribute, ?> basic = font.getAttributes();
+        Map<TextAttribute, Object> clone = new HashMap<>(basic.size());
+        for (TextAttribute key : basic.keySet()) {
             Object value = basic.get(key);
             if (value != null) {
                 clone.put(key, value);
@@ -784,7 +784,7 @@
                 }
             }
         }
-        Class type = font.getClass();
+        Class<?> type = font.getClass();
         if (count == clone.size()) {
             return new Expression(font, type, "new", new Object[]{family, style, size});
         }
@@ -832,7 +832,7 @@
         if (args == null) {
             throw new IllegalStateException("Unsupported KeyStroke: " + key);
         }
-        Class type = key.getClass();
+        Class<?> type = key.getClass();
         String name = type.getName();
         // get short name of the class
         int index = name.lastIndexOf('.') + 1;
@@ -1057,12 +1057,12 @@
     protected void initialize(Class<?> type, Object oldInstance,
                               Object newInstance, Encoder out) {
         super.initialize(type, oldInstance, newInstance, out);
-        Hashtable tab = (Hashtable)ReflectionUtils.getPrivateField(oldInstance,
+        Hashtable<?,?> tab = (Hashtable<?,?>)ReflectionUtils.getPrivateField(oldInstance,
                                                                    java.awt.CardLayout.class,
                                                                    "tab",
                                                                    out.getExceptionListener());
         if (tab != null) {
-            for(Enumeration e = tab.keys(); e.hasMoreElements();) {
+            for(Enumeration<?> e = tab.keys(); e.hasMoreElements();) {
                 Object child = e.nextElement();
                 invokeStatement(oldInstance, "addLayoutComponent",
                                 new Object[]{child, (String)tab.get(child)}, out);
@@ -1076,12 +1076,12 @@
     protected void initialize(Class<?> type, Object oldInstance,
                               Object newInstance, Encoder out) {
         super.initialize(type, oldInstance, newInstance, out);
-        Hashtable comptable = (Hashtable)ReflectionUtils.getPrivateField(oldInstance,
+        Hashtable<?,?> comptable = (Hashtable<?,?>)ReflectionUtils.getPrivateField(oldInstance,
                                                  java.awt.GridBagLayout.class,
                                                  "comptable",
                                                  out.getExceptionListener());
         if (comptable != null) {
-            for(Enumeration e = comptable.keys(); e.hasMoreElements();) {
+            for(Enumeration<?> e = comptable.keys(); e.hasMoreElements();) {
                 Object child = e.nextElement();
                 invokeStatement(oldInstance, "addLayoutComponent",
                                 new Object[]{child, comptable.get(child)}, out);
@@ -1119,8 +1119,8 @@
     protected void initialize(Class<?> type, Object oldInstance, Object newInstance, Encoder out) {
         // Note, the "size" property will be set here.
         super.initialize(type, oldInstance, newInstance, out);
-        javax.swing.DefaultListModel m = (javax.swing.DefaultListModel)oldInstance;
-        javax.swing.DefaultListModel n = (javax.swing.DefaultListModel)newInstance;
+        javax.swing.DefaultListModel<?> m = (javax.swing.DefaultListModel<?>)oldInstance;
+        javax.swing.DefaultListModel<?> n = (javax.swing.DefaultListModel<?>)newInstance;
         for (int i = n.getSize(); i < m.getSize(); i++) {
             invokeStatement(oldInstance, "add", // Can also use "addElement".
                     new Object[]{m.getElementAt(i)}, out);
@@ -1132,7 +1132,7 @@
 class javax_swing_DefaultComboBoxModel_PersistenceDelegate extends DefaultPersistenceDelegate {
     protected void initialize(Class<?> type, Object oldInstance, Object newInstance, Encoder out) {
         super.initialize(type, oldInstance, newInstance, out);
-        javax.swing.DefaultComboBoxModel m = (javax.swing.DefaultComboBoxModel)oldInstance;
+        javax.swing.DefaultComboBoxModel<?> m = (javax.swing.DefaultComboBoxModel<?>)oldInstance;
         for (int i = 0; i < m.getSize(); i++) {
             invokeStatement(oldInstance, "addElement", new Object[]{m.getElementAt(i)}, out);
         }
@@ -1275,7 +1275,7 @@
 
 class MetaData {
     private static final Map<String,Field> fields = Collections.synchronizedMap(new WeakHashMap<String, Field>());
-    private static Hashtable internalPersistenceDelegates = new Hashtable();
+    private static Hashtable<String, PersistenceDelegate> internalPersistenceDelegates = new Hashtable<>();
 
     private static PersistenceDelegate nullPersistenceDelegate = new NullPersistenceDelegate();
     private static PersistenceDelegate enumPersistenceDelegate = new EnumPersistenceDelegate();
@@ -1308,6 +1308,7 @@
         internalPersistenceDelegates.put("java.util.RegularEnumSet", new java_util_EnumSet_PersistenceDelegate());
     }
 
+    @SuppressWarnings("rawtypes")
     public synchronized static PersistenceDelegate getPersistenceDelegate(Class type) {
         if (type == null) {
             return nullPersistenceDelegate;
@@ -1342,7 +1343,7 @@
         String typeName = type.getName();
         PersistenceDelegate pd = (PersistenceDelegate)getBeanAttribute(type, "persistenceDelegate");
         if (pd == null) {
-            pd = (PersistenceDelegate)internalPersistenceDelegates.get(typeName);
+            pd = internalPersistenceDelegates.get(typeName);
             if (pd != null) {
                 return pd;
             }
@@ -1369,7 +1370,7 @@
         return (pd != null) ? pd : defaultPersistenceDelegate;
     }
 
-    private static String[] getConstructorProperties(Class type) {
+    private static String[] getConstructorProperties(Class<?> type) {
         String[] names = null;
         int length = 0;
         for (Constructor<?> constructor : type.getConstructors()) {
@@ -1402,7 +1403,7 @@
         return true;
     }
 
-    private static Object getBeanAttribute(Class type, String attribute) {
+    private static Object getBeanAttribute(Class<?> type, String attribute) {
         try {
             return Introspector.getBeanInfo(type).getBeanDescriptor().getValue(attribute);
         } catch (IntrospectionException exception) {
diff --git a/jdk/src/share/classes/java/beans/MethodDescriptor.java b/jdk/src/share/classes/java/beans/MethodDescriptor.java
index d9e78be..ae26fb2 100644
--- a/jdk/src/share/classes/java/beans/MethodDescriptor.java
+++ b/jdk/src/share/classes/java/beans/MethodDescriptor.java
@@ -42,7 +42,7 @@
 
     private String[] paramNames;
 
-    private List params;
+    private List<WeakReference<Class<?>>> params;
 
     private ParameterDescriptor parameterDescriptors[];
 
@@ -81,10 +81,10 @@
     public synchronized Method getMethod() {
         Method method = getMethod0();
         if (method == null) {
-            Class cls = getClass0();
+            Class<?> cls = getClass0();
             String name = getName();
             if ((cls != null) && (name != null)) {
-                Class[] params = getParams();
+                Class<?>[] params = getParams();
                 if (params == null) {
                     for (int i = 0; i < 3; i++) {
                         // Find methods for up to 2 params. We are guessing here.
@@ -121,15 +121,15 @@
                 : null;
     }
 
-    private synchronized void setParams(Class[] param) {
+    private synchronized void setParams(Class<?>[] param) {
         if (param == null) {
             return;
         }
         paramNames = new String[param.length];
-        params = new ArrayList(param.length);
+        params = new ArrayList<>(param.length);
         for (int i = 0; i < param.length; i++) {
             paramNames[i] = param[i].getName();
-            params.add(new WeakReference(param[i]));
+            params.add(new WeakReference<Class<?>>(param[i]));
         }
     }
 
@@ -138,12 +138,12 @@
         return paramNames;
     }
 
-    private synchronized Class[] getParams() {
-        Class[] clss = new Class[params.size()];
+    private synchronized Class<?>[] getParams() {
+        Class<?>[] clss = new Class<?>[params.size()];
 
         for (int i = 0; i < params.size(); i++) {
-            Reference ref = (Reference)params.get(i);
-            Class cls = (Class)ref.get();
+            Reference<? extends Class<?>> ref = (Reference<? extends Class<?>>)params.get(i);
+            Class<?> cls = ref.get();
             if (cls == null) {
                 return null;
             } else {
diff --git a/jdk/src/share/classes/java/beans/NameGenerator.java b/jdk/src/share/classes/java/beans/NameGenerator.java
index 3fa7f52..ddc1b21 100644
--- a/jdk/src/share/classes/java/beans/NameGenerator.java
+++ b/jdk/src/share/classes/java/beans/NameGenerator.java
@@ -43,12 +43,12 @@
  */
 class NameGenerator {
 
-    private Map valueToName;
-    private Map nameToCount;
+    private Map<Object, String> valueToName;
+    private Map<String, Integer> nameToCount;
 
     public NameGenerator() {
-        valueToName = new IdentityHashMap();
-        nameToCount = new HashMap();
+        valueToName = new IdentityHashMap<>();
+        nameToCount = new HashMap<>();
     }
 
     /**
@@ -63,6 +63,7 @@
     /**
      * Returns the root name of the class.
      */
+    @SuppressWarnings("rawtypes")
     public static String unqualifiedClassName(Class type) {
         if (type.isArray()) {
             return unqualifiedClassName(type.getComponentType())+"Array";
@@ -97,15 +98,15 @@
             return unqualifiedClassName((Class)instance);
         }
         else {
-            String result = (String)valueToName.get(instance);
+            String result = valueToName.get(instance);
             if (result != null) {
                 return result;
             }
-            Class type = instance.getClass();
+            Class<?> type = instance.getClass();
             String className = unqualifiedClassName(type);
 
-            Object size = nameToCount.get(className);
-            int instanceNumber = (size == null) ? 0 : ((Integer)size).intValue() + 1;
+            Integer size = nameToCount.get(className);
+            int instanceNumber = (size == null) ? 0 : (size).intValue() + 1;
             nameToCount.put(className, new Integer(instanceNumber));
 
             result = className + instanceNumber;
diff --git a/jdk/src/share/classes/java/beans/PersistenceDelegate.java b/jdk/src/share/classes/java/beans/PersistenceDelegate.java
index f8622c1..01c5bb1 100644
--- a/jdk/src/share/classes/java/beans/PersistenceDelegate.java
+++ b/jdk/src/share/classes/java/beans/PersistenceDelegate.java
@@ -207,7 +207,7 @@
                               Object oldInstance, Object newInstance,
                               Encoder out)
     {
-        Class superType = type.getSuperclass();
+        Class<?> superType = type.getSuperclass();
         PersistenceDelegate info = out.getPersistenceDelegate(superType);
         info.initialize(superType, oldInstance, newInstance, out);
     }
diff --git a/jdk/src/share/classes/java/beans/PropertyChangeEvent.java b/jdk/src/share/classes/java/beans/PropertyChangeEvent.java
index 55397ef..eeaa651 100644
--- a/jdk/src/share/classes/java/beans/PropertyChangeEvent.java
+++ b/jdk/src/share/classes/java/beans/PropertyChangeEvent.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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
@@ -25,6 +25,8 @@
 
 package java.beans;
 
+import java.util.EventObject;
+
 /**
  * A "PropertyChange" event gets delivered whenever a bean changes a "bound"
  * or "constrained" property.  A PropertyChangeEvent object is sent as an
@@ -42,21 +44,21 @@
  * arbitrary set of if its properties have changed.  In this case the
  * old and new values should also be null.
  */
-
-public class PropertyChangeEvent extends java.util.EventObject {
+public class PropertyChangeEvent extends EventObject {
     private static final long serialVersionUID = 7042693688939648123L;
 
     /**
-     * Constructs a new <code>PropertyChangeEvent</code>.
+     * Constructs a new {@code PropertyChangeEvent}.
      *
-     * @param source  The bean that fired the event.
-     * @param propertyName  The programmatic name of the property
-     *          that was changed.
-     * @param oldValue  The old value of the property.
-     * @param newValue  The new value of the property.
+     * @param source        the bean that fired the event
+     * @param propertyName  the programmatic name of the property that was changed
+     * @param oldValue      the old value of the property
+     * @param newValue      the new value of the property
+     *
+     * @throws IllegalArgumentException if {@code source} is {@code null}
      */
     public PropertyChangeEvent(Object source, String propertyName,
-                                     Object oldValue, Object newValue) {
+                               Object oldValue, Object newValue) {
         super(source);
         this.propertyName = propertyName;
         this.newValue = newValue;
diff --git a/jdk/src/share/classes/java/beans/PropertyChangeSupport.java b/jdk/src/share/classes/java/beans/PropertyChangeSupport.java
index db5b613..1ea326e 100644
--- a/jdk/src/share/classes/java/beans/PropertyChangeSupport.java
+++ b/jdk/src/share/classes/java/beans/PropertyChangeSupport.java
@@ -431,7 +431,7 @@
                     listeners = entry.getValue();
                 } else {
                     if (children == null) {
-                        children = new Hashtable<String, PropertyChangeSupport>();
+                        children = new Hashtable<>();
                     }
                     PropertyChangeSupport pcs = new PropertyChangeSupport(this.source);
                     pcs.map.set(null, entry.getValue());
@@ -460,6 +460,7 @@
 
         ObjectInputStream.GetField fields = s.readFields();
 
+        @SuppressWarnings("unchecked")
         Hashtable<String, PropertyChangeSupport> children = (Hashtable<String, PropertyChangeSupport>) fields.get("children", null);
         this.source = fields.get("source", null);
         fields.get("propertyChangeSupportSerializedDataVersion", 2);
diff --git a/jdk/src/share/classes/java/beans/PropertyDescriptor.java b/jdk/src/share/classes/java/beans/PropertyDescriptor.java
index 429d2b4..6abe8a0 100644
--- a/jdk/src/share/classes/java/beans/PropertyDescriptor.java
+++ b/jdk/src/share/classes/java/beans/PropertyDescriptor.java
@@ -35,10 +35,10 @@
  */
 public class PropertyDescriptor extends FeatureDescriptor {
 
-    private Reference<Class> propertyTypeRef;
+    private Reference<? extends Class<?>> propertyTypeRef;
     private Reference<Method> readMethodRef;
     private Reference<Method> writeMethodRef;
-    private Reference<Class> propertyEditorClassRef;
+    private Reference<? extends Class<?>> propertyEditorClassRef;
 
     private boolean bound;
     private boolean constrained;
@@ -174,7 +174,7 @@
      *         or {@code null} if the type cannot be determined
      */
     public synchronized Class<?> getPropertyType() {
-        Class type = getPropertyType0();
+        Class<?> type = getPropertyType0();
         if (type  == null) {
             try {
                 type = findPropertyType(getReadMethod(), getWriteMethod());
@@ -186,11 +186,11 @@
         return type;
     }
 
-    private void setPropertyType(Class type) {
+    private void setPropertyType(Class<?> type) {
         this.propertyTypeRef = getWeakReference(type);
     }
 
-    private Class getPropertyType0() {
+    private Class<?> getPropertyType0() {
         return (this.propertyTypeRef != null)
                 ? this.propertyTypeRef.get()
                 : null;
@@ -205,13 +205,13 @@
     public synchronized Method getReadMethod() {
         Method readMethod = getReadMethod0();
         if (readMethod == null) {
-            Class cls = getClass0();
+            Class<?> cls = getClass0();
             if (cls == null || (readMethodName == null && readMethodRef == null)) {
                 // The read method was explicitly set to null.
                 return null;
             }
             if (readMethodName == null) {
-                Class type = getPropertyType0();
+                Class<?> type = getPropertyType0();
                 if (type == boolean.class || type == null) {
                     readMethodName = Introspector.IS_PREFIX + getBaseName();
                 } else {
@@ -268,14 +268,14 @@
     public synchronized Method getWriteMethod() {
         Method writeMethod = getWriteMethod0();
         if (writeMethod == null) {
-            Class cls = getClass0();
+            Class<?> cls = getClass0();
             if (cls == null || (writeMethodName == null && writeMethodRef == null)) {
                 // The write method was explicitly set to null.
                 return null;
             }
 
             // We need the type to fetch the correct method.
-            Class type = getPropertyType0();
+            Class<?> type = getPropertyType0();
             if (type == null) {
                 try {
                     // Can't use getPropertyType since it will lead to recursive loop.
@@ -292,7 +292,7 @@
                 writeMethodName = Introspector.SET_PREFIX + getBaseName();
             }
 
-            Class[] args = (type == null) ? null : new Class[] { type };
+            Class<?>[] args = (type == null) ? null : new Class<?>[] { type };
             writeMethod = Introspector.findMethod(cls, writeMethodName, 1, args);
             if (writeMethod != null) {
                 if (!writeMethod.getReturnType().equals(void.class)) {
@@ -344,7 +344,7 @@
     /**
      * Overridden to ensure that a super class doesn't take precedent
      */
-    void setClass0(Class clz) {
+    void setClass0(Class<?> clz) {
         if (getClass0() != null && clz.isAssignableFrom(getClass0())) {
             // dont replace a subclass with a superclass
             return;
@@ -402,7 +402,7 @@
      * @param propertyEditorClass  The Class for the desired PropertyEditor.
      */
     public void setPropertyEditorClass(Class<?> propertyEditorClass) {
-        this.propertyEditorClassRef = getWeakReference((Class)propertyEditorClass);
+        this.propertyEditorClassRef = getWeakReference(propertyEditorClass);
     }
 
     /**
@@ -437,12 +437,12 @@
     public PropertyEditor createPropertyEditor(Object bean) {
         Object editor = null;
 
-        Class cls = getPropertyEditorClass();
+        Class<?> cls = getPropertyEditorClass();
         if (cls != null) {
-            Constructor ctor = null;
+            Constructor<?> ctor = null;
             if (bean != null) {
                 try {
-                    ctor = cls.getConstructor(new Class[] { Object.class });
+                    ctor = cls.getConstructor(new Class<?>[] { Object.class });
                 } catch (Exception ex) {
                     // Fall through
                 }
@@ -454,10 +454,7 @@
                     editor = ctor.newInstance(new Object[] { bean });
                 }
             } catch (Exception ex) {
-                // A serious error has occured.
-                // Proably due to an invalid property editor.
-                throw new RuntimeException("PropertyEditor not instantiated",
-                                           ex);
+                // Fall through
             }
         }
         return (PropertyEditor)editor;
@@ -637,12 +634,12 @@
      *         read and write methods are null.
      * @throws IntrospectionException if the read or write method is invalid
      */
-    private Class findPropertyType(Method readMethod, Method writeMethod)
+    private Class<?> findPropertyType(Method readMethod, Method writeMethod)
         throws IntrospectionException {
-        Class propertyType = null;
+        Class<?> propertyType = null;
         try {
             if (readMethod != null) {
-                Class[] params = getParameterTypes(getClass0(), readMethod);
+                Class<?>[] params = getParameterTypes(getClass0(), readMethod);
                 if (params.length != 0) {
                     throw new IntrospectionException("bad read method arg count: "
                                                      + readMethod);
@@ -654,7 +651,7 @@
                 }
             }
             if (writeMethod != null) {
-                Class params[] = getParameterTypes(getClass0(), writeMethod);
+                Class<?>[] params = getParameterTypes(getClass0(), writeMethod);
                 if (params.length != 1) {
                     throw new IntrospectionException("bad write method arg count: "
                                                      + writeMethod);
diff --git a/jdk/src/share/classes/java/beans/PropertyEditorManager.java b/jdk/src/share/classes/java/beans/PropertyEditorManager.java
index 6bdfa95..3fee3f4 100644
--- a/jdk/src/share/classes/java/beans/PropertyEditorManager.java
+++ b/jdk/src/share/classes/java/beans/PropertyEditorManager.java
@@ -25,9 +25,6 @@
 
 package java.beans;
 
-import com.sun.beans.finder.PropertyEditorFinder;
-import sun.awt.AppContext;
-
 /**
  * The PropertyEditorManager can be used to locate a property editor for
  * any given type name.  This property editor must support the
@@ -55,8 +52,6 @@
 
 public class PropertyEditorManager {
 
-    private static final Object FINDER_KEY = new Object();
-
     /**
      * Registers an editor class to edit values of the given target class.
      * If the editor class is {@code null},
@@ -81,7 +76,7 @@
         if (sm != null) {
             sm.checkPropertiesAccess();
         }
-        getFinder().register(targetType, editorClass);
+        ThreadGroupContext.getContext().getPropertyEditorFinder().register(targetType, editorClass);
     }
 
     /**
@@ -92,7 +87,7 @@
      * The result is null if no suitable editor can be found.
      */
     public static PropertyEditor findEditor(Class<?> targetType) {
-        return getFinder().find(targetType);
+        return ThreadGroupContext.getContext().getPropertyEditorFinder().find(targetType);
     }
 
     /**
@@ -104,7 +99,7 @@
      *         e.g. Sun implementation initially sets to  {"sun.beans.editors"}.
      */
     public static String[] getEditorSearchPath() {
-        return getFinder().getPackages();
+        return ThreadGroupContext.getContext().getPropertyEditorFinder().getPackages();
     }
 
     /**
@@ -125,17 +120,6 @@
         if (sm != null) {
             sm.checkPropertiesAccess();
         }
-        getFinder().setPackages(path);
-    }
-
-    private static PropertyEditorFinder getFinder() {
-        AppContext context = AppContext.getAppContext();
-        Object object = context.get(FINDER_KEY);
-        if (object instanceof PropertyEditorFinder) {
-            return (PropertyEditorFinder) object;
-        }
-        PropertyEditorFinder finder = new PropertyEditorFinder();
-        context.put(FINDER_KEY, finder);
-        return finder;
+        ThreadGroupContext.getContext().getPropertyEditorFinder().setPackages(path);
     }
 }
diff --git a/jdk/src/share/classes/java/beans/PropertyEditorSupport.java b/jdk/src/share/classes/java/beans/PropertyEditorSupport.java
index 776b47e..246eca0 100644
--- a/jdk/src/share/classes/java/beans/PropertyEditorSupport.java
+++ b/jdk/src/share/classes/java/beans/PropertyEditorSupport.java
@@ -251,7 +251,7 @@
     public synchronized void addPropertyChangeListener(
                                 PropertyChangeListener listener) {
         if (listeners == null) {
-            listeners = new java.util.Vector();
+            listeners = new java.util.Vector<>();
         }
         listeners.addElement(listener);
     }
@@ -278,25 +278,30 @@
      * Report that we have been modified to any interested listeners.
      */
     public void firePropertyChange() {
-        java.util.Vector targets;
+        java.util.Vector<PropertyChangeListener> targets;
         synchronized (this) {
             if (listeners == null) {
                 return;
             }
-            targets = (java.util.Vector) listeners.clone();
+            targets = unsafeClone(listeners);
         }
         // Tell our listeners that "everything" has changed.
         PropertyChangeEvent evt = new PropertyChangeEvent(source, null, null, null);
 
         for (int i = 0; i < targets.size(); i++) {
-            PropertyChangeListener target = (PropertyChangeListener)targets.elementAt(i);
+            PropertyChangeListener target = targets.elementAt(i);
             target.propertyChange(evt);
         }
     }
 
+    @SuppressWarnings("unchecked")
+    private <T> java.util.Vector<T> unsafeClone(java.util.Vector<T> v) {
+        return (java.util.Vector<T>)v.clone();
+    }
+
     //----------------------------------------------------------------------
 
     private Object value;
     private Object source;
-    private java.util.Vector listeners;
+    private java.util.Vector<PropertyChangeListener> listeners;
 }
diff --git a/jdk/src/share/classes/java/beans/ReflectionUtils.java b/jdk/src/share/classes/java/beans/ReflectionUtils.java
index c1c9dca..9271827 100644
--- a/jdk/src/share/classes/java/beans/ReflectionUtils.java
+++ b/jdk/src/share/classes/java/beans/ReflectionUtils.java
@@ -32,10 +32,12 @@
  */
 class ReflectionUtils {
 
+    @SuppressWarnings("rawtypes")
     public static boolean isPrimitive(Class type) {
         return primitiveTypeFor(type) != null;
     }
 
+    @SuppressWarnings("rawtypes")
     public static Class primitiveTypeFor(Class wrapper) {
         if (wrapper == Boolean.class) return Boolean.TYPE;
         if (wrapper == Byte.class) return Byte.TYPE;
@@ -58,6 +60,7 @@
      * @param el an exception listener to handle exceptions; or null
      * @return value of the field; null if not found or an error is encountered
      */
+    @SuppressWarnings("rawtypes")
     public static Object getPrivateField(Object instance, Class cls,
                                          String name, ExceptionListener el) {
         try {
diff --git a/jdk/src/share/classes/java/beans/SimpleBeanInfo.java b/jdk/src/share/classes/java/beans/SimpleBeanInfo.java
index ddd6b02..88348ffd 100644
--- a/jdk/src/share/classes/java/beans/SimpleBeanInfo.java
+++ b/jdk/src/share/classes/java/beans/SimpleBeanInfo.java
@@ -116,10 +116,10 @@
      */
     public java.awt.Image loadImage(final String resourceName) {
         try {
-            final Class c = getClass();
+            final Class<?> c = getClass();
             java.awt.image.ImageProducer ip = (java.awt.image.ImageProducer)
                 java.security.AccessController.doPrivileged(
-                new java.security.PrivilegedAction() {
+                new java.security.PrivilegedAction<Object>() {
                     public Object run() {
                         java.net.URL url;
                         if ((url = c.getResource(resourceName)) == null) {
diff --git a/jdk/src/share/classes/java/beans/Statement.java b/jdk/src/share/classes/java/beans/Statement.java
index b6e1c2f..5ffccc3 100644
--- a/jdk/src/share/classes/java/beans/Statement.java
+++ b/jdk/src/share/classes/java/beans/Statement.java
@@ -212,7 +212,7 @@
         if (target == Class.class && methodName.equals("forName")) {
             return ClassFinder.resolveClass((String)arguments[0], this.loader);
         }
-        Class[] argClasses = new Class[arguments.length];
+        Class<?>[] argClasses = new Class<?>[arguments.length];
         for(int i = 0; i < arguments.length; i++) {
             argClasses[i] = (arguments[i] == null) ? null : arguments[i].getClass();
         }
diff --git a/jdk/src/share/classes/java/beans/ThreadGroupContext.java b/jdk/src/share/classes/java/beans/ThreadGroupContext.java
new file mode 100644
index 0000000..dc1d38a
--- /dev/null
+++ b/jdk/src/share/classes/java/beans/ThreadGroupContext.java
@@ -0,0 +1,133 @@
+/*
+ * 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.  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 java.beans;
+
+import com.sun.beans.finder.BeanInfoFinder;
+import com.sun.beans.finder.PropertyEditorFinder;
+
+import java.awt.GraphicsEnvironment;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.WeakHashMap;
+
+/**
+ * The {@code ThreadGroupContext} is an application-dependent
+ * context referenced by the specific {@link ThreadGroup}.
+ * This is a replacement for the {@link sun.awt.AppContext}.
+ *
+ * @author  Sergey Malenkov
+ */
+final class ThreadGroupContext {
+
+    private static final Map<ThreadGroup, ThreadGroupContext> contexts = new WeakHashMap<>();
+
+    /**
+     * Returns the appropriate {@code AppContext} for the caller,
+     * as determined by its {@code ThreadGroup}.
+     *
+     * @return  the application-dependent context
+     */
+    static ThreadGroupContext getContext() {
+        ThreadGroup group = Thread.currentThread().getThreadGroup();
+        synchronized (contexts) {
+            ThreadGroupContext context = contexts.get(group);
+            if (context == null) {
+                context = new ThreadGroupContext();
+                contexts.put(group, context);
+            }
+            return context;
+        }
+    }
+
+    private volatile boolean isDesignTime;
+    private volatile Boolean isGuiAvailable;
+
+    private Map<Class<?>, BeanInfo> beanInfoCache;
+    private BeanInfoFinder beanInfoFinder;
+    private PropertyEditorFinder propertyEditorFinder;
+
+
+    boolean isDesignTime() {
+        return this.isDesignTime;
+    }
+
+    void setDesignTime(boolean isDesignTime) {
+        this.isDesignTime = isDesignTime;
+    }
+
+
+    boolean isGuiAvailable() {
+        Boolean isGuiAvailable = this.isGuiAvailable;
+        return (isGuiAvailable != null)
+                ? isGuiAvailable.booleanValue()
+                : !GraphicsEnvironment.isHeadless();
+    }
+
+    void setGuiAvailable(boolean isGuiAvailable) {
+        this.isGuiAvailable = Boolean.valueOf(isGuiAvailable);
+    }
+
+
+    BeanInfo getBeanInfo(Class<?> type) {
+        return (this.beanInfoCache != null)
+                ? this.beanInfoCache.get(type)
+                : null;
+    }
+
+    BeanInfo putBeanInfo(Class<?> type, BeanInfo info) {
+        if (this.beanInfoCache == null) {
+            this.beanInfoCache = new WeakHashMap<>();
+        }
+        return this.beanInfoCache.put(type, info);
+    }
+
+    void removeBeanInfo(Class<?> type) {
+        if (this.beanInfoCache != null) {
+            this.beanInfoCache.remove(type);
+        }
+    }
+
+    void clearBeanInfoCache() {
+        if (this.beanInfoCache != null) {
+            this.beanInfoCache.clear();
+        }
+    }
+
+
+    synchronized BeanInfoFinder getBeanInfoFinder() {
+        if (this.beanInfoFinder == null) {
+            this.beanInfoFinder = new BeanInfoFinder();
+        }
+        return this.beanInfoFinder;
+    }
+
+    synchronized PropertyEditorFinder getPropertyEditorFinder() {
+        if (this.propertyEditorFinder == null) {
+            this.propertyEditorFinder = new PropertyEditorFinder();
+        }
+        return this.propertyEditorFinder;
+    }
+}
diff --git a/jdk/src/share/classes/java/beans/VetoableChangeSupport.java b/jdk/src/share/classes/java/beans/VetoableChangeSupport.java
index 4cb8f3f..318abd2 100644
--- a/jdk/src/share/classes/java/beans/VetoableChangeSupport.java
+++ b/jdk/src/share/classes/java/beans/VetoableChangeSupport.java
@@ -420,7 +420,7 @@
                     listeners = entry.getValue();
                 } else {
                     if (children == null) {
-                        children = new Hashtable<String, VetoableChangeSupport>();
+                        children = new Hashtable<>();
                     }
                     VetoableChangeSupport vcs = new VetoableChangeSupport(this.source);
                     vcs.map.set(null, entry.getValue());
@@ -449,7 +449,8 @@
 
         ObjectInputStream.GetField fields = s.readFields();
 
-        Hashtable<String, VetoableChangeSupport> children = (Hashtable<String, VetoableChangeSupport>) fields.get("children", null);
+        @SuppressWarnings("unchecked")
+        Hashtable<String, VetoableChangeSupport> children = (Hashtable<String, VetoableChangeSupport>)fields.get("children", null);
         this.source = fields.get("source", null);
         fields.get("vetoableChangeSupportSerializedDataVersion", 2);
 
diff --git a/jdk/src/share/classes/java/beans/XMLEncoder.java b/jdk/src/share/classes/java/beans/XMLEncoder.java
index 3866a63..21749e0 100644
--- a/jdk/src/share/classes/java/beans/XMLEncoder.java
+++ b/jdk/src/share/classes/java/beans/XMLEncoder.java
@@ -287,8 +287,8 @@
         this.declaration = declaration;
         this.indentation = indentation;
         this.out = new OutputStreamWriter(out, cs.newEncoder());
-        valueToExpression = new IdentityHashMap<Object, ValueData>();
-        targetToStatementList = new IdentityHashMap<Object, List<Statement>>();
+        valueToExpression = new IdentityHashMap<>();
+        targetToStatementList = new IdentityHashMap<>();
         nameGenerator = new NameGenerator();
     }
 
@@ -334,7 +334,7 @@
     private List<Statement> statementList(Object target) {
         List<Statement> list = targetToStatementList.get(target);
         if (list == null) {
-            list = new ArrayList<Statement>();
+            list = new ArrayList<>();
             targetToStatementList.put(target, list);
         }
         return list;
@@ -604,7 +604,7 @@
                 return;
             }
 
-            Class primitiveType = ReflectionUtils.primitiveTypeFor(value.getClass());
+            Class<?> primitiveType = ReflectionUtils.primitiveTypeFor(value.getClass());
             if (primitiveType != null && target == value.getClass() &&
                 methodName.equals("new")) {
                 String primitiveTypeName = primitiveType.getName();
diff --git a/jdk/src/share/classes/java/beans/beancontext/BeanContext.java b/jdk/src/share/classes/java/beans/beancontext/BeanContext.java
index 37f15f9..c621728 100644
--- a/jdk/src/share/classes/java/beans/beancontext/BeanContext.java
+++ b/jdk/src/share/classes/java/beans/beancontext/BeanContext.java
@@ -53,6 +53,7 @@
  * @see java.util.Collection
  */
 
+@SuppressWarnings("rawtypes")
 public interface BeanContext extends BeanContextChild, Collection, DesignMode, Visibility {
 
     /**
diff --git a/jdk/src/share/classes/java/beans/beancontext/BeanContextMembershipEvent.java b/jdk/src/share/classes/java/beans/beancontext/BeanContextMembershipEvent.java
index 0ed013a..6b5f4f5 100644
--- a/jdk/src/share/classes/java/beans/beancontext/BeanContextMembershipEvent.java
+++ b/jdk/src/share/classes/java/beans/beancontext/BeanContextMembershipEvent.java
@@ -65,6 +65,7 @@
      * @throws NullPointerException if <CODE>changes</CODE> is <CODE>null</CODE>
      */
 
+    @SuppressWarnings("rawtypes")
     public BeanContextMembershipEvent(BeanContext bc, Collection changes) {
         super(bc);
 
@@ -117,6 +118,7 @@
      * Gets the array of children affected by this event.
      * @return the array of children effected
      */
+    @SuppressWarnings("rawtypes")
     public Iterator iterator() { return children.iterator(); }
 
     /*
@@ -127,5 +129,6 @@
     * The list of children affected by this
     * event notification.
     */
+    @SuppressWarnings("rawtypes")
     protected Collection children;
 }
diff --git a/jdk/src/share/classes/java/io/ExpiringCache.java b/jdk/src/share/classes/java/io/ExpiringCache.java
index 8c07afb..42c9ce2 100644
--- a/jdk/src/share/classes/java/io/ExpiringCache.java
+++ b/jdk/src/share/classes/java/io/ExpiringCache.java
@@ -35,7 +35,7 @@
 
 class ExpiringCache {
     private long millisUntilExpiration;
-    private Map  map;
+    private Map<String,Entry> map;
     // Clear out old entries every few queries
     private int queryCount;
     private int queryOverflow = 300;
@@ -61,10 +61,11 @@
         this(30000);
     }
 
+    @SuppressWarnings("serial")
     ExpiringCache(long millisUntilExpiration) {
         this.millisUntilExpiration = millisUntilExpiration;
-        map = new LinkedHashMap() {
-            protected boolean removeEldestEntry(Map.Entry eldest) {
+        map = new LinkedHashMap<String,Entry>() {
+            protected boolean removeEldestEntry(Map.Entry<String,Entry> eldest) {
               return size() > MAX_ENTRIES;
             }
           };
@@ -99,7 +100,7 @@
     }
 
     private Entry entryFor(String key) {
-        Entry entry = (Entry) map.get(key);
+        Entry entry = map.get(key);
         if (entry != null) {
             long delta = System.currentTimeMillis() - entry.timestamp();
             if (delta < 0 || delta >= millisUntilExpiration) {
@@ -111,12 +112,11 @@
     }
 
     private void cleanup() {
-        Set keySet = map.keySet();
+        Set<String> keySet = map.keySet();
         // Avoid ConcurrentModificationExceptions
         String[] keys = new String[keySet.size()];
         int i = 0;
-        for (Iterator iter = keySet.iterator(); iter.hasNext(); ) {
-            String key = (String) iter.next();
+        for (String key: keySet) {
             keys[i++] = key;
         }
         for (int j = 0; j < keys.length; j++) {
diff --git a/jdk/src/share/classes/java/io/File.java b/jdk/src/share/classes/java/io/File.java
index 4b9d389..fba80c2 100644
--- a/jdk/src/share/classes/java/io/File.java
+++ b/jdk/src/share/classes/java/io/File.java
@@ -2006,7 +2006,7 @@
         throws IOException
     {
         s.defaultWriteObject();
-        s.writeChar(this.separatorChar); // Add the separator character
+        s.writeChar(separatorChar); // Add the separator character
     }
 
     /**
diff --git a/jdk/src/share/classes/java/io/LineNumberInputStream.java b/jdk/src/share/classes/java/io/LineNumberInputStream.java
index d3b5d9b..11cfdf8 100644
--- a/jdk/src/share/classes/java/io/LineNumberInputStream.java
+++ b/jdk/src/share/classes/java/io/LineNumberInputStream.java
@@ -87,6 +87,7 @@
      * @see        java.io.FilterInputStream#in
      * @see        java.io.LineNumberInputStream#getLineNumber()
      */
+    @SuppressWarnings("fallthrough")
     public int read() throws IOException {
         int c = pushBack;
 
diff --git a/jdk/src/share/classes/java/io/LineNumberReader.java b/jdk/src/share/classes/java/io/LineNumberReader.java
index 31f1e87..40a0272 100644
--- a/jdk/src/share/classes/java/io/LineNumberReader.java
+++ b/jdk/src/share/classes/java/io/LineNumberReader.java
@@ -120,6 +120,7 @@
      * @throws  IOException
      *          If an I/O error occurs
      */
+    @SuppressWarnings("fallthrough")
     public int read() throws IOException {
         synchronized (lock) {
             int c = super.read();
@@ -159,6 +160,7 @@
      * @throws  IOException
      *          If an I/O error occurs
      */
+    @SuppressWarnings("fallthrough")
     public int read(char cbuf[], int off, int len) throws IOException {
         synchronized (lock) {
             int n = super.read(cbuf, off, len);
diff --git a/jdk/src/share/classes/java/io/ObjectInputStream.java b/jdk/src/share/classes/java/io/ObjectInputStream.java
index 04705e6..1963187 100644
--- a/jdk/src/share/classes/java/io/ObjectInputStream.java
+++ b/jdk/src/share/classes/java/io/ObjectInputStream.java
@@ -689,9 +689,9 @@
         boolean hasNonPublicInterface = false;
 
         // define proxy in class loader of non-public interface(s), if any
-        Class[] classObjs = new Class[interfaces.length];
+        Class<?>[] classObjs = new Class<?>[interfaces.length];
         for (int i = 0; i < interfaces.length; i++) {
-            Class cl = Class.forName(interfaces[i], false, latestLoader);
+            Class<?> cl = Class.forName(interfaces[i], false, latestLoader);
             if ((cl.getModifiers() & Modifier.PUBLIC) == 0) {
                 if (hasNonPublicInterface) {
                     if (nonPublicLoader != cl.getClassLoader()) {
@@ -1229,7 +1229,7 @@
      * "enableSubclassImplementation" SerializablePermission is checked.
      */
     private void verifySubclass() {
-        Class cl = getClass();
+        Class<?> cl = getClass();
         if (cl == ObjectInputStream.class) {
             return;
         }
@@ -1473,12 +1473,12 @@
      * ClassNotFoundException will be associated with the class' handle in the
      * handle table).
      */
-    private Class readClass(boolean unshared) throws IOException {
+    private Class<?> readClass(boolean unshared) throws IOException {
         if (bin.readByte() != TC_CLASS) {
             throw new InternalError();
         }
         ObjectStreamClass desc = readClassDesc(false);
-        Class cl = desc.forClass();
+        Class<?> cl = desc.forClass();
         passHandle = handles.assign(unshared ? unsharedMarker : cl);
 
         ClassNotFoundException resolveEx = desc.getResolveException();
@@ -1542,7 +1542,7 @@
             ifaces[i] = bin.readUTF();
         }
 
-        Class cl = null;
+        Class<?> cl = null;
         ClassNotFoundException resolveEx = null;
         bin.setBlockDataMode(true);
         try {
@@ -1586,7 +1586,7 @@
                 "failed to read class descriptor").initCause(ex);
         }
 
-        Class cl = null;
+        Class<?> cl = null;
         ClassNotFoundException resolveEx = null;
         bin.setBlockDataMode(true);
         try {
@@ -1643,7 +1643,7 @@
         int len = bin.readInt();
 
         Object array = null;
-        Class cl, ccl = null;
+        Class<?> cl, ccl = null;
         if ((cl = desc.forClass()) != null) {
             ccl = cl.getComponentType();
             array = Array.newInstance(ccl, len);
@@ -1696,7 +1696,7 @@
      * Reads in and returns enum constant, or null if enum type is
      * unresolvable.  Sets passHandle to enum constant's assigned handle.
      */
-    private Enum readEnum(boolean unshared) throws IOException {
+    private Enum<?> readEnum(boolean unshared) throws IOException {
         if (bin.readByte() != TC_ENUM) {
             throw new InternalError();
         }
@@ -1713,24 +1713,26 @@
         }
 
         String name = readString(false);
-        Enum en = null;
-        Class cl = desc.forClass();
+        Enum<?> result = null;
+        Class<?> cl = desc.forClass();
         if (cl != null) {
             try {
-                en = Enum.valueOf(cl, name);
+                @SuppressWarnings("unchecked")
+                Enum<?> en = Enum.valueOf((Class)cl, name);
+                result = en;
             } catch (IllegalArgumentException ex) {
                 throw (IOException) new InvalidObjectException(
                     "enum constant " + name + " does not exist in " +
                     cl).initCause(ex);
             }
             if (!unshared) {
-                handles.setObject(enumHandle, en);
+                handles.setObject(enumHandle, result);
             }
         }
 
         handles.finish(enumHandle);
         passHandle = enumHandle;
-        return en;
+        return result;
     }
 
     /**
@@ -1941,7 +1943,7 @@
         throws IOException
     {
         // REMIND: is isInstance check necessary?
-        Class cl = desc.forClass();
+        Class<?> cl = desc.forClass();
         if (cl != null && obj != null && !cl.isInstance(obj)) {
             throw new ClassCastException();
         }
@@ -2140,7 +2142,7 @@
          * class descriptor, returns -1.  Throws IllegalArgumentException if
          * neither incoming nor local class descriptor contains a match.
          */
-        private int getFieldOffset(String name, Class type) {
+        private int getFieldOffset(String name, Class<?> type) {
             ObjectStreamField field = desc.getField(name, type);
             if (field != null) {
                 return field.getOffset();
@@ -2838,6 +2840,7 @@
             return readUTFBody(readUnsignedShort());
         }
 
+        @SuppressWarnings("deprecation")
         public String readLine() throws IOException {
             return din.readLine();      // deprecated, not worth optimizing
         }
diff --git a/jdk/src/share/classes/java/io/ObjectOutputStream.java b/jdk/src/share/classes/java/io/ObjectOutputStream.java
index 76a08f3..52e590f 100644
--- a/jdk/src/share/classes/java/io/ObjectOutputStream.java
+++ b/jdk/src/share/classes/java/io/ObjectOutputStream.java
@@ -1034,7 +1034,7 @@
      * "enableSubclassImplementation" SerializablePermission is checked.
      */
     private void verifySubclass() {
-        Class cl = getClass();
+        Class<?> cl = getClass();
         if (cl == ObjectOutputStream.class) {
             return;
         }
@@ -1060,22 +1060,22 @@
      * override security-sensitive non-final methods.  Returns true if subclass
      * is "safe", false otherwise.
      */
-    private static boolean auditSubclass(final Class subcl) {
+    private static boolean auditSubclass(final Class<?> subcl) {
         Boolean result = AccessController.doPrivileged(
             new PrivilegedAction<Boolean>() {
                 public Boolean run() {
-                    for (Class cl = subcl;
+                    for (Class<?> cl = subcl;
                          cl != ObjectOutputStream.class;
                          cl = cl.getSuperclass())
                     {
                         try {
                             cl.getDeclaredMethod(
-                                "writeUnshared", new Class[] { Object.class });
+                                "writeUnshared", new Class<?>[] { Object.class });
                             return Boolean.FALSE;
                         } catch (NoSuchMethodException ex) {
                         }
                         try {
-                            cl.getDeclaredMethod("putFields", (Class[]) null);
+                            cl.getDeclaredMethod("putFields", (Class<?>[]) null);
                             return Boolean.FALSE;
                         } catch (NoSuchMethodException ex) {
                         }
@@ -1122,11 +1122,11 @@
 
             // check for replacement object
             Object orig = obj;
-            Class cl = obj.getClass();
+            Class<?> cl = obj.getClass();
             ObjectStreamClass desc;
             for (;;) {
                 // REMIND: skip this check for strings/arrays?
-                Class repCl;
+                Class<?> repCl;
                 desc = ObjectStreamClass.lookup(cl, true);
                 if (!desc.hasWriteReplaceMethod() ||
                     (obj = desc.invokeWriteReplace(obj)) == null ||
@@ -1169,7 +1169,7 @@
             } else if (cl.isArray()) {
                 writeArray(obj, desc, unshared);
             } else if (obj instanceof Enum) {
-                writeEnum((Enum) obj, desc, unshared);
+                writeEnum((Enum<?>) obj, desc, unshared);
             } else if (obj instanceof Serializable) {
                 writeOrdinaryObject(obj, desc, unshared);
             } else {
@@ -1204,7 +1204,7 @@
     /**
      * Writes representation of given class to stream.
      */
-    private void writeClass(Class cl, boolean unshared) throws IOException {
+    private void writeClass(Class<?> cl, boolean unshared) throws IOException {
         bout.writeByte(TC_CLASS);
         writeClassDesc(ObjectStreamClass.lookup(cl, true), false);
         handles.assign(unshared ? null : cl);
@@ -1237,7 +1237,7 @@
         bout.writeByte(TC_PROXYCLASSDESC);
         handles.assign(unshared ? null : desc);
 
-        Class cl = desc.forClass();
+        Class<?> cl = desc.forClass();
         Class[] ifaces = cl.getInterfaces();
         bout.writeInt(ifaces.length);
         for (int i = 0; i < ifaces.length; i++) {
@@ -1269,7 +1269,7 @@
             writeClassDescriptor(desc);
         }
 
-        Class cl = desc.forClass();
+        Class<?> cl = desc.forClass();
         bout.setBlockDataMode(true);
         annotateClass(cl);
         bout.setBlockDataMode(false);
@@ -1306,7 +1306,7 @@
         writeClassDesc(desc, false);
         handles.assign(unshared ? null : array);
 
-        Class ccl = desc.forClass().getComponentType();
+        Class<?> ccl = desc.forClass().getComponentType();
         if (ccl.isPrimitive()) {
             if (ccl == Integer.TYPE) {
                 int[] ia = (int[]) array;
@@ -1377,7 +1377,7 @@
     /**
      * Writes given enum constant to stream.
      */
-    private void writeEnum(Enum en,
+    private void writeEnum(Enum<?> en,
                            ObjectStreamClass desc,
                            boolean unshared)
         throws IOException
@@ -1700,7 +1700,7 @@
          * types, and any other non-null type matches assignable types only.
          * Throws IllegalArgumentException if no matching field found.
          */
-        private int getFieldOffset(String name, Class type) {
+        private int getFieldOffset(String name, Class<?> type) {
             ObjectStreamField field = desc.getField(name, type);
             if (field == null) {
                 throw new IllegalArgumentException("no such field " + name +
diff --git a/jdk/src/share/classes/java/io/ObjectStreamClass.java b/jdk/src/share/classes/java/io/ObjectStreamClass.java
index f1c0d5b..1a03b6b 100644
--- a/jdk/src/share/classes/java/io/ObjectStreamClass.java
+++ b/jdk/src/share/classes/java/io/ObjectStreamClass.java
@@ -144,7 +144,7 @@
     private volatile ClassDataSlot[] dataLayout;
 
     /** serialization-appropriate constructor, or null if none */
-    private Constructor cons;
+    private Constructor<?> cons;
     /** class-defined writeObject method, or null if none */
     private Method writeObjectMethod;
     /** class-defined readObject method, or null if none */
@@ -1308,9 +1308,9 @@
      * Access checks are disabled on the returned constructor (if any), since
      * the defining class may still be non-public.
      */
-    private static Constructor getExternalizableConstructor(Class<?> cl) {
+    private static Constructor<?> getExternalizableConstructor(Class<?> cl) {
         try {
-            Constructor cons = cl.getDeclaredConstructor((Class<?>[]) null);
+            Constructor<?> cons = cl.getDeclaredConstructor((Class<?>[]) null);
             cons.setAccessible(true);
             return ((cons.getModifiers() & Modifier.PUBLIC) != 0) ?
                 cons : null;
@@ -1324,7 +1324,7 @@
      * superclass, or null if none found.  Access checks are disabled on the
      * returned constructor (if any).
      */
-    private static Constructor getSerializableConstructor(Class<?> cl) {
+    private static Constructor<?> getSerializableConstructor(Class<?> cl) {
         Class<?> initCl = cl;
         while (Serializable.class.isAssignableFrom(initCl)) {
             if ((initCl = initCl.getSuperclass()) == null) {
@@ -1332,7 +1332,7 @@
             }
         }
         try {
-            Constructor cons = initCl.getDeclaredConstructor((Class<?>[]) null);
+            Constructor<?> cons = initCl.getDeclaredConstructor((Class<?>[]) null);
             int mods = cons.getModifiers();
             if ((mods & Modifier.PRIVATE) != 0 ||
                 ((mods & (Modifier.PUBLIC | Modifier.PROTECTED)) == 0 &&
@@ -1802,7 +1802,7 @@
             signature = getClassSignature(field.getType());
         }
 
-        public MemberSignature(Constructor cons) {
+        public MemberSignature(Constructor<?> cons) {
             member = cons;
             name = cons.getName();
             signature = getMethodSignature(
diff --git a/jdk/src/share/classes/java/io/RandomAccessFile.java b/jdk/src/share/classes/java/io/RandomAccessFile.java
index 65bfbf4..893fc94 100644
--- a/jdk/src/share/classes/java/io/RandomAccessFile.java
+++ b/jdk/src/share/classes/java/io/RandomAccessFile.java
@@ -1049,6 +1049,7 @@
      * @param      s   a string of bytes to be written.
      * @exception  IOException  if an I/O error occurs.
      */
+    @SuppressWarnings("deprecation")
     public final void writeBytes(String s) throws IOException {
         int len = s.length();
         byte[] b = new byte[len];
diff --git a/jdk/src/share/classes/java/io/SequenceInputStream.java b/jdk/src/share/classes/java/io/SequenceInputStream.java
index f64ec38..efc3af7 100644
--- a/jdk/src/share/classes/java/io/SequenceInputStream.java
+++ b/jdk/src/share/classes/java/io/SequenceInputStream.java
@@ -44,7 +44,7 @@
  */
 public
 class SequenceInputStream extends InputStream {
-    Enumeration e;
+    Enumeration<? extends InputStream> e;
     InputStream in;
 
     /**
@@ -85,7 +85,7 @@
      * @param   s2   the second input stream to read.
      */
     public SequenceInputStream(InputStream s1, InputStream s2) {
-        Vector  v = new Vector(2);
+        Vector<InputStream> v = new Vector<>(2);
 
         v.addElement(s1);
         v.addElement(s2);
diff --git a/jdk/src/share/classes/java/lang/ClassLoader.java b/jdk/src/share/classes/java/lang/ClassLoader.java
index f8588f5..d599396 100644
--- a/jdk/src/share/classes/java/lang/ClassLoader.java
+++ b/jdk/src/share/classes/java/lang/ClassLoader.java
@@ -258,7 +258,7 @@
     private final Set<ProtectionDomain> domains;
 
     // Invoked by the VM to record every loaded class with this loader.
-    void addClass(Class c) {
+    void addClass(Class<?> c) {
         classes.addElement(c);
     }
 
@@ -402,7 +402,7 @@
     {
         synchronized (getClassLoadingLock(name)) {
             // First, check if the class has already been loaded
-            Class c = findLoadedClass(name);
+            Class<?> c = findLoadedClass(name);
             if (c == null) {
                 long t0 = System.nanoTime();
                 try {
@@ -468,7 +468,7 @@
     }
 
     // This method is invoked by the virtual machine to load a class.
-    private Class loadClassInternal(String name)
+    private Class<?> loadClassInternal(String name)
         throws ClassNotFoundException
     {
         // For backward compatibility, explicitly lock on 'this' when
@@ -483,7 +483,7 @@
     }
 
     // Invoked by the VM after loading class with this loader.
-    private void checkPackageAccess(Class cls, ProtectionDomain pd) {
+    private void checkPackageAccess(Class<?> cls, ProtectionDomain pd) {
         final SecurityManager sm = System.getSecurityManager();
         if (sm != null) {
             final String name = cls.getName();
@@ -669,9 +669,9 @@
         return source;
     }
 
-    private Class defineTransformedClass(String name, byte[] b, int off, int len,
-                                         ProtectionDomain pd,
-                                         ClassFormatError cfe, String source)
+    private Class<?> defineTransformedClass(String name, byte[] b, int off, int len,
+                                            ProtectionDomain pd,
+                                            ClassFormatError cfe, String source)
       throws ClassFormatError
     {
         // Class format error - try to transform the bytecode and
@@ -679,7 +679,7 @@
         //
         ClassFileTransformer[] transformers =
             ClassFileTransformer.getTransformers();
-        Class c = null;
+        Class<?> c = null;
 
         if (transformers != null) {
             for (ClassFileTransformer transformer : transformers) {
@@ -704,7 +704,7 @@
         return c;
     }
 
-    private void postDefineClass(Class c, ProtectionDomain pd)
+    private void postDefineClass(Class<?> c, ProtectionDomain pd)
     {
         if (pd.getCodeSource() != null) {
             Certificate certs[] = pd.getCodeSource().getCertificates();
@@ -784,7 +784,7 @@
     {
         protectionDomain = preDefineClass(name, protectionDomain);
 
-        Class c = null;
+        Class<?> c = null;
         String source = defineClassSourceLocation(protectionDomain);
 
         try {
@@ -882,7 +882,7 @@
 
         protectionDomain = preDefineClass(name, protectionDomain);
 
-        Class c = null;
+        Class<?> c = null;
         String source = defineClassSourceLocation(protectionDomain);
 
         try {
@@ -899,15 +899,15 @@
         return c;
     }
 
-    private native Class defineClass0(String name, byte[] b, int off, int len,
-                                      ProtectionDomain pd);
+    private native Class<?> defineClass0(String name, byte[] b, int off, int len,
+                                         ProtectionDomain pd);
 
-    private native Class defineClass1(String name, byte[] b, int off, int len,
-                                      ProtectionDomain pd, String source);
+    private native Class<?> defineClass1(String name, byte[] b, int off, int len,
+                                         ProtectionDomain pd, String source);
 
-    private native Class defineClass2(String name, java.nio.ByteBuffer b,
-                                      int off, int len, ProtectionDomain pd,
-                                      String source);
+    private native Class<?> defineClass2(String name, java.nio.ByteBuffer b,
+                                         int off, int len, ProtectionDomain pd,
+                                         String source);
 
     // true if the name is null or has the potential to be a valid binary name
     private boolean checkName(String name) {
@@ -1010,7 +1010,7 @@
         resolveClass0(c);
     }
 
-    private native void resolveClass0(Class c);
+    private native void resolveClass0(Class<?> c);
 
     /**
      * Finds a class with the specified <a href="#name">binary name</a>,
@@ -1041,7 +1041,7 @@
         if (system == null) {
             if (!checkName(name))
                 throw new ClassNotFoundException(name);
-            Class cls = findBootstrapClass(name);
+            Class<?> cls = findBootstrapClass(name);
             if (cls == null) {
                 throw new ClassNotFoundException(name);
             }
@@ -1054,7 +1054,7 @@
      * Returns a class loaded by the bootstrap class loader;
      * or return null if not found.
      */
-    private Class findBootstrapClassOrNull(String name)
+    private Class<?> findBootstrapClassOrNull(String name)
     {
         if (!checkName(name)) return null;
 
@@ -1062,7 +1062,7 @@
     }
 
     // return null if not found
-    private native Class findBootstrapClass(String name);
+    private native Class<?> findBootstrapClass(String name);
 
     /**
      * Returns the class with the given <a href="#name">binary name</a> if this
@@ -1084,7 +1084,7 @@
         return findLoadedClass0(name);
     }
 
-    private native final Class findLoadedClass0(String name);
+    private native final Class<?> findLoadedClass0(String name);
 
     /**
      * Sets the signers of a class.  This should be invoked after defining a
@@ -1528,7 +1528,7 @@
     // invocation and the desired invoker.
     static ClassLoader getCallerClassLoader() {
         // NOTE use of more generic Reflection.getCallerClass()
-        Class caller = Reflection.getCallerClass(3);
+        Class<?> caller = Reflection.getCallerClass(3);
         // This can be null if the VM is requesting it
         if (caller == null) {
             return null;
@@ -1722,7 +1722,7 @@
         private int jniVersion;
         // the class from which the library is loaded, also indicates
         // the loader this native library belongs.
-        private Class fromClass;
+        private Class<?> fromClass;
         // the canonicalized name of the native library.
         String name;
 
@@ -1730,7 +1730,7 @@
         native long find(String name);
         native void unload();
 
-        public NativeLibrary(Class fromClass, String name) {
+        public NativeLibrary(Class<?> fromClass, String name) {
             this.name = name;
             this.fromClass = fromClass;
         }
@@ -1758,7 +1758,7 @@
         }
         // Invoked in the VM to determine the context class in
         // JNI_Load/JNI_Unload
-        static Class getFromClass() {
+        static Class<?> getFromClass() {
             return ClassLoader.nativeLibraryContext.peek().fromClass;
         }
     }
@@ -1813,7 +1813,7 @@
     }
 
     // Invoked in the java.lang.Runtime class to implement load and loadLibrary.
-    static void loadLibrary(Class fromClass, String name,
+    static void loadLibrary(Class<?> fromClass, String name,
                             boolean isAbsolute) {
         ClassLoader loader =
             (fromClass == null) ? null : fromClass.getClassLoader();
@@ -1860,7 +1860,7 @@
         throw new UnsatisfiedLinkError("no " + name + " in java.library.path");
     }
 
-    private static boolean loadLibrary0(Class fromClass, final File file) {
+    private static boolean loadLibrary0(Class<?> fromClass, final File file) {
         boolean exists = AccessController.doPrivileged(
             new PrivilegedAction<Object>() {
                 public Object run() {
@@ -2194,8 +2194,8 @@
             return parent;
         }
 
-        Constructor ctor = Class.forName(cls, true, parent)
-            .getDeclaredConstructor(new Class[] { ClassLoader.class });
+        Constructor<?> ctor = Class.forName(cls, true, parent)
+            .getDeclaredConstructor(new Class<?>[] { ClassLoader.class });
         ClassLoader sys = (ClassLoader) ctor.newInstance(
             new Object[] { parent });
         Thread.currentThread().setContextClassLoader(sys);
diff --git a/jdk/src/share/classes/java/lang/Enum.java b/jdk/src/share/classes/java/lang/Enum.java
index 798ae3f..80fcd9c 100644
--- a/jdk/src/share/classes/java/lang/Enum.java
+++ b/jdk/src/share/classes/java/lang/Enum.java
@@ -173,8 +173,8 @@
      * method is the order in which the constants are declared.
      */
     public final int compareTo(E o) {
-        Enum other = (Enum)o;
-        Enum self = this;
+        Enum<?> other = (Enum<?>)o;
+        Enum<E> self = this;
         if (self.getClass() != other.getClass() && // optimization
             self.getDeclaringClass() != other.getDeclaringClass())
             throw new ClassCastException();
@@ -193,10 +193,11 @@
      * @return the Class object corresponding to this enum constant's
      *     enum type
      */
+    @SuppressWarnings("unchecked")
     public final Class<E> getDeclaringClass() {
-        Class clazz = getClass();
-        Class zuper = clazz.getSuperclass();
-        return (zuper == Enum.class) ? clazz : zuper;
+        Class<?> clazz = getClass();
+        Class<?> zuper = clazz.getSuperclass();
+        return (zuper == Enum.class) ? (Class<E>)clazz : (Class<E>)zuper;
     }
 
     /**
diff --git a/jdk/src/share/classes/java/lang/Package.java b/jdk/src/share/classes/java/lang/Package.java
index 3ea8013..f7af97a 100644
--- a/jdk/src/share/classes/java/lang/Package.java
+++ b/jdk/src/share/classes/java/lang/Package.java
@@ -608,5 +608,5 @@
     private final String implVendor;
     private final URL sealBase;
     private transient final ClassLoader loader;
-    private transient Class packageInfo;
+    private transient Class<?> packageInfo;
 }
diff --git a/jdk/src/share/classes/java/lang/Runtime.java b/jdk/src/share/classes/java/lang/Runtime.java
index 3fc29d0..7f2ef46 100644
--- a/jdk/src/share/classes/java/lang/Runtime.java
+++ b/jdk/src/share/classes/java/lang/Runtime.java
@@ -780,7 +780,7 @@
         load0(System.getCallerClass(), filename);
     }
 
-    synchronized void load0(Class fromClass, String filename) {
+    synchronized void load0(Class<?> fromClass, String filename) {
         SecurityManager security = System.getSecurityManager();
         if (security != null) {
             security.checkLink(filename);
@@ -833,7 +833,7 @@
         loadLibrary0(System.getCallerClass(), libname);
     }
 
-    synchronized void loadLibrary0(Class fromClass, String libname) {
+    synchronized void loadLibrary0(Class<?> fromClass, String libname) {
         SecurityManager security = System.getSecurityManager();
         if (security != null) {
             security.checkLink(libname);
diff --git a/jdk/src/share/classes/java/lang/SecurityManager.java b/jdk/src/share/classes/java/lang/SecurityManager.java
index 27f7d90..f84fe3e 100644
--- a/jdk/src/share/classes/java/lang/SecurityManager.java
+++ b/jdk/src/share/classes/java/lang/SecurityManager.java
@@ -400,7 +400,7 @@
      */
     @Deprecated
     protected Class<?> currentLoadedClass() {
-        Class c = currentLoadedClass0();
+        Class<?> c = currentLoadedClass0();
         if ((c != null) && hasAllPermission())
             c = null;
         return c;
@@ -1715,7 +1715,7 @@
         checkPermission(new SecurityPermission(target));
     }
 
-    private native Class currentLoadedClass0();
+    private native Class<?> currentLoadedClass0();
 
     /**
      * Returns the thread group into which to instantiate any new
diff --git a/jdk/src/share/classes/java/lang/String.java b/jdk/src/share/classes/java/lang/String.java
index 1a40916..50b3f7b 100644
--- a/jdk/src/share/classes/java/lang/String.java
+++ b/jdk/src/share/classes/java/lang/String.java
@@ -1245,6 +1245,9 @@
             }
             return n1 - n2;
         }
+
+        /** Replaces the de-serialized object. */
+        private Object readResolve() { return CASE_INSENSITIVE_ORDER; }
     }
 
     /**
diff --git a/jdk/src/share/classes/java/lang/System.java b/jdk/src/share/classes/java/lang/System.java
index 5c33dd0..6e4f743 100644
--- a/jdk/src/share/classes/java/lang/System.java
+++ b/jdk/src/share/classes/java/lang/System.java
@@ -1171,13 +1171,13 @@
     private static void setJavaLangAccess() {
         // Allow privileged classes outside of java.lang
         sun.misc.SharedSecrets.setJavaLangAccess(new sun.misc.JavaLangAccess(){
-            public sun.reflect.ConstantPool getConstantPool(Class klass) {
+            public sun.reflect.ConstantPool getConstantPool(Class<?> klass) {
                 return klass.getConstantPool();
             }
-            public void setAnnotationType(Class klass, AnnotationType type) {
+            public void setAnnotationType(Class<?> klass, AnnotationType type) {
                 klass.setAnnotationType(type);
             }
-            public AnnotationType getAnnotationType(Class klass) {
+            public AnnotationType getAnnotationType(Class<?> klass) {
                 return klass.getAnnotationType();
             }
             public <E extends Enum<E>>
diff --git a/jdk/src/share/classes/java/lang/Thread.java b/jdk/src/share/classes/java/lang/Thread.java
index 45393eb..b3d2e39 100644
--- a/jdk/src/share/classes/java/lang/Thread.java
+++ b/jdk/src/share/classes/java/lang/Thread.java
@@ -1650,7 +1650,7 @@
      * security-sensitive non-final methods, or else the
      * "enableContextClassLoaderOverride" RuntimePermission is checked.
      */
-    private static boolean isCCLOverridden(Class cl) {
+    private static boolean isCCLOverridden(Class<?> cl) {
         if (cl == Thread.class)
             return false;
 
@@ -1670,21 +1670,21 @@
      * override security-sensitive non-final methods.  Returns true if the
      * subclass overrides any of the methods, false otherwise.
      */
-    private static boolean auditSubclass(final Class subcl) {
+    private static boolean auditSubclass(final Class<?> subcl) {
         Boolean result = AccessController.doPrivileged(
             new PrivilegedAction<Boolean>() {
                 public Boolean run() {
-                    for (Class cl = subcl;
+                    for (Class<?> cl = subcl;
                          cl != Thread.class;
                          cl = cl.getSuperclass())
                     {
                         try {
-                            cl.getDeclaredMethod("getContextClassLoader", new Class[0]);
+                            cl.getDeclaredMethod("getContextClassLoader", new Class<?>[0]);
                             return Boolean.TRUE;
                         } catch (NoSuchMethodException ex) {
                         }
                         try {
-                            Class[] params = {ClassLoader.class};
+                            Class<?>[] params = {ClassLoader.class};
                             cl.getDeclaredMethod("setContextClassLoader", params);
                             return Boolean.TRUE;
                         } catch (NoSuchMethodException ex) {
diff --git a/jdk/src/share/classes/java/lang/ThreadGroup.java b/jdk/src/share/classes/java/lang/ThreadGroup.java
index a0ec567..8b93210 100644
--- a/jdk/src/share/classes/java/lang/ThreadGroup.java
+++ b/jdk/src/share/classes/java/lang/ThreadGroup.java
@@ -670,6 +670,7 @@
      *     {@link Thread#suspend} for details.
      */
     @Deprecated
+    @SuppressWarnings("deprecation")
     public final void suspend() {
         if (stopOrSuspend(true))
             Thread.currentThread().suspend();
@@ -682,6 +683,7 @@
      * if (and only if) the current thread is found to be in this thread
      * group or one of its subgroups.
      */
+    @SuppressWarnings("deprecation")
     private boolean stopOrSuspend(boolean suspend) {
         boolean suicide = false;
         Thread us = Thread.currentThread();
@@ -731,6 +733,7 @@
      *       deadlock-prone.  See {@link Thread#suspend} for details.
      */
     @Deprecated
+    @SuppressWarnings("deprecation")
     public final void resume() {
         int ngroupsSnapshot;
         ThreadGroup[] groupsSnapshot;
diff --git a/jdk/src/share/classes/java/lang/instrument/ClassDefinition.java b/jdk/src/share/classes/java/lang/instrument/ClassDefinition.java
index db925e6..aa02609 100644
--- a/jdk/src/share/classes/java/lang/instrument/ClassDefinition.java
+++ b/jdk/src/share/classes/java/lang/instrument/ClassDefinition.java
@@ -40,12 +40,12 @@
     /**
      *  The class to redefine
      */
-    private final   Class   mClass;
+    private final Class<?> mClass;
 
     /**
      *  The replacement class file bytes
      */
-    private final   byte[]  mClassFile;
+    private final byte[]   mClassFile;
 
     /**
      *  Creates a new <code>ClassDefinition</code> binding using the supplied
diff --git a/jdk/src/share/classes/java/lang/management/ManagementFactory.java b/jdk/src/share/classes/java/lang/management/ManagementFactory.java
index 695bc37..98f2e40 100644
--- a/jdk/src/share/classes/java/lang/management/ManagementFactory.java
+++ b/jdk/src/share/classes/java/lang/management/ManagementFactory.java
@@ -576,7 +576,7 @@
                                Class<T> mxbeanInterface)
             throws java.io.IOException {
 
-        final Class interfaceClass = mxbeanInterface;
+        final Class<?> interfaceClass = mxbeanInterface;
         // Only allow MXBean interfaces from rt.jar loaded by the
         // bootstrap class loader
         final ClassLoader loader =
diff --git a/jdk/src/share/classes/java/lang/management/PlatformComponent.java b/jdk/src/share/classes/java/lang/management/PlatformComponent.java
index 82b6e87..d924335 100644
--- a/jdk/src/share/classes/java/lang/management/PlatformComponent.java
+++ b/jdk/src/share/classes/java/lang/management/PlatformComponent.java
@@ -314,7 +314,7 @@
     private final String domain;
     private final String type;
     private final Set<String> keyProperties;
-    private final MXBeanFetcher fetcher;
+    private final MXBeanFetcher<?> fetcher;
     private final PlatformComponent[] subComponents;
     private final boolean singleton;
 
@@ -322,7 +322,7 @@
                               String domain, String type,
                               Set<String> keyProperties,
                               boolean singleton,
-                              MXBeanFetcher fetcher,
+                              MXBeanFetcher<?> fetcher,
                               PlatformComponent... subComponents) {
         this.mxbeanInterfaceName = intfName;
         this.domain = domain;
@@ -373,7 +373,7 @@
     <T extends PlatformManagedObject>
         List<T> getMXBeans(Class<T> mxbeanInterface)
     {
-        return fetcher.getMXBeans();
+        return (List<T>) fetcher.getMXBeans();
     }
 
     <T extends PlatformManagedObject> T getSingletonMXBean(Class<T> mxbeanInterface)
@@ -382,7 +382,7 @@
             throw new IllegalArgumentException(mxbeanInterfaceName +
                 " can have zero or more than one instances");
 
-        List<T> list = fetcher.getMXBeans();
+        List<T> list = getMXBeans(mxbeanInterface);
         assert list.size() == 1;
         return list.isEmpty() ? null : list.get(0);
     }
diff --git a/jdk/src/share/classes/java/net/HttpCookie.java b/jdk/src/share/classes/java/net/HttpCookie.java
index a932a5f..52d1218 100644
--- a/jdk/src/share/classes/java/net/HttpCookie.java
+++ b/jdk/src/share/classes/java/net/HttpCookie.java
@@ -31,17 +31,15 @@
 import java.text.SimpleDateFormat;
 import java.util.TimeZone;
 import java.util.Date;
-
-import java.lang.NullPointerException;  // for javadoc
 import java.util.Locale;
 import java.util.Objects;
 
 /**
- * An HttpCookie object represents an http cookie, which carries state
+ * An HttpCookie object represents an HTTP cookie, which carries state
  * information between server and user agent. Cookie is widely adopted
  * to create stateful sessions.
  *
- * <p>There are 3 http cookie specifications:
+ * <p> There are 3 HTTP cookie specifications:
  * <blockquote>
  *   Netscape draft<br>
  *   RFC 2109 - <a href="http://www.ietf.org/rfc/rfc2109.txt">
@@ -50,25 +48,19 @@
  * <i>http://www.ietf.org/rfc/rfc2965.txt</i></a>
  * </blockquote>
  *
- * <p>HttpCookie class can accept all these 3 forms of syntax.
+ * <p> HttpCookie class can accept all these 3 forms of syntax.
  *
  * @author Edward Wang
  * @since 1.6
  */
 public final class HttpCookie implements Cloneable {
-    /* ---------------- Fields -------------- */
+    // ---------------- Fields --------------
 
-    //
     // The value of the cookie itself.
-    //
-
-    private String name;        // NAME= ... "$Name" style is reserved
+    private final String name;  // NAME= ... "$Name" style is reserved
     private String value;       // value of NAME
 
-    //
     // Attributes encoded in the header's cookie fields.
-    //
-
     private String comment;     // Comment=VALUE ... describes cookie's use
     private String commentURL;  // CommentURL="http URL" ... describes cookie's use
     private boolean toDiscard;  // Discard ... discard cookie unconditionally
@@ -80,70 +72,61 @@
     private boolean httpOnly;   // HttpOnly ... i.e. not accessible to scripts
     private int version = 1;    // Version=1 ... RFC 2965 style
 
-    //
     // Hold the creation time (in seconds) of the http cookie for later
     // expiration calculation
-    //
-    private long whenCreated = 0;
+    private final long whenCreated;
 
-
-    //
     // Since the positive and zero max-age have their meanings,
     // this value serves as a hint as 'not specify max-age'
-    //
     private final static long MAX_AGE_UNSPECIFIED = -1;
 
-
-    //
     // date formats used by Netscape's cookie draft
     // as well as formats seen on various sites
-    //
     private final static String[] COOKIE_DATE_FORMATS = {
         "EEE',' dd-MMM-yyyy HH:mm:ss 'GMT'",
         "EEE',' dd MMM yyyy HH:mm:ss 'GMT'",
         "EEE MMM dd yyyy HH:mm:ss 'GMT'Z"
     };
 
-    //
     // constant strings represent set-cookie header token
-    //
     private final static String SET_COOKIE = "set-cookie:";
     private final static String SET_COOKIE2 = "set-cookie2:";
 
-
-    /* ---------------- Ctors -------------- */
+    // ---------------- Ctors --------------
 
     /**
      * Constructs a cookie with a specified name and value.
      *
-     * <p>The name must conform to RFC 2965. That means it can contain
+     * <p> The name must conform to RFC 2965. That means it can contain
      * only ASCII alphanumeric characters and cannot contain commas,
      * semicolons, or white space or begin with a $ character. The cookie's
      * name cannot be changed after creation.
      *
-     * <p>The value can be anything the server chooses to send. Its
+     * <p> The value can be anything the server chooses to send. Its
      * value is probably of interest only to the server. The cookie's
      * value can be changed after creation with the
-     * <code>setValue</code> method.
+     * {@code setValue} method.
      *
-     * <p>By default, cookies are created according to the RFC 2965
+     * <p> By default, cookies are created according to the RFC 2965
      * cookie specification. The version can be changed with the
-     * <code>setVersion</code> method.
+     * {@code setVersion} method.
      *
      *
-     * @param name                      a <code>String</code> specifying the name of the cookie
+     * @param  name
+     *         a {@code String} specifying the name of the cookie
      *
-     * @param value                     a <code>String</code> specifying the value of the cookie
+     * @param  value
+     *         a {@code String} specifying the value of the cookie
      *
-     * @throws IllegalArgumentException if the cookie name contains illegal characters
-     *                                  or it is one of the tokens reserved for use
-     *                                  by the cookie protocol
-     * @throws NullPointerException     if <tt>name</tt> is <tt>null</tt>
+     * @throws  IllegalArgumentException
+     *          if the cookie name contains illegal characters or it is one of
+     *          the tokens reserved for use by the cookie protocol
+     * @throws  NullPointerException
+     *          if {@code name} is {@code null}
+     *
      * @see #setValue
      * @see #setVersion
-     *
      */
-
     public HttpCookie(String name, String value) {
         name = name.trim();
         if (name.length() == 0 || !isToken(name) || isReserved(name)) {
@@ -159,23 +142,25 @@
         portlist = null;
     }
 
-
     /**
      * Constructs cookies from set-cookie or set-cookie2 header string.
      * RFC 2965 section 3.2.2 set-cookie2 syntax indicates that one header line
      * may contain more than one cookie definitions, so this is a static
      * utility method instead of another constructor.
      *
-     * @param header    a <tt>String</tt> specifying the set-cookie header.
-     *                  The header should start with "set-cookie", or "set-cookie2"
-     *                  token; or it should have no leading token at all.
-     * @return          a List of cookie parsed from header line string
-     * @throws IllegalArgumentException if header string violates the cookie
-     *                                  specification's syntax, or the cookie
-     *                                  name contains llegal characters, or
-     *                                  the cookie name is one of the tokens
-     *                                  reserved for use by the cookie protocol
-     * @throws NullPointerException     if the header string is <tt>null</tt>
+     * @param  header
+     *         a {@code String} specifying the set-cookie header. The header
+     *         should start with "set-cookie", or "set-cookie2" token; or it
+     *         should have no leading token at all.
+     *
+     * @return  a List of cookie parsed from header line string
+     *
+     * @throws  IllegalArgumentException
+     *          if header string violates the cookie specification's syntax, or
+     *          the cookie name contains illegal characters, or the cookie name
+     *          is one of the tokens reserved for use by the cookie protocol
+     * @throws  NullPointerException
+     *          if the header string is {@code null}
      */
     public static List<HttpCookie> parse(String header) {
         int version = guessCookieVersion(header);
@@ -187,10 +172,9 @@
             header = header.substring(SET_COOKIE.length());
         }
 
-
-        List<HttpCookie> cookies = new java.util.ArrayList<HttpCookie>();
-        // The Netscape cookie may have a comma in its expires attribute,
-        // while the comma is the delimiter in rfc 2965/2109 cookie header string.
+        List<HttpCookie> cookies = new java.util.ArrayList<>();
+        // The Netscape cookie may have a comma in its expires attribute, while
+        // the comma is the delimiter in rfc 2965/2109 cookie header string.
         // so the parse logic is slightly different
         if (version == 0) {
             // Netscape draft cookie
@@ -212,17 +196,13 @@
         return cookies;
     }
 
-
-
-
-    /* ---------------- Public operations -------------- */
-
+    // ---------------- Public operations --------------
 
     /**
-     * Reports whether this http cookie has expired or not.
+     * Reports whether this HTTP cookie has expired or not.
      *
-     * @return  <tt>true</tt> to indicate this http cookie has expired;
-     *          otherwise, <tt>false</tt>
+     * @return  {@code true} to indicate this HTTP cookie has expired;
+     *          otherwise, {@code false}
      */
     public boolean hasExpired() {
         if (maxAge == 0) return true;
@@ -240,155 +220,123 @@
     }
 
     /**
-     *
      * Specifies a comment that describes a cookie's purpose.
      * The comment is useful if the browser presents the cookie
-     * to the user. Comments
-     * are not supported by Netscape Version 0 cookies.
+     * to the user. Comments are not supported by Netscape Version 0 cookies.
      *
-     * @param purpose           a <code>String</code> specifying the comment
-     *                          to display to the user
+     * @param  purpose
+     *         a {@code String} specifying the comment to display to the user
      *
-     * @see #getComment
-     *
+     * @see  #getComment
      */
-
     public void setComment(String purpose) {
         comment = purpose;
     }
 
-
-
-
     /**
      * Returns the comment describing the purpose of this cookie, or
-     * <code>null</code> if the cookie has no comment.
+     * {@code null} if the cookie has no comment.
      *
-     * @return                  a <code>String</code> containing the comment,
-     *                          or <code>null</code> if none
+     * @return  a {@code String} containing the comment, or {@code null} if none
      *
-     * @see #setComment
-     *
+     * @see  #setComment
      */
-
     public String getComment() {
         return comment;
     }
 
-
     /**
+     * Specifies a comment URL that describes a cookie's purpose.
+     * The comment URL is useful if the browser presents the cookie
+     * to the user. Comment URL is RFC 2965 only.
      *
-     * Specifies a comment url that describes a cookie's purpose.
-     * The comment url is useful if the browser presents the cookie
-     * to the user. Comment url is RFC 2965 only.
+     * @param  purpose
+     *         a {@code String} specifying the comment URL to display to the user
      *
-     * @param purpose           a <code>String</code> specifying the comment url
-     *                          to display to the user
-     *
-     * @see #getCommentURL
-     *
+     * @see  #getCommentURL
      */
-
     public void setCommentURL(String purpose) {
         commentURL = purpose;
     }
 
-
-
-
     /**
-     * Returns the comment url describing the purpose of this cookie, or
-     * <code>null</code> if the cookie has no comment url.
+     * Returns the comment URL describing the purpose of this cookie, or
+     * {@code null} if the cookie has no comment URL.
      *
-     * @return                  a <code>String</code> containing the comment url,
-     *                          or <code>null</code> if none
+     * @return  a {@code String} containing the comment URL, or {@code null}
+     *          if none
      *
-     * @see #setCommentURL
-     *
+     * @see  #setCommentURL
      */
-
     public String getCommentURL() {
         return commentURL;
     }
 
-
     /**
      * Specify whether user agent should discard the cookie unconditionally.
      * This is RFC 2965 only attribute.
      *
-     * @param discard   <tt>true</tt> indicates to discard cookie unconditionally
+     * @param  discard
+     *         {@code true} indicates to discard cookie unconditionally
      *
-     * @see #getDiscard
+     * @see  #getDiscard
      */
-
     public void setDiscard(boolean discard) {
         toDiscard = discard;
     }
 
-
-
-
     /**
-     * Return the discard attribute of the cookie
+     * Returns the discard attribute of the cookie
      *
-     * @return  a <tt>boolean</tt> to represent this cookie's discard attribute
+     * @return  a {@code boolean} to represent this cookie's discard attribute
      *
-     * @see #setDiscard
+     * @see  #setDiscard
      */
-
     public boolean getDiscard() {
         return toDiscard;
     }
 
-
     /**
      * Specify the portlist of the cookie, which restricts the port(s)
      * to which a cookie may be sent back in a Cookie header.
      *
-     * @param ports     a <tt>String</tt> specify the port list, which is
-     *                  comma seperated series of digits
-     * @see #getPortlist
+     * @param  ports
+     *         a {@code String} specify the port list, which is comma separated
+     *         series of digits
+     *
+     * @see  #getPortlist
      */
-
     public void setPortlist(String ports) {
         portlist = ports;
     }
 
-
-
-
     /**
-     * Return the port list attribute of the cookie
+     * Returns the port list attribute of the cookie
      *
-     * @return  a <tt>String</tt> contains the port list
-     *          or <tt>null</tt> if none
-     * @see #setPortlist
+     * @return  a {@code String} contains the port list or {@code null} if none
+     *
+     * @see  #setPortlist
      */
-
     public String getPortlist() {
         return portlist;
     }
 
     /**
-     *
      * Specifies the domain within which this cookie should be presented.
      *
-     * <p>The form of the domain name is specified by RFC 2965. A domain
-     * name begins with a dot (<code>.foo.com</code>) and means that
+     * <p> The form of the domain name is specified by RFC 2965. A domain
+     * name begins with a dot ({@code .foo.com}) and means that
      * the cookie is visible to servers in a specified Domain Name System
-     * (DNS) zone (for example, <code>www.foo.com</code>, but not
-     * <code>a.b.foo.com</code>). By default, cookies are only returned
+     * (DNS) zone (for example, {@code www.foo.com}, but not
+     * {@code a.b.foo.com}). By default, cookies are only returned
      * to the server that sent them.
      *
+     * @param  pattern
+     *         a {@code String} containing the domain name within which this
+     *         cookie is visible; form is according to RFC 2965
      *
-     * @param pattern           a <code>String</code> containing the domain name
-     *                          within which this cookie is visible;
-     *                          form is according to RFC 2965
-     *
-     * @see #getDomain
-     *
+     * @see  #getDomain
      */
-
     public void setDomain(String pattern) {
         if (pattern != null)
             domain = pattern.toLowerCase();
@@ -396,261 +344,187 @@
             domain = pattern;
     }
 
-
-
-
-
     /**
-     * Returns the domain name set for this cookie. The form of
-     * the domain name is set by RFC 2965.
+     * Returns the domain name set for this cookie. The form of the domain name
+     * is set by RFC 2965.
      *
-     * @return                  a <code>String</code> containing the domain name
+     * @return  a {@code String} containing the domain name
      *
-     * @see #setDomain
-     *
+     * @see  #setDomain
      */
-
     public String getDomain() {
         return domain;
     }
 
-
     /**
      * Sets the maximum age of the cookie in seconds.
      *
-     * <p>A positive value indicates that the cookie will expire
+     * <p> A positive value indicates that the cookie will expire
      * after that many seconds have passed. Note that the value is
      * the <i>maximum</i> age when the cookie will expire, not the cookie's
      * current age.
      *
-     * <p>A negative value means
-     * that the cookie is not stored persistently and will be deleted
-     * when the Web browser exits. A zero value causes the cookie
-     * to be deleted.
+     * <p> A negative value means that the cookie is not stored persistently
+     * and will be deleted when the Web browser exits. A zero value causes the
+     * cookie to be deleted.
      *
-     * @param expiry            an integer specifying the maximum age of the
-     *                          cookie in seconds; if zero, the cookie
-     *                          should be discarded immediately;
-     *                          otherwise, the cookie's max age is unspecified.
+     * @param  expiry
+     *         an integer specifying the maximum age of the cookie in seconds;
+     *         if zero, the cookie should be discarded immediately; otherwise,
+     *         the cookie's max age is unspecified.
      *
-     * @see #getMaxAge
-     *
+     * @see  #getMaxAge
      */
     public void setMaxAge(long expiry) {
         maxAge = expiry;
     }
 
-
-
-
     /**
-     * Returns the maximum age of the cookie, specified in seconds.
-     * By default, <code>-1</code> indicating the cookie will persist
-     * until browser shutdown.
+     * Returns the maximum age of the cookie, specified in seconds. By default,
+     * {@code -1} indicating the cookie will persist until browser shutdown.
      *
+     * @return  an integer specifying the maximum age of the cookie in seconds
      *
-     * @return                  an integer specifying the maximum age of the
-     *                          cookie in seconds
-     *
-     *
-     * @see #setMaxAge
-     *
+     * @see  #setMaxAge
      */
-
     public long getMaxAge() {
         return maxAge;
     }
 
-
-
-
     /**
-     * Specifies a path for the cookie
-     * to which the client should return the cookie.
+     * Specifies a path for the cookie to which the client should return
+     * the cookie.
      *
-     * <p>The cookie is visible to all the pages in the directory
+     * <p> The cookie is visible to all the pages in the directory
      * you specify, and all the pages in that directory's subdirectories.
      * A cookie's path must include the servlet that set the cookie,
      * for example, <i>/catalog</i>, which makes the cookie
      * visible to all directories on the server under <i>/catalog</i>.
      *
-     * <p>Consult RFC 2965 (available on the Internet) for more
+     * <p> Consult RFC 2965 (available on the Internet) for more
      * information on setting path names for cookies.
      *
+     * @param  uri
+     *         a {@code String} specifying a path
      *
-     * @param uri               a <code>String</code> specifying a path
-     *
-     *
-     * @see #getPath
-     *
+     * @see  #getPath
      */
-
     public void setPath(String uri) {
         path = uri;
     }
 
-
-
-
     /**
-     * Returns the path on the server
-     * to which the browser returns this cookie. The
-     * cookie is visible to all subpaths on the server.
+     * Returns the path on the server to which the browser returns this cookie.
+     * The cookie is visible to all subpaths on the server.
      *
+     * @return  a {@code String} specifying a path that contains a servlet name,
+     *          for example, <i>/catalog</i>
      *
-     * @return          a <code>String</code> specifying a path that contains
-     *                  a servlet name, for example, <i>/catalog</i>
-     *
-     * @see #setPath
-     *
+     * @see  #setPath
      */
-
     public String getPath() {
         return path;
     }
 
-
-
-
-
     /**
      * Indicates whether the cookie should only be sent using a secure protocol,
      * such as HTTPS or SSL.
      *
-     * <p>The default value is <code>false</code>.
+     * <p> The default value is {@code false}.
      *
-     * @param flag      If <code>true</code>, the cookie can only be sent over
-     *                  a secure protocol like https.
-     *                  If <code>false</code>, it can be sent over any protocol.
+     * @param  flag
+     *         If {@code true}, the cookie can only be sent over a secure
+     *         protocol like HTTPS. If {@code false}, it can be sent over
+     *         any protocol.
      *
-     * @see #getSecure
-     *
+     * @see  #getSecure
      */
-
     public void setSecure(boolean flag) {
         secure = flag;
     }
 
-
-
-
     /**
-     * Returns <code>true</code> if sending this cookie should be
-     * restricted to a secure protocol, or <code>false</code> if the
-     * it can be sent using any protocol.
+     * Returns {@code true} if sending this cookie should be restricted to a
+     * secure protocol, or {@code false} if the it can be sent using any
+     * protocol.
      *
-     * @return          <code>false</code> if the cookie can be sent over
-     *                  any standard protocol; otherwise, <code>true</code>
+     * @return  {@code false} if the cookie can be sent over any standard
+     *          protocol; otherwise, <code>true</code>
      *
-     * @see #setSecure
-     *
+     * @see  #setSecure
      */
-
     public boolean getSecure() {
         return secure;
     }
 
-
-
-
-
     /**
      * Returns the name of the cookie. The name cannot be changed after
      * creation.
      *
-     * @return          a <code>String</code> specifying the cookie's name
-     *
+     * @return  a {@code String} specifying the cookie's name
      */
-
     public String getName() {
         return name;
     }
 
-
-
-
-
     /**
-     *
      * Assigns a new value to a cookie after the cookie is created.
      * If you use a binary value, you may want to use BASE64 encoding.
      *
-     * <p>With Version 0 cookies, values should not contain white
-     * space, brackets, parentheses, equals signs, commas,
-     * double quotes, slashes, question marks, at signs, colons,
-     * and semicolons. Empty values may not behave the same way
-     * on all browsers.
+     * <p> With Version 0 cookies, values should not contain white space,
+     * brackets, parentheses, equals signs, commas, double quotes, slashes,
+     * question marks, at signs, colons, and semicolons. Empty values may not
+     * behave the same way on all browsers.
      *
-     * @param newValue          a <code>String</code> specifying the new value
+     * @param  newValue
+     *         a {@code String} specifying the new value
      *
-     *
-     * @see #getValue
-     *
+     * @see  #getValue
      */
-
     public void setValue(String newValue) {
         value = newValue;
     }
 
-
-
-
     /**
      * Returns the value of the cookie.
      *
-     * @return                  a <code>String</code> containing the cookie's
-     *                          present value
+     * @return  a {@code String} containing the cookie's present value
      *
-     * @see #setValue
-     *
+     * @see  #setValue
      */
-
     public String getValue() {
         return value;
     }
 
-
-
-
     /**
-     * Returns the version of the protocol this cookie complies
-     * with. Version 1 complies with RFC 2965/2109,
-     * and version 0 complies with the original
-     * cookie specification drafted by Netscape. Cookies provided
-     * by a browser use and identify the browser's cookie version.
+     * Returns the version of the protocol this cookie complies with. Version 1
+     * complies with RFC 2965/2109, and version 0 complies with the original
+     * cookie specification drafted by Netscape. Cookies provided by a browser
+     * use and identify the browser's cookie version.
      *
+     * @return  0 if the cookie complies with the original Netscape
+     *          specification; 1 if the cookie complies with RFC 2965/2109
      *
-     * @return                  0 if the cookie complies with the
-     *                          original Netscape specification; 1
-     *                          if the cookie complies with RFC 2965/2109
-     *
-     * @see #setVersion
-     *
+     * @see  #setVersion
      */
-
     public int getVersion() {
         return version;
     }
 
-
-
-
     /**
      * Sets the version of the cookie protocol this cookie complies
      * with. Version 0 complies with the original Netscape cookie
      * specification. Version 1 complies with RFC 2965/2109.
      *
+     * @param  v
+     *         0 if the cookie should comply with the original Netscape
+     *         specification; 1 if the cookie should comply with RFC 2965/2109
      *
-     * @param v                 0 if the cookie should comply with
-     *                          the original Netscape specification;
-     *                          1 if the cookie should comply with RFC 2965/2109
+     * @throws  IllegalArgumentException
+     *          if {@code v} is neither 0 nor 1
      *
-     * @throws IllegalArgumentException if <tt>v</tt> is neither 0 nor 1
-     *
-     * @see #getVersion
-     *
+     * @see  #getVersion
      */
-
     public void setVersion(int v) {
         if (v != 0 && v != 1) {
             throw new IllegalArgumentException("cookie version should be 0 or 1");
@@ -664,11 +538,11 @@
      * attribute. This means that the cookie should not be accessible to
      * scripting engines, like javascript.
      *
-     * @return {@code true} if this cookie should be considered http only.
-     * @see #setHttpOnly(boolean)
+     * @return  {@code true} if this cookie should be considered HTTPOnly
+     *
+     * @see  #setHttpOnly(boolean)
      */
-    public boolean isHttpOnly()
-    {
+    public boolean isHttpOnly() {
         return httpOnly;
     }
 
@@ -677,24 +551,25 @@
      * {@code true} it means the cookie should not be accessible to scripting
      * engines like javascript.
      *
-     * @param httpOnly if {@code true} make the cookie HTTP only, i.e.
-     *                 only visible as part of an HTTP request.
-     * @see #isHttpOnly()
+     * @param  httpOnly
+     *         if {@code true} make the cookie HTTP only, i.e. only visible as
+     *         part of an HTTP request.
+     *
+     * @see  #isHttpOnly()
      */
-    public void setHttpOnly(boolean httpOnly)
-    {
+    public void setHttpOnly(boolean httpOnly) {
         this.httpOnly = httpOnly;
     }
 
     /**
-     * The utility method to check whether a host name is in a domain
-     * or not.
+     * The utility method to check whether a host name is in a domain or not.
      *
-     * <p>This concept is described in the cookie specification.
+     * <p> This concept is described in the cookie specification.
      * To understand the concept, some terminologies need to be defined first:
      * <blockquote>
      * effective host name = hostname if host name contains dot<br>
-     * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;or = hostname.local if not
+     * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+     * &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;or = hostname.local if not
      * </blockquote>
      * <p>Host A's name domain-matches host B's if:
      * <blockquote><ul>
@@ -731,9 +606,13 @@
      *   host is example.local, and example.local domain-matches .local.</li>
      * </ul></blockquote>
      *
-     * @param domain    the domain name to check host name with
-     * @param host      the host name in question
-     * @return          <tt>true</tt> if they domain-matches; <tt>false</tt> if not
+     * @param  domain
+     *         the domain name to check host name with
+     *
+     * @param  host
+     *         the host name in question
+     *
+     * @return  {@code true} if they domain-matches; {@code false} if not
      */
     public static boolean domainMatches(String domain, String host) {
         if (domain == null || host == null)
@@ -745,7 +624,8 @@
         if (embeddedDotInDomain == 0)
             embeddedDotInDomain = domain.indexOf('.', 1);
         if (!isLocalDomain
-            && (embeddedDotInDomain == -1 || embeddedDotInDomain == domain.length() - 1))
+            && (embeddedDotInDomain == -1 ||
+                embeddedDotInDomain == domain.length() - 1))
             return false;
 
         // if the host name contains no dot and the domain name
@@ -779,7 +659,6 @@
         return false;
     }
 
-
     /**
      * Constructs a cookie header string representation of this cookie,
      * which is in the format defined by corresponding cookie specification,
@@ -796,17 +675,15 @@
         }
     }
 
-
     /**
-     * Test the equality of two http cookies.
+     * Test the equality of two HTTP cookies.
      *
-     * <p> The result is <tt>true</tt> only if two cookies
-     * come from same domain (case-insensitive),
-     * have same name (case-insensitive),
-     * and have same path (case-sensitive).
+     * <p> The result is {@code true} only if two cookies come from same domain
+     * (case-insensitive), have same name (case-insensitive), and have same path
+     * (case-sensitive).
      *
-     * @return          <tt>true</tt> if 2 http cookies equal to each other;
-     *                  otherwise, <tt>false</tt>
+     * @return  {@code true} if two HTTP cookies equal to each other;
+     *          otherwise, {@code false}
      */
     @Override
     public boolean equals(Object obj) {
@@ -825,19 +702,17 @@
                Objects.equals(getPath(), other.getPath());
     }
 
-
     /**
-     * Return hash code of this http cookie. The result is the sum of
-     * hash code value of three significant components of this cookie:
-     * name, domain, and path.
-     * That is, the hash code is the value of the expression:
+     * Returns the hash code of this HTTP cookie. The result is the sum of
+     * hash code value of three significant components of this cookie: name,
+     * domain, and path. That is, the hash code is the value of the expression:
      * <blockquote>
      * getName().toLowerCase().hashCode()<br>
      * + getDomain().toLowerCase().hashCode()<br>
      * + getPath().hashCode()
      * </blockquote>
      *
-     * @return          this http cookie's hash code
+     * @return  this HTTP cookie's hash code
      */
     @Override
     public int hashCode() {
@@ -851,7 +726,7 @@
     /**
      * Create and return a copy of this object.
      *
-     * @return          a clone of this http cookie
+     * @return  a clone of this HTTP cookie
      */
     @Override
     public Object clone() {
@@ -862,8 +737,7 @@
         }
     }
 
-
-    /* ---------------- Private operations -------------- */
+    // ---------------- Private operations --------------
 
     // Note -- disabled for now to allow full Netscape compatibility
     // from RFC 2068, token special case characters
@@ -872,15 +746,14 @@
     private static final String tspecials = ",;";
 
     /*
-     * Tests a string and returns true if the string counts as a
-     * token.
+     * Tests a string and returns true if the string counts as a token.
      *
-     * @param value             the <code>String</code> to be tested
+     * @param  value
+     *         the {@code String} to be tested
      *
-     * @return                  <code>true</code> if the <code>String</code> is
-     *                          a token; <code>false</code> if it is not
+     * @return  {@code true} if the {@code String} is a token;
+     *          {@code false} if it is not
      */
-
     private static boolean isToken(String value) {
         int len = value.length();
 
@@ -893,11 +766,12 @@
         return true;
     }
 
-
     /*
-     * @param name      the name to be tested
-     * @return          <tt>true</tt> if the name is reserved by cookie
-     *                  specification, <tt>false</tt> if it is not
+     * @param  name
+     *         the name to be tested
+     *
+     * @return  {@code true} if the name is reserved by cookie specification,
+     *          {@code false} if it is not
      */
     private static boolean isReserved(String name) {
         if (name.equalsIgnoreCase("Comment")
@@ -919,16 +793,16 @@
         return false;
     }
 
-
     /*
      * Parse header string to cookie object.
      *
-     * @param header    header string; should contain only one NAME=VALUE pair
+     * @param  header
+     *         header string; should contain only one NAME=VALUE pair
      *
-     * @return          an HttpCookie being extracted
+     * @return  an HttpCookie being extracted
      *
-     * @throws IllegalArgumentException if header string violates the cookie
-     *                                  specification
+     * @throws  IllegalArgumentException
+     *          if header string violates the cookie specification
      */
     private static HttpCookie parseInternal(String header)
     {
@@ -974,69 +848,97 @@
         return cookie;
     }
 
-
     /*
      * assign cookie attribute value to attribute name;
      * use a map to simulate method dispatch
      */
     static interface CookieAttributeAssignor {
-            public void assign(HttpCookie cookie, String attrName, String attrValue);
+            public void assign(HttpCookie cookie,
+                               String attrName,
+                               String attrValue);
     }
-    static java.util.Map<String, CookieAttributeAssignor> assignors = null;
+    static final java.util.Map<String, CookieAttributeAssignor> assignors =
+            new java.util.HashMap<>();
     static {
-        assignors = new java.util.HashMap<String, CookieAttributeAssignor>();
-        assignors.put("comment", new CookieAttributeAssignor(){
-                public void assign(HttpCookie cookie, String attrName, String attrValue) {
-                    if (cookie.getComment() == null) cookie.setComment(attrValue);
+        assignors.put("comment", new CookieAttributeAssignor() {
+                public void assign(HttpCookie cookie,
+                                   String attrName,
+                                   String attrValue) {
+                    if (cookie.getComment() == null)
+                        cookie.setComment(attrValue);
                 }
             });
-        assignors.put("commenturl", new CookieAttributeAssignor(){
-                public void assign(HttpCookie cookie, String attrName, String attrValue) {
-                    if (cookie.getCommentURL() == null) cookie.setCommentURL(attrValue);
+        assignors.put("commenturl", new CookieAttributeAssignor() {
+                public void assign(HttpCookie cookie,
+                                   String attrName,
+                                   String attrValue) {
+                    if (cookie.getCommentURL() == null)
+                        cookie.setCommentURL(attrValue);
                 }
             });
-        assignors.put("discard", new CookieAttributeAssignor(){
-                public void assign(HttpCookie cookie, String attrName, String attrValue) {
+        assignors.put("discard", new CookieAttributeAssignor() {
+                public void assign(HttpCookie cookie,
+                                   String attrName,
+                                   String attrValue) {
                     cookie.setDiscard(true);
                 }
             });
         assignors.put("domain", new CookieAttributeAssignor(){
-                public void assign(HttpCookie cookie, String attrName, String attrValue) {
-                    if (cookie.getDomain() == null) cookie.setDomain(attrValue);
+                public void assign(HttpCookie cookie,
+                                   String attrName,
+                                   String attrValue) {
+                    if (cookie.getDomain() == null)
+                        cookie.setDomain(attrValue);
                 }
             });
         assignors.put("max-age", new CookieAttributeAssignor(){
-                public void assign(HttpCookie cookie, String attrName, String attrValue) {
+                public void assign(HttpCookie cookie,
+                                   String attrName,
+                                   String attrValue) {
                     try {
                         long maxage = Long.parseLong(attrValue);
-                        if (cookie.getMaxAge() == MAX_AGE_UNSPECIFIED) cookie.setMaxAge(maxage);
+                        if (cookie.getMaxAge() == MAX_AGE_UNSPECIFIED)
+                            cookie.setMaxAge(maxage);
                     } catch (NumberFormatException ignored) {
-                        throw new IllegalArgumentException("Illegal cookie max-age attribute");
+                        throw new IllegalArgumentException(
+                                "Illegal cookie max-age attribute");
                     }
                 }
             });
         assignors.put("path", new CookieAttributeAssignor(){
-                public void assign(HttpCookie cookie, String attrName, String attrValue) {
-                    if (cookie.getPath() == null) cookie.setPath(attrValue);
+                public void assign(HttpCookie cookie,
+                                   String attrName,
+                                   String attrValue) {
+                    if (cookie.getPath() == null)
+                        cookie.setPath(attrValue);
                 }
             });
         assignors.put("port", new CookieAttributeAssignor(){
-                public void assign(HttpCookie cookie, String attrName, String attrValue) {
-                    if (cookie.getPortlist() == null) cookie.setPortlist(attrValue == null ? "" : attrValue);
+                public void assign(HttpCookie cookie,
+                                   String attrName,
+                                   String attrValue) {
+                    if (cookie.getPortlist() == null)
+                        cookie.setPortlist(attrValue == null ? "" : attrValue);
                 }
             });
         assignors.put("secure", new CookieAttributeAssignor(){
-                public void assign(HttpCookie cookie, String attrName, String attrValue) {
+                public void assign(HttpCookie cookie,
+                                   String attrName,
+                                   String attrValue) {
                     cookie.setSecure(true);
                 }
             });
         assignors.put("httponly", new CookieAttributeAssignor(){
-                public void assign(HttpCookie cookie, String attrName, String attrValue) {
+                public void assign(HttpCookie cookie,
+                                   String attrName,
+                                   String attrValue) {
                     cookie.setHttpOnly(true);
                 }
             });
         assignors.put("version", new CookieAttributeAssignor(){
-                public void assign(HttpCookie cookie, String attrName, String attrValue) {
+                public void assign(HttpCookie cookie,
+                                   String attrName,
+                                   String attrValue) {
                     try {
                         int version = Integer.parseInt(attrValue);
                         cookie.setVersion(version);
@@ -1046,7 +948,9 @@
                 }
             });
         assignors.put("expires", new CookieAttributeAssignor(){ // Netscape only
-                public void assign(HttpCookie cookie, String attrName, String attrValue) {
+                public void assign(HttpCookie cookie,
+                                   String attrName,
+                                   String attrValue) {
                     if (cookie.getMaxAge() == MAX_AGE_UNSPECIFIED) {
                         cookie.setMaxAge(cookie.expiryDate2DeltaSeconds(attrValue));
                     }
@@ -1054,8 +958,8 @@
             });
     }
     private static void assignAttribute(HttpCookie cookie,
-                                       String attrName,
-                                       String attrValue)
+                                        String attrName,
+                                        String attrValue)
     {
         // strip off the surrounding "-sign if there's any
         attrValue = stripOffSurroundingQuote(attrValue);
@@ -1073,11 +977,7 @@
      * as Netscape spec, but without leading "Cookie:" token.
      */
     private String toNetscapeHeaderString() {
-        StringBuilder sb = new StringBuilder();
-
-        sb.append(getName() + "=" + getValue());
-
-        return sb.toString();
+        return getName() + "=" + getValue();
     }
 
     /*
@@ -1101,15 +1001,16 @@
     static final TimeZone GMT = TimeZone.getTimeZone("GMT");
 
     /*
-     * @param dateString        a date string in one of the formats
-     *                          defined in Netscape cookie spec
+     * @param  dateString
+     *         a date string in one of the formats defined in Netscape cookie spec
      *
-     * @return                  delta seconds between this cookie's creation
-     *                          time and the time specified by dateString
+     * @return  delta seconds between this cookie's creation time and the time
+     *          specified by dateString
      */
     private long expiryDate2DeltaSeconds(String dateString) {
         for (int i = 0; i < COOKIE_DATE_FORMATS.length; i++) {
-            SimpleDateFormat df = new SimpleDateFormat(COOKIE_DATE_FORMATS[i], Locale.US);
+            SimpleDateFormat df = new SimpleDateFormat(COOKIE_DATE_FORMATS[i],
+                                                       Locale.US);
             df.setTimeZone(GMT);
             try {
                 Date date = df.parse(dateString);
@@ -1121,8 +1022,6 @@
         return 0;
     }
 
-
-
     /*
      * try to guess the cookie version through set-cookie header string
      */
@@ -1184,10 +1083,10 @@
      *   2) but not the comma surrounding by double-quotes, which is the comma
      *      inside port list or embeded URIs.
      *
-     * @param header            the cookie header string to split
+     * @param  header
+     *         the cookie header string to split
      *
-     * @return                  list of strings; never null
-     *
+     * @return  list of strings; never null
      */
     private static List<String> splitMultiCookies(String header) {
         List<String> cookies = new java.util.ArrayList<String>();
@@ -1197,7 +1096,8 @@
         for (p = 0, q = 0; p < header.length(); p++) {
             char c = header.charAt(p);
             if (c == '"') quoteCount++;
-            if (c == ',' && (quoteCount % 2 == 0)) {      // it is comma and not surrounding by double-quotes
+            if (c == ',' && (quoteCount % 2 == 0)) {
+                // it is comma and not surrounding by double-quotes
                 cookies.add(header.substring(q, p));
                 q = p + 1;
             }
diff --git a/jdk/src/share/classes/java/net/InetAddress.java b/jdk/src/share/classes/java/net/InetAddress.java
index 8758cab..d927d16 100644
--- a/jdk/src/share/classes/java/net/InetAddress.java
+++ b/jdk/src/share/classes/java/net/InetAddress.java
@@ -32,6 +32,7 @@
 import java.util.LinkedList;
 import java.util.List;
 import java.util.ArrayList;
+import java.util.ServiceLoader;
 import java.security.AccessController;
 import java.io.ObjectStreamException;
 import java.io.IOException;
@@ -39,7 +40,6 @@
 import sun.security.action.*;
 import sun.net.InetAddressCachePolicy;
 import sun.net.util.IPAddressUtil;
-import sun.misc.Service;
 import sun.net.spi.nameservice.*;
 
 /**
@@ -876,10 +876,9 @@
                 nameService = java.security.AccessController.doPrivileged(
                     new java.security.PrivilegedExceptionAction<NameService>() {
                         public NameService run() {
-                            // sun.misc.Service.providers returns a raw Iterator
-                            @SuppressWarnings("unchecked")
                             Iterator<NameServiceDescriptor> itr =
-                                Service.providers(NameServiceDescriptor.class);
+                                ServiceLoader.load(NameServiceDescriptor.class)
+                                    .iterator();
                             while (itr.hasNext()) {
                                 NameServiceDescriptor nsd = itr.next();
                                 if (providerName.
diff --git a/jdk/src/share/classes/java/rmi/MarshalledObject.java b/jdk/src/share/classes/java/rmi/MarshalledObject.java
index cd88129..4ac4a8b 100644
--- a/jdk/src/share/classes/java/rmi/MarshalledObject.java
+++ b/jdk/src/share/classes/java/rmi/MarshalledObject.java
@@ -156,6 +156,7 @@
             (locBytes == null ? null : new ByteArrayInputStream(locBytes));
         MarshalledObjectInputStream in =
             new MarshalledObjectInputStream(bin, lin);
+        @SuppressWarnings("unchecked")
         T obj = (T) in.readObject();
         in.close();
         return obj;
@@ -190,7 +191,7 @@
             return true;
 
         if (obj != null && obj instanceof MarshalledObject) {
-            MarshalledObject other = (MarshalledObject) obj;
+            MarshalledObject<?> other = (MarshalledObject<?>) obj;
 
             // if either is a ref to null, both must be
             if (objBytes == null || other.objBytes == null)
diff --git a/jdk/src/share/classes/java/rmi/dgc/VMID.java b/jdk/src/share/classes/java/rmi/dgc/VMID.java
index c9f1647..5e9c0a5 100644
--- a/jdk/src/share/classes/java/rmi/dgc/VMID.java
+++ b/jdk/src/share/classes/java/rmi/dgc/VMID.java
@@ -118,7 +118,7 @@
         StringBuffer result = new StringBuffer();
         if (addr != null)
             for (int i = 0; i < addr.length; ++ i) {
-                int x = (int) (addr[i] & 0xFF);
+                int x = addr[i] & 0xFF;
                 result.append((x < 0x10 ? "0" : "") +
                               Integer.toString(x, 16));
             }
diff --git a/jdk/src/share/classes/java/rmi/server/LogStream.java b/jdk/src/share/classes/java/rmi/server/LogStream.java
index 4120e32..cc35f7a 100644
--- a/jdk/src/share/classes/java/rmi/server/LogStream.java
+++ b/jdk/src/share/classes/java/rmi/server/LogStream.java
@@ -39,7 +39,7 @@
 public class LogStream extends PrintStream {
 
     /** table mapping known log names to log stream objects */
-    private static Hashtable    known = new Hashtable(5);
+    private static Map<String,LogStream> known = new HashMap<>(5);
     /** default output stream for new logs */
     private static PrintStream  defaultStream = System.err;
 
@@ -90,7 +90,7 @@
     public static LogStream log(String name) {
         LogStream stream;
         synchronized (known) {
-            stream = (LogStream)known.get(name);
+            stream = known.get(name);
             if (stream == null) {
                 stream = new LogStream(name, defaultStream);
             }
diff --git a/jdk/src/share/classes/java/rmi/server/RemoteObject.java b/jdk/src/share/classes/java/rmi/server/RemoteObject.java
index 31aab0c..b3b32c5 100644
--- a/jdk/src/share/classes/java/rmi/server/RemoteObject.java
+++ b/jdk/src/share/classes/java/rmi/server/RemoteObject.java
@@ -436,7 +436,7 @@
              */
             String internalRefClassName =
                 RemoteRef.packagePrefix + "." + refClassName;
-            Class refClass = Class.forName(internalRefClassName);
+            Class<?> refClass = Class.forName(internalRefClassName);
             try {
                 ref = (RemoteRef) refClass.newInstance();
 
diff --git a/jdk/src/share/classes/java/sql/Date.java b/jdk/src/share/classes/java/sql/Date.java
index 1d82ab3..de39d14 100644
--- a/jdk/src/share/classes/java/sql/Date.java
+++ b/jdk/src/share/classes/java/sql/Date.java
@@ -150,6 +150,7 @@
      * <P>
      * @return a String in yyyy-mm-dd format
      */
+    @SuppressWarnings("deprecation")
     public String toString () {
         int year = super.getYear() + 1900;
         int month = super.getMonth() + 1;
diff --git a/jdk/src/share/classes/java/sql/DriverManager.java b/jdk/src/share/classes/java/sql/DriverManager.java
index 4864eb2..0a7cd94 100644
--- a/jdk/src/share/classes/java/sql/DriverManager.java
+++ b/jdk/src/share/classes/java/sql/DriverManager.java
@@ -80,7 +80,7 @@
 
 
     // List of registered JDBC drivers
-    private final static CopyOnWriteArrayList<DriverInfo> registeredDrivers = new CopyOnWriteArrayList<DriverInfo>();
+    private final static CopyOnWriteArrayList<DriverInfo> registeredDrivers = new CopyOnWriteArrayList<>();
     private static volatile int loginTimeout = 0;
     private static volatile java.io.PrintWriter logWriter = null;
     private static volatile java.io.PrintStream logStream = null;
@@ -357,7 +357,7 @@
      * @return the list of JDBC Drivers loaded by the caller's class loader
      */
     public static java.util.Enumeration<Driver> getDrivers() {
-        java.util.Vector<Driver> result = new java.util.Vector<Driver>();
+        java.util.Vector<Driver> result = new java.util.Vector<>();
 
         // Gets the classloader of the code that called this method, may
         // be null.
@@ -621,15 +621,18 @@
         this.driver = driver;
     }
 
+    @Override
     public boolean equals(Object other) {
         return (other instanceof DriverInfo)
                 && this.driver == ((DriverInfo) other).driver;
     }
 
+    @Override
     public int hashCode() {
         return driver.hashCode();
     }
 
+    @Override
     public String toString() {
         return ("driver[className="  + driver + "]");
     }
diff --git a/jdk/src/share/classes/java/sql/Time.java b/jdk/src/share/classes/java/sql/Time.java
index 22d60d6..230e07b 100644
--- a/jdk/src/share/classes/java/sql/Time.java
+++ b/jdk/src/share/classes/java/sql/Time.java
@@ -115,6 +115,7 @@
      *
      * @return a <code>String</code> in hh:mm:ss format
      */
+    @SuppressWarnings("deprecation")
     public String toString () {
         int hour = super.getHours();
         int minute = super.getMinutes();
diff --git a/jdk/src/share/classes/java/sql/Timestamp.java b/jdk/src/share/classes/java/sql/Timestamp.java
index 14f648b2..18b61ed 100644
--- a/jdk/src/share/classes/java/sql/Timestamp.java
+++ b/jdk/src/share/classes/java/sql/Timestamp.java
@@ -271,6 +271,7 @@
      * @return a <code>String</code> object in
      *           <code>yyyy-mm-dd hh:mm:ss.fffffffff</code> format
      */
+    @SuppressWarnings("deprecation")
     public String toString () {
 
         int year = super.getYear() + 1900;
diff --git a/jdk/src/share/classes/java/util/Currency.java b/jdk/src/share/classes/java/util/Currency.java
index dc9271a..87b7e01 100644
--- a/jdk/src/share/classes/java/util/Currency.java
+++ b/jdk/src/share/classes/java/util/Currency.java
@@ -189,7 +189,7 @@
     private static final int VALID_FORMAT_VERSION = 1;
 
     static {
-        AccessController.doPrivileged(new PrivilegedAction() {
+        AccessController.doPrivileged(new PrivilegedAction<Object>() {
             public Object run() {
                 String homeDir = System.getProperty("java.home");
                 try {
@@ -431,7 +431,9 @@
             }
         }
 
-        return (Set<Currency>) available.clone();
+        @SuppressWarnings("unchecked")
+        Set<Currency> result = (Set<Currency>) available.clone();
+        return result;
     }
 
     /**
diff --git a/jdk/src/share/classes/java/util/Date.java b/jdk/src/share/classes/java/util/Date.java
index e5e5e14..7735209 100644
--- a/jdk/src/share/classes/java/util/Date.java
+++ b/jdk/src/share/classes/java/util/Date.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 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
@@ -770,7 +770,7 @@
      */
     @Deprecated
     public int getDay() {
-        return normalize().getDayOfWeek() - gcal.SUNDAY;
+        return normalize().getDayOfWeek() - BaseCalendar.SUNDAY;
     }
 
     /**
@@ -1027,7 +1027,7 @@
         BaseCalendar.Date date = normalize();
         StringBuilder sb = new StringBuilder(28);
         int index = date.getDayOfWeek();
-        if (index == gcal.SUNDAY) {
+        if (index == BaseCalendar.SUNDAY) {
             index = 8;
         }
         convertToAbbr(sb, wtb[index]).append(' ');                        // EEE
@@ -1039,7 +1039,7 @@
         CalendarUtils.sprintf0d(sb, date.getSeconds(), 2).append(' '); // ss
         TimeZone zi = date.getZone();
         if (zi != null) {
-            sb.append(zi.getDisplayName(date.isDaylightTime(), zi.SHORT, Locale.US)); // zzz
+            sb.append(zi.getDisplayName(date.isDaylightTime(), TimeZone.SHORT, Locale.US)); // zzz
         } else {
             sb.append("GMT");
         }
@@ -1237,7 +1237,7 @@
             }
             GregorianCalendar gc = new GregorianCalendar(tz);
             gc.clear();
-            gc.set(gc.MILLISECOND, ms);
+            gc.set(GregorianCalendar.MILLISECOND, ms);
             gc.set(y, m-1, d, hh, mm, ss);
             fastTime = gc.getTimeInMillis();
             BaseCalendar cal = getCalendarSystem(fastTime);
diff --git a/jdk/src/share/classes/java/util/Formatter.java b/jdk/src/share/classes/java/util/Formatter.java
index 038ec6e..65d34fa 100644
--- a/jdk/src/share/classes/java/util/Formatter.java
+++ b/jdk/src/share/classes/java/util/Formatter.java
@@ -2879,7 +2879,7 @@
         }
 
         public String toString() {
-            StringBuilder sb = new StringBuilder('%');
+            StringBuilder sb = new StringBuilder("%");
             // Flags.UPPERCASE is set internally for legal conversions.
             Flags dupf = f.dup().remove(Flags.UPPERCASE);
             sb.append(dupf.toString());
diff --git a/jdk/src/share/classes/java/util/GregorianCalendar.java b/jdk/src/share/classes/java/util/GregorianCalendar.java
index 3a6d203..586524b 100644
--- a/jdk/src/share/classes/java/util/GregorianCalendar.java
+++ b/jdk/src/share/classes/java/util/GregorianCalendar.java
@@ -947,7 +947,7 @@
             }
 
             if (month >= 0) {
-                set(MONTH, (int) (month % 12));
+                set(MONTH, month % 12);
             } else {
                 // month < 0
                 month %= 12;
@@ -1313,8 +1313,8 @@
                 }
 
                 // the first day of week of the month.
-                long monthDay1st = calsys.getDayOfWeekDateOnOrBefore(month1 + 6,
-                                                                     getFirstDayOfWeek());
+                long monthDay1st = BaseCalendar.getDayOfWeekDateOnOrBefore(month1 + 6,
+                                                                           getFirstDayOfWeek());
                 // if the week has enough days to form a week, the
                 // week starts from the previous month.
                 if ((int)(monthDay1st - month1) >= getMinimalDaysInFirstWeek()) {
@@ -1407,7 +1407,7 @@
                     return;
                 }
                 long fd = getCurrentFixedDate();
-                long dowFirst = calsys.getDayOfWeekDateOnOrBefore(fd, getFirstDayOfWeek());
+                long dowFirst = BaseCalendar.getDayOfWeekDateOnOrBefore(fd, getFirstDayOfWeek());
                 fd += amount;
                 if (fd < dowFirst) {
                     fd += 7;
@@ -1926,7 +1926,7 @@
      * Returns the millisecond offset from the beginning of this
      * year. This Calendar object must have been normalized.
      */
-    private final long getYearOffsetInMillis() {
+    private long getYearOffsetInMillis() {
         long t = (internalGet(DAY_OF_YEAR) - 1) * 24;
         t += internalGet(HOUR_OF_DAY);
         t *= 60;
@@ -2485,8 +2485,8 @@
                         if (cdate.isLeapYear()) {
                             nextJan1++;
                         }
-                        long nextJan1st = calsys.getDayOfWeekDateOnOrBefore(nextJan1 + 6,
-                                                                            getFirstDayOfWeek());
+                        long nextJan1st = BaseCalendar.getDayOfWeekDateOnOrBefore(nextJan1 + 6,
+                                                                                  getFirstDayOfWeek());
                         int ndays = (int)(nextJan1st - nextJan1);
                         if (ndays >= getMinimalDaysInFirstWeek() && fixedDate >= (nextJan1st - 7)) {
                             // The first days forms a week in which the date is included.
@@ -2518,8 +2518,8 @@
                         calForJan1 = gcal;
                     }
 
-                    long nextJan1st = calForJan1.getDayOfWeekDateOnOrBefore(nextJan1 + 6,
-                                                                            getFirstDayOfWeek());
+                    long nextJan1st = BaseCalendar.getDayOfWeekDateOnOrBefore(nextJan1 + 6,
+                                                                              getFirstDayOfWeek());
                     int ndays = (int)(nextJan1st - nextJan1);
                     if (ndays >= getMinimalDaysInFirstWeek() && fixedDate >= (nextJan1st - 7)) {
                         // The first days forms a week in which the date is included.
@@ -2543,11 +2543,11 @@
      * @param fixedDate the fixed date of the last day of the period
      * @return the number of weeks of the given period
      */
-    private final int getWeekNumber(long fixedDay1, long fixedDate) {
+    private int getWeekNumber(long fixedDay1, long fixedDate) {
         // We can always use `gcal' since Julian and Gregorian are the
         // same thing for this calculation.
-        long fixedDay1st = gcal.getDayOfWeekDateOnOrBefore(fixedDay1 + 6,
-                                                           getFirstDayOfWeek());
+        long fixedDay1st = Gregorian.getDayOfWeekDateOnOrBefore(fixedDay1 + 6,
+                                                                getFirstDayOfWeek());
         int ndays = (int)(fixedDay1st - fixedDay1);
         assert ndays <= 7;
         if (ndays >= getMinimalDaysInFirstWeek()) {
@@ -2818,16 +2818,16 @@
                 }
             } else {
                 if (isFieldSet(fieldMask, WEEK_OF_MONTH)) {
-                    long firstDayOfWeek = cal.getDayOfWeekDateOnOrBefore(fixedDate + 6,
-                                                                         getFirstDayOfWeek());
+                    long firstDayOfWeek = BaseCalendar.getDayOfWeekDateOnOrBefore(fixedDate + 6,
+                                                                                  getFirstDayOfWeek());
                     // If we have enough days in the first week, then
                     // move to the previous week.
                     if ((firstDayOfWeek - fixedDate) >= getMinimalDaysInFirstWeek()) {
                         firstDayOfWeek -= 7;
                     }
                     if (isFieldSet(fieldMask, DAY_OF_WEEK)) {
-                        firstDayOfWeek = cal.getDayOfWeekDateOnOrBefore(firstDayOfWeek + 6,
-                                                                        internalGet(DAY_OF_WEEK));
+                        firstDayOfWeek = BaseCalendar.getDayOfWeekDateOnOrBefore(firstDayOfWeek + 6,
+                                                                                 internalGet(DAY_OF_WEEK));
                     }
                     // In lenient mode, we treat days of the previous
                     // months as a part of the specified
@@ -2850,15 +2850,15 @@
                         dowim = 1;
                     }
                     if (dowim >= 0) {
-                        fixedDate = cal.getDayOfWeekDateOnOrBefore(fixedDate + (7 * dowim) - 1,
-                                                                   dayOfWeek);
+                        fixedDate = BaseCalendar.getDayOfWeekDateOnOrBefore(fixedDate + (7 * dowim) - 1,
+                                                                            dayOfWeek);
                     } else {
                         // Go to the first day of the next week of
                         // the specified week boundary.
                         int lastDate = monthLength(month, year) + (7 * (dowim + 1));
                         // Then, get the day of week date on or before the last date.
-                        fixedDate = cal.getDayOfWeekDateOnOrBefore(fixedDate + lastDate - 1,
-                                                                   dayOfWeek);
+                        fixedDate = BaseCalendar.getDayOfWeekDateOnOrBefore(fixedDate + lastDate - 1,
+                                                                            dayOfWeek);
                     }
                 }
             }
@@ -2877,8 +2877,8 @@
                 fixedDate += internalGet(DAY_OF_YEAR);
                 fixedDate--;
             } else {
-                long firstDayOfWeek = cal.getDayOfWeekDateOnOrBefore(fixedDate + 6,
-                                                                     getFirstDayOfWeek());
+                long firstDayOfWeek = BaseCalendar.getDayOfWeekDateOnOrBefore(fixedDate + 6,
+                                                                              getFirstDayOfWeek());
                 // If we have enough days in the first week, then move
                 // to the previous week.
                 if ((firstDayOfWeek - fixedDate) >= getMinimalDaysInFirstWeek()) {
@@ -2887,8 +2887,8 @@
                 if (isFieldSet(fieldMask, DAY_OF_WEEK)) {
                     int dayOfWeek = internalGet(DAY_OF_WEEK);
                     if (dayOfWeek != getFirstDayOfWeek()) {
-                        firstDayOfWeek = cal.getDayOfWeekDateOnOrBefore(firstDayOfWeek + 6,
-                                                                        dayOfWeek);
+                        firstDayOfWeek = BaseCalendar.getDayOfWeekDateOnOrBefore(firstDayOfWeek + 6,
+                                                                                 dayOfWeek);
                     }
                 }
                 fixedDate = firstDayOfWeek + 7 * ((long)internalGet(WEEK_OF_YEAR) - 1);
@@ -2903,7 +2903,7 @@
      * in sync). Otherwise, a cloned object is returned after calling
      * complete() in lenient mode.
      */
-    private final GregorianCalendar getNormalizedCalendar() {
+    private GregorianCalendar getNormalizedCalendar() {
         GregorianCalendar gc;
         if (isFullyNormalized()) {
             gc = this;
@@ -2920,7 +2920,7 @@
      * Returns the Julian calendar system instance (singleton). 'jcal'
      * and 'jeras' are set upon the return.
      */
-    synchronized private static final BaseCalendar getJulianCalendarSystem() {
+    synchronized private static BaseCalendar getJulianCalendarSystem() {
         if (jcal == null) {
             jcal = (JulianCalendar) CalendarSystem.forName("julian");
             jeras = jcal.getEras();
@@ -2958,7 +2958,7 @@
      * or Julian).
      * @param fixedDate the fixed date representation of the date
      */
-    private final long getFixedDateJan1(BaseCalendar.Date date, long fixedDate) {
+    private long getFixedDateJan1(BaseCalendar.Date date, long fixedDate) {
         assert date.getNormalizedYear() == gregorianCutoverYear ||
             date.getNormalizedYear() == gregorianCutoverYearJulian;
         if (gregorianCutoverYear != gregorianCutoverYearJulian) {
@@ -2984,7 +2984,7 @@
      * or Julian).
      * @param fixedDate the fixed date representation of the date
      */
-    private final long getFixedDateMonth1(BaseCalendar.Date date, long fixedDate) {
+    private long getFixedDateMonth1(BaseCalendar.Date date, long fixedDate) {
         assert date.getNormalizedYear() == gregorianCutoverYear ||
             date.getNormalizedYear() == gregorianCutoverYearJulian;
         BaseCalendar.Date gCutover = getGregorianCutoverDate();
@@ -3023,7 +3023,7 @@
      *
      * @param fd the fixed date
      */
-    private final BaseCalendar.Date getCalendarDate(long fd) {
+    private BaseCalendar.Date getCalendarDate(long fd) {
         BaseCalendar cal = (fd >= gregorianCutoverDate) ? gcal : getJulianCalendarSystem();
         BaseCalendar.Date d = (BaseCalendar.Date) cal.newCalendarDate(TimeZone.NO_TIMEZONE);
         cal.getCalendarDateFromFixedDate(d, fd);
@@ -3034,7 +3034,7 @@
      * Returns the Gregorian cutover date as a BaseCalendar.Date. The
      * date is a Gregorian date.
      */
-    private final BaseCalendar.Date getGregorianCutoverDate() {
+    private BaseCalendar.Date getGregorianCutoverDate() {
         return getCalendarDate(gregorianCutoverDate);
     }
 
@@ -3042,7 +3042,7 @@
      * Returns the day before the Gregorian cutover date as a
      * BaseCalendar.Date. The date is a Julian date.
      */
-    private final BaseCalendar.Date getLastJulianDate() {
+    private BaseCalendar.Date getLastJulianDate() {
         return getCalendarDate(gregorianCutoverDate - 1);
     }
 
@@ -3052,7 +3052,7 @@
      *
      * @see #isLeapYear(int)
      */
-    private final int monthLength(int month, int year) {
+    private int monthLength(int month, int year) {
         return isLeapYear(year) ? LEAP_MONTH_LENGTH[month] : MONTH_LENGTH[month];
     }
 
@@ -3062,7 +3062,7 @@
      *
      * @see #isLeapYear(int)
      */
-    private final int monthLength(int month) {
+    private int monthLength(int month) {
         int year = internalGet(YEAR);
         if (internalGetEra() == BCE) {
             year = 1 - year;
@@ -3070,7 +3070,7 @@
         return monthLength(month, year);
     }
 
-    private final int actualMonthLength() {
+    private int actualMonthLength() {
         int year = cdate.getNormalizedYear();
         if (year != gregorianCutoverYear && year != gregorianCutoverYearJulian) {
             return calsys.getMonthLength(cdate);
@@ -3094,7 +3094,7 @@
      * Returns the length (in days) of the specified year. The year
      * must be normalized.
      */
-    private final int yearLength(int year) {
+    private int yearLength(int year) {
         return isLeapYear(year) ? 366 : 365;
     }
 
@@ -3102,7 +3102,7 @@
      * Returns the length (in days) of the year provided by
      * internalGet(YEAR).
      */
-    private final int yearLength() {
+    private int yearLength() {
         int year = internalGet(YEAR);
         if (internalGetEra() == BCE) {
             year = 1 - year;
@@ -3116,7 +3116,7 @@
      * 3, we want it to go to Feb 28.  Adjustments which might run into this
      * problem call this method to retain the proper month.
      */
-    private final void pinDayOfMonth() {
+    private void pinDayOfMonth() {
         int year = internalGet(YEAR);
         int monthLen;
         if (year > gregorianCutoverYear || year < gregorianCutoverYearJulian) {
@@ -3135,14 +3135,14 @@
      * Returns the fixed date value of this object. The time value and
      * calendar fields must be in synch.
      */
-    private final long getCurrentFixedDate() {
+    private long getCurrentFixedDate() {
         return (calsys == gcal) ? cachedFixedDate : calsys.getFixedDate(cdate);
     }
 
     /**
      * Returns the new value after 'roll'ing the specified value and amount.
      */
-    private static final int getRolledValue(int value, int amount, int min, int max) {
+    private static int getRolledValue(int value, int amount, int min, int max) {
         assert value >= min && value <= max;
         int range = max - min + 1;
         amount %= range;
@@ -3160,7 +3160,7 @@
      * Returns the ERA.  We need a special method for this because the
      * default ERA is CE, but a zero (unset) ERA is BCE.
      */
-    private final int internalGetEra() {
+    private int internalGetEra() {
         return isSet(ERA) ? internalGet(ERA) : CE;
     }
 
diff --git a/jdk/src/share/classes/java/util/JapaneseImperialCalendar.java b/jdk/src/share/classes/java/util/JapaneseImperialCalendar.java
index c18c0bb..940ab62 100644
--- a/jdk/src/share/classes/java/util/JapaneseImperialCalendar.java
+++ b/jdk/src/share/classes/java/util/JapaneseImperialCalendar.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -260,8 +260,9 @@
             // max value could be one year short. For example, if it's
             // Showa 63 January 8, 63 is the actual max value since
             // Showa 64 January 8 doesn't exist.
-            if (!(lgd.getMonth() == BaseCalendar.JANUARY && lgd.getDayOfMonth() == 1))
+            if (!(lgd.getMonth() == BaseCalendar.JANUARY && lgd.getDayOfMonth() == 1)) {
                 y--;
+            }
             year = Math.min(y, year);
         }
         LEAST_MAX_VALUES[YEAR] = year; // Max year could be smaller than this value.
@@ -294,7 +295,7 @@
      * @param zone the given time zone.
      * @param aLocale the given locale.
      */
-    public JapaneseImperialCalendar(TimeZone zone, Locale aLocale) {
+    JapaneseImperialCalendar(TimeZone zone, Locale aLocale) {
         super(zone, aLocale);
         jdate = jcal.newCalendarDate(zone);
         setTimeInMillis(System.currentTimeMillis());
@@ -792,8 +793,8 @@
                 }
 
                 // the first day of week of the month.
-                long monthDay1st = jcal.getDayOfWeekDateOnOrBefore(month1 + 6,
-                                                                   getFirstDayOfWeek());
+                long monthDay1st = LocalGregorianCalendar.getDayOfWeekDateOnOrBefore(month1 + 6,
+                                                                                     getFirstDayOfWeek());
                 // if the week has enough days to form a week, the
                 // week starts from the previous month.
                 if ((int)(monthDay1st - month1) >= getMinimalDaysInFirstWeek()) {
@@ -884,7 +885,7 @@
                     return;
                 }
                 long fd = cachedFixedDate;
-                long dowFirst = jcal.getDayOfWeekDateOnOrBefore(fd, getFirstDayOfWeek());
+                long dowFirst = LocalGregorianCalendar.getDayOfWeekDateOnOrBefore(fd, getFirstDayOfWeek());
                 fd += amount;
                 if (fd < dowFirst) {
                     fd += 7;
@@ -963,8 +964,9 @@
                     Era era = eras[index];
                     name = (style == SHORT) ? era.getAbbreviation() : era.getName();
                 } else {
-                    if (field == DAY_OF_WEEK)
+                    if (field == DAY_OF_WEEK) {
                         --index;
+                    }
                     name = strings[index];
                 }
             }
@@ -1000,7 +1002,7 @@
     private Map<String,Integer> getDisplayNamesImpl(int field, int style, Locale locale) {
         ResourceBundle rb = LocaleData.getDateFormatData(locale);
         String key = getKey(field, style);
-        Map<String,Integer> map = new HashMap<String,Integer>();
+        Map<String,Integer> map = new HashMap<>();
         if (key != null) {
             String[] strings = rb.getStringArray(key);
             if (field == YEAR) {
@@ -1392,8 +1394,8 @@
                         jcal.normalize(jd);
                         long jan1 = jcal.getFixedDate(d);
                         long nextJan1 = jcal.getFixedDate(jd);
-                        long nextJan1st = jcal.getDayOfWeekDateOnOrBefore(nextJan1 + 6,
-                                                                          getFirstDayOfWeek());
+                        long nextJan1st = LocalGregorianCalendar.getDayOfWeekDateOnOrBefore(nextJan1 + 6,
+                                                                                            getFirstDayOfWeek());
                         int ndays = (int)(nextJan1st - nextJan1);
                         if (ndays >= getMinimalDaysInFirstWeek()) {
                             nextJan1st -= 7;
@@ -1523,7 +1525,7 @@
      * beyond the limit. The given CalendarDate object must have been
      * normalized before calling this method.
      */
-    private final long getYearOffsetInMillis(CalendarDate date) {
+    private long getYearOffsetInMillis(CalendarDate date) {
         long t = (jcal.getDayOfYear(date) - 1) * ONE_DAY;
         return t + date.getTimeOfDay() - date.getZoneOffset();
     }
@@ -1755,7 +1757,7 @@
                                 d.setMonth(pd.getMonth()).setDayOfMonth(pd.getDayOfMonth());
                             }
                         } else {
-                            d.setMonth(jcal.JANUARY).setDayOfMonth(1);
+                            d.setMonth(LocalGregorianCalendar.JANUARY).setDayOfMonth(1);
                         }
                         jcal.normalize(d);
                         prevJan1 = jcal.getFixedDate(d);
@@ -1780,8 +1782,8 @@
                         if (jdate.isLeapYear()) {
                             nextJan1++;
                         }
-                        long nextJan1st = jcal.getDayOfWeekDateOnOrBefore(nextJan1 + 6,
-                                                                          getFirstDayOfWeek());
+                        long nextJan1st = LocalGregorianCalendar.getDayOfWeekDateOnOrBefore(nextJan1 + 6,
+                                                                                            getFirstDayOfWeek());
                         int ndays = (int)(nextJan1st - nextJan1);
                         if (ndays >= getMinimalDaysInFirstWeek() && fixedDate >= (nextJan1st - 7)) {
                             // The first days forms a week in which the date is included.
@@ -1793,7 +1795,7 @@
                     long nextJan1;
                     if (jdate.getYear() == 1) {
                         d.addYear(+1);
-                        d.setMonth(jcal.JANUARY).setDayOfMonth(1);
+                        d.setMonth(LocalGregorianCalendar.JANUARY).setDayOfMonth(1);
                         nextJan1 = jcal.getFixedDate(d);
                     } else {
                         int nextEraIndex = getEraIndex(d) + 1;
@@ -1803,8 +1805,8 @@
                         jcal.normalize(d);
                         nextJan1 = jcal.getFixedDate(d);
                     }
-                    long nextJan1st = jcal.getDayOfWeekDateOnOrBefore(nextJan1 + 6,
-                                                                      getFirstDayOfWeek());
+                    long nextJan1st = LocalGregorianCalendar.getDayOfWeekDateOnOrBefore(nextJan1 + 6,
+                                                                                        getFirstDayOfWeek());
                     int ndays = (int)(nextJan1st - nextJan1);
                     if (ndays >= getMinimalDaysInFirstWeek() && fixedDate >= (nextJan1st - 7)) {
                         // The first days forms a week in which the date is included.
@@ -1828,11 +1830,11 @@
      * @param fixedDate the fixed date of the last day of the period
      * @return the number of weeks of the given period
      */
-    private final int getWeekNumber(long fixedDay1, long fixedDate) {
+    private int getWeekNumber(long fixedDay1, long fixedDate) {
         // We can always use `jcal' since Julian and Gregorian are the
         // same thing for this calculation.
-        long fixedDay1st = jcal.getDayOfWeekDateOnOrBefore(fixedDay1 + 6,
-                                                           getFirstDayOfWeek());
+        long fixedDay1st = LocalGregorianCalendar.getDayOfWeekDateOnOrBefore(fixedDay1 + 6,
+                                                                             getFirstDayOfWeek());
         int ndays = (int)(fixedDay1st - fixedDay1);
         assert ndays <= 7;
         if (ndays >= getMinimalDaysInFirstWeek()) {
@@ -2026,10 +2028,12 @@
         if (year == MIN_VALUES[YEAR]) {
             CalendarDate dx = jcal.getCalendarDate(Long.MIN_VALUE, getZone());
             int m = dx.getMonth() - 1;
-            if (month < m)
+            if (month < m) {
                 month = m;
-            if (month == m)
+            }
+            if (month == m) {
                 firstDayOfMonth = dx.getDayOfMonth();
+            }
         }
 
         LocalGregorianCalendar.Date date = jcal.newCalendarDate(TimeZone.NO_TIMEZONE);
@@ -2058,16 +2062,16 @@
                 }
             } else {
                 if (isFieldSet(fieldMask, WEEK_OF_MONTH)) {
-                    long firstDayOfWeek = jcal.getDayOfWeekDateOnOrBefore(fixedDate + 6,
-                                                                          getFirstDayOfWeek());
+                    long firstDayOfWeek = LocalGregorianCalendar.getDayOfWeekDateOnOrBefore(fixedDate + 6,
+                                                                                            getFirstDayOfWeek());
                     // If we have enough days in the first week, then
                     // move to the previous week.
                     if ((firstDayOfWeek - fixedDate) >= getMinimalDaysInFirstWeek()) {
                         firstDayOfWeek -= 7;
                     }
                     if (isFieldSet(fieldMask, DAY_OF_WEEK)) {
-                        firstDayOfWeek = jcal.getDayOfWeekDateOnOrBefore(firstDayOfWeek + 6,
-                                                                         internalGet(DAY_OF_WEEK));
+                        firstDayOfWeek = LocalGregorianCalendar.getDayOfWeekDateOnOrBefore(firstDayOfWeek + 6,
+                                                                                           internalGet(DAY_OF_WEEK));
                     }
                     // In lenient mode, we treat days of the previous
                     // months as a part of the specified
@@ -2090,15 +2094,15 @@
                         dowim = 1;
                     }
                     if (dowim >= 0) {
-                        fixedDate = jcal.getDayOfWeekDateOnOrBefore(fixedDate + (7 * dowim) - 1,
-                                                                    dayOfWeek);
+                        fixedDate = LocalGregorianCalendar.getDayOfWeekDateOnOrBefore(fixedDate + (7 * dowim) - 1,
+                                                                                      dayOfWeek);
                     } else {
                         // Go to the first day of the next week of
                         // the specified week boundary.
                         int lastDate = monthLength(month, year) + (7 * (dowim + 1));
                         // Then, get the day of week date on or before the last date.
-                        fixedDate = jcal.getDayOfWeekDateOnOrBefore(fixedDate + lastDate - 1,
-                                                                    dayOfWeek);
+                        fixedDate = LocalGregorianCalendar.getDayOfWeekDateOnOrBefore(fixedDate + lastDate - 1,
+                                                                                      dayOfWeek);
                     }
                 }
             }
@@ -2112,8 +2116,8 @@
                 fixedDate += internalGet(DAY_OF_YEAR);
                 fixedDate--;
             } else {
-                long firstDayOfWeek = jcal.getDayOfWeekDateOnOrBefore(fixedDate + 6,
-                                                                      getFirstDayOfWeek());
+                long firstDayOfWeek = LocalGregorianCalendar.getDayOfWeekDateOnOrBefore(fixedDate + 6,
+                                                                                        getFirstDayOfWeek());
                 // If we have enough days in the first week, then move
                 // to the previous week.
                 if ((firstDayOfWeek - fixedDate) >= getMinimalDaysInFirstWeek()) {
@@ -2122,8 +2126,8 @@
                 if (isFieldSet(fieldMask, DAY_OF_WEEK)) {
                     int dayOfWeek = internalGet(DAY_OF_WEEK);
                     if (dayOfWeek != getFirstDayOfWeek()) {
-                        firstDayOfWeek = jcal.getDayOfWeekDateOnOrBefore(firstDayOfWeek + 6,
-                                                                         dayOfWeek);
+                        firstDayOfWeek = LocalGregorianCalendar.getDayOfWeekDateOnOrBefore(firstDayOfWeek + 6,
+                                                                                           dayOfWeek);
                     }
                 }
                 fixedDate = firstDayOfWeek + 7 * ((long)internalGet(WEEK_OF_YEAR) - 1);
@@ -2140,7 +2144,7 @@
      * calculated. The date has to be in the cut-over year.
      * @param fixedDate the fixed date representation of the date
      */
-    private final long getFixedDateJan1(LocalGregorianCalendar.Date date, long fixedDate) {
+    private long getFixedDateJan1(LocalGregorianCalendar.Date date, long fixedDate) {
         Era era = date.getEra();
         if (date.getEra() != null && date.getYear() == 1) {
             for (int eraIndex = getEraIndex(date); eraIndex > 0; eraIndex--) {
@@ -2154,7 +2158,7 @@
             }
         }
         CalendarDate d = gcal.newCalendarDate(TimeZone.NO_TIMEZONE);
-        d.setDate(date.getNormalizedYear(), gcal.JANUARY, 1);
+        d.setDate(date.getNormalizedYear(), Gregorian.JANUARY, 1);
         return gcal.getFixedDate(d);
     }
 
@@ -2166,7 +2170,7 @@
      * calculated. The date must be in the era transition year.
      * @param fixedDate the fixed date representation of the date
      */
-    private final long getFixedDateMonth1(LocalGregorianCalendar.Date date,
+    private long getFixedDateMonth1(LocalGregorianCalendar.Date date,
                                           long fixedDate) {
         int eraIndex = getTransitionEraIndex(date);
         if (eraIndex != -1) {
@@ -2187,7 +2191,7 @@
      *
      * @param fd the fixed date
      */
-    private static final LocalGregorianCalendar.Date getCalendarDate(long fd) {
+    private static LocalGregorianCalendar.Date getCalendarDate(long fd) {
         LocalGregorianCalendar.Date d = jcal.newCalendarDate(TimeZone.NO_TIMEZONE);
         jcal.getCalendarDateFromFixedDate(d, fd);
         return d;
@@ -2199,7 +2203,7 @@
      *
      * @see #isLeapYear(int)
      */
-    private final int monthLength(int month, int gregorianYear) {
+    private int monthLength(int month, int gregorianYear) {
         return CalendarUtils.isGregorianLeapYear(gregorianYear) ?
             GregorianCalendar.LEAP_MONTH_LENGTH[month] : GregorianCalendar.MONTH_LENGTH[month];
     }
@@ -2210,13 +2214,13 @@
      *
      * @see #isLeapYear(int)
      */
-    private final int monthLength(int month) {
+    private int monthLength(int month) {
         assert jdate.isNormalized();
         return jdate.isLeapYear() ?
             GregorianCalendar.LEAP_MONTH_LENGTH[month] : GregorianCalendar.MONTH_LENGTH[month];
     }
 
-    private final int actualMonthLength() {
+    private int actualMonthLength() {
         int length = jcal.getMonthLength(jdate);
         int eraIndex = getTransitionEraIndex(jdate);
         if (eraIndex == -1) {
@@ -2239,7 +2243,7 @@
      * January 3, then the era index for Heisei is returned. If the
      * given date is not in any transition month, then -1 is returned.
      */
-    private static final int getTransitionEraIndex(LocalGregorianCalendar.Date date) {
+    private static int getTransitionEraIndex(LocalGregorianCalendar.Date date) {
         int eraIndex = getEraIndex(date);
         CalendarDate transitionDate = eras[eraIndex].getSinceDate();
         if (transitionDate.getYear() == date.getNormalizedYear() &&
@@ -2256,7 +2260,7 @@
         return -1;
     }
 
-    private final boolean isTransitionYear(int normalizedYear) {
+    private boolean isTransitionYear(int normalizedYear) {
         for (int i = eras.length - 1; i > 0; i--) {
             int transitionYear = eras[i].getSinceDate().getYear();
             if (normalizedYear == transitionYear) {
@@ -2269,7 +2273,7 @@
         return false;
     }
 
-    private static final int getEraIndex(LocalGregorianCalendar.Date date) {
+    private static int getEraIndex(LocalGregorianCalendar.Date date) {
         Era era = date.getEra();
         for (int i = eras.length - 1; i > 0; i--) {
             if (eras[i] == era) {
@@ -2284,7 +2288,7 @@
      * in sync). Otherwise, a cloned object is returned after calling
      * complete() in lenient mode.
      */
-    private final JapaneseImperialCalendar getNormalizedCalendar() {
+    private JapaneseImperialCalendar getNormalizedCalendar() {
         JapaneseImperialCalendar jc;
         if (isFullyNormalized()) {
             jc = this;
@@ -2303,7 +2307,7 @@
      * 3, we want it to go to Feb 28.  Adjustments which might run into this
      * problem call this method to retain the proper month.
      */
-    private final void pinDayOfMonth(LocalGregorianCalendar.Date date) {
+    private void pinDayOfMonth(LocalGregorianCalendar.Date date) {
         int year = date.getYear();
         int dom = date.getDayOfMonth();
         if (year != getMinimum(YEAR)) {
@@ -2347,7 +2351,7 @@
     /**
      * Returns the new value after 'roll'ing the specified value and amount.
      */
-    private static final int getRolledValue(int value, int amount, int min, int max) {
+    private static int getRolledValue(int value, int amount, int min, int max) {
         assert value >= min && value <= max;
         int range = max - min + 1;
         amount %= range;
@@ -2365,7 +2369,7 @@
      * Returns the ERA.  We need a special method for this because the
      * default ERA is the current era, but a zero (unset) ERA means before Meiji.
      */
-    private final int internalGetEra() {
+    private int internalGetEra() {
         return isSet(ERA) ? internalGet(ERA) : eras.length - 1;
     }
 
diff --git a/jdk/src/share/classes/java/util/PropertyPermission.java b/jdk/src/share/classes/java/util/PropertyPermission.java
index 026ce9b..1773188 100644
--- a/jdk/src/share/classes/java/util/PropertyPermission.java
+++ b/jdk/src/share/classes/java/util/PropertyPermission.java
@@ -305,7 +305,7 @@
                 switch(a[i-matchlen]) {
                 case ',':
                     seencomma = true;
-                    /*FALLTHROUGH*/
+                    break;
                 case ' ': case '\r': case '\n':
                 case '\f': case '\t':
                     break;
@@ -442,7 +442,7 @@
      * Key is property name; value is PropertyPermission.
      * Not serialized; see serialization section at end of class.
      */
-    private transient Map perms;
+    private transient Map<String, Permission> perms;
 
     /**
      * Boolean saying if "*" is in the collection.
@@ -458,7 +458,7 @@
      */
 
     public PropertyPermissionCollection() {
-        perms = new HashMap(32);     // Capacity for default policy
+        perms = new HashMap<>(32);     // Capacity for default policy
         all_allowed = false;
     }
 
@@ -593,7 +593,7 @@
      * @return an enumeration of all the PropertyPermission objects.
      */
 
-    public Enumeration elements() {
+    public Enumeration<Permission> elements() {
         // Convert Iterator of Map values into an Enumeration
         synchronized (this) {
             return Collections.enumeration(perms.values());
@@ -633,7 +633,7 @@
         // Don't call out.defaultWriteObject()
 
         // Copy perms into a Hashtable
-        Hashtable permissions = new Hashtable(perms.size()*2);
+        Hashtable<String, Permission> permissions = new Hashtable<>(perms.size()*2);
         synchronized (this) {
             permissions.putAll(perms);
         }
@@ -660,8 +660,10 @@
         all_allowed = gfields.get("all_allowed", false);
 
         // Get permissions
-        Hashtable permissions = (Hashtable)gfields.get("permissions", null);
-        perms = new HashMap(permissions.size()*2);
+        @SuppressWarnings("unchecked")
+        Hashtable<String, Permission> permissions =
+            (Hashtable<String, Permission>)gfields.get("permissions", null);
+        perms = new HashMap<>(permissions.size()*2);
         perms.putAll(permissions);
     }
 }
diff --git a/jdk/src/share/classes/java/util/ResourceBundle.java b/jdk/src/share/classes/java/util/ResourceBundle.java
index a4a4d55..c7b425d 100644
--- a/jdk/src/share/classes/java/util/ResourceBundle.java
+++ b/jdk/src/share/classes/java/util/ResourceBundle.java
@@ -294,7 +294,7 @@
     /**
      * Queue for reference objects referring to class loaders or bundles.
      */
-    private static final ReferenceQueue referenceQueue = new ReferenceQueue();
+    private static final ReferenceQueue<Object> referenceQueue = new ReferenceQueue<>();
 
     /**
      * The parent bundle of this bundle.
@@ -389,12 +389,13 @@
             if (parent != null) {
                 obj = parent.getObject(key);
             }
-            if (obj == null)
+            if (obj == null) {
                 throw new MissingResourceException("Can't find resource for bundle "
                                                    +this.getClass().getName()
                                                    +", key "+key,
                                                    this.getClass().getName(),
                                                    key);
+            }
         }
         return obj;
     }
@@ -418,7 +419,7 @@
     private static ClassLoader getLoader() {
         Class[] stack = getClassContext();
         /* Magic number 2 identifies our caller's caller */
-        Class c = stack[2];
+        Class<?> c = stack[2];
         ClassLoader cl = (c == null) ? null : c.getClassLoader();
         if (cl == null) {
             // When the caller's loader is the boot class loader, cl is null
@@ -488,7 +489,7 @@
      * null, but the base name and the locale must have a non-null
      * value.
      */
-    private static final class CacheKey implements Cloneable {
+    private static class CacheKey implements Cloneable {
         // These three are the actual keys for lookup in Map.
         private String name;
         private Locale locale;
@@ -583,8 +584,7 @@
                         // treat it as unequal
                         && (loader != null)
                         && (loader == otherEntry.loaderRef.get());
-            } catch (NullPointerException e) {
-            } catch (ClassCastException e) {
+            } catch (    NullPointerException | ClassCastException e) {
             }
             return false;
         }
@@ -669,11 +669,11 @@
      * garbage collected when nobody else is using them. The ResourceBundle
      * class has no reason to keep class loaders alive.
      */
-    private static final class LoaderReference extends WeakReference<ClassLoader>
-                                               implements CacheKeyReference {
+    private static class LoaderReference extends WeakReference<ClassLoader>
+                                         implements CacheKeyReference {
         private CacheKey cacheKey;
 
-        LoaderReference(ClassLoader referent, ReferenceQueue q, CacheKey key) {
+        LoaderReference(ClassLoader referent, ReferenceQueue<Object> q, CacheKey key) {
             super(referent, q);
             cacheKey = key;
         }
@@ -687,11 +687,11 @@
      * References to bundles are soft references so that they can be garbage
      * collected when they have no hard references.
      */
-    private static final class BundleReference extends SoftReference<ResourceBundle>
-                                               implements CacheKeyReference {
+    private static class BundleReference extends SoftReference<ResourceBundle>
+                                         implements CacheKeyReference {
         private CacheKey cacheKey;
 
-        BundleReference(ResourceBundle referent, ReferenceQueue q, CacheKey key) {
+        BundleReference(ResourceBundle referent, ReferenceQueue<Object> q, CacheKey key) {
             super(referent, q);
             cacheKey = key;
         }
@@ -1331,8 +1331,8 @@
      * Checks if the given <code>List</code> is not null, not empty,
      * not having null in its elements.
      */
-    private static final boolean checkList(List a) {
-        boolean valid = (a != null && a.size() != 0);
+    private static boolean checkList(List<?> a) {
+        boolean valid = (a != null && !a.isEmpty());
         if (valid) {
             int size = a.size();
             for (int i = 0; valid && i < size; i++) {
@@ -1342,12 +1342,12 @@
         return valid;
     }
 
-    private static final ResourceBundle findBundle(CacheKey cacheKey,
-                                                   List<Locale> candidateLocales,
-                                                   List<String> formats,
-                                                   int index,
-                                                   Control control,
-                                                   ResourceBundle baseBundle) {
+    private static ResourceBundle findBundle(CacheKey cacheKey,
+                                             List<Locale> candidateLocales,
+                                             List<String> formats,
+                                             int index,
+                                             Control control,
+                                             ResourceBundle baseBundle) {
         Locale targetLocale = candidateLocales.get(index);
         ResourceBundle parent = null;
         if (index != candidateLocales.size() - 1) {
@@ -1419,10 +1419,10 @@
         return parent;
     }
 
-    private static final ResourceBundle loadBundle(CacheKey cacheKey,
-                                                   List<String> formats,
-                                                   Control control,
-                                                   boolean reload) {
+    private static ResourceBundle loadBundle(CacheKey cacheKey,
+                                             List<String> formats,
+                                             Control control,
+                                             boolean reload) {
 
         // Here we actually load the bundle in the order of formats
         // specified by the getFormats() value.
@@ -1459,7 +1459,7 @@
         return bundle;
     }
 
-    private static final boolean isValidBundle(ResourceBundle bundle) {
+    private static boolean isValidBundle(ResourceBundle bundle) {
         return bundle != null && bundle != NONEXISTENT_BUNDLE;
     }
 
@@ -1467,7 +1467,7 @@
      * Determines whether any of resource bundles in the parent chain,
      * including the leaf, have expired.
      */
-    private static final boolean hasValidParentChain(ResourceBundle bundle) {
+    private static boolean hasValidParentChain(ResourceBundle bundle) {
         long now = System.currentTimeMillis();
         while (bundle != null) {
             if (bundle.expired) {
@@ -1488,9 +1488,9 @@
     /**
      * Throw a MissingResourceException with proper message
      */
-    private static final void throwMissingResourceException(String baseName,
-                                                            Locale locale,
-                                                            Throwable cause) {
+    private static void throwMissingResourceException(String baseName,
+                                                      Locale locale,
+                                                      Throwable cause) {
         // If the cause is a MissingResourceException, avoid creating
         // a long chain. (6355009)
         if (cause instanceof MissingResourceException) {
@@ -1513,8 +1513,8 @@
      * cache or its parent has expired. <code>bundle.expire</code> is true
      * upon return if the bundle in the cache has expired.
      */
-    private static final ResourceBundle findBundleInCache(CacheKey cacheKey,
-                                                          Control control) {
+    private static ResourceBundle findBundleInCache(CacheKey cacheKey,
+                                                    Control control) {
         BundleReference bundleRef = cacheList.get(cacheKey);
         if (bundleRef == null) {
             return null;
@@ -1620,9 +1620,9 @@
      * the bundle before this call, the one found in the cache is
      * returned.
      */
-    private static final ResourceBundle putBundleInCache(CacheKey cacheKey,
-                                                         ResourceBundle bundle,
-                                                         Control control) {
+    private static ResourceBundle putBundleInCache(CacheKey cacheKey,
+                                                   ResourceBundle bundle,
+                                                   Control control) {
         setExpirationTime(cacheKey, control);
         if (cacheKey.expirationTime != Control.TTL_DONT_CACHE) {
             CacheKey key = (CacheKey) cacheKey.clone();
@@ -1653,7 +1653,7 @@
         return bundle;
     }
 
-    private static final void setExpirationTime(CacheKey cacheKey, Control control) {
+    private static void setExpirationTime(CacheKey cacheKey, Control control) {
         long ttl = control.getTimeToLive(cacheKey.getName(),
                                          cacheKey.getLocale());
         if (ttl >= 0) {
@@ -2350,18 +2350,27 @@
                     if (script.length() == 0 && region.length() > 0) {
                         // Supply script for users who want to use zh_Hans/zh_Hant
                         // as bundle names (recommended for Java7+)
-                        if (region.equals("TW") || region.equals("HK") || region.equals("MO")) {
+                        switch (region) {
+                        case "TW":
+                        case "HK":
+                        case "MO":
                             script = "Hant";
-                        } else if (region.equals("CN") || region.equals("SG")) {
+                            break;
+                        case "CN":
+                        case "SG":
                             script = "Hans";
+                            break;
                         }
                     } else if (script.length() > 0 && region.length() == 0) {
                         // Supply region(country) for users who still package Chinese
                         // bundles using old convension.
-                        if (script.equals("Hans")) {
+                        switch (script) {
+                        case "Hans":
                             region = "CN";
-                        } else if (script.equals("Hant")) {
+                            break;
+                        case "Hant":
                             region = "TW";
+                            break;
                         }
                     }
                 }
@@ -2562,6 +2571,7 @@
             ResourceBundle bundle = null;
             if (format.equals("java.class")) {
                 try {
+                    @SuppressWarnings("unchecked")
                     Class<? extends ResourceBundle> bundleClass
                         = (Class<? extends ResourceBundle>)loader.loadClass(bundleName);
 
diff --git a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicBoolean.java b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicBoolean.java
index c21df7b..a4d6d82 100644
--- a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicBoolean.java
+++ b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicBoolean.java
@@ -54,10 +54,10 @@
     private static final long valueOffset;
 
     static {
-      try {
-        valueOffset = unsafe.objectFieldOffset
-            (AtomicBoolean.class.getDeclaredField("value"));
-      } catch (Exception ex) { throw new Error(ex); }
+        try {
+            valueOffset = unsafe.objectFieldOffset
+                (AtomicBoolean.class.getDeclaredField("value"));
+        } catch (Exception ex) { throw new Error(ex); }
     }
 
     private volatile int value;
diff --git a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicInteger.java b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicInteger.java
index ec68acd..1bc7fa2 100644
--- a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicInteger.java
+++ b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicInteger.java
@@ -57,10 +57,10 @@
     private static final long valueOffset;
 
     static {
-      try {
-        valueOffset = unsafe.objectFieldOffset
-            (AtomicInteger.class.getDeclaredField("value"));
-      } catch (Exception ex) { throw new Error(ex); }
+        try {
+            valueOffset = unsafe.objectFieldOffset
+                (AtomicInteger.class.getDeclaredField("value"));
+        } catch (Exception ex) { throw new Error(ex); }
     }
 
     private volatile int value;
@@ -247,8 +247,7 @@
 
 
     /**
-     * Returns the value of this {@code AtomicInteger} as an
-     * {@code int}.
+     * Returns the value of this {@code AtomicInteger} as an {@code int}.
      */
     public int intValue() {
         return get();
diff --git a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicIntegerArray.java b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicIntegerArray.java
index 4622701..9928e59 100644
--- a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicIntegerArray.java
+++ b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicIntegerArray.java
@@ -35,7 +35,6 @@
 
 package java.util.concurrent.atomic;
 import sun.misc.Unsafe;
-import java.util.*;
 
 /**
  * An {@code int} array in which elements may be updated atomically.
diff --git a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java
index aed5d1f..9f4fee4 100644
--- a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java
+++ b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java
@@ -135,7 +135,6 @@
      */
     public abstract void lazySet(T obj, int newValue);
 
-
     /**
      * Gets the current value held in the field of the given object managed
      * by this updater.
@@ -266,11 +265,11 @@
         private static final Unsafe unsafe = Unsafe.getUnsafe();
         private final long offset;
         private final Class<T> tclass;
-        private final Class cclass;
+        private final Class<?> cclass;
 
         AtomicIntegerFieldUpdaterImpl(Class<T> tclass, String fieldName) {
             Field field = null;
-            Class caller = null;
+            Class<?> caller = null;
             int modifiers = 0;
             try {
                 field = tclass.getDeclaredField(fieldName);
@@ -283,7 +282,7 @@
                 throw new RuntimeException(ex);
             }
 
-            Class fieldt = field.getType();
+            Class<?> fieldt = field.getType();
             if (fieldt != int.class)
                 throw new IllegalArgumentException("Must be integer type");
 
diff --git a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicLong.java b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicLong.java
index bf2c71a..f503d57 100644
--- a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicLong.java
+++ b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicLong.java
@@ -71,10 +71,10 @@
     private static native boolean VMSupportsCS8();
 
     static {
-      try {
-        valueOffset = unsafe.objectFieldOffset
-            (AtomicLong.class.getDeclaredField("value"));
-      } catch (Exception ex) { throw new Error(ex); }
+        try {
+            valueOffset = unsafe.objectFieldOffset
+                (AtomicLong.class.getDeclaredField("value"));
+        } catch (Exception ex) { throw new Error(ex); }
     }
 
     private volatile long value;
@@ -270,8 +270,7 @@
     }
 
     /**
-     * Returns the value of this {@code AtomicLong} as a {@code long}
-     * value.
+     * Returns the value of this {@code AtomicLong} as a {@code long}.
      */
     public long longValue() {
         return get();
@@ -287,8 +286,8 @@
     }
 
     /**
-     * Returns the value of this {@code AtomicLong} as a {@code
-     * double} after a widening primitive conversion.
+     * Returns the value of this {@code AtomicLong} as a {@code double}
+     * after a widening primitive conversion.
      * @jls 5.1.2 Widening Primitive Conversions
      */
     public double doubleValue() {
diff --git a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicLongArray.java b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicLongArray.java
index ece5b6a..856ab39 100644
--- a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicLongArray.java
+++ b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicLongArray.java
@@ -35,7 +35,6 @@
 
 package java.util.concurrent.atomic;
 import sun.misc.Unsafe;
-import java.util.*;
 
 /**
  * A {@code long} array in which elements may be updated atomically.
@@ -136,7 +135,6 @@
         unsafe.putOrderedLong(array, checkedByteOffset(i), newValue);
     }
 
-
     /**
      * Atomically sets the element at position {@code i} to the given value
      * and returns the old value.
diff --git a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java
index fa0a857..ccc5acb 100644
--- a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java
+++ b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java
@@ -265,11 +265,11 @@
         private static final Unsafe unsafe = Unsafe.getUnsafe();
         private final long offset;
         private final Class<T> tclass;
-        private final Class cclass;
+        private final Class<?> cclass;
 
         CASUpdater(Class<T> tclass, String fieldName) {
             Field field = null;
-            Class caller = null;
+            Class<?> caller = null;
             int modifiers = 0;
             try {
                 field = tclass.getDeclaredField(fieldName);
@@ -282,7 +282,7 @@
                 throw new RuntimeException(ex);
             }
 
-            Class fieldt = field.getType();
+            Class<?> fieldt = field.getType();
             if (fieldt != long.class)
                 throw new IllegalArgumentException("Must be long type");
 
@@ -348,11 +348,11 @@
         private static final Unsafe unsafe = Unsafe.getUnsafe();
         private final long offset;
         private final Class<T> tclass;
-        private final Class cclass;
+        private final Class<?> cclass;
 
         LockedUpdater(Class<T> tclass, String fieldName) {
             Field field = null;
-            Class caller = null;
+            Class<?> caller = null;
             int modifiers = 0;
             try {
                 field = tclass.getDeclaredField(fieldName);
@@ -365,7 +365,7 @@
                 throw new RuntimeException(ex);
             }
 
-            Class fieldt = field.getType();
+            Class<?> fieldt = field.getType();
             if (fieldt != long.class)
                 throw new IllegalArgumentException("Must be long type");
 
diff --git a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicReference.java b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicReference.java
index 3178ca1..978664e 100644
--- a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicReference.java
+++ b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicReference.java
@@ -51,10 +51,10 @@
     private static final long valueOffset;
 
     static {
-      try {
-        valueOffset = unsafe.objectFieldOffset
-            (AtomicReference.class.getDeclaredField("value"));
-      } catch (Exception ex) { throw new Error(ex); }
+        try {
+            valueOffset = unsafe.objectFieldOffset
+                (AtomicReference.class.getDeclaredField("value"));
+        } catch (Exception ex) { throw new Error(ex); }
     }
 
     private volatile V value;
diff --git a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java
index b173f26..d92bdb5 100644
--- a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java
+++ b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java
@@ -113,6 +113,7 @@
         return getRaw(checkedByteOffset(i));
     }
 
+    @SuppressWarnings("unchecked")
     private E getRaw(long offset) {
         return (E) unsafe.getObjectVolatile(array, offset);
     }
@@ -150,7 +151,7 @@
     public final E getAndSet(int i, E newValue) {
         long offset = checkedByteOffset(i);
         while (true) {
-            E current = (E) getRaw(offset);
+            E current = getRaw(offset);
             if (compareAndSetRaw(offset, current, newValue))
                 return current;
         }
diff --git a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java
index 7b72f0f..f2e0118 100644
--- a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java
+++ b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java
@@ -183,7 +183,7 @@
         private final long offset;
         private final Class<T> tclass;
         private final Class<V> vclass;
-        private final Class cclass;
+        private final Class<?> cclass;
 
         /*
          * Internal type checks within all update methods contain
@@ -201,8 +201,8 @@
                                         Class<V> vclass,
                                         String fieldName) {
             Field field = null;
-            Class fieldClass = null;
-            Class caller = null;
+            Class<?> fieldClass = null;
+            Class<?> caller = null;
             int modifiers = 0;
             try {
                 field = tclass.getDeclaredField(fieldName);
@@ -280,6 +280,7 @@
             unsafe.putOrderedObject(obj, offset, newValue);
         }
 
+        @SuppressWarnings("unchecked")
         public V get(T obj) {
             if (obj == null || obj.getClass() != tclass || cclass != null)
                 targetCheck(obj);
diff --git a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicStampedReference.java b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicStampedReference.java
index 90aa3a0..5f8f1a0 100644
--- a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicStampedReference.java
+++ b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicStampedReference.java
@@ -155,7 +155,6 @@
              casPair(current, Pair.of(newReference, newStamp)));
     }
 
-
     /**
      * Unconditionally sets the value of both the reference and stamp.
      *
diff --git a/jdk/src/share/classes/java/util/jar/JarVerifier.java b/jdk/src/share/classes/java/util/jar/JarVerifier.java
index 4f84ac2..6a9a8b5 100644
--- a/jdk/src/share/classes/java/util/jar/JarVerifier.java
+++ b/jdk/src/share/classes/java/util/jar/JarVerifier.java
@@ -90,7 +90,7 @@
     private Object csdomain = new Object();
 
     /** collect -DIGEST-MANIFEST values for blacklist */
-    private List manifestDigests;
+    private List<Object> manifestDigests;
 
     public JarVerifier(byte rawBytes[]) {
         manifestRawBytes = rawBytes;
@@ -99,7 +99,7 @@
         sigFileData = new Hashtable(11);
         pendingBlocks = new ArrayList();
         baos = new ByteArrayOutputStream();
-        manifestDigests = new ArrayList();
+        manifestDigests = new ArrayList<>();
     }
 
     /**
@@ -872,7 +872,7 @@
         eagerValidation = eager;
     }
 
-    public synchronized List getManifestDigests() {
+    public synchronized List<Object> getManifestDigests() {
         return Collections.unmodifiableList(manifestDigests);
     }
 
diff --git a/jdk/src/share/classes/java/util/jar/JavaUtilJarAccessImpl.java b/jdk/src/share/classes/java/util/jar/JavaUtilJarAccessImpl.java
index c53ba0c..9541a5a 100644
--- a/jdk/src/share/classes/java/util/jar/JavaUtilJarAccessImpl.java
+++ b/jdk/src/share/classes/java/util/jar/JavaUtilJarAccessImpl.java
@@ -57,7 +57,7 @@
         jar.setEagerValidation(eager);
     }
 
-    public List getManifestDigests(JarFile jar) {
+    public List<Object> getManifestDigests(JarFile jar) {
         return jar.getManifestDigests();
     }
 }
diff --git a/jdk/src/share/classes/java/util/zip/Adler32.java b/jdk/src/share/classes/java/util/zip/Adler32.java
index fd53459..1e67a80 100644
--- a/jdk/src/share/classes/java/util/zip/Adler32.java
+++ b/jdk/src/share/classes/java/util/zip/Adler32.java
@@ -25,16 +25,23 @@
 
 package java.util.zip;
 
+import java.nio.ByteBuffer;
+import sun.nio.ch.DirectBuffer;
+
 /**
  * A class that can be used to compute the Adler-32 checksum of a data
  * stream. An Adler-32 checksum is almost as reliable as a CRC-32 but
  * can be computed much faster.
  *
+ * <p> Passing a {@code null} argument to a method in this class will cause
+ * a {@link NullPointerException} to be thrown.
+ *
  * @see         Checksum
  * @author      David Connelly
  */
 public
 class Adler32 implements Checksum {
+
     private int adler = 1;
 
     /**
@@ -75,6 +82,39 @@
         adler = updateBytes(adler, b, 0, b.length);
     }
 
+
+    /**
+     * Updates the checksum with the bytes from the specified buffer.
+     *
+     * The checksum is updated using
+     * buffer.{@link java.nio.Buffer#remaining() remaining()}
+     * bytes starting at
+     * buffer.{@link java.nio.Buffer#position() position()}
+     * Upon return, the buffer's position will be updated to its
+     * limit; its limit will not have been changed.
+     *
+     * @param buffer the ByteBuffer to update the checksum with
+     * @since 1.8
+     */
+    public void update(ByteBuffer buffer) {
+        int pos = buffer.position();
+        int limit = buffer.limit();
+        assert (pos <= limit);
+        int rem = limit - pos;
+        if (rem <= 0)
+            return;
+        if (buffer instanceof DirectBuffer) {
+            adler = updateByteBuffer(adler, ((DirectBuffer)buffer).address(), pos, rem);
+        } else if (buffer.hasArray()) {
+            adler = updateBytes(adler, buffer.array(), pos + buffer.arrayOffset(), rem);
+        } else {
+            byte[] b = new byte[rem];
+            buffer.get(b);
+            adler = updateBytes(adler, b, 0, b.length);
+        }
+        buffer.position(limit);
+    }
+
     /**
      * Resets the checksum to initial value.
      */
@@ -92,4 +132,6 @@
     private native static int update(int adler, int b);
     private native static int updateBytes(int adler, byte[] b, int off,
                                           int len);
+    private native static int updateByteBuffer(int adler, long addr,
+                                               int off, int len);
 }
diff --git a/jdk/src/share/classes/java/util/zip/CRC32.java b/jdk/src/share/classes/java/util/zip/CRC32.java
index 9f62c85..7c17369 100644
--- a/jdk/src/share/classes/java/util/zip/CRC32.java
+++ b/jdk/src/share/classes/java/util/zip/CRC32.java
@@ -25,9 +25,15 @@
 
 package java.util.zip;
 
+import java.nio.ByteBuffer;
+import sun.nio.ch.DirectBuffer;
+
 /**
  * A class that can be used to compute the CRC-32 of a data stream.
  *
+ * <p> Passing a {@code null} argument to a method in this class will cause
+ * a {@link NullPointerException} to be thrown.
+ *
  * @see         Checksum
  * @author      David Connelly
  */
@@ -75,6 +81,38 @@
     }
 
     /**
+     * Updates the checksum with the bytes from the specified buffer.
+     *
+     * The checksum is updated using
+     * buffer.{@link java.nio.Buffer#remaining() remaining()}
+     * bytes starting at
+     * buffer.{@link java.nio.Buffer#position() position()}
+     * Upon return, the buffer's position will
+     * be updated to its limit; its limit will not have been changed.
+     *
+     * @param buffer the ByteBuffer to update the checksum with
+     * @since 1.8
+     */
+    public void update(ByteBuffer buffer) {
+        int pos = buffer.position();
+        int limit = buffer.limit();
+        assert (pos <= limit);
+        int rem = limit - pos;
+        if (rem <= 0)
+            return;
+        if (buffer instanceof DirectBuffer) {
+            crc = updateByteBuffer(crc, ((DirectBuffer)buffer).address(), pos, rem);
+        } else if (buffer.hasArray()) {
+            crc = updateBytes(crc, buffer.array(), pos + buffer.arrayOffset(), rem);
+        } else {
+            byte[] b = new byte[rem];
+            buffer.get(b);
+            crc = updateBytes(crc, b, 0, b.length);
+        }
+        buffer.position(limit);
+    }
+
+    /**
      * Resets CRC-32 to initial value.
      */
     public void reset() {
@@ -90,4 +128,7 @@
 
     private native static int update(int crc, int b);
     private native static int updateBytes(int crc, byte[] b, int off, int len);
+
+    private native static int updateByteBuffer(int adler, long addr,
+                                               int off, int len);
 }
diff --git a/jdk/src/share/classes/javax/script/ScriptEngineManager.java b/jdk/src/share/classes/javax/script/ScriptEngineManager.java
index c87f481..bb43053 100644
--- a/jdk/src/share/classes/javax/script/ScriptEngineManager.java
+++ b/jdk/src/share/classes/javax/script/ScriptEngineManager.java
@@ -25,11 +25,9 @@
 
 package javax.script;
 import java.util.*;
-import java.net.URL;
-import java.io.*;
 import java.security.*;
-import sun.misc.Service;
-import sun.misc.ServiceConfigurationError;
+import java.util.ServiceLoader;
+import java.util.ServiceConfigurationError;
 import sun.reflect.Reflection;
 import sun.security.util.SecurityConstants;
 
@@ -102,13 +100,15 @@
     }
 
     private void initEngines(final ClassLoader loader) {
-        Iterator itr = null;
+        Iterator<ScriptEngineFactory> itr = null;
         try {
+            ServiceLoader<ScriptEngineFactory> sl;
             if (loader != null) {
-                itr = Service.providers(ScriptEngineFactory.class, loader);
+                sl = ServiceLoader.load(ScriptEngineFactory.class, loader);
             } else {
-                itr = Service.installedProviders(ScriptEngineFactory.class);
+                sl = ServiceLoader.loadInstalled(ScriptEngineFactory.class);
             }
+            itr = sl.iterator();
         } catch (ServiceConfigurationError err) {
             System.err.println("Can't find ScriptEngineFactory providers: " +
                           err.getMessage());
@@ -124,7 +124,7 @@
         try {
             while (itr.hasNext()) {
                 try {
-                    ScriptEngineFactory fact = (ScriptEngineFactory) itr.next();
+                    ScriptEngineFactory fact = itr.next();
                     engineSpis.add(fact);
                 } catch (ServiceConfigurationError err) {
                     System.err.println("ScriptEngineManager providers.next(): "
@@ -441,7 +441,7 @@
     // Note that this code is same as ClassLoader.getCallerClassLoader().
     // But, that method is package private and hence we can't call here.
     private ClassLoader getCallerClassLoader() {
-        Class caller = Reflection.getCallerClass(3);
+        Class<?> caller = Reflection.getCallerClass(3);
         if (caller == null) {
             return null;
         }
diff --git a/jdk/src/share/classes/javax/security/auth/kerberos/ServicePermission.java b/jdk/src/share/classes/javax/security/auth/kerberos/ServicePermission.java
index c79d0e1..a22e8cc 100644
--- a/jdk/src/share/classes/javax/security/auth/kerberos/ServicePermission.java
+++ b/jdk/src/share/classes/javax/security/auth/kerberos/ServicePermission.java
@@ -369,7 +369,7 @@
                 switch(a[i-matchlen]) {
                 case ',':
                     seencomma = true;
-                    /*FALLTHROUGH*/
+                    break;
                 case ' ': case '\r': case '\n':
                 case '\f': case '\t':
                     break;
diff --git a/jdk/src/share/classes/javax/sql/StatementEvent.java b/jdk/src/share/classes/javax/sql/StatementEvent.java
index bb41be7..53c61c5 100644
--- a/jdk/src/share/classes/javax/sql/StatementEvent.java
+++ b/jdk/src/share/classes/javax/sql/StatementEvent.java
@@ -42,6 +42,7 @@
  */
 public class StatementEvent extends EventObject {
 
+        static final long serialVersionUID = -8089573731826608315L;
         private SQLException            exception;
         private PreparedStatement       statement;
 
diff --git a/jdk/src/share/classes/javax/sql/rowset/BaseRowSet.java b/jdk/src/share/classes/javax/sql/rowset/BaseRowSet.java
index cf0bbec..bbb1852 100644
--- a/jdk/src/share/classes/javax/sql/rowset/BaseRowSet.java
+++ b/jdk/src/share/classes/javax/sql/rowset/BaseRowSet.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -619,8 +619,8 @@
         checkforRowSetInterface();
         if (listeners.isEmpty() == false) {
             RowSetEvent event = new RowSetEvent((RowSet)this);
-            for (Iterator i = listeners.iterator(); i.hasNext(); ) {
-                ((RowSetListener)i.next()).cursorMoved(event);
+            for (RowSetListener rsl : listeners) {
+                rsl.cursorMoved(event);
             }
         }
     }
@@ -644,8 +644,8 @@
         checkforRowSetInterface();
         if (listeners.isEmpty() == false) {
                 RowSetEvent event = new RowSetEvent((RowSet)this);
-                for (Iterator i = listeners.iterator(); i.hasNext(); ) {
-                        ((RowSetListener)i.next()).rowChanged(event);
+                for (RowSetListener rsl : listeners) {
+                    rsl.rowChanged(event);
                 }
         }
     }
@@ -669,8 +669,8 @@
         checkforRowSetInterface();
         if (listeners.isEmpty() == false) {
                 RowSetEvent event = new RowSetEvent((RowSet)this);
-                for (Iterator i = listeners.iterator(); i.hasNext(); ) {
-                        ((RowSetListener)i.next()).rowSetChanged(event);
+                for (RowSetListener rsl : listeners) {
+                    rsl.rowSetChanged(event);
                 }
         }
 }
diff --git a/jdk/src/share/classes/javax/sql/rowset/RowSetMetaDataImpl.java b/jdk/src/share/classes/javax/sql/rowset/RowSetMetaDataImpl.java
index f4591c0..659f2e5 100644
--- a/jdk/src/share/classes/javax/sql/rowset/RowSetMetaDataImpl.java
+++ b/jdk/src/share/classes/javax/sql/rowset/RowSetMetaDataImpl.java
@@ -97,7 +97,7 @@
      */
     private void checkColType(int SQLType) throws SQLException {
         try {
-            Class c = java.sql.Types.class;
+            Class<?> c = java.sql.Types.class;
             Field[] publicFields = c.getFields();
             int fieldValue = 0;
             for (int i = 0; i < publicFields.length; i++) {
@@ -1091,5 +1091,7 @@
          *@serial
          */
         public boolean writable = true;
+
+        static final long serialVersionUID = 5490834817919311283L;
     }
 }
diff --git a/jdk/src/share/classes/javax/sql/rowset/RowSetProvider.java b/jdk/src/share/classes/javax/sql/rowset/RowSetProvider.java
index c161ede..68226ee 100644
--- a/jdk/src/share/classes/javax/sql/rowset/RowSetProvider.java
+++ b/jdk/src/share/classes/javax/sql/rowset/RowSetProvider.java
@@ -181,7 +181,7 @@
 
         trace("***In newInstance()");
         try {
-            Class providerClass = getFactoryClass(factoryClassName, cl, false);
+            Class<?> providerClass = getFactoryClass(factoryClassName, cl, false);
             RowSetFactory instance = (RowSetFactory) providerClass.newInstance();
             if (debug) {
                 trace("Created new instance of " + providerClass +
@@ -229,7 +229,7 @@
      * context class loader followed by the current class loader.
      *  @return The class which was loaded
      */
-    static private Class getFactoryClass(String factoryClassName, ClassLoader cl,
+    static private Class<?> getFactoryClass(String factoryClassName, ClassLoader cl,
             boolean doFallback) throws ClassNotFoundException {
         try {
             if (cl == null) {
diff --git a/jdk/src/share/classes/javax/sql/rowset/serial/SQLInputImpl.java b/jdk/src/share/classes/javax/sql/rowset/serial/SQLInputImpl.java
index c84527d..c4b1e4d 100644
--- a/jdk/src/share/classes/javax/sql/rowset/serial/SQLInputImpl.java
+++ b/jdk/src/share/classes/javax/sql/rowset/serial/SQLInputImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -22,13 +22,9 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
-
 package javax.sql.rowset.serial;
 
 import java.sql.*;
-import javax.sql.*;
-import java.io.*;
-import java.math.*;
 import java.util.Map;
 
 /**
@@ -91,7 +87,7 @@
      * <code>SQLData</code> (the Java class that defines how the UDT
      * will be mapped).
      */
-    private Map map;
+    private Map<String,Class<?>> map;
 
 
     /**
@@ -279,7 +275,7 @@
 
         if (attrib == null) {
             lastValueWasNull = true;
-            return (int)0;
+            return 0;
         } else {
             lastValueWasNull = false;
             return attrib.intValue();
@@ -591,7 +587,7 @@
      * position; or if there are no further values in the stream.
      */
     public Object readObject() throws SQLException {
-        Object attrib = (Object)getNextAttribute();
+        Object attrib = getNextAttribute();
 
         if (attrib == null) {
             lastValueWasNull = true;
@@ -601,7 +597,7 @@
             if (attrib instanceof Struct) {
                 Struct s = (Struct)attrib;
                 // look up the class in the map
-                Class c = (Class)map.get(s.getSQLTypeName());
+                Class<?> c = map.get(s.getSQLTypeName());
                 if (c != null) {
                     // create new instance of the class
                     SQLData obj = null;
@@ -620,10 +616,10 @@
                     SQLInputImpl sqlInput = new SQLInputImpl(attribs, map);
                     // read the values...
                     obj.readSQL(sqlInput, s.getSQLTypeName());
-                    return (Object)obj;
+                    return obj;
                 }
             }
-            return (Object)attrib;
+            return attrib;
         }
     }
 
diff --git a/jdk/src/share/classes/javax/sql/rowset/serial/SQLOutputImpl.java b/jdk/src/share/classes/javax/sql/rowset/serial/SQLOutputImpl.java
index 7b5d8d4..2217e4e 100644
--- a/jdk/src/share/classes/javax/sql/rowset/serial/SQLOutputImpl.java
+++ b/jdk/src/share/classes/javax/sql/rowset/serial/SQLOutputImpl.java
@@ -60,6 +60,7 @@
      * A reference to an existing vector that
      * contains the attributes of a <code>Struct</code> object.
      */
+    @SuppressWarnings("rawtypes")
     private Vector attribs;
 
     /**
@@ -70,6 +71,7 @@
      * method will in turn call the appropriate
      * <code>SQLOutputImpl</code> writer methods.
      */
+    @SuppressWarnings("rawtypes")
     private Map map;
 
     /**
@@ -121,6 +123,7 @@
      *        use by a <code>SQLData</code> object attempting to write the attribute
      *        values of a UDT to the database.
      */
+    @SuppressWarnings("unchecked")
     public void writeString(String x) throws SQLException {
         //System.out.println("Adding :"+x);
         attribs.add(x);
@@ -136,6 +139,7 @@
      *        use by a <code>SQLData</code> object attempting to write the attribute
      *        values of a UDT to the database.
      */
+    @SuppressWarnings("unchecked")
     public void writeBoolean(boolean x) throws SQLException {
         attribs.add(Boolean.valueOf(x));
     }
@@ -150,6 +154,7 @@
      *        use by a <code>SQLData</code> object attempting to write the attribute
      *        values of a UDT to the database.
      */
+    @SuppressWarnings("unchecked")
     public void writeByte(byte x) throws SQLException {
         attribs.add(Byte.valueOf(x));
     }
@@ -164,6 +169,7 @@
      *        use by a <code>SQLData</code> object attempting to write the attribute
      *        values of a UDT to the database.
      */
+    @SuppressWarnings("unchecked")
     public void writeShort(short x) throws SQLException {
         attribs.add(Short.valueOf(x));
     }
@@ -178,6 +184,7 @@
      *        use by a <code>SQLData</code> object attempting to write the attribute
      *        values of a UDT to the database.
      */
+    @SuppressWarnings("unchecked")
     public void writeInt(int x) throws SQLException {
         attribs.add(Integer.valueOf(x));
     }
@@ -192,6 +199,7 @@
      *        use by a <code>SQLData</code> object attempting to write the attribute
      *        values of a UDT to the database.
      */
+    @SuppressWarnings("unchecked")
     public void writeLong(long x) throws SQLException {
         attribs.add(Long.valueOf(x));
     }
@@ -206,6 +214,7 @@
      *        use by a <code>SQLData</code> object attempting to write the attribute
      *        values of a UDT to the database.
      */
+    @SuppressWarnings("unchecked")
     public void writeFloat(float x) throws SQLException {
         attribs.add(new Float(x));
     }
@@ -220,6 +229,7 @@
      *        use by a <code>SQLData</code> object attempting to write the attribute
      *        values of a UDT to the database.
      */
+    @SuppressWarnings("unchecked")
     public void writeDouble(double x) throws SQLException{
         attribs.add(new Double(x));
     }
@@ -234,6 +244,7 @@
      *        use by a <code>SQLData</code> object attempting to write the attribute
      *        values of a UDT to the database.
      */
+    @SuppressWarnings("unchecked")
     public void writeBigDecimal(java.math.BigDecimal x) throws SQLException{
         attribs.add(x);
     }
@@ -249,6 +260,7 @@
      *        use by a <code>SQLData</code> object attempting to write the attribute
      *        values of a UDT to the database.
      */
+    @SuppressWarnings("unchecked")
     public void writeBytes(byte[] x) throws SQLException {
         attribs.add(x);
     }
@@ -263,6 +275,7 @@
      *        use by a <code>SQLData</code> object attempting to write the attribute
      *        values of a UDT to the database.
      */
+    @SuppressWarnings("unchecked")
     public void writeDate(java.sql.Date x) throws SQLException {
         attribs.add(x);
     }
@@ -277,6 +290,7 @@
      *        use by a <code>SQLData</code> object attempting to write the attribute
      *        values of a UDT to the database.
      */
+    @SuppressWarnings("unchecked")
     public void writeTime(java.sql.Time x) throws SQLException {
         attribs.add(x);
     }
@@ -291,6 +305,7 @@
      *        use by a <code>SQLData</code> object attempting to write the attribute
      *        values of a UDT to the database.
      */
+    @SuppressWarnings("unchecked")
     public void writeTimestamp(java.sql.Timestamp x) throws SQLException {
         attribs.add(x);
     }
@@ -305,6 +320,7 @@
      *        use by a <code>SQLData</code> object attempting to write the attribute
      *        values of a UDT to the database.
      */
+    @SuppressWarnings("unchecked")
     public void writeCharacterStream(java.io.Reader x) throws SQLException {
          BufferedReader bufReader = new BufferedReader(x);
          try {
@@ -334,6 +350,7 @@
      *        use by a <code>SQLData</code> object attempting to write the attribute
      *        values of a UDT to the database.
      */
+    @SuppressWarnings("unchecked")
     public void writeAsciiStream(java.io.InputStream x) throws SQLException {
          BufferedReader bufReader = new BufferedReader(new InputStreamReader(x));
          try {
@@ -363,6 +380,7 @@
      *        use by a <code>SQLData</code> object attempting to write the attribute
      *        values of a UDT to the database.
      */
+    @SuppressWarnings("unchecked")
     public void writeBinaryStream(java.io.InputStream x) throws SQLException {
          BufferedReader bufReader = new BufferedReader(new InputStreamReader(x));
          try {
@@ -414,6 +432,7 @@
      *        use by a <code>SQLData</code> object attempting to write the attribute
      *        values of a UDT to the database.
      */
+    @SuppressWarnings("unchecked")
     public void writeObject(SQLData x) throws SQLException {
 
         /*
@@ -434,7 +453,7 @@
          * the name of this class otherwise we don't know
          * what to re-instantiate during readSQL()
          */
-        attribs.add(new SerialStruct((SQLData)x, map));
+        attribs.add(new SerialStruct(x, map));
     }
 
     /**
@@ -448,6 +467,7 @@
      *        use by a <code>SQLData</code> object attempting to write the attribute
      *        values of a UDT to the database.
      */
+    @SuppressWarnings("unchecked")
     public void writeRef(Ref x) throws SQLException {
         if (x == null) {
             attribs.add(x);
@@ -467,6 +487,7 @@
      *        use by a <code>SQLData</code> object attempting to write the attribute
      *        values of a UDT to the database.
      */
+    @SuppressWarnings("unchecked")
     public void writeBlob(Blob x) throws SQLException {
         if (x == null) {
             attribs.add(x);
@@ -486,6 +507,7 @@
      *        use by a <code>SQLData</code> object attempting to write the attribute
      *        values of a UDT to the database.
      */
+    @SuppressWarnings("unchecked")
     public void writeClob(Clob x) throws SQLException {
         if (x == null) {
             attribs.add(x);
@@ -511,6 +533,7 @@
      *        use by a <code>SQLData</code> object attempting to write the attribute
      *        values of a UDT to the database.
      */
+    @SuppressWarnings("unchecked")
     public void writeStruct(Struct x) throws SQLException {
         SerialStruct s = new SerialStruct(x,map);;
         attribs.add(s);
@@ -528,6 +551,7 @@
      *        use by a <code>SQLData</code> object attempting to write the attribute
      *        values of a UDT to the database.
      */
+    @SuppressWarnings("unchecked")
     public void writeArray(Array x) throws SQLException {
         if (x == null) {
             attribs.add(x);
@@ -547,6 +571,7 @@
      *        use by a <code>SQLData</code> object attempting to write the attribute
      *        values of a UDT to the database.
      */
+    @SuppressWarnings("unchecked")
     public void writeURL(java.net.URL url) throws SQLException {
         if (url == null) {
             attribs.add(url);
@@ -570,6 +595,7 @@
    * @exception SQLException if a database access error occurs
    * @since 1.6
    */
+   @SuppressWarnings("unchecked")
    public void writeNString(String x) throws SQLException {
         throw new UnsupportedOperationException("Operation not supported");
     }
@@ -583,6 +609,7 @@
    * @exception SQLException if a database access error occurs
    * @since 1.6
    */
+   @SuppressWarnings("unchecked")
    public void writeNClob(NClob x) throws SQLException {
         throw new UnsupportedOperationException("Operation not supported");
     }
@@ -597,6 +624,7 @@
    * @exception SQLException if a database access error occurs
    * @since 1.6
    */
+   @SuppressWarnings("unchecked")
    public void writeRowId(RowId x) throws SQLException {
         throw new UnsupportedOperationException("Operation not supported");
     }
@@ -611,6 +639,7 @@
    * @exception SQLException if a database access error occurs
    * @since 1.6
    */
+   @SuppressWarnings("unchecked")
    public void writeSQLXML(SQLXML x) throws SQLException {
         throw new UnsupportedOperationException("Operation not supported");
     }
diff --git a/jdk/src/share/classes/javax/sql/rowset/serial/SerialArray.java b/jdk/src/share/classes/javax/sql/rowset/serial/SerialArray.java
index 17856e1..5ab127c 100644
--- a/jdk/src/share/classes/javax/sql/rowset/serial/SerialArray.java
+++ b/jdk/src/share/classes/javax/sql/rowset/serial/SerialArray.java
@@ -186,10 +186,8 @@
 
             case java.sql.Types.JAVA_OBJECT:
                 for (int i = 0; i < len; i++) {
-                elements[i] = new SerialJavaObject((Object)elements[i]);
+                elements[i] = new SerialJavaObject(elements[i]);
             }
-        default:
-            ;
         }
   }
 
@@ -285,11 +283,10 @@
 
         case java.sql.Types.JAVA_OBJECT:
             for (int i = 0; i < len; i++) {
-                elements[i] = new SerialJavaObject((Object)elements[i]);
+                elements[i] = new SerialJavaObject(elements[i]);
             }
+            break;
 
-        default:
-            ;
         }
 
 
diff --git a/jdk/src/share/classes/javax/sql/rowset/serial/SerialBlob.java b/jdk/src/share/classes/javax/sql/rowset/serial/SerialBlob.java
index 795e404..bae2d93 100644
--- a/jdk/src/share/classes/javax/sql/rowset/serial/SerialBlob.java
+++ b/jdk/src/share/classes/javax/sql/rowset/serial/SerialBlob.java
@@ -207,7 +207,7 @@
      */
     public java.io.InputStream getBinaryStream() throws SerialException {
          InputStream stream = new ByteArrayInputStream(buf);
-         return (java.io.InputStream)stream;
+         return stream;
     }
 
     /**
diff --git a/jdk/src/share/classes/javax/sql/rowset/serial/SerialJavaObject.java b/jdk/src/share/classes/javax/sql/rowset/serial/SerialJavaObject.java
index 5aa034f..4517ff3 100644
--- a/jdk/src/share/classes/javax/sql/rowset/serial/SerialJavaObject.java
+++ b/jdk/src/share/classes/javax/sql/rowset/serial/SerialJavaObject.java
@@ -142,14 +142,14 @@
      * object. When there are multiple warnings, each warning is chained to the
      * previous warning.
      */
-    java.util.Vector chain;
+    java.util.Vector<RowSetWarning> chain;
 
     /**
      * Registers the given warning.
      */
     private void setWarning(RowSetWarning e) {
         if (chain == null) {
-            chain = new java.util.Vector();
+            chain = new java.util.Vector<>();
         }
         chain.add(e);
     }
diff --git a/jdk/src/share/classes/javax/sql/rowset/serial/SerialRef.java b/jdk/src/share/classes/javax/sql/rowset/serial/SerialRef.java
index 8503caa..efc8819 100644
--- a/jdk/src/share/classes/javax/sql/rowset/serial/SerialRef.java
+++ b/jdk/src/share/classes/javax/sql/rowset/serial/SerialRef.java
@@ -109,7 +109,7 @@
     public Object getObject(java.util.Map<String,Class<?>> map)
         throws SerialException
     {
-        map = new Hashtable(map);
+        map = new Hashtable<String, Class<?>>(map);
         if (object != null) {
             return map.get(object);
         } else {
diff --git a/jdk/src/share/classes/javax/sql/rowset/serial/SerialStruct.java b/jdk/src/share/classes/javax/sql/rowset/serial/SerialStruct.java
index b546da7..a9462eb 100644
--- a/jdk/src/share/classes/javax/sql/rowset/serial/SerialStruct.java
+++ b/jdk/src/share/classes/javax/sql/rowset/serial/SerialStruct.java
@@ -139,7 +139,7 @@
         //set the type name
         SQLTypeName = in.getSQLTypeName();
 
-        Vector tmp = new Vector();
+        Vector<Object> tmp = new Vector<>();
         in.writeSQL(new SQLOutputImpl(tmp, map));
         attribs = tmp.toArray();
 
@@ -220,7 +220,7 @@
      *        that defines how the UDT is to be mapped
      * @throws SerialException if an error occurs
      */
-    private void mapToSerial(Map map) throws SerialException {
+    private void mapToSerial(Map<String,Class<?>> map) throws SerialException {
 
         try {
 
diff --git a/jdk/src/share/classes/javax/sql/rowset/spi/SyncFactory.java b/jdk/src/share/classes/javax/sql/rowset/spi/SyncFactory.java
index 4e2b164..11a59c4 100644
--- a/jdk/src/share/classes/javax/sql/rowset/spi/SyncFactory.java
+++ b/jdk/src/share/classes/javax/sql/rowset/spi/SyncFactory.java
@@ -257,7 +257,7 @@
      * See section 2.0 of the class comment for <code>SyncFactory</code> for an
      * explanation of how a provider can be added to this registry.
      */
-    private static Hashtable implementations;
+    private static Hashtable<String, SyncProvider> implementations;
     /**
      * Internal sync object used to maintain the SPI as a singleton
      */
@@ -344,7 +344,7 @@
         Properties properties = new Properties();
 
         if (implementations == null) {
-            implementations = new Hashtable();
+            implementations = new Hashtable<>();
 
             try {
 
@@ -445,7 +445,7 @@
         String key = null;
         String[] propertyNames = null;
 
-        for (Enumeration e = p.propertyNames(); e.hasMoreElements();) {
+        for (Enumeration<?> e = p.propertyNames(); e.hasMoreElements();) {
 
             String str = (String) e.nextElement();
 
@@ -541,7 +541,7 @@
         }
 
         // Attempt to invoke classname from registered SyncProvider list
-        Class c = null;
+        Class<?> c = null;
         try {
             ClassLoader cl = Thread.currentThread().getContextClassLoader();
 
@@ -740,7 +740,7 @@
      */
     private static Properties parseJNDIContext() throws NamingException {
 
-        NamingEnumeration bindings = ic.listBindings("");
+        NamingEnumeration<?> bindings = ic.listBindings("");
         Properties properties = new Properties();
 
         // Hunt one level below context for available SyncProvider objects
@@ -755,7 +755,7 @@
      * scan the current context using a re-entrant call to this method until all
      * bindings have been enumerated.
      */
-    private static void enumerateBindings(NamingEnumeration bindings,
+    private static void enumerateBindings(NamingEnumeration<?> bindings,
             Properties properties) throws NamingException {
 
         boolean syncProviderObj = false; // move to parameters ?
diff --git a/jdk/src/share/classes/javax/swing/text/DefaultCaret.java b/jdk/src/share/classes/javax/swing/text/DefaultCaret.java
index 464fff6..79a0cee 100644
--- a/jdk/src/share/classes/javax/swing/text/DefaultCaret.java
+++ b/jdk/src/share/classes/javax/swing/text/DefaultCaret.java
@@ -403,6 +403,10 @@
      * @see MouseListener#mouseClicked
      */
     public void mouseClicked(MouseEvent e) {
+        if (getComponent() == null) {
+            return;
+        }
+
         int nclicks = SwingUtilities2.getAdjustedClickCount(getComponent(), e);
 
         if (! e.isConsumed()) {
diff --git a/jdk/src/share/classes/sun/awt/im/CompositionArea.java b/jdk/src/share/classes/sun/awt/im/CompositionArea.java
index 5e0a19d..15eb088 100644
--- a/jdk/src/share/classes/sun/awt/im/CompositionArea.java
+++ b/jdk/src/share/classes/sun/awt/im/CompositionArea.java
@@ -313,4 +313,7 @@
           compositionWindow.pack();
     }
 
+    // Proclaim serial compatibility with 1.7.0
+    private static final long serialVersionUID = -1057247068746557444L;
+
 }
diff --git a/jdk/src/share/classes/sun/awt/im/CompositionAreaHandler.java b/jdk/src/share/classes/sun/awt/im/CompositionAreaHandler.java
index 7a5626d..6ae4a95 100644
--- a/jdk/src/share/classes/sun/awt/im/CompositionAreaHandler.java
+++ b/jdk/src/share/classes/sun/awt/im/CompositionAreaHandler.java
@@ -257,7 +257,7 @@
      */
     InputMethodRequests getClientInputMethodRequests() {
         if (clientComponent != null) {
-            return (InputMethodRequests) clientComponent.getInputMethodRequests();
+            return clientComponent.getInputMethodRequests();
         }
 
         return null;
diff --git a/jdk/src/share/classes/sun/awt/im/InputContext.java b/jdk/src/share/classes/sun/awt/im/InputContext.java
index 226b7f9..27f05465 100644
--- a/jdk/src/share/classes/sun/awt/im/InputContext.java
+++ b/jdk/src/share/classes/sun/awt/im/InputContext.java
@@ -79,7 +79,7 @@
     private boolean inputMethodCreationFailed;
 
     // holding bin for previously used input method instances, but not the current one
-    private HashMap usedInputMethods;
+    private HashMap<InputMethodLocator, InputMethod> usedInputMethods;
 
     // the current client component is kept until the user focusses on a different
     // client component served by the same input context. When that happens, we call
@@ -106,7 +106,7 @@
     // cache location notification
     private Rectangle clientWindowLocation = null;
     // holding the state of clientWindowNotificationEnabled of only non-current input methods
-    private HashMap perInputMethodState;
+    private HashMap<InputMethod, Boolean> perInputMethodState;
 
     // Input Method selection hot key stuff
     private static AWTKeyStroke inputMethodSelectionKey;
@@ -219,6 +219,7 @@
     /**
      * @see java.awt.im.InputContext#dispatchEvent
      */
+    @SuppressWarnings("fallthrough")
     public void dispatchEvent(AWTEvent event) {
 
         if (event instanceof InputMethodEvent) {
@@ -394,7 +395,7 @@
             isInputMethodActive = true;
 
             if (perInputMethodState != null) {
-                Boolean state = (Boolean) perInputMethodState.remove(inputMethod);
+                Boolean state = perInputMethodState.remove(inputMethod);
                 if (state != null) {
                     clientWindowNotificationEnabled = state.booleanValue();
                 }
@@ -549,10 +550,10 @@
 
             // keep the input method instance around for future use
             if (usedInputMethods == null) {
-                usedInputMethods = new HashMap(5);
+                usedInputMethods = new HashMap<>(5);
             }
             if (perInputMethodState == null) {
-                perInputMethodState = new HashMap(5);
+                perInputMethodState = new HashMap<>(5);
             }
             usedInputMethods.put(inputMethodLocator.deriveLocator(null), inputMethod);
             perInputMethodState.put(inputMethod,
@@ -689,10 +690,10 @@
         }
         inputMethodLocator = null;
         if (usedInputMethods != null && !usedInputMethods.isEmpty()) {
-            Iterator iterator = usedInputMethods.values().iterator();
+            Iterator<InputMethod> iterator = usedInputMethods.values().iterator();
             usedInputMethods = null;
             while (iterator.hasNext()) {
-                ((InputMethod) iterator.next()).dispose();
+                iterator.next().dispose();
             }
         }
 
@@ -830,13 +831,13 @@
 
         // see whether we have a previously used input method
         if (usedInputMethods != null) {
-            inputMethodInstance = (InputMethod) usedInputMethods.remove(locator.deriveLocator(null));
+            inputMethodInstance = usedInputMethods.remove(locator.deriveLocator(null));
             if (inputMethodInstance != null) {
                 if (locale != null) {
                     inputMethodInstance.setLocale(locale);
                 }
                 inputMethodInstance.setCharacterSubsets(characterSubsets);
-                Boolean state = (Boolean) perInputMethodState.remove(inputMethodInstance);
+                Boolean state = perInputMethodState.remove(inputMethodInstance);
                 if (state != null) {
                     enableClientWindowNotification(inputMethodInstance, state.booleanValue());
                 }
@@ -919,7 +920,7 @@
         // method becomes the current one.
         if (requester != inputMethod) {
             if (perInputMethodState == null) {
-                perInputMethodState = new HashMap(5);
+                perInputMethodState = new HashMap<>(5);
             }
             perInputMethodState.put(requester, Boolean.valueOf(enable));
             return;
@@ -1029,7 +1030,7 @@
      * Initializes the input method selection key definition in preference trees
      */
     private void initializeInputMethodSelectionKey() {
-        AccessController.doPrivileged(new PrivilegedAction() {
+        AccessController.doPrivileged(new PrivilegedAction<Object>() {
             public Object run() {
                 // Look in user's tree
                 Preferences root = Preferences.userRoot();
diff --git a/jdk/src/share/classes/sun/awt/im/InputMethodContext.java b/jdk/src/share/classes/sun/awt/im/InputMethodContext.java
index 78706ba..98f3538 100644
--- a/jdk/src/share/classes/sun/awt/im/InputMethodContext.java
+++ b/jdk/src/share/classes/sun/awt/im/InputMethodContext.java
@@ -72,12 +72,11 @@
     static {
         // check whether we should use below-the-spot input
         // get property from command line
-        String inputStyle = (String) AccessController.doPrivileged
+        String inputStyle = AccessController.doPrivileged
                 (new GetPropertyAction("java.awt.im.style", null));
         // get property from awt.properties file
         if (inputStyle == null) {
-            inputStyle = Toolkit.getDefaultToolkit().
-                    getProperty("java.awt.im.style", null);
+            inputStyle = Toolkit.getProperty("java.awt.im.style", null);
         }
         belowTheSpotInputRequested = "below-the-spot".equals(inputStyle);
     }
diff --git a/jdk/src/share/classes/sun/awt/im/InputMethodJFrame.java b/jdk/src/share/classes/sun/awt/im/InputMethodJFrame.java
index 602b46d..e83dc9e 100644
--- a/jdk/src/share/classes/sun/awt/im/InputMethodJFrame.java
+++ b/jdk/src/share/classes/sun/awt/im/InputMethodJFrame.java
@@ -68,4 +68,7 @@
             return super.getInputContext();
         }
     }
+
+    // Proclaim serial compatibility with 1.7.0
+    private static final long serialVersionUID = -4705856747771842549L;
 }
diff --git a/jdk/src/share/classes/sun/awt/im/InputMethodManager.java b/jdk/src/share/classes/sun/awt/im/InputMethodManager.java
index 1b99c3d..0e15b7e 100644
--- a/jdk/src/share/classes/sun/awt/im/InputMethodManager.java
+++ b/jdk/src/share/classes/sun/awt/im/InputMethodManager.java
@@ -270,7 +270,7 @@
     // IM preference stuff
     private static final String preferredIMNode = "/sun/awt/im/preferredInputMethod";
     private static final String descriptorKey = "descriptor";
-    private Hashtable preferredLocatorCache = new Hashtable();
+    private Hashtable<String, InputMethodLocator> preferredLocatorCache = new Hashtable<>();
     private Preferences userRoot;
 
     ExecutableInputMethodManager() {
@@ -430,7 +430,7 @@
         synchronized (javaInputMethodLocatorList) {
             javaInputMethodLocatorList.clear();
             try {
-                AccessController.doPrivileged(new PrivilegedExceptionAction() {
+                AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
                     public Object run() {
                         for (InputMethodDescriptor descriptor :
                             ServiceLoader.loadInstalled(InputMethodDescriptor.class)) {
@@ -611,7 +611,7 @@
         }
 
         // look for the cached preference first.
-        preferredLocator = (InputMethodLocator)preferredLocatorCache.get(locale.toString().intern());
+        preferredLocator = preferredLocatorCache.get(locale.toString().intern());
         if (preferredLocator != null) {
             return preferredLocator;
         }
@@ -767,8 +767,8 @@
     }
 
     private Preferences getUserRoot() {
-        return (Preferences)AccessController.doPrivileged(new PrivilegedAction() {
-            public Object run() {
+        return AccessController.doPrivileged(new PrivilegedAction<Preferences>() {
+            public Preferences run() {
                 return Preferences.userRoot();
             }
         });
diff --git a/jdk/src/share/classes/sun/awt/im/SimpleInputMethodWindow.java b/jdk/src/share/classes/sun/awt/im/SimpleInputMethodWindow.java
index 2bcbdc3..5ed1340 100644
--- a/jdk/src/share/classes/sun/awt/im/SimpleInputMethodWindow.java
+++ b/jdk/src/share/classes/sun/awt/im/SimpleInputMethodWindow.java
@@ -61,4 +61,7 @@
             return super.getInputContext();
         }
     }
+
+    // Proclaim serial compatibility with 1.7.0
+    private static final long serialVersionUID = 5093376647036461555L;
 }
diff --git a/jdk/src/share/classes/sun/awt/image/BufImgSurfaceData.java b/jdk/src/share/classes/sun/awt/image/BufImgSurfaceData.java
index 239f883..5910c4b 100644
--- a/jdk/src/share/classes/sun/awt/image/BufImgSurfaceData.java
+++ b/jdk/src/share/classes/sun/awt/image/BufImgSurfaceData.java
@@ -323,8 +323,8 @@
     }
 
     public RenderLoops getRenderLoops(SunGraphics2D sg2d) {
-        if (sg2d.paintState <= sg2d.PAINT_ALPHACOLOR &&
-            sg2d.compositeState <= sg2d.COMP_ISCOPY)
+        if (sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR &&
+            sg2d.compositeState <= SunGraphics2D.COMP_ISCOPY)
         {
             return solidloops;
         }
diff --git a/jdk/src/share/classes/sun/instrument/InstrumentationImpl.java b/jdk/src/share/classes/sun/instrument/InstrumentationImpl.java
index 359cdbd..9957e1c 100644
--- a/jdk/src/share/classes/sun/instrument/InstrumentationImpl.java
+++ b/jdk/src/share/classes/sun/instrument/InstrumentationImpl.java
@@ -136,7 +136,7 @@
     }
 
     public void
-    retransformClasses(Class<?>[] classes) {
+    retransformClasses(Class<?>... classes) {
         if (!isRetransformClassesSupported()) {
             throw new UnsupportedOperationException(
               "retransformClasses is not supported in this environment");
@@ -150,7 +150,7 @@
     }
 
     public void
-    redefineClasses(ClassDefinition[]   definitions)
+    redefineClasses(ClassDefinition...  definitions)
             throws  ClassNotFoundException {
         if (!isRedefineClassesSupported()) {
             throw new UnsupportedOperationException("redefineClasses is not supported in this environment");
@@ -321,7 +321,7 @@
 
         try {
             m = javaAgentClass.getDeclaredMethod( methodname,
-                                 new Class[] {
+                                 new Class<?>[] {
                                      String.class,
                                      java.lang.instrument.Instrumentation.class
                                  }
@@ -336,7 +336,7 @@
             // now try the declared 1-arg method
             try {
                 m = javaAgentClass.getDeclaredMethod(methodname,
-                                                 new Class[] { String.class });
+                                                 new Class<?>[] { String.class });
             } catch (NoSuchMethodException x) {
                 // ignore this exception because we'll try
                 // two arg inheritance next
@@ -347,7 +347,7 @@
             // now try the inherited 2-arg method
             try {
                 m = javaAgentClass.getMethod( methodname,
-                                 new Class[] {
+                                 new Class<?>[] {
                                      String.class,
                                      java.lang.instrument.Instrumentation.class
                                  }
@@ -363,7 +363,7 @@
             // finally try the inherited 1-arg method
             try {
                 m = javaAgentClass.getMethod(methodname,
-                                             new Class[] { String.class });
+                                             new Class<?>[] { String.class });
             } catch (NoSuchMethodException x) {
                 // none of the methods exists so we throw the
                 // first NoSuchMethodException as per 5.0
@@ -411,7 +411,7 @@
     private byte[]
     transform(  ClassLoader         loader,
                 String              classname,
-                Class               classBeingRedefined,
+                Class<?>            classBeingRedefined,
                 ProtectionDomain    protectionDomain,
                 byte[]              classfileBuffer,
                 boolean             isRetransformer) {
diff --git a/jdk/src/share/classes/sun/instrument/TransformerManager.java b/jdk/src/share/classes/sun/instrument/TransformerManager.java
index 2f8cfa1..b0a0205 100644
--- a/jdk/src/share/classes/sun/instrument/TransformerManager.java
+++ b/jdk/src/share/classes/sun/instrument/TransformerManager.java
@@ -169,7 +169,7 @@
     public byte[]
     transform(  ClassLoader         loader,
                 String              classname,
-                Class               classBeingRedefined,
+                Class<?>            classBeingRedefined,
                 ProtectionDomain    protectionDomain,
                 byte[]              classfileBuffer) {
         boolean someoneTouchedTheBytecode = false;
diff --git a/jdk/src/share/classes/sun/java2d/SunGraphics2D.java b/jdk/src/share/classes/sun/java2d/SunGraphics2D.java
index 8d9c2ea..4571b81 100644
--- a/jdk/src/share/classes/sun/java2d/SunGraphics2D.java
+++ b/jdk/src/share/classes/sun/java2d/SunGraphics2D.java
@@ -941,7 +941,7 @@
                 }
             }
         }
-        Class paintClass = paint.getClass();
+        Class<? extends Paint> paintClass = paint.getClass();
         if (paintClass == GradientPaint.class) {
             paintState = PAINT_GRADIENT;
         } else if (paintClass == LinearGradientPaint.class) {
@@ -1280,7 +1280,7 @@
         interpolationHint = -1;
         interpolationType = AffineTransformOp.TYPE_NEAREST_NEIGHBOR;
         boolean customHintPresent = false;
-        Iterator iter = hints.keySet().iterator();
+        Iterator<?> iter = hints.keySet().iterator();
         while (iter.hasNext()) {
             Object key = iter.next();
             if (key == SunHints.KEY_RENDERING ||
@@ -1311,7 +1311,7 @@
      */
     public void addRenderingHints(Map<?,?> hints) {
         boolean customHintPresent = false;
-        Iterator iter = hints.keySet().iterator();
+        Iterator<?> iter = hints.keySet().iterator();
         while (iter.hasNext()) {
             Object key = iter.next();
             if (key == SunHints.KEY_RENDERING ||
diff --git a/jdk/src/share/classes/sun/java2d/SurfaceData.java b/jdk/src/share/classes/sun/java2d/SurfaceData.java
index 9916c5b..bd88234 100644
--- a/jdk/src/share/classes/sun/java2d/SurfaceData.java
+++ b/jdk/src/share/classes/sun/java2d/SurfaceData.java
@@ -520,8 +520,8 @@
     }
 
     public boolean canRenderParallelograms(SunGraphics2D sg2d) {
-        if (sg2d.paintState <= sg2d.PAINT_ALPHACOLOR) {
-            if (sg2d.compositeState == sg2d.COMP_XOR) {
+        if (sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR) {
+            if (sg2d.compositeState == SunGraphics2D.COMP_XOR) {
                 if (havePgramXORLoop == LOOP_UNKNOWN) {
                     FillParallelogram loop =
                         FillParallelogram.locate(SurfaceType.AnyColor,
@@ -531,9 +531,9 @@
                         (loop != null) ? LOOP_FOUND : LOOP_NOTFOUND;
                 }
                 return havePgramXORLoop == LOOP_FOUND;
-            } else if (sg2d.compositeState <= sg2d.COMP_ISCOPY &&
+            } else if (sg2d.compositeState <= SunGraphics2D.COMP_ISCOPY &&
                        sg2d.antialiasHint != SunHints.INTVAL_ANTIALIAS_ON &&
-                       sg2d.clipState != sg2d.CLIP_SHAPE)
+                       sg2d.clipState != SunGraphics2D.CLIP_SHAPE)
             {
                 if (havePgramSolidLoop == LOOP_UNKNOWN) {
                     FillParallelogram loop =
@@ -551,8 +551,8 @@
 
     public void validatePipe(SunGraphics2D sg2d) {
         sg2d.imagepipe = imagepipe;
-        if (sg2d.compositeState == sg2d.COMP_XOR) {
-            if (sg2d.paintState > sg2d.PAINT_ALPHACOLOR) {
+        if (sg2d.compositeState == SunGraphics2D.COMP_XOR) {
+            if (sg2d.paintState > SunGraphics2D.PAINT_ALPHACOLOR) {
                 sg2d.drawpipe = paintViaShape;
                 sg2d.fillpipe = paintViaShape;
                 sg2d.shapepipe = paintShape;
@@ -576,7 +576,7 @@
                     converter = colorViaShape;
                     sg2d.shapepipe = colorPrimitives;
                 }
-                if (sg2d.clipState == sg2d.CLIP_SHAPE) {
+                if (sg2d.clipState == SunGraphics2D.CLIP_SHAPE) {
                     sg2d.drawpipe = converter;
                     sg2d.fillpipe = converter;
                     // REMIND: We should not be changing text strategies
@@ -589,11 +589,11 @@
                     // which is not defined for XOR.
                     sg2d.textpipe = outlineTextRenderer;
                 } else {
-                    if (sg2d.transformState >= sg2d.TRANSFORM_TRANSLATESCALE) {
+                    if (sg2d.transformState >= SunGraphics2D.TRANSFORM_TRANSLATESCALE) {
                         sg2d.drawpipe = converter;
                         sg2d.fillpipe = converter;
                     } else {
-                        if (sg2d.strokeState != sg2d.STROKE_THIN) {
+                        if (sg2d.strokeState != SunGraphics2D.STROKE_THIN) {
                             sg2d.drawpipe = converter;
                         } else {
                             sg2d.drawpipe = colorPrimitives;
@@ -604,9 +604,9 @@
                 }
                 // assert(sg2d.surfaceData == this);
             }
-        } else if (sg2d.compositeState == sg2d.COMP_CUSTOM) {
+        } else if (sg2d.compositeState == SunGraphics2D.COMP_CUSTOM) {
             if (sg2d.antialiasHint == SunHints.INTVAL_ANTIALIAS_ON) {
-                if (sg2d.clipState == sg2d.CLIP_SHAPE) {
+                if (sg2d.clipState == SunGraphics2D.CLIP_SHAPE) {
                     sg2d.drawpipe = AAClipCompViaShape;
                     sg2d.fillpipe = AAClipCompViaShape;
                     sg2d.shapepipe = AAClipCompViaShape;
@@ -621,7 +621,7 @@
                 sg2d.drawpipe = compViaShape;
                 sg2d.fillpipe = compViaShape;
                 sg2d.shapepipe = compShape;
-                if (sg2d.clipState == sg2d.CLIP_SHAPE) {
+                if (sg2d.clipState == SunGraphics2D.CLIP_SHAPE) {
                     sg2d.textpipe = clipCompText;
                 } else {
                     sg2d.textpipe = compText;
@@ -631,7 +631,7 @@
             sg2d.alphafill = getMaskFill(sg2d);
             // assert(sg2d.surfaceData == this);
             if (sg2d.alphafill != null) {
-                if (sg2d.clipState == sg2d.CLIP_SHAPE) {
+                if (sg2d.clipState == SunGraphics2D.CLIP_SHAPE) {
                     sg2d.drawpipe = AAClipColorViaShape;
                     sg2d.fillpipe = AAClipColorViaShape;
                     sg2d.shapepipe = AAClipColorViaShape;
@@ -644,8 +644,8 @@
                     sg2d.drawpipe = converter;
                     sg2d.fillpipe = converter;
                     sg2d.shapepipe = converter;
-                    if (sg2d.paintState > sg2d.PAINT_ALPHACOLOR ||
-                        sg2d.compositeState > sg2d.COMP_ISCOPY)
+                    if (sg2d.paintState > SunGraphics2D.PAINT_ALPHACOLOR ||
+                        sg2d.compositeState > SunGraphics2D.COMP_ISCOPY)
                     {
                         sg2d.textpipe = colorText;
                     } else {
@@ -653,7 +653,7 @@
                     }
                 }
             } else {
-                if (sg2d.clipState == sg2d.CLIP_SHAPE) {
+                if (sg2d.clipState == SunGraphics2D.CLIP_SHAPE) {
                     sg2d.drawpipe = AAClipPaintViaShape;
                     sg2d.fillpipe = AAClipPaintViaShape;
                     sg2d.shapepipe = AAClipPaintViaShape;
@@ -665,9 +665,9 @@
                     sg2d.textpipe = paintText;
                 }
             }
-        } else if (sg2d.paintState > sg2d.PAINT_ALPHACOLOR ||
-                   sg2d.compositeState > sg2d.COMP_ISCOPY ||
-                   sg2d.clipState == sg2d.CLIP_SHAPE)
+        } else if (sg2d.paintState > SunGraphics2D.PAINT_ALPHACOLOR ||
+                   sg2d.compositeState > SunGraphics2D.COMP_ISCOPY ||
+                   sg2d.clipState == SunGraphics2D.CLIP_SHAPE)
         {
             sg2d.drawpipe = paintViaShape;
             sg2d.fillpipe = paintViaShape;
@@ -675,13 +675,13 @@
             sg2d.alphafill = getMaskFill(sg2d);
             // assert(sg2d.surfaceData == this);
             if (sg2d.alphafill != null) {
-                if (sg2d.clipState == sg2d.CLIP_SHAPE) {
+                if (sg2d.clipState == SunGraphics2D.CLIP_SHAPE) {
                     sg2d.textpipe = clipColorText;
                 } else {
                     sg2d.textpipe = colorText;
                 }
             } else {
-                if (sg2d.clipState == sg2d.CLIP_SHAPE) {
+                if (sg2d.clipState == SunGraphics2D.CLIP_SHAPE) {
                     sg2d.textpipe = clipPaintText;
                 } else {
                     sg2d.textpipe = paintText;
@@ -700,11 +700,11 @@
                 converter = colorViaShape;
                 sg2d.shapepipe = colorPrimitives;
             }
-            if (sg2d.transformState >= sg2d.TRANSFORM_TRANSLATESCALE) {
+            if (sg2d.transformState >= SunGraphics2D.TRANSFORM_TRANSLATESCALE) {
                 sg2d.drawpipe = converter;
                 sg2d.fillpipe = converter;
             } else {
-                if (sg2d.strokeState != sg2d.STROKE_THIN) {
+                if (sg2d.strokeState != SunGraphics2D.STROKE_THIN) {
                     sg2d.drawpipe = converter;
                 } else {
                     sg2d.drawpipe = colorPrimitives;
@@ -817,7 +817,7 @@
 
     private static CompositeType getFillCompositeType(SunGraphics2D sg2d) {
         CompositeType compType = sg2d.imageComp;
-        if (sg2d.compositeState == sg2d.COMP_ISCOPY) {
+        if (sg2d.compositeState == SunGraphics2D.COMP_ISCOPY) {
             if (compType == CompositeType.SrcOverNoEa) {
                 compType = CompositeType.OpaqueSrcOverNoEa;
             } else {
diff --git a/jdk/src/share/classes/sun/java2d/SurfaceDataProxy.java b/jdk/src/share/classes/sun/java2d/SurfaceDataProxy.java
index 638579c..fefb507 100644
--- a/jdk/src/share/classes/sun/java2d/SurfaceDataProxy.java
+++ b/jdk/src/share/classes/sun/java2d/SurfaceDataProxy.java
@@ -71,7 +71,7 @@
 
     static {
         cachingAllowed = true;
-        String manimg = (String)AccessController.doPrivileged(
+        String manimg = AccessController.doPrivileged(
             new GetPropertyAction("sun.java2d.managedimages"));
         if (manimg != null && manimg.equals("false")) {
             cachingAllowed = false;
@@ -79,7 +79,7 @@
         }
 
         defaultThreshold = 1;
-        String num = (String)AccessController.doPrivileged(
+        String num = AccessController.doPrivileged(
             new GetPropertyAction("sun.java2d.accthreshold"));
         if (num != null) {
             try {
diff --git a/jdk/src/share/classes/sun/java2d/loops/GraphicsPrimitive.java b/jdk/src/share/classes/sun/java2d/loops/GraphicsPrimitive.java
index 664d5ff..205da2f 100644
--- a/jdk/src/share/classes/sun/java2d/loops/GraphicsPrimitive.java
+++ b/jdk/src/share/classes/sun/java2d/loops/GraphicsPrimitive.java
@@ -328,7 +328,7 @@
 
     static {
         GetPropertyAction gpa = new GetPropertyAction("sun.java2d.trace");
-        String trace = (String)AccessController.doPrivileged(gpa);
+        String trace = AccessController.doPrivileged(gpa);
         if (trace != null) {
             boolean verbose = false;
             int traceflags = 0;
@@ -391,9 +391,9 @@
     private static PrintStream getTraceOutputFile() {
         if (traceout == null) {
             if (tracefile != null) {
-                Object o =
-                    AccessController.doPrivileged(new PrivilegedAction() {
-                        public Object run() {
+                FileOutputStream o = AccessController.doPrivileged(
+                    new PrivilegedAction<FileOutputStream>() {
+                        public FileOutputStream run() {
                             try {
                                 return new FileOutputStream(tracefile);
                             } catch (FileNotFoundException e) {
@@ -402,7 +402,7 @@
                         }
                     });
                 if (o != null) {
-                    traceout = new PrintStream((OutputStream) o);
+                    traceout = new PrintStream(o);
                 } else {
                     traceout = System.err;
                 }
@@ -415,8 +415,8 @@
 
     public static class TraceReporter extends Thread {
         public static void setShutdownHook() {
-            AccessController.doPrivileged(new PrivilegedAction() {
-                public Object run() {
+            AccessController.doPrivileged(new PrivilegedAction<Void>() {
+                public Void run() {
                     TraceReporter t = new TraceReporter();
                     t.setContextClassLoader(null);
                     Runtime.getRuntime().addShutdownHook(t);
diff --git a/jdk/src/share/classes/sun/java2d/loops/SurfaceType.java b/jdk/src/share/classes/sun/java2d/loops/SurfaceType.java
index bcce58e..907c6f3 100644
--- a/jdk/src/share/classes/sun/java2d/loops/SurfaceType.java
+++ b/jdk/src/share/classes/sun/java2d/loops/SurfaceType.java
@@ -56,7 +56,7 @@
 public final class SurfaceType {
 
     private static int unusedUID = 1;
-    private static HashMap surfaceUIDMap = new HashMap(100);
+    private static HashMap<String, Integer> surfaceUIDMap = new HashMap<>(100);
 
     /*
      * CONSTANTS USED BY ALL PRIMITIVES TO DESCRIBE THE SURFACES
@@ -402,7 +402,7 @@
     }
 
     public synchronized static final int makeUniqueID(String desc) {
-        Integer i = (Integer) surfaceUIDMap.get((Object) desc);
+        Integer i = surfaceUIDMap.get(desc);
 
         if (i == null) {
             if (unusedUID > 255) {
diff --git a/jdk/src/share/classes/sun/java2d/opengl/OGLBufImgOps.java b/jdk/src/share/classes/sun/java2d/opengl/OGLBufImgOps.java
index 994b46e..8d8366b 100644
--- a/jdk/src/share/classes/sun/java2d/opengl/OGLBufImgOps.java
+++ b/jdk/src/share/classes/sun/java2d/opengl/OGLBufImgOps.java
@@ -78,12 +78,12 @@
         }
 
         SurfaceData srcData =
-            dstData.getSourceSurfaceData(img, sg.TRANSFORM_ISIDENT,
+            dstData.getSourceSurfaceData(img, SunGraphics2D.TRANSFORM_ISIDENT,
                                          CompositeType.SrcOver, null);
         if (!(srcData instanceof OGLSurfaceData)) {
             // REMIND: this hack tries to ensure that we have a cached texture
             srcData =
-                dstData.getSourceSurfaceData(img, sg.TRANSFORM_ISIDENT,
+                dstData.getSourceSurfaceData(img, SunGraphics2D.TRANSFORM_ISIDENT,
                                              CompositeType.SrcOver, null);
             if (!(srcData instanceof OGLSurfaceData)) {
                 return false;
diff --git a/jdk/src/share/classes/sun/java2d/opengl/OGLDrawImage.java b/jdk/src/share/classes/sun/java2d/opengl/OGLDrawImage.java
index 07a416e..9e373f2 100644
--- a/jdk/src/share/classes/sun/java2d/opengl/OGLDrawImage.java
+++ b/jdk/src/share/classes/sun/java2d/opengl/OGLDrawImage.java
@@ -60,7 +60,7 @@
             SurfaceData dstData = sg.surfaceData;
             SurfaceData srcData =
                 dstData.getSourceSurfaceData(img,
-                                             sg.TRANSFORM_GENERIC,
+                                             SunGraphics2D.TRANSFORM_GENERIC,
                                              sg.imageComp,
                                              bgColor);
 
diff --git a/jdk/src/share/classes/sun/java2d/opengl/OGLPaints.java b/jdk/src/share/classes/sun/java2d/opengl/OGLPaints.java
index 24b839b..62d4001 100644
--- a/jdk/src/share/classes/sun/java2d/opengl/OGLPaints.java
+++ b/jdk/src/share/classes/sun/java2d/opengl/OGLPaints.java
@@ -123,14 +123,16 @@
             }
 
             SurfaceData srcData =
-                dstData.getSourceSurfaceData(bi, sg2d.TRANSFORM_ISIDENT,
+                dstData.getSourceSurfaceData(bi,
+                                             SunGraphics2D.TRANSFORM_ISIDENT,
                                              CompositeType.SrcOver, null);
             if (!(srcData instanceof OGLSurfaceData)) {
                 // REMIND: this is a hack that attempts to cache the system
                 //         memory image from the TexturePaint instance into an
                 //         OpenGL texture...
                 srcData =
-                    dstData.getSourceSurfaceData(bi, sg2d.TRANSFORM_ISIDENT,
+                    dstData.getSourceSurfaceData(bi,
+                                                 SunGraphics2D.TRANSFORM_ISIDENT,
                                                  CompositeType.SrcOver, null);
                 if (!(srcData instanceof OGLSurfaceData)) {
                     return false;
diff --git a/jdk/src/share/classes/sun/java2d/opengl/OGLSurfaceData.java b/jdk/src/share/classes/sun/java2d/opengl/OGLSurfaceData.java
index ca6c9a6..3968f05 100644
--- a/jdk/src/share/classes/sun/java2d/opengl/OGLSurfaceData.java
+++ b/jdk/src/share/classes/sun/java2d/opengl/OGLSurfaceData.java
@@ -428,18 +428,18 @@
         // by the CompositeType.SrcNoEa (any color) test below.)
 
         if (/* CompositeType.SrcNoEa (any color) */
-            (sg2d.compositeState <= sg2d.COMP_ISCOPY &&
-             sg2d.paintState <= sg2d.PAINT_ALPHACOLOR)        ||
+            (sg2d.compositeState <= SunGraphics2D.COMP_ISCOPY &&
+             sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR)         ||
 
             /* CompositeType.SrcOver (any color) */
-            (sg2d.compositeState == sg2d.COMP_ALPHA    &&
-             sg2d.paintState <= sg2d.PAINT_ALPHACOLOR &&
+            (sg2d.compositeState == SunGraphics2D.COMP_ALPHA   &&
+             sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR &&
              (((AlphaComposite)sg2d.composite).getRule() ==
-              AlphaComposite.SRC_OVER))                       ||
+              AlphaComposite.SRC_OVER))                                 ||
 
             /* CompositeType.Xor (any color) */
-            (sg2d.compositeState == sg2d.COMP_XOR &&
-             sg2d.paintState <= sg2d.PAINT_ALPHACOLOR))
+            (sg2d.compositeState == SunGraphics2D.COMP_XOR &&
+             sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR))
         {
             textpipe = oglTextPipe;
         } else {
@@ -454,12 +454,12 @@
         OGLRenderer nonTxPipe = null;
 
         if (sg2d.antialiasHint != SunHints.INTVAL_ANTIALIAS_ON) {
-            if (sg2d.paintState <= sg2d.PAINT_ALPHACOLOR) {
-                if (sg2d.compositeState <= sg2d.COMP_XOR) {
+            if (sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR) {
+                if (sg2d.compositeState <= SunGraphics2D.COMP_XOR) {
                     txPipe = oglTxRenderPipe;
                     nonTxPipe = oglRenderPipe;
                 }
-            } else if (sg2d.compositeState <= sg2d.COMP_ALPHA) {
+            } else if (sg2d.compositeState <= SunGraphics2D.COMP_ALPHA) {
                 if (OGLPaints.isValid(sg2d)) {
                     txPipe = oglTxRenderPipe;
                     nonTxPipe = oglRenderPipe;
@@ -467,7 +467,7 @@
                 // custom paints handled by super.validatePipe() below
             }
         } else {
-            if (sg2d.paintState <= sg2d.PAINT_ALPHACOLOR) {
+            if (sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR) {
                 if (graphicsConfig.isCapPresent(CAPS_PS30) &&
                     (sg2d.imageComp == CompositeType.SrcOverNoEa ||
                      sg2d.imageComp == CompositeType.SrcOver))
@@ -484,7 +484,7 @@
                     sg2d.drawpipe = aaConverter;
                     sg2d.fillpipe = aaConverter;
                     sg2d.shapepipe = aaConverter;
-                } else if (sg2d.compositeState == sg2d.COMP_XOR) {
+                } else if (sg2d.compositeState == SunGraphics2D.COMP_XOR) {
                     // install the solid pipes when AA and XOR are both enabled
                     txPipe = oglTxRenderPipe;
                     nonTxPipe = oglRenderPipe;
@@ -494,10 +494,10 @@
         }
 
         if (txPipe != null) {
-            if (sg2d.transformState >= sg2d.TRANSFORM_TRANSLATESCALE) {
+            if (sg2d.transformState >= SunGraphics2D.TRANSFORM_TRANSLATESCALE) {
                 sg2d.drawpipe = txPipe;
                 sg2d.fillpipe = txPipe;
-            } else if (sg2d.strokeState != sg2d.STROKE_THIN) {
+            } else if (sg2d.strokeState != SunGraphics2D.STROKE_THIN) {
                 sg2d.drawpipe = txPipe;
                 sg2d.fillpipe = nonTxPipe;
             } else {
@@ -524,7 +524,7 @@
 
     @Override
     protected MaskFill getMaskFill(SunGraphics2D sg2d) {
-        if (sg2d.paintState > sg2d.PAINT_ALPHACOLOR) {
+        if (sg2d.paintState > SunGraphics2D.PAINT_ALPHACOLOR) {
             /*
              * We can only accelerate non-Color MaskFill operations if
              * all of the following conditions hold true:
@@ -548,8 +548,8 @@
     public boolean copyArea(SunGraphics2D sg2d,
                             int x, int y, int w, int h, int dx, int dy)
     {
-        if (sg2d.transformState < sg2d.TRANSFORM_TRANSLATESCALE &&
-            sg2d.compositeState < sg2d.COMP_XOR)
+        if (sg2d.transformState < SunGraphics2D.TRANSFORM_TRANSLATESCALE &&
+            sg2d.compositeState < SunGraphics2D.COMP_XOR)
         {
             x += sg2d.transX;
             y += sg2d.transY;
diff --git a/jdk/src/share/classes/sun/java2d/pipe/AAShapePipe.java b/jdk/src/share/classes/sun/java2d/pipe/AAShapePipe.java
index eaa821d..7da9b58 100644
--- a/jdk/src/share/classes/sun/java2d/pipe/AAShapePipe.java
+++ b/jdk/src/share/classes/sun/java2d/pipe/AAShapePipe.java
@@ -144,7 +144,7 @@
     public void renderPath(SunGraphics2D sg, Shape s, BasicStroke bs) {
         boolean adjust = (bs != null &&
                           sg.strokeHint != SunHints.INTVAL_STROKE_PURE);
-        boolean thin = (sg.strokeState <= sg.STROKE_THINDASHED);
+        boolean thin = (sg.strokeState <= SunGraphics2D.STROKE_THINDASHED);
 
         Region clip = sg.getCompClip();
         int abox[] = new int[4];
diff --git a/jdk/src/share/classes/sun/java2d/pipe/BufferedPaints.java b/jdk/src/share/classes/sun/java2d/pipe/BufferedPaints.java
index 87ff649..afdfe6d 100644
--- a/jdk/src/share/classes/sun/java2d/pipe/BufferedPaints.java
+++ b/jdk/src/share/classes/sun/java2d/pipe/BufferedPaints.java
@@ -247,7 +247,7 @@
         BufferedImage bi = paint.getImage();
         SurfaceData dstData = sg2d.surfaceData;
         SurfaceData srcData =
-            dstData.getSourceSurfaceData(bi, sg2d.TRANSFORM_ISIDENT,
+            dstData.getSourceSurfaceData(bi, SunGraphics2D.TRANSFORM_ISIDENT,
                                          CompositeType.SrcOver, null);
         boolean filter =
             (sg2d.interpolationType !=
diff --git a/jdk/src/share/classes/sun/java2d/pipe/BufferedRenderPipe.java b/jdk/src/share/classes/sun/java2d/pipe/BufferedRenderPipe.java
index c5f3097..3270a46 100644
--- a/jdk/src/share/classes/sun/java2d/pipe/BufferedRenderPipe.java
+++ b/jdk/src/share/classes/sun/java2d/pipe/BufferedRenderPipe.java
@@ -508,9 +508,9 @@
     }
 
     public void draw(SunGraphics2D sg2d, Shape s) {
-        if (sg2d.strokeState == sg2d.STROKE_THIN) {
+        if (sg2d.strokeState == SunGraphics2D.STROKE_THIN) {
             if (s instanceof Polygon) {
-                if (sg2d.transformState < sg2d.TRANSFORM_TRANSLATESCALE) {
+                if (sg2d.transformState < SunGraphics2D.TRANSFORM_TRANSLATESCALE) {
                     Polygon p = (Polygon)s;
                     drawPolygon(sg2d, p.xpoints, p.ypoints, p.npoints);
                     return;
@@ -518,7 +518,7 @@
             }
             Path2D.Float p2df;
             int transx, transy;
-            if (sg2d.transformState <= sg2d.TRANSFORM_INT_TRANSLATE) {
+            if (sg2d.transformState <= SunGraphics2D.TRANSFORM_INT_TRANSLATE) {
                 if (s instanceof Path2D.Float) {
                     p2df = (Path2D.Float)s;
                 } else {
@@ -532,7 +532,7 @@
                 transy = 0;
             }
             drawPath(sg2d, p2df, transx, transy);
-        } else if (sg2d.strokeState < sg2d.STROKE_CUSTOM) {
+        } else if (sg2d.strokeState < SunGraphics2D.STROKE_CUSTOM) {
             ShapeSpanIterator si = LoopPipe.getStrokeSpans(sg2d, s);
             try {
                 fillSpans(sg2d, si, 0, 0);
@@ -547,11 +547,11 @@
     public void fill(SunGraphics2D sg2d, Shape s) {
         int transx, transy;
 
-        if (sg2d.strokeState == sg2d.STROKE_THIN) {
+        if (sg2d.strokeState == SunGraphics2D.STROKE_THIN) {
             // Here we are able to use fillPath() for
             // high-quality fills.
             Path2D.Float p2df;
-            if (sg2d.transformState <= sg2d.TRANSFORM_INT_TRANSLATE) {
+            if (sg2d.transformState <= SunGraphics2D.TRANSFORM_INT_TRANSLATE) {
                 if (s instanceof Path2D.Float) {
                     p2df = (Path2D.Float)s;
                 } else {
@@ -569,7 +569,7 @@
         }
 
         AffineTransform at;
-        if (sg2d.transformState <= sg2d.TRANSFORM_INT_TRANSLATE) {
+        if (sg2d.transformState <= SunGraphics2D.TRANSFORM_INT_TRANSLATE) {
             // Transform (translation) will be done by FillSpans (we could
             // delegate to fillPolygon() here, but most hardware accelerated
             // libraries cannot handle non-convex polygons, so we will use
diff --git a/jdk/src/share/classes/sun/java2d/pipe/DrawImage.java b/jdk/src/share/classes/sun/java2d/pipe/DrawImage.java
index f702a68..510a46b 100644
--- a/jdk/src/share/classes/sun/java2d/pipe/DrawImage.java
+++ b/jdk/src/share/classes/sun/java2d/pipe/DrawImage.java
@@ -146,7 +146,7 @@
         int imgh = img.getHeight(null);
         boolean checkfinalxform;
 
-        if (sg.transformState <= sg.TRANSFORM_ANY_TRANSLATE &&
+        if (sg.transformState <= SunGraphics2D.TRANSFORM_ANY_TRANSLATE &&
             (txtype == AffineTransform.TYPE_IDENTITY ||
              txtype == AffineTransform.TYPE_TRANSLATION))
         {
@@ -166,7 +166,7 @@
                 return;
             }
             checkfinalxform = false;
-        } else if (sg.transformState <= sg.TRANSFORM_TRANSLATESCALE &&
+        } else if (sg.transformState <= SunGraphics2D.TRANSFORM_TRANSLATESCALE &&
                    ((txtype & (AffineTransform.TYPE_FLIP |
                                AffineTransform.TYPE_MASK_ROTATION |
                                AffineTransform.TYPE_GENERAL_TRANSFORM)) == 0))
@@ -344,14 +344,14 @@
         Region clip = sg.getCompClip();
         SurfaceData dstData = sg.surfaceData;
         SurfaceData srcData = dstData.getSourceSurfaceData(img,
-                                                           sg.TRANSFORM_GENERIC,
+                                                           SunGraphics2D.TRANSFORM_GENERIC,
                                                            sg.imageComp,
                                                            bgColor);
 
         if (srcData == null) {
             img = getBufferedImage(img);
             srcData = dstData.getSourceSurfaceData(img,
-                                                   sg.TRANSFORM_GENERIC,
+                                                   SunGraphics2D.TRANSFORM_GENERIC,
                                                    sg.imageComp,
                                                    bgColor);
             if (srcData == null) {
@@ -372,7 +372,7 @@
             sx1 = sy1 = 0;
 
             srcData = dstData.getSourceSurfaceData(img,
-                                                   sg.TRANSFORM_GENERIC,
+                                                   SunGraphics2D.TRANSFORM_GENERIC,
                                                    sg.imageComp,
                                                    bgColor);
         }
@@ -398,7 +398,7 @@
             sx1 = sy1 = 0;
 
             srcData = dstData.getSourceSurfaceData(img,
-                                                   sg.TRANSFORM_GENERIC,
+                                                   SunGraphics2D.TRANSFORM_GENERIC,
                                                    sg.imageComp,
                                                    null);
             srcType = srcData.getSurfaceType();
@@ -449,7 +449,7 @@
         SurfaceType dstType = dstData.getSurfaceType();
         MaskBlit maskblit;
         Blit blit;
-        if (sg.compositeState <= sg.COMP_ALPHA) {
+        if (sg.compositeState <= SunGraphics2D.COMP_ALPHA) {
             /* NOTE: We either have, or we can make,
              * a MaskBlit for any alpha composite type
              */
@@ -565,7 +565,7 @@
         while (true) {
             SurfaceData srcData =
                 dstData.getSourceSurfaceData(img,
-                                             sg.TRANSFORM_ISIDENT,
+                                             SunGraphics2D.TRANSFORM_ISIDENT,
                                              sg.imageComp,
                                              bgColor);
             if (srcData == null) {
@@ -628,7 +628,7 @@
         while (true) {
             SurfaceData srcData =
                 dstData.getSourceSurfaceData(img,
-                                             sg.TRANSFORM_TRANSLATESCALE,
+                                             SunGraphics2D.TRANSFORM_TRANSLATESCALE,
                                              sg.imageComp,
                                              bgColor);
 
@@ -800,11 +800,11 @@
 
     public static boolean isSimpleTranslate(SunGraphics2D sg) {
         int ts = sg.transformState;
-        if (ts <= sg.TRANSFORM_INT_TRANSLATE) {
+        if (ts <= SunGraphics2D.TRANSFORM_INT_TRANSLATE) {
             // Integer translates are always "simple"
             return true;
         }
-        if (ts >= sg.TRANSFORM_TRANSLATESCALE) {
+        if (ts >= SunGraphics2D.TRANSFORM_TRANSLATESCALE) {
             // Scales and beyond are always "not simple"
             return false;
         }
@@ -846,8 +846,11 @@
         }
         int type = tx.getType();
         boolean needTrans =
-            ((type&(tx.TYPE_MASK_ROTATION|tx.TYPE_GENERAL_TRANSFORM)) != 0);
-        if (! needTrans && type != tx.TYPE_TRANSLATION && type != tx.TYPE_IDENTITY)
+                ((type & (AffineTransform.TYPE_MASK_ROTATION |
+                          AffineTransform.TYPE_GENERAL_TRANSFORM)) != 0);
+        if (! needTrans &&
+              type != AffineTransform.TYPE_TRANSLATION &&
+              type != AffineTransform.TYPE_IDENTITY)
         {
             double[] mtx = new double[4];
             tx.getMatrix(mtx);
@@ -861,7 +864,7 @@
                 Raster raster = bImg.getRaster();
                 IndexColorModel icm = (IndexColorModel) cm;
                 // Just need to make sure that we have a transparent pixel
-                if (needTrans && cm.getTransparency() == cm.OPAQUE) {
+                if (needTrans && cm.getTransparency() == Transparency.OPAQUE) {
                     // Fix 4221407
                     if (raster instanceof sun.awt.image.BytePackedRaster) {
                         dstCM = ColorModel.getRGBdefault();
@@ -892,7 +895,7 @@
                     }   /* raster instanceof sun.awt.image.BytePackedRaster */
                 } /* if (cm.getTransparency() == cm.OPAQUE) */
             } /* if (cm instanceof IndexColorModel) */
-            else if (needTrans && cm.getTransparency() == cm.OPAQUE) {
+            else if (needTrans && cm.getTransparency() == Transparency.OPAQUE) {
                 // Need a bitmask transparency
                 // REMIND: for now, use full transparency since no loops
                 // for bitmask
@@ -902,7 +905,7 @@
         else {
 
             if (cm instanceof IndexColorModel ||
-                (needTrans && cm.getTransparency() == cm.OPAQUE))
+                (needTrans && cm.getTransparency() == Transparency.OPAQUE))
             {
                 // Need a bitmask transparency
                 // REMIND: for now, use full transparency since no loops
diff --git a/jdk/src/share/classes/sun/java2d/pipe/GlyphListPipe.java b/jdk/src/share/classes/sun/java2d/pipe/GlyphListPipe.java
index 5a44749..0467290 100644
--- a/jdk/src/share/classes/sun/java2d/pipe/GlyphListPipe.java
+++ b/jdk/src/share/classes/sun/java2d/pipe/GlyphListPipe.java
@@ -54,7 +54,7 @@
         }
 
         float devx, devy;
-        if (sg2d.transformState >= sg2d.TRANSFORM_TRANSLATESCALE) {
+        if (sg2d.transformState >= SunGraphics2D.TRANSFORM_TRANSLATESCALE) {
             double origin[] = {x + info.originX, y + info.originY};
             sg2d.transform.transform(origin, 0, origin, 0, 1);
             devx = (float)origin[0];
@@ -90,7 +90,7 @@
                                         sg2d, data, offset, length, ix, iy);
             return;
         }
-        if (sg2d.transformState >= sg2d.TRANSFORM_TRANSLATESCALE) {
+        if (sg2d.transformState >= SunGraphics2D.TRANSFORM_TRANSLATESCALE) {
             double origin[] = {ix + info.originX, iy + info.originY};
             sg2d.transform.transform(origin, 0, origin, 0, 1);
             x = (float) origin[0];
@@ -122,7 +122,7 @@
             SurfaceData.outlineTextRenderer.drawGlyphVector(sg2d, gv, x, y);
             return;
         }
-        if (sg2d.transformState >= sg2d.TRANSFORM_TRANSLATESCALE) {
+        if (sg2d.transformState >= SunGraphics2D.TRANSFORM_TRANSLATESCALE) {
             double origin[] = {x, y};
             sg2d.transform.transform(origin, 0, origin, 0, 1);
             x = (float) origin[0];
diff --git a/jdk/src/share/classes/sun/java2d/pipe/LoopPipe.java b/jdk/src/share/classes/sun/java2d/pipe/LoopPipe.java
index e975cc9..e70ab69 100644
--- a/jdk/src/share/classes/sun/java2d/pipe/LoopPipe.java
+++ b/jdk/src/share/classes/sun/java2d/pipe/LoopPipe.java
@@ -171,11 +171,11 @@
 
 
     public void draw(SunGraphics2D sg2d, Shape s) {
-        if (sg2d.strokeState == sg2d.STROKE_THIN) {
+        if (sg2d.strokeState == SunGraphics2D.STROKE_THIN) {
             Path2D.Float p2df;
             int transX;
             int transY;
-            if (sg2d.transformState <= sg2d.TRANSFORM_INT_TRANSLATE) {
+            if (sg2d.transformState <= SunGraphics2D.TRANSFORM_INT_TRANSLATE) {
                 if (s instanceof Path2D.Float) {
                     p2df = (Path2D.Float)s;
                 } else {
@@ -193,7 +193,7 @@
             return;
         }
 
-        if (sg2d.strokeState == sg2d.STROKE_CUSTOM) {
+        if (sg2d.strokeState == SunGraphics2D.STROKE_CUSTOM) {
             fill(sg2d, sg2d.stroke.createStrokedShape(s));
             return;
         }
@@ -271,7 +271,7 @@
             sr.setRule(PathIterator.WIND_NON_ZERO);
 
             BasicStroke bs = (BasicStroke) sg2d.stroke;
-            boolean thin = (sg2d.strokeState <= sg2d.STROKE_THINDASHED);
+            boolean thin = (sg2d.strokeState <= SunGraphics2D.STROKE_THINDASHED);
             boolean normalize =
                 (sg2d.strokeHint != SunHints.INTVAL_STROKE_PURE);
 
@@ -288,11 +288,11 @@
     }
 
     public void fill(SunGraphics2D sg2d, Shape s) {
-        if (sg2d.strokeState == sg2d.STROKE_THIN) {
+        if (sg2d.strokeState == SunGraphics2D.STROKE_THIN) {
             Path2D.Float p2df;
             int transX;
             int transY;
-            if (sg2d.transformState <= sg2d.TRANSFORM_INT_TRANSLATE) {
+            if (sg2d.transformState <= SunGraphics2D.TRANSFORM_INT_TRANSLATE) {
                 if (s instanceof Path2D.Float) {
                     p2df = (Path2D.Float)s;
                 } else {
@@ -314,7 +314,7 @@
         try {
             sr.setOutputArea(sg2d.getCompClip());
             AffineTransform at =
-                ((sg2d.transformState == sg2d.TRANSFORM_ISIDENT)
+                ((sg2d.transformState == SunGraphics2D.TRANSFORM_ISIDENT)
                  ? null
                  : sg2d.transform);
             sr.appendPath(s.getPathIterator(at));
@@ -328,7 +328,7 @@
         // REMIND: Eventually, the plan is that it will not be possible for
         // fs to be null since the FillSpans loop will be the fundamental
         // loop implemented for any destination type...
-        if (sg2d.clipState == sg2d.CLIP_SHAPE) {
+        if (sg2d.clipState == SunGraphics2D.CLIP_SHAPE) {
             si = sg2d.clipRegion.filter(si);
             // REMIND: Region.filter produces a Java-only iterator
             // with no native counterpart...
diff --git a/jdk/src/share/classes/sun/java2d/pipe/RenderingEngine.java b/jdk/src/share/classes/sun/java2d/pipe/RenderingEngine.java
index e2913ab..83b6911 100644
--- a/jdk/src/share/classes/sun/java2d/pipe/RenderingEngine.java
+++ b/jdk/src/share/classes/sun/java2d/pipe/RenderingEngine.java
@@ -117,16 +117,16 @@
             return reImpl;
         }
 
-        reImpl = (RenderingEngine)
-            AccessController.doPrivileged(new PrivilegedAction() {
-                public Object run() {
+        reImpl =
+            AccessController.doPrivileged(new PrivilegedAction<RenderingEngine>() {
+                public RenderingEngine run() {
                     final String ductusREClass = "sun.dc.DuctusRenderingEngine";
                     String reClass =
                         System.getProperty("sun.java2d.renderer", ductusREClass);
                     if (reClass.equals(ductusREClass)) {
                         try {
-                            Class cls = Class.forName(ductusREClass);
-                            return cls.newInstance();
+                            Class<?> cls = Class.forName(ductusREClass);
+                            return (RenderingEngine) cls.newInstance();
                         } catch (ReflectiveOperationException ignored) {
                             // not found
                         }
@@ -153,7 +153,7 @@
 
         GetPropertyAction gpa =
             new GetPropertyAction("sun.java2d.renderer.trace");
-        String reTrace = (String) AccessController.doPrivileged(gpa);
+        String reTrace = AccessController.doPrivileged(gpa);
         if (reTrace != null) {
             reImpl = new Tracer(reImpl);
         }
diff --git a/jdk/src/share/classes/sun/launcher/LauncherHelper.java b/jdk/src/share/classes/sun/launcher/LauncherHelper.java
index 24eeaca..2f3710b 100644
--- a/jdk/src/share/classes/sun/launcher/LauncherHelper.java
+++ b/jdk/src/share/classes/sun/launcher/LauncherHelper.java
@@ -428,7 +428,7 @@
             if (t != null) {
                 t.printStackTrace();
             } else {
-                Thread.currentThread().dumpStack();
+                Thread.dumpStack();
             }
         }
         System.exit(1);
diff --git a/jdk/src/share/classes/sun/management/counter/perf/PerfInstrumentation.java b/jdk/src/share/classes/sun/management/counter/perf/PerfInstrumentation.java
index 1541744..eb7ae7a 100644
--- a/jdk/src/share/classes/sun/management/counter/perf/PerfInstrumentation.java
+++ b/jdk/src/share/classes/sun/management/counter/perf/PerfInstrumentation.java
@@ -169,17 +169,15 @@
         Matcher matcher = pattern.matcher("");
         List<Counter> matches = new ArrayList<Counter>();
 
-        Iterator iter = map.entrySet().iterator();
-        while (iter.hasNext()) {
-            Map.Entry me = (Map.Entry) iter.next();
-            String name = (String) me.getKey();
+        for (Map.Entry<String,Counter> me: map.entrySet()) {
+            String name = me.getKey();
 
             // apply pattern to counter name
             matcher.reset(name);
 
             // if the pattern matches, then add Counter to list
             if (matcher.lookingAt()) {
-                matches.add((Counter)me.getValue());
+                matches.add(me.getValue());
             }
         }
         return matches;
diff --git a/jdk/src/share/classes/sun/management/jmxremote/ConnectorBootstrap.java b/jdk/src/share/classes/sun/management/jmxremote/ConnectorBootstrap.java
index 3e48089..a3b318a 100644
--- a/jdk/src/share/classes/sun/management/jmxremote/ConnectorBootstrap.java
+++ b/jdk/src/share/classes/sun/management/jmxremote/ConnectorBootstrap.java
@@ -233,16 +233,14 @@
                         "the access file [" + accessFile + "] as the " +
                         "authenticated Subject is null");
             }
-            final Set principals = subject.getPrincipals();
-            for (Iterator i = principals.iterator(); i.hasNext();) {
-                final Principal p = (Principal) i.next();
+            final Set<Principal> principals = subject.getPrincipals();
+            for (Principal p: principals) {
                 if (properties.containsKey(p.getName())) {
                     return;
                 }
             }
             final Set<String> principalsStr = new HashSet<String>();
-            for (Iterator i = principals.iterator(); i.hasNext();) {
-                final Principal p = (Principal) i.next();
+            for (Principal p: principals) {
                 principalsStr.add(p.getName());
             }
             throw new SecurityException(
@@ -653,7 +651,7 @@
                 }
                 TrustManagerFactory tmf = TrustManagerFactory.getInstance(
                         TrustManagerFactory.getDefaultAlgorithm());
-                tmf.init((KeyStore) ts);
+                tmf.init(ts);
 
                 SSLContext ctx = SSLContext.getInstance("SSL");
                 ctx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
diff --git a/jdk/src/share/classes/sun/misc/BASE64Decoder.java b/jdk/src/share/classes/sun/misc/BASE64Decoder.java
index 63f1228..d413252 100644
--- a/jdk/src/share/classes/sun/misc/BASE64Decoder.java
+++ b/jdk/src/share/classes/sun/misc/BASE64Decoder.java
@@ -102,6 +102,7 @@
     /**
      * Decode one BASE64 atom into 1, 2, or 3 bytes of data.
      */
+    @SuppressWarnings("fallthrough")
     protected void decodeAtom(PushbackInputStream inStream, OutputStream outStream, int rem)
         throws java.io.IOException
     {
diff --git a/jdk/src/share/classes/sun/misc/CEFormatException.java b/jdk/src/share/classes/sun/misc/CEFormatException.java
index 974a55c..0b3aa05 100644
--- a/jdk/src/share/classes/sun/misc/CEFormatException.java
+++ b/jdk/src/share/classes/sun/misc/CEFormatException.java
@@ -28,7 +28,9 @@
 import java.io.IOException;
 
 public class CEFormatException extends IOException {
-        public CEFormatException(String s) {
-                super(s);
-        }
+    static final long serialVersionUID = -7139121221067081482L;
+    public CEFormatException(String s) {
+        super(s);
+    }
 }
+
diff --git a/jdk/src/share/classes/sun/misc/CEStreamExhausted.java b/jdk/src/share/classes/sun/misc/CEStreamExhausted.java
index 28e0ffe..d346d55 100644
--- a/jdk/src/share/classes/sun/misc/CEStreamExhausted.java
+++ b/jdk/src/share/classes/sun/misc/CEStreamExhausted.java
@@ -27,4 +27,7 @@
 import java.io.IOException;
 
 /** This exception is thrown when EOF is reached */
-public class CEStreamExhausted extends IOException { };
+public class CEStreamExhausted extends IOException {
+    static final long serialVersionUID = -5889118049525891904L;
+}
+
diff --git a/jdk/src/share/classes/sun/misc/ClassLoaderUtil.java b/jdk/src/share/classes/sun/misc/ClassLoaderUtil.java
index 61106db..81f00d4 100644
--- a/jdk/src/share/classes/sun/misc/ClassLoaderUtil.java
+++ b/jdk/src/share/classes/sun/misc/ClassLoaderUtil.java
@@ -79,9 +79,9 @@
 
             URLClassPath ucp = SharedSecrets.getJavaNetAccess()
                                                 .getURLClassPath(classLoader);
-            ArrayList loaders = ucp.loaders;
-            Stack urls = ucp.urls;
-            HashMap lmap = ucp.lmap;
+            ArrayList<?> loaders = ucp.loaders;
+            Stack<?> urls = ucp.urls;
+            HashMap<?,?> lmap = ucp.lmap;
 
             /*
              *The urls variable in the URLClassPath object holds URLs that have not yet
diff --git a/jdk/src/share/classes/sun/misc/CompoundEnumeration.java b/jdk/src/share/classes/sun/misc/CompoundEnumeration.java
index 69de7f8..fc3ecea 100644
--- a/jdk/src/share/classes/sun/misc/CompoundEnumeration.java
+++ b/jdk/src/share/classes/sun/misc/CompoundEnumeration.java
@@ -33,10 +33,10 @@
  * enumerations.
  */
 public class CompoundEnumeration<E> implements Enumeration<E> {
-    private Enumeration[] enums;
+    private Enumeration<E>[] enums;
     private int index = 0;
 
-    public CompoundEnumeration(Enumeration[] enums) {
+    public CompoundEnumeration(Enumeration<E>[] enums) {
         this.enums = enums;
     }
 
@@ -58,6 +58,6 @@
         if (!next()) {
             throw new NoSuchElementException();
         }
-        return (E)enums[index].nextElement();
+        return enums[index].nextElement();
     }
 }
diff --git a/jdk/src/share/classes/sun/misc/ExtensionDependency.java b/jdk/src/share/classes/sun/misc/ExtensionDependency.java
index ca9ad72..81a7774 100644
--- a/jdk/src/share/classes/sun/misc/ExtensionDependency.java
+++ b/jdk/src/share/classes/sun/misc/ExtensionDependency.java
@@ -70,7 +70,7 @@
 public class ExtensionDependency {
 
     /* Callbak interfaces to delegate installation of missing extensions */
-    private static Vector providers;
+    private static Vector<ExtensionInstallationProvider> providers;
 
     /**
      * <p>
@@ -83,7 +83,7 @@
         (ExtensionInstallationProvider eip)
     {
         if (providers == null) {
-            providers = new Vector();
+            providers = new Vector<>();
         }
         providers.add(eip);
     }
@@ -93,7 +93,7 @@
      * Unregister a previously installed installation provider
      * </p>
      */
-    public synchronized  static void removeExtensionInstallationProvider
+    public synchronized static void removeExtensionInstallationProvider
         (ExtensionInstallationProvider eip)
     {
         providers.remove(eip);
@@ -348,14 +348,16 @@
                                        ExtensionInfo instInfo)
         throws ExtensionInstallationException
     {
-
-        Vector currentProviders;
+        Vector<ExtensionInstallationProvider> currentProviders;
         synchronized(providers) {
-            currentProviders = (Vector) providers.clone();
+            @SuppressWarnings("unchecked")
+            Vector<ExtensionInstallationProvider> tmp =
+                (Vector<ExtensionInstallationProvider>) providers.clone();
+            currentProviders = tmp;
         }
-        for (Enumeration e=currentProviders.elements();e.hasMoreElements();) {
-            ExtensionInstallationProvider eip =
-                (ExtensionInstallationProvider) e.nextElement();
+        for (Enumeration<ExtensionInstallationProvider> e = currentProviders.elements();
+                e.hasMoreElements();) {
+            ExtensionInstallationProvider eip = e.nextElement();
 
             if (eip!=null) {
                 // delegate the installation to the provider
diff --git a/jdk/src/share/classes/sun/misc/ExtensionInstallationException.java b/jdk/src/share/classes/sun/misc/ExtensionInstallationException.java
index 61f484a..156ba0b 100644
--- a/jdk/src/share/classes/sun/misc/ExtensionInstallationException.java
+++ b/jdk/src/share/classes/sun/misc/ExtensionInstallationException.java
@@ -34,6 +34,8 @@
 
 public class ExtensionInstallationException extends Exception {
 
+    static final long serialVersionUID = 3139688306909345924L;
+
     /*
      * <p>
      * Construct a new exception with an exception reason
diff --git a/jdk/src/share/classes/sun/misc/FloatingDecimal.java b/jdk/src/share/classes/sun/misc/FloatingDecimal.java
index 4df0487..478f120 100644
--- a/jdk/src/share/classes/sun/misc/FloatingDecimal.java
+++ b/jdk/src/share/classes/sun/misc/FloatingDecimal.java
@@ -325,7 +325,7 @@
             // can do int arithmetic rather than long!
             int  ivalue = (int)lvalue;
             ndigits = 10;
-            digits = (char[])(perThreadBuffer.get());
+            digits = perThreadBuffer.get();
             digitno = ndigits-1;
             c = ivalue%10;
             ivalue /= 10;
@@ -345,7 +345,7 @@
             // same algorithm as above (same bugs, too )
             // but using long arithmetic.
             ndigits = 20;
-            digits = (char[])(perThreadBuffer.get());
+            digits = perThreadBuffer.get();
             digitno = ndigits-1;
             c = (int)(lvalue%10L);
             lvalue /= 10L;
@@ -477,9 +477,9 @@
         }
         // Begin to unpack
         // Discover obvious special cases of NaN and Infinity.
-        binExp = (int)( (fBits&singleExpMask) >> singleExpShift );
+        binExp = (fBits&singleExpMask) >> singleExpShift;
         fractBits = fBits&singleFractMask;
-        if ( binExp == (int)(singleExpMask>>singleExpShift) ) {
+        if ( binExp == (singleExpMask>>singleExpShift) ) {
             isExceptional = true;
             if ( fractBits == 0L ){
                 digits =  infinity;
@@ -900,7 +900,7 @@
     }
 
     public String toJavaFormatString() {
-        char result[] = (char[])(perThreadBuffer.get());
+        char result[] = perThreadBuffer.get();
         int i = getChars(result);
         return new String(result, 0, i);
     }
@@ -978,14 +978,14 @@
     }
 
     // Per-thread buffer for string/stringbuffer conversion
-    private static ThreadLocal perThreadBuffer = new ThreadLocal() {
-            protected synchronized Object initialValue() {
+    private static ThreadLocal<char[]> perThreadBuffer = new ThreadLocal<char[]>() {
+            protected synchronized char[] initialValue() {
                 return new char[26];
             }
         };
 
     public void appendTo(Appendable buf) {
-          char result[] = (char[])(perThreadBuffer.get());
+          char result[] = perThreadBuffer.get();
           int i = getChars(result);
         if (buf instanceof StringBuilder)
             ((StringBuilder) buf).append(result, 0, i);
@@ -995,6 +995,7 @@
             assert false;
     }
 
+    @SuppressWarnings("fallthrough")
     public static FloatingDecimal
     readJavaFormatString( String in ) throws NumberFormatException {
         boolean isNegative = false;
@@ -2209,7 +2210,7 @@
                     // exponent correctly, even in the case of
                     // Double.MAX_VALUE overflowing to infinity.
 
-                    significand = (( ((long)exponent +
+                    significand = (( (exponent +
                                      (long)DoubleConsts.EXP_BIAS) <<
                                      (DoubleConsts.SIGNIFICAND_WIDTH-1))
                                    & DoubleConsts.EXP_BIT_MASK) |
diff --git a/jdk/src/share/classes/sun/misc/FormattedFloatingDecimal.java b/jdk/src/share/classes/sun/misc/FormattedFloatingDecimal.java
index 261dbc0..5532b92 100644
--- a/jdk/src/share/classes/sun/misc/FormattedFloatingDecimal.java
+++ b/jdk/src/share/classes/sun/misc/FormattedFloatingDecimal.java
@@ -333,7 +333,7 @@
             // can do int arithmetic rather than long!
             int  ivalue = (int)lvalue;
             ndigits = 10;
-            digits = (char[])(perThreadBuffer.get());
+            digits = perThreadBuffer.get();
             digitno = ndigits-1;
             c = ivalue%10;
             ivalue /= 10;
@@ -353,7 +353,7 @@
             // same algorithm as above (same bugs, too )
             // but using long arithmetic.
             ndigits = 20;
-            digits = (char[])(perThreadBuffer.get());
+            digits = perThreadBuffer.get();
             digitno = ndigits-1;
             c = (int)(lvalue%10L);
             lvalue /= 10L;
@@ -554,9 +554,9 @@
         }
         // Begin to unpack
         // Discover obvious special cases of NaN and Infinity.
-        binExp = (int)( (fBits&singleExpMask) >> singleExpShift );
+        binExp = (fBits&singleExpMask) >> singleExpShift;
         fractBits = fBits&singleFractMask;
-        if ( binExp == (int)(singleExpMask>>singleExpShift) ) {
+        if ( binExp == (singleExpMask>>singleExpShift) ) {
             isExceptional = true;
             if ( fractBits == 0L ){
                 digits =  infinity;
@@ -1140,8 +1140,8 @@
     }
 
     // Per-thread buffer for string/stringbuffer conversion
-    private static ThreadLocal perThreadBuffer = new ThreadLocal() {
-            protected synchronized Object initialValue() {
+    private static ThreadLocal<char[]> perThreadBuffer = new ThreadLocal<char[]>() {
+            protected synchronized char[] initialValue() {
                 return new char[26];
             }
         };
diff --git a/jdk/src/share/classes/sun/misc/InvalidJarIndexException.java b/jdk/src/share/classes/sun/misc/InvalidJarIndexException.java
index 83e8199..4c6de5d 100644
--- a/jdk/src/share/classes/sun/misc/InvalidJarIndexException.java
+++ b/jdk/src/share/classes/sun/misc/InvalidJarIndexException.java
@@ -38,6 +38,8 @@
 public
 class InvalidJarIndexException extends RuntimeException {
 
+    static final long serialVersionUID = -6159797516569680148L;
+
     /**
      * Constructs an <code>InvalidJarIndexException</code> with no
      * detail message.
diff --git a/jdk/src/share/classes/sun/misc/JarIndex.java b/jdk/src/share/classes/sun/misc/JarIndex.java
index f9781d6..02f3c52 100644
--- a/jdk/src/share/classes/sun/misc/JarIndex.java
+++ b/jdk/src/share/classes/sun/misc/JarIndex.java
@@ -48,13 +48,13 @@
      * The hash map that maintains mappings from
      * package/classe/resource to jar file list(s)
      */
-    private HashMap indexMap;
+    private HashMap<String,LinkedList<String>> indexMap;
 
     /**
      * The hash map that maintains mappings from
      * jar file to package/class/resource lists
      */
-    private HashMap jarMap;
+    private HashMap<String,LinkedList<String>> jarMap;
 
     /*
      * An ordered list of jar file names.
@@ -78,8 +78,8 @@
      * Constructs a new, empty jar index.
      */
     public JarIndex() {
-        indexMap = new HashMap();
-        jarMap = new HashMap();
+        indexMap = new HashMap<>();
+        jarMap = new HashMap<>();
     }
 
     /**
@@ -150,10 +150,11 @@
      * Add the key, value pair to the hashmap, the value will
      * be put in a linked list which is created if necessary.
      */
-    private void addToList(String key, String value, HashMap t) {
-        LinkedList list = (LinkedList)t.get(key);
+    private void addToList(String key, String value,
+                           HashMap<String,LinkedList<String>> t) {
+        LinkedList<String> list = t.get(key);
         if (list == null) {
-            list = new LinkedList();
+            list = new LinkedList<>();
             list.add(value);
             t.put(key, list);
         } else if (!list.contains(value)) {
@@ -166,13 +167,13 @@
      *
      * @param fileName the key of the mapping
      */
-    public LinkedList get(String fileName) {
-        LinkedList jarFiles = null;
-        if ((jarFiles = (LinkedList)indexMap.get(fileName)) == null) {
+    public LinkedList<String> get(String fileName) {
+        LinkedList<String> jarFiles = null;
+        if ((jarFiles = indexMap.get(fileName)) == null) {
             /* try the package name again */
             int pos;
             if((pos = fileName.lastIndexOf("/")) != -1) {
-                jarFiles = (LinkedList)indexMap.get(fileName.substring(0, pos));
+                jarFiles = indexMap.get(fileName.substring(0, pos));
             }
         }
         return jarFiles;
@@ -235,9 +236,9 @@
             ZipFile zrf = new ZipFile(currentJar.replace
                                       ('/', File.separatorChar));
 
-            Enumeration entries = zrf.entries();
+            Enumeration<? extends ZipEntry> entries = zrf.entries();
             while(entries.hasMoreElements()) {
-                ZipEntry entry = (ZipEntry) entries.nextElement();
+                ZipEntry entry = entries.nextElement();
                 String fileName = entry.getName();
 
                 // Skip the META-INF directory, the index, and manifest.
@@ -282,11 +283,11 @@
                 /* print out the jar file name */
                 String jar = jarFiles[i];
                 bw.write(jar + "\n");
-                LinkedList jarlist = (LinkedList)jarMap.get(jar);
+                LinkedList<String> jarlist = jarMap.get(jar);
                 if (jarlist != null) {
-                    Iterator listitr = jarlist.iterator();
+                    Iterator<String> listitr = jarlist.iterator();
                     while(listitr.hasNext()) {
-                        bw.write((String)(listitr.next()) + "\n");
+                        bw.write(listitr.next() + "\n");
                     }
                 }
                 bw.write("\n");
@@ -309,7 +310,7 @@
         String currentJar = null;
 
         /* an ordered list of jar file names */
-        Vector jars = new Vector();
+        Vector<String> jars = new Vector<>();
 
         /* read until we see a .jar line */
         while((line = br.readLine()) != null && !line.endsWith(".jar"));
@@ -328,7 +329,7 @@
             }
         }
 
-        jarFiles = (String[])jars.toArray(new String[jars.size()]);
+        jarFiles = jars.toArray(new String[jars.size()]);
     }
 
     /**
@@ -342,14 +343,14 @@
      *
      */
     public void merge(JarIndex toIndex, String path) {
-        Iterator itr = indexMap.entrySet().iterator();
+        Iterator<Map.Entry<String,LinkedList<String>>> itr = indexMap.entrySet().iterator();
         while(itr.hasNext()) {
-            Map.Entry e = (Map.Entry)itr.next();
-            String packageName = (String)e.getKey();
-            LinkedList from_list = (LinkedList)e.getValue();
-            Iterator listItr = from_list.iterator();
+            Map.Entry<String,LinkedList<String>> e = itr.next();
+            String packageName = e.getKey();
+            LinkedList<String> from_list = e.getValue();
+            Iterator<String> listItr = from_list.iterator();
             while(listItr.hasNext()) {
-                String jarName = (String)listItr.next();
+                String jarName = listItr.next();
                 if (path != null) {
                     jarName = path.concat(jarName);
                 }
diff --git a/jdk/src/share/classes/sun/misc/JavaLangAccess.java b/jdk/src/share/classes/sun/misc/JavaLangAccess.java
index c61f590..d4805d87 100644
--- a/jdk/src/share/classes/sun/misc/JavaLangAccess.java
+++ b/jdk/src/share/classes/sun/misc/JavaLangAccess.java
@@ -31,19 +31,19 @@
 
 public interface JavaLangAccess {
     /** Return the constant pool for a class. */
-    ConstantPool getConstantPool(Class klass);
+    ConstantPool getConstantPool(Class<?> klass);
 
     /**
      * Set the AnnotationType instance corresponding to this class.
      * (This method only applies to annotation types.)
      */
-    void setAnnotationType(Class klass, AnnotationType annotationType);
+    void setAnnotationType(Class<?> klass, AnnotationType annotationType);
 
     /**
      * Get the AnnotationType instance corresponding to this class.
      * (This method only applies to annotation types.)
      */
-    AnnotationType getAnnotationType(Class klass);
+    AnnotationType getAnnotationType(Class<?> klass);
 
     /**
      * Returns the elements of an enum class or null if the
diff --git a/jdk/src/share/classes/sun/misc/JavaUtilJarAccess.java b/jdk/src/share/classes/sun/misc/JavaUtilJarAccess.java
index 0f1efd1..8165482 100644
--- a/jdk/src/share/classes/sun/misc/JavaUtilJarAccess.java
+++ b/jdk/src/share/classes/sun/misc/JavaUtilJarAccess.java
@@ -40,5 +40,5 @@
     public Enumeration<String> entryNames(JarFile jar, CodeSource[] cs);
     public Enumeration<JarEntry> entries2(JarFile jar);
     public void setEagerValidation(JarFile jar, boolean eager);
-    public List getManifestDigests(JarFile jar);
+    public List<Object> getManifestDigests(JarFile jar);
 }
diff --git a/jdk/src/share/classes/sun/misc/LRUCache.java b/jdk/src/share/classes/sun/misc/LRUCache.java
index d4b9554..f40f65a 100644
--- a/jdk/src/share/classes/sun/misc/LRUCache.java
+++ b/jdk/src/share/classes/sun/misc/LRUCache.java
@@ -52,7 +52,9 @@
 
     public V forName(N name) {
         if (oa == null) {
-            oa = (V[])new Object[size];
+            @SuppressWarnings("unchecked")
+            V[] temp = (V[])new Object[size];
+            oa = temp;
         } else {
             for (int i = 0; i < oa.length; i++) {
                 V ob = oa[i];
diff --git a/jdk/src/share/classes/sun/misc/Launcher.java b/jdk/src/share/classes/sun/misc/Launcher.java
index 3d9b336..71b3d3b 100644
--- a/jdk/src/share/classes/sun/misc/Launcher.java
+++ b/jdk/src/share/classes/sun/misc/Launcher.java
@@ -295,7 +295,7 @@
         /**
          * Override loadClass so we can checkPackageAccess.
          */
-        public Class loadClass(String name, boolean resolve)
+        public Class<?> loadClass(String name, boolean resolve)
             throws ClassNotFoundException
         {
             int i = name.lastIndexOf('.');
@@ -473,7 +473,7 @@
         public URLStreamHandler createURLStreamHandler(String protocol) {
             String name = PREFIX + "." + protocol + ".Handler";
             try {
-                Class c = Class.forName(name);
+                Class<?> c = Class.forName(name);
                 return (URLStreamHandler)c.newInstance();
             } catch (ReflectiveOperationException e) {
                 throw new InternalError("could not load " + protocol +
diff --git a/jdk/src/share/classes/sun/misc/ProxyGenerator.java b/jdk/src/share/classes/sun/misc/ProxyGenerator.java
index c66f82c..4b5e361 100644
--- a/jdk/src/share/classes/sun/misc/ProxyGenerator.java
+++ b/jdk/src/share/classes/sun/misc/ProxyGenerator.java
@@ -351,7 +351,7 @@
         try {
             hashCodeMethod = Object.class.getMethod("hashCode");
             equalsMethod =
-                Object.class.getMethod("equals", new Class[] { Object.class });
+                Object.class.getMethod("equals", new Class<?>[] { Object.class });
             toStringMethod = Object.class.getMethod("toString");
         } catch (NoSuchMethodException e) {
             throw new NoSuchMethodError(e.getMessage());
@@ -559,11 +559,11 @@
      * passed to the invocation handler's "invoke" method for a given
      * set of duplicate methods.
      */
-    private void addProxyMethod(Method m, Class fromClass) {
+    private void addProxyMethod(Method m, Class<?> fromClass) {
         String name = m.getName();
-        Class[] parameterTypes = m.getParameterTypes();
-        Class returnType = m.getReturnType();
-        Class[] exceptionTypes = m.getExceptionTypes();
+        Class<?>[] parameterTypes = m.getParameterTypes();
+        Class<?> returnType = m.getReturnType();
+        Class<?>[] exceptionTypes = m.getExceptionTypes();
 
         String sig = name + getParameterDescriptors(parameterTypes);
         List<ProxyMethod> sigmethods = proxyMethods.get(sig);
@@ -581,7 +581,7 @@
                         exceptionTypes, pm.exceptionTypes, legalExceptions);
                     collectCompatibleTypes(
                         pm.exceptionTypes, exceptionTypes, legalExceptions);
-                    pm.exceptionTypes = new Class[legalExceptions.size()];
+                    pm.exceptionTypes = new Class<?>[legalExceptions.size()];
                     pm.exceptionTypes =
                         legalExceptions.toArray(pm.exceptionTypes);
                     return;
@@ -848,15 +848,15 @@
     private class ProxyMethod {
 
         public String methodName;
-        public Class[] parameterTypes;
-        public Class returnType;
-        public Class[] exceptionTypes;
-        public Class fromClass;
+        public Class<?>[] parameterTypes;
+        public Class<?> returnType;
+        public Class<?>[] exceptionTypes;
+        public Class<?> fromClass;
         public String methodFieldName;
 
-        private ProxyMethod(String methodName, Class[] parameterTypes,
-                            Class returnType, Class[] exceptionTypes,
-                            Class fromClass)
+        private ProxyMethod(String methodName, Class<?>[] parameterTypes,
+                            Class<?> returnType, Class<?>[] exceptionTypes,
+                            Class<?> fromClass)
         {
             this.methodName = methodName;
             this.parameterTypes = parameterTypes;
@@ -1001,7 +1001,7 @@
          * invocation handler's "invoke" method.  The code is written
          * to the supplied stream.
          */
-        private void codeWrapArgument(Class type, int slot,
+        private void codeWrapArgument(Class<?> type, int slot,
                                       DataOutputStream out)
             throws IOException
         {
@@ -1042,7 +1042,7 @@
          * Object) to its correct type.  The code is written to the
          * supplied stream.
          */
-        private void codeUnwrapReturnValue(Class type, DataOutputStream out)
+        private void codeUnwrapReturnValue(Class<?> type, DataOutputStream out)
             throws IOException
         {
             if (type.isPrimitive()) {
@@ -1391,7 +1391,7 @@
      * the supplied stream.  Note that the code generated by this method
      * may caused the checked ClassNotFoundException to be thrown.
      */
-    private void codeClassForName(Class cl, DataOutputStream out)
+    private void codeClassForName(Class<?> cl, DataOutputStream out)
         throws IOException
     {
         code_ldc(cp.getString(cl.getName()), out);
@@ -1422,8 +1422,8 @@
      * Return the "method descriptor" string for a method with the given
      * parameter types and return type.  See JVMS section 4.3.3.
      */
-    private static String getMethodDescriptor(Class[] parameterTypes,
-                                              Class returnType)
+    private static String getMethodDescriptor(Class<?>[] parameterTypes,
+                                              Class<?> returnType)
     {
         return getParameterDescriptors(parameterTypes) +
             ((returnType == void.class) ? "V" : getFieldType(returnType));
@@ -1436,7 +1436,7 @@
      * string is useful for constructing string keys for methods without
      * regard to their return type.
      */
-    private static String getParameterDescriptors(Class[] parameterTypes) {
+    private static String getParameterDescriptors(Class<?>[] parameterTypes) {
         StringBuilder desc = new StringBuilder("(");
         for (int i = 0; i < parameterTypes.length; i++) {
             desc.append(getFieldType(parameterTypes[i]));
@@ -1450,7 +1450,7 @@
      * a field descriptor, a parameter descriptor, or a return descriptor
      * other than "void".  See JVMS section 4.3.2.
      */
-    private static String getFieldType(Class type) {
+    private static String getFieldType(Class<?> type) {
         if (type.isPrimitive()) {
             return PrimitiveTypeInfo.get(type).baseTypeString;
         } else if (type.isArray()) {
@@ -1472,7 +1472,7 @@
      * method with the given name and parameter types.
      */
     private static String getFriendlyMethodSignature(String name,
-                                                     Class[] parameterTypes)
+                                                     Class<?>[] parameterTypes)
     {
         StringBuilder sig = new StringBuilder(name);
         sig.append('(');
@@ -1480,7 +1480,7 @@
             if (i > 0) {
                 sig.append(',');
             }
-            Class parameterType = parameterTypes[i];
+            Class<?> parameterType = parameterTypes[i];
             int dimensions = 0;
             while (parameterType.isArray()) {
                 parameterType = parameterType.getComponentType();
@@ -1504,7 +1504,7 @@
      * this abstract notion of a "word" in section 3.4, but that definition
      * was removed for the second edition.
      */
-    private static int getWordsPerType(Class type) {
+    private static int getWordsPerType(Class<?> type) {
         if (type == long.class || type == double.class) {
             return 2;
         } else {
@@ -1632,8 +1632,7 @@
         /** descriptor of same method */
         public String unwrapMethodDesc;
 
-        private static Map<Class,PrimitiveTypeInfo> table =
-            new HashMap<Class,PrimitiveTypeInfo>();
+        private static Map<Class<?>,PrimitiveTypeInfo> table = new HashMap<>();
         static {
             add(byte.class, Byte.class);
             add(char.class, Character.class);
@@ -1645,12 +1644,12 @@
             add(boolean.class, Boolean.class);
         }
 
-        private static void add(Class primitiveClass, Class wrapperClass) {
+        private static void add(Class<?> primitiveClass, Class<?> wrapperClass) {
             table.put(primitiveClass,
                       new PrimitiveTypeInfo(primitiveClass, wrapperClass));
         }
 
-        private PrimitiveTypeInfo(Class primitiveClass, Class wrapperClass) {
+        private PrimitiveTypeInfo(Class<?> primitiveClass, Class<?> wrapperClass) {
             assert primitiveClass.isPrimitive();
 
             baseTypeString =
@@ -1663,7 +1662,7 @@
             unwrapMethodDesc = "()" + baseTypeString;
         }
 
-        public static PrimitiveTypeInfo get(Class cl) {
+        public static PrimitiveTypeInfo get(Class<?> cl) {
             return table.get(cl);
         }
     }
@@ -1694,7 +1693,7 @@
          * and for assigning the next index value.  Note that element 0
          * of this list corresponds to constant pool index 1.
          */
-        private List<Entry> pool = new ArrayList<Entry>(32);
+        private List<Entry> pool = new ArrayList<>(32);
 
         /**
          * maps constant pool data of all types to constant pool indexes.
@@ -1702,7 +1701,7 @@
          * This map is used to look up the index of an existing entry for
          * values of all types.
          */
-        private Map<Object,Short> map = new HashMap<Object,Short>(16);
+        private Map<Object,Short> map = new HashMap<>(16);
 
         /** true if no new constant pool entries may be added */
         private boolean readOnly = false;
diff --git a/jdk/src/share/classes/sun/misc/Queue.java b/jdk/src/share/classes/sun/misc/Queue.java
index 4edc8c9..5a447a5 100644
--- a/jdk/src/share/classes/sun/misc/Queue.java
+++ b/jdk/src/share/classes/sun/misc/Queue.java
@@ -35,12 +35,12 @@
  * @author Herb Jellinek
  */
 
-public class Queue {
+public class Queue<T> {
 
     int length = 0;
 
-    QueueElement head = null;
-    QueueElement tail = null;
+    QueueElement<T> head = null;
+    QueueElement<T> tail = null;
 
     public Queue() {
     }
@@ -48,9 +48,9 @@
     /**
      * Enqueue an object.
      */
-    public synchronized void enqueue(Object obj) {
+    public synchronized void enqueue(T obj) {
 
-        QueueElement newElt = new QueueElement(obj);
+        QueueElement<T> newElt = new QueueElement<>(obj);
 
         if (head == null) {
             head = newElt;
@@ -72,7 +72,7 @@
      * @exception java.lang.InterruptedException if any thread has
      *              interrupted this thread.
      */
-    public Object dequeue() throws InterruptedException {
+    public T dequeue() throws InterruptedException {
         return dequeue(0L);
     }
 
@@ -85,13 +85,13 @@
      * @exception java.lang.InterruptedException if any thread has
      *              interrupted this thread.
      */
-    public synchronized Object dequeue(long timeOut)
+    public synchronized T dequeue(long timeOut)
         throws InterruptedException {
 
         while (tail == null) {
             wait(timeOut);
         }
-        QueueElement elt = tail;
+        QueueElement<T> elt = tail;
         tail = elt.prev;
         if (tail == null) {
             head = null;
@@ -115,8 +115,8 @@
      * order. Use the Enumeration methods on the returned object to
      * fetch the elements sequentially.
      */
-    public final synchronized Enumeration elements() {
-        return new LIFOQueueEnumerator(this);
+    public final synchronized Enumeration<T> elements() {
+        return new LIFOQueueEnumerator<>(this);
     }
 
     /**
@@ -124,8 +124,8 @@
      * order. Use the Enumeration methods on the returned object to
      * fetch the elements sequentially.
      */
-    public final synchronized Enumeration reverseElements() {
-        return new FIFOQueueEnumerator(this);
+    public final synchronized Enumeration<T> reverseElements() {
+        return new FIFOQueueEnumerator<>(this);
     }
 
     public synchronized void dump(String msg) {
@@ -133,8 +133,8 @@
         System.err.println("["+length+" elt(s); head = "+
                            (head == null ? "null" : (head.obj)+"")+
                            " tail = "+(tail == null ? "null" : (tail.obj)+""));
-        QueueElement cursor = head;
-        QueueElement last = null;
+        QueueElement<T> cursor = head;
+        QueueElement<T> last = null;
         while (cursor != null) {
             System.err.println("  "+cursor);
             last = cursor;
@@ -147,11 +147,11 @@
     }
 }
 
-final class FIFOQueueEnumerator implements Enumeration {
-    Queue queue;
-    QueueElement cursor;
+final class FIFOQueueEnumerator<T> implements Enumeration<T> {
+    Queue<T> queue;
+    QueueElement<T> cursor;
 
-    FIFOQueueEnumerator(Queue q) {
+    FIFOQueueEnumerator(Queue<T> q) {
         queue = q;
         cursor = q.tail;
     }
@@ -160,10 +160,10 @@
         return (cursor != null);
     }
 
-    public Object nextElement() {
+    public T nextElement() {
         synchronized (queue) {
             if (cursor != null) {
-                QueueElement result = cursor;
+                QueueElement<T> result = cursor;
                 cursor = cursor.prev;
                 return result.obj;
             }
@@ -172,11 +172,11 @@
     }
 }
 
-final class LIFOQueueEnumerator implements Enumeration {
-    Queue queue;
-    QueueElement cursor;
+final class LIFOQueueEnumerator<T> implements Enumeration<T> {
+    Queue<T> queue;
+    QueueElement<T> cursor;
 
-    LIFOQueueEnumerator(Queue q) {
+    LIFOQueueEnumerator(Queue<T> q) {
         queue = q;
         cursor = q.head;
     }
@@ -185,10 +185,10 @@
         return (cursor != null);
     }
 
-    public Object nextElement() {
+    public T nextElement() {
         synchronized (queue) {
             if (cursor != null) {
-                QueueElement result = cursor;
+                QueueElement<T> result = cursor;
                 cursor = cursor.next;
                 return result.obj;
             }
@@ -197,13 +197,13 @@
     }
 }
 
-class QueueElement {
-    QueueElement next = null;
-    QueueElement prev = null;
+class QueueElement<T> {
+    QueueElement<T> next = null;
+    QueueElement<T> prev = null;
 
-    Object obj = null;
+    T obj = null;
 
-    QueueElement(Object obj) {
+    QueueElement(T obj) {
         this.obj = obj;
     }
 
diff --git a/jdk/src/share/classes/sun/misc/RequestProcessor.java b/jdk/src/share/classes/sun/misc/RequestProcessor.java
index ae9e1b9..51b8e99 100644
--- a/jdk/src/share/classes/sun/misc/RequestProcessor.java
+++ b/jdk/src/share/classes/sun/misc/RequestProcessor.java
@@ -36,7 +36,7 @@
 
 public class RequestProcessor implements Runnable {
 
-    private static Queue requestQueue;
+    private static Queue<Request> requestQueue;
     private static Thread dispatcher;
 
     /**
@@ -55,15 +55,12 @@
         lazyInitialize();
         while (true) {
             try {
-                Object obj = requestQueue.dequeue();
-                if (obj instanceof Request) { // ignore bogons
-                    Request req = (Request)obj;
-                    try {
-                        req.execute();
-                    } catch (Throwable t) {
-                        // do nothing at the moment...maybe report an error
-                        // in the future
-                    }
+                Request req = requestQueue.dequeue();
+                try {
+                    req.execute();
+                } catch (Throwable t) {
+                    // do nothing at the moment...maybe report an error
+                    // in the future
                 }
             } catch (InterruptedException e) {
                 // do nothing at the present time.
@@ -92,7 +89,7 @@
      */
     private static synchronized void lazyInitialize() {
         if (requestQueue == null) {
-            requestQueue = new Queue();
+            requestQueue = new Queue<Request>();
         }
     }
 
diff --git a/jdk/src/share/classes/sun/misc/Service.java b/jdk/src/share/classes/sun/misc/Service.java
index ce0ed44..37d39b4 100644
--- a/jdk/src/share/classes/sun/misc/Service.java
+++ b/jdk/src/share/classes/sun/misc/Service.java
@@ -125,13 +125,13 @@
  * @since 1.3
  */
 
-public final class Service {
+public final class Service<S> {
 
     private static final String prefix = "META-INF/services/";
 
     private Service() { }
 
-    private static void fail(Class service, String msg, Throwable cause)
+    private static void fail(Class<?> service, String msg, Throwable cause)
         throws ServiceConfigurationError
     {
         ServiceConfigurationError sce
@@ -140,13 +140,13 @@
         throw sce;
     }
 
-    private static void fail(Class service, String msg)
+    private static void fail(Class<?> service, String msg)
         throws ServiceConfigurationError
     {
         throw new ServiceConfigurationError(service.getName() + ": " + msg);
     }
 
-    private static void fail(Class service, URL u, int line, String msg)
+    private static void fail(Class<?> service, URL u, int line, String msg)
         throws ServiceConfigurationError
     {
         fail(service, u + ":" + line + ": " + msg);
@@ -157,8 +157,8 @@
      * on the line to both the names list and the returned set iff the name is
      * not already a member of the returned set.
      */
-    private static int parseLine(Class service, URL u, BufferedReader r, int lc,
-                                 List names, Set returned)
+    private static int parseLine(Class<?> service, URL u, BufferedReader r, int lc,
+                                 List<String> names, Set<String> returned)
         throws IOException, ServiceConfigurationError
     {
         String ln = r.readLine();
@@ -211,12 +211,12 @@
      *         If an I/O error occurs while reading from the given URL, or
      *         if a configuration-file format error is detected
      */
-    private static Iterator parse(Class service, URL u, Set returned)
+    private static Iterator<String> parse(Class<?> service, URL u, Set<String> returned)
         throws ServiceConfigurationError
     {
         InputStream in = null;
         BufferedReader r = null;
-        ArrayList names = new ArrayList();
+        ArrayList<String> names = new ArrayList<>();
         try {
             in = u.openStream();
             r = new BufferedReader(new InputStreamReader(in, "utf-8"));
@@ -239,16 +239,16 @@
     /**
      * Private inner class implementing fully-lazy provider lookup
      */
-    private static class LazyIterator implements Iterator {
+    private static class LazyIterator<S> implements Iterator<S> {
 
-        Class service;
+        Class<S> service;
         ClassLoader loader;
-        Enumeration configs = null;
-        Iterator pending = null;
-        Set returned = new TreeSet();
+        Enumeration<URL> configs = null;
+        Iterator<String> pending = null;
+        Set<String> returned = new TreeSet<>();
         String nextName = null;
 
-        private LazyIterator(Class service, ClassLoader loader) {
+        private LazyIterator(Class<S> service, ClassLoader loader) {
             this.service = service;
             this.loader = loader;
         }
@@ -272,20 +272,20 @@
                 if (!configs.hasMoreElements()) {
                     return false;
                 }
-                pending = parse(service, (URL)configs.nextElement(), returned);
+                pending = parse(service, configs.nextElement(), returned);
             }
-            nextName = (String)pending.next();
+            nextName = pending.next();
             return true;
         }
 
-        public Object next() throws ServiceConfigurationError {
+        public S next() throws ServiceConfigurationError {
             if (!hasNext()) {
                 throw new NoSuchElementException();
             }
             String cn = nextName;
             nextName = null;
             try {
-                return Class.forName(cn, true, loader).newInstance();
+                return service.cast(Class.forName(cn, true, loader).newInstance());
             } catch (ClassNotFoundException x) {
                 fail(service,
                      "Provider " + cn + " not found");
@@ -342,10 +342,10 @@
      * @see #providers(java.lang.Class)
      * @see #installedProviders(java.lang.Class)
      */
-    public static Iterator providers(Class service, ClassLoader loader)
+    public static <S> Iterator<S> providers(Class<S> service, ClassLoader loader)
         throws ServiceConfigurationError
     {
-        return new LazyIterator(service, loader);
+        return new LazyIterator<S>(service, loader);
     }
 
 
@@ -374,7 +374,7 @@
      *
      * @see #providers(java.lang.Class, java.lang.ClassLoader)
      */
-    public static Iterator providers(Class service)
+    public static <S> Iterator<S> providers(Class<S> service)
         throws ServiceConfigurationError
     {
         ClassLoader cl = Thread.currentThread().getContextClassLoader();
@@ -411,7 +411,7 @@
      *
      * @see #providers(java.lang.Class, java.lang.ClassLoader)
      */
-    public static Iterator installedProviders(Class service)
+    public static <S> Iterator<S> installedProviders(Class<S> service)
         throws ServiceConfigurationError
     {
         ClassLoader cl = ClassLoader.getSystemClassLoader();
diff --git a/jdk/src/share/classes/sun/misc/ServiceConfigurationError.java b/jdk/src/share/classes/sun/misc/ServiceConfigurationError.java
index 5659b23..74d0c84 100644
--- a/jdk/src/share/classes/sun/misc/ServiceConfigurationError.java
+++ b/jdk/src/share/classes/sun/misc/ServiceConfigurationError.java
@@ -43,6 +43,8 @@
 
 public class ServiceConfigurationError extends Error {
 
+    static final long serialVersionUID = 8769866263384244465L;
+
     /**
      * Constructs a new instance with the specified detail string.
      */
diff --git a/jdk/src/share/classes/sun/misc/Signal.java b/jdk/src/share/classes/sun/misc/Signal.java
index 613cc38..b663c5b 100644
--- a/jdk/src/share/classes/sun/misc/Signal.java
+++ b/jdk/src/share/classes/sun/misc/Signal.java
@@ -72,8 +72,8 @@
  * @since    1.2
  */
 public final class Signal {
-    private static Hashtable handlers = new Hashtable(4);
-    private static Hashtable signals = new Hashtable(4);
+    private static Hashtable<Signal,SignalHandler> handlers = new Hashtable<>(4);
+    private static Hashtable<Integer,Signal> signals = new Hashtable<>(4);
 
     private int number;
     private String name;
@@ -166,9 +166,9 @@
             throw new IllegalArgumentException
                 ("Signal already used by VM or OS: " + sig);
         }
-        signals.put(new Integer(sig.number), sig);
+        signals.put(sig.number, sig);
         synchronized (handlers) {
-            SignalHandler oldHandler = (SignalHandler)handlers.get(sig);
+            SignalHandler oldHandler = handlers.get(sig);
             handlers.remove(sig);
             if (newH == 2) {
                 handlers.put(sig, handler);
@@ -200,8 +200,8 @@
 
     /* Called by the VM to execute Java signal handlers. */
     private static void dispatch(final int number) {
-        final Signal sig = (Signal)signals.get(new Integer(number));
-        final SignalHandler handler = (SignalHandler)handlers.get(sig);
+        final Signal sig = signals.get(number);
+        final SignalHandler handler = handlers.get(sig);
 
         Runnable runnable = new Runnable () {
             public void run() {
diff --git a/jdk/src/share/classes/sun/misc/URLClassPath.java b/jdk/src/share/classes/sun/misc/URLClassPath.java
index cee9823..eb6b86a 100644
--- a/jdk/src/share/classes/sun/misc/URLClassPath.java
+++ b/jdk/src/share/classes/sun/misc/URLClassPath.java
@@ -836,10 +836,9 @@
                              Set<String> visited) {
 
             Resource res;
-            Object[] jarFiles;
-            boolean done = false;
+            String[] jarFiles;
             int count = 0;
-            LinkedList jarFilesList = null;
+            LinkedList<String> jarFilesList = null;
 
             /* If there no jar files in the index that can potential contain
              * this resource then return immediately.
@@ -848,11 +847,11 @@
                 return null;
 
             do {
-                jarFiles = jarFilesList.toArray();
                 int size = jarFilesList.size();
+                jarFiles = jarFilesList.toArray(new String[size]);
                 /* loop through the mapped jar file list */
                 while(count < size) {
-                    String jarName = (String)jarFiles[count++];
+                    String jarName = jarFiles[count++];
                     JarLoader newLoader;
                     final URL url;
 
diff --git a/jdk/src/share/classes/sun/misc/Unsafe.java b/jdk/src/share/classes/sun/misc/Unsafe.java
index dba1628..da7ec27 100644
--- a/jdk/src/share/classes/sun/misc/Unsafe.java
+++ b/jdk/src/share/classes/sun/misc/Unsafe.java
@@ -81,7 +81,7 @@
      *             access to the system properties.
      */
     public static Unsafe getUnsafe() {
-        Class cc = sun.reflect.Reflection.getCallerClass(2);
+        Class<?> cc = sun.reflect.Reflection.getCallerClass(2);
         if (cc.getClassLoader() != null)
             throw new SecurityException("Unsafe");
         return theUnsafe;
@@ -616,7 +616,7 @@
      * for a given class in one place.
      */
     @Deprecated
-    public Object staticFieldBase(Class c) {
+    public Object staticFieldBase(Class<?> c) {
         Field[] fields = c.getDeclaredFields();
         for (int i = 0; i < fields.length; i++) {
             if (Modifier.isStatic(fields[i].getModifiers())) {
@@ -682,7 +682,7 @@
      * needed in conjunction with obtaining the static field base of a
      * class.
      */
-    public native void ensureClassInitialized(Class c);
+    public native void ensureClassInitialized(Class<?> c);
 
     /**
      * Report the offset of the first element in the storage allocation of a
@@ -694,7 +694,7 @@
      * @see #getInt(Object, long)
      * @see #putInt(Object, long, int)
      */
-    public native int arrayBaseOffset(Class arrayClass);
+    public native int arrayBaseOffset(Class<?> arrayClass);
 
     /** The value of {@code arrayBaseOffset(boolean[].class)} */
     public static final int ARRAY_BOOLEAN_BASE_OFFSET
@@ -743,7 +743,7 @@
      * @see #getInt(Object, long)
      * @see #putInt(Object, long, int)
      */
-    public native int arrayIndexScale(Class arrayClass);
+    public native int arrayIndexScale(Class<?> arrayClass);
 
     /** The value of {@code arrayIndexScale(boolean[].class)} */
     public static final int ARRAY_BOOLEAN_INDEX_SCALE
@@ -805,11 +805,11 @@
      * Tell the VM to define a class, without security checks.  By default, the
      * class loader and protection domain come from the caller's class.
      */
-    public native Class defineClass(String name, byte[] b, int off, int len,
-                                    ClassLoader loader,
-                                    ProtectionDomain protectionDomain);
+    public native Class<?> defineClass(String name, byte[] b, int off, int len,
+                                       ClassLoader loader,
+                                       ProtectionDomain protectionDomain);
 
-    public native Class defineClass(String name, byte[] b, int off, int len);
+    public native Class<?> defineClass(String name, byte[] b, int off, int len);
 
     /**
      * Define a class but do not make it known to the class loader or system dictionary.
@@ -827,12 +827,12 @@
      * @params data      bytes of a class file
      * @params cpPatches where non-null entries exist, they replace corresponding CP entries in data
      */
-    public native Class defineAnonymousClass(Class hostClass, byte[] data, Object[] cpPatches);
+    public native Class<?> defineAnonymousClass(Class<?> hostClass, byte[] data, Object[] cpPatches);
 
 
     /** Allocate an instance but do not run any constructor.
         Initializes the class if it has not yet been. */
-    public native Object allocateInstance(Class cls)
+    public native Object allocateInstance(Class<?> cls)
         throws InstantiationException;
 
     /** Lock the object.  It must get unlocked via {@link #monitorExit}. */
diff --git a/jdk/src/share/classes/sun/misc/VM.java b/jdk/src/share/classes/sun/misc/VM.java
index e1fb584..61b3b0f 100644
--- a/jdk/src/share/classes/sun/misc/VM.java
+++ b/jdk/src/share/classes/sun/misc/VM.java
@@ -48,6 +48,7 @@
         return suspended;
     }
 
+    @SuppressWarnings("deprecation")
     public static boolean allowThreadSuspension(ThreadGroup g, boolean b) {
         return g.allowThreadSuspension(b);
     }
diff --git a/jdk/src/share/classes/sun/net/RegisteredDomain.java b/jdk/src/share/classes/sun/net/RegisteredDomain.java
index 49c67c2..7e75b32 100644
--- a/jdk/src/share/classes/sun/net/RegisteredDomain.java
+++ b/jdk/src/share/classes/sun/net/RegisteredDomain.java
@@ -118,8 +118,8 @@
 private static Set<String>  usSubStateSet = new HashSet<String>(Arrays.asList("state",
                 "lib", "k12", "cc", "tec", "gen", "cog", "mus", "dst"));
 
-private static Map<String,Set> topMap = new HashMap<String,Set>();
-private static Map<String,Set> top3Map = new HashMap<String,Set>();
+private static Map<String,Set<String>> topMap = new HashMap<>();
+private static Map<String,Set<String>> top3Map = new HashMap<>();
 
 static {
     /*
@@ -764,7 +764,7 @@
          */
         String str = cname.substring(third + 1);
         if (third != -1) {
-            Set set = top3Map.get(s);
+            Set<String> set = top3Map.get(s);
             if (set != null) {
                 if (set.contains(str)) {
                     return cname.substring(fourth + 1);
@@ -801,7 +801,7 @@
         /*
          * XX.MA.US.
          */
-        Set topSet = topMap.get(s);
+        Set<String> topSet = topMap.get(s);
         if (topSet != null) {
             if (topSet.contains(s2)) {
                 return cname.substring(third + 1);
diff --git a/jdk/src/share/classes/sun/net/ftp/FtpClientProvider.java b/jdk/src/share/classes/sun/net/ftp/FtpClientProvider.java
index 7a09810..06deae6 100644
--- a/jdk/src/share/classes/sun/net/ftp/FtpClientProvider.java
+++ b/jdk/src/share/classes/sun/net/ftp/FtpClientProvider.java
@@ -27,7 +27,7 @@
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.util.ServiceConfigurationError;
-//import sun.misc.Service;
+//import java.util.ServiceLoader;
 
 /**
  * Service provider class for FtpClient.
@@ -79,20 +79,22 @@
     }
 
     private static boolean loadProviderAsService() {
-        //        Iterator i = Service.providers(FtpClientProvider.class,
-        //                ClassLoader.getSystemClassLoader());
-        //        while (i.hasNext()) {
-        //            try {
-        //                provider = (FtpClientProvider) i.next();
-        //                return true;
-        //            } catch (ServiceConfigurationError sce) {
-        //                if (sce.getCause() instanceof SecurityException) {
-        //                    // Ignore, try next provider, if any
-        //                    continue;
-        //                }
-        //                throw sce;
-        //            }
-        //        }
+//        Iterator<FtpClientProvider> i =
+//                ServiceLoader.load(FtpClientProvider.class,
+//                                   ClassLoader.getSystemClassLoader()).iterator();
+//
+//        while (i.hasNext()) {
+//            try {
+//                provider = i.next();
+//                return true;
+//            } catch (ServiceConfigurationError sce) {
+//                if (sce.getCause() instanceof SecurityException) {
+//                    // Ignore, try next provider, if any
+//                    continue;
+//                }
+//                throw sce;
+//            }
+//        }
         return false;
     }
 
diff --git a/jdk/src/share/classes/sun/net/www/protocol/jar/Handler.java b/jdk/src/share/classes/sun/net/www/protocol/jar/Handler.java
index 62686c6..8e9f8e3 100644
--- a/jdk/src/share/classes/sun/net/www/protocol/jar/Handler.java
+++ b/jdk/src/share/classes/sun/net/www/protocol/jar/Handler.java
@@ -123,6 +123,7 @@
 
 
     @Override
+    @SuppressWarnings("deprecation")
     protected void parseURL(URL url, String spec,
                             int start, int limit) {
         String file = null;
diff --git a/jdk/src/share/classes/sun/nio/ch/SocketAdaptor.java b/jdk/src/share/classes/sun/nio/ch/SocketAdaptor.java
index dd10a72..2fbc517 100644
--- a/jdk/src/share/classes/sun/nio/ch/SocketAdaptor.java
+++ b/jdk/src/share/classes/sun/nio/ch/SocketAdaptor.java
@@ -57,13 +57,17 @@
     // Timeout "option" value for reads
     private volatile int timeout = 0;
 
-    // ## super will create a useless impl
-    private SocketAdaptor(SocketChannelImpl sc) {
+    private SocketAdaptor(SocketChannelImpl sc) throws SocketException {
+        super((SocketImpl) null);
         this.sc = sc;
     }
 
     public static Socket create(SocketChannelImpl sc) {
-        return new SocketAdaptor(sc);
+        try {
+            return new SocketAdaptor(sc);
+        } catch (SocketException e) {
+            throw new InternalError("Should not reach here");
+        }
     }
 
     public SocketChannel getChannel() {
diff --git a/jdk/src/share/classes/sun/security/provider/certpath/ssl/SSLServerCertStore.java b/jdk/src/share/classes/sun/security/provider/certpath/ssl/SSLServerCertStore.java
index 5109e13..f2a999f 100644
--- a/jdk/src/share/classes/sun/security/provider/certpath/ssl/SSLServerCertStore.java
+++ b/jdk/src/share/classes/sun/security/provider/certpath/ssl/SSLServerCertStore.java
@@ -44,12 +44,16 @@
 import java.security.cert.CRLSelector;
 import java.security.cert.X509Certificate;
 import java.security.cert.X509CRL;
+import java.net.Socket;
+import java.net.URLConnection;
 import javax.net.ssl.HostnameVerifier;
 import javax.net.ssl.HttpsURLConnection;
 import javax.net.ssl.SSLContext;
 import javax.net.ssl.SSLSession;
+import javax.net.ssl.SSLEngine;
+import javax.net.ssl.SSLSocketFactory;
 import javax.net.ssl.TrustManager;
-import javax.net.ssl.X509TrustManager;
+import javax.net.ssl.X509ExtendedTrustManager;
 
 /**
  * A CertStore that retrieves an SSL server's certificate chain.
@@ -57,31 +61,74 @@
 public final class SSLServerCertStore extends CertStoreSpi {
 
     private final URI uri;
+    private final static GetChainTrustManager trustManager;
+    private final static SSLSocketFactory socketFactory;
+    private final static HostnameVerifier hostnameVerifier;
+
+    static {
+        trustManager = new GetChainTrustManager();
+        hostnameVerifier = new HostnameVerifier() {
+            public boolean verify(String hostname, SSLSession session) {
+                return true;
+            }
+        };
+
+        SSLSocketFactory tempFactory;
+        try {
+            SSLContext context = SSLContext.getInstance("SSL");
+            context.init(null, new TrustManager[] { trustManager }, null);
+            tempFactory = context.getSocketFactory();
+        } catch (GeneralSecurityException gse) {
+            tempFactory = null;
+        }
+
+        socketFactory = tempFactory;
+    }
 
     SSLServerCertStore(URI uri) throws InvalidAlgorithmParameterException {
         super(null);
         this.uri = uri;
     }
 
-    public synchronized Collection<X509Certificate> engineGetCertificates
-        (CertSelector selector) throws CertStoreException
-    {
+    public Collection<X509Certificate> engineGetCertificates
+            (CertSelector selector) throws CertStoreException {
+
         try {
-            SSLContext sc = SSLContext.getInstance("SSL");
-            GetChainTrustManager xtm = new GetChainTrustManager();
-            sc.init(null, new TrustManager[] { xtm }, null);
-            HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
-            HttpsURLConnection.setDefaultHostnameVerifier(
-                new HostnameVerifier() {
-                    public boolean verify(String hostname, SSLSession session) {
-                        return true;
+            URLConnection urlConn = uri.toURL().openConnection();
+            if (urlConn instanceof HttpsURLConnection) {
+                if (socketFactory == null) {
+                    throw new CertStoreException(
+                        "No initialized SSLSocketFactory");
+                }
+
+                HttpsURLConnection https = (HttpsURLConnection)urlConn;
+                https.setSSLSocketFactory(socketFactory);
+                https.setHostnameVerifier(hostnameVerifier);
+                synchronized (trustManager) {
+                    try {
+                        https.connect();
+                        return getMatchingCerts(
+                            trustManager.serverChain, selector);
+                    } catch (IOException ioe) {
+                        // If the server certificate has already been
+                        // retrieved, don't mind the connection state.
+                        if (trustManager.exchangedServerCerts) {
+                            return getMatchingCerts(
+                                trustManager.serverChain, selector);
+                        }
+
+                        // otherwise, rethrow the exception
+                        throw ioe;
+                    } finally {
+                        trustManager.cleanup();
                     }
-            });
-            uri.toURL().openConnection().connect();
-            return getMatchingCerts(xtm.serverChain, selector);
-        } catch (GeneralSecurityException | IOException e) {
-            throw new CertStoreException(e);
+                }
+            }
+        } catch (IOException ioe) {
+            throw new CertStoreException(ioe);
         }
+
+        return Collections.<X509Certificate>emptySet();
     }
 
     private static List<X509Certificate> getMatchingCerts
@@ -106,37 +153,77 @@
         throw new UnsupportedOperationException();
     }
 
-    static synchronized CertStore getInstance(URI uri)
+    static CertStore getInstance(URI uri)
         throws InvalidAlgorithmParameterException
     {
         return new CS(new SSLServerCertStore(uri), null, "SSLServer", null);
     }
 
     /*
-     * An X509TrustManager that simply stores a reference to the server's
-     * certificate chain.
+     * An X509ExtendedTrustManager that ignores the server certificate
+     * validation.
      */
-    private static class GetChainTrustManager implements X509TrustManager {
-        private List<X509Certificate> serverChain;
+    private static class GetChainTrustManager
+            extends X509ExtendedTrustManager {
 
+        private List<X509Certificate> serverChain =
+                        Collections.<X509Certificate>emptyList();
+        private boolean exchangedServerCerts = false;
+
+        @Override
         public X509Certificate[] getAcceptedIssuers() {
-            throw new UnsupportedOperationException();
+            return new X509Certificate[0];
         }
 
+        @Override
         public void checkClientTrusted(X509Certificate[] chain,
-                                       String authType)
-            throws CertificateException
-        {
+                String authType) throws CertificateException {
+
             throw new UnsupportedOperationException();
         }
 
+        @Override
+        public void checkClientTrusted(X509Certificate[] chain, String authType,
+                Socket socket) throws CertificateException {
+
+            throw new UnsupportedOperationException();
+        }
+
+        @Override
+        public void checkClientTrusted(X509Certificate[] chain, String authType,
+                SSLEngine engine) throws CertificateException {
+
+            throw new UnsupportedOperationException();
+        }
+
+        @Override
         public void checkServerTrusted(X509Certificate[] chain,
-                                       String authType)
-            throws CertificateException
-        {
+                String authType) throws CertificateException {
+
+            exchangedServerCerts = true;
             this.serverChain = (chain == null)
-                               ? Collections.<X509Certificate>emptyList()
-                               : Arrays.asList(chain);
+                           ? Collections.<X509Certificate>emptyList()
+                           : Arrays.<X509Certificate>asList(chain);
+
+        }
+
+        @Override
+        public void checkServerTrusted(X509Certificate[] chain, String authType,
+                Socket socket) throws CertificateException {
+
+            checkServerTrusted(chain, authType);
+        }
+
+        @Override
+        public void checkServerTrusted(X509Certificate[] chain, String authType,
+                SSLEngine engine) throws CertificateException {
+
+            checkServerTrusted(chain, authType);
+        }
+
+        void cleanup() {
+            exchangedServerCerts = false;
+            serverChain = Collections.<X509Certificate>emptyList();
         }
     }
 
diff --git a/jdk/src/share/classes/sun/text/CompactByteArray.java b/jdk/src/share/classes/sun/text/CompactByteArray.java
index 042d88f..d28b1db 100644
--- a/jdk/src/share/classes/sun/text/CompactByteArray.java
+++ b/jdk/src/share/classes/sun/text/CompactByteArray.java
@@ -264,9 +264,9 @@
     {
         try {
             CompactByteArray other = (CompactByteArray) super.clone();
-            other.values = (byte[])values.clone();
-            other.indices = (short[])indices.clone();
-            if (hashes != null) other.hashes = (int[])hashes.clone();
+            other.values = values.clone();
+            other.indices = indices.clone();
+            if (hashes != null) other.hashes = hashes.clone();
             return other;
         } catch (CloneNotSupportedException e) {
             throw new InternalError(e);
diff --git a/jdk/src/share/classes/sun/text/IntHashtable.java b/jdk/src/share/classes/sun/text/IntHashtable.java
index a066d09..679c710 100644
--- a/jdk/src/share/classes/sun/text/IntHashtable.java
+++ b/jdk/src/share/classes/sun/text/IntHashtable.java
@@ -122,11 +122,11 @@
             // this line just scrambles the bits as each value is added into the
             // has value.  This helps to make sure we affect all the bits and that
             // the same values in a different order will produce a different hash value
-            result = (int)(result * scrambler + 1);
+            result = result * scrambler + 1;
             result += keyList[i];
         }
         for (int i = 0; i < values.length; ++i) {
-            result = (int)(result * scrambler + 1);
+            result = result * scrambler + 1;
             result += values[i];
         }
         return result;
@@ -135,8 +135,8 @@
     public Object clone ()
                     throws CloneNotSupportedException {
         IntHashtable result = (IntHashtable) super.clone();
-        values = (int[]) values.clone();
-        keyList = (int[])keyList.clone();
+        values = values.clone();
+        keyList = keyList.clone();
         return result;
     }
 
diff --git a/jdk/src/share/classes/sun/text/bidi/BidiBase.java b/jdk/src/share/classes/sun/text/bidi/BidiBase.java
index d6733ce..a803f82 100644
--- a/jdk/src/share/classes/sun/text/bidi/BidiBase.java
+++ b/jdk/src/share/classes/sun/text/bidi/BidiBase.java
@@ -1106,7 +1106,7 @@
      * Assume sizeNeeded>0.
      * If object != null, then assume size > 0.
      */
-    private Object getMemory(String label, Object array, Class arrayClass,
+    private Object getMemory(String label, Object array, Class<?> arrayClass,
             boolean mayAllocate, int sizeNeeded)
     {
         int len = Array.getLength(array);
@@ -1990,7 +1990,7 @@
         cell = impTab[oldStateSeq][_prop];
         levState.state = GetState(cell);        /* isolate the new state */
         actionSeq = impAct[GetAction(cell)];    /* isolate the action */
-        addLevel = (byte)impTab[levState.state][IMPTABLEVELS_RES];
+        addLevel = impTab[levState.state][IMPTABLEVELS_RES];
 
         if (actionSeq != 0) {
             switch (actionSeq) {
@@ -2014,7 +2014,7 @@
                     /* nothing, just clean up */
                     levState.lastStrongRTL = -1;
                     /* check if we have a pending conditional segment */
-                    level = (byte)impTab[oldStateSeq][IMPTABLEVELS_RES];
+                    level = impTab[oldStateSeq][IMPTABLEVELS_RES];
                     if ((level & 1) != 0 && levState.startON > 0) { /* after ON */
                         start = levState.startON;   /* reset to basic run level */
                     }
@@ -2115,7 +2115,7 @@
                 break;
 
             case 11:                    /* L after L+ON+EN/AN/ON */
-                level = (byte)levState.runLevel;
+                level = levState.runLevel;
                 for (k = start0-1; k >= levState.startON; k--) {
                     if (levels[k] == level+3) {
                         while (levels[k] == level+3) {
@@ -2178,7 +2178,7 @@
         levState.runLevel = levels[start];
         levState.impTab = impTabPair.imptab[levState.runLevel & 1];
         levState.impAct = impTabPair.impact[levState.runLevel & 1];
-        processPropertySeq(levState, (short)sor, start, start);
+        processPropertySeq(levState, sor, start, start);
         /* initialize for property state table */
         if (dirProps[start] == NSM) {
             stateImp = (short)(1 + sor);
@@ -2230,7 +2230,7 @@
             }
         }
         /* flush possible pending sequence, e.g. ON */
-        processPropertySeq(levState, (short)eor, limit, limit);
+        processPropertySeq(levState, eor, limit, limit);
     }
 
     /* perform (L1) and (X9) ---------------------------------------------------- */
@@ -3484,6 +3484,7 @@
             }
         }
 
+        @SuppressWarnings("serial")
         private static AttributedCharacterIterator.Attribute
             getTextAttribute(String name)
         {
diff --git a/jdk/src/share/classes/sun/text/normalizer/ICUData.java b/jdk/src/share/classes/sun/text/normalizer/ICUData.java
index bf6e60f..6163329 100644
--- a/jdk/src/share/classes/sun/text/normalizer/ICUData.java
+++ b/jdk/src/share/classes/sun/text/normalizer/ICUData.java
@@ -48,12 +48,12 @@
  */
 public final class ICUData {
 
-    private static InputStream getStream(final Class root, final String resourceName, boolean required) {
+    private static InputStream getStream(final Class<ICUData> root, final String resourceName, boolean required) {
         InputStream i = null;
 
         if (System.getSecurityManager() != null) {
-            i = (InputStream)AccessController.doPrivileged(new PrivilegedAction() {
-                    public Object run() {
+            i = AccessController.doPrivileged(new PrivilegedAction<InputStream>() {
+                    public InputStream run() {
                         return root.getResourceAsStream(resourceName);
                     }
                 });
diff --git a/jdk/src/share/classes/sun/text/normalizer/NormalizerBase.java b/jdk/src/share/classes/sun/text/normalizer/NormalizerBase.java
index 576e67b..875d059 100644
--- a/jdk/src/share/classes/sun/text/normalizer/NormalizerBase.java
+++ b/jdk/src/share/classes/sun/text/normalizer/NormalizerBase.java
@@ -886,6 +886,7 @@
      * @deprecated ICU 3.2
      * @obsolete ICU 3.2
      */
+     @Deprecated
      public int setIndex(int index) {
          setIndexOnly(index);
          return current();
@@ -899,6 +900,7 @@
      * @return The codepoint as an int
      * @see #startIndex
      */
+    @Deprecated
     public int getBeginIndex() {
         return 0;
     }
@@ -911,6 +913,7 @@
      * @return The codepoint as an int
      * @see #endIndex
      */
+    @Deprecated
     public int getEndIndex() {
         return endIndex();
     }
@@ -1235,11 +1238,11 @@
                                                 mode, options);
 
                 if(pNeededToNormalize!=null) {
-                    pNeededToNormalize[0]=(boolean)(destLength!=bufferLength ||
-                                                    Utility.arrayRegionMatches(
-                                                                               buffer,0,dest,
-                                                                               destStart,destLimit
-                                                                               ));
+                    pNeededToNormalize[0]=destLength!=bufferLength ||
+                                          Utility.arrayRegionMatches(
+                                            buffer,0,dest,
+                                            destStart,destLimit
+                                          );
                 }
             } else {
                 /* just copy the source characters */
@@ -1458,10 +1461,10 @@
                                           dest,destStart,destLimit, options);
 
                 if(pNeededToNormalize!=null) {
-                    pNeededToNormalize[0]=(boolean)(destLength!=bufferLength ||
-                                                    Utility.arrayRegionMatches(buffer,startIndex[0],
-                                                                               dest,destStart,
-                                                                               destLength));
+                    pNeededToNormalize[0]=destLength!=bufferLength ||
+                                          Utility.arrayRegionMatches(buffer,startIndex[0],
+                                            dest,destStart,
+                                            destLength);
                 }
             } else {
                 /* just copy the source characters */
diff --git a/jdk/src/share/classes/sun/text/normalizer/NormalizerImpl.java b/jdk/src/share/classes/sun/text/normalizer/NormalizerImpl.java
index b0b8e37..8f0c966 100644
--- a/jdk/src/share/classes/sun/text/normalizer/NormalizerImpl.java
+++ b/jdk/src/share/classes/sun/text/normalizer/NormalizerImpl.java
@@ -98,11 +98,11 @@
     private static final int EXTRA_SHIFT=16;
 
     /* norm32 value constants using >16 bits */
-    private static final long  MIN_SPECIAL    =  (long)(0xfc000000 & UNSIGNED_INT_MASK);
-    private static final long  SURROGATES_TOP =  (long)(0xfff00000 & UNSIGNED_INT_MASK);
-    private static final long  MIN_HANGUL     =  (long)(0xfff00000 & UNSIGNED_INT_MASK);
-//  private static final long  MIN_JAMO_V     =  (long)(0xfff20000 & UNSIGNED_INT_MASK);
-    private static final long  JAMO_V_TOP     =  (long)(0xfff30000 & UNSIGNED_INT_MASK);
+    private static final long  MIN_SPECIAL    =  0xfc000000 & UNSIGNED_INT_MASK;
+    private static final long  SURROGATES_TOP =  0xfff00000 & UNSIGNED_INT_MASK;
+    private static final long  MIN_HANGUL     =  0xfff00000 & UNSIGNED_INT_MASK;
+//  private static final long  MIN_JAMO_V     =  0xfff20000 & UNSIGNED_INT_MASK;
+    private static final long  JAMO_V_TOP     =  0xfff30000 & UNSIGNED_INT_MASK;
 
 
     /* indexes[] value names */
@@ -134,7 +134,7 @@
     private static final int AUX_COMP_EX_SHIFT           = 10;
     private static final int AUX_NFC_SKIPPABLE_F_SHIFT = 12;
 
-    private static final int AUX_MAX_FNC          =   ((int)1<<AUX_COMP_EX_SHIFT);
+    private static final int AUX_MAX_FNC          =   1<<AUX_COMP_EX_SHIFT;
     private static final int AUX_UNSAFE_MASK      =   (int)((1<<AUX_UNSAFE_SHIFT) & UNSIGNED_INT_MASK);
     private static final int AUX_FNC_MASK         =   (int)((AUX_MAX_FNC-1) & UNSIGNED_INT_MASK);
     private static final int AUX_COMP_EX_MASK     =   (int)((1<<AUX_COMP_EX_SHIFT) & UNSIGNED_INT_MASK);
@@ -188,7 +188,7 @@
         */
         /* auxTrie: the folding offset is in bits 9..0 of the 16-bit trie result */
         public int getFoldingOffset(int value){
-            return (int)(value &AUX_FNC_MASK)<<SURROGATE_BLOCK_BITS;
+            return (value &AUX_FNC_MASK)<<SURROGATE_BLOCK_BITS;
         }
     }
 
@@ -972,7 +972,7 @@
 
             /* copy these code units all at once */
             if(srcIndex!=prevSrc) {
-                length=(int)(srcIndex-prevSrc);
+                length=srcIndex-prevSrc;
                 if((destIndex+length)<=destLimit) {
                     System.arraycopy(src,prevSrc,dest,destIndex,length);
                 }
@@ -1814,7 +1814,7 @@
 
             /* copy these code units all at once */
             if(srcIndex!=prevSrc) {
-                length=(int)(srcIndex-prevSrc);
+                length=srcIndex-prevSrc;
                 if((destIndex+length)<=destLimit) {
                     System.arraycopy(src,prevSrc,dest,destIndex,length);
                 }
@@ -2022,13 +2022,13 @@
     public static int getCombiningClass(int c) {
         long norm32;
         norm32=getNorm32(c);
-        return (char)((norm32>>CC_SHIFT)&0xFF);
+        return (int)((norm32>>CC_SHIFT)&0xFF);
     }
 
     public static boolean isFullCompositionExclusion(int c) {
         if(isFormatVersion_2_1) {
             int aux =AuxTrieImpl.auxTrie.getCodePointValue(c);
-            return (boolean)((aux & AUX_COMP_EX_MASK)!=0);
+            return (aux & AUX_COMP_EX_MASK)!=0;
         } else {
             return false;
         }
@@ -2037,7 +2037,7 @@
     public static boolean isCanonSafeStart(int c) {
         if(isFormatVersion_2_1) {
             int aux = AuxTrieImpl.auxTrie.getCodePointValue(c);
-            return (boolean)((aux & AUX_UNSAFE_MASK)==0);
+            return (aux & AUX_UNSAFE_MASK)==0;
         } else {
             return false;
         }
@@ -2546,7 +2546,7 @@
 
             // copy these code units all at once
             if (srcIndex != prevSrc) {
-                length = (int)(srcIndex - prevSrc);
+                length = srcIndex - prevSrc;
                 if ((destIndex + length) <= destLimit) {
                     System.arraycopy(src,prevSrc,dest,destIndex,length);
                 }
diff --git a/jdk/src/share/classes/sun/text/normalizer/SymbolTable.java b/jdk/src/share/classes/sun/text/normalizer/SymbolTable.java
index a1dfab5..95af219 100644
--- a/jdk/src/share/classes/sun/text/normalizer/SymbolTable.java
+++ b/jdk/src/share/classes/sun/text/normalizer/SymbolTable.java
@@ -65,6 +65,7 @@
  * @draft ICU 2.8
  * @deprecated This is a draft API and might change in a future release of ICU.
  */
+@Deprecated
 public interface SymbolTable {
 
     /**
@@ -72,6 +73,7 @@
      * @draft ICU 2.8
      * @deprecated This is a draft API and might change in a future release of ICU.
      */
+    @Deprecated
     static final char SYMBOL_REF = '$';
 
     /**
@@ -84,6 +86,7 @@
      * @draft ICU 2.8
      * @deprecated This is a draft API and might change in a future release of ICU.
      */
+    @Deprecated
     char[] lookup(String s);
 
     /**
@@ -95,6 +98,7 @@
      * @draft ICU 2.8
      * @deprecated This is a draft API and might change in a future release of ICU.
      */
+    @Deprecated
     UnicodeMatcher lookupMatcher(int ch);
 
     /**
@@ -115,5 +119,6 @@
      * @draft ICU 2.8
      * @deprecated This is a draft API and might change in a future release of ICU.
      */
+    @Deprecated
     String parseReference(String text, ParsePosition pos, int limit);
 }
diff --git a/jdk/src/share/classes/sun/text/normalizer/UnicodeSet.java b/jdk/src/share/classes/sun/text/normalizer/UnicodeSet.java
index 569daff..42f6fdb 100644
--- a/jdk/src/share/classes/sun/text/normalizer/UnicodeSet.java
+++ b/jdk/src/share/classes/sun/text/normalizer/UnicodeSet.java
@@ -298,7 +298,7 @@
 
     // NOTE: normally the field should be of type SortedSet; but that is missing a public clone!!
     // is not private so that UnicodeSetIterator can get access
-    TreeSet strings = new TreeSet();
+    TreeSet<String> strings = new TreeSet<>();
 
     /**
      * The pattern representation of this set.  This may not be the
@@ -368,7 +368,7 @@
      * @stable ICU 2.0
      */
     public UnicodeSet set(UnicodeSet other) {
-        list = (int[]) other.list.clone();
+        list = other.list.clone();
         len = other.len;
         pat = other.pat;
         strings = (TreeSet)other.strings.clone();
@@ -524,10 +524,10 @@
         }
 
         if (includeStrings && strings.size() > 0) {
-            Iterator it = strings.iterator();
+            Iterator<String> it = strings.iterator();
             while (it.hasNext()) {
                 result.append('{');
-                _appendToPat(result, (String) it.next(), escapeUnprintable);
+                _appendToPat(result, it.next(), escapeUnprintable);
                 result.append('}');
             }
         }
@@ -1180,14 +1180,17 @@
                         }
                     }
                     syntaxError(chars, "'-' not after char or set");
+                    break;
                 case '&':
                     if (lastItem == 2 && op == 0) {
                         op = (char) c;
                         continue;
                     }
                     syntaxError(chars, "'&' not after set");
+                    break;
                 case '^':
                     syntaxError(chars, "'^' not after '['");
+                    break;
                 case '{':
                     if (op != 0) {
                         syntaxError(chars, "Missing operand after operator");
@@ -1251,6 +1254,7 @@
                         continue;
                     }
                     syntaxError(chars, "Unquoted '$'");
+                    break;
                 default:
                     break;
                 }
diff --git a/jdk/src/share/classes/sun/text/normalizer/UnicodeSetIterator.java b/jdk/src/share/classes/sun/text/normalizer/UnicodeSetIterator.java
index a27df03..53a145c 100644
--- a/jdk/src/share/classes/sun/text/normalizer/UnicodeSetIterator.java
+++ b/jdk/src/share/classes/sun/text/normalizer/UnicodeSetIterator.java
@@ -154,7 +154,7 @@
 
         if (stringIterator == null) return false;
         codepoint = IS_STRING; // signal that value is actually a string
-        string = (String)stringIterator.next();
+        string = stringIterator.next();
         if (!stringIterator.hasNext()) stringIterator = null;
         return true;
     }
@@ -203,7 +203,7 @@
      * @internal
      */
     protected int nextElement;
-    private Iterator stringIterator = null;
+    private Iterator<String> stringIterator = null;
 
     /**
      * Invariant: stringIterator is null when there are no (more) strings remaining
diff --git a/jdk/src/share/classes/sun/text/normalizer/VersionInfo.java b/jdk/src/share/classes/sun/text/normalizer/VersionInfo.java
index 44b2e69..2f418b0 100644
--- a/jdk/src/share/classes/sun/text/normalizer/VersionInfo.java
+++ b/jdk/src/share/classes/sun/text/normalizer/VersionInfo.java
@@ -153,7 +153,7 @@
     /**
      * Map of singletons
      */
-    private static final HashMap MAP_ = new HashMap();
+    private static final HashMap<Integer, Object> MAP_ = new HashMap<>();
     /**
      * Error statement string
      */
diff --git a/jdk/src/share/classes/sun/tools/attach/HotSpotAttachProvider.java b/jdk/src/share/classes/sun/tools/attach/HotSpotAttachProvider.java
index 08535a1..c28ddda 100644
--- a/jdk/src/share/classes/sun/tools/attach/HotSpotAttachProvider.java
+++ b/jdk/src/share/classes/sun/tools/attach/HotSpotAttachProvider.java
@@ -75,7 +75,7 @@
             new ArrayList<VirtualMachineDescriptor>();
 
         MonitoredHost host;
-        Set vms;
+        Set<Integer> vms;
         try {
             host = MonitoredHost.getMonitoredHost(new HostIdentifier((String)null));
             vms = host.activeVms();
@@ -92,31 +92,29 @@
             throw new InternalError(t);          // shouldn't happen
         }
 
-        for (Object vmid: vms) {
-            if (vmid instanceof Integer) {
-                String pid = vmid.toString();
-                String name = pid;      // default to pid if name not available
-                boolean isAttachable = false;
-                MonitoredVm mvm = null;
+        for (Integer vmid: vms) {
+            String pid = vmid.toString();
+            String name = pid;      // default to pid if name not available
+            boolean isAttachable = false;
+            MonitoredVm mvm = null;
+            try {
+                mvm = host.getMonitoredVm(new VmIdentifier(pid));
                 try {
-                    mvm = host.getMonitoredVm(new VmIdentifier(pid));
-                    try {
-                        isAttachable = MonitoredVmUtil.isAttachable(mvm);
-                        // use the command line as the display name
-                        name =  MonitoredVmUtil.commandLine(mvm);
-                    } catch (Exception e) {
-                    }
-                    if (isAttachable) {
-                        result.add(new HotSpotVirtualMachineDescriptor(this, pid, name));
-                    }
-                } catch (Throwable t) {
-                    if (t instanceof ThreadDeath) {
-                        throw (ThreadDeath)t;
-                    }
-                } finally {
-                    if (mvm != null) {
-                        mvm.detach();
-                    }
+                    isAttachable = MonitoredVmUtil.isAttachable(mvm);
+                    // use the command line as the display name
+                    name =  MonitoredVmUtil.commandLine(mvm);
+                } catch (Exception e) {
+                }
+                if (isAttachable) {
+                    result.add(new HotSpotVirtualMachineDescriptor(this, pid, name));
+                }
+            } catch (Throwable t) {
+                if (t instanceof ThreadDeath) {
+                    throw (ThreadDeath)t;
+                }
+            } finally {
+                if (mvm != null) {
+                    mvm.detach();
                 }
             }
         }
diff --git a/jdk/src/share/classes/sun/tools/jinfo/JInfo.java b/jdk/src/share/classes/sun/tools/jinfo/JInfo.java
index 9812a1e..5a40534 100644
--- a/jdk/src/share/classes/sun/tools/jinfo/JInfo.java
+++ b/jdk/src/share/classes/sun/tools/jinfo/JInfo.java
@@ -98,7 +98,7 @@
     }
 
     // loads the given class using the system class loader
-    private static Class loadClass(String name) {
+    private static Class<?> loadClass(String name) {
         //
         // We specify the system clas loader so as to cater for development
         // environments where this class is on the boot class path but sa-jdi.jar
@@ -178,7 +178,7 @@
     // print usage message
     private static void usage() {
 
-        Class c = loadClass("sun.jvm.hotspot.tools.JInfo");
+        Class<?> c = loadClass("sun.jvm.hotspot.tools.JInfo");
         boolean usageSA = (c != null);
 
         System.out.println("Usage:");
diff --git a/jdk/src/share/classes/sun/tools/jmap/JMap.java b/jdk/src/share/classes/sun/tools/jmap/JMap.java
index 0fb7b79..1d68b66 100644
--- a/jdk/src/share/classes/sun/tools/jmap/JMap.java
+++ b/jdk/src/share/classes/sun/tools/jmap/JMap.java
@@ -198,7 +198,7 @@
     }
 
     // loads the given class using the system class loader
-    private static Class loadClass(String name) {
+    private static Class<?> loadClass(String name) {
         //
         // We specify the system clas loader so as to cater for development
         // environments where this class is on the boot class path but sa-jdi.jar
@@ -336,7 +336,7 @@
 
     // returns true if SA is available
     private static boolean haveSA() {
-        Class c = loadClass("sun.jvm.hotspot.tools.HeapSummary");
+        Class<?> c = loadClass("sun.jvm.hotspot.tools.HeapSummary");
         return (c != null);
     }
 
diff --git a/jdk/src/share/classes/sun/tools/jps/Jps.java b/jdk/src/share/classes/sun/tools/jps/Jps.java
index 9611dd3..9c65381 100644
--- a/jdk/src/share/classes/sun/tools/jps/Jps.java
+++ b/jdk/src/share/classes/sun/tools/jps/Jps.java
@@ -59,13 +59,13 @@
                     MonitoredHost.getMonitoredHost(hostId);
 
             // get the set active JVMs on the specified host.
-            Set jvms = monitoredHost.activeVms();
+            Set<Integer> jvms = monitoredHost.activeVms();
 
-            for (Iterator j = jvms.iterator(); j.hasNext(); /* empty */ ) {
+            for (Integer jvm: jvms) {
                 StringBuilder output = new StringBuilder();
                 Throwable lastError = null;
 
-                int lvmid = ((Integer)j.next()).intValue();
+                int lvmid = jvm;
 
                 output.append(String.valueOf(lvmid));
 
diff --git a/jdk/src/share/classes/sun/tools/jstack/JStack.java b/jdk/src/share/classes/sun/tools/jstack/JStack.java
index 004c2ab..66fc672 100644
--- a/jdk/src/share/classes/sun/tools/jstack/JStack.java
+++ b/jdk/src/share/classes/sun/tools/jstack/JStack.java
@@ -137,7 +137,7 @@
     }
 
     // Returns sun.jvm.hotspot.tools.JStack if available, otherwise null.
-    private static Class loadSAClass() {
+    private static Class<?> loadSAClass() {
         //
         // Attempt to load JStack class - we specify the system class
         // loader so as to cater for development environments where
diff --git a/jdk/src/share/classes/sun/tools/serialver/SerialVer.java b/jdk/src/share/classes/sun/tools/serialver/SerialVer.java
index 13ff359..4b310a8 100644
--- a/jdk/src/share/classes/sun/tools/serialver/SerialVer.java
+++ b/jdk/src/share/classes/sun/tools/serialver/SerialVer.java
@@ -98,6 +98,7 @@
         classname_t.requestFocus();
     }
 
+    @SuppressWarnings("deprecation")
     public boolean action(Event ev, Object obj) {
         if (ev.target == classname_t) {
             show((String)ev.arg);
@@ -110,6 +111,7 @@
     }
 
 
+    @SuppressWarnings("deprecation")
     public boolean handleEvent(Event ev) {
         boolean rc = super.handleEvent(ev);
         return rc;
@@ -206,7 +208,7 @@
     }
 
     static String resolveClass(String classname) throws ClassNotFoundException {
-        Class cl = Class.forName(classname, false, loader);
+        Class<?> cl = Class.forName(classname, false, loader);
         ObjectStreamClass desc = ObjectStreamClass.lookup(cl);
         if (desc != null) {
             return "    static final long serialVersionUID = " +
@@ -216,6 +218,10 @@
         }
     }
 
+    @SuppressWarnings("deprecation")
+    private static void showWindow(Window w) {
+        w.show();
+    }
 
     public static void main(String[] args) {
         boolean show = false;
@@ -316,7 +322,7 @@
 
             f.add("Center", sv);
             f.pack();
-            f.show();
+            showWindow(f);
         }
     }
 
@@ -362,6 +368,7 @@
     /*
      * Handle a window destroy event by exiting.
      */
+    @SuppressWarnings("deprecation")
     public boolean handleEvent(Event e) {
         if (e.id == Event.WINDOW_DESTROY) {
             exit(0);
@@ -371,6 +378,7 @@
     /*
      * Handle an Exit event by exiting.
      */
+    @SuppressWarnings("deprecation")
     public boolean action(Event ev, Object obj) {
         if (ev.target == exit_i) {
             exit(0);
@@ -455,11 +463,7 @@
         }
         try {
             String message = messageRB.getString(key);
-            String[] args = new String[3];
-            args[0] = a1;
-            args[1] = a2;
-            args[2] = a3;
-            return MessageFormat.format(message, args);
+            return MessageFormat.format(message, a1, a2, a3);
         } catch (MissingResourceException e) {
             throw new Error("Fatal: Resource for serialver is broken. There is no " + key + " key in resource.");
         }
diff --git a/jdk/src/share/classes/sun/util/LocaleServiceProviderPool.java b/jdk/src/share/classes/sun/util/LocaleServiceProviderPool.java
index c45100d..349ce56 100644
--- a/jdk/src/share/classes/sun/util/LocaleServiceProviderPool.java
+++ b/jdk/src/share/classes/sun/util/LocaleServiceProviderPool.java
@@ -58,7 +58,7 @@
      * A Map that holds singleton instances of this class.  Each instance holds a
      * set of provider implementations of a particular locale sensitive service.
      */
-    private static ConcurrentMap<Class, LocaleServiceProviderPool> poolOfPools =
+    private static ConcurrentMap<Class<? extends LocaleServiceProvider>, LocaleServiceProviderPool> poolOfPools =
         new ConcurrentHashMap<>();
 
     /**
@@ -147,6 +147,10 @@
     /**
      * Lazy loaded set of available locales.
      * Loading all locales is a very long operation.
+     *
+     * We know "providerClasses" contains classes that extends LocaleServiceProvider,
+     * but generic array creation is not allowed, thus the "unchecked" warning
+     * is suppressed here.
      */
     private static class AllAvailableLocales {
         /**
@@ -156,7 +160,9 @@
         static final Locale[] allAvailableLocales;
 
         static {
-            Class[] providerClasses = {
+            @SuppressWarnings("unchecked")
+            Class<LocaleServiceProvider>[] providerClasses =
+                        (Class<LocaleServiceProvider>[]) new Class<?>[] {
                 java.text.spi.BreakIteratorProvider.class,
                 java.text.spi.CollatorProvider.class,
                 java.text.spi.DateFormatProvider.class,
@@ -174,7 +180,7 @@
                 all.add(getLookupLocale(locale));
             }
 
-            for (Class providerClass : providerClasses) {
+            for (Class<LocaleServiceProvider> providerClass : providerClasses) {
                 LocaleServiceProviderPool pool =
                     LocaleServiceProviderPool.getPool(providerClass);
                 all.addAll(pool.getProviderLocales());
@@ -355,7 +361,6 @@
             }
             Locale bundleLocale = (bundle != null ? bundle.getLocale() : null);
             List<Locale> lookupLocales = getLookupLocales(locale);
-            P lsp;
             S providersObj = null;
 
             // check whether a provider has an implementation that's closer
@@ -375,7 +380,9 @@
                     }
                 }
                 if (provLoc.contains(current)) {
-                    lsp = (P)findProvider(current);
+                    // It is safe to assume that findProvider() returns the instance of type P.
+                    @SuppressWarnings("unchecked")
+                    P lsp = (P)findProvider(current);
                     if (lsp != null) {
                         providersObj = getter.getObject(lsp, locale, key, params);
                         if (providersObj != null) {
@@ -397,7 +404,9 @@
                     // JRE has it.
                     return null;
                 } else {
-                    lsp = (P)findProvider(bundleLocale);
+                    // It is safe to assume that findProvider() returns the instance of type P.
+                    @SuppressWarnings("unchecked")
+                    P lsp = (P)findProvider(bundleLocale);
                     if (lsp != null) {
                         providersObj = getter.getObject(lsp, locale, key, params);
                         if (providersObj != null) {
diff --git a/jdk/src/share/classes/sun/util/calendar/BaseCalendar.java b/jdk/src/share/classes/sun/util/calendar/BaseCalendar.java
index 21528dc..a7e763a 100644
--- a/jdk/src/share/classes/sun/util/calendar/BaseCalendar.java
+++ b/jdk/src/share/classes/sun/util/calendar/BaseCalendar.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -25,7 +25,6 @@
 
 package sun.util.calendar;
 
-import java.util.Locale;
 import java.util.TimeZone;
 
 /**
@@ -203,7 +202,7 @@
             return false;
         }
         int dow = bdate.getDayOfWeek();
-        if (dow != bdate.FIELD_UNDEFINED && dow != getDayOfWeek(bdate)) {
+        if (dow != Date.FIELD_UNDEFINED && dow != getDayOfWeek(bdate)) {
             return false;
         }
 
@@ -329,7 +328,7 @@
     }
 
     // accepts 0 (December in the previous year) to 12.
-    private final int getMonthLength(int year, int month) {
+    private int getMonthLength(int year, int month) {
         int days = DAYS_IN_MONTH[month];
         if (month == FEBRUARY && isLeapYear(year)) {
             days++;
diff --git a/jdk/src/share/classes/sun/util/calendar/CalendarSystem.java b/jdk/src/share/classes/sun/util/calendar/CalendarSystem.java
index ac85641..fdbdcb0 100644
--- a/jdk/src/share/classes/sun/util/calendar/CalendarSystem.java
+++ b/jdk/src/share/classes/sun/util/calendar/CalendarSystem.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -25,13 +25,6 @@
 
 package sun.util.calendar;
 
-import java.lang.reflect.Field;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-import java.util.Set;
 import java.util.TimeZone;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
@@ -99,7 +92,7 @@
     };
 
     private static void initNames() {
-        ConcurrentMap<String,String> nameMap = new ConcurrentHashMap<String,String>();
+        ConcurrentMap<String,String> nameMap = new ConcurrentHashMap<>();
 
         // Associate a calendar name with its class name and the
         // calendar class name with its date class name.
@@ -112,7 +105,7 @@
         synchronized (CalendarSystem.class) {
             if (!initialized) {
                 names = nameMap;
-                calendars = new ConcurrentHashMap<String,CalendarSystem>();
+                calendars = new ConcurrentHashMap<>();
                 initialized = true;
             }
         }
@@ -164,10 +157,10 @@
             cal = LocalGregorianCalendar.getLocalGregorianCalendar(calendarName);
         } else {
             try {
-                Class cl = Class.forName(className);
+                Class<?> cl = Class.forName(className);
                 cal = (CalendarSystem) cl.newInstance();
             } catch (Exception e) {
-                throw new RuntimeException("internal error", e);
+                throw new InternalError(e);
             }
         }
         if (cal == null) {
diff --git a/jdk/src/share/classes/sun/util/calendar/LocalGregorianCalendar.java b/jdk/src/share/classes/sun/util/calendar/LocalGregorianCalendar.java
index 99da4cd..d107a00 100644
--- a/jdk/src/share/classes/sun/util/calendar/LocalGregorianCalendar.java
+++ b/jdk/src/share/classes/sun/util/calendar/LocalGregorianCalendar.java
@@ -29,7 +29,6 @@
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.security.AccessController;
-import java.security.PrivilegedAction;
 import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
 import java.util.ArrayList;
@@ -124,8 +123,8 @@
                 new sun.security.action.GetPropertyAction("java.home"));
             final String fname = homeDir + File.separator + "lib" + File.separator
                                  + "calendars.properties";
-            calendarProps = (Properties) AccessController.doPrivileged(new PrivilegedExceptionAction() {
-                public Object run() throws IOException {
+            calendarProps = AccessController.doPrivileged(new PrivilegedExceptionAction<Properties>() {
+                public Properties run() throws IOException {
                     Properties props = new Properties();
                     try (FileInputStream fis = new FileInputStream(fname)) {
                         props.load(fis);
@@ -142,7 +141,7 @@
         if (props == null) {
             return null;
         }
-        List<Era> eras = new ArrayList<Era>();
+        List<Era> eras = new ArrayList<>();
         StringTokenizer eraTokens = new StringTokenizer(props, ";");
         while (eraTokens.hasMoreTokens()) {
             String items = eraTokens.nextToken().trim();
diff --git a/jdk/src/share/classes/sun/util/calendar/ZoneInfo.java b/jdk/src/share/classes/sun/util/calendar/ZoneInfo.java
index b79e7cc..975e3ed 100644
--- a/jdk/src/share/classes/sun/util/calendar/ZoneInfo.java
+++ b/jdk/src/share/classes/sun/util/calendar/ZoneInfo.java
@@ -31,7 +31,6 @@
 import java.security.AccessController;
 import java.util.ArrayList;
 import java.util.Date;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
@@ -318,7 +317,7 @@
         return offset;
     }
 
-    private final int getTransitionIndex(long date, int type) {
+    private int getTransitionIndex(long date, int type) {
         int low = 0;
         int high = transitions.length - 1;
 
@@ -572,7 +571,7 @@
         List<String> excluded = ZoneInfoFile.getExcludedZones();
         if (excluded != null) {
             // List all zones from the idList and excluded lists
-            List<String> list = new ArrayList<String>(idList.size() + excluded.size());
+            List<String> list = new ArrayList<>(idList.size() + excluded.size());
             list.addAll(idList);
             list.addAll(excluded);
             idList = list;
@@ -592,7 +591,7 @@
      */
     public static String[] getAvailableIDs(int rawOffset) {
         String[] result;
-        List<String> matched = new ArrayList<String>();
+        List<String> matched = new ArrayList<>();
         List<String> IDs = ZoneInfoFile.getZoneIDs();
         int[] rawOffsets = ZoneInfoFile.getRawOffsets();
 
@@ -807,7 +806,7 @@
         return (checksum == ((ZoneInfo)other).checksum);
     }
 
-    private static SoftReference<Map> aliasTable;
+    private static SoftReference<Map<String, String>> aliasTable;
 
     /**
      * Returns a Map from alias time zone IDs to their standard
@@ -820,7 +819,7 @@
     public synchronized static Map<String, String> getAliasTable() {
         Map<String, String> aliases = null;
 
-        SoftReference<Map> cache = aliasTable;
+        SoftReference<Map<String, String>> cache = aliasTable;
         if (cache != null) {
             aliases = cache.get();
             if (aliases != null) {
@@ -830,7 +829,7 @@
 
         aliases = ZoneInfoFile.getZoneAliases();
         if (aliases != null) {
-            aliasTable = new SoftReference<Map>(aliases);
+            aliasTable = new SoftReference<>(aliases);
         }
         return aliases;
     }
diff --git a/jdk/src/share/classes/sun/util/calendar/ZoneInfoFile.java b/jdk/src/share/classes/sun/util/calendar/ZoneInfoFile.java
index 8918177..2ad72b0 100644
--- a/jdk/src/share/classes/sun/util/calendar/ZoneInfoFile.java
+++ b/jdk/src/share/classes/sun/util/calendar/ZoneInfoFile.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -573,7 +573,7 @@
 
     synchronized static ZoneInfo addToCache(String id, ZoneInfo zi) {
         if (zoneInfoObjects == null) {
-            zoneInfoObjects = new HashMap<String, ZoneInfo>();
+            zoneInfoObjects = new HashMap<>();
         } else {
             ZoneInfo zone = zoneInfoObjects.get(id);
             if (zone != null) {
@@ -758,7 +758,7 @@
                 case TAG_ZoneIDs:
                     {
                         int n = (buf[index++] << 8) + (buf[index++] & 0xFF);
-                        ids = new ArrayList<String>(n);
+                        ids = new ArrayList<>(n);
 
                         for (int i = 0; i < n; i++) {
                             byte m = buf[index++];
@@ -777,7 +777,7 @@
             System.err.println("ZoneInfo: corrupted " + JAVAZM_FILE_NAME);
         }
 
-        zoneIDs = new SoftReference<List<String>>(ids);
+        zoneIDs = new SoftReference<>(ids);
         return ids;
     }
 
@@ -802,7 +802,7 @@
                 case TAG_ZoneAliases:
                     {
                         int n = (buf[index++] << 8) + (buf[index++] & 0xFF);
-                        aliases = new HashMap<String, String>(n);
+                        aliases = new HashMap<>(n);
                         for (int i = 0; i < n; i++) {
                             byte m = buf[index++];
                             String name = new String(buf, index, m, "UTF-8");
@@ -865,7 +865,7 @@
                 case TAG_ExcludedZones:
                     {
                         int n = (buf[index++] << 8) + (buf[index++] & 0xFF);
-                        excludeList = new ArrayList<String>();
+                        excludeList = new ArrayList<>();
                         for (int i = 0; i < n; i++) {
                             byte m = buf[index++];
                             String name = new String(buf, index, m, "UTF-8");
@@ -886,7 +886,7 @@
         }
 
         if (excludeList != null) {
-            excludedIDs = new SoftReference<List<String>>(excludeList);
+            excludedIDs = new SoftReference<>(excludeList);
         } else {
             hasNoExcludeList = true;
         }
@@ -935,7 +935,7 @@
             System.err.println("ZoneInfo: corrupted " + JAVAZM_FILE_NAME);
         }
 
-        rawOffsetIndices = new SoftReference<byte[]>(indices);
+        rawOffsetIndices = new SoftReference<>(indices);
         return indices;
     }
 
@@ -986,7 +986,7 @@
             System.err.println("ZoneInfo: corrupted " + JAVAZM_FILE_NAME);
         }
 
-        rawOffsets = new SoftReference<int[]>(offsets);
+        rawOffsets = new SoftReference<>(offsets);
         return offsets;
     }
 
@@ -1022,7 +1022,7 @@
             return null;
         }
 
-        zoneInfoMappings = new SoftReference<byte[]>(data);
+        zoneInfoMappings = new SoftReference<>(data);
         return data;
     }
 
@@ -1034,8 +1034,8 @@
         byte[] buffer = null;
 
         try {
-            buffer = (byte[]) AccessController.doPrivileged(new PrivilegedExceptionAction() {
-                public Object run() throws IOException {
+            buffer = AccessController.doPrivileged(new PrivilegedExceptionAction<byte[]>() {
+                public byte[] run() throws IOException {
                     File file = new File(ziDir, fileName);
                     if (!file.exists() || !file.isFile()) {
                         return null;
@@ -1068,4 +1068,7 @@
         }
         return buffer;
     }
+
+    private ZoneInfoFile() {
+    }
 }
diff --git a/jdk/src/share/classes/sun/util/resources/LocaleData.java b/jdk/src/share/classes/sun/util/resources/LocaleData.java
index a082a60..ac8fdd2 100644
--- a/jdk/src/share/classes/sun/util/resources/LocaleData.java
+++ b/jdk/src/share/classes/sun/util/resources/LocaleData.java
@@ -137,8 +137,8 @@
     }
 
     private static ResourceBundle getBundle(final String baseName, final Locale locale) {
-        return (ResourceBundle) AccessController.doPrivileged(new PrivilegedAction() {
-                public Object run() {
+        return AccessController.doPrivileged(new PrivilegedAction<ResourceBundle>() {
+                public ResourceBundle run() {
                     return ResourceBundle.
                         getBundle(baseName, locale,
                                   LocaleDataResourceBundleControl.getRBControlInstance());
diff --git a/jdk/src/share/classes/sun/util/resources/OpenListResourceBundle.java b/jdk/src/share/classes/sun/util/resources/OpenListResourceBundle.java
index 86a91f8..f8d48a2 100644
--- a/jdk/src/share/classes/sun/util/resources/OpenListResourceBundle.java
+++ b/jdk/src/share/classes/sun/util/resources/OpenListResourceBundle.java
@@ -119,11 +119,12 @@
      * loading.
      */
     private synchronized void loadLookup() {
-        if (lookup != null)
+        if (lookup != null) {
             return;
+        }
 
         Object[][] contents = getContents();
-        Map temp = createMap(contents.length);
+        Map<String, Object> temp = createMap(contents.length);
         for (int i = 0; i < contents.length; ++i) {
             // key must be non-null String, value must be non-null
             String key = (String) contents[i][0];
@@ -140,9 +141,9 @@
      * Lets subclasses provide specialized Map implementations.
      * Default uses HashMap.
      */
-    protected Map createMap(int size) {
-        return new HashMap(size);
+    protected Map<String, Object> createMap(int size) {
+        return new HashMap<>(size);
     }
 
-    private Map lookup = null;
+    private Map<String, Object> lookup = null;
 }
diff --git a/jdk/src/share/classes/sun/util/resources/TimeZoneNamesBundle.java b/jdk/src/share/classes/sun/util/resources/TimeZoneNamesBundle.java
index 6360125..3757ed1 100644
--- a/jdk/src/share/classes/sun/util/resources/TimeZoneNamesBundle.java
+++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNamesBundle.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -80,17 +80,16 @@
         int clen = contents.length;
         String[] tmpobj = new String[clen+1];
         tmpobj[0] = key;
-        for (int i = 0; i < clen; i++) {
-            tmpobj[i+1] = contents[i];
-        }
+        System.arraycopy(contents, 0, tmpobj, 1, clen);
         return tmpobj;
     }
 
     /**
      * Use LinkedHashMap to preserve order of bundle entries.
      */
-    protected Map createMap(int size) {
-        return new LinkedHashMap(size);
+    @Override
+    protected Map<String, Object> createMap(int size) {
+        return new LinkedHashMap<>(size);
     }
 
     /**
diff --git a/jdk/src/share/native/java/io/io_util.c b/jdk/src/share/native/java/io/io_util.c
index e17652a..8777ff0 100644
--- a/jdk/src/share/native/java/io/io_util.c
+++ b/jdk/src/share/native/java/io/io_util.c
@@ -44,7 +44,7 @@
         JNU_ThrowIOException(env, "Stream Closed");
         return -1;
     }
-    nread = (jint)IO_Read(fd, &ret, 1);
+    nread = IO_Read(fd, &ret, 1);
     if (nread == 0) { /* EOF */
         return -1;
     } else if (nread == JVM_IO_ERR) { /* error */
@@ -108,7 +108,7 @@
         JNU_ThrowIOException(env, "Stream Closed");
         nread = -1;
     } else {
-        nread = (jint)IO_Read(fd, buf, len);
+        nread = IO_Read(fd, buf, len);
         if (nread > 0) {
             (*env)->SetByteArrayRegion(env, bytes, off, nread, (jbyte *)buf);
         } else if (nread == JVM_IO_ERR) {
@@ -137,9 +137,9 @@
         return;
     }
     if (append == JNI_TRUE) {
-        n = (jint)IO_Append(fd, &c, 1);
+        n = IO_Append(fd, &c, 1);
     } else {
-        n = (jint)IO_Write(fd, &c, 1);
+        n = IO_Write(fd, &c, 1);
     }
     if (n == JVM_IO_ERR) {
         JNU_ThrowIOExceptionWithLastError(env, "Write error");
@@ -190,9 +190,9 @@
                 break;
             }
             if (append == JNI_TRUE) {
-                n = (jint)IO_Append(fd, buf+off, len);
+                n = IO_Append(fd, buf+off, len);
             } else {
-                n = (jint)IO_Write(fd, buf+off, len);
+                n = IO_Write(fd, buf+off, len);
             }
             if (n == JVM_IO_ERR) {
                 JNU_ThrowIOExceptionWithLastError(env, "Write error");
diff --git a/jdk/src/share/native/java/util/zip/Adler32.c b/jdk/src/share/native/java/util/zip/Adler32.c
index d7666ca..36b5499 100644
--- a/jdk/src/share/native/java/util/zip/Adler32.c
+++ b/jdk/src/share/native/java/util/zip/Adler32.c
@@ -30,6 +30,7 @@
 #include "jni.h"
 #include "jni_util.h"
 #include "zlib.h"
+#include "jlong.h"
 
 #include "java_util_zip_Adler32.h"
 
@@ -53,3 +54,17 @@
     }
     return adler;
 }
+
+
+JNIEXPORT jint JNICALL
+Java_java_util_zip_Adler32_updateByteBuffer(JNIEnv *env, jclass cls, jint adler,
+                                       jlong address, jint off, jint len)
+{
+    Bytef *buf = (Bytef *)jlong_to_ptr(address);
+    if (buf) {
+        adler = adler32(adler, buf + off, len);
+    }
+    return adler;
+}
+
+
diff --git a/jdk/src/share/native/java/util/zip/CRC32.c b/jdk/src/share/native/java/util/zip/CRC32.c
index 48b6652..c8cb2de 100644
--- a/jdk/src/share/native/java/util/zip/CRC32.c
+++ b/jdk/src/share/native/java/util/zip/CRC32.c
@@ -58,3 +58,14 @@
 {
     return crc32(crc, (Bytef*)buf, len);
 }
+
+JNIEXPORT jint JNICALL
+Java_java_util_zip_CRC32_updateByteBuffer(JNIEnv *env, jclass cls, jint crc,
+                                          jlong address, jint off, jint len)
+{
+    Bytef *buf = (Bytef *)jlong_to_ptr(address);
+    if (buf) {
+        crc = crc32(crc, buf + off, len);
+    }
+    return crc;
+}
diff --git a/jdk/src/share/native/java/util/zip/zlib-1.2.3/README b/jdk/src/share/native/java/util/zip/zlib-1.2.3/README
deleted file mode 100644
index 758cc50..0000000
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/README
+++ /dev/null
@@ -1,125 +0,0 @@
-ZLIB DATA COMPRESSION LIBRARY
-
-zlib 1.2.3 is a general purpose data compression library.  All the code is
-thread safe.  The data format used by the zlib library is described by RFCs
-(Request for Comments) 1950 to 1952 in the files
-http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format)
-and rfc1952.txt (gzip format). These documents are also available in other
-formats from ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html
-
-All functions of the compression library are documented in the file zlib.h
-(volunteer to write man pages welcome, contact zlib@gzip.org). A usage example
-of the library is given in the file example.c which also tests that the library
-is working correctly. Another example is given in the file minigzip.c. The
-compression library itself is composed of all source files except example.c and
-minigzip.c.
-
-To compile all files and run the test program, follow the instructions given at
-the top of Makefile. In short "make test; make install" should work for most
-machines. For Unix: "./configure; make test; make install". For MSDOS, use one
-of the special makefiles such as Makefile.msc. For VMS, use make_vms.com.
-
-Questions about zlib should be sent to <zlib@gzip.org>, or to Gilles Vollant
-<info@winimage.com> for the Windows DLL version. The zlib home page is
-http://www.zlib.org or http://www.gzip.org/zlib/ Before reporting a problem,
-please check this site to verify that you have the latest version of zlib;
-otherwise get the latest version and check whether the problem still exists or
-not.
-
-PLEASE read the zlib FAQ http://www.gzip.org/zlib/zlib_faq.html before asking
-for help.
-
-Mark Nelson <markn@ieee.org> wrote an article about zlib for the Jan. 1997
-issue of  Dr. Dobb's Journal; a copy of the article is available in
-http://dogma.net/markn/articles/zlibtool/zlibtool.htm
-
-The changes made in version 1.2.3 are documented in the file ChangeLog.
-
-Unsupported third party contributions are provided in directory "contrib".
-
-A Java implementation of zlib is available in the Java Development Kit
-http://java.sun.com/j2se/1.4.2/docs/api/java/util/zip/package-summary.html
-See the zlib home page http://www.zlib.org for details.
-
-A Perl interface to zlib written by Paul Marquess <pmqs@cpan.org> is in the
-CPAN (Comprehensive Perl Archive Network) sites
-http://www.cpan.org/modules/by-module/Compress/
-
-A Python interface to zlib written by A.M. Kuchling <amk@amk.ca> is
-available in Python 1.5 and later versions, see
-http://www.python.org/doc/lib/module-zlib.html
-
-A zlib binding for TCL written by Andreas Kupries <a.kupries@westend.com> is
-availlable at http://www.oche.de/~akupries/soft/trf/trf_zip.html
-
-An experimental package to read and write files in .zip format, written on top
-of zlib by Gilles Vollant <info@winimage.com>, is available in the
-contrib/minizip directory of zlib.
-
-
-Notes for some targets:
-
-- For Windows DLL versions, please see win32/DLL_FAQ.txt
-
-- For 64-bit Irix, deflate.c must be compiled without any optimization. With
-  -O, one libpng test fails. The test works in 32 bit mode (with the -n32
-  compiler flag). The compiler bug has been reported to SGI.
-
-- zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1 it works
-  when compiled with cc.
-
-- On Digital Unix 4.0D (formely OSF/1) on AlphaServer, the cc option -std1 is
-  necessary to get gzprintf working correctly. This is done by configure.
-
-- zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with
-  other compilers. Use "make test" to check your compiler.
-
-- gzdopen is not supported on RISCOS, BEOS and by some Mac compilers.
-
-- For PalmOs, see http://palmzlib.sourceforge.net/
-
-- When building a shared, i.e. dynamic library on Mac OS X, the library must be
-  installed before testing (do "make install" before "make test"), since the
-  library location is specified in the library.
-
-
-Acknowledgments:
-
-  The deflate format used by zlib was defined by Phil Katz. The deflate
-  and zlib specifications were written by L. Peter Deutsch. Thanks to all the
-  people who reported problems and suggested various improvements in zlib;
-  they are too numerous to cite here.
-
-Copyright notice:
-
- (C) 1995-2004 Jean-loup Gailly and Mark Adler
-
-  This software is provided 'as-is', without any express or implied
-  warranty.  In no event will the authors be held liable for any damages
-  arising from the use of this software.
-
-  Permission is granted to anyone to use this software for any purpose,
-  including commercial applications, and to alter it and redistribute it
-  freely, subject to the following restrictions:
-
-  1. The origin of this software must not be misrepresented; you must not
-     claim that you wrote the original software. If you use this software
-     in a product, an acknowledgment in the product documentation would be
-     appreciated but is not required.
-  2. Altered source versions must be plainly marked as such, and must not be
-     misrepresented as being the original software.
-  3. This notice may not be removed or altered from any source distribution.
-
-  Jean-loup Gailly        Mark Adler
-  jloup@gzip.org          madler@alumni.caltech.edu
-
-If you use the zlib library in a product, we would appreciate *not*
-receiving lengthy legal documents to sign. The sources are provided
-for free but without warranty of any kind.  The library has been
-entirely written by Jean-loup Gailly and Mark Adler; it does not
-include third-party code.
-
-If you redistribute modified sources, we would appreciate that you include
-in the file ChangeLog history information documenting your changes. Please
-read the FAQ for more information on the distribution of modified source
-versions.
diff --git a/jdk/src/share/native/java/util/zip/zlib-1.2.3/gzio.c b/jdk/src/share/native/java/util/zip/zlib-1.2.3/gzio.c
deleted file mode 100644
index 2926d93..0000000
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/gzio.c
+++ /dev/null
@@ -1,1050 +0,0 @@
-/*
- * 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.
- */
-
-/* gzio.c -- IO on .gz files
- * Copyright (C) 1995-2005 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- *
- * Compile this file with -DNO_GZCOMPRESS to avoid the compression code.
- */
-
-/* @(#) $Id$ */
-
-#include <stdio.h>
-
-#include "zutil.h"
-
-#ifdef NO_DEFLATE       /* for compatibility with old definition */
-#  define NO_GZCOMPRESS
-#endif
-
-#ifndef NO_DUMMY_DECL
-struct internal_state {int dummy;}; /* for buggy compilers */
-#endif
-
-#ifndef Z_BUFSIZE
-#  ifdef MAXSEG_64K
-#    define Z_BUFSIZE 4096 /* minimize memory usage for 16-bit DOS */
-#  else
-#    define Z_BUFSIZE 16384
-#  endif
-#endif
-#ifndef Z_PRINTF_BUFSIZE
-#  define Z_PRINTF_BUFSIZE 4096
-#endif
-
-#ifdef __MVS__
-#  pragma map (fdopen , "\174\174FDOPEN")
-   FILE *fdopen(int, const char *);
-#endif
-
-#ifndef STDC
-extern voidp  malloc OF((uInt size));
-extern void   free   OF((voidpf ptr));
-#endif
-
-#define ALLOC(size) malloc(size)
-#define TRYFREE(p) {if (p) free(p);}
-
-static int const gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */
-
-/* gzip flag byte */
-#define ASCII_FLAG   0x01 /* bit 0 set: file probably ascii text */
-#define HEAD_CRC     0x02 /* bit 1 set: header CRC present */
-#define EXTRA_FIELD  0x04 /* bit 2 set: extra field present */
-#define ORIG_NAME    0x08 /* bit 3 set: original file name present */
-#define COMMENT      0x10 /* bit 4 set: file comment present */
-#define RESERVED     0xE0 /* bits 5..7: reserved */
-
-typedef struct gz_stream {
-    z_stream stream;
-    int      z_err;   /* error code for last stream operation */
-    int      z_eof;   /* set if end of input file */
-    FILE     *file;   /* .gz file */
-    Byte     *inbuf;  /* input buffer */
-    Byte     *outbuf; /* output buffer */
-    uLong    crc;     /* crc32 of uncompressed data */
-    char     *msg;    /* error message */
-    char     *path;   /* path name for debugging only */
-    int      transparent; /* 1 if input file is not a .gz file */
-    char     mode;    /* 'w' or 'r' */
-    z_off_t  start;   /* start of compressed data in file (header skipped) */
-    z_off_t  in;      /* bytes into deflate or inflate */
-    z_off_t  out;     /* bytes out of deflate or inflate */
-    int      back;    /* one character push-back */
-    int      last;    /* true if push-back is last character */
-} gz_stream;
-
-
-local gzFile gz_open      OF((const char *path, const char *mode, int  fd));
-local int do_flush        OF((gzFile file, int flush));
-local int    get_byte     OF((gz_stream *s));
-local void   check_header OF((gz_stream *s));
-local int    destroy      OF((gz_stream *s));
-local void   putLong      OF((FILE *file, uLong x));
-local uLong  getLong      OF((gz_stream *s));
-
-/* ===========================================================================
-     Opens a gzip (.gz) file for reading or writing. The mode parameter
-   is as in fopen ("rb" or "wb"). The file is given either by file descriptor
-   or path name (if fd == -1).
-     gz_open returns NULL if the file could not be opened or if there was
-   insufficient memory to allocate the (de)compression state; errno
-   can be checked to distinguish the two cases (if errno is zero, the
-   zlib error is Z_MEM_ERROR).
-*/
-local gzFile gz_open (path, mode, fd)
-    const char *path;
-    const char *mode;
-    int  fd;
-{
-    int err;
-    int level = Z_DEFAULT_COMPRESSION; /* compression level */
-    int strategy = Z_DEFAULT_STRATEGY; /* compression strategy */
-    char *p = (char*)mode;
-    gz_stream *s;
-    char fmode[80]; /* copy of mode, without the compression level */
-    char *m = fmode;
-
-    if (!path || !mode) return Z_NULL;
-
-    s = (gz_stream *)ALLOC(sizeof(gz_stream));
-    if (!s) return Z_NULL;
-
-    s->stream.zalloc = (alloc_func)0;
-    s->stream.zfree = (free_func)0;
-    s->stream.opaque = (voidpf)0;
-    s->stream.next_in = s->inbuf = Z_NULL;
-    s->stream.next_out = s->outbuf = Z_NULL;
-    s->stream.avail_in = s->stream.avail_out = 0;
-    s->file = NULL;
-    s->z_err = Z_OK;
-    s->z_eof = 0;
-    s->in = 0;
-    s->out = 0;
-    s->back = EOF;
-    s->crc = crc32(0L, Z_NULL, 0);
-    s->msg = NULL;
-    s->transparent = 0;
-
-    s->path = (char*)ALLOC(strlen(path)+1);
-    if (s->path == NULL) {
-        return destroy(s), (gzFile)Z_NULL;
-    }
-    strcpy(s->path, path); /* do this early for debugging */
-
-    s->mode = '\0';
-    do {
-        if (*p == 'r') s->mode = 'r';
-        if (*p == 'w' || *p == 'a') s->mode = 'w';
-        if (*p >= '0' && *p <= '9') {
-            level = *p - '0';
-        } else if (*p == 'f') {
-          strategy = Z_FILTERED;
-        } else if (*p == 'h') {
-          strategy = Z_HUFFMAN_ONLY;
-        } else if (*p == 'R') {
-          strategy = Z_RLE;
-        } else {
-            *m++ = *p; /* copy the mode */
-        }
-    } while (*p++ && m != fmode + sizeof(fmode));
-    if (s->mode == '\0') return destroy(s), (gzFile)Z_NULL;
-
-    if (s->mode == 'w') {
-#ifdef NO_GZCOMPRESS
-        err = Z_STREAM_ERROR;
-#else
-        err = deflateInit2(&(s->stream), level,
-                           Z_DEFLATED, -MAX_WBITS, DEF_MEM_LEVEL, strategy);
-        /* windowBits is passed < 0 to suppress zlib header */
-
-        s->stream.next_out = s->outbuf = (Byte*)ALLOC(Z_BUFSIZE);
-#endif
-        if (err != Z_OK || s->outbuf == Z_NULL) {
-            return destroy(s), (gzFile)Z_NULL;
-        }
-    } else {
-        s->stream.next_in  = s->inbuf = (Byte*)ALLOC(Z_BUFSIZE);
-
-        err = inflateInit2(&(s->stream), -MAX_WBITS);
-        /* windowBits is passed < 0 to tell that there is no zlib header.
-         * Note that in this case inflate *requires* an extra "dummy" byte
-         * after the compressed stream in order to complete decompression and
-         * return Z_STREAM_END. Here the gzip CRC32 ensures that 4 bytes are
-         * present after the compressed stream.
-         */
-        if (err != Z_OK || s->inbuf == Z_NULL) {
-            return destroy(s), (gzFile)Z_NULL;
-        }
-    }
-    s->stream.avail_out = Z_BUFSIZE;
-
-    errno = 0;
-    s->file = fd < 0 ? F_OPEN(path, fmode) : (FILE*)fdopen(fd, fmode);
-
-    if (s->file == NULL) {
-        return destroy(s), (gzFile)Z_NULL;
-    }
-    if (s->mode == 'w') {
-        /* Write a very simple .gz header:
-         */
-        fprintf(s->file, "%c%c%c%c%c%c%c%c%c%c", gz_magic[0], gz_magic[1],
-             Z_DEFLATED, 0 /*flags*/, 0,0,0,0 /*time*/, 0 /*xflags*/, OS_CODE);
-        s->start = 10L;
-        /* We use 10L instead of ftell(s->file) to because ftell causes an
-         * fflush on some systems. This version of the library doesn't use
-         * start anyway in write mode, so this initialization is not
-         * necessary.
-         */
-    } else {
-        check_header(s); /* skip the .gz header */
-        s->start = ftell(s->file) - s->stream.avail_in;
-    }
-
-    return (gzFile)s;
-}
-
-/* ===========================================================================
-     Opens a gzip (.gz) file for reading or writing.
-*/
-gzFile ZEXPORT gzopen (path, mode)
-    const char *path;
-    const char *mode;
-{
-    return gz_open (path, mode, -1);
-}
-
-/* ===========================================================================
-     Associate a gzFile with the file descriptor fd. fd is not dup'ed here
-   to mimic the behavio(u)r of fdopen.
-*/
-gzFile ZEXPORT gzdopen (fd, mode)
-    int fd;
-    const char *mode;
-{
-    char name[46];      /* allow for up to 128-bit integers */
-
-    if (fd < 0) return (gzFile)Z_NULL;
-    sprintf(name, "<fd:%d>", fd); /* for debugging */
-
-    return gz_open (name, mode, fd);
-}
-
-/* ===========================================================================
- * Update the compression level and strategy
- */
-int ZEXPORT gzsetparams (file, level, strategy)
-    gzFile file;
-    int level;
-    int strategy;
-{
-    gz_stream *s = (gz_stream*)file;
-
-    if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR;
-
-    /* Make room to allow flushing */
-    if (s->stream.avail_out == 0) {
-
-        s->stream.next_out = s->outbuf;
-        if (fwrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) {
-            s->z_err = Z_ERRNO;
-        }
-        s->stream.avail_out = Z_BUFSIZE;
-    }
-
-    return deflateParams (&(s->stream), level, strategy);
-}
-
-/* ===========================================================================
-     Read a byte from a gz_stream; update next_in and avail_in. Return EOF
-   for end of file.
-   IN assertion: the stream s has been sucessfully opened for reading.
-*/
-local int get_byte(s)
-    gz_stream *s;
-{
-    if (s->z_eof) return EOF;
-    if (s->stream.avail_in == 0) {
-        errno = 0;
-        s->stream.avail_in = (uInt)fread(s->inbuf, 1, Z_BUFSIZE, s->file);
-        if (s->stream.avail_in == 0) {
-            s->z_eof = 1;
-            if (ferror(s->file)) s->z_err = Z_ERRNO;
-            return EOF;
-        }
-        s->stream.next_in = s->inbuf;
-    }
-    s->stream.avail_in--;
-    return *(s->stream.next_in)++;
-}
-
-/* ===========================================================================
-      Check the gzip header of a gz_stream opened for reading. Set the stream
-    mode to transparent if the gzip magic header is not present; set s->err
-    to Z_DATA_ERROR if the magic header is present but the rest of the header
-    is incorrect.
-    IN assertion: the stream s has already been created sucessfully;
-       s->stream.avail_in is zero for the first time, but may be non-zero
-       for concatenated .gz files.
-*/
-local void check_header(s)
-    gz_stream *s;
-{
-    int method; /* method byte */
-    int flags;  /* flags byte */
-    uInt len;
-    int c;
-
-    /* Assure two bytes in the buffer so we can peek ahead -- handle case
-       where first byte of header is at the end of the buffer after the last
-       gzip segment */
-    len = s->stream.avail_in;
-    if (len < 2) {
-        if (len) s->inbuf[0] = s->stream.next_in[0];
-        errno = 0;
-        len = (uInt)fread(s->inbuf + len, 1, Z_BUFSIZE >> len, s->file);
-        if (len == 0 && ferror(s->file)) s->z_err = Z_ERRNO;
-        s->stream.avail_in += len;
-        s->stream.next_in = s->inbuf;
-        if (s->stream.avail_in < 2) {
-            s->transparent = s->stream.avail_in;
-            return;
-        }
-    }
-
-    /* Peek ahead to check the gzip magic header */
-    if (s->stream.next_in[0] != gz_magic[0] ||
-        s->stream.next_in[1] != gz_magic[1]) {
-        s->transparent = 1;
-        return;
-    }
-    s->stream.avail_in -= 2;
-    s->stream.next_in += 2;
-
-    /* Check the rest of the gzip header */
-    method = get_byte(s);
-    flags = get_byte(s);
-    if (method != Z_DEFLATED || (flags & RESERVED) != 0) {
-        s->z_err = Z_DATA_ERROR;
-        return;
-    }
-
-    /* Discard time, xflags and OS code: */
-    for (len = 0; len < 6; len++) (void)get_byte(s);
-
-    if ((flags & EXTRA_FIELD) != 0) { /* skip the extra field */
-        len  =  (uInt)get_byte(s);
-        len += ((uInt)get_byte(s))<<8;
-        /* len is garbage if EOF but the loop below will quit anyway */
-        while (len-- != 0 && get_byte(s) != EOF) ;
-    }
-    if ((flags & ORIG_NAME) != 0) { /* skip the original file name */
-        while ((c = get_byte(s)) != 0 && c != EOF) ;
-    }
-    if ((flags & COMMENT) != 0) {   /* skip the .gz file comment */
-        while ((c = get_byte(s)) != 0 && c != EOF) ;
-    }
-    if ((flags & HEAD_CRC) != 0) {  /* skip the header crc */
-        for (len = 0; len < 2; len++) (void)get_byte(s);
-    }
-    s->z_err = s->z_eof ? Z_DATA_ERROR : Z_OK;
-}
-
- /* ===========================================================================
- * Cleanup then free the given gz_stream. Return a zlib error code.
-   Try freeing in the reverse order of allocations.
- */
-local int destroy (s)
-    gz_stream *s;
-{
-    int err = Z_OK;
-
-    if (!s) return Z_STREAM_ERROR;
-
-    TRYFREE(s->msg);
-
-    if (s->stream.state != NULL) {
-        if (s->mode == 'w') {
-#ifdef NO_GZCOMPRESS
-            err = Z_STREAM_ERROR;
-#else
-            err = deflateEnd(&(s->stream));
-#endif
-        } else if (s->mode == 'r') {
-            err = inflateEnd(&(s->stream));
-        }
-    }
-    if (s->file != NULL && fclose(s->file)) {
-#ifdef ESPIPE
-        if (errno != ESPIPE) /* fclose is broken for pipes in HP/UX */
-#endif
-            err = Z_ERRNO;
-    }
-    if (s->z_err < 0) err = s->z_err;
-
-    TRYFREE(s->inbuf);
-    TRYFREE(s->outbuf);
-    TRYFREE(s->path);
-    TRYFREE(s);
-    return err;
-}
-
-/* ===========================================================================
-     Reads the given number of uncompressed bytes from the compressed file.
-   gzread returns the number of bytes actually read (0 for end of file).
-*/
-int ZEXPORT gzread (file, buf, len)
-    gzFile file;
-    voidp buf;
-    unsigned len;
-{
-    gz_stream *s = (gz_stream*)file;
-    Bytef *start = (Bytef*)buf; /* starting point for crc computation */
-    Byte  *next_out; /* == stream.next_out but not forced far (for MSDOS) */
-
-    if (s == NULL || s->mode != 'r') return Z_STREAM_ERROR;
-
-    if (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO) return -1;
-    if (s->z_err == Z_STREAM_END) return 0;  /* EOF */
-
-    next_out = (Byte*)buf;
-    s->stream.next_out = (Bytef*)buf;
-    s->stream.avail_out = len;
-
-    if (s->stream.avail_out && s->back != EOF) {
-        *next_out++ = s->back;
-        s->stream.next_out++;
-        s->stream.avail_out--;
-        s->back = EOF;
-        s->out++;
-        start++;
-        if (s->last) {
-            s->z_err = Z_STREAM_END;
-            return 1;
-        }
-    }
-
-    while (s->stream.avail_out != 0) {
-
-        if (s->transparent) {
-            /* Copy first the lookahead bytes: */
-            uInt n = s->stream.avail_in;
-            if (n > s->stream.avail_out) n = s->stream.avail_out;
-            if (n > 0) {
-                zmemcpy(s->stream.next_out, s->stream.next_in, n);
-                next_out += n;
-                s->stream.next_out = next_out;
-                s->stream.next_in   += n;
-                s->stream.avail_out -= n;
-                s->stream.avail_in  -= n;
-            }
-            if (s->stream.avail_out > 0) {
-                s->stream.avail_out -=
-                    (uInt)fread(next_out, 1, s->stream.avail_out, s->file);
-            }
-            len -= s->stream.avail_out;
-            s->in  += len;
-            s->out += len;
-            if (len == 0) s->z_eof = 1;
-            return (int)len;
-        }
-        if (s->stream.avail_in == 0 && !s->z_eof) {
-
-            errno = 0;
-            s->stream.avail_in = (uInt)fread(s->inbuf, 1, Z_BUFSIZE, s->file);
-            if (s->stream.avail_in == 0) {
-                s->z_eof = 1;
-                if (ferror(s->file)) {
-                    s->z_err = Z_ERRNO;
-                    break;
-                }
-            }
-            s->stream.next_in = s->inbuf;
-        }
-        s->in += s->stream.avail_in;
-        s->out += s->stream.avail_out;
-        s->z_err = inflate(&(s->stream), Z_NO_FLUSH);
-        s->in -= s->stream.avail_in;
-        s->out -= s->stream.avail_out;
-
-        if (s->z_err == Z_STREAM_END) {
-            /* Check CRC and original size */
-            s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start));
-            start = s->stream.next_out;
-
-            if (getLong(s) != s->crc) {
-                s->z_err = Z_DATA_ERROR;
-            } else {
-                (void)getLong(s);
-                /* The uncompressed length returned by above getlong() may be
-                 * different from s->out in case of concatenated .gz files.
-                 * Check for such files:
-                 */
-                check_header(s);
-                if (s->z_err == Z_OK) {
-                    inflateReset(&(s->stream));
-                    s->crc = crc32(0L, Z_NULL, 0);
-                }
-            }
-        }
-        if (s->z_err != Z_OK || s->z_eof) break;
-    }
-    s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start));
-
-    if (len == s->stream.avail_out &&
-        (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO))
-        return -1;
-    return (int)(len - s->stream.avail_out);
-}
-
-
-/* ===========================================================================
-      Reads one byte from the compressed file. gzgetc returns this byte
-   or -1 in case of end of file or error.
-*/
-int ZEXPORT gzgetc(file)
-    gzFile file;
-{
-    unsigned char c;
-
-    return gzread(file, &c, 1) == 1 ? c : -1;
-}
-
-
-/* ===========================================================================
-      Push one byte back onto the stream.
-*/
-int ZEXPORT gzungetc(c, file)
-    int c;
-    gzFile file;
-{
-    gz_stream *s = (gz_stream*)file;
-
-    if (s == NULL || s->mode != 'r' || c == EOF || s->back != EOF) return EOF;
-    s->back = c;
-    s->out--;
-    s->last = (s->z_err == Z_STREAM_END);
-    if (s->last) s->z_err = Z_OK;
-    s->z_eof = 0;
-    return c;
-}
-
-
-/* ===========================================================================
-      Reads bytes from the compressed file until len-1 characters are
-   read, or a newline character is read and transferred to buf, or an
-   end-of-file condition is encountered.  The string is then terminated
-   with a null character.
-      gzgets returns buf, or Z_NULL in case of error.
-
-      The current implementation is not optimized at all.
-*/
-char * ZEXPORT gzgets(file, buf, len)
-    gzFile file;
-    char *buf;
-    int len;
-{
-    char *b = buf;
-    if (buf == Z_NULL || len <= 0) return Z_NULL;
-
-    while (--len > 0 && gzread(file, buf, 1) == 1 && *buf++ != '\n') ;
-    *buf = '\0';
-    return b == buf && len > 0 ? Z_NULL : b;
-}
-
-
-#ifndef NO_GZCOMPRESS
-/* ===========================================================================
-     Writes the given number of uncompressed bytes into the compressed file.
-   gzwrite returns the number of bytes actually written (0 in case of error).
-*/
-int ZEXPORT gzwrite (file, buf, len)
-    gzFile file;
-    voidpc buf;
-    unsigned len;
-{
-    gz_stream *s = (gz_stream*)file;
-
-    if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR;
-
-    s->stream.next_in = (Bytef*)buf;
-    s->stream.avail_in = len;
-
-    while (s->stream.avail_in != 0) {
-
-        if (s->stream.avail_out == 0) {
-
-            s->stream.next_out = s->outbuf;
-            if (fwrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) {
-                s->z_err = Z_ERRNO;
-                break;
-            }
-            s->stream.avail_out = Z_BUFSIZE;
-        }
-        s->in += s->stream.avail_in;
-        s->out += s->stream.avail_out;
-        s->z_err = deflate(&(s->stream), Z_NO_FLUSH);
-        s->in -= s->stream.avail_in;
-        s->out -= s->stream.avail_out;
-        if (s->z_err != Z_OK) break;
-    }
-    s->crc = crc32(s->crc, (const Bytef *)buf, len);
-
-    return (int)(len - s->stream.avail_in);
-}
-
-
-/* ===========================================================================
-     Converts, formats, and writes the args to the compressed file under
-   control of the format string, as in fprintf. gzprintf returns the number of
-   uncompressed bytes actually written (0 in case of error).
-*/
-#ifdef STDC
-#include <stdarg.h>
-
-int ZEXPORTVA gzprintf (gzFile file, const char *format, /* args */ ...)
-{
-    char buf[Z_PRINTF_BUFSIZE];
-    va_list va;
-    int len;
-
-    buf[sizeof(buf) - 1] = 0;
-    va_start(va, format);
-#ifdef NO_vsnprintf
-#  ifdef HAS_vsprintf_void
-    (void)vsprintf(buf, format, va);
-    va_end(va);
-    for (len = 0; len < sizeof(buf); len++)
-        if (buf[len] == 0) break;
-#  else
-    len = vsprintf(buf, format, va);
-    va_end(va);
-#  endif
-#else
-#  ifdef HAS_vsnprintf_void
-    (void)vsnprintf(buf, sizeof(buf), format, va);
-    va_end(va);
-    len = strlen(buf);
-#  else
-    len = vsnprintf(buf, sizeof(buf), format, va);
-    va_end(va);
-#  endif
-#endif
-    if (len <= 0 || len >= (int)sizeof(buf) || buf[sizeof(buf) - 1] != 0)
-        return 0;
-    return gzwrite(file, buf, (unsigned)len);
-}
-#else /* not ANSI C */
-
-int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
-                       a11, a12, a13, a14, a15, a16, a17, a18, a19, a20)
-    gzFile file;
-    const char *format;
-    int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
-        a11, a12, a13, a14, a15, a16, a17, a18, a19, a20;
-{
-    char buf[Z_PRINTF_BUFSIZE];
-    int len;
-
-    buf[sizeof(buf) - 1] = 0;
-#ifdef NO_snprintf
-#  ifdef HAS_sprintf_void
-    sprintf(buf, format, a1, a2, a3, a4, a5, a6, a7, a8,
-            a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
-    for (len = 0; len < sizeof(buf); len++)
-        if (buf[len] == 0) break;
-#  else
-    len = sprintf(buf, format, a1, a2, a3, a4, a5, a6, a7, a8,
-                a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
-#  endif
-#else
-#  ifdef HAS_snprintf_void
-    snprintf(buf, sizeof(buf), format, a1, a2, a3, a4, a5, a6, a7, a8,
-             a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
-    len = strlen(buf);
-#  else
-    len = snprintf(buf, sizeof(buf), format, a1, a2, a3, a4, a5, a6, a7, a8,
-                 a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
-#  endif
-#endif
-    if (len <= 0 || len >= sizeof(buf) || buf[sizeof(buf) - 1] != 0)
-        return 0;
-    return gzwrite(file, buf, len);
-}
-#endif
-
-/* ===========================================================================
-      Writes c, converted to an unsigned char, into the compressed file.
-   gzputc returns the value that was written, or -1 in case of error.
-*/
-int ZEXPORT gzputc(file, c)
-    gzFile file;
-    int c;
-{
-    unsigned char cc = (unsigned char) c; /* required for big endian systems */
-
-    return gzwrite(file, &cc, 1) == 1 ? (int)cc : -1;
-}
-
-
-/* ===========================================================================
-      Writes the given null-terminated string to the compressed file, excluding
-   the terminating null character.
-      gzputs returns the number of characters written, or -1 in case of error.
-*/
-int ZEXPORT gzputs(file, s)
-    gzFile file;
-    const char *s;
-{
-    return gzwrite(file, (char*)s, (unsigned)strlen(s));
-}
-
-
-/* ===========================================================================
-     Flushes all pending output into the compressed file. The parameter
-   flush is as in the deflate() function.
-*/
-local int do_flush (file, flush)
-    gzFile file;
-    int flush;
-{
-    uInt len;
-    int done = 0;
-    gz_stream *s = (gz_stream*)file;
-
-    if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR;
-
-    s->stream.avail_in = 0; /* should be zero already anyway */
-
-    for (;;) {
-        len = Z_BUFSIZE - s->stream.avail_out;
-
-        if (len != 0) {
-            if ((uInt)fwrite(s->outbuf, 1, len, s->file) != len) {
-                s->z_err = Z_ERRNO;
-                return Z_ERRNO;
-            }
-            s->stream.next_out = s->outbuf;
-            s->stream.avail_out = Z_BUFSIZE;
-        }
-        if (done) break;
-        s->out += s->stream.avail_out;
-        s->z_err = deflate(&(s->stream), flush);
-        s->out -= s->stream.avail_out;
-
-        /* Ignore the second of two consecutive flushes: */
-        if (len == 0 && s->z_err == Z_BUF_ERROR) s->z_err = Z_OK;
-
-        /* deflate has finished flushing only when it hasn't used up
-         * all the available space in the output buffer:
-         */
-        done = (s->stream.avail_out != 0 || s->z_err == Z_STREAM_END);
-
-        if (s->z_err != Z_OK && s->z_err != Z_STREAM_END) break;
-    }
-    return  s->z_err == Z_STREAM_END ? Z_OK : s->z_err;
-}
-
-int ZEXPORT gzflush (file, flush)
-     gzFile file;
-     int flush;
-{
-    gz_stream *s = (gz_stream*)file;
-    int err = do_flush (file, flush);
-
-    if (err) return err;
-    fflush(s->file);
-    return  s->z_err == Z_STREAM_END ? Z_OK : s->z_err;
-}
-#endif /* NO_GZCOMPRESS */
-
-/* ===========================================================================
-      Sets the starting position for the next gzread or gzwrite on the given
-   compressed file. The offset represents a number of bytes in the
-      gzseek returns the resulting offset location as measured in bytes from
-   the beginning of the uncompressed stream, or -1 in case of error.
-      SEEK_END is not implemented, returns error.
-      In this version of the library, gzseek can be extremely slow.
-*/
-z_off_t ZEXPORT gzseek (file, offset, whence)
-    gzFile file;
-    z_off_t offset;
-    int whence;
-{
-    gz_stream *s = (gz_stream*)file;
-
-    if (s == NULL || whence == SEEK_END ||
-        s->z_err == Z_ERRNO || s->z_err == Z_DATA_ERROR) {
-        return -1L;
-    }
-
-    if (s->mode == 'w') {
-#ifdef NO_GZCOMPRESS
-        return -1L;
-#else
-        if (whence == SEEK_SET) {
-            offset -= s->in;
-        }
-        if (offset < 0) return -1L;
-
-        /* At this point, offset is the number of zero bytes to write. */
-        if (s->inbuf == Z_NULL) {
-            s->inbuf = (Byte*)ALLOC(Z_BUFSIZE); /* for seeking */
-            if (s->inbuf == Z_NULL) return -1L;
-            zmemzero(s->inbuf, Z_BUFSIZE);
-        }
-        while (offset > 0)  {
-            uInt size = Z_BUFSIZE;
-            if (offset < Z_BUFSIZE) size = (uInt)offset;
-
-            size = gzwrite(file, s->inbuf, size);
-            if (size == 0) return -1L;
-
-            offset -= size;
-        }
-        return s->in;
-#endif
-    }
-    /* Rest of function is for reading only */
-
-    /* compute absolute position */
-    if (whence == SEEK_CUR) {
-        offset += s->out;
-    }
-    if (offset < 0) return -1L;
-
-    if (s->transparent) {
-        /* map to fseek */
-        s->back = EOF;
-        s->stream.avail_in = 0;
-        s->stream.next_in = s->inbuf;
-        if (fseek(s->file, offset, SEEK_SET) < 0) return -1L;
-
-        s->in = s->out = offset;
-        return offset;
-    }
-
-    /* For a negative seek, rewind and use positive seek */
-    if (offset >= s->out) {
-        offset -= s->out;
-    } else if (gzrewind(file) < 0) {
-        return -1L;
-    }
-    /* offset is now the number of bytes to skip. */
-
-    if (offset != 0 && s->outbuf == Z_NULL) {
-        s->outbuf = (Byte*)ALLOC(Z_BUFSIZE);
-        if (s->outbuf == Z_NULL) return -1L;
-    }
-    if (offset && s->back != EOF) {
-        s->back = EOF;
-        s->out++;
-        offset--;
-        if (s->last) s->z_err = Z_STREAM_END;
-    }
-    while (offset > 0)  {
-        int size = Z_BUFSIZE;
-        if (offset < Z_BUFSIZE) size = (int)offset;
-
-        size = gzread(file, s->outbuf, (uInt)size);
-        if (size <= 0) return -1L;
-        offset -= size;
-    }
-    return s->out;
-}
-
-/* ===========================================================================
-     Rewinds input file.
-*/
-int ZEXPORT gzrewind (file)
-    gzFile file;
-{
-    gz_stream *s = (gz_stream*)file;
-
-    if (s == NULL || s->mode != 'r') return -1;
-
-    s->z_err = Z_OK;
-    s->z_eof = 0;
-    s->back = EOF;
-    s->stream.avail_in = 0;
-    s->stream.next_in = s->inbuf;
-    s->crc = crc32(0L, Z_NULL, 0);
-    if (!s->transparent) (void)inflateReset(&s->stream);
-    s->in = 0;
-    s->out = 0;
-    return fseek(s->file, s->start, SEEK_SET);
-}
-
-/* ===========================================================================
-     Returns the starting position for the next gzread or gzwrite on the
-   given compressed file. This position represents a number of bytes in the
-   uncompressed data stream.
-*/
-z_off_t ZEXPORT gztell (file)
-    gzFile file;
-{
-    return gzseek(file, 0L, SEEK_CUR);
-}
-
-/* ===========================================================================
-     Returns 1 when EOF has previously been detected reading the given
-   input stream, otherwise zero.
-*/
-int ZEXPORT gzeof (file)
-    gzFile file;
-{
-    gz_stream *s = (gz_stream*)file;
-
-    /* With concatenated compressed files that can have embedded
-     * crc trailers, z_eof is no longer the only/best indicator of EOF
-     * on a gz_stream. Handle end-of-stream error explicitly here.
-     */
-    if (s == NULL || s->mode != 'r') return 0;
-    if (s->z_eof) return 1;
-    return s->z_err == Z_STREAM_END;
-}
-
-/* ===========================================================================
-     Returns 1 if reading and doing so transparently, otherwise zero.
-*/
-int ZEXPORT gzdirect (file)
-    gzFile file;
-{
-    gz_stream *s = (gz_stream*)file;
-
-    if (s == NULL || s->mode != 'r') return 0;
-    return s->transparent;
-}
-
-/* ===========================================================================
-   Outputs a long in LSB order to the given file
-*/
-local void putLong (file, x)
-    FILE *file;
-    uLong x;
-{
-    int n;
-    for (n = 0; n < 4; n++) {
-        fputc((int)(x & 0xff), file);
-        x >>= 8;
-    }
-}
-
-/* ===========================================================================
-   Reads a long in LSB order from the given gz_stream. Sets z_err in case
-   of error.
-*/
-local uLong getLong (s)
-    gz_stream *s;
-{
-    uLong x = (uLong)get_byte(s);
-    int c;
-
-    x += ((uLong)get_byte(s))<<8;
-    x += ((uLong)get_byte(s))<<16;
-    c = get_byte(s);
-    if (c == EOF) s->z_err = Z_DATA_ERROR;
-    x += ((uLong)c)<<24;
-    return x;
-}
-
-/* ===========================================================================
-     Flushes all pending output if necessary, closes the compressed file
-   and deallocates all the (de)compression state.
-*/
-int ZEXPORT gzclose (file)
-    gzFile file;
-{
-    gz_stream *s = (gz_stream*)file;
-
-    if (s == NULL) return Z_STREAM_ERROR;
-
-    if (s->mode == 'w') {
-#ifdef NO_GZCOMPRESS
-        return Z_STREAM_ERROR;
-#else
-        if (do_flush (file, Z_FINISH) != Z_OK)
-            return destroy((gz_stream*)file);
-
-        putLong (s->file, s->crc);
-        putLong (s->file, (uLong)(s->in & 0xffffffff));
-#endif
-    }
-    return destroy((gz_stream*)file);
-}
-
-#ifdef STDC
-#  define zstrerror(errnum) strerror(errnum)
-#else
-#  define zstrerror(errnum) ""
-#endif
-
-/* ===========================================================================
-     Returns the error message for the last error which occurred on the
-   given compressed file. errnum is set to zlib error number. If an
-   error occurred in the file system and not in the compression library,
-   errnum is set to Z_ERRNO and the application may consult errno
-   to get the exact error code.
-*/
-const char * ZEXPORT gzerror (file, errnum)
-    gzFile file;
-    int *errnum;
-{
-    char *m;
-    gz_stream *s = (gz_stream*)file;
-
-    if (s == NULL) {
-        *errnum = Z_STREAM_ERROR;
-        return (const char*)ERR_MSG(Z_STREAM_ERROR);
-    }
-    *errnum = s->z_err;
-    if (*errnum == Z_OK) return (const char*)"";
-
-    m = (char*)(*errnum == Z_ERRNO ? zstrerror(errno) : s->stream.msg);
-
-    if (m == NULL || *m == '\0') m = (char*)ERR_MSG(s->z_err);
-
-    TRYFREE(s->msg);
-    s->msg = (char*)ALLOC(strlen(s->path) + strlen(m) + 3);
-    if (s->msg == Z_NULL) return (const char*)ERR_MSG(Z_MEM_ERROR);
-    strcpy(s->msg, s->path);
-    strcat(s->msg, ": ");
-    strcat(s->msg, m);
-    return (const char*)s->msg;
-}
-
-/* ===========================================================================
-     Clear the error and end-of-file flags, and do the same for the real file.
-*/
-void ZEXPORT gzclearerr (file)
-    gzFile file;
-{
-    gz_stream *s = (gz_stream*)file;
-
-    if (s == NULL) return;
-    if (s->z_err != Z_STREAM_END) s->z_err = Z_OK;
-    s->z_eof = 0;
-    clearerr(s->file);
-}
diff --git a/jdk/src/share/native/java/util/zip/zlib-1.2.3/patches/crc32.c.diff b/jdk/src/share/native/java/util/zip/zlib-1.2.3/patches/crc32.c.diff
deleted file mode 100644
index 6bd57b9..0000000
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/patches/crc32.c.diff
+++ /dev/null
@@ -1,25 +0,0 @@
---- /home/sherman/TL/zlib-1.2.3_ORG/crc32.c	Sun Jun 12 16:56:07 2005
-+++ zcrc32.c	Tue Aug 25 14:22:41 2009
-@@ -216,8 +216,8 @@
- #define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1
- 
- /* ========================================================================= */
--unsigned long ZEXPORT crc32(crc, buf, len)
--    unsigned long crc;
-+uLong ZEXPORT crc32(crc, buf, len)
-+    uLong crc;
-     const unsigned char FAR *buf;
-     unsigned len;
- {
-@@ -234,9 +234,9 @@
- 
-         endian = 1;
-         if (*((unsigned char *)(&endian)))
--            return crc32_little(crc, buf, len);
-+            return (uLong)crc32_little(crc, buf, len);
-         else
--            return crc32_big(crc, buf, len);
-+            return (uLong)crc32_big(crc, buf, len);
-     }
- #endif /* BYFOUR */
-     crc = crc ^ 0xffffffffUL;
diff --git a/jdk/src/share/native/java/util/zip/zlib-1.2.3/patches/inflate.c.diff b/jdk/src/share/native/java/util/zip/zlib-1.2.3/patches/inflate.c.diff
deleted file mode 100644
index 1280ac8..0000000
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/patches/inflate.c.diff
+++ /dev/null
@@ -1,11 +0,0 @@
---- /home/sherman/TL/zlib-1.2.3_ORG/inflate.c	Tue Jun 14 14:50:12 2005
-+++ inflate.c	Tue Aug 25 14:22:09 2009
-@@ -1263,7 +1263,7 @@
- z_streamp strm;
- {
-     unsigned len;               /* number of bytes to look at or looked at */
--    unsigned long in, out;      /* temporary to save total_in and total_out */
-+    long long in, out;          /* temporary to save total_in and total_out */
-     unsigned char buf[4];       /* to restore bit buffer to byte string */
-     struct inflate_state FAR *state;
- 
diff --git a/jdk/src/share/native/java/util/zip/zlib-1.2.3/patches/zconf.h.diff b/jdk/src/share/native/java/util/zip/zlib-1.2.3/patches/zconf.h.diff
deleted file mode 100644
index 04edcb2..0000000
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/patches/zconf.h.diff
+++ /dev/null
@@ -1,24 +0,0 @@
---- /home/sherman/TL/zlib-1.2.3_ORG/zconf.h	Fri May 27 23:40:35 2005
-+++ zconf.h	Tue Aug 25 14:22:28 2009
-@@ -8,6 +8,9 @@
- #ifndef ZCONF_H
- #define ZCONF_H
- 
-+/* for _LP64 */
-+#include <sys/types.h>
-+
- /*
-  * If you *really* need a unique prefix for all types and library functions,
-  * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
-@@ -261,7 +264,11 @@
- typedef unsigned char  Byte;  /* 8 bits */
- #endif
- typedef unsigned int   uInt;  /* 16 bits or more */
-+#ifdef _LP64
-+typedef unsigned int  uLong;  /* 32 bits or more */
-+#else
- typedef unsigned long  uLong; /* 32 bits or more */
-+#endif
- 
- #ifdef SMALL_MEDIUM
-    /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
diff --git a/jdk/src/share/native/java/util/zip/zlib-1.2.3/patches/zlib.h.diff b/jdk/src/share/native/java/util/zip/zlib-1.2.3/patches/zlib.h.diff
deleted file mode 100644
index 043f4ed..0000000
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/patches/zlib.h.diff
+++ /dev/null
@@ -1,25 +0,0 @@
---- /home/sherman/TL/zlib-1.2.3_ORG/zlib.h	Sun Jul 17 19:26:49 2005
-+++ zlib.h	Tue Aug 25 14:22:50 2009
-@@ -82,11 +82,11 @@
- typedef struct z_stream_s {
-     Bytef    *next_in;  /* next input byte */
-     uInt     avail_in;  /* number of bytes available at next_in */
--    uLong    total_in;  /* total nb of input bytes read so far */
-+    long long total_in; /* total nb of input bytes read so far */
- 
-     Bytef    *next_out; /* next output byte should be put there */
-     uInt     avail_out; /* remaining free space at next_out */
--    uLong    total_out; /* total nb of bytes output so far */
-+    long long total_out;/* total nb of bytes output so far */
- 
-     char     *msg;      /* last error message, NULL if no error */
-     struct internal_state FAR *state; /* not visible by applications */
-@@ -1348,7 +1348,7 @@
- 
- ZEXTERN const char   * ZEXPORT zError           OF((int));
- ZEXTERN int            ZEXPORT inflateSyncPoint OF((z_streamp z));
--ZEXTERN const uLongf * ZEXPORT get_crc_table    OF((void));
-+ZEXTERN const unsigned long FAR * ZEXPORT get_crc_table    OF((void));
- 
- #ifdef __cplusplus
- }
diff --git a/jdk/src/share/native/java/util/zip/zlib-1.2.3/zlib.h b/jdk/src/share/native/java/util/zip/zlib-1.2.3/zlib.h
deleted file mode 100644
index 518b31a..0000000
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/zlib.h
+++ /dev/null
@@ -1,1381 +0,0 @@
-/*
- * 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.
- */
-
-/* zlib.h -- interface of the 'zlib' general purpose compression library
-  version 1.2.3, July 18th, 2005
-
-  Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler
-
-  This software is provided 'as-is', without any express or implied
-  warranty.  In no event will the authors be held liable for any damages
-  arising from the use of this software.
-
-  Permission is granted to anyone to use this software for any purpose,
-  including commercial applications, and to alter it and redistribute it
-  freely, subject to the following restrictions:
-
-  1. The origin of this software must not be misrepresented; you must not
-     claim that you wrote the original software. If you use this software
-     in a product, an acknowledgment in the product documentation would be
-     appreciated but is not required.
-  2. Altered source versions must be plainly marked as such, and must not be
-     misrepresented as being the original software.
-  3. This notice may not be removed or altered from any source distribution.
-
-  Jean-loup Gailly        Mark Adler
-  jloup@gzip.org          madler@alumni.caltech.edu
-
-
-  The data format used by the zlib library is described by RFCs (Request for
-  Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt
-  (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).
-*/
-
-#ifndef ZLIB_H
-#define ZLIB_H
-
-#include "zconf.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define ZLIB_VERSION "1.2.3"
-#define ZLIB_VERNUM 0x1230
-
-/*
-     The 'zlib' compression library provides in-memory compression and
-  decompression functions, including integrity checks of the uncompressed
-  data.  This version of the library supports only one compression method
-  (deflation) but other algorithms will be added later and will have the same
-  stream interface.
-
-     Compression can be done in a single step if the buffers are large
-  enough (for example if an input file is mmap'ed), or can be done by
-  repeated calls of the compression function.  In the latter case, the
-  application must provide more input and/or consume the output
-  (providing more output space) before each call.
-
-     The compressed data format used by default by the in-memory functions is
-  the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped
-  around a deflate stream, which is itself documented in RFC 1951.
-
-     The library also supports reading and writing files in gzip (.gz) format
-  with an interface similar to that of stdio using the functions that start
-  with "gz".  The gzip format is different from the zlib format.  gzip is a
-  gzip wrapper, documented in RFC 1952, wrapped around a deflate stream.
-
-     This library can optionally read and write gzip streams in memory as well.
-
-     The zlib format was designed to be compact and fast for use in memory
-  and on communications channels.  The gzip format was designed for single-
-  file compression on file systems, has a larger header than zlib to maintain
-  directory information, and uses a different, slower check method than zlib.
-
-     The library does not install any signal handler. The decoder checks
-  the consistency of the compressed data, so the library should never
-  crash even in case of corrupted input.
-*/
-
-typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
-typedef void   (*free_func)  OF((voidpf opaque, voidpf address));
-
-struct internal_state;
-
-typedef struct z_stream_s {
-    Bytef    *next_in;  /* next input byte */
-    uInt     avail_in;  /* number of bytes available at next_in */
-    long long total_in; /* total nb of input bytes read so far */
-
-    Bytef    *next_out; /* next output byte should be put there */
-    uInt     avail_out; /* remaining free space at next_out */
-    long long total_out;/* total nb of bytes output so far */
-
-    char     *msg;      /* last error message, NULL if no error */
-    struct internal_state FAR *state; /* not visible by applications */
-
-    alloc_func zalloc;  /* used to allocate the internal state */
-    free_func  zfree;   /* used to free the internal state */
-    voidpf     opaque;  /* private data object passed to zalloc and zfree */
-
-    int     data_type;  /* best guess about the data type: binary or text */
-    uLong   adler;      /* adler32 value of the uncompressed data */
-    uLong   reserved;   /* reserved for future use */
-} z_stream;
-
-typedef z_stream FAR *z_streamp;
-
-/*
-     gzip header information passed to and from zlib routines.  See RFC 1952
-  for more details on the meanings of these fields.
-*/
-typedef struct gz_header_s {
-    int     text;       /* true if compressed data believed to be text */
-    uLong   time;       /* modification time */
-    int     xflags;     /* extra flags (not used when writing a gzip file) */
-    int     os;         /* operating system */
-    Bytef   *extra;     /* pointer to extra field or Z_NULL if none */
-    uInt    extra_len;  /* extra field length (valid if extra != Z_NULL) */
-    uInt    extra_max;  /* space at extra (only when reading header) */
-    Bytef   *name;      /* pointer to zero-terminated file name or Z_NULL */
-    uInt    name_max;   /* space at name (only when reading header) */
-    Bytef   *comment;   /* pointer to zero-terminated comment or Z_NULL */
-    uInt    comm_max;   /* space at comment (only when reading header) */
-    int     hcrc;       /* true if there was or will be a header crc */
-    int     done;       /* true when done reading gzip header (not used
-                           when writing a gzip file) */
-} gz_header;
-
-typedef gz_header FAR *gz_headerp;
-
-/*
-   The application must update next_in and avail_in when avail_in has
-   dropped to zero. It must update next_out and avail_out when avail_out
-   has dropped to zero. The application must initialize zalloc, zfree and
-   opaque before calling the init function. All other fields are set by the
-   compression library and must not be updated by the application.
-
-   The opaque value provided by the application will be passed as the first
-   parameter for calls of zalloc and zfree. This can be useful for custom
-   memory management. The compression library attaches no meaning to the
-   opaque value.
-
-   zalloc must return Z_NULL if there is not enough memory for the object.
-   If zlib is used in a multi-threaded application, zalloc and zfree must be
-   thread safe.
-
-   On 16-bit systems, the functions zalloc and zfree must be able to allocate
-   exactly 65536 bytes, but will not be required to allocate more than this
-   if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS,
-   pointers returned by zalloc for objects of exactly 65536 bytes *must*
-   have their offset normalized to zero. The default allocation function
-   provided by this library ensures this (see zutil.c). To reduce memory
-   requirements and avoid any allocation of 64K objects, at the expense of
-   compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h).
-
-   The fields total_in and total_out can be used for statistics or
-   progress reports. After compression, total_in holds the total size of
-   the uncompressed data and may be saved for use in the decompressor
-   (particularly if the decompressor wants to decompress everything in
-   a single step).
-*/
-
-                        /* constants */
-
-#define Z_NO_FLUSH      0
-#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */
-#define Z_SYNC_FLUSH    2
-#define Z_FULL_FLUSH    3
-#define Z_FINISH        4
-#define Z_BLOCK         5
-/* Allowed flush values; see deflate() and inflate() below for details */
-
-#define Z_OK            0
-#define Z_STREAM_END    1
-#define Z_NEED_DICT     2
-#define Z_ERRNO        (-1)
-#define Z_STREAM_ERROR (-2)
-#define Z_DATA_ERROR   (-3)
-#define Z_MEM_ERROR    (-4)
-#define Z_BUF_ERROR    (-5)
-#define Z_VERSION_ERROR (-6)
-/* Return codes for the compression/decompression functions. Negative
- * values are errors, positive values are used for special but normal events.
- */
-
-#define Z_NO_COMPRESSION         0
-#define Z_BEST_SPEED             1
-#define Z_BEST_COMPRESSION       9
-#define Z_DEFAULT_COMPRESSION  (-1)
-/* compression levels */
-
-#define Z_FILTERED            1
-#define Z_HUFFMAN_ONLY        2
-#define Z_RLE                 3
-#define Z_FIXED               4
-#define Z_DEFAULT_STRATEGY    0
-/* compression strategy; see deflateInit2() below for details */
-
-#define Z_BINARY   0
-#define Z_TEXT     1
-#define Z_ASCII    Z_TEXT   /* for compatibility with 1.2.2 and earlier */
-#define Z_UNKNOWN  2
-/* Possible values of the data_type field (though see inflate()) */
-
-#define Z_DEFLATED   8
-/* The deflate compression method (the only one supported in this version) */
-
-#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
-
-#define zlib_version zlibVersion()
-/* for compatibility with versions < 1.0.2 */
-
-                        /* basic functions */
-
-ZEXTERN const char * ZEXPORT zlibVersion OF((void));
-/* The application can compare zlibVersion and ZLIB_VERSION for consistency.
-   If the first character differs, the library code actually used is
-   not compatible with the zlib.h header file used by the application.
-   This check is automatically made by deflateInit and inflateInit.
- */
-
-/*
-ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));
-
-     Initializes the internal stream state for compression. The fields
-   zalloc, zfree and opaque must be initialized before by the caller.
-   If zalloc and zfree are set to Z_NULL, deflateInit updates them to
-   use default allocation functions.
-
-     The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:
-   1 gives best speed, 9 gives best compression, 0 gives no compression at
-   all (the input data is simply copied a block at a time).
-   Z_DEFAULT_COMPRESSION requests a default compromise between speed and
-   compression (currently equivalent to level 6).
-
-     deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not
-   enough memory, Z_STREAM_ERROR if level is not a valid compression level,
-   Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible
-   with the version assumed by the caller (ZLIB_VERSION).
-   msg is set to null if there is no error message.  deflateInit does not
-   perform any compression: this will be done by deflate().
-*/
-
-
-ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
-/*
-    deflate compresses as much data as possible, and stops when the input
-  buffer becomes empty or the output buffer becomes full. It may introduce some
-  output latency (reading input without producing any output) except when
-  forced to flush.
-
-    The detailed semantics are as follows. deflate performs one or both of the
-  following actions:
-
-  - Compress more input starting at next_in and update next_in and avail_in
-    accordingly. If not all input can be processed (because there is not
-    enough room in the output buffer), next_in and avail_in are updated and
-    processing will resume at this point for the next call of deflate().
-
-  - Provide more output starting at next_out and update next_out and avail_out
-    accordingly. This action is forced if the parameter flush is non zero.
-    Forcing flush frequently degrades the compression ratio, so this parameter
-    should be set only when necessary (in interactive applications).
-    Some output may be provided even if flush is not set.
-
-  Before the call of deflate(), the application should ensure that at least
-  one of the actions is possible, by providing more input and/or consuming
-  more output, and updating avail_in or avail_out accordingly; avail_out
-  should never be zero before the call. The application can consume the
-  compressed output when it wants, for example when the output buffer is full
-  (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK
-  and with zero avail_out, it must be called again after making room in the
-  output buffer because there might be more output pending.
-
-    Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to
-  decide how much data to accumualte before producing output, in order to
-  maximize compression.
-
-    If the parameter flush is set to Z_SYNC_FLUSH, all pending output is
-  flushed to the output buffer and the output is aligned on a byte boundary, so
-  that the decompressor can get all input data available so far. (In particular
-  avail_in is zero after the call if enough output space has been provided
-  before the call.)  Flushing may degrade compression for some compression
-  algorithms and so it should be used only when necessary.
-
-    If flush is set to Z_FULL_FLUSH, all output is flushed as with
-  Z_SYNC_FLUSH, and the compression state is reset so that decompression can
-  restart from this point if previous compressed data has been damaged or if
-  random access is desired. Using Z_FULL_FLUSH too often can seriously degrade
-  compression.
-
-    If deflate returns with avail_out == 0, this function must be called again
-  with the same value of the flush parameter and more output space (updated
-  avail_out), until the flush is complete (deflate returns with non-zero
-  avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that
-  avail_out is greater than six to avoid repeated flush markers due to
-  avail_out == 0 on return.
-
-    If the parameter flush is set to Z_FINISH, pending input is processed,
-  pending output is flushed and deflate returns with Z_STREAM_END if there
-  was enough output space; if deflate returns with Z_OK, this function must be
-  called again with Z_FINISH and more output space (updated avail_out) but no
-  more input data, until it returns with Z_STREAM_END or an error. After
-  deflate has returned Z_STREAM_END, the only possible operations on the
-  stream are deflateReset or deflateEnd.
-
-    Z_FINISH can be used immediately after deflateInit if all the compression
-  is to be done in a single step. In this case, avail_out must be at least
-  the value returned by deflateBound (see below). If deflate does not return
-  Z_STREAM_END, then it must be called again as described above.
-
-    deflate() sets strm->adler to the adler32 checksum of all input read
-  so far (that is, total_in bytes).
-
-    deflate() may update strm->data_type if it can make a good guess about
-  the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered
-  binary. This field is only for information purposes and does not affect
-  the compression algorithm in any manner.
-
-    deflate() returns Z_OK if some progress has been made (more input
-  processed or more output produced), Z_STREAM_END if all input has been
-  consumed and all output has been produced (only when flush is set to
-  Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example
-  if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible
-  (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not
-  fatal, and deflate() can be called again with more input and more output
-  space to continue compressing.
-*/
-
-
-ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));
-/*
-     All dynamically allocated data structures for this stream are freed.
-   This function discards any unprocessed input and does not flush any
-   pending output.
-
-     deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the
-   stream state was inconsistent, Z_DATA_ERROR if the stream was freed
-   prematurely (some input or output was discarded). In the error case,
-   msg may be set but then points to a static string (which must not be
-   deallocated).
-*/
-
-
-/*
-ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));
-
-     Initializes the internal stream state for decompression. The fields
-   next_in, avail_in, zalloc, zfree and opaque must be initialized before by
-   the caller. If next_in is not Z_NULL and avail_in is large enough (the exact
-   value depends on the compression method), inflateInit determines the
-   compression method from the zlib header and allocates all data structures
-   accordingly; otherwise the allocation will be deferred to the first call of
-   inflate.  If zalloc and zfree are set to Z_NULL, inflateInit updates them to
-   use default allocation functions.
-
-     inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
-   memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
-   version assumed by the caller.  msg is set to null if there is no error
-   message. inflateInit does not perform any decompression apart from reading
-   the zlib header if present: this will be done by inflate().  (So next_in and
-   avail_in may be modified, but next_out and avail_out are unchanged.)
-*/
-
-
-ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
-/*
-    inflate decompresses as much data as possible, and stops when the input
-  buffer becomes empty or the output buffer becomes full. It may introduce
-  some output latency (reading input without producing any output) except when
-  forced to flush.
-
-  The detailed semantics are as follows. inflate performs one or both of the
-  following actions:
-
-  - Decompress more input starting at next_in and update next_in and avail_in
-    accordingly. If not all input can be processed (because there is not
-    enough room in the output buffer), next_in is updated and processing
-    will resume at this point for the next call of inflate().
-
-  - Provide more output starting at next_out and update next_out and avail_out
-    accordingly.  inflate() provides as much output as possible, until there
-    is no more input data or no more space in the output buffer (see below
-    about the flush parameter).
-
-  Before the call of inflate(), the application should ensure that at least
-  one of the actions is possible, by providing more input and/or consuming
-  more output, and updating the next_* and avail_* values accordingly.
-  The application can consume the uncompressed output when it wants, for
-  example when the output buffer is full (avail_out == 0), or after each
-  call of inflate(). If inflate returns Z_OK and with zero avail_out, it
-  must be called again after making room in the output buffer because there
-  might be more output pending.
-
-    The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH,
-  Z_FINISH, or Z_BLOCK. Z_SYNC_FLUSH requests that inflate() flush as much
-  output as possible to the output buffer. Z_BLOCK requests that inflate() stop
-  if and when it gets to the next deflate block boundary. When decoding the
-  zlib or gzip format, this will cause inflate() to return immediately after
-  the header and before the first block. When doing a raw inflate, inflate()
-  will go ahead and process the first block, and will return when it gets to
-  the end of that block, or when it runs out of data.
-
-    The Z_BLOCK option assists in appending to or combining deflate streams.
-  Also to assist in this, on return inflate() will set strm->data_type to the
-  number of unused bits in the last byte taken from strm->next_in, plus 64
-  if inflate() is currently decoding the last block in the deflate stream,
-  plus 128 if inflate() returned immediately after decoding an end-of-block
-  code or decoding the complete header up to just before the first byte of the
-  deflate stream. The end-of-block will not be indicated until all of the
-  uncompressed data from that block has been written to strm->next_out.  The
-  number of unused bits may in general be greater than seven, except when
-  bit 7 of data_type is set, in which case the number of unused bits will be
-  less than eight.
-
-    inflate() should normally be called until it returns Z_STREAM_END or an
-  error. However if all decompression is to be performed in a single step
-  (a single call of inflate), the parameter flush should be set to
-  Z_FINISH. In this case all pending input is processed and all pending
-  output is flushed; avail_out must be large enough to hold all the
-  uncompressed data. (The size of the uncompressed data may have been saved
-  by the compressor for this purpose.) The next operation on this stream must
-  be inflateEnd to deallocate the decompression state. The use of Z_FINISH
-  is never required, but can be used to inform inflate that a faster approach
-  may be used for the single inflate() call.
-
-     In this implementation, inflate() always flushes as much output as
-  possible to the output buffer, and always uses the faster approach on the
-  first call. So the only effect of the flush parameter in this implementation
-  is on the return value of inflate(), as noted below, or when it returns early
-  because Z_BLOCK is used.
-
-     If a preset dictionary is needed after this call (see inflateSetDictionary
-  below), inflate sets strm->adler to the adler32 checksum of the dictionary
-  chosen by the compressor and returns Z_NEED_DICT; otherwise it sets
-  strm->adler to the adler32 checksum of all output produced so far (that is,
-  total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described
-  below. At the end of the stream, inflate() checks that its computed adler32
-  checksum is equal to that saved by the compressor and returns Z_STREAM_END
-  only if the checksum is correct.
-
-    inflate() will decompress and check either zlib-wrapped or gzip-wrapped
-  deflate data.  The header type is detected automatically.  Any information
-  contained in the gzip header is not retained, so applications that need that
-  information should instead use raw inflate, see inflateInit2() below, or
-  inflateBack() and perform their own processing of the gzip header and
-  trailer.
-
-    inflate() returns Z_OK if some progress has been made (more input processed
-  or more output produced), Z_STREAM_END if the end of the compressed data has
-  been reached and all uncompressed output has been produced, Z_NEED_DICT if a
-  preset dictionary is needed at this point, Z_DATA_ERROR if the input data was
-  corrupted (input stream not conforming to the zlib format or incorrect check
-  value), Z_STREAM_ERROR if the stream structure was inconsistent (for example
-  if next_in or next_out was NULL), Z_MEM_ERROR if there was not enough memory,
-  Z_BUF_ERROR if no progress is possible or if there was not enough room in the
-  output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and
-  inflate() can be called again with more input and more output space to
-  continue decompressing. If Z_DATA_ERROR is returned, the application may then
-  call inflateSync() to look for a good compression block if a partial recovery
-  of the data is desired.
-*/
-
-
-ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));
-/*
-     All dynamically allocated data structures for this stream are freed.
-   This function discards any unprocessed input and does not flush any
-   pending output.
-
-     inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state
-   was inconsistent. In the error case, msg may be set but then points to a
-   static string (which must not be deallocated).
-*/
-
-                        /* Advanced functions */
-
-/*
-    The following functions are needed only in some special applications.
-*/
-
-/*
-ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
-                                     int  level,
-                                     int  method,
-                                     int  windowBits,
-                                     int  memLevel,
-                                     int  strategy));
-
-     This is another version of deflateInit with more compression options. The
-   fields next_in, zalloc, zfree and opaque must be initialized before by
-   the caller.
-
-     The method parameter is the compression method. It must be Z_DEFLATED in
-   this version of the library.
-
-     The windowBits parameter is the base two logarithm of the window size
-   (the size of the history buffer). It should be in the range 8..15 for this
-   version of the library. Larger values of this parameter result in better
-   compression at the expense of memory usage. The default value is 15 if
-   deflateInit is used instead.
-
-     windowBits can also be -8..-15 for raw deflate. In this case, -windowBits
-   determines the window size. deflate() will then generate raw deflate data
-   with no zlib header or trailer, and will not compute an adler32 check value.
-
-     windowBits can also be greater than 15 for optional gzip encoding. Add
-   16 to windowBits to write a simple gzip header and trailer around the
-   compressed data instead of a zlib wrapper. The gzip header will have no
-   file name, no extra data, no comment, no modification time (set to zero),
-   no header crc, and the operating system will be set to 255 (unknown).  If a
-   gzip stream is being written, strm->adler is a crc32 instead of an adler32.
-
-     The memLevel parameter specifies how much memory should be allocated
-   for the internal compression state. memLevel=1 uses minimum memory but
-   is slow and reduces compression ratio; memLevel=9 uses maximum memory
-   for optimal speed. The default value is 8. See zconf.h for total memory
-   usage as a function of windowBits and memLevel.
-
-     The strategy parameter is used to tune the compression algorithm. Use the
-   value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a
-   filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no
-   string match), or Z_RLE to limit match distances to one (run-length
-   encoding). Filtered data consists mostly of small values with a somewhat
-   random distribution. In this case, the compression algorithm is tuned to
-   compress them better. The effect of Z_FILTERED is to force more Huffman
-   coding and less string matching; it is somewhat intermediate between
-   Z_DEFAULT and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as fast as
-   Z_HUFFMAN_ONLY, but give better compression for PNG image data. The strategy
-   parameter only affects the compression ratio but not the correctness of the
-   compressed output even if it is not set appropriately.  Z_FIXED prevents the
-   use of dynamic Huffman codes, allowing for a simpler decoder for special
-   applications.
-
-      deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
-   memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid
-   method). msg is set to null if there is no error message.  deflateInit2 does
-   not perform any compression: this will be done by deflate().
-*/
-
-ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
-                                             const Bytef *dictionary,
-                                             uInt  dictLength));
-/*
-     Initializes the compression dictionary from the given byte sequence
-   without producing any compressed output. This function must be called
-   immediately after deflateInit, deflateInit2 or deflateReset, before any
-   call of deflate. The compressor and decompressor must use exactly the same
-   dictionary (see inflateSetDictionary).
-
-     The dictionary should consist of strings (byte sequences) that are likely
-   to be encountered later in the data to be compressed, with the most commonly
-   used strings preferably put towards the end of the dictionary. Using a
-   dictionary is most useful when the data to be compressed is short and can be
-   predicted with good accuracy; the data can then be compressed better than
-   with the default empty dictionary.
-
-     Depending on the size of the compression data structures selected by
-   deflateInit or deflateInit2, a part of the dictionary may in effect be
-   discarded, for example if the dictionary is larger than the window size in
-   deflate or deflate2. Thus the strings most likely to be useful should be
-   put at the end of the dictionary, not at the front. In addition, the
-   current implementation of deflate will use at most the window size minus
-   262 bytes of the provided dictionary.
-
-     Upon return of this function, strm->adler is set to the adler32 value
-   of the dictionary; the decompressor may later use this value to determine
-   which dictionary has been used by the compressor. (The adler32 value
-   applies to the whole dictionary even if only a subset of the dictionary is
-   actually used by the compressor.) If a raw deflate was requested, then the
-   adler32 value is not computed and strm->adler is not set.
-
-     deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a
-   parameter is invalid (such as NULL dictionary) or the stream state is
-   inconsistent (for example if deflate has already been called for this stream
-   or if the compression method is bsort). deflateSetDictionary does not
-   perform any compression: this will be done by deflate().
-*/
-
-ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,
-                                    z_streamp source));
-/*
-     Sets the destination stream as a complete copy of the source stream.
-
-     This function can be useful when several compression strategies will be
-   tried, for example when there are several ways of pre-processing the input
-   data with a filter. The streams that will be discarded should then be freed
-   by calling deflateEnd.  Note that deflateCopy duplicates the internal
-   compression state which can be quite large, so this strategy is slow and
-   can consume lots of memory.
-
-     deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
-   enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
-   (such as zalloc being NULL). msg is left unchanged in both source and
-   destination.
-*/
-
-ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));
-/*
-     This function is equivalent to deflateEnd followed by deflateInit,
-   but does not free and reallocate all the internal compression state.
-   The stream will keep the same compression level and any other attributes
-   that may have been set by deflateInit2.
-
-      deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
-   stream state was inconsistent (such as zalloc or state being NULL).
-*/
-
-ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
-                                      int level,
-                                      int strategy));
-/*
-     Dynamically update the compression level and compression strategy.  The
-   interpretation of level and strategy is as in deflateInit2.  This can be
-   used to switch between compression and straight copy of the input data, or
-   to switch to a different kind of input data requiring a different
-   strategy. If the compression level is changed, the input available so far
-   is compressed with the old level (and may be flushed); the new level will
-   take effect only at the next call of deflate().
-
-     Before the call of deflateParams, the stream state must be set as for
-   a call of deflate(), since the currently available input may have to
-   be compressed and flushed. In particular, strm->avail_out must be non-zero.
-
-     deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source
-   stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR
-   if strm->avail_out was zero.
-*/
-
-ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm,
-                                    int good_length,
-                                    int max_lazy,
-                                    int nice_length,
-                                    int max_chain));
-/*
-     Fine tune deflate's internal compression parameters.  This should only be
-   used by someone who understands the algorithm used by zlib's deflate for
-   searching for the best matching string, and even then only by the most
-   fanatic optimizer trying to squeeze out the last compressed bit for their
-   specific input data.  Read the deflate.c source code for the meaning of the
-   max_lazy, good_length, nice_length, and max_chain parameters.
-
-     deflateTune() can be called after deflateInit() or deflateInit2(), and
-   returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream.
- */
-
-ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm,
-                                       uLong sourceLen));
-/*
-     deflateBound() returns an upper bound on the compressed size after
-   deflation of sourceLen bytes.  It must be called after deflateInit()
-   or deflateInit2().  This would be used to allocate an output buffer
-   for deflation in a single pass, and so would be called before deflate().
-*/
-
-ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm,
-                                     int bits,
-                                     int value));
-/*
-     deflatePrime() inserts bits in the deflate output stream.  The intent
-  is that this function is used to start off the deflate output with the
-  bits leftover from a previous deflate stream when appending to it.  As such,
-  this function can only be used for raw deflate, and must be used before the
-  first deflate() call after a deflateInit2() or deflateReset().  bits must be
-  less than or equal to 16, and that many of the least significant bits of
-  value will be inserted in the output.
-
-      deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source
-   stream state was inconsistent.
-*/
-
-ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm,
-                                         gz_headerp head));
-/*
-      deflateSetHeader() provides gzip header information for when a gzip
-   stream is requested by deflateInit2().  deflateSetHeader() may be called
-   after deflateInit2() or deflateReset() and before the first call of
-   deflate().  The text, time, os, extra field, name, and comment information
-   in the provided gz_header structure are written to the gzip header (xflag is
-   ignored -- the extra flags are set according to the compression level).  The
-   caller must assure that, if not Z_NULL, name and comment are terminated with
-   a zero byte, and that if extra is not Z_NULL, that extra_len bytes are
-   available there.  If hcrc is true, a gzip header crc is included.  Note that
-   the current versions of the command-line version of gzip (up through version
-   1.3.x) do not support header crc's, and will report that it is a "multi-part
-   gzip file" and give up.
-
-      If deflateSetHeader is not used, the default gzip header has text false,
-   the time set to zero, and os set to 255, with no extra, name, or comment
-   fields.  The gzip header is returned to the default state by deflateReset().
-
-      deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source
-   stream state was inconsistent.
-*/
-
-/*
-ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
-                                     int  windowBits));
-
-     This is another version of inflateInit with an extra parameter. The
-   fields next_in, avail_in, zalloc, zfree and opaque must be initialized
-   before by the caller.
-
-     The windowBits parameter is the base two logarithm of the maximum window
-   size (the size of the history buffer).  It should be in the range 8..15 for
-   this version of the library. The default value is 15 if inflateInit is used
-   instead. windowBits must be greater than or equal to the windowBits value
-   provided to deflateInit2() while compressing, or it must be equal to 15 if
-   deflateInit2() was not used. If a compressed stream with a larger window
-   size is given as input, inflate() will return with the error code
-   Z_DATA_ERROR instead of trying to allocate a larger window.
-
-     windowBits can also be -8..-15 for raw inflate. In this case, -windowBits
-   determines the window size. inflate() will then process raw deflate data,
-   not looking for a zlib or gzip header, not generating a check value, and not
-   looking for any check values for comparison at the end of the stream. This
-   is for use with other formats that use the deflate compressed data format
-   such as zip.  Those formats provide their own check values. If a custom
-   format is developed using the raw deflate format for compressed data, it is
-   recommended that a check value such as an adler32 or a crc32 be applied to
-   the uncompressed data as is done in the zlib, gzip, and zip formats.  For
-   most applications, the zlib format should be used as is. Note that comments
-   above on the use in deflateInit2() applies to the magnitude of windowBits.
-
-     windowBits can also be greater than 15 for optional gzip decoding. Add
-   32 to windowBits to enable zlib and gzip decoding with automatic header
-   detection, or add 16 to decode only the gzip format (the zlib format will
-   return a Z_DATA_ERROR).  If a gzip stream is being decoded, strm->adler is
-   a crc32 instead of an adler32.
-
-     inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
-   memory, Z_STREAM_ERROR if a parameter is invalid (such as a null strm). msg
-   is set to null if there is no error message.  inflateInit2 does not perform
-   any decompression apart from reading the zlib header if present: this will
-   be done by inflate(). (So next_in and avail_in may be modified, but next_out
-   and avail_out are unchanged.)
-*/
-
-ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
-                                             const Bytef *dictionary,
-                                             uInt  dictLength));
-/*
-     Initializes the decompression dictionary from the given uncompressed byte
-   sequence. This function must be called immediately after a call of inflate,
-   if that call returned Z_NEED_DICT. The dictionary chosen by the compressor
-   can be determined from the adler32 value returned by that call of inflate.
-   The compressor and decompressor must use exactly the same dictionary (see
-   deflateSetDictionary).  For raw inflate, this function can be called
-   immediately after inflateInit2() or inflateReset() and before any call of
-   inflate() to set the dictionary.  The application must insure that the
-   dictionary that was used for compression is provided.
-
-     inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a
-   parameter is invalid (such as NULL dictionary) or the stream state is
-   inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the
-   expected one (incorrect adler32 value). inflateSetDictionary does not
-   perform any decompression: this will be done by subsequent calls of
-   inflate().
-*/
-
-ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));
-/*
-    Skips invalid compressed data until a full flush point (see above the
-  description of deflate with Z_FULL_FLUSH) can be found, or until all
-  available input is skipped. No output is provided.
-
-    inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR
-  if no more input was provided, Z_DATA_ERROR if no flush point has been found,
-  or Z_STREAM_ERROR if the stream structure was inconsistent. In the success
-  case, the application may save the current current value of total_in which
-  indicates where valid compressed data was found. In the error case, the
-  application may repeatedly call inflateSync, providing more input each time,
-  until success or end of the input data.
-*/
-
-ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest,
-                                    z_streamp source));
-/*
-     Sets the destination stream as a complete copy of the source stream.
-
-     This function can be useful when randomly accessing a large stream.  The
-   first pass through the stream can periodically record the inflate state,
-   allowing restarting inflate at those points when randomly accessing the
-   stream.
-
-     inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
-   enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
-   (such as zalloc being NULL). msg is left unchanged in both source and
-   destination.
-*/
-
-ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));
-/*
-     This function is equivalent to inflateEnd followed by inflateInit,
-   but does not free and reallocate all the internal decompression state.
-   The stream will keep attributes that may have been set by inflateInit2.
-
-      inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
-   stream state was inconsistent (such as zalloc or state being NULL).
-*/
-
-ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm,
-                                     int bits,
-                                     int value));
-/*
-     This function inserts bits in the inflate input stream.  The intent is
-  that this function is used to start inflating at a bit position in the
-  middle of a byte.  The provided bits will be used before any bytes are used
-  from next_in.  This function should only be used with raw inflate, and
-  should be used before the first inflate() call after inflateInit2() or
-  inflateReset().  bits must be less than or equal to 16, and that many of the
-  least significant bits of value will be inserted in the input.
-
-      inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source
-   stream state was inconsistent.
-*/
-
-ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm,
-                                         gz_headerp head));
-/*
-      inflateGetHeader() requests that gzip header information be stored in the
-   provided gz_header structure.  inflateGetHeader() may be called after
-   inflateInit2() or inflateReset(), and before the first call of inflate().
-   As inflate() processes the gzip stream, head->done is zero until the header
-   is completed, at which time head->done is set to one.  If a zlib stream is
-   being decoded, then head->done is set to -1 to indicate that there will be
-   no gzip header information forthcoming.  Note that Z_BLOCK can be used to
-   force inflate() to return immediately after header processing is complete
-   and before any actual data is decompressed.
-
-      The text, time, xflags, and os fields are filled in with the gzip header
-   contents.  hcrc is set to true if there is a header CRC.  (The header CRC
-   was valid if done is set to one.)  If extra is not Z_NULL, then extra_max
-   contains the maximum number of bytes to write to extra.  Once done is true,
-   extra_len contains the actual extra field length, and extra contains the
-   extra field, or that field truncated if extra_max is less than extra_len.
-   If name is not Z_NULL, then up to name_max characters are written there,
-   terminated with a zero unless the length is greater than name_max.  If
-   comment is not Z_NULL, then up to comm_max characters are written there,
-   terminated with a zero unless the length is greater than comm_max.  When
-   any of extra, name, or comment are not Z_NULL and the respective field is
-   not present in the header, then that field is set to Z_NULL to signal its
-   absence.  This allows the use of deflateSetHeader() with the returned
-   structure to duplicate the header.  However if those fields are set to
-   allocated memory, then the application will need to save those pointers
-   elsewhere so that they can be eventually freed.
-
-      If inflateGetHeader is not used, then the header information is simply
-   discarded.  The header is always checked for validity, including the header
-   CRC if present.  inflateReset() will reset the process to discard the header
-   information.  The application would need to call inflateGetHeader() again to
-   retrieve the header from the next gzip stream.
-
-      inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source
-   stream state was inconsistent.
-*/
-
-/*
-ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits,
-                                        unsigned char FAR *window));
-
-     Initialize the internal stream state for decompression using inflateBack()
-   calls.  The fields zalloc, zfree and opaque in strm must be initialized
-   before the call.  If zalloc and zfree are Z_NULL, then the default library-
-   derived memory allocation routines are used.  windowBits is the base two
-   logarithm of the window size, in the range 8..15.  window is a caller
-   supplied buffer of that size.  Except for special applications where it is
-   assured that deflate was used with small window sizes, windowBits must be 15
-   and a 32K byte window must be supplied to be able to decompress general
-   deflate streams.
-
-     See inflateBack() for the usage of these routines.
-
-     inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of
-   the paramaters are invalid, Z_MEM_ERROR if the internal state could not
-   be allocated, or Z_VERSION_ERROR if the version of the library does not
-   match the version of the header file.
-*/
-
-typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *));
-typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned));
-
-ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,
-                                    in_func in, void FAR *in_desc,
-                                    out_func out, void FAR *out_desc));
-/*
-     inflateBack() does a raw inflate with a single call using a call-back
-   interface for input and output.  This is more efficient than inflate() for
-   file i/o applications in that it avoids copying between the output and the
-   sliding window by simply making the window itself the output buffer.  This
-   function trusts the application to not change the output buffer passed by
-   the output function, at least until inflateBack() returns.
-
-     inflateBackInit() must be called first to allocate the internal state
-   and to initialize the state with the user-provided window buffer.
-   inflateBack() may then be used multiple times to inflate a complete, raw
-   deflate stream with each call.  inflateBackEnd() is then called to free
-   the allocated state.
-
-     A raw deflate stream is one with no zlib or gzip header or trailer.
-   This routine would normally be used in a utility that reads zip or gzip
-   files and writes out uncompressed files.  The utility would decode the
-   header and process the trailer on its own, hence this routine expects
-   only the raw deflate stream to decompress.  This is different from the
-   normal behavior of inflate(), which expects either a zlib or gzip header and
-   trailer around the deflate stream.
-
-     inflateBack() uses two subroutines supplied by the caller that are then
-   called by inflateBack() for input and output.  inflateBack() calls those
-   routines until it reads a complete deflate stream and writes out all of the
-   uncompressed data, or until it encounters an error.  The function's
-   parameters and return types are defined above in the in_func and out_func
-   typedefs.  inflateBack() will call in(in_desc, &buf) which should return the
-   number of bytes of provided input, and a pointer to that input in buf.  If
-   there is no input available, in() must return zero--buf is ignored in that
-   case--and inflateBack() will return a buffer error.  inflateBack() will call
-   out(out_desc, buf, len) to write the uncompressed data buf[0..len-1].  out()
-   should return zero on success, or non-zero on failure.  If out() returns
-   non-zero, inflateBack() will return with an error.  Neither in() nor out()
-   are permitted to change the contents of the window provided to
-   inflateBackInit(), which is also the buffer that out() uses to write from.
-   The length written by out() will be at most the window size.  Any non-zero
-   amount of input may be provided by in().
-
-     For convenience, inflateBack() can be provided input on the first call by
-   setting strm->next_in and strm->avail_in.  If that input is exhausted, then
-   in() will be called.  Therefore strm->next_in must be initialized before
-   calling inflateBack().  If strm->next_in is Z_NULL, then in() will be called
-   immediately for input.  If strm->next_in is not Z_NULL, then strm->avail_in
-   must also be initialized, and then if strm->avail_in is not zero, input will
-   initially be taken from strm->next_in[0 .. strm->avail_in - 1].
-
-     The in_desc and out_desc parameters of inflateBack() is passed as the
-   first parameter of in() and out() respectively when they are called.  These
-   descriptors can be optionally used to pass any information that the caller-
-   supplied in() and out() functions need to do their job.
-
-     On return, inflateBack() will set strm->next_in and strm->avail_in to
-   pass back any unused input that was provided by the last in() call.  The
-   return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR
-   if in() or out() returned an error, Z_DATA_ERROR if there was a format
-   error in the deflate stream (in which case strm->msg is set to indicate the
-   nature of the error), or Z_STREAM_ERROR if the stream was not properly
-   initialized.  In the case of Z_BUF_ERROR, an input or output error can be
-   distinguished using strm->next_in which will be Z_NULL only if in() returned
-   an error.  If strm->next is not Z_NULL, then the Z_BUF_ERROR was due to
-   out() returning non-zero.  (in() will always be called before out(), so
-   strm->next_in is assured to be defined if out() returns non-zero.)  Note
-   that inflateBack() cannot return Z_OK.
-*/
-
-ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm));
-/*
-     All memory allocated by inflateBackInit() is freed.
-
-     inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream
-   state was inconsistent.
-*/
-
-ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void));
-/* Return flags indicating compile-time options.
-
-    Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other:
-     1.0: size of uInt
-     3.2: size of uLong
-     5.4: size of voidpf (pointer)
-     7.6: size of z_off_t
-
-    Compiler, assembler, and debug options:
-     8: DEBUG
-     9: ASMV or ASMINF -- use ASM code
-     10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention
-     11: 0 (reserved)
-
-    One-time table building (smaller code, but not thread-safe if true):
-     12: BUILDFIXED -- build static block decoding tables when needed
-     13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed
-     14,15: 0 (reserved)
-
-    Library content (indicates missing functionality):
-     16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking
-                          deflate code when not needed)
-     17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect
-                    and decode gzip streams (to avoid linking crc code)
-     18-19: 0 (reserved)
-
-    Operation variations (changes in library functionality):
-     20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate
-     21: FASTEST -- deflate algorithm with only one, lowest compression level
-     22,23: 0 (reserved)
-
-    The sprintf variant used by gzprintf (zero is best):
-     24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format
-     25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure!
-     26: 0 = returns value, 1 = void -- 1 means inferred string length returned
-
-    Remainder:
-     27-31: 0 (reserved)
- */
-
-
-                        /* utility functions */
-
-/*
-     The following utility functions are implemented on top of the
-   basic stream-oriented functions. To simplify the interface, some
-   default options are assumed (compression level and memory usage,
-   standard memory allocation functions). The source code of these
-   utility functions can easily be modified if you need special options.
-*/
-
-ZEXTERN int ZEXPORT compress OF((Bytef *dest,   uLongf *destLen,
-                                 const Bytef *source, uLong sourceLen));
-/*
-     Compresses the source buffer into the destination buffer.  sourceLen is
-   the byte length of the source buffer. Upon entry, destLen is the total
-   size of the destination buffer, which must be at least the value returned
-   by compressBound(sourceLen). Upon exit, destLen is the actual size of the
-   compressed buffer.
-     This function can be used to compress a whole file at once if the
-   input file is mmap'ed.
-     compress returns Z_OK if success, Z_MEM_ERROR if there was not
-   enough memory, Z_BUF_ERROR if there was not enough room in the output
-   buffer.
-*/
-
-ZEXTERN int ZEXPORT compress2 OF((Bytef *dest,   uLongf *destLen,
-                                  const Bytef *source, uLong sourceLen,
-                                  int level));
-/*
-     Compresses the source buffer into the destination buffer. The level
-   parameter has the same meaning as in deflateInit.  sourceLen is the byte
-   length of the source buffer. Upon entry, destLen is the total size of the
-   destination buffer, which must be at least the value returned by
-   compressBound(sourceLen). Upon exit, destLen is the actual size of the
-   compressed buffer.
-
-     compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
-   memory, Z_BUF_ERROR if there was not enough room in the output buffer,
-   Z_STREAM_ERROR if the level parameter is invalid.
-*/
-
-ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen));
-/*
-     compressBound() returns an upper bound on the compressed size after
-   compress() or compress2() on sourceLen bytes.  It would be used before
-   a compress() or compress2() call to allocate the destination buffer.
-*/
-
-ZEXTERN int ZEXPORT uncompress OF((Bytef *dest,   uLongf *destLen,
-                                   const Bytef *source, uLong sourceLen));
-/*
-     Decompresses the source buffer into the destination buffer.  sourceLen is
-   the byte length of the source buffer. Upon entry, destLen is the total
-   size of the destination buffer, which must be large enough to hold the
-   entire uncompressed data. (The size of the uncompressed data must have
-   been saved previously by the compressor and transmitted to the decompressor
-   by some mechanism outside the scope of this compression library.)
-   Upon exit, destLen is the actual size of the compressed buffer.
-     This function can be used to decompress a whole file at once if the
-   input file is mmap'ed.
-
-     uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
-   enough memory, Z_BUF_ERROR if there was not enough room in the output
-   buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete.
-*/
-
-
-typedef voidp gzFile;
-
-ZEXTERN gzFile ZEXPORT gzopen  OF((const char *path, const char *mode));
-/*
-     Opens a gzip (.gz) file for reading or writing. The mode parameter
-   is as in fopen ("rb" or "wb") but can also include a compression level
-   ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for
-   Huffman only compression as in "wb1h", or 'R' for run-length encoding
-   as in "wb1R". (See the description of deflateInit2 for more information
-   about the strategy parameter.)
-
-     gzopen can be used to read a file which is not in gzip format; in this
-   case gzread will directly read from the file without decompression.
-
-     gzopen returns NULL if the file could not be opened or if there was
-   insufficient memory to allocate the (de)compression state; errno
-   can be checked to distinguish the two cases (if errno is zero, the
-   zlib error is Z_MEM_ERROR).  */
-
-ZEXTERN gzFile ZEXPORT gzdopen  OF((int fd, const char *mode));
-/*
-     gzdopen() associates a gzFile with the file descriptor fd.  File
-   descriptors are obtained from calls like open, dup, creat, pipe or
-   fileno (in the file has been previously opened with fopen).
-   The mode parameter is as in gzopen.
-     The next call of gzclose on the returned gzFile will also close the
-   file descriptor fd, just like fclose(fdopen(fd), mode) closes the file
-   descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode).
-     gzdopen returns NULL if there was insufficient memory to allocate
-   the (de)compression state.
-*/
-
-ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
-/*
-     Dynamically update the compression level or strategy. See the description
-   of deflateInit2 for the meaning of these parameters.
-     gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not
-   opened for writing.
-*/
-
-ZEXTERN int ZEXPORT    gzread  OF((gzFile file, voidp buf, unsigned len));
-/*
-     Reads the given number of uncompressed bytes from the compressed file.
-   If the input file was not in gzip format, gzread copies the given number
-   of bytes into the buffer.
-     gzread returns the number of uncompressed bytes actually read (0 for
-   end of file, -1 for error). */
-
-ZEXTERN int ZEXPORT    gzwrite OF((gzFile file,
-                                   voidpc buf, unsigned len));
-/*
-     Writes the given number of uncompressed bytes into the compressed file.
-   gzwrite returns the number of uncompressed bytes actually written
-   (0 in case of error).
-*/
-
-ZEXTERN int ZEXPORTVA   gzprintf OF((gzFile file, const char *format, ...));
-/*
-     Converts, formats, and writes the args to the compressed file under
-   control of the format string, as in fprintf. gzprintf returns the number of
-   uncompressed bytes actually written (0 in case of error).  The number of
-   uncompressed bytes written is limited to 4095. The caller should assure that
-   this limit is not exceeded. If it is exceeded, then gzprintf() will return
-   return an error (0) with nothing written. In this case, there may also be a
-   buffer overflow with unpredictable consequences, which is possible only if
-   zlib was compiled with the insecure functions sprintf() or vsprintf()
-   because the secure snprintf() or vsnprintf() functions were not available.
-*/
-
-ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));
-/*
-      Writes the given null-terminated string to the compressed file, excluding
-   the terminating null character.
-      gzputs returns the number of characters written, or -1 in case of error.
-*/
-
-ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));
-/*
-      Reads bytes from the compressed file until len-1 characters are read, or
-   a newline character is read and transferred to buf, or an end-of-file
-   condition is encountered.  The string is then terminated with a null
-   character.
-      gzgets returns buf, or Z_NULL in case of error.
-*/
-
-ZEXTERN int ZEXPORT    gzputc OF((gzFile file, int c));
-/*
-      Writes c, converted to an unsigned char, into the compressed file.
-   gzputc returns the value that was written, or -1 in case of error.
-*/
-
-ZEXTERN int ZEXPORT    gzgetc OF((gzFile file));
-/*
-      Reads one byte from the compressed file. gzgetc returns this byte
-   or -1 in case of end of file or error.
-*/
-
-ZEXTERN int ZEXPORT    gzungetc OF((int c, gzFile file));
-/*
-      Push one character back onto the stream to be read again later.
-   Only one character of push-back is allowed.  gzungetc() returns the
-   character pushed, or -1 on failure.  gzungetc() will fail if a
-   character has been pushed but not read yet, or if c is -1. The pushed
-   character will be discarded if the stream is repositioned with gzseek()
-   or gzrewind().
-*/
-
-ZEXTERN int ZEXPORT    gzflush OF((gzFile file, int flush));
-/*
-     Flushes all pending output into the compressed file. The parameter
-   flush is as in the deflate() function. The return value is the zlib
-   error number (see function gzerror below). gzflush returns Z_OK if
-   the flush parameter is Z_FINISH and all output could be flushed.
-     gzflush should be called only when strictly necessary because it can
-   degrade compression.
-*/
-
-ZEXTERN z_off_t ZEXPORT    gzseek OF((gzFile file,
-                                      z_off_t offset, int whence));
-/*
-      Sets the starting position for the next gzread or gzwrite on the
-   given compressed file. The offset represents a number of bytes in the
-   uncompressed data stream. The whence parameter is defined as in lseek(2);
-   the value SEEK_END is not supported.
-     If the file is opened for reading, this function is emulated but can be
-   extremely slow. If the file is opened for writing, only forward seeks are
-   supported; gzseek then compresses a sequence of zeroes up to the new
-   starting position.
-
-      gzseek returns the resulting offset location as measured in bytes from
-   the beginning of the uncompressed stream, or -1 in case of error, in
-   particular if the file is opened for writing and the new starting position
-   would be before the current position.
-*/
-
-ZEXTERN int ZEXPORT    gzrewind OF((gzFile file));
-/*
-     Rewinds the given file. This function is supported only for reading.
-
-   gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)
-*/
-
-ZEXTERN z_off_t ZEXPORT    gztell OF((gzFile file));
-/*
-     Returns the starting position for the next gzread or gzwrite on the
-   given compressed file. This position represents a number of bytes in the
-   uncompressed data stream.
-
-   gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)
-*/
-
-ZEXTERN int ZEXPORT gzeof OF((gzFile file));
-/*
-     Returns 1 when EOF has previously been detected reading the given
-   input stream, otherwise zero.
-*/
-
-ZEXTERN int ZEXPORT gzdirect OF((gzFile file));
-/*
-     Returns 1 if file is being read directly without decompression, otherwise
-   zero.
-*/
-
-ZEXTERN int ZEXPORT    gzclose OF((gzFile file));
-/*
-     Flushes all pending output if necessary, closes the compressed file
-   and deallocates all the (de)compression state. The return value is the zlib
-   error number (see function gzerror below).
-*/
-
-ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
-/*
-     Returns the error message for the last error which occurred on the
-   given compressed file. errnum is set to zlib error number. If an
-   error occurred in the file system and not in the compression library,
-   errnum is set to Z_ERRNO and the application may consult errno
-   to get the exact error code.
-*/
-
-ZEXTERN void ZEXPORT gzclearerr OF((gzFile file));
-/*
-     Clears the error and end-of-file flags for file. This is analogous to the
-   clearerr() function in stdio. This is useful for continuing to read a gzip
-   file that is being written concurrently.
-*/
-
-                        /* checksum functions */
-
-/*
-     These functions are not related to compression but are exported
-   anyway because they might be useful in applications using the
-   compression library.
-*/
-
-ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
-/*
-     Update a running Adler-32 checksum with the bytes buf[0..len-1] and
-   return the updated checksum. If buf is NULL, this function returns
-   the required initial value for the checksum.
-   An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
-   much faster. Usage example:
-
-     uLong adler = adler32(0L, Z_NULL, 0);
-
-     while (read_buffer(buffer, length) != EOF) {
-       adler = adler32(adler, buffer, length);
-     }
-     if (adler != original_adler) error();
-*/
-
-ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,
-                                          z_off_t len2));
-/*
-     Combine two Adler-32 checksums into one.  For two sequences of bytes, seq1
-   and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for
-   each, adler1 and adler2.  adler32_combine() returns the Adler-32 checksum of
-   seq1 and seq2 concatenated, requiring only adler1, adler2, and len2.
-*/
-
-ZEXTERN uLong ZEXPORT crc32   OF((uLong crc, const Bytef *buf, uInt len));
-/*
-     Update a running CRC-32 with the bytes buf[0..len-1] and return the
-   updated CRC-32. If buf is NULL, this function returns the required initial
-   value for the for the crc. Pre- and post-conditioning (one's complement) is
-   performed within this function so it shouldn't be done by the application.
-   Usage example:
-
-     uLong crc = crc32(0L, Z_NULL, 0);
-
-     while (read_buffer(buffer, length) != EOF) {
-       crc = crc32(crc, buffer, length);
-     }
-     if (crc != original_crc) error();
-*/
-
-ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));
-
-/*
-     Combine two CRC-32 check values into one.  For two sequences of bytes,
-   seq1 and seq2 with lengths len1 and len2, CRC-32 check values were
-   calculated for each, crc1 and crc2.  crc32_combine() returns the CRC-32
-   check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and
-   len2.
-*/
-
-
-                        /* various hacks, don't look :) */
-
-/* deflateInit and inflateInit are macros to allow checking the zlib version
- * and the compiler's view of z_stream:
- */
-ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level,
-                                     const char *version, int stream_size));
-ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm,
-                                     const char *version, int stream_size));
-ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int  level, int  method,
-                                      int windowBits, int memLevel,
-                                      int strategy, const char *version,
-                                      int stream_size));
-ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int  windowBits,
-                                      const char *version, int stream_size));
-ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,
-                                         unsigned char FAR *window,
-                                         const char *version,
-                                         int stream_size));
-#define deflateInit(strm, level) \
-        deflateInit_((strm), (level),       ZLIB_VERSION, sizeof(z_stream))
-#define inflateInit(strm) \
-        inflateInit_((strm),                ZLIB_VERSION, sizeof(z_stream))
-#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
-        deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
-                      (strategy),           ZLIB_VERSION, sizeof(z_stream))
-#define inflateInit2(strm, windowBits) \
-        inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))
-#define inflateBackInit(strm, windowBits, window) \
-        inflateBackInit_((strm), (windowBits), (window), \
-        ZLIB_VERSION, sizeof(z_stream))
-
-
-#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL)
-    struct internal_state {int dummy;}; /* hack for buggy compilers */
-#endif
-
-ZEXTERN const char   * ZEXPORT zError           OF((int));
-ZEXTERN int            ZEXPORT inflateSyncPoint OF((z_streamp z));
-ZEXTERN const unsigned long FAR * ZEXPORT get_crc_table    OF((void));
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* ZLIB_H */
diff --git a/jdk/src/share/native/java/util/zip/zlib-1.2.3/ChangeLog b/jdk/src/share/native/java/util/zip/zlib-1.2.5/ChangeLog
similarity index 68%
rename from jdk/src/share/native/java/util/zip/zlib-1.2.3/ChangeLog
rename to jdk/src/share/native/java/util/zip/zlib-1.2.5/ChangeLog
index 7f6869d..f310bb0 100644
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/ChangeLog
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/ChangeLog
@@ -1,6 +1,359 @@
 
                 ChangeLog file for zlib
 
+Changes in 1.2.5 (19 Apr 2010)
+- Disable visibility attribute in win32/Makefile.gcc [Bar-Lev]
+- Default to libdir as sharedlibdir in configure [Nieder]
+- Update copyright dates on modified source files
+- Update trees.c to be able to generate modified trees.h
+- Exit configure for MinGW, suggesting win32/Makefile.gcc
+
+Changes in 1.2.4.5 (18 Apr 2010)
+- Set sharedlibdir in configure [Torok]
+- Set LDFLAGS in Makefile.in [Bar-Lev]
+- Avoid mkdir objs race condition in Makefile.in [Bowler]
+- Add ZLIB_INTERNAL in front of internal inter-module functions and arrays
+- Define ZLIB_INTERNAL to hide internal functions and arrays for GNU C
+- Don't use hidden attribute when it is a warning generator (e.g. Solaris)
+
+Changes in 1.2.4.4 (18 Apr 2010)
+- Fix CROSS_PREFIX executable testing, CHOST extract, mingw* [Torok]
+- Undefine _LARGEFILE64_SOURCE in zconf.h if it is zero, but not if empty
+- Try to use bash or ksh regardless of functionality of /bin/sh
+- Fix configure incompatibility with NetBSD sh
+- Remove attempt to run under bash or ksh since have better NetBSD fix
+- Fix win32/Makefile.gcc for MinGW [Bar-Lev]
+- Add diagnostic messages when using CROSS_PREFIX in configure
+- Added --sharedlibdir option to configure [Weigelt]
+- Use hidden visibility attribute when available [Frysinger]
+
+Changes in 1.2.4.3 (10 Apr 2010)
+- Only use CROSS_PREFIX in configure for ar and ranlib if they exist
+- Use CROSS_PREFIX for nm [Bar-Lev]
+- Assume _LARGEFILE64_SOURCE defined is equivalent to true
+- Avoid use of undefined symbols in #if with && and ||
+- Make *64 prototypes in gzguts.h consistent with functions
+- Add -shared load option for MinGW in configure [Bowler]
+- Move z_off64_t to public interface, use instead of off64_t
+- Remove ! from shell test in configure (not portable to Solaris)
+- Change +0 macro tests to -0 for possibly increased portability
+
+Changes in 1.2.4.2 (9 Apr 2010)
+- Add consistent carriage returns to readme.txt's in masmx86 and masmx64
+- Really provide prototypes for *64 functions when building without LFS
+- Only define unlink() in minigzip.c if unistd.h not included
+- Update README to point to contrib/vstudio project files
+- Move projects/vc6 to old/ and remove projects/
+- Include stdlib.h in minigzip.c for setmode() definition under WinCE
+- Clean up assembler builds in win32/Makefile.msc [Rowe]
+- Include sys/types.h for Microsoft for off_t definition
+- Fix memory leak on error in gz_open()
+- Symbolize nm as $NM in configure [Weigelt]
+- Use TEST_LDSHARED instead of LDSHARED to link test programs [Weigelt]
+- Add +0 to _FILE_OFFSET_BITS and _LFS64_LARGEFILE in case not defined
+- Fix bug in gzeof() to take into account unused input data
+- Avoid initialization of structures with variables in puff.c
+- Updated win32/README-WIN32.txt [Rowe]
+
+Changes in 1.2.4.1 (28 Mar 2010)
+- Remove the use of [a-z] constructs for sed in configure [gentoo 310225]
+- Remove $(SHAREDLIB) from LIBS in Makefile.in [Creech]
+- Restore "for debugging" comment on sprintf() in gzlib.c
+- Remove fdopen for MVS from gzguts.h
+- Put new README-WIN32.txt in win32 [Rowe]
+- Add check for shell to configure and invoke another shell if needed
+- Fix big fat stinking bug in gzseek() on uncompressed files
+- Remove vestigial F_OPEN64 define in zutil.h
+- Set and check the value of _LARGEFILE_SOURCE and _LARGEFILE64_SOURCE
+- Avoid errors on non-LFS systems when applications define LFS macros
+- Set EXE to ".exe" in configure for MINGW [Kahle]
+- Match crc32() in crc32.c exactly to the prototype in zlib.h [Sherrill]
+- Add prefix for cross-compilation in win32/makefile.gcc [Bar-Lev]
+- Add DLL install in win32/makefile.gcc [Bar-Lev]
+- Allow Linux* or linux* from uname in configure [Bar-Lev]
+- Allow ldconfig to be redefined in configure and Makefile.in [Bar-Lev]
+- Add cross-compilation prefixes to configure [Bar-Lev]
+- Match type exactly in gz_load() invocation in gzread.c
+- Match type exactly of zcalloc() in zutil.c to zlib.h alloc_func
+- Provide prototypes for *64 functions when building zlib without LFS
+- Don't use -lc when linking shared library on MinGW
+- Remove errno.h check in configure and vestigial errno code in zutil.h
+
+Changes in 1.2.4 (14 Mar 2010)
+- Fix VER3 extraction in configure for no fourth subversion
+- Update zlib.3, add docs to Makefile.in to make .pdf out of it
+- Add zlib.3.pdf to distribution
+- Don't set error code in gzerror() if passed pointer is NULL
+- Apply destination directory fixes to CMakeLists.txt [Lowman]
+- Move #cmakedefine's to a new zconf.in.cmakein
+- Restore zconf.h for builds that don't use configure or cmake
+- Add distclean to dummy Makefile for convenience
+- Update and improve INDEX, README, and FAQ
+- Update CMakeLists.txt for the return of zconf.h [Lowman]
+- Update contrib/vstudio/vc9 and vc10 [Vollant]
+- Change libz.dll.a back to libzdll.a in win32/Makefile.gcc
+- Apply license and readme changes to contrib/asm686 [Raiter]
+- Check file name lengths and add -c option in minigzip.c [Li]
+- Update contrib/amd64 and contrib/masmx86/ [Vollant]
+- Avoid use of "eof" parameter in trees.c to not shadow library variable
+- Update make_vms.com for removal of zlibdefs.h [Zinser]
+- Update assembler code and vstudio projects in contrib [Vollant]
+- Remove outdated assembler code contrib/masm686 and contrib/asm586
+- Remove old vc7 and vc8 from contrib/vstudio
+- Update win32/Makefile.msc, add ZLIB_VER_SUBREVISION [Rowe]
+- Fix memory leaks in gzclose_r() and gzclose_w(), file leak in gz_open()
+- Add contrib/gcc_gvmat64 for longest_match and inflate_fast [Vollant]
+- Remove *64 functions from win32/zlib.def (they're not 64-bit yet)
+- Fix bug in void-returning vsprintf() case in gzwrite.c
+- Fix name change from inflate.h in contrib/inflate86/inffas86.c
+- Check if temporary file exists before removing in make_vms.com [Zinser]
+- Fix make install and uninstall for --static option
+- Fix usage of _MSC_VER in gzguts.h and zutil.h [Truta]
+- Update readme.txt in contrib/masmx64 and masmx86 to assemble
+
+Changes in 1.2.3.9 (21 Feb 2010)
+- Expunge gzio.c
+- Move as400 build information to old
+- Fix updates in contrib/minizip and contrib/vstudio
+- Add const to vsnprintf test in configure to avoid warnings [Weigelt]
+- Delete zconf.h (made by configure) [Weigelt]
+- Change zconf.in.h to zconf.h.in per convention [Weigelt]
+- Check for NULL buf in gzgets()
+- Return empty string for gzgets() with len == 1 (like fgets())
+- Fix description of gzgets() in zlib.h for end-of-file, NULL return
+- Update minizip to 1.1 [Vollant]
+- Avoid MSVC loss of data warnings in gzread.c, gzwrite.c
+- Note in zlib.h that gzerror() should be used to distinguish from EOF
+- Remove use of snprintf() from gzlib.c
+- Fix bug in gzseek()
+- Update contrib/vstudio, adding vc9 and vc10 [Kuno, Vollant]
+- Fix zconf.h generation in CMakeLists.txt [Lowman]
+- Improve comments in zconf.h where modified by configure
+
+Changes in 1.2.3.8 (13 Feb 2010)
+- Clean up text files (tabs, trailing whitespace, etc.) [Oberhumer]
+- Use z_off64_t in gz_zero() and gz_skip() to match state->skip
+- Avoid comparison problem when sizeof(int) == sizeof(z_off64_t)
+- Revert to Makefile.in from 1.2.3.6 (live with the clutter)
+- Fix missing error return in gzflush(), add zlib.h note
+- Add *64 functions to zlib.map [Levin]
+- Fix signed/unsigned comparison in gz_comp()
+- Use SFLAGS when testing shared linking in configure
+- Add --64 option to ./configure to use -m64 with gcc
+- Fix ./configure --help to correctly name options
+- Have make fail if a test fails [Levin]
+- Avoid buffer overrun in contrib/masmx64/gvmat64.asm [Simpson]
+- Remove assembler object files from contrib
+
+Changes in 1.2.3.7 (24 Jan 2010)
+- Always gzopen() with O_LARGEFILE if available
+- Fix gzdirect() to work immediately after gzopen() or gzdopen()
+- Make gzdirect() more precise when the state changes while reading
+- Improve zlib.h documentation in many places
+- Catch memory allocation failure in gz_open()
+- Complete close operation if seek forward in gzclose_w() fails
+- Return Z_ERRNO from gzclose_r() if close() fails
+- Return Z_STREAM_ERROR instead of EOF for gzclose() being passed NULL
+- Return zero for gzwrite() errors to match zlib.h description
+- Return -1 on gzputs() error to match zlib.h description
+- Add zconf.in.h to allow recovery from configure modification [Weigelt]
+- Fix static library permissions in Makefile.in [Weigelt]
+- Avoid warnings in configure tests that hide functionality [Weigelt]
+- Add *BSD and DragonFly to Linux case in configure [gentoo 123571]
+- Change libzdll.a to libz.dll.a in win32/Makefile.gcc [gentoo 288212]
+- Avoid access of uninitialized data for first inflateReset2 call [Gomes]
+- Keep object files in subdirectories to reduce the clutter somewhat
+- Remove default Makefile and zlibdefs.h, add dummy Makefile
+- Add new external functions to Z_PREFIX, remove duplicates, z_z_ -> z_
+- Remove zlibdefs.h completely -- modify zconf.h instead
+
+Changes in 1.2.3.6 (17 Jan 2010)
+- Avoid void * arithmetic in gzread.c and gzwrite.c
+- Make compilers happier with const char * for gz_error message
+- Avoid unused parameter warning in inflate.c
+- Avoid signed-unsigned comparison warning in inflate.c
+- Indent #pragma's for traditional C
+- Fix usage of strwinerror() in glib.c, change to gz_strwinerror()
+- Correct email address in configure for system options
+- Update make_vms.com and add make_vms.com to contrib/minizip [Zinser]
+- Update zlib.map [Brown]
+- Fix Makefile.in for Solaris 10 make of example64 and minizip64 [Torok]
+- Apply various fixes to CMakeLists.txt [Lowman]
+- Add checks on len in gzread() and gzwrite()
+- Add error message for no more room for gzungetc()
+- Remove zlib version check in gzwrite()
+- Defer compression of gzprintf() result until need to
+- Use snprintf() in gzdopen() if available
+- Remove USE_MMAP configuration determination (only used by minigzip)
+- Remove examples/pigz.c (available separately)
+- Update examples/gun.c to 1.6
+
+Changes in 1.2.3.5 (8 Jan 2010)
+- Add space after #if in zutil.h for some compilers
+- Fix relatively harmless bug in deflate_fast() [Exarevsky]
+- Fix same problem in deflate_slow()
+- Add $(SHAREDLIBV) to LIBS in Makefile.in [Brown]
+- Add deflate_rle() for faster Z_RLE strategy run-length encoding
+- Add deflate_huff() for faster Z_HUFFMAN_ONLY encoding
+- Change name of "write" variable in inffast.c to avoid library collisions
+- Fix premature EOF from gzread() in gzio.c [Brown]
+- Use zlib header window size if windowBits is 0 in inflateInit2()
+- Remove compressBound() call in deflate.c to avoid linking compress.o
+- Replace use of errno in gz* with functions, support WinCE [Alves]
+- Provide alternative to perror() in minigzip.c for WinCE [Alves]
+- Don't use _vsnprintf on later versions of MSVC [Lowman]
+- Add CMake build script and input file [Lowman]
+- Update contrib/minizip to 1.1 [Svensson, Vollant]
+- Moved nintendods directory from contrib to .
+- Replace gzio.c with a new set of routines with the same functionality
+- Add gzbuffer(), gzoffset(), gzclose_r(), gzclose_w() as part of above
+- Update contrib/minizip to 1.1b
+- Change gzeof() to return 0 on error instead of -1 to agree with zlib.h
+
+Changes in 1.2.3.4 (21 Dec 2009)
+- Use old school .SUFFIXES in Makefile.in for FreeBSD compatibility
+- Update comments in configure and Makefile.in for default --shared
+- Fix test -z's in configure [Marquess]
+- Build examplesh and minigzipsh when not testing
+- Change NULL's to Z_NULL's in deflate.c and in comments in zlib.h
+- Import LDFLAGS from the environment in configure
+- Fix configure to populate SFLAGS with discovered CFLAGS options
+- Adapt make_vms.com to the new Makefile.in [Zinser]
+- Add zlib2ansi script for C++ compilation [Marquess]
+- Add _FILE_OFFSET_BITS=64 test to make test (when applicable)
+- Add AMD64 assembler code for longest match to contrib [Teterin]
+- Include options from $SFLAGS when doing $LDSHARED
+- Simplify 64-bit file support by introducing z_off64_t type
+- Make shared object files in objs directory to work around old Sun cc
+- Use only three-part version number for Darwin shared compiles
+- Add rc option to ar in Makefile.in for when ./configure not run
+- Add -WI,-rpath,. to LDFLAGS for OSF 1 V4*
+- Set LD_LIBRARYN32_PATH for SGI IRIX shared compile
+- Protect against _FILE_OFFSET_BITS being defined when compiling zlib
+- Rename Makefile.in targets allstatic to static and allshared to shared
+- Fix static and shared Makefile.in targets to be independent
+- Correct error return bug in gz_open() by setting state [Brown]
+- Put spaces before ;;'s in configure for better sh compatibility
+- Add pigz.c (parallel implementation of gzip) to examples/
+- Correct constant in crc32.c to UL [Leventhal]
+- Reject negative lengths in crc32_combine()
+- Add inflateReset2() function to work like inflateEnd()/inflateInit2()
+- Include sys/types.h for _LARGEFILE64_SOURCE [Brown]
+- Correct typo in doc/algorithm.txt [Janik]
+- Fix bug in adler32_combine() [Zhu]
+- Catch missing-end-of-block-code error in all inflates and in puff
+    Assures that random input to inflate eventually results in an error
+- Added enough.c (calculation of ENOUGH for inftrees.h) to examples/
+- Update ENOUGH and its usage to reflect discovered bounds
+- Fix gzerror() error report on empty input file [Brown]
+- Add ush casts in trees.c to avoid pedantic runtime errors
+- Fix typo in zlib.h uncompress() description [Reiss]
+- Correct inflate() comments with regard to automatic header detection
+- Remove deprecation comment on Z_PARTIAL_FLUSH (it stays)
+- Put new version of gzlog (2.0) in examples with interruption recovery
+- Add puff compile option to permit invalid distance-too-far streams
+- Add puff TEST command options, ability to read piped input
+- Prototype the *64 functions in zlib.h when _FILE_OFFSET_BITS == 64, but
+  _LARGEFILE64_SOURCE not defined
+- Fix Z_FULL_FLUSH to truly erase the past by resetting s->strstart
+- Fix deflateSetDictionary() to use all 32K for output consistency
+- Remove extraneous #define MIN_LOOKAHEAD in deflate.c (in deflate.h)
+- Clear bytes after deflate lookahead to avoid use of uninitialized data
+- Change a limit in inftrees.c to be more transparent to Coverity Prevent
+- Update win32/zlib.def with exported symbols from zlib.h
+- Correct spelling error in zlib.h [Willem]
+- Allow Z_BLOCK for deflate() to force a new block
+- Allow negative bits in inflatePrime() to delete existing bit buffer
+- Add Z_TREES flush option to inflate() to return at end of trees
+- Add inflateMark() to return current state information for random access
+- Add Makefile for NintendoDS to contrib [Costa]
+- Add -w in configure compile tests to avoid spurious warnings [Beucler]
+- Fix typos in zlib.h comments for deflateSetDictionary()
+- Fix EOF detection in transparent gzread() [Maier]
+
+Changes in 1.2.3.3 (2 October 2006)
+- Make --shared the default for configure, add a --static option
+- Add compile option to permit invalid distance-too-far streams
+- Add inflateUndermine() function which is required to enable above
+- Remove use of "this" variable name for C++ compatibility [Marquess]
+- Add testing of shared library in make test, if shared library built
+- Use ftello() and fseeko() if available instead of ftell() and fseek()
+- Provide two versions of all functions that use the z_off_t type for
+  binary compatibility -- a normal version and a 64-bit offset version,
+  per the Large File Support Extension when _LARGEFILE64_SOURCE is
+  defined; use the 64-bit versions by default when _FILE_OFFSET_BITS
+  is defined to be 64
+- Add a --uname= option to configure to perhaps help with cross-compiling
+
+Changes in 1.2.3.2 (3 September 2006)
+- Turn off silly Borland warnings [Hay]
+- Use off64_t and define _LARGEFILE64_SOURCE when present
+- Fix missing dependency on inffixed.h in Makefile.in
+- Rig configure --shared to build both shared and static [Teredesai, Truta]
+- Remove zconf.in.h and instead create a new zlibdefs.h file
+- Fix contrib/minizip/unzip.c non-encrypted after encrypted [Vollant]
+- Add treebuild.xml (see http://treebuild.metux.de/) [Weigelt]
+
+Changes in 1.2.3.1 (16 August 2006)
+- Add watcom directory with OpenWatcom make files [Daniel]
+- Remove #undef of FAR in zconf.in.h for MVS [Fedtke]
+- Update make_vms.com [Zinser]
+- Use -fPIC for shared build in configure [Teredesai, Nicholson]
+- Use only major version number for libz.so on IRIX and OSF1 [Reinholdtsen]
+- Use fdopen() (not _fdopen()) for Interix in zutil.h [BŠck]
+- Add some FAQ entries about the contrib directory
+- Update the MVS question in the FAQ
+- Avoid extraneous reads after EOF in gzio.c [Brown]
+- Correct spelling of "successfully" in gzio.c [Randers-Pehrson]
+- Add comments to zlib.h about gzerror() usage [Brown]
+- Set extra flags in gzip header in gzopen() like deflate() does
+- Make configure options more compatible with double-dash conventions
+  [Weigelt]
+- Clean up compilation under Solaris SunStudio cc [Rowe, Reinholdtsen]
+- Fix uninstall target in Makefile.in [Truta]
+- Add pkgconfig support [Weigelt]
+- Use $(DESTDIR) macro in Makefile.in [Reinholdtsen, Weigelt]
+- Replace set_data_type() with a more accurate detect_data_type() in
+  trees.c, according to the txtvsbin.txt document [Truta]
+- Swap the order of #include <stdio.h> and #include "zlib.h" in
+  gzio.c, example.c and minigzip.c [Truta]
+- Shut up annoying VS2005 warnings about standard C deprecation [Rowe,
+  Truta] (where?)
+- Fix target "clean" from win32/Makefile.bor [Truta]
+- Create .pdb and .manifest files in win32/makefile.msc [Ziegler, Rowe]
+- Update zlib www home address in win32/DLL_FAQ.txt [Truta]
+- Update contrib/masmx86/inffas32.asm for VS2005 [Vollant, Van Wassenhove]
+- Enable browse info in the "Debug" and "ASM Debug" configurations in
+  the Visual C++ 6 project, and set (non-ASM) "Debug" as default [Truta]
+- Add pkgconfig support [Weigelt]
+- Add ZLIB_VER_MAJOR, ZLIB_VER_MINOR and ZLIB_VER_REVISION in zlib.h,
+  for use in win32/zlib1.rc [Polushin, Rowe, Truta]
+- Add a document that explains the new text detection scheme to
+  doc/txtvsbin.txt [Truta]
+- Add rfc1950.txt, rfc1951.txt and rfc1952.txt to doc/ [Truta]
+- Move algorithm.txt into doc/ [Truta]
+- Synchronize FAQ with website
+- Fix compressBound(), was low for some pathological cases [Fearnley]
+- Take into account wrapper variations in deflateBound()
+- Set examples/zpipe.c input and output to binary mode for Windows
+- Update examples/zlib_how.html with new zpipe.c (also web site)
+- Fix some warnings in examples/gzlog.c and examples/zran.c (it seems
+  that gcc became pickier in 4.0)
+- Add zlib.map for Linux: "All symbols from zlib-1.1.4 remain
+  un-versioned, the patch adds versioning only for symbols introduced in
+  zlib-1.2.0 or later.  It also declares as local those symbols which are
+  not designed to be exported." [Levin]
+- Update Z_PREFIX list in zconf.in.h, add --zprefix option to configure
+- Do not initialize global static by default in trees.c, add a response
+  NO_INIT_GLOBAL_POINTERS to initialize them if needed [Marquess]
+- Don't use strerror() in gzio.c under WinCE [Yakimov]
+- Don't use errno.h in zutil.h under WinCE [Yakimov]
+- Move arguments for AR to its usage to allow replacing ar [Marot]
+- Add HAVE_VISIBILITY_PRAGMA in zconf.in.h for Mozilla [Randers-Pehrson]
+- Improve inflateInit() and inflateInit2() documentation
+- Fix structure size comment in inflate.h
+- Change configure help option from --h* to --help [Santos]
+
 Changes in 1.2.3 (18 July 2005)
 - Apply security vulnerability fixes to contrib/infback9 as well
 - Clean up some text files (carriage returns, trailing space)
@@ -13,7 +366,7 @@
   compile
 - Fix some spelling errors in comments [Betts]
 - Correct inflateInit2() error return documentation in zlib.h
-- Added zran.c example of compressed data random access to examples
+- Add zran.c example of compressed data random access to examples
   directory, shows use of inflatePrime()
 - Fix cast for assignments to strm->state in inflate.c and infback.c
 - Fix zlibCompileFlags() in zutil.c to use 1L for long shifts [Oberhumer]
diff --git a/jdk/src/share/native/java/util/zip/zlib-1.2.5/README b/jdk/src/share/native/java/util/zip/zlib-1.2.5/README
new file mode 100644
index 0000000..d4219bf
--- /dev/null
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/README
@@ -0,0 +1,115 @@
+ZLIB DATA COMPRESSION LIBRARY
+
+zlib 1.2.5 is a general purpose data compression library.  All the code is
+thread safe.  The data format used by the zlib library is described by RFCs
+(Request for Comments) 1950 to 1952 in the files
+http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format)
+and rfc1952.txt (gzip format).
+
+All functions of the compression library are documented in the file zlib.h
+(volunteer to write man pages welcome, contact zlib@gzip.org).  A usage example
+of the library is given in the file example.c which also tests that the library
+is working correctly.  Another example is given in the file minigzip.c.  The
+compression library itself is composed of all source files except example.c and
+minigzip.c.
+
+To compile all files and run the test program, follow the instructions given at
+the top of Makefile.in.  In short "./configure; make test", and if that goes
+well, "make install" should work for most flavors of Unix.  For Windows, use one
+of the special makefiles in win32/ or contrib/vstudio/ .  For VMS, use
+make_vms.com.
+
+Questions about zlib should be sent to <zlib@gzip.org>, or to Gilles Vollant
+<info@winimage.com> for the Windows DLL version.  The zlib home page is
+http://zlib.net/ .  Before reporting a problem, please check this site to
+verify that you have the latest version of zlib; otherwise get the latest
+version and check whether the problem still exists or not.
+
+PLEASE read the zlib FAQ http://zlib.net/zlib_faq.html before asking for help.
+
+Mark Nelson <markn@ieee.org> wrote an article about zlib for the Jan.  1997
+issue of Dr.  Dobb's Journal; a copy of the article is available at
+http://marknelson.us/1997/01/01/zlib-engine/ .
+
+The changes made in version 1.2.5 are documented in the file ChangeLog.
+
+Unsupported third party contributions are provided in directory contrib/ .
+
+zlib is available in Java using the java.util.zip package, documented at
+http://java.sun.com/developer/technicalArticles/Programming/compression/ .
+
+A Perl interface to zlib written by Paul Marquess <pmqs@cpan.org> is available
+at CPAN (Comprehensive Perl Archive Network) sites, including
+http://search.cpan.org/~pmqs/IO-Compress-Zlib/ .
+
+A Python interface to zlib written by A.M. Kuchling <amk@amk.ca> is
+available in Python 1.5 and later versions, see
+http://www.python.org/doc/lib/module-zlib.html .
+
+zlib is built into tcl: http://wiki.tcl.tk/4610 .
+
+An experimental package to read and write files in .zip format, written on top
+of zlib by Gilles Vollant <info@winimage.com>, is available in the
+contrib/minizip directory of zlib.
+
+
+Notes for some targets:
+
+- For Windows DLL versions, please see win32/DLL_FAQ.txt
+
+- For 64-bit Irix, deflate.c must be compiled without any optimization. With
+  -O, one libpng test fails. The test works in 32 bit mode (with the -n32
+  compiler flag). The compiler bug has been reported to SGI.
+
+- zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1 it works
+  when compiled with cc.
+
+- On Digital Unix 4.0D (formely OSF/1) on AlphaServer, the cc option -std1 is
+  necessary to get gzprintf working correctly. This is done by configure.
+
+- zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with
+  other compilers. Use "make test" to check your compiler.
+
+- gzdopen is not supported on RISCOS or BEOS.
+
+- For PalmOs, see http://palmzlib.sourceforge.net/
+
+
+Acknowledgments:
+
+  The deflate format used by zlib was defined by Phil Katz.  The deflate and
+  zlib specifications were written by L.  Peter Deutsch.  Thanks to all the
+  people who reported problems and suggested various improvements in zlib; they
+  are too numerous to cite here.
+
+Copyright notice:
+
+ (C) 1995-2010 Jean-loup Gailly and Mark Adler
+
+  This software is provided 'as-is', without any express or implied
+  warranty.  In no event will the authors be held liable for any damages
+  arising from the use of this software.
+
+  Permission is granted to anyone to use this software for any purpose,
+  including commercial applications, and to alter it and redistribute it
+  freely, subject to the following restrictions:
+
+  1. The origin of this software must not be misrepresented; you must not
+     claim that you wrote the original software. If you use this software
+     in a product, an acknowledgment in the product documentation would be
+     appreciated but is not required.
+  2. Altered source versions must be plainly marked as such, and must not be
+     misrepresented as being the original software.
+  3. This notice may not be removed or altered from any source distribution.
+
+  Jean-loup Gailly        Mark Adler
+  jloup@gzip.org          madler@alumni.caltech.edu
+
+If you use the zlib library in a product, we would appreciate *not* receiving
+lengthy legal documents to sign.  The sources are provided for free but without
+warranty of any kind.  The library has been entirely written by Jean-loup
+Gailly and Mark Adler; it does not include third-party code.
+
+If you redistribute modified sources, we would appreciate that you include in
+the file ChangeLog history information documenting your changes.  Please read
+the FAQ for more information on the distribution of modified source versions.
diff --git a/jdk/src/share/native/java/util/zip/zlib-1.2.3/compress.c b/jdk/src/share/native/java/util/zip/zlib-1.2.5/compress.c
similarity index 95%
rename from jdk/src/share/native/java/util/zip/zlib-1.2.3/compress.c
rename to jdk/src/share/native/java/util/zip/zlib-1.2.5/compress.c
index 5866998..c05285a 100644
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/compress.c
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/compress.c
@@ -23,7 +23,7 @@
  */
 
 /* compress.c -- compress a memory buffer
- * Copyright (C) 1995-2003 Jean-loup Gailly.
+ * Copyright (C) 1995-2005 Jean-loup Gailly.
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
@@ -99,5 +99,6 @@
 uLong ZEXPORT compressBound (sourceLen)
     uLong sourceLen;
 {
-    return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + 11;
+    return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
+           (sourceLen >> 25) + 13;
 }
diff --git a/jdk/src/share/native/java/util/zip/zlib-1.2.3/crc32.h b/jdk/src/share/native/java/util/zip/zlib-1.2.5/crc32.h
similarity index 100%
rename from jdk/src/share/native/java/util/zip/zlib-1.2.3/crc32.h
rename to jdk/src/share/native/java/util/zip/zlib-1.2.5/crc32.h
diff --git a/jdk/src/share/native/java/util/zip/zlib-1.2.3/deflate.c b/jdk/src/share/native/java/util/zip/zlib-1.2.5/deflate.c
similarity index 89%
rename from jdk/src/share/native/java/util/zip/zlib-1.2.3/deflate.c
rename to jdk/src/share/native/java/util/zip/zlib-1.2.5/deflate.c
index ba1661d..1dce5b0 100644
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/deflate.c
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/deflate.c
@@ -23,7 +23,7 @@
  */
 
 /* deflate.c -- compress data using the deflation algorithm
- * Copyright (C) 1995-2005 Jean-loup Gailly.
+ * Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
@@ -76,7 +76,7 @@
 #include "deflate.h"
 
 const char deflate_copyright[] =
-   " deflate 1.2.3 Copyright 1995-2005 Jean-loup Gailly ";
+   " deflate 1.2.5 Copyright 1995-2010 Jean-loup Gailly and Mark Adler ";
 /*
   If you use the zlib library in a product, an acknowledgment is welcome
   in the documentation of your product. If for some reason you cannot
@@ -103,19 +103,18 @@
 #ifndef FASTEST
 local block_state deflate_slow   OF((deflate_state *s, int flush));
 #endif
+local block_state deflate_rle    OF((deflate_state *s, int flush));
+local block_state deflate_huff   OF((deflate_state *s, int flush));
 local void lm_init        OF((deflate_state *s));
 local void putShortMSB    OF((deflate_state *s, uInt b));
 local void flush_pending  OF((z_streamp strm));
 local int read_buf        OF((z_streamp strm, Bytef *buf, unsigned size));
-#ifndef FASTEST
 #ifdef ASMV
       void match_init OF((void)); /* asm code initialization */
       uInt longest_match  OF((deflate_state *s, IPos cur_match));
 #else
 local uInt longest_match  OF((deflate_state *s, IPos cur_match));
 #endif
-#endif
-local uInt longest_match_fast OF((deflate_state *s, IPos cur_match));
 
 #ifdef DEBUG
 local  void check_match OF((deflate_state *s, IPos start, IPos match,
@@ -134,11 +133,6 @@
 #endif
 /* Matches of length 3 are discarded if their distance exceeds TOO_FAR */
 
-#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
-/* Minimum amount of lookahead, except at the end of the input file.
- * See deflate.c for comments about the MIN_MATCH+1.
- */
-
 /* Values for max_lazy_match, good_match and max_chain_length, depending on
  * the desired pack level (0..9). The values given below have been tuned to
  * exclude worst case performance for pathological files. Better values may be
@@ -312,6 +306,8 @@
     s->prev   = (Posf *)  ZALLOC(strm, s->w_size, sizeof(Pos));
     s->head   = (Posf *)  ZALLOC(strm, s->hash_size, sizeof(Pos));
 
+    s->high_water = 0;      /* nothing written to s->window yet */
+
     s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */
 
     overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2);
@@ -356,8 +352,8 @@
         strm->adler = adler32(strm->adler, dictionary, dictLength);
 
     if (length < MIN_MATCH) return Z_OK;
-    if (length > MAX_DIST(s)) {
-        length = MAX_DIST(s);
+    if (length > s->w_size) {
+        length = s->w_size;
         dictionary += dictLength - length; /* use the tail of the dictionary */
     }
     zmemcpy(s->window, dictionary, length);
@@ -459,9 +455,10 @@
     }
     func = configuration_table[s->level].func;
 
-    if (func != configuration_table[level].func && strm->total_in != 0) {
+    if ((strategy != s->strategy || func != configuration_table[level].func) &&
+        strm->total_in != 0) {
         /* Flush the last buffer: */
-        err = deflate(strm, Z_PARTIAL_FLUSH);
+        err = deflate(strm, Z_BLOCK);
     }
     if (s->level != level) {
         s->level = level;
@@ -505,33 +502,66 @@
  * resulting from using fixed blocks instead of stored blocks, which deflate
  * can emit on compressed data for some combinations of the parameters.
  *
- * This function could be more sophisticated to provide closer upper bounds
- * for every combination of windowBits and memLevel, as well as wrap.
- * But even the conservative upper bound of about 14% expansion does not
- * seem onerous for output buffer allocation.
+ * This function could be more sophisticated to provide closer upper bounds for
+ * every combination of windowBits and memLevel.  But even the conservative
+ * upper bound of about 14% expansion does not seem onerous for output buffer
+ * allocation.
  */
 uLong ZEXPORT deflateBound(strm, sourceLen)
     z_streamp strm;
     uLong sourceLen;
 {
     deflate_state *s;
-    uLong destLen;
+    uLong complen, wraplen;
+    Bytef *str;
 
-    /* conservative upper bound */
-    destLen = sourceLen +
-              ((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 11;
+    /* conservative upper bound for compressed data */
+    complen = sourceLen +
+              ((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 5;
 
-    /* if can't get parameters, return conservative bound */
+    /* if can't get parameters, return conservative bound plus zlib wrapper */
     if (strm == Z_NULL || strm->state == Z_NULL)
-        return destLen;
+        return complen + 6;
+
+    /* compute wrapper length */
+    s = strm->state;
+    switch (s->wrap) {
+    case 0:                                 /* raw deflate */
+        wraplen = 0;
+        break;
+    case 1:                                 /* zlib wrapper */
+        wraplen = 6 + (s->strstart ? 4 : 0);
+        break;
+    case 2:                                 /* gzip wrapper */
+        wraplen = 18;
+        if (s->gzhead != Z_NULL) {          /* user-supplied gzip header */
+            if (s->gzhead->extra != Z_NULL)
+                wraplen += 2 + s->gzhead->extra_len;
+            str = s->gzhead->name;
+            if (str != Z_NULL)
+                do {
+                    wraplen++;
+                } while (*str++);
+            str = s->gzhead->comment;
+            if (str != Z_NULL)
+                do {
+                    wraplen++;
+                } while (*str++);
+            if (s->gzhead->hcrc)
+                wraplen += 2;
+        }
+        break;
+    default:                                /* for compiler happiness */
+        wraplen = 6;
+    }
 
     /* if not default parameters, return conservative bound */
-    s = strm->state;
     if (s->w_bits != 15 || s->hash_bits != 8 + 7)
-        return destLen;
+        return complen + wraplen;
 
     /* default settings: return tight bound for that case */
-    return compressBound(sourceLen);
+    return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
+           (sourceLen >> 25) + 13 - 6 + wraplen;
 }
 
 /* =========================================================================
@@ -581,7 +611,7 @@
     deflate_state *s;
 
     if (strm == Z_NULL || strm->state == Z_NULL ||
-        flush > Z_FINISH || flush < 0) {
+        flush > Z_BLOCK || flush < 0) {
         return Z_STREAM_ERROR;
     }
     s = strm->state;
@@ -605,7 +635,7 @@
             put_byte(s, 31);
             put_byte(s, 139);
             put_byte(s, 8);
-            if (s->gzhead == NULL) {
+            if (s->gzhead == Z_NULL) {
                 put_byte(s, 0);
                 put_byte(s, 0);
                 put_byte(s, 0);
@@ -632,7 +662,7 @@
                             (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
                              4 : 0));
                 put_byte(s, s->gzhead->os & 0xff);
-                if (s->gzhead->extra != NULL) {
+                if (s->gzhead->extra != Z_NULL) {
                     put_byte(s, s->gzhead->extra_len & 0xff);
                     put_byte(s, (s->gzhead->extra_len >> 8) & 0xff);
                 }
@@ -674,7 +704,7 @@
     }
 #ifdef GZIP
     if (s->status == EXTRA_STATE) {
-        if (s->gzhead->extra != NULL) {
+        if (s->gzhead->extra != Z_NULL) {
             uInt beg = s->pending;  /* start of bytes to update crc */
 
             while (s->gzindex < (s->gzhead->extra_len & 0xffff)) {
@@ -702,7 +732,7 @@
             s->status = NAME_STATE;
     }
     if (s->status == NAME_STATE) {
-        if (s->gzhead->name != NULL) {
+        if (s->gzhead->name != Z_NULL) {
             uInt beg = s->pending;  /* start of bytes to update crc */
             int val;
 
@@ -733,7 +763,7 @@
             s->status = COMMENT_STATE;
     }
     if (s->status == COMMENT_STATE) {
-        if (s->gzhead->comment != NULL) {
+        if (s->gzhead->comment != Z_NULL) {
             uInt beg = s->pending;  /* start of bytes to update crc */
             int val;
 
@@ -811,7 +841,9 @@
         (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) {
         block_state bstate;
 
-        bstate = (*(configuration_table[s->level].func))(s, flush);
+        bstate = s->strategy == Z_HUFFMAN_ONLY ? deflate_huff(s, flush) :
+                    (s->strategy == Z_RLE ? deflate_rle(s, flush) :
+                        (*(configuration_table[s->level].func))(s, flush));
 
         if (bstate == finish_started || bstate == finish_done) {
             s->status = FINISH_STATE;
@@ -832,13 +864,17 @@
         if (bstate == block_done) {
             if (flush == Z_PARTIAL_FLUSH) {
                 _tr_align(s);
-            } else { /* FULL_FLUSH or SYNC_FLUSH */
+            } else if (flush != Z_BLOCK) { /* FULL_FLUSH or SYNC_FLUSH */
                 _tr_stored_block(s, (char*)0, 0L, 0);
                 /* For a full flush, this empty block will be recognized
                  * as a special marker by inflate_sync().
                  */
                 if (flush == Z_FULL_FLUSH) {
                     CLEAR_HASH(s);             /* forget history */
+                    if (s->lookahead == 0) {
+                        s->strstart = 0;
+                        s->block_start = 0L;
+                    }
                 }
             }
             flush_pending(strm);
@@ -1191,12 +1227,13 @@
     return s->lookahead;
 }
 #endif /* ASMV */
-#endif /* FASTEST */
+
+#else /* FASTEST */
 
 /* ---------------------------------------------------------------------------
- * Optimized version for level == 1 or strategy == Z_RLE only
+ * Optimized version for FASTEST only
  */
-local uInt longest_match_fast(s, cur_match)
+local uInt longest_match(s, cur_match)
     deflate_state *s;
     IPos cur_match;                             /* current match */
 {
@@ -1249,6 +1286,8 @@
     return (uInt)len <= s->lookahead ? (uInt)len : s->lookahead;
 }
 
+#endif /* FASTEST */
+
 #ifdef DEBUG
 /* ===========================================================================
  * Check that the match at match_start is indeed a match.
@@ -1327,7 +1366,6 @@
                later. (Using level 0 permanently is not an optimal usage of
                zlib, so we don't care about this pathological case.)
              */
-            /* %%% avoid this when Z_RLE */
             n = s->hash_size;
             p = &s->head[n];
             do {
@@ -1379,27 +1417,61 @@
          */
 
     } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0);
+
+    /* If the WIN_INIT bytes after the end of the current data have never been
+     * written, then zero those bytes in order to avoid memory check reports of
+     * the use of uninitialized (or uninitialised as Julian writes) bytes by
+     * the longest match routines.  Update the high water mark for the next
+     * time through here.  WIN_INIT is set to MAX_MATCH since the longest match
+     * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead.
+     */
+    if (s->high_water < s->window_size) {
+        ulg curr = s->strstart + (ulg)(s->lookahead);
+        ulg init;
+
+        if (s->high_water < curr) {
+            /* Previous high water mark below current data -- zero WIN_INIT
+             * bytes or up to end of window, whichever is less.
+             */
+            init = s->window_size - curr;
+            if (init > WIN_INIT)
+                init = WIN_INIT;
+            zmemzero(s->window + curr, (unsigned)init);
+            s->high_water = curr + init;
+        }
+        else if (s->high_water < (ulg)curr + WIN_INIT) {
+            /* High water mark at or above current data, but below current data
+             * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up
+             * to end of window, whichever is less.
+             */
+            init = (ulg)curr + WIN_INIT - s->high_water;
+            if (init > s->window_size - s->high_water)
+                init = s->window_size - s->high_water;
+            zmemzero(s->window + s->high_water, (unsigned)init);
+            s->high_water += init;
+        }
+    }
 }
 
 /* ===========================================================================
  * Flush the current block, with given end-of-file flag.
  * IN assertion: strstart is set to the end of the current match.
  */
-#define FLUSH_BLOCK_ONLY(s, eof) { \
+#define FLUSH_BLOCK_ONLY(s, last) { \
    _tr_flush_block(s, (s->block_start >= 0L ? \
                    (charf *)&s->window[(unsigned)s->block_start] : \
                    (charf *)Z_NULL), \
                 (ulg)((long)s->strstart - s->block_start), \
-                (eof)); \
+                (last)); \
    s->block_start = s->strstart; \
    flush_pending(s->strm); \
    Tracev((stderr,"[FLUSH]")); \
 }
 
 /* Same but force premature exit if necessary. */
-#define FLUSH_BLOCK(s, eof) { \
-   FLUSH_BLOCK_ONLY(s, eof); \
-   if (s->strm->avail_out == 0) return (eof) ? finish_started : need_more; \
+#define FLUSH_BLOCK(s, last) { \
+   FLUSH_BLOCK_ONLY(s, last); \
+   if (s->strm->avail_out == 0) return (last) ? finish_started : need_more; \
 }
 
 /* ===========================================================================
@@ -1473,7 +1545,7 @@
     deflate_state *s;
     int flush;
 {
-    IPos hash_head = NIL; /* head of the hash chain */
+    IPos hash_head;       /* head of the hash chain */
     int bflush;           /* set if current block must be flushed */
 
     for (;;) {
@@ -1493,6 +1565,7 @@
         /* Insert the string window[strstart .. strstart+2] in the
          * dictionary, and set hash_head to the head of the hash chain:
          */
+        hash_head = NIL;
         if (s->lookahead >= MIN_MATCH) {
             INSERT_STRING(s, s->strstart, hash_head);
         }
@@ -1505,19 +1578,8 @@
              * of window index 0 (in particular we have to avoid a match
              * of the string with itself at the start of the input file).
              */
-#ifdef FASTEST
-            if ((s->strategy != Z_HUFFMAN_ONLY && s->strategy != Z_RLE) ||
-                (s->strategy == Z_RLE && s->strstart - hash_head == 1)) {
-                s->match_length = longest_match_fast (s, hash_head);
-            }
-#else
-            if (s->strategy != Z_HUFFMAN_ONLY && s->strategy != Z_RLE) {
-                s->match_length = longest_match (s, hash_head);
-            } else if (s->strategy == Z_RLE && s->strstart - hash_head == 1) {
-                s->match_length = longest_match_fast (s, hash_head);
-            }
-#endif
-            /* longest_match() or longest_match_fast() sets match_start */
+            s->match_length = longest_match (s, hash_head);
+            /* longest_match() sets match_start */
         }
         if (s->match_length >= MIN_MATCH) {
             check_match(s, s->strstart, s->match_start, s->match_length);
@@ -1579,7 +1641,7 @@
     deflate_state *s;
     int flush;
 {
-    IPos hash_head = NIL;    /* head of hash chain */
+    IPos hash_head;          /* head of hash chain */
     int bflush;              /* set if current block must be flushed */
 
     /* Process the input block. */
@@ -1600,6 +1662,7 @@
         /* Insert the string window[strstart .. strstart+2] in the
          * dictionary, and set hash_head to the head of the hash chain:
          */
+        hash_head = NIL;
         if (s->lookahead >= MIN_MATCH) {
             INSERT_STRING(s, s->strstart, hash_head);
         }
@@ -1615,12 +1678,8 @@
              * of window index 0 (in particular we have to avoid a match
              * of the string with itself at the start of the input file).
              */
-            if (s->strategy != Z_HUFFMAN_ONLY && s->strategy != Z_RLE) {
-                s->match_length = longest_match (s, hash_head);
-            } else if (s->strategy == Z_RLE && s->strstart - hash_head == 1) {
-                s->match_length = longest_match_fast (s, hash_head);
-            }
-            /* longest_match() or longest_match_fast() sets match_start */
+            s->match_length = longest_match (s, hash_head);
+            /* longest_match() sets match_start */
 
             if (s->match_length <= 5 && (s->strategy == Z_FILTERED
 #if TOO_FAR <= 32767
@@ -1698,7 +1757,6 @@
 }
 #endif /* FASTEST */
 
-#if 0
 /* ===========================================================================
  * For Z_RLE, simply look for runs of bytes, generate matches only of distance
  * one.  Do not maintain a hash table.  (It will be regenerated if this run of
@@ -1708,11 +1766,9 @@
     deflate_state *s;
     int flush;
 {
-    int bflush;         /* set if current block must be flushed */
-    uInt run;           /* length of run */
-    uInt max;           /* maximum length of run */
-    uInt prev;          /* byte at distance one to match */
-    Bytef *scan;        /* scan for end of run */
+    int bflush;             /* set if current block must be flushed */
+    uInt prev;              /* byte at distance one to match */
+    Bytef *scan, *strend;   /* scan goes up to strend for length of run */
 
     for (;;) {
         /* Make sure that we always have enough lookahead, except
@@ -1728,23 +1784,33 @@
         }
 
         /* See how many times the previous byte repeats */
-        run = 0;
-        if (s->strstart > 0) {      /* if there is a previous byte, that is */
-            max = s->lookahead < MAX_MATCH ? s->lookahead : MAX_MATCH;
+        s->match_length = 0;
+        if (s->lookahead >= MIN_MATCH && s->strstart > 0) {
             scan = s->window + s->strstart - 1;
-            prev = *scan++;
-            do {
-                if (*scan++ != prev)
-                    break;
-            } while (++run < max);
+            prev = *scan;
+            if (prev == *++scan && prev == *++scan && prev == *++scan) {
+                strend = s->window + s->strstart + MAX_MATCH;
+                do {
+                } while (prev == *++scan && prev == *++scan &&
+                         prev == *++scan && prev == *++scan &&
+                         prev == *++scan && prev == *++scan &&
+                         prev == *++scan && prev == *++scan &&
+                         scan < strend);
+                s->match_length = MAX_MATCH - (int)(strend - scan);
+                if (s->match_length > s->lookahead)
+                    s->match_length = s->lookahead;
+            }
         }
 
         /* Emit match if have run of MIN_MATCH or longer, else emit literal */
-        if (run >= MIN_MATCH) {
-            check_match(s, s->strstart, s->strstart - 1, run);
-            _tr_tally_dist(s, 1, run - MIN_MATCH, bflush);
-            s->lookahead -= run;
-            s->strstart += run;
+        if (s->match_length >= MIN_MATCH) {
+            check_match(s, s->strstart, s->strstart - 1, s->match_length);
+
+            _tr_tally_dist(s, 1, s->match_length - MIN_MATCH, bflush);
+
+            s->lookahead -= s->match_length;
+            s->strstart += s->match_length;
+            s->match_length = 0;
         } else {
             /* No match, output a literal byte */
             Tracevv((stderr,"%c", s->window[s->strstart]));
@@ -1757,4 +1823,36 @@
     FLUSH_BLOCK(s, flush == Z_FINISH);
     return flush == Z_FINISH ? finish_done : block_done;
 }
-#endif
+
+/* ===========================================================================
+ * For Z_HUFFMAN_ONLY, do not look for matches.  Do not maintain a hash table.
+ * (It will be regenerated if this run of deflate switches away from Huffman.)
+ */
+local block_state deflate_huff(s, flush)
+    deflate_state *s;
+    int flush;
+{
+    int bflush;             /* set if current block must be flushed */
+
+    for (;;) {
+        /* Make sure that we have a literal to write. */
+        if (s->lookahead == 0) {
+            fill_window(s);
+            if (s->lookahead == 0) {
+                if (flush == Z_NO_FLUSH)
+                    return need_more;
+                break;      /* flush the current block */
+            }
+        }
+
+        /* Output a literal byte */
+        s->match_length = 0;
+        Tracevv((stderr,"%c", s->window[s->strstart]));
+        _tr_tally_lit (s, s->window[s->strstart], bflush);
+        s->lookahead--;
+        s->strstart++;
+        if (bflush) FLUSH_BLOCK(s, 0);
+    }
+    FLUSH_BLOCK(s, flush == Z_FINISH);
+    return flush == Z_FINISH ? finish_done : block_done;
+}
diff --git a/jdk/src/share/native/java/util/zip/zlib-1.2.3/deflate.h b/jdk/src/share/native/java/util/zip/zlib-1.2.5/deflate.h
similarity index 91%
rename from jdk/src/share/native/java/util/zip/zlib-1.2.3/deflate.h
rename to jdk/src/share/native/java/util/zip/zlib-1.2.5/deflate.h
index a5f4e64..652be48 100644
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/deflate.h
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/deflate.h
@@ -23,7 +23,7 @@
  */
 
 /* deflate.h -- internal compression state
- * Copyright (C) 1995-2004 Jean-loup Gailly
+ * Copyright (C) 1995-2010 Jean-loup Gailly
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
@@ -284,6 +284,13 @@
      * are always zero.
      */
 
+    ulg high_water;
+    /* High water mark offset in window for initialized bytes -- bytes above
+     * this are set to zero in order to avoid memory check warnings when
+     * longest match routines access bytes past the input.  This is then
+     * updated to the new high water mark.
+     */
+
 } FAR deflate_state;
 
 /* Output a byte on the stream.
@@ -302,14 +309,18 @@
  * distances are limited to MAX_DIST instead of WSIZE.
  */
 
+#define WIN_INIT MAX_MATCH
+/* Number of bytes after end of data in window to initialize in order to avoid
+   memory checker errors from longest match routines */
+
         /* in trees.c */
-void _tr_init         OF((deflate_state *s));
-int  _tr_tally        OF((deflate_state *s, unsigned dist, unsigned lc));
-void _tr_flush_block  OF((deflate_state *s, charf *buf, ulg stored_len,
-                          int eof));
-void _tr_align        OF((deflate_state *s));
-void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len,
-                          int eof));
+void ZLIB_INTERNAL _tr_init OF((deflate_state *s));
+int ZLIB_INTERNAL _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc));
+void ZLIB_INTERNAL _tr_flush_block OF((deflate_state *s, charf *buf,
+                        ulg stored_len, int last));
+void ZLIB_INTERNAL _tr_align OF((deflate_state *s));
+void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf,
+                        ulg stored_len, int last));
 
 #define d_code(dist) \
    ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)])
@@ -322,11 +333,11 @@
 /* Inline versions of _tr_tally for speed: */
 
 #if defined(GEN_TREES_H) || !defined(STDC)
-  extern uch _length_code[];
-  extern uch _dist_code[];
+  extern uch ZLIB_INTERNAL _length_code[];
+  extern uch ZLIB_INTERNAL _dist_code[];
 #else
-  extern const uch _length_code[];
-  extern const uch _dist_code[];
+  extern const uch ZLIB_INTERNAL _length_code[];
+  extern const uch ZLIB_INTERNAL _dist_code[];
 #endif
 
 # define _tr_tally_lit(s, c, flush) \
diff --git a/jdk/src/share/native/java/util/zip/zlib-1.2.3/inffast.h b/jdk/src/share/native/java/util/zip/zlib-1.2.5/gzclose.c
similarity index 66%
copy from jdk/src/share/native/java/util/zip/zlib-1.2.3/inffast.h
copy to jdk/src/share/native/java/util/zip/zlib-1.2.5/gzclose.c
index c45d087..5cce4b0 100644
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/inffast.h
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/gzclose.c
@@ -22,14 +22,28 @@
  * questions.
  */
 
-/* inffast.h -- header to use inffast.c
- * Copyright (C) 1995-2003 Mark Adler
+/* gzclose.c -- zlib gzclose() function
+ * Copyright (C) 2004, 2010 Mark Adler
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
-/* WARNING: this file should *not* be used by applications. It is
-   part of the implementation of the compression library and is
-   subject to change. Applications should only use zlib.h.
- */
+#include "gzguts.h"
 
-void inflate_fast OF((z_streamp strm, unsigned start));
+/* gzclose() is in a separate file so that it is linked in only if it is used.
+   That way the other gzclose functions can be used instead to avoid linking in
+   unneeded compression or decompression routines. */
+int ZEXPORT gzclose(file)
+    gzFile file;
+{
+#ifndef NO_GZCOMPRESS
+    gz_statep state;
+
+    if (file == NULL)
+        return Z_STREAM_ERROR;
+    state = (gz_statep)file;
+
+    return state->mode == GZ_READ ? gzclose_r(file) : gzclose_w(file);
+#else
+    return gzclose_r(file);
+#endif
+}
diff --git a/jdk/src/share/native/java/util/zip/zlib-1.2.5/gzguts.h b/jdk/src/share/native/java/util/zip/zlib-1.2.5/gzguts.h
new file mode 100644
index 0000000..d8fbf1e
--- /dev/null
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/gzguts.h
@@ -0,0 +1,156 @@
+/*
+ * 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.
+ */
+
+/* gzguts.h -- zlib internal header definitions for gz* operations
+ * Copyright (C) 2004, 2005, 2010 Mark Adler
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+#ifdef _LARGEFILE64_SOURCE
+#  ifndef _LARGEFILE_SOURCE
+#    define _LARGEFILE_SOURCE 1
+#  endif
+#  ifdef _FILE_OFFSET_BITS
+#    undef _FILE_OFFSET_BITS
+#  endif
+#endif
+
+#if ((__GNUC__-0) * 10 + __GNUC_MINOR__-0 >= 33) && !defined(NO_VIZ)
+#  define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
+#else
+#  define ZLIB_INTERNAL
+#endif
+
+#include <stdio.h>
+#include "zlib.h"
+#ifdef STDC
+#  include <string.h>
+#  include <stdlib.h>
+#  include <limits.h>
+#endif
+#include <fcntl.h>
+
+#ifdef NO_DEFLATE       /* for compatibility with old definition */
+#  define NO_GZCOMPRESS
+#endif
+
+#ifdef _MSC_VER
+#  include <io.h>
+#  define vsnprintf _vsnprintf
+#endif
+
+#ifndef local
+#  define local static
+#endif
+/* compile with -Dlocal if your debugger can't find static symbols */
+
+/* gz* functions always use library allocation functions */
+#ifndef STDC
+  extern voidp  malloc OF((uInt size));
+  extern void   free   OF((voidpf ptr));
+#endif
+
+/* get errno and strerror definition */
+#if defined UNDER_CE
+#  include <windows.h>
+#  define zstrerror() gz_strwinerror((DWORD)GetLastError())
+#else
+#  ifdef STDC
+#    include <errno.h>
+#    define zstrerror() strerror(errno)
+#  else
+#    define zstrerror() "stdio error (consult errno)"
+#  endif
+#endif
+
+/* provide prototypes for these when building zlib without LFS */
+#if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0
+    ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
+    ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int));
+    ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile));
+    ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile));
+#endif
+
+/* default i/o buffer size -- double this for output when reading */
+#define GZBUFSIZE 8192
+
+/* gzip modes, also provide a little integrity check on the passed structure */
+#define GZ_NONE 0
+#define GZ_READ 7247
+#define GZ_WRITE 31153
+#define GZ_APPEND 1     /* mode set to GZ_WRITE after the file is opened */
+
+/* values for gz_state how */
+#define LOOK 0      /* look for a gzip header */
+#define COPY 1      /* copy input directly */
+#define GZIP 2      /* decompress a gzip stream */
+
+/* internal gzip file state data structure */
+typedef struct {
+        /* used for both reading and writing */
+    int mode;               /* see gzip modes above */
+    int fd;                 /* file descriptor */
+    char *path;             /* path or fd for error messages */
+    z_off64_t pos;          /* current position in uncompressed data */
+    unsigned size;          /* buffer size, zero if not allocated yet */
+    unsigned want;          /* requested buffer size, default is GZBUFSIZE */
+    unsigned char *in;      /* input buffer */
+    unsigned char *out;     /* output buffer (double-sized when reading) */
+    unsigned char *next;    /* next output data to deliver or write */
+        /* just for reading */
+    unsigned have;          /* amount of output data unused at next */
+    int eof;                /* true if end of input file reached */
+    z_off64_t start;        /* where the gzip data started, for rewinding */
+    z_off64_t raw;          /* where the raw data started, for seeking */
+    int how;                /* 0: get header, 1: copy, 2: decompress */
+    int direct;             /* true if last read direct, false if gzip */
+        /* just for writing */
+    int level;              /* compression level */
+    int strategy;           /* compression strategy */
+        /* seek request */
+    z_off64_t skip;         /* amount to skip (already rewound if backwards) */
+    int seek;               /* true if seek request pending */
+        /* error information */
+    int err;                /* error code */
+    char *msg;              /* error message */
+        /* zlib inflate or deflate stream */
+    z_stream strm;          /* stream structure in-place (not a pointer) */
+} gz_state;
+typedef gz_state FAR *gz_statep;
+
+/* shared functions */
+void ZLIB_INTERNAL gz_error OF((gz_statep, int, const char *));
+#if defined UNDER_CE
+char ZLIB_INTERNAL *gz_strwinerror OF((DWORD error));
+#endif
+
+/* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t
+   value -- needed when comparing unsigned to z_off64_t, which is signed
+   (possible z_off64_t types off_t, off64_t, and long are all signed) */
+#ifdef INT_MAX
+#  define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > INT_MAX)
+#else
+unsigned ZLIB_INTERNAL gz_intmax OF((void));
+#  define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax())
+#endif
diff --git a/jdk/src/share/native/java/util/zip/zlib-1.2.5/gzlib.c b/jdk/src/share/native/java/util/zip/zlib-1.2.5/gzlib.c
new file mode 100644
index 0000000..d285126
--- /dev/null
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/gzlib.c
@@ -0,0 +1,560 @@
+/* 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.
+ */
+
+/*
+ * Copyright (C) 2004, 2010 Mark Adler
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+#include "gzguts.h"
+
+#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
+#  define LSEEK lseek64
+#else
+#  define LSEEK lseek
+#endif
+
+/* Local functions */
+local void gz_reset OF((gz_statep));
+local gzFile gz_open OF((const char *, int, const char *));
+
+#if defined UNDER_CE
+
+/* Map the Windows error number in ERROR to a locale-dependent error message
+   string and return a pointer to it.  Typically, the values for ERROR come
+   from GetLastError.
+
+   The string pointed to shall not be modified by the application, but may be
+   overwritten by a subsequent call to gz_strwinerror
+
+   The gz_strwinerror function does not change the current setting of
+   GetLastError. */
+char ZLIB_INTERNAL *gz_strwinerror (error)
+     DWORD error;
+{
+    static char buf[1024];
+
+    wchar_t *msgbuf;
+    DWORD lasterr = GetLastError();
+    DWORD chars = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM
+        | FORMAT_MESSAGE_ALLOCATE_BUFFER,
+        NULL,
+        error,
+        0, /* Default language */
+        (LPVOID)&msgbuf,
+        0,
+        NULL);
+    if (chars != 0) {
+        /* If there is an \r\n appended, zap it.  */
+        if (chars >= 2
+            && msgbuf[chars - 2] == '\r' && msgbuf[chars - 1] == '\n') {
+            chars -= 2;
+            msgbuf[chars] = 0;
+        }
+
+        if (chars > sizeof (buf) - 1) {
+            chars = sizeof (buf) - 1;
+            msgbuf[chars] = 0;
+        }
+
+        wcstombs(buf, msgbuf, chars + 1);
+        LocalFree(msgbuf);
+    }
+    else {
+        sprintf(buf, "unknown win32 error (%ld)", error);
+    }
+
+    SetLastError(lasterr);
+    return buf;
+}
+
+#endif /* UNDER_CE */
+
+/* Reset gzip file state */
+local void gz_reset(state)
+    gz_statep state;
+{
+    if (state->mode == GZ_READ) {   /* for reading ... */
+        state->have = 0;            /* no output data available */
+        state->eof = 0;             /* not at end of file */
+        state->how = LOOK;          /* look for gzip header */
+        state->direct = 1;          /* default for empty file */
+    }
+    state->seek = 0;                /* no seek request pending */
+    gz_error(state, Z_OK, NULL);    /* clear error */
+    state->pos = 0;                 /* no uncompressed data yet */
+    state->strm.avail_in = 0;       /* no input data yet */
+}
+
+/* Open a gzip file either by name or file descriptor. */
+local gzFile gz_open(path, fd, mode)
+    const char *path;
+    int fd;
+    const char *mode;
+{
+    gz_statep state;
+
+    /* allocate gzFile structure to return */
+    state = malloc(sizeof(gz_state));
+    if (state == NULL)
+        return NULL;
+    state->size = 0;            /* no buffers allocated yet */
+    state->want = GZBUFSIZE;    /* requested buffer size */
+    state->msg = NULL;          /* no error message yet */
+
+    /* interpret mode */
+    state->mode = GZ_NONE;
+    state->level = Z_DEFAULT_COMPRESSION;
+    state->strategy = Z_DEFAULT_STRATEGY;
+    while (*mode) {
+        if (*mode >= '0' && *mode <= '9')
+            state->level = *mode - '0';
+        else
+            switch (*mode) {
+            case 'r':
+                state->mode = GZ_READ;
+                break;
+#ifndef NO_GZCOMPRESS
+            case 'w':
+                state->mode = GZ_WRITE;
+                break;
+            case 'a':
+                state->mode = GZ_APPEND;
+                break;
+#endif
+            case '+':       /* can't read and write at the same time */
+                free(state);
+                return NULL;
+            case 'b':       /* ignore -- will request binary anyway */
+                break;
+            case 'f':
+                state->strategy = Z_FILTERED;
+                break;
+            case 'h':
+                state->strategy = Z_HUFFMAN_ONLY;
+                break;
+            case 'R':
+                state->strategy = Z_RLE;
+                break;
+            case 'F':
+                state->strategy = Z_FIXED;
+            default:        /* could consider as an error, but just ignore */
+                ;
+            }
+        mode++;
+    }
+
+    /* must provide an "r", "w", or "a" */
+    if (state->mode == GZ_NONE) {
+        free(state);
+        return NULL;
+    }
+
+    /* save the path name for error messages */
+    state->path = malloc(strlen(path) + 1);
+    if (state->path == NULL) {
+        free(state);
+        return NULL;
+    }
+    strcpy(state->path, path);
+
+    /* open the file with the appropriate mode (or just use fd) */
+    state->fd = fd != -1 ? fd :
+        open(path,
+#ifdef O_LARGEFILE
+            O_LARGEFILE |
+#endif
+#ifdef O_BINARY
+            O_BINARY |
+#endif
+            (state->mode == GZ_READ ?
+                O_RDONLY :
+                (O_WRONLY | O_CREAT | (
+                    state->mode == GZ_WRITE ?
+                        O_TRUNC :
+                        O_APPEND))),
+            0666);
+    if (state->fd == -1) {
+        free(state->path);
+        free(state);
+        return NULL;
+    }
+    if (state->mode == GZ_APPEND)
+        state->mode = GZ_WRITE;         /* simplify later checks */
+
+    /* save the current position for rewinding (only if reading) */
+    if (state->mode == GZ_READ) {
+        state->start = LSEEK(state->fd, 0, SEEK_CUR);
+        if (state->start == -1) state->start = 0;
+    }
+
+    /* initialize stream */
+    gz_reset(state);
+
+    /* return stream */
+    return (gzFile)state;
+}
+
+/* -- see zlib.h -- */
+gzFile ZEXPORT gzopen(path, mode)
+    const char *path;
+    const char *mode;
+{
+    return gz_open(path, -1, mode);
+}
+
+/* -- see zlib.h -- */
+gzFile ZEXPORT gzopen64(path, mode)
+    const char *path;
+    const char *mode;
+{
+    return gz_open(path, -1, mode);
+}
+
+/* -- see zlib.h -- */
+gzFile ZEXPORT gzdopen(fd, mode)
+    int fd;
+    const char *mode;
+{
+    char *path;         /* identifier for error messages */
+    gzFile gz;
+
+    if (fd == -1 || (path = malloc(7 + 3 * sizeof(int))) == NULL)
+        return NULL;
+    sprintf(path, "<fd:%d>", fd);   /* for debugging */
+    gz = gz_open(path, fd, mode);
+    free(path);
+    return gz;
+}
+
+/* -- see zlib.h -- */
+int ZEXPORT gzbuffer(file, size)
+    gzFile file;
+    unsigned size;
+{
+    gz_statep state;
+
+    /* get internal structure and check integrity */
+    if (file == NULL)
+        return -1;
+    state = (gz_statep)file;
+    if (state->mode != GZ_READ && state->mode != GZ_WRITE)
+        return -1;
+
+    /* make sure we haven't already allocated memory */
+    if (state->size != 0)
+        return -1;
+
+    /* check and set requested size */
+    if (size == 0)
+        return -1;
+    state->want = size;
+    return 0;
+}
+
+/* -- see zlib.h -- */
+int ZEXPORT gzrewind(file)
+    gzFile file;
+{
+    gz_statep state;
+
+    /* get internal structure */
+    if (file == NULL)
+        return -1;
+    state = (gz_statep)file;
+
+    /* check that we're reading and that there's no error */
+    if (state->mode != GZ_READ || state->err != Z_OK)
+        return -1;
+
+    /* back up and start over */
+    if (LSEEK(state->fd, state->start, SEEK_SET) == -1)
+        return -1;
+    gz_reset(state);
+    return 0;
+}
+
+/* -- see zlib.h -- */
+z_off64_t ZEXPORT gzseek64(file, offset, whence)
+    gzFile file;
+    z_off64_t offset;
+    int whence;
+{
+    unsigned n;
+    z_off64_t ret;
+    gz_statep state;
+
+    /* get internal structure and check integrity */
+    if (file == NULL)
+        return -1;
+    state = (gz_statep)file;
+    if (state->mode != GZ_READ && state->mode != GZ_WRITE)
+        return -1;
+
+    /* check that there's no error */
+    if (state->err != Z_OK)
+        return -1;
+
+    /* can only seek from start or relative to current position */
+    if (whence != SEEK_SET && whence != SEEK_CUR)
+        return -1;
+
+    /* normalize offset to a SEEK_CUR specification */
+    if (whence == SEEK_SET)
+        offset -= state->pos;
+    else if (state->seek)
+        offset += state->skip;
+    state->seek = 0;
+
+    /* if within raw area while reading, just go there */
+    if (state->mode == GZ_READ && state->how == COPY &&
+        state->pos + offset >= state->raw) {
+        ret = LSEEK(state->fd, offset - state->have, SEEK_CUR);
+        if (ret == -1)
+            return -1;
+        state->have = 0;
+        state->eof = 0;
+        state->seek = 0;
+        gz_error(state, Z_OK, NULL);
+        state->strm.avail_in = 0;
+        state->pos += offset;
+        return state->pos;
+    }
+
+    /* calculate skip amount, rewinding if needed for back seek when reading */
+    if (offset < 0) {
+        if (state->mode != GZ_READ)         /* writing -- can't go backwards */
+            return -1;
+        offset += state->pos;
+        if (offset < 0)                     /* before start of file! */
+            return -1;
+        if (gzrewind(file) == -1)           /* rewind, then skip to offset */
+            return -1;
+    }
+
+    /* if reading, skip what's in output buffer (one less gzgetc() check) */
+    if (state->mode == GZ_READ) {
+        n = GT_OFF(state->have) || (z_off64_t)state->have > offset ?
+            (unsigned)offset : state->have;
+        state->have -= n;
+        state->next += n;
+        state->pos += n;
+        offset -= n;
+    }
+
+    /* request skip (if not zero) */
+    if (offset) {
+        state->seek = 1;
+        state->skip = offset;
+    }
+    return state->pos + offset;
+}
+
+/* -- see zlib.h -- */
+z_off_t ZEXPORT gzseek(file, offset, whence)
+    gzFile file;
+    z_off_t offset;
+    int whence;
+{
+    z_off64_t ret;
+
+    ret = gzseek64(file, (z_off64_t)offset, whence);
+    return ret == (z_off_t)ret ? (z_off_t)ret : -1;
+}
+
+/* -- see zlib.h -- */
+z_off64_t ZEXPORT gztell64(file)
+    gzFile file;
+{
+    gz_statep state;
+
+    /* get internal structure and check integrity */
+    if (file == NULL)
+        return -1;
+    state = (gz_statep)file;
+    if (state->mode != GZ_READ && state->mode != GZ_WRITE)
+        return -1;
+
+    /* return position */
+    return state->pos + (state->seek ? state->skip : 0);
+}
+
+/* -- see zlib.h -- */
+z_off_t ZEXPORT gztell(file)
+    gzFile file;
+{
+    z_off64_t ret;
+
+    ret = gztell64(file);
+    return ret == (z_off_t)ret ? (z_off_t)ret : -1;
+}
+
+/* -- see zlib.h -- */
+z_off64_t ZEXPORT gzoffset64(file)
+    gzFile file;
+{
+    z_off64_t offset;
+    gz_statep state;
+
+    /* get internal structure and check integrity */
+    if (file == NULL)
+        return -1;
+    state = (gz_statep)file;
+    if (state->mode != GZ_READ && state->mode != GZ_WRITE)
+        return -1;
+
+    /* compute and return effective offset in file */
+    offset = LSEEK(state->fd, 0, SEEK_CUR);
+    if (offset == -1)
+        return -1;
+    if (state->mode == GZ_READ)             /* reading */
+        offset -= state->strm.avail_in;     /* don't count buffered input */
+    return offset;
+}
+
+/* -- see zlib.h -- */
+z_off_t ZEXPORT gzoffset(file)
+    gzFile file;
+{
+    z_off64_t ret;
+
+    ret = gzoffset64(file);
+    return ret == (z_off_t)ret ? (z_off_t)ret : -1;
+}
+
+/* -- see zlib.h -- */
+int ZEXPORT gzeof(file)
+    gzFile file;
+{
+    gz_statep state;
+
+    /* get internal structure and check integrity */
+    if (file == NULL)
+        return 0;
+    state = (gz_statep)file;
+    if (state->mode != GZ_READ && state->mode != GZ_WRITE)
+        return 0;
+
+    /* return end-of-file state */
+    return state->mode == GZ_READ ?
+        (state->eof && state->strm.avail_in == 0 && state->have == 0) : 0;
+}
+
+/* -- see zlib.h -- */
+const char * ZEXPORT gzerror(file, errnum)
+    gzFile file;
+    int *errnum;
+{
+    gz_statep state;
+
+    /* get internal structure and check integrity */
+    if (file == NULL)
+        return NULL;
+    state = (gz_statep)file;
+    if (state->mode != GZ_READ && state->mode != GZ_WRITE)
+        return NULL;
+
+    /* return error information */
+    if (errnum != NULL)
+        *errnum = state->err;
+    return state->msg == NULL ? "" : state->msg;
+}
+
+/* -- see zlib.h -- */
+void ZEXPORT gzclearerr(file)
+    gzFile file;
+{
+    gz_statep state;
+
+    /* get internal structure and check integrity */
+    if (file == NULL)
+        return;
+    state = (gz_statep)file;
+    if (state->mode != GZ_READ && state->mode != GZ_WRITE)
+        return;
+
+    /* clear error and end-of-file */
+    if (state->mode == GZ_READ)
+        state->eof = 0;
+    gz_error(state, Z_OK, NULL);
+}
+
+/* Create an error message in allocated memory and set state->err and
+   state->msg accordingly.  Free any previous error message already there.  Do
+   not try to free or allocate space if the error is Z_MEM_ERROR (out of
+   memory).  Simply save the error message as a static string.  If there is an
+   allocation failure constructing the error message, then convert the error to
+   out of memory. */
+void ZLIB_INTERNAL gz_error(state, err, msg)
+    gz_statep state;
+    int err;
+    const char *msg;
+{
+    /* free previously allocated message and clear */
+    if (state->msg != NULL) {
+        if (state->err != Z_MEM_ERROR)
+            free(state->msg);
+        state->msg = NULL;
+    }
+
+    /* set error code, and if no message, then done */
+    state->err = err;
+    if (msg == NULL)
+        return;
+
+    /* for an out of memory error, save as static string */
+    if (err == Z_MEM_ERROR) {
+        state->msg = (char *)msg;
+        return;
+    }
+
+    /* construct error message with path */
+    if ((state->msg = malloc(strlen(state->path) + strlen(msg) + 3)) == NULL) {
+        state->err = Z_MEM_ERROR;
+        state->msg = (char *)"out of memory";
+        return;
+    }
+    strcpy(state->msg, state->path);
+    strcat(state->msg, ": ");
+    strcat(state->msg, msg);
+    return;
+}
+
+#ifndef INT_MAX
+/* portably return maximum value for an int (when limits.h presumed not
+   available) -- we need to do this to cover cases where 2's complement not
+   used, since C standard permits 1's complement and sign-bit representations,
+   otherwise we could just use ((unsigned)-1) >> 1 */
+unsigned ZLIB_INTERNAL gz_intmax()
+{
+    unsigned p, q;
+
+    p = 1;
+    do {
+        q = p;
+        p <<= 1;
+        p++;
+    } while (p > q);
+    return q >> 1;
+}
+#endif
diff --git a/jdk/src/share/native/java/util/zip/zlib-1.2.5/gzread.c b/jdk/src/share/native/java/util/zip/zlib-1.2.5/gzread.c
new file mode 100644
index 0000000..15e8502
--- /dev/null
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/gzread.c
@@ -0,0 +1,677 @@
+/*
+ * 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.
+ */
+
+/* gzread.c -- zlib functions for reading gzip files
+ * Copyright (C) 2004, 2005, 2010 Mark Adler
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+#include "gzguts.h"
+
+/* Local functions */
+local int gz_load OF((gz_statep, unsigned char *, unsigned, unsigned *));
+local int gz_avail OF((gz_statep));
+local int gz_next4 OF((gz_statep, unsigned long *));
+local int gz_head OF((gz_statep));
+local int gz_decomp OF((gz_statep));
+local int gz_make OF((gz_statep));
+local int gz_skip OF((gz_statep, z_off64_t));
+
+/* Use read() to load a buffer -- return -1 on error, otherwise 0.  Read from
+   state->fd, and update state->eof, state->err, and state->msg as appropriate.
+   This function needs to loop on read(), since read() is not guaranteed to
+   read the number of bytes requested, depending on the type of descriptor. */
+local int gz_load(state, buf, len, have)
+    gz_statep state;
+    unsigned char *buf;
+    unsigned len;
+    unsigned *have;
+{
+    int ret;
+
+    *have = 0;
+    do {
+        ret = read(state->fd, buf + *have, len - *have);
+        if (ret <= 0)
+            break;
+        *have += ret;
+    } while (*have < len);
+    if (ret < 0) {
+        gz_error(state, Z_ERRNO, zstrerror());
+        return -1;
+    }
+    if (ret == 0)
+        state->eof = 1;
+    return 0;
+}
+
+/* Load up input buffer and set eof flag if last data loaded -- return -1 on
+   error, 0 otherwise.  Note that the eof flag is set when the end of the input
+   file is reached, even though there may be unused data in the buffer.  Once
+   that data has been used, no more attempts will be made to read the file.
+   gz_avail() assumes that strm->avail_in == 0. */
+local int gz_avail(state)
+    gz_statep state;
+{
+    z_streamp strm = &(state->strm);
+
+    if (state->err != Z_OK)
+        return -1;
+    if (state->eof == 0) {
+        if (gz_load(state, state->in, state->size,
+                (unsigned *)&(strm->avail_in)) == -1)
+            return -1;
+        strm->next_in = state->in;
+    }
+    return 0;
+}
+
+/* Get next byte from input, or -1 if end or error. */
+#define NEXT() ((strm->avail_in == 0 && gz_avail(state) == -1) ? -1 : \
+                (strm->avail_in == 0 ? -1 : \
+                 (strm->avail_in--, *(strm->next_in)++)))
+
+/* Get a four-byte little-endian integer and return 0 on success and the value
+   in *ret.  Otherwise -1 is returned and *ret is not modified. */
+local int gz_next4(state, ret)
+    gz_statep state;
+    unsigned long *ret;
+{
+    int ch;
+    unsigned long val;
+    z_streamp strm = &(state->strm);
+
+    val = NEXT();
+    val += (unsigned)NEXT() << 8;
+    val += (unsigned long)NEXT() << 16;
+    ch = NEXT();
+    if (ch == -1)
+        return -1;
+    val += (unsigned long)ch << 24;
+    *ret = val;
+    return 0;
+}
+
+/* Look for gzip header, set up for inflate or copy.  state->have must be zero.
+   If this is the first time in, allocate required memory.  state->how will be
+   left unchanged if there is no more input data available, will be set to COPY
+   if there is no gzip header and direct copying will be performed, or it will
+   be set to GZIP for decompression, and the gzip header will be skipped so
+   that the next available input data is the raw deflate stream.  If direct
+   copying, then leftover input data from the input buffer will be copied to
+   the output buffer.  In that case, all further file reads will be directly to
+   either the output buffer or a user buffer.  If decompressing, the inflate
+   state and the check value will be initialized.  gz_head() will return 0 on
+   success or -1 on failure.  Failures may include read errors or gzip header
+   errors.  */
+local int gz_head(state)
+    gz_statep state;
+{
+    z_streamp strm = &(state->strm);
+    int flags;
+    unsigned len;
+
+    /* allocate read buffers and inflate memory */
+    if (state->size == 0) {
+        /* allocate buffers */
+        state->in = malloc(state->want);
+        state->out = malloc(state->want << 1);
+        if (state->in == NULL || state->out == NULL) {
+            if (state->out != NULL)
+                free(state->out);
+            if (state->in != NULL)
+                free(state->in);
+            gz_error(state, Z_MEM_ERROR, "out of memory");
+            return -1;
+        }
+        state->size = state->want;
+
+        /* allocate inflate memory */
+        state->strm.zalloc = Z_NULL;
+        state->strm.zfree = Z_NULL;
+        state->strm.opaque = Z_NULL;
+        state->strm.avail_in = 0;
+        state->strm.next_in = Z_NULL;
+        if (inflateInit2(&(state->strm), -15) != Z_OK) {    /* raw inflate */
+            free(state->out);
+            free(state->in);
+            state->size = 0;
+            gz_error(state, Z_MEM_ERROR, "out of memory");
+            return -1;
+        }
+    }
+
+    /* get some data in the input buffer */
+    if (strm->avail_in == 0) {
+        if (gz_avail(state) == -1)
+            return -1;
+        if (strm->avail_in == 0)
+            return 0;
+    }
+
+    /* look for the gzip magic header bytes 31 and 139 */
+    if (strm->next_in[0] == 31) {
+        strm->avail_in--;
+        strm->next_in++;
+        if (strm->avail_in == 0 && gz_avail(state) == -1)
+            return -1;
+        if (strm->avail_in && strm->next_in[0] == 139) {
+            /* we have a gzip header, woo hoo! */
+            strm->avail_in--;
+            strm->next_in++;
+
+            /* skip rest of header */
+            if (NEXT() != 8) {      /* compression method */
+                gz_error(state, Z_DATA_ERROR, "unknown compression method");
+                return -1;
+            }
+            flags = NEXT();
+            if (flags & 0xe0) {     /* reserved flag bits */
+                gz_error(state, Z_DATA_ERROR, "unknown header flags set");
+                return -1;
+            }
+            NEXT();                 /* modification time */
+            NEXT();
+            NEXT();
+            NEXT();
+            NEXT();                 /* extra flags */
+            NEXT();                 /* operating system */
+            if (flags & 4) {        /* extra field */
+                len = (unsigned)NEXT();
+                len += (unsigned)NEXT() << 8;
+                while (len--)
+                    if (NEXT() < 0)
+                        break;
+            }
+            if (flags & 8)          /* file name */
+                while (NEXT() > 0)
+                    ;
+            if (flags & 16)         /* comment */
+                while (NEXT() > 0)
+                    ;
+            if (flags & 2) {        /* header crc */
+                NEXT();
+                NEXT();
+            }
+            /* an unexpected end of file is not checked for here -- it will be
+               noticed on the first request for uncompressed data */
+
+            /* set up for decompression */
+            inflateReset(strm);
+            strm->adler = crc32(0L, Z_NULL, 0);
+            state->how = GZIP;
+            state->direct = 0;
+            return 0;
+        }
+        else {
+            /* not a gzip file -- save first byte (31) and fall to raw i/o */
+            state->out[0] = 31;
+            state->have = 1;
+        }
+    }
+
+    /* doing raw i/o, save start of raw data for seeking, copy any leftover
+       input to output -- this assumes that the output buffer is larger than
+       the input buffer, which also assures space for gzungetc() */
+    state->raw = state->pos;
+    state->next = state->out;
+    if (strm->avail_in) {
+        memcpy(state->next + state->have, strm->next_in, strm->avail_in);
+        state->have += strm->avail_in;
+        strm->avail_in = 0;
+    }
+    state->how = COPY;
+    state->direct = 1;
+    return 0;
+}
+
+/* Decompress from input to the provided next_out and avail_out in the state.
+   If the end of the compressed data is reached, then verify the gzip trailer
+   check value and length (modulo 2^32).  state->have and state->next are set
+   to point to the just decompressed data, and the crc is updated.  If the
+   trailer is verified, state->how is reset to LOOK to look for the next gzip
+   stream or raw data, once state->have is depleted.  Returns 0 on success, -1
+   on failure.  Failures may include invalid compressed data or a failed gzip
+   trailer verification. */
+local int gz_decomp(state)
+    gz_statep state;
+{
+    int ret;
+    unsigned had;
+    unsigned long crc, len;
+    z_streamp strm = &(state->strm);
+
+    /* fill output buffer up to end of deflate stream */
+    had = strm->avail_out;
+    do {
+        /* get more input for inflate() */
+        if (strm->avail_in == 0 && gz_avail(state) == -1)
+            return -1;
+        if (strm->avail_in == 0) {
+            gz_error(state, Z_DATA_ERROR, "unexpected end of file");
+            return -1;
+        }
+
+        /* decompress and handle errors */
+        ret = inflate(strm, Z_NO_FLUSH);
+        if (ret == Z_STREAM_ERROR || ret == Z_NEED_DICT) {
+            gz_error(state, Z_STREAM_ERROR,
+                      "internal error: inflate stream corrupt");
+            return -1;
+        }
+        if (ret == Z_MEM_ERROR) {
+            gz_error(state, Z_MEM_ERROR, "out of memory");
+            return -1;
+        }
+        if (ret == Z_DATA_ERROR) {              /* deflate stream invalid */
+            gz_error(state, Z_DATA_ERROR,
+                      strm->msg == NULL ? "compressed data error" : strm->msg);
+            return -1;
+        }
+    } while (strm->avail_out && ret != Z_STREAM_END);
+
+    /* update available output and crc check value */
+    state->have = had - strm->avail_out;
+    state->next = strm->next_out - state->have;
+    strm->adler = crc32(strm->adler, state->next, state->have);
+
+    /* check gzip trailer if at end of deflate stream */
+    if (ret == Z_STREAM_END) {
+        if (gz_next4(state, &crc) == -1 || gz_next4(state, &len) == -1) {
+            gz_error(state, Z_DATA_ERROR, "unexpected end of file");
+            return -1;
+        }
+        if (crc != strm->adler) {
+            gz_error(state, Z_DATA_ERROR, "incorrect data check");
+            return -1;
+        }
+        if (len != (strm->total_out & 0xffffffffL)) {
+            gz_error(state, Z_DATA_ERROR, "incorrect length check");
+            return -1;
+        }
+        state->how = LOOK;      /* ready for next stream, once have is 0 (leave
+                                   state->direct unchanged to remember how) */
+    }
+
+    /* good decompression */
+    return 0;
+}
+
+/* Make data and put in the output buffer.  Assumes that state->have == 0.
+   Data is either copied from the input file or decompressed from the input
+   file depending on state->how.  If state->how is LOOK, then a gzip header is
+   looked for (and skipped if found) to determine wither to copy or decompress.
+   Returns -1 on error, otherwise 0.  gz_make() will leave state->have as COPY
+   or GZIP unless the end of the input file has been reached and all data has
+   been processed.  */
+local int gz_make(state)
+    gz_statep state;
+{
+    z_streamp strm = &(state->strm);
+
+    if (state->how == LOOK) {           /* look for gzip header */
+        if (gz_head(state) == -1)
+            return -1;
+        if (state->have)                /* got some data from gz_head() */
+            return 0;
+    }
+    if (state->how == COPY) {           /* straight copy */
+        if (gz_load(state, state->out, state->size << 1, &(state->have)) == -1)
+            return -1;
+        state->next = state->out;
+    }
+    else if (state->how == GZIP) {      /* decompress */
+        strm->avail_out = state->size << 1;
+        strm->next_out = state->out;
+        if (gz_decomp(state) == -1)
+            return -1;
+    }
+    return 0;
+}
+
+/* Skip len uncompressed bytes of output.  Return -1 on error, 0 on success. */
+local int gz_skip(state, len)
+    gz_statep state;
+    z_off64_t len;
+{
+    unsigned n;
+
+    /* skip over len bytes or reach end-of-file, whichever comes first */
+    while (len)
+        /* skip over whatever is in output buffer */
+        if (state->have) {
+            n = GT_OFF(state->have) || (z_off64_t)state->have > len ?
+                (unsigned)len : state->have;
+            state->have -= n;
+            state->next += n;
+            state->pos += n;
+            len -= n;
+        }
+
+        /* output buffer empty -- return if we're at the end of the input */
+        else if (state->eof && state->strm.avail_in == 0)
+            break;
+
+        /* need more data to skip -- load up output buffer */
+        else {
+            /* get more output, looking for header if required */
+            if (gz_make(state) == -1)
+                return -1;
+        }
+    return 0;
+}
+
+/* -- see zlib.h -- */
+int ZEXPORT gzread(file, buf, len)
+    gzFile file;
+    voidp buf;
+    unsigned len;
+{
+    unsigned got, n;
+    gz_statep state;
+    z_streamp strm;
+
+    /* get internal structure */
+    if (file == NULL)
+        return -1;
+    state = (gz_statep)file;
+    strm = &(state->strm);
+
+    /* check that we're reading and that there's no error */
+    if (state->mode != GZ_READ || state->err != Z_OK)
+        return -1;
+
+    /* since an int is returned, make sure len fits in one, otherwise return
+       with an error (this avoids the flaw in the interface) */
+    if ((int)len < 0) {
+        gz_error(state, Z_BUF_ERROR, "requested length does not fit in int");
+        return -1;
+    }
+
+    /* if len is zero, avoid unnecessary operations */
+    if (len == 0)
+        return 0;
+
+    /* process a skip request */
+    if (state->seek) {
+        state->seek = 0;
+        if (gz_skip(state, state->skip) == -1)
+            return -1;
+    }
+
+    /* get len bytes to buf, or less than len if at the end */
+    got = 0;
+    do {
+        /* first just try copying data from the output buffer */
+        if (state->have) {
+            n = state->have > len ? len : state->have;
+            memcpy(buf, state->next, n);
+            state->next += n;
+            state->have -= n;
+        }
+
+        /* output buffer empty -- return if we're at the end of the input */
+        else if (state->eof && strm->avail_in == 0)
+            break;
+
+        /* need output data -- for small len or new stream load up our output
+           buffer */
+        else if (state->how == LOOK || len < (state->size << 1)) {
+            /* get more output, looking for header if required */
+            if (gz_make(state) == -1)
+                return -1;
+            continue;       /* no progress yet -- go back to memcpy() above */
+            /* the copy above assures that we will leave with space in the
+               output buffer, allowing at least one gzungetc() to succeed */
+        }
+
+        /* large len -- read directly into user buffer */
+        else if (state->how == COPY) {      /* read directly */
+            if (gz_load(state, buf, len, &n) == -1)
+                return -1;
+        }
+
+        /* large len -- decompress directly into user buffer */
+        else {  /* state->how == GZIP */
+            strm->avail_out = len;
+            strm->next_out = buf;
+            if (gz_decomp(state) == -1)
+                return -1;
+            n = state->have;
+            state->have = 0;
+        }
+
+        /* update progress */
+        len -= n;
+        buf = (char *)buf + n;
+        got += n;
+        state->pos += n;
+    } while (len);
+
+    /* return number of bytes read into user buffer (will fit in int) */
+    return (int)got;
+}
+
+/* -- see zlib.h -- */
+int ZEXPORT gzgetc(file)
+    gzFile file;
+{
+    int ret;
+    unsigned char buf[1];
+    gz_statep state;
+
+    /* get internal structure */
+    if (file == NULL)
+        return -1;
+    state = (gz_statep)file;
+
+    /* check that we're reading and that there's no error */
+    if (state->mode != GZ_READ || state->err != Z_OK)
+        return -1;
+
+    /* try output buffer (no need to check for skip request) */
+    if (state->have) {
+        state->have--;
+        state->pos++;
+        return *(state->next)++;
+    }
+
+    /* nothing there -- try gzread() */
+    ret = gzread(file, buf, 1);
+    return ret < 1 ? -1 : buf[0];
+}
+
+/* -- see zlib.h -- */
+int ZEXPORT gzungetc(c, file)
+    int c;
+    gzFile file;
+{
+    gz_statep state;
+
+    /* get internal structure */
+    if (file == NULL)
+        return -1;
+    state = (gz_statep)file;
+
+    /* check that we're reading and that there's no error */
+    if (state->mode != GZ_READ || state->err != Z_OK)
+        return -1;
+
+    /* process a skip request */
+    if (state->seek) {
+        state->seek = 0;
+        if (gz_skip(state, state->skip) == -1)
+            return -1;
+    }
+
+    /* can't push EOF */
+    if (c < 0)
+        return -1;
+
+    /* if output buffer empty, put byte at end (allows more pushing) */
+    if (state->have == 0) {
+        state->have = 1;
+        state->next = state->out + (state->size << 1) - 1;
+        state->next[0] = c;
+        state->pos--;
+        return c;
+    }
+
+    /* if no room, give up (must have already done a gzungetc()) */
+    if (state->have == (state->size << 1)) {
+        gz_error(state, Z_BUF_ERROR, "out of room to push characters");
+        return -1;
+    }
+
+    /* slide output data if needed and insert byte before existing data */
+    if (state->next == state->out) {
+        unsigned char *src = state->out + state->have;
+        unsigned char *dest = state->out + (state->size << 1);
+        while (src > state->out)
+            *--dest = *--src;
+        state->next = dest;
+    }
+    state->have++;
+    state->next--;
+    state->next[0] = c;
+    state->pos--;
+    return c;
+}
+
+/* -- see zlib.h -- */
+char * ZEXPORT gzgets(file, buf, len)
+    gzFile file;
+    char *buf;
+    int len;
+{
+    unsigned left, n;
+    char *str;
+    unsigned char *eol;
+    gz_statep state;
+
+    /* check parameters and get internal structure */
+    if (file == NULL || buf == NULL || len < 1)
+        return NULL;
+    state = (gz_statep)file;
+
+    /* check that we're reading and that there's no error */
+    if (state->mode != GZ_READ || state->err != Z_OK)
+        return NULL;
+
+    /* process a skip request */
+    if (state->seek) {
+        state->seek = 0;
+        if (gz_skip(state, state->skip) == -1)
+            return NULL;
+    }
+
+    /* copy output bytes up to new line or len - 1, whichever comes first --
+       append a terminating zero to the string (we don't check for a zero in
+       the contents, let the user worry about that) */
+    str = buf;
+    left = (unsigned)len - 1;
+    if (left) do {
+        /* assure that something is in the output buffer */
+        if (state->have == 0) {
+            if (gz_make(state) == -1)
+                return NULL;            /* error */
+            if (state->have == 0) {     /* end of file */
+                if (buf == str)         /* got bupkus */
+                    return NULL;
+                break;                  /* got something -- return it */
+            }
+        }
+
+        /* look for end-of-line in current output buffer */
+        n = state->have > left ? left : state->have;
+        eol = memchr(state->next, '\n', n);
+        if (eol != NULL)
+            n = (unsigned)(eol - state->next) + 1;
+
+        /* copy through end-of-line, or remainder if not found */
+        memcpy(buf, state->next, n);
+        state->have -= n;
+        state->next += n;
+        state->pos += n;
+        left -= n;
+        buf += n;
+    } while (left && eol == NULL);
+
+    /* found end-of-line or out of space -- terminate string and return it */
+    buf[0] = 0;
+    return str;
+}
+
+/* -- see zlib.h -- */
+int ZEXPORT gzdirect(file)
+    gzFile file;
+{
+    gz_statep state;
+
+    /* get internal structure */
+    if (file == NULL)
+        return 0;
+    state = (gz_statep)file;
+
+    /* check that we're reading */
+    if (state->mode != GZ_READ)
+        return 0;
+
+    /* if the state is not known, but we can find out, then do so (this is
+       mainly for right after a gzopen() or gzdopen()) */
+    if (state->how == LOOK && state->have == 0)
+        (void)gz_head(state);
+
+    /* return 1 if reading direct, 0 if decompressing a gzip stream */
+    return state->direct;
+}
+
+/* -- see zlib.h -- */
+int ZEXPORT gzclose_r(file)
+    gzFile file;
+{
+    int ret;
+    gz_statep state;
+
+    /* get internal structure */
+    if (file == NULL)
+        return Z_STREAM_ERROR;
+    state = (gz_statep)file;
+
+    /* check that we're reading */
+    if (state->mode != GZ_READ)
+        return Z_STREAM_ERROR;
+
+    /* free memory and close file */
+    if (state->size) {
+        inflateEnd(&(state->strm));
+        free(state->out);
+        free(state->in);
+    }
+    gz_error(state, Z_OK, NULL);
+    free(state->path);
+    ret = close(state->fd);
+    free(state);
+    return ret ? Z_ERRNO : Z_OK;
+}
diff --git a/jdk/src/share/native/java/util/zip/zlib-1.2.5/gzwrite.c b/jdk/src/share/native/java/util/zip/zlib-1.2.5/gzwrite.c
new file mode 100644
index 0000000..bff643e
--- /dev/null
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/gzwrite.c
@@ -0,0 +1,555 @@
+/*
+ * 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.
+ */
+
+/* gzwrite.c -- zlib functions for writing gzip files
+ * Copyright (C) 2004, 2005, 2010 Mark Adler
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+#include "gzguts.h"
+
+/* Local functions */
+local int gz_init OF((gz_statep));
+local int gz_comp OF((gz_statep, int));
+local int gz_zero OF((gz_statep, z_off64_t));
+
+/* Initialize state for writing a gzip file.  Mark initialization by setting
+   state->size to non-zero.  Return -1 on failure or 0 on success. */
+local int gz_init(state)
+    gz_statep state;
+{
+    int ret;
+    z_streamp strm = &(state->strm);
+
+    /* allocate input and output buffers */
+    state->in = malloc(state->want);
+    state->out = malloc(state->want);
+    if (state->in == NULL || state->out == NULL) {
+        if (state->out != NULL)
+            free(state->out);
+        if (state->in != NULL)
+            free(state->in);
+        gz_error(state, Z_MEM_ERROR, "out of memory");
+        return -1;
+    }
+
+    /* allocate deflate memory, set up for gzip compression */
+    strm->zalloc = Z_NULL;
+    strm->zfree = Z_NULL;
+    strm->opaque = Z_NULL;
+    ret = deflateInit2(strm, state->level, Z_DEFLATED,
+                       15 + 16, 8, state->strategy);
+    if (ret != Z_OK) {
+        free(state->in);
+        gz_error(state, Z_MEM_ERROR, "out of memory");
+        return -1;
+    }
+
+    /* mark state as initialized */
+    state->size = state->want;
+
+    /* initialize write buffer */
+    strm->avail_out = state->size;
+    strm->next_out = state->out;
+    state->next = strm->next_out;
+    return 0;
+}
+
+/* Compress whatever is at avail_in and next_in and write to the output file.
+   Return -1 if there is an error writing to the output file, otherwise 0.
+   flush is assumed to be a valid deflate() flush value.  If flush is Z_FINISH,
+   then the deflate() state is reset to start a new gzip stream. */
+local int gz_comp(state, flush)
+    gz_statep state;
+    int flush;
+{
+    int ret, got;
+    unsigned have;
+    z_streamp strm = &(state->strm);
+
+    /* allocate memory if this is the first time through */
+    if (state->size == 0 && gz_init(state) == -1)
+        return -1;
+
+    /* run deflate() on provided input until it produces no more output */
+    ret = Z_OK;
+    do {
+        /* write out current buffer contents if full, or if flushing, but if
+           doing Z_FINISH then don't write until we get to Z_STREAM_END */
+        if (strm->avail_out == 0 || (flush != Z_NO_FLUSH &&
+            (flush != Z_FINISH || ret == Z_STREAM_END))) {
+            have = (unsigned)(strm->next_out - state->next);
+            if (have && ((got = write(state->fd, state->next, have)) < 0 ||
+                         (unsigned)got != have)) {
+                gz_error(state, Z_ERRNO, zstrerror());
+                return -1;
+            }
+            if (strm->avail_out == 0) {
+                strm->avail_out = state->size;
+                strm->next_out = state->out;
+            }
+            state->next = strm->next_out;
+        }
+
+        /* compress */
+        have = strm->avail_out;
+        ret = deflate(strm, flush);
+        if (ret == Z_STREAM_ERROR) {
+            gz_error(state, Z_STREAM_ERROR,
+                      "internal error: deflate stream corrupt");
+            return -1;
+        }
+        have -= strm->avail_out;
+    } while (have);
+
+    /* if that completed a deflate stream, allow another to start */
+    if (flush == Z_FINISH)
+        deflateReset(strm);
+
+    /* all done, no errors */
+    return 0;
+}
+
+/* Compress len zeros to output.  Return -1 on error, 0 on success. */
+local int gz_zero(state, len)
+    gz_statep state;
+    z_off64_t len;
+{
+    int first;
+    unsigned n;
+    z_streamp strm = &(state->strm);
+
+    /* consume whatever's left in the input buffer */
+    if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1)
+        return -1;
+
+    /* compress len zeros (len guaranteed > 0) */
+    first = 1;
+    while (len) {
+        n = GT_OFF(state->size) || (z_off64_t)state->size > len ?
+            (unsigned)len : state->size;
+        if (first) {
+            memset(state->in, 0, n);
+            first = 0;
+        }
+        strm->avail_in = n;
+        strm->next_in = state->in;
+        state->pos += n;
+        if (gz_comp(state, Z_NO_FLUSH) == -1)
+            return -1;
+        len -= n;
+    }
+    return 0;
+}
+
+/* -- see zlib.h -- */
+int ZEXPORT gzwrite(file, buf, len)
+    gzFile file;
+    voidpc buf;
+    unsigned len;
+{
+    unsigned put = len;
+    unsigned n;
+    gz_statep state;
+    z_streamp strm;
+
+    /* get internal structure */
+    if (file == NULL)
+        return 0;
+    state = (gz_statep)file;
+    strm = &(state->strm);
+
+    /* check that we're writing and that there's no error */
+    if (state->mode != GZ_WRITE || state->err != Z_OK)
+        return 0;
+
+    /* since an int is returned, make sure len fits in one, otherwise return
+       with an error (this avoids the flaw in the interface) */
+    if ((int)len < 0) {
+        gz_error(state, Z_BUF_ERROR, "requested length does not fit in int");
+        return 0;
+    }
+
+    /* if len is zero, avoid unnecessary operations */
+    if (len == 0)
+        return 0;
+
+    /* allocate memory if this is the first time through */
+    if (state->size == 0 && gz_init(state) == -1)
+        return 0;
+
+    /* check for seek request */
+    if (state->seek) {
+        state->seek = 0;
+        if (gz_zero(state, state->skip) == -1)
+            return 0;
+    }
+
+    /* for small len, copy to input buffer, otherwise compress directly */
+    if (len < state->size) {
+        /* copy to input buffer, compress when full */
+        do {
+            if (strm->avail_in == 0)
+                strm->next_in = state->in;
+            n = state->size - strm->avail_in;
+            if (n > len)
+                n = len;
+            memcpy(strm->next_in + strm->avail_in, buf, n);
+            strm->avail_in += n;
+            state->pos += n;
+            buf = (char *)buf + n;
+            len -= n;
+            if (len && gz_comp(state, Z_NO_FLUSH) == -1)
+                return 0;
+        } while (len);
+    }
+    else {
+        /* consume whatever's left in the input buffer */
+        if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1)
+            return 0;
+
+        /* directly compress user buffer to file */
+        strm->avail_in = len;
+        strm->next_in = (voidp)buf;
+        state->pos += len;
+        if (gz_comp(state, Z_NO_FLUSH) == -1)
+            return 0;
+    }
+
+    /* input was all buffered or compressed (put will fit in int) */
+    return (int)put;
+}
+
+/* -- see zlib.h -- */
+int ZEXPORT gzputc(file, c)
+    gzFile file;
+    int c;
+{
+    unsigned char buf[1];
+    gz_statep state;
+    z_streamp strm;
+
+    /* get internal structure */
+    if (file == NULL)
+        return -1;
+    state = (gz_statep)file;
+    strm = &(state->strm);
+
+    /* check that we're writing and that there's no error */
+    if (state->mode != GZ_WRITE || state->err != Z_OK)
+        return -1;
+
+    /* check for seek request */
+    if (state->seek) {
+        state->seek = 0;
+        if (gz_zero(state, state->skip) == -1)
+            return -1;
+    }
+
+    /* try writing to input buffer for speed (state->size == 0 if buffer not
+       initialized) */
+    if (strm->avail_in < state->size) {
+        if (strm->avail_in == 0)
+            strm->next_in = state->in;
+        strm->next_in[strm->avail_in++] = c;
+        state->pos++;
+        return c;
+    }
+
+    /* no room in buffer or not initialized, use gz_write() */
+    buf[0] = c;
+    if (gzwrite(file, buf, 1) != 1)
+        return -1;
+    return c;
+}
+
+/* -- see zlib.h -- */
+int ZEXPORT gzputs(file, str)
+    gzFile file;
+    const char *str;
+{
+    int ret;
+    unsigned len;
+
+    /* write string */
+    len = (unsigned)strlen(str);
+    ret = gzwrite(file, str, len);
+    return ret == 0 && len != 0 ? -1 : ret;
+}
+
+#ifdef STDC
+#include <stdarg.h>
+
+/* -- see zlib.h -- */
+int ZEXPORTVA gzprintf (gzFile file, const char *format, ...)
+{
+    int size, len;
+    gz_statep state;
+    z_streamp strm;
+    va_list va;
+
+    /* get internal structure */
+    if (file == NULL)
+        return -1;
+    state = (gz_statep)file;
+    strm = &(state->strm);
+
+    /* check that we're writing and that there's no error */
+    if (state->mode != GZ_WRITE || state->err != Z_OK)
+        return 0;
+
+    /* make sure we have some buffer space */
+    if (state->size == 0 && gz_init(state) == -1)
+        return 0;
+
+    /* check for seek request */
+    if (state->seek) {
+        state->seek = 0;
+        if (gz_zero(state, state->skip) == -1)
+            return 0;
+    }
+
+    /* consume whatever's left in the input buffer */
+    if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1)
+        return 0;
+
+    /* do the printf() into the input buffer, put length in len */
+    size = (int)(state->size);
+    state->in[size - 1] = 0;
+    va_start(va, format);
+#ifdef NO_vsnprintf
+#  ifdef HAS_vsprintf_void
+    (void)vsprintf(state->in, format, va);
+    va_end(va);
+    for (len = 0; len < size; len++)
+        if (state->in[len] == 0) break;
+#  else
+    len = vsprintf(state->in, format, va);
+    va_end(va);
+#  endif
+#else
+#  ifdef HAS_vsnprintf_void
+    (void)vsnprintf(state->in, size, format, va);
+    va_end(va);
+    len = strlen(state->in);
+#  else
+    len = vsnprintf((char *)(state->in), size, format, va);
+    va_end(va);
+#  endif
+#endif
+
+    /* check that printf() results fit in buffer */
+    if (len <= 0 || len >= (int)size || state->in[size - 1] != 0)
+        return 0;
+
+    /* update buffer and position, defer compression until needed */
+    strm->avail_in = (unsigned)len;
+    strm->next_in = state->in;
+    state->pos += len;
+    return len;
+}
+
+#else /* !STDC */
+
+/* -- see zlib.h -- */
+int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
+                       a11, a12, a13, a14, a15, a16, a17, a18, a19, a20)
+    gzFile file;
+    const char *format;
+    int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
+        a11, a12, a13, a14, a15, a16, a17, a18, a19, a20;
+{
+    int size, len;
+    gz_statep state;
+    z_streamp strm;
+
+    /* get internal structure */
+    if (file == NULL)
+        return -1;
+    state = (gz_statep)file;
+    strm = &(state->strm);
+
+    /* check that we're writing and that there's no error */
+    if (state->mode != GZ_WRITE || state->err != Z_OK)
+        return 0;
+
+    /* make sure we have some buffer space */
+    if (state->size == 0 && gz_init(state) == -1)
+        return 0;
+
+    /* check for seek request */
+    if (state->seek) {
+        state->seek = 0;
+        if (gz_zero(state, state->skip) == -1)
+            return 0;
+    }
+
+    /* consume whatever's left in the input buffer */
+    if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1)
+        return 0;
+
+    /* do the printf() into the input buffer, put length in len */
+    size = (int)(state->size);
+    state->in[size - 1] = 0;
+#ifdef NO_snprintf
+#  ifdef HAS_sprintf_void
+    sprintf(state->in, format, a1, a2, a3, a4, a5, a6, a7, a8,
+            a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
+    for (len = 0; len < size; len++)
+        if (state->in[len] == 0) break;
+#  else
+    len = sprintf(state->in, format, a1, a2, a3, a4, a5, a6, a7, a8,
+                a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
+#  endif
+#else
+#  ifdef HAS_snprintf_void
+    snprintf(state->in, size, format, a1, a2, a3, a4, a5, a6, a7, a8,
+             a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
+    len = strlen(state->in);
+#  else
+    len = snprintf(state->in, size, format, a1, a2, a3, a4, a5, a6, a7, a8,
+                 a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
+#  endif
+#endif
+
+    /* check that printf() results fit in buffer */
+    if (len <= 0 || len >= (int)size || state->in[size - 1] != 0)
+        return 0;
+
+    /* update buffer and position, defer compression until needed */
+    strm->avail_in = (unsigned)len;
+    strm->next_in = state->in;
+    state->pos += len;
+    return len;
+}
+
+#endif
+
+/* -- see zlib.h -- */
+int ZEXPORT gzflush(file, flush)
+    gzFile file;
+    int flush;
+{
+    gz_statep state;
+
+    /* get internal structure */
+    if (file == NULL)
+        return -1;
+    state = (gz_statep)file;
+
+    /* check that we're writing and that there's no error */
+    if (state->mode != GZ_WRITE || state->err != Z_OK)
+        return Z_STREAM_ERROR;
+
+    /* check flush parameter */
+    if (flush < 0 || flush > Z_FINISH)
+        return Z_STREAM_ERROR;
+
+    /* check for seek request */
+    if (state->seek) {
+        state->seek = 0;
+        if (gz_zero(state, state->skip) == -1)
+            return -1;
+    }
+
+    /* compress remaining data with requested flush */
+    gz_comp(state, flush);
+    return state->err;
+}
+
+/* -- see zlib.h -- */
+int ZEXPORT gzsetparams(file, level, strategy)
+    gzFile file;
+    int level;
+    int strategy;
+{
+    gz_statep state;
+    z_streamp strm;
+
+    /* get internal structure */
+    if (file == NULL)
+        return Z_STREAM_ERROR;
+    state = (gz_statep)file;
+    strm = &(state->strm);
+
+    /* check that we're writing and that there's no error */
+    if (state->mode != GZ_WRITE || state->err != Z_OK)
+        return Z_STREAM_ERROR;
+
+    /* if no change is requested, then do nothing */
+    if (level == state->level && strategy == state->strategy)
+        return Z_OK;
+
+    /* check for seek request */
+    if (state->seek) {
+        state->seek = 0;
+        if (gz_zero(state, state->skip) == -1)
+            return -1;
+    }
+
+    /* change compression parameters for subsequent input */
+    if (state->size) {
+        /* flush previous input with previous parameters before changing */
+        if (strm->avail_in && gz_comp(state, Z_PARTIAL_FLUSH) == -1)
+            return state->err;
+        deflateParams(strm, level, strategy);
+    }
+    state->level = level;
+    state->strategy = strategy;
+    return Z_OK;
+}
+
+/* -- see zlib.h -- */
+int ZEXPORT gzclose_w(file)
+    gzFile file;
+{
+    int ret = 0;
+    gz_statep state;
+
+    /* get internal structure */
+    if (file == NULL)
+        return Z_STREAM_ERROR;
+    state = (gz_statep)file;
+
+    /* check that we're writing */
+    if (state->mode != GZ_WRITE)
+        return Z_STREAM_ERROR;
+
+    /* check for seek request */
+    if (state->seek) {
+        state->seek = 0;
+        ret += gz_zero(state, state->skip);
+    }
+
+    /* flush, free memory, and close file */
+    ret += gz_comp(state, Z_FINISH);
+    (void)deflateEnd(&(state->strm));
+    free(state->out);
+    free(state->in);
+    gz_error(state, Z_OK, NULL);
+    free(state->path);
+    ret += close(state->fd);
+    free(state);
+    return ret ? Z_ERRNO : Z_OK;
+}
diff --git a/jdk/src/share/native/java/util/zip/zlib-1.2.3/infback.c b/jdk/src/share/native/java/util/zip/zlib-1.2.5/infback.c
similarity index 89%
rename from jdk/src/share/native/java/util/zip/zlib-1.2.3/infback.c
rename to jdk/src/share/native/java/util/zip/zlib-1.2.5/infback.c
index 3fc03f8..783274e 100644
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/infback.c
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/infback.c
@@ -23,7 +23,7 @@
  */
 
 /* infback.c -- inflate using a call-back interface
- * Copyright (C) 1995-2005 Mark Adler
+ * Copyright (C) 1995-2009 Mark Adler
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
@@ -79,7 +79,7 @@
     state->wbits = windowBits;
     state->wsize = 1U << windowBits;
     state->window = window;
-    state->write = 0;
+    state->wnext = 0;
     state->whave = 0;
     return Z_OK;
 }
@@ -277,7 +277,7 @@
     unsigned bits;              /* bits in bit buffer */
     unsigned copy;              /* number of stored or match bytes to copy */
     unsigned char FAR *from;    /* where to copy match bytes from */
-    code this;                  /* current decoding table entry */
+    code here;                  /* current decoding table entry */
     code last;                  /* parent table entry */
     unsigned len;               /* length to copy for repeats, bits to drop */
     int ret;                    /* return code */
@@ -413,19 +413,19 @@
             state->have = 0;
             while (state->have < state->nlen + state->ndist) {
                 for (;;) {
-                    this = state->lencode[BITS(state->lenbits)];
-                    if ((unsigned)(this.bits) <= bits) break;
+                    here = state->lencode[BITS(state->lenbits)];
+                    if ((unsigned)(here.bits) <= bits) break;
                     PULLBYTE();
                 }
-                if (this.val < 16) {
-                    NEEDBITS(this.bits);
-                    DROPBITS(this.bits);
-                    state->lens[state->have++] = this.val;
+                if (here.val < 16) {
+                    NEEDBITS(here.bits);
+                    DROPBITS(here.bits);
+                    state->lens[state->have++] = here.val;
                 }
                 else {
-                    if (this.val == 16) {
-                        NEEDBITS(this.bits + 2);
-                        DROPBITS(this.bits);
+                    if (here.val == 16) {
+                        NEEDBITS(here.bits + 2);
+                        DROPBITS(here.bits);
                         if (state->have == 0) {
                             strm->msg = (char *)"invalid bit length repeat";
                             state->mode = BAD;
@@ -435,16 +435,16 @@
                         copy = 3 + BITS(2);
                         DROPBITS(2);
                     }
-                    else if (this.val == 17) {
-                        NEEDBITS(this.bits + 3);
-                        DROPBITS(this.bits);
+                    else if (here.val == 17) {
+                        NEEDBITS(here.bits + 3);
+                        DROPBITS(here.bits);
                         len = 0;
                         copy = 3 + BITS(3);
                         DROPBITS(3);
                     }
                     else {
-                        NEEDBITS(this.bits + 7);
-                        DROPBITS(this.bits);
+                        NEEDBITS(here.bits + 7);
+                        DROPBITS(here.bits);
                         len = 0;
                         copy = 11 + BITS(7);
                         DROPBITS(7);
@@ -462,7 +462,16 @@
             /* handle error breaks in while */
             if (state->mode == BAD) break;
 
-            /* build code tables */
+            /* check for end-of-block code (better have one) */
+            if (state->lens[256] == 0) {
+                strm->msg = (char *)"invalid code -- missing end-of-block";
+                state->mode = BAD;
+                break;
+            }
+
+            /* build code tables -- note: do not change the lenbits or distbits
+               values here (9 and 6) without reading the comments in inftrees.h
+               concerning the ENOUGH constants, which depend on those values */
             state->next = state->codes;
             state->lencode = (code const FAR *)(state->next);
             state->lenbits = 9;
@@ -498,28 +507,28 @@
 
             /* get a literal, length, or end-of-block code */
             for (;;) {
-                this = state->lencode[BITS(state->lenbits)];
-                if ((unsigned)(this.bits) <= bits) break;
+                here = state->lencode[BITS(state->lenbits)];
+                if ((unsigned)(here.bits) <= bits) break;
                 PULLBYTE();
             }
-            if (this.op && (this.op & 0xf0) == 0) {
-                last = this;
+            if (here.op && (here.op & 0xf0) == 0) {
+                last = here;
                 for (;;) {
-                    this = state->lencode[last.val +
+                    here = state->lencode[last.val +
                             (BITS(last.bits + last.op) >> last.bits)];
-                    if ((unsigned)(last.bits + this.bits) <= bits) break;
+                    if ((unsigned)(last.bits + here.bits) <= bits) break;
                     PULLBYTE();
                 }
                 DROPBITS(last.bits);
             }
-            DROPBITS(this.bits);
-            state->length = (unsigned)this.val;
+            DROPBITS(here.bits);
+            state->length = (unsigned)here.val;
 
             /* process literal */
-            if (this.op == 0) {
-                Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ?
+            if (here.op == 0) {
+                Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
                         "inflate:         literal '%c'\n" :
-                        "inflate:         literal 0x%02x\n", this.val));
+                        "inflate:         literal 0x%02x\n", here.val));
                 ROOM();
                 *put++ = (unsigned char)(state->length);
                 left--;
@@ -528,21 +537,21 @@
             }
 
             /* process end of block */
-            if (this.op & 32) {
+            if (here.op & 32) {
                 Tracevv((stderr, "inflate:         end of block\n"));
                 state->mode = TYPE;
                 break;
             }
 
             /* invalid code */
-            if (this.op & 64) {
+            if (here.op & 64) {
                 strm->msg = (char *)"invalid literal/length code";
                 state->mode = BAD;
                 break;
             }
 
             /* length code -- get extra bits, if any */
-            state->extra = (unsigned)(this.op) & 15;
+            state->extra = (unsigned)(here.op) & 15;
             if (state->extra != 0) {
                 NEEDBITS(state->extra);
                 state->length += BITS(state->extra);
@@ -552,30 +561,30 @@
 
             /* get distance code */
             for (;;) {
-                this = state->distcode[BITS(state->distbits)];
-                if ((unsigned)(this.bits) <= bits) break;
+                here = state->distcode[BITS(state->distbits)];
+                if ((unsigned)(here.bits) <= bits) break;
                 PULLBYTE();
             }
-            if ((this.op & 0xf0) == 0) {
-                last = this;
+            if ((here.op & 0xf0) == 0) {
+                last = here;
                 for (;;) {
-                    this = state->distcode[last.val +
+                    here = state->distcode[last.val +
                             (BITS(last.bits + last.op) >> last.bits)];
-                    if ((unsigned)(last.bits + this.bits) <= bits) break;
+                    if ((unsigned)(last.bits + here.bits) <= bits) break;
                     PULLBYTE();
                 }
                 DROPBITS(last.bits);
             }
-            DROPBITS(this.bits);
-            if (this.op & 64) {
+            DROPBITS(here.bits);
+            if (here.op & 64) {
                 strm->msg = (char *)"invalid distance code";
                 state->mode = BAD;
                 break;
             }
-            state->offset = (unsigned)this.val;
+            state->offset = (unsigned)here.val;
 
             /* get distance extra bits, if any */
-            state->extra = (unsigned)(this.op) & 15;
+            state->extra = (unsigned)(here.op) & 15;
             if (state->extra != 0) {
                 NEEDBITS(state->extra);
                 state->offset += BITS(state->extra);
diff --git a/jdk/src/share/native/java/util/zip/zlib-1.2.3/inffast.c b/jdk/src/share/native/java/util/zip/zlib-1.2.5/inffast.c
similarity index 84%
rename from jdk/src/share/native/java/util/zip/zlib-1.2.3/inffast.c
rename to jdk/src/share/native/java/util/zip/zlib-1.2.5/inffast.c
index eaffa05..e6a0572 100644
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/inffast.c
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/inffast.c
@@ -23,7 +23,7 @@
  */
 
 /* inffast.c -- fast decoding
- * Copyright (C) 1995-2004 Mark Adler
+ * Copyright (C) 1995-2008, 2010 Mark Adler
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
@@ -88,7 +88,7 @@
       requires strm->avail_out >= 258 for each loop to avoid checking for
       output space.
  */
-void inflate_fast(strm, start)
+void ZLIB_INTERNAL inflate_fast(strm, start)
 z_streamp strm;
 unsigned start;         /* inflate()'s starting value for strm->avail_out */
 {
@@ -103,7 +103,7 @@
 #endif
     unsigned wsize;             /* window size or zero if not using window */
     unsigned whave;             /* valid bytes in the window */
-    unsigned write;             /* window write index */
+    unsigned wnext;             /* window write index */
     unsigned char FAR *window;  /* allocated sliding window, if wsize != 0 */
     unsigned long hold;         /* local strm->hold */
     unsigned bits;              /* local strm->bits */
@@ -111,7 +111,7 @@
     code const FAR *dcode;      /* local strm->distcode */
     unsigned lmask;             /* mask for first level of length codes */
     unsigned dmask;             /* mask for first level of distance codes */
-    code this;                  /* retrieved table entry */
+    code here;                  /* retrieved table entry */
     unsigned op;                /* code bits, operation, extra bits, or */
                                 /*  window position, window bytes to copy */
     unsigned len;               /* match length, unused bytes */
@@ -130,7 +130,7 @@
 #endif
     wsize = state->wsize;
     whave = state->whave;
-    write = state->write;
+    wnext = state->wnext;
     window = state->window;
     hold = state->hold;
     bits = state->bits;
@@ -148,20 +148,20 @@
             hold += (unsigned long)(PUP(in)) << bits;
             bits += 8;
         }
-        this = lcode[hold & lmask];
+        here = lcode[hold & lmask];
       dolen:
-        op = (unsigned)(this.bits);
+        op = (unsigned)(here.bits);
         hold >>= op;
         bits -= op;
-        op = (unsigned)(this.op);
+        op = (unsigned)(here.op);
         if (op == 0) {                          /* literal */
-            Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ?
+            Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
                     "inflate:         literal '%c'\n" :
-                    "inflate:         literal 0x%02x\n", this.val));
-            PUP(out) = (unsigned char)(this.val);
+                    "inflate:         literal 0x%02x\n", here.val));
+            PUP(out) = (unsigned char)(here.val);
         }
         else if (op & 16) {                     /* length base */
-            len = (unsigned)(this.val);
+            len = (unsigned)(here.val);
             op &= 15;                           /* number of extra bits */
             if (op) {
                 if (bits < op) {
@@ -179,14 +179,14 @@
                 hold += (unsigned long)(PUP(in)) << bits;
                 bits += 8;
             }
-            this = dcode[hold & dmask];
+            here = dcode[hold & dmask];
           dodist:
-            op = (unsigned)(this.bits);
+            op = (unsigned)(here.bits);
             hold >>= op;
             bits -= op;
-            op = (unsigned)(this.op);
+            op = (unsigned)(here.op);
             if (op & 16) {                      /* distance base */
-                dist = (unsigned)(this.val);
+                dist = (unsigned)(here.val);
                 op &= 15;                       /* number of extra bits */
                 if (bits < op) {
                     hold += (unsigned long)(PUP(in)) << bits;
@@ -211,12 +211,34 @@
                 if (dist > op) {                /* see if copy from window */
                     op = dist - op;             /* distance back in window */
                     if (op > whave) {
-                        strm->msg = (char *)"invalid distance too far back";
-                        state->mode = BAD;
-                        break;
+                        if (state->sane) {
+                            strm->msg =
+                                (char *)"invalid distance too far back";
+                            state->mode = BAD;
+                            break;
+                        }
+#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
+                        if (len <= op - whave) {
+                            do {
+                                PUP(out) = 0;
+                            } while (--len);
+                            continue;
+                        }
+                        len -= op - whave;
+                        do {
+                            PUP(out) = 0;
+                        } while (--op > whave);
+                        if (op == 0) {
+                            from = out - dist;
+                            do {
+                                PUP(out) = PUP(from);
+                            } while (--len);
+                            continue;
+                        }
+#endif
                     }
                     from = window - OFF;
-                    if (write == 0) {           /* very common case */
+                    if (wnext == 0) {           /* very common case */
                         from += wsize - op;
                         if (op < len) {         /* some from window */
                             len -= op;
@@ -226,17 +248,17 @@
                             from = out - dist;  /* rest from output */
                         }
                     }
-                    else if (write < op) {      /* wrap around window */
-                        from += wsize + write - op;
-                        op -= write;
+                    else if (wnext < op) {      /* wrap around window */
+                        from += wsize + wnext - op;
+                        op -= wnext;
                         if (op < len) {         /* some from end of window */
                             len -= op;
                             do {
                                 PUP(out) = PUP(from);
                             } while (--op);
                             from = window - OFF;
-                            if (write < len) {  /* some from start of window */
-                                op = write;
+                            if (wnext < len) {  /* some from start of window */
+                                op = wnext;
                                 len -= op;
                                 do {
                                     PUP(out) = PUP(from);
@@ -246,7 +268,7 @@
                         }
                     }
                     else {                      /* contiguous in window */
-                        from += write - op;
+                        from += wnext - op;
                         if (op < len) {         /* some from window */
                             len -= op;
                             do {
@@ -283,7 +305,7 @@
                 }
             }
             else if ((op & 64) == 0) {          /* 2nd level distance code */
-                this = dcode[this.val + (hold & ((1U << op) - 1))];
+                here = dcode[here.val + (hold & ((1U << op) - 1))];
                 goto dodist;
             }
             else {
@@ -293,7 +315,7 @@
             }
         }
         else if ((op & 64) == 0) {              /* 2nd level length code */
-            this = lcode[this.val + (hold & ((1U << op) - 1))];
+            here = lcode[here.val + (hold & ((1U << op) - 1))];
             goto dolen;
         }
         else if (op & 32) {                     /* end-of-block */
@@ -329,7 +351,7 @@
    inflate_fast() speedups that turned out slower (on a PowerPC G3 750CXe):
    - Using bit fields for code structure
    - Different op definition to avoid & for extra bits (do & for table bits)
-   - Three separate decoding do-loops for direct, window, and write == 0
+   - Three separate decoding do-loops for direct, window, and wnext == 0
    - Special case for distance > 1 copies to do overlapped load and store copy
    - Explicit branch predictions (based on measured branch probabilities)
    - Deferring match copy and interspersed it with decoding subsequent codes
diff --git a/jdk/src/share/native/java/util/zip/zlib-1.2.3/inffast.h b/jdk/src/share/native/java/util/zip/zlib-1.2.5/inffast.h
similarity index 92%
rename from jdk/src/share/native/java/util/zip/zlib-1.2.3/inffast.h
rename to jdk/src/share/native/java/util/zip/zlib-1.2.5/inffast.h
index c45d087..b8da8bb 100644
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/inffast.h
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/inffast.h
@@ -23,7 +23,7 @@
  */
 
 /* inffast.h -- header to use inffast.c
- * Copyright (C) 1995-2003 Mark Adler
+ * Copyright (C) 1995-2003, 2010 Mark Adler
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
@@ -32,4 +32,4 @@
    subject to change. Applications should only use zlib.h.
  */
 
-void inflate_fast OF((z_streamp strm, unsigned start));
+void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start));
diff --git a/jdk/src/share/native/java/util/zip/zlib-1.2.3/inffixed.h b/jdk/src/share/native/java/util/zip/zlib-1.2.5/inffixed.h
similarity index 100%
rename from jdk/src/share/native/java/util/zip/zlib-1.2.3/inffixed.h
rename to jdk/src/share/native/java/util/zip/zlib-1.2.5/inffixed.h
diff --git a/jdk/src/share/native/java/util/zip/zlib-1.2.3/inflate.c b/jdk/src/share/native/java/util/zip/zlib-1.2.5/inflate.c
similarity index 87%
rename from jdk/src/share/native/java/util/zip/zlib-1.2.3/inflate.c
rename to jdk/src/share/native/java/util/zip/zlib-1.2.5/inflate.c
index caf1ad0..98e210a 100644
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/inflate.c
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/inflate.c
@@ -23,7 +23,7 @@
  */
 
 /* inflate.c -- zlib decompression
- * Copyright (C) 1995-2005 Mark Adler
+ * Copyright (C) 1995-2010 Mark Adler
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
@@ -69,7 +69,7 @@
  * - Rearrange window copies in inflate_fast() for speed and simplification
  * - Unroll last copy for window match in inflate_fast()
  * - Use local copies of window variables in inflate_fast() for speed
- * - Pull out common write == 0 case for speed in inflate_fast()
+ * - Pull out common wnext == 0 case for speed in inflate_fast()
  * - Make op and len in inflate_fast() unsigned for consistency
  * - Add FAR to lcode and dcode declarations in inflate_fast()
  * - Simplified bad distance check in inflate_fast()
@@ -141,28 +141,52 @@
     state->head = Z_NULL;
     state->wsize = 0;
     state->whave = 0;
-    state->write = 0;
+    state->wnext = 0;
     state->hold = 0;
     state->bits = 0;
     state->lencode = state->distcode = state->next = state->codes;
+    state->sane = 1;
+    state->back = -1;
     Tracev((stderr, "inflate: reset\n"));
     return Z_OK;
 }
 
-int ZEXPORT inflatePrime(strm, bits, value)
+int ZEXPORT inflateReset2(strm, windowBits)
 z_streamp strm;
-int bits;
-int value;
+int windowBits;
 {
+    int wrap;
     struct inflate_state FAR *state;
 
+    /* get the state */
     if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
     state = (struct inflate_state FAR *)strm->state;
-    if (bits > 16 || state->bits + bits > 32) return Z_STREAM_ERROR;
-    value &= (1L << bits) - 1;
-    state->hold += value << state->bits;
-    state->bits += bits;
-    return Z_OK;
+
+    /* extract wrap request from windowBits parameter */
+    if (windowBits < 0) {
+        wrap = 0;
+        windowBits = -windowBits;
+    }
+    else {
+        wrap = (windowBits >> 4) + 1;
+#ifdef GUNZIP
+        if (windowBits < 48)
+            windowBits &= 15;
+#endif
+    }
+
+    /* set number of window bits, free window if different */
+    if (windowBits && (windowBits < 8 || windowBits > 15))
+        return Z_STREAM_ERROR;
+    if (state->window != Z_NULL && state->wbits != (unsigned)windowBits) {
+        ZFREE(strm, state->window);
+        state->window = Z_NULL;
+    }
+
+    /* update state and reset the rest of it */
+    state->wrap = wrap;
+    state->wbits = (unsigned)windowBits;
+    return inflateReset(strm);
 }
 
 int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size)
@@ -171,6 +195,7 @@
 const char *version;
 int stream_size;
 {
+    int ret;
     struct inflate_state FAR *state;
 
     if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
@@ -188,24 +213,13 @@
     if (state == Z_NULL) return Z_MEM_ERROR;
     Tracev((stderr, "inflate: allocated\n"));
     strm->state = (struct internal_state FAR *)state;
-    if (windowBits < 0) {
-        state->wrap = 0;
-        windowBits = -windowBits;
-    }
-    else {
-        state->wrap = (windowBits >> 4) + 1;
-#ifdef GUNZIP
-        if (windowBits < 48) windowBits &= 15;
-#endif
-    }
-    if (windowBits < 8 || windowBits > 15) {
+    state->window = Z_NULL;
+    ret = inflateReset2(strm, windowBits);
+    if (ret != Z_OK) {
         ZFREE(strm, state);
         strm->state = Z_NULL;
-        return Z_STREAM_ERROR;
     }
-    state->wbits = (unsigned)windowBits;
-    state->window = Z_NULL;
-    return inflateReset(strm);
+    return ret;
 }
 
 int ZEXPORT inflateInit_(strm, version, stream_size)
@@ -216,6 +230,27 @@
     return inflateInit2_(strm, DEF_WBITS, version, stream_size);
 }
 
+int ZEXPORT inflatePrime(strm, bits, value)
+z_streamp strm;
+int bits;
+int value;
+{
+    struct inflate_state FAR *state;
+
+    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+    state = (struct inflate_state FAR *)strm->state;
+    if (bits < 0) {
+        state->hold = 0;
+        state->bits = 0;
+        return Z_OK;
+    }
+    if (bits > 16 || state->bits + bits > 32) return Z_STREAM_ERROR;
+    value &= (1L << bits) - 1;
+    state->hold += value << state->bits;
+    state->bits += bits;
+    return Z_OK;
+}
+
 /*
    Return state with length and distance decoding tables and index sizes set to
    fixed code decoding.  Normally this returns fixed tables from inffixed.h.
@@ -364,7 +399,7 @@
     /* if window not in use yet, initialize */
     if (state->wsize == 0) {
         state->wsize = 1U << state->wbits;
-        state->write = 0;
+        state->wnext = 0;
         state->whave = 0;
     }
 
@@ -372,22 +407,22 @@
     copy = out - strm->avail_out;
     if (copy >= state->wsize) {
         zmemcpy(state->window, strm->next_out - state->wsize, state->wsize);
-        state->write = 0;
+        state->wnext = 0;
         state->whave = state->wsize;
     }
     else {
-        dist = state->wsize - state->write;
+        dist = state->wsize - state->wnext;
         if (dist > copy) dist = copy;
-        zmemcpy(state->window + state->write, strm->next_out - copy, dist);
+        zmemcpy(state->window + state->wnext, strm->next_out - copy, dist);
         copy -= dist;
         if (copy) {
             zmemcpy(state->window, strm->next_out - copy, copy);
-            state->write = copy;
+            state->wnext = copy;
             state->whave = state->wsize;
         }
         else {
-            state->write += dist;
-            if (state->write == state->wsize) state->write = 0;
+            state->wnext += dist;
+            if (state->wnext == state->wsize) state->wnext = 0;
             if (state->whave < state->wsize) state->whave += dist;
         }
     }
@@ -588,7 +623,7 @@
     unsigned in, out;           /* save starting available input and output */
     unsigned copy;              /* number of stored or match bytes to copy */
     unsigned char FAR *from;    /* where to copy match bytes from */
-    code this;                  /* current decoding table entry */
+    code here;                  /* current decoding table entry */
     code last;                  /* parent table entry */
     unsigned len;               /* length to copy for repeats, bits to drop */
     int ret;                    /* return code */
@@ -643,7 +678,9 @@
             }
             DROPBITS(4);
             len = BITS(4) + 8;
-            if (len > state->wbits) {
+            if (state->wbits == 0)
+                state->wbits = len;
+            else if (len > state->wbits) {
                 strm->msg = (char *)"invalid window size";
                 state->mode = BAD;
                 break;
@@ -795,7 +832,7 @@
             strm->adler = state->check = adler32(0L, Z_NULL, 0);
             state->mode = TYPE;
         case TYPE:
-            if (flush == Z_BLOCK) goto inf_leave;
+            if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave;
         case TYPEDO:
             if (state->last) {
                 BYTEBITS();
@@ -815,7 +852,11 @@
                 fixedtables(state);
                 Tracev((stderr, "inflate:     fixed codes block%s\n",
                         state->last ? " (last)" : ""));
-                state->mode = LEN;              /* decode codes */
+                state->mode = LEN_;             /* decode codes */
+                if (flush == Z_TREES) {
+                    DROPBITS(2);
+                    goto inf_leave;
+                }
                 break;
             case 2:                             /* dynamic block */
                 Tracev((stderr, "inflate:     dynamic codes block%s\n",
@@ -840,6 +881,9 @@
             Tracev((stderr, "inflate:       stored length %u\n",
                     state->length));
             INITBITS();
+            state->mode = COPY_;
+            if (flush == Z_TREES) goto inf_leave;
+        case COPY_:
             state->mode = COPY;
         case COPY:
             copy = state->length;
@@ -900,19 +944,19 @@
         case CODELENS:
             while (state->have < state->nlen + state->ndist) {
                 for (;;) {
-                    this = state->lencode[BITS(state->lenbits)];
-                    if ((unsigned)(this.bits) <= bits) break;
+                    here = state->lencode[BITS(state->lenbits)];
+                    if ((unsigned)(here.bits) <= bits) break;
                     PULLBYTE();
                 }
-                if (this.val < 16) {
-                    NEEDBITS(this.bits);
-                    DROPBITS(this.bits);
-                    state->lens[state->have++] = this.val;
+                if (here.val < 16) {
+                    NEEDBITS(here.bits);
+                    DROPBITS(here.bits);
+                    state->lens[state->have++] = here.val;
                 }
                 else {
-                    if (this.val == 16) {
-                        NEEDBITS(this.bits + 2);
-                        DROPBITS(this.bits);
+                    if (here.val == 16) {
+                        NEEDBITS(here.bits + 2);
+                        DROPBITS(here.bits);
                         if (state->have == 0) {
                             strm->msg = (char *)"invalid bit length repeat";
                             state->mode = BAD;
@@ -922,16 +966,16 @@
                         copy = 3 + BITS(2);
                         DROPBITS(2);
                     }
-                    else if (this.val == 17) {
-                        NEEDBITS(this.bits + 3);
-                        DROPBITS(this.bits);
+                    else if (here.val == 17) {
+                        NEEDBITS(here.bits + 3);
+                        DROPBITS(here.bits);
                         len = 0;
                         copy = 3 + BITS(3);
                         DROPBITS(3);
                     }
                     else {
-                        NEEDBITS(this.bits + 7);
-                        DROPBITS(this.bits);
+                        NEEDBITS(here.bits + 7);
+                        DROPBITS(here.bits);
                         len = 0;
                         copy = 11 + BITS(7);
                         DROPBITS(7);
@@ -949,7 +993,16 @@
             /* handle error breaks in while */
             if (state->mode == BAD) break;
 
-            /* build code tables */
+            /* check for end-of-block code (better have one) */
+            if (state->lens[256] == 0) {
+                strm->msg = (char *)"invalid code -- missing end-of-block";
+                state->mode = BAD;
+                break;
+            }
+
+            /* build code tables -- note: do not change the lenbits or distbits
+               values here (9 and 6) without reading the comments in inftrees.h
+               concerning the ENOUGH constants, which depend on those values */
             state->next = state->codes;
             state->lencode = (code const FAR *)(state->next);
             state->lenbits = 9;
@@ -970,88 +1023,102 @@
                 break;
             }
             Tracev((stderr, "inflate:       codes ok\n"));
+            state->mode = LEN_;
+            if (flush == Z_TREES) goto inf_leave;
+        case LEN_:
             state->mode = LEN;
         case LEN:
             if (have >= 6 && left >= 258) {
                 RESTORE();
                 inflate_fast(strm, out);
                 LOAD();
+                if (state->mode == TYPE)
+                    state->back = -1;
                 break;
             }
+            state->back = 0;
             for (;;) {
-                this = state->lencode[BITS(state->lenbits)];
-                if ((unsigned)(this.bits) <= bits) break;
+                here = state->lencode[BITS(state->lenbits)];
+                if ((unsigned)(here.bits) <= bits) break;
                 PULLBYTE();
             }
-            if (this.op && (this.op & 0xf0) == 0) {
-                last = this;
+            if (here.op && (here.op & 0xf0) == 0) {
+                last = here;
                 for (;;) {
-                    this = state->lencode[last.val +
+                    here = state->lencode[last.val +
                             (BITS(last.bits + last.op) >> last.bits)];
-                    if ((unsigned)(last.bits + this.bits) <= bits) break;
+                    if ((unsigned)(last.bits + here.bits) <= bits) break;
                     PULLBYTE();
                 }
                 DROPBITS(last.bits);
+                state->back += last.bits;
             }
-            DROPBITS(this.bits);
-            state->length = (unsigned)this.val;
-            if ((int)(this.op) == 0) {
-                Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ?
+            DROPBITS(here.bits);
+            state->back += here.bits;
+            state->length = (unsigned)here.val;
+            if ((int)(here.op) == 0) {
+                Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
                         "inflate:         literal '%c'\n" :
-                        "inflate:         literal 0x%02x\n", this.val));
+                        "inflate:         literal 0x%02x\n", here.val));
                 state->mode = LIT;
                 break;
             }
-            if (this.op & 32) {
+            if (here.op & 32) {
                 Tracevv((stderr, "inflate:         end of block\n"));
+                state->back = -1;
                 state->mode = TYPE;
                 break;
             }
-            if (this.op & 64) {
+            if (here.op & 64) {
                 strm->msg = (char *)"invalid literal/length code";
                 state->mode = BAD;
                 break;
             }
-            state->extra = (unsigned)(this.op) & 15;
+            state->extra = (unsigned)(here.op) & 15;
             state->mode = LENEXT;
         case LENEXT:
             if (state->extra) {
                 NEEDBITS(state->extra);
                 state->length += BITS(state->extra);
                 DROPBITS(state->extra);
+                state->back += state->extra;
             }
             Tracevv((stderr, "inflate:         length %u\n", state->length));
+            state->was = state->length;
             state->mode = DIST;
         case DIST:
             for (;;) {
-                this = state->distcode[BITS(state->distbits)];
-                if ((unsigned)(this.bits) <= bits) break;
+                here = state->distcode[BITS(state->distbits)];
+                if ((unsigned)(here.bits) <= bits) break;
                 PULLBYTE();
             }
-            if ((this.op & 0xf0) == 0) {
-                last = this;
+            if ((here.op & 0xf0) == 0) {
+                last = here;
                 for (;;) {
-                    this = state->distcode[last.val +
+                    here = state->distcode[last.val +
                             (BITS(last.bits + last.op) >> last.bits)];
-                    if ((unsigned)(last.bits + this.bits) <= bits) break;
+                    if ((unsigned)(last.bits + here.bits) <= bits) break;
                     PULLBYTE();
                 }
                 DROPBITS(last.bits);
+                state->back += last.bits;
             }
-            DROPBITS(this.bits);
-            if (this.op & 64) {
+            DROPBITS(here.bits);
+            state->back += here.bits;
+            if (here.op & 64) {
                 strm->msg = (char *)"invalid distance code";
                 state->mode = BAD;
                 break;
             }
-            state->offset = (unsigned)this.val;
-            state->extra = (unsigned)(this.op) & 15;
+            state->offset = (unsigned)here.val;
+            state->extra = (unsigned)(here.op) & 15;
             state->mode = DISTEXT;
         case DISTEXT:
             if (state->extra) {
                 NEEDBITS(state->extra);
                 state->offset += BITS(state->extra);
                 DROPBITS(state->extra);
+                state->back += state->extra;
             }
 #ifdef INFLATE_STRICT
             if (state->offset > state->dmax) {
@@ -1060,11 +1127,6 @@
                 break;
             }
 #endif
-            if (state->offset > state->whave + out - left) {
-                strm->msg = (char *)"invalid distance too far back";
-                state->mode = BAD;
-                break;
-            }
             Tracevv((stderr, "inflate:         distance %u\n", state->offset));
             state->mode = MATCH;
         case MATCH:
@@ -1072,12 +1134,32 @@
             copy = out - left;
             if (state->offset > copy) {         /* copy from window */
                 copy = state->offset - copy;
-                if (copy > state->write) {
-                    copy -= state->write;
+                if (copy > state->whave) {
+                    if (state->sane) {
+                        strm->msg = (char *)"invalid distance too far back";
+                        state->mode = BAD;
+                        break;
+                    }
+#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
+                    Trace((stderr, "inflate.c too far\n"));
+                    copy -= state->whave;
+                    if (copy > state->length) copy = state->length;
+                    if (copy > left) copy = left;
+                    left -= copy;
+                    state->length -= copy;
+                    do {
+                        *put++ = 0;
+                    } while (--copy);
+                    if (state->length == 0) state->mode = LEN;
+                    break;
+#endif
+                }
+                if (copy > state->wnext) {
+                    copy -= state->wnext;
                     from = state->window + (state->wsize - copy);
                 }
                 else
-                    from = state->window + (state->write - copy);
+                    from = state->window + (state->wnext - copy);
                 if (copy > state->length) copy = state->length;
             }
             else {                              /* copy from output */
@@ -1170,7 +1252,8 @@
         strm->adler = state->check =
             UPDATE(state->check, strm->next_out - out, out);
     strm->data_type = state->bits + (state->last ? 64 : 0) +
-                      (state->mode == TYPE ? 128 : 0);
+                      (state->mode == TYPE ? 128 : 0) +
+                      (state->mode == LEN_ || state->mode == COPY_ ? 256 : 0);
     if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)
         ret = Z_BUF_ERROR;
     return ret;
@@ -1287,7 +1370,7 @@
 z_streamp strm;
 {
     unsigned len;               /* number of bytes to look at or looked at */
-    long long in, out;          /* temporary to save total_in and total_out */
+    long long in, out;      /* temporary to save total_in and total_out */
     unsigned char buf[4];       /* to restore bit buffer to byte string */
     struct inflate_state FAR *state;
 
@@ -1390,3 +1473,32 @@
     dest->state = (struct internal_state FAR *)copy;
     return Z_OK;
 }
+
+int ZEXPORT inflateUndermine(strm, subvert)
+z_streamp strm;
+int subvert;
+{
+    struct inflate_state FAR *state;
+
+    if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+    state = (struct inflate_state FAR *)strm->state;
+    state->sane = !subvert;
+#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
+    return Z_OK;
+#else
+    state->sane = 1;
+    return Z_DATA_ERROR;
+#endif
+}
+
+long ZEXPORT inflateMark(strm)
+z_streamp strm;
+{
+    struct inflate_state FAR *state;
+
+    if (strm == Z_NULL || strm->state == Z_NULL) return -1L << 16;
+    state = (struct inflate_state FAR *)strm->state;
+    return ((long)(state->back) << 16) +
+        (state->mode == COPY ? state->length :
+            (state->mode == MATCH ? state->was - state->length : 0));
+}
diff --git a/jdk/src/share/native/java/util/zip/zlib-1.2.3/inflate.h b/jdk/src/share/native/java/util/zip/zlib-1.2.5/inflate.h
similarity index 85%
rename from jdk/src/share/native/java/util/zip/zlib-1.2.3/inflate.h
rename to jdk/src/share/native/java/util/zip/zlib-1.2.5/inflate.h
index 11a5b08..090cb8a 100644
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/inflate.h
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/inflate.h
@@ -23,7 +23,7 @@
  */
 
 /* inflate.h -- internal inflate state definition
- * Copyright (C) 1995-2004 Mark Adler
+ * Copyright (C) 1995-2009 Mark Adler
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
@@ -56,11 +56,13 @@
         TYPE,       /* i: waiting for type bits, including last-flag bit */
         TYPEDO,     /* i: same, but skip check to exit inflate on new block */
         STORED,     /* i: waiting for stored size (length and complement) */
+        COPY_,      /* i/o: same as COPY below, but only first time in */
         COPY,       /* i/o: waiting for input or output to copy stored block */
         TABLE,      /* i: waiting for dynamic block table lengths */
         LENLENS,    /* i: waiting for code length code lengths */
         CODELENS,   /* i: waiting for length/lit and distance code lengths */
-            LEN,        /* i: waiting for length/lit code */
+            LEN_,       /* i: same as LEN below, but only first time in */
+            LEN,        /* i: waiting for length/lit/eob code */
             LENEXT,     /* i: waiting for length extra bits */
             DIST,       /* i: waiting for distance code */
             DISTEXT,    /* i: waiting for distance extra bits */
@@ -77,19 +79,21 @@
 /*
     State transitions between above modes -
 
-    (most modes can go to the BAD or MEM mode -- not shown for clarity)
+    (most modes can go to BAD or MEM on error -- not shown for clarity)
 
     Process header:
-        HEAD -> (gzip) or (zlib)
-        (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME
-        NAME -> COMMENT -> HCRC -> TYPE
+        HEAD -> (gzip) or (zlib) or (raw)
+        (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME -> COMMENT ->
+                  HCRC -> TYPE
         (zlib) -> DICTID or TYPE
         DICTID -> DICT -> TYPE
+        (raw) -> TYPEDO
     Read deflate blocks:
-            TYPE -> STORED or TABLE or LEN or CHECK
-            STORED -> COPY -> TYPE
-            TABLE -> LENLENS -> CODELENS -> LEN
-    Read deflate codes:
+            TYPE -> TYPEDO -> STORED or TABLE or LEN_ or CHECK
+            STORED -> COPY_ -> COPY -> TYPE
+            TABLE -> LENLENS -> CODELENS -> LEN_
+            LEN_ -> LEN
+    Read deflate codes in fixed or dynamic block:
                 LEN -> LENEXT or LIT or TYPE
                 LENEXT -> DIST -> DISTEXT -> MATCH -> LEN
                 LIT -> LEN
@@ -97,7 +101,7 @@
         CHECK -> LENGTH -> DONE
  */
 
-/* state maintained between inflate() calls.  Approximately 7K bytes. */
+/* state maintained between inflate() calls.  Approximately 10K bytes. */
 struct inflate_state {
     inflate_mode mode;          /* current inflate mode */
     int last;                   /* true if processing last block */
@@ -112,7 +116,7 @@
     unsigned wbits;             /* log base 2 of requested window size */
     unsigned wsize;             /* window size or zero if not using window */
     unsigned whave;             /* valid bytes in the window */
-    unsigned write;             /* window write index */
+    unsigned wnext;             /* window write index */
     unsigned char FAR *window;  /* allocated sliding window, if needed */
         /* bit accumulator */
     unsigned long hold;         /* input bit accumulator */
@@ -136,4 +140,7 @@
     unsigned short lens[320];   /* temporary storage for code lengths */
     unsigned short work[288];   /* work area for code table building */
     code codes[ENOUGH];         /* space for code tables */
+    int sane;                   /* if false, allow invalid distance too far */
+    int back;                   /* bits back of last unprocessed length/lit */
+    unsigned was;               /* initial length of match */
 };
diff --git a/jdk/src/share/native/java/util/zip/zlib-1.2.3/inftrees.c b/jdk/src/share/native/java/util/zip/zlib-1.2.5/inftrees.c
similarity index 88%
rename from jdk/src/share/native/java/util/zip/zlib-1.2.3/inftrees.c
rename to jdk/src/share/native/java/util/zip/zlib-1.2.5/inftrees.c
index 0abd610..9842631 100644
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/inftrees.c
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/inftrees.c
@@ -23,7 +23,7 @@
  */
 
 /* inftrees.c -- generate Huffman trees for efficient decoding
- * Copyright (C) 1995-2005 Mark Adler
+ * Copyright (C) 1995-2010 Mark Adler
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
@@ -33,7 +33,7 @@
 #define MAXBITS 15
 
 const char inflate_copyright[] =
-   " inflate 1.2.3 Copyright 1995-2005 Mark Adler ";
+   " inflate 1.2.5 Copyright 1995-2010 Mark Adler ";
 /*
   If you use the zlib library in a product, an acknowledgment is welcome
   in the documentation of your product. If for some reason you cannot
@@ -53,7 +53,7 @@
    table index bits.  It will differ if the request is greater than the
    longest code or if it is less than the shortest code.
  */
-int inflate_table(type, lens, codes, table, bits, work)
+int ZLIB_INTERNAL inflate_table(type, lens, codes, table, bits, work)
 codetype type;
 unsigned short FAR *lens;
 unsigned codes;
@@ -74,7 +74,7 @@
     unsigned fill;              /* index for replicating entries */
     unsigned low;               /* low bits for current root entry */
     unsigned mask;              /* mask for low root bits */
-    code this;                  /* table entry for duplication */
+    code here;                  /* table entry for duplication */
     code FAR *next;             /* next available space in table */
     const unsigned short FAR *base;     /* base value table to use */
     const unsigned short FAR *extra;    /* extra bits table to use */
@@ -86,7 +86,7 @@
         35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
     static const unsigned short lext[31] = { /* Length codes 257..285 extra */
         16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
-        19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 201, 196};
+        19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 73, 195};
     static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
         1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
         257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
@@ -139,15 +139,15 @@
         if (count[max] != 0) break;
     if (root > max) root = max;
     if (max == 0) {                     /* no symbols to code at all */
-        this.op = (unsigned char)64;    /* invalid code marker */
-        this.bits = (unsigned char)1;
-        this.val = (unsigned short)0;
-        *(*table)++ = this;             /* make a table to force an error */
-        *(*table)++ = this;
+        here.op = (unsigned char)64;    /* invalid code marker */
+        here.bits = (unsigned char)1;
+        here.val = (unsigned short)0;
+        *(*table)++ = here;             /* make a table to force an error */
+        *(*table)++ = here;
         *bits = 1;
         return 0;     /* no symbols, but wait for decoding to report error */
     }
-    for (min = 1; min <= MAXBITS; min++)
+    for (min = 1; min < max; min++)
         if (count[min] != 0) break;
     if (root < min) root = min;
 
@@ -190,11 +190,10 @@
        entered in the tables.
 
        used keeps track of how many table entries have been allocated from the
-       provided *table space.  It is checked when a LENS table is being made
-       against the space in *table, ENOUGH, minus the maximum space needed by
-       the worst case distance code, MAXD.  This should never happen, but the
-       sufficiency of ENOUGH has not been proven exhaustively, hence the check.
-       This assumes that when type == LENS, bits == 9.
+       provided *table space.  It is checked for LENS and DIST tables against
+       the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in
+       the initial root table size constants.  See the comments in inftrees.h
+       for more information.
 
        sym increments through all symbols, and the loop terminates when
        all codes of length max, i.e. all codes, have been processed.  This
@@ -233,24 +232,25 @@
     mask = used - 1;            /* mask for comparing low */
 
     /* check available table space */
-    if (type == LENS && used >= ENOUGH - MAXD)
+    if ((type == LENS && used >= ENOUGH_LENS) ||
+        (type == DISTS && used >= ENOUGH_DISTS))
         return 1;
 
     /* process all codes and make table entries */
     for (;;) {
         /* create table entry */
-        this.bits = (unsigned char)(len - drop);
+        here.bits = (unsigned char)(len - drop);
         if ((int)(work[sym]) < end) {
-            this.op = (unsigned char)0;
-            this.val = work[sym];
+            here.op = (unsigned char)0;
+            here.val = work[sym];
         }
         else if ((int)(work[sym]) > end) {
-            this.op = (unsigned char)(extra[work[sym]]);
-            this.val = base[work[sym]];
+            here.op = (unsigned char)(extra[work[sym]]);
+            here.val = base[work[sym]];
         }
         else {
-            this.op = (unsigned char)(32 + 64);         /* end of block */
-            this.val = 0;
+            here.op = (unsigned char)(32 + 64);         /* end of block */
+            here.val = 0;
         }
 
         /* replicate for those indices with low len bits equal to huff */
@@ -259,7 +259,7 @@
         min = fill;                 /* save offset to next table */
         do {
             fill -= incr;
-            next[(huff >> drop) + fill] = this;
+            next[(huff >> drop) + fill] = here;
         } while (fill != 0);
 
         /* backwards increment the len-bit code huff */
@@ -301,7 +301,8 @@
 
             /* check for enough space */
             used += 1U << curr;
-            if (type == LENS && used >= ENOUGH - MAXD)
+            if ((type == LENS && used >= ENOUGH_LENS) ||
+                (type == DISTS && used >= ENOUGH_DISTS))
                 return 1;
 
             /* point entry in root table to sub-table */
@@ -319,20 +320,20 @@
        through high index bits.  When the current sub-table is filled, the loop
        drops back to the root table to fill in any remaining entries there.
      */
-    this.op = (unsigned char)64;                /* invalid code marker */
-    this.bits = (unsigned char)(len - drop);
-    this.val = (unsigned short)0;
+    here.op = (unsigned char)64;                /* invalid code marker */
+    here.bits = (unsigned char)(len - drop);
+    here.val = (unsigned short)0;
     while (huff != 0) {
         /* when done with sub-table, drop back to root table */
         if (drop != 0 && (huff & mask) != low) {
             drop = 0;
             len = root;
             next = *table;
-            this.bits = (unsigned char)len;
+            here.bits = (unsigned char)len;
         }
 
         /* put invalid code marker in table */
-        next[huff >> drop] = this;
+        next[huff >> drop] = here;
 
         /* backwards increment the len-bit code huff */
         incr = 1U << (len - 1);
diff --git a/jdk/src/share/native/java/util/zip/zlib-1.2.3/inftrees.h b/jdk/src/share/native/java/util/zip/zlib-1.2.5/inftrees.h
similarity index 74%
rename from jdk/src/share/native/java/util/zip/zlib-1.2.3/inftrees.h
rename to jdk/src/share/native/java/util/zip/zlib-1.2.5/inftrees.h
index 8642e0d..77326a7 100644
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/inftrees.h
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/inftrees.h
@@ -23,7 +23,7 @@
  */
 
 /* inftrees.h -- header to use inftrees.c
- * Copyright (C) 1995-2005 Mark Adler
+ * Copyright (C) 1995-2005, 2010 Mark Adler
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
@@ -59,21 +59,28 @@
     01000000 - invalid code
  */
 
-/* Maximum size of dynamic tree.  The maximum found in a long but non-
-   exhaustive search was 1444 code structures (852 for length/literals
-   and 592 for distances, the latter actually the result of an
-   exhaustive search).  The true maximum is not known, but the value
-   below is more than safe. */
-#define ENOUGH 2048
-#define MAXD 592
+/* Maximum size of the dynamic table.  The maximum number of code structures is
+   1444, which is the sum of 852 for literal/length codes and 592 for distance
+   codes.  These values were found by exhaustive searches using the program
+   examples/enough.c found in the zlib distribtution.  The arguments to that
+   program are the number of symbols, the initial root table size, and the
+   maximum bit length of a code.  "enough 286 9 15" for literal/length codes
+   returns returns 852, and "enough 30 6 15" for distance codes returns 592.
+   The initial root table size (9 or 6) is found in the fifth argument of the
+   inflate_table() calls in inflate.c and infback.c.  If the root table size is
+   changed, then these maximum sizes would be need to be recalculated and
+   updated. */
+#define ENOUGH_LENS 852
+#define ENOUGH_DISTS 592
+#define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS)
 
-/* Type of code to build for inftable() */
+/* Type of code to build for inflate_table() */
 typedef enum {
     CODES,
     LENS,
     DISTS
 } codetype;
 
-extern int inflate_table OF((codetype type, unsigned short FAR *lens,
+int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens,
                              unsigned codes, code FAR * FAR *table,
                              unsigned FAR *bits, unsigned short FAR *work));
diff --git a/jdk/src/share/native/java/util/zip/zlib-1.2.3/patches/ChangeLog_java b/jdk/src/share/native/java/util/zip/zlib-1.2.5/patches/ChangeLog_java
similarity index 71%
rename from jdk/src/share/native/java/util/zip/zlib-1.2.3/patches/ChangeLog_java
rename to jdk/src/share/native/java/util/zip/zlib-1.2.5/patches/ChangeLog_java
index 068a0aa..8d6957f 100644
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/patches/ChangeLog_java
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/patches/ChangeLog_java
@@ -12,5 +12,8 @@
 (4)updated zlib.h (to support > 4G zipfile):
    total_in/out: uLong -> long long
 
-(5)updated upinflate.c/inflateSync()
+(5)updated inflate.c/inflateSync()
    unsigned long in, out; -->  long long in, out;
+
+(6)updated compress.c/uncompr.c
+   *destLen = stream.total_out; --> *destLen = (uLong)stream.total_out;
diff --git a/jdk/src/share/native/java/util/zip/zlib-1.2.3/trees.c b/jdk/src/share/native/java/util/zip/zlib-1.2.5/trees.c
similarity index 93%
rename from jdk/src/share/native/java/util/zip/zlib-1.2.3/trees.c
rename to jdk/src/share/native/java/util/zip/zlib-1.2.5/trees.c
index 7d09e2e..04da4d7 100644
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/trees.c
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/trees.c
@@ -23,7 +23,8 @@
  */
 
 /* trees.c -- output deflated data using Huffman coding
- * Copyright (C) 1995-2005 Jean-loup Gailly
+ * Copyright (C) 1995-2010 Jean-loup Gailly
+ * detect_data_type() function provided freely by Cosmin Truta, 2006
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
@@ -176,7 +177,7 @@
                               int blcodes));
 local void compress_block OF((deflate_state *s, ct_data *ltree,
                               ct_data *dtree));
-local void set_data_type  OF((deflate_state *s));
+local int  detect_data_type OF((deflate_state *s));
 local unsigned bi_reverse OF((unsigned value, int length));
 local void bi_windup      OF((deflate_state *s));
 local void bi_flush       OF((deflate_state *s));
@@ -227,12 +228,12 @@
      * unused bits in value.
      */
     if (s->bi_valid > (int)Buf_size - length) {
-        s->bi_buf |= (value << s->bi_valid);
+        s->bi_buf |= (ush)value << s->bi_valid;
         put_short(s, s->bi_buf);
         s->bi_buf = (ush)value >> (Buf_size - s->bi_valid);
         s->bi_valid += length - Buf_size;
     } else {
-        s->bi_buf |= value << s->bi_valid;
+        s->bi_buf |= (ush)value << s->bi_valid;
         s->bi_valid += length;
     }
 }
@@ -242,12 +243,12 @@
 { int len = length;\
   if (s->bi_valid > (int)Buf_size - len) {\
     int val = value;\
-    s->bi_buf |= (val << s->bi_valid);\
+    s->bi_buf |= (ush)val << s->bi_valid;\
     put_short(s, s->bi_buf);\
     s->bi_buf = (ush)val >> (Buf_size - s->bi_valid);\
     s->bi_valid += len - Buf_size;\
   } else {\
-    s->bi_buf |= (value) << s->bi_valid;\
+    s->bi_buf |= (ush)(value) << s->bi_valid;\
     s->bi_valid += len;\
   }\
 }
@@ -274,11 +275,13 @@
     if (static_init_done) return;
 
     /* For some embedded targets, global variables are not initialized: */
+#ifdef NO_INIT_GLOBAL_POINTERS
     static_l_desc.static_tree = static_ltree;
     static_l_desc.extra_bits = extra_lbits;
     static_d_desc.static_tree = static_dtree;
     static_d_desc.extra_bits = extra_dbits;
     static_bl_desc.extra_bits = extra_blbits;
+#endif
 
     /* Initialize the mapping length (0..255) -> length code (0..28) */
     length = 0;
@@ -372,13 +375,14 @@
                 static_dtree[i].Len, SEPARATOR(i, D_CODES-1, 5));
     }
 
-    fprintf(header, "const uch _dist_code[DIST_CODE_LEN] = {\n");
+    fprintf(header, "const uch ZLIB_INTERNAL _dist_code[DIST_CODE_LEN] = {\n");
     for (i = 0; i < DIST_CODE_LEN; i++) {
         fprintf(header, "%2u%s", _dist_code[i],
                 SEPARATOR(i, DIST_CODE_LEN-1, 20));
     }
 
-    fprintf(header, "const uch _length_code[MAX_MATCH-MIN_MATCH+1]= {\n");
+    fprintf(header,
+        "const uch ZLIB_INTERNAL _length_code[MAX_MATCH-MIN_MATCH+1]= {\n");
     for (i = 0; i < MAX_MATCH-MIN_MATCH+1; i++) {
         fprintf(header, "%2u%s", _length_code[i],
                 SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20));
@@ -403,7 +407,7 @@
 /* ===========================================================================
  * Initialize the tree data structures for a new zlib stream.
  */
-void _tr_init(s)
+void ZLIB_INTERNAL _tr_init(s)
     deflate_state *s;
 {
     tr_static_init();
@@ -888,13 +892,13 @@
 /* ===========================================================================
  * Send a stored block
  */
-void _tr_stored_block(s, buf, stored_len, eof)
+void ZLIB_INTERNAL _tr_stored_block(s, buf, stored_len, last)
     deflate_state *s;
     charf *buf;       /* input block */
     ulg stored_len;   /* length of input block */
-    int eof;          /* true if this is the last block for a file */
+    int last;         /* one if this is the last block for a file */
 {
-    send_bits(s, (STORED_BLOCK<<1)+eof, 3);  /* send block type */
+    send_bits(s, (STORED_BLOCK<<1)+last, 3);    /* send block type */
 #ifdef DEBUG
     s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L;
     s->compressed_len += (stored_len + 4) << 3;
@@ -913,7 +917,7 @@
  * To simplify the code, we assume the worst case of last real code encoded
  * on one bit only.
  */
-void _tr_align(s)
+void ZLIB_INTERNAL _tr_align(s)
     deflate_state *s;
 {
     send_bits(s, STATIC_TREES<<1, 3);
@@ -942,11 +946,11 @@
  * Determine the best encoding for the current block: dynamic trees, static
  * trees or store, and output the encoded block to the zip file.
  */
-void _tr_flush_block(s, buf, stored_len, eof)
+void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
     deflate_state *s;
     charf *buf;       /* input block, or NULL if too old */
     ulg stored_len;   /* length of input block */
-    int eof;          /* true if this is the last block for a file */
+    int last;         /* one if this is the last block for a file */
 {
     ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */
     int max_blindex = 0;  /* index of last bit length code of non zero freq */
@@ -955,8 +959,8 @@
     if (s->level > 0) {
 
         /* Check if the file is binary or text */
-        if (stored_len > 0 && s->strm->data_type == Z_UNKNOWN)
-            set_data_type(s);
+        if (s->strm->data_type == Z_UNKNOWN)
+            s->strm->data_type = detect_data_type(s);
 
         /* Construct the literal and distance trees */
         build_tree(s, (tree_desc *)(&(s->l_desc)));
@@ -1002,20 +1006,20 @@
          * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to
          * transform a block into a stored block.
          */
-        _tr_stored_block(s, buf, stored_len, eof);
+        _tr_stored_block(s, buf, stored_len, last);
 
 #ifdef FORCE_STATIC
     } else if (static_lenb >= 0) { /* force static trees */
 #else
     } else if (s->strategy == Z_FIXED || static_lenb == opt_lenb) {
 #endif
-        send_bits(s, (STATIC_TREES<<1)+eof, 3);
+        send_bits(s, (STATIC_TREES<<1)+last, 3);
         compress_block(s, (ct_data *)static_ltree, (ct_data *)static_dtree);
 #ifdef DEBUG
         s->compressed_len += 3 + s->static_len;
 #endif
     } else {
-        send_bits(s, (DYN_TREES<<1)+eof, 3);
+        send_bits(s, (DYN_TREES<<1)+last, 3);
         send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1,
                        max_blindex+1);
         compress_block(s, (ct_data *)s->dyn_ltree, (ct_data *)s->dyn_dtree);
@@ -1029,21 +1033,21 @@
      */
     init_block(s);
 
-    if (eof) {
+    if (last) {
         bi_windup(s);
 #ifdef DEBUG
         s->compressed_len += 7;  /* align on byte boundary */
 #endif
     }
     Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len>>3,
-           s->compressed_len-7*eof));
+           s->compressed_len-7*last));
 }
 
 /* ===========================================================================
  * Save the match info and tally the frequency counts. Return true if
  * the current block must be flushed.
  */
-int _tr_tally (s, dist, lc)
+int ZLIB_INTERNAL _tr_tally (s, dist, lc)
     deflate_state *s;
     unsigned dist;  /* distance of matched string */
     unsigned lc;    /* match length-MIN_MATCH or unmatched char (if dist==0) */
@@ -1142,24 +1146,45 @@
 }
 
 /* ===========================================================================
- * Set the data type to BINARY or TEXT, using a crude approximation:
- * set it to Z_TEXT if all symbols are either printable characters (33 to 255)
- * or white spaces (9 to 13, or 32); or set it to Z_BINARY otherwise.
+ * Check if the data type is TEXT or BINARY, using the following algorithm:
+ * - TEXT if the two conditions below are satisfied:
+ *    a) There are no non-portable control characters belonging to the
+ *       "black list" (0..6, 14..25, 28..31).
+ *    b) There is at least one printable character belonging to the
+ *       "white list" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255).
+ * - BINARY otherwise.
+ * - The following partially-portable control characters form a
+ *   "gray list" that is ignored in this detection algorithm:
+ *   (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}).
  * IN assertion: the fields Freq of dyn_ltree are set.
  */
-local void set_data_type(s)
+local int detect_data_type(s)
     deflate_state *s;
 {
+    /* black_mask is the bit mask of black-listed bytes
+     * set bits 0..6, 14..25, and 28..31
+     * 0xf3ffc07f = binary 11110011111111111100000001111111
+     */
+    unsigned long black_mask = 0xf3ffc07fUL;
     int n;
 
-    for (n = 0; n < 9; n++)
+    /* Check for non-textual ("black-listed") bytes. */
+    for (n = 0; n <= 31; n++, black_mask >>= 1)
+        if ((black_mask & 1) && (s->dyn_ltree[n].Freq != 0))
+            return Z_BINARY;
+
+    /* Check for textual ("white-listed") bytes. */
+    if (s->dyn_ltree[9].Freq != 0 || s->dyn_ltree[10].Freq != 0
+            || s->dyn_ltree[13].Freq != 0)
+        return Z_TEXT;
+    for (n = 32; n < LITERALS; n++)
         if (s->dyn_ltree[n].Freq != 0)
-            break;
-    if (n == 9)
-        for (n = 14; n < 32; n++)
-            if (s->dyn_ltree[n].Freq != 0)
-                break;
-    s->strm->data_type = (n == 32) ? Z_TEXT : Z_BINARY;
+            return Z_TEXT;
+
+    /* There are no "black-listed" or "white-listed" bytes:
+     * this stream either is empty or has tolerated ("gray-listed") bytes only.
+     */
+    return Z_BINARY;
 }
 
 /* ===========================================================================
diff --git a/jdk/src/share/native/java/util/zip/zlib-1.2.3/trees.h b/jdk/src/share/native/java/util/zip/zlib-1.2.5/trees.h
similarity index 98%
rename from jdk/src/share/native/java/util/zip/zlib-1.2.3/trees.h
rename to jdk/src/share/native/java/util/zip/zlib-1.2.5/trees.h
index 35de4b0..5cbff5c 100644
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/trees.h
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/trees.h
@@ -94,7 +94,7 @@
 {{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}}
 };
 
-const uch _dist_code[DIST_CODE_LEN] = {
+const uch ZLIB_INTERNAL _dist_code[DIST_CODE_LEN] = {
  0,  1,  2,  3,  4,  4,  5,  5,  6,  6,  6,  6,  7,  7,  7,  7,  8,  8,  8,  8,
  8,  8,  8,  8,  9,  9,  9,  9,  9,  9,  9,  9, 10, 10, 10, 10, 10, 10, 10, 10,
 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
@@ -123,7 +123,7 @@
 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29
 };
 
-const uch _length_code[MAX_MATCH-MIN_MATCH+1]= {
+const uch ZLIB_INTERNAL _length_code[MAX_MATCH-MIN_MATCH+1]= {
  0,  1,  2,  3,  4,  5,  6,  7,  8,  8,  9,  9, 10, 10, 11, 11, 12, 12, 12, 12,
 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16,
 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19,
diff --git a/jdk/src/share/native/java/util/zip/zlib-1.2.3/uncompr.c b/jdk/src/share/native/java/util/zip/zlib-1.2.5/uncompr.c
similarity index 95%
rename from jdk/src/share/native/java/util/zip/zlib-1.2.3/uncompr.c
rename to jdk/src/share/native/java/util/zip/zlib-1.2.5/uncompr.c
index d2e4ef4..e71d018 100644
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/uncompr.c
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/uncompr.c
@@ -23,7 +23,7 @@
  */
 
 /* uncompr.c -- decompress a memory buffer
- * Copyright (C) 1995-2003 Jean-loup Gailly.
+ * Copyright (C) 1995-2003, 2010 Jean-loup Gailly.
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
@@ -40,8 +40,6 @@
    been saved previously by the compressor and transmitted to the decompressor
    by some mechanism outside the scope of this compression library.)
    Upon exit, destLen is the actual size of the compressed buffer.
-     This function can be used to decompress a whole file at once if the
-   input file is mmap'ed.
 
      uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
    enough memory, Z_BUF_ERROR if there was not enough room in the output
diff --git a/jdk/src/share/native/java/util/zip/zlib-1.2.3/zadler32.c b/jdk/src/share/native/java/util/zip/zlib-1.2.5/zadler32.c
similarity index 88%
rename from jdk/src/share/native/java/util/zip/zlib-1.2.3/zadler32.c
rename to jdk/src/share/native/java/util/zip/zlib-1.2.5/zadler32.c
index 6bb56f3..c4465e1 100644
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/zadler32.c
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/zadler32.c
@@ -23,14 +23,17 @@
  */
 
 /* adler32.c -- compute the Adler-32 checksum of a data stream
- * Copyright (C) 1995-2004 Mark Adler
+ * Copyright (C) 1995-2007 Mark Adler
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
 /* @(#) $Id$ */
 
-#define ZLIB_INTERNAL
-#include "zlib.h"
+#include "zutil.h"
+
+#define local static
+
+local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2);
 
 #define BASE 65521UL    /* largest prime smaller than 65536 */
 #define NMAX 5552
@@ -149,10 +152,10 @@
 }
 
 /* ========================================================================= */
-uLong ZEXPORT adler32_combine(adler1, adler2, len2)
+local uLong adler32_combine_(adler1, adler2, len2)
     uLong adler1;
     uLong adler2;
-    z_off_t len2;
+    z_off64_t len2;
 {
     unsigned long sum1;
     unsigned long sum2;
@@ -165,9 +168,26 @@
     MOD(sum2);
     sum1 += (adler2 & 0xffff) + BASE - 1;
     sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem;
-    if (sum1 > BASE) sum1 -= BASE;
-    if (sum1 > BASE) sum1 -= BASE;
-    if (sum2 > (BASE << 1)) sum2 -= (BASE << 1);
-    if (sum2 > BASE) sum2 -= BASE;
+    if (sum1 >= BASE) sum1 -= BASE;
+    if (sum1 >= BASE) sum1 -= BASE;
+    if (sum2 >= (BASE << 1)) sum2 -= (BASE << 1);
+    if (sum2 >= BASE) sum2 -= BASE;
     return sum1 | (sum2 << 16);
 }
+
+/* ========================================================================= */
+uLong ZEXPORT adler32_combine(adler1, adler2, len2)
+    uLong adler1;
+    uLong adler2;
+    z_off_t len2;
+{
+    return adler32_combine_(adler1, adler2, len2);
+}
+
+uLong ZEXPORT adler32_combine64(adler1, adler2, len2)
+    uLong adler1;
+    uLong adler2;
+    z_off64_t len2;
+{
+    return adler32_combine_(adler1, adler2, len2);
+}
diff --git a/jdk/src/share/native/java/util/zip/zlib-1.2.3/zconf.h b/jdk/src/share/native/java/util/zip/zlib-1.2.5/zconf.h
similarity index 68%
rename from jdk/src/share/native/java/util/zip/zlib-1.2.3/zconf.h
rename to jdk/src/share/native/java/util/zip/zlib-1.2.5/zconf.h
index e7c3f51..78f162cf 100644
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/zconf.h
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/zconf.h
@@ -23,7 +23,7 @@
  */
 
 /* zconf.h -- configuration of the zlib compression library
- * Copyright (C) 1995-2005 Jean-loup Gailly.
+ * Copyright (C) 1995-2010 Jean-loup Gailly.
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
@@ -38,52 +38,124 @@
 /*
  * If you *really* need a unique prefix for all types and library functions,
  * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
+ * Even better than compiling with -DZ_PREFIX would be to use configure to set
+ * this permanently in zconf.h using "./configure --zprefix".
  */
-#ifdef Z_PREFIX
-#  define deflateInit_          z_deflateInit_
-#  define deflate               z_deflate
-#  define deflateEnd            z_deflateEnd
-#  define inflateInit_          z_inflateInit_
-#  define inflate               z_inflate
-#  define inflateEnd            z_inflateEnd
-#  define deflateInit2_         z_deflateInit2_
-#  define deflateSetDictionary  z_deflateSetDictionary
-#  define deflateCopy           z_deflateCopy
-#  define deflateReset          z_deflateReset
-#  define deflateParams         z_deflateParams
-#  define deflateBound          z_deflateBound
-#  define deflatePrime          z_deflatePrime
-#  define inflateInit2_         z_inflateInit2_
-#  define inflateSetDictionary  z_inflateSetDictionary
-#  define inflateSync           z_inflateSync
-#  define inflateSyncPoint      z_inflateSyncPoint
-#  define inflateCopy           z_inflateCopy
-#  define inflateReset          z_inflateReset
-#  define inflateBack           z_inflateBack
-#  define inflateBackEnd        z_inflateBackEnd
+#ifdef Z_PREFIX     /* may be set to #if 1 by ./configure */
+
+/* all linked symbols */
+#  define _dist_code            z__dist_code
+#  define _length_code          z__length_code
+#  define _tr_align             z__tr_align
+#  define _tr_flush_block       z__tr_flush_block
+#  define _tr_init              z__tr_init
+#  define _tr_stored_block      z__tr_stored_block
+#  define _tr_tally             z__tr_tally
+#  define adler32               z_adler32
+#  define adler32_combine       z_adler32_combine
+#  define adler32_combine64     z_adler32_combine64
 #  define compress              z_compress
 #  define compress2             z_compress2
 #  define compressBound         z_compressBound
-#  define uncompress            z_uncompress
-#  define adler32               z_adler32
 #  define crc32                 z_crc32
+#  define crc32_combine         z_crc32_combine
+#  define crc32_combine64       z_crc32_combine64
+#  define deflate               z_deflate
+#  define deflateBound          z_deflateBound
+#  define deflateCopy           z_deflateCopy
+#  define deflateEnd            z_deflateEnd
+#  define deflateInit2_         z_deflateInit2_
+#  define deflateInit_          z_deflateInit_
+#  define deflateParams         z_deflateParams
+#  define deflatePrime          z_deflatePrime
+#  define deflateReset          z_deflateReset
+#  define deflateSetDictionary  z_deflateSetDictionary
+#  define deflateSetHeader      z_deflateSetHeader
+#  define deflateTune           z_deflateTune
+#  define deflate_copyright     z_deflate_copyright
 #  define get_crc_table         z_get_crc_table
+#  define gz_error              z_gz_error
+#  define gz_intmax             z_gz_intmax
+#  define gz_strwinerror        z_gz_strwinerror
+#  define gzbuffer              z_gzbuffer
+#  define gzclearerr            z_gzclearerr
+#  define gzclose               z_gzclose
+#  define gzclose_r             z_gzclose_r
+#  define gzclose_w             z_gzclose_w
+#  define gzdirect              z_gzdirect
+#  define gzdopen               z_gzdopen
+#  define gzeof                 z_gzeof
+#  define gzerror               z_gzerror
+#  define gzflush               z_gzflush
+#  define gzgetc                z_gzgetc
+#  define gzgets                z_gzgets
+#  define gzoffset              z_gzoffset
+#  define gzoffset64            z_gzoffset64
+#  define gzopen                z_gzopen
+#  define gzopen64              z_gzopen64
+#  define gzprintf              z_gzprintf
+#  define gzputc                z_gzputc
+#  define gzputs                z_gzputs
+#  define gzread                z_gzread
+#  define gzrewind              z_gzrewind
+#  define gzseek                z_gzseek
+#  define gzseek64              z_gzseek64
+#  define gzsetparams           z_gzsetparams
+#  define gztell                z_gztell
+#  define gztell64              z_gztell64
+#  define gzungetc              z_gzungetc
+#  define gzwrite               z_gzwrite
+#  define inflate               z_inflate
+#  define inflateBack           z_inflateBack
+#  define inflateBackEnd        z_inflateBackEnd
+#  define inflateBackInit_      z_inflateBackInit_
+#  define inflateCopy           z_inflateCopy
+#  define inflateEnd            z_inflateEnd
+#  define inflateGetHeader      z_inflateGetHeader
+#  define inflateInit2_         z_inflateInit2_
+#  define inflateInit_          z_inflateInit_
+#  define inflateMark           z_inflateMark
+#  define inflatePrime          z_inflatePrime
+#  define inflateReset          z_inflateReset
+#  define inflateReset2         z_inflateReset2
+#  define inflateSetDictionary  z_inflateSetDictionary
+#  define inflateSync           z_inflateSync
+#  define inflateSyncPoint      z_inflateSyncPoint
+#  define inflateUndermine      z_inflateUndermine
+#  define inflate_copyright     z_inflate_copyright
+#  define inflate_fast          z_inflate_fast
+#  define inflate_table         z_inflate_table
+#  define uncompress            z_uncompress
 #  define zError                z_zError
+#  define zcalloc               z_zcalloc
+#  define zcfree                z_zcfree
+#  define zlibCompileFlags      z_zlibCompileFlags
+#  define zlibVersion           z_zlibVersion
 
-#  define alloc_func            z_alloc_func
-#  define free_func             z_free_func
-#  define in_func               z_in_func
-#  define out_func              z_out_func
+/* all zlib typedefs in zlib.h and zconf.h */
 #  define Byte                  z_Byte
-#  define uInt                  z_uInt
-#  define uLong                 z_uLong
 #  define Bytef                 z_Bytef
+#  define alloc_func            z_alloc_func
 #  define charf                 z_charf
+#  define free_func             z_free_func
+#  define gzFile                z_gzFile
+#  define gz_header             z_gz_header
+#  define gz_headerp            z_gz_headerp
+#  define in_func               z_in_func
 #  define intf                  z_intf
+#  define out_func              z_out_func
+#  define uInt                  z_uInt
 #  define uIntf                 z_uIntf
+#  define uLong                 z_uLong
 #  define uLongf                z_uLongf
-#  define voidpf                z_voidpf
 #  define voidp                 z_voidp
+#  define voidpc                z_voidpc
+#  define voidpf                z_voidpf
+
+/* all zlib structs in zlib.h and zconf.h */
+#  define gz_header_s           z_gz_header_s
+#  define internal_state        z_internal_state
+
 #endif
 
 #if defined(__MSDOS__) && !defined(MSDOS)
@@ -315,49 +387,73 @@
    typedef Byte       *voidp;
 #endif
 
-#if 0           /* HAVE_UNISTD_H -- this line is updated by ./configure */
-#  include <sys/types.h> /* for off_t */
-#  include <unistd.h>    /* for SEEK_* and off_t */
-#  ifdef VMS
-#    include <unixio.h>   /* for off_t */
-#  endif
-#  define z_off_t off_t
+#ifdef HAVE_UNISTD_H    /* may be set to #if 1 by ./configure */
+#  define Z_HAVE_UNISTD_H
 #endif
+
+#ifdef STDC
+#  include <sys/types.h>    /* for off_t */
+#endif
+
+/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
+ * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even
+ * though the former does not conform to the LFS document), but considering
+ * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as
+ * equivalently requesting no 64-bit operations
+ */
+#if -_LARGEFILE64_SOURCE - -1 == 1
+#  undef _LARGEFILE64_SOURCE
+#endif
+
+#if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)
+#  include <unistd.h>       /* for SEEK_* and off_t */
+#  ifdef VMS
+#    include <unixio.h>     /* for off_t */
+#  endif
+#  ifndef z_off_t
+#    define z_off_t off_t
+#  endif
+#endif
+
 #ifndef SEEK_SET
 #  define SEEK_SET        0       /* Seek from beginning of file.  */
 #  define SEEK_CUR        1       /* Seek from current position.  */
 #  define SEEK_END        2       /* Set file pointer to EOF plus "offset" */
 #endif
+
 #ifndef z_off_t
 #  define z_off_t long
 #endif
 
+#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
+#  define z_off64_t off64_t
+#else
+#  define z_off64_t z_off_t
+#endif
+
 #if defined(__OS400__)
 #  define NO_vsnprintf
 #endif
 
 #if defined(__MVS__)
 #  define NO_vsnprintf
-#  ifdef FAR
-#    undef FAR
-#  endif
 #endif
 
 /* MVS linker does not support external names larger than 8 bytes */
 #if defined(__MVS__)
-#   pragma map(deflateInit_,"DEIN")
-#   pragma map(deflateInit2_,"DEIN2")
-#   pragma map(deflateEnd,"DEEND")
-#   pragma map(deflateBound,"DEBND")
-#   pragma map(inflateInit_,"ININ")
-#   pragma map(inflateInit2_,"ININ2")
-#   pragma map(inflateEnd,"INEND")
-#   pragma map(inflateSync,"INSY")
-#   pragma map(inflateSetDictionary,"INSEDI")
-#   pragma map(compressBound,"CMBND")
-#   pragma map(inflate_table,"INTABL")
-#   pragma map(inflate_fast,"INFA")
-#   pragma map(inflate_copyright,"INCOPY")
+  #pragma map(deflateInit_,"DEIN")
+  #pragma map(deflateInit2_,"DEIN2")
+  #pragma map(deflateEnd,"DEEND")
+  #pragma map(deflateBound,"DEBND")
+  #pragma map(inflateInit_,"ININ")
+  #pragma map(inflateInit2_,"ININ2")
+  #pragma map(inflateEnd,"INEND")
+  #pragma map(inflateSync,"INSY")
+  #pragma map(inflateSetDictionary,"INSEDI")
+  #pragma map(compressBound,"CMBND")
+  #pragma map(inflate_table,"INTABL")
+  #pragma map(inflate_fast,"INFA")
+  #pragma map(inflate_copyright,"INCOPY")
 #endif
 
 #endif /* ZCONF_H */
diff --git a/jdk/src/share/native/java/util/zip/zlib-1.2.3/zcrc32.c b/jdk/src/share/native/java/util/zip/zlib-1.2.5/zcrc32.c
similarity index 95%
rename from jdk/src/share/native/java/util/zip/zlib-1.2.3/zcrc32.c
rename to jdk/src/share/native/java/util/zip/zlib-1.2.5/zcrc32.c
index 0fd9a92..0eb5b64 100644
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/zcrc32.c
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/zcrc32.c
@@ -23,7 +23,7 @@
  */
 
 /* crc32.c -- compute the CRC-32 of a data stream
- * Copyright (C) 1995-2005 Mark Adler
+ * Copyright (C) 1995-2006, 2010 Mark Adler
  * For conditions of distribution and use, see copyright notice in zlib.h
  *
  * Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster
@@ -77,7 +77,7 @@
 
 /* Definitions for doing the crc four data bytes at a time. */
 #ifdef BYFOUR
-#  define REV(w) (((w)>>24)+(((w)>>8)&0xff00)+ \
+#  define REV(w) ((((w)>>24)&0xff)+(((w)>>8)&0xff00)+ \
                 (((w)&0xff00)<<8)+(((w)&0xff)<<24))
    local unsigned long crc32_little OF((unsigned long,
                         const unsigned char FAR *, unsigned));
@@ -92,6 +92,8 @@
 local unsigned long gf2_matrix_times OF((unsigned long *mat,
                                          unsigned long vec));
 local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat));
+local uLong crc32_combine_(uLong crc1, uLong crc2, z_off64_t len2);
+
 
 #ifdef DYNAMIC_CRC_TABLE
 
@@ -243,7 +245,7 @@
 uLong ZEXPORT crc32(crc, buf, len)
     uLong crc;
     const unsigned char FAR *buf;
-    unsigned len;
+    uInt len;
 {
     if (buf == Z_NULL) return 0UL;
 
@@ -391,22 +393,22 @@
 }
 
 /* ========================================================================= */
-uLong ZEXPORT crc32_combine(crc1, crc2, len2)
+local uLong crc32_combine_(crc1, crc2, len2)
     uLong crc1;
     uLong crc2;
-    z_off_t len2;
+    z_off64_t len2;
 {
     int n;
     unsigned long row;
     unsigned long even[GF2_DIM];    /* even-power-of-two zeros operator */
     unsigned long odd[GF2_DIM];     /* odd-power-of-two zeros operator */
 
-    /* degenerate case */
-    if (len2 == 0)
+    /* degenerate case (also disallow negative lengths) */
+    if (len2 <= 0)
         return crc1;
 
     /* put operator for one zero bit in odd */
-    odd[0] = 0xedb88320UL;           /* CRC-32 polynomial */
+    odd[0] = 0xedb88320UL;          /* CRC-32 polynomial */
     row = 1;
     for (n = 1; n < GF2_DIM; n++) {
         odd[n] = row;
@@ -445,3 +447,20 @@
     crc1 ^= crc2;
     return crc1;
 }
+
+/* ========================================================================= */
+uLong ZEXPORT crc32_combine(crc1, crc2, len2)
+    uLong crc1;
+    uLong crc2;
+    z_off_t len2;
+{
+    return crc32_combine_(crc1, crc2, len2);
+}
+
+uLong ZEXPORT crc32_combine64(crc1, crc2, len2)
+    uLong crc1;
+    uLong crc2;
+    z_off64_t len2;
+{
+    return crc32_combine_(crc1, crc2, len2);
+}
diff --git a/jdk/src/share/native/java/util/zip/zlib-1.2.5/zlib.h b/jdk/src/share/native/java/util/zip/zlib-1.2.5/zlib.h
new file mode 100644
index 0000000..b847c10
--- /dev/null
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/zlib.h
@@ -0,0 +1,1637 @@
+/*
+ * 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.
+ */
+
+/* zlib.h -- interface of the 'zlib' general purpose compression library
+  version 1.2.5, April 19th, 2010
+
+  Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler
+
+  This software is provided 'as-is', without any express or implied
+  warranty.  In no event will the authors be held liable for any damages
+  arising from the use of this software.
+
+  Permission is granted to anyone to use this software for any purpose,
+  including commercial applications, and to alter it and redistribute it
+  freely, subject to the following restrictions:
+
+  1. The origin of this software must not be misrepresented; you must not
+     claim that you wrote the original software. If you use this software
+     in a product, an acknowledgment in the product documentation would be
+     appreciated but is not required.
+  2. Altered source versions must be plainly marked as such, and must not be
+     misrepresented as being the original software.
+  3. This notice may not be removed or altered from any source distribution.
+
+  Jean-loup Gailly        Mark Adler
+  jloup@gzip.org          madler@alumni.caltech.edu
+
+
+  The data format used by the zlib library is described by RFCs (Request for
+  Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt
+  (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).
+*/
+
+#ifndef ZLIB_H
+#define ZLIB_H
+
+#include "zconf.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define ZLIB_VERSION "1.2.5"
+#define ZLIB_VERNUM 0x1250
+#define ZLIB_VER_MAJOR 1
+#define ZLIB_VER_MINOR 2
+#define ZLIB_VER_REVISION 5
+#define ZLIB_VER_SUBREVISION 0
+
+/*
+    The 'zlib' compression library provides in-memory compression and
+  decompression functions, including integrity checks of the uncompressed data.
+  This version of the library supports only one compression method (deflation)
+  but other algorithms will be added later and will have the same stream
+  interface.
+
+    Compression can be done in a single step if the buffers are large enough,
+  or can be done by repeated calls of the compression function.  In the latter
+  case, the application must provide more input and/or consume the output
+  (providing more output space) before each call.
+
+    The compressed data format used by default by the in-memory functions is
+  the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped
+  around a deflate stream, which is itself documented in RFC 1951.
+
+    The library also supports reading and writing files in gzip (.gz) format
+  with an interface similar to that of stdio using the functions that start
+  with "gz".  The gzip format is different from the zlib format.  gzip is a
+  gzip wrapper, documented in RFC 1952, wrapped around a deflate stream.
+
+    This library can optionally read and write gzip streams in memory as well.
+
+    The zlib format was designed to be compact and fast for use in memory
+  and on communications channels.  The gzip format was designed for single-
+  file compression on file systems, has a larger header than zlib to maintain
+  directory information, and uses a different, slower check method than zlib.
+
+    The library does not install any signal handler.  The decoder checks
+  the consistency of the compressed data, so the library should never crash
+  even in case of corrupted input.
+*/
+
+typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
+typedef void   (*free_func)  OF((voidpf opaque, voidpf address));
+
+struct internal_state;
+
+typedef struct z_stream_s {
+    Bytef    *next_in;  /* next input byte */
+    uInt     avail_in;  /* number of bytes available at next_in */
+    long long total_in; /* total nb of input bytes read so far */
+
+    Bytef    *next_out; /* next output byte should be put there */
+    uInt     avail_out; /* remaining free space at next_out */
+    long long total_out;/* total nb of bytes output so far */
+
+    char     *msg;      /* last error message, NULL if no error */
+    struct internal_state FAR *state; /* not visible by applications */
+
+    alloc_func zalloc;  /* used to allocate the internal state */
+    free_func  zfree;   /* used to free the internal state */
+    voidpf     opaque;  /* private data object passed to zalloc and zfree */
+
+    int     data_type;  /* best guess about the data type: binary or text */
+    uLong   adler;      /* adler32 value of the uncompressed data */
+    uLong   reserved;   /* reserved for future use */
+} z_stream;
+
+typedef z_stream FAR *z_streamp;
+
+/*
+     gzip header information passed to and from zlib routines.  See RFC 1952
+  for more details on the meanings of these fields.
+*/
+typedef struct gz_header_s {
+    int     text;       /* true if compressed data believed to be text */
+    uLong   time;       /* modification time */
+    int     xflags;     /* extra flags (not used when writing a gzip file) */
+    int     os;         /* operating system */
+    Bytef   *extra;     /* pointer to extra field or Z_NULL if none */
+    uInt    extra_len;  /* extra field length (valid if extra != Z_NULL) */
+    uInt    extra_max;  /* space at extra (only when reading header) */
+    Bytef   *name;      /* pointer to zero-terminated file name or Z_NULL */
+    uInt    name_max;   /* space at name (only when reading header) */
+    Bytef   *comment;   /* pointer to zero-terminated comment or Z_NULL */
+    uInt    comm_max;   /* space at comment (only when reading header) */
+    int     hcrc;       /* true if there was or will be a header crc */
+    int     done;       /* true when done reading gzip header (not used
+                           when writing a gzip file) */
+} gz_header;
+
+typedef gz_header FAR *gz_headerp;
+
+/*
+     The application must update next_in and avail_in when avail_in has dropped
+   to zero.  It must update next_out and avail_out when avail_out has dropped
+   to zero.  The application must initialize zalloc, zfree and opaque before
+   calling the init function.  All other fields are set by the compression
+   library and must not be updated by the application.
+
+     The opaque value provided by the application will be passed as the first
+   parameter for calls of zalloc and zfree.  This can be useful for custom
+   memory management.  The compression library attaches no meaning to the
+   opaque value.
+
+     zalloc must return Z_NULL if there is not enough memory for the object.
+   If zlib is used in a multi-threaded application, zalloc and zfree must be
+   thread safe.
+
+     On 16-bit systems, the functions zalloc and zfree must be able to allocate
+   exactly 65536 bytes, but will not be required to allocate more than this if
+   the symbol MAXSEG_64K is defined (see zconf.h).  WARNING: On MSDOS, pointers
+   returned by zalloc for objects of exactly 65536 bytes *must* have their
+   offset normalized to zero.  The default allocation function provided by this
+   library ensures this (see zutil.c).  To reduce memory requirements and avoid
+   any allocation of 64K objects, at the expense of compression ratio, compile
+   the library with -DMAX_WBITS=14 (see zconf.h).
+
+     The fields total_in and total_out can be used for statistics or progress
+   reports.  After compression, total_in holds the total size of the
+   uncompressed data and may be saved for use in the decompressor (particularly
+   if the decompressor wants to decompress everything in a single step).
+*/
+
+                        /* constants */
+
+#define Z_NO_FLUSH      0
+#define Z_PARTIAL_FLUSH 1
+#define Z_SYNC_FLUSH    2
+#define Z_FULL_FLUSH    3
+#define Z_FINISH        4
+#define Z_BLOCK         5
+#define Z_TREES         6
+/* Allowed flush values; see deflate() and inflate() below for details */
+
+#define Z_OK            0
+#define Z_STREAM_END    1
+#define Z_NEED_DICT     2
+#define Z_ERRNO        (-1)
+#define Z_STREAM_ERROR (-2)
+#define Z_DATA_ERROR   (-3)
+#define Z_MEM_ERROR    (-4)
+#define Z_BUF_ERROR    (-5)
+#define Z_VERSION_ERROR (-6)
+/* Return codes for the compression/decompression functions. Negative values
+ * are errors, positive values are used for special but normal events.
+ */
+
+#define Z_NO_COMPRESSION         0
+#define Z_BEST_SPEED             1
+#define Z_BEST_COMPRESSION       9
+#define Z_DEFAULT_COMPRESSION  (-1)
+/* compression levels */
+
+#define Z_FILTERED            1
+#define Z_HUFFMAN_ONLY        2
+#define Z_RLE                 3
+#define Z_FIXED               4
+#define Z_DEFAULT_STRATEGY    0
+/* compression strategy; see deflateInit2() below for details */
+
+#define Z_BINARY   0
+#define Z_TEXT     1
+#define Z_ASCII    Z_TEXT   /* for compatibility with 1.2.2 and earlier */
+#define Z_UNKNOWN  2
+/* Possible values of the data_type field (though see inflate()) */
+
+#define Z_DEFLATED   8
+/* The deflate compression method (the only one supported in this version) */
+
+#define Z_NULL  0  /* for initializing zalloc, zfree, opaque */
+
+#define zlib_version zlibVersion()
+/* for compatibility with versions < 1.0.2 */
+
+
+                        /* basic functions */
+
+ZEXTERN const char * ZEXPORT zlibVersion OF((void));
+/* The application can compare zlibVersion and ZLIB_VERSION for consistency.
+   If the first character differs, the library code actually used is not
+   compatible with the zlib.h header file used by the application.  This check
+   is automatically made by deflateInit and inflateInit.
+ */
+
+/*
+ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));
+
+     Initializes the internal stream state for compression.  The fields
+   zalloc, zfree and opaque must be initialized before by the caller.  If
+   zalloc and zfree are set to Z_NULL, deflateInit updates them to use default
+   allocation functions.
+
+     The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:
+   1 gives best speed, 9 gives best compression, 0 gives no compression at all
+   (the input data is simply copied a block at a time).  Z_DEFAULT_COMPRESSION
+   requests a default compromise between speed and compression (currently
+   equivalent to level 6).
+
+     deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
+   memory, Z_STREAM_ERROR if level is not a valid compression level, or
+   Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible
+   with the version assumed by the caller (ZLIB_VERSION).  msg is set to null
+   if there is no error message.  deflateInit does not perform any compression:
+   this will be done by deflate().
+*/
+
+
+ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
+/*
+    deflate compresses as much data as possible, and stops when the input
+  buffer becomes empty or the output buffer becomes full.  It may introduce
+  some output latency (reading input without producing any output) except when
+  forced to flush.
+
+    The detailed semantics are as follows.  deflate performs one or both of the
+  following actions:
+
+  - Compress more input starting at next_in and update next_in and avail_in
+    accordingly.  If not all input can be processed (because there is not
+    enough room in the output buffer), next_in and avail_in are updated and
+    processing will resume at this point for the next call of deflate().
+
+  - Provide more output starting at next_out and update next_out and avail_out
+    accordingly.  This action is forced if the parameter flush is non zero.
+    Forcing flush frequently degrades the compression ratio, so this parameter
+    should be set only when necessary (in interactive applications).  Some
+    output may be provided even if flush is not set.
+
+    Before the call of deflate(), the application should ensure that at least
+  one of the actions is possible, by providing more input and/or consuming more
+  output, and updating avail_in or avail_out accordingly; avail_out should
+  never be zero before the call.  The application can consume the compressed
+  output when it wants, for example when the output buffer is full (avail_out
+  == 0), or after each call of deflate().  If deflate returns Z_OK and with
+  zero avail_out, it must be called again after making room in the output
+  buffer because there might be more output pending.
+
+    Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to
+  decide how much data to accumulate before producing output, in order to
+  maximize compression.
+
+    If the parameter flush is set to Z_SYNC_FLUSH, all pending output is
+  flushed to the output buffer and the output is aligned on a byte boundary, so
+  that the decompressor can get all input data available so far.  (In
+  particular avail_in is zero after the call if enough output space has been
+  provided before the call.) Flushing may degrade compression for some
+  compression algorithms and so it should be used only when necessary.  This
+  completes the current deflate block and follows it with an empty stored block
+  that is three bits plus filler bits to the next byte, followed by four bytes
+  (00 00 ff ff).
+
+    If flush is set to Z_PARTIAL_FLUSH, all pending output is flushed to the
+  output buffer, but the output is not aligned to a byte boundary.  All of the
+  input data so far will be available to the decompressor, as for Z_SYNC_FLUSH.
+  This completes the current deflate block and follows it with an empty fixed
+  codes block that is 10 bits long.  This assures that enough bytes are output
+  in order for the decompressor to finish the block before the empty fixed code
+  block.
+
+    If flush is set to Z_BLOCK, a deflate block is completed and emitted, as
+  for Z_SYNC_FLUSH, but the output is not aligned on a byte boundary, and up to
+  seven bits of the current block are held to be written as the next byte after
+  the next deflate block is completed.  In this case, the decompressor may not
+  be provided enough bits at this point in order to complete decompression of
+  the data provided so far to the compressor.  It may need to wait for the next
+  block to be emitted.  This is for advanced applications that need to control
+  the emission of deflate blocks.
+
+    If flush is set to Z_FULL_FLUSH, all output is flushed as with
+  Z_SYNC_FLUSH, and the compression state is reset so that decompression can
+  restart from this point if previous compressed data has been damaged or if
+  random access is desired.  Using Z_FULL_FLUSH too often can seriously degrade
+  compression.
+
+    If deflate returns with avail_out == 0, this function must be called again
+  with the same value of the flush parameter and more output space (updated
+  avail_out), until the flush is complete (deflate returns with non-zero
+  avail_out).  In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that
+  avail_out is greater than six to avoid repeated flush markers due to
+  avail_out == 0 on return.
+
+    If the parameter flush is set to Z_FINISH, pending input is processed,
+  pending output is flushed and deflate returns with Z_STREAM_END if there was
+  enough output space; if deflate returns with Z_OK, this function must be
+  called again with Z_FINISH and more output space (updated avail_out) but no
+  more input data, until it returns with Z_STREAM_END or an error.  After
+  deflate has returned Z_STREAM_END, the only possible operations on the stream
+  are deflateReset or deflateEnd.
+
+    Z_FINISH can be used immediately after deflateInit if all the compression
+  is to be done in a single step.  In this case, avail_out must be at least the
+  value returned by deflateBound (see below).  If deflate does not return
+  Z_STREAM_END, then it must be called again as described above.
+
+    deflate() sets strm->adler to the adler32 checksum of all input read
+  so far (that is, total_in bytes).
+
+    deflate() may update strm->data_type if it can make a good guess about
+  the input data type (Z_BINARY or Z_TEXT).  In doubt, the data is considered
+  binary.  This field is only for information purposes and does not affect the
+  compression algorithm in any manner.
+
+    deflate() returns Z_OK if some progress has been made (more input
+  processed or more output produced), Z_STREAM_END if all input has been
+  consumed and all output has been produced (only when flush is set to
+  Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example
+  if next_in or next_out was Z_NULL), Z_BUF_ERROR if no progress is possible
+  (for example avail_in or avail_out was zero).  Note that Z_BUF_ERROR is not
+  fatal, and deflate() can be called again with more input and more output
+  space to continue compressing.
+*/
+
+
+ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));
+/*
+     All dynamically allocated data structures for this stream are freed.
+   This function discards any unprocessed input and does not flush any pending
+   output.
+
+     deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the
+   stream state was inconsistent, Z_DATA_ERROR if the stream was freed
+   prematurely (some input or output was discarded).  In the error case, msg
+   may be set but then points to a static string (which must not be
+   deallocated).
+*/
+
+
+/*
+ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));
+
+     Initializes the internal stream state for decompression.  The fields
+   next_in, avail_in, zalloc, zfree and opaque must be initialized before by
+   the caller.  If next_in is not Z_NULL and avail_in is large enough (the
+   exact value depends on the compression method), inflateInit determines the
+   compression method from the zlib header and allocates all data structures
+   accordingly; otherwise the allocation will be deferred to the first call of
+   inflate.  If zalloc and zfree are set to Z_NULL, inflateInit updates them to
+   use default allocation functions.
+
+     inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
+   memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
+   version assumed by the caller, or Z_STREAM_ERROR if the parameters are
+   invalid, such as a null pointer to the structure.  msg is set to null if
+   there is no error message.  inflateInit does not perform any decompression
+   apart from possibly reading the zlib header if present: actual decompression
+   will be done by inflate().  (So next_in and avail_in may be modified, but
+   next_out and avail_out are unused and unchanged.) The current implementation
+   of inflateInit() does not process any header information -- that is deferred
+   until inflate() is called.
+*/
+
+
+ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
+/*
+    inflate decompresses as much data as possible, and stops when the input
+  buffer becomes empty or the output buffer becomes full.  It may introduce
+  some output latency (reading input without producing any output) except when
+  forced to flush.
+
+  The detailed semantics are as follows.  inflate performs one or both of the
+  following actions:
+
+  - Decompress more input starting at next_in and update next_in and avail_in
+    accordingly.  If not all input can be processed (because there is not
+    enough room in the output buffer), next_in is updated and processing will
+    resume at this point for the next call of inflate().
+
+  - Provide more output starting at next_out and update next_out and avail_out
+    accordingly.  inflate() provides as much output as possible, until there is
+    no more input data or no more space in the output buffer (see below about
+    the flush parameter).
+
+    Before the call of inflate(), the application should ensure that at least
+  one of the actions is possible, by providing more input and/or consuming more
+  output, and updating the next_* and avail_* values accordingly.  The
+  application can consume the uncompressed output when it wants, for example
+  when the output buffer is full (avail_out == 0), or after each call of
+  inflate().  If inflate returns Z_OK and with zero avail_out, it must be
+  called again after making room in the output buffer because there might be
+  more output pending.
+
+    The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FINISH,
+  Z_BLOCK, or Z_TREES.  Z_SYNC_FLUSH requests that inflate() flush as much
+  output as possible to the output buffer.  Z_BLOCK requests that inflate()
+  stop if and when it gets to the next deflate block boundary.  When decoding
+  the zlib or gzip format, this will cause inflate() to return immediately
+  after the header and before the first block.  When doing a raw inflate,
+  inflate() will go ahead and process the first block, and will return when it
+  gets to the end of that block, or when it runs out of data.
+
+    The Z_BLOCK option assists in appending to or combining deflate streams.
+  Also to assist in this, on return inflate() will set strm->data_type to the
+  number of unused bits in the last byte taken from strm->next_in, plus 64 if
+  inflate() is currently decoding the last block in the deflate stream, plus
+  128 if inflate() returned immediately after decoding an end-of-block code or
+  decoding the complete header up to just before the first byte of the deflate
+  stream.  The end-of-block will not be indicated until all of the uncompressed
+  data from that block has been written to strm->next_out.  The number of
+  unused bits may in general be greater than seven, except when bit 7 of
+  data_type is set, in which case the number of unused bits will be less than
+  eight.  data_type is set as noted here every time inflate() returns for all
+  flush options, and so can be used to determine the amount of currently
+  consumed input in bits.
+
+    The Z_TREES option behaves as Z_BLOCK does, but it also returns when the
+  end of each deflate block header is reached, before any actual data in that
+  block is decoded.  This allows the caller to determine the length of the
+  deflate block header for later use in random access within a deflate block.
+  256 is added to the value of strm->data_type when inflate() returns
+  immediately after reaching the end of the deflate block header.
+
+    inflate() should normally be called until it returns Z_STREAM_END or an
+  error.  However if all decompression is to be performed in a single step (a
+  single call of inflate), the parameter flush should be set to Z_FINISH.  In
+  this case all pending input is processed and all pending output is flushed;
+  avail_out must be large enough to hold all the uncompressed data.  (The size
+  of the uncompressed data may have been saved by the compressor for this
+  purpose.) The next operation on this stream must be inflateEnd to deallocate
+  the decompression state.  The use of Z_FINISH is never required, but can be
+  used to inform inflate that a faster approach may be used for the single
+  inflate() call.
+
+     In this implementation, inflate() always flushes as much output as
+  possible to the output buffer, and always uses the faster approach on the
+  first call.  So the only effect of the flush parameter in this implementation
+  is on the return value of inflate(), as noted below, or when it returns early
+  because Z_BLOCK or Z_TREES is used.
+
+     If a preset dictionary is needed after this call (see inflateSetDictionary
+  below), inflate sets strm->adler to the adler32 checksum of the dictionary
+  chosen by the compressor and returns Z_NEED_DICT; otherwise it sets
+  strm->adler to the adler32 checksum of all output produced so far (that is,
+  total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described
+  below.  At the end of the stream, inflate() checks that its computed adler32
+  checksum is equal to that saved by the compressor and returns Z_STREAM_END
+  only if the checksum is correct.
+
+    inflate() can decompress and check either zlib-wrapped or gzip-wrapped
+  deflate data.  The header type is detected automatically, if requested when
+  initializing with inflateInit2().  Any information contained in the gzip
+  header is not retained, so applications that need that information should
+  instead use raw inflate, see inflateInit2() below, or inflateBack() and
+  perform their own processing of the gzip header and trailer.
+
+    inflate() returns Z_OK if some progress has been made (more input processed
+  or more output produced), Z_STREAM_END if the end of the compressed data has
+  been reached and all uncompressed output has been produced, Z_NEED_DICT if a
+  preset dictionary is needed at this point, Z_DATA_ERROR if the input data was
+  corrupted (input stream not conforming to the zlib format or incorrect check
+  value), Z_STREAM_ERROR if the stream structure was inconsistent (for example
+  next_in or next_out was Z_NULL), Z_MEM_ERROR if there was not enough memory,
+  Z_BUF_ERROR if no progress is possible or if there was not enough room in the
+  output buffer when Z_FINISH is used.  Note that Z_BUF_ERROR is not fatal, and
+  inflate() can be called again with more input and more output space to
+  continue decompressing.  If Z_DATA_ERROR is returned, the application may
+  then call inflateSync() to look for a good compression block if a partial
+  recovery of the data is desired.
+*/
+
+
+ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));
+/*
+     All dynamically allocated data structures for this stream are freed.
+   This function discards any unprocessed input and does not flush any pending
+   output.
+
+     inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state
+   was inconsistent.  In the error case, msg may be set but then points to a
+   static string (which must not be deallocated).
+*/
+
+
+                        /* Advanced functions */
+
+/*
+    The following functions are needed only in some special applications.
+*/
+
+/*
+ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
+                                     int  level,
+                                     int  method,
+                                     int  windowBits,
+                                     int  memLevel,
+                                     int  strategy));
+
+     This is another version of deflateInit with more compression options.  The
+   fields next_in, zalloc, zfree and opaque must be initialized before by the
+   caller.
+
+     The method parameter is the compression method.  It must be Z_DEFLATED in
+   this version of the library.
+
+     The windowBits parameter is the base two logarithm of the window size
+   (the size of the history buffer).  It should be in the range 8..15 for this
+   version of the library.  Larger values of this parameter result in better
+   compression at the expense of memory usage.  The default value is 15 if
+   deflateInit is used instead.
+
+     windowBits can also be -8..-15 for raw deflate.  In this case, -windowBits
+   determines the window size.  deflate() will then generate raw deflate data
+   with no zlib header or trailer, and will not compute an adler32 check value.
+
+     windowBits can also be greater than 15 for optional gzip encoding.  Add
+   16 to windowBits to write a simple gzip header and trailer around the
+   compressed data instead of a zlib wrapper.  The gzip header will have no
+   file name, no extra data, no comment, no modification time (set to zero), no
+   header crc, and the operating system will be set to 255 (unknown).  If a
+   gzip stream is being written, strm->adler is a crc32 instead of an adler32.
+
+     The memLevel parameter specifies how much memory should be allocated
+   for the internal compression state.  memLevel=1 uses minimum memory but is
+   slow and reduces compression ratio; memLevel=9 uses maximum memory for
+   optimal speed.  The default value is 8.  See zconf.h for total memory usage
+   as a function of windowBits and memLevel.
+
+     The strategy parameter is used to tune the compression algorithm.  Use the
+   value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a
+   filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no
+   string match), or Z_RLE to limit match distances to one (run-length
+   encoding).  Filtered data consists mostly of small values with a somewhat
+   random distribution.  In this case, the compression algorithm is tuned to
+   compress them better.  The effect of Z_FILTERED is to force more Huffman
+   coding and less string matching; it is somewhat intermediate between
+   Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY.  Z_RLE is designed to be almost as
+   fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data.  The
+   strategy parameter only affects the compression ratio but not the
+   correctness of the compressed output even if it is not set appropriately.
+   Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler
+   decoder for special applications.
+
+     deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
+   memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid
+   method), or Z_VERSION_ERROR if the zlib library version (zlib_version) is
+   incompatible with the version assumed by the caller (ZLIB_VERSION).  msg is
+   set to null if there is no error message.  deflateInit2 does not perform any
+   compression: this will be done by deflate().
+*/
+
+ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
+                                             const Bytef *dictionary,
+                                             uInt  dictLength));
+/*
+     Initializes the compression dictionary from the given byte sequence
+   without producing any compressed output.  This function must be called
+   immediately after deflateInit, deflateInit2 or deflateReset, before any call
+   of deflate.  The compressor and decompressor must use exactly the same
+   dictionary (see inflateSetDictionary).
+
+     The dictionary should consist of strings (byte sequences) that are likely
+   to be encountered later in the data to be compressed, with the most commonly
+   used strings preferably put towards the end of the dictionary.  Using a
+   dictionary is most useful when the data to be compressed is short and can be
+   predicted with good accuracy; the data can then be compressed better than
+   with the default empty dictionary.
+
+     Depending on the size of the compression data structures selected by
+   deflateInit or deflateInit2, a part of the dictionary may in effect be
+   discarded, for example if the dictionary is larger than the window size
+   provided in deflateInit or deflateInit2.  Thus the strings most likely to be
+   useful should be put at the end of the dictionary, not at the front.  In
+   addition, the current implementation of deflate will use at most the window
+   size minus 262 bytes of the provided dictionary.
+
+     Upon return of this function, strm->adler is set to the adler32 value
+   of the dictionary; the decompressor may later use this value to determine
+   which dictionary has been used by the compressor.  (The adler32 value
+   applies to the whole dictionary even if only a subset of the dictionary is
+   actually used by the compressor.) If a raw deflate was requested, then the
+   adler32 value is not computed and strm->adler is not set.
+
+     deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a
+   parameter is invalid (e.g.  dictionary being Z_NULL) or the stream state is
+   inconsistent (for example if deflate has already been called for this stream
+   or if the compression method is bsort).  deflateSetDictionary does not
+   perform any compression: this will be done by deflate().
+*/
+
+ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,
+                                    z_streamp source));
+/*
+     Sets the destination stream as a complete copy of the source stream.
+
+     This function can be useful when several compression strategies will be
+   tried, for example when there are several ways of pre-processing the input
+   data with a filter.  The streams that will be discarded should then be freed
+   by calling deflateEnd.  Note that deflateCopy duplicates the internal
+   compression state which can be quite large, so this strategy is slow and can
+   consume lots of memory.
+
+     deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
+   enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
+   (such as zalloc being Z_NULL).  msg is left unchanged in both source and
+   destination.
+*/
+
+ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));
+/*
+     This function is equivalent to deflateEnd followed by deflateInit,
+   but does not free and reallocate all the internal compression state.  The
+   stream will keep the same compression level and any other attributes that
+   may have been set by deflateInit2.
+
+     deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
+   stream state was inconsistent (such as zalloc or state being Z_NULL).
+*/
+
+ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
+                                      int level,
+                                      int strategy));
+/*
+     Dynamically update the compression level and compression strategy.  The
+   interpretation of level and strategy is as in deflateInit2.  This can be
+   used to switch between compression and straight copy of the input data, or
+   to switch to a different kind of input data requiring a different strategy.
+   If the compression level is changed, the input available so far is
+   compressed with the old level (and may be flushed); the new level will take
+   effect only at the next call of deflate().
+
+     Before the call of deflateParams, the stream state must be set as for
+   a call of deflate(), since the currently available input may have to be
+   compressed and flushed.  In particular, strm->avail_out must be non-zero.
+
+     deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source
+   stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR if
+   strm->avail_out was zero.
+*/
+
+ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm,
+                                    int good_length,
+                                    int max_lazy,
+                                    int nice_length,
+                                    int max_chain));
+/*
+     Fine tune deflate's internal compression parameters.  This should only be
+   used by someone who understands the algorithm used by zlib's deflate for
+   searching for the best matching string, and even then only by the most
+   fanatic optimizer trying to squeeze out the last compressed bit for their
+   specific input data.  Read the deflate.c source code for the meaning of the
+   max_lazy, good_length, nice_length, and max_chain parameters.
+
+     deflateTune() can be called after deflateInit() or deflateInit2(), and
+   returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream.
+ */
+
+ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm,
+                                       uLong sourceLen));
+/*
+     deflateBound() returns an upper bound on the compressed size after
+   deflation of sourceLen bytes.  It must be called after deflateInit() or
+   deflateInit2(), and after deflateSetHeader(), if used.  This would be used
+   to allocate an output buffer for deflation in a single pass, and so would be
+   called before deflate().
+*/
+
+ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm,
+                                     int bits,
+                                     int value));
+/*
+     deflatePrime() inserts bits in the deflate output stream.  The intent
+   is that this function is used to start off the deflate output with the bits
+   leftover from a previous deflate stream when appending to it.  As such, this
+   function can only be used for raw deflate, and must be used before the first
+   deflate() call after a deflateInit2() or deflateReset().  bits must be less
+   than or equal to 16, and that many of the least significant bits of value
+   will be inserted in the output.
+
+     deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source
+   stream state was inconsistent.
+*/
+
+ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm,
+                                         gz_headerp head));
+/*
+     deflateSetHeader() provides gzip header information for when a gzip
+   stream is requested by deflateInit2().  deflateSetHeader() may be called
+   after deflateInit2() or deflateReset() and before the first call of
+   deflate().  The text, time, os, extra field, name, and comment information
+   in the provided gz_header structure are written to the gzip header (xflag is
+   ignored -- the extra flags are set according to the compression level).  The
+   caller must assure that, if not Z_NULL, name and comment are terminated with
+   a zero byte, and that if extra is not Z_NULL, that extra_len bytes are
+   available there.  If hcrc is true, a gzip header crc is included.  Note that
+   the current versions of the command-line version of gzip (up through version
+   1.3.x) do not support header crc's, and will report that it is a "multi-part
+   gzip file" and give up.
+
+     If deflateSetHeader is not used, the default gzip header has text false,
+   the time set to zero, and os set to 255, with no extra, name, or comment
+   fields.  The gzip header is returned to the default state by deflateReset().
+
+     deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source
+   stream state was inconsistent.
+*/
+
+/*
+ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
+                                     int  windowBits));
+
+     This is another version of inflateInit with an extra parameter.  The
+   fields next_in, avail_in, zalloc, zfree and opaque must be initialized
+   before by the caller.
+
+     The windowBits parameter is the base two logarithm of the maximum window
+   size (the size of the history buffer).  It should be in the range 8..15 for
+   this version of the library.  The default value is 15 if inflateInit is used
+   instead.  windowBits must be greater than or equal to the windowBits value
+   provided to deflateInit2() while compressing, or it must be equal to 15 if
+   deflateInit2() was not used.  If a compressed stream with a larger window
+   size is given as input, inflate() will return with the error code
+   Z_DATA_ERROR instead of trying to allocate a larger window.
+
+     windowBits can also be zero to request that inflate use the window size in
+   the zlib header of the compressed stream.
+
+     windowBits can also be -8..-15 for raw inflate.  In this case, -windowBits
+   determines the window size.  inflate() will then process raw deflate data,
+   not looking for a zlib or gzip header, not generating a check value, and not
+   looking for any check values for comparison at the end of the stream.  This
+   is for use with other formats that use the deflate compressed data format
+   such as zip.  Those formats provide their own check values.  If a custom
+   format is developed using the raw deflate format for compressed data, it is
+   recommended that a check value such as an adler32 or a crc32 be applied to
+   the uncompressed data as is done in the zlib, gzip, and zip formats.  For
+   most applications, the zlib format should be used as is.  Note that comments
+   above on the use in deflateInit2() applies to the magnitude of windowBits.
+
+     windowBits can also be greater than 15 for optional gzip decoding.  Add
+   32 to windowBits to enable zlib and gzip decoding with automatic header
+   detection, or add 16 to decode only the gzip format (the zlib format will
+   return a Z_DATA_ERROR).  If a gzip stream is being decoded, strm->adler is a
+   crc32 instead of an adler32.
+
+     inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
+   memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
+   version assumed by the caller, or Z_STREAM_ERROR if the parameters are
+   invalid, such as a null pointer to the structure.  msg is set to null if
+   there is no error message.  inflateInit2 does not perform any decompression
+   apart from possibly reading the zlib header if present: actual decompression
+   will be done by inflate().  (So next_in and avail_in may be modified, but
+   next_out and avail_out are unused and unchanged.) The current implementation
+   of inflateInit2() does not process any header information -- that is
+   deferred until inflate() is called.
+*/
+
+ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
+                                             const Bytef *dictionary,
+                                             uInt  dictLength));
+/*
+     Initializes the decompression dictionary from the given uncompressed byte
+   sequence.  This function must be called immediately after a call of inflate,
+   if that call returned Z_NEED_DICT.  The dictionary chosen by the compressor
+   can be determined from the adler32 value returned by that call of inflate.
+   The compressor and decompressor must use exactly the same dictionary (see
+   deflateSetDictionary).  For raw inflate, this function can be called
+   immediately after inflateInit2() or inflateReset() and before any call of
+   inflate() to set the dictionary.  The application must insure that the
+   dictionary that was used for compression is provided.
+
+     inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a
+   parameter is invalid (e.g.  dictionary being Z_NULL) or the stream state is
+   inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the
+   expected one (incorrect adler32 value).  inflateSetDictionary does not
+   perform any decompression: this will be done by subsequent calls of
+   inflate().
+*/
+
+ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));
+/*
+     Skips invalid compressed data until a full flush point (see above the
+   description of deflate with Z_FULL_FLUSH) can be found, or until all
+   available input is skipped.  No output is provided.
+
+     inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR
+   if no more input was provided, Z_DATA_ERROR if no flush point has been
+   found, or Z_STREAM_ERROR if the stream structure was inconsistent.  In the
+   success case, the application may save the current current value of total_in
+   which indicates where valid compressed data was found.  In the error case,
+   the application may repeatedly call inflateSync, providing more input each
+   time, until success or end of the input data.
+*/
+
+ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest,
+                                    z_streamp source));
+/*
+     Sets the destination stream as a complete copy of the source stream.
+
+     This function can be useful when randomly accessing a large stream.  The
+   first pass through the stream can periodically record the inflate state,
+   allowing restarting inflate at those points when randomly accessing the
+   stream.
+
+     inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
+   enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
+   (such as zalloc being Z_NULL).  msg is left unchanged in both source and
+   destination.
+*/
+
+ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));
+/*
+     This function is equivalent to inflateEnd followed by inflateInit,
+   but does not free and reallocate all the internal decompression state.  The
+   stream will keep attributes that may have been set by inflateInit2.
+
+     inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
+   stream state was inconsistent (such as zalloc or state being Z_NULL).
+*/
+
+ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm,
+                                      int windowBits));
+/*
+     This function is the same as inflateReset, but it also permits changing
+   the wrap and window size requests.  The windowBits parameter is interpreted
+   the same as it is for inflateInit2.
+
+     inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source
+   stream state was inconsistent (such as zalloc or state being Z_NULL), or if
+   the windowBits parameter is invalid.
+*/
+
+ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm,
+                                     int bits,
+                                     int value));
+/*
+     This function inserts bits in the inflate input stream.  The intent is
+   that this function is used to start inflating at a bit position in the
+   middle of a byte.  The provided bits will be used before any bytes are used
+   from next_in.  This function should only be used with raw inflate, and
+   should be used before the first inflate() call after inflateInit2() or
+   inflateReset().  bits must be less than or equal to 16, and that many of the
+   least significant bits of value will be inserted in the input.
+
+     If bits is negative, then the input stream bit buffer is emptied.  Then
+   inflatePrime() can be called again to put bits in the buffer.  This is used
+   to clear out bits leftover after feeding inflate a block description prior
+   to feeding inflate codes.
+
+     inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source
+   stream state was inconsistent.
+*/
+
+ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm));
+/*
+     This function returns two values, one in the lower 16 bits of the return
+   value, and the other in the remaining upper bits, obtained by shifting the
+   return value down 16 bits.  If the upper value is -1 and the lower value is
+   zero, then inflate() is currently decoding information outside of a block.
+   If the upper value is -1 and the lower value is non-zero, then inflate is in
+   the middle of a stored block, with the lower value equaling the number of
+   bytes from the input remaining to copy.  If the upper value is not -1, then
+   it is the number of bits back from the current bit position in the input of
+   the code (literal or length/distance pair) currently being processed.  In
+   that case the lower value is the number of bytes already emitted for that
+   code.
+
+     A code is being processed if inflate is waiting for more input to complete
+   decoding of the code, or if it has completed decoding but is waiting for
+   more output space to write the literal or match data.
+
+     inflateMark() is used to mark locations in the input data for random
+   access, which may be at bit positions, and to note those cases where the
+   output of a code may span boundaries of random access blocks.  The current
+   location in the input stream can be determined from avail_in and data_type
+   as noted in the description for the Z_BLOCK flush parameter for inflate.
+
+     inflateMark returns the value noted above or -1 << 16 if the provided
+   source stream state was inconsistent.
+*/
+
+ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm,
+                                         gz_headerp head));
+/*
+     inflateGetHeader() requests that gzip header information be stored in the
+   provided gz_header structure.  inflateGetHeader() may be called after
+   inflateInit2() or inflateReset(), and before the first call of inflate().
+   As inflate() processes the gzip stream, head->done is zero until the header
+   is completed, at which time head->done is set to one.  If a zlib stream is
+   being decoded, then head->done is set to -1 to indicate that there will be
+   no gzip header information forthcoming.  Note that Z_BLOCK or Z_TREES can be
+   used to force inflate() to return immediately after header processing is
+   complete and before any actual data is decompressed.
+
+     The text, time, xflags, and os fields are filled in with the gzip header
+   contents.  hcrc is set to true if there is a header CRC.  (The header CRC
+   was valid if done is set to one.) If extra is not Z_NULL, then extra_max
+   contains the maximum number of bytes to write to extra.  Once done is true,
+   extra_len contains the actual extra field length, and extra contains the
+   extra field, or that field truncated if extra_max is less than extra_len.
+   If name is not Z_NULL, then up to name_max characters are written there,
+   terminated with a zero unless the length is greater than name_max.  If
+   comment is not Z_NULL, then up to comm_max characters are written there,
+   terminated with a zero unless the length is greater than comm_max.  When any
+   of extra, name, or comment are not Z_NULL and the respective field is not
+   present in the header, then that field is set to Z_NULL to signal its
+   absence.  This allows the use of deflateSetHeader() with the returned
+   structure to duplicate the header.  However if those fields are set to
+   allocated memory, then the application will need to save those pointers
+   elsewhere so that they can be eventually freed.
+
+     If inflateGetHeader is not used, then the header information is simply
+   discarded.  The header is always checked for validity, including the header
+   CRC if present.  inflateReset() will reset the process to discard the header
+   information.  The application would need to call inflateGetHeader() again to
+   retrieve the header from the next gzip stream.
+
+     inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source
+   stream state was inconsistent.
+*/
+
+/*
+ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits,
+                                        unsigned char FAR *window));
+
+     Initialize the internal stream state for decompression using inflateBack()
+   calls.  The fields zalloc, zfree and opaque in strm must be initialized
+   before the call.  If zalloc and zfree are Z_NULL, then the default library-
+   derived memory allocation routines are used.  windowBits is the base two
+   logarithm of the window size, in the range 8..15.  window is a caller
+   supplied buffer of that size.  Except for special applications where it is
+   assured that deflate was used with small window sizes, windowBits must be 15
+   and a 32K byte window must be supplied to be able to decompress general
+   deflate streams.
+
+     See inflateBack() for the usage of these routines.
+
+     inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of
+   the paramaters are invalid, Z_MEM_ERROR if the internal state could not be
+   allocated, or Z_VERSION_ERROR if the version of the library does not match
+   the version of the header file.
+*/
+
+typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *));
+typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned));
+
+ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,
+                                    in_func in, void FAR *in_desc,
+                                    out_func out, void FAR *out_desc));
+/*
+     inflateBack() does a raw inflate with a single call using a call-back
+   interface for input and output.  This is more efficient than inflate() for
+   file i/o applications in that it avoids copying between the output and the
+   sliding window by simply making the window itself the output buffer.  This
+   function trusts the application to not change the output buffer passed by
+   the output function, at least until inflateBack() returns.
+
+     inflateBackInit() must be called first to allocate the internal state
+   and to initialize the state with the user-provided window buffer.
+   inflateBack() may then be used multiple times to inflate a complete, raw
+   deflate stream with each call.  inflateBackEnd() is then called to free the
+   allocated state.
+
+     A raw deflate stream is one with no zlib or gzip header or trailer.
+   This routine would normally be used in a utility that reads zip or gzip
+   files and writes out uncompressed files.  The utility would decode the
+   header and process the trailer on its own, hence this routine expects only
+   the raw deflate stream to decompress.  This is different from the normal
+   behavior of inflate(), which expects either a zlib or gzip header and
+   trailer around the deflate stream.
+
+     inflateBack() uses two subroutines supplied by the caller that are then
+   called by inflateBack() for input and output.  inflateBack() calls those
+   routines until it reads a complete deflate stream and writes out all of the
+   uncompressed data, or until it encounters an error.  The function's
+   parameters and return types are defined above in the in_func and out_func
+   typedefs.  inflateBack() will call in(in_desc, &buf) which should return the
+   number of bytes of provided input, and a pointer to that input in buf.  If
+   there is no input available, in() must return zero--buf is ignored in that
+   case--and inflateBack() will return a buffer error.  inflateBack() will call
+   out(out_desc, buf, len) to write the uncompressed data buf[0..len-1].  out()
+   should return zero on success, or non-zero on failure.  If out() returns
+   non-zero, inflateBack() will return with an error.  Neither in() nor out()
+   are permitted to change the contents of the window provided to
+   inflateBackInit(), which is also the buffer that out() uses to write from.
+   The length written by out() will be at most the window size.  Any non-zero
+   amount of input may be provided by in().
+
+     For convenience, inflateBack() can be provided input on the first call by
+   setting strm->next_in and strm->avail_in.  If that input is exhausted, then
+   in() will be called.  Therefore strm->next_in must be initialized before
+   calling inflateBack().  If strm->next_in is Z_NULL, then in() will be called
+   immediately for input.  If strm->next_in is not Z_NULL, then strm->avail_in
+   must also be initialized, and then if strm->avail_in is not zero, input will
+   initially be taken from strm->next_in[0 ..  strm->avail_in - 1].
+
+     The in_desc and out_desc parameters of inflateBack() is passed as the
+   first parameter of in() and out() respectively when they are called.  These
+   descriptors can be optionally used to pass any information that the caller-
+   supplied in() and out() functions need to do their job.
+
+     On return, inflateBack() will set strm->next_in and strm->avail_in to
+   pass back any unused input that was provided by the last in() call.  The
+   return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR
+   if in() or out() returned an error, Z_DATA_ERROR if there was a format error
+   in the deflate stream (in which case strm->msg is set to indicate the nature
+   of the error), or Z_STREAM_ERROR if the stream was not properly initialized.
+   In the case of Z_BUF_ERROR, an input or output error can be distinguished
+   using strm->next_in which will be Z_NULL only if in() returned an error.  If
+   strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning
+   non-zero.  (in() will always be called before out(), so strm->next_in is
+   assured to be defined if out() returns non-zero.) Note that inflateBack()
+   cannot return Z_OK.
+*/
+
+ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm));
+/*
+     All memory allocated by inflateBackInit() is freed.
+
+     inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream
+   state was inconsistent.
+*/
+
+ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void));
+/* Return flags indicating compile-time options.
+
+    Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other:
+     1.0: size of uInt
+     3.2: size of uLong
+     5.4: size of voidpf (pointer)
+     7.6: size of z_off_t
+
+    Compiler, assembler, and debug options:
+     8: DEBUG
+     9: ASMV or ASMINF -- use ASM code
+     10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention
+     11: 0 (reserved)
+
+    One-time table building (smaller code, but not thread-safe if true):
+     12: BUILDFIXED -- build static block decoding tables when needed
+     13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed
+     14,15: 0 (reserved)
+
+    Library content (indicates missing functionality):
+     16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking
+                          deflate code when not needed)
+     17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect
+                    and decode gzip streams (to avoid linking crc code)
+     18-19: 0 (reserved)
+
+    Operation variations (changes in library functionality):
+     20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate
+     21: FASTEST -- deflate algorithm with only one, lowest compression level
+     22,23: 0 (reserved)
+
+    The sprintf variant used by gzprintf (zero is best):
+     24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format
+     25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure!
+     26: 0 = returns value, 1 = void -- 1 means inferred string length returned
+
+    Remainder:
+     27-31: 0 (reserved)
+ */
+
+
+                        /* utility functions */
+
+/*
+     The following utility functions are implemented on top of the basic
+   stream-oriented functions.  To simplify the interface, some default options
+   are assumed (compression level and memory usage, standard memory allocation
+   functions).  The source code of these utility functions can be modified if
+   you need special options.
+*/
+
+ZEXTERN int ZEXPORT compress OF((Bytef *dest,   uLongf *destLen,
+                                 const Bytef *source, uLong sourceLen));
+/*
+     Compresses the source buffer into the destination buffer.  sourceLen is
+   the byte length of the source buffer.  Upon entry, destLen is the total size
+   of the destination buffer, which must be at least the value returned by
+   compressBound(sourceLen).  Upon exit, destLen is the actual size of the
+   compressed buffer.
+
+     compress returns Z_OK if success, Z_MEM_ERROR if there was not
+   enough memory, Z_BUF_ERROR if there was not enough room in the output
+   buffer.
+*/
+
+ZEXTERN int ZEXPORT compress2 OF((Bytef *dest,   uLongf *destLen,
+                                  const Bytef *source, uLong sourceLen,
+                                  int level));
+/*
+     Compresses the source buffer into the destination buffer.  The level
+   parameter has the same meaning as in deflateInit.  sourceLen is the byte
+   length of the source buffer.  Upon entry, destLen is the total size of the
+   destination buffer, which must be at least the value returned by
+   compressBound(sourceLen).  Upon exit, destLen is the actual size of the
+   compressed buffer.
+
+     compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
+   memory, Z_BUF_ERROR if there was not enough room in the output buffer,
+   Z_STREAM_ERROR if the level parameter is invalid.
+*/
+
+ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen));
+/*
+     compressBound() returns an upper bound on the compressed size after
+   compress() or compress2() on sourceLen bytes.  It would be used before a
+   compress() or compress2() call to allocate the destination buffer.
+*/
+
+ZEXTERN int ZEXPORT uncompress OF((Bytef *dest,   uLongf *destLen,
+                                   const Bytef *source, uLong sourceLen));
+/*
+     Decompresses the source buffer into the destination buffer.  sourceLen is
+   the byte length of the source buffer.  Upon entry, destLen is the total size
+   of the destination buffer, which must be large enough to hold the entire
+   uncompressed data.  (The size of the uncompressed data must have been saved
+   previously by the compressor and transmitted to the decompressor by some
+   mechanism outside the scope of this compression library.) Upon exit, destLen
+   is the actual size of the uncompressed buffer.
+
+     uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
+   enough memory, Z_BUF_ERROR if there was not enough room in the output
+   buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete.
+*/
+
+
+                        /* gzip file access functions */
+
+/*
+     This library supports reading and writing files in gzip (.gz) format with
+   an interface similar to that of stdio, using the functions that start with
+   "gz".  The gzip format is different from the zlib format.  gzip is a gzip
+   wrapper, documented in RFC 1952, wrapped around a deflate stream.
+*/
+
+typedef voidp gzFile;       /* opaque gzip file descriptor */
+
+/*
+ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
+
+     Opens a gzip (.gz) file for reading or writing.  The mode parameter is as
+   in fopen ("rb" or "wb") but can also include a compression level ("wb9") or
+   a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman-only
+   compression as in "wb1h", 'R' for run-length encoding as in "wb1R", or 'F'
+   for fixed code compression as in "wb9F".  (See the description of
+   deflateInit2 for more information about the strategy parameter.) Also "a"
+   can be used instead of "w" to request that the gzip stream that will be
+   written be appended to the file.  "+" will result in an error, since reading
+   and writing to the same gzip file is not supported.
+
+     gzopen can be used to read a file which is not in gzip format; in this
+   case gzread will directly read from the file without decompression.
+
+     gzopen returns NULL if the file could not be opened, if there was
+   insufficient memory to allocate the gzFile state, or if an invalid mode was
+   specified (an 'r', 'w', or 'a' was not provided, or '+' was provided).
+   errno can be checked to determine if the reason gzopen failed was that the
+   file could not be opened.
+*/
+
+ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));
+/*
+     gzdopen associates a gzFile with the file descriptor fd.  File descriptors
+   are obtained from calls like open, dup, creat, pipe or fileno (if the file
+   has been previously opened with fopen).  The mode parameter is as in gzopen.
+
+     The next call of gzclose on the returned gzFile will also close the file
+   descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor
+   fd.  If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd,
+   mode);.  The duplicated descriptor should be saved to avoid a leak, since
+   gzdopen does not close fd if it fails.
+
+     gzdopen returns NULL if there was insufficient memory to allocate the
+   gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not
+   provided, or '+' was provided), or if fd is -1.  The file descriptor is not
+   used until the next gz* read, write, seek, or close operation, so gzdopen
+   will not detect if fd is invalid (unless fd is -1).
+*/
+
+ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size));
+/*
+     Set the internal buffer size used by this library's functions.  The
+   default buffer size is 8192 bytes.  This function must be called after
+   gzopen() or gzdopen(), and before any other calls that read or write the
+   file.  The buffer memory allocation is always deferred to the first read or
+   write.  Two buffers are allocated, either both of the specified size when
+   writing, or one of the specified size and the other twice that size when
+   reading.  A larger buffer size of, for example, 64K or 128K bytes will
+   noticeably increase the speed of decompression (reading).
+
+     The new buffer size also affects the maximum length for gzprintf().
+
+     gzbuffer() returns 0 on success, or -1 on failure, such as being called
+   too late.
+*/
+
+ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
+/*
+     Dynamically update the compression level or strategy.  See the description
+   of deflateInit2 for the meaning of these parameters.
+
+     gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not
+   opened for writing.
+*/
+
+ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));
+/*
+     Reads the given number of uncompressed bytes from the compressed file.  If
+   the input file was not in gzip format, gzread copies the given number of
+   bytes into the buffer.
+
+     After reaching the end of a gzip stream in the input, gzread will continue
+   to read, looking for another gzip stream, or failing that, reading the rest
+   of the input file directly without decompression.  The entire input file
+   will be read if gzread is called until it returns less than the requested
+   len.
+
+     gzread returns the number of uncompressed bytes actually read, less than
+   len for end of file, or -1 for error.
+*/
+
+ZEXTERN int ZEXPORT gzwrite OF((gzFile file,
+                                voidpc buf, unsigned len));
+/*
+     Writes the given number of uncompressed bytes into the compressed file.
+   gzwrite returns the number of uncompressed bytes written or 0 in case of
+   error.
+*/
+
+ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...));
+/*
+     Converts, formats, and writes the arguments to the compressed file under
+   control of the format string, as in fprintf.  gzprintf returns the number of
+   uncompressed bytes actually written, or 0 in case of error.  The number of
+   uncompressed bytes written is limited to 8191, or one less than the buffer
+   size given to gzbuffer().  The caller should assure that this limit is not
+   exceeded.  If it is exceeded, then gzprintf() will return an error (0) with
+   nothing written.  In this case, there may also be a buffer overflow with
+   unpredictable consequences, which is possible only if zlib was compiled with
+   the insecure functions sprintf() or vsprintf() because the secure snprintf()
+   or vsnprintf() functions were not available.  This can be determined using
+   zlibCompileFlags().
+*/
+
+ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));
+/*
+     Writes the given null-terminated string to the compressed file, excluding
+   the terminating null character.
+
+     gzputs returns the number of characters written, or -1 in case of error.
+*/
+
+ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));
+/*
+     Reads bytes from the compressed file until len-1 characters are read, or a
+   newline character is read and transferred to buf, or an end-of-file
+   condition is encountered.  If any characters are read or if len == 1, the
+   string is terminated with a null character.  If no characters are read due
+   to an end-of-file or len < 1, then the buffer is left untouched.
+
+     gzgets returns buf which is a null-terminated string, or it returns NULL
+   for end-of-file or in case of error.  If there was an error, the contents at
+   buf are indeterminate.
+*/
+
+ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c));
+/*
+     Writes c, converted to an unsigned char, into the compressed file.  gzputc
+   returns the value that was written, or -1 in case of error.
+*/
+
+ZEXTERN int ZEXPORT gzgetc OF((gzFile file));
+/*
+     Reads one byte from the compressed file.  gzgetc returns this byte or -1
+   in case of end of file or error.
+*/
+
+ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file));
+/*
+     Push one character back onto the stream to be read as the first character
+   on the next read.  At least one character of push-back is allowed.
+   gzungetc() returns the character pushed, or -1 on failure.  gzungetc() will
+   fail if c is -1, and may fail if a character has been pushed but not read
+   yet.  If gzungetc is used immediately after gzopen or gzdopen, at least the
+   output buffer size of pushed characters is allowed.  (See gzbuffer above.)
+   The pushed character will be discarded if the stream is repositioned with
+   gzseek() or gzrewind().
+*/
+
+ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));
+/*
+     Flushes all pending output into the compressed file.  The parameter flush
+   is as in the deflate() function.  The return value is the zlib error number
+   (see function gzerror below).  gzflush is only permitted when writing.
+
+     If the flush parameter is Z_FINISH, the remaining data is written and the
+   gzip stream is completed in the output.  If gzwrite() is called again, a new
+   gzip stream will be started in the output.  gzread() is able to read such
+   concatented gzip streams.
+
+     gzflush should be called only when strictly necessary because it will
+   degrade compression if called too often.
+*/
+
+/*
+ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,
+                                   z_off_t offset, int whence));
+
+     Sets the starting position for the next gzread or gzwrite on the given
+   compressed file.  The offset represents a number of bytes in the
+   uncompressed data stream.  The whence parameter is defined as in lseek(2);
+   the value SEEK_END is not supported.
+
+     If the file is opened for reading, this function is emulated but can be
+   extremely slow.  If the file is opened for writing, only forward seeks are
+   supported; gzseek then compresses a sequence of zeroes up to the new
+   starting position.
+
+     gzseek returns the resulting offset location as measured in bytes from
+   the beginning of the uncompressed stream, or -1 in case of error, in
+   particular if the file is opened for writing and the new starting position
+   would be before the current position.
+*/
+
+ZEXTERN int ZEXPORT    gzrewind OF((gzFile file));
+/*
+     Rewinds the given file. This function is supported only for reading.
+
+     gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)
+*/
+
+/*
+ZEXTERN z_off_t ZEXPORT    gztell OF((gzFile file));
+
+     Returns the starting position for the next gzread or gzwrite on the given
+   compressed file.  This position represents a number of bytes in the
+   uncompressed data stream, and is zero when starting, even if appending or
+   reading a gzip stream from the middle of a file using gzdopen().
+
+     gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)
+*/
+
+/*
+ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file));
+
+     Returns the current offset in the file being read or written.  This offset
+   includes the count of bytes that precede the gzip stream, for example when
+   appending or when using gzdopen() for reading.  When reading, the offset
+   does not include as yet unused buffered input.  This information can be used
+   for a progress indicator.  On error, gzoffset() returns -1.
+*/
+
+ZEXTERN int ZEXPORT gzeof OF((gzFile file));
+/*
+     Returns true (1) if the end-of-file indicator has been set while reading,
+   false (0) otherwise.  Note that the end-of-file indicator is set only if the
+   read tried to go past the end of the input, but came up short.  Therefore,
+   just like feof(), gzeof() may return false even if there is no more data to
+   read, in the event that the last read request was for the exact number of
+   bytes remaining in the input file.  This will happen if the input file size
+   is an exact multiple of the buffer size.
+
+     If gzeof() returns true, then the read functions will return no more data,
+   unless the end-of-file indicator is reset by gzclearerr() and the input file
+   has grown since the previous end of file was detected.
+*/
+
+ZEXTERN int ZEXPORT gzdirect OF((gzFile file));
+/*
+     Returns true (1) if file is being copied directly while reading, or false
+   (0) if file is a gzip stream being decompressed.  This state can change from
+   false to true while reading the input file if the end of a gzip stream is
+   reached, but is followed by data that is not another gzip stream.
+
+     If the input file is empty, gzdirect() will return true, since the input
+   does not contain a gzip stream.
+
+     If gzdirect() is used immediately after gzopen() or gzdopen() it will
+   cause buffers to be allocated to allow reading the file to determine if it
+   is a gzip file.  Therefore if gzbuffer() is used, it should be called before
+   gzdirect().
+*/
+
+ZEXTERN int ZEXPORT    gzclose OF((gzFile file));
+/*
+     Flushes all pending output if necessary, closes the compressed file and
+   deallocates the (de)compression state.  Note that once file is closed, you
+   cannot call gzerror with file, since its structures have been deallocated.
+   gzclose must not be called more than once on the same file, just as free
+   must not be called more than once on the same allocation.
+
+     gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a
+   file operation error, or Z_OK on success.
+*/
+
+ZEXTERN int ZEXPORT gzclose_r OF((gzFile file));
+ZEXTERN int ZEXPORT gzclose_w OF((gzFile file));
+/*
+     Same as gzclose(), but gzclose_r() is only for use when reading, and
+   gzclose_w() is only for use when writing or appending.  The advantage to
+   using these instead of gzclose() is that they avoid linking in zlib
+   compression or decompression code that is not used when only reading or only
+   writing respectively.  If gzclose() is used, then both compression and
+   decompression code will be included the application when linking to a static
+   zlib library.
+*/
+
+ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
+/*
+     Returns the error message for the last error which occurred on the given
+   compressed file.  errnum is set to zlib error number.  If an error occurred
+   in the file system and not in the compression library, errnum is set to
+   Z_ERRNO and the application may consult errno to get the exact error code.
+
+     The application must not modify the returned string.  Future calls to
+   this function may invalidate the previously returned string.  If file is
+   closed, then the string previously returned by gzerror will no longer be
+   available.
+
+     gzerror() should be used to distinguish errors from end-of-file for those
+   functions above that do not distinguish those cases in their return values.
+*/
+
+ZEXTERN void ZEXPORT gzclearerr OF((gzFile file));
+/*
+     Clears the error and end-of-file flags for file.  This is analogous to the
+   clearerr() function in stdio.  This is useful for continuing to read a gzip
+   file that is being written concurrently.
+*/
+
+
+                        /* checksum functions */
+
+/*
+     These functions are not related to compression but are exported
+   anyway because they might be useful in applications using the compression
+   library.
+*/
+
+ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
+/*
+     Update a running Adler-32 checksum with the bytes buf[0..len-1] and
+   return the updated checksum.  If buf is Z_NULL, this function returns the
+   required initial value for the checksum.
+
+     An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
+   much faster.
+
+   Usage example:
+
+     uLong adler = adler32(0L, Z_NULL, 0);
+
+     while (read_buffer(buffer, length) != EOF) {
+       adler = adler32(adler, buffer, length);
+     }
+     if (adler != original_adler) error();
+*/
+
+/*
+ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,
+                                          z_off_t len2));
+
+     Combine two Adler-32 checksums into one.  For two sequences of bytes, seq1
+   and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for
+   each, adler1 and adler2.  adler32_combine() returns the Adler-32 checksum of
+   seq1 and seq2 concatenated, requiring only adler1, adler2, and len2.
+*/
+
+ZEXTERN uLong ZEXPORT crc32   OF((uLong crc, const Bytef *buf, uInt len));
+/*
+     Update a running CRC-32 with the bytes buf[0..len-1] and return the
+   updated CRC-32.  If buf is Z_NULL, this function returns the required
+   initial value for the for the crc.  Pre- and post-conditioning (one's
+   complement) is performed within this function so it shouldn't be done by the
+   application.
+
+   Usage example:
+
+     uLong crc = crc32(0L, Z_NULL, 0);
+
+     while (read_buffer(buffer, length) != EOF) {
+       crc = crc32(crc, buffer, length);
+     }
+     if (crc != original_crc) error();
+*/
+
+/*
+ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));
+
+     Combine two CRC-32 check values into one.  For two sequences of bytes,
+   seq1 and seq2 with lengths len1 and len2, CRC-32 check values were
+   calculated for each, crc1 and crc2.  crc32_combine() returns the CRC-32
+   check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and
+   len2.
+*/
+
+
+                        /* various hacks, don't look :) */
+
+/* deflateInit and inflateInit are macros to allow checking the zlib version
+ * and the compiler's view of z_stream:
+ */
+ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level,
+                                     const char *version, int stream_size));
+ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm,
+                                     const char *version, int stream_size));
+ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int  level, int  method,
+                                      int windowBits, int memLevel,
+                                      int strategy, const char *version,
+                                      int stream_size));
+ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int  windowBits,
+                                      const char *version, int stream_size));
+ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,
+                                         unsigned char FAR *window,
+                                         const char *version,
+                                         int stream_size));
+#define deflateInit(strm, level) \
+        deflateInit_((strm), (level),       ZLIB_VERSION, sizeof(z_stream))
+#define inflateInit(strm) \
+        inflateInit_((strm),                ZLIB_VERSION, sizeof(z_stream))
+#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
+        deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
+                      (strategy),           ZLIB_VERSION, sizeof(z_stream))
+#define inflateInit2(strm, windowBits) \
+        inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))
+#define inflateBackInit(strm, windowBits, window) \
+        inflateBackInit_((strm), (windowBits), (window), \
+                                            ZLIB_VERSION, sizeof(z_stream))
+
+/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or
+ * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if
+ * both are true, the application gets the *64 functions, and the regular
+ * functions are changed to 64 bits) -- in case these are set on systems
+ * without large file support, _LFS64_LARGEFILE must also be true
+ */
+#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
+   ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
+   ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int));
+   ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile));
+   ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile));
+   ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t));
+   ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t));
+#endif
+
+#if !defined(ZLIB_INTERNAL) && _FILE_OFFSET_BITS-0 == 64 && _LFS64_LARGEFILE-0
+#  define gzopen gzopen64
+#  define gzseek gzseek64
+#  define gztell gztell64
+#  define gzoffset gzoffset64
+#  define adler32_combine adler32_combine64
+#  define crc32_combine crc32_combine64
+#  ifdef _LARGEFILE64_SOURCE
+     ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
+     ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int));
+     ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile));
+     ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile));
+     ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));
+     ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));
+#  endif
+#else
+   ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *));
+   ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int));
+   ZEXTERN z_off_t ZEXPORT gztell OF((gzFile));
+   ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile));
+   ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));
+   ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));
+#endif
+
+/* hack for buggy compilers */
+#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL)
+    struct internal_state {int dummy;};
+#endif
+
+/* undocumented functions */
+ZEXTERN const char   * ZEXPORT zError           OF((int));
+ZEXTERN int            ZEXPORT inflateSyncPoint OF((z_streamp));
+ZEXTERN const unsigned long FAR * ZEXPORT get_crc_table    OF((void));
+ZEXTERN int            ZEXPORT inflateUndermine OF((z_streamp, int));
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* ZLIB_H */
diff --git a/jdk/src/share/native/java/util/zip/zlib-1.2.3/zutil.c b/jdk/src/share/native/java/util/zip/zlib-1.2.5/zutil.c
similarity index 91%
rename from jdk/src/share/native/java/util/zip/zlib-1.2.3/zutil.c
rename to jdk/src/share/native/java/util/zip/zlib-1.2.5/zutil.c
index 24cb60a..041aa97 100644
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/zutil.c
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/zutil.c
@@ -23,7 +23,7 @@
  */
 
 /* zutil.c -- target dependent utility functions for the compression library
- * Copyright (C) 1995-2005 Jean-loup Gailly.
+ * Copyright (C) 1995-2005, 2010 Jean-loup Gailly.
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
@@ -58,25 +58,25 @@
     uLong flags;
 
     flags = 0;
-    switch (sizeof(uInt)) {
+    switch ((int)(sizeof(uInt))) {
     case 2:     break;
     case 4:     flags += 1;     break;
     case 8:     flags += 2;     break;
     default:    flags += 3;
     }
-    switch (sizeof(uLong)) {
+    switch ((int)(sizeof(uLong))) {
     case 2:     break;
     case 4:     flags += 1 << 2;        break;
     case 8:     flags += 2 << 2;        break;
     default:    flags += 3 << 2;
     }
-    switch (sizeof(voidpf)) {
+    switch ((int)(sizeof(voidpf))) {
     case 2:     break;
     case 4:     flags += 1 << 4;        break;
     case 8:     flags += 2 << 4;        break;
     default:    flags += 3 << 4;
     }
-    switch (sizeof(z_off_t)) {
+    switch ((int)(sizeof(z_off_t))) {
     case 2:     break;
     case 4:     flags += 1 << 6;        break;
     case 8:     flags += 2 << 6;        break;
@@ -141,9 +141,9 @@
 #  ifndef verbose
 #    define verbose 0
 #  endif
-int z_verbose = verbose;
+int ZLIB_INTERNAL z_verbose = verbose;
 
-void z_error (m)
+void ZLIB_INTERNAL z_error (m)
     char *m;
 {
     fprintf(stderr, "%s\n", m);
@@ -170,7 +170,7 @@
 
 #ifndef HAVE_MEMCPY
 
-void zmemcpy(dest, source, len)
+void ZLIB_INTERNAL zmemcpy(dest, source, len)
     Bytef* dest;
     const Bytef* source;
     uInt  len;
@@ -181,7 +181,7 @@
     } while (--len != 0);
 }
 
-int zmemcmp(s1, s2, len)
+int ZLIB_INTERNAL zmemcmp(s1, s2, len)
     const Bytef* s1;
     const Bytef* s2;
     uInt  len;
@@ -194,7 +194,7 @@
     return 0;
 }
 
-void zmemzero(dest, len)
+void ZLIB_INTERNAL zmemzero(dest, len)
     Bytef* dest;
     uInt  len;
 {
@@ -237,7 +237,7 @@
  * a protected system like OS/2. Use Microsoft C instead.
  */
 
-voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
+voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items, unsigned size)
 {
     voidpf buf = opaque; /* just to make some compilers happy */
     ulg bsize = (ulg)items*size;
@@ -261,7 +261,7 @@
     return buf;
 }
 
-void  zcfree (voidpf opaque, voidpf ptr)
+void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)
 {
     int n;
     if (*(ush*)&ptr != 0) { /* object < 64K */
@@ -296,13 +296,13 @@
 #  define _hfree   hfree
 #endif
 
-voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
+voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, uInt items, uInt size)
 {
     if (opaque) opaque = 0; /* to make compiler happy */
     return _halloc((long)items, size);
 }
 
-void  zcfree (voidpf opaque, voidpf ptr)
+void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)
 {
     if (opaque) opaque = 0; /* to make compiler happy */
     _hfree(ptr);
@@ -321,7 +321,7 @@
 extern void   free   OF((voidpf ptr));
 #endif
 
-voidpf zcalloc (opaque, items, size)
+voidpf ZLIB_INTERNAL zcalloc (opaque, items, size)
     voidpf opaque;
     unsigned items;
     unsigned size;
@@ -331,7 +331,7 @@
                               (voidpf)calloc(items, size);
 }
 
-void  zcfree (opaque, ptr)
+void ZLIB_INTERNAL zcfree (opaque, ptr)
     voidpf opaque;
     voidpf ptr;
 {
diff --git a/jdk/src/share/native/java/util/zip/zlib-1.2.3/zutil.h b/jdk/src/share/native/java/util/zip/zlib-1.2.5/zutil.h
similarity index 82%
rename from jdk/src/share/native/java/util/zip/zlib-1.2.3/zutil.h
rename to jdk/src/share/native/java/util/zip/zlib-1.2.5/zutil.h
index 0a2ec6c..1c4e8d3 100644
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/zutil.h
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/zutil.h
@@ -23,7 +23,7 @@
  */
 
 /* zutil.h -- internal interface and configuration of the compression library
- * Copyright (C) 1995-2005 Jean-loup Gailly.
+ * Copyright (C) 1995-2010 Jean-loup Gailly.
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
@@ -37,31 +37,21 @@
 #ifndef ZUTIL_H
 #define ZUTIL_H
 
-#define ZLIB_INTERNAL
+#if ((__GNUC__-0) * 10 + __GNUC_MINOR__-0 >= 33) && !defined(NO_VIZ)
+#  define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
+#else
+#  define ZLIB_INTERNAL
+#endif
+
 #include "zlib.h"
 
 #ifdef STDC
-#  ifndef _WIN32_WCE
+#  if !(defined(_WIN32_WCE) && defined(_MSC_VER))
 #    include <stddef.h>
 #  endif
 #  include <string.h>
 #  include <stdlib.h>
 #endif
-#ifdef NO_ERRNO_H
-#   ifdef _WIN32_WCE
-      /* The Microsoft C Run-Time Library for Windows CE doesn't have
-       * errno.  We define it as a global variable to simplify porting.
-       * Its value is always 0 and should not be used.  We rename it to
-       * avoid conflict with other libraries that use the same workaround.
-       */
-#     define errno z_errno
-#   endif
-    extern int errno;
-#else
-#  ifndef _WIN32_WCE
-#    include <errno.h>
-#  endif
-#endif
 
 #ifndef local
 #  define local static
@@ -113,7 +103,7 @@
 #if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
 #  define OS_CODE  0x00
 #  if defined(__TURBOC__) || defined(__BORLANDC__)
-#    if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
+#    if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
        /* Allow compilation with ANSI keywords only enabled */
        void _Cdecl farfree( void *block );
        void *_Cdecl farmalloc( unsigned long nbytes );
@@ -142,7 +132,7 @@
 #ifdef OS2
 #  define OS_CODE  0x06
 #  ifdef M_I86
-     #include <malloc.h>
+#    include <malloc.h>
 #  endif
 #endif
 
@@ -175,7 +165,7 @@
 #  define fdopen(fd,mode) NULL /* No fdopen() */
 #endif
 
-#if (defined(_MSC_VER) && (_MSC_VER > 600))
+#if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX
 #  if defined(_WIN32_WCE)
 #    define fdopen(fd,mode) NULL /* No fdopen() */
 #    ifndef _PTRDIFF_T_DEFINED
@@ -187,6 +177,18 @@
 #  endif
 #endif
 
+#if defined(__BORLANDC__)
+  #pragma warn -8004
+  #pragma warn -8008
+  #pragma warn -8066
+#endif
+
+/* provide prototypes for these when building zlib without LFS */
+#if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0
+    ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));
+    ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));
+#endif
+
         /* common defaults */
 
 #ifndef OS_CODE
@@ -220,9 +222,10 @@
 #  endif
 #  ifdef WIN32
      /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */
-#    if !defined(vsnprintf) && !defined(NO_vsnprintf) && (!defined(_MSC_VER) || (_MSC_VER < 1500))
-       /* Only needed before Visual Studio 2008 */
-#      define vsnprintf _vsnprintf
+#    if !defined(vsnprintf) && !defined(NO_vsnprintf)
+#      if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 )
+#         define vsnprintf _vsnprintf
+#      endif
 #    endif
 #  endif
 #  ifdef __SASC
@@ -257,16 +260,16 @@
 #    define zmemzero(dest, len) memset(dest, 0, len)
 #  endif
 #else
-   extern void zmemcpy  OF((Bytef* dest, const Bytef* source, uInt len));
-   extern int  zmemcmp  OF((const Bytef* s1, const Bytef* s2, uInt len));
-   extern void zmemzero OF((Bytef* dest, uInt len));
+   void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
+   int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));
+   void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len));
 #endif
 
 /* Diagnostic functions */
 #ifdef DEBUG
 #  include <stdio.h>
-   extern int z_verbose;
-   extern void z_error    OF((char *m));
+   extern int ZLIB_INTERNAL z_verbose;
+   extern void ZLIB_INTERNAL z_error OF((char *m));
 #  define Assert(cond,msg) {if(!(cond)) z_error(msg);}
 #  define Trace(x) {if (z_verbose>=0) fprintf x ;}
 #  define Tracev(x) {if (z_verbose>0) fprintf x ;}
@@ -283,8 +286,9 @@
 #endif
 
 
-voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size));
-void   zcfree  OF((voidpf opaque, voidpf ptr));
+voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items,
+                        unsigned size));
+void ZLIB_INTERNAL zcfree  OF((voidpf opaque, voidpf ptr));
 
 #define ZALLOC(strm, items, size) \
            (*((strm)->zalloc))((strm)->opaque, (items), (size))
diff --git a/jdk/src/solaris/classes/sun/awt/X11/ListHelper.java b/jdk/src/solaris/classes/sun/awt/X11/ListHelper.java
index f959137..9301eaf 100644
--- a/jdk/src/solaris/classes/sun/awt/X11/ListHelper.java
+++ b/jdk/src/solaris/classes/sun/awt/X11/ListHelper.java
@@ -29,10 +29,8 @@
 import java.awt.event.MouseEvent;
 import java.awt.event.MouseWheelEvent;
 import java.awt.event.AdjustmentEvent;
-import java.util.List;
 import java.util.ArrayList;
 import java.util.Iterator;
-import sun.awt.motif.X11FontMetrics;
 import sun.util.logging.PlatformLogger;
 
 // FIXME: implement multi-select
diff --git a/jdk/src/solaris/classes/sun/awt/X11/XEmbedCanvasPeer.java b/jdk/src/solaris/classes/sun/awt/X11/XEmbedCanvasPeer.java
index 9e7ac7c..2d8a528 100644
--- a/jdk/src/solaris/classes/sun/awt/X11/XEmbedCanvasPeer.java
+++ b/jdk/src/solaris/classes/sun/awt/X11/XEmbedCanvasPeer.java
@@ -35,7 +35,6 @@
 import java.awt.image.VolatileImage;
 import java.awt.peer.*;
 import sun.awt.*;
-import sun.awt.motif.X11FontMetrics;
 import java.lang.reflect.*;
 import sun.util.logging.PlatformLogger;
 import java.util.*;
diff --git a/jdk/src/solaris/classes/sun/awt/X11/XEmbedChildProxyPeer.java b/jdk/src/solaris/classes/sun/awt/X11/XEmbedChildProxyPeer.java
index 1ab53e6..4d75d21 100644
--- a/jdk/src/solaris/classes/sun/awt/X11/XEmbedChildProxyPeer.java
+++ b/jdk/src/solaris/classes/sun/awt/X11/XEmbedChildProxyPeer.java
@@ -34,8 +34,6 @@
 import java.awt.peer.*;
 import sun.java2d.pipe.Region;
 import sun.awt.*;
-import sun.awt.motif.MToolkit;
-import sun.awt.motif.X11FontMetrics;
 
 public class XEmbedChildProxyPeer implements ComponentPeer, XEventDispatcher{
     XEmbeddingContainer container;
diff --git a/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java b/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java
index 9f29d73..e49f783 100644
--- a/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java
+++ b/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java
@@ -51,6 +51,7 @@
 import sun.awt.*;
 import sun.font.FontConfigManager;
 import sun.font.FontManager;
+import sun.java2d.SunGraphicsEnvironment;
 import sun.misc.PerformanceLogger;
 import sun.print.PrintJob2D;
 import sun.security.action.GetBooleanAction;
@@ -109,7 +110,7 @@
     static int awt_multiclick_time;
     static boolean securityWarningEnabled;
 
-    private static int screenWidth = -1, screenHeight = -1; // Dimensions of default screen
+    private static volatile int screenWidth = -1, screenHeight = -1; // Dimensions of default screen
     static long awt_defaultFg; // Pixel
     private static XMouseInfoPeer xPeer;
     private static Method m_removeSourceEvents;
@@ -310,6 +311,19 @@
             System.setProperty("sun.awt.enableExtraMouseButtons", ""+areExtraMouseButtonsEnabled);
 
             saved_error_handler = XlibWrapper.SetToolkitErrorHandler();
+
+            // Detect display mode changes
+            XlibWrapper.XSelectInput(XToolkit.getDisplay(), XToolkit.getDefaultRootWindow(), XConstants.StructureNotifyMask);
+            XToolkit.addEventDispatcher(XToolkit.getDefaultRootWindow(), new XEventDispatcher() {
+                @Override
+                public void dispatchEvent(XEvent ev) {
+                    if (ev.get_type() == XConstants.ConfigureNotify) {
+                        ((X11GraphicsEnvironment)GraphicsEnvironment.
+                         getLocalGraphicsEnvironment()).
+                            displayChanged();
+                    }
+                }
+            });
         } finally {
             awtUnlock();
         }
@@ -684,29 +698,49 @@
         }
     }
 
-    static int getDefaultScreenWidth() {
-        if (screenWidth == -1) {
-            long display = getDisplay();
+    static {
+        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
+        if (ge instanceof SunGraphicsEnvironment) {
+            ((SunGraphicsEnvironment)ge).addDisplayChangedListener(
+                new DisplayChangedListener() {
+                    @Override
+                    public void displayChanged() {
+                        // 7045370: Reset the cached values
+                        XToolkit.screenWidth = -1;
+                        XToolkit.screenHeight = -1;
+                    }
+
+                    @Override
+                    public void paletteChanged() {}
+            });
+        }
+    }
+
+    private static void initScreenSize() {
+        if (screenWidth == -1 || screenHeight == -1) {
             awtLock();
             try {
-                screenWidth = (int) XlibWrapper.DisplayWidth(display, XlibWrapper.DefaultScreen(display));
+                XWindowAttributes pattr = new XWindowAttributes();
+                try {
+                    XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(), XToolkit.getDefaultRootWindow(), pattr.pData);
+                    screenWidth  = (int) pattr.get_width();
+                    screenHeight = (int) pattr.get_height();
+                } finally {
+                    pattr.dispose();
+                }
             } finally {
                 awtUnlock();
             }
         }
+    }
+
+    static int getDefaultScreenWidth() {
+        initScreenSize();
         return screenWidth;
     }
 
     static int getDefaultScreenHeight() {
-        if (screenHeight == -1) {
-            long display = getDisplay();
-            awtLock();
-            try {
-                screenHeight = (int) XlibWrapper.DisplayHeight(display, XlibWrapper.DefaultScreen(display));
-            } finally {
-                awtUnlock();
-            }
-        }
+        initScreenSize();
         return screenHeight;
     }
 
diff --git a/jdk/src/solaris/classes/sun/awt/X11/XWindowPeer.java b/jdk/src/solaris/classes/sun/awt/X11/XWindowPeer.java
index 395dbcd..9d7daf0 100644
--- a/jdk/src/solaris/classes/sun/awt/X11/XWindowPeer.java
+++ b/jdk/src/solaris/classes/sun/awt/X11/XWindowPeer.java
@@ -208,12 +208,19 @@
         return name;
     }
 
+    private static native String getLocalHostname();
+    private static native int getJvmPID();
+
     void postInit(XCreateWindowParams params) {
         super.postInit(params);
 
         // Init WM_PROTOCOLS atom
         initWMProtocols();
 
+        // Set _NET_WM_PID and WM_CLIENT_MACHINE using this JVM
+        XAtom.get("WM_CLIENT_MACHINE").setProperty(getWindow(), getLocalHostname());
+        XAtom.get("_NET_WM_PID").setCard32Property(getWindow(), getJvmPID());
+
         // Set WM_TRANSIENT_FOR and group_leader
         Window t_window = (Window)target;
         Window owner = t_window.getOwner();
diff --git a/jdk/src/solaris/classes/sun/awt/X11GraphicsDevice.java b/jdk/src/solaris/classes/sun/awt/X11GraphicsDevice.java
index ca415b1..cedf90a 100644
--- a/jdk/src/solaris/classes/sun/awt/X11GraphicsDevice.java
+++ b/jdk/src/solaris/classes/sun/awt/X11GraphicsDevice.java
@@ -487,14 +487,9 @@
      * X11GraphicsEnvironment when the display mode has been changed.
      */
     public synchronized void displayChanged() {
-        // reset the list of configs (and default config)
-        defaultConfig = null;
-        configs = null;
-        doubleBufferVisuals = null;
-
-        // reset the native data structures associated with this device (they
-        // will be reinitialized when the GraphicsConfigs are configured)
-        resetNativeData(screen);
+        // On X11 the visuals do not change, and therefore we don't need
+        // to reset the defaultConfig, config, doubleBufferVisuals,
+        // neither do we need to reset the native data.
 
         // pass on to all top-level windows on this screen
         topLevels.notifyListeners();
diff --git a/jdk/src/solaris/classes/sun/awt/motif/AWTLockAccess.java b/jdk/src/solaris/classes/sun/awt/motif/AWTLockAccess.java
deleted file mode 100644
index b05828f..0000000
--- a/jdk/src/solaris/classes/sun/awt/motif/AWTLockAccess.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 1998, 2000, 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.awt.motif;
-
-final class AWTLockAccess {
-    static native void awtLock();
-    static native void awtUnlock();
-    static void awtWait() { awtWait(0); }
-    static native void awtWait(long timeout);
-    static native void awtNotifyAll();
-}
diff --git a/jdk/src/solaris/classes/sun/awt/motif/MFontConfiguration.java b/jdk/src/solaris/classes/sun/awt/motif/MFontConfiguration.java
index 25e676e..6c28d20 100644
--- a/jdk/src/solaris/classes/sun/awt/motif/MFontConfiguration.java
+++ b/jdk/src/solaris/classes/sun/awt/motif/MFontConfiguration.java
@@ -25,26 +25,19 @@
 
 package sun.awt.motif;
 
-import java.awt.Font;
-import java.io.BufferedReader;
+import sun.awt.FontConfiguration;
+import sun.awt.X11FontManager;
+import sun.font.FontUtilities;
+import sun.font.SunFontManager;
+import sun.util.logging.PlatformLogger;
+
 import java.io.File;
 import java.io.FileInputStream;
-import java.io.InputStreamReader;
 import java.nio.charset.Charset;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Locale;
 import java.util.Properties;
 import java.util.Scanner;
-import sun.awt.FontConfiguration;
-import sun.awt.X11FontManager;
-import sun.awt.X11GraphicsEnvironment;
-import sun.font.FontManager;
-import sun.font.SunFontManager;
-import sun.font.FontManagerFactory;
-import sun.font.FontUtilities;
-import sun.java2d.SunGraphicsEnvironment;
-import sun.util.logging.PlatformLogger;
 
 public class MFontConfiguration extends FontConfiguration {
 
@@ -258,47 +251,6 @@
         return Charset.forName("ISO8859_1");
     }
 
-    /* methods for Motif support *********************************************/
-
-    private String[][] motifFontSets = new String[NUM_FONTS][NUM_STYLES];
-
-    public String getMotifFontSet(String fontName, int style) {
-        assert isLogicalFontFamilyName(fontName);
-        fontName = fontName.toLowerCase(Locale.ENGLISH);
-        int fontIndex = getFontIndex(fontName);
-        int styleIndex = getStyleIndex(style);
-        return getMotifFontSet(fontIndex, styleIndex);
-    }
-
-    private String getMotifFontSet(int fontIndex, int styleIndex) {
-        String fontSet = motifFontSets[fontIndex][styleIndex];
-        if (fontSet == null) {
-            fontSet = buildMotifFontSet(fontIndex, styleIndex);
-            motifFontSets[fontIndex][styleIndex] = fontSet;
-        }
-        return fontSet;
-    }
-
-    private String buildMotifFontSet(int fontIndex, int styleIndex) {
-        StringBuilder buffer = new StringBuilder();
-        short[] scripts = getCoreScripts(fontIndex);
-        for (int i = 0; i < scripts.length; i++) {
-            short nameID = getComponentFontIDMotif(scripts[i], fontIndex, styleIndex);
-            if (nameID == 0) {
-                nameID = getComponentFontID(scripts[i], fontIndex, styleIndex);
-            }
-            String name = getComponentFontName(nameID);
-            if (name == null || name.endsWith("fontspecific")) {
-                continue;
-            }
-            if (buffer.length() > 0) {
-                buffer.append(',');
-            }
-            buffer.append(name);
-        }
-        return buffer.toString();
-    }
-
     protected String getFaceNameFromComponentFontName(String componentFontName) {
         return null;
     }
@@ -315,36 +267,6 @@
         return ((X11FontManager) fontManager).getFileNameFromXLFD(componentFontName);
     }
 
-    /**
-     * Get default font for Motif widgets to use, preventing them from
-     * wasting time accessing inappropriate X resources.  This is called
-     * only from native code.
-     *
-     * This is part of a Motif specific performance enhancement.  By
-     * default, when Motif widgets are created and initialized, Motif will
-     * set up default fonts for the widgets, which we ALWAYS override.
-     * This set up includes finding the default font in the widget's X
-     * resources and fairly expensive requests of the X server to identify
-     * the specific font or fontset.  We avoid all of this overhead by
-     * providing a well known font to use at the creation of widgets, where
-     * possible.
-     *
-     * The X11 fonts are specified by XLFD strings which have %d as a
-     * marker to indicate where the fontsize should be substituted.  [The
-     * libc function sprintf() is used to replace it.]  The value 140
-     * specifies a font size of 14 points.
-     */
-    private static String getDefaultMotifFontSet() {
-        String font = ((MFontConfiguration) getFontConfiguration()).getMotifFontSet("sansserif", Font.PLAIN);
-        if (font != null) {
-            int i;
-            while ((i = font.indexOf("%d")) >= 0) {
-                font = font.substring(0, i) + "140" + font.substring(i+2);
-            }
-        }
-        return font;
-    }
-
     public HashSet<String> getAWTFontPathSet() {
         HashSet<String> fontDirs = new HashSet<String>();
         short[] scripts = getCoreScripts(0);
diff --git a/jdk/src/solaris/classes/sun/awt/motif/MFontPeer.java b/jdk/src/solaris/classes/sun/awt/motif/MFontPeer.java
deleted file mode 100644
index c544c02..0000000
--- a/jdk/src/solaris/classes/sun/awt/motif/MFontPeer.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 1996, 2003, 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.awt.motif;
-
-import java.awt.GraphicsEnvironment;
-import sun.awt.PlatformFont;
-
-public class MFontPeer extends PlatformFont {
-
-    /*
-     * XLFD name for XFontSet.
-     */
-    private String xfsname;
-
-    /*
-     * converter name for this XFontSet encoding.
-     */
-    private String converter;
-
-    static {
-        if (!GraphicsEnvironment.isHeadless()) {
-            initIDs();
-        }
-    }
-
-    /**
-     * Initialize JNI field and method IDs for fields that may be
-       accessed from C.
-     */
-    private static native void initIDs();
-
-    public MFontPeer(String name, int style){
-        super(name, style);
-
-        if (fontConfig != null) {
-            xfsname = ((MFontConfiguration) fontConfig).getMotifFontSet(familyName, style);
-        }
-    }
-
-    protected char getMissingGlyphCharacter() {
-        return '\u274F';
-    }
-}
diff --git a/jdk/src/solaris/classes/sun/awt/motif/MToolkit.java b/jdk/src/solaris/classes/sun/awt/motif/MToolkit.java
deleted file mode 100644
index 44108be..0000000
--- a/jdk/src/solaris/classes/sun/awt/motif/MToolkit.java
+++ /dev/null
@@ -1,849 +0,0 @@
-/*
- * Copyright (c) 1995, 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.awt.motif;
-
-import java.awt.*;
-import java.awt.im.InputMethodHighlight;
-import java.awt.im.spi.InputMethodDescriptor;
-import java.awt.image.*;
-import java.awt.peer.*;
-import java.awt.datatransfer.Clipboard;
-import java.awt.event.*;
-import java.lang.reflect.*;
-import java.lang.Math;
-import java.io.*;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-
-import java.util.Properties;
-import java.util.Map;
-import java.util.Iterator;
-
-import sun.awt.AppContext;
-import sun.awt.AWTAutoShutdown;
-import sun.awt.SunToolkit;
-import sun.awt.UNIXToolkit;
-import sun.awt.GlobalCursorManager;
-import sun.awt.datatransfer.DataTransferer;
-
-import java.awt.dnd.DragSource;
-import java.awt.dnd.DragGestureListener;
-import java.awt.dnd.DragGestureEvent;
-import java.awt.dnd.DragGestureRecognizer;
-import java.awt.dnd.MouseDragGestureRecognizer;
-import java.awt.dnd.InvalidDnDOperationException;
-import java.awt.dnd.peer.DragSourceContextPeer;
-
-//import sun.awt.motif.MInputMethod;
-import sun.awt.X11FontManager;
-import sun.awt.X11GraphicsConfig;
-import sun.awt.X11GraphicsEnvironment;
-import sun.awt.XSettings;
-
-//import sun.awt.motif.MDragSourceContextPeer;
-
-import sun.print.PrintJob2D;
-
-import sun.misc.PerformanceLogger;
-import sun.misc.Unsafe;
-
-import sun.security.action.GetBooleanAction;
-import sun.util.logging.PlatformLogger;
-
-public class MToolkit extends UNIXToolkit implements Runnable {
-
-    private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.motif.MToolkit");
-
-    // the system clipboard - CLIPBOARD selection
-    //X11Clipboard clipboard;
-    // the system selection - PRIMARY selection
-    //X11Clipboard selection;
-
-    // Dynamic Layout Resize client code setting
-    protected static boolean dynamicLayoutSetting = false;
-
-    /**
-     * True when the x settings have been loaded.
-     */
-    private boolean loadedXSettings;
-
-    /**
-     * XSETTINGS for the default screen.
-     * <p>
-     * <strong>XXX:</strong> see <code>MToolkit.parseXSettings</code>
-     * and <code>awt_xsettings_update</code> in
-     * <samp>awt_MToolkit.c</samp>
-     */
-    private XSettings xs;
-
-    /*
-     * Note: The MToolkit object depends on the static initializer
-     * of X11GraphicsEnvironment to initialize the connection to
-     * the X11 server.
-     */
-    static final X11GraphicsConfig config;
-
-    private static final boolean motifdnd;
-
-    static {
-        if (GraphicsEnvironment.isHeadless()) {
-            config = null;
-        } else {
-            config = (X11GraphicsConfig) (GraphicsEnvironment.
-                             getLocalGraphicsEnvironment().
-                             getDefaultScreenDevice().
-                             getDefaultConfiguration());
-        }
-
-        motifdnd = ((Boolean)java.security.AccessController.doPrivileged(
-            new GetBooleanAction("awt.dnd.motifdnd"))).booleanValue();
-    }
-
-    //public static final String DATA_TRANSFERER_CLASS_NAME = "sun.awt.motif.MDataTransferer";
-
-    public MToolkit() {
-        super();
-        if (PerformanceLogger.loggingEnabled()) {
-            PerformanceLogger.setTime("MToolkit construction");
-        }
-        if (!GraphicsEnvironment.isHeadless()) {
-            String mainClassName = null;
-
-            StackTraceElement trace[] = (new Throwable()).getStackTrace();
-            int bottom = trace.length - 1;
-            if (bottom >= 0) {
-                mainClassName = trace[bottom].getClassName();
-            }
-            if (mainClassName == null || mainClassName.equals("")) {
-                mainClassName = "AWT";
-            }
-
-            init(mainClassName);
-            //SunToolkit.setDataTransfererClassName(DATA_TRANSFERER_CLASS_NAME);
-
-            Thread toolkitThread = new Thread(this, "AWT-Motif");
-            toolkitThread.setPriority(Thread.NORM_PRIORITY + 1);
-            toolkitThread.setDaemon(true);
-
-            PrivilegedAction<Void> a = new PrivilegedAction<Void>() {
-                public Void run() {
-                    ThreadGroup mainTG = Thread.currentThread().getThreadGroup();
-                    ThreadGroup parentTG = mainTG.getParent();
-
-                    while (parentTG != null) {
-                        mainTG = parentTG;
-                        parentTG = mainTG.getParent();
-                    }
-                    Thread shutdownThread = new Thread(mainTG, new Runnable() {
-                            public void run() {
-                                shutdown();
-                            }
-                        }, "Shutdown-Thread");
-                    shutdownThread.setContextClassLoader(null);
-                    Runtime.getRuntime().addShutdownHook(shutdownThread);
-                    return null;
-                }
-            };
-            AccessController.doPrivileged(a);
-
-            /*
-             * Fix for 4701990.
-             * AWTAutoShutdown state must be changed before the toolkit thread
-             * starts to avoid race condition.
-             */
-            AWTAutoShutdown.notifyToolkitThreadBusy();
-
-            toolkitThread.start();
-        }
-    }
-
-    public native void init(String mainClassName);
-    public native void run();
-    private native void shutdown();
-
-    /*
-     * Create peer objects.
-     */
-
-    public ButtonPeer createButton(Button target) {
-        //ButtonPeer peer = new MButtonPeer(target);
-        //targetCreatedPeer(target, peer);
-        //return peer;
-        return null;
-    }
-
-    public TextFieldPeer createTextField(TextField target) {
-        //TextFieldPeer peer = new MTextFieldPeer(target);
-        //targetCreatedPeer(target, peer);
-        //return peer;
-        return null;
-    }
-
-    public LabelPeer createLabel(Label target) {
-        //LabelPeer peer = new MLabelPeer(target);
-        //targetCreatedPeer(target, peer);
-        //return peer;
-        return null;
-    }
-
-    public ListPeer createList(List target) {
-        //ListPeer peer = new MListPeer(target);
-        //targetCreatedPeer(target, peer);
-        //return peer;
-        return null;
-    }
-
-    public CheckboxPeer createCheckbox(Checkbox target) {
-        //CheckboxPeer peer = new MCheckboxPeer(target);
-        //targetCreatedPeer(target, peer);
-        //return peer;
-        return null;
-    }
-
-    public ScrollbarPeer createScrollbar(Scrollbar target) {
-        //ScrollbarPeer peer = new MScrollbarPeer(target);
-        //targetCreatedPeer(target, peer);
-        //return peer;
-        return null;
-    }
-
-    public ScrollPanePeer createScrollPane(ScrollPane target) {
-        //ScrollPanePeer peer = new MScrollPanePeer(target);
-        //targetCreatedPeer(target, peer);
-        //return peer;
-        return null;
-    }
-
-    public TextAreaPeer createTextArea(TextArea target) {
-        //TextAreaPeer peer = new MTextAreaPeer(target);
-        //targetCreatedPeer(target, peer);
-        //return peer;
-        return null;
-    }
-
-    public ChoicePeer createChoice(Choice target) {
-        //ChoicePeer peer = new MChoicePeer(target);
-        //targetCreatedPeer(target, peer);
-        //return peer;
-        return null;
-    }
-
-    public FramePeer  createFrame(Frame target) {
-        //FramePeer peer = new MFramePeer(target);
-        //targetCreatedPeer(target, peer);
-        //return peer;
-        return null;
-    }
-
-    public CanvasPeer createCanvas(Canvas target) {
-        //CanvasPeer peer = (isXEmbedServerRequested() ? new MEmbedCanvasPeer(target) : new MCanvasPeer(target));
-        //targetCreatedPeer(target, peer);
-        //return peer;
-        return null;
-    }
-
-    public PanelPeer createPanel(Panel target) {
-        //PanelPeer peer = new MPanelPeer(target);
-        //targetCreatedPeer(target, peer);
-        //return peer;
-        return null;
-    }
-
-    public WindowPeer createWindow(Window target) {
-        //WindowPeer peer = new MWindowPeer(target);
-        //targetCreatedPeer(target, peer);
-        //return peer;
-        return null;
-    }
-
-    public DialogPeer createDialog(Dialog target) {
-        //DialogPeer peer = new MDialogPeer(target);
-        //targetCreatedPeer(target, peer);
-        //return peer;
-        return null;
-    }
-
-    public FileDialogPeer createFileDialog(FileDialog target) {
-        //FileDialogPeer peer = new MFileDialogPeer(target);
-        //targetCreatedPeer(target, peer);
-        //return peer;
-        return null;
-    }
-
-    public MenuBarPeer createMenuBar(MenuBar target) {
-        //MenuBarPeer peer = new MMenuBarPeer(target);
-        //targetCreatedPeer(target, peer);
-        //return peer;
-        return null;
-    }
-
-    public MenuPeer createMenu(Menu target) {
-        //MenuPeer peer = new MMenuPeer(target);
-        //targetCreatedPeer(target, peer);
-        //return peer;
-        return null;
-    }
-
-    public PopupMenuPeer createPopupMenu(PopupMenu target) {
-        //PopupMenuPeer peer = new MPopupMenuPeer(target);
-        //targetCreatedPeer(target, peer);
-        //return peer;
-        return null;
-    }
-
-    public MenuItemPeer createMenuItem(MenuItem target) {
-        //MenuItemPeer peer = new MMenuItemPeer(target);
-        //targetCreatedPeer(target, peer);
-        //return peer;
-        return null;
-    }
-
-    public CheckboxMenuItemPeer createCheckboxMenuItem(CheckboxMenuItem target) {
-        //CheckboxMenuItemPeer peer = new MCheckboxMenuItemPeer(target);
-        //targetCreatedPeer(target, peer);
-        //return peer;
-        return null;
-    }
-
-    public KeyboardFocusManagerPeer createKeyboardFocusManagerPeer(KeyboardFocusManager manager) {
-        return null;
-    }
-
-    //public MEmbeddedFramePeer createEmbeddedFrame(MEmbeddedFrame target)
-    //{
-        //MEmbeddedFramePeer peer = new MEmbeddedFramePeer(target);
-        //targetCreatedPeer(target, peer);
-        //return peer;
-    //    return null;
-    //}
-
-
-    public FontPeer getFontPeer(String name, int style){
-        return new MFontPeer(name, style);
-    }
-
-    /*
-     * On X, support for dynamic layout on resizing is governed by the
-     * window manager.  If the window manager supports it, it happens
-     * automatically.  The setter method for this property is
-     * irrelevant on X.
-     */
-    public void setDynamicLayout(boolean b) {
-        dynamicLayoutSetting = b;
-    }
-
-    protected boolean isDynamicLayoutSet() {
-        return dynamicLayoutSetting;
-    }
-
-    /* Called from isDynamicLayoutActive() and from
-     * lazilyLoadDynamicLayoutSupportedProperty()
-     */
-    protected native boolean isDynamicLayoutSupportedNative();
-
-    public boolean isDynamicLayoutActive() {
-        return isDynamicLayoutSupportedNative();
-    }
-
-    public native boolean isFrameStateSupported(int state);
-
-    public TrayIconPeer createTrayIcon(TrayIcon target) throws HeadlessException {
-        return null;
-    }
-
-    public SystemTrayPeer createSystemTray(SystemTray target) throws HeadlessException {
-        return null;
-    }
-
-    public boolean isTraySupported() {
-        return false;
-    }
-
-    static native ColorModel makeColorModel();
-    static ColorModel screenmodel;
-
-    static ColorModel getStaticColorModel() {
-        if (screenmodel == null) {
-            screenmodel = config.getColorModel ();
-        }
-        return screenmodel;
-    }
-
-    public ColorModel getColorModel() {
-        return getStaticColorModel();
-    }
-
-    public native int getScreenResolution();
-
-    public Insets getScreenInsets(GraphicsConfiguration gc) {
-        return new Insets(0,0,0,0);
-    }
-
-    protected native int getScreenWidth();
-    protected native int getScreenHeight();
-
-    public FontMetrics getFontMetrics(Font font) {
-        /*
-        // REMIND: platform font flag should be obsolete soon
-        if (!RasterOutputManager.usesPlatformFont()) {
-            return super.getFontMetrics(font);
-        } else {
-            return X11FontMetrics.getFontMetrics(font);
-        }
-        */
-        return super.getFontMetrics(font);
-    }
-
-    public PrintJob getPrintJob(final Frame frame, final String doctitle,
-                                final Properties props) {
-
-        if (GraphicsEnvironment.isHeadless()) {
-            throw new IllegalArgumentException();
-        }
-
-        PrintJob2D printJob = new PrintJob2D(frame, doctitle, props);
-
-        if (printJob.printDialog() == false) {
-            printJob = null;
-        }
-
-        return printJob;
-    }
-
-    public PrintJob getPrintJob(final Frame frame, final String doctitle,
-                                final JobAttributes jobAttributes,
-                                final PageAttributes pageAttributes) {
-
-
-        if (GraphicsEnvironment.isHeadless()) {
-            throw new IllegalArgumentException();
-        }
-
-        PrintJob2D printJob = new PrintJob2D(frame, doctitle,
-                                             jobAttributes, pageAttributes);
-
-        if (printJob.printDialog() == false) {
-            printJob = null;
-        }
-
-        return printJob;
-    }
-
-    public native void beep();
-
-    public  Clipboard getSystemClipboard() {
-        //SecurityManager security = System.getSecurityManager();
-        //if (security != null) {
-        //  security.checkSystemClipboardAccess();
-        //}
-        //synchronized (this) {
-        //    if (clipboard == null) {
-        //        clipboard = new X11Clipboard("System", "CLIPBOARD");
-        //    }
-        //}
-        //return clipboard;
-        return null;
-    }
-
-    public Clipboard getSystemSelection() {
-        //SecurityManager security = System.getSecurityManager();
-        //if (security != null) {
-        //    security.checkSystemClipboardAccess();
-        //}
-        //synchronized (this) {
-        //    if (selection == null) {
-        //        selection = new X11Clipboard("Selection", "PRIMARY");
-        //    }
-        //}
-        //return selection;
-        return null;
-    }
-
-    public boolean getLockingKeyState(int key) {
-        if (! (key == KeyEvent.VK_CAPS_LOCK || key == KeyEvent.VK_NUM_LOCK ||
-               key == KeyEvent.VK_SCROLL_LOCK || key == KeyEvent.VK_KANA_LOCK)) {
-            throw new IllegalArgumentException("invalid key for Toolkit.getLockingKeyState");
-        }
-        return getLockingKeyStateNative(key);
-    }
-
-    public native boolean getLockingKeyStateNative(int key);
-
-    public native void loadSystemColors(int[] systemColors);
-
-    /**
-     * Give native peers the ability to query the native container
-     * given a native component (e.g. the direct parent may be lightweight).
-     */
-    public static Container getNativeContainer(Component c) {
-        return Toolkit.getNativeContainer(c);
-    }
-
-    protected static final Object targetToPeer(Object target) {
-        return SunToolkit.targetToPeer(target);
-    }
-
-    protected static final void targetDisposedPeer(Object target, Object peer) {
-        SunToolkit.targetDisposedPeer(target, peer);
-    }
-
-    public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException {
-        //if (MToolkit.useMotifDnD()) {
-        //    return MDragSourceContextPeer.createDragSourceContextPeer(dge);
-        //} else {
-        //    return X11DragSourceContextPeer.createDragSourceContextPeer(dge);
-        //}
-        return null;
-    }
-
-    public <T extends DragGestureRecognizer> T
-        createDragGestureRecognizer(Class<T> abstractRecognizerClass,
-                                    DragSource ds, Component c, int srcActions,
-                                    DragGestureListener dgl)
-    {
-        //if (MouseDragGestureRecognizer.class.equals(abstractRecognizerClass))
-        //    return (T)new MMouseDragGestureRecognizer(ds, c, srcActions, dgl);
-        //else
-            return null;
-    }
-
-    /**
-     * Returns a new input method adapter descriptor for native input methods.
-     */
-    public InputMethodDescriptor getInputMethodAdapterDescriptor() throws AWTException {
-        return null; // return new MInputMethodDescriptor();
-    }
-
-    /**
-     * Returns a style map for the input method highlight.
-     */
-    public Map mapInputMethodHighlight(InputMethodHighlight highlight) {
-        return null; //return MInputMethod.mapInputMethodHighlight(highlight);
-    }
-
-    /**
-     * Returns a new custom cursor.
-     */
-    public Cursor createCustomCursor(Image cursor, Point hotSpot, String name)
-        throws IndexOutOfBoundsException {
-        return null; //return new MCustomCursor(cursor, hotSpot, name);
-    }
-
-    /**
-     * Returns the supported cursor size
-     */
-    public Dimension getBestCursorSize(int preferredWidth, int preferredHeight) {
-        return null; //MCustomCursor.getBestCursorSize(
-            //java.lang.Math.max(1,preferredWidth), java.lang.Math.max(1,preferredHeight));
-    }
-
-    public int getMaximumCursorColors() {
-        return 2;  // Black and white.
-    }
-
-    private final static String prefix  = "DnD.Cursor.";
-    private final static String postfix = ".32x32";
-    private static final String dndPrefix  = "DnD.";
-
-    protected Object lazilyLoadDesktopProperty(String name) {
-        if (name.startsWith(prefix)) {
-            String cursorName = name.substring(prefix.length(), name.length()) + postfix;
-
-            try {
-                return Cursor.getSystemCustomCursor(cursorName);
-            } catch (AWTException awte) {
-                System.err.println("cannot load system cursor: " + cursorName);
-
-                return null;
-            }
-        }
-
-        if (name.equals("awt.dynamicLayoutSupported")) {
-            return lazilyLoadDynamicLayoutSupportedProperty(name);
-        }
-
-        if (!loadedXSettings &&
-            (name.startsWith("gnome.") ||
-             name.equals(SunToolkit.DESKTOPFONTHINTS) ||
-             name.startsWith(dndPrefix))) {
-            loadedXSettings = true;
-            if (!GraphicsEnvironment.isHeadless()) {
-                loadXSettings();
-                desktopProperties.put(SunToolkit.DESKTOPFONTHINTS,
-                                      SunToolkit.getDesktopFontHints());
-                return desktopProperties.get(name);
-            }
-        }
-
-        return super.lazilyLoadDesktopProperty(name);
-    }
-
-    /*
-     * Called from lazilyLoadDesktopProperty because we may not know if
-     * the user has quit the previous window manager and started another.
-     */
-    protected Boolean lazilyLoadDynamicLayoutSupportedProperty(String name) {
-        boolean nativeDynamic = isDynamicLayoutSupportedNative();
-
-        if (log.isLoggable(PlatformLogger.FINER)) {
-            log.finer("nativeDynamic == " + nativeDynamic);
-        }
-
-        return Boolean.valueOf(nativeDynamic);
-    }
-
-    private native int getMulticlickTime();
-
-    protected void initializeDesktopProperties() {
-        desktopProperties.put("DnD.Autoscroll.initialDelay",     Integer.valueOf(50));
-        desktopProperties.put("DnD.Autoscroll.interval",         Integer.valueOf(50));
-        desktopProperties.put("DnD.Autoscroll.cursorHysteresis", Integer.valueOf(5));
-
-        /* As of 1.4, no wheel mice are supported on Solaris
-         * however, they are on Linux, and there isn't a way to detect them,
-         * so we leave this property unset to indicate we're not sure if there's
-         * a wheel mouse or not.
-         */
-        //desktopProperties.put("awt.wheelMousePresent", Boolean.valueOf(false));
-
-        // We don't want to call getMultilclickTime() if we're headless
-        if (!GraphicsEnvironment.isHeadless()) {
-            desktopProperties.put("awt.multiClickInterval",
-                                  Integer.valueOf(getMulticlickTime()));
-            desktopProperties.put("awt.mouse.numButtons",
-                                  Integer.valueOf(getNumberOfButtons()));
-        }
-    }
-
-    public RobotPeer createRobot(Robot target, GraphicsDevice screen) {
-        /* 'target' is unused for now... */
-        //return new MRobotPeer(screen.getDefaultConfiguration());
-        return null;
-    }
-
-    static boolean useMotifDnD() {
-        return motifdnd;
-    }
-
-    //
-    // The following support Gnome's equivalent of desktop properties.
-    // A writeup of this can be found at:
-    // http://www.freedesktop.org/standards/xsettings/xsettings.html
-    //
-
-    /**
-     * Triggers a callback to parseXSettings with the x settings values
-     * from the window server. Note that this will NOT call
-     * parseXSettings if we are not running on a GNOME desktop.
-     */
-    private native void loadXSettings();
-
-    /**
-     * Callback from the native side indicating some, or all, of the
-     * desktop properties have changed and need to be reloaded.
-     * <code>data</code> is the byte array directly from the x server and
-     * may be in little endian format.
-     * <p>
-     * NB: This could be called from any thread if triggered by
-     * <code>loadXSettings</code>.  It is called from the toolkit
-     * thread if triggered by an XSETTINGS change.
-     */
-    private void parseXSettings(int screen_XXX_ignored, byte[] data) {
-        // XXX: notyet: map screen -> per screen XSettings object
-        // for now native code only calls us for default screen
-        // see awt_MToolkit.c awt_xsettings_update().
-        if (xs == null) {
-            xs = new XSettings();
-        }
-
-        Map updatedSettings = xs.update(data);
-        if (updatedSettings == null || updatedSettings.isEmpty()) {
-            return;
-        }
-
-        Iterator i = updatedSettings.entrySet().iterator();
-        while (i.hasNext()) {
-            Map.Entry e = (Map.Entry)i.next();
-            String name = (String)e.getKey();
-
-            name = "gnome." + name;
-            setDesktopProperty(name, e.getValue());
-
-            // XXX: we probably want to do something smarter.  In
-            // particular, "Net" properties are of interest to the
-            // "core" AWT itself.  E.g.
-            //
-            // Net/DndDragThreshold -> ???
-            // Net/DoubleClickTime  -> awt.multiClickInterval
-        }
-
-        setDesktopProperty(SunToolkit.DESKTOPFONTHINTS,
-                           SunToolkit.getDesktopFontHints());
-
-        Integer dragThreshold = null;
-        synchronized (this) {
-            dragThreshold = (Integer)desktopProperties.get("gnome.Net/DndDragThreshold");
-        }
-        if (dragThreshold != null) {
-            setDesktopProperty("DnD.gestureMotionThreshold", dragThreshold);
-        }
-    }
-
-    protected boolean needsXEmbedImpl() {
-        return true;
-    }
-
-    public boolean isModalityTypeSupported(Dialog.ModalityType modalityType) {
-        return (modalityType == Dialog.ModalityType.MODELESS) ||
-               (modalityType == Dialog.ModalityType.APPLICATION_MODAL);
-    }
-
-    public boolean isModalExclusionTypeSupported(Dialog.ModalExclusionType exclusionType) {
-        return (exclusionType == Dialog.ModalExclusionType.NO_EXCLUDE);
-    }
-
-    private native boolean isSyncUpdated();
-    private native boolean isSyncFailed();
-    private native int getEventNumber();
-    private native void updateSyncSelection();
-    private static final long WORKAROUND_SLEEP = 100;
-
-    /**
-     * @inheritDoc
-     */
-    protected boolean syncNativeQueue(final long timeout) {
-        awtLock();
-        try {
-            long event_number = getEventNumber();
-            updateSyncSelection();
-
-            // Wait for selection notify for oops on win
-            long start = System.currentTimeMillis();
-            while (!isSyncUpdated() && !isSyncFailed()) {
-                try {
-                    awtLockWait(timeout);
-                } catch (InterruptedException e) {
-                    throw new RuntimeException(e);
-                }
-                // This "while" is a protection from spurious
-                // wake-ups.  However, we shouldn't wait for too long
-                if (((System.currentTimeMillis() - start) > timeout) && (timeout >= 0)) {
-                    throw new OperationTimedOut();
-                }
-            }
-            if (isSyncFailed() && getEventNumber() - event_number == 1) {
-                awtUnlock();
-                try {
-                    Thread.sleep(WORKAROUND_SLEEP);
-                } catch (InterruptedException ie) {
-                    throw new RuntimeException(ie);
-                } finally {
-                    awtLock();
-                }
-            }
-            return getEventNumber() - event_number > 2;
-        } finally {
-            awtUnlock();
-        }
-    }
-
-    public  void grab(Window w) {
-        WindowPeer peer = (WindowPeer)w.getPeer();
-        if (peer != null) {
-            nativeGrab(peer);
-        }
-    }
-
-    public void ungrab(Window w) {
-        WindowPeer peer = (WindowPeer)w.getPeer();
-        if (peer != null) {
-            nativeUnGrab(peer);
-        }
-    }
-    private native void nativeGrab(WindowPeer peer);
-    private native void nativeUnGrab(WindowPeer peer);
-
-
-    public boolean isDesktopSupported(){
-        return false;
-    }
-
-    public DesktopPeer createDesktopPeer(Desktop target)
-    throws HeadlessException{
-        throw new UnsupportedOperationException();
-    }
-
-    public final static int
-        UNDETERMINED_WM = 1,
-        NO_WM = 2,
-        OTHER_WM = 3,
-        OPENLOOK_WM = 4,
-        MOTIF_WM = 5,
-        CDE_WM = 6,
-        ENLIGHTEN_WM = 7,
-        KDE2_WM = 8,
-        SAWFISH_WM = 9,
-        ICE_WM = 10,
-        METACITY_WM = 11,
-        COMPIZ_WM = 12,
-        LG3D_WM = 13;
-
-    public static int getWMID() {
-        String wmName = getWMName();
-
-        if ("NO_WM".equals(wmName)) {
-            return NO_WM;
-        } else if ("OTHER_WM".equals(wmName)) {
-            return OTHER_WM;
-        } else if ("ENLIGHTEN_WM".equals(wmName)) {
-            return ENLIGHTEN_WM;
-        } else if ("KDE2_WM".equals(wmName)) {
-            return KDE2_WM;
-        } else if ("SAWFISH_WM".equals(wmName)) {
-            return SAWFISH_WM;
-        } else if ("ICE_WM".equals(wmName)) {
-            return ICE_WM;
-        } else if ("METACITY_WM".equals(wmName)) {
-            return METACITY_WM;
-        } else if ("OPENLOOK_WM".equals(wmName)) {
-            return OPENLOOK_WM;
-        } else if ("MOTIF_WM".equals(wmName)) {
-            return MOTIF_WM;
-        } else if ("CDE_WM".equals(wmName)) {
-            return CDE_WM;
-        } else if ("COMPIZ_WM".equals(wmName)) {
-            return COMPIZ_WM;
-        } else if ("LG3D_WM".equals(wmName)) {
-            return LG3D_WM;
-        }
-        return UNDETERMINED_WM;
-    }
-
-    private static native String getWMName();
-
-} // class MToolkit
diff --git a/jdk/src/solaris/classes/sun/awt/motif/MToolkitThreadBlockedHandler.java b/jdk/src/solaris/classes/sun/awt/motif/MToolkitThreadBlockedHandler.java
deleted file mode 100644
index ab3a055..0000000
--- a/jdk/src/solaris/classes/sun/awt/motif/MToolkitThreadBlockedHandler.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2001, 2005, 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.awt.motif;
-
-import sun.awt.datatransfer.ToolkitThreadBlockedHandler;
-import sun.awt.SunToolkit;
-
-final class MToolkitThreadBlockedHandler implements
-                                 ToolkitThreadBlockedHandler {
-    private static ToolkitThreadBlockedHandler priveleged_lock = null;
-    static {
-        priveleged_lock = new MToolkitThreadBlockedHandler();
-    }
-    private MToolkitThreadBlockedHandler() {}
-    static ToolkitThreadBlockedHandler getToolkitThreadBlockedHandler() {
-        return priveleged_lock;
-    }
-    public void lock() {
-        SunToolkit.awtLock();
-    }
-    public void unlock() {
-        SunToolkit.awtUnlock();
-    }
-    public native void enter();
-    public native void exit();
-}
diff --git a/jdk/src/solaris/classes/sun/awt/motif/MWindowAttributes.java b/jdk/src/solaris/classes/sun/awt/motif/MWindowAttributes.java
deleted file mode 100644
index a920cca..0000000
--- a/jdk/src/solaris/classes/sun/awt/motif/MWindowAttributes.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 1999, 2002, 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.awt.motif;
-import java.awt.Image;
-
-class MWindowAttributes {
-    static int NORMAL           = 0;
-    static int ICONIC           = 1;
-    static int MAXIMIZED        = 2;
-
-    static int AWT_DECOR_NONE        = 0;
-    static int AWT_DECOR_ALL         = 1;
-    static int AWT_DECOR_BORDER      = 2;
-    static int AWT_DECOR_RESIZEH     = 4;
-    static int AWT_DECOR_TITLE       = 8;
-    static int AWT_DECOR_MENU        = 0x10;
-    static int AWT_DECOR_MINIMIZE    = 0x20;
-    static int AWT_DECOR_MAXIMIZE    = 0x40;
-    static int AWT_UNOBSCURED        = 0;   // X11 VisibilityUnobscured
-    static int AWT_PARTIALLY_OBSCURED = 1;  // X11 VisibilityPartiallyObscured
-    static int AWT_FULLY_OBSCURED    =  2;  // X11 VisibilityFullyObscured
-    static int AWT_UNKNOWN_OBSCURITY = 3;
-
-    boolean nativeDecor;
-    boolean initialFocus;
-    boolean isResizable;
-    int initialState;
-    int visibilityState; // updated by native X11 event handling code.
-    String title;
-    java.awt.Image icon;
-    int decorations;            // for future expansion to be able to
-                                // specify native decorations
-
-    private static native void initIDs();
-
-    static {
-        initIDs();
-    }
-
-    MWindowAttributes() {
-        nativeDecor = false;
-        initialFocus = false;
-        isResizable = false;
-        initialState = NORMAL;
-        visibilityState = AWT_UNKNOWN_OBSCURITY;
-        title = null;
-        icon = null;
-        decorations = 0;
-    }
-}
diff --git a/jdk/src/solaris/classes/sun/awt/motif/X11FontMetrics.java b/jdk/src/solaris/classes/sun/awt/motif/X11FontMetrics.java
deleted file mode 100644
index f158eae..0000000
--- a/jdk/src/solaris/classes/sun/awt/motif/X11FontMetrics.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- * Copyright (c) 1995, 2004, 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.awt.motif;
-
-import java.awt.*;
-import java.util.Hashtable;
-import sun.awt.PlatformFont;
-
-/**
- * A font metrics object for a WServer font.
- *
- * @author Jim Graham
- */
-public class X11FontMetrics extends FontMetrics {
-    /**
-     * The widths of the first 256 characters.
-     */
-    int widths[];
-
-    /**
-     * The standard ascent of the font.  This is the logical height
-     * above the baseline for the Alphanumeric characters and should
-     * be used for determining line spacing.  Note, however, that some
-     * characters in the font may extend above this height.
-     */
-    int ascent;
-
-    /**
-     * The standard descent of the font.  This is the logical height
-     * below the baseline for the Alphanumeric characters and should
-     * be used for determining line spacing.  Note, however, that some
-     * characters in the font may extend below this height.
-     */
-    int descent;
-
-    /**
-     * The standard leading for the font.  This is the logical amount
-     * of space to be reserved between the descent of one line of text
-     * and the ascent of the next line.  The height metric is calculated
-     * to include this extra space.
-     */
-    int leading;
-
-    /**
-     * The standard height of a line of text in this font.  This is
-     * the distance between the baseline of adjacent lines of text.
-     * It is the sum of the ascent+descent+leading.  There is no
-     * guarantee that lines of text spaced at this distance will be
-     * disjoint; such lines may overlap if some characters overshoot
-     * the standard ascent and descent metrics.
-     */
-    int height;
-
-    /**
-     * The maximum ascent for all characters in this font.  No character
-     * will extend further above the baseline than this metric.
-     */
-    int maxAscent;
-
-    /**
-     * The maximum descent for all characters in this font.  No character
-     * will descend further below the baseline than this metric.
-     */
-    int maxDescent;
-
-    /**
-     * The maximum possible height of a line of text in this font.
-     * Adjacent lines of text spaced this distance apart will be
-     * guaranteed not to overlap.  Note, however, that many paragraphs
-     * that contain ordinary alphanumeric text may look too widely
-     * spaced if this metric is used to determine line spacing.  The
-     * height field should be preferred unless the text in a given
-     * line contains particularly tall characters.
-     */
-    int maxHeight;
-
-    /**
-     * The maximum advance width of any character in this font.
-     */
-    int maxAdvance;
-
-    static {
-        initIDs();
-    }
-
-    /**
-     * Initialize JNI field and method IDs for fields that may be
-       accessed from C.
-     */
-    private static native void initIDs();
-
-     /**
-     * Calculate the metrics from the given WServer and font.
-     */
-    public X11FontMetrics(Font font) {
-        super(font);
-        init();
-    }
-
-    /**
-     * Get leading
-     */
-    public int getLeading() {
-        return leading;
-    }
-
-    /**
-     * Get ascent.
-     */
-    public int getAscent() {
-        return ascent;
-    }
-
-    /**
-     * Get descent
-     */
-    public int getDescent() {
-        return descent;
-    }
-
-    /**
-     * Get height
-     */
-    public int getHeight() {
-        return height;
-    }
-
-    /**
-     * Get maxAscent
-     */
-    public int getMaxAscent() {
-        return maxAscent;
-    }
-
-    /**
-     * Get maxDescent
-     */
-    public int getMaxDescent() {
-        return maxDescent;
-    }
-
-    /**
-     * Get maxAdvance
-     */
-    public int getMaxAdvance() {
-        return maxAdvance;
-    }
-
-    /**
-     * Return the width of the specified string in this Font.
-     */
-    public int stringWidth(String string) {
-        return charsWidth(string.toCharArray(), 0, string.length());
-    }
-
-    /**
-     * Return the width of the specified char[] in this Font.
-     */
-    public int charsWidth(char chars[], int offset, int length) {
-        Font font = getFont();
-        PlatformFont pf = ((PlatformFont) font.getPeer());
-        if (pf.mightHaveMultiFontMetrics()) {
-            return getMFCharsWidth(chars, offset, length, font);
-        } else {
-            if (widths != null) {
-                int w = 0;
-                for (int i = offset; i < offset + length; i++) {
-                    int ch = chars[i];
-                    if (ch < 0 || ch >= widths.length) {
-                        w += maxAdvance;
-                    } else {
-                        w += widths[ch];
-                    }
-                }
-                return w;
-            } else {
-                return maxAdvance * length;
-            }
-        }
-    }
-
-    private native int getMFCharsWidth(char chars[], int offset, int length, Font font);
-
-    /**
-     * Return the width of the specified byte[] in this Font.
-     */
-    public native int bytesWidth(byte data[], int off, int len);
-
-    /**
-     * Get the widths of the first 256 characters in the font.
-     */
-    public int[] getWidths() {
-        return widths;
-    }
-
-    native void init();
-
-    static Hashtable table = new Hashtable();
-
-    static synchronized FontMetrics getFontMetrics(Font font) {
-        FontMetrics fm = (FontMetrics)table.get(font);
-        if (fm == null) {
-            table.put(font, fm = new X11FontMetrics(font));
-        }
-        return fm;
-    }
-}
diff --git a/jdk/src/solaris/classes/sun/java2d/x11/X11Renderer.java b/jdk/src/solaris/classes/sun/java2d/x11/X11Renderer.java
index c25d7ab..f335781 100644
--- a/jdk/src/solaris/classes/sun/java2d/x11/X11Renderer.java
+++ b/jdk/src/solaris/classes/sun/java2d/x11/X11Renderer.java
@@ -299,7 +299,7 @@
     private void doPath(SunGraphics2D sg2d, Shape s, boolean isFill) {
         Path2D.Float p2df;
         int transx, transy;
-        if (sg2d.transformState <= sg2d.TRANSFORM_INT_TRANSLATE) {
+        if (sg2d.transformState <= SunGraphics2D.TRANSFORM_INT_TRANSLATE) {
             if (s instanceof Path2D.Float) {
                 p2df = (Path2D.Float)s;
             } else {
@@ -323,10 +323,10 @@
     }
 
     public void draw(SunGraphics2D sg2d, Shape s) {
-        if (sg2d.strokeState == sg2d.STROKE_THIN) {
+        if (sg2d.strokeState == SunGraphics2D.STROKE_THIN) {
             // Delegate to drawPolygon() if possible...
             if (s instanceof Polygon &&
-                sg2d.transformState < sg2d.TRANSFORM_TRANSLATESCALE)
+                sg2d.transformState < SunGraphics2D.TRANSFORM_TRANSLATESCALE)
             {
                 Polygon p = (Polygon) s;
                 drawPolygon(sg2d, p.xpoints, p.ypoints, p.npoints);
@@ -336,7 +336,7 @@
             // Otherwise we will use drawPath() for
             // high-quality thin paths.
             doPath(sg2d, s, false);
-        } else if (sg2d.strokeState < sg2d.STROKE_CUSTOM) {
+        } else if (sg2d.strokeState < SunGraphics2D.STROKE_CUSTOM) {
             // REMIND: X11 can handle uniform scaled wide lines
             // and dashed lines itself if we set the appropriate
             // XGC attributes (TBD).
@@ -360,10 +360,10 @@
     }
 
     public void fill(SunGraphics2D sg2d, Shape s) {
-        if (sg2d.strokeState == sg2d.STROKE_THIN) {
+        if (sg2d.strokeState == SunGraphics2D.STROKE_THIN) {
             // Delegate to fillPolygon() if possible...
             if (s instanceof Polygon &&
-                sg2d.transformState < sg2d.TRANSFORM_TRANSLATESCALE)
+                sg2d.transformState < SunGraphics2D.TRANSFORM_TRANSLATESCALE)
             {
                 Polygon p = (Polygon) s;
                 fillPolygon(sg2d, p.xpoints, p.ypoints, p.npoints);
@@ -378,7 +378,7 @@
 
         AffineTransform at;
         int transx, transy;
-        if (sg2d.transformState < sg2d.TRANSFORM_TRANSLATESCALE) {
+        if (sg2d.transformState < SunGraphics2D.TRANSFORM_TRANSLATESCALE) {
             // Transform (translation) will be done by XFillSpans
             at = null;
             transx = sg2d.transX;
diff --git a/jdk/src/solaris/classes/sun/java2d/x11/X11SurfaceData.java b/jdk/src/solaris/classes/sun/java2d/x11/X11SurfaceData.java
index 24513aa..d9d883a 100644
--- a/jdk/src/solaris/classes/sun/java2d/x11/X11SurfaceData.java
+++ b/jdk/src/solaris/classes/sun/java2d/x11/X11SurfaceData.java
@@ -295,9 +295,9 @@
 
     public void validatePipe(SunGraphics2D sg2d) {
         if (sg2d.antialiasHint != SunHints.INTVAL_ANTIALIAS_ON &&
-            sg2d.paintState <= sg2d.PAINT_ALPHACOLOR &&
-            (sg2d.compositeState <= sg2d.COMP_ISCOPY ||
-             sg2d.compositeState == sg2d.COMP_XOR))
+            sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR &&
+            (sg2d.compositeState <= SunGraphics2D.COMP_ISCOPY ||
+             sg2d.compositeState == SunGraphics2D.COMP_XOR))
         {
             if (x11txpipe == null) {
                 /*
@@ -315,7 +315,7 @@
                 return;
             }
 
-            if (sg2d.clipState == sg2d.CLIP_SHAPE) {
+            if (sg2d.clipState == SunGraphics2D.CLIP_SHAPE) {
                 // Do this to init textpipe correctly; we will override the
                 // other non-text pipes below
                 // REMIND: we should clean this up eventually instead of
@@ -329,7 +329,7 @@
                 case SunHints.INTVAL_TEXT_ANTIALIAS_OFF:
                     // Use X11 pipe even if DGA is available since DGA
                     // text slows everything down when mixed with X11 calls
-                    if (sg2d.compositeState == sg2d.COMP_ISCOPY) {
+                    if (sg2d.compositeState == SunGraphics2D.COMP_ISCOPY) {
                         sg2d.textpipe = x11textpipe;
                     } else {
                         sg2d.textpipe = solidTextRenderer;
@@ -353,7 +353,7 @@
                     case SunHints.INTVAL_TEXT_ANTIALIAS_OFF:
                     // Use X11 pipe even if DGA is available since DGA
                     // text slows everything down when mixed with X11 calls
-                    if (sg2d.compositeState == sg2d.COMP_ISCOPY) {
+                    if (sg2d.compositeState == SunGraphics2D.COMP_ISCOPY) {
                         sg2d.textpipe = x11textpipe;
                     } else {
                         sg2d.textpipe = solidTextRenderer;
@@ -370,10 +370,10 @@
                 }
             }
 
-            if (sg2d.transformState >= sg2d.TRANSFORM_TRANSLATESCALE) {
+            if (sg2d.transformState >= SunGraphics2D.TRANSFORM_TRANSLATESCALE) {
                 sg2d.drawpipe = x11txpipe;
                 sg2d.fillpipe = x11txpipe;
-            } else if (sg2d.strokeState != sg2d.STROKE_THIN){
+            } else if (sg2d.strokeState != SunGraphics2D.STROKE_THIN){
                 sg2d.drawpipe = x11txpipe;
                 sg2d.fillpipe = x11pipe;
             } else {
@@ -398,8 +398,8 @@
     }
 
     public RenderLoops getRenderLoops(SunGraphics2D sg2d) {
-        if (sg2d.paintState <= sg2d.PAINT_ALPHACOLOR &&
-            sg2d.compositeState <= sg2d.COMP_ISCOPY)
+        if (sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR &&
+            sg2d.compositeState <= SunGraphics2D.COMP_ISCOPY)
         {
             return solidloops;
         }
@@ -488,7 +488,7 @@
             makePipes();
         }
         CompositeType comptype = sg2d.imageComp;
-        if (sg2d.transformState < sg2d.TRANSFORM_TRANSLATESCALE &&
+        if (sg2d.transformState < SunGraphics2D.TRANSFORM_TRANSLATESCALE &&
             (CompositeType.SrcOverNoEa.equals(comptype) ||
              CompositeType.SrcNoEa.equals(comptype)))
         {
diff --git a/jdk/src/solaris/native/sun/awt/awt_PopupMenu.h b/jdk/src/solaris/native/sun/awt/HeadlessToolkit.c
similarity index 77%
rename from jdk/src/solaris/native/sun/awt/awt_PopupMenu.h
rename to jdk/src/solaris/native/sun/awt/HeadlessToolkit.c
index 3a6d0b7..fd17f3b 100644
--- a/jdk/src/solaris/native/sun/awt/awt_PopupMenu.h
+++ b/jdk/src/solaris/native/sun/awt/HeadlessToolkit.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -23,7 +23,22 @@
  * questions.
  */
 
-/* methodsIDs for MPopupMenuPeer methods that may be accessed from C */
-struct MPopupMenuPeerIDs {
-  jmethodID destroyNativeWidgetAfterGettingTreeLock;
-};
+#include <jni.h>
+#include <jni_util.h>
+
+#ifdef HEADLESS
+
+extern JavaVM *jvm;
+
+JNIEXPORT jint JNICALL
+JNI_OnLoad(JavaVM *vm, void *reserved)
+{
+    jvm = vm;
+    return JNI_VERSION_1_2;
+}
+
+JNIEXPORT jboolean JNICALL AWTIsHeadless() {
+    return JNI_TRUE;
+}
+
+#endif
diff --git a/jdk/src/solaris/native/sun/awt/MouseInfo.c b/jdk/src/solaris/native/sun/awt/MouseInfo.c
deleted file mode 100644
index 07262cf..0000000
--- a/jdk/src/solaris/native/sun/awt/MouseInfo.c
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Copyright (c) 2003, 2008, 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.
- */
-
-#ifdef HEADLESS
-    #error This file should not be included in headless library
-#endif
-
-#include "awt_p.h"
-#include "awt_Component.h"
-
-#include <jni.h>
-#include <jni_util.h>
-
-extern int awt_numScreens;
-extern AwtScreenDataPtr x11Screens;
-extern struct ComponentIDs componentIDs;
-extern struct MComponentPeerIDs mComponentPeerIDs;
-
-/*
- * Class:     sun_awt_DefaultMouseInfoPeer
- * Method:    fillPointWithCoords
- * Signature: (Ljava/awt/Point)I
- */
-JNIEXPORT jint JNICALL
-Java_sun_awt_DefaultMouseInfoPeer_fillPointWithCoords(JNIEnv *env, jclass cls,
-                                                          jobject point)
-{
-     static jclass pointClass = NULL;
-     jclass pointClassLocal;
-     static jfieldID xID, yID;
-     Window rootWindow, childWindow;
-     int i;
-     int32_t xr, yr, xw, yw;
-     uint32_t keys;
-     Bool pointerFound;
-
-     AWT_LOCK();
-     if (pointClass == NULL) {
-         pointClassLocal = (*env)->FindClass(env, "java/awt/Point");
-         DASSERT(pointClassLocal != NULL);
-         if (pointClassLocal == NULL) {
-             AWT_UNLOCK();
-             return (jint)0;
-         }
-         pointClass = (jclass)(*env)->NewGlobalRef(env, pointClassLocal);
-         (*env)->DeleteLocalRef(env, pointClassLocal);
-         xID = (*env)->GetFieldID(env, pointClass, "x", "I");
-         yID = (*env)->GetFieldID(env, pointClass, "y", "I");
-     }
-
-     for (i = 0; i < awt_numScreens; i++) {
-         pointerFound = XQueryPointer(awt_display, x11Screens[i].root,
-                           &rootWindow, &childWindow,
-                           &xr, &yr, &xw, &yw, &keys);
-         if (pointerFound) {
-             (*env)->SetIntField(env, point, xID, xr);
-             (*env)->SetIntField(env, point, yID, yr);
-             AWT_UNLOCK();
-             return (jint)i;
-         }
-     }
-     /* This should never happen */
-     DASSERT(FALSE);
-     AWT_UNLOCK();
-     return (jint)0;
-}
-
-/*
- * Class:     sun_awt_DefaultMouseInfoPeer
- * Method:    isWindowUnderMouse
- * Signature: (Ljava/awt/Window)Z
- */
-JNIEXPORT jboolean JNICALL Java_sun_awt_DefaultMouseInfoPeer_isWindowUnderMouse
-  (JNIEnv * env, jclass cls, jobject window)
-{
-    Window rootWindow = None, parentWindow = None, siblingWindow = None;
-    Window * children = NULL;
-    int i = 0;
-    int is_the_same_screen = 0;
-    int32_t xr = 0, yr = 0, xw = 0, yw = 0;
-    uint32_t keys = 0;
-    uint32_t nchildren = 0;
-    Bool pointerFound = 0;
-    struct FrameData *wdata = NULL;
-    jobject winPeer = NULL;
-
-    if ((*env)->EnsureLocalCapacity(env, 1) < 0) {
-        return JNI_FALSE;
-    }
-    winPeer = (*env)->GetObjectField(env, window, componentIDs.peer);
-    if (JNU_IsNull(env, winPeer)) {
-        return JNI_FALSE;
-    }
-
-    wdata = (struct FrameData *)
-        JNU_GetLongFieldAsPtr(env, winPeer, mComponentPeerIDs.pData);
-    (*env)->DeleteLocalRef(env, winPeer);
-
-    if (wdata == NULL) {
-        return JNI_FALSE;
-    }
-
-    AWT_LOCK();
-
-    XQueryTree(awt_display, XtWindow(wdata->winData.comp.widget),
-                    &rootWindow, &parentWindow, &children, &nchildren);
-
-    is_the_same_screen = XQueryPointer(awt_display, parentWindow,
-            &rootWindow, &siblingWindow, &xr, &yr, &xw, &yw, &keys);
-
-    if (siblingWindow == XtWindow(wdata->winData.comp.widget) && is_the_same_screen) {
-        AWT_UNLOCK();
-        return JNI_TRUE;
-    }
-
-    AWT_UNLOCK();
-    return JNI_FALSE ;
-
-}
diff --git a/jdk/src/solaris/native/sun/awt/XDrawingArea.c b/jdk/src/solaris/native/sun/awt/XDrawingArea.c
deleted file mode 100644
index bd14768..0000000
--- a/jdk/src/solaris/native/sun/awt/XDrawingArea.c
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Copyright (c) 2002, 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 <X11/IntrinsicP.h>
-#include "XDrawingAreaP.h"
-#include <Xm/XmP.h>
-
-#include <stdio.h>
-#include <malloc.h>
-
-#ifdef DEBUG
-#include <jvm.h>  /* To get jio_fprintf() */
-#endif
-
-/******************************************************************
- *
- * Provides Canvas widget which allows the X11 visual to be
- * changed (the Motif DrawingArea restricts the visual to that
- * of the parent widget).
- *
- ******************************************************************/
-
-
-static XmNavigability WidgetNavigable();
-static void ClassInitialize();
-
-static XmBaseClassExtRec baseClassExtRec = {
-    NULL,
-    NULLQUARK,
-    XmBaseClassExtVersion,
-    sizeof(XmBaseClassExtRec),
-    NULL,                               /* InitializePrehook    */
-    NULL,                               /* SetValuesPrehook     */
-    NULL,                               /* InitializePosthook   */
-    NULL,                               /* SetValuesPosthook    */
-    NULL,                               /* secondaryObjectClass */
-    NULL,                               /* secondaryCreate      */
-    NULL,                               /* getSecRes data       */
-    { 0 },                              /* fastSubclass flags   */
-    NULL,                               /* getValuesPrehook     */
-    NULL,                               /* getValuesPosthook    */
-    NULL,                               /* classPartInitPrehook */
-    NULL,                               /* classPartInitPosthook*/
-    NULL,                               /* ext_resources        */
-    NULL,                               /* compiled_ext_resources*/
-    0,                                  /* num_ext_resources    */
-    FALSE,                              /* use_sub_resources    */
-    WidgetNavigable,                    /* widgetNavigable      */
-    NULL                                /* focusChange          */
-};
-
-XDrawingAreaClassRec xDrawingAreaClassRec = {
-{
-    /* Core class part */
-
-    /* superclass         */    (WidgetClass)&xmDrawingAreaClassRec,
-    /* class_name         */    "XDrawingArea",
-    /* widget_size        */    sizeof(XDrawingAreaRec),
-    /* class_initialize   */    ClassInitialize,
-    /* class_part_initialize*/  NULL,
-    /* class_inited       */    FALSE,
-    /* initialize         */    NULL,
-    /* initialize_hook    */    NULL,
-    /* realize            */    XtInheritRealize,
-    /* actions            */    NULL,
-    /* num_actions        */    0,
-    /* resources          */    NULL,
-    /* num_resources      */    0,
-    /* xrm_class          */    NULLQUARK,
-    /* compress_motion    */    FALSE,
-    /* compress_exposure  */    FALSE,
-    /* compress_enterleave*/    FALSE,
-    /* visible_interest   */    FALSE,
-    /* destroy            */    NULL,
-    /* resize             */    XtInheritResize,
-    /* expose             */    XtInheritExpose,
-    /* set_values         */    NULL,
-    /* set_values_hook    */    NULL,
-    /* set_values_almost  */    XtInheritSetValuesAlmost,
-    /* get_values_hook    */    NULL,
-    /* accept_focus       */    NULL,
-    /* version            */    XtVersion,
-    /* callback_offsets   */    NULL,
-    /* tm_table           */    NULL,
-    /* query_geometry       */  NULL,
-    /* display_accelerator  */  NULL,
-    /* extension            */  (XtPointer)&baseClassExtRec
-  },
-
-   {            /* composite_class fields */
-      XtInheritGeometryManager,                 /* geometry_manager   */
-      XtInheritChangeManaged,                   /* change_managed     */
-      XtInheritInsertChild,                     /* insert_child       */
-      XtInheritDeleteChild,                     /* delete_child       */
-      NULL,                                     /* extension          */
-   },
-
-   {            /* constraint_class fields */
-      NULL,                                     /* resource list        */
-      0,                                        /* num resources        */
-      0,                                        /* constraint size      */
-      NULL,                                     /* init proc            */
-      NULL,                                     /* destroy proc         */
-      NULL,                                     /* set values proc      */
-      NULL,                                     /* extension            */
-   },
-
-   {            /* manager_class fields */
-      XtInheritTranslations,                    /* translations           */
-      NULL,                                     /* syn_resources          */
-      0,                                        /* num_get_resources      */
-      NULL,                                     /* syn_cont_resources     */
-      0,                                        /* num_get_cont_resources */
-      XmInheritParentProcess,                   /* parent_process         */
-      NULL,                                     /* extension           */
-   },
-
-   {            /* drawingArea class */
-           /* extension */      NULL
-   },
-
-   /* XDrawingArea class part */
-   {
-        /* extension    */      NULL
-   }
-};
-
-WidgetClass xDrawingAreaClass = (WidgetClass)&xDrawingAreaClassRec;
-
-static void ClassInitialize( void )
-{
-    baseClassExtRec.record_type = XmQmotif ;
-}
-
-static XmNavigability WidgetNavigable(Widget wid)
-{
-    return XmCONTROL_NAVIGABLE;
-}
diff --git a/jdk/src/solaris/native/sun/awt/XDrawingArea.h b/jdk/src/solaris/native/sun/awt/XDrawingArea.h
deleted file mode 100644
index 4cc1cbf..0000000
--- a/jdk/src/solaris/native/sun/awt/XDrawingArea.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2002, 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 _XDrawingArea_h_
-#define _XDrawingArea_h_
-
-extern WidgetClass xDrawingAreaClass;
-
-typedef struct _XDrawingAreaClassRec    *XDrawingAreaWidgetClass;
-typedef struct _XDrawingAreaRec         *XDrawingAreaWidget;
-
-#endif /* !_VDrawingArea_h_ */
diff --git a/jdk/src/solaris/native/sun/awt/XDrawingAreaP.h b/jdk/src/solaris/native/sun/awt/XDrawingAreaP.h
deleted file mode 100644
index d98f7da..0000000
--- a/jdk/src/solaris/native/sun/awt/XDrawingAreaP.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 2002, 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 _XDrawingAreaP_h_
-#define _XDrawingAreaP_h_
-
-#include <Xm/DrawingAP.h>
-#include "XDrawingArea.h"
-
-
-/***************************************************************
- * VDrawingArea Widget Data Structures
- *
- *
- **************************************************************/
-
-/* Define part class structure */
-typedef struct _XDrawingAreaClass {
-        XtPointer                       extension;
-} XDrawingAreaClassPart;
-
-/* Define the full class record */
-typedef struct _XDrawingAreaClassRec {
-        CoreClassPart           core_class;
-        CompositeClassPart      composite_class;
-        ConstraintClassPart     constraint_class;
-        XmManagerClassPart      manager_class;
-        XmDrawingAreaClassPart  drawing_area_class;
-        XDrawingAreaClassPart   xdrawingarea_class;
-} XDrawingAreaClassRec;
-
-/* External definition for class record */
-extern XDrawingAreaClassRec xDrawingAreaClassRec;
-
-/****************************************************************
- *
-* Full instance record declaration
- *
- ****************************************************************/
-
-typedef struct _XDrawingAreaRec
-{
-        CorePart                core;
-        CompositePart           composite;
-        ConstraintPart          constraint;
-        XmManagerPart           manager;
-        XmDrawingAreaPart       drawing_area;
-} XDrawingAreaRec;
-
-
-
-#endif /* !_VDrawingAreaP_h_ */
diff --git a/jdk/src/solaris/native/sun/awt/awt.h b/jdk/src/solaris/native/sun/awt/awt.h
index d83d645..c591300 100644
--- a/jdk/src/solaris/native/sun/awt/awt.h
+++ b/jdk/src/solaris/native/sun/awt/awt.h
@@ -90,74 +90,12 @@
  * Unfortunately AWT_LOCK debugging does not work with XAWT due to mixed
  * Java/C use of AWT lock.
  */
-#if defined(DEBUG_AWT_LOCK) && !defined(XAWT)
-extern int awt_locked;
-extern char *lastF;
-extern int lastL;
-
-#define AWT_LOCK() do {                                                 \
-    if (!awtLockInited) {                                               \
-        jio_fprintf(stderr, "AWT lock error, awt_lock is null\n");      \
-    }                                                                   \
-    if (awt_locked < 0) {                                               \
-        jio_fprintf(stderr,                                             \
-                    "AWT lock error (%s,%d) (last held by %s,%d) %d\n", \
-                    __FILE__, __LINE__, lastF, lastL, awt_locked);      \
-    }                                                                   \
-    lastF = __FILE__;                                                   \
-    lastL = __LINE__;                                                   \
-    AWT_LOCK_IMPL();                                                    \
-    ++awt_locked;                                                       \
-} while (0)
-
-#define AWT_NOFLUSH_UNLOCK() do {                               \
-    lastF = "";                                                 \
-    lastL = -1;                                                 \
-    if (awt_locked < 1) {                                       \
-        jio_fprintf(stderr, "AWT unlock error (%s,%d,%d)\n",    \
-                    __FILE__, __LINE__, awt_locked);            \
-    }                                                           \
-    --awt_locked;                                               \
-    AWT_NOFLUSH_UNLOCK_IMPL();                                  \
-} while (0)
-
-#define AWT_WAIT(tm) do {                                       \
-    int old_lockcount = awt_locked;                             \
-    if (awt_locked < 1) {                                       \
-        jio_fprintf(stderr, "AWT wait error (%s,%d,%d)\n",      \
-                    __FILE__, __LINE__, awt_locked);            \
-    }                                                           \
-    awt_locked = 0;                                             \
-    AWT_WAIT_IMPL(tm);                                          \
-    awt_locked = old_lockcount;                                 \
-} while (0)
-
-#define AWT_NOTIFY() do {                                       \
-    if (awt_locked < 1) {                                       \
-        jio_fprintf(stderr, "AWT notify error (%s,%d,%d)\n",    \
-                    __FILE__, __LINE__, awt_locked);            \
-    }                                                           \
-    AWT_NOTIFY_IMPL();                                          \
-} while(0)
-
-#define AWT_NOTIFY_ALL() do {                                           \
-    if (awt_locked < 1) {                                               \
-        jio_fprintf(stderr, "AWT notify all error (%s,%d,%d)\n",        \
-                    __FILE__, __LINE__, awt_locked);                    \
-    }                                                                   \
-    AWT_NOTIFY_ALL_IMPL();                                              \
-} while (0)
-
-#else
-
 #define AWT_LOCK()           AWT_LOCK_IMPL()
 #define AWT_NOFLUSH_UNLOCK() AWT_NOFLUSH_UNLOCK_IMPL()
 #define AWT_WAIT(tm)         AWT_WAIT_IMPL(tm)
 #define AWT_NOTIFY()         AWT_NOTIFY_IMPL()
 #define AWT_NOTIFY_ALL()     AWT_NOTIFY_ALL_IMPL()
 
-#endif /* DEBUG_AWT_LOCK && !XAWT */
-
 #ifndef HEADLESS
 extern Display         *awt_display; /* awt_GraphicsEnv.c */
 extern Boolean          awt_ModLockIsShiftLock; /* XToolkit.c */
diff --git a/jdk/src/solaris/native/sun/awt/awt_AWTEvent.c b/jdk/src/solaris/native/sun/awt/awt_AWTEvent.c
index aee39e7..72c0b56 100644
--- a/jdk/src/solaris/native/sun/awt/awt_AWTEvent.c
+++ b/jdk/src/solaris/native/sun/awt/awt_AWTEvent.c
@@ -40,14 +40,11 @@
 #include "java_awt_event_KeyEvent.h"
 #include "jni_util.h"
 
-#include "canvas.h"
 #include "awt_AWTEvent.h"
-#include "awt_Component.h"
 
 struct AWTEventIDs awtEventIDs;
 struct InputEventIDs inputEventIDs;
 struct KeyEventIDs keyEventIDs;
-struct MComponentPeerIDs mComponentPeerIDs;
 
 JNIEXPORT void JNICALL
 Java_java_awt_AWTEvent_initIDs(JNIEnv *env, jclass cls)
@@ -69,61 +66,10 @@
     keyEventIDs.keyCode = (*env)->GetFieldID(env, cls, "keyCode", "I");
     keyEventIDs.keyChar = (*env)->GetFieldID(env, cls, "keyChar", "C");
 }
-#ifndef XAWT
-JNIEXPORT void JNICALL
-Java_java_awt_AWTEvent_nativeSetSource(JNIEnv *env, jobject self,
-                                       jobject newSource)
-{
-    jbyteArray bdata;
 
-    AWT_LOCK();
-
-    bdata = (jbyteArray)(*env)->GetObjectField(env, self, awtEventIDs.bdata);
-
-    if (bdata != NULL) {
-        XEvent *xev;
-        Window w;
-        jboolean dummy;
-
-        /* get the widget out of the peer newSource */
-        struct ComponentData *cdata = (struct ComponentData *)
-            JNU_GetLongFieldAsPtr(env, newSource, mComponentPeerIDs.pData);
-        if (JNU_IsNull(env, cdata) || (cdata == NULL) ||
-            ((cdata->widget != NULL) && (XtIsObject(cdata->widget)) &&
-             (cdata->widget->core.being_destroyed))) {
-            JNU_ThrowNullPointerException(env, "null widget");
-            AWT_UNLOCK();
-            return;
-        }
-
-        /* get the Window out of the widget */
-        w = XtWindow(cdata->widget);
-
-        if (w == None) {
-            JNU_ThrowNullPointerException(env, "null window");
-            AWT_UNLOCK();
-            return;
-        }
-
-        /* reset the filed in the event */
-        xev = (XEvent *)(*env)->GetPrimitiveArrayCritical(env, bdata, &dummy);
-        if (xev == NULL) {
-            JNU_ThrowNullPointerException(env, "null data");
-            AWT_UNLOCK();
-            return;
-        }
-        xev->xany.window = w;
-        (*env)->ReleasePrimitiveArrayCritical(env, bdata, (void *)xev, 0);
-    }
-
-    AWT_UNLOCK();
-}
-#else
 JNIEXPORT void JNICALL
 Java_java_awt_AWTEvent_nativeSetSource(JNIEnv *env, jobject self,
                                        jobject newSource)
 {
 
 }
-
-#endif
diff --git a/jdk/src/solaris/native/sun/awt/awt_Component.h b/jdk/src/solaris/native/sun/awt/awt_Component.h
index 560b63e..7a43ab8 100644
--- a/jdk/src/solaris/native/sun/awt/awt_Component.h
+++ b/jdk/src/solaris/native/sun/awt/awt_Component.h
@@ -42,25 +42,3 @@
     jmethodID getParent;
     jmethodID getLocationOnScreen;
 };
-
-/* field and method IDs for Container */
-struct ContainerIDs {
-    jfieldID layoutMgr;
-    jmethodID getComponents;
-    jmethodID findComponentAt;
-};
-
-/* fieldIDs for MComponentPeer fields that may be accessed from C */
-struct MComponentPeerIDs {
-    jfieldID pData;
-    jfieldID target;
-    jfieldID jniGlobalRef;
-    jfieldID graphicsConfig;
-    jfieldID drawState;
-    jmethodID isFocusableMID;
-};
-
-#ifndef HEADLESS
-extern void processTree(Widget from, Widget to, Boolean action);
-#endif // HEADLESS
-
diff --git a/jdk/src/solaris/native/sun/awt/awt_Cursor.h b/jdk/src/solaris/native/sun/awt/awt_Cursor.h
deleted file mode 100644
index b71f2ec..0000000
--- a/jdk/src/solaris/native/sun/awt/awt_Cursor.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 1998, 2005, 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 "jni_util.h"
-#include "awt_p.h"
-
-#define CACHE_UPDATE 0          /* cache the component and update cursor */
-#define UPDATE_ONLY  1          /* update cursor, but not cache component */
-#define CACHE_ONLY   2          /* cache the component, no cursor update */
-
-/* fieldIDs for Cursor fields that may be accessed from C */
-struct CursorIDs {
-  jfieldID type;
-  jmethodID mSetPData;
-  jfieldID pData;
-};
-
-#ifndef HEADLESS
-Cursor getCursor(JNIEnv *env, jobject jCur);
-void updateCursor(XPointer client_data, int32_t replace);
-#endif /* !HEADLESS */
diff --git a/jdk/src/solaris/native/sun/awt/awt_DrawingSurface.c b/jdk/src/solaris/native/sun/awt/awt_DrawingSurface.c
index 21cc862d..fe19f99 100644
--- a/jdk/src/solaris/native/sun/awt/awt_DrawingSurface.c
+++ b/jdk/src/solaris/native/sun/awt/awt_DrawingSurface.c
@@ -29,30 +29,21 @@
 
 #include "awt_p.h"
 #include "java_awt_Component.h"
-//#include "sun_awt_motif_MComponentPeer.h"
 
 #include "awt_Component.h"
 
-
 #include <jni.h>
 #include <jni_util.h>
 #include <jawt_md.h>
 
-extern struct MComponentPeerIDs mComponentPeerIDs;
 extern struct ComponentIDs componentIDs;
-#ifndef XAWT
-extern AwtGraphicsConfigDataPtr
-getGraphicsConfigFromComponentPeer(JNIEnv *env, jobject this);
-#endif
 
-#ifdef XAWT
 #include "awt_GraphicsEnv.h"
 extern jfieldID windowID;
 extern jfieldID targetID;
 extern jfieldID graphicsConfigID;
 extern jfieldID drawStateID;
 extern struct X11GraphicsConfigIDs x11GraphicsConfigIDs;
-#endif
 
 /*
  * Lock the surface of the target component for native rendering.
@@ -109,13 +100,8 @@
         return (jint)JAWT_LOCK_ERROR;
     }
 
-#ifndef XAWT
-    drawState = (*env)->GetIntField(env, peer, mComponentPeerIDs.drawState);
-    (*env)->SetIntField(env, peer, mComponentPeerIDs.drawState, 0);
-#else
    drawState = (*env)->GetIntField(env, peer, drawStateID);
     (*env)->SetIntField(env, peer, drawStateID, 0);
-#endif
     return drawState;
 }
 
@@ -127,9 +113,7 @@
     jclass componentClass;
     AwtGraphicsConfigDataPtr adata;
     int32_t result;
-#ifdef XAWT
      jobject gc_object;
-#endif
     if (ds == NULL) {
 #ifdef DEBUG
         fprintf(stderr, "Drawing Surface is NULL\n");
@@ -164,9 +148,6 @@
         AWT_UNLOCK();
         return (int32_t) 0;
     }
-#ifndef XAWT
-    adata = getGraphicsConfigFromComponentPeer(env, peer);
-#else
      /* GraphicsConfiguration object of MComponentPeer */
     gc_object = (*env)->GetObjectField(env, peer, graphicsConfigID);
 
@@ -177,7 +158,6 @@
     } else {
         adata = getDefaultConfig(DefaultScreen(awt_display));
     }
-#endif
 
     result = adata->AwtColorMatch(r, g, b, adata);
         AWT_UNLOCK();
@@ -201,9 +181,6 @@
     jclass componentClass;
     JAWT_X11DrawingSurfaceInfo* px;
     JAWT_DrawingSurfaceInfo* p;
-#ifndef XAWT
-    struct ComponentData *cdata;
-#endif
     XWindowAttributes attrs;
 
     if (ds == NULL) {
@@ -241,31 +218,14 @@
         return NULL;
     }
 
-#ifndef XAWT
-    /* Get the component data from the peer */
-    cdata = (struct ComponentData *)
-        JNU_GetLongFieldAsPtr(env, peer, mComponentPeerIDs.pData);
-    if (cdata == NULL) {
-#ifdef DEBUG
-        fprintf(stderr, "Component data is NULL\n");
-#endif
-                AWT_UNLOCK();
-        return NULL;
-    }
-#endif
-
-        AWT_UNLOCK();
+    AWT_UNLOCK();
 
     /* Allocate platform-specific data */
     px = (JAWT_X11DrawingSurfaceInfo*)
         malloc(sizeof(JAWT_X11DrawingSurfaceInfo));
 
     /* Set drawable and display */
-#ifndef XAWT
-    px->drawable = XtWindow(cdata->widget);
-#else
     px->drawable = (*env)->GetLongField(env, peer, windowID);
-#endif
     px->display = awt_display;
 
     /* Get window attributes to set other values */
@@ -392,21 +352,7 @@
 
     AWT_LOCK();
 
-#ifndef XAWT
-    if (window != None) {
-        widget = XtWindowToWidget(awt_display, window);
-    }
-
-    if (widget != NULL) {
-        XtVaGetValues (widget, XmNuserData, &peer, NULL);
-    }
-
-    if (peer != NULL) {
-        target = (*env)->GetObjectField(env, peer, mComponentPeerIDs.target);
-    }
-#else
     target =  (*env)->GetObjectField(env, peer, targetID);
-#endif
 
     if (target == NULL) {
         JNU_ThrowNullPointerException(env, "NullPointerException");
diff --git a/jdk/src/solaris/native/sun/awt/awt_Font.c b/jdk/src/solaris/native/sun/awt/awt_Font.c
index 871a19c..239ea32 100644
--- a/jdk/src/solaris/native/sun/awt/awt_Font.c
+++ b/jdk/src/solaris/native/sun/awt/awt_Font.c
@@ -30,8 +30,6 @@
 #include "java_awt_Component.h"
 #include "java_awt_Font.h"
 #include "java_awt_FontMetrics.h"
-#include "sun_awt_motif_MToolkit.h"
-#include "sun_awt_motif_X11FontMetrics.h"
 #include "sun_awt_X11GraphicsEnvironment.h"
 
 #include "awt_Font.h"
@@ -100,57 +98,6 @@
 }
 
 #ifndef HEADLESS
-
-/* fieldIDs for X11FontMetrics fields that may be accessed from C */
-static struct X11FontMetricsIDs {
-    jfieldID widths;
-    jfieldID font;
-    jfieldID ascent;
-    jfieldID descent;
-    jfieldID leading;
-    jfieldID height;
-    jfieldID maxAscent;
-    jfieldID maxDescent;
-    jfieldID maxHeight;
-    jfieldID maxAdvance;
-} x11FontMetricsIDs;
-
-/*
- * Class:     sun_awt_motif_X11FontMetrics
- * Method:    initIDs
- * Signature: ()V
- */
-
-/* This function gets called from the static initializer for
-   X11FontMetrics.java to initialize the fieldIDs for fields
-   that may be accessed from C */
-
-JNIEXPORT void JNICALL
-Java_sun_awt_motif_X11FontMetrics_initIDs
-  (JNIEnv *env, jclass cls)
-{
-    x11FontMetricsIDs.widths = (*env)->GetFieldID(env, cls, "widths", "[I");
-    x11FontMetricsIDs.font =
-      (*env)->GetFieldID(env, cls, "font", "Ljava/awt/Font;");
-    x11FontMetricsIDs.ascent =
-      (*env)->GetFieldID(env, cls, "ascent", "I");
-    x11FontMetricsIDs.descent =
-      (*env)->GetFieldID(env, cls, "descent", "I");
-    x11FontMetricsIDs.leading =
-      (*env)->GetFieldID(env, cls, "leading", "I");
-    x11FontMetricsIDs.height =
-      (*env)->GetFieldID(env, cls, "height", "I");
-    x11FontMetricsIDs.maxAscent =
-      (*env)->GetFieldID(env, cls, "maxAscent", "I");
-    x11FontMetricsIDs.maxDescent =
-      (*env)->GetFieldID(env, cls, "maxDescent", "I");
-    x11FontMetricsIDs.maxHeight =
-      (*env)->GetFieldID(env, cls, "maxHeight", "I");
-    x11FontMetricsIDs.maxAdvance =
-      (*env)->GetFieldID(env, cls, "maxAdvance", "I");
-}
-
-
 /* fieldIDs for FontDescriptor fields that may be accessed from C */
 static struct FontDescriptorIDs {
     jfieldID nativeName;
@@ -182,27 +129,6 @@
 #endif /* !HEADLESS */
 }
 
-#ifndef HEADLESS
-struct MFontPeerIDs mFontPeerIDs;
-/*
- * Class:     sun_awt_motif_MFontPeer
- * Method:    initIDs
- * Signature: ()V
- */
-
-/* This function gets called from the static initializer for
-   MFontPeer.java to initialize the fieldIDs for fields
-   that may be accessed from C */
-
-JNIEXPORT void JNICALL
-Java_sun_awt_motif_MFontPeer_initIDs
-  (JNIEnv *env, jclass cls)
-{
-    mFontPeerIDs.xfsname =
-      (*env)->GetFieldID(env, cls, "xfsname", "Ljava/lang/String;");
-}
-#endif /* !HEADLESS */
-
 /*
  * Class:     sun_awt_PlatformFont
  * Method:    initIDs
@@ -747,193 +673,6 @@
 }
 
 /*
- * Class:     sun_awt_motif_X11FontMetrics
- * Method:    getMFCharsWidth
- * Signature: ([CIILjava/awt/Font;)I
- */
-JNIEXPORT jint JNICALL Java_sun_awt_motif_X11FontMetrics_getMFCharsWidth
-  (JNIEnv *env, jobject this, jcharArray data, jint offset, jint length, jobject font)
-{
-    jint retVal = 0;
-
-    AWT_LOCK();
-
-    retVal = awtJNI_GetMFStringWidth(env, data, offset, length, font);
-
-    AWT_UNLOCK();
-    return retVal;
-}
-
-/*
- * Class:     sun_awt_motif_X11FontMetrics
- * Method:    bytesWidth
- * Signature: ([BII)I
- */
-JNIEXPORT jint JNICALL Java_sun_awt_motif_X11FontMetrics_bytesWidth
-  (JNIEnv *env, jobject this, jbyteArray str, jint off, jint len)
-{
-    jint w = 0;
-    unsigned char *s = NULL, *tmpPointer = NULL;
-    int32_t ch = 0;
-    int32_t cnt = 0;
-    jobject widths = NULL;
-    jint tempWidths[256];
-    jint maxAdvance = 0;
-    int32_t widlen = 0;
-
-    if (JNU_IsNull(env, str)) {
-        JNU_ThrowNullPointerException(env, "NullPointerException");
-        return 0;
-    }
-
-    cnt = (*env)->GetArrayLength(env, str);
-    if (cnt == 0) {
-        return 0;
-    }
-
-    widths = (*env)->GetObjectField(env, this, x11FontMetricsIDs.widths);
-    maxAdvance = (*env)->GetIntField(env, this, x11FontMetricsIDs.maxAdvance);
-    if (!JNU_IsNull(env, widths)) {
-        w = 0;
-        widlen = (*env)->GetArrayLength(env, widths);
-        (*env)->GetIntArrayRegion(env, widths, 0, widlen, (jint *) tempWidths);
-
-        s = tmpPointer = (unsigned char *) (*env)->GetPrimitiveArrayCritical(env, str, NULL);
-        if (s == NULL) {
-            return 0;
-        }
-
-        while (--cnt >= 0) {
-            ch = *tmpPointer++;
-            if (ch < widlen) {
-                w += tempWidths[ch];
-            } else {
-                w += maxAdvance;
-            }
-        }
-
-        (*env)->ReleasePrimitiveArrayCritical(env, str, (jchar *) s, JNI_ABORT);
-    } else {
-        w = maxAdvance * cnt;
-    }
-    return w;
-}
-
-/*
- * Class:     sun_awt_motif_X11FontMetrics
- * Method:    init
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_sun_awt_motif_X11FontMetrics_init
-  (JNIEnv *env, jobject this)
-{
-    jobject font = NULL;
-    struct FontData *fdata = NULL;
-    jint tempWidths[256];
-    jintArray widths = NULL;
-    int32_t ccount = 0;
-    int32_t i = 0;
-    int32_t tempWidthsIndex = 0;
-    char *err = NULL;
-
-    if (JNU_IsNull(env, this)) {
-        JNU_ThrowNullPointerException(env, "NullPointerException");
-        return;
-    }
-    AWT_LOCK();
-
-    font = (*env)->GetObjectField(env, this, x11FontMetricsIDs.font);
-    if (JNU_IsNull(env, this)) {
-        JNU_ThrowNullPointerException(env, "NullPointerException");
-        AWT_UNLOCK();
-        return;
-    }
-    fdata = awtJNI_GetFontData(env, font, &err);
-    if (fdata == NULL) {
-        JNU_ThrowInternalError(env, err);
-        AWT_UNLOCK();
-        return;
-    }
-
-    /*
-     * Bug 4103248, 4120310. We must take all of the fonts into
-     * consideration in providing the metrics, not just the 8859-1 font,
-     * because the underlying Motif widgets are.
-     */
-    if (awtJNI_IsMultiFont(env, font) && fdata->xfs == NULL) {
-        fdata->xfs = awtJNI_MakeFontSet(env, font);
-    }
-    if (fdata->xfs != NULL) {
-        XFontSetExtents *fs_extents = NULL;
-        fs_extents = XExtentsOfFontSet(fdata->xfs);
-
-        (*env)->SetIntField(env, this, x11FontMetricsIDs.maxAscent,
-                        (jint)(-fs_extents->max_logical_extent.y));
-        (*env)->SetIntField(env, this, x11FontMetricsIDs.maxDescent,
-                        (jint)(fs_extents->max_logical_extent.height +
-                               fs_extents->max_logical_extent.y));
-        (*env)->SetIntField(env, this, x11FontMetricsIDs.maxAdvance,
-                        (jint)(fs_extents->max_logical_extent.width));
-        (*env)->SetIntField(env, this, x11FontMetricsIDs.ascent,
-                        (jint)(-fs_extents->max_ink_extent.y));
-        (*env)->SetIntField(env, this, x11FontMetricsIDs.descent,
-                        (jint)(fs_extents->max_ink_extent.height +
-                         fs_extents->max_ink_extent.y));
-    } else {
-        (*env)->SetIntField(env, this, x11FontMetricsIDs.maxAscent,
-                        (jint) fdata->xfont->max_bounds.ascent);
-        (*env)->SetIntField(env, this, x11FontMetricsIDs.maxDescent,
-                        (jint) fdata->xfont->max_bounds.descent);
-        (*env)->SetIntField(env, this, x11FontMetricsIDs.maxAdvance,
-                        (jint) fdata->xfont->max_bounds.width);
-        (*env)->SetIntField(env, this, x11FontMetricsIDs.ascent,
-                        (jint) fdata->xfont->ascent);
-        (*env)->SetIntField(env, this, x11FontMetricsIDs.descent,
-                        (jint) fdata->xfont->descent);
-    }
-
-    (*env)->SetIntField(env, this, x11FontMetricsIDs.leading, (jint) 1);
-    (*env)->SetIntField(env, this, x11FontMetricsIDs.height,
-                        (jint) fdata->xfont->ascent + fdata->xfont->descent + 1);
-    (*env)->SetIntField(env, this, x11FontMetricsIDs.maxHeight,
-                        (jint) fdata->xfont->max_bounds.ascent
-                        + fdata->xfont->max_bounds.descent + 1);
-
-
-    widths = (*env)->NewIntArray(env, 256);
-    (*env)->SetObjectField(env, this, x11FontMetricsIDs.widths, widths);
-    if (JNU_IsNull(env, widths)) {
-        JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
-        AWT_UNLOCK();
-        return;
-    }
-    /*
-     * We could pin the array and then release it, but I believe this method
-     * is faster and perturbs the VM less
-     *
-     */
-    memset(tempWidths, 0, 256 * sizeof(jint));
-
-    tempWidthsIndex = fdata->xfont->min_char_or_byte2;
-
-    ccount = fdata->xfont->max_char_or_byte2 - fdata->xfont->min_char_or_byte2;
-
-    if (fdata->xfont->per_char) {
-        for (i = 0; i <= ccount; i++) {
-            tempWidths[tempWidthsIndex++] = (jint) fdata->xfont->per_char[i].width;
-        }
-    } else {
-        for (i = 0; i <= ccount; i++) {
-            tempWidths[tempWidthsIndex++] = (jint) fdata->xfont->max_bounds.width;
-        }
-    }
-
-    (*env)->SetIntArrayRegion(env, widths, 0, 256, (jint *) tempWidths);
-
-    AWT_UNLOCK();
-}
-
-/*
  * Registered with the 2D disposer to be called after the Font is GC'd.
  */
 static void pDataDisposeMethod(JNIEnv *env, jlong pData)
diff --git a/jdk/src/solaris/native/sun/awt/awt_Font.h b/jdk/src/solaris/native/sun/awt/awt_Font.h
index 6231799..ca00288 100644
--- a/jdk/src/solaris/native/sun/awt/awt_Font.h
+++ b/jdk/src/solaris/native/sun/awt/awt_Font.h
@@ -34,8 +34,8 @@
     jmethodID getFamily;
 };
 
-/* fieldIDs for MFontPeer fields that may be accessed from C */
-struct MFontPeerIDs {
+/* fieldIDs for XFontPeer fields that may be accessed from C */
+struct XFontPeerIDs {
     jfieldID xfsname;
 };
 
diff --git a/jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c b/jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c
index 301df87..f6e4b06 100644
--- a/jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c
+++ b/jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c
@@ -45,7 +45,6 @@
 #include <stdlib.h>
 
 #include "awt_GraphicsEnv.h"
-#include "awt_Window.h"
 #include "awt_util.h"
 #include "gdefs.h"
 #include <dlfcn.h>
@@ -94,8 +93,6 @@
 
 struct X11GraphicsConfigIDs x11GraphicsConfigIDs;
 struct X11GraphicsDeviceIDs x11GraphicsDeviceIDs;
-extern struct WindowIDs mWindowIDs;
-extern struct MWindowPeerIDs mWindowPeerIDs;
 
 #ifndef HEADLESS
 int awtCreateX11Colormap(AwtGraphicsConfigDataPtr adata);
@@ -570,75 +567,6 @@
     AWT_UNLOCK ();
 }
 
-/*
- * Determing if this top-level has been moved onto another Xinerama screen.
- * Called from awt_TopLevel.c
- *
- * ASSUME: wdata != null
- */
-#ifndef HEADLESS
-void checkNewXineramaScreen(JNIEnv* env, jobject peer, struct FrameData* wdata,
-                            int32_t newX, int32_t newY,
-                            int32_t newWidth, int32_t newHeight) {
-    int i;
-    int amt;
-    int totAmt = 0;
-    int largestAmt = 0;
-    int largestAmtScr = 0;
-
-    int horiz;
-    int vert;
-
-    if (!usingXinerama) { return; }
-
-    totAmt = newWidth * newHeight;
-
-    /* assert that peer implements WindowPeer */
-    DASSERT(JNU_IsInstanceOfByName(env, peer, "java/awt/peer/WindowPeer"));
-
-    DTRACE_PRINTLN4("checkNewXineramaScreen() x=%i y=%i w=%i h=%i\n",newX, newY, newWidth, newHeight);
-
-    /* decide which screen we're on
-     * if we're spanning, figure out which screen we're most on
-     */
-    for (i = 0; i < awt_numScreens; i++) {
-        if (INTERSECTS(newX, newX + newWidth, newY, newY + newHeight,
-                       fbrects[i].x, fbrects[i].x + fbrects[i].width,
-                       fbrects[i].y, fbrects[i].y + fbrects[i].height)) {
-
-            /* calc how much of window is on this screen */
-            horiz = MIN(newX + newWidth, fbrects[i].x + fbrects[i].width) -
-                    MAX(newX, fbrects[i].x);
-            vert =  MIN(newY + newHeight, fbrects[i].y + fbrects[i].height) -
-                    MAX(newY, fbrects[i].y);
-            DASSERT(horiz > 0);
-            DASSERT(vert > 0);
-
-            amt = horiz * vert;
-            if (amt == totAmt) {
-                /* completely on this screen - done! */
-                largestAmtScr = i;
-                break;
-            }
-            if (amt > largestAmt) {
-                largestAmt = amt;
-                largestAmtScr = i;
-            }
-        }
-    }
-
-#ifndef XAWT
-    /* check if we're on a new screen */
-    if (largestAmtScr != wdata->screenNum) {
-        wdata->screenNum = largestAmtScr;
-        /* update peer, target Comp */
-        (*env)->CallVoidMethod(env, peer,
-                               mWindowPeerIDs.draggedToScreenMID, largestAmtScr);
-    }
-#endif /* XAWT */
-}
-#endif /* HEADLESS */
-
 #ifndef HEADLESS
 #ifdef __linux__
 static void xinerama_init_linux()
@@ -1434,11 +1362,17 @@
                                                         fbrects[screen].height);
         }
         else {
+            XWindowAttributes xwa;
+            memset(&xwa, 0, sizeof(xwa));
+
+            AWT_LOCK ();
+            XGetWindowAttributes(awt_display,
+                    RootWindow(awt_display, adata->awt_visInfo.screen),
+                    &xwa);
+            AWT_UNLOCK ();
+
             bounds = (*env)->NewObject(env, clazz, mid, 0, 0,
-                                   DisplayWidth(awt_display,
-                                                adata->awt_visInfo.screen),
-                                   DisplayHeight(awt_display,
-                                                 adata->awt_visInfo.screen));
+                    xwa.width, xwa.height);
         }
 
         if ((*env)->ExceptionOccurred(env)) {
diff --git a/jdk/src/solaris/native/sun/awt/awt_InputMethod.c b/jdk/src/solaris/native/sun/awt/awt_InputMethod.c
index 116a531..af85e48 100644
--- a/jdk/src/solaris/native/sun/awt/awt_InputMethod.c
+++ b/jdk/src/solaris/native/sun/awt/awt_InputMethod.c
@@ -30,28 +30,14 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <X11/Xlib.h>
-#ifdef XAWT
 #include <sys/time.h>
-#else /* !XAWT */
-#include <Xm/Xm.h>
-#include <Xm/RowColumn.h>
-#include <Xm/MwmUtil.h>
-#include <Xm/MenuShell.h>
-#endif /* XAWT */
 
 #include "awt.h"
 #include "awt_p.h"
 
 #include <sun_awt_X11InputMethod.h>
-#ifdef XAWT
 #include <sun_awt_X11_XComponentPeer.h>
 #include <sun_awt_X11_XInputMethod.h>
-#else /* !XAWT */
-#include <sun_awt_motif_MComponentPeer.h>
-#include <sun_awt_motif_MInputMethod.h>
-
-#define MCOMPONENTPEER_CLASS_NAME       "sun/awt/motif/MComponentPeer"
-#endif /* XAWT */
 
 #define THROW_OUT_OF_MEMORY_ERROR() \
         JNU_ThrowOutOfMemoryError((JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2), NULL)
@@ -111,11 +97,7 @@
 typedef struct {
     Window   w;                /*status window id        */
     Window   root;             /*the root window id      */
-#ifdef XAWT
     Window   parent;           /*parent shell window     */
-#else
-    Widget   parent;           /*parent shell window     */
-#endif
     int      x, y;             /*parent's upperleft position */
     int      width, height;    /*parent's width, height  */
     GC       lightGC;          /*gc for light border     */
@@ -141,17 +123,10 @@
     XIC         ic_active;      /* X Input Context for active clients */
     XIC         ic_passive;     /* X Input Context for passive clients */
     XIMCallback *callbacks;     /* callback parameters */
-#ifndef XAWT
-    jobject     peer;           /* MComponentPeer of client Window */
-#endif /* XAWT */
     jobject     x11inputmethod; /* global ref to X11InputMethod instance */
                                 /* associated with the XIC */
 #ifdef __linux__
     StatusWindow *statusWindow; /* our own status window  */
-#else
-#ifndef XAWT
-    Widget      statusWidget;   /* IM status window widget */
-#endif /* XAWT */
 #endif
     char        *lookup_buf;    /* buffer used for XmbLookupString */
     int         lookup_buf_len; /* lookup buffer size in bytes */
@@ -191,12 +166,6 @@
 
 #define GetJNIEnv() (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2)
 
-#ifndef XAWT
-static jobject  mcompClass = NULL;
-static jobject  awteventClass = NULL;
-static jfieldID mcompPDataID = NULL;
-#endif /* XAWT */
-
 static void DestroyXIMCallback(XIM, XPointer, XPointer);
 static void OpenXIMCallback(Display *, XPointer, XPointer);
 /* Solaris XIM Extention */
@@ -261,28 +230,6 @@
     return mbs;
 }
 
-#ifndef XAWT
-/*
- * Find a class for the given class name and return a global reference to the
- * class.
- */
-static jobject
-findClass(const char *className)
-{
-    JNIEnv *env = GetJNIEnv();
-    jclass classClass;
-    jobject objectClass;
-
-    classClass = (*env)->FindClass(env, className);
-    objectClass = (*env)->NewGlobalRef(env,classClass);
-
-    if (JNU_IsNull(env, objectClass)) {
-        JNU_ThrowClassNotFoundException(env, className);
-    }
-    return objectClass;
-}
-#endif /* XAWT */
-
 /*
  * Returns True if the global reference is still in the list,
  * otherwise False.
@@ -444,9 +391,6 @@
         free((void *)pX11IMData->callbacks);
 
     if (env) {
-#ifndef XAWT
-        (*env)->DeleteGlobalRef(env, pX11IMData->peer);
-#endif /* XAWT */
         /* Remove the global reference from the list, so that
            the callback function or whoever refers to it could know.
         */
@@ -580,23 +524,10 @@
     /* Get keysym without taking modifiers into account first to map
      * to AWT keyCode table.
      */
-#ifndef XAWT
-    if (((event->state & ShiftMask) ||
-        (event->state & LockMask)) &&
-         keysym >= 'A' && keysym <= 'Z')
-    {
-        keysym = XLookupKeysym(event, 0);
-    }
-#endif
-
     switch (status) {
     case XLookupBoth:
         if (!composing) {
-#ifdef XAWT
             if (event->keycode != 0) {
-#else
-            if (keysym < 128 || ((keysym & 0xff00) == 0xff00)) {
-#endif
                 *keysymp = keysym;
                 result = False;
                 break;
@@ -650,11 +581,7 @@
 
 #ifdef __linux__
 static StatusWindow *createStatusWindow(
-#ifdef XAWT
                                 Window parent) {
-#else
-                                Widget parent) {
-#endif
     StatusWindow *statusWindow;
     XSetWindowAttributes attrib;
     unsigned long attribmask;
@@ -682,22 +609,12 @@
     Window *ignoreWindowPtr;
     unsigned int ignoreUnit;
 
-#ifdef XAWT
     XGetGeometry(dpy, parent, &rootWindow, &x, &y, &w, &h, &bw, &depth);
-#else
-    while (!XtIsShell(parent)){
-        parent = XtParent(parent);
-    }
-#endif
 
     attrib.override_redirect = True;
     attribmask = CWOverrideRedirect;
     for (i = 0; i < awt_numScreens; i++) {
-#ifdef XAWT
         if (RootWindow(dpy, i) == rootWindow) {
-#else
-        if (ScreenOfDisplay(dpy, i) == XtScreen(parent)) {
-#endif
             screen = i;
             break;
         }
@@ -798,11 +715,7 @@
 
 /* This method is to turn off or turn on the status window. */
 static void onoffStatusWindow(X11InputMethodData* pX11IMData,
-#ifdef XAWT
                                 Window parent,
-#else
-                                Widget parent,
-#endif
                                 Bool ON){
     XWindowAttributes xwa;
     Window child;
@@ -820,15 +733,9 @@
         statusWindow->on = False;
         return;
     }
-#ifdef XAWT
     parent = JNU_CallMethodByName(GetJNIEnv(), NULL, pX11IMData->x11inputmethod,
                                   "getCurrentParentWindow",
                                   "()J").j;
-#else
-    while (!XtIsShell(parent)){
-        parent = XtParent(parent);
-    }
-#endif
     if (statusWindow->parent != parent){
         statusWindow->parent = parent;
     }
@@ -941,11 +848,7 @@
   }
 }
 
-#ifdef XAWT
 static void adjustStatusWindow(Window shell){
-#else
-void adjustStatusWindow(Widget shell){
-#endif
     JNIEnv *env = GetJNIEnv();
     X11InputMethodData *pX11IMData = NULL;
     StatusWindow *statusWindow;
@@ -957,11 +860,7 @@
         || !statusWindow->on) {
         return;
     }
-#ifdef XAWT
     {
-#else
-    if (statusWindow->parent == shell) {
-#endif
         XWindowAttributes xwa;
         int x, y;
         Window child;
@@ -1009,12 +908,7 @@
  * fallback to None styles.
  */
 static Bool
-#ifdef XAWT
 createXIC(JNIEnv * env, X11InputMethodData *pX11IMData, Window w)
-#else /* !XAWT */
-createXIC(Widget w, X11InputMethodData *pX11IMData,
-          jobject tc, jobject peer)
-#endif /* XAWT */
 {
     XIC active_ic, passive_ic;
     XVaNestedList preedit = NULL;
@@ -1031,17 +925,9 @@
     if (X11im == NULL) {
         return False;
     }
-#ifdef XAWT
     if (!w) {
         return False;
     }
-#else /* !XAWT */
-    /*
-     * If the parent window has one or more TextComponents, the status
-     * area of Motif will be shared with the created XIC. Otherwise,
-     * root-window style status is used.
-     */
-#endif /* XAWT */
 
     ret = XGetIMValues(X11im, XNQueryInputStyle, &im_styles, NULL);
 
@@ -1064,28 +950,7 @@
         }
     }
 #else /*! __linux__ */
-#ifdef XAWT
     on_the_spot_styles |= XIMStatusNothing;
-#else /* !XAWT */
-    /*
-     * If the parent window has one or more TextComponents, the status
-     * area of Motif will be shared with the created XIC. Otherwise,
-     * root-window style status is used.
-     */
-    if (tc != NULL){
-        XVaNestedList status = NULL;
-        status = awt_motif_getXICStatusAreaList(w, tc);
-        if (status != NULL){
-            on_the_spot_styles |=  XIMStatusArea;
-            XFree(status);
-        }
-        else
-            on_the_spot_styles |= XIMStatusNothing;
-    }
-    else
-        on_the_spot_styles |= XIMStatusNothing;
-
-#endif /* XAWT */
 #endif /* __linux__ */
 
     for (i = 0; i < im_styles->count_styles; i++) {
@@ -1157,32 +1022,12 @@
             XFree((void *)preedit);
         }
 #else /* !__linux__ */
-#ifndef XAWT
-        if (on_the_spot_styles & XIMStatusArea) {
-            Widget parent;
-            status = awt_motif_getXICStatusAreaList(w, tc);
-            if (status == NULL)
-                goto err;
-            pX11IMData->statusWidget = awt_util_getXICStatusAreaWindow(w);
-            pX11IMData->ic_active = XCreateIC(X11im,
-                                              XNClientWindow, pX11IMData->statusWidget,
-                                              XNFocusWindow, w,
-                                              XNInputStyle, active_styles,
-                                              XNPreeditAttributes, preedit,
-                                              XNStatusAttributes, status,
-                                              NULL);
-            XFree((void *)status);
-        } else {
-#endif /* XAWT */
             pX11IMData->ic_active = XCreateIC(X11im,
                                               XNClientWindow, w,
                                               XNFocusWindow, w,
                                               XNInputStyle, active_styles,
                                               XNPreeditAttributes, preedit,
                                               NULL);
-#ifndef XAWT
-        }
-#endif /* XAWT */
         XFree((void *)preedit);
 #endif /* __linux__ */
         pX11IMData->ic_passive = XCreateIC(X11im,
@@ -1479,7 +1324,7 @@
 }
 
 /*
- * Class:     java_sun_awt_motif_X11InputMethod
+ * Class:     sun_awt_X11InputMethod
  * Method:    initIDs
  * Signature: ()V
  */
@@ -1495,24 +1340,15 @@
 
 
 JNIEXPORT jboolean JNICALL
-#ifdef XAWT
 Java_sun_awt_X11_XInputMethod_openXIMNative(JNIEnv *env,
                                           jobject this,
                                           jlong display)
-#else
-Java_sun_awt_motif_MInputMethod_openXIMNative(JNIEnv *env,
-                                          jobject this)
-#endif
 {
     Bool registered;
 
     AWT_LOCK();
 
-#ifdef XAWT
     dpy = (Display *)jlong_to_ptr(display);
-#else
-    dpy = awt_display;
-#endif
 
 /* Use IMInstantiate call back only on Linux, as there is a bug in Solaris
    (4768335)
@@ -1534,30 +1370,17 @@
 }
 
 JNIEXPORT jboolean JNICALL
-#ifdef XAWT
 Java_sun_awt_X11_XInputMethod_createXICNative(JNIEnv *env,
                                                   jobject this,
                                                   jlong window)
 {
-#else /* !XAWT */
-Java_sun_awt_motif_MInputMethod_createXICNative(JNIEnv *env,
-                                                  jobject this,
-                                                  jobject comp,
-                                                  jobject tc)
-{
-    struct ComponentData *cdata;
-#endif /* XAWT */
     X11InputMethodData *pX11IMData;
     jobject globalRef;
     XIC ic;
 
     AWT_LOCK();
 
-#ifdef XAWT
     if (!window) {
-#else /* !XAWT */
-    if (JNU_IsNull(env, comp)) {
-#endif /* XAWT */
         JNU_ThrowNullPointerException(env, "NullPointerException");
         AWT_UNLOCK();
         return JNI_FALSE;
@@ -1570,40 +1393,16 @@
         return JNI_FALSE;
     }
 
-#ifndef XAWT
-    if (mcompClass == NULL) {
-        mcompClass = findClass(MCOMPONENTPEER_CLASS_NAME);
-        mcompPDataID = (*env)->GetFieldID(env, mcompClass, "pData", "J");
-    }
-    cdata = (struct ComponentData *) JNU_GetLongFieldAsPtr(env,comp,mcompPDataID);
-
-    if (cdata == 0) {
-        free((void *)pX11IMData);
-        JNU_ThrowNullPointerException(env, "createXIC");
-        AWT_UNLOCK();
-        return JNI_FALSE;
-    }
-
-    pX11IMData->peer = (*env)->NewGlobalRef(env, comp);
-#endif /* XAWT */
     globalRef = (*env)->NewGlobalRef(env, this);
     pX11IMData->x11inputmethod = globalRef;
 #ifdef __linux__
     pX11IMData->statusWindow = NULL;
-#else /* __linux__ */
-#ifndef XAWT
-    pX11IMData->statusWidget = (Widget) NULL;
-#endif /* XAWT */
 #endif /* __linux__ */
 
     pX11IMData->lookup_buf = 0;
     pX11IMData->lookup_buf_len = 0;
 
-#ifdef XAWT
     if (createXIC(env, pX11IMData, (Window)window)
-#else /* !XAWT */
-    if (createXIC(cdata->widget, pX11IMData, tc, comp)
-#endif /* XAWT */
         == False) {
         destroyX11InputMethodData((JNIEnv *) NULL, pX11IMData);
         pX11IMData = (X11InputMethodData *) NULL;
@@ -1615,77 +1414,6 @@
     return (pX11IMData != NULL);
 }
 
-#ifndef XAWT
-JNIEXPORT void JNICALL
-Java_sun_awt_motif_MInputMethod_reconfigureXICNative(JNIEnv *env,
-                                                       jobject this,
-                                                       jobject comp,
-                                                       jobject tc)
-{
-    X11InputMethodData *pX11IMData;
-
-    AWT_LOCK();
-
-    pX11IMData = getX11InputMethodData(env, this);
-    if (pX11IMData == NULL) {
-        AWT_UNLOCK();
-        return;
-    }
-
-    if (pX11IMData->current_ic == (XIC)0) {
-        destroyX11InputMethodData(env, pX11IMData);
-        pX11IMData = (X11InputMethodData *)NULL;
-    } else {
-        Bool active;
-        struct ComponentData *cdata;
-
-        active = pX11IMData->current_ic == pX11IMData->ic_active;
-        if (mcompClass == NULL) {
-            mcompClass = findClass(MCOMPONENTPEER_CLASS_NAME);
-            mcompPDataID = (*env)->GetFieldID(env, mcompClass, "pData", "J");
-        }
-        cdata = (struct ComponentData *) JNU_GetLongFieldAsPtr(env,comp,mcompPDataID);
-        if (cdata == 0) {
-            JNU_ThrowNullPointerException(env, "reconfigureXICNative");
-            destroyX11InputMethodData(env, pX11IMData);
-            pX11IMData = (X11InputMethodData *)NULL;
-        }
-        XDestroyIC(pX11IMData->ic_active);
-        if (pX11IMData->ic_active != pX11IMData->ic_passive)
-            XDestroyIC(pX11IMData->ic_passive);
-        pX11IMData->current_ic = (XIC)0;
-        pX11IMData->ic_active = (XIC)0;
-        pX11IMData->ic_passive = (XIC)0;
-        if (createXIC(cdata->widget, pX11IMData, tc, comp)) {
-            pX11IMData->current_ic = active ?
-                        pX11IMData->ic_active : pX11IMData->ic_passive;
-            /*
-             * On Solaris2.6, setXICWindowFocus() has to be invoked
-             * before setting focus.
-             */
-            setXICWindowFocus(pX11IMData->current_ic, cdata->widget);
-            setXICFocus(pX11IMData->current_ic, True);
-        } else {
-            destroyX11InputMethodData((JNIEnv *) NULL, pX11IMData);
-            pX11IMData = (X11InputMethodData *)NULL;
-        }
-    }
-
-    setX11InputMethodData(env, this, pX11IMData);
-
-    AWT_UNLOCK();
-}
-
-JNIEXPORT void JNICALL
-Java_sun_awt_motif_MInputMethod_setXICFocusNative(JNIEnv *env,
-                                              jobject this,
-                                              jobject comp,
-                                              jboolean req,
-                                              jboolean active)
-{
-    struct ComponentData *cdata;
-    Widget w;
-#else /* !XAWT */
 JNIEXPORT void JNICALL
 Java_sun_awt_X11_XInputMethod_setXICFocusNative(JNIEnv *env,
                                               jobject this,
@@ -1693,7 +1421,6 @@
                                               jboolean req,
                                               jboolean active)
 {
-#endif /* XAWT */
     X11InputMethodData *pX11IMData;
     AWT_LOCK();
     pX11IMData = getX11InputMethodData(env, this);
@@ -1703,40 +1430,16 @@
     }
 
     if (req) {
-#ifdef XAWT
         if (!w) {
             AWT_UNLOCK();
             return;
         }
-#else /* !XAWT */
-        struct ComponentData *cdata;
-
-        if (JNU_IsNull(env, comp)) {
-            AWT_UNLOCK();
-            return;
-        }
-        if (mcompClass == NULL) {
-            mcompClass = findClass(MCOMPONENTPEER_CLASS_NAME);
-            mcompPDataID = (*env)->GetFieldID(env, mcompClass, "pData", "J");
-        }
-        cdata = (struct ComponentData *)JNU_GetLongFieldAsPtr(env, comp,
-                                                              mcompPDataID);
-        if (cdata == 0) {
-            JNU_ThrowNullPointerException(env, "setXICFocus pData");
-            AWT_UNLOCK();
-            return;
-        }
-#endif /* XAWT */
-
         pX11IMData->current_ic = active ?
                         pX11IMData->ic_active : pX11IMData->ic_passive;
         /*
          * On Solaris2.6, setXICWindowFocus() has to be invoked
          * before setting focus.
          */
-#ifndef XAWT
-        w = cdata->widget;
-#endif /* XAWT */
         setXICWindowFocus(pX11IMData->current_ic, w);
         setXICFocus(pX11IMData->current_ic, req);
         currentX11InputMethodInstance = pX11IMData->x11inputmethod;
@@ -1853,40 +1556,6 @@
     return jText;
 }
 
-#ifndef XAWT
-JNIEXPORT void JNICALL
-Java_sun_awt_motif_MInputMethod_configureStatusAreaNative(JNIEnv *env,
-                                                            jobject this,
-                                                            jobject tc)
-{
-    X11InputMethodData *pX11IMData;
-    XVaNestedList status;
-
-#ifdef __linux__
-      /*do nothing for linux? */
-#else
-    AWT_LOCK();
-    pX11IMData = getX11InputMethodData(env, this);
-
-    if ((pX11IMData == NULL) || (pX11IMData->ic_active == (XIC)0)) {
-        AWT_UNLOCK();
-        return;
-    }
-
-    if (pX11IMData->statusWidget) {
-        status = awt_motif_getXICStatusAreaList(pX11IMData->statusWidget, tc);
-        if (status != (XVaNestedList)NULL) {
-            XSetICValues(pX11IMData->ic_active,
-                         XNStatusAttributes, status,
-                         NULL);
-            XFree((void *)status);
-        }
-    }
-    AWT_UNLOCK();
-#endif
-}
-#endif /* XAWT */
-
 /*
  * Class:     sun_awt_X11InputMethod
  * Method:    setCompositionEnabledNative
@@ -1964,7 +1633,6 @@
     return (jboolean)(state == XIMPreeditEnable);
 }
 
-#ifdef XAWT
 JNIEXPORT void JNICALL Java_sun_awt_X11_XInputMethod_adjustStatusWindow
   (JNIEnv *env, jobject this, jlong window)
 {
@@ -1974,4 +1642,3 @@
     AWT_UNLOCK();
 #endif
 }
-#endif
diff --git a/jdk/src/solaris/native/sun/awt/awt_KeyboardFocusManager.h b/jdk/src/solaris/native/sun/awt/awt_KeyboardFocusManager.h
deleted file mode 100644
index fc28275..0000000
--- a/jdk/src/solaris/native/sun/awt/awt_KeyboardFocusManager.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2001, 2002, 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 "jni.h"
-
-struct KeyboardFocusManagerIDs {
-    jclass keyboardFocusManagerCls;
-    jmethodID shouldNativelyFocusHeavyweightMID;
-    jmethodID heavyweightButtonDownMID;
-    jmethodID heavyweightButtonDownZMID;
-    jmethodID markClearGlobalFocusOwnerMID;
-    jmethodID processSynchronousTransferMID;
-    jfieldID isProxyActive;
-};
diff --git a/jdk/src/solaris/native/sun/awt/awt_MToolkit.c b/jdk/src/solaris/native/sun/awt/awt_MToolkit.c
deleted file mode 100644
index 3a7c117..0000000
--- a/jdk/src/solaris/native/sun/awt/awt_MToolkit.c
+++ /dev/null
@@ -1,3430 +0,0 @@
-/*
- * Copyright (c) 1995, 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.  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 "awt_p.h"
-
-#include <sys/time.h>
-#include <limits.h>
-#include <locale.h>
-
-#ifndef HEADLESS
-#include <X11/cursorfont.h>
-#include <Xm/MenuShell.h>
-#include <Xm/RowColumn.h>
-#endif /* !HEADLESS */
-
-#include <jvm.h>
-#include <jni.h>
-#include <jlong.h>
-#include <jni_util.h>
-
-/* JNI headers */
-#include "java_awt_AWTEvent.h"
-#include "java_awt_Frame.h"
-#include "java_awt_SystemColor.h"
-#include "sun_awt_motif_MToolkit.h"
-
-/* JNI field and method ids */
-#include "awt_Component.h"
-//#include "awt_Cursor.h"
-#include "awt_MenuComponent.h"
-#include "awt_TopLevel.h"
-#include "canvas.h"
-#include "color.h"
-#include "awt_mgrsel.h"
-#include "awt_wm.h"
-#include "awt_DrawingSurface.h"
-#include "awt_Window.h"
-#include "awt_xembed.h"
-#include "awt_xembed_server.h"
-
-extern JavaVM *jvm;
-
-#ifndef HEADLESS
-#ifdef __linux__
-extern void statusWindowEventHandler(XEvent event);
-#endif
-#endif /* !HEADLESS */
-
-JNIEXPORT jint JNICALL
-JNI_OnLoad(JavaVM *vm, void *reserved)
-{
-#ifndef HEADLESS
-    awt_util_debug_init();
-#endif /* !HEADLESS */
-    jvm = vm;
-    return JNI_VERSION_1_2;
-}
-
-JNIEXPORT jboolean JNICALL AWTIsHeadless() {
-#ifdef HEADLESS
-    return JNI_TRUE;
-#else
-    return JNI_FALSE;
-#endif
-}
-
-#ifndef HEADLESS
-static jlong awtJNI_TimeMillis(void);
-extern void awt_initialize_Xm_DnD(Display*);
-extern void awt_initialize_DataTransferer();
-
-extern Display *awt_init_Display(JNIEnv *env);
-
-extern void X11SD_LibDispose(JNIEnv *env);
-
-extern Widget drag_source = NULL;
-
-extern struct ComponentIDs componentIDs;
-extern struct MenuComponentIDs menuComponentIDs;
-extern struct MComponentPeerIDs mComponentPeerIDs;
-extern struct WindowIDs windowIDs;
-
-static Atom _XA_XSETTINGS_SETTINGS = None;
-struct xsettings_callback_cookie {
-    jobject mtoolkit;
-    jmethodID upcallMID;
-};
-
-static struct xsettings_callback_cookie xsettings_callback_cookie;
-
-
-static XEvent focusOutEvent;
-
-static void awt_pipe_init(void);
-static void processOneEvent(XtInputMask iMask);
-extern void waitForEvents(JNIEnv *env, int32_t fdXPipe, int32_t fdAWTPipe);
-#ifdef USE_SELECT
-static void performSelect(JNIEnv *env, int32_t fdXPipe, int32_t fdAWTPipe);
-#else
-static void performPoll(JNIEnv *env,int32_t fdXPipe, int32_t fdAWTPipe);
-#endif
-
-
-#include <X11/Intrinsic.h>
-#include <dlfcn.h>
-#include <fcntl.h>
-
-#ifdef USE_SELECT
-#if defined(AIX)
-#include <sys/select.h>
-#endif
-#else
-#include <poll.h>
-#ifndef POLLRDNORM
-#define POLLRDNORM POLLIN
-#endif
-#endif
-
-#ifdef NDEBUG
-#undef DEBUG            /* NDEBUG overrides DEBUG */
-#endif
-
-static struct WidgetInfo *awt_winfo = (struct WidgetInfo *) NULL;
-static struct MenuList* menu_list = (struct MenuList*) NULL;
-
-#ifndef bzero
-#define bzero(a,b) memset(a, 0, b)
-#endif
-
-static jboolean syncUpdated = JNI_FALSE;
-static jboolean syncFailed = JNI_FALSE;
-static jint eventNumber = 0;
-static void syncWait_eventHandler(XEvent *);
-static Atom oops_atom = None;
-static Atom wm_selection = None;
-static Atom version_atom = None;
-
-static Boolean inSyncWait = False;
-
-Widget grabbed_widget = NULL;
-
-XtAppContext awt_appContext;
-Widget awt_root_shell;
-Pixel awt_defaultBg;
-Pixel awt_defaultFg;
-int32_t awt_multiclick_time;        /* milliseconds */
-uint32_t awt_MetaMask = 0;
-uint32_t awt_AltMask = 0;
-uint32_t awt_NumLockMask = 0;
-uint32_t awt_ModeSwitchMask = 0;
-Cursor awt_scrollCursor;
-Boolean  awt_ModLockIsShiftLock = False;
-extern Boolean awt_UseType4Patch;
-extern Boolean awt_UseXKB;
-
-#define SPECIAL_KEY_EVENT 2
-
-/* implement a "putback queue" -- see comments on awt_put_back_event() */
-#define PUTBACK_QUEUE_MIN_INCREMENT 5   /* min size increase */
-static XEvent *putbackQueue = NULL;     /* the queue -- next event is 0 */
-static int32_t putbackQueueCount = 0;   /* # of events available on queue */
-static int32_t putbackQueueCapacity = 0;        /* total capacity of queue */
-static XtInputMask awt_events_pending(XtAppContext appContext);
-static int32_t awt_get_next_put_back_event(XEvent *xev_out);
-
-#define AWT_FLUSH_TIMEOUT    ((uint32_t)100) /* milliseconds */
-#define AWT_MIN_POLL_TIMEOUT ((uint32_t)0) /* milliseconds */
-#define AWT_MAX_POLL_TIMEOUT ((uint32_t)250) /* milliseconds */
-
-#define AWT_POLL_BUFSIZE        100
-#define AWT_READPIPE            (awt_pipe_fds[0])
-#define AWT_WRITEPIPE           (awt_pipe_fds[1])
-#define AWT_FLUSHOUTPUT_NOW()  \
-{                              \
-    XFlush(awt_display);       \
-    awt_next_flush_time = 0LL; \
-}
-
-typedef XtIntervalId (*XTFUNC)();
-
-static jobject  awt_MainThread = NULL;
-static char     read_buf[AWT_POLL_BUFSIZE + 1];    /* dummy buf to empty pipe */
-static int32_t      awt_pipe_fds[2];                   /* fds for wkaeup pipe */
-static Boolean  awt_pipe_inited = False;           /* make sure pipe is initialized before write */
-static int32_t      def_poll_timeout = AWT_MAX_POLL_TIMEOUT;   /* default value for timeout */
-static jlong awt_next_flush_time = 0LL; /* 0 == no scheduled flush */
-static void     *xt_lib = NULL;
-static XTFUNC   xt_timeout = NULL;
-
-#ifdef DEBUG_AWT_LOCK
-
-int32_t awt_locked = 0;
-char *lastF = "";
-int32_t lastL = -1;
-
-#endif
-
-#ifndef NOMODALFIX
-extern Boolean awt_isModal();
-extern Boolean awt_isWidgetModal(Widget w);
-#endif
-
-Boolean keyboardGrabbed = False;
-
-static uint32_t curPollTimeout = AWT_MAX_POLL_TIMEOUT;
-
-/* Font information to feed Motif widgets. */
-static const char      *motifFontList;
-static XFontSet        defaultMotifFontSet;
-static XFontStruct     *defaultMotifFontStruct;
-static const char *defaultMotifFont =  /* a.k.a "fixed", known everywhere */
-        "-misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso8859-1";
-
-XFontSet getMotifFontSet() {
-    char    **missingList;
-    int32_t     missingCount;
-    char    *defChar;
-
-    return XCreateFontSet(awt_display, motifFontList,
-                          &missingList, &missingCount, &defChar);
-}
-
-XFontStruct *getMotifFontStruct() {
-    return XLoadQueryFont(awt_display, defaultMotifFont);
-}
-
-XmFontList getMotifFontList() {
-    XmFontListEntry motifFontListEntry;
-    XmFontList fontlist;
-
-    if (strchr(motifFontList, ',') == NULL) {
-        /* If the default font is a single font. */
-        if (defaultMotifFontStruct == NULL)
-            defaultMotifFontStruct = getMotifFontStruct();
-        motifFontListEntry = XmFontListEntryCreate(XmFONTLIST_DEFAULT_TAG,
-                                                   XmFONT_IS_FONT,
-                                           (XtPointer)defaultMotifFontStruct);
-    }
-    else {
-        /* If the default font is multiple fonts. */
-        if (defaultMotifFontSet == NULL)
-            defaultMotifFontSet = getMotifFontSet();
-            motifFontListEntry = XmFontListEntryCreate(XmFONTLIST_DEFAULT_TAG,
-                                               XmFONT_IS_FONTSET,
-                                               (XtPointer)defaultMotifFontSet);
-    }
-    fontlist = XmFontListAppendEntry(NULL, motifFontListEntry);
-    XmFontListEntryFree(&motifFontListEntry);
-    return fontlist;
-}
-
-static void
-awt_set_poll_timeout (uint32_t newTimeout)
-{
-    DTRACE_PRINTLN1("awt_set_poll_timeout(%lu)", newTimeout);
-
-    newTimeout = max(AWT_MIN_POLL_TIMEOUT, newTimeout);
-    newTimeout = min(AWT_MAX_POLL_TIMEOUT, newTimeout);
-    newTimeout = min(newTimeout, curPollTimeout);
-    curPollTimeout = newTimeout;
-
-} /* awt_set_poll_timeout */
-
-/*
- * Gets the best timeout for the next call to poll() or select().
- * If timedOut is True, we assume that our previous timeout elapsed
- * with no events/timers arriving. Therefore, we can increase the
- * next timeout slightly.
- */
-static uint32_t
-awt_get_poll_timeout( Boolean timedOut )
-{
-    uint32_t timeout = AWT_MAX_POLL_TIMEOUT;
-
-    DTRACE_PRINTLN2("awt_get_poll_timeout(%s), awt_next_flush_time:%ld",
-        (remove?"true":"false"),
-        awt_next_flush_time);
-
-    if (timedOut) {
-        /* add 1/16 (plus 1, in case the division truncates to 0) */
-        curPollTimeout += ((curPollTimeout>>4) + 1);
-        curPollTimeout = min(AWT_MAX_POLL_TIMEOUT, curPollTimeout);
-    }
-    if (awt_next_flush_time > 0) {
-        int32_t flushDiff = (int32_t)(awt_next_flush_time - awtJNI_TimeMillis());
-        timeout = min(curPollTimeout, flushDiff);
-    } else {
-        timeout = curPollTimeout;
-    }
-
-    return timeout;
-} /* awt_get_poll_timeout() */
-
-static jlong
-awtJNI_TimeMillis(void)
-{
-    struct timeval t;
-
-    gettimeofday(&t, 0);
-
-    return jlong_add(jlong_mul(jint_to_jlong(t.tv_sec), jint_to_jlong(1000)),
-                     jint_to_jlong(t.tv_usec / 1000));
-}
-
-static int32_t
-xtError()
-{
-#ifdef DEBUG
-    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
-
-    jio_fprintf(stderr, "Xt error\n");
-    JNU_ThrowNullPointerException(env, "NullPointerException");
-#endif
-    return 0;
-}
-
-static int32_t
-xIOError(Display *dpy)
-{
-    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
-    jclass cl = (*env)->FindClass(env, "java/lang/Thread");
-
-    if (errno == EPIPE) {
-        jio_fprintf(stderr, "X connection to %s host broken (explicit kill or server shutdown)\n", XDisplayName(NULL));
-    }
-    AWT_NOFLUSH_UNLOCK();
-    JVM_RaiseSignal(JVM_SIGTERM); /* Shut down cleanly */
-    if (cl != NULL) {
-        JVM_Sleep(env, cl, 20000);
-    }
-
-    return 0; /* to keep compiler happy */
-}
-
-/* Like XKeysymToKeycode, but ensures that keysym is the primary
- * symbol on the keycode returned.  Returns zero otherwise.
- */
-static int32_t
-keysym_to_keycode_if_primary(Display *dpy, KeySym sym)
-{
-    KeyCode code;
-    KeySym primary;
-
-    code = XKeysymToKeycode(dpy, sym);
-    if (code == 0) {
-        return 0;
-    }
-
-    primary = XKeycodeToKeysym(dpy, code, 0);
-    if (sym == primary) {
-        return code;
-    } else {
-        return 0;
-    }
-}
-/*
- * +kb or -kb ?
- */
-static Boolean
-isXKBenabled(Display *display) {
-    int mop, beve, berr;
-    /*
-     * NB: TODO: hope it will return False if XkbIgnoreExtension was called!
-     */
-    return XQueryExtension(display, "XKEYBOARD", &mop, &beve, &berr);
-}
-
-
-/* Assign meaning - alt, meta, etc. - to X modifiers mod1 ... mod5.
- * Only consider primary symbols on keycodes attached to modifiers.
- */
-static void
-setup_modifier_map(Display *disp)
-{
-    KeyCode metaL      = keysym_to_keycode_if_primary(disp, XK_Meta_L);
-    KeyCode metaR      = keysym_to_keycode_if_primary(disp, XK_Meta_R);
-    KeyCode altL       = keysym_to_keycode_if_primary(disp, XK_Alt_L);
-    KeyCode altR       = keysym_to_keycode_if_primary(disp, XK_Alt_R);
-    KeyCode numLock    = keysym_to_keycode_if_primary(disp, XK_Num_Lock);
-    KeyCode modeSwitch = keysym_to_keycode_if_primary(disp, XK_Mode_switch);
-    KeyCode shiftLock  = keysym_to_keycode_if_primary(disp, XK_Shift_Lock);
-    KeyCode capsLock   = keysym_to_keycode_if_primary(disp, XK_Caps_Lock);
-
-    XModifierKeymap *modmap = NULL;
-    int32_t nkeys, modn, i;
-    char *ptr = NULL;
-
-    DTRACE_PRINTLN("In setup_modifier_map");
-
-    modmap = XGetModifierMapping(disp);
-    nkeys = modmap->max_keypermod;
-
-    for (modn = Mod1MapIndex;
-         (modn <= Mod5MapIndex) &&
-             (awt_MetaMask == 0 || awt_AltMask == 0 ||
-              awt_NumLockMask == 0 || awt_ModeSwitchMask == 0);
-         ++modn)
-    {
-        static const uint32_t modmask[8] = {
-            ShiftMask, LockMask, ControlMask,
-            Mod1Mask, Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask
-        };
-
-
-        for (i = 0; i < nkeys; ++i) {
-            /* for each keycode attached to this modifier */
-            KeyCode keycode = modmap->modifiermap[modn * nkeys + i];
-            if (keycode == 0) {
-                continue;
-            }
-
-            if (awt_MetaMask == 0 && (keycode == metaL || keycode == metaR)) {
-                awt_MetaMask = modmask[modn];
-                DTRACE_PRINTLN2("    awt_MetaMask       = %d, modn = %d", awt_MetaMask, modn);
-                break;
-            } else if (awt_AltMask == 0 && (keycode == altL || keycode == altR)) {
-                awt_AltMask = modmask[modn];
-                DTRACE_PRINTLN2("    awt_AltMask        = %d, modn = %d", awt_AltMask, modn);
-                break;
-            } else if (awt_NumLockMask == 0 && keycode == numLock) {
-                awt_NumLockMask = modmask[modn];
-                DTRACE_PRINTLN2("    awt_NumLockMask    = %d, modn = %d", awt_NumLockMask, modn);
-                break;
-            } else if (awt_ModeSwitchMask == 0 && keycode == modeSwitch) {
-                awt_ModeSwitchMask = modmask[modn];
-                DTRACE_PRINTLN2("    awt_ModeSwitchMask = %d, modn = %d", awt_ModeSwitchMask, modn);
-                break;
-            }
-        }
-    }
-    for(i = 0; i < nkeys; i++) {
-        KeyCode keycode = modmap->modifiermap[LockMapIndex * nkeys + i];
-        if (keycode == 0) {
-            break;
-        }
-        if (keycode == shiftLock) {
-            awt_ModLockIsShiftLock = True;
-            break;
-        }
-        if (keycode == capsLock) {
-            break;
-        }
-    }
-
-    DTRACE_PRINTLN1("    ShiftMask          = %d", ShiftMask);
-    DTRACE_PRINTLN1("    ControlMask        = %d", ControlMask);
-
-    XFreeModifiermap(modmap);
-    ptr = getenv("_AWT_USE_TYPE4_PATCH");
-    if( ptr != NULL && ptr[0] != 0 ) {
-        if( strncmp("true", ptr, 4) == 0 ) {
-           awt_UseType4Patch = True;
-        }else if( strncmp("false", ptr, 5) == 0 ) {
-           awt_UseType4Patch = False;
-        }
-    }
-    awt_UseXKB = isXKBenabled(disp);
-
-}
-
-
-Boolean scrollBugWorkAround;
-
-
-void
-awt_output_flush()
-{
-    char c = 'p';
-
-    if (awt_next_flush_time == 0)
-    {
-        Boolean needsWakeup = False;
-        JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
-        if (awt_pipe_inited && (awt_get_poll_timeout(False) > (2*AWT_FLUSH_TIMEOUT))){
-            needsWakeup = True;
-        }
-        /* awt_next_flush_time affects awt_get_poll_timeout(), so set
-         * the variable *after* calling the function.
-         */
-        awt_next_flush_time = awtJNI_TimeMillis() + AWT_FLUSH_TIMEOUT;
-        if (needsWakeup)
-        {
-            /* write to the utility pipe to wake up the event
-             * loop, if it's sleeping
-             */
-            write ( AWT_WRITEPIPE, &c, 1 );
-        }
-    }
-#ifdef FLUSHDEBUG
-else
-jio_fprintf(stderr, "!");
-#endif
-} /* awt_output_flush() */
-
-void
-null_event_handler(Widget w, XtPointer client_data,
-                   XEvent * event, Boolean * cont)
-{
-    /* do nothing */
-}
-
-struct WidgetInfo *
-findWidgetInfo(Widget widget)
-{
-    struct WidgetInfo *cw;
-
-    for (cw = awt_winfo; cw != NULL; cw = cw->next) {
-        if (cw->widget == widget || cw->origin == widget) {
-            return cw;
-        }
-    }
-    return NULL;
-}
-
-void
-awt_addWidget(Widget w, Widget origin, void *peer, jlong event_flags)
-{
-    if (findWidgetInfo(w) != NULL) return;
-
-    if (!XtIsSubclass(w, xmFileSelectionBoxWidgetClass)) {
-        struct WidgetInfo *nw = (struct WidgetInfo *) malloc(sizeof(struct WidgetInfo));
-
-        if (nw) {
-            nw->widget     = w;
-            nw->origin     = origin;
-            nw->peer       = peer;
-            nw->event_mask = event_flags;
-            nw->next       = awt_winfo;
-            awt_winfo      = nw;
-
-            if (event_flags & java_awt_AWTEvent_MOUSE_EVENT_MASK) {
-                XtAddEventHandler(w,
-                                  ButtonPressMask | ButtonReleaseMask |
-                                  EnterWindowMask | LeaveWindowMask,
-                                  False, null_event_handler, NULL);
-                if (w != origin) {
-                    XtAddEventHandler(origin,
-                                      ButtonPressMask | ButtonReleaseMask |
-                                      EnterWindowMask | LeaveWindowMask,
-                                      False, null_event_handler, NULL);
-                }
-            }
-            if (event_flags & java_awt_AWTEvent_MOUSE_MOTION_EVENT_MASK) {
-                XtAddEventHandler(w,
-                                  PointerMotionMask,
-                                  False, null_event_handler, NULL);
-                if (w != origin) {
-                    XtAddEventHandler(origin,
-                                      PointerMotionMask,
-                                      False, null_event_handler, NULL);
-                }
-            }
-            if (event_flags & java_awt_AWTEvent_KEY_EVENT_MASK) {
-                XtAddEventHandler(w,
-                                  KeyPressMask | KeyReleaseMask,
-                                  False, null_event_handler, NULL);
-                if (w != origin) {
-                    XtAddEventHandler(origin,
-                                      KeyPressMask | KeyReleaseMask,
-                                      False, null_event_handler, NULL);
-                }
-            }
-        } else {
-            JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
-            JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
-        }
-
-    }
-}
-
-void
-awt_delWidget(Widget w)
-{
-    struct WidgetInfo *cw;
-
-    if (awt_winfo != NULL) {
-        if ((awt_winfo->widget == w) ||
-            (awt_winfo->origin == w)) {
-            cw = awt_winfo;
-            awt_winfo = awt_winfo->next;
-            free((void *) cw);
-        } else {
-            struct WidgetInfo *pw;
-
-            for (pw = awt_winfo, cw = awt_winfo->next;
-                 cw != NULL;
-                 pw = cw, cw = cw->next) {
-                if ((cw->widget == w) ||
-                    (cw->origin == w)) {
-                    pw->next = cw->next;
-                    free((void *) cw);
-                    break;
-                }
-            }
-        }
-    }
-}
-
-
-void *
-findPeer(Widget * pwidget)
-{
-    struct WidgetInfo   *cw;
-    Widget widgetParent;
-    void * peer;
-
-    if ((cw = findWidgetInfo(*pwidget)) != NULL) {
-        return cw->peer;
-    }
-    /* fix for 4053856, robi.khan@eng
-       couldn't find peer corresponding to widget
-       but the widget may be child of one with
-       a peer, so recurse up the hierarchy */
-    widgetParent = XtParent(*pwidget);
-    if (widgetParent != NULL ) {
-        peer = findPeer(&widgetParent);
-        if( peer != NULL ) {
-        /* found peer attached to ancestor of given
-           widget, so set widget return value as well */
-            *pwidget = widgetParent;
-            return peer;
-        }
-    }
-
-    return NULL;
-}
-
-Boolean
-awt_isAwtWidget(Widget widget)
-{
-    return (findWidgetInfo(widget) != NULL);
-}
-
-
-static Boolean
-awt_isAwtMenuWidget(Widget wdgt) {
-    struct MenuList* cur;
-
-    if (!XtIsSubclass(wdgt, xmRowColumnWidgetClass)) {
-        return False;
-    }
-    for (cur = menu_list; cur != NULL; cur = cur->next) {
-        if (cur->menu == wdgt) {
-            return True;
-        }
-    }
-    return False;
-}
-
-void
-awt_addMenuWidget(Widget wdgt) {
-    DASSERT(XtIsSubclass(wdgt, xmRowColumnWidgetClass));
-
-    if (!awt_isAwtMenuWidget(wdgt)) {
-        struct MenuList* ml = (struct MenuList*) malloc(sizeof(struct MenuList));
-        if (ml != NULL) {
-            ml->menu = wdgt;
-            ml->next = menu_list;
-            menu_list = ml;
-        } else {
-            JNIEnv* env = (JNIEnv*)JNU_GetEnv(jvm, JNI_VERSION_1_2);
-            JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
-        }
-    }
-}
-
-void
-awt_delMenuWidget(Widget wdgt) {
-    struct MenuList** pp;
-    struct MenuList* p;
-
-    DASSERT(XtIsSubclass(wdgt, xmRowColumnWidgetClass));
-
-    for (pp = &menu_list; *pp != NULL; pp = &((*pp)->next)) {
-        if ((*pp)->menu == wdgt) {
-            p = *pp;
-            *pp = (*pp)->next;
-            free((void*)p);
-            break;
-        }
-    }
-}
-
-
-static Widget
-getShellWidgetByPart(Widget part) {
-    int i;
-    for (i = 0; i < 3; i++) {
-        if (part == NULL) return NULL;
-        if (XtIsShell(part)) return part;
-        part = XtParent(part);
-    }
-    return NULL;
-}
-
-static Boolean
-isTheSameShellWidget(Widget shell, Widget w) {
-    Widget s1, s2;
-    if (shell == NULL || w == NULL) return False;
-    s1 = getShellWidgetByPart(shell);
-    s2 = getShellWidgetByPart(w);
-    if (s1 == s2 && s1 != NULL) {
-        return True;
-    } else {
-        return False;
-    }
-}
-
-static Boolean
-shouldDispatchToWidget(XEvent * xev)
-{
-  /* If this function returns False, that means that it has not pre-posted
-     this event to Java. The caller will then dispatch the event to Motif,
-     and our handlers will be called to post it to Java.
-     If this function returns true, then this function has posted this event
-     to java before returning. The caller will not dispatch it to Motif;
-     it will be dispatched to Motif via the putbackQueue after it has been
-     processed by Java */
-
-    Window win;
-    Widget widget = NULL;
-    struct WidgetInfo *winfo;
-    void *peer = NULL;
-    Boolean cont = FALSE;
-
-    switch (xev->type) {
-        case KeyPress:
-        case KeyRelease:
-            win = xev->xkey.window;
-            break;
-        case FocusIn:
-        case FocusOut:
-            win = xev->xfocus.window;
-            break;
-        case ButtonPress:
-        case ButtonRelease:
-            win = xev->xbutton.window;
-            break;
-        case MotionNotify:
-            win = xev->xmotion.window;
-            break;
-        case EnterNotify:
-        case LeaveNotify:
-            win = xev->xcrossing.window;
-            break;
-        default:
-            return False;
-    }
-
-    if ((widget = XtWindowToWidget(awt_display, win)) == NULL) {
-        return False;
-    }
-
-    if (xev->type == KeyPress || xev->type == KeyRelease) {
-        Widget focusWidget = XmGetFocusWidget(widget);
-
-        /* Fix for 4328561 by ibd@sparc.spb.su
-           If the widget is a Choice, the widget with focus is probably lying
-           outside the current widget's sub-hierarchy, so we have to go up the
-           hierarchy to reach it */
-
-        if ((focusWidget == NULL) && XmIsMenuShell(widget)) {
-            if ((widget = XtParent(widget)) != NULL) {
-                focusWidget = XmGetFocusWidget(widget);
-            } else {
-                return False;
-            }
-
-            /* In this case, focus widget should be CascadeButtonGadget type,
-               but we should send the events to its parent */
-            if (focusWidget != NULL && XmIsCascadeButtonGadget(focusWidget)) {
-                widget = XtParent(focusWidget);
-            } else {
-                /* If something went wrong, restore the original status */
-                widget = XtWindowToWidget(awt_display, win);
-            }
-        }
-
-        /* if focus owner is null, redirect key events to focused window */
-        if (focusWidget == NULL && findWidgetInfo(widget) == NULL) {
-            focusWidget = findTopLevelByShell(widget);
-        }
-
-        /* If we are on a non-choice widget, process events in a normal way */
-        if ((focusWidget != NULL) && (focusWidget != widget)) {
-            if (isTheSameShellWidget(focusWidget, widget)) {
-                focusWidget = findTopLevelByShell(widget);
-            }
-            if (focusWidget != NULL) {
-                peer = findPeer(&focusWidget);
-            }
-            if (peer != NULL) {
-                widget = focusWidget;
-                win = xev->xkey.window = XtWindow(focusWidget);
-            }
-        }
-    }
-
-    if ((winfo = findWidgetInfo(widget)) == NULL) {
-        return False;
-    }
-
-    /*
-     * Fix for bug 4145193
-     *
-     * If a menu is up (not just a popup menu), prevent awt components from
-     * getting any events until the menu is popped down.
-     * Before this fix, the fact that mouse/button events were
-     * preposted to the Java event queue was causing the ButtonRelease
-     * (needed to pop menu down) to be seen by the menu's parent and
-     * not the menu.
-     */
-    if (awtMenuIsActive()) {
-        Widget focusWidget = XmGetFocusWidget(widget);
-
-        if (focusWidget == NULL) {
-            return False;
-        }
-
-        /* If we are on a choice, dispatch the events to widget, but do not
-         * dispatch the events if we are on popped up menu.
-         */
-        if (!XmIsRowColumn(widget) || !XmIsCascadeButtonGadget(focusWidget)) {
-            /* Fix for 4328557 by ibd@sparc.spb.su
-             * If we are dragging mouse from choice and are currently outside
-             * of it, dispatch events to the choice - the source of dragging.
-             */
-
-            if ((drag_source != NULL) && (widget != drag_source) &&
-                (peer = findPeer(&drag_source))) {
-                awt_canvas_handleEvent(drag_source, peer, xev, winfo, &cont, TRUE);
-            }
-            return False;
-        }
-    }
-
-    /* If the keyboard is grabbed by a popup (such as a choice) during
-       a time when a focus proxy is in effect, the abovefocusIsOnMenu
-       test will not detect the sitation because the focus will be on
-       the proxy. But we need events to go to Motif first, so that the
-       grab can be undone when appropriate. */
-    if (keyboardGrabbed) {
-        return False;
-    }
-
-    /* If it's a keyboard event, we need to find the peer associated */
-    /* with the widget that has the focus rather than the widget */
-    /* associated with the window in the X event. */
-
-    switch (xev->type) {
-      case KeyPress:
-      case KeyRelease:
-          if (!(winfo->event_mask & java_awt_AWTEvent_KEY_EVENT_MASK))
-              return False;
-          break;
-        case FocusIn:
-        case FocusOut:
-            if (!(winfo->event_mask & java_awt_AWTEvent_FOCUS_EVENT_MASK))
-                return False;
-            break;
-        case ButtonPress:
-        case ButtonRelease:
-            if (!(winfo->event_mask & java_awt_AWTEvent_MOUSE_EVENT_MASK)) {
-                return False;
-            }
-            break;
-        case EnterNotify:
-        case LeaveNotify:
-            /*
-             * Do not post the enter/leave event if it's on a subwidget
-             * within the component.
-             */
-            if (!(winfo->event_mask & java_awt_AWTEvent_MOUSE_EVENT_MASK) ||
-                widget != winfo->origin)
-                return False;
-            break;
-        case MotionNotify:
-            if (!(winfo->event_mask & java_awt_AWTEvent_MOUSE_MOTION_EVENT_MASK))
-                return False;
-            break;
-        default:
-            return False;
-    }
-
-    peer = winfo->peer;
-
-    /* If we found a widget and a suitable peer (either the focus
-       peer above or the one associated with the widget then we
-       dispatch to it. */
-    if (peer == NULL) {
-        return False;
-    }
-
-    /*
-     * Fix for bug 4173714 - java.awt.button behaves differently under
-     * Win32/Solaris.
-     * Component should not get any events when it's disabled.
-     */
-    if (!XtIsSensitive(widget)) {
-        if (xev->type == EnterNotify) {
-            updateCursor(peer, CACHE_UPDATE);
-        }
-        return False;
-    }
-
-    awt_canvas_handleEvent(widget, peer, xev, winfo, &cont, TRUE);
-    return (!cont);
-} /* shouldDispatchToWidget() */
-
-
-void set_toolkit_busy(Boolean busy) {
-
-    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
-
-    static jclass awtAutoShutdownClass = NULL;
-    static jmethodID notifyBusyMethodID = NULL;
-    static jmethodID notifyFreeMethodID = NULL;
-
-    if (awtAutoShutdownClass == NULL) {
-        jclass awtAutoShutdownClassLocal = (*env)->FindClass(env, "sun/awt/AWTAutoShutdown");
-        if ((*env)->ExceptionOccurred(env)) {
-            (*env)->ExceptionDescribe(env);
-            (*env)->ExceptionClear(env);
-        }
-        DASSERT(awtAutoShutdownClassLocal != NULL);
-        if (awtAutoShutdownClassLocal == NULL) {
-            return;
-        }
-
-        awtAutoShutdownClass = (jclass)(*env)->NewGlobalRef(env, awtAutoShutdownClassLocal);
-        (*env)->DeleteLocalRef(env, awtAutoShutdownClassLocal);
-
-        notifyBusyMethodID = (*env)->GetStaticMethodID(env, awtAutoShutdownClass,
-                                                    "notifyToolkitThreadBusy", "()V");
-        if ((*env)->ExceptionOccurred(env)) {
-            (*env)->ExceptionDescribe(env);
-            (*env)->ExceptionClear(env);
-        }
-        notifyFreeMethodID = (*env)->GetStaticMethodID(env, awtAutoShutdownClass,
-                                                    "notifyToolkitThreadFree", "()V");
-        if ((*env)->ExceptionOccurred(env)) {
-            (*env)->ExceptionDescribe(env);
-            (*env)->ExceptionClear(env);
-        }
-        DASSERT(notifyBusyMethodID != NULL);
-        DASSERT(notifyFreeMethodID != NULL);
-        if (notifyBusyMethodID == NULL || notifyFreeMethodID == NULL) {
-            return;
-        }
-    } /* awtAutoShutdownClass == NULL*/
-
-    if (busy) {
-        (*env)->CallStaticVoidMethod(env, awtAutoShutdownClass,
-                                     notifyBusyMethodID);
-    } else {
-        (*env)->CallStaticVoidMethod(env, awtAutoShutdownClass,
-                                     notifyFreeMethodID);
-    }
-
-    if ((*env)->ExceptionOccurred(env)) {
-        (*env)->ExceptionDescribe(env);
-        (*env)->ExceptionClear(env);
-    }
-}
-
-#ifdef DEBUG
-static int32_t debugPrintLineCount = 0;   /* limit debug output per line */
-#endif
-
-/*
- * This is the main Xt event loop for the AWT.
- *
- * Because java applications are multithreaded, but X and Xt
- * are thread-dumb, we must make special considerations to
- * make ensure that the X/Xt libraries are not entered by
- * multiple threads simultaneously.
- *
- * The biggest difference between the standard Xt loop
- * and this loop is that we go to great lengths never to block
- * in the X libraries. We poll() on the X event pipe, waiting
- * for events, rather than simply calling XtAppNextEvent() and
- * blocking. If this thread were to block in XtAppNextEvent(),
- * no other thread could enter (e.g., to perform a paint or
- * retrieve data).
- */
-/* #ifdef DEBUG */
-    int32_t  numEventsHandled = 0;
-/* #endif */
-static void
-awt_MToolkit_loop(JNIEnv *env)
-{
-    XtInputMask iMask;
-    int32_t  fdXPipe = -1;              /* pipe where X events arrive */
-
-    /* only privileged thread should be running here */
-    DASSERT(awt_currentThreadIsPrivileged(env));
-
-    /* The pipe where X events arrive */
-    fdXPipe = ConnectionNumber(awt_display) ;
-
-    /* We execute events while locked, unlocking only when waiting
-     * for an event
-     */
-    AWT_LOCK();
-
-    /* Create the AWT utility pipe. See the comments on awt_pipe_init() */
-    awt_pipe_init();
-
-    /*
-     * Need to flush here in case data on the connection was read
-     * before we acquired the monitor.
-     *
-     * I don't get this, but I'm too chicken to remove it. -jethro 2Sep98
-     */
-    AWT_FLUSHOUTPUT_NOW();
-
-    /*
-     * ACTUALLY PROCESS EVENTS
-     */
-    while(True) {
-
-        /* process all events in the queue */
-/*      #ifdef DEBUG */
-/*          numEventsHandled = 0; */
-/*      #endif */
-        while (((iMask = awt_events_pending(awt_appContext)) & XtIMAll) > 0) {
-
-/*          #ifdef DEBUG */
-                ++numEventsHandled;
-/*          #endif */
-            processOneEvent(iMask);
-
-        }  /* end while awt_events_pending() */
-        /* At this point, we have exhausted the event queue */
-
-        /* print the number of events handled in parens */
-        DTRACE_PRINT1("(%d events)",(int32_t)numEventsHandled);
-#ifdef DEBUG
-        if (++debugPrintLineCount > 8) {
-            DTRACE_PRINTLN("");
-            debugPrintLineCount = 0;
-        }
-#endif
-
-        AWT_NOTIFY_ALL();               /* wake up modalWait() */
-
-        set_toolkit_busy(False);
-
-        /* Here, we wait for X events, outside of the X libs. When
-         * it's likely that an event is waiting, we process the queue
-         */
-        waitForEvents(env, fdXPipe, AWT_READPIPE);
-
-        set_toolkit_busy(True);
-
-    } /* while(True) */
-
-    /* If we ever exit the loop, must unlock the toolkit */
-
-} /* awt_MToolkit_loop() */
-
-/*
- * Creates the AWT utility pipe. This pipe exists solely so that
- * we can cause the main event thread to wake up from a poll() or
- * select() by writing to this pipe.
- */
-static void
-awt_pipe_init(void) {
-
-    if (awt_pipe_inited) {
-        return;
-    }
-
-    if ( pipe ( awt_pipe_fds ) == 0 )
-    {
-        /*
-        ** the write wakes us up from the infinite sleep, which
-        ** then we cause a delay of AWT_FLUSHTIME and then we
-        ** flush.
-        */
-        int32_t flags = 0;
-        awt_set_poll_timeout (def_poll_timeout);
-        /* set the pipe to be non-blocking */
-        flags = fcntl ( AWT_READPIPE, F_GETFL, 0 );
-        fcntl( AWT_READPIPE, F_SETFL, flags | O_NDELAY | O_NONBLOCK );
-        flags = fcntl ( AWT_WRITEPIPE, F_GETFL, 0 );
-        fcntl( AWT_WRITEPIPE, F_SETFL, flags | O_NDELAY | O_NONBLOCK );
-        awt_pipe_inited = True;
-    }
-    else
-    {
-        AWT_READPIPE = -1;
-        AWT_WRITEPIPE = -1;
-        awt_pipe_inited = False;
-    }
-} /* awt_pipe_init() */
-
-static Window
-proxyTopLevel(Window proxyWindow) {
-    Window parent = None, root = None, *children = NULL, retvalue = None;
-    uint32_t nchildren = 0;
-    Status res = XQueryTree(awt_display, proxyWindow, &root, &parent,
-             &children, &nchildren);
-    if (res != 0) {
-        if (nchildren > 0) {
-            retvalue = children[0];
-        }
-        else retvalue = None;
-        if (children != NULL) {
-            XFree(children);
-        }
-        return retvalue;
-    } else {
-        return None;
-    }
-}
-
-static jclass clazzF, clazzD = NULL;
-
-static Boolean
-initClazzD(JNIEnv *env) {
-    jclass t_clazzD = (*env)->FindClass(env, "java/awt/Dialog");
-    if ((*env)->ExceptionOccurred(env)) {
-        (*env)->ExceptionDescribe(env);
-        (*env)->ExceptionClear(env);
-    }
-    DASSERT(t_clazzD != NULL);
-    if (t_clazzD == NULL) {
-        return False;
-    }
-    clazzD = (*env)->NewGlobalRef(env, t_clazzD);
-    DASSERT(clazzD != NULL);
-    (*env)->DeleteLocalRef(env, t_clazzD);
-    return True;
-}
-
-Boolean
-isFrameOrDialog(jobject target, JNIEnv *env) {
-    if ((*env)->EnsureLocalCapacity(env, 1) < 0) {
-        return False;
-    }
-
-    if (clazzF == NULL) {
-        jclass t_clazzF = (*env)->FindClass(env, "java/awt/Frame");
-        if ((*env)->ExceptionOccurred(env)) {
-            (*env)->ExceptionDescribe(env);
-            (*env)->ExceptionClear(env);
-        }
-        DASSERT(t_clazzF != NULL);
-        if (t_clazzF == NULL) {
-            return False;
-        }
-        clazzF = (*env)->NewGlobalRef(env, t_clazzF);
-        DASSERT(clazzF != NULL);
-        (*env)->DeleteLocalRef(env, t_clazzF);
-    }
-
-    if (clazzD == NULL && !initClazzD(env)) {
-        return False;
-    }
-
-    return (*env)->IsInstanceOf(env, target, clazzF) ||
-        (*env)->IsInstanceOf(env, target, clazzD);
-}
-
-Boolean
-isDialog(jobject target, JNIEnv *env) {
-    if (clazzD == NULL && !initClazzD(env)) {
-        return False;
-    }
-    return (*env)->IsInstanceOf(env, target, clazzD);
-}
-
-// Returns a local ref to a decorated owner of the target,
-// or NULL if the target is Frame or Dialog itself.
-// The local ref returned should be deleted by the caller.
-jobject
-getOwningFrameOrDialog(jobject target, JNIEnv *env) {
-    jobject _target = (*env)->NewLocalRef(env, target);
-    jobject parent = _target;
-    Boolean isSelfFrameOrDialog = True;
-
-    while (!isFrameOrDialog(parent, env)) {
-        isSelfFrameOrDialog = False;
-        parent = (*env)->CallObjectMethod(env, _target, componentIDs.getParent);
-        (*env)->DeleteLocalRef(env, _target);
-        _target = parent;
-    }
-
-    if (isSelfFrameOrDialog) {
-        (*env)->DeleteLocalRef(env, parent);
-        return NULL;
-    }
-    return parent;
-}
-
-Widget
-findWindowsProxy(jobject window, JNIEnv *env) {
-    struct ComponentData *cdata;
-    jobject tlPeer;
-    jobject owner_prev = NULL, owner_new = NULL;
-    /* the owner of a Window is in its parent field */
-    /* we may have a chain of Windows; go up the chain till we find the
-       owning Frame or Dialog */
-    if ((*env)->EnsureLocalCapacity(env, 4) < 0) {
-        return NULL;
-    }
-
-    if (window == NULL) return NULL;
-
-    owner_prev = (*env)->NewLocalRef(env, window);
-    while (!JNU_IsNull(env, owner_prev) && !(isFrameOrDialog(owner_prev, env))) {
-        owner_new = (*env)->CallObjectMethod(env, owner_prev, componentIDs.getParent);
-        (*env)->DeleteLocalRef(env, owner_prev);
-        owner_prev = owner_new;
-    }
-
-    if (owner_prev == NULL) return NULL;
-
-    tlPeer = (*env)->GetObjectField(env, owner_prev, componentIDs.peer);
-    (*env)->DeleteLocalRef(env, owner_prev);
-    if (tlPeer == NULL) return NULL;
-
-    cdata = (struct ComponentData *)
-        JNU_GetLongFieldAsPtr(env, tlPeer, mComponentPeerIDs.pData);
-    (*env)->DeleteLocalRef(env, tlPeer);
-
-    if (cdata == NULL) return NULL;
-    return(findFocusProxy(cdata->widget));
-}
-
-jobject
-findTopLevel(jobject peer, JNIEnv *env) {
-    jobject target_prev = NULL;
-    static jclass clazzW = NULL;
-
-    if ((*env)->EnsureLocalCapacity(env, 3) < 0) {
-        return NULL;
-    }
-
-    if (clazzW == NULL) {
-        jclass t_clazzW = (*env)->FindClass(env, "java/awt/Window");
-        if ((*env)->ExceptionOccurred(env)) {
-            (*env)->ExceptionDescribe(env);
-            (*env)->ExceptionClear(env);
-        }
-        DASSERT(t_clazzW != NULL);
-        if (t_clazzW == NULL) {
-            return NULL;
-        }
-        clazzW = (*env)->NewGlobalRef(env, t_clazzW);
-        DASSERT(clazzW != NULL);
-        (*env)->DeleteLocalRef(env, t_clazzW);
-    }
-    target_prev = (*env)->GetObjectField(env, peer, mComponentPeerIDs.target);
-    if (target_prev == NULL) {
-        return NULL;
-    }
-
-    while ((target_prev != NULL)
-           && !(*env)->IsInstanceOf(env, target_prev, clazzW) )
-    {
-        /* go up the hierarchy until we find a window */
-        jobject target_new = (*env)->CallObjectMethod(env, target_prev, componentIDs.getParent);
-        (*env)->DeleteLocalRef(env, target_prev);
-        target_prev = target_new;
-    }
-    return target_prev;
-}
-
-static Window
-rootWindow(Window w) {
-    Window root = None;
-    Window parent = None;
-    Window *children = NULL;
-    uint32_t nchildren = 0;
-
-    if (w != None) {
-        Status res = XQueryTree(awt_display, w, &root, &parent, &children, &nchildren);
-        if (res == 0) {
-            return None;
-        }
-        if (children != NULL) {
-            XFree(children);
-        }
-  return root;
-    } else {
-        return None;
-    }
-}
-
-Boolean IsRootOf(Window root, Window child) {
-    Window w_root = None, w_parent = None, * children = NULL;
-    uint32_t c_count = 0;
-    if (root == None || child == None) {
-        return False;
-    }
-    do {
-        w_root = None;
-        w_parent = None;
-        children = NULL;
-        c_count = 0;
-        if (XQueryTree(awt_display, child, &w_root, &w_parent,
-                       &children, &c_count)) {
-            if (children != NULL) {
-                XFree(children);
-            }
-            if (w_parent == None) {
-                return False;
-            }
-            if (w_parent == root) {
-                return True;
-            }
-        } else {
-            return False;
-        }
-        child = w_parent;
-    } while (True);
-}
-
-Window findShellByProxy(Window proxy) {
-    Widget proxy_wid = XtWindowToWidget(awt_display, proxy);
-    while (proxy_wid != NULL && !XtIsShell(proxy_wid)) {
-        proxy_wid = XtParent(proxy_wid);
-    }
-    if (proxy_wid == NULL) {
-        return None;
-    }
-    return XtWindow(proxy_wid);
-}
-
-// Window which contains focus owner when focus proxy is enabled
-Window trueFocusWindow = None;
-// Window which works as proxy for input events for real focus owner.
-Window focusProxyWindow = None;
-
-void clearFocusPathOnWindow(Window win) {
-    if (focusProxyWindow != None && IsRootOf(win, trueFocusWindow)) {
-        XEvent ev;
-        memset(&ev, 0, sizeof(ev));
-        ev.type = FocusOut;
-        ev.xany.send_event = True;
-        ev.xany.display = awt_display;
-        ev.xfocus.mode = NotifyNormal;
-        ev.xfocus.detail = NotifyNonlinear;
-        {
-            Window root = rootWindow(trueFocusWindow);
-            JNIEnv *env = (JNIEnv *) JNU_GetEnv(jvm, JNI_VERSION_1_2);
-            ev.xfocus.window = trueFocusWindow;
-            while (ev.xfocus.window != root &&
-                   ev.xfocus.window != None) {
-                Widget w = XtWindowToWidget(awt_display,
-                                            ev.xfocus.window);
-                awt_put_back_event(env, &ev);
-                if (w == NULL) {
-                    break;
-                }
-                if (XtParent(w) != NULL) {
-                    ev.xfocus.window = XtWindow(XtParent(w));
-                } else {
-                    ev.xfocus.window = None;
-                }
-            }
-        }
-        XSetInputFocus(awt_display, findShellByProxy(focusProxyWindow), RevertToPointerRoot, CurrentTime);
-        trueFocusWindow = None;
-        focusProxyWindow = None;
-    }
-}
-void clearFocusPath(Widget shell) {
-    Window w = None;
-    if (shell == NULL) {
-        return;
-    }
-    w = XtWindow(shell);
-    clearFocusPathOnWindow(w);
-}
-
-void globalClearFocusPath(Widget focusOwnerShell ) {
-    if (focusProxyWindow != None) {
-        Window shellWindow = findShellByProxy(trueFocusWindow);
-        if (shellWindow != None) {
-            Widget shell = XtWindowToWidget(awt_display, shellWindow);
-            if (shell != NULL && shell != focusOwnerShell) {
-                clearFocusPath(shell);
-            }
-        }
-    }
-}
-
-static void
-focusEventForProxy(XEvent xev,
-                   JNIEnv *env,
-                   Window *trueFocusWindow,
-                   Window *focusProxyWindow) {
-
-    DASSERT (trueFocusWindow != NULL && focusProxyWindow != NULL);
-  if (xev.type == FocusOut) {
-    if (xev.xfocus.window == *focusProxyWindow) {
-            if (*trueFocusWindow != None) {
-                Window root = rootWindow(*trueFocusWindow);
-      focusOutEvent.xfocus.window = *trueFocusWindow;
-#ifdef DEBUG_FOCUS
-      printf(" nulling out proxy; putting back event"
-             "\n");
-#endif
-
-      while (focusOutEvent.xfocus.window != root &&
-             focusOutEvent.xfocus.window != None) {
-        Widget w = XtWindowToWidget(awt_display,
-                                    focusOutEvent.xfocus.window);
-        awt_put_back_event(env, &focusOutEvent);
-        if (w != NULL && XtParent(w) != NULL) {
-          focusOutEvent.xfocus.window = XtWindow(XtParent(w));
-        } else {
-          focusOutEvent.xfocus.window = None;
-        }
-      }
-      *trueFocusWindow = None;
-      *focusProxyWindow = None;
-      return;
-    } else {
-#ifdef DEBUG_FOCUS
-      printf("\n");
-#endif
-      return;
-    }
-  } else {
-#ifdef DEBUG_FOCUS
-    printf("\n");
-#endif
-    return;
-  }
-    }
-}
-
-static void
-focusEventForFrame(XEvent xev, Window focusProxyWindow) {
-  if (xev.type == FocusIn) {
-    if (focusProxyWindow != None) {
-      /* eat it */
-      return;
-    } else /* FocusIn on Frame or Dialog */ {
-      XtDispatchEvent(&xev);
-    }
-  } else /* FocusOut on Frame or Dialog */{
-    XtDispatchEvent(&xev);
-  }
-}
-
-static void
-focusEventForWindow(XEvent xev, JNIEnv *env, Window *trueFocusWindow,
-                    Window *focusProxyWindow, jobject target) {
-  XEvent pev;
-  if (xev.type == FocusIn && xev.xfocus.mode == NotifyNormal) {
-    /* If it's a FocusIn, allow it to process, then set
-       focus to focus proxy */
-    Widget focusProxy;
-    focusProxy = findWindowsProxy(target, env);
-    if (focusProxy != NULL) {
-      XtDispatchEvent(&xev);
-      *focusProxyWindow = XtWindow(focusProxy);
-
-      XSetInputFocus(awt_display, *focusProxyWindow,
-                     RevertToParent,
-                     CurrentTime);
-
-      XPeekEvent(awt_display, &pev);
-      while (pev.type == FocusIn) {
-        XNextEvent(awt_display, &xev);
-        XPeekEvent(awt_display, &pev);
-      }
-      *trueFocusWindow = xev.xany.window;
-
-    } /* otherwise error */
-  } else /* FocusOut */ {
-    /* If it's a FocusOut on a Window, discard it unless
-       it's an event generated by us. */
-    if (xev.xany.send_event) {
-      XtDispatchEvent(&xev);
-    }
-  }
-}
-
-Boolean
-isAncestor(Window ancestor, Window child) {
-  Window *children;
-  uint32_t nchildren;
-  Boolean retvalue = False;
-
-  while (child != ancestor) {
-    Window parent, root;
-    Status status;
-
-    status = XQueryTree(awt_display, child, &root, &parent,
-                        &children, &nchildren);
-    if (status == 0) return False; /* should be an error of some sort? */
-
-    if (parent == root) {
-      if (child != ancestor) {
-        retvalue = False;
-        break;
-      } else {
-        retvalue = True;
-        break;
-      }
-    }
-    if (parent == ancestor) { retvalue = True; break; }
-    if (nchildren > 0) XFree(children);
-    child = parent;
-  }
-  if (nchildren > 0) XFree(children);
-  return retvalue;
-}
-
-/**
- * Returns focusability of the corresponding Java Window object
- */
-Boolean
-isFocusableWindow(Window w) {
-    Widget wid = NULL;
-    JNIEnv *env = (JNIEnv *) JNU_GetEnv(jvm, JNI_VERSION_1_2);
-
-    wid = XtWindowToWidget(awt_display, w);
-    while (wid != NULL && !XtIsShell(wid)) {
-        wid = XtParent(wid);
-    }
-
-    // If the window doesn't have shell consider it focusable as all windows
-    // are focusable by default
-    if (wid == NULL) return True;
-
-    return isFocusableWindowByShell(env, wid);
-}
-
-void postUngrabEvent(Widget shell) {
-    JNIEnv *env = (JNIEnv *) JNU_GetEnv(jvm, JNI_VERSION_1_2);
-    Widget canvas = findTopLevelByShell(shell);
-    if (canvas != NULL) {
-        jobject peer = findPeer(&canvas);
-        if (peer != NULL) {
-            JNU_CallMethodByName(env, NULL, peer, "postUngrabEvent", "()V", NULL);
-        }
-    }
-}
-
-Boolean eventInsideGrabbed(XEvent * ev) {
-    if (grabbed_widget == NULL) {
-        return False;
-    }
-
-    switch (ev->xany.type) {
-      case LeaveNotify:
-      case ButtonPress:
-      case ButtonRelease:
-      case MotionNotify:
-      case EnterNotify:
-      {
-          JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
-          Widget grab = findTopLevelByShell(grabbed_widget);
-          if (grab != NULL) {
-              jobject peer = findPeer(&grab);
-              Widget target = XtWindowToWidget(awt_display, ev->xbutton.window);
-              jobject targetPeer = findPeer(&target);
-              if (peer != NULL) {
-                  return JNU_CallMethodByName(env, NULL, peer, "processUngrabMouseEvent", "(Lsun/awt/motif/MComponentPeer;III)Z",
-                                              targetPeer, ev->xbutton.x_root, ev->xbutton.y_root,
-                                              ev->xany.type, NULL).z;
-              }
-          }
-          return False;
-      }
-      case FocusOut:
-          if (ev->xfocus.window == XtWindow(grabbed_widget) ||
-              isAncestor(XtWindow(grabbed_widget), ev->xfocus.window))
-          {
-              postUngrabEvent(grabbed_widget);
-              return True;
-          }
-      default:
-          return True;
-    }
-}
-
-/**
- * Processes and removes one X/Xt event from the Xt event queue.
- * Handles events pushed back via awt_put_back_event() FIRST,
- * then new events on the X queue
- */
-static void
-processOneEvent(XtInputMask iMask) {
-            XEvent xev;
-            Boolean haveEvent = False;
-            if (putbackQueueCount > 0) {
-                // There is a pushed-back event - handle it first
-                if (awt_get_next_put_back_event(&xev) == 0) {
-                    if (xev.xany.send_event != SPECIAL_KEY_EVENT) {
-#ifdef DEBUG_FOCUS
-                        if (xev.type == FocusOut) {
-                            printf("putback FocusOut on window %d, mode %d, "
-                                   "detail %d, send_event  %d\n",
-                                   xev.xfocus.window, xev.xfocus.mode,
-                                   xev.xfocus.detail, xev.xfocus.send_event);
-                        }
-#endif
-                        eventNumber++;
-                        XtDispatchEvent(&xev);
-                        return;
-                    } else {
-                        haveEvent = True;
-                    }
-                }
-            }
-
-            if (haveEvent || XtAppPeekEvent(awt_appContext, &xev)) {
-             /*
-              * Fix for BugTraq ID 4041235, 4100167:
-              * First check that the event still has a widget, because
-              * the widget may have been destroyed by another thread.
-              */
-              Widget widget=XtWindowToWidget(awt_display, xev.xany.window);
-              eventNumber++;
-#ifdef __linux__
-              statusWindowEventHandler(xev);
-#endif
-              xembed_eventHandler(&xev);
-              xembed_serverEventHandler(&xev);
-              syncWait_eventHandler(&xev);
-
-              if (!haveEvent && awt_dnd_process_event(&xev)) {
-                  return;
-              }
-
-              if ((widget == NULL) || (!XtIsObject(widget)) ||
-                  (widget->core.being_destroyed)) {
-                /*
-                 * if we get here, the event could be one of
-                 * the following:
-                 * - notification that a "container" of
-                 *    any of our embedded frame has been moved
-                 * - event understandable by XFilterEvent
-                 * - for one of our old widget which has gone away
-                 */
-                XNextEvent(awt_display, &xev);
-
-                if (widget == NULL) {
-                    /* an embedded frame container has been moved? */
-                    if (awt_util_processEventForEmbeddedFrame(&xev)) {
-                        return;
-                    }
-
-                    /* manager selections related event? */
-                    if (awt_mgrsel_processEvent(&xev)) {
-                        return;
-                    }
-                }
-
-                /*
-                 * Fix for BugTraq ID 4196573:
-                 * Call XFilterEvent() to give a chance to X Input
-                 * Method to process this event before being
-                 * discarded.
-                 */
-                (void) XFilterEvent(&xev, NULL);
-                return;
-              }
-
-              /* There is an X event on the queue. */
-              switch (xev.type) {
-              case KeyPress:
-              case KeyRelease:
-              case ButtonPress:
-              case ButtonRelease:
-              case MotionNotify:
-              case EnterNotify:
-              case LeaveNotify:
-                /* Fix for BugTraq ID 4048060. Dispatch scrolling events
-                   immediately to the ScrollBar widget to prevent spurious
-                   continuous scrolling. Otherwise, if the application is busy,
-                   the ButtonRelease event is not dispatched in time to prevent
-                   a ScrollBar timeout from expiring, and restarting the
-                   continuous scrolling timer.
-                   */
-                  if ((xev.type == ButtonPress                          ||
-                       xev.type == ButtonRelease                                ||
-                       (xev.type == MotionNotify                                &&
-                        (xev.xmotion.state == Button1Mask                       ||
-                         xev.xmotion.state == Button2Mask                       ||
-                         xev.xmotion.state == Button3Mask)))            &&
-                      (XtIsSubclass(widget, xmScrollBarWidgetClass))) {
-                      /* Use XNextEvent instead of XtAppNextEvent, because
-                         XtAppNextEvent processes timers before getting the next X
-                         event, causing a race condition, since the TimerEvent
-                         callback in the ScrollBar widget restarts the continuous
-                         scrolling timer.
-                      */
-                      XNextEvent(awt_display, &xev);
-
-                      XtDispatchEvent(&xev);
-                      XSync(awt_display, False);
-
-                      // This is the event on scrollbar.  Key, Motion,
-                      // Enter/Leave dispatch as usual, Button should
-                      // generate Ungrab after Java mouse event
-                      if (xev.type == ButtonPress && grabbed_widget != NULL) {
-                          eventInsideGrabbed(&xev);
-                      }
-                  }
-                  else {
-                      if (!haveEvent) XtAppNextEvent(awt_appContext, &xev);
-
-                      // This is an event on one of our widgets.  Key,
-                      // Motion, Enter/Leave dispatch as usual, Button
-                      // should generate Ungrab after Java mouse event
-/*                       if (grabbed_widget != NULL && !eventInsideGrabbed(&xev)) { */
-/*                           return; */
-/*                       } */
-
-                      if (xev.type == ButtonPress) {
-                          Window window = findShellByProxy(xev.xbutton.window);
-                          if (window != None) {
-                              XWindowAttributes winAttr;
-                              memset(&winAttr, 0, sizeof(XWindowAttributes));
-                              XGetWindowAttributes(awt_display, window, &winAttr);
-                              if (winAttr.override_redirect == TRUE && isFocusableWindow(window)) {
-                                  XSetInputFocus(awt_display, window, RevertToPointerRoot, CurrentTime);
-                              }
-                          }
-                      }
-                      if(xev.type == KeyPress) {
-#ifdef DEBUG_FOCUS
-                          printf("KeyPress on window %d\n", xev.xany.window);
-#endif
-                      }
-
-                    /* this could be moved to shouldDispatchToWidget */
-                    /* if there is a proxy in effect, dispatch key events
-                       through the proxy */
-                    if ((xev.type == KeyPress || xev.type == KeyRelease) &&
-                        !keyboardGrabbed && !haveEvent) {
-                        if (focusProxyWindow != None) {
-                            Widget widget;
-                            struct WidgetInfo *winfo;
-                            Boolean cont;
-                            /* Key event should be posted to the top-level
-                               widget of the proxy */
-                            xev.xany.window = proxyTopLevel(focusProxyWindow);
-                            widget = XtWindowToWidget(awt_display,
-                                                      xev.xany.window);
-                            if (widget == NULL) return;
-                            if ((winfo = findWidgetInfo(widget)) == NULL) {
-                                return;
-                            }
-                            awt_canvas_handleEvent(widget, winfo->peer, &xev,
-                                                   winfo, &cont, TRUE);
-                            return;
-                        }
-                    }
-                    if (!shouldDispatchToWidget(&xev)) {
-                        XtDispatchEvent(&xev);
-                    }
-
-                    // See comment above - "after time" is here.
-                    if (grabbed_widget != NULL && xev.type == ButtonPress) {
-                        eventInsideGrabbed(&xev);
-                    }
-                }
-
-
-              break;
-
-              case FocusIn:
-              case FocusOut: {
-                  void *peer;
-                  jobject target;
-
-                  JNIEnv *env = (JNIEnv *) JNU_GetEnv(jvm, JNI_VERSION_1_2);
-
-#ifdef DEBUG_FOCUS
-                  if (xev.type == FocusIn) {
-
-                      fprintf(stderr, "FocusIn on window %x, mode %d, detail %d, "
-                             "send_event %d\n", xev.xfocus.window,
-                             xev.xfocus.mode, xev.xfocus.detail,
-                             xev.xfocus.send_event);
-                  } else {
-                      fprintf(stderr, "FocusOut on window %x, mode %d, detail %d, "
-                             "send_event %d\n", xev.xfocus.window,
-                             xev.xfocus.mode, xev.xfocus.detail,
-                             xev.xfocus.send_event);
-                  }
-#endif
-                  XtAppNextEvent(awt_appContext, &xev);
-
-                  if (xev.xfocus.detail == NotifyVirtual ||
-                      xev.xfocus.detail == NotifyNonlinearVirtual) {
-#ifdef DEBUG_FOCUS
-                      printf("discarding\n");
-#endif
-                      return;
-                  }
-
-                  // Check for xembed on this window. If it is active and this is not XEmbed focus
-                  // event(send_event = 0) then we should skip it
-                  if (isXEmbedActiveByWindow(xev.xfocus.window) && !xev.xfocus.send_event) {
-                      return;
-                  }
-
-                  /* In general, we need to to block out focus events
-                     that are caused by keybaord grabs initiated by
-                     dragging the title bar or the scrollbar. But we
-                     need to let through the ones that are aimed at
-                     choice boxes or menus. So we keep track of when
-                     the keyboard is grabbed by a popup. */
-
-                  if (awt_isAwtMenuWidget(widget)) {
-                    if (xev.type == FocusIn &&
-                        xev.xfocus.mode == NotifyGrab) {
-                          extern Boolean poppingDown;
-                          if (!poppingDown) {
-                      keyboardGrabbed = True;
-                           }
-                      } else /* FocusOut */ {
-                          if (xev.type == FocusOut &&
-                              xev.xfocus.mode == NotifyUngrab) {
-                        keyboardGrabbed = False;
-                      }
-                    }
-                  }
-
-                  if (focusProxyWindow != None) {
-#ifdef DEBUG_FOCUS
-                      printf("non-null proxy; proxy = %d ", focusProxyWindow);
-#endif
-                      if (trueFocusWindow != None) {
-                        /* trueFocusWindow should never be None here, but if
-                           things ever get skewed, we want to be able to
-                           recover rather than crash */
-                        focusEventForProxy(xev, env, &trueFocusWindow,
-                                           &focusProxyWindow);
-                      return;
-                      } else {
-                        /* beartrap -- remove before shipping */
-                        /* printf("trueFocusWindow None in processOneEvent;\n"); */
-                        /* printf("Please file a bug\n"); */
-                      }
-                  }
-
-                  peer = findPeer(&widget);
-                  if (peer == NULL) {
-#ifdef DEBUG_FOCUS
-                      printf("null peer -- shouldn't see in java handler\n");
-#endif
-                      XtDispatchEvent(&xev);
-                      return;
-                  }
-
-                  /* Find the top-level component */
-
-                  if ((*env)->EnsureLocalCapacity(env, 1) < 0) {
-                    return;
-                  }
-                  target = findTopLevel(peer, env);
-                  if (target == NULL) {
-                      JNU_ThrowNullPointerException(env, "component without a "
-                                                    "window");
-                      return;
-                  }
-
-                  if (isFrameOrDialog(target, env)) {
-#ifdef DEBUG_FOCUS
-                      printf("Focus event directed at a frame; frame = %d\n",
-                             xev.xany.window);
-#endif
-                      focusEventForFrame(xev, focusProxyWindow);
-                      (*env)->DeleteLocalRef(env, target);
-                      return;
-                  } else {
-#ifdef DEBUG_FOCUS
-                      printf("Focus event directed at a window; window = %d\n",
-                             xev.xany.window);
-#endif
-                      focusEventForWindow(xev, env, &trueFocusWindow,
-                                          &focusProxyWindow, target);
-                      (*env)->DeleteLocalRef(env, target);
-                      return;
-                  }
-              }
-
-              case UnmapNotify:
-#ifdef DEBUG_FOCUS
-                printf("Unmap on window %d\n", xev.xany.window);
-                printf("True focus window is %d\n", trueFocusWindow);
-#endif
-                clearFocusPathOnWindow(xev.xunmap.window);
-
-              default:
-                XtAppProcessEvent(awt_appContext, iMask);
-                break;
-              }
-            }
-            else {
-              /* There must be a timer, alternate input, or signal event. */
-              XtAppProcessEvent(awt_appContext, iMask & ~XtIMXEvent);
-            }
-
-} /* processOneEvent() */
-
-/*
- * Waits for X/Xt events to appear on the pipe. Returns only when
- * it is likely (but not definite) that there are events waiting to
- * be processed.
- *
- * This routine also flushes the outgoing X queue, when the
- * awt_next_flush_time has been reached.
- *
- * If fdAWTPipe is greater or equal than zero the routine also
- * checks if there are events pending on the putback queue.
- */
-void
-waitForEvents(JNIEnv *env, int32_t fdXPipe, int32_t fdAWTPipe) {
-
-        while ((fdAWTPipe >= 0 && awt_events_pending(awt_appContext) == 0) ||
-               (fdAWTPipe <  0 && XtAppPending(awt_appContext) == 0)) {
-#ifdef USE_SELECT
-            performSelect(env,fdXPipe,fdAWTPipe);
-#else
-            performPoll(env,fdXPipe,fdAWTPipe);
-#endif
-            if ((awt_next_flush_time > 0) &&
-                (awtJNI_TimeMillis() > awt_next_flush_time)) {
-                AWT_FLUSHOUTPUT_NOW();
-            }
-        }  /* end while awt_events_pending() == 0 */
-} /* waitForEvents() */
-
-/*************************************************************************
- **                                                                     **
- ** WE USE EITHER select() OR poll(), DEPENDING ON THE USE_SELECT       **
- ** COMPILE-TIME CONSTANT.                                              **
- **                                                                     **
- *************************************************************************/
-
-#ifdef USE_SELECT
-
-static struct fd_set rdset;
-struct timeval sel_time;
-
-/*
- * Performs select() on both the X pipe and our AWT utility pipe.
- * Returns when data arrives or the operation times out.
- *
- * Not all Xt events come across the X pipe (e.g., timers
- * and alternate inputs), so we must time out every now and
- * then to check the Xt event queue.
- *
- * The fdAWTPipe will be empty when this returns.
- */
-static void
-performSelect(JNIEnv *env, int32_t fdXPipe, int32_t fdAWTPipe) {
-
-            int32_t result;
-            int32_t count;
-            int32_t nfds = 1;
-            uint32_t timeout = awt_get_poll_timeout(False);
-
-            /* Fixed 4250354 7/28/99 ssi@sparc.spb.su
-             * Cleaning up Global Refs in case of No Events
-             */
-            awtJNI_CleanupGlobalRefs();
-
-            FD_ZERO( &rdset );
-            FD_SET(fdXPipe, &rdset);
-            if (fdAWTPipe >= 0) {
-                nfds++;
-                FD_SET(fdAWTPipe, &rdset);
-            }
-            if (timeout == 0) {
-                // be sure other threads get a chance
-                awtJNI_ThreadYield(env);
-            }
-            // set the appropriate time values. The DASSERT() in
-            // MToolkit_run() makes sure that this will not overflow
-            sel_time.tv_sec = (timeout * 1000) / (1000 * 1000);
-            sel_time.tv_usec = (timeout * 1000) % (1000 * 1000);
-            AWT_NOFLUSH_UNLOCK();
-            result = select(nfds, &rdset, 0, 0, &sel_time);
-            AWT_LOCK();
-
-            /* reset tick if this was not a time out */
-            if (result == 0) {
-                /* select() timed out -- update timeout value */
-                awt_get_poll_timeout(True);
-            }
-            if (fdAWTPipe >= 0 && FD_ISSET ( fdAWTPipe, &rdset ) )
-            {
-                /* There is data on the AWT pipe - empty it */
-                do {
-                    count = read(fdAWTPipe, read_buf, AWT_POLL_BUFSIZE );
-                } while (count == AWT_POLL_BUFSIZE );
-            }
-} /* performSelect() */
-
-#else /* !USE_SELECT */
-
-/*
- * Polls both the X pipe and our AWT utility pipe. Returns
- * when there is data on one of the pipes, or the operation times
- * out.
- *
- * Not all Xt events come across the X pipe (e.g., timers
- * and alternate inputs), so we must time out every now and
- * then to check the Xt event queue.
- *
- * The fdAWTPipe will be empty when this returns.
- */
-static void
-performPoll(JNIEnv *env, int32_t fdXPipe, int32_t fdAWTPipe) {
-
-            static struct pollfd pollFds[2];
-            uint32_t timeout = awt_get_poll_timeout(False);
-            int32_t result;
-            int32_t count;
-
-            /* Fixed 4250354 7/28/99 ssi@sparc.spb.su
-             * Cleaning up Global Refs in case of No Events
-             */
-            awtJNI_CleanupGlobalRefs();
-
-            pollFds[0].fd = fdXPipe;
-            pollFds[0].events = POLLRDNORM;
-            pollFds[0].revents = 0;
-
-            pollFds[1].fd = fdAWTPipe;
-            pollFds[1].events = POLLRDNORM;
-            pollFds[1].revents = 0;
-
-            AWT_NOFLUSH_UNLOCK();
-
-            /* print the poll timeout time in brackets */
-            DTRACE_PRINT1("[%dms]",(int32_t)timeout);
-#ifdef DEBUG
-            if (++debugPrintLineCount > 8) {
-                DTRACE_PRINTLN("");
-                debugPrintLineCount = 0;
-            }
-#endif
-            /* ACTUALLY DO THE POLL() */
-            if (timeout == 0) {
-                // be sure other threads get a chance
-                awtJNI_ThreadYield(env);
-            }
-            result = poll( pollFds, 2, (int32_t) timeout );
-
-#ifdef DEBUG
-            DTRACE_PRINT1("[poll()->%d]", result);
-            if (++debugPrintLineCount > 8) {
-                DTRACE_PRINTLN("");
-                debugPrintLineCount = 0;
-            }
-#endif
-            AWT_LOCK();
-            if (result == 0) {
-                /* poll() timed out -- update timeout value */
-                awt_get_poll_timeout(True);
-            }
-            if ( pollFds[1].revents )
-            {
-                /* There is data on the AWT pipe - empty it */
-                do {
-                    count = read(AWT_READPIPE, read_buf, AWT_POLL_BUFSIZE );
-                } while (count == AWT_POLL_BUFSIZE );
-                DTRACE_PRINTLN1("wokeup on AWTPIPE, timeout:%d", timeout);
-            }
-            return;
-
-} /* performPoll() */
-
-#endif /* !USE_SELECT */
-
-/*
- * Pushes an X event back on the queue to be handled
- * later.
- *
- * Ignores the request if event is NULL
- */
-void
-awt_put_back_event(JNIEnv *env, XEvent *event) {
-
-    Boolean addIt = True;
-    if (putbackQueueCount >= putbackQueueCapacity) {
-        /* not enough room - alloc 50% more space */
-        int32_t newCapacity;
-        XEvent *newQueue;
-        newCapacity = putbackQueueCapacity * 3 / 2;
-        if ((newCapacity - putbackQueueCapacity)
-                                        < PUTBACK_QUEUE_MIN_INCREMENT) {
-            /* always increase by at least min increment */
-            newCapacity = putbackQueueCapacity + PUTBACK_QUEUE_MIN_INCREMENT;
-        }
-        newQueue = (XEvent*)realloc(
-                        putbackQueue, newCapacity*(sizeof(XEvent)));
-        if (newQueue == NULL) {
-            JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
-            addIt = False;
-        } else {
-            putbackQueue = newQueue;
-            putbackQueueCapacity = newCapacity;
-        }
-    }
-    if (addIt) {
-        char oneChar = 'p';
-        memcpy(&(putbackQueue[putbackQueueCount]), event, sizeof(XEvent));
-        putbackQueueCount++;
-
-        // wake up the event loop, if it's sleeping
-        write (AWT_WRITEPIPE, &oneChar, 1);
-    }
-
-    return;
-} /* awt_put_back_event() */
-
-/*
- * Gets the next event that has been pushed back onto the queue.
- * Returns 0 and fills in xev_out if successful
- */
-static int32_t
-awt_get_next_put_back_event(XEvent *xev_out) {
-
-    Boolean err = False;
-    if (putbackQueueCount < 1) {
-        err = True;
-    } else {
-        memcpy(xev_out, &(putbackQueue[0]), sizeof(XEvent));
-    }
-    if (!err) {
-        /* remove it from the queue */
-        if (putbackQueueCount == 1) {
-
-            // queue is now empty
-            if (putbackQueueCapacity > PUTBACK_QUEUE_MIN_INCREMENT) {
-
-                /* Too much space -- delete it and rebuild later */
-                free(putbackQueue);
-                putbackQueue = NULL;
-                putbackQueueCapacity = 0;
-            }
-        } else {
-            /* more than 1 event in queue - shift all events to the left */
-            /* We don't free the allocated memory until the queue
-               becomes empty, just 'cause it's easier that way. */
-            /* NOTE: use memmove(), because the memory blocks overlap */
-            memmove(&(putbackQueue[0]), &(putbackQueue[1]),
-                (putbackQueueCount-1)*sizeof(XEvent));
-        }
-        --putbackQueueCount;
-    }
-    DASSERT(putbackQueueCount >= 0);
-
-    return (err? -1:0);
-
-} /* awt_get_next_put_back_event() */
-
-/**
- * Determines whether or not there are X or Xt events pending.
- * Looks at the putbackQueue.
- */
-static XtInputMask
-awt_events_pending(XtAppContext appContext) {
-    XtInputMask imask = 0L;
-    imask = XtAppPending(appContext);
-    if (putbackQueueCount > 0) {
-        imask |= XtIMXEvent;
-    }
-    return imask;
-}
-
-
-#ifndef NOMODALFIX
-#define WIDGET_ARRAY_SIZE 5;
-static int32_t arraySize = 0;
-static int32_t arrayIndx = 0;
-static Widget *dShells = NULL;
-
-void
-awt_shellPoppedUp(Widget shell,
-                   XtPointer modal,
-                   XtPointer call_data)
-{
-    if (arrayIndx == arraySize ) {
-        /* if we have not allocate an array, do it first */
-        if (arraySize == 0) {
-            arraySize += WIDGET_ARRAY_SIZE;
-            dShells = (Widget *) malloc(sizeof(Widget) * arraySize);
-        } else {
-            arraySize += WIDGET_ARRAY_SIZE;
-            dShells = (Widget *) realloc((void *)dShells, sizeof(Widget) * arraySize);
-        }
-    }
-
-    dShells[arrayIndx] = shell;
-    arrayIndx++;
-}
-
-void
-awt_shellPoppedDown(Widget shell,
-                   XtPointer modal,
-                   XtPointer call_data)
-{
-    arrayIndx--;
-
-    if (dShells[arrayIndx] == shell) {
-        dShells[arrayIndx] = NULL;
-        return;
-    } else {
-        int32_t i;
-
-        /* find the position of the shell in the array */
-        for (i = arrayIndx; i >= 0; i--) {
-            if (dShells[i] == shell) {
-                break;
-            }
-        }
-
-        /* remove the found element */
-        while (i <= arrayIndx-1) {
-            dShells[i] = dShells[i+1];
-            i++;
-        }
-    }
-}
-
-Boolean
-awt_isWidgetModal(Widget widget)
-{
-    Widget w;
-
-    for (w = widget; !XtIsShell(w); w = XtParent(w)) { }
-
-    while (w != NULL) {
-        if (w == dShells[arrayIndx-1]) {
-            return True;
-        }
-        w = XtParent(w);
-    }
-    return False;
-}
-
-Boolean
-awt_isModal()
-{
-    return (arrayIndx > 0);
-}
-#endif // NOMODALFIX
-
-
-/*
- * Simply waits for terminateFn() to return True. Waits on the
- * awt lock and is notified to check its state by the main event
- * loop whenever the Xt event queue is empty.
- *
- * NOTE: when you use this routine check if it can be called on the event
- * dispatch thread during drag-n-drop operation and update
- * secondary_loop_event() predicate to prevent deadlock.
- */
-void
-awt_MToolkit_modalWait(int32_t (*terminateFn) (void *data), void *data )
-{
-    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
-
-    AWT_LOCK();
-    AWT_FLUSHOUTPUT_NOW();
-    while ((*terminateFn) (data) == 0) {
-        AWT_WAIT(AWT_MAX_POLL_TIMEOUT);
-        if ((*env)->ExceptionCheck(env)) {
-            (*env)->ExceptionClear(env);
-            break;
-        }
-    }
-    AWT_NOTIFY_ALL();
-    AWT_UNLOCK();
-}
-
-static uint32_t
-colorToRGB(XColor * color)
-{
-    int32_t rgb = 0;
-
-    rgb |= ((color->red >> 8) << 16);
-    rgb |= ((color->green >> 8) << 8);
-    rgb |= ((color->blue >> 8) << 0);
-
-    return rgb;
-}
-
-/*
- * fix for bug #4088106 - ugly text boxes and grayed out looking text
- */
-
-XmColorProc oldColorProc;
-
-void
-ColorProc(XColor* bg_color,
-          XColor* fg_color,
-          XColor* sel_color,
-          XColor* ts_color,
-          XColor* bs_color)
-{
-    unsigned long plane_masks[1];
-    unsigned long colors[5];
-
-    AwtGraphicsConfigDataPtr defaultConfig =
-        getDefaultConfig(DefaultScreen(awt_display));
-
-    /* use the default procedure to calculate colors */
-    oldColorProc(bg_color, fg_color, sel_color, ts_color, bs_color);
-
-    /* check if there is enought free color cells */
-    if (XAllocColorCells(awt_display, defaultConfig->awt_cmap, False,
-        plane_masks, 0, colors, 5)) {
-        XFreeColors(awt_display, defaultConfig->awt_cmap, colors, 5, 0);
-        return;
-    }
-
-    /* find the closest matches currently available */
-    fg_color->pixel = defaultConfig->AwtColorMatch(fg_color->red   >> 8,
-                                                   fg_color->green >> 8,
-                                                   fg_color->blue  >> 8,
-                                                   defaultConfig);
-    fg_color->flags = DoRed | DoGreen | DoBlue;
-    XQueryColor(awt_display, defaultConfig->awt_cmap, fg_color);
-    sel_color->pixel = defaultConfig->AwtColorMatch(sel_color->red   >> 8,
-                                                    sel_color->green >> 8,
-                                                    sel_color->blue  >> 8,
-                                                    defaultConfig);
-    sel_color->flags = DoRed | DoGreen | DoBlue;
-    XQueryColor(awt_display, defaultConfig->awt_cmap, sel_color);
-    ts_color->pixel = defaultConfig->AwtColorMatch(ts_color->red   >> 8,
-                                                   ts_color->green >> 8,
-                                                   ts_color->blue  >> 8,
-                                                   defaultConfig);
-    ts_color->flags = DoRed | DoGreen | DoBlue;
-    XQueryColor(awt_display, defaultConfig->awt_cmap, ts_color);
-    bs_color->pixel = defaultConfig->AwtColorMatch(bs_color->red   >> 8,
-                                                   bs_color->green >> 8,
-                                                   bs_color->blue  >> 8,
-                                                   defaultConfig);
-    bs_color->flags = DoRed | DoGreen | DoBlue;
-    XQueryColor(awt_display, defaultConfig->awt_cmap, bs_color);
-}
-
-
-/*
- * Read _XSETTINGS_SETTINGS property from _XSETTINGS selection owner
- * and pass its value to the java world for processing.
- */
-/*static*/ void
-awt_xsettings_update(int scr, Window owner, void *cookie)
-{
-    Display *dpy = awt_display;
-    int status;
-
-    JNIEnv *env;
-    jobject mtoolkit;
-    jmethodID upcall;
-    jbyteArray array;
-
-    struct xsettings_callback_cookie *upcall_cookie = cookie;
-
-    /* Returns of XGetWindowProperty */
-    Atom actual_type;
-    int actual_format;
-    unsigned long nitems;
-    unsigned long bytes_after;
-    unsigned char *xsettings;
-
-    DTRACE_PRINTLN2("XS: update screen %d, owner 0x%08lx",
-                    scr, owner);
-
-#if 1 /* XXX: kludge */
-    /*
-     * As toolkit cannot yet cope with per-screen desktop properties,
-     * only report XSETTINGS changes on the default screen.  This
-     * should be "good enough" for most cases.
-     */
-    if (scr != DefaultScreen(dpy)) {
-        DTRACE_PRINTLN2("XS: XXX: default screen is %d, update is for %d, ignoring", DefaultScreen(dpy), scr);
-        return;
-    }
-#endif /* kludge */
-
-    env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
-    DASSERT(env != NULL);
-
-    DASSERT(upcall_cookie != NULL);
-    mtoolkit = upcall_cookie->mtoolkit;
-    upcall = upcall_cookie->upcallMID;
-
-    DASSERT(!JNU_IsNull(env, mtoolkit));
-    DASSERT(upcall != NULL);
-
-    /*
-     * XXX: move awt_getPropertyFOO from awt_wm.c to awt_util.c and
-     * use the appropriate one.
-     */
-    status = XGetWindowProperty(dpy, owner,
-                 _XA_XSETTINGS_SETTINGS, 0, 0xFFFF, False,
-                 _XA_XSETTINGS_SETTINGS,
-                 &actual_type, &actual_format, &nitems, &bytes_after,
-                 &xsettings);
-
-    if (status != Success) {
-        DTRACE_PRINTLN("XS:   unable to read _XSETTINGS");
-        return;
-    }
-
-    if (xsettings == NULL) {
-        DTRACE_PRINTLN("XS:   reading _XSETTINGS, got NULL");
-        return;
-    }
-
-    if (actual_type != _XA_XSETTINGS_SETTINGS) {
-        XFree(xsettings);       /* NULL data already catched above */
-        DTRACE_PRINTLN("XS:   _XSETTINGS_SETTINGS is not of type _XSETTINGS_SETTINGS");
-        return;
-    }
-
-    DTRACE_PRINTLN1("XS:   read %lu bytes of _XSETTINGS_SETTINGS",
-                    nitems);
-
-    /* ok, propagate xsettings to the toolkit for processing */
-    if ((*env)->EnsureLocalCapacity(env, 1) < 0) {
-        DTRACE_PRINTLN("XS:   EnsureLocalCapacity failed");
-        XFree(xsettings);
-        return;
-    }
-
-    array = (*env)->NewByteArray(env, (jint)nitems);
-    if (JNU_IsNull(env, array)) {
-        DTRACE_PRINTLN("awt_xsettings_update: NewByteArray failed");
-        XFree(xsettings);
-        return;
-    }
-
-    (*env)->SetByteArrayRegion(env, array, 0, (jint)nitems,
-                               (jbyte *)xsettings);
-    XFree(xsettings);
-
-    (*env)->CallVoidMethod(env, mtoolkit, upcall, (jint)scr, array);
-    (*env)->DeleteLocalRef(env, array);
-}
-
-
-/*
- * Event handler for events on XSETTINGS selection owner.
- * We are interested in PropertyNotify only.
- */
-static void
-awt_xsettings_callback(int scr, XEvent *xev, void *cookie)
-{
-    Display *dpy = awt_display; /* xev->xany.display */
-    XPropertyEvent *ev;
-
-    if (xev->type != PropertyNotify) {
-        DTRACE_PRINTLN2("XS: awt_xsettings_callback(%d) event %d ignored",
-                        scr, xev->type);
-        return;
-    }
-
-    ev = &xev->xproperty;
-
-    if (ev->atom == None) {
-        DTRACE_PRINTLN("XS: awt_xsettings_callback(%d) atom == None");
-        return;
-    }
-
-#ifdef DEBUG
-    {
-        char *name;
-
-        DTRACE_PRINT2("XS: awt_xsettings_callback(%d) 0x%08lx ",
-                      scr, ev->window);
-        name = XGetAtomName(dpy, ev->atom);
-        if (name == NULL) {
-            DTRACE_PRINT1("atom #%d", ev->atom);
-        } else {
-            DTRACE_PRINT1("%s", name);
-            XFree(name);
-        }
-        DTRACE_PRINTLN1(" %s", ev->state == PropertyNewValue ?
-                                        "changed" : "deleted");
-    }
-#endif
-
-    if (ev->atom != _XA_XSETTINGS_SETTINGS) {
-        DTRACE_PRINTLN("XS:   property != _XSETTINGS_SETTINGS ...  ignoring");
-        return;
-    }
-
-
-    if (ev->state == PropertyDelete) {
-        /* XXX: notify toolkit to reset to "defaults"? */
-        return;
-    }
-
-    awt_xsettings_update(scr, ev->window, cookie);
-}
-
-
-/*
- * Owner of XSETTINGS selection changed on the given screen.
- */
-static void
-awt_xsettings_owner_callback(int scr, Window owner, long *data_unused,
-                             void *cookie)
-{
-    if (owner == None) {
-        DTRACE_PRINTLN("XS: awt_xsettings_owner_callback: owner = None");
-        /* XXX: reset to defaults??? */
-        return;
-    }
-
-    DTRACE_PRINTLN1("XS: awt_xsettings_owner_callback: owner = 0x%08lx",
-                    owner);
-
-    awt_xsettings_update(scr, owner, cookie);
-}
-
-/*
- * Returns a reference to the class java.awt.Component.
- */
-jclass
-getComponentClass(JNIEnv *env)
-{
-    static jclass componentCls = NULL;
-
-    // get global reference of java/awt/Component class (run only once)
-    if (componentCls == NULL) {
-        jclass componentClsLocal = (*env)->FindClass(env, "java/awt/Component");
-        DASSERT(componentClsLocal != NULL);
-        if (componentClsLocal == NULL) {
-            /* exception already thrown */
-            return NULL;
-        }
-        componentCls = (jclass)(*env)->NewGlobalRef(env, componentClsLocal);
-        (*env)->DeleteLocalRef(env, componentClsLocal);
-    }
-    return componentCls;
-}
-
-
-/*
- * Returns a reference to the class java.awt.MenuComponent.
- */
-jclass
-getMenuComponentClass(JNIEnv *env)
-{
-    static jclass menuComponentCls = NULL;
-
-    // get global reference of java/awt/MenuComponent class (run only once)
-    if (menuComponentCls == NULL) {
-        jclass menuComponentClsLocal = (*env)->FindClass(env, "java/awt/MenuComponent");
-        DASSERT(menuComponentClsLocal != NULL);
-        if (menuComponentClsLocal == NULL) {
-            /* exception already thrown */
-            return NULL;
-        }
-        menuComponentCls = (jclass)(*env)->NewGlobalRef(env, menuComponentClsLocal);
-        (*env)->DeleteLocalRef(env, menuComponentClsLocal);
-    }
-    return menuComponentCls;
-}
-
-/*
- * Class:     sun_awt_motif_MToolkit
- * Method:    init
- * Signature: (Ljava/lang/String;)V
- */
-JNIEXPORT void JNICALL
-Java_sun_awt_motif_MToolkit_init(JNIEnv *env, jobject this,
-    jstring mainClassName)
-{
-    char *appName = NULL;
-    char *mainChars = NULL;
-
-    int32_t   argc     = 0;
-    char *argv[10] = { NULL };
-
-    /*
-     * Note: The MToolkit object depends on the static initializer
-     * of X11GraphicsEnvironment to initialize the connection to
-     * the X11 server.
-     */
-    XFontStruct *xfont;
-    XmFontListEntry tmpFontListEntry;
-    char *multiclick_time_query;
-    AwtGraphicsConfigDataPtr defaultConfig =
-        getDefaultConfig(DefaultScreen(awt_display));
-    AwtScreenDataPtr defaultScreen =
-        getScreenData(DefaultScreen(awt_display));
-
-    static String fallback_resources[] =
-    {
-        "*enableThinThickness:                   True",
-        "*XmFileSelectionBox.fileFilterStyle:    XmFILTER_HIDDEN_FILES",
-        "*XmFileSelectionBox.pathMode:           XmPATH_MODE_RELATIVE",
-        "*XmFileSelectionBox.resizePolicy:       XmRESIZE_GROW",
-        "*XmFileSelectionBox*dirTextLabelString:         Enter path or folder name:",
-        "*XmFileSelectionBox*applyLabelString:           Update",
-        "*XmFileSelectionBox*selectionLabelString:       Enter file name:",
-        "*XmFileSelectionBox*dirListLabelString:         Folders",
-        NULL                        /* Must be NULL terminated */
-    };
-
-    focusOutEvent.type = FocusOut;
-    focusOutEvent.xfocus.send_event = True;
-    focusOutEvent.xfocus.display = awt_display;
-    focusOutEvent.xfocus.mode = NotifyNormal;
-    focusOutEvent.xfocus.detail = NotifyNonlinear;
-
-    /* Need to make sure this is deleted someplace! */
-    AWT_LOCK();
-
-    XSetIOErrorHandler(xIOError);
-
-    if (!XSupportsLocale()) {
-        jio_fprintf(stderr,
-                    "current locale is not supported in X11, locale is set to C");
-        setlocale(LC_ALL, "C");
-    }
-    if (!XSetLocaleModifiers("")) {
-        jio_fprintf(stderr, "X locale modifiers are not supported, using default");
-    }
-#ifdef NETSCAPE
-    if (awt_init_xt) {
-        XtToolkitInitialize();
-    }
-#else
-    XtToolkitInitialize();
-#endif
-
-    {
-        jclass  fontConfigClass;
-        jmethodID methID;
-        jstring jFontList;
-        char       *cFontRsrc;
-        char       *cFontRsrc2;
-
-        fontConfigClass = (*env)->FindClass(env, "sun/awt/motif/MFontConfiguration");
-        methID = (*env)->GetStaticMethodID(env, fontConfigClass,
-                                           "getDefaultMotifFontSet",
-                                           "()Ljava/lang/String;");
-        jFontList = (*env)->CallStaticObjectMethod(env, fontConfigClass, methID);
-        if (jFontList == NULL) {
-            motifFontList =
-                "-monotype-arial-regular-r-normal--*-140-*-*-p-*-iso8859-1";
-        } else {
-            motifFontList = JNU_GetStringPlatformChars(env, jFontList, NULL);
-        }
-
-        /* fprintf(stderr, "motifFontList: %s\n", motifFontList); */
-
-        cFontRsrc = malloc(strlen(motifFontList) + 20);
-        strcpy(cFontRsrc, "*fontList: ");
-        strcat(cFontRsrc, motifFontList);
-        cFontRsrc2 = malloc(strlen(motifFontList) + 20);
-        strcpy(cFontRsrc2, "*labelFontList: ");
-        strcat(cFontRsrc2, motifFontList);
-
-        argc = 1;
-        argv[argc++] = "-xrm";
-        argv[argc++] = cFontRsrc;
-        argv[argc++] = "-xrm";
-        argv[argc++] = cFontRsrc2;
-        argv[argc++] = "-font";
-        argv[argc++] = (char *)defaultMotifFont;
-    }
-
-    awt_appContext = XtCreateApplicationContext();
-    XtAppSetErrorHandler(awt_appContext, (XtErrorHandler) xtError);
-    XtAppSetFallbackResources(awt_appContext, fallback_resources);
-
-    appName = NULL;
-    mainChars = NULL;
-    if (!JNU_IsNull(env, mainClassName)) {
-        mainChars = (char *)JNU_GetStringPlatformChars(env, mainClassName, NULL);
-        appName = mainChars;
-    }
-    if (appName == NULL || appName[0] == '\0') {
-        appName = "AWT";
-    }
-
-    XtDisplayInitialize(awt_appContext, awt_display,
-                        appName, /* application name  */
-                        appName, /* application class */
-                        NULL, 0, &argc, argv);
-
-    /* Root shell widget that serves as a parent for all AWT top-levels.    */
-    awt_root_shell = XtVaAppCreateShell(appName, /* application name  */
-                                        appName, /* application class */
-                                        applicationShellWidgetClass,
-                                        awt_display,
-                                        /* va_list */
-                                        XmNmappedWhenManaged, False,
-                                        NULL);
-    XtRealizeWidget(awt_root_shell);
-
-    if (mainChars != NULL) {
-        JNU_ReleaseStringPlatformChars(env, mainClassName, mainChars);
-    }
-
-    awt_mgrsel_init();
-    awt_wm_init();
-    init_xembed();
-
-    /*
-     * Find the correct awt_multiclick_time to use. We normally
-     * would call XtMultiClickTime() and wouldn't have to do
-     * anything special, but because OpenWindows defines its own
-     * version (OpenWindows.MultiClickTimeout), we need to
-     * determine out which resource to use.
-     *
-     * We do this by searching in order for:
-     *
-     *   1) an explicit definition of multiClickTime
-     *      (this is the resource that XtGetMultiClickTime uses)
-     *
-     * if that fails, search for:
-     *
-     *   2) an explicit definition of Openwindows.MultiClickTimeout
-     *
-     * if both searches fail:
-     *
-     *   3) use the fallback provided by XtGetMultiClickTime()
-     *      (which is 200 milliseconds... I looked at the source :-)
-     *
-     */
-    multiclick_time_query = XGetDefault(awt_display, "*", "multiClickTime");
-    if (multiclick_time_query) {
-        awt_multiclick_time = XtGetMultiClickTime(awt_display);
-    } else {
-        multiclick_time_query = XGetDefault(awt_display,
-                                            "OpenWindows", "MultiClickTimeout");
-        if (multiclick_time_query) {
-            /* Note: OpenWindows.MultiClickTimeout is in tenths of
-               a second, so we need to multiply by 100 to convert to
-               milliseconds */
-            awt_multiclick_time = atoi(multiclick_time_query) * 100;
-        } else {
-            awt_multiclick_time = XtGetMultiClickTime(awt_display);
-        }
-    }
-
-    scrollBugWorkAround = TRUE;
-
-    /*
-     * Create the cursor for TextArea scrollbars...
-     */
-    awt_scrollCursor = XCreateFontCursor(awt_display, XC_left_ptr);
-
-    awt_defaultBg = defaultConfig->AwtColorMatch(200, 200, 200, defaultConfig);
-    awt_defaultFg = defaultScreen->blackpixel;
-    setup_modifier_map(awt_display);
-
-    awt_initialize_DataTransferer();
-    awt_initialize_Xm_DnD(awt_display);
-
-    /*
-     * fix for bug #4088106 - ugly text boxes and grayed out looking text
-     */
-    oldColorProc = XmGetColorCalculation();
-    XmSetColorCalculation(ColorProc);
-
-    AWT_UNLOCK();
-}
-
-/*
- * Class:     sun_awt_motif_MToolkit
- * Method:    run
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_sun_awt_motif_MToolkit_run
-  (JNIEnv *env, jobject this)
-{
-    /*
-     * in performSelect(), we multiply the timeout by 1000. Make sure
-     * that the maximum value will not cause an overflow.
-     */
-    DASSERT(AWT_MAX_POLL_TIMEOUT <= (ULONG_MAX/1000));
-
-    awt_MainThread = (*env)->NewGlobalRef(env, awtJNI_GetCurrentThread(env));
-    awt_MToolkit_loop(env); /* never returns */
-}
-
-/*
- * Class:     sun_awt_motif_MToolkit
- * Method:    makeColorModel
- * Signature: ()Ljava/awt/image/ColorModel;
- */
-JNIEXPORT jobject JNICALL Java_sun_awt_motif_MToolkit_makeColorModel
-  (JNIEnv *env, jclass this)
-{
-    AwtGraphicsConfigDataPtr defaultConfig =
-        getDefaultConfig(DefaultScreen(awt_display));
-
-    return awtJNI_GetColorModel(env, defaultConfig);
-}
-
-/*
- * Class:     sun_awt_motif_MToolkit
- * Method:    getScreenResolution
- * Signature: ()I
- */
-JNIEXPORT jint JNICALL Java_sun_awt_motif_MToolkit_getScreenResolution
-  (JNIEnv *env, jobject this)
-{
-    return (jint) ((DisplayWidth(awt_display, DefaultScreen(awt_display))
-                    * 25.4) /
-                   DisplayWidthMM(awt_display, DefaultScreen(awt_display)));
-}
-
-/*
- * Class:     sun_awt_motif_MToolkit
- * Method:    getScreenWidth
- * Signature: ()I
- */
-JNIEXPORT jint JNICALL Java_sun_awt_motif_MToolkit_getScreenWidth
-  (JNIEnv *env, jobject this)
-{
-    return DisplayWidth(awt_display, DefaultScreen(awt_display));
-}
-/*
- * Class:     sun_awt_motif_MToolkit
- * Method:    getScreenHeight
- * Signature: ()I
- */
-JNIEXPORT jint JNICALL Java_sun_awt_motif_MToolkit_getScreenHeight
-  (JNIEnv *env, jobject this)
-{
-    return DisplayHeight(awt_display, DefaultScreen(awt_display));
-}
-
-/*
- * Class:     sun_awt_motif_MToolkit
- * Method:    beep
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_sun_awt_motif_MToolkit_beep
-  (JNIEnv *env, jobject this)
-{
-    AWT_LOCK();
-    XBell(awt_display, 0);
-    AWT_FLUSH_UNLOCK();
-}
-
-/*
- * Class:     sun_awt_motif_MToolkit
- * Method:    shutdown
- * Signature: ()V
- */
-
-JNIEXPORT void JNICALL Java_sun_awt_motif_MToolkit_shutdown
-  (JNIEnv *env, jobject this)
-{
-    X11SD_LibDispose(env);
-}
-
-/*
- * Class:     sun_awt_motif_MToolkit
- * Method:    getLockingKeyStateNative
- * Signature: (I)B
- */
-JNIEXPORT jboolean JNICALL Java_sun_awt_motif_MToolkit_getLockingKeyStateNative
-  (JNIEnv *env, jobject this, jint awtKey)
-{
-    KeySym sym;
-    KeyCode keyCode;
-    uint32_t byteIndex;
-    uint32_t bitIndex;
-    char keyVector[32];
-
-    AWT_LOCK();
-
-    sym = awt_getX11KeySym(awtKey);
-    keyCode = XKeysymToKeycode(awt_display, sym);
-    if (sym == NoSymbol || keyCode == 0) {
-        JNU_ThrowByName(env, "java/lang/UnsupportedOperationException", "Keyboard doesn't have requested key");
-        AWT_UNLOCK();
-        return False;
-    }
-
-    byteIndex = (keyCode/8);
-    bitIndex = keyCode & 7;
-    XQueryKeymap(awt_display, keyVector);
-
-    AWT_UNLOCK();
-
-    return (1 & (keyVector[byteIndex] >> bitIndex));
-}
-
-/*
- * Class:     sun_awt_motif_MToolkit
- * Method:    loadSystemColors
- * Signature: ([I)V
- */
-JNIEXPORT void JNICALL Java_sun_awt_motif_MToolkit_loadSystemColors
-  (JNIEnv *env, jobject this, jintArray systemColors)
-{
-    Widget frame, panel, control, menu, text, scrollbar;
-    Colormap cmap;
-    Pixel bg, fg, highlight, shadow;
-    Pixel pixels[java_awt_SystemColor_NUM_COLORS];
-    XColor *colorsPtr;
-    jint rgbColors[java_awt_SystemColor_NUM_COLORS];
-    int32_t count = 0;
-    int32_t i, j;
-    Arg args[10];
-    int32_t argc;
-    AwtGraphicsConfigDataPtr defaultConfig =
-        getDefaultConfig(DefaultScreen(awt_display));
-
-    AWT_LOCK();
-
-    /*
-     * initialize array of pixels
-     */
-    for (i = 0; i < java_awt_SystemColor_NUM_COLORS; i++) {
-        pixels[i] = -1;
-    }
-
-    /*
-     * Create phantom widgets in order to determine the default
-     * colors;  this is somewhat inelegant, however it is the simplest
-     * and most reliable way to determine the system's default colors
-     * for objects.
-     */
-    argc = 0;
-    XtSetArg(args[argc], XmNbuttonFontList,  getMotifFontList()); argc++;
-    XtSetArg(args[argc], XmNlabelFontList,   getMotifFontList()); argc++;
-    XtSetArg(args[argc], XmNtextFontList,    getMotifFontList()); argc++;
-    frame = XtAppCreateShell("AWTColors", "XApplication",
-                             vendorShellWidgetClass,
-                             awt_display,
-                             args, argc);
-    /*
-      XtSetMappedWhenManaged(frame, False);
-      XtRealizeWidget(frame);
-    */
-    panel = XmCreateDrawingArea(frame, "awtPanelColor", NULL, 0);
-    argc = 0;
-    XtSetArg(args[argc], XmNfontList,        getMotifFontList()); argc++;
-    control = XmCreatePushButton(panel, "awtControlColor", args, argc);
-    argc = 0;
-    XtSetArg(args[argc], XmNlabelFontList,   getMotifFontList()); argc++;
-    XtSetArg(args[argc], XmNbuttonFontList,  getMotifFontList()); argc++;
-    menu = XmCreatePulldownMenu(control, "awtColorMenu", args, argc);
-    argc = 0;
-    XtSetArg(args[argc], XmNfontList,        getMotifFontList()); argc++;
-    text = XmCreateText(panel, "awtTextColor", args, argc);
-    scrollbar = XmCreateScrollBar(panel, "awtScrollbarColor", NULL, 0);
-
-    XtVaGetValues(panel,
-                  XmNbackground, &bg,
-                  XmNforeground, &fg,
-                  XmNcolormap, &cmap,
-                  NULL);
-
-    pixels[java_awt_SystemColor_WINDOW] = bg;
-    count++;
-    pixels[java_awt_SystemColor_INFO] = bg;
-    count++;
-    pixels[java_awt_SystemColor_WINDOW_TEXT] = fg;
-    count++;
-    pixels[java_awt_SystemColor_INFO_TEXT] = fg;
-    count++;
-
-    XtVaGetValues(menu,
-                  XmNbackground, &bg,
-                  XmNforeground, &fg,
-                  NULL);
-
-    pixels[java_awt_SystemColor_MENU] = bg;
-    count++;
-    pixels[java_awt_SystemColor_MENU_TEXT] = fg;
-    count++;
-
-    XtVaGetValues(text,
-                  XmNbackground, &bg,
-                  XmNforeground, &fg,
-                  NULL);
-
-    pixels[java_awt_SystemColor_TEXT] = bg;
-    count++;
-    pixels[java_awt_SystemColor_TEXT_TEXT] = fg;
-    count++;
-    pixels[java_awt_SystemColor_TEXT_HIGHLIGHT] = fg;
-    count++;
-    pixels[java_awt_SystemColor_TEXT_HIGHLIGHT_TEXT] = bg;
-    count++;
-
-    XtVaGetValues(control,
-                  XmNbackground, &bg,
-                  XmNforeground, &fg,
-                  XmNtopShadowColor, &highlight,
-                  XmNbottomShadowColor, &shadow,
-                  NULL);
-
-    pixels[java_awt_SystemColor_CONTROL] = bg;
-    count++;
-    pixels[java_awt_SystemColor_CONTROL_TEXT] = fg;
-    count++;
-    pixels[java_awt_SystemColor_CONTROL_HIGHLIGHT] = highlight;
-    count++;
-    pixels[java_awt_SystemColor_CONTROL_LT_HIGHLIGHT] = highlight;
-    count++;
-    pixels[java_awt_SystemColor_CONTROL_SHADOW] = shadow;
-    count++;
-    pixels[java_awt_SystemColor_CONTROL_DK_SHADOW] = shadow;
-    count++;
-
-    XtVaGetValues(scrollbar,
-                  XmNbackground, &bg,
-                  NULL);
-    pixels[java_awt_SystemColor_SCROLLBAR] = bg;
-    count++;
-
-    /*
-     * Convert pixel values to RGB
-     */
-    colorsPtr = (XColor *) malloc(count * sizeof(XColor));
-    j = 0;
-    for (i = 0; i < java_awt_SystemColor_NUM_COLORS; i++) {
-        if (pixels[i] != -1) {
-            colorsPtr[j++].pixel = pixels[i];
-        }
-    }
-    XQueryColors(awt_display, cmap, colorsPtr, count);
-
-    /* Get current System Colors */
-
-    (*env)->GetIntArrayRegion (env, systemColors, 0,
-                              java_awt_SystemColor_NUM_COLORS,
-                              rgbColors);
-
-    /*
-     * Fill systemColor array with new rgb values
-     */
-
-    j = 0;
-    for (i = 0; i < java_awt_SystemColor_NUM_COLORS; i++) {
-        if (pixels[i] != -1) {
-            uint32_t rgb = colorToRGB(&colorsPtr[j++]);
-
-            /*
-              printf("SystemColor[%d] = %x\n", i, rgb);
-            */
-            rgbColors[i] = (rgb | 0xFF000000);
-        }
-    }
-
-    (*env)->SetIntArrayRegion(env,
-                              systemColors,
-                              0,
-                              java_awt_SystemColor_NUM_COLORS,
-                              rgbColors);
-
-    /* Duplicate system colors. If color allocation is unsuccessful,
-       system colors will be approximated with matched colors */
-    if (defaultConfig->awt_depth == 8)
-        awt_allocate_systemcolors(colorsPtr, count, defaultConfig);
-
-    /*
-     * Cleanup
-     */
-    XtDestroyWidget(frame);
-    free(colorsPtr);
-
-    AWT_UNLOCK();
-}
-
-/*
- * Class:     sun_awt_motif_MToolkit
- * Method:    isDynamicLayoutSupportedNative
- * Signature: ()Z
- *
- * Note: there doesn't seem to be a protocol for querying the WM
- * about its opaque resize settings, so this function just returns
- * whether there is a solid resize option available for that WM.
- */
-JNIEXPORT jboolean JNICALL
-Java_sun_awt_motif_MToolkit_isDynamicLayoutSupportedNative(JNIEnv *env, jobject this)
-{
-    enum wmgr_t wm;
-
-    AWT_LOCK();
-    wm = awt_wm_getRunningWM();
-    AWT_UNLOCK();
-
-    switch (wm) {
-      case ENLIGHTEN_WM:
-      case KDE2_WM:
-      case SAWFISH_WM:
-      case ICE_WM:
-      case METACITY_WM:
-        return JNI_TRUE;
-      case OPENLOOK_WM:
-      case MOTIF_WM:
-      case CDE_WM:
-        return JNI_FALSE;
-      default:
-        return JNI_FALSE;
-    }
-}
-
-/*
- * Class:     sun_awt_motif_MToolkit
- * Method:    isFrameStateSupported
- * Signature: (I)Z
- */
-JNIEXPORT jboolean JNICALL
-Java_sun_awt_motif_MToolkit_isFrameStateSupported(JNIEnv *env, jobject this,
-    jint state)
-{
-    if (state == java_awt_Frame_NORMAL || state == java_awt_Frame_ICONIFIED) {
-        return JNI_TRUE;
-    } else {
-        return awt_wm_supportsExtendedState(state) ? JNI_TRUE : JNI_FALSE;
-    }
-}
-
-/*
- * Class:     sun_awt_motif_MToolkit
- * Method:    getMulticlickTime
- * Signature: ()I
- */
-JNIEXPORT jint JNICALL Java_sun_awt_motif_MToolkit_getMulticlickTime
-  (JNIEnv *env, jobject this)
-{
-    return awt_multiclick_time;
-}
-
-/*
- * Class:     sun_awt_motif_MToolkit
- * Method:    loadXSettings
- * Signature: ()V
- */
-JNIEXPORT void JNICALL
-Java_sun_awt_motif_MToolkit_loadXSettings(JNIEnv *env, jobject this)
-{
-    static Boolean registered = False;
-
-    jclass mtoolkitCLS;
-    Display *dpy = awt_display;
-    const Window *owners;
-    int scr;
-
-    AWT_LOCK();
-
-    if (registered) {
-        AWT_UNLOCK();
-        return;
-    }
-
-    if (_XA_XSETTINGS_SETTINGS == None) {
-        _XA_XSETTINGS_SETTINGS = XInternAtom(dpy, "_XSETTINGS_SETTINGS", False);
-        if (_XA_XSETTINGS_SETTINGS == None) {
-            JNU_ThrowNullPointerException(env,
-                "unable to intern _XSETTINGS_SETTINGS");
-            AWT_UNLOCK();
-            return;
-        }
-    }
-
-    mtoolkitCLS = (*env)->GetObjectClass(env, this);
-
-    xsettings_callback_cookie.mtoolkit =
-        (*env)->NewGlobalRef(env, this);
-    xsettings_callback_cookie.upcallMID =
-        (*env)->GetMethodID(env, mtoolkitCLS,
-                            "parseXSettings", "(I[B)V");
-
-    if (JNU_IsNull(env, xsettings_callback_cookie.upcallMID)) {
-        JNU_ThrowNoSuchMethodException(env,
-            "sun.awt.motif.MToolkit.parseXSettings");
-        AWT_UNLOCK();
-        return;
-    }
-
-    owners = awt_mgrsel_select("_XSETTINGS", PropertyChangeMask,
-                               &xsettings_callback_cookie,
-                               awt_xsettings_callback,
-                               awt_xsettings_owner_callback);
-    if (owners == NULL) {
-        JNU_ThrowNullPointerException(env,
-            "unable to regiser _XSETTINGS with mgrsel");
-        AWT_UNLOCK();
-        return;
-    }
-
-    registered = True;
-
-    for (scr = 0; scr < ScreenCount(dpy); ++scr) {
-        if (owners[scr] == None) {
-            DTRACE_PRINTLN1("XS: MToolkit.loadXSettings: none on screen %d",
-                            scr);
-            continue;
-        }
-
-        awt_xsettings_update(scr, owners[scr], &xsettings_callback_cookie);
-    }
-
-    AWT_UNLOCK();
-}
-
-JNIEXPORT jboolean JNICALL
-Java_sun_awt_motif_MToolkit_isAlwaysOnTopSupported(JNIEnv *env, jobject toolkit) {
-    Boolean res;
-    AWT_LOCK();
-    res = awt_wm_supportsAlwaysOnTop();
-    AWT_UNLOCK();
-    return res;
-}
-
-/*
- * Returns true if the current thread is privileged. Currently,
- * only the main event loop thread is considered to be privileged.
- */
-Boolean
-awt_currentThreadIsPrivileged(JNIEnv *env) {
-    return (*env)->IsSameObject(env,
-                        awt_MainThread, awtJNI_GetCurrentThread(env));
-}
-
-JNIEXPORT jboolean JNICALL
-Java_sun_awt_motif_MToolkit_isSyncUpdated(JNIEnv *env, jobject toolkit) {
-    return syncUpdated;
-}
-
-JNIEXPORT jboolean JNICALL
-Java_sun_awt_motif_MToolkit_isSyncFailed(JNIEnv *env, jobject toolkit) {
-    return syncFailed;
-}
-
-JNIEXPORT void JNICALL
-Java_sun_awt_motif_MToolkit_updateSyncSelection(JNIEnv *env, jobject toolkit) {
-
-    // AWT_LOCK is held by calling function
-    if (wm_selection == None) {
-        wm_selection = XInternAtom(awt_display, "WM_S0", False);
-    }
-    if (version_atom == None) {
-        version_atom = XInternAtom(awt_display, "VERSION", False);
-    }
-    if (oops_atom == None) {
-        oops_atom = XInternAtom(awt_display, "OOPS", False);
-    }
-    syncUpdated = False;
-    syncFailed = False;
-    XConvertSelection(awt_display, wm_selection, version_atom, oops_atom, XtWindow(awt_root_shell), CurrentTime);
-    XSync(awt_display, False);
-    inSyncWait = True; // Protect from spurious events
-    // Calling function will call AWT_LOCK_WAIT instead of AWT_UNLOCK
-}
-
-JNIEXPORT jint JNICALL
-Java_sun_awt_motif_MToolkit_getEventNumber(JNIEnv *env, jobject toolkit) {
-    // AWT_LOCK must be held by the calling method
-    return eventNumber;
-}
-
-static void
-syncWait_eventHandler(XEvent * event) {
-    static jmethodID syncNotifyMID = NULL;
-    if (event != NULL && event->xany.type == SelectionNotify &&
-        event->xselection.requestor == XtWindow(awt_root_shell) &&
-        event->xselection.property == oops_atom &&
-        inSyncWait)
-    {
-        JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
-        syncUpdated = True;
-        inSyncWait = False;
-        AWT_NOTIFY_ALL();
-    } else if (event != NULL && event->xany.type == SelectionNotify &&
-               event->xselection.requestor == XtWindow(awt_root_shell) &&
-               event->xselection.target == version_atom &&
-               event->xselection.property == None &&
-               XGetSelectionOwner(awt_display, wm_selection) == None &&
-               event->xselection.selection == wm_selection)
-    {
-        JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
-        syncFailed = True;
-        inSyncWait = False;
-        AWT_NOTIFY_ALL();
-    }
-}
-
-JNIEXPORT void JNICALL
-Java_sun_awt_motif_MToolkit_nativeGrab(JNIEnv *env, jobject toolkit, jobject window) {
-    struct FrameData    *wdata;
-    static Cursor cursor = None;
-    int grab_result;
-
-    AWT_LOCK();
-
-    wdata = (struct FrameData *)
-        JNU_GetLongFieldAsPtr(env, window, mComponentPeerIDs.pData);
-
-    if (wdata == NULL ||
-        wdata->winData.comp.widget == NULL ||
-        wdata->winData.shell == NULL)
-    {
-        AWT_UNLOCK();
-        return;
-    }
-    if (None == cursor) {
-        cursor = XCreateFontCursor(awt_display, XC_hand2);
-    }
-    grabbed_widget = wdata->winData.shell;
-    grab_result = XGrabPointer(awt_display, XtWindow(wdata->winData.shell),
-                               True, (ButtonPressMask | ButtonReleaseMask
-                                      | EnterWindowMask | LeaveWindowMask | PointerMotionMask
-                                      | ButtonMotionMask),
-                               GrabModeAsync, GrabModeAsync, None,
-                               cursor, CurrentTime);
-    if (GrabSuccess != grab_result) {
-        XUngrabPointer(awt_display, CurrentTime);
-        AWT_UNLOCK();
-        DTRACE_PRINTLN1("XGrabPointer() failed, result %d", grab_result);
-        return;
-    }
-    grab_result = XGrabKeyboard(awt_display, XtWindow(wdata->winData.shell),
-                                True,
-                                GrabModeAsync, GrabModeAsync, CurrentTime);
-    if (GrabSuccess != grab_result) {
-        XUngrabKeyboard(awt_display, CurrentTime);
-        XUngrabPointer(awt_display, CurrentTime);
-        DTRACE_PRINTLN1("XGrabKeyboard() failed, result %d", grab_result);
-    }
-    AWT_UNLOCK();
-}
-
-JNIEXPORT void JNICALL
-Java_sun_awt_motif_MToolkit_nativeUnGrab(JNIEnv *env, jobject toolkit, jobject window) {
-    struct FrameData    *wdata;
-
-    AWT_LOCK();
-
-    wdata = (struct FrameData *)
-        JNU_GetLongFieldAsPtr(env, window, mComponentPeerIDs.pData);
-
-    if (wdata == NULL ||
-        wdata->winData.comp.widget == NULL ||
-        wdata->winData.shell == NULL)
-    {
-        AWT_UNLOCK();
-        return;
-    }
-
-    XUngrabPointer(awt_display, CurrentTime);
-    XUngrabKeyboard(awt_display, CurrentTime);
-    grabbed_widget = NULL;
-    AWT_FLUSHOUTPUT_NOW();
-
-    AWT_UNLOCK();
-
-}
-
-/*
- * Class:     sun_awt_motif_MToolkit
- * Method:    getWMName
- * Signature: ()Ljava/lang/String;
- */
-JNIEXPORT jstring JNICALL
-Java_sun_awt_motif_MToolkit_getWMName(JNIEnv *env, jclass this)
-{
-    enum wmgr_t wm;
-
-    AWT_LOCK();
-    wm = awt_wm_getRunningWM();
-    AWT_UNLOCK();
-
-    switch (wm) {
-      case NO_WM:
-          return (*env)->NewStringUTF(env, "NO_WM");
-      case OTHER_WM:
-          return (*env)->NewStringUTF(env, "OTHER_WM");
-      case ENLIGHTEN_WM:
-          return (*env)->NewStringUTF(env, "ENLIGHTEN_WM");
-      case KDE2_WM:
-          return (*env)->NewStringUTF(env, "KDE2_WM");
-      case SAWFISH_WM:
-          return (*env)->NewStringUTF(env, "SAWFISH_WM");
-      case ICE_WM:
-          return (*env)->NewStringUTF(env, "ICE_WM");
-      case METACITY_WM:
-          return (*env)->NewStringUTF(env, "METACITY_WM");
-      case OPENLOOK_WM:
-          return (*env)->NewStringUTF(env, "OPENLOOK_WM");
-      case MOTIF_WM:
-          return (*env)->NewStringUTF(env, "MOTIF_WM");
-      case CDE_WM:
-          return (*env)->NewStringUTF(env, "CDE_WM");
-    }
-    return (*env)->NewStringUTF(env, "UNDETERMINED_WM");
-}
-
-
-#endif /* !HEADLESS */
diff --git a/jdk/src/solaris/native/sun/awt/awt_MToolkit.h b/jdk/src/solaris/native/sun/awt/awt_MToolkit.h
deleted file mode 100644
index 4288e0b..0000000
--- a/jdk/src/solaris/native/sun/awt/awt_MToolkit.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2001, 2005, 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 _MTOOLKIT_H_
-#define _MTOOLKIT_H_
-#ifndef HEADLESS
-extern void *findPeer(Widget * pwidget);
-extern Widget findWindowsProxy(jobject window, JNIEnv *env);
-extern struct WidgetInfo *findWidgetInfo(Widget widget);
-extern Boolean isAncestor(Window ancestor, Window child);
-extern void clearFocusPath(Widget shell);
-extern void globalClearFocusPath(Widget focusOwnerShell);
-extern Boolean isFrameOrDialog(jobject target, JNIEnv * env);
-extern jobject getOwningFrameOrDialog(jobject target, JNIEnv *env);
-
-#define SPECIAL_KEY_EVENT 2
-
-#endif /* !HEADLESS */
-#endif           /* _MTOOLKIT_H_ */
diff --git a/jdk/src/solaris/native/sun/awt/awt_MenuItem.h b/jdk/src/solaris/native/sun/awt/awt_MenuItem.h
deleted file mode 100644
index ed7f909..0000000
--- a/jdk/src/solaris/native/sun/awt/awt_MenuItem.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#include <jni_util.h>
-
-/* fieldIDs for MenuItem fields that may be accessed from C */
-struct MenuItemIDs {
-    jfieldID label;
-    jfieldID enabled;
-    jfieldID shortcut;
-};
-
-/* fieldIDs for MMenuItemPeer fields that may be accessed from C */
-struct MMenuItemPeerIDs {
-    jfieldID target;
-    jfieldID pData;
-    jfieldID isCheckbox;
-    jfieldID jniGlobalRef;
-};
diff --git a/jdk/src/solaris/native/sun/awt/awt_Robot.c b/jdk/src/solaris/native/sun/awt/awt_Robot.c
index c3384b2..a830756 100644
--- a/jdk/src/solaris/native/sun/awt/awt_Robot.c
+++ b/jdk/src/solaris/native/sun/awt/awt_Robot.c
@@ -28,7 +28,6 @@
 #endif
 
 #include "awt_p.h"
-#include "awt_Component.h"
 #include "awt_GraphicsEnv.h"
 #define XK_MISCELLANY
 #include <X11/keysymdef.h>
diff --git a/jdk/src/solaris/native/sun/awt/awt_TopLevel.h b/jdk/src/solaris/native/sun/awt/awt_TopLevel.h
deleted file mode 100644
index 1d8107f..0000000
--- a/jdk/src/solaris/native/sun/awt/awt_TopLevel.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2001, 2005, 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 _TOPLEVEL_H_
-#define _TOPLEVEL_H_
-#ifndef HEADLESS
-
-extern Widget findFocusProxy(Widget widget);
-extern Widget findTopLevelByShell(Widget widget);
-extern jobject findTopLevel(jobject peer, JNIEnv *env);
-extern void shellEH(Widget w, XtPointer data, XEvent *event, Boolean *continueToDispatch);
-extern Boolean isFocusableWindowByShell(JNIEnv * env, Widget shell);
-extern Boolean isFocusableWindowByPeer(JNIEnv * env, jobject peer);
-extern Widget getShellWidget(Widget child);
-extern Boolean isFocusableComponentTopLevelByWidget(JNIEnv * env, Widget child);
-#endif /* !HEADLESS */
-#endif           /* _TOPLEVEL_H_ */
diff --git a/jdk/src/solaris/native/sun/awt/awt_Window.h b/jdk/src/solaris/native/sun/awt/awt_Window.h
deleted file mode 100644
index b816d41..0000000
--- a/jdk/src/solaris/native/sun/awt/awt_Window.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 1998, 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.  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 <jni_util.h>
-
-/* fieldIDs for Window fields that may be accessed from C */
-struct WindowIDs {
-    jfieldID warningString;
-    jfieldID locationByPlatform;
-    jfieldID isAutoRequestFocus;
-};
-
-/* fieldIDs for MWindowPeer fields that may be accessed from C */
-struct MWindowPeerIDs {
-    jfieldID insets;
-    jfieldID iconWidth;
-    jfieldID iconHeight;
-    jfieldID winAttr;
-    jmethodID handleWindowFocusIn;
-    jmethodID handleWindowFocusOut;
-    jmethodID handleIconify;
-    jmethodID handleDeiconify;
-    jmethodID handleStateChange;
-    jmethodID draggedToScreenMID;
-};
diff --git a/jdk/src/solaris/native/sun/awt/awt_mgrsel.c b/jdk/src/solaris/native/sun/awt/awt_mgrsel.c
deleted file mode 100644
index b033227..0000000
--- a/jdk/src/solaris/native/sun/awt/awt_mgrsel.c
+++ /dev/null
@@ -1,449 +0,0 @@
-/*
- * Copyright (c) 2003, 2004, 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.
- */
-
-#ifdef HEADLESS
-    #error This file should not be included in headless library
-#endif
-
-#include "awt_mgrsel.h"
-
-static Atom XA_MANAGER = None;
-
-/*
- * Structures that describes the manager selection AWT listens to with
- * callabacks to the subsytems interested in the selection.  (We only
- * listen to a couple of selections, so linear search is enough).
- */
-struct AwtMgrsel {
-    char *selname;              /* base name of selection atoms */
-    Atom *per_scr_atoms;        /* per-screen selection atoms (ICCCM 1.2.6) */
-    Atom *per_scr_owners;       /* windows currently owning the selection */
-    long extra_mask;            /* extra events to listen to on owners */
-    void *cookie;
-    void (*callback_event)(int, XEvent *, void *); /* extra_mask events */
-    void (*callback_owner)(int, Window, long *, void *); /* owner changes */
-    struct AwtMgrsel *next;
-};
-
-static struct AwtMgrsel *mgrsel_list = NULL;
-
-
-static int awt_mgrsel_screen(Window w);
-static Window awt_mgrsel_select_per_screen(Atom, long);
-static int awt_mgrsel_managed(XClientMessageEvent *mgrown);
-static int awt_mgrsel_unmanaged(XDestroyWindowEvent *ev);
-
-#ifdef DEBUG
-static void awt_mgrsel_dtraceManaged(XClientMessageEvent *mgrown);
-#endif
-
-
-
-/*
- * Find which screen the window W is the root of.
- * Returns the screen number, or -1 if W is not a root.
- */
-static int
-awt_mgrsel_screen(Window w)
-{
-    Display *dpy = awt_display;
-    int scr;
-
-    for (scr = 0; scr < ScreenCount(dpy); ++scr) {
-        if (w == RootWindow(dpy, scr)) {
-            return (scr);
-        }
-    }
-
-    return (-1);
-}
-
-
-/************************************************************************
- * For every one that asketh receiveth; and he that seeketh findeth;
- * and to him that knocketh it shall be opened.  (Luke 11:10).
- */
-
-
-/*
- * A method for a subsytem to express its interest in a certain
- * manager selection.
- *
- * If owner changes, the callback_owner will be called with the screen
- * number and the new owning window when onwership is established, or
- * None if the owner is gone.
- *
- * Events in extra_mask are selected for on owning windows (exsiting
- * ones and on new owners when established) and callback_event will be
- * called with the screen number and an event.
- *
- * The function returns an array of current owners.  The size of the
- * array is ScreenCount(awt_display).  The array is "owned" by this
- * module and should be considered by the caller as read-only.
- */
-const Window *
-awt_mgrsel_select(const char *selname, long extra_mask,
-                  void *cookie,
-                  void (*callback_event)(int, XEvent *, void *),
-                  void (*callback_owner)(int, Window, long *, void *))
-{
-    Display *dpy = awt_display;
-    struct AwtMgrsel *mgrsel;
-    Atom *per_scr_atoms;
-    Window *per_scr_owners;
-    char *namesbuf;
-    char **names;
-    int per_scr_sz;
-    int nscreens = ScreenCount(dpy);
-    int scr;
-    Status status;
-
-    DASSERT(selname != NULL);
-    DTRACE_PRINTLN1("MG: select: %s", selname);
-
-    /* buffer size for one per-screen atom name */
-    per_scr_sz = strlen(selname) + /* "_S" */ 2 + /* %2d */ + 2 /* '\0' */+ 1;
-
-    namesbuf = malloc(per_scr_sz * nscreens);  /* actual storage for names */
-    names = malloc(sizeof(char *) * nscreens); /* pointers to names */
-    per_scr_atoms = malloc(sizeof(Atom) * nscreens);
-    per_scr_owners = malloc(sizeof(Window) * nscreens);
-    mgrsel = malloc(sizeof(struct AwtMgrsel));
-
-    if (namesbuf == NULL || names == NULL || per_scr_atoms == NULL
-        || per_scr_owners == NULL || mgrsel == NULL)
-    {
-        DTRACE_PRINTLN("MG: select: unable to allocate memory");
-        if (namesbuf != NULL) free(namesbuf);
-        if (names != NULL) free(names);
-        if (per_scr_atoms != NULL) free(per_scr_atoms);
-        if (per_scr_owners != NULL) free(per_scr_owners);
-        if (mgrsel != NULL) free(mgrsel);
-        return (NULL);
-    }
-
-
-    for (scr = 0; scr < nscreens; ++scr) {
-        size_t sz;
-
-        names[scr] = &namesbuf[per_scr_sz * scr];
-        sz = snprintf(names[scr], per_scr_sz, "%s_S%-d", selname, scr);
-        DASSERT(sz < per_scr_sz);
-    }
-
-    status = XInternAtoms(dpy, names, nscreens, False, per_scr_atoms);
-
-    free(names);
-    free(namesbuf);
-
-    if (status == 0) {
-        DTRACE_PRINTLN("MG: select: XInternAtoms failed");
-        free(per_scr_atoms);
-        free(per_scr_owners);
-        return (NULL);
-    }
-
-    mgrsel->selname = strdup(selname);
-    mgrsel->per_scr_atoms = per_scr_atoms;
-    mgrsel->per_scr_owners = per_scr_owners;
-    mgrsel->extra_mask = extra_mask;
-    mgrsel->cookie = cookie;
-    mgrsel->callback_event = callback_event;
-    mgrsel->callback_owner = callback_owner;
-
-    for (scr = 0; scr < nscreens; ++scr) {
-        Window owner;
-
-        owner = awt_mgrsel_select_per_screen(per_scr_atoms[scr], extra_mask);
-        mgrsel->per_scr_owners[scr] = owner;
-#ifdef DEBUG
-        if (owner == None) {
-            DTRACE_PRINTLN1("MG:   screen %d - None", scr);
-        } else {
-            DTRACE_PRINTLN2("MG:   screen %d - 0x%08lx", scr, owner);
-        }
-#endif
-    }
-
-    mgrsel->next = mgrsel_list;
-    mgrsel_list = mgrsel;
-
-    return (per_scr_owners);
-}
-
-
-static Window
-awt_mgrsel_select_per_screen(Atom selection, long extra_mask)
-{
-    Display *dpy = awt_display;
-    Window owner;
-
-    XGrabServer(dpy);
-
-    owner = XGetSelectionOwner(dpy, selection);
-    if (owner == None) {
-        /* we'll get notified later if one arrives */
-        XUngrabServer(dpy);
-        /* Workaround for bug 5039226 */
-        XSync(dpy, False);
-        return (None);
-    }
-
-    /*
-     * Select for StructureNotifyMask to get DestroyNotify when owner
-     * is gone.  Also select for any additional events caller is
-     * interested in (e.g. PropertyChangeMask).  Caller will be
-     * notifed of these events via ... XXX ...
-     */
-    XSelectInput(dpy, owner, StructureNotifyMask | extra_mask);
-
-    XUngrabServer(dpy);
-    /* Workaround for bug 5039226 */
-    XSync(dpy, False);
-    return (owner);
-}
-
-
-/************************************************************************
- * And so I saw the wicked buried, who had come and gone from the
- * place of the holy, and they were forgotten in the city where they
- * had so done: this is also vanity.  (Eccl 8:10)
- */
-
-#ifdef DEBUG
-/*
- * Print the message from the new manager that announces it acquired
- * ownership.
- */
-static void
-awt_mgrsel_dtraceManaged(XClientMessageEvent *mgrown)
-{
-    Display *dpy = awt_display;
-    Atom selection;
-    char *selname, *print_selname;
-    int scr;
-
-    scr = awt_mgrsel_screen(mgrown->window);
-
-    selection = mgrown->data.l[1];
-    print_selname = selname = XGetAtomName(dpy, selection);
-    if (selname == NULL) {
-        if (selection == None) {
-            print_selname = "<None>";
-        } else {
-            print_selname = "<Unknown>";
-        }
-    }
-
-    DTRACE_PRINTLN4("MG: new MANAGER for %s: screen %d, owner 0x%08lx (@%lu)",
-                   print_selname, scr,
-                   mgrown->data.l[2],  /* the window owning the selection */
-                   mgrown->data.l[0]); /* timestamp */
-    DTRACE_PRINTLN4("MG:   %ld %ld / 0x%lx 0x%lx", /* extra data */
-                    mgrown->data.l[3], mgrown->data.l[4],
-                    mgrown->data.l[3], mgrown->data.l[4]);
-
-    if (selname != NULL) {
-        XFree(selname);
-    }
-}
-#endif /* DEBUG */
-
-
-static int
-awt_mgrsel_managed(XClientMessageEvent *mgrown)
-{
-    Display *dpy = awt_display;
-    struct AwtMgrsel *mgrsel;
-    int scr;
-
-    long timestamp;
-    Atom selection;
-    Window owner;
-    long *data;
-
-    if (mgrown->message_type != XA_MANAGER) {
-        DTRACE_PRINTLN("MG: ClientMessage type != MANAGER, ignoring");
-        return (0);
-    }
-
-    scr = awt_mgrsel_screen(mgrown->window);
-
-#ifdef DEBUG
-    awt_mgrsel_dtraceManaged(mgrown);
-#endif
-
-    if (scr < 0) {
-        DTRACE_PRINTLN("MG: MANAGER ClientMessage with a non-root window!");
-        return (0);
-    }
-
-    timestamp = mgrown->data.l[0];
-    selection = mgrown->data.l[1];
-    owner     = mgrown->data.l[2];
-    data      = &mgrown->data.l[3]; /* long[2], selection specific */
-
-    /* is this a selection we are intrested in? */
-    for (mgrsel = mgrsel_list; mgrsel != NULL; mgrsel = mgrsel->next) {
-        if (selection == mgrsel->per_scr_atoms[scr])
-            break;
-    }
-
-    if (mgrsel == NULL) {
-        DTRACE_PRINTLN("MG: not interested in this selection, ignoring");
-        return (0);
-    }
-
-
-    mgrsel->per_scr_owners[scr] = owner;
-
-    XSelectInput(dpy, owner, StructureNotifyMask | mgrsel->extra_mask);
-
-    /* notify the listener */
-    if (mgrsel->callback_owner != NULL) {
-        (*mgrsel->callback_owner)(scr, owner, data, mgrsel->cookie);
-    }
-
-    return (1);
-}
-
-
-static int
-awt_mgrsel_unmanaged(XDestroyWindowEvent *ev)
-{
-    Display *dpy = awt_display;
-    struct AwtMgrsel *mgrsel;
-    Window exowner;
-    int scr;
-
-    exowner = ev->window;       /* selection owner that's gone */
-
-    /* is this a selection we are intrested in? */
-    for (mgrsel = mgrsel_list; mgrsel != NULL; mgrsel = mgrsel->next) {
-        for (scr = 0; scr < ScreenCount(dpy); ++scr) {
-            if (exowner == mgrsel->per_scr_owners[scr]) {
-                /* can one window own selections for more than one screen? */
-                goto out;       /* XXX??? */
-            }
-        }
-    }
-  out:
-    if (mgrsel == NULL) {
-        DTRACE_PRINTLN1("MG: DestroyNotify for 0x%08lx ignored", exowner);
-        return (0);
-    }
-
-    DTRACE_PRINTLN3("MG: DestroyNotify for 0x%08lx, owner of %s at screen %d",
-                    exowner, mgrsel->selname, scr);
-
-    /* notify the listener (pass exowner as data???) */
-    if (mgrsel->callback_owner != NULL) {
-        (*mgrsel->callback_owner)(scr, None, NULL, mgrsel->cookie);
-    }
-
-    return (1);
-}
-
-
-/*
- * Hook to be called from toolkit event loop.
- */
-int
-awt_mgrsel_processEvent(XEvent *ev)
-{
-    Display *dpy = awt_display;
-    struct AwtMgrsel *mgrsel;
-    int scr;
-
-    if (ev->type == ClientMessage) { /* new manager announces ownership? */
-        if (awt_mgrsel_managed(&ev->xclient))
-            return (1);
-    }
-
-    if (ev->type == DestroyNotify) { /* manager gives up selection? */
-        if (awt_mgrsel_unmanaged(&ev->xdestroywindow))
-            return (1);
-    }
-
-    /* is this an event selected on one of selection owners? */
-    for (mgrsel = mgrsel_list; mgrsel != NULL; mgrsel = mgrsel->next) {
-        for (scr = 0; scr < ScreenCount(dpy); ++scr) {
-            if (ev->xany.window == mgrsel->per_scr_owners[scr]) {
-                /* can one window own selections for more than one screen? */
-                goto out;       /* XXX??? */
-            }
-        }
-    }
-  out:
-    DTRACE_PRINT2("MG: screen %d, event %d ...  ",
-                  scr, ev->xany.type);
-    if (mgrsel == NULL) {
-        DTRACE_PRINTLN("ignored");
-        return (0);             /* not interested */
-    }
-
-    DTRACE_PRINT1("%s ...  ", mgrsel->selname);
-    if (mgrsel->callback_event != NULL) {
-        DTRACE_PRINTLN("dispatching");
-        (*mgrsel->callback_event)(scr, ev, mgrsel->cookie);
-    }
-#ifdef DEBUG
-    else {
-        DTRACE_PRINTLN("no callback");
-    }
-#endif
-
-    return (1);
-}
-
-
-void
-awt_mgrsel_init(void)
-{
-    static Boolean inited = False;
-
-    Display *dpy = awt_display;
-    int scr;
-
-    if (inited) {
-        return;
-    }
-
-    XA_MANAGER = XInternAtom(dpy, "MANAGER", False);
-    DASSERT(XA_MANAGER != None);
-
-
-    /*
-     * Listen for ClientMessage's on each screen's root.  We hook into
-     * the message loop in the toolkit (with awt_mgrsel_processEvent)
-     * to get the events processed.  We need this for notifications of
-     * new manager acquiring ownership of the manager selection.
-     */
-    for (scr = 0; scr < ScreenCount(dpy); ++scr) {
-        XSelectInput(dpy, RootWindow(dpy, scr), StructureNotifyMask);
-    }
-
-    inited = True;
-}
diff --git a/jdk/src/solaris/native/sun/awt/awt_mgrsel.h b/jdk/src/solaris/native/sun/awt/awt_mgrsel.h
deleted file mode 100644
index fdb9bfa..0000000
--- a/jdk/src/solaris/native/sun/awt/awt_mgrsel.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2003, 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 _AWT_MGRSEL_H_
-#define _AWT_MGRSEL_H_
-
-#ifndef HEADLESS
-
-#include "awt_p.h"
-
-extern void awt_mgrsel_init(void);
-extern int awt_mgrsel_processEvent(XEvent *);
-
-extern const Window * awt_mgrsel_select(const char *, long,
-                                        void *,
-                                        void (*)(int, XEvent *, void *),
-                                        void (*)(int, Window, long *, void *));
-
-#endif /* !HEADLESS */
-#endif /* _AWT_MGRSEL_H_ */
diff --git a/jdk/src/solaris/native/sun/awt/awt_motif.h b/jdk/src/solaris/native/sun/awt/awt_motif.h
deleted file mode 100644
index 011a8dc..0000000
--- a/jdk/src/solaris/native/sun/awt/awt_motif.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2000, 2001, 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 _SWITCHXM_P_H_
-#define _SWITCHXM_P_H_
-
-#include <sun_awt_motif_MComponentPeer.h>
-
-#include "gdefs.h"
-#include <X11/Xlib.h>
-#include <X11/Intrinsic.h>
-
-#define MOTIF_NA  sun_awt_motif_MComponentPeer_MOTIF_NA
-#define MOTIF_V1  sun_awt_motif_MComponentPeer_MOTIF_V1
-#define MOTIF_V2  sun_awt_motif_MComponentPeer_MOTIF_V2
-
-
-extern int32_t awt_motif_getIMStatusHeight(Widget w, jobject tc);
-extern XVaNestedList awt_motif_getXICStatusAreaList(Widget w, jobject tc);
-extern void awt_motif_Scrollbar_ButtonReleaseHandler (Widget,
-                                                      XtPointer,
-                                                      XEvent *,
-                                                      Boolean *) ;
-
-    /* This function causes an UnsatisfiedLinkError on Linux.
-     * It's a no-op for Motif 2.1.
-     * Since Linux only links against Motif 2.1, we can safely remove
-     * this function altogether from the Linux build.
-     * bchristi 1/22/2001
-     */
-#ifdef __solaris__
-extern void awt_motif_adjustDragTriggerEvent(XEvent* xevent);
-#endif
-
-void awt_motif_enableSingleDragInitiator(Widget w);
-
-#endif /* _SWITCHXM_P_H_ */
diff --git a/jdk/src/solaris/native/sun/awt/awt_p.h b/jdk/src/solaris/native/sun/awt/awt_p.h
index 70f1ccf..97d96b3 100644
--- a/jdk/src/solaris/native/sun/awt/awt_p.h
+++ b/jdk/src/solaris/native/sun/awt/awt_p.h
@@ -49,28 +49,6 @@
 #include <X11/keysym.h>
 #include <X11/keysymdef.h>
 #include <X11/extensions/Xrender.h>
-#ifndef XAWT
-#include <Xm/CascadeB.h>
-#include <Xm/DrawingA.h>
-#include <Xm/FileSB.h>
-#include <Xm/BulletinB.h>
-#include <Xm/Form.h>
-#include <Xm/Frame.h>
-#include <Xm/Label.h>
-#include <Xm/PushB.h>
-#include <Xm/PushBG.h>
-#include <Xm/RowColumn.h>
-#include <Xm/ScrollBar.h>
-#include <Xm/ScrolledW.h>
-#include <Xm/SelectioB.h>
-#include <Xm/SeparatoG.h>
-#include <Xm/ToggleB.h>
-#include <Xm/TextF.h>
-#include <Xm/Text.h>
-#include <Xm/List.h>
-#include <Xm/Xm.h>
-#include <Xm/MainW.h>
-#endif
 #endif /* !HEADLESS */
 #include "awt.h"
 #include "awt_util.h"
@@ -78,33 +56,13 @@
 #include "colordata.h"
 #include "gdefs.h"
 
-#ifndef XAWT
-#include "GLXGraphicsConfig.h"
-//#include <sun_awt_motif_MComponentPeer.h>
-#endif
-
 #ifndef HEADLESS
-#ifndef XAWT
-#include "awt_motif.h"
-#endif
 #ifndef min
 #define min(a,b) ((a) <= (b)? (a):(b))
 #endif
 #ifndef max
 #define max(a,b) ((a) >= (b)? (a):(b))
 #endif
-
-extern Pixel awt_pixel_by_name(Display *dpy, char *color, char *defaultColor);
-
-typedef struct DropSiteInfo* DropSitePtr;
-
-struct WidgetInfo {
-    Widget             widget;
-    Widget             origin;
-    void*              peer;
-    jlong              event_mask;
-    struct WidgetInfo* next;
-};
 #endif /* !HEADLESS */
 
 #define RepaintPending_NONE     0
@@ -112,13 +70,6 @@
 #define RepaintPending_EXPOSE   (1 << 1)
 #define LOOKUPSIZE 32
 
-typedef struct _DamageRect {
-    int x1;
-    int y1;
-    int x2;
-    int y2;
-} DamageRect;
-
 #ifndef HEADLESS
 
 typedef XRenderPictFormat *
@@ -157,110 +108,9 @@
 
 typedef AwtScreenData* AwtScreenDataPtr;
 
-struct ComponentData {
-    Widget      widget;
-    int         repaintPending;
-    DamageRect  repaintRect;
-    DamageRect  exposeRect;
-    DropSitePtr dsi;
-};
-
-struct MessageDialogData {
-    struct ComponentData        comp;
-    int                 isModal;
-};
-
-struct CanvasData {
-    struct ComponentData        comp;
-    Widget                      shell;
-    int                         flags;
-};
-
-struct MenuItemData {
-    struct ComponentData        comp;
-    int                         index;
-};
-
-struct MenuData {
-    struct ComponentData        comp;
-    struct MenuItemData         itemData;
-};
-
-
 #define W_GRAVITY_INITIALIZED 1
 #define W_IS_EMBEDDED 2
 
-struct FrameData {
-    struct CanvasData   winData;
-    int                 isModal;
-    Widget              mainWindow;
-    Widget              focusProxy;     /* for all key events */
-    Widget              menuBar;
-    Widget              warningWindow;
-    int                 top;            /* these four are the insets... */
-    int                 bottom;
-    int                 left;
-    int                 right;
-    int                 topGuess;       /* these four are the guessed insets */
-    int                 bottomGuess;
-    int                 leftGuess;
-    int                 rightGuess;
-    int                 mbHeight;       /* height of the menubar window */
-    int                 wwHeight;       /* height of the warning window */
-    jint                state;          /* java.awt.Frame.state bits    */
-    Boolean             reparented;
-    Boolean             configure_seen;
-    Boolean             shellResized;   /* frame shell has been resized */
-    Boolean             canvasResized;  /* frame inner canvas resized   */
-    Boolean             menuBarReset;   /* frame menu bar added/removed */
-    Boolean             isResizable;    /* is this window resizable ?   */
-    Boolean             isFixedSizeSet; /* is fixed size already set ?  */
-    Boolean             isShowing;      /* is this window now showing ? */
-    Boolean             hasTextComponentNative;
-    Boolean             need_reshape;
-    Boolean             callbacksAdded; /* needed for fix for 4078176   */
-    Pixmap              iconPixmap;     /* Pixmap to hold icon image    */
-    int                 iconWidth;
-    int                 iconHeight;
-    int                 imHeight;       /* imStatusBar's height         */
-    Boolean             imRemove;       /* ImStatusBar is being removed */
-    Boolean             fixInsets;      /* [jk] REMINDER: remove if possible */
-    int                 decor;          /* type of native decorations */
-    Boolean             initialFocus;   /* does Window take focus initially */
-    Boolean             isInputMethodWindow;
-
-    /*
-     * Fix for BugTraq ID 4060975.
-     * firstShellEH() stores to this field handle of the widget that had
-     * focus before the shell was resized so that we can later restore it.
-     */
-    Widget              focusWidget;
-    int screenNum;      /* Which screen this Window is on.  Xinerama-aware. */
-    Boolean             isDisposeScheduled;
-    Boolean             isFocusableWindow;  /* a cache of Window.isFocusableWindow() return value */
-};
-
-struct ListData {
-    struct ComponentData comp;
-    Widget               list;
-};
-
-struct TextAreaData {
-    struct ComponentData comp;
-    Widget               txt;
-};
-
-struct TextFieldData {
-    struct ComponentData comp;
-    int                  echoContextID;
-    Boolean              echoContextIDInit;
-};
-
-struct FileDialogData {
-    struct ComponentData comp;
-    char        *file;
-};
-
 typedef struct awtFontList {
     char *xlfd;
     int index_length;
@@ -276,33 +126,6 @@
     XFontStruct *xfont; /* Latin1 font */
 };
 
-#ifndef XAWT
-extern XmFontList getMotifFontList(void);
-extern XFontSet getMotifFontSet(void);
-extern XFontStruct *getMotifFontStruct(void);
-extern Boolean awt_isAwtWidget(Widget widget);
-#endif
-
-struct ChoiceData {
-    struct ComponentData comp;
-    Widget               menu;
-    Widget               *items;
-    int                  maxitems;
-    int                  n_items;
-    short                n_columns;
-/* Bug 4255631 Solaris: Size returned by Choice.getSize() does not match
- * actual size
- * y and height which Choice takes in pReshape
-*/
-    jint                 bounds_y;
-    jint                 bounds_height;
-};
-
-struct MenuList {
-    Widget menu;
-    struct MenuList* next;
-};
-
 extern struct FontData *awtJNI_GetFontData(JNIEnv *env,jobject font, char **errmsg);
 
 extern AwtGraphicsConfigDataPtr getDefaultConfig(int screen);
@@ -315,20 +138,6 @@
 #ifndef HEADLESS
 #define XDISPLAY awt_display;
 
-extern Boolean awt_currentThreadIsPrivileged(JNIEnv *env);
-extern void null_event_handler(Widget w, XtPointer client_data,
-                        XEvent * event, Boolean * cont);
-
-extern void awt_put_back_event(JNIEnv *env, XEvent *event);
-extern void awt_MToolkit_modalWait(int (*terminateFn)(void *data), void *data);
-extern void awt_Frame_guessInsets(struct FrameData *fdata);
-
-extern void awt_addWidget(Widget w, Widget origin, void *peer, jlong event_mask);
-extern void awt_delWidget(Widget w);
-
-extern void awt_addMenuWidget(Widget w);
-extern void awt_delMenuWidget(Widget w);
-
 extern int awt_allocate_colors(AwtGraphicsConfigDataPtr);
 extern void awt_allocate_systemcolors(XColor *, int, AwtGraphicsConfigDataPtr);
 extern void awt_allocate_systemrgbcolors(jint *, int, AwtGraphicsConfigDataPtr);
@@ -338,24 +147,5 @@
 extern jobject awtJNI_GetColorModel(JNIEnv *, AwtGraphicsConfigDataPtr);
 extern void awtJNI_CreateColorData (JNIEnv *, AwtGraphicsConfigDataPtr, int lock);
 
-extern Boolean awtJNI_isSelectionOwner(JNIEnv *env, char *sel_str);
-extern void awtJNI_notifySelectionLost(JNIEnv *env, char *sel_str);
-extern void removePopupMenus();
-extern Boolean awtMenuIsActive();
 #endif /* !HEADLESS */
-
-extern void awtJNI_DeleteGlobalRef(JNIEnv *env,jobject thiscomp);
-extern void awtJNI_DeleteGlobalMenuRef(JNIEnv *env,jobject thismenu);
-extern jobject awtJNI_CreateAndSetGlobalRef(JNIEnv *env,jobject thiscomp);
-extern void awtJNI_CleanupGlobalRefs(void);
-
-#ifndef HEADLESS
-/* XXX: Motif internals. Need to fix 4090493. */
-#define MOTIF_XmINVALID_DIMENSION       ((Dimension) 0xFFFF)
-#define MOTIF_XmDEFAULT_INDICATOR_DIM   ((Dimension) 9)
-
-extern Dimension awt_computeIndicatorSize(struct FontData *fdata);
-extern Dimension awt_adjustIndicatorSizeForMenu(Dimension indSize);
-#endif /* !HEADLESS */
-
 #endif           /* _AWT_P_H_ */
diff --git a/jdk/src/solaris/native/sun/awt/awt_util.c b/jdk/src/solaris/native/sun/awt/awt_util.c
index bf48c09..f1f897c 100644
--- a/jdk/src/solaris/native/sun/awt/awt_util.c
+++ b/jdk/src/solaris/native/sun/awt/awt_util.c
@@ -29,31 +29,15 @@
 
 #include "awt_p.h"
 #include "color.h"
-#include "awt_TopLevel.h"
 #include <X11/IntrinsicP.h>
 #include <X11/Xatom.h>
 #include <X11/Xmd.h>
 #include <X11/Xutil.h>
 #include <X11/Xproto.h>
-#ifndef XAWT
-#include <Xm/MenuShell.h>
-#include <Xm/List.h>
-#include <Xm/Form.h>
-#include <Xm/RowColumn.h>
-#include <Xm/MwmUtil.h>
-#endif /* XAWT */
 #include <jni.h>
 #include <jni_util.h>
 #include <sys/time.h>
 
-#include "awt_xembed.h"
-
-
-#ifndef XAWT
-#if MOTIF_VERSION!=1
-    #include <Xm/GrabShell.h>
-#endif
-#endif
 
 #include "java_awt_event_MouseWheelEvent.h"
 
@@ -72,7 +56,6 @@
 extern jint getModifiers(uint32_t state, jint button, jint keyCode);
 extern jint getButton(uint32_t button);
 
-static int32_t winmgr_running = 0;
 static Atom OLDecorDelAtom = 0;
 static Atom MWMHints = 0;
 static Atom DTWMHints = 0;
@@ -86,840 +69,6 @@
 #define MIN(a,b) ((a) < (b) ? (a) : (b))
 #endif
 
-#ifndef XAWT
-/*
- * The following three funtions are to work around menu problems
- */
-
-/*
- * test if there is a menu that has the current focus
- * called from awt_Dialog.c and awt_Component.c
- */
-Boolean
-awt_util_focusIsOnMenu(Display *display)
-{
-  Window window;
-  Widget widget;
-  int32_t rtr;
-
-  XGetInputFocus(display, &window, &rtr);
-  if (window == None) {
-    return False;
-  }
-
-  widget = XtWindowToWidget(display, window);
-  if (widget == NULL) {
-    return False;
-  }
-
-  if (XtIsSubclass(widget, xmMenuShellWidgetClass)) {
-    return True;
-  }
-
-  #if MOTIF_VERSION!=1
-  /* Motif 2.1 uses XmGrabShell on XmComboBox instead
-     of XmMenuShell
-  */
-  if (XtIsSubclass(widget, xmGrabShellWidgetClass)) {
-      return True;
-  }
-  /* Fix 4800638 check the ancestor of focus widget is
-     GrabSell
-   */
-  if (XtIsSubclass(widget, xmListWidgetClass))
-  {
-      Widget shell = getShellWidget(widget);
-      if (shell && XtIsSubclass(shell,
-          xmGrabShellWidgetClass))
-      {
-          return True;
-      }
-  }
-  #endif
-
-  if (XtIsSubclass(widget, xmRowColumnWidgetClass)) {
-      unsigned char type;
-      XtVaGetValues(widget, XmNrowColumnType, &type, NULL);
-      if (type == XmMENU_BAR) {
-          return True;
-      }
-  }
-  return False;
-}
-
-static
-void fillButtonEvent(XButtonEvent *ev, int32_t type, Display *display, Window window) {
-    ev->type = type;
-    ev->display = display;
-    ev->window = window;
-    ev->send_event = True;
-
-    /* REMIND: multi-screen */
-    ev->root = RootWindow(display, DefaultScreen(display));
-    ev->subwindow = (Window)None;
-    ev->time = CurrentTime;
-    ev->x = 0;
-    ev->y = 0;
-    ev->x_root = 0;
-    ev->y_root = 0;
-    ev->same_screen = True;
-    ev->button = Button1;
-    ev->state = Button1Mask;
-}
-
-/*
- * generates a mouse press event and a release event
- * called from awt_Dialog.c
- */
-int32_t
-awt_util_sendButtonClick(Display *display, Window window)
-{
-  XButtonEvent ev;
-  int32_t status;
-
-  fillButtonEvent(&ev, ButtonPress, display, window);
-  status = XSendEvent(display, window, True, ButtonPressMask, (XEvent *)&ev);
-
-  if (status != 0) {
-      fillButtonEvent(&ev, ButtonRelease, display, window);
-      status = XSendEvent(display, window, False, ButtonReleaseMask,
-                          (XEvent *)&ev);
-  }
-  return status;
-}
-
-Widget
-awt_util_createWarningWindow(Widget parent, char *warning)
-{
-    Widget warningWindow;
-#ifdef NETSCAPE
-    extern Widget FE_MakeAppletSecurityChrome(Widget parent, char* message);
-    warningWindow = FE_MakeAppletSecurityChrome(parent, warning);
-#else
-    Widget label;
-    int32_t argc;
-#define MAX_ARGC 10
-    Arg args[MAX_ARGC];
-    int32_t screen = 0;
-    int32_t i;
-    AwtGraphicsConfigDataPtr adata;
-    extern int32_t awt_numScreens;
-
-    Pixel gray;
-    Pixel black;
-
-    for (i = 0; i < awt_numScreens; i++) {
-        if (ScreenOfDisplay(awt_display, i) == XtScreen(parent)) {
-            screen = i;
-            break;
-        }
-    }
-    adata = getDefaultConfig(screen);
-
-    gray = adata->AwtColorMatch(192, 192, 192, adata);
-    black = adata->AwtColorMatch(0, 0, 0, adata);
-
-    argc = 0;
-    XtSetArg(args[argc], XmNbackground, gray); argc++;
-    XtSetArg(args[argc], XmNmarginHeight, 0); argc++;
-    XtSetArg(args[argc], XmNmarginWidth, 0); argc++;
-    XtSetArg (args[argc], XmNscreen, XtScreen(parent)); argc++;
-
-    DASSERT(!(argc > MAX_ARGC));
-    warningWindow =  XmCreateForm(parent, "main", args, argc);
-
-    XtManageChild(warningWindow);
-    label = XtVaCreateManagedWidget(warning,
-                                    xmLabelWidgetClass, warningWindow,
-                                    XmNhighlightThickness, 0,
-                                    XmNbackground, gray,
-                                    XmNforeground, black,
-                                    XmNalignment, XmALIGNMENT_CENTER,
-                                    XmNrecomputeSize, False,
-                                    NULL);
-    XtVaSetValues(label,
-                  XmNbottomAttachment, XmATTACH_FORM,
-                  XmNtopAttachment, XmATTACH_FORM,
-                  XmNleftAttachment, XmATTACH_FORM,
-                  XmNrightAttachment, XmATTACH_FORM,
-                  NULL);
-#endif
-    return warningWindow;
-}
-
-void
-awt_setWidgetGravity(Widget w, int32_t gravity)
-{
-    XSetWindowAttributes    xattr;
-    Window  win = XtWindow(w);
-
-    if (win != None) {
-        xattr.bit_gravity = StaticGravity;
-        xattr.win_gravity = StaticGravity;
-        XChangeWindowAttributes(XtDisplay(w), win,
-                                CWBitGravity|CWWinGravity,
-                                &xattr);
-    }
-}
-
-Widget get_shell_focused_widget(Widget w) {
-    while (w != NULL && !XtIsShell(w)) {
-        w = XtParent(w);
-    }
-    if (w != NULL) {
-        return XmGetFocusWidget(w);
-    } else {
-        return NULL;
-    }
-}
-
-void
-awt_util_reshape(Widget w, jint x, jint y, jint wd, jint ht)
-{
-    Widget parent;
-    Dimension ww, wh;
-    Position wx, wy;
-    Boolean move = False;
-    Boolean resize = False;
-    Boolean mapped_when_managed = False;
-    Boolean need_to_unmanage = True;
-    Widget saved_focus_widget = NULL;
-
-    if (w == NULL) {
-        JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
-        JNU_ThrowNullPointerException(env,"NullPointerException");
-        return;
-    }
-    parent = XtParent(w);
-
-    /* Aim: hack to prevent direct children of scrollpane from
-     * being unmanaged during a reshape operation (which results
-     * in too many expose events).
-     */
-    if (parent != NULL && XtParent(parent) != NULL &&
-        XtIsSubclass(XtParent(parent), xmScrolledWindowWidgetClass)) {
-        need_to_unmanage = False;
-    }
-
-    XtVaGetValues(w,
-                  XmNwidth, &ww,
-                  XmNheight, &wh,
-                  XmNx, &wx,
-                  XmNy, &wy,
-                  NULL);
-
-    if (x != wx || y != wy) {
-        move = True;
-    }
-    if (wd != ww || ht != wh) {
-        resize = True;
-    }
-    if (!move && !resize) {
-        return;
-    }
-
-    if (need_to_unmanage) {
-        if (!resize) {
-            mapped_when_managed = w->core.mapped_when_managed;
-            w->core.mapped_when_managed = False;
-        }
-        saved_focus_widget = get_shell_focused_widget(w);
-        XtUnmanageChild(w);
-    }
-
-    /* GES: AVH's hack:
-     * Motif ignores attempts to move a toplevel window to 0,0.
-     * Instead we set the position to 1,1. The expected value is
-     * returned by Frame.getBounds() since it uses the internally
-     * held rectangle rather than querying the peer.
-     * N.B. [pauly, 9/97]  This is only required for wm shells
-     * under the Motif Window Manager (MWM), not for any others.
-     * Note. Utilizes C short-circuiting if w is not a wm shell.
-     */
-    if ((x == 0) && (y == 0) &&
-        (XtIsSubclass(w, wmShellWidgetClass)) &&
-        (XmIsMotifWMRunning(w))) {
-        XtVaSetValues(w, XmNx, 1, XmNy, 1, NULL);
-    }
-
-    if (move && !resize) {
-        XtVaSetValues(w, XmNx, x, XmNy, y, NULL);
-
-    } else if (resize && !move) {
-        XtVaSetValues(w,
-                      XmNwidth, (wd > 0) ? wd : 1,
-                      XmNheight, (ht > 0) ? ht : 1,
-                      NULL);
-
-    } else  {
-        XtVaSetValues(w,
-                  XmNx, x,
-                  XmNy, y,
-                  XmNwidth, (wd > 0) ? wd : 1,
-                  XmNheight, (ht > 0) ? ht : 1,
-                  NULL);
-    }
-
-    if (need_to_unmanage) {
-        XtManageChild(w);
-        if (!resize) {
-            w->core.mapped_when_managed = mapped_when_managed;
-        }
-        if (saved_focus_widget != NULL) {
-            Boolean result = XmProcessTraversal(saved_focus_widget, XmTRAVERSE_CURRENT);
-            if (!result)
-            {
-                Widget shell = saved_focus_widget;
-                while(shell != NULL && !XtIsShell(shell)) {
-                    shell = XtParent(shell);
-                }
-                XtSetKeyboardFocus(shell, saved_focus_widget);
-            }
-        }
-    }
-}
-
-void
-awt_util_hide(Widget w)
-{
-    if (w == NULL) {
-        JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
-        JNU_ThrowNullPointerException(env,"NullPointerException");
-        return;
-    }
-    XtSetMappedWhenManaged(w, False);
-}
-
-void
-awt_util_show(Widget w)
-{
-/*
-    extern Boolean  scrollBugWorkAround;
-*/
-    if (w == NULL) {
-        JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
-        JNU_ThrowNullPointerException(env,"NullPointerException");
-        return;
-    }
-    XtSetMappedWhenManaged(w, True);
-/*
-  XXX: causes problems on 2.5
-    if (!scrollBugWorkAround) {
-        awt_setWidgetGravity(w, StaticGravity);
-    }
-*/
-}
-
-void
-awt_util_enable(Widget w)
-{
-    XtSetSensitive(w, True);
-}
-
-void
-awt_util_disable(Widget w)
-{
-    XtSetSensitive(w, False);
-}
-
-void
-awt_util_mapChildren(Widget w, void (*func)(Widget,void *),
-                     int32_t applyToCurrent, void *data) {
-    WidgetList                  wlist;
-    Cardinal                    wlen = 0;
-    Cardinal                    i;
-
-    /* The widget may have been destroyed by another thread. */
-    if ((w == NULL) || (!XtIsObject(w)) || (w->core.being_destroyed))
-        return;
-
-    if (applyToCurrent != 0) {
-        (*func)(w, data);
-    }
-    if (!XtIsComposite(w)) {
-        return;
-    }
-
-    XtVaGetValues(w,
-                  XmNchildren, &wlist,
-                  XmNnumChildren, &wlen,
-                  NULL);
-    if (wlen > 0) {
-        for (i=0; i < wlen; i++) {
-            awt_util_mapChildren(wlist[i], func, 1, data);
-        }
-    }
-}
-
-void
-awt_changeAttributes(Display *dpy, Widget w, unsigned long mask,
-                     XSetWindowAttributes *xattr)
-{
-    WidgetList          wlist;
-    Cardinal            wlen = 0;
-    Cardinal            i;
-
-    if (XtWindow(w) && XtIsRealized(w)) {
-        XChangeWindowAttributes(dpy,
-                                XtWindow(w),
-                                mask,
-                                xattr);
-    } else {
-        return;
-    }
-    XtVaGetValues(w,
-                  XmNchildren, &wlist,
-                  XmNnumChildren, &wlen,
-                  NULL);
-    for (i = 0; i < wlen; i++) {
-        if (XtWindow(wlist[i]) && XtIsRealized(wlist[i])) {
-            XChangeWindowAttributes(dpy,
-                                    XtWindow(wlist[i]),
-                                    mask,
-                                    xattr);
-        }
-    }
-}
-
-static Widget prevWgt = NULL;
-
-static void
-DestroyCB(Widget w, XtPointer client_data, XtPointer call_data) {
-    if (prevWgt == w) {
-        prevWgt = NULL;
-    }
-}
-
-int32_t
-awt_util_setCursor(Widget w, Cursor c) {
-    static Cursor prevCur = None;
-
-    if (XtIsRealized(w)) {
-        unsigned long valuemask = 0;
-        XSetWindowAttributes    attributes;
-
-        valuemask = CWCursor;
-        if (prevWgt != NULL) {
-            attributes.cursor = None;
-            XChangeWindowAttributes(awt_display,
-                        XtWindow(prevWgt),
-                        valuemask,
-                        &attributes);
-        }
-
-        if (c == None) {
-            c = prevCur;
-            if (w != NULL) {
-                XtAddCallback(w, XmNdestroyCallback, DestroyCB, NULL);
-            }
-            prevWgt = w;
-        } else {
-            prevCur = c;
-            prevWgt = NULL;
-        }
-        attributes.cursor = c;
-        XChangeWindowAttributes(awt_display,
-                                XtWindow(w),
-                                valuemask,
-                                &attributes);
-        XFlush(awt_display);
-        return 1;
-    } else
-        return 0;
-}
-
-void
-awt_util_convertEventTimeAndModifiers(XEvent *event,
-                                      ConvertEventTimeAndModifiers *output) {
-    switch (event->type) {
-    case KeyPress:
-    case KeyRelease:
-        output->when = awt_util_nowMillisUTC_offset(event->xkey.time);
-        output->modifiers = getModifiers(event->xkey.state, 0, 0);
-        break;
-    case ButtonPress:
-    case ButtonRelease:
-        output->when = awt_util_nowMillisUTC_offset(event->xbutton.time);
-        output->modifiers = getModifiers(event->xbutton.state,
-            getButton(event->xbutton.button), 0);
-        break;
-    default:
-        output->when = awt_util_nowMillisUTC();
-        output->modifiers =0;
-        break;
-    }
-}
-
-
-/*
-  Part fix for bug id 4017222. Return the widget at the given screen coords
-  by searching the widget tree beginning at root. This function will return
-  null if the pointer is not over the root widget or child of the root widget.
-
-  Additionally, this function will only return a Widget with non-nil XmNuserData.
-  In 1.2.1, when the mouse was dragged over a Choice component, this function
-  returned the GadgetButton associated with the Choice.  This GadgetButton had
-  nil as its XmNuserData.  This lead to a crash when the nil XmNuserData was
-  extracted and used as a reference to a peer.  Ooops.
-  Now the GadgetButton is not returned and the function goes on to find a widget
-  which contains the correct peer reference in XmNuserData.
-*/
-Widget
-awt_WidgetAtXY(Widget root, Position pointerx, Position pointery) {
-  Widget answer = NULL;
-
-  if(!root) return NULL;
-
-  if(XtIsComposite(root)) {
-    int32_t i=0;
-    WidgetList wl=NULL;
-    Cardinal wlen=0;
-
-    XtVaGetValues(root, XmNchildren, &wl, XmNnumChildren, &wlen, NULL);
-
-    if(wlen>0) {
-      for(i=0; i<wlen && !answer; i++) {
-        answer = awt_WidgetAtXY(wl[i], pointerx, pointery);
-      }
-    }
-  }
-
-  if(!answer) {
-    Position wx=0, wy=0;
-    Dimension width=0, height=0;
-    int32_t lastx=0, lasty=0;
-    XtPointer widgetUserData=NULL;
-
-    XtVaGetValues(root, XmNwidth, &width, XmNheight, &height,
-                  XmNuserData, &widgetUserData,
-                  NULL);
-
-    XtTranslateCoords(root, 0, 0, &wx, &wy);
-    lastx = wx + width;
-    lasty = wy + height;
-
-    if(pointerx>=wx && pointerx<=lastx && pointery>=wy && pointery<=lasty &&
-           widgetUserData)
-        answer = root;
-  }
-
-  return answer;
-}
-#ifdef __linux__
-
-
-#define MAXARGS 10
-static Arg xic_vlist[MAXARGS];
-static Arg status_vlist[MAXARGS];
-static Arg preedit_vlist[MAXARGS];
-
-#define NO_ARG_VAL -1
-#define SEPARATOR_HEIGHT 2
-
-static XFontSet extract_fontset(XmFontList);
-
-/* get_im_height: returns height of the input method status area in pixels.
- *
- * This function assumes that if any XIM related information cannot be
- * queried then the app must not have an input method status area in the
- * current locale and returns zero as the status area height
- */
-
-static XtPointer*
-get_im_info_ptr(Widget  w,
-                Boolean create)
-{
-  Widget p;
-  XmVendorShellExtObject ve;
-  XmWidgetExtData extData;
-  XmImShellInfo im_info;
-  XmImDisplayInfo xim_info;
-
-  if (w == NULL)
-    return NULL;
-
-  p = w;
-  while (!XtIsShell(p))
-    p = XtParent(p);
-
-  /* Check extension data since app could be attempting to create
-   * a text widget as child of menu shell.  This is illegal, and will
-   * be detected later, but check here so we don't core dump.
-   */
-  if ((extData = _XmGetWidgetExtData((Widget)p, XmSHELL_EXTENSION)) == NULL)
-    return NULL;
-
-  ve = (XmVendorShellExtObject) extData->widget;
-
-  return &ve->vendor.im_info;
-}
-
-static XmImShellInfo
-get_im_info(Widget w,
-            Boolean create)
-{
-  XmImShellInfo* ptr = (XmImShellInfo *) get_im_info_ptr(w, create);
-  if (ptr != NULL)
-    return *ptr;
-  else
-    return NULL;
-}
-
-#endif /* !linux */
-
-Widget
-awt_util_getXICStatusAreaWindow(Widget w)
-{
-    while (!XtIsShell(w)){
-        w = XtParent(w);
-    }
-    return w;
-}
-
-#ifdef __linux__
-static XRectangle geometryRect;
-XVaNestedList awt_util_getXICStatusAreaList(Widget w)
-{
-    XIC xic;
-    XmImXICInfo icp;
-    XmVendorShellExtObject ve;
-    XmWidgetExtData extData;
-    XmImShellInfo im_info;
-    XmFontList fl=NULL;
-
-    XRectangle  *ssgeometry = &geometryRect;
-    XRectangle geomRect ;
-    XRectangle *im_rect;
-    XFontSet   *im_font;
-
-    Pixel bg ;
-    Pixel fg ;
-    Dimension height, width ;
-    Position x,y ;
-    Pixmap bpm, *bpmout ;
-
-    XVaNestedList list = NULL;
-
-    char *ret;
-    Widget p=w;
-
-    while (!XtIsShell(p)) {
-        p = XtParent(p);
-    }
-
-    XtVaGetValues(p,
-        XmNx, &x,
-        XmNy, &y,
-        XmNwidth, &width,
-        XmNheight, &height,
-        XmNbackgroundPixmap, &bpm,
-        NULL);
-
-    extData = _XmGetWidgetExtData((Widget) p, XmSHELL_EXTENSION);
-    if (extData == NULL) {
-        return NULL;
-    }
-    ve = (XmVendorShellExtObject) extData->widget;
-    im_info = get_im_info(w, False);
-
-    if (im_info == NULL) {
-        return NULL;
-    } else {
-        icp = im_info->iclist;
-    }
-
-    if (icp) {
-        /*
-         * We have at least a textfield/textarea in the frame, use the
-         * first one.
-         */
-        ssgeometry->x = 0;
-        ssgeometry->y = height - icp->sp_height;
-        ssgeometry->width = icp->status_width;
-        ssgeometry->height = icp->sp_height;
-        XtVaGetValues(w, XmNbackground, &bg, NULL);
-        XtVaGetValues(w, XmNforeground, &fg, NULL);
-        XtVaGetValues(w, XmNfontList, &fl, NULL);
-        /*
-         * use motif TextComponent's resource
-         */
-
-        list = XVaCreateNestedList(0,
-                        XNFontSet, extract_fontset(fl),
-                        XNArea, ssgeometry,
-                        XNBackground, bg,
-                        XNForeground, fg,
-                        NULL);
-   }
-   return list ;
-}
-
-static XFontSet
-extract_fontset(XmFontList fl)
-{
-    XmFontContext context;
-    XmFontListEntry next_entry;
-    XmFontType type_return;
-    XtPointer tmp_font;
-    XFontSet first_fs = NULL;
-    char *font_tag;
-
-    if (!XmFontListInitFontContext(&context, fl))
-        return NULL;
-
-    do {
-        next_entry = XmFontListNextEntry(context);
-        if (next_entry) {
-            tmp_font = XmFontListEntryGetFont(next_entry, &type_return);
-            if (type_return == XmFONT_IS_FONTSET) {
-                font_tag = XmFontListEntryGetTag(next_entry);
-                if (!strcmp(font_tag, XmFONTLIST_DEFAULT_TAG)) {
-                    XmFontListFreeFontContext(context);
-                    XtFree(font_tag);
-                    return (XFontSet) tmp_font;
-                }
-                XtFree(font_tag);
-                if (first_fs == NULL)
-                    first_fs = (XFontSet) tmp_font;
-            }
-        }
-    } while (next_entry);
-
-    XmFontListFreeFontContext(context);
-    return first_fs;
-}
-#endif
-
-/*the caller does have the responsibility to free the memory return
-  from this function...*/
-char* awt_util_makeWMMenuItem(char *target, Atom protocol){
-    char        *buf = NULL;
-    int32_t         buflen = 0;
-
-    /*a label in a menuitem is not supposed to be a FullOfSpaceString... */
-    buflen = strlen(target) * 3;
-    buf = (char*)malloc(buflen + 20);
-    if (buf == NULL){
-        JNU_ThrowOutOfMemoryError((JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2), NULL);
-    }
-    else{
-      int32_t   off = 0;
-      char  *ptr = target;
-      while ((off < (buflen - 20)) && (*ptr != '\0')){
-        if (*ptr == ' '){
-          *(buf + off++) = 0x5c;
-        }
-        *(buf + off++) = *ptr++;
-      }
-      sprintf(buf + off, " f.send_msg %ld", protocol);
-    }
-    return buf;
-}
-
-/*
- * This callback proc is installed via setting the XmNinsertPosition
- * resource on a widget. It ensures that components added
- * to a widget are inserted in the correct z-order position
- * to match up with their peer/target ordering in Container.java
- */
-Cardinal
-awt_util_insertCallback(Widget w)
-{
-    jobject peer;
-    WidgetList children;
-    Cardinal num_children;
-    Widget parent;
-    XtPointer userdata;
-    Cardinal index;
-    int32_t pos;
-    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
-
-    parent = XtParent(w);
-    XtVaGetValues(parent,
-                  XmNnumChildren, &num_children,
-                  XmNchildren, &children,
-                  NULL);
-    XtVaGetValues(w, XmNuserData, &userdata, NULL);
-
-    index = num_children;         /* default is to add to end */
-
-    if (userdata != NULL) {
-        peer = (jobject) userdata;
-
-        // SECURITY: We are running on the privileged toolkit thread.
-        //           The peer must *NOT* call into user code
-        pos = (int32_t) JNU_CallMethodByName(env
-                                          ,NULL
-                                          ,(jobject) peer
-                                          ,"getZOrderPosition_NoClientCode"
-                                          ,"()I").i;
-        if ((*env)->ExceptionOccurred(env)) {
-            (*env)->ExceptionDescribe(env);
-            (*env)->ExceptionClear(env);
-        }
-        index = (Cardinal) (pos != -1 ? pos : num_children);
-    }
-    return index;
-}
-
-void
-awt_util_consumeAllXEvents(Widget widget)
-{
-    /* Remove all queued X Events for the window of the widget. */
-
-#define ALL_EVENTS_MASK 0xFFFF
-
-    XEvent xev;
-
-    XFlush(awt_display);
-    while (XCheckWindowEvent(awt_display, XtWindow(widget),
-               ALL_EVENTS_MASK, &xev)) ;
-}
-
-#endif /* XAWT */
-/**
- * Gets the thread we are currently executing on
- */
-jobject
-awtJNI_GetCurrentThread(JNIEnv *env) {
-    static jclass threadClass = NULL;
-    static jmethodID currentThreadMethodID = NULL;
-
-    jobject currentThread = NULL;
-
-    /* Initialize our java identifiers once. Checking before locking
-     * is a huge performance win.
-     */
-    if (threadClass == NULL) {
-        // should enter a monitor here...
-        Boolean err = FALSE;
-        if (threadClass == NULL) {
-            jclass tc = (*env)->FindClass(env, "java/lang/Thread");
-            threadClass = (*env)->NewGlobalRef(env, tc);
-            if (threadClass != NULL) {
-                currentThreadMethodID = (*env)->GetStaticMethodID(env,
-                                              threadClass,
-                                              "currentThread",
-                                              "()Ljava/lang/Thread;"
-                                                );
-            }
-        }
-        if (currentThreadMethodID == NULL) {
-            threadClass = NULL;
-            err = TRUE;
-        }
-        if (err) {
-            return NULL;
-        }
-    } /* threadClass == NULL*/
-
-    currentThread = (*env)->CallStaticObjectMethod(
-                        env, threadClass, currentThreadMethodID);
-    DASSERT(!((*env)->ExceptionOccurred(env)));
-    /*JNU_PrintString(env, "getCurrentThread() -> ", JNU_ToString(env,currentThread));*/
-    return currentThread;
-} /* awtJNI_GetCurrentThread() */
-
 void
 awtJNI_ThreadYield(JNIEnv *env) {
 
@@ -956,426 +105,3 @@
     (*env)->CallStaticVoidMethod(env, threadClass, yieldMethodID);
     DASSERT(!((*env)->ExceptionOccurred(env)));
 } /* awtJNI_ThreadYield() */
-
-#ifndef XAWT
-
-void
-awt_util_cleanupBeforeDestroyWidget(Widget widget)
-{
-    /* Bug 4017222: Drag processing uses global prevWidget. */
-    if (widget == prevWidget) {
-        prevWidget = NULL;
-    }
-}
-
-static Boolean timeStampUpdated = False;
-
-static int32_t
-isTimeStampUpdated(void* p) {
-    return timeStampUpdated;
-}
-
-static void
-propertyChangeEventHandler(Widget w, XtPointer client_data,
-                           XEvent* event, Boolean* continue_to_dispatch) {
-    timeStampUpdated = True;
-}
-
-/*
- * If the application doesn't receive events with timestamp for a long time
- * XtLastTimestampProcessed() will return out-of-date value. This may cause
- * selection handling routines to fail (see BugTraq ID 4085183).
- * This routine is to resolve this problem. It queries the current X server
- * time by appending a zero-length data to a property as prescribed by
- * X11 Reference Manual.
- * Note that this is a round-trip request, so it can be slow. If you know
- * that the Xt timestamp is up-to-date use XtLastTimestampProcessed().
- */
-Time
-awt_util_getCurrentServerTime() {
-
-    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
-    static Atom _XA_JAVA_TIME_PROPERTY_ATOM = 0;
-    Time server_time = 0;
-
-    AWT_LOCK();
-
-    if (_XA_JAVA_TIME_PROPERTY_ATOM == 0) {
-        XtAddEventHandler(awt_root_shell, PropertyChangeMask, False,
-                          propertyChangeEventHandler, NULL);
-        _XA_JAVA_TIME_PROPERTY_ATOM = XInternAtom(awt_display, "_SUNW_JAVA_AWT_TIME", False);
-    }
-
-    timeStampUpdated = False;
-    XChangeProperty(awt_display, XtWindow(awt_root_shell),
-                    _XA_JAVA_TIME_PROPERTY_ATOM, XA_ATOM, 32, PropModeAppend,
-                    (unsigned char *)"", 0);
-    XFlush(awt_display);
-
-    if (awt_currentThreadIsPrivileged(env)) {
-        XEvent event;
-        XMaskEvent(awt_display, PropertyChangeMask, &event);
-        XtDispatchEvent(&event);
-    } else {
-        awt_MToolkit_modalWait(isTimeStampUpdated, NULL);
-    }
-    server_time = XtLastTimestampProcessed(awt_display);
-
-    AWT_UNLOCK();
-
-    return server_time;
-}
-
-/*
- * This function is stolen from /src/solaris/hpi/src/system_md.c
- * It is used in setting the time in Java-level InputEvents
- */
-jlong
-awt_util_nowMillisUTC()
-{
-    struct timeval t;
-    gettimeofday(&t, NULL);
-    return ((jlong)t.tv_sec) * 1000 + (jlong)(t.tv_usec/1000);
-}
-
-/*
- * This function converts between the X server time (number of milliseconds
- * since the last server reset) and the UTC time for the 'when' field of an
- * InputEvent (or another event type with a timestamp).
- */
-jlong
-awt_util_nowMillisUTC_offset(Time server_offset)
-{
-    /*
-     * Because Time is of type 'unsigned long', it is possible that Time will
-     * never wrap when using 64-bit Xlib. However, if a 64-bit client
-     * connects to a 32-bit server, I suspect the values will still wrap. So
-     * we should not attempt to remove the wrap checking even if _LP64 is
-     * true.
-     */
-    static const jlong WRAP_TIME_MILLIS = (jlong)((uint32_t)-1);
-    static jlong reset_time_utc;
-
-    jlong current_time_utc = awt_util_nowMillisUTC();
-
-    if ((current_time_utc - reset_time_utc) > WRAP_TIME_MILLIS) {
-        reset_time_utc = awt_util_nowMillisUTC() -
-            awt_util_getCurrentServerTime();
-    }
-
-    return reset_time_utc + server_offset;
-}
-
-void awt_util_do_wheel_scroll(Widget scrolled_window, jint scrollType,
-                              jint scrollAmt, jint wheelAmt) {
-    Widget scrollbar = NULL;
-    int value;
-    int slider_size;
-    int min;
-    int max;
-    int increment;
-    int page_increment;
-    int scrollAdjustment;
-    int newValue;
-
-    /* TODO:
-     * If a TextArea's scrollbar policy is set to never, it should still
-     * wheel scroll, but right now it doesn't.
-     */
-
-    scrollbar = awt_util_get_scrollbar_to_scroll(scrolled_window);
-    if (scrollbar == NULL) { /* no suitable scrollbar for scrolling */
-        return;
-    }
-
-    XtVaGetValues(scrollbar, XmNvalue, &value,
-                             XmNsliderSize, &slider_size,
-                             XmNminimum, &min,
-                             XmNmaximum, &max,
-                             XmNincrement, &increment,
-                             XmNpageIncrement, &page_increment, NULL);
-
-    if (scrollType == java_awt_event_MouseWheelEvent_WHEEL_BLOCK_SCROLL) {
-        scrollAdjustment = page_increment;
-    }
-    else { // WHEEL_UNIT_SCROLL
-        scrollAdjustment = increment * scrollAmt;
-    }
-
-    if (wheelAmt < 0) {
-        // Don't need to check that newValue < max - slider_size because
-        // newValue < current value.  If scrollAmt is ever user-configurable,
-        // we'll have to check this.
-        newValue = MAX(min, value+ (scrollAdjustment * wheelAmt));
-    }
-    else {
-        newValue = MIN(max - slider_size,
-                       value + (scrollAdjustment * wheelAmt));
-    }
-
-    XtVaSetValues(scrollbar, XmNvalue, newValue, NULL);
-    XtCallCallbacks(scrollbar, XmNvalueChangedCallback, NULL);
-}
-
-
-/* Given a ScrollWindow widget, return the Scrollbar that the wheel should
- * scroll.  A null return value means that the ScrollWindow has a scrollbar
- * display policy of none, or that neither scrollbar can be scrolled.
- */
-Widget awt_util_get_scrollbar_to_scroll(Widget scrolled_window) {
-    Widget scrollbar = NULL;
-    int value;
-    int slider_size;
-    int min;
-    int max;
-
-    /* first, try the vertical scrollbar */
-    XtVaGetValues(scrolled_window, XmNverticalScrollBar, &scrollbar, NULL);
-    if (scrollbar != NULL) {
-        XtVaGetValues(scrollbar, XmNvalue, &value,
-                                 XmNsliderSize, &slider_size,
-                                 XmNminimum, &min,
-                                 XmNmaximum, &max, NULL);
-        if (slider_size < max - min) {
-            return scrollbar;
-        }
-    }
-
-    /* then, try the horiz */
-    XtVaGetValues(scrolled_window, XmNhorizontalScrollBar, &scrollbar, NULL);
-    if (scrollbar != NULL) {
-        XtVaGetValues(scrollbar, XmNvalue, &value,
-                                 XmNsliderSize, &slider_size,
-                                 XmNminimum, &min,
-                                 XmNmaximum, &max, NULL);
-        if (slider_size < max - min) {
-            return scrollbar;
-        }
-    }
-    /* neither is suitable for scrolling */
-    return NULL;
-}
-
-EmbeddedFrame *theEmbeddedFrameList = NULL;
-
-static void awt_util_updateXtCoordinatesForEmbeddedFrame(Widget ef)
-{
-    Window ef_window;
-    Window win;
-    int32_t x, y;
-    ef_window = XtWindow(ef);
-    if (ef_window != None) {
-        if (XTranslateCoordinates(awt_display, ef_window,
-            RootWindowOfScreen(XtScreen(ef)),
-            0, 0, &x, &y, &win)) {
-            DTRACE_PRINTLN("correcting coordinates");
-            ef->core.x = x;
-            ef->core.y = y;
-        }
-    }
-}
-
-Boolean awt_util_processEventForEmbeddedFrame(XEvent *ev)
-{
-    EmbeddedFrame *ef;
-    Boolean dummy;
-    Boolean eventProcessed = False;
-    switch (ev->type) {
-    case FocusIn:
-    case FocusOut:
-        ef = theEmbeddedFrameList;
-        while (ef != NULL) {
-            if (ef->frameContainer == ev->xfocus.window) {
-                eventProcessed = True;
-                if (isXEmbedActiveByWindow(XtWindow(ef->embeddedFrame))) {
-                    return True;
-                }
-                // pretend that the embedded frame gets a focus event
-                // the event's window field is not the same as
-                // the embeddedFrame's widget, but luckily the shellEH
-                // doesnt seem to care about this.
-                shellEH(ef->embeddedFrame, ef->javaRef, ev, &dummy);
-            }
-            ef = ef->next;
-        }
-        return eventProcessed;
-    case ConfigureNotify:
-        for (ef = theEmbeddedFrameList; ef != NULL; ef = ef->next) {
-            awt_util_updateXtCoordinatesForEmbeddedFrame(ef->embeddedFrame);
-        }
-        return True;
-    }
-    return False;
-}
-
-void awt_util_addEmbeddedFrame(Widget embeddedFrame, jobject javaRef)
-{
-    EmbeddedFrame *ef, *eflist;
-    Atom WM_STATE;
-    Window win;
-    Window parent, root;
-    Window *children;
-    uint32_t nchildren;
-    Atom type = None;
-    int32_t format;
-    unsigned long nitems, after;
-    unsigned char * data;
-    XWindowAttributes win_attributes;
-
-    WM_STATE = XInternAtom(awt_display, "WM_STATE", True);
-    if (WM_STATE == None) {
-        return;
-    }
-    win = XtWindow(embeddedFrame);
-    if (win == None)
-        return;
-    /*
-     * according to XICCM, we search our toplevel window
-     * by looking for WM_STATE property
-     */
-    while (True) {
-        if (!XQueryTree(awt_display, win, &root, &parent,
-            &children, &nchildren)) {
-            return;
-        }
-        if (children) {
-            XFree(children);
-        }
-        if (parent == NULL || parent == root) {
-            return;
-        }
-        win = parent;
-        /*
-         * Add StructureNotifyMask through hierarchy upto toplevel
-         */
-        XGetWindowAttributes(awt_display, win, &win_attributes);
-        XSelectInput(awt_display, win, win_attributes.your_event_mask |
-                StructureNotifyMask);
-
-        if (XGetWindowProperty(awt_display, win, WM_STATE,
-                0, 0, False, AnyPropertyType,
-                &type, &format, &nitems, &after, &data) == Success) {
-            XFree(data);
-            if (type) {
-                break;
-            }
-        }
-    }
-    ef = (EmbeddedFrame *) malloc(sizeof(EmbeddedFrame));
-    if (ef == NULL) {
-        JNU_ThrowOutOfMemoryError((JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2),
-            "OutOfMemory in awt_util_addEmbeddedFrame");
-        return;
-    }
-    ef->embeddedFrame = embeddedFrame;
-    ef->frameContainer = win;
-    ef->javaRef = javaRef;
-    ef->eventSelectedPreviously = False;
-    /* initialize the xt coordinates */
-    awt_util_updateXtCoordinatesForEmbeddedFrame(embeddedFrame);
-
-    /*
-     * go through the exisiting embedded frames see if we have
-     * already selected the event on the same frameContainer
-     */
-    eflist = theEmbeddedFrameList;
-    while (eflist != NULL) {
-        if (eflist->frameContainer == win) {
-            break;
-        }
-        eflist = eflist->next;
-    }
-    if (eflist != NULL) {
-        /*
-         * we already have a embedded frame selecting this container's
-         * event, we remember its eventSelectedPreviously value
-         * so that we know whether to deselect later when we are removed
-         */
-        ef->eventSelectedPreviously = eflist->eventSelectedPreviously;
-    } else {
-        XGetWindowAttributes(awt_display, ef->frameContainer,
-            &win_attributes);
-        XSelectInput(awt_display, ef->frameContainer,
-                     win_attributes.your_event_mask | FocusChangeMask);
-    }
-
-    /* ef will become the head of the embedded frame list */
-    ef->next = theEmbeddedFrameList;
-    if (theEmbeddedFrameList != NULL) {
-        theEmbeddedFrameList->prev = ef;
-    }
-    ef->prev = NULL;
-    theEmbeddedFrameList = ef;
-}
-
-void awt_util_delEmbeddedFrame(Widget embeddedFrame)
-{
-    EmbeddedFrame *ef = theEmbeddedFrameList;
-    Window frameContainer;
-    XWindowAttributes win_attributes;
-    Boolean needToDeselect;
-
-    while (ef != NULL) {
-        if (ef->embeddedFrame == embeddedFrame) {
-            break;
-        }
-        ef = ef->next;
-    }
-    if (ef == NULL) { /* cannot find specified embedded frame */
-        return;
-    }
-    /* remove ef from link list EmbeddedFrameList */
-    if (ef->prev) {
-        ef->prev->next = ef->next;
-    }
-    if (ef->next) {
-        ef->next->prev = ef->prev;
-    }
-    if (theEmbeddedFrameList == ef) {
-        theEmbeddedFrameList = ef->next;
-    }
-
-    frameContainer = ef->frameContainer;
-    needToDeselect = ef->eventSelectedPreviously ? False : True;
-    free(ef);
-    if (!needToDeselect) {
-        return;
-    }
-    /*
-     * now decide whether we need to stop listenning event for
-     * frameContainer
-     */
-    ef = theEmbeddedFrameList;
-    while (ef != NULL) {
-        if (ef->frameContainer == frameContainer) {
-            break;
-        }
-        ef = ef->next;
-    }
-    if (ef == NULL)  {
-        /*
-         * if we get here, no one is interested in this frame
-         * and StructureNotify was not selected by anyone else
-         * so we deselect it
-         */
-        DTRACE_PRINTLN("remove event from frame");
-        XGetWindowAttributes(awt_display, frameContainer, &win_attributes);
-        XSelectInput(awt_display, frameContainer,
-            win_attributes.your_event_mask &
-                (~FocusChangeMask));
-    }
-}
-
-#endif /* XAWT */
-
-void awt_util_debug_init() {
-#if defined(DEBUG)
-    DTrace_Initialize();
-#endif
-}
-
-static void awt_util_debug_fini() {
-#if defined(DEBUG)
-    DTrace_Shutdown();
-#endif
-}
diff --git a/jdk/src/solaris/native/sun/awt/awt_util.h b/jdk/src/solaris/native/sun/awt/awt_util.h
index 38e2fbc..5fb113f 100644
--- a/jdk/src/solaris/native/sun/awt/awt_util.h
+++ b/jdk/src/solaris/native/sun/awt/awt_util.h
@@ -27,58 +27,8 @@
 #define _AWT_UTIL_H_
 
 #ifndef HEADLESS
-#ifndef XAWT
-#include <Xm/VendorSEP.h>
-#include <Xm/VendorSP.h>
-#endif
 #include "gdefs.h"
 
-typedef struct ConvertEventTimeAndModifiers {
-    jlong when;
-    jint modifiers;
-} ConvertEventTimeAndModifiers;
-
-Boolean awt_util_focusIsOnMenu(Display *display);
-int32_t awt_util_sendButtonClick(Display *display, Window window);
-
-Widget awt_util_createWarningWindow(Widget parent, char *warning);
-void awt_util_show(Widget w);
-void awt_util_hide(Widget w);
-void awt_util_enable(Widget w);
-void awt_util_disable(Widget w);
-void awt_util_reshape(Widget w, jint x, jint y, jint wd, jint ht);
-void awt_util_mapChildren(Widget w, void (*func)(Widget,void *),
-                          int32_t applyToSelf, void *data);
-int32_t awt_util_setCursor(Widget w, Cursor c);
-void awt_util_convertEventTimeAndModifiers
-    (XEvent *event, ConvertEventTimeAndModifiers *output);
-Widget awt_WidgetAtXY(Widget root, Position x, Position y);
-char *awt_util_makeWMMenuItem(char *target, Atom protocol);
-Cardinal awt_util_insertCallback(Widget w);
-void awt_util_consumeAllXEvents(Widget widget);
-void awt_util_cleanupBeforeDestroyWidget(Widget widget);
-void awt_util_debug_init();
-Time awt_util_getCurrentServerTime();
-jlong awt_util_nowMillisUTC();
-jlong awt_util_nowMillisUTC_offset(Time server_offset);
-void awt_util_do_wheel_scroll(Widget scrolled_window, jint scrollType,
-                                jint scrollAmt, jint wheelAmt);
-Widget awt_util_get_scrollbar_to_scroll(Widget window);
-
-
-typedef struct _EmbeddedFrame {
-    Widget embeddedFrame;
-    Window frameContainer;
-    jobject javaRef;
-    Boolean eventSelectedPreviously;
-    struct _EmbeddedFrame * next;
-    struct _EmbeddedFrame * prev;
-} EmbeddedFrame;
-
-void awt_util_addEmbeddedFrame(Widget embeddedFrame, jobject javaRef);
-void awt_util_delEmbeddedFrame(Widget embeddedFrame);
-Boolean awt_util_processEventForEmbeddedFrame(XEvent *ev);
-
 #define WITH_XERROR_HANDLER(f) do {             \
     XSync(awt_display, False);                  \
     xerror_code = Success;                      \
@@ -115,8 +65,6 @@
  */
 extern unsigned char xerror_code;
 
-extern int xerror_ignore_bad_window(Display *dpy, XErrorEvent *err);
-
 #endif /* !HEADLESS */
 
 #ifndef INTERSECTS
@@ -143,13 +91,8 @@
     int32_t echoC;
 };
 
-extern jobject awtJNI_GetCurrentThread(JNIEnv *env);
 extern void awtJNI_ThreadYield(JNIEnv *env);
 
-#ifndef HEADLESS
-extern Widget prevWidget;
-#endif /* !HEADLESS */
-
 /*
  * Functions for accessing fields by name and signature
  */
@@ -183,69 +126,4 @@
 JNIEXPORT jint JNICALL
 JNU_GetCharField(JNIEnv *env, jobject self, const char *name);
 
-#ifndef HEADLESS
-#ifdef __solaris__
-extern Widget awt_util_getXICStatusAreaWindow(Widget w);
-#else
-int32_t awt_util_getIMStatusHeight(Widget vw);
-XVaNestedList awt_util_getXICStatusAreaList(Widget w);
-Widget awt_util_getXICStatusAreaWindow(Widget w);
-#endif
-
-
-
-
-#ifdef __linux__
-typedef struct _XmImRefRec {
-  Cardinal      num_refs;       /* Number of referencing widgets. */
-  Cardinal      max_refs;       /* Maximum length of refs array. */
-  Widget*       refs;           /* Array of referencing widgets. */
-  XtPointer     **callbacks;
-} XmImRefRec, *XmImRefInfo;
-
-typedef struct _PreeditBufferRec {
-  unsigned short length;
-  wchar_t        *text;
-  XIMFeedback    *feedback;
-  int32_t            caret;
-  XIMCaretStyle  style;
-} PreeditBufferRec, *PreeditBuffer;
-
-typedef struct _XmImXICRec {
-  struct _XmImXICRec *next;     /* Links all have the same XIM. */
-  XIC           xic;            /* The XIC. */
-  Window        focus_window;   /* Cached information about the XIC. */
-  XIMStyle      input_style;    /* ...ditto... */
-  int32_t           status_width;   /* ...ditto... */
-  int32_t           preedit_width;  /* ...ditto... */
-  int32_t           sp_height;      /* ...ditto... */
-  Boolean       has_focus;      /* Does this XIC have keyboard focus. */
-  Boolean       anonymous;      /* Do we have exclusive rights to this XIC. */
-  XmImRefRec    widget_refs;    /* Widgets referencing this XIC. */
-  struct _XmImXICRec **source; /* Original source of shared XICs. */
-  PreeditBuffer preedit_buffer;
-} XmImXICRec, *XmImXICInfo;
-
-typedef struct _XmImShellRec {
-  /* per-Shell fields. */
-  Widget        im_widget;      /* Dummy widget to make intrinsics behave. */
-  Widget        current_widget; /* Widget whose visual we're matching. */
-
-  /* per <Shell,XIM> fields. */
-  XmImXICInfo   shell_xic;      /* For PER_SHELL sharing policy. */
-  XmImXICInfo   iclist;         /* All known XICs for this <XIM,Shell>. */
-} XmImShellRec, *XmImShellInfo;
-
-typedef struct {
-  /* per-Display fields. */
-  XContext      current_xics;   /* Map widget -> current XmImXICInfo. */
-
-  /* per-XIM fields. */
-  XIM           xim;            /* The XIM. */
-  XIMStyles     *styles;        /* XNQueryInputStyle result. */
-  XmImRefRec    shell_refs;     /* Shells referencing this XIM. */
-} XmImDisplayRec, *XmImDisplayInfo;
-
-#endif
-#endif /* !HEADLESS */
 #endif           /* _AWT_UTIL_H_ */
diff --git a/jdk/src/solaris/native/sun/awt/awt_wm.c b/jdk/src/solaris/native/sun/awt/awt_wm.c
deleted file mode 100644
index d1da64f..0000000
--- a/jdk/src/solaris/native/sun/awt/awt_wm.c
+++ /dev/null
@@ -1,2869 +0,0 @@
-/*
- * Copyright (c) 2001, 2006, 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.
- */
-
-#ifdef HEADLESS
-    #error This file should not be included in headless library
-#endif
-
-/*
- * Some SCIENCE stuff happens, and it is CONFUSING
- */
-
-#include "awt_p.h"
-
-#include <X11/Xproto.h>
-#include <X11/Xlib.h>
-#include <X11/Xatom.h>
-#include <Xm/MwmUtil.h>
-
-/* JNI headers */
-#include "java_awt_Frame.h"     /* for frame state constants */
-
-#include "awt_wm.h"
-#include "awt_util.h"           /* for X11 error handling macros */
-
-/*
- * NB: 64 bit awareness.
- *
- * Since this code reads/writes window properties heavily, one thing
- * should be noted well.  Xlib uses C type 'long' for properties of
- * format 32.  Fortunately, typedef for Atom is 'long' as well, so
- * passing property data as or casting returned property data to
- * arrays of atoms is safe.
- */
-
-
-/*
- * Atoms used to communicate with window manager(s).
- * Naming convention:
- *   o  for atom  "FOO" the variable is  "XA_FOO"
- *   o  for atom "_BAR" the variable is "_XA_BAR"
- * Don't forget to add initialization to awt_wm_initAtoms below.
- */
-
-/*
- * Before WM rototill JDK used to check for running WM by just testing
- * if certain atom is interned or not.  We'd better not confuse older
- * JDK by interning these atoms.  Use awt_wm_atomInterned() to intern
- * them lazily.
- *
- * ENLIGHTENMENT_COMMS
- * _ICEWM_WINOPTHINT
- * _SAWMILL_TIMESTAMP
- * _DT_SM_WINDOW_INFO
- * _MOTIF_WM_INFO
- * _SUN_WM_PROTOCOLS
- */
-
-/* Good old ICCCM */
-static Atom XA_WM_STATE;
-
-/* New "netwm" spec from www.freedesktop.org */
-static Atom XA_UTF8_STRING;     /* like STRING but encoding is UTF-8 */
-static Atom _XA_NET_SUPPORTING_WM_CHECK;
-static Atom _XA_NET_SUPPORTED;  /* list of protocols (property of root) */
-static Atom _XA_NET_WM_NAME;    /* window property */
-static Atom _XA_NET_WM_STATE;   /* both window property and request */
-
-/*
- * _NET_WM_STATE is a list of atoms.
- * NB: Standard spelling is "HORZ" (yes, without an 'I'), but KDE2
- * uses misspelled "HORIZ" (see KDE bug #20229).  This was fixed in
- * KDE 2.2.  Under earlier versions of KDE2 horizontal and full
- * maximization doesn't work .
- */
-static Atom _XA_NET_WM_STATE_MAXIMIZED_HORZ;
-static Atom _XA_NET_WM_STATE_MAXIMIZED_VERT;
-static Atom _XA_NET_WM_STATE_SHADED;
-static Atom _XA_NET_WM_STATE_ABOVE;
-static Atom _XA_NET_WM_STATE_BELOW;
-static Atom _XA_NET_WM_STATE_HIDDEN;
-
-/* Currently we only care about max_v and max_h in _NET_WM_STATE */
-#define AWT_NET_N_KNOWN_STATES 2
-
-/* Gnome WM spec (superseded by "netwm" above, but still in use) */
-static Atom _XA_WIN_SUPPORTING_WM_CHECK;
-static Atom _XA_WIN_PROTOCOLS;
-static Atom _XA_WIN_STATE;
-static Atom _XA_WIN_LAYER;
-
-/* Enlightenment */
-static Atom _XA_E_FRAME_SIZE;
-
-/* KWin (KDE2) */
-static Atom _XA_KDE_NET_WM_FRAME_STRUT;
-
-/* KWM (KDE 1.x) OBSOLETE??? */
-static Atom XA_KWM_WIN_ICONIFIED;
-static Atom XA_KWM_WIN_MAXIMIZED;
-
-/* OpenLook */
-static Atom _XA_OL_DECOR_DEL;
-static Atom _XA_OL_DECOR_HEADER;
-static Atom _XA_OL_DECOR_RESIZE;
-static Atom _XA_OL_DECOR_PIN;
-static Atom _XA_OL_DECOR_CLOSE;
-
-/* For _NET_WM_STATE ClientMessage requests */
-#define _NET_WM_STATE_REMOVE    0 /* remove/unset property */
-#define _NET_WM_STATE_ADD       1 /* add/set property      */
-#define _NET_WM_STATE_TOGGLE    2 /* toggle property       */
-
-/* _WIN_STATE bits */
-#define WIN_STATE_STICKY          (1<<0) /* everyone knows sticky            */
-#define WIN_STATE_MINIMIZED       (1<<1) /* Reserved - definition is unclear */
-#define WIN_STATE_MAXIMIZED_VERT  (1<<2) /* window in maximized V state      */
-#define WIN_STATE_MAXIMIZED_HORIZ (1<<3) /* window in maximized H state      */
-#define WIN_STATE_HIDDEN          (1<<4) /* not on taskbar but window visible*/
-#define WIN_STATE_SHADED          (1<<5) /* shaded (MacOS / Afterstep style) */
-#define WIN_LAYER_ONTOP           6
-#define WIN_LAYER_NORMAL          4
-
-#define  URGENCY_HINT             (1<<8)
-#define  LAYER_ALWAYS_ON_TOP      1
-#define  LAYER_NORMAL             0
-
-
-/*
- * Intern a bunch of atoms we are going use.
- */
-static void
-awt_wm_initAtoms(void)
-{
-    /* Minimize X traffic by creating atoms en mass...  This requires
-       slightly more code but reduces number of server requests. */
-    struct atominit {
-        Atom *atomptr;
-        const char *name;
-    };
-
-    /* Just add new atoms to this list */
-    static struct atominit atom_list[] = {
-        { &XA_WM_STATE,                      "WM_STATE"                      },
-
-        { &XA_UTF8_STRING,                   "UTF8_STRING"                   },
-
-        { &_XA_NET_SUPPORTING_WM_CHECK,      "_NET_SUPPORTING_WM_CHECK"      },
-        { &_XA_NET_SUPPORTED,                "_NET_SUPPORTED"                },
-        { &_XA_NET_WM_STATE,                 "_NET_WM_STATE"                 },
-        { &_XA_NET_WM_STATE_MAXIMIZED_VERT,  "_NET_WM_STATE_MAXIMIZED_VERT"  },
-        { &_XA_NET_WM_STATE_MAXIMIZED_HORZ,  "_NET_WM_STATE_MAXIMIZED_HORZ"  },
-        { &_XA_NET_WM_STATE_SHADED,          "_NET_WM_STATE_SHADED"          },
-        { &_XA_NET_WM_STATE_ABOVE,           "_NET_WM_STATE_ABOVE"           },
-        { &_XA_NET_WM_STATE_BELOW,           "_NET_WM_STATE_BELOW"           },
-        { &_XA_NET_WM_STATE_HIDDEN,          "_NET_WM_STATE_HIDDEN"          },
-        { &_XA_NET_WM_NAME,                  "_NET_WM_NAME"                  },
-
-        { &_XA_WIN_SUPPORTING_WM_CHECK,      "_WIN_SUPPORTING_WM_CHECK"      },
-        { &_XA_WIN_PROTOCOLS,                "_WIN_PROTOCOLS"                },
-        { &_XA_WIN_STATE,                    "_WIN_STATE"                    },
-        { &_XA_WIN_LAYER,                    "_WIN_LAYER"                    },
-
-        { &_XA_KDE_NET_WM_FRAME_STRUT,       "_KDE_NET_WM_FRAME_STRUT"       },
-
-        { &_XA_E_FRAME_SIZE,                 "_E_FRAME_SIZE"                 },
-
-        { &XA_KWM_WIN_ICONIFIED,             "KWM_WIN_ICONIFIED"             },
-        { &XA_KWM_WIN_MAXIMIZED,             "KWM_WIN_MAXIMIZED"             },
-
-        { &_XA_OL_DECOR_DEL,                 "_OL_DECOR_DEL"                 },
-        { &_XA_OL_DECOR_HEADER,              "_OL_DECOR_HEADER"              },
-        { &_XA_OL_DECOR_RESIZE,              "_OL_DECOR_RESIZE"              },
-        { &_XA_OL_DECOR_PIN,                 "_OL_DECOR_PIN"                 },
-        { &_XA_OL_DECOR_CLOSE,               "_OL_DECOR_CLOSE"               }
-    };
-#define ATOM_LIST_LENGTH (sizeof(atom_list)/sizeof(atom_list[0]))
-
-    const char *names[ATOM_LIST_LENGTH];
-    Atom atoms[ATOM_LIST_LENGTH];
-    Status status;
-    size_t i;
-
-    /* Fill the array of atom names */
-    for (i = 0; i < ATOM_LIST_LENGTH; ++i) {
-        names[i] = atom_list[i].name;
-    }
-
-    DTRACE_PRINT("WM: initializing atoms ...  ");
-    status = XInternAtoms(awt_display, (char**)names, ATOM_LIST_LENGTH,
-                          False, atoms);
-    if (status == 0) {
-        DTRACE_PRINTLN("failed");
-        return;
-    }
-
-    /* Store returned atoms into corresponding global variables */
-    DTRACE_PRINTLN("ok");
-    for (i = 0; i < ATOM_LIST_LENGTH; ++i) {
-        *atom_list[i].atomptr = atoms[i];
-    }
-#undef ATOM_LIST_LENGTH
-}
-
-
-/*
- * When checking for various WMs don't intern certain atoms we use to
- * distinguish those WMs.  Rather check if the atom is interned first.
- * If it's not, further tests are not necessary anyway.
- * This also saves older JDK a great deal of confusion (4487993).
- */
-static Boolean
-awt_wm_atomInterned(Atom *pa, const char *name)
-{
-    DASSERT(pa != NULL);
-    if (*pa == None) {
-        DASSERT(name != NULL);
-        *pa = XInternAtom(awt_display, name, True);
-        if (*pa == None) {
-            DTRACE_PRINTLN1("\"%s\" is not interned", name);
-            return False;
-        } else {
-            return True;
-        }
-    } else {
-        return True;
-    }
-}
-
-
-
-/*****************************************************************************\
- *
- * DTRACE utils for various states ...
- *
-\*****************************************************************************/
-
-
-static void
-awt_wm_dtraceWMState(uint32_t wm_state)
-{
-#ifdef DEBUG
-    DTRACE_PRINT("WM_STATE = ");
-    switch (wm_state) {
-      case WithdrawnState:
-          DTRACE_PRINTLN("Withdrawn");
-          break;
-      case NormalState:
-          DTRACE_PRINTLN("Normal");
-          break;
-      case IconicState:
-          DTRACE_PRINTLN("Iconic");
-          break;
-      default:
-          DTRACE_PRINTLN1("unknown state %d", wm_state);
-          break;
-    }
-#endif /* DEBUG */
-}
-
-static void
-awt_wm_dtraceStateNet(Atom *net_wm_state, unsigned long nitems)
-{
-#ifdef DEBUG
-    unsigned long i;
-
-    DTRACE_PRINT("_NET_WM_STATE = {");
-    for (i = 0; i < nitems; ++i) {
-        char *name, *print_name;
-        name = XGetAtomName(awt_display, net_wm_state[i]);
-        if (name == NULL) {
-            print_name = "???";
-        } else if (strncmp(name, "_NET_WM_STATE", 13) == 0) {
-            print_name = name + 13; /* skip common prefix to reduce noice */
-        } else {
-            print_name = name;
-        }
-        DTRACE_PRINT1(" %s", print_name);
-        if (name) {
-            XFree(name);
-        }
-    }
-    DTRACE_PRINTLN(" }");
-#endif
-}
-
-
-static void
-awt_wm_dtraceStateWin(uint32_t win_state)
-{
-#ifdef DEBUG
-    DTRACE_PRINT("_WIN_STATE = {");
-    if (win_state & WIN_STATE_STICKY) {
-        DTRACE_PRINT(" STICKY");
-    }
-    if (win_state & WIN_STATE_MINIMIZED) {
-        DTRACE_PRINT(" MINIMIZED");
-    }
-    if (win_state & WIN_STATE_MAXIMIZED_VERT) {
-        DTRACE_PRINT(" MAXIMIZED_VERT");
-    }
-    if (win_state & WIN_STATE_MAXIMIZED_HORIZ) {
-        DTRACE_PRINT(" MAXIMIZED_HORIZ");
-    }
-    if (win_state & WIN_STATE_HIDDEN) {
-        DTRACE_PRINT(" HIDDEN");
-    }
-    if (win_state & WIN_STATE_SHADED) {
-        DTRACE_PRINT(" SHADED");
-    }
-    DTRACE_PRINTLN(" }");
-#endif
-}
-
-
-static void
-awt_wm_dtraceStateJava(jint java_state)
-{
-#ifdef DEBUG
-    DTRACE_PRINT("java state = ");
-    if (java_state == java_awt_Frame_NORMAL) {
-        DTRACE_PRINTLN("NORMAL");
-    }
-    else {
-        DTRACE_PRINT("{");
-        if (java_state & java_awt_Frame_ICONIFIED) {
-            DTRACE_PRINT(" ICONIFIED");
-        }
-        if ((java_state & java_awt_Frame_MAXIMIZED_BOTH)
-                       == java_awt_Frame_MAXIMIZED_BOTH)
-        {
-            DTRACE_PRINT(" MAXIMIZED_BOTH");
-        }
-        else if (java_state & java_awt_Frame_MAXIMIZED_HORIZ) {
-            DTRACE_PRINT(" MAXIMIZED_HORIZ");
-        }
-        else if (java_state & java_awt_Frame_MAXIMIZED_VERT) {
-            DTRACE_PRINT(" MAXIMIZED_VERT");
-        }
-        DTRACE_PRINTLN(" }");
-    }
-#endif /* DEBUG */
-}
-
-
-
-/*****************************************************************************\
- *
- * Utility functions ...
- *
-\*****************************************************************************/
-
-/*
- * Instead of validating window id, we simply call XGetWindowProperty,
- * but temporary install this function as the error handler to ignore
- * BadWindow error.
- */
-int /* but ingored */
-xerror_ignore_bad_window(Display *dpy, XErrorEvent *err)
-{
-    XERROR_SAVE(err);
-    if (err->error_code == BadWindow) {
-        DTRACE_PRINTLN("IGNORING BadWindow");
-        return 0; /* ok to fail */
-    }
-    else {
-        return (*xerror_saved_handler)(dpy, err);
-    }
-}
-
-
-/*
- * Convenience wrapper for XGetWindowProperty for XA_ATOM properties.
- * E.g. WM_PROTOCOLS, _NET_WM_STATE, _OL_DECOR_DEL.
- * It's up to caller to XFree returned value.
- * Number of items returned is stored to nitems_ptr (if non-null).
- */
-static Atom *
-awt_getAtomListProperty(Window w, Atom property, unsigned long *nitems_ptr)
-{
-    /* Request status */
-    int status;
-
-    /* Returns of XGetWindowProperty */
-    Atom actual_type;
-    int actual_format;
-    unsigned long nitems_stub;
-    unsigned long bytes_after;
-    Atom *list;
-
-    if (nitems_ptr == NULL) {
-        /* Caller is not interested in the number of items,
-           provide a stub for XGetWindowProperty */
-        nitems_ptr = &nitems_stub;
-    }
-
-    status = XGetWindowProperty(awt_display, w,
-                 property, 0, 0xFFFF, False, XA_ATOM,
-                 &actual_type, &actual_format, nitems_ptr, &bytes_after,
-                 (unsigned char **)&list);
-
-    if (status != Success || list == NULL) {
-        *nitems_ptr = 0;
-        return NULL;
-    }
-
-    if (actual_type != XA_ATOM || actual_format != 32) {
-        XFree(list);
-        *nitems_ptr = 0;
-        return NULL;
-    }
-
-    if (*nitems_ptr == 0) {
-        XFree(list);
-        return NULL;
-    }
-
-    return list;
-}
-
-
-/*
- * Auxiliary function that returns the value of 'property' of type
- * 'property_type' on window 'w'.  Format of the property must be 8.
- * Terminating zero added by XGetWindowProperty is preserved.
- * It's up to caller to XFree the result.
- */
-static unsigned char *
-awt_getProperty8(Window w, Atom property, Atom property_type)
-{
-    /* Request status */
-    int status;
-
-    /* Returns of XGetWindowProperty */
-    Atom actual_type;
-    int actual_format;
-    unsigned long nitems;
-    unsigned long bytes_after;
-    unsigned char *string;
-
-    /* BadWindow is ok and will be blocked by our special handler */
-    WITH_XERROR_HANDLER(xerror_ignore_bad_window);
-    {
-        status = XGetWindowProperty(awt_display, w,
-                     property, 0, 0xFFFF, False, property_type,
-                     &actual_type, &actual_format, &nitems, &bytes_after,
-                     &string);
-    }
-    RESTORE_XERROR_HANDLER;
-
-    if (status != Success || string == NULL) {
-        return NULL;
-    }
-
-    if (actual_type != property_type || actual_format != 8) {
-        XFree(string);
-        return NULL;
-    }
-
-    /* XGetWindowProperty kindly supplies terminating zero */
-    return string;
-}
-
-
-/*
- * Auxiliary function that returns the value of 'property' of type
- * 'property_type' on window 'w'.  Format of the property must be 32.
- */
-static int32_t
-awt_getProperty32(Window w, Atom property, Atom property_type)
-{
-    /* Property value*/
-    int32_t value;
-
-    /* Request status */
-    int status;
-
-    /* Returns of XGetWindowProperty */
-    Atom actual_type;
-    int actual_format;
-    unsigned long nitems;
-    unsigned long bytes_after;
-    long *data;                 /* NB: 64 bit: Format 32 props are 'long' */
-
-    /* BadWindow is ok and will be blocked by our special handler */
-    WITH_XERROR_HANDLER(xerror_ignore_bad_window);
-    {
-        status = XGetWindowProperty(awt_display, w,
-                     property, 0, 1, False, property_type,
-                     &actual_type, &actual_format, &nitems, &bytes_after,
-                     (unsigned char **)&data);
-    }
-    RESTORE_XERROR_HANDLER;
-
-    if (status != Success || data == NULL) {
-        return 0;
-    }
-
-    if (actual_type != property_type || actual_format != 32) {
-        XFree(data);            /* NULL data already catched above */
-        return 0;
-    }
-
-    value = (int32_t)*data;
-    XFree(data);
-
-    return value;
-}
-
-
-
-/*****************************************************************************\
- *
- * Detecting WM ...
- *
-\*****************************************************************************/
-
-
-
-/*
- * Check for anchor_prop(anchor_type) on root, take the value as the
- * window id and check if that window exists and has anchor_prop(anchor_type)
- * with the same value (i.e. pointing back to self).
- *
- * Returns the anchor window, as some WM may put interesting stuff in
- * its properties (e.g. sawfish).
- */
-static Window
-awt_wm_checkAnchor(Atom anchor_prop, Atom anchor_type)
-{
-    Window root_xref;
-    Window self_xref;
-
-    root_xref = (Window)awt_getProperty32(DefaultRootWindow(awt_display),
-                                          anchor_prop, anchor_type);
-    if (root_xref == None) {
-        DTRACE_PRINTLN("no");
-        return None;
-    }
-
-    DTRACE_PRINT1("0x%x ...  ", (unsigned int)root_xref);
-    self_xref = (Window)awt_getProperty32(root_xref,
-                                          anchor_prop, anchor_type);
-    if (self_xref != root_xref) {
-        DTRACE_PRINTLN("stale");
-        return None;
-    }
-
-    DTRACE_PRINTLN("ok");
-    return self_xref;
-}
-
-
-/*
- * New WM spec: KDE 2.0.1, sawfish 0.3x, ...
- * <http://www.freedesktop.org/standards/wm-spec.html>
- */
-static Window
-awt_wm_isNetSupporting(void)
-{
-    static Boolean checked = False;
-    static Window isNetSupporting = None;
-
-    if (checked) {
-        return isNetSupporting;
-    }
-
-    DTRACE_PRINT("WM: checking for _NET_SUPPORTING ...  ");
-    isNetSupporting = awt_wm_checkAnchor(_XA_NET_SUPPORTING_WM_CHECK,
-                                         XA_WINDOW);
-    checked = True;
-    return isNetSupporting;
-}
-
-
-/*
- * Old Gnome WM spec: WindowMaker, Enlightenment, IceWM ...
- * <http://developer.gnome.org/doc/standards/wm/book1.html>
- */
-static Window
-awt_wm_isWinSupporting(void)
-{
-    static Boolean checked = False;
-    static Window isWinSupporting = None;
-
-    if (checked) {
-        return isWinSupporting;
-    }
-
-    DTRACE_PRINT("WM: checking for _WIN_SUPPORTING ...  ");
-    isWinSupporting = awt_wm_checkAnchor(_XA_WIN_SUPPORTING_WM_CHECK,
-                                         XA_CARDINAL);
-    checked = True;
-    return isWinSupporting;
-}
-
-
-/*
- * Check that that the list of protocols specified by WM in property
- * named LIST_NAME on the root window contains protocol PROTO.
- */
-static Boolean
-awt_wm_checkProtocol(Atom list_name, Atom proto)
-{
-    Atom *protocols;
-    unsigned long nproto;
-    Boolean found;
-    unsigned long i;
-
-    protocols = awt_getAtomListProperty(DefaultRootWindow(awt_display),
-                                        list_name, &nproto);
-    if (protocols == NULL) {
-        return False;
-    }
-
-    found = False;
-    for (i = 0; i < nproto; ++i) {
-        if (protocols[i] == proto) {
-            found = True;
-            break;
-        }
-    }
-
-    if (protocols != NULL) {
-        XFree(protocols);
-    }
-    return found;
-}
-
-static Boolean
-awt_wm_doStateProtocolNet(void)
-{
-    static Boolean checked = False;
-    static Boolean supported = False;
-
-    if (checked) {
-        return supported;
-    }
-
-    if (awt_wm_isNetSupporting()) {
-        DTRACE_PRINT("WM: checking for _NET_WM_STATE in _NET_SUPPORTED ...  ");
-        supported = awt_wm_checkProtocol(_XA_NET_SUPPORTED, _XA_NET_WM_STATE);
-        DTRACE_PRINTLN1("%s", supported ? "yes" : "no");
-    }
-
-    checked = True;
-    return supported;
-}
-
-static Boolean
-awt_wm_doStateProtocolWin(void)
-{
-    static Boolean checked = False;
-    static Boolean supported = False;
-
-    if (checked) {
-        return supported;
-    }
-
-    if (awt_wm_isWinSupporting()) {
-        DTRACE_PRINT("WM: checking for _WIN_STATE in _WIN_PROTOCOLS ...  ");
-        supported = awt_wm_checkProtocol(_XA_WIN_PROTOCOLS, _XA_WIN_STATE);
-        DTRACE_PRINTLN1("%s", supported ? "yes" : "no");
-    }
-    checked = True;
-    return supported;
-}
-
-
-
-/*
- * Helper function for awt_wm_isEnlightenment.
- * Enlightenment uses STRING property for its comms window id.  Gaaa!
- * The property is ENLIGHTENMENT_COMMS, STRING/8 and the string format
- * is "WINID %8x".  Gee, I haven't been using scanf for *ages*... :-)
- */
-static Window
-awt_getECommsWindowIDProperty(Window w)
-{
-    static Atom XA_ENLIGHTENMENT_COMMS = None;
-
-    /* Property value*/
-    Window value;
-
-    /* Request status */
-    int status;
-
-    /* Returns of XGetWindowProperty */
-    Atom actual_type;
-    int actual_format;
-    unsigned long nitems;
-    unsigned long bytes_after;
-    unsigned char *data;
-
-    if (!awt_wm_atomInterned(&XA_ENLIGHTENMENT_COMMS, "ENLIGHTENMENT_COMMS")) {
-        return False;
-    }
-
-    /* BadWindow is ok and will be blocked by our special handler */
-    WITH_XERROR_HANDLER(xerror_ignore_bad_window);
-    {
-        status = XGetWindowProperty(awt_display, w,
-                     XA_ENLIGHTENMENT_COMMS, 0, 14, False, XA_STRING,
-                     &actual_type, &actual_format, &nitems, &bytes_after,
-                     &data);
-    }
-    RESTORE_XERROR_HANDLER;
-
-    if (status != Success || data == NULL) {
-        DTRACE_PRINTLN("no ENLIGHTENMENT_COMMS");
-        return None;
-    }
-
-    if (actual_type != XA_STRING || actual_format != 8
-        || nitems != 14 || bytes_after != 0)
-    {
-        DTRACE_PRINTLN("malformed ENLIGHTENMENT_COMMS");
-        XFree(data);            /* NULL data already catched above */
-        return None;
-    }
-
-    value = None;
-    sscanf((char *)data, "WINID %8lx", &value); /* NB: 64 bit: XID is long */
-    XFree(data);
-
-    return value;
-}
-
-
-/*
- * Is Enlightenment WM running?  Congruent to awt_wm_checkAnchor, but
- * uses STRING property peculiar to Enlightenment.
- */
-static Boolean
-awt_wm_isEnlightenment(void)
-{
-    Window root_xref;
-    Window self_xref;
-
-    DTRACE_PRINT("WM: checking for Enlightenment ...  ");
-    root_xref = awt_getECommsWindowIDProperty(DefaultRootWindow(awt_display));
-    if (root_xref == None) {
-        return False;
-    }
-
-    DTRACE_PRINT1("0x%x ...  ", root_xref);
-    self_xref = awt_getECommsWindowIDProperty(root_xref);
-    if (self_xref != root_xref) {
-        return False;
-    }
-
-    DTRACE_PRINTLN("ok");
-    return True;
-}
-
-
-/*
- * Is CDE running?
- *
- * XXX: This is hairy...  CDE is MWM as well.  It seems we simply test
- * for default setup and will be bitten if user changes things...
- *
- * Check for _DT_SM_WINDOW_INFO(_DT_SM_WINDOW_INFO) on root.  Take the
- * second element of the property and check for presence of
- * _DT_SM_STATE_INFO(_DT_SM_STATE_INFO) on that window.
- *
- * XXX: Any header that defines this structures???
- */
-static Boolean
-awt_wm_isCDE(void)
-{
-    static Atom _XA_DT_SM_WINDOW_INFO = None;
-    static Atom _XA_DT_SM_STATE_INFO = None;
-
-    /* Property value*/
-    Window wmwin;
-
-    /* Request status */
-    int status;
-
-    /* Returns of XGetWindowProperty */
-    Atom actual_type;
-    int actual_format;
-    unsigned long nitems;
-    unsigned long bytes_after;
-    long *data;                 /* NB: 64 bit: Format 32 props are 'long' */
-
-    DTRACE_PRINT("WM: checking for CDE ...  ");
-
-    if (!awt_wm_atomInterned(&_XA_DT_SM_WINDOW_INFO, "_DT_SM_WINDOW_INFO")) {
-        return False;
-    }
-
-    status = XGetWindowProperty(awt_display, DefaultRootWindow(awt_display),
-                 _XA_DT_SM_WINDOW_INFO, 0, 2, False, _XA_DT_SM_WINDOW_INFO,
-                 &actual_type, &actual_format, &nitems, &bytes_after,
-                 (unsigned char **)&data);
-
-    if (status != Success || data == NULL) {
-        DTRACE_PRINTLN("no _DT_SM_WINDOW_INFO on root");
-        return False;
-    }
-
-    if (actual_type != _XA_DT_SM_WINDOW_INFO || actual_format != 32
-        || nitems != 2 || bytes_after != 0)
-    {
-        DTRACE_PRINTLN("malformed _DT_SM_WINDOW_INFO on root");
-        XFree(data);            /* NULL data already catched above */
-        return False;
-    }
-
-    wmwin = (Window)data[1];
-    XFree(data);
-
-    /* Now check that this window has _DT_SM_STATE_INFO (ignore contents) */
-
-    if (!awt_wm_atomInterned(&_XA_DT_SM_STATE_INFO, "_DT_SM_STATE_INFO")) {
-        return False;
-    }
-
-    /* BadWindow is ok and will be blocked by our special handler */
-    WITH_XERROR_HANDLER(xerror_ignore_bad_window);
-    {
-        status = XGetWindowProperty(awt_display, wmwin,
-                     _XA_DT_SM_STATE_INFO, 0, 1, False, _XA_DT_SM_STATE_INFO,
-                     &actual_type, &actual_format, &nitems, &bytes_after,
-                     (unsigned char **)&data);
-    }
-    RESTORE_XERROR_HANDLER;
-
-    if (status != Success || data == NULL) {
-        DTRACE_PRINTLN("no _DT_SM_STATE_INFO");
-        return False;
-    }
-
-    if (actual_type != _XA_DT_SM_STATE_INFO || actual_format != 32) {
-        DTRACE_PRINTLN("malformed _DT_SM_STATE_INFO");
-        XFree(data);            /* NULL data already catched above */
-        return False;
-    }
-
-    DTRACE_PRINTLN("yes");
-    XFree(data);
-    return True;
-}
-
-/*
- * Is MWM running?  (Note that CDE will test positive as well).
- *
- * Check for _MOTIF_WM_INFO(_MOTIF_WM_INFO) on root.  Take the
- * second element of the property and check for presence of
- * _DT_SM_STATE_INFO(_DT_SM_STATE_INFO) on that window.
- */
-static Boolean
-awt_wm_isMotif(void)
-{
-    /*
-     * Grr.  Motif just had to be different, ain't it!?  Everyone use
-     * "XA" for things of type Atom, but motif folks chose to define
-     * _XA_MOTIF_* to be atom *names*.  How pathetic...
-     */
-#undef _XA_MOTIF_WM_INFO
-    static Atom _XA_MOTIF_WM_INFO = None;
-    static Atom _XA_DT_WORKSPACE_CURRENT = None;
-
-    /* Property value */
-    Window wmwin;
-    Atom *curws;
-
-    /* Request status */
-    int status;
-
-    /* Returns of XGetWindowProperty */
-    Atom actual_type;
-    int actual_format;
-    unsigned long nitems;
-    unsigned long bytes_after;
-    long *data;                 /* NB: 64 bit: Format 32 props are 'long' */
-
-    DTRACE_PRINT("WM: checking for MWM ...  ");
-
-    if (!awt_wm_atomInterned(&_XA_MOTIF_WM_INFO, "_MOTIF_WM_INFO")
-        || !awt_wm_atomInterned(&_XA_DT_WORKSPACE_CURRENT, "_DT_WORKSPACE_CURRENT"))
-    {
-        return False;
-    }
-
-
-    status = XGetWindowProperty(awt_display, DefaultRootWindow(awt_display),
-                 _XA_MOTIF_WM_INFO, 0, PROP_MOTIF_WM_INFO_ELEMENTS, False,
-                 _XA_MOTIF_WM_INFO, &actual_type,
-                 &actual_format, &nitems, &bytes_after,
-                 (unsigned char **)&data);
-
-    if (status != Success || data == NULL) {
-        DTRACE_PRINTLN("no _MOTIF_WM_INFO on root");
-        return False;
-    }
-
-    if (actual_type != _XA_MOTIF_WM_INFO || actual_format != 32
-        || nitems != PROP_MOTIF_WM_INFO_ELEMENTS || bytes_after != 0)
-    {
-        DTRACE_PRINTLN("malformed _MOTIF_WM_INFO on root");
-        XFree(data);            /* NULL data already catched above */
-        return False;
-    }
-
-    /* NB: 64 bit: Cannot cast data to MotifWmInfo */
-    wmwin = (Window)data[1];
-    XFree(data);
-
-    /* Now check that this window has _DT_WORKSPACE_CURRENT */
-    curws = awt_getAtomListProperty(wmwin, _XA_DT_WORKSPACE_CURRENT, NULL);
-    if (curws == NULL) {
-        DTRACE_PRINTLN("no _DT_WORKSPACE_CURRENT");
-        return False;
-    }
-
-    DTRACE_PRINTLN("yes");
-    XFree(curws);
-    return True;
-}
-
-
-static Boolean
-awt_wm_isNetWMName(char *name)
-{
-    Window anchor;
-    unsigned char *net_wm_name;
-    Boolean matched;
-
-    anchor = awt_wm_isNetSupporting();
-    if (anchor == None) {
-        return False;
-    }
-
-    DTRACE_PRINT1("WM: checking for %s by _NET_WM_NAME ...  ", name);
-
-    /*
-     * Check both UTF8_STRING and STRING.  We only call this function
-     * with ASCII names and UTF8 preserves ASCII bit-wise.  wm-spec
-     * mandates UTF8_STRING for _NET_WM_NAME but at least sawfish-1.0
-     * still uses STRING.  (mmm, moving targets...).
-     */
-    net_wm_name = awt_getProperty8(anchor, _XA_NET_WM_NAME, XA_UTF8_STRING);
-    if (net_wm_name == NULL) {
-        net_wm_name = awt_getProperty8(anchor, _XA_NET_WM_NAME, XA_STRING);
-    }
-
-    if (net_wm_name == NULL) {
-        DTRACE_PRINTLN("no (missing _NET_WM_NAME)");
-        return False;
-    }
-
-    matched = (strcmp((char *)net_wm_name, name) == 0);
-    if (matched) {
-        DTRACE_PRINTLN("yes");
-    } else {
-        DTRACE_PRINTLN1("no (_NET_WM_NAME = \"%s\")", net_wm_name);
-    }
-    XFree(net_wm_name);
-    return matched;
-}
-
-/*
- * Is Sawfish running?
- */
-static Boolean
-awt_wm_isSawfish(void)
-{
-    return awt_wm_isNetWMName("Sawfish");
-}
-
-/*
- * Is KDE2 (KWin) running?
- */
-static Boolean
-awt_wm_isKDE2(void)
-{
-    return awt_wm_isNetWMName("KWin");
-}
-
-
-/*
- * Is Metacity running?
- */
-static Boolean
-awt_wm_isMetacity(void)
-{
-    return awt_wm_isNetWMName("Metacity");
-}
-
-
-/*
- * Temporary error handler that ensures that we know if
- * XChangeProperty succeeded or not.
- */
-static int /* but ignored */
-xerror_verify_change_property(Display *dpy, XErrorEvent *err)
-{
-    XERROR_SAVE(err);
-    if (err->request_code == X_ChangeProperty) {
-        return 0;
-    }
-    else {
-        return (*xerror_saved_handler)(dpy, err);
-    }
-}
-
-
-/*
- * Prepare IceWM check.
- *
- * The only way to detect IceWM, seems to be by setting
- * _ICEWM_WINOPTHINT(_ICEWM_WINOPTHINT/8) on root and checking if it
- * was immediately deleted by IceWM.
- *
- * But messing with PropertyNotify here is way too much trouble, so
- * approximate the check by setting the property in this function and
- * checking if it still exists later on.
- *
- * Gaa, dirty dances...
- */
-static Boolean
-awt_wm_prepareIsIceWM(void)
-{
-    static Atom _XA_ICEWM_WINOPTHINT = None;
-
-    /*
-     * Choose something innocuous: "AWT_ICEWM_TEST allWorkspaces 0".
-     * IceWM expects "class\0option\0arg\0" with zero bytes as delimiters.
-     */
-    static unsigned char opt[] = {
-        'A','W','T','_','I','C','E','W','M','_','T','E','S','T','\0',
-        'a','l','l','W','o','r','k','s','p','a','c','e','s','\0',
-        '0','\0'
-    };
-
-    DTRACE_PRINT("WM: scheduling check for IceWM ...  ");
-
-    if (!awt_wm_atomInterned(&_XA_ICEWM_WINOPTHINT, "_ICEWM_WINOPTHINT")) {
-        return False;
-    }
-
-    WITH_XERROR_HANDLER(xerror_verify_change_property);
-    {
-        XChangeProperty(awt_display, DefaultRootWindow(awt_display),
-                        _XA_ICEWM_WINOPTHINT, _XA_ICEWM_WINOPTHINT, 8,
-                        PropModeReplace, opt, sizeof(opt));
-    }
-    RESTORE_XERROR_HANDLER;
-
-    if (xerror_code != Success) {
-        DTRACE_PRINTLN1("can't set _ICEWM_WINOPTHINT, error = %d",
-                        xerror_code);
-        return False;
-    }
-    else {
-        DTRACE_PRINTLN("scheduled");
-        return True;
-    }
-}
-
-/*
- * Is IceWM running?
- *
- * Note well: Only call this if awt_wm_prepareIsIceWM succeeded, or a
- * false positive will be reported.
- */
-static Boolean
-awt_wm_isIceWM(void)
-{
-    static Atom _XA_ICEWM_WINOPTHINT = None;
-
-    /* Request status */
-    int status;
-
-    /* Returns of XGetWindowProperty */
-    Atom actual_type;
-    int actual_format;
-    unsigned long nitems;
-    unsigned long bytes_after;
-    unsigned char *data;
-
-    DTRACE_PRINT("WM: checking for IceWM ...  ");
-
-    if (!awt_wm_atomInterned(&_XA_ICEWM_WINOPTHINT, "_ICEWM_WINOPTHINT")) {
-        return False;
-    }
-
-    XGetWindowProperty(awt_display, DefaultRootWindow(awt_display),
-                 _XA_ICEWM_WINOPTHINT, 0, 0xFFFF, True, /* NB: deleting! */
-                 _XA_ICEWM_WINOPTHINT, &actual_type,
-                 &actual_format, &nitems, &bytes_after,
-                 &data);
-
-    if (data != NULL) {
-        XFree(data);
-    }
-
-    if (actual_type == None) {
-        DTRACE_PRINTLN("yes");
-        return True;
-    }
-    else {
-        DTRACE_PRINTLN("no");
-        return False;
-    }
-}
-
-/*
- * Is OpenLook WM running?
- *
- * This one is pretty lame, but the only property peculiar to OLWM is
- * _SUN_WM_PROTOCOLS(ATOM[]).  Fortunately, olwm deletes it on exit.
- */
-static Boolean
-awt_wm_isOpenLook(void)
-{
-    static Atom _XA_SUN_WM_PROTOCOLS = None;
-    Atom *list;
-
-    DTRACE_PRINT("WM: checking for OpenLook WM ...  ");
-
-    if (!awt_wm_atomInterned(&_XA_SUN_WM_PROTOCOLS, "_SUN_WM_PROTOCOLS")) {
-        return False;
-    }
-
-    list = awt_getAtomListProperty(DefaultRootWindow(awt_display),
-                                   _XA_SUN_WM_PROTOCOLS, NULL);
-    if (list == NULL) {
-        DTRACE_PRINTLN("no _SUN_WM_PROTOCOLS on root");
-        return False;
-    }
-
-    DTRACE_PRINTLN("yes");
-    XFree(list);
-    return True;
-}
-
-
-
-static Boolean winmgr_running = False;
-
-/*
- * Temporary error handler that checks if selecting for
- * SubstructureRedirect failed.
- */
-static int /* but ignored */
-xerror_detect_wm(Display *dpy, XErrorEvent *err)
-{
-    XERROR_SAVE(err);
-    if (err->request_code == X_ChangeWindowAttributes
-        && err->error_code == BadAccess)
-    {
-        DTRACE_PRINTLN("some WM is running (hmm, we'll see)");
-        winmgr_running = True;
-        return 0;
-    }
-    else {
-        return (*xerror_saved_handler)(dpy, err);
-    }
-}
-
-
-/*
- * Make an educated guess about running window manager.
- * XXX: ideally, we should detect wm restart.
- */
-enum wmgr_t
-awt_wm_getRunningWM(void)
-{
-    /*
-     * Ideally, we should support cases when a different WM is started
-     * during a Java app lifetime.
-     */
-    static enum wmgr_t awt_wmgr = UNDETERMINED_WM;
-
-    XSetWindowAttributes substruct;
-    const char *vendor_string;
-    Boolean doIsIceWM;
-
-    if (awt_wmgr != UNDETERMINED_WM) {
-        return awt_wmgr;
-    }
-
-    /*
-     * Quick checks for specific servers.
-     */
-    vendor_string = ServerVendor(awt_display);
-    if (strstr(vendor_string, "eXcursion") != NULL) {
-        /*
-         * Use NO_WM since in all other aspects eXcursion is like not
-         * having a window manager running. I.e. it does not reparent
-         * top level shells.
-         */
-        DTRACE_PRINTLN("WM: eXcursion detected - treating as NO_WM");
-        awt_wmgr = NO_WM;
-        return awt_wmgr;
-    }
-
-    /*
-     * If *any* window manager is running?
-     *
-     * Try selecting for SubstructureRedirect, that only one client
-     * can select for, and if the request fails, than some other WM is
-     * already running.
-     */
-    winmgr_running = 0;
-    substruct.event_mask = SubstructureRedirectMask;
-
-    DTRACE_PRINT("WM: trying SubstructureRedirect ...  ");
-    WITH_XERROR_HANDLER(xerror_detect_wm);
-    {
-        XChangeWindowAttributes(awt_display, DefaultRootWindow(awt_display),
-                                CWEventMask, &substruct);
-    }
-    RESTORE_XERROR_HANDLER;
-
-    /*
-     * If no WM is running than our selection for SubstructureRedirect
-     * succeeded and needs to be undone (hey we are *not* a WM ;-).
-     */
-    if (!winmgr_running) {
-        DTRACE_PRINTLN("no WM is running");
-        awt_wmgr = NO_WM;
-        substruct.event_mask = 0;
-        XChangeWindowAttributes(awt_display, DefaultRootWindow(awt_display),
-                                CWEventMask, &substruct);
-        return NO_WM;
-    }
-
-    /* actual check for IceWM to follow below */
-    doIsIceWM = awt_wm_prepareIsIceWM(); /* and let IceWM to act */
-
-    if (awt_wm_isNetSupporting()) {
-        awt_wm_doStateProtocolNet();
-    }
-    if (awt_wm_isWinSupporting()) {
-        awt_wm_doStateProtocolWin();
-    }
-
-    /*
-     * Ok, some WM is out there.  Check which one by testing for
-     * "distinguishing" atoms.
-     */
-    if (doIsIceWM && awt_wm_isIceWM()) {
-        awt_wmgr = ICE_WM;
-    }
-    else if (awt_wm_isEnlightenment()) {
-        awt_wmgr = ENLIGHTEN_WM;
-    }
-    else if (awt_wm_isMetacity()) {
-        awt_wmgr = METACITY_WM;
-    }
-    else if (awt_wm_isSawfish()) {
-        awt_wmgr = SAWFISH_WM;
-    }
-    else if (awt_wm_isKDE2()) {
-        awt_wmgr = KDE2_WM;
-    }
-    /*
-     * We don't check for legacy WM when we already know that WM
-     * supports WIN or _NET wm spec.
-     */
-    else if (awt_wm_isNetSupporting()) {
-        DTRACE_PRINTLN("WM: other WM (supports _NET)");
-        awt_wmgr = OTHER_WM;
-    }
-    else if (awt_wm_isWinSupporting()) {
-        DTRACE_PRINTLN("WM: other WM (supports _WIN)");
-        awt_wmgr = OTHER_WM;
-    }
-    /*
-     * Check for legacy WMs.
-     */
-    else if (awt_wm_isCDE()) {  /* XXX: must come before isMotif */
-        awt_wmgr = CDE_WM;
-    }
-    else if (awt_wm_isMotif()) {
-        awt_wmgr = MOTIF_WM;
-    }
-    else if (awt_wm_isOpenLook()) {
-        awt_wmgr = OPENLOOK_WM;
-    }
-    else {
-        DTRACE_PRINTLN("WM: some other legacy WM");
-        awt_wmgr = OTHER_WM;
-    }
-
-    return awt_wmgr;
-}
-
-
-/*
- * Some buggy WMs ignore window gravity when processing
- * ConfigureRequest and position window as if the gravity is Static.
- * We work around this in MWindowPeer.pReshape().
- */
-Boolean
-awt_wm_configureGravityBuggy(void)
-{
-    static int env_not_checked = 1;
-    static int env_buggy = 0;
-
-    if (env_not_checked) {
-        DTRACE_PRINT("WM: checking for _JAVA_AWT_WM_STATIC_GRAVITY in environment ...  ");
-        if (getenv("_JAVA_AWT_WM_STATIC_GRAVITY") != NULL) {
-            DTRACE_PRINTLN("set");
-            env_buggy = 1;
-        } else {
-            DTRACE_PRINTLN("no");
-        }
-        env_not_checked = 0;
-    }
-
-    if (env_buggy) {
-        return True;
-    }
-
-    switch (awt_wm_getRunningWM()) {
-      case ICE_WM:
-          /*
-           * See bug #228981 at IceWM's SourceForge pages.
-           * Latest stable version 1.0.8-6 still has this problem.
-           */
-          return True;
-
-      case ENLIGHTEN_WM:
-          /* At least E16 is buggy. */
-          return True;
-
-      default:
-          return False;
-    }
-}
-
-/**
- * Check if state is supported.
- * Note that a compound state is always reported as not supported.
- * Note also that MAXIMIZED_BOTH is considered not a compound state.
- * Therefore, a compound state is just ICONIFIED | anything else.
- *
- */
-Boolean
-awt_wm_supportsExtendedState(jint state)
-{
-    switch (state) {
-      case java_awt_Frame_MAXIMIZED_VERT:
-      case java_awt_Frame_MAXIMIZED_HORIZ:
-          /*
-           * WMs that talk NET/WIN protocol, but do not support
-           * unidirectional maximization.
-           */
-          if (awt_wm_getRunningWM() == METACITY_WM) {
-              /* "This is a deliberate policy decision." -hp */
-              return JNI_FALSE;
-          }
-          /* FALLTROUGH */
-      case java_awt_Frame_MAXIMIZED_BOTH:
-          return (awt_wm_doStateProtocolNet() || awt_wm_doStateProtocolWin());
-      default:
-          return JNI_FALSE;
-    }
-}
-
-
-
-
-/*****************************************************************************\
- *
- * Size and decoration hints ...
- *
-\*****************************************************************************/
-
-
-/*
- * Remove size hints specified by the mask.
- * XXX: Why do we need this in the first place???
- */
-void
-awt_wm_removeSizeHints(Widget shell, long mask)
-{
-    Display *dpy = XtDisplay(shell);
-    Window shell_win = XtWindow(shell);
-    XSizeHints *hints = XAllocSizeHints();
-    long ignore = 0;
-
-    if (hints == NULL) {
-        DTRACE_PRINTLN("WM: removeSizeHints FAILED to allocate XSizeHints");
-        return;
-    }
-
-    /* sanitize the mask, only do these hints */
-    mask &= (PMaxSize|PMinSize|USPosition|PPosition);
-
-    XGetWMNormalHints(dpy, shell_win, hints, &ignore);
-    if ((hints->flags & mask) == 0) {
-        XFree(hints);
-        return;
-    }
-
-#ifdef DEBUG
-    DTRACE_PRINT("WM: removing hints");
-
-    if (mask & PMaxSize) {
-        DTRACE_PRINT(" Max = ");
-        if (hints->flags & PMaxSize) {
-            DTRACE_PRINT2("%d x %d;", hints->max_width, hints->max_height);
-        } else {
-            DTRACE_PRINT("none;");
-        }
-    }
-
-    if (mask & PMinSize) {
-        DTRACE_PRINT(" Min = ");
-        if (hints->flags & PMinSize) {
-            DTRACE_PRINT2("%d x %d;", hints->min_width, hints->min_height);
-        } else {
-            DTRACE_PRINT("none;");
-        }
-    }
-
-    DTRACE_PRINTLN("");
-#endif
-
-    hints->flags &= ~mask;
-    XSetWMNormalHints(dpy, shell_win, hints);
-    XFree(hints);
-}
-
-/*
- *
- *
- */
-static void
-awt_wm_proclaimUrgency(struct FrameData *wdata)
-{
-    Display *dpy = XtDisplay(wdata->winData.shell);
-    Window shell_win = XtWindow(wdata->winData.shell);
-
-    XWMHints *hints = XGetWMHints(dpy, shell_win);
-    if( hints == NULL ) {
-       /* For now just */ return;
-    }
-    if ((hints->flags & URGENCY_HINT) != 0) {
-        /* it's here already */
-        XFree(hints);
-        return;
-    }
-    hints->flags |= URGENCY_HINT;
-    XSetWMHints(dpy, shell_win, hints);
-    XFree(hints);
-}
-
-/*
- * If MWM_DECOR_ALL bit is set, then the rest of the bit-mask is taken
- * to be subtracted from the decorations.  Normalize decoration spec
- * so that we can map motif decor to something else bit-by-bit in the
- * rest of the code.
- */
-static int
-awt_wm_normalizeMotifDecor(int decorations)
-{
-    int d;
-
-    if (!(decorations & MWM_DECOR_ALL))
-        return decorations;     /* already normalized */
-
-    d = MWM_DECOR_BORDER |MWM_DECOR_RESIZEH | MWM_DECOR_TITLE
-        | MWM_DECOR_MENU | MWM_DECOR_MINIMIZE | MWM_DECOR_MAXIMIZE;
-    d &= ~decorations;
-    return d;
-}
-
-
-/*
- * Infer OL properties from MWM decorations.
- * Use _OL_DECOR_DEL(ATOM[]) to remove unwanted ones.
- */
-static void
-awt_wm_setOLDecor(struct FrameData *wdata, Boolean resizable, int decorations)
-{
-    Window shell_win = XtWindow(wdata->winData.shell);
-    Atom decorDel[3];
-    int nitems;
-
-    if (shell_win == None) {
-        DTRACE_PRINTLN("WM: setOLDecor - no window, returning");
-        return;
-    }
-
-    decorations = awt_wm_normalizeMotifDecor(decorations);
-    DTRACE_PRINT("WM: _OL_DECOR_DEL = {");
-
-    nitems = 0;
-    if (!(decorations & MWM_DECOR_TITLE)) {
-        DTRACE_PRINT(" _OL_DECOR_HEADER");
-        decorDel[nitems++] = _XA_OL_DECOR_HEADER;
-    }
-    if (!(decorations & (MWM_DECOR_RESIZEH | MWM_DECOR_MAXIMIZE))) {
-        DTRACE_PRINT(" _OL_DECOR_RESIZE");
-        decorDel[nitems++] = _XA_OL_DECOR_RESIZE;
-    }
-    if (!(decorations & (MWM_DECOR_MENU | MWM_DECOR_MAXIMIZE
-                         | MWM_DECOR_MINIMIZE)))
-    {
-        DTRACE_PRINT(" _OL_DECOR_CLOSE");
-        decorDel[nitems++] = _XA_OL_DECOR_CLOSE;
-    }
-    DTRACE_PRINT(" }");
-
-    if (nitems == 0) {
-        DTRACE_PRINTLN(" ...  removing");
-        XDeleteProperty(awt_display, shell_win, _XA_OL_DECOR_DEL);
-    }
-    else {
-        DTRACE_PRINTLN(" ...  setting");
-        XChangeProperty(awt_display, shell_win,
-                        _XA_OL_DECOR_DEL, XA_ATOM, 32,
-                        PropModeReplace, (unsigned char *)decorDel, nitems);
-    }
-}
-
-/*
- * Set MWM decorations.  Infer MWM functions from decorations.
- */
-static void
-awt_wm_setMotifDecor(struct FrameData *wdata, Boolean resizable, int decorations)
-{
-    int functions;
-
-    /* Apparently some WMs don't implement MWM_*_ALL semantic correctly */
-    if ((decorations & MWM_DECOR_ALL) && (decorations != MWM_DECOR_ALL)) {
-        decorations = awt_wm_normalizeMotifDecor(decorations);
-        DTRACE_PRINTLN1("WM: setMotifDecor normalize exclusions, decor = 0x%X",
-                        decorations);
-    }
-
-    DTRACE_PRINT("WM: setMotifDecor functions = {");
-    functions = 0;
-
-    if (decorations & MWM_DECOR_ALL) {
-        DTRACE_PRINT(" ALL");
-        functions |= MWM_FUNC_ALL;
-    }
-    else {
-        /*
-         * Functions we always want to be enabled as mwm(1) and
-         * descendants not only hide disabled functions away from
-         * user, but also ignore corresponding requests from the
-         * program itself (e.g. 4442047).
-         */
-        DTRACE_PRINT(" CLOSE MOVE MINIMIZE");
-        functions |= (MWM_FUNC_CLOSE | MWM_FUNC_MOVE | MWM_FUNC_MINIMIZE);
-
-        if (resizable) {
-            DTRACE_PRINT(" RESIZE MAXIMIZE");
-            functions |= MWM_FUNC_RESIZE | MWM_FUNC_MAXIMIZE;
-        }
-    }
-
-    DTRACE_PRINTLN(" }");
-
-    XtVaSetValues(wdata->winData.shell,
-                  XmNmwmDecorations, decorations,
-                  XmNmwmFunctions, functions,
-                  NULL);
-}
-
-
-/*
- * Under some window managers if shell is already mapped, we MUST
- * unmap and later remap in order to effect the changes we make in the
- * window manager decorations.
- *
- * N.B.  This unmapping / remapping of the shell exposes a bug in
- * X/Motif or the Motif Window Manager.  When you attempt to map a
- * widget which is positioned (partially) off-screen, the window is
- * relocated to be entirely on screen. Good idea.  But if both the x
- * and the y coordinates are less than the origin (0,0), the first
- * (re)map will move the window to the origin, and any subsequent
- * (re)map will relocate the window at some other point on the screen.
- * I have written a short Motif test program to discover this bug.
- * This should occur infrequently and it does not cause any real
- * problem.  So for now we'll let it be.
- */
-static Boolean
-awt_wm_needRemap()
-{
-    switch (awt_wm_getRunningWM()) {
-#if 0 /* XXX */
-      case OPENLOOK_WM:
-      case MOTIF_WM:
-      case CDE_WM:
-      case ICE_WM:
-      case ENLIGHTEN_WM:
-          return True;
-#endif
-      default:
-          return True;
-    }
-}
-
-/*
- * Set decoration hints on the shell to wdata->decor adjusted
- * appropriately if not resizable.
- */
-void
-awt_wm_setShellDecor(struct FrameData *wdata, Boolean resizable)
-{
-    int decorations = wdata->decor;
-
-    DTRACE_PRINTLN3("WM: setShellDecor(0x%x/0x%x, %s)",
-                    wdata->winData.shell, XtWindow(wdata->winData.shell),
-                    resizable ? "resizable" : "not resizable");
-
-    if (!resizable) {
-        if (decorations & MWM_DECOR_ALL) {
-            decorations |= (MWM_DECOR_RESIZEH | MWM_DECOR_MAXIMIZE);
-        }
-        else {
-            decorations &= ~(MWM_DECOR_RESIZEH | MWM_DECOR_MAXIMIZE);
-        }
-    }
-
-    DTRACE_PRINTLN1("WM:     decorations = 0x%X", decorations);
-    awt_wm_setMotifDecor(wdata, resizable, decorations);
-    awt_wm_setOLDecor(wdata, resizable, decorations);
-
-    /* Some WMs need remap to redecorate the window */
-    if (wdata->isShowing && awt_wm_needRemap()) {
-        /*
-         * Do the re/mapping at the Xlib level.  Since we essentially
-         * work around a WM bug we don't want this hack to be exposed
-         * to Intrinsics (i.e. don't mess with grabs, callbacks etc).
-         */
-        Display *dpy = XtDisplay(wdata->winData.shell);
-        Window shell_win = XtWindow(wdata->winData.shell);
-
-        DTRACE_PRINT("WM: setShellDecor REMAPPING ...  ");
-        XUnmapWindow(dpy, shell_win);
-        XSync(dpy, False);      /* give WM a chance to catch up */
-        XMapWindow(dpy, shell_win);
-        DTRACE_PRINTLN("done");
-    }
-}
-
-
-/*
- * Make specified shell resizable.
- */
-void
-awt_wm_setShellResizable(struct FrameData *wdata)
-{
-    DTRACE_PRINTLN2("WM: setShellResizable(0x%x/0x%x)",
-                    wdata->winData.shell, XtWindow(wdata->winData.shell));
-
-    XtVaSetValues(wdata->winData.shell,
-                  XmNallowShellResize, True,
-                  XmNminWidth,  XtUnspecifiedShellInt,
-                  XmNminHeight, XtUnspecifiedShellInt,
-                  XmNmaxWidth,  XtUnspecifiedShellInt,
-                  XmNmaxHeight, XtUnspecifiedShellInt,
-                  NULL);
-
-    /* REMINDER: will need to revisit when setExtendedStateBounds is added */
-    awt_wm_removeSizeHints(wdata->winData.shell, PMinSize|PMaxSize);
-
-    /* Restore decorations */
-    awt_wm_setShellDecor(wdata, True);
-}
-
-
-/*
- * Make specified shell non-resizable.
- * If justChangeSize is false, update decorations as well.
- */
-void
-awt_wm_setShellNotResizable(struct FrameData *wdata,
-                            int32_t width, int32_t height,
-                            Boolean justChangeSize)
-{
-    DTRACE_PRINTLN5("WM: setShellNotResizable(0x%x/0x%x, %d, %d, %s)",
-                    wdata->winData.shell, XtWindow(wdata->winData.shell),
-                    width, height,
-                    justChangeSize ? "size only" : "redecorate");
-
-    /* Fix min/max size hints at the specified values */
-    if ((width > 0) && (height > 0)) {
-        XtVaSetValues(wdata->winData.shell,
-                      XmNwidth,     (XtArgVal)width,
-                      XmNheight,    (XtArgVal)height,
-                      XmNminWidth,  (XtArgVal)width,
-                      XmNminHeight, (XtArgVal)height,
-                      XmNmaxWidth,  (XtArgVal)width,
-                      XmNmaxHeight, (XtArgVal)height,
-                      NULL);
-    }
-
-    if (!justChangeSize) {      /* update decorations */
-        awt_wm_setShellDecor(wdata, False);
-    }
-}
-
-
-/*
- * Helper function for awt_wm_getInsetsFromProp.
- * Read property of type CARDINAL[4] = { left, right, top, bottom }
- */
-static Boolean
-awt_wm_readInsetsArray(Window shell_win, Atom insets_property,
-    int32_t *top, int32_t *left, int32_t *bottom, int32_t *right)
-{
-    /* Request status */
-    int status;
-
-    /* Returns of XGetWindowProperty */
-    Atom actual_type;
-    int actual_format;
-    unsigned long nitems;
-    unsigned long bytes_after;
-    long *insets = NULL;        /* NB: 64 bit: Format 32 props are 'long' */
-
-    status = XGetWindowProperty (awt_display, shell_win,
-                 insets_property, 0, 4, False, XA_CARDINAL,
-                 &actual_type, &actual_format, &nitems, &bytes_after,
-                 (unsigned char **)&insets);
-
-    if (status != Success || insets == NULL) {
-        DTRACE_PRINTLN("failed");
-        return False;
-    }
-
-    if (actual_type != XA_CARDINAL || actual_format != 32) {
-        DTRACE_PRINTLN("type/format mismatch");
-        XFree(insets);
-        return False;
-    }
-
-    *left   = (int32_t)insets[0];
-    *right  = (int32_t)insets[1];
-    *top    = (int32_t)insets[2];
-    *bottom = (int32_t)insets[3];
-    XFree(insets);
-
-    /* Order is that of java.awt.Insets.toString */
-    DTRACE_PRINTLN4("[top=%d,left=%d,bottom=%d,right=%d]",
-                    *top, *left, *bottom, *right);
-    return True;
-}
-
-/*
- * If WM implements the insets property - fill insets with values
- * specified in that property.
- */
-Boolean
-awt_wm_getInsetsFromProp(Window shell_win,
-    int32_t *top, int32_t *left, int32_t *bottom, int32_t *right)
-{
-    switch (awt_wm_getRunningWM()) {
-
-      case ENLIGHTEN_WM:
-          DTRACE_PRINT("WM: reading _E_FRAME_SIZE ...  ");
-          return awt_wm_readInsetsArray(shell_win, _XA_E_FRAME_SIZE,
-                                        top, left, bottom, right);
-
-#if 0
-     /*
-      * uwe: disabled for now, as KDE seems to supply bogus values
-      * when we maximize iconified frame.  Need to verify with KDE2.1.
-      * NB: Also note, that "external" handles (e.g. in laptop decor)
-      * are also included in the frame strut, which is probably not
-      * what we want.
-      */
-      case KDE2_WM:
-          DTRACE_PRINT("WM: reading _KDE_NET_WM_FRAME_STRUT ...  ");
-          return awt_wm_readInsetsArray(shell_win, _XA_KDE_NET_WM_FRAME_STRUT,
-                                        top, left, bottom, right);
-#endif
-
-      default:
-          return False;
-    }
-}
-
-/*
- * XmNiconic and Map/UnmapNotify (that XmNiconic relies on) are
- * unreliable, since mapping changes can happen for a virtual desktop
- * switch or MacOS style shading that became quite popular under X as
- * well.  Yes, it probably should not be this way, as it violates
- * ICCCM, but reality is that quite a lot of window managers abuse
- * mapping state.
- */
-int
-awt_wm_getWMState(Window shell_win)
-{
-    /* Request status */
-    int status;
-
-    /* Returns of XGetWindowProperty */
-    Atom actual_type;
-    int actual_format;
-    unsigned long nitems;
-    unsigned long bytes_after;
-    long *data;                 /* NB: 64 bit: Format 32 props are 'long' */
-
-    int wm_state;
-
-    status = XGetWindowProperty(awt_display, shell_win,
-                 XA_WM_STATE, 0, 1, False, XA_WM_STATE,
-                 &actual_type, &actual_format, &nitems, &bytes_after,
-                 (unsigned char **)&data);
-
-    if (status != Success || data == NULL) {
-        return WithdrawnState;
-    }
-
-    if (actual_type != XA_WM_STATE) {
-        DTRACE_PRINTLN1("WM:     WM_STATE(0x%x) - wrong type", shell_win);
-        XFree(data);
-        return WithdrawnState;
-    }
-
-    wm_state = (int)*data;
-    XFree(data);
-    return wm_state;
-}
-
-
-
-/*****************************************************************************\
- *
- * Reading state from properties WM puts on our window ...
- *
-\*****************************************************************************/
-
-/*
- * New "NET" WM spec: _NET_WM_STATE/Atom[]
- */
-static jint
-awt_wm_getStateNet(Window shell_win)
-{
-    Atom *net_wm_state;
-    jint java_state;
-    unsigned long nitems;
-    unsigned long i;
-
-    net_wm_state = awt_getAtomListProperty(shell_win, _XA_NET_WM_STATE, &nitems);
-    if (nitems == 0) {
-        DTRACE_PRINTLN("WM:     _NET_WM_STATE = { }");
-        if (net_wm_state) {
-            XFree(net_wm_state);
-        }
-        return java_awt_Frame_NORMAL;
-    }
-#ifdef DEBUG
-    DTRACE_PRINT("WM:     ");
-    awt_wm_dtraceStateNet(net_wm_state, nitems);
-#endif
-
-    java_state = java_awt_Frame_NORMAL;
-    for (i = 0; i < nitems; ++i) {
-        if (net_wm_state[i] == _XA_NET_WM_STATE_MAXIMIZED_VERT) {
-            java_state |= java_awt_Frame_MAXIMIZED_VERT;
-        }
-        else if (net_wm_state[i] == _XA_NET_WM_STATE_MAXIMIZED_HORZ) {
-            java_state |= java_awt_Frame_MAXIMIZED_HORIZ;
-        }
-    }
-    XFree(net_wm_state);
-    return java_state;
-}
-
-Boolean
-awt_wm_isStateNetHidden(Window shell_win)
-{
-    Atom *net_wm_state;
-    Boolean result = False;
-    unsigned long nitems;
-    unsigned long i;
-
-    net_wm_state = awt_getAtomListProperty(shell_win, _XA_NET_WM_STATE, &nitems);
-    if (nitems == 0) {
-        DTRACE_PRINTLN("WM:     _NET_WM_STATE = { }");
-        if (net_wm_state) {
-            XFree(net_wm_state);
-        }
-        return False;
-    }
-#ifdef DEBUG
-    DTRACE_PRINT("WM:     ");
-    awt_wm_dtraceStateNet(net_wm_state, nitems);
-#endif
-
-    for (i = 0; i < nitems; ++i) {
-        if (net_wm_state[i] == _XA_NET_WM_STATE_HIDDEN) {
-            result = True;
-        }
-    }
-    XFree(net_wm_state);
-    return result;
-}
-
-/*
- * Similar code to getStateNet, to get layer state.
- */
-static int
-awt_wm_getLayerNet(Window shell_win)
-{
-    Atom *net_wm_state;
-    int java_state;
-    unsigned long nitems;
-    unsigned long i;
-
-    net_wm_state = awt_getAtomListProperty(shell_win, _XA_NET_WM_STATE, &nitems);
-    if (nitems == 0) {
-        DTRACE_PRINTLN("WM:     _NET_WM_STATE = { }");
-        if (net_wm_state) {
-            XFree(net_wm_state);
-        }
-        return LAYER_NORMAL;
-    }
-#ifdef DEBUG
-    DTRACE_PRINT("WM:     ");
-    awt_wm_dtraceStateNet(net_wm_state, nitems);
-#endif
-
-    java_state = LAYER_NORMAL;
-    for (i = 0; i < nitems; ++i) {
-        if (net_wm_state[i] == _XA_NET_WM_STATE_ABOVE) {
-            java_state = LAYER_ALWAYS_ON_TOP;
-        }
-    }
-    XFree(net_wm_state);
-    return java_state;
-}
-
-/*
- * Old Gnome spec: _WIN_STATE/CARDINAL
- */
-static jint
-awt_wm_getStateWin(Window shell_win)
-{
-    long win_state;
-    jint java_state;
-
-    win_state = awt_getProperty32(shell_win, _XA_WIN_STATE, XA_CARDINAL);
-#ifdef DEBUG
-    DTRACE_PRINT("WM:     ");
-    awt_wm_dtraceStateWin(win_state);
-#endif
-
-    java_state = java_awt_Frame_NORMAL;
-    if (win_state & WIN_STATE_MAXIMIZED_VERT) {
-        java_state |= java_awt_Frame_MAXIMIZED_VERT;
-    }
-    if (win_state & WIN_STATE_MAXIMIZED_HORIZ) {
-        java_state |= java_awt_Frame_MAXIMIZED_HORIZ;
-    }
-    return java_state;
-}
-
-/*
- * Code similar to getStateWin, to get layer state.
- */
-static int
-awt_wm_getLayerWin(Window shell_win)
-{
-    long win_state;
-    jint java_state;
-
-    win_state = awt_getProperty32(shell_win, _XA_WIN_LAYER, XA_CARDINAL);
-#ifdef DEBUG
-    DTRACE_PRINT("WM:     ");
-    awt_wm_dtraceStateWin(win_state);
-#endif
-
-    java_state = LAYER_NORMAL;
-    if (win_state == WIN_LAYER_ONTOP) {
-        java_state = LAYER_ALWAYS_ON_TOP;
-    }
-    return java_state;
-}
-
-
-static jint
-awt_wm_getExtendedState(Window shell_win)
-{
-    if (awt_wm_doStateProtocolNet()) {
-        return awt_wm_getStateNet(shell_win);
-    }
-    else if (awt_wm_doStateProtocolWin()) {
-        return awt_wm_getStateWin(shell_win);
-    }
-    else {
-        return java_awt_Frame_NORMAL;
-    }
-}
-
-jint
-awt_wm_getState(struct FrameData *wdata)
-{
-    Window shell_win = XtWindow(wdata->winData.shell);
-    jint java_state;
-
-    DTRACE_PRINTLN2("WM: getState(0x%x/0x%x)",
-                    wdata->winData.shell, shell_win);
-
-    if (shell_win == None) {
-        DTRACE_PRINTLN("WM:     no window, use wdata");
-        java_state = wdata->state;
-    }
-    else {
-        int wm_state = awt_wm_getWMState(shell_win);
-        if (wm_state == WithdrawnState) {
-            DTRACE_PRINTLN("WM:     window withdrawn, use wdata");
-            java_state = wdata->state;
-        }
-        else {
-#ifdef DEBUG
-            DTRACE_PRINT("WM:     ");
-            awt_wm_dtraceWMState(wm_state);
-#endif
-            if (wm_state == IconicState) {
-                java_state = java_awt_Frame_ICONIFIED;
-            } else {
-                java_state = java_awt_Frame_NORMAL;
-            }
-            java_state |= awt_wm_getExtendedState(shell_win);
-        }
-    }
-
-#ifdef DEBUG
-    DTRACE_PRINT("WM: ");
-    awt_wm_dtraceStateJava(java_state);
-#endif
-
-    return java_state;
-}
-
-
-
-/*****************************************************************************\
- *
- * Notice window state change when WM changes a property on the window ...
- *
-\*****************************************************************************/
-
-
-/*
- * Check if property change is a window state protocol message.
- * If it is - return True and return the new state in *pstate.
- */
-Boolean
-awt_wm_isStateChange(struct FrameData *wdata, XPropertyEvent *e, jint *pstate)
-{
-    Window shell_win = XtWindow(wdata->winData.shell);
-    Boolean is_state_change = False;
-    int wm_state;
-
-    if (!wdata->isShowing) {
-        return False;
-    }
-
-    wm_state = awt_wm_getWMState(shell_win);
-    if (wm_state == WithdrawnState) {
-        return False;
-    }
-
-    if (e->atom == XA_WM_STATE) {
-        is_state_change = True;
-    }
-    else if (e->atom == _XA_NET_WM_STATE) {
-        is_state_change = awt_wm_doStateProtocolNet();
-    }
-    else if (e->atom == _XA_WIN_STATE) {
-        is_state_change = awt_wm_doStateProtocolWin();
-    }
-
-    if (is_state_change) {
-#ifdef DEBUG
-        Widget shell = wdata->winData.shell;
-        char *name = XGetAtomName(XtDisplay(shell), e->atom);
-        DTRACE_PRINTLN4("WM: PropertyNotify(0x%x/0x%x) %s %s",
-                        shell, XtWindow(shell),
-                        name != NULL ? name : "???",
-                        e->state == PropertyNewValue ? "changed" : "deleted");
-        if (name != NULL) {
-            XFree(name);
-        }
-        DTRACE_PRINT("WM:     ");
-        awt_wm_dtraceWMState(wm_state);
-#endif
-        if (wm_state == IconicState) {
-            *pstate = java_awt_Frame_ICONIFIED;
-        } else {
-            *pstate = java_awt_Frame_NORMAL;
-        }
-        *pstate |= awt_wm_getExtendedState(shell_win);
-
-#ifdef DEBUG
-        DTRACE_PRINT("WM: ");
-        awt_wm_dtraceStateJava(*pstate);
-#endif
-    }
-
-    return is_state_change;
-}
-
-
-
-
-/*****************************************************************************\
- *
- * Setting/changing window state ...
- *
-\*****************************************************************************/
-
-/*
- * Request a state transition from a _NET supporting WM by sending
- * _NET_WM_STATE ClientMessage to root window.
- */
-static void
-awt_wm_requestStateNet(struct FrameData *wdata, jint state)
-{
-    Widget shell = wdata->winData.shell;
-    Window shell_win = XtWindow(shell);
-    XClientMessageEvent req;
-    jint old_net_state;
-    jint max_changed;
-
-    /* must use awt_wm_setInitialStateNet for withdrawn windows */
-    DASSERT(wdata->isShowing);
-
-    /*
-     * We have to use toggle for maximization because of transitions
-     * from maximization in one direction only to maximization in the
-     * other direction only.
-     */
-    old_net_state = awt_wm_getStateNet(shell_win);
-    max_changed = (state ^ old_net_state) & java_awt_Frame_MAXIMIZED_BOTH;
-
-    switch (max_changed) {
-      case 0:
-          DTRACE_PRINTLN("WM: requestStateNet - maximization unchanged");
-          return;
-
-      case java_awt_Frame_MAXIMIZED_HORIZ:
-          DTRACE_PRINTLN("WM: requestStateNet - toggling MAX_HORZ");
-          req.data.l[1] = _XA_NET_WM_STATE_MAXIMIZED_HORZ;
-          req.data.l[2] = 0;
-          break;
-
-      case java_awt_Frame_MAXIMIZED_VERT:
-          DTRACE_PRINTLN("WM: requestStateNet - toggling MAX_VERT");
-          req.data.l[1] = _XA_NET_WM_STATE_MAXIMIZED_VERT;
-          req.data.l[2] = 0;
-          break;
-
-      default: /* both */
-          DTRACE_PRINTLN("WM: requestStateNet - toggling HORZ + VERT");
-          req.data.l[1] = _XA_NET_WM_STATE_MAXIMIZED_HORZ;
-          req.data.l[2] = _XA_NET_WM_STATE_MAXIMIZED_VERT;
-          break;
-    }
-
-    req.type         = ClientMessage;
-    req.window       = XtWindow(shell);
-    req.message_type = _XA_NET_WM_STATE;
-    req.format       = 32;
-    req.data.l[0]    = _NET_WM_STATE_TOGGLE;
-
-    XSendEvent(XtDisplay(shell), RootWindowOfScreen(XtScreen(shell)), False,
-               (SubstructureRedirectMask | SubstructureNotifyMask),
-               (XEvent *)&req);
-}
-
-
-/*
- * Request state transition from a Gnome WM (_WIN protocol) by sending
- * _WIN_STATE ClientMessage to root window.
- */
-static void
-awt_wm_requestStateWin(struct FrameData *wdata, jint state)
-{
-    Widget shell = wdata->winData.shell;
-    XClientMessageEvent req;
-    long win_state;             /* typeof(XClientMessageEvent.data.l) */
-
-    /* must use awt_wm_setInitialStateWin for withdrawn windows */
-    DASSERT(wdata->isShowing);
-
-    win_state = 0;
-    if (state & java_awt_Frame_MAXIMIZED_VERT) {
-        win_state |= WIN_STATE_MAXIMIZED_VERT;
-    }
-    if (state & java_awt_Frame_MAXIMIZED_HORIZ) {
-        win_state |= WIN_STATE_MAXIMIZED_HORIZ;
-    }
-
-    req.type         = ClientMessage;
-    req.window       = XtWindow(shell);
-    req.message_type = _XA_WIN_STATE;
-    req.format       = 32;
-    req.data.l[0]    = (WIN_STATE_MAXIMIZED_HORIZ | WIN_STATE_MAXIMIZED_VERT);
-    req.data.l[1]    = win_state;
-
-    XSendEvent(XtDisplay(shell), RootWindowOfScreen(XtScreen(shell)), False,
-               (SubstructureRedirectMask | SubstructureNotifyMask),
-               (XEvent *)&req);
-}
-
-
-/*
- * Specify initial state for _NET supporting WM by setting
- * _NET_WM_STATE property on the window to the desired state before
- * mapping it.
- */
-static void
-awt_wm_setInitialStateNet(struct FrameData *wdata, jint state)
-{
-    Widget shell = wdata->winData.shell;
-    Window shell_win = XtWindow(shell);
-    Display *dpy = XtDisplay(shell);
-
-    Atom *old_state;
-    unsigned long nitems;
-
-    /* must use awt_wm_requestStateNet for managed windows */
-    DASSERT(!wdata->isShowing);
-
-    /* Be careful to not wipe out state bits we don't understand */
-    old_state = awt_getAtomListProperty(shell_win, _XA_NET_WM_STATE, &nitems);
-
-    if (nitems == 0) {
-        /*
-         * Empty or absent _NET_WM_STATE - set a new one if necessary.
-         */
-        Atom net_wm_state[AWT_NET_N_KNOWN_STATES];
-
-        if (old_state != NULL) {
-            XFree(old_state);
-        }
-
-        if (state & java_awt_Frame_MAXIMIZED_VERT) {
-            net_wm_state[nitems++] = _XA_NET_WM_STATE_MAXIMIZED_VERT;
-        }
-        if (state & java_awt_Frame_MAXIMIZED_HORIZ) {
-            net_wm_state[nitems++] = _XA_NET_WM_STATE_MAXIMIZED_HORZ;
-        }
-        DASSERT(nitems <= AWT_NET_N_KNOWN_STATES);
-
-        if (nitems == 0) {
-            DTRACE_PRINTLN("WM:     initial _NET_WM_STATE not necessary");
-            return;
-        }
-
-#ifdef DEBUG
-        DTRACE_PRINT("WM:     setting initial ");
-        awt_wm_dtraceStateNet(net_wm_state, nitems);
-#endif
-        XChangeProperty(dpy, shell_win,
-                        _XA_NET_WM_STATE, XA_ATOM, 32, PropModeReplace,
-                        (unsigned char *)net_wm_state, nitems);
-    }
-    else {
-        /*
-         * Tweak existing _NET_WM_STATE, preserving bits we don't use.
-         */
-        jint want= state        /* which flags we want */
-            & (java_awt_Frame_MAXIMIZED_HORIZ | java_awt_Frame_MAXIMIZED_VERT);
-
-        jint has = 0;           /* which flags the window already has */
-        int mode;               /* property mode: replace/append */
-
-        Atom *new_state;        /* new _net_wm_state value */
-        int new_nitems;
-        unsigned long i;
-
-#ifdef DEBUG
-        DTRACE_PRINT("WM:     already has ");
-        awt_wm_dtraceStateNet(old_state, nitems);
-#endif
-
-        for (i = 0; i < nitems; ++i) {
-            if (old_state[i] == _XA_NET_WM_STATE_MAXIMIZED_HORZ) {
-                has |= java_awt_Frame_MAXIMIZED_HORIZ;
-            }
-            else if (old_state[i] == _XA_NET_WM_STATE_MAXIMIZED_VERT) {
-                has |= java_awt_Frame_MAXIMIZED_VERT;
-            }
-        }
-
-        if ((has ^ want) == 0) {
-            DTRACE_PRINTLN("WM:     no changes to _NET_WM_STATE necessary");
-            XFree(old_state);
-            return;
-        }
-
-        new_nitems = 0;
-        if (has == 0) {         /* only adding flags */
-            new_state = calloc(AWT_NET_N_KNOWN_STATES, sizeof(Atom));
-            mode = PropModeAppend;
-        }
-        else {
-            new_state = calloc(nitems + AWT_NET_N_KNOWN_STATES, sizeof(Atom));
-            mode = PropModeReplace;
-        }
-
-        if (has != 0) {         /* copy existing flags */
-            DTRACE_PRINT("WM:    ");
-            for (i = 0; i < nitems; ++i) {
-                if (old_state[i] == _XA_NET_WM_STATE_MAXIMIZED_HORZ) {
-                    if (want & java_awt_Frame_MAXIMIZED_HORIZ) {
-                        DTRACE_PRINT(" keep _HORZ");
-                    } else {
-                        DTRACE_PRINT(" drop _HORZ");
-                        continue;
-                    }
-                }
-                else if (old_state[i] == _XA_NET_WM_STATE_MAXIMIZED_VERT) {
-                    if (want & java_awt_Frame_MAXIMIZED_VERT) {
-                        DTRACE_PRINT(" keep _VERT");
-                    } else {
-                        DTRACE_PRINT(" drop _VERT");
-                        continue;
-                    }
-                }
-                new_state[new_nitems++] = old_state[i];
-            }
-        }
-
-        /* Add missing flags */
-        if ((want & java_awt_Frame_MAXIMIZED_HORIZ)
-             && !(has & java_awt_Frame_MAXIMIZED_HORIZ))
-        {
-            DTRACE_PRINT(" add _HORZ");
-            new_state[new_nitems] = _XA_NET_WM_STATE_MAXIMIZED_HORZ;
-            ++new_nitems;
-        }
-        if ((want & java_awt_Frame_MAXIMIZED_VERT)
-             && !(has & java_awt_Frame_MAXIMIZED_VERT))
-        {
-            DTRACE_PRINT(" add _VERT");
-            new_state[new_nitems] = _XA_NET_WM_STATE_MAXIMIZED_VERT;
-            ++new_nitems;
-        }
-
-        DTRACE_PRINTLN(mode == PropModeReplace ?
-                       " ...  replacing" : " ...  appending");
-        XChangeProperty(dpy, shell_win,
-                        _XA_NET_WM_STATE, XA_ATOM, 32, mode,
-                        (unsigned char *)new_state, new_nitems);
-        XFree(old_state);
-        XFree(new_state);
-    }
-}
-
-
-/*
- * Specify initial state for a Gnome WM (_WIN protocol) by setting
- * WIN_STATE property on the window to the desired state before
- * mapping it.
- */
-static void
-awt_wm_setInitialStateWin(struct FrameData *wdata, jint state)
-{
-    Display *dpy = XtDisplay(wdata->winData.shell);
-    Window shell_win = XtWindow(wdata->winData.shell);
-    long win_state, old_win_state;
-
-    /* must use awt_wm_requestStateWin for managed windows */
-    DASSERT(!wdata->isShowing);
-
-    /* Be careful to not wipe out state bits we don't understand */
-    win_state = awt_getProperty32(shell_win, _XA_WIN_STATE, XA_CARDINAL);
-    old_win_state = win_state;
-#ifdef DEBUG
-    if (win_state != 0) {
-        DTRACE_PRINT("WM:     already has ");
-        awt_wm_dtraceStateWin(win_state);
-    }
-#endif
-
-    /*
-     * In their stupid quest of reinventing every wheel, Gnome WM spec
-     * have its own "minimized" hint (instead of using initial state
-     * and WM_STATE hints).  This is bogus, but, apparently, some WMs
-     * pay attention.
-     */
-    if (state & java_awt_Frame_ICONIFIED) {
-        win_state |= WIN_STATE_MINIMIZED;
-    } else {
-        win_state &= ~WIN_STATE_MINIMIZED;
-    }
-
-    if (state & java_awt_Frame_MAXIMIZED_VERT) {
-        win_state |= WIN_STATE_MAXIMIZED_VERT;
-    } else {
-        win_state &= ~WIN_STATE_MAXIMIZED_VERT;
-    }
-
-    if (state & java_awt_Frame_MAXIMIZED_HORIZ) {
-        win_state |= WIN_STATE_MAXIMIZED_HORIZ;
-    } else {
-        win_state &= ~WIN_STATE_MAXIMIZED_HORIZ;
-    }
-
-    if (old_win_state ^ win_state) {
-#ifdef DEBUG
-        DTRACE_PRINT("WM:     setting initial ");
-        awt_wm_dtraceStateWin(win_state);
-#endif
-        XChangeProperty(dpy, shell_win,
-          _XA_WIN_STATE, XA_CARDINAL, 32, PropModeReplace,
-          (unsigned char *)&win_state, 1);
-    }
-#ifdef DEBUG
-    else {
-        DTRACE_PRINTLN("WM:     no changes to _WIN_STATE necessary");
-    }
-#endif
-}
-
-/*
- * Request a layer change from a _NET supporting WM by sending
- * _NET_WM_STATE ClientMessage to root window.
- */
-static void
-awt_wm_requestLayerNet(struct FrameData *wdata, int state)
-{
-    Widget shell = wdata->winData.shell;
-    Window shell_win = XtWindow(shell);
-    XClientMessageEvent req;
-    int currentLayer;
-    long cmd;
-
-    /* must use awt_wm_setInitialLayerNet for withdrawn windows */
-    DASSERT(wdata->isShowing);
-
-    currentLayer = awt_wm_getLayerNet(shell_win);
-    if(state == currentLayer) {
-       return;
-    }
-    cmd = currentLayer == LAYER_ALWAYS_ON_TOP && state == LAYER_NORMAL ?
-                                                  _NET_WM_STATE_REMOVE :
-          currentLayer == LAYER_NORMAL && state == LAYER_ALWAYS_ON_TOP  ?
-                                                  _NET_WM_STATE_ADD :
-                                                  _NET_WM_STATE_ADD;
-    req.type          = ClientMessage;
-    req.window          = XtWindow(shell);
-    req.message_type = _XA_NET_WM_STATE;
-    req.format          = 32;
-    req.data.l[0]    = cmd;
-    req.data.l[1]    = _XA_NET_WM_STATE_ABOVE;
-    req.data.l[2]    = 0L;
-
-    XSendEvent(XtDisplay(shell), RootWindowOfScreen(XtScreen(shell)), False,
-           (SubstructureRedirectMask | SubstructureNotifyMask),
-           (XEvent *)&req);
-}
-
-/*
- * Request a layer change from a Gnome WM (_WIN protocol) by sending
- * _WIN_LAYER ClientMessage to root window.
- */
-static void
-awt_wm_requestLayerWin(struct FrameData *wdata, int state)
-{
-    Widget shell = wdata->winData.shell;
-    XClientMessageEvent req;
-    Display *dpy = XtDisplay(shell);
-
-    /* must use awt_wm_setInitialLayerWin for withdrawn windows */
-    DASSERT(wdata->isShowing);
-
-    req.type          = ClientMessage;
-    req.window          = XtWindow(shell);
-    req.message_type = _XA_WIN_LAYER;
-    req.format          = 32;
-    req.data.l[0]    = state == LAYER_NORMAL ? WIN_LAYER_NORMAL : WIN_LAYER_ONTOP;
-    req.data.l[1]    = 0L;
-    req.data.l[2]    = 0L;
-
-    XSendEvent(XtDisplay(shell), RootWindowOfScreen(XtScreen(shell)), False,
-           /*(SubstructureRedirectMask |*/
-               SubstructureNotifyMask,
-           (XEvent *)&req);
-}
-/*
- * Specify initial layer for _NET supporting WM by setting
- * _NET_WM_STATE property on the window to the desired state before
- * mapping it.
- * NB: looks like it doesn't have any effect.
- */
-static void
-awt_wm_setInitialLayerNet(struct FrameData *wdata, int state)
-{
-    Widget shell = wdata->winData.shell;
-    Window shell_win = XtWindow(shell);
-    Display *dpy = XtDisplay(shell);
-
-    Atom *old_state;
-    unsigned long nitems;
-    Atom new_state = _XA_NET_WM_STATE_ABOVE;
-
-    /* must use awt_wm_requestLayerNet for managed windows */
-    DASSERT(!wdata->isShowing);
-
-    /* Be careful to not wipe out state bits we don't understand */
-    old_state = awt_getAtomListProperty(shell_win, _XA_NET_WM_STATE, &nitems);
-
-    if (nitems == 0 && state != LAYER_ALWAYS_ON_TOP) {
-        if (old_state != NULL) {
-            XFree(old_state);
-        }
-        return;
-    }else if( nitems == 0 && state == LAYER_ALWAYS_ON_TOP) {
-        unsigned long data[2];
-        /* create new state */
-        if (old_state != NULL) {
-            XFree(old_state);
-        }
-        nitems = 1;
-        data[0] = new_state;
-        data[1] = 0;
-        XChangeProperty(dpy, shell_win,
-                _XA_NET_WM_STATE, XA_ATOM, 32, PropModeReplace,
-                (unsigned char *)data, nitems);
-            XSync(dpy, False);
-    }else { /* nitems > 0 */
-        unsigned long i;
-        Boolean bShift = False;
-        int mode;
-        for(i = 0; i < nitems; i++) {
-            if( bShift ) {
-                old_state[i-1] = old_state[i];
-            }else if( old_state[i] == _XA_NET_WM_STATE_ABOVE ) {
-                if(state == LAYER_ALWAYS_ON_TOP) {
-                    /* no change necessary */
-                    XFree(old_state);
-                    return;
-                }else{
-                    /* wipe off this atom */
-                    bShift = True;
-                }
-            }
-        }
-
-        if( bShift ) {
-            /* atom was found and removed: change property */
-            mode = PropModeReplace;
-            nitems--;
-        }else if( state != LAYER_ALWAYS_ON_TOP ) {
-            /* atom was not found and not needed */
-            XFree( old_state);
-            return;
-        }else {
-            /* must add new atom */
-            mode = PropModeAppend;
-            nitems = 1;
-        }
-
-        XChangeProperty(dpy, shell_win,
-                _XA_NET_WM_STATE, XA_ATOM, 32, mode,
-                mode == PropModeAppend ?
-                            (unsigned char *)(&new_state) :
-                            (unsigned char *)old_state, nitems);
-        XFree(old_state);
-            XSync(dpy, False);
-    }
-}
-
-/*
- * Specify initial layer for a Gnome WM (_WIN protocol) by setting
- * WIN_LAYER property on the window to the desired state before
- * mapping it.
- */
-static void
-awt_wm_setInitialLayerWin(struct FrameData *wdata, int state)
-{
-    Display *dpy = XtDisplay(wdata->winData.shell);
-    Window shell_win = XtWindow(wdata->winData.shell);
-    long win_state, old_win_state;
-    int currentLayer;
-
-    /* must use awt_wm_requestLayerWin for managed windows */
-    DASSERT(!wdata->isShowing);
-
-    currentLayer = awt_wm_getLayerWin(shell_win);
-    if( currentLayer == state ) {
-        /* no change necessary */
-        return;
-    }
-    if( state == LAYER_ALWAYS_ON_TOP ) {
-        win_state = WIN_LAYER_ONTOP;
-    }else {
-        win_state = WIN_LAYER_NORMAL;
-    }
-
-    XChangeProperty(dpy, shell_win,
-            _XA_WIN_LAYER, XA_CARDINAL, 32, PropModeReplace,
-            (unsigned char *)&win_state, 1);
-}
-
-void
-awt_wm_setExtendedState(struct FrameData *wdata, jint state)
-{
-    Display *dpy = XtDisplay(wdata->winData.shell);
-    Window shell_win = XtWindow(wdata->winData.shell);
-
-#ifdef DEBUG
-    DTRACE_PRINT2("WM: setExtendedState(0x%x/0x%x) ",
-                  wdata->winData.shell, shell_win);
-    awt_wm_dtraceStateJava(state);
-#endif
-
-    if (wdata->isShowing) {
-        /*
-         * If the window is managed by WM, we should send
-         * ClientMessage requests.
-         */
-        if (awt_wm_doStateProtocolNet()) {
-            awt_wm_requestStateNet(wdata, state);
-        }
-        else if (awt_wm_doStateProtocolWin()) {
-            awt_wm_requestStateWin(wdata, state);
-        }
-        XSync(dpy, False);
-    }
-    else {
-        /*
-         * If the window is withdrawn we should set necessary
-         * properties directly to the window before mapping it.
-         */
-        if (awt_wm_doStateProtocolNet()) {
-            awt_wm_setInitialStateNet(wdata, state);
-        }
-        else if (awt_wm_doStateProtocolWin()) {
-            awt_wm_setInitialStateWin(wdata, state);
-        }
-#if 1
-        /*
-         * Purge KWM bits.
-         * Not really tested with KWM, only with WindowMaker.
-         */
-        XDeleteProperty(dpy, shell_win, XA_KWM_WIN_ICONIFIED);
-        XDeleteProperty(dpy, shell_win, XA_KWM_WIN_MAXIMIZED);
-#endif /* 1 */
-    }
-}
-
-static Boolean
-awt_wm_supportsLayersNet() {
-    Boolean supported = awt_wm_doStateProtocolNet();
-
-    /*
-       In fact, WM may report this not supported but do support.
-     */
-    supported &= awt_wm_checkProtocol(_XA_NET_SUPPORTED, _XA_NET_WM_STATE_ABOVE);
-    return supported;
-}
-
-static Boolean
-awt_wm_supportsLayersWin() {
-    Boolean supported = awt_wm_doStateProtocolWin();
-    /*
-     * In fact, WM may report this supported but do not support.
-     */
-    supported &= awt_wm_checkProtocol(_XA_WIN_PROTOCOLS, _XA_WIN_LAYER);
-    return supported;
-}
-
-void
-awt_wm_updateAlwaysOnTop(struct FrameData *wdata, jboolean bLayerState) {
-    Display *dpy = XtDisplay(wdata->winData.shell);
-    Window shell_win = XtWindow(wdata->winData.shell);
-    int layerState = bLayerState ? LAYER_ALWAYS_ON_TOP : LAYER_NORMAL;
-
-    if (wdata->isShowing) {
-        /**
-           We don't believe anyone, and now send both ClientMessage requests.
-           And eg Metacity under RH 6.1 required both to work.
-         **/
-        awt_wm_requestLayerNet(wdata, layerState);
-        awt_wm_requestLayerWin(wdata, layerState);
-    } else {
-        /**
-           We don't believe anyone, and now set both atoms.
-           And eg Metacity under RH 6.1 required both to work.
-         **/
-        awt_wm_setInitialLayerNet(wdata, layerState);
-        awt_wm_setInitialLayerWin(wdata, layerState);
-    }
-    XSync(dpy, False);
-}
-
-/*
- * Work around for 4775545.  _NET version.
- */
-static void
-awt_wm_unshadeKludgeNet(struct FrameData *wdata)
-{
-    Display *dpy = XtDisplay(wdata->winData.shell);
-    Window shell_win = XtWindow(wdata->winData.shell);
-    Atom *net_wm_state;
-    Boolean shaded;
-    unsigned long nitems;
-    unsigned long i;
-
-    net_wm_state = awt_getAtomListProperty(shell_win,
-                                           _XA_NET_WM_STATE, &nitems);
-    if (nitems == 0) {
-        DTRACE_PRINTLN("WM:     _NET_WM_STATE = { }");
-        if (net_wm_state) {
-            XFree(net_wm_state);
-        }
-        return;
-    }
-#ifdef DEBUG
-    DTRACE_PRINT("WM:     ");
-    awt_wm_dtraceStateNet(net_wm_state, nitems);
-#endif
-
-    shaded = False;
-    for (i = 0; i < nitems; ++i) {
-        if (net_wm_state[i] == _XA_NET_WM_STATE_SHADED) {
-            shaded = True;
-            break;
-        }
-    }
-
-    if (!shaded) {
-        DTRACE_PRINTLN("WM:     not _SHADED, no workaround necessary");
-        return;
-    }
-
-    DTRACE_PRINTLN("WM:     removing _SHADED");
-    ++i;                        /* skip _SHADED  */
-    while (i < nitems) {        /* copy the rest */
-        net_wm_state[i-1] = net_wm_state[i];
-        ++i;
-    }
-    --nitems;                   /* _SHADED has been removed */
-
-#ifdef DEBUG
-    DTRACE_PRINT("WM:     ");
-    awt_wm_dtraceStateNet(net_wm_state, nitems);
-#endif
-
-    WITH_XERROR_HANDLER(xerror_verify_change_property);
-    {
-        XChangeProperty(dpy, shell_win,
-                        _XA_NET_WM_STATE, XA_ATOM, 32, PropModeReplace,
-                        (unsigned char *)net_wm_state, nitems);
-    }
-    RESTORE_XERROR_HANDLER;
-
-    if (xerror_code != Success) {
-        DTRACE_PRINTLN1("WM:     XChangeProperty failed, error = %d",
-                        xerror_code);
-    }
-
-    XFree(net_wm_state);
-}
-
-
-/*
- * Work around for 4775545.  _WIN version.
- */
-static void
-awt_wm_unshadeKludgeWin(struct FrameData *wdata)
-{
-    Display *dpy = XtDisplay(wdata->winData.shell);
-    Window shell_win = XtWindow(wdata->winData.shell);
-    long win_state;
-
-    win_state = awt_getProperty32(shell_win, _XA_WIN_STATE, XA_CARDINAL);
-#ifdef DEBUG
-    DTRACE_PRINT("WM:     ");
-    awt_wm_dtraceStateWin(win_state);
-#endif
-
-    if ((win_state & WIN_STATE_SHADED) == 0) {
-        DTRACE_PRINTLN("WM:     not _SHADED, no workaround necessary");
-        return;
-    }
-
-    win_state &= ~WIN_STATE_SHADED;
-    XChangeProperty(dpy, shell_win,
-                    _XA_WIN_STATE, XA_CARDINAL, 32, PropModeReplace,
-                    (unsigned char *)&win_state, 1);
-}
-
-
-/*
- * Work around for 4775545.
- *
- * If WM exits while the top-level is shaded, the shaded hint remains
- * on the top-level properties.  When WM restarts and sees the shaded
- * window it can reparent it into a "pre-shaded" decoration frame
- * (Metacity does), and our insets logic will go crazy, b/c it will
- * see a huge nagative bottom inset.  There's no clean solution for
- * this, so let's just be weasels and drop the shaded hint if we
- * detect that WM exited.  NB: we are in for a race condition with WM
- * restart here.  NB2: e.g. WindowMaker saves the state in a private
- * property that this code knows nothing about, so this workaround is
- * not effective; other WMs might play similar tricks.
- */
-void
-awt_wm_unshadeKludge(struct FrameData *wdata)
-{
-    DTRACE_PRINTLN("WM: unshade kludge");
-    DASSERT(wdata->isShowing);
-
-    if (awt_wm_doStateProtocolNet()) {
-        awt_wm_unshadeKludgeNet(wdata);
-    }
-    else if (awt_wm_doStateProtocolWin()) {
-        awt_wm_unshadeKludgeWin(wdata);
-    }
-#ifdef DEBUG
-    else {
-        DTRACE_PRINTLN("WM:     not a _NET or _WIN supporting WM");
-    }
-#endif
-
-    XSync(XtDisplay(wdata->winData.shell), False);
-}
-
-
-void
-awt_wm_init(void)
-{
-    static Boolean inited = False;
-    if (inited) {
-        return;
-    }
-
-    awt_wm_initAtoms();
-    awt_wm_getRunningWM();
-    inited = True;
-}
-
-Boolean awt_wm_supportsAlwaysOnTop() {
-    return awt_wm_supportsLayersNet() || awt_wm_supportsLayersWin();
-}
diff --git a/jdk/src/solaris/native/sun/awt/awt_wm.h b/jdk/src/solaris/native/sun/awt/awt_wm.h
deleted file mode 100644
index 6656e2b..0000000
--- a/jdk/src/solaris/native/sun/awt/awt_wm.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (c) 2001, 2004, 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 _AWT_WM_H_
-#define _AWT_WM_H_
-
-#ifndef HEADLESS
-
-#include "awt_p.h"
-
-/*
- * Window Managers we care to distinguish.
- * See awt_wm_getRunningWM()
- */
-enum wmgr_t {
-    UNDETERMINED_WM,
-    NO_WM,
-    OTHER_WM,
-    OPENLOOK_WM,
-    MOTIF_WM,
-    CDE_WM,
-    ENLIGHTEN_WM,
-    KDE2_WM,
-    SAWFISH_WM,
-    ICE_WM,
-    METACITY_WM
-};
-
-extern void awt_wm_init(void);
-
-extern enum wmgr_t awt_wm_getRunningWM(void);
-extern Boolean awt_wm_configureGravityBuggy(void);
-extern Boolean awt_wm_supportsExtendedState(jint state);
-
-/* XWMHints.flags is declared long, so 'mask' argument is declared long too */
-extern void awt_wm_removeSizeHints(Widget shell, long mask);
-
-extern void awt_wm_setShellDecor(struct FrameData *wdata, Boolean resizable);
-extern void awt_wm_setShellResizable(struct FrameData *wdata);
-extern void awt_wm_setShellNotResizable(struct FrameData *wdata,
-                                        int32_t width, int32_t height,
-                                        Boolean justChangeSize);
-
-extern Boolean awt_wm_getInsetsFromProp(Window w,
-                 int32_t *top, int32_t *left, int32_t *bottom, int32_t *right);
-
-/*
- * WM_STATE: WithdrawnState, NormalState, IconicState.
- * Absence of WM_STATE is treated as WithdrawnState.
- */
-extern int awt_wm_getWMState(Window w);
-
-extern void awt_wm_setExtendedState(struct FrameData *wdata, jint state);
-extern Boolean awt_wm_isStateChange(struct FrameData *wdata, XPropertyEvent *e,
-                                    jint *pstate);
-
-extern void awt_wm_unshadeKludge(struct FrameData *wdata);
-extern void awt_wm_updateAlwaysOnTop(struct FrameData *wdata, jboolean bLayerState);
-extern Boolean awt_wm_supportsAlwaysOnTop();
-
-#endif /* !HEADLESS */
-#endif /* _AWT_WM_H_ */
diff --git a/jdk/src/solaris/native/sun/awt/awt_xembed.h b/jdk/src/solaris/native/sun/awt/awt_xembed.h
deleted file mode 100644
index 42b9955..0000000
--- a/jdk/src/solaris/native/sun/awt/awt_xembed.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 2003, 2004, 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 _AWT_XEMBED_H_
-#define _AWT_XEMBED_H_
-
-#ifndef HEADLESS
-
-#include "awt_p.h"
-
-#define XEMBED_VERSION  0
-#define XEMBED_MAPPED  (1 << 0)
-/* XEMBED messages */
-#define XEMBED_EMBEDDED_NOTIFY              0
-#define XEMBED_WINDOW_ACTIVATE      1
-#define XEMBED_WINDOW_DEACTIVATE    2
-#define XEMBED_REQUEST_FOCUS         3
-#define XEMBED_FOCUS_IN             4
-#define XEMBED_FOCUS_OUT            5
-#define XEMBED_FOCUS_NEXT           6
-#define XEMBED_FOCUS_PREV           7
-/* 8-9 were used for XEMBED_GRAB_KEY/XEMBED_UNGRAB_KEY */
-#define XEMBED_MODALITY_ON          10
-#define XEMBED_MODALITY_OFF         11
-#define XEMBED_REGISTER_ACCELERATOR     12
-#define XEMBED_UNREGISTER_ACCELERATOR   13
-#define XEMBED_ACTIVATE_ACCELERATOR     14
-
-#define XEMBED_LAST_MSG XEMBED_ACTIVATE_ACCELERATOR
-
-#define  NON_STANDARD_XEMBED_GTK_GRAB_KEY  108
-#define NON_STANDARD_XEMBED_GTK_UNGRAB_KEY  109
-
-// Sun internal special message, to resolve start race condition
-#define _SUN_XEMBED_START  1119
-
-
-//     A detail code is required for XEMBED_FOCUS_IN. The following values are valid:
-/* Details for  XEMBED_FOCUS_IN: */
-#define XEMBED_FOCUS_CURRENT        0
-#define XEMBED_FOCUS_FIRST          1
-#define XEMBED_FOCUS_LAST           2
-
-
-extern void init_xembed();
-extern void xembed_eventHandler(XEvent *event);
-extern void requestXEmbedFocus(struct FrameData * wdata);
-extern void install_xembed(Widget client, struct FrameData* wdata);
-extern void deinstall_xembed(struct FrameData* wdata);
-extern Boolean isXEmbedActive(struct FrameData * wdata);
-extern Boolean isXEmbedActiveByWindow(Window client);
-extern Boolean isXEmbedApplicationActive(struct FrameData * wdata);
-extern void sendMessageHelper(Window window, int message, long detail,
-                              long data1, long data2);
-extern void sendMessage(Window window, int message);
-extern void xembed_traverse_out(struct FrameData * wdata, jboolean);
-#endif
-#endif
diff --git a/jdk/src/solaris/native/sun/awt/awt_xembed_server.c b/jdk/src/solaris/native/sun/awt/awt_xembed_server.c
deleted file mode 100644
index d4eb5ea..0000000
--- a/jdk/src/solaris/native/sun/awt/awt_xembed_server.c
+++ /dev/null
@@ -1,969 +0,0 @@
-/*
- * Copyright (c) 2003, 2005, 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.
- */
-
-// TODO: Propogate applicationActive from Java
-
-#ifdef HEADLESS
-    #error This file should not be included in headless library
-#endif
-
-#include "awt_p.h"
-
-#include <X11/Xproto.h>
-#include <X11/Xlib.h>
-#include <X11/Xatom.h>
-#include <Xm/MwmUtil.h>
-#ifdef __linux__
-#include <execinfo.h>
-#endif
-#include <stdio.h>
-#include <stdlib.h>
-
-/* JNI headers */
-#include "java_awt_Frame.h"     /* for frame state constants */
-#include "java_awt_event_KeyEvent.h"
-#include "awt_wm.h"
-#include "awt_util.h"           /* for X11 error handling macros */
-#include "awt_xembed.h"
-#include "awt_Component.h"
-#include "awt_AWTEvent.h"
-#include "canvas.h"
-#include "sun_awt_motif_MEmbedCanvasPeer.h"
-
-#ifdef DOTRACE
-#define MTRACE(param) fprintf(stderr, param)
-#define MTRACEP1(format, p1) fprintf(stderr, format, p1)
-#define MTRACEP2(format, p1, p2) fprintf(stderr, format, p1, p2)
-#define MTRACEP3(format, p1, p2, p3) fprintf(stderr, format, p1, p2, p3)
-#define MTRACEP4(format, p1, p2, p3, p4) fprintf(stderr, format, p1, p2, p3, p4)
-#define MTRACEP5(format, p1, p2, p3, p4, p5) fprintf(stderr, format, p1, p2, p3, p4, p5)
-#define MTRACEP6(format, p1, p2, p3, p4, p5, p6) fprintf(stderr, format, p1, p2, p3, p4, p5, p6)
-#define MTRACEP7(format, p1, p2, p3, p4, p5, p6, p7) fprintf(stderr, format, p1, p2, p3, p4, p5, p6, p7)
-#else
-#define MTRACE(param)
-#define MTRACEP1(format, p1)
-#define MTRACEP2(format, p1, p2)
-#define MTRACEP3(format, p1, p2, p3)
-#define MTRACEP4(format, p1, p2, p3, p4)
-#define MTRACEP5(format, p1, p2, p3, p4, p5)
-#define MTRACEP6(format, p1, p2, p3, p4, p5, p6)
-#define MTRACEP7(format, p1, p2, p3, p4, p5, p6, p7)
-#endif
-
-/**************************** XEmbed server DnD support ***********************/
-extern Atom XA_XdndAware;
-extern Boolean
-register_xembed_drop_site(JNIEnv* env, Display* dpy, jobject server,
-                          Window serverHandle, Window clientHandle);
-extern Boolean
-unregister_xembed_drop_site(JNIEnv* env, Display* dpy, jobject server,
-                            Window serverHandle, Window clientHandle);
-extern void
-forward_event_to_embedded(Window embedded, jlong ctxt, jint eventID);
-
-extern const char * msg_to_str(int msg);
-
-void
-set_xembed_drop_target(JNIEnv* env, jobject server);
-void
-remove_xembed_drop_target(JNIEnv* env, jobject server);
-Boolean
-is_xembed_client(Window window);
-/******************************************************************************/
-extern struct MComponentPeerIDs mComponentPeerIDs;
-static jobject createRectangle(JNIEnv* env, int x, int y, int width, int height);
-static jobject createDimension(JNIEnv* env, int width, int height);
-static void processXEmbedInfo(JNIEnv* env, jobject this);
-static Atom XA_XEmbedInfo;
-static Atom XA_XEmbed;
-static jmethodID requestXEmbedFocusMID, focusNextMID, focusPrevMID,
-    registerAcceleratorMID, unregisterAcceleratorMID,
-    grabKeyMID, ungrabKeyMID, childResizedMID,
-    setXEmbedDropTargetMID, removeXEmbedDropTargetMID;
-static jfieldID keysymFID, modifiersFID, applicationActiveFID;
-
-typedef struct _xembed_server_data {
-    Window handle; // pointer to plugin intermediate widget, XEmbed client
-    Window serverHandle;
-    Widget serverWidget;
-    Boolean dispatching; // whether we dispatch messages for handle
-    int version;
-    jobject server;
-    struct _xembed_server_data * next;
-} xembed_server_data, * pxembed_server_data;
-
-static pxembed_server_data xembed_list = NULL;
-
-static pxembed_server_data
-getData(Window handle) {
-    pxembed_server_data temp = xembed_list;
-    while (temp != NULL) {
-        if (temp->handle == handle) {
-            return temp;
-        }
-        temp = temp->next;
-    }
-    return NULL;
-}
-
-static pxembed_server_data
-getDataByEmbedder(jobject server) {
-    JNIEnv      *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
-    pxembed_server_data temp = xembed_list;
-    DASSERT(server != NULL);
-    while (temp != NULL) {
-        if ((*env)->IsSameObject(env, temp->server, server)) {
-            return temp;
-        }
-        temp = temp->next;
-    }
-    return NULL;
-}
-
-static pxembed_server_data
-getDataByServerHandle(Window serverHandle) {
-    JNIEnv      *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
-    pxembed_server_data temp = xembed_list;
-    Widget serverWidget = NULL;
-    if (serverHandle == None) {
-        return NULL;
-    }
-    serverWidget = XtWindowToWidget(awt_display, serverHandle);
-    while (temp != NULL) {
-        if (temp->serverHandle == serverHandle || temp->serverWidget == serverWidget) {
-            temp->serverHandle = serverWidget;
-            return temp;
-        }
-        temp = temp->next;
-    }
-    return NULL;
-}
-
-static pxembed_server_data
-addData(jobject server) {
-    JNIEnv      *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
-    struct ComponentData *cdata;
-    xembed_server_data * data = malloc(sizeof(xembed_server_data));
-    DASSERT(server != NULL);
-    memset(data, 0, sizeof(xembed_server_data));
-    data->server = server;
-    cdata = (struct ComponentData *)
-        JNU_GetLongFieldAsPtr(env, server, mComponentPeerIDs.pData);
-    DASSERT(cdata != NULL);
-    data->serverHandle = XtWindow(cdata->widget);
-    data->serverWidget = cdata->widget;
-    data->next = xembed_list;
-    xembed_list = data;
-    return data;
-}
-
-static void
-removeData(jobject server) {
-    JNIEnv      *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
-    pxembed_server_data * temp = &xembed_list;
-    DASSERT(server != NULL);
-    while (*temp != NULL) {
-        if ((*env)->IsSameObject(env, (*temp)->server, server)) {
-            xembed_server_data * data = *temp;
-            *temp = (*temp)->next;
-            DASSERT(data->server != NULL);
-            (*env)->DeleteGlobalRef(env, data->server);
-            free(data);
-            return;
-        }
-        temp = &(*temp)->next;
-    }
-}
-
-void
-initXEmbedServerData() {
-    JNIEnv      *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
-    jclass clazz;
-    MTRACE("initXEmbedServerData\n");
-    XA_XEmbedInfo = XInternAtom(awt_display, "_XEMBED_INFO", False);
-    XA_XEmbed = XInternAtom(awt_display, "_XEMBED", False);
-
-    clazz = (*env)->FindClass(env, "sun/awt/motif/MEmbedCanvasPeer");
-    DASSERT(clazz != NULL);
-    requestXEmbedFocusMID = (*env)->GetMethodID(env, clazz, "requestXEmbedFocus", "()V");
-    DASSERT(requestXEmbedFocusMID != NULL);
-    focusNextMID = (*env)->GetMethodID(env, clazz, "focusNext", "()V");
-    DASSERT(focusNextMID != NULL);
-    focusPrevMID = (*env)->GetMethodID(env, clazz, "focusPrev", "()V");
-    DASSERT(focusPrevMID != NULL);
-    registerAcceleratorMID = (*env)->GetMethodID(env, clazz, "registerAccelerator", "(JJJ)V");
-    DASSERT(registerAcceleratorMID != NULL);
-    unregisterAcceleratorMID = (*env)->GetMethodID(env, clazz, "unregisterAccelerator", "(J)V");
-    DASSERT(unregisterAcceleratorMID != NULL);
-    grabKeyMID = (*env)->GetMethodID(env, clazz, "grabKey", "(JJ)V");
-    DASSERT(grabKeyMID != NULL);
-    ungrabKeyMID = (*env)->GetMethodID(env, clazz, "ungrabKey", "(JJ)V");
-    DASSERT(ungrabKeyMID != NULL);
-    childResizedMID = (*env)->GetMethodID(env, clazz, "childResized", "()V");
-    DASSERT(childResizedMID != NULL);
-    setXEmbedDropTargetMID =
-        (*env)->GetMethodID(env, clazz, "setXEmbedDropTarget", "()V");
-    DASSERT(setXEmbedDropTargetMID != NULL);
-    removeXEmbedDropTargetMID =
-        (*env)->GetMethodID(env, clazz, "removeXEmbedDropTarget", "()V");
-    DASSERT(removeXEmbedDropTargetMID != NULL);
-
-    applicationActiveFID = (*env)->GetFieldID(env, clazz, "applicationActive", "Z");
-    DASSERT(applicationActiveFID != NULL);
-    (*env)->DeleteLocalRef(env, clazz);
-
-    clazz = (*env)->FindClass(env, "sun/awt/motif/GrabbedKey");
-    DASSERT(clazz != NULL);
-    keysymFID = (*env)->GetFieldID(env, clazz, "keysym", "J");
-    DASSERT(keysymFID != NULL);
-    modifiersFID = (*env)->GetFieldID(env, clazz, "modifiers", "J");
-    DASSERT(modifiersFID != NULL);
-    (*env)->DeleteLocalRef(env, clazz);
-}
-
-/*
- * Class:     sun_awt_motif_MEmbedCanvasPeer
- * Method:    initXEmbedServer
- * Signature: ()V
- */
-JNIEXPORT void JNICALL
-Java_sun_awt_motif_MEmbedCanvasPeer_initXEmbedServer(JNIEnv *env, jobject this) {
-    struct ComponentData *cdata;
-    AWT_LOCK();
-    MTRACE("initXEmbedServer\n");
-    addData((*env)->NewGlobalRef(env, this));
-    if (XA_XEmbedInfo == None) {
-        initXEmbedServerData();
-    }
-    cdata = (struct ComponentData *)
-        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
-/*     XSelectInput(awt_display, XtWindow(cdata->widget), SubstructureNotifyMask); */
-    XtAddEventHandler(cdata->widget,
-                      SubstructureNotifyMask,
-                      False, null_event_handler, NULL);
-    AWT_UNLOCK();
-}
-
-/*
- * Class:     sun_awt_motif_MEmbedCanvasPeer
- * Method:    destroyXEmbedServer
- * Signature: ()V
- */
-JNIEXPORT void JNICALL
-Java_sun_awt_motif_MEmbedCanvasPeer_destroyXEmbedServer(JNIEnv *env, jobject this) {
-    AWT_LOCK();
-    MTRACE("destroyXEmbedServer\n");
-    removeData(this);
-    AWT_UNLOCK();
-}
-
-/*
- * Class:     sun_awt_motif_MEmbedCanvasPeer
- * Method:    isXEmbedActive
- * Signature: ()Z
- */
-JNIEXPORT jboolean JNICALL
-Java_sun_awt_motif_MEmbedCanvasPeer_isXEmbedActive(JNIEnv *env, jobject this) {
-    pxembed_server_data sdata;
-    jboolean res = JNI_FALSE;
-    AWT_LOCK();
-    sdata = getDataByEmbedder(this);
-    if (sdata != NULL) {
-        res = (sdata->handle != None)?JNI_TRUE:JNI_FALSE;
-    }
-    AWT_UNLOCK();
-    return res;
-}
-
-/*
- * Class:     sun_awt_motif_MEmbedCanvasPeer
- * Method:    initDispatching
- * Signature: ()V
- */
-JNIEXPORT void JNICALL
-Java_sun_awt_motif_MEmbedCanvasPeer_initDispatching (JNIEnv *env, jobject this) {
-    pxembed_server_data sdata;
-    AWT_LOCK();
-    MTRACE("initDispatching\n");
-    sdata = getDataByEmbedder(this);
-    if (sdata != NULL) {
-        XSelectInput(awt_display, sdata->handle, StructureNotifyMask | PropertyChangeMask);
-        sdata->dispatching = True;
-        register_xembed_drop_site(env, awt_display, sdata->server,
-                                  sdata->serverHandle, sdata->handle);
-    }
-    processXEmbedInfo(env, this);
-    Java_sun_awt_motif_MEmbedCanvasPeer_notifyChildEmbedded(env, this);
-    AWT_UNLOCK();
-}
-
-/*
- * Class:     sun_awt_motif_MEmbedCanvasPeer
- * Method:    endDispatching
- * Signature: ()V
- */
-JNIEXPORT void JNICALL
-Java_sun_awt_motif_MEmbedCanvasPeer_endDispatching (JNIEnv *env, jobject this) {
-    pxembed_server_data sdata;
-    AWT_LOCK();
-    MTRACE("endDispatching\n");
-    sdata = getDataByEmbedder(this);
-    if (sdata != NULL) {
-        unregister_xembed_drop_site(env, awt_display, sdata->server,
-                                    sdata->serverHandle, sdata->handle);
-        sdata->dispatching = False;
-    }
-    AWT_UNLOCK();
-}
-
-/*
- * Class:     sun_awt_motif_MEmbedCanvasPeer
- * Method:    embedChild
- * Signature: (J)V
- */
-JNIEXPORT void JNICALL
-Java_sun_awt_motif_MEmbedCanvasPeer_embedChild (JNIEnv * env, jobject this, jlong handle) {
-    pxembed_server_data sdata;
-    AWT_LOCK();
-    MTRACE("embedChild\n");
-    sdata = getDataByEmbedder(this);
-    if (sdata != NULL) {
-        if (sdata->handle != None) {
-            Java_sun_awt_motif_MEmbedCanvasPeer_detachChild(env, this);
-        }
-        sdata->handle = (Window)handle;
-        Java_sun_awt_motif_MEmbedCanvasPeer_initDispatching(env, this);
-    }
-    AWT_UNLOCK();
-}
-
-/*
- * Class:     sun_awt_motif_MEmbedCanvasPeer
- * Method:    childDestroyed
- * Signature: ()V
- */
-JNIEXPORT void JNICALL
-Java_sun_awt_motif_MEmbedCanvasPeer_childDestroyed (JNIEnv *env, jobject this) {
-    pxembed_server_data sdata;
-    AWT_LOCK();
-    MTRACE("childDestroyed\n");
-    Java_sun_awt_motif_MEmbedCanvasPeer_endDispatching(env, this);
-    sdata = getDataByEmbedder(this);
-    if (sdata != NULL) {
-        sdata->handle = None;
-    }
-    AWT_UNLOCK();
-}
-
-/*
- * Class:     sun_awt_motif_MEmbedCanvasPeer
- * Method:    getEmbedPreferredSize
- * Signature: ()Ljava/awt/Dimension;
- */
-JNIEXPORT jobject JNICALL
-Java_sun_awt_motif_MEmbedCanvasPeer_getEmbedPreferredSize (JNIEnv *env, jobject this) {
-    pxembed_server_data sdata;
-    jobject res = NULL;
-    XSizeHints * hints;
-    long dummy;
-    AWT_LOCK();
-    MTRACE("getPreferredSize\n");
-    sdata = getDataByEmbedder(this);
-    if (sdata != NULL) {
-        hints = XAllocSizeHints();
-        DASSERT(hints != NULL);
-        DASSERT(sdata->handle != None);
-        if (XGetWMNormalHints(awt_display, sdata->handle, hints, &dummy) == Success) {
-            res = createDimension(env, hints->width, hints->height);
-        }
-        XFree(hints);
-    }
-    AWT_UNLOCK();
-    return res;
-}
-
-/*
- * Class:     sun_awt_motif_MEmbedCanvasPeer
- * Method:    getEmbedMinimumSize
- * Signature: ()Ljava/awt/Dimension;
- */
-JNIEXPORT jobject JNICALL
-Java_sun_awt_motif_MEmbedCanvasPeer_getEmbedMinimumSize (JNIEnv *env, jobject this) {
-    pxembed_server_data sdata;
-    jobject res = NULL;
-    XSizeHints * hints;
-    long dummy;
-    AWT_LOCK();
-    MTRACE("getMinimumSize\n");
-    sdata = getDataByEmbedder(this);
-    if (sdata != NULL) {
-        hints = XAllocSizeHints();
-        DASSERT(hints != NULL);
-        DASSERT(sdata->handle != None);
-        if (XGetWMNormalHints(awt_display, sdata->handle, hints, &dummy) == Success) {
-            res = createDimension(env, hints->min_width, hints->min_height);
-        }
-        XFree(hints);
-    }
-    AWT_UNLOCK();
-    return res;
-}
-
-/*
- * Class:     sun_awt_motif_MEmbedCanvasPeer
- * Method:    getClientBounds
- * Signature: ()Ljava/awt/Rectangle;
- */
-JNIEXPORT jobject JNICALL
-Java_sun_awt_motif_MEmbedCanvasPeer_getClientBounds (JNIEnv *env, jobject this) {
-    pxembed_server_data sdata;
-    jobject res = NULL;
-    AWT_LOCK();
-    MTRACE("getClientBounds\n");
-    sdata = getDataByEmbedder(this);
-    if (sdata != NULL) {
-        XWindowAttributes attrs;
-        DASSERT(sdata->handle != None);
-        if (XGetWindowAttributes(awt_display, sdata->handle, &attrs) == Success) {
-            res = createRectangle(env, attrs.x, attrs.y, attrs.width, attrs.height);
-        }
-    }
-    AWT_UNLOCK();
-    return res;
-}
-
-Boolean
-isApplicationActive(JNIEnv * env, jobject this) {
-    return (*env)->GetBooleanField(env, this, applicationActiveFID);
-}
-
-/*
- * Class:     sun_awt_motif_MEmbedCanvasPeer
- * Method:    notifyChildEmbedded
- * Signature: ()V
- */
-JNIEXPORT void JNICALL
-Java_sun_awt_motif_MEmbedCanvasPeer_notifyChildEmbedded (JNIEnv *env, jobject this) {
-    struct ComponentData *cdata;
-    pxembed_server_data sdata;
-    AWT_LOCK();
-    MTRACE("notifyChildEmbedded\n");
-    cdata = (struct ComponentData *)
-        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
-    sdata = getDataByEmbedder(this);
-    if (sdata != NULL) {
-        DASSERT(sdata->handle != None);
-        DASSERT(cdata != NULL);
-        DASSERT(XtWindow(cdata->widget) != None);
-        sendMessageHelper(sdata->handle, XEMBED_EMBEDDED_NOTIFY, XtWindow(cdata->widget), min(sdata->version, XEMBED_VERSION), 0);
-        if (isApplicationActive(env, this)) {
-            sendMessage(sdata->handle, XEMBED_WINDOW_ACTIVATE);
-        }
-    }
-    AWT_UNLOCK();
-}
-
-/*
- * Class:     sun_awt_motif_MEmbedCanvasPeer
- * Method:    detachChild
- * Signature: ()V
- */
-JNIEXPORT void JNICALL
-Java_sun_awt_motif_MEmbedCanvasPeer_detachChild (JNIEnv *env, jobject this) {
-    pxembed_server_data sdata;
-    AWT_LOCK();
-    MTRACE("detachChild\n");
-    sdata = getDataByEmbedder(this);
-    if (sdata != NULL) {
-        /**
-         *  XEmbed specification:
-         *  "The embedder can unmap the client and reparent the client window to the root window. If the
-         *  client receives an ReparentNotify event, it should check the parent field of the XReparentEvent
-         *  structure. If this is the root window of the window's screen, then the protocol is finished and
-         *  there is no further interaction. If it is a window other than the root window, then the protocol
-         *  continues with the new parent acting as the embedder window."
-         */
-        DASSERT(sdata->handle != None);
-        XUnmapWindow(awt_display, sdata->handle);
-        XReparentWindow(awt_display, sdata->handle, DefaultRootWindow(awt_display), 0, 0);
-        Java_sun_awt_motif_MEmbedCanvasPeer_endDispatching(env, this);
-        sdata->handle = None;
-    }
-    AWT_UNLOCK();
-}
-
-/*
- * Class:     sun_awt_motif_MEmbedCanvasPeer
- * Method:    forwardKeyEvent
- * Signature: (Ljava/awt/event/KeyEvent;)V
- */
-JNIEXPORT void JNICALL
-Java_sun_awt_motif_MEmbedCanvasPeer_forwardKeyEvent (JNIEnv *env, jobject this, jobject event) {
-    pxembed_server_data sdata;
-    jbyteArray array;
-    XEvent *xevent;
-    AWT_LOCK();
-    MTRACE("forwardKeyEvent\n");
-    sdata = getDataByEmbedder(this);
-    if (sdata != NULL) {
-        DASSERT(sdata->handle != None);
-        array = (jbyteArray)(*env)->GetObjectField(env, event, awtEventIDs.bdata);
-        if (array == NULL) {
-            MTRACE("array is null\n");
-            AWT_UNLOCK();
-            return;
-        }
-
-        xevent = (XEvent *)(*env)->GetByteArrayElements(env, array, NULL);
-        if (xevent == NULL) {
-            (*env)->DeleteLocalRef(env, array);
-            MTRACE("xevent is null\n");
-            AWT_UNLOCK();
-            return;
-        }
-        xevent->xany.window = sdata->handle;
-        XSendEvent(awt_display, sdata->handle, False, NoEventMask, xevent);
-        (*env)->DeleteLocalRef(env, array);
-    }
-    AWT_UNLOCK();
-}
-
-/*
- * Class:     sun_awt_motif_MEmbedCanvasPeer
- * Method:    getAWTKeyCodeForKeySym
- * Signature: (I)I
- */
-JNIEXPORT jint JNICALL
-Java_sun_awt_motif_MEmbedCanvasPeer_getAWTKeyCodeForKeySym (JNIEnv *env, jobject this, jint keysym) {
-    jint keycode = java_awt_event_KeyEvent_VK_UNDEFINED;
-    Boolean mapsToUnicodeChar;
-    jint keyLocation;
-    keysymToAWTKeyCode(keysym, &keycode, &mapsToUnicodeChar, &keyLocation);
-    return keycode;
-}
-
-/*
- * Class:     sun_awt_motif_MEmbedCanvasPeer
- * Method:    sendMessage
- * Signature: (I)V
- */
-JNIEXPORT void JNICALL
-Java_sun_awt_motif_MEmbedCanvasPeer_sendMessage__I (JNIEnv *env, jobject this, jint msg) {
-    pxembed_server_data sdata;
-    AWT_LOCK();
-    MTRACEP2("sendMessage %d(%s)\n", msg, msg_to_str(msg));
-    sdata = getDataByEmbedder(this);
-    if (sdata != NULL) {
-        DASSERT(sdata->handle != None);
-        sendMessage(sdata->handle, msg);
-    }
-    AWT_UNLOCK();
-}
-
-/*
- * Class:     sun_awt_motif_MEmbedCanvasPeer
- * Method:    sendMessage
- * Signature: (IJJJ)V
- */
-JNIEXPORT void JNICALL
-Java_sun_awt_motif_MEmbedCanvasPeer_sendMessage__IJJJ (JNIEnv *env, jobject this, jint msg, jlong detail, jlong data1, jlong data2) {
-    pxembed_server_data sdata;
-    AWT_LOCK();
-    MTRACEP5("sendMessage2 msg %d(%s) detail %d data: %d %d\n", msg, msg_to_str(msg), detail, data1, data2);
-    sdata = getDataByEmbedder(this);
-    if (sdata != NULL) {
-        DASSERT(sdata->handle != None);
-        sendMessageHelper(sdata->handle, msg, detail, data1, data2);
-    }
-    AWT_UNLOCK();
-}
-
-static jobject
-createRectangle(JNIEnv* env, int x, int y, int width, int height) {
-    static jclass clazz;
-    static jmethodID mid;
-    jobject rect = NULL;
-    if (mid == 0) {
-        jclass l_clazz = (*env)->FindClass(env, "java/awt/Rectangle");
-        DASSERT(l_clazz != NULL);
-        mid = (*env)->GetMethodID(env, clazz, "<init>", "(IIII)V");
-        DASSERT(mid != NULL);
-        clazz = (*env)->NewGlobalRef(env, l_clazz);
-        (*env)->DeleteLocalRef(env, l_clazz);
-    }
-    if (mid != NULL) {
-        rect = (*env)->NewObject(env, clazz, mid, x, y, width, height);
-        if ((*env)->ExceptionOccurred(env)) {
-            return NULL;
-        }
-    }
-    return rect;
-}
-
-static jobject
-createDimension(JNIEnv* env, int width, int height) {
-    static jclass clazz;
-    static jmethodID mid;
-    jobject dim = NULL;
-    if (mid == 0) {
-        jclass l_clazz = (*env)->FindClass(env, "java/awt/Dimension");
-        DASSERT(l_clazz != NULL);
-        mid = (*env)->GetMethodID(env, clazz, "<init>", "(II)V");
-        DASSERT(mid != NULL);
-        clazz = (*env)->NewGlobalRef(env, l_clazz);
-        (*env)->DeleteLocalRef(env, l_clazz);
-    }
-    if (mid != NULL) {
-        dim = (*env)->NewObject(env, clazz, mid, width, height);
-        if ((*env)->ExceptionOccurred(env)) {
-            return NULL;
-        }
-    }
-    return dim;
-}
-
-Boolean isMapped(Window w) {
-    XWindowAttributes attr;
-    Status status = 0;
-    WITH_XERROR_HANDLER(xerror_ignore_bad_window);
-    status = XGetWindowAttributes(awt_display, w, &attr);
-    RESTORE_XERROR_HANDLER;
-    if (status == 0 || xerror_code != Success) {
-        return False;
-    }
-    return !(attr.map_state == IsUnmapped);
-}
-
-static void
-processXEmbedInfo(JNIEnv * env, jobject this) {
-    pxembed_server_data sdata;
-    AWT_LOCK();
-    MTRACE("processXEmbedInfo\n");
-    sdata = getDataByEmbedder(this);
-    if (Java_sun_awt_motif_MEmbedCanvasPeer_isXEmbedActive(env, this)) {
-        Atom actual_type;
-        int actual_format;
-        unsigned long nitems;
-        unsigned long bytes_after;
-        CARD32 * data = NULL;
-        DASSERT(sdata->handle != None);
-        if (XGetWindowProperty(awt_display, sdata->handle, XA_XEmbedInfo,
-                           0, 2, False, XA_XEmbedInfo, &actual_type,
-                           &actual_format, &nitems, &bytes_after,
-                               (unsigned char**)&data) != Success)
-        {
-            AWT_UNLOCK();
-            return;
-        }
-        if (actual_type == XA_XEmbedInfo && actual_format == 32
-            && nitems == 2)
-        {
-            CARD32 flags;
-            Boolean new_mapped, currently_mapped;
-            sdata->version = *data;
-            flags = *(data+1);
-            new_mapped = (flags & XEMBED_MAPPED) != 0;
-            currently_mapped = isMapped(sdata->handle);
-            if (new_mapped != currently_mapped) {
-                if (new_mapped) {
-                    XMapWindow(awt_display, sdata->handle);
-                } else {
-                    XUnmapWindow(awt_display, sdata->handle);
-                }
-            }
-        }
-        if (data != NULL) {
-            XFree(data);
-        }
-    }
-    AWT_UNLOCK();
-}
-
-/**
- * Handles client message on embedder
- */
-static void
-handleClientMessage(JNIEnv* env, jobject this, XClientMessageEvent * ev) {
-    pxembed_server_data sdata;
-    AWT_LOCK();
-    MTRACEP5("handleClientMessage: 0=%ld 1=%ld 2=%ld 3=%ld 4=%ld\n",
-            ev->data.l[0], ev->data.l[1], ev->data.l[2], ev->data.l[3], ev->data.l[4]);
-    sdata = getDataByEmbedder(this);
-    if (sdata != NULL && sdata->handle != None) {
-        switch ((int)ev->data.l[1]) {
-          case XEMBED_REQUEST_FOCUS:
-              MTRACE("REQUEST_FOCUS\n");
-              (*env)->CallVoidMethod(env, this, requestXEmbedFocusMID);
-              break;
-          case XEMBED_FOCUS_NEXT:
-              MTRACE("FOCUS_NEXT\n");
-              (*env)->CallVoidMethod(env, this, focusNextMID);
-              break;
-          case XEMBED_FOCUS_PREV:
-              MTRACE("FOCUS_PREV\n");
-              (*env)->CallVoidMethod(env, this, focusPrevMID);
-              break;
-          case XEMBED_REGISTER_ACCELERATOR:
-              MTRACE("REGISTER_ACCEL\n");
-              (*env)->CallVoidMethod(env, this, registerAcceleratorMID,
-                                     (jlong)ev->data.l[2],
-                                     (jlong)ev->data.l[3],
-                                     (jlong)ev->data.l[4]);
-              break;
-          case XEMBED_UNREGISTER_ACCELERATOR:
-              MTRACE("UNREGISTER_ACCEL\n");
-              (*env)->CallVoidMethod(env, this, unregisterAcceleratorMID,
-                                     (jlong)ev->data.l[2]);
-              break;
-          case NON_STANDARD_XEMBED_GTK_GRAB_KEY:
-              MTRACE("GRAB_KEY\n");
-              (*env)->CallVoidMethod(env, this, grabKeyMID,
-                                     (jlong)ev->data.l[3],
-                                     (jlong)ev->data.l[4]);
-              break;
-          case NON_STANDARD_XEMBED_GTK_UNGRAB_KEY:
-              MTRACE("UNGRAB_KEY\n");
-              (*env)->CallVoidMethod(env, this, ungrabKeyMID,
-                                     (jlong)ev->data.l[3],
-                                     (jlong)ev->data.l[4]);
-          case _SUN_XEMBED_START:
-              MTRACE("XEMBED_START\n");
-              processXEmbedInfo(env, this);
-              Java_sun_awt_motif_MEmbedCanvasPeer_notifyChildEmbedded(env, this);
-              break;
-        }
-    }
-    AWT_UNLOCK();
-}
-
-/**
- * Handles property changes on xembed client
- */
-static void
-handlePropertyNotify(XPropertyEvent * ev) {
-    JNIEnv      *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
-    pxembed_server_data sdata;
-    AWT_LOCK();
-    MTRACE("handlePropertyNotify\n");
-    sdata = getData(ev->window);
-    if (sdata != NULL) {
-        if (ev->atom == XA_WM_NORMAL_HINTS) {
-            DASSERT(sdata->server != NULL);
-            (*env)->CallVoidMethod(env, sdata->server, childResizedMID);
-            MTRACE("NORMAL_HINTS have changed\n");
-        } else if (ev->atom == XA_XdndAware) {
-            unregister_xembed_drop_site(env, awt_display, sdata->server,
-                                        sdata->serverHandle, sdata->handle);
-            if (ev->state == PropertyNewValue) {
-                register_xembed_drop_site(env, awt_display, sdata->server,
-                                          sdata->serverHandle, sdata->handle);
-            }
-        } else if (ev->atom == XA_XEmbedInfo) {
-            DASSERT(sdata->server != NULL);
-            MTRACE("XEMBED_INFO has changed\n");
-            processXEmbedInfo(env, sdata->server);
-        }
-    }
-    AWT_UNLOCK();
-}
-
-static void
-handleConfigureNotify(XConfigureEvent * ev) {
-    JNIEnv      *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
-    pxembed_server_data sdata;
-    AWT_LOCK();
-    MTRACE("handleConfigureNotify\n");
-    sdata = getData(ev->window);
-    if (sdata != NULL) {
-        DASSERT(sdata->server != NULL);
-        (*env)->CallVoidMethod(env, sdata->server, childResizedMID);
-    }
-    AWT_UNLOCK();
-}
-
-/*
- * Class:     sun_awt_motif_MEmbedCanvasPeer
- * Method:    sendMessage
- * Signature: (IJJJ)V
- */
-JNIEXPORT void JNICALL
-Java_sun_awt_motif_GrabbedKey_initKeySymAndModifiers (JNIEnv *env, jobject this, jobject keyevent) {
-    jbyteArray array;
-    XEvent *xevent;
-    int keysym, modifiers;
-    int keycode;
-    AWT_LOCK();
-    array = (jbyteArray)(*env)->GetObjectField(env, keyevent, awtEventIDs.bdata);
-    if (array == NULL) {
-        AWT_UNLOCK();
-        return;
-    }
-    xevent = (XEvent *)(*env)->GetByteArrayElements(env, array, NULL);
-    if (xevent == NULL) {
-        (*env)->DeleteLocalRef(env, array);
-        AWT_UNLOCK();
-        return;
-    }
-    keycode = (*env)->GetIntField(env, keyevent, keyEventIDs.keyCode);
-    keysym = awt_getX11KeySym(keycode);
-    modifiers = xevent->xkey.state;
-    (*env)->SetLongField(env, this, keysymFID, (jlong)keysym);
-    (*env)->SetLongField(env, this, modifiersFID, (jlong)modifiers);
-    (*env)->DeleteLocalRef(env, array);
-    AWT_UNLOCK();
-}
-
-#ifdef __linux__
-void
-print_stack (void)
-{
-  void *array[10];
-  size_t size;
-  char **strings;
-  size_t i;
-
-  size = backtrace (array, 10);
-  strings = backtrace_symbols (array, size);
-
-  fprintf (stderr, "Obtained %zd stack frames.\n", size);
-
-  for (i = 0; i < size; i++)
-     fprintf (stderr, "%s\n", strings[i]);
-
-  free (strings);
-}
-#endif
-
-extern int32_t  numEventsHandled;
-
-XCreateWindowEvent cr;
-
-void
-dispatchEmbedderEvent(jobject server, XEvent * ev) {
-    JNIEnv      *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
-    DASSERT(server != NULL);
-    DASSERT(ev != NULL);
-    AWT_LOCK();
-/*     MTRACE("dispatchEmebddedEvent\n"); */
-    switch (ev->type) {
-      case CreateNotify:
-
-          MTRACEP3("CreateNotify for %x, serial %d, num events %d\n", (ev->xcreatewindow.window), (ev->xany.serial), (numEventsHandled));
-          Java_sun_awt_motif_MEmbedCanvasPeer_embedChild(env, server, ev->xcreatewindow.window);
-          break;
-      case DestroyNotify:
-          MTRACE("DestroyNotify\n");
-          Java_sun_awt_motif_MEmbedCanvasPeer_childDestroyed(env, server);
-          break;
-      case ReparentNotify:
-          MTRACEP2("ReparentNotify for %x, parent %x\n", (ev->xreparent.window), (ev->xreparent.parent));
-          Java_sun_awt_motif_MEmbedCanvasPeer_embedChild(env, server, ev->xreparent.window);
-          break;
-      case ClientMessage:
-          MTRACE("ClientMessage\n");
-          handleClientMessage(env, server, &ev->xclient);
-          break;
-    }
-    AWT_UNLOCK();
-}
-
-void
-dispatchEmbeddingClientEvent(XEvent * ev) {
-    DASSERT(ev != NULL);
-    MTRACE("dispatchEmbeddingClientEvent\n");
-    switch (ev->type) {
-      case PropertyNotify:
-          handlePropertyNotify(&ev->xproperty);
-          break;
-      case ConfigureNotify:
-          handleConfigureNotify(&ev->xconfigure);
-          break;
-    }
-}
-
-void
-xembed_serverEventHandler(XEvent * ev) {
-    pxembed_server_data sdata;
-    sdata = getData(ev->xany.window);
-    if (sdata != NULL) { // Event on client
-        dispatchEmbeddingClientEvent(ev);
-    } else {
-        sdata = getDataByServerHandle(ev->xany.window);
-        if (sdata != NULL) {
-            DASSERT(sdata->server != NULL);
-            dispatchEmbedderEvent(sdata->server, ev);
-        }
-    }
-}
-
-/**************************** XEmbed server DnD support ***********************/
-void
-set_xembed_drop_target(JNIEnv* env, jobject server) {
-
-    (*env)->CallVoidMethod(env, server, setXEmbedDropTargetMID);
-}
-
-void
-remove_xembed_drop_target(JNIEnv* env, jobject server) {
-    (*env)->CallVoidMethod(env, server, removeXEmbedDropTargetMID);
-}
-
-Boolean
-is_xembed_client(Window window) {
-    return getData(window) != NULL;
-}
-/******************************************************************************/
-
-/*
- * Class:     sun_awt_motif_MEmbedCanvasPeer
- * Method:    getWindow
- * Signature: ()V
- */
-JNIEXPORT jlong JNICALL
-Java_sun_awt_motif_MEmbedCanvasPeer_getWindow(JNIEnv *env, jobject this) {
-    struct ComponentData *cdata;
-    Window res = None;
-    AWT_LOCK();
-    cdata = (struct ComponentData *)
-        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.pData);
-    DASSERT(cdata != NULL);
-    res = XtWindow(cdata->widget);
-    AWT_UNLOCK();
-    return (jlong)res;
-}
-
-JNIEXPORT void JNICALL
-Java_sun_awt_motif_MEmbedCanvasPeer_forwardEventToEmbedded(JNIEnv *env,
-                                                           jobject this,
-                                                           jlong ctxt,
-                                                           jint eventID){
-    pxembed_server_data sdata;
-    AWT_LOCK();
-    sdata = getDataByEmbedder(this);
-    if (sdata != NULL) {
-        forward_event_to_embedded(sdata->handle, ctxt, eventID);
-    }
-    AWT_UNLOCK();
-}
diff --git a/jdk/src/solaris/native/sun/awt/awt_xembed_server.h b/jdk/src/solaris/native/sun/awt/awt_xembed_server.h
deleted file mode 100644
index b74b9990..0000000
--- a/jdk/src/solaris/native/sun/awt/awt_xembed_server.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2003, 2005, 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 _AWT_XEMBED_SERVER_H_
-#define _AWT_XEMBED_SERVER_H_
-
-#ifndef HEADLESS
-
-#include "awt_p.h"
-
-extern void xembed_serverEventHandler(XEvent *);
-
-#endif
-#endif
diff --git a/jdk/src/solaris/native/sun/awt/canvas.h b/jdk/src/solaris/native/sun/awt/canvas.h
index 45cc7da..eafc118 100644
--- a/jdk/src/solaris/native/sun/awt/canvas.h
+++ b/jdk/src/solaris/native/sun/awt/canvas.h
@@ -26,44 +26,7 @@
 #define _CANVAS_H_
 #ifndef HEADLESS
 
-void awt_canvas_reconfigure(struct FrameData *wdata);
-Widget awt_canvas_create(XtPointer this,
-                         Widget parent,
-                         char *base,
-                         int32_t width,
-                         int32_t height,
-                         Boolean parentIsFrame,
-                         struct FrameData *wdata,
-                         AwtGraphicsConfigDataPtr awtData);
-void awt_canvas_scroll(XtPointer this, struct CanvasData *wdata, long dx, long dy);
-void awt_canvas_event_handler(Widget w, XtPointer client_data,
-                              XEvent *event, Boolean *cont);
-void awt_canvas_handleEvent(Widget w, XtPointer client_data,
-                            XEvent *event, struct WidgetInfo *winfo,
-                            Boolean *cont, Boolean passEvent);
-
-void awt_copyXEventToAWTEvent(JNIEnv* env, XEvent * xevent, jobject jevent);
 KeySym awt_getX11KeySym(jint awtKey);
-jobject awt_canvas_getFocusOwnerPeer();
-jobject awt_canvas_getFocusedWindowPeer();
-void awt_canvas_setFocusOwnerPeer(jobject peer);
-void awt_canvas_setFocusedWindowPeer(jobject peer);
-jobject awt_canvas_wrapInSequenced(jobject awtevent);
-extern void keysymToAWTKeyCode(KeySym x11Key, jint *keycode, Boolean *mapsToUnicodeChar,
-                        jint *keyLocation);
-#define awt_canvas_addToFocusList awt_canvas_addToFocusListDefault
-void awt_canvas_addToFocusListDefault(jobject target);
-void awt_canvas_addToFocusListWithDuplicates(jobject target, jboolean acceptDuplicate);
-extern void callFocusCallback(jobject focusPeer, int focus_type, jobject cause);
-extern void callFocusHandler(Widget w, int eventType, jobject cause);
-
-typedef struct FocusListElt{
-  jweak requestor;
-  struct FocusListElt * next;
-} FocusListElt;
-extern FocusListElt *focusList;
-extern FocusListElt *focusListEnd;
-extern jweak forGained;
 
 #endif /* !HEADLESS */
 #endif           /* _CANVAS_H_ */
diff --git a/jdk/src/solaris/native/sun/awt/multi_font.c b/jdk/src/solaris/native/sun/awt/multi_font.c
index 0cb6e5b..e131564 100644
--- a/jdk/src/solaris/native/sun/awt/multi_font.c
+++ b/jdk/src/solaris/native/sun/awt/multi_font.c
@@ -38,24 +38,15 @@
 #include <jni.h>
 #include <jni_util.h>
 #include <jvm.h>
-#ifndef XAWT
-#include <Xm/Display.h>
-#endif
 #include "awt_Font.h"
-#ifndef XAWT
-#include "awt_Component.h"
-#endif
-#include "awt_MenuItem.h"
 #include "awt_p.h"
 #include "multi_font.h"
 
 extern XFontStruct *loadFont(Display *, char *, int32_t);
 
 extern struct FontIDs fontIDs;
-//extern struct MComponentPeerIDs mComponentPeerIDs;
-//extern struct MMenuItemPeerIDs mMenuItemPeerIDs;
 extern struct PlatformFontIDs platformFontIDs;
-extern struct MFontPeerIDs mFontPeerIDs;
+extern struct XFontPeerIDs xFontPeerIDs;
 
 /*
  * make string with str + string representation of num
@@ -70,145 +61,7 @@
     buf[len] = '0' + num % 100;
     buf[len + 1] = '\0';
 }
-#ifndef XAWT
-jobject
-awtJNI_CreateAndSetGlobalRef(JNIEnv * env, jobject this)
-{
-    jobject gRef;
 
-    gRef = (*env)->NewGlobalRef(env, this);
-
-    JNU_SetLongFieldFromPtr(env, this, mComponentPeerIDs.jniGlobalRef, gRef);
-
-    return gRef;
-}
-
-struct gRefStruct
-{
-    jobject gRef;
-    struct gRefStruct *next;
-};
-
-static struct gRefStruct *gRefHead = NULL;
-static struct gRefStruct *gRefTail = NULL;
-
-/*
- * This function is called by components that
- * are being disposed. It used to invalidate
- * the global ref immediately, but the awt is
- * rather full of thread race conditions involving
- * component disposal and outstanding events.
- * Now we queue up 'to be deleted' global refs
- * as they come in, and don't invalidate them
- * until the X event queue is empty. Callers of
- * either of these functions _must_ have AWT_LOCK'd
- * before using them!
- */
-void
-awtJNI_DeleteGlobalRef(JNIEnv * env, jobject this)
-{
-    jobject gRef;
-    struct gRefStruct *newGRef;
-    struct gRefStruct *temp;
-
-    gRef = (jobject)
-        JNU_GetLongFieldAsPtr(env, this, mComponentPeerIDs.jniGlobalRef);
-    JNU_SetLongFieldFromPtr(env, this, mComponentPeerIDs.jniGlobalRef, NULL);
-
-    /*
-     * Verra handy for tracking down race conditions. If you
-     * have a peer getting called after its been disposed...
-     */
-    /* jio_fprintf(stderr,"%p\n",(void *)gRef); */
-
-    newGRef = (struct gRefStruct *)malloc((size_t)sizeof(struct gRefStruct));
-
-    if(newGRef == NULL)
-        (*env)->DeleteGlobalRef(env, gRef);
-    else
-    {
-        newGRef->gRef = gRef;
-        newGRef->next = NULL;
-
-        if(gRefHead == NULL)
-        {
-            gRefTail = newGRef;
-            gRefHead = newGRef;
-        }
-        else
-        {
-            gRefTail->next = newGRef;
-            gRefTail = newGRef;
-        }
-    }
-}
-
-void
-awtJNI_DeleteGlobalMenuRef(JNIEnv * env, jobject this)
-{
-    jobject gRef;
-    struct gRefStruct *newGRef;
-    struct gRefStruct *temp;
-
-    gRef = (jobject)
-    //JNU_GetLongFieldAsPtr(env, this, mMenuItemPeerIDs.jniGlobalRef);
-    //JNU_SetLongFieldFromPtr(env, this, mMenuItemPeerIDs.jniGlobalRef, NULL);
-
-    /*
-     * Verra handy for tracking down race conditions. If you
-     * have a peer getting called after its been disposed...
-     */
-    /* jio_fprintf(stderr,"%p\n",(void *)gRef); */
-
-    newGRef = (struct gRefStruct *)malloc((size_t)sizeof(struct gRefStruct));
-
-    if(newGRef == NULL)
-        (*env)->DeleteGlobalRef(env, gRef);
-    else
-    {
-        newGRef->gRef = gRef;
-        newGRef->next = NULL;
-
-        if(gRefHead == NULL)
-        {
-            gRefTail = newGRef;
-            gRefHead = newGRef;
-        }
-        else
-        {
-            gRefTail->next = newGRef;
-            gRefTail = newGRef;
-        }
-    }
-}
-
-void awtJNI_CleanupGlobalRefs()
-{
-    struct gRefStruct *working,*next;
-    JNIEnv *env;
-    int32_t count = 0;
-
-    if(gRefHead == NULL) {
-        return;
-    }
-
-    env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
-
-    working = gRefHead;
-    gRefHead = gRefTail = NULL;
-
-    while(working != NULL)
-    {
-        count++;
-        next = working->next;
-        (*env)->DeleteGlobalRef(env, working->gRef);
-
-        free((void *)working);
-
-        working = next;
-    }
-}
-#endif
 static int32_t
 awtJNI_GetFontDescriptorNumber(JNIEnv * env
                                ,jobject font
@@ -255,25 +108,7 @@
 
     return 0;
 }
-#ifndef XAWT
-jobject
-awtJNI_GetFont(JNIEnv * env, jobject this)
-{
-    jobject target = NULL;
-    jobject font = NULL;
 
-    target = (*env)->GetObjectField(env, this, mComponentPeerIDs.target);
-    // SECURITY: Must call _NoClientCode() methods to ensure that we
-    //           are not invoking client code on the privileged thread
-    font = JNU_CallMethodByName(env,
-                                NULL,
-                                target,
-                                "getFont_NoClientCode",
-                                "()Ljava/awt/Font;").l;
-    (*env)->DeleteLocalRef(env, target);
-    return font;
-}
-#endif
 jobject
 awtJNI_GetFMFont(JNIEnv * env, jobject this)
 {
@@ -347,258 +182,7 @@
 
     return JNI_TRUE;
 }
-#ifndef XAWT
-#ifdef __linux__
-XmString
-unicodeXmStringCreate(char* text, char* tag, int len) {
-    XmString ret_val;
-    XtProcessLock();
-    ret_val = _XmStringNCreate (text, tag, len);
-    XtProcessUnlock();
-    return ret_val;
-}
-#endif
 
-/*
- * Unicode to Motif Multi Font Compound String converter
- *
- * ASSUMES: We are not running on a privileged thread
- */
-XmString
-awtJNI_MakeMultiFontString(JNIEnv * env, jstring s, jobject font)
-{
-    XmString xmstr = NULL, xmtmp1, xmtmp2;
-    jobjectArray dataArray = NULL;
-    char *err = NULL;
-    int32_t stringCount,i;
-    int32_t fdnumber;
-    struct FontData *fdata = awtJNI_GetFontData(env, font, &err);
-    jobject fontDescriptor = NULL;
-    jbyteArray data = NULL;
-    char *stringData = NULL;
-    char tag[BUFSIZ];
-
-    if ((*env)->PushLocalFrame(env, 16) < 0)
-        return NULL;
-
-    if (!JNU_IsNull(env, s) && !JNU_IsNull(env, font)) {
-        jobject peer;
-
-        peer = (*env)->CallObjectMethod(env,font,fontIDs.getPeer);
-
-        DASSERT(!awt_currentThreadIsPrivileged(env));
-        dataArray =
-            (*env)->CallObjectMethod(
-                             env,
-                             peer,
-                             platformFontIDs.makeConvertedMultiFontString,
-                             s);
-
-        if ((*env)->ExceptionOccurred(env)) {
-            (*env)->ExceptionDescribe(env);
-            (*env)->ExceptionClear(env);
-
-            (*env)->PopLocalFrame(env, NULL);
-            return (XmString) NULL;
-        }
-
-        if(dataArray == NULL) {
-            (*env)->PopLocalFrame(env, NULL);
-            return (XmString) NULL;
-        }
-    } else {
-        (*env)->PopLocalFrame(env, NULL);
-        return (XmString) NULL;
-    }
-
-    stringCount = (*env)->GetArrayLength(env, dataArray);
-
-    for (i = 0; i < stringCount; i+=2) {
-        fontDescriptor = (*env)->GetObjectArrayElement(env, dataArray, i);
-        data = (*env)->GetObjectArrayElement(env, dataArray, i + 1);
-
-        /* Bail if we've finished */
-        if(fontDescriptor == NULL || data == NULL)
-            break;
-
-        fdnumber = awtJNI_GetFontDescriptorNumber(env, font, fontDescriptor);
-        fdata = awtJNI_GetFontData(env, font, &err);
-
-        makeTag(fdata->flist[fdnumber].charset_name, fdnumber, tag);
-
-        stringData = (char *)(*env)->GetPrimitiveArrayCritical(env, data, NULL);
-        if(stringData != NULL) {
-            unsigned char* buf = stringData;
-            int len;
-            char *offsetStringData;
-
-            offsetStringData = stringData + (4 * sizeof(char));
-#ifdef __linux__
-            len = buf[0] << 24 | buf[1] << 16 | buf[2] << 8 | buf[3];
-            /* Motif XmStringCreate() API requests "text must be a NULL-terminated
-               string" and its implementation uses "strlen()" to calculate the length
-               of the text string. Unfortunately when we deal with iso10646 font
-               on linux, the "text" is requested to be encoded in UTF16, which has the
-               posibility of including code points like "0xYY00" ("0xYY" + "0x00") that
-               causes problem when XmStringCreate() calls _XmStringNCreate() without
-               specifying a specific text lenth (see Motif XmString.c). The workaround is
-               to call _XmStringNCreate() directly with specific text length at this
-               cirsumstance.
-            */
-            if (strstr(fdata->flist[fdnumber].charset_name, "UnicodeBigUnmarked"))
-                xmtmp1 = unicodeXmStringCreate(offsetStringData, tag, len);
-            else
-                xmtmp1 = XmStringCreate(offsetStringData, tag);
-            if (xmstr == NULL)
-                xmstr = xmtmp1;
-            else {
-                xmtmp2 = XmStringConcat(xmstr, xmtmp1);
-                XmStringFree(xmtmp1);
-                XmStringFree(xmstr);
-                xmstr = xmtmp2;
-            }
-#else
-            if(xmstr == NULL) {
-                xmstr = XmStringCreate(offsetStringData, tag);
-            }
-            else {
-                xmtmp1 = XmStringCreate(offsetStringData, tag);
-                xmtmp2 = XmStringConcat(xmstr, xmtmp1);
-                XmStringFree(xmtmp1);
-                XmStringFree(xmstr);
-                xmstr = xmtmp2;
-            }
-#endif
-        }
-
-        (*env)->ReleasePrimitiveArrayCritical(env, data, stringData, JNI_ABORT);
-        (*env)->DeleteLocalRef(env, fontDescriptor);
-        (*env)->DeleteLocalRef(env, data);
-    }
-    (*env)->PopLocalFrame(env, NULL);
-    return xmstr;
-}
-
-/*
- * Find the character encoding for a given font and register that encoding
- * with the given tag.  The encoding is the last two fields of the XLFD of
- * the font (converted to uppercase).
- */
-static void registerEncoding(char *xlfd, char *tag)
-{
-    char *e = xlfd + strlen(xlfd);
-    char *ret = NULL;
-
-    do { --e; } while (e != xlfd && *e != '-');
-    do { --e; } while (e != xlfd && *e != '-');
-    if (e != xlfd) {
-        char *encoding = strdup(++e);
-        char *u = NULL;
-
-        for (u = encoding; *u != '\0'; ++u) {
-            if (islower(*u)) {
-                *u = toupper(*u);
-            }
-        }
-
-        /*
-         * Motif will core dump on or otherwise mishandle unknown (or
-         * non-standard) character encodings (in conversion to compound
-         * text, bug 4122785).  Register Sun private encodings for
-         * Symbol or dingbat fonts as ISO8859-1, which is a lie,
-         * but produces predictable results.
-         */
-        if (strncmp(encoding, "SUN-", 4) == 0) {
-                free(encoding);
-                encoding = strdup("ISO8859-1");
-        }
-        ret = XmRegisterSegmentEncoding(tag, encoding);
-        if (ret != NULL)
-                XtFree(ret);
-        free(encoding);
-    }
-}
-
-
-XmFontList
-awtJNI_GetFontList(JNIEnv * env, jobject font)
-{
-    int32_t i;
-    XmFontListEntry fle;
-    XmFontList fontlist;
-    XFontStruct *xf = NULL;
-    int32_t size;
-    struct FontData *fdata = NULL;
-    char *err = NULL, tag[BUFSIZ];
-
-    fdata = awtJNI_GetFontData(env, font, &err);
-
-    makeTag(fdata->flist[0].charset_name, 0, tag);
-
-    size = (int32_t) (*env)->GetIntField(env, font, fontIDs.size);
-
-    if (fdata->flist[0].load == 0) {
-        xf = loadFont(awt_display, fdata->flist[0].xlfd, size * 10);
-
-        if (xf == NULL) {
-            /* printf("Cannot load font: %s\n", fdata->list[0].xlfd); */
-        } else {
-            fdata->flist[0].xfont = xf;
-            fdata->flist[0].load = 1;
-
-            if (xf->min_byte1 == 0 && xf->max_byte1 == 0)
-                fdata->flist[0].index_length = 1;
-            else
-                fdata->flist[0].index_length = 2;
-        }
-    }
-    registerEncoding(fdata->flist[0].xlfd, tag);
-    fle = XmFontListEntryCreate(tag, XmFONT_IS_FONT,
-                                (XtPointer) fdata->flist[0].xfont);
-
-    fontlist = XmFontListAppendEntry(NULL, fle);
-    /*
-     * Some versions of motif have a bug in
-     * XmFontListEntryFree() which causes it to free more than it
-     * should.  Use XtFree() is used instead.  See O'Reilly's
-     * Motif Reference Manual for more information.
-     */
-    XmFontListEntryFree(&fle);
-
-    for (i = 1; i < fdata->charset_num; i++) {
-        makeTag(fdata->flist[i].charset_name, i, tag);
-
-        if (fdata->flist[i].load == 0) {
-            xf = loadFont(awt_display, fdata->flist[i].xlfd, size * 10);
-
-            if (xf == NULL) {
-                /* printf("Cannot load font: %s\n", fdata->flist[0].xlfd); */
-                continue;
-            }
-            fdata->flist[i].xfont = xf;
-            fdata->flist[i].load = 1;
-            if (xf->min_byte1 == 0 && xf->max_byte1 == 0) {
-                fdata->flist[i].index_length = 1;
-            } else {
-                fdata->flist[i].index_length = 2;
-            }
-        }
-        registerEncoding(fdata->flist[i].xlfd, tag);
-        fle = XmFontListEntryCreate(tag, XmFONT_IS_FONT,
-                                    (XtPointer) fdata->flist[i].xfont);
-        fontlist = XmFontListAppendEntry(fontlist, fle);
-        /*
-         * Some versions of motif have a bug in
-         * XmFontListEntryFree() which causes it to free more than it
-         * should.  Use XtFree() instead.  See O'Reilly's
-         * Motif Reference Manual for more information.
-         */
-        XmFontListEntryFree(&fle);
-    }
-
-    return fontlist;
-}
-#endif
 /* #define FONT_DEBUG 2 */
 
 XFontSet
@@ -625,7 +209,7 @@
     size = (*env)->GetIntField(env, font, fontIDs.size) * 10;
 
     peer = (*env)->CallObjectMethod(env,font,fontIDs.getPeer);
-    xfsname = (*env)->GetObjectField(env, peer, mFontPeerIDs.xfsname);
+    xfsname = (*env)->GetObjectField(env, peer, xFontPeerIDs.xfsname);
 
     if (JNU_IsNull(env, xfsname))
         xfontset = "";
@@ -703,9 +287,6 @@
     int32_t length;
     XFontStruct *xf = NULL;
     jobjectArray dataArray = NULL;
-#ifndef XAWT
-    DASSERT(!awt_currentThreadIsPrivileged(env));
-#endif
     if ((*env)->EnsureLocalCapacity(env, 3) < 0)
         return 0;
 
diff --git a/jdk/src/solaris/native/sun/awt/multi_font.h b/jdk/src/solaris/native/sun/awt/multi_font.h
index ae8d8f9..460eab0 100644
--- a/jdk/src/solaris/native/sun/awt/multi_font.h
+++ b/jdk/src/solaris/native/sun/awt/multi_font.h
@@ -29,13 +29,8 @@
 #define _MULTI_FONT_H_
 
 #ifndef HEADLESS
-jobject awtJNI_GetFont(JNIEnv *env,jobject this);
 jboolean awtJNI_IsMultiFont(JNIEnv *env,jobject this);
 jboolean awtJNI_IsMultiFontMetrics(JNIEnv *env,jobject this);
-#ifndef XAWT
-XmString awtJNI_MakeMultiFontString(JNIEnv *env,jstring s,jobject font);
-XmFontList awtJNI_GetFontList(JNIEnv *env,jobject font);
-#endif
 XFontSet awtJNI_MakeFontSet(JNIEnv *env,jobject font);
 struct FontData *awtJNI_GetFontData(JNIEnv *env,jobject font, char **errmsg);
 int32_t awtJNI_GetMFStringWidth(JNIEnv * env, jcharArray s, int32_t offset,
diff --git a/jdk/src/solaris/native/sun/java2d/opengl/GLXSurfaceData.c b/jdk/src/solaris/native/sun/java2d/opengl/GLXSurfaceData.c
index 76c8c8b..d389e16 100644
--- a/jdk/src/solaris/native/sun/java2d/opengl/GLXSurfaceData.c
+++ b/jdk/src/solaris/native/sun/java2d/opengl/GLXSurfaceData.c
@@ -45,8 +45,6 @@
 extern UnlockFunc     OGLSD_Unlock;
 extern DisposeFunc    OGLSD_Dispose;
 
-extern struct MComponentPeerIDs mComponentPeerIDs;
-
 extern void
     OGLSD_SetNativeDimensions(JNIEnv *env, OGLSDOps *oglsdo, jint w, jint h);
 
@@ -86,34 +84,12 @@
     oglsdo->activeBuffer = GL_FRONT;
     oglsdo->needsInit = JNI_TRUE;
 
-#ifdef XAWT
     if (peer != NULL) {
         glxsdo->window = JNU_CallMethodByName(env, NULL, peer,
                                               "getContentWindow", "()J").j;
     } else {
         glxsdo->window = 0;
     }
-#else
-    if (peer != NULL) {
-        struct ComponentData *cdata;
-        cdata = (struct ComponentData *)
-            JNU_GetLongFieldAsPtr(env, peer, mComponentPeerIDs.pData);
-        if (cdata == NULL) {
-            free(glxsdo);
-            JNU_ThrowNullPointerException(env, "Component data missing");
-            return;
-        }
-        if (cdata->widget == NULL) {
-            free(glxsdo);
-            JNU_ThrowInternalError(env, "Widget is NULL in initOps");
-            return;
-        }
-        glxsdo->widget = cdata->widget;
-    } else {
-        glxsdo->widget = NULL;
-    }
-#endif
-
     glxsdo->configData = (AwtGraphicsConfigDataPtr)jlong_to_ptr(aData);
     if (glxsdo->configData == NULL) {
         free(glxsdo);
@@ -331,11 +307,7 @@
 {
     GLXSDOps *glxsdo;
     Window window;
-#ifdef XAWT
     XWindowAttributes attr;
-#else
-    Widget widget;
-#endif
 
     J2dTraceLn(J2D_TRACE_INFO, "OGLSD_InitOGLWindow");
 
@@ -352,7 +324,6 @@
         return JNI_FALSE;
     }
 
-#ifdef XAWT
     window = glxsdo->window;
     if (window == 0) {
         J2dRlsTraceLn(J2D_TRACE_ERROR,
@@ -363,22 +334,6 @@
     XGetWindowAttributes(awt_display, window, &attr);
     oglsdo->width = attr.width;
     oglsdo->height = attr.height;
-#else
-    widget = glxsdo->widget;
-    if (widget == NULL) {
-        J2dTraceLn(J2D_TRACE_WARNING, "OGLSD_InitOGLWindow: widget is null");
-    }
-
-    if (!XtIsRealized(widget)) {
-        J2dRlsTraceLn(J2D_TRACE_ERROR,
-                      "OGLSD_InitOGLWindow: widget is unrealized");
-        return JNI_FALSE;
-    }
-
-    window = XtWindow(widget);
-    oglsdo->width = widget->core.width;
-    oglsdo->height = widget->core.height;
-#endif
 
     oglsdo->drawableType = OGLSD_WINDOW;
     oglsdo->isOpaque = JNI_TRUE;
diff --git a/jdk/src/solaris/native/sun/java2d/opengl/GLXSurfaceData.h b/jdk/src/solaris/native/sun/java2d/opengl/GLXSurfaceData.h
index 7019406..9cbec5c 100644
--- a/jdk/src/solaris/native/sun/java2d/opengl/GLXSurfaceData.h
+++ b/jdk/src/solaris/native/sun/java2d/opengl/GLXSurfaceData.h
@@ -38,16 +38,11 @@
  * The GLXSDOps structure contains the GLX-specific information for a given
  * OGLSurfaceData.  It is referenced by the native OGLSDOps structure.
  *
- *     Window window; (used in XAWT only)
+ *     Window window;
  * For onscreen windows, we maintain a reference to that window's associated
  * XWindow handle here.  Offscreen surfaces have no associated Window, so for
  * those surfaces, this value will simply be zero.
  *
- *     Widget widget; (used in MAWT only)
- * For onscreen windows, we maintain a reference to that window's associated
- * Widget handle here.  Offscreen surfaces have no associated Widget, so for
- * those surfaces, this value will simply be zero.
- *
  *     Drawable xdrawable;
  * If a GLXDrawable has a corresponding X11 Drawable, it is stored here.  For
  * example, each GLXWindow has an associated Window and each GLXPixmap has an
@@ -63,11 +58,7 @@
  * created.
  */
 typedef struct _GLXSDOps {
-#ifdef XAWT
     Window      window;
-#else
-    Widget      widget;
-#endif
     Drawable    xdrawable;
     GLXDrawable drawable;
     struct _AwtGraphicsConfigData *configData;
diff --git a/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.c b/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.c
index 9b3e706..a993217 100644
--- a/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.c
+++ b/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.c
@@ -64,9 +64,6 @@
 static DisposeFunc X11SD_Dispose;
 static GetPixmapBgFunc X11SD_GetPixmapWithBg;
 static ReleasePixmapBgFunc X11SD_ReleasePixmapWithBg;
-#ifndef XAWT
-extern struct MComponentPeerIDs mComponentPeerIDs;
-#endif
 extern int J2DXErrHandler(Display *display, XErrorEvent *xerr);
 extern AwtGraphicsConfigDataPtr
     getGraphicsConfigFromComponentPeer(JNIEnv *env, jobject this);
@@ -263,31 +260,12 @@
     xsdo->sdOps.Dispose = X11SD_Dispose;
     xsdo->GetPixmapWithBg = X11SD_GetPixmapWithBg;
     xsdo->ReleasePixmapWithBg = X11SD_ReleasePixmapWithBg;
-#ifndef XAWT
-    if (peer != NULL) {
-        struct ComponentData *cdata;
-        cdata = (struct ComponentData *)
-            JNU_GetLongFieldAsPtr(env, peer, mComponentPeerIDs.pData);
-        if (cdata == NULL) {
-            JNU_ThrowNullPointerException(env, "Component data missing");
-            return;
-        }
-        if (cdata->widget == NULL) {
-            JNU_ThrowInternalError(env, "Widget is NULL in initOps");
-            return;
-        }
-        xsdo->widget = cdata->widget;
-    } else {
-        xsdo->widget = NULL;
-    }
-#else
     xsdo->widget = NULL;
     if (peer != NULL) {
         xsdo->drawable = JNU_CallMethodByName(env, NULL, peer, "getWindow", "()J").j;
     } else {
         xsdo->drawable = 0;
     }
-#endif
     xsdo->depth = depth;
     xsdo->dgaAvailable = dgaAvailable;
     xsdo->isPixmap = JNI_FALSE;
@@ -775,14 +753,6 @@
     if (xsdo->isPixmap == JNI_TRUE) {
         return SD_FAILURE;
     }
-#ifndef XAWT
-    if (!XtIsRealized(xsdo->widget)) {
-        J2dTraceLn(J2D_TRACE_WARNING, "X11SD_InitWindow: widget is unrealized");
-        /* AWT_UNLOCK(); unlock it in caller */
-        return SD_FAILURE;
-    }
-    xsdo->drawable = XtWindow(xsdo->widget);
-#endif
     xsdo->cData = xsdo->configData->color_data;
 
     return SD_SUCCESS;
@@ -804,9 +774,7 @@
         SurfaceData_ThrowInvalidPipeException(env, "bounds changed");
         return SD_FAILURE;
     }
-#ifdef XAWT
     xsdo->cData = xsdo->configData->color_data;
-#endif
     if (xsdo->drawable == 0 && X11SD_InitWindow(env, xsdo) == SD_FAILURE) {
         AWT_UNLOCK();
         return SD_FAILURE;
@@ -1081,30 +1049,6 @@
     int tmpx, tmpy;
     Window tmpchild;
 
-#ifndef XAWT
-    Widget w = xsdo->widget;
-
-    x1 = y1 = 0;
-    for (; w != NULL && ! XtIsShell(w); w = w->core.parent) {
-        x1 += w->core.x + w->core.border_width;
-        y1 += w->core.y + w->core.border_width;
-    }
-    if (w == NULL) {
-        return FALSE;
-    }
-
-    /*
-     * REMIND: We should not be offsetting here by border_width
-     * but for some unknown reason if we do not do that the
-     * results will be off exactly by border_width. We were unable
-     * to find cause of this.
-     */
-    (void) XTranslateCoordinates(XtDisplay(w), XtWindow(w),
-                                 RootWindowOfScreen(XtScreen(w)),
-                                 (int) w->core.border_width,
-                                 (int) w->core.border_width,
-                                 &tmpx, &tmpy, &tmpchild);
-#else
     Window window = (Window)(xsdo->drawable); /* is always a Window */
     XWindowAttributes winAttr;
 
@@ -1118,7 +1062,6 @@
                                0, 0, &tmpx, &tmpy, &tmpchild)) {
         return FALSE;
     }
-#endif
 
     x1 = -(x1 + tmpx);
     y1 = -(y1 + tmpy);
@@ -1150,89 +1093,6 @@
 static int
 X11SD_FindClip(SurfaceDataBounds *b, SurfaceDataBounds *bounds, X11SDOps *xsdo)
 {
-#ifndef XAWT
-    int x1, y1, x2, y2, px1, py1, px2, py2, child_x, child_y;
-    Widget current_widget, child_widget;
-
-    XWindowAttributes attr;
-    Window ignore_root, current_window, *ignore_children;
-    unsigned int pborder, ignore_uint;
-
-    x1 = bounds->x1;
-    y1 = bounds->y1;
-    x2 = bounds->x2;
-    y2 = bounds->y2;
-
-    px1 = py1 = 0;
-
-    child_widget = xsdo->widget;
-    current_widget = XtParent(xsdo->widget);
-    while (current_widget != NULL && !XtIsShell(current_widget)) {
-        px1 = px1 - (child_widget->core.x + child_widget->core.border_width);
-        py1 = py1 - (child_widget->core.y + child_widget->core.border_width);
-        px2 = px1 + current_widget->core.width;
-        py2 = py1 + current_widget->core.height;
-        x1 = MAX(x1, px1);
-        y1 = MAX(y1, py1);
-        x2 = MIN(x2, px2);
-        y2 = MIN(y2, py2);
-        if ((x1 >= x2) || (y1 >= y2)) {
-            return FALSE;
-        }
-
-        child_widget = current_widget;
-        current_widget = current_widget->core.parent;
-    }
-
-    if (current_widget == NULL) {
-        XQueryTree(awt_display,
-                   XtWindow(child_widget),
-                   &ignore_root,
-                   &current_window,
-                   &ignore_children,
-                   &ignore_uint);
-        XFree(ignore_children);
-    } else {
-        current_window = XtWindow(current_widget);
-    }
-
-    child_x = child_widget->core.x + child_widget->core.border_width;
-    child_y = child_widget->core.y + child_widget->core.border_width;
-    while (current_window != 0) {
-        px1 = px1 - child_x;
-        py1 = py1 - child_y;
-        if (!XGetGeometry(awt_display, current_window, &ignore_root,
-                          &child_x, &child_y,
-                          (unsigned int *)&px2, (unsigned int *)&py2,
-                          &pborder, &ignore_uint)) {
-            return FALSE;
-        }
-        child_x += pborder;
-        child_y += pborder;
-        px2 += px1;
-        py2 += py1;
-
-        x1 = MAX(x1, px1);
-        y1 = MAX(y1, py1);
-        x2 = MIN(x2, px2);
-        y2 = MIN(y2, py2);
-        if ((x1 >= x2) || (y1 >= y2)) {
-            return FALSE;
-        }
-        XQueryTree(awt_display,
-                   current_window,
-                   &ignore_root,
-                   &current_window,
-                   &ignore_children,
-                   &ignore_uint);
-        XFree(ignore_children);
-    }
-
-    b->x1 = x1;
-    b->y1 = y1;
-    b->x2 = x2;
-    b->y2 = y2;
-#endif
     return TRUE;
 }
 
diff --git a/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.h b/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.h
index a082df9..91ad462 100644
--- a/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.h
+++ b/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.h
@@ -30,6 +30,10 @@
 
 #include <jdga.h>
 
+#ifdef HEADLESS
+#include "GLXGraphicsConfig.h"
+#endif
+
 #include <X11/extensions/Xrender.h>
 
 /**
diff --git a/jdk/src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c b/jdk/src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c
index f41409b..57882b6 100644
--- a/jdk/src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c
+++ b/jdk/src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c
@@ -996,7 +996,7 @@
 
         if (res != 0 || p == NULL || p->pw_name == NULL || *(p->pw_name) == '\0') {
             /* not found or error */
-            if (errno != 0 && errno != ENOENT)
+            if (errno != 0 && errno != ENOENT && errno != ESRCH)
                 throwUnixException(env, errno);
         } else {
             uid = p->pw_uid;
@@ -1042,7 +1042,7 @@
         retry = 0;
         if (res != 0 || g == NULL || g->gr_name == NULL || *(g->gr_name) == '\0') {
             /* not found or error */
-            if (errno != 0 && errno != ENOENT) {
+            if (errno != 0 && errno != ENOENT && errno != ESRCH) {
                 if (errno == ERANGE) {
                     /* insufficient buffer size so need larger buffer */
                     buflen += ENT_BUF_SIZE;
diff --git a/jdk/src/solaris/native/sun/xawt/XToolkit.c b/jdk/src/solaris/native/sun/xawt/XToolkit.c
index 69620ff..6dfb80d 100644
--- a/jdk/src/solaris/native/sun/xawt/XToolkit.c
+++ b/jdk/src/solaris/native/sun/xawt/XToolkit.c
@@ -39,7 +39,6 @@
 #include "awt_p.h"
 #include "awt_Component.h"
 #include "awt_MenuComponent.h"
-#include "awt_KeyboardFocusManager.h"
 #include "awt_Font.h"
 
 #include "sun_awt_X11_XToolkit.h"
@@ -47,6 +46,8 @@
 #include "java_awt_TrayIcon.h"
 #include <X11/extensions/XTest.h>
 
+#include <unistd.h>
+
 uint32_t awt_NumLockMask = 0;
 Boolean  awt_ModLockIsShiftLock = False;
 
@@ -72,19 +73,17 @@
 
 struct MenuComponentIDs menuComponentIDs;
 
-struct KeyboardFocusManagerIDs keyboardFocusManagerIDs;
-
 #ifndef HEADLESS
 
 extern Display* awt_init_Display(JNIEnv *env, jobject this);
 
-extern struct MFontPeerIDs mFontPeerIDs;
+struct XFontPeerIDs xFontPeerIDs;
 
 JNIEXPORT void JNICALL
 Java_sun_awt_X11_XFontPeer_initIDs
   (JNIEnv *env, jclass cls)
 {
-    mFontPeerIDs.xfsname =
+    xFontPeerIDs.xfsname =
       (*env)->GetFieldID(env, cls, "xfsname", "Ljava/lang/String;");
 }
 #endif /* !HEADLESS */
@@ -1087,3 +1086,38 @@
 
     return local_num_buttons;
 }
+
+/*
+ * Class:     sun_awt_X11_XWindowPeer
+ * Method:    getJvmPID
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_sun_awt_X11_XWindowPeer_getJvmPID
+(JNIEnv *env, jclass cls)
+{
+    /* Return the JVM's PID. */
+    return getpid();
+}
+
+#ifndef HOST_NAME_MAX
+#define HOST_NAME_MAX 1024 /* Overestimated */
+#endif
+
+/*
+ * Class:     sun_awt_X11_XWindowPeer
+ * Method:    getLocalHostname
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_sun_awt_X11_XWindowPeer_getLocalHostname
+(JNIEnv *env, jclass cls)
+{
+    /* Return the machine's FQDN. */
+    char hostname[HOST_NAME_MAX + 1];
+    if (gethostname(hostname, HOST_NAME_MAX + 1) == 0) {
+        hostname[HOST_NAME_MAX] = '\0';
+        jstring res = (*env)->NewStringUTF(env, hostname);
+        return res;
+    }
+
+    return (jstring)NULL;
+}
diff --git a/jdk/src/windows/native/java/io/io_util_md.c b/jdk/src/windows/native/java/io/io_util_md.c
index 345f955..787617e 100644
--- a/jdk/src/windows/native/java/io/io_util_md.c
+++ b/jdk/src/windows/native/java/io/io_util_md.c
@@ -478,7 +478,7 @@
 }
 
 JNIEXPORT
-size_t
+jint
 handleRead(jlong fd, void *buf, jint len)
 {
     DWORD read = 0;
@@ -499,10 +499,10 @@
         }
         return -1;
     }
-    return read;
+    return (jint)read;
 }
 
-static size_t writeInternal(jlong fd, const void *buf, jint len, jboolean append)
+static jint writeInternal(jlong fd, const void *buf, jint len, jboolean append)
 {
     BOOL result = 0;
     DWORD written = 0;
@@ -527,16 +527,16 @@
     if ((h == INVALID_HANDLE_VALUE) || (result == 0)) {
         return -1;
     }
-    return (size_t)written;
+    return (jint)written;
 }
 
 JNIEXPORT
-size_t handleWrite(jlong fd, const void *buf, jint len) {
+jint handleWrite(jlong fd, const void *buf, jint len) {
     return writeInternal(fd, buf, len, JNI_FALSE);
 }
 
 JNIEXPORT
-size_t handleAppend(jlong fd, const void *buf, jint len) {
+jint handleAppend(jlong fd, const void *buf, jint len) {
     return writeInternal(fd, buf, len, JNI_TRUE);
 }
 
diff --git a/jdk/src/windows/native/java/io/io_util_md.h b/jdk/src/windows/native/java/io/io_util_md.h
index d979970..392b8c3 100644
--- a/jdk/src/windows/native/java/io/io_util_md.h
+++ b/jdk/src/windows/native/java/io/io_util_md.h
@@ -39,9 +39,9 @@
 int handleAvailable(jlong fd, jlong *pbytes);
 JNIEXPORT int handleSync(jlong fd);
 int handleSetLength(jlong fd, jlong length);
-JNIEXPORT size_t handleRead(jlong fd, void *buf, jint len);
-JNIEXPORT size_t handleWrite(jlong fd, const void *buf, jint len);
-JNIEXPORT size_t handleAppend(jlong fd, const void *buf, jint len);
+JNIEXPORT jint handleRead(jlong fd, void *buf, jint len);
+JNIEXPORT jint handleWrite(jlong fd, const void *buf, jint len);
+JNIEXPORT jint handleAppend(jlong fd, const void *buf, jint len);
 jint handleClose(JNIEnv *env, jobject this, jfieldID fid);
 jlong handleLseek(jlong fd, jlong offset, jint whence);
 
diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt
index 0860daf..5e0d374 100644
--- a/jdk/test/ProblemList.txt
+++ b/jdk/test/ProblemList.txt
@@ -400,8 +400,8 @@
 # 6963118
 java/nio/channels/Selector/Wakeup.java                          windows-all
 
-# 7076700
-java/nio/channels/SocketChannel/AdaptSocket.java                generic-all
+# 7052549
+java/nio/channels/FileChannel/ReleaseOnCloseDeadlock.java 	windows-all
 
 ############################################################################
 
diff --git a/jdk/test/java/awt/print/PaintSetEnabledDeadlock/PaintSetEnabledDeadlock.java b/jdk/test/java/awt/print/PaintSetEnabledDeadlock/PaintSetEnabledDeadlock.java
new file mode 100644
index 0000000..294f455
--- /dev/null
+++ b/jdk/test/java/awt/print/PaintSetEnabledDeadlock/PaintSetEnabledDeadlock.java
@@ -0,0 +1,175 @@
+/*
+ * 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 7108598
+ * @summary Container.paint/KeyboardFocusManager.clearMostRecentFocusOwner methods deadlock
+ * @library ../../regtesthelpers
+ * @author Oleg Pekhovskiy
+ * @build Util
+ * @run main/timeout=20 PaintSetEnabledDeadlock
+ */
+
+import java.awt.*;
+import java.awt.event.*;
+import test.java.awt.regtesthelpers.Util;
+
+public class PaintSetEnabledDeadlock extends Frame {
+
+    final TestPanel panel;
+    final Button button;
+
+    public static void main(String[] args) {
+        PaintSetEnabledDeadlock frame = new PaintSetEnabledDeadlock();
+        frame.setSize(200, 200);
+        frame.setVisible(true);
+
+        Robot robot = Util.createRobot();
+        robot.setAutoDelay(100);
+        robot.setAutoWaitForIdle(true);
+
+        for (int i = 0; i < 20; ++i) {
+            Util.clickOnComp(frame.panel, robot);
+            Util.clickOnComp(frame.button, robot);
+        }
+
+        frame.panel.stop();
+        frame.dispose();
+
+        System.out.println("Test passed.");
+    }
+
+    public PaintSetEnabledDeadlock() {
+        super("7108598 test");
+        setLayout(new GridLayout(1, 2));
+        addWindowListener(new WindowAdapter() {
+
+            @Override
+            public void windowClosing(WindowEvent e) {
+                panel.stop();
+                System.exit(0);
+            }
+        });
+        panel = new TestPanel();
+        add(panel);
+        button = new Button("Enable");
+        button.addMouseListener(new MouseAdapter() {
+
+            @Override
+            public void mousePressed(MouseEvent e) {
+                panel.setEnabled(true);
+                panel.sync();
+                panel.repaint();
+            }
+        });
+        add(button);
+    }
+}
+
+class TestPanel extends Panel implements Runnable {
+
+    Image image = null;
+    Thread thread = null;
+    volatile boolean active = true;
+    final Object sync = new Object();
+    Panel panel = this;
+
+    public TestPanel() {
+        addMouseListener(new MouseAdapter() {
+
+            @Override
+            public void mouseReleased(MouseEvent e) {
+                synchronized (panel) {
+                    sync();
+                    panel.setEnabled(false);
+                }
+                panel.repaint();
+            }
+        });
+        thread = new Thread(this);
+        thread.start();
+    }
+
+    @Override
+    public void paint(Graphics paramGraphics) {
+        synchronized (getTreeLock()) {
+            Rectangle rect = getBounds();
+            if (image == null) {
+                image = createImage(rect.width, rect.height);
+            }
+
+            if (image != null) {
+                paramGraphics.drawImage(image, 0, 0, this);
+            }
+        }
+    }
+
+    @Override
+    public void run() {
+        while (active) {
+            try {
+                synchronized (sync) {
+                    sync.wait();
+                }
+            } catch (InterruptedException ex) {
+            }
+            if (active) {
+                draw();
+            }
+        }
+    }
+
+    public void stop() {
+        active = false;
+        try {
+            synchronized (sync) {
+                sync.notify();
+            }
+            synchronized (thread) {
+                thread.wait();
+            }
+        } catch (InterruptedException ex) {
+        }
+    }
+
+    public void draw() {
+        synchronized (getTreeLock()) {
+            if (image != null) {
+                Graphics localGraphics = image.getGraphics();
+                Dimension size = getSize();
+                localGraphics.setColor(isEnabled() ? Color.green : Color.red);
+                localGraphics.fillRect(0, 0, size.width, size.height);
+                super.paint(localGraphics);
+                localGraphics.dispose();
+                getTreeLock().notifyAll();
+            }
+        }
+    }
+
+    public void sync() {
+        synchronized (sync) {
+            sync.notify();
+        }
+    }
+}
diff --git a/jdk/test/java/beans/Beans/6669869/TestDesignTime.java b/jdk/test/java/beans/Beans/6669869/TestDesignTime.java
index b73cee4..731ab4a 100644
--- a/jdk/test/java/beans/Beans/6669869/TestDesignTime.java
+++ b/jdk/test/java/beans/Beans/6669869/TestDesignTime.java
@@ -29,7 +29,6 @@
  */
 
 import java.beans.Beans;
-import sun.awt.SunToolkit;
 
 public class TestDesignTime implements Runnable {
     public static void main(String[] args) throws InterruptedException {
@@ -44,7 +43,6 @@
     }
 
     public void run() {
-        SunToolkit.createNewAppContext();
         if (Beans.isDesignTime()) {
             throw new Error("shared DesignTime property");
         }
diff --git a/jdk/test/java/beans/Beans/6669869/TestGuiAvailable.java b/jdk/test/java/beans/Beans/6669869/TestGuiAvailable.java
index 6156882..67d88ae 100644
--- a/jdk/test/java/beans/Beans/6669869/TestGuiAvailable.java
+++ b/jdk/test/java/beans/Beans/6669869/TestGuiAvailable.java
@@ -30,7 +30,6 @@
 
 import java.awt.GraphicsEnvironment;
 import java.beans.Beans;
-import sun.awt.SunToolkit;
 
 public class TestGuiAvailable implements Runnable {
     public static void main(String[] args) throws InterruptedException {
@@ -45,7 +44,6 @@
     }
 
     public void run() {
-        SunToolkit.createNewAppContext();
         if (Beans.isGuiAvailable() == GraphicsEnvironment.isHeadless()) {
             throw new Error("shared GuiAvailable property");
         }
diff --git a/jdk/test/java/beans/Introspector/6380849/TestBeanInfo.java b/jdk/test/java/beans/Introspector/6380849/TestBeanInfo.java
index 8232756..6d68535 100644
--- a/jdk/test/java/beans/Introspector/6380849/TestBeanInfo.java
+++ b/jdk/test/java/beans/Introspector/6380849/TestBeanInfo.java
@@ -41,8 +41,6 @@
 import java.lang.ref.Reference;
 import java.lang.reflect.Field;
 
-import sun.awt.SunToolkit;
-
 public class TestBeanInfo implements Runnable {
 
     private static final String[] SEARCH_PATH = { "infos" }; // NON-NLS: package name
@@ -81,9 +79,6 @@
     private boolean passed;
 
     public void run() {
-        if (this.passed) {
-            SunToolkit.createNewAppContext();
-        }
         Introspector.flushCaches();
 
         test(FirstBean.class, FirstBeanBeanInfo.class);
@@ -98,7 +93,5 @@
         test(SecondBean.class, SecondBeanBeanInfo.class);
         test(ThirdBean.class, null);
         test(ThirdBeanBeanInfo.class, ThirdBeanBeanInfo.class);
-
-        this.passed = true;
     }
 }
diff --git a/jdk/test/java/beans/Introspector/7064279/Test7064279.java b/jdk/test/java/beans/Introspector/7064279/Test7064279.java
new file mode 100644
index 0000000..91d10fe
--- /dev/null
+++ b/jdk/test/java/beans/Introspector/7064279/Test7064279.java
@@ -0,0 +1,75 @@
+/*
+ * 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 7064279
+ * @summary Tests that Introspector does not have strong references to context class loader
+ * @author Sergey Malenkov
+ */
+
+import java.beans.Introspector;
+import java.io.File;
+import java.lang.ref.WeakReference;
+import java.net.URL;
+import java.net.URLClassLoader;
+
+public class Test7064279 {
+
+    public static void main(String[] args) throws Exception {
+        WeakReference ref = new WeakReference(test("test.jar", "test.Test"));
+        try {
+            int[] array = new int[1024];
+            while (true) {
+                array = new int[array.length << 1];
+            }
+        }
+        catch (OutOfMemoryError error) {
+            System.gc();
+        }
+        if (null != ref.get()) {
+            throw new Error("ClassLoader is not released");
+        }
+    }
+
+    private static Object test(String jarName, String className) throws Exception {
+        StringBuilder sb = new StringBuilder(256);
+        sb.append("file:");
+        sb.append(System.getProperty("test.src", "."));
+        sb.append(File.separatorChar);
+        sb.append(jarName);
+
+        ClassLoader newLoader = new URLClassLoader(new URL[] { new URL(sb.toString()) });
+        ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
+
+        Thread.currentThread().setContextClassLoader(newLoader);
+        test(newLoader.loadClass(className));
+        Thread.currentThread().setContextClassLoader(oldLoader);
+
+        return newLoader;
+    }
+
+    private static void test(Class type) throws Exception {
+        Introspector.getBeanInfo(type);
+    }
+}
diff --git a/jdk/test/java/beans/Introspector/7064279/test.jar b/jdk/test/java/beans/Introspector/7064279/test.jar
new file mode 100644
index 0000000..7516a33
--- /dev/null
+++ b/jdk/test/java/beans/Introspector/7064279/test.jar
Binary files differ
diff --git a/jdk/test/java/beans/Introspector/Test6660539.java b/jdk/test/java/beans/Introspector/Test6660539.java
index d1cb628..349f1b3 100644
--- a/jdk/test/java/beans/Introspector/Test6660539.java
+++ b/jdk/test/java/beans/Introspector/Test6660539.java
@@ -28,8 +28,6 @@
  * @author Sergey Malenkov
  */
 
-import sun.awt.SunToolkit;
-
 import java.beans.BeanInfo;
 import java.beans.IntrospectionException;
 import java.beans.Introspector;
@@ -49,7 +47,6 @@
     }
 
     public void run() {
-        SunToolkit.createNewAppContext();
         for (PropertyDescriptor pd : getPropertyDescriptors()) {
             if (pd.getDisplayName().equals(NAME))
                 throw new Error("shared BeanInfo cache");
diff --git a/jdk/test/java/beans/Introspector/TestTypeResolver.java b/jdk/test/java/beans/Introspector/TestTypeResolver.java
index 0e03782..6704d8f 100644
--- a/jdk/test/java/beans/Introspector/TestTypeResolver.java
+++ b/jdk/test/java/beans/Introspector/TestTypeResolver.java
@@ -29,6 +29,7 @@
 
 import com.sun.beans.TypeResolver;
 
+import java.lang.annotation.Annotation;
 import java.lang.reflect.Field;
 import java.lang.reflect.GenericDeclaration;
 import java.lang.reflect.Method;
@@ -170,6 +171,22 @@
         public int hashCode() {
             return hash(name) ^ hash(gd) ^ Arrays.hashCode(bounds);
         }
+
+        public boolean isAnnotationPresent(Class<? extends Annotation> annotationClass) {
+            return false; // not used
+        }
+
+        public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
+            return null; // not used
+        }
+
+        public Annotation[] getAnnotations() {
+            return null; // not used
+        }
+
+        public Annotation[] getDeclaredAnnotations() {
+            return null; // not used
+        }
     }
 
     private static class ClassTypeVariable extends TypeVariableImpl<Class<?>> {
diff --git a/jdk/test/java/beans/PropertyChangeSupport/Test7087429.java b/jdk/test/java/beans/PropertyChangeSupport/Test7087429.java
new file mode 100644
index 0000000..4a829d8
--- /dev/null
+++ b/jdk/test/java/beans/PropertyChangeSupport/Test7087429.java
@@ -0,0 +1,45 @@
+/*
+ * 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 7087429
+ * @summary Tests IllegalArgumentException from the PropertyChangeEvent constructor
+ * @author Sergey Malenkov
+ */
+
+import java.beans.PropertyChangeEvent;
+
+public final class Test7087429 {
+    public static void main(String[] args) {
+        try {
+            new PropertyChangeEvent(null, null, null, null);
+        }
+        catch (IllegalArgumentException exception) {
+            if (exception.getMessage().equals("null source")) {
+                return;
+            }
+        }
+        throw new Error("IllegalArgumentException expected");
+    }
+}
diff --git a/jdk/test/java/beans/PropertyEditor/6380849/TestPropertyEditor.java b/jdk/test/java/beans/PropertyEditor/6380849/TestPropertyEditor.java
index 5d42144..e07254a 100644
--- a/jdk/test/java/beans/PropertyEditor/6380849/TestPropertyEditor.java
+++ b/jdk/test/java/beans/PropertyEditor/6380849/TestPropertyEditor.java
@@ -36,7 +36,6 @@
 import java.beans.PropertyEditor;
 import java.beans.PropertyEditorManager;
 
-import sun.awt.SunToolkit;
 import sun.beans.editors.BooleanEditor;
 import sun.beans.editors.ByteEditor;
 import sun.beans.editors.ColorEditor;
@@ -77,12 +76,7 @@
         }
     }
 
-    private boolean passed;
-
     public void run() {
-        if (this.passed) {
-            SunToolkit.createNewAppContext();
-        }
         PropertyEditorManager.registerEditor(ThirdBean.class, ThirdBeanEditor.class);
 
         test(FirstBean.class, FirstBeanEditor.class);
@@ -135,7 +129,5 @@
         test(Color.class, null);
         test(Font.class, null);
         test(Enumeration.class, EnumEditor.class);
-
-        this.passed = true;
     }
 }
diff --git a/jdk/test/java/beans/PropertyEditor/Test7087876.java b/jdk/test/java/beans/PropertyEditor/Test7087876.java
new file mode 100644
index 0000000..9088934
--- /dev/null
+++ b/jdk/test/java/beans/PropertyEditor/Test7087876.java
@@ -0,0 +1,59 @@
+/*
+ * 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 7087876
+ * @summary Tests spec of the createPropertyEditor method
+ * @author Sergey Malenkov
+ */
+
+import java.beans.IntrospectionException;
+import java.beans.PropertyDescriptor;
+import java.beans.PropertyEditorSupport;
+
+public class Test7087876 {
+
+    public static void main(String[] args) throws IntrospectionException {
+        PropertyDescriptor pd = new PropertyDescriptor("value", Bean.class);
+        pd.setPropertyEditorClass(Editor.class);
+        pd.createPropertyEditor(new Bean());
+    }
+
+    public static class Bean {
+        private String value;
+
+        public String getValue() {
+            return this.value;
+        }
+
+        public void setValue(String value) {
+            this.value = value;
+        }
+    }
+
+    public static class Editor extends PropertyEditorSupport {
+        private Editor() {
+        }
+    }
+}
diff --git a/jdk/test/java/beans/XMLEncoder/Test7092744.java b/jdk/test/java/beans/XMLEncoder/Test7092744.java
new file mode 100644
index 0000000..52f029b
--- /dev/null
+++ b/jdk/test/java/beans/XMLEncoder/Test7092744.java
@@ -0,0 +1,66 @@
+/*
+ * 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 7092744
+ * @summary Tests for ambiguous methods
+ * @author Sergey Malenkov
+ */
+
+public class Test7092744 extends AbstractTest {
+
+    public static void main(String[] args) {
+        new Test7092744().test(true);
+    }
+
+    protected Object getObject() {
+        return new Bean();
+    }
+
+    protected Object getAnotherObject() {
+        Bean bean = new Bean();
+        bean.setValue(99);
+        return bean;
+    }
+
+    public static interface I<T extends Number> {
+
+        T getValue();
+
+        void setValue(T value);
+    }
+
+    public static class Bean implements I<Integer> {
+
+        private Integer value;
+
+        public Integer getValue() {
+            return this.value;
+        }
+
+        public void setValue(Integer value) {
+            this.value = value;
+        }
+    }
+}
diff --git a/jdk/test/java/lang/String/CaseInsensitiveComparator.java b/jdk/test/java/lang/String/CaseInsensitiveComparator.java
new file mode 100644
index 0000000..0393932
--- /dev/null
+++ b/jdk/test/java/lang/String/CaseInsensitiveComparator.java
@@ -0,0 +1,68 @@
+/*
+ * 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.
+ */
+
+/*
+ * This test tests that the String.CaseInsensitiveComparator.readResolve method
+ * deserializes String.CASE_INSENSITIVE_ORDER into an object which satisfies the
+ * equals method.
+ *
+ * @test
+ * @bug 5035850
+ * @summary Test for String.CaseInsensitiveComparator.readResolve
+ */
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+public class CaseInsensitiveComparator {
+    public static void main(String[] args) throws Exception {
+        Object result;
+
+        try (ByteArrayOutputStream outBuffer = new ByteArrayOutputStream();
+                ObjectOutputStream out = new ObjectOutputStream(outBuffer))
+        {
+            out.writeObject(String.CASE_INSENSITIVE_ORDER);
+            out.close();
+
+            try (ByteArrayInputStream inBuffer = new ByteArrayInputStream(outBuffer.toByteArray());
+                    ObjectInputStream in = new ObjectInputStream(inBuffer))
+            {
+                result = in.readObject();
+            }
+        }
+
+        if (!String.CASE_INSENSITIVE_ORDER.equals(result)) {
+            throw new Exception("Value restored from serial form does not equal original!");
+        }
+
+        if (!result.equals(String.CASE_INSENSITIVE_ORDER)) {
+            throw new Exception("Value restored from serial form does not equal original!");
+        }
+
+        if (String.CASE_INSENSITIVE_ORDER != result) {
+            throw new Exception("Value restored from serial form does not equal original!");
+        }
+    }
+}
diff --git a/jdk/test/java/nio/channels/AsynchronousSocketChannel/Basic.java b/jdk/test/java/nio/channels/AsynchronousSocketChannel/Basic.java
index 32b6c83..9442f9b 100644
--- a/jdk/test/java/nio/channels/AsynchronousSocketChannel/Basic.java
+++ b/jdk/test/java/nio/channels/AsynchronousSocketChannel/Basic.java
@@ -63,7 +63,9 @@
         testRead3();
         testWrite1();
         testWrite2();
-        testTimeout();
+        // skip timeout tests until 7052549 is fixed
+        if (!System.getProperty("os.name").startsWith("Windows"))
+            testTimeout();
         testShutdown();
     }
 
diff --git a/jdk/test/java/util/MissingFormatArgumentException/GetFormatSpecifier.java b/jdk/test/java/util/MissingFormatArgumentException/GetFormatSpecifier.java
new file mode 100644
index 0000000..24722cf
--- /dev/null
+++ b/jdk/test/java/util/MissingFormatArgumentException/GetFormatSpecifier.java
@@ -0,0 +1,56 @@
+/*
+ * 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     5063455
+ * @summary Unit test for MissingFormatArgumentException.getFormatSpecifier
+ * @author  Brandon Passanisi
+ */
+import java.util.MissingFormatArgumentException;
+
+public class GetFormatSpecifier {
+
+    static void fail(String s) {
+        throw new RuntimeException(s);
+    }
+
+    public static void main(String[] args) {
+
+        // Use the format specifier below, which should throw a
+        // MissingFormatArgumentException. Then, use getFormatSpecifier()
+        // to make sure the returned value equals the original format string.
+        final String formatSpecifier = "%1$5.3s";
+        try {
+            String formatResult = String.format(formatSpecifier);
+            fail("MissingFormatArgumentException not thrown.");
+        } catch (MissingFormatArgumentException ex) {
+            final String returnedFormatSpecifier = ex.getFormatSpecifier();
+            if (!returnedFormatSpecifier.equals(formatSpecifier)) {
+                fail("The specified format specifier: " + formatSpecifier
+                        + " does not match the value from getFormatSpecifier(): "
+                        + returnedFormatSpecifier);
+            }
+        }
+    }
+}
diff --git a/jdk/test/java/util/ResourceBundle/Control/ExpirationTest.java b/jdk/test/java/util/ResourceBundle/Control/ExpirationTest.java
deleted file mode 100644
index bdaf7db..0000000
--- a/jdk/test/java/util/ResourceBundle/Control/ExpirationTest.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * 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.
- */
-/*
- *
- */
-
-/*
- * This class is used by ExpirationTest.sh. See the timing information in
- * the shell script.
- */
-
-import java.util.*;
-
-public class ExpirationTest {
-    static final Locale AUSTRIA = new Locale("de", "AT");
-    static String format;
-    static String fileType;
-
-    public static void main(String[] args) {
-        // If -latency is specified, try sleeping for 3 seconds 3
-        // times to see its latency. If the latency is too large, then
-        // the program exits with 2. (See sleep())
-        if ("-latency".equals(args[0])) {
-            System.out.print("Checking latency... ");
-            for (int i = 0; i < 3; i++) {
-                sleep(3);
-            }
-            System.out.println("done");
-            System.exit(0);
-        }
-
-        format = args[0];
-        fileType = args[1];
-
-        Locale loc = Locale.getDefault();
-        try {
-            Locale.setDefault(Locale.JAPAN);
-            ResourceBundle.Control control = new TestControl();
-            ResourceBundle rb = ResourceBundle.getBundle("ExpirationData", Locale.GERMAN,
-                                                         control);
-            check(rb.getString("data"), "German");
-
-            rb = ResourceBundle.getBundle("ExpirationData", AUSTRIA, control);
-            check(rb.getString("january"), "Januar");
-
-            // Wait until the instance gets expired in the cache in 7 seconds.
-            sleep(7);
-
-            // At this point, it should be determined that reloading is not needed.
-            rb = ResourceBundle.getBundle("ExpirationData", Locale.GERMAN, control);
-            check(rb.getString("data"), "German");
-
-            rb = ResourceBundle.getBundle("ExpirationData", AUSTRIA, control);
-            check(rb.getString("january"), "Januar");
-
-            // Wait until the instance in the cache gets expired again and
-            // ExpirationData_de gets updated.
-            // 33 = 40 - 7 (See the timing chart in ExpirationTest.sh)
-            sleep(33);
-
-            // At this point, getBundle must reload the updated
-            // ExpirationData_de and ExpirationData_de_AT must be
-            // avaible.
-
-            rb = ResourceBundle.getBundle("ExpirationData", Locale.GERMAN, control);
-            try {
-                check(rb.getString("data"), "Deutsch");
-            } catch (RuntimeException e) {
-                if (format.equals("class")) {
-                    // Class loader doesn't load updated classes.
-                    System.out.println("Known class limitation: " + e.getMessage());
-                }
-            }
-
-            rb = ResourceBundle.getBundle("ExpirationData", AUSTRIA, control);
-            try {
-                check(rb.getString("january"), "J\u00e4nner");
-            } catch (RuntimeException e) {
-                if (fileType.equals("jar")) {
-                    // Jar doesn't load new entries.
-                    System.out.println("Known jar limitation: " + e.getMessage());
-                } else {
-                    throw e;
-                }
-            }
-        } finally {
-            Locale.setDefault(loc);
-        }
-    }
-
-    private static void check(String s, String expected) {
-        String time = getTime();
-        if (!s.equals(expected)) {
-            throw new RuntimeException("got '" + s + "', expected '" + expected + "' at "
-                                       + time);
-        }
-        System.out.println("ExpirationTest: got '" + s + "' at " + time);
-    }
-
-    private static void sleep(int seconds) {
-        long millis = seconds * 1000;
-        long start = System.currentTimeMillis();
-        try {
-            Thread.sleep(millis);
-        } catch (InterruptedException e) {
-        }
-        long end = System.currentTimeMillis();
-        long latency = end - start - millis;
-        // If the latecy is more than 1% of the requested sleep time,
-        // then give up the testing.
-        if (latency > millis/100) {
-            System.err.printf("Latency is too large: slept for %d [ms], "
-                              + "expected %d [ms] latency rate: %+.2f%% (expected not more than 1%%)%n"
-                              + "exiting...%n",
-                              end - start, millis, (double)latency*100.0/millis);
-            System.exit(2);
-        }
-    }
-
-    private static final String getTime() {
-        return new Date().toString().substring(11, 19);
-    }
-
-    private static class TestControl extends ResourceBundle.Control {
-        @Override
-        public long getTimeToLive(String name, Locale loc) {
-            return 5000; // 5 seconds
-        }
-
-        @Override
-        public ResourceBundle newBundle(String name, Locale loc,
-                                        String fmt, ClassLoader cl, boolean reload)
-            throws IllegalAccessException, InstantiationException, java.io.IOException {
-            ResourceBundle bundle = super.newBundle(name, loc, fmt, cl, reload);
-            if (bundle != null) {
-                System.out.println("newBundle: " + (reload ? "**re" : "")
-                                   + "loaded '" + toName(name, loc , fmt) + "' at " + getTime());
-            }
-            return bundle;
-        }
-
-        @Override
-        public boolean needsReload(String name, Locale loc,
-                                   String fmt, ClassLoader cl,
-                                   ResourceBundle rb, long time) {
-            boolean b = super.needsReload(name, loc, fmt, cl, rb, time);
-            System.out.println("needsReload: '" + b + "' for " + toName(name, loc, fmt)
-                               + " at " + getTime());
-            return b;
-        }
-
-        private String toName(String name, Locale loc, String fmt) {
-            return toResourceName(toBundleName(name, loc), fmt.substring(5));
-        }
-    }
-}
diff --git a/jdk/test/java/util/ResourceBundle/Control/ExpirationTest.sh b/jdk/test/java/util/ResourceBundle/Control/ExpirationTest.sh
deleted file mode 100644
index e798bf9..0000000
--- a/jdk/test/java/util/ResourceBundle/Control/ExpirationTest.sh
+++ /dev/null
@@ -1,331 +0,0 @@
-# 
-# Copyright (c) 2007, 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.
-# 
-# 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 4212439 5102289 6272156
-# @summary Tests for expiration control and reloading expired resource bundles.
-# @build ExpirationTest
-# @run shell/timeout=300 ExpirationTest.sh
-
-#
-# Timings of the test sequence
-#
-# 0         5    7      10             20             40  [seconds]
-# +---------+----+------+------//------+------//------+--
-# g         X    g      X              U              g   [event]
-#
-#  0 g - java starts; the first getBundle call gets "German";
-#        sleep for 7 sec
-#  5 X - the bundle expires (every 5 seconds)
-#  7 g - java wakes up; the second getBundle call still gets "German";
-#        sleep for 33 sec
-# 10 X - the bundle expires in the cache
-# 20 U - shell script updates DE and add AT
-# 40 g - java wakes up; third getBundle call; gets "Deutsch"
-#
-# event: g - getBundle, X - eXpire, U - Update
-#
-#
-# ExpirationTest.java uses 3 exit values.
-#  0 - passed
-#  1 - failed
-#  2 - can't proceed due to slow platform
-#
-
-# Check environment variables
-if [ "x$TESTJAVA" = "x" ]; then
-    1>&2 echo "No TESTJAVA defined. exiting..."
-    exit 1
-fi
-
-# Make sure that this test is run in C locale
-LANG=C
-export LANG
-LC_ALL=
-export LC_ALL
-
-: ${TESTCLASSES:=.}
-
-# YES if the platform has %s support in date
-HAS_S=NO
-
-case "`uname`" in
-Windows* | CYGWIN* )
-    DEL=";"
-    ;;
-SunOS)
-    DEL=":"
-    ;;
-Linux)
-    DEL=":"
-    HAS_S=YES
-    ;;
-esac
-
-# Interval until resources are updated
-INTERVAL=20
-
-DATA=ExpirationData
-
-ROOT=${DATA}.properties
-JA=${DATA}_ja.properties
-DE=${DATA}_de.properties
-AT=${DATA}_de_AT.properties
-
-JARFILE=data.jar
-
-createProperties() {
-    rm -f ${DATA}*.properties
-    echo "data: English" > $ROOT
-    (echo "data: Japanese"; echo "january: 1gatsu") > $JA
-    (echo "data: German"; echo "january: Januar") > $DE
-    echo "Properties files have been created at `date +%T`"
-}
-
-createJar() {
-    if [ "$FORMAT" = "properties" ]; then
-	createProperties
-	F="${DATA}*.properties"
-    else
-	createClasses
-	F="-C classes ${ROOT}.class -C classes ${JA}.class -C classes ${DE}.class"
-    fi
-    ${TESTJAVA}/bin/jar cf $JARFILE $F
-    ${TESTJAVA}/bin/jar tvf $JARFILE
-    rm -f ${DATA}*.properties
-    echo "Jar created at `date +%T`"
-}
-
-createClasses() {
-    rm -f ${DATA}*.java
-    rm -rf classes
-    mkdir classes
-    createJava $ROOT English
-    createJava $JA Japanese
-    createJava $DE German Januar
-    ${TESTJAVA}/bin/javac -d classes ${ROOT}.java ${JA}.java ${DE}.java
-    echo "Created" classes/*.class "at `date +%T`"
-}
-
-createJava() {
-    (echo "
-import java.util.*;
-
-public class $1 extends ListResourceBundle {
-    public Object[][] getContents() {
-	return new Object[][] {
-	    { \"data\", \"$2\" },"
-    if [ "x$3" != "x" ]; then
-	echo "	    { \"january\", \"$3\" },"
-    fi
-echo "	};
-    }
-}") >$1.java
-}
-
-updateDEaddAT() {
-    rm -f $DE
-    (echo "data=Deutsch"; echo "january=Januar") > $DE
-    # add de_AT
-    echo "january=J\u00e4nner" > $AT
-    echo "Updated '"${DE}"' and added '"${AT}"' at `date +%T`"
-}
-
-updateClassDEaddClassAT() {
-    rm -f $DE.java classes/$DE.class
-    createJava $DE Deutsch Januar
-    ${TESTJAVA}/bin/javac -d classes ${DE}.java
-    createJava $AT Deutsch "J\\u00e4nner"
-    ${TESTJAVA}/bin/javac -d classes ${AT}.java
-    echo "Updated '"${DE}"' class and added '"${AT}"' class at `date +%T`"
-}
-
-updateJar() {
-    if [ "$FORMAT" = "properties" ]; then
-	updateDEaddAT
-	F="$DE $AT"
-    else
-	updateClassDEaddClassAT
-	F="-C classes ${DE}.class -C classes ${AT}.class"
-    fi
-    ${TESTJAVA}/bin/jar uf $JARFILE $F
-    rm -f $DE $AT
-    echo "Updated '"${JARFILE}"' at `date +%T`"
-    ${TESTJAVA}/bin/jar tvf $JARFILE
-}
-
-getSeconds() {
-    if [ "$HAS_S" = "YES" ]; then
-	date '+%s'
-    else
-	# Returns an approximation of the offset from the Epoch in
-	# seconds.
-	date -u '+%Y %j %H %M %S' | \
-	awk '{d=($1-1970)*365.2425; print int(((((((d+$2-1)*24)+$3)*60)+$3)*60)+$5);}'
-    fi
-}
-
-#
-# Execute $1 and check how long it takes
-#
-timedExec() {
-    S=`getSeconds`
-    eval $1
-    E=`getSeconds`
-    D=`expr $E - $S`
-    #
-    # If this machine is too slow, give up the further testing.
-    #
-    if [ "$D" -gt $2 ]; then
-	1>&2 echo "This machine took $D seconds to prepare test data," \
-		  "which is too slow to proceed. Exiting..."
-	exit 0
-    fi
-    unset S
-    unset E
-    unset D
-}
-
-checkStatus() {
-    if [ $1 = 0 ]; then
-	echo "$2: PASSED"
-    elif [ $1 != 2 ]; then
-	echo "$2: FAILED"
-	exit 1
-    else
-	# Just we should't proceed to avoid timing issues.
-	exit 0
-    fi
-}
-
-#
-# Before starting tests, check the latency with Thread.sleep().
-#
-${TESTJAVA}/bin/java -cp "${TESTCLASSES}${DEL}." ExpirationTest -latency
-STATUS=$?
-if [ $STATUS = 2 ]; then
-    exit 0
-fi
-
-#
-# Tests for properties
-#
-FORMAT=properties
-
-#
-# Test with plain files (properties)
-#
-echo "Starting test with properties files at `date +%T`"
-
-#
-# Creates properties files
-#
-timedExec createProperties 10
-
-#
-# Execute a child process which will update files in $INTERVAL seconds.
-#
-(sleep $INTERVAL; updateDEaddAT; exit 0) &
-
-${TESTJAVA}/bin/java -cp "${TESTCLASSES}${DEL}." ExpirationTest properties file
-STATUS=$?
-wait
-checkStatus $STATUS "Test with properties files"
-
-#
-# Test with jar file if jar is available (properties)
-#
-if [ -x ${TESTJAVA}/bin/jar ] || [ -x ${TESTJAVA}/bin/jar.exe ]; then
-    HASJAR=YES
-else
-    HASJAR=NO
-fi
-
-if [ $HASJAR = YES  ]; then
-    echo ""
-    echo "Starting test with a jar file (properties) at `date +%T`"
-
-    #
-    # Create a jar files with properties
-    #
-    timedExec createJar 10
-
-    (sleep $INTERVAL; updateJar; exit 0) &
-    ${TESTJAVA}/bin/java -cp "${TESTCLASSES}${DEL}${JARFILE}" ExpirationTest properties jar
-    STATUS=$?
-    wait
-    checkStatus $STATUS "Test with a jar file (properties)"
-fi
-
-#
-# Test for classes
-#
-
-# Note: class-based resource bundles can't be reloaded due to the
-# cache support in class loaders. So the results of the test cases
-# below are not checked. (Test cases always pass.)
-
-# If there's no javac available, then give up the test with
-# class-based properties.
-if [ ! -x ${TESTJAVA}/bin/javac ] && [ ! -x ${TESTJAVA}/bin/javac.exe ]; then
-    exit 0
-fi
-
-rm -f ${DATA}*.properties $JARFILE
-
-FORMAT=class
-ROOT=`basename $ROOT .properties`
-JA=`basename $JA .properties`
-DE=`basename $DE .properties`
-AT=`basename $AT .properties`
-
-echo ""
-echo "Starting test with class files at `date +%T`"
-
-#
-# Create class files
-#
-timedExec createClasses 10
-
-(sleep $INTERVAL; updateClassDEaddClassAT; exit 0) &
-${TESTJAVA}/bin/java -cp "${TESTCLASSES}${DEL}classes" ExpirationTest class file
-STATUS=$?
-wait
-checkStatus $STATUS "Test with class files"
-
-if [ $HASJAR = YES ]; then
-    echo ""
-    echo "Starting test with a jar file (class) at `date +%T`"
-
-    #
-    # Create a jar file with class files
-    #
-    timedExec createJar 10
-
-    (sleep $INTERVAL; updateJar; exit 0) &
-    ${TESTJAVA}/bin/java -cp "${TESTCLASSES}${DEL}${JARFILE}" ExpirationTest class jar
-    STATUS=$?
-    wait
-    checkStatus $STATUS "Test with a jar file (class)"
-fi
-
-exit 0
diff --git a/jdk/test/java/util/zip/DeInflate.java b/jdk/test/java/util/zip/DeInflate.java
new file mode 100644
index 0000000..c3ca7ac
--- /dev/null
+++ b/jdk/test/java/util/zip/DeInflate.java
@@ -0,0 +1,96 @@
+/*
+ * 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 7110149
+ * @summary Test basic deflater & inflater functionality
+ */
+
+import java.io.*;
+import java.util.*;
+import java.util.zip.*;
+
+public class DeInflate {
+
+    static void check(Deflater compresser, byte[] in, int len,
+                      byte[] out1, byte[] out2, boolean nowrap)
+        throws Throwable
+    {
+        Arrays.fill(out1, (byte)0);
+        Arrays.fill(out2, (byte)0);
+
+        compresser.setInput(in, 0, len);
+        compresser.finish();
+        int m = compresser.deflate(out1);
+
+        Inflater decompresser = new Inflater(nowrap);
+        decompresser.setInput(out1, 0, m);
+        int n = decompresser.inflate(out2);
+
+        if (n != len ||
+            !Arrays.equals(Arrays.copyOf(in, len), Arrays.copyOf(out2, len)) ||
+            decompresser.inflate(out2) != 0) {
+            System.out.printf("m=%d, n=%d, len=%d, eq=%b%n",
+                              m, n, len, Arrays.equals(in, out2));
+            throw new RuntimeException("De/inflater failed:" + compresser);
+        }
+    }
+
+    public static void main(String[] args) throws Throwable {
+        byte[] dataIn = new byte[1024 * 512];
+        new Random().nextBytes(dataIn);
+        byte[] dataOut1 = new byte[dataIn.length + 1024];
+        byte[] dataOut2 = new byte[dataIn.length];
+        boolean wrap[] = new boolean[] { false, true };
+
+        for (int level = Deflater.DEFAULT_COMPRESSION;
+                 level <= Deflater.BEST_COMPRESSION; level++) {
+            System.out.print("level=" + level + ", strategy= ");
+            for (int strategy = Deflater.DEFAULT_STRATEGY;
+                     strategy <= Deflater.HUFFMAN_ONLY; strategy++) {
+                System.out.print(" " + strategy + " nowrap[");
+                for (int dowrap = 0; dowrap <= 1; dowrap++) {
+                    System.out.print(" " + wrap[dowrap]);
+                    for (int i = 0; i < 5; i++) {
+                        Deflater def = new Deflater(level, wrap[dowrap]);
+                        if (strategy != Deflater.DEFAULT_STRATEGY) {
+                            def.setStrategy(strategy);
+                            // The first invocation after setLevel/Strategy()
+                            // with a different level/stragety returns 0, if
+                            // there is no need to flush out anything for the
+                            // previous setting/"data", this is tricky and
+                            // appears un-documented.
+                            def.deflate(dataOut2);
+                        }
+                        int len = (i == 0)? dataIn.length
+                                          : new Random().nextInt(dataIn.length);
+                            check(def, dataIn, len, dataOut1, dataOut2, wrap[dowrap]);
+                    }
+                }
+                System.out.print("] ");
+            }
+            System.out.println();
+        }
+    }
+}
diff --git a/jdk/test/java/util/zip/TimeChecksum.java b/jdk/test/java/util/zip/TimeChecksum.java
new file mode 100644
index 0000000..cc81f1e
--- /dev/null
+++ b/jdk/test/java/util/zip/TimeChecksum.java
@@ -0,0 +1,205 @@
+/*
+ * 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 7109837
+ * @summary Test Adler32/CRC32.update(ByteBuffer)
+ */
+
+import java.util.*;
+import java.util.zip.*;
+import java.nio.*;
+
+public class TimeChecksum {
+
+    static long time(Adler32 adler32, byte[] data, int iters, int len) {
+        long start_t = System.nanoTime();
+        for (int i = 0; i < iters; i++) {
+            adler32.reset();
+            adler32.update(data, 0, len);
+        }
+        long t = System.nanoTime() - start_t;
+        System.out.printf("%,12d", t / len);
+        return t;
+    }
+
+    static long time(Adler32 adler32, ByteBuffer buf, int iters) {
+        long start_t = System.nanoTime();
+        for (int i = 0; i < iters; i++) {
+            adler32.reset();
+            buf.mark();
+            adler32.update(buf);
+            buf.reset();
+        }
+        long t = System.nanoTime() - start_t;
+        System.out.printf("%,12d", t / buf.remaining());
+        return t;
+    }
+
+    static void testPosLimit(Adler32 adler32, ByteBuffer buf) {
+        int pos = buf.position();
+        int limit = buf.limit();
+        adler32.update(buf);
+        if (limit != buf.position() || limit != buf.limit()) {
+            System.out.printf("%nFAILED: pos,limit=(%d, %d), expected (%d, %d)%n",
+                    buf.position(), buf.limit(), limit, limit);
+            throw new RuntimeException();
+        }
+        buf.position(pos);
+    }
+
+    static long time(CRC32 crc32, byte[] data, int iters, int len) {
+        long start_t = System.nanoTime();
+        for (int i = 0; i < iters; i++) {
+            crc32.reset();
+            crc32.update(data, 0, len);
+        }
+        long t = System.nanoTime() - start_t;
+        System.out.printf("%,12d", t / len);
+        return t;
+    }
+
+    static long time(CRC32 crc32, ByteBuffer buf, int iters) {
+        long start_t = System.nanoTime();
+        for (int i = 0; i < iters; i++) {
+            crc32.reset();
+            buf.mark();
+            crc32.update(buf);
+            buf.reset();
+        }
+        long t = System.nanoTime() - start_t;
+        System.out.printf("%,12d", t / buf.remaining());
+        return t;
+    }
+
+    static void testPosLimit(CRC32 crc32, ByteBuffer buf) {
+        int pos = buf.position();
+        int limit = buf.limit();
+        crc32.update(buf);
+        if (limit != buf.position() || limit != buf.limit()) {
+            System.out.printf("%nFAILED: pos,limit=(%d, %d), expected (%d, %d)%n",
+                    buf.position(), buf.limit(), limit, limit);
+            throw new RuntimeException();
+        }
+        buf.position(pos);
+    }
+
+    public static void main(String[] args) {
+        int len     = 1024 * 32;
+        int iters   = 1;
+        if (args.length != 0 && "-benchmark".equals(args[0]))
+            iters = 100000;
+        Adler32 adler32 = new Adler32();
+        CRC32 crc32 = new CRC32();
+        Random rdm = new Random();
+        byte[] data = new byte[len];
+        new Random().nextBytes(data);
+        ByteBuffer buf;
+
+        System.out.println("---------- Adler32 ----------");
+        System.out.print("Warmup...");
+        time(adler32, data, iters, len);
+        time(adler32, ByteBuffer.wrap(data), iters);
+        buf = ByteBuffer.allocateDirect(len);
+        buf.put(data, 0, len);
+        buf.flip();
+        time(adler32, buf, iters);
+        System.out.println("\n");
+
+        System.out.println("Length    byte[](ns/len)  ByteBuffer(direct)   ByteBuffer");
+        for (int testlen = 1; testlen < data.length; testlen <<= 1) {
+            System.out.print(testlen + "\t");
+            long baT = time(adler32, data, iters, testlen);
+            long baV = adler32.getValue();
+            System.out.print("\t");
+
+            buf = ByteBuffer.allocateDirect(testlen);
+            buf.put(data, 0, testlen);
+            buf.flip();
+            long bbdT = time(adler32, buf, iters);
+            long bbdV = adler32.getValue();
+            if (baV != bbdV) {
+                System.out.printf("%nFAILED: baV=%x,bbdV=%x%n", baV, bbdV);
+                throw new RuntimeException();
+            }
+            System.out.printf(" (%.2f)", (float)bbdT/baT);
+            testPosLimit(adler32, buf);
+
+            buf = ByteBuffer.allocate(testlen);
+            buf.put(data, 0, testlen);
+            buf.flip();
+            long bbT = time(adler32, buf, iters);
+            long bbV = adler32.getValue();
+            if (baV != bbV) {
+                System.out.printf("%nFAILED: baV=%x,bbV=%x%n", baV, bbV);
+                throw new RuntimeException();
+            }
+            testPosLimit(adler32, buf);
+            System.out.printf(" (%.2f)     checksum=%x%n", (float)bbT/baT, bbV);
+        }
+
+        System.out.println("\n---------- CRC32 ----------");
+        System.out.print("Warmup...");
+        time(crc32, data, iters, len);
+        time(crc32, ByteBuffer.wrap(data), iters);
+        buf = ByteBuffer.allocateDirect(len);
+        buf.put(data, 0, len);
+        buf.flip();
+        time(crc32, buf, iters);
+        System.out.println("\n");
+
+
+        System.out.println("Length    byte[](ns/len)  ByteBuffer(direct)   ByteBuffer");
+        for (int testlen = 1; testlen < data.length; testlen <<= 1) {
+            System.out.print(testlen + "\t");
+            long baT = time(crc32, data, iters, testlen);
+            long baV = crc32.getValue();
+            System.out.print("\t");
+
+            buf = ByteBuffer.allocateDirect(testlen);
+            buf.put(data, 0,  testlen);
+            buf.flip();
+            long bbdT = time(crc32, buf, iters);
+            long bbdV = crc32.getValue();
+            if (baV != bbdV) {
+                System.out.printf("%nFAILED: baV=%x,bbdV=%x%n", baV, bbdV);
+                throw new RuntimeException();
+            }
+            System.out.printf(" (%.2f)", (float)bbdT/baT);
+            testPosLimit(crc32, buf);
+
+            buf = ByteBuffer.allocate(testlen);
+            buf.put(data, 0, testlen);
+            buf.flip();
+            long bbT = time(crc32, buf, iters);
+            long bbV = crc32.getValue();
+            if (baV != bbV) {
+                System.out.printf("%nFAILED: baV=%x,bbV=%x%n", baV, bbV);
+                throw new RuntimeException();
+            }
+            testPosLimit(crc32, buf);
+            System.out.printf(" (%.2f)     checksum=%x%n", (float)bbT / baT, bbV);
+        }
+    }
+}
diff --git a/jdk/test/java/util/zip/ZipFile/ClearStaleZipFileInputStreams.java b/jdk/test/java/util/zip/ZipFile/ClearStaleZipFileInputStreams.java
index 4c05fa5..d1be7dc 100644
--- a/jdk/test/java/util/zip/ZipFile/ClearStaleZipFileInputStreams.java
+++ b/jdk/test/java/util/zip/ZipFile/ClearStaleZipFileInputStreams.java
@@ -63,11 +63,9 @@
             File.createTempFile("test-data" + compression, ".zip");
         tempZipFile.deleteOnExit();
 
-        ZipOutputStream zos =
-            new ZipOutputStream(new FileOutputStream(tempZipFile));
-        zos.setLevel(compression);
-
-        try {
+        try (FileOutputStream fos = new FileOutputStream(tempZipFile);
+                ZipOutputStream zos = new ZipOutputStream(fos)) {
+            zos.setLevel(compression);
             for (int i = 0; i < ZIP_ENTRY_NUM; i++) {
                 String text = "Entry" + i;
                 ZipEntry entry = new ZipEntry(text);
@@ -78,33 +76,47 @@
                     zos.closeEntry();
                 }
             }
-        } finally {
-            zos.close();
         }
 
         return tempZipFile;
     }
 
-    private static void startGcInducingThread(final int sleepMillis) {
-        final Thread gcInducingThread = new Thread() {
-            public void run() {
-                while (true) {
-                    System.gc();
-                    try {
-                        Thread.sleep(sleepMillis);
-                    } catch (InterruptedException e) { }
+    private static final class GcInducingThread extends Thread {
+        private final int sleepMillis;
+        private boolean keepRunning = true;
+
+        public GcInducingThread(final int sleepMillis) {
+            this.sleepMillis = sleepMillis;
+        }
+
+        public synchronized void run() {
+            while (keepRunning) {
+                System.gc();
+                try {
+                    wait(sleepMillis);
+                } catch (InterruptedException e) {
+                    System.out.println("GCing thread unexpectedly interrupted");
+                    return;
                 }
             }
-        };
+        }
 
-        gcInducingThread.setDaemon(true);
-        gcInducingThread.start();
+        public synchronized void shutDown() {
+            keepRunning = false;
+            notifyAll();
+        }
     }
 
     public static void main(String[] args) throws Exception {
-        startGcInducingThread(500);
-        runTest(ZipOutputStream.DEFLATED);
-        runTest(ZipOutputStream.STORED);
+        GcInducingThread gcThread = new GcInducingThread(500);
+        gcThread.start();
+        try {
+            runTest(ZipOutputStream.DEFLATED);
+            runTest(ZipOutputStream.STORED);
+        } finally {
+            gcThread.shutDown();
+            gcThread.join();
+        }
     }
 
     private static void runTest(int compression) throws Exception {
@@ -113,21 +125,16 @@
         System.out.println("Testing with a zip file with compression level = "
                 + compression);
         File f = createTestFile(compression);
-        try {
-            ZipFile zf = new ZipFile(f);
-            try {
-                Set<Object> refSet = createTransientInputStreams(zf, rq);
+        try (ZipFile zf = new ZipFile(f)) {
+            Set<Object> refSet = createTransientInputStreams(zf, rq);
 
-                System.out.println("Waiting for 'stale' input streams from ZipFile to be GC'd ...");
-                System.out.println("(The test will hang on failure)");
-                while (false == refSet.isEmpty()) {
-                    refSet.remove(rq.remove());
-                }
-                System.out.println("Test PASSED.");
-                System.out.println();
-            } finally {
-                zf.close();
+            System.out.println("Waiting for 'stale' input streams from ZipFile to be GC'd ...");
+            System.out.println("(The test will hang on failure)");
+            while (false == refSet.isEmpty()) {
+                refSet.remove(rq.remove());
             }
+            System.out.println("Test PASSED.");
+            System.out.println();
         } finally {
             f.delete();
         }
diff --git a/jdk/test/javax/swing/JScrollBar/4865918/bug4865918.java b/jdk/test/javax/swing/JScrollBar/4865918/bug4865918.java
new file mode 100644
index 0000000..8a1a804
--- /dev/null
+++ b/jdk/test/javax/swing/JScrollBar/4865918/bug4865918.java
@@ -0,0 +1,116 @@
+/*
+ * 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 4865918
+ * @summary REGRESSION:JCK1.4a-runtime api/javax_swing/interactive/JScrollBarTests.html#JScrollBar
+ * @author Andrey Pikalev
+ * @run main bug4865918
+ */
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.util.*;
+import sun.awt.SunToolkit;
+
+public class bug4865918 {
+
+    private static TestScrollBar sbar;
+
+    public static void main(String[] argv) throws Exception {
+        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            public void run() {
+                createAndShowGUI();
+            }
+        });
+
+        toolkit.realSync();
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                sbar.pressMouse();
+            }
+        });
+
+        toolkit.realSync();
+
+        int value = getValue();
+
+        if (value != 9) {
+            throw new Error("The scrollbar block increment is incorect");
+        }
+    }
+
+    private static int getValue() throws Exception {
+        final int[] result = new int[1];
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
+            public void run() {
+                result[0] = sbar.getValue();
+            }
+        });
+
+        return result[0];
+    }
+
+    private static void createAndShowGUI() {
+        JFrame frame = new JFrame("bug4865918");
+        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+        sbar = new TestScrollBar(JScrollBar.HORIZONTAL, -1, 10, -100, 100);
+        sbar.setPreferredSize(new Dimension(200, 20));
+        sbar.setBlockIncrement(10);
+
+        frame.getContentPane().add(sbar);
+        frame.pack();
+        frame.setVisible(true);
+
+    }
+
+    static class TestScrollBar extends JScrollBar {
+
+        public TestScrollBar(int orientation, int value, int extent,
+                int min, int max) {
+            super(orientation, value, extent, min, max);
+
+        }
+
+        public void pressMouse() {
+            MouseEvent me = new MouseEvent(sbar,
+                    MouseEvent.MOUSE_PRESSED,
+                    (new Date()).getTime(),
+                    MouseEvent.BUTTON1_MASK,
+                    3 * getWidth() / 4, getHeight() / 2,
+                    1, true);
+            processMouseEvent(me);
+        }
+    }
+}
diff --git a/jdk/test/javax/swing/JTabbedPane/4624207/bug4624207.java b/jdk/test/javax/swing/JTabbedPane/4624207/bug4624207.java
new file mode 100644
index 0000000..45ca603
--- /dev/null
+++ b/jdk/test/javax/swing/JTabbedPane/4624207/bug4624207.java
@@ -0,0 +1,131 @@
+/*
+ * 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 4624207
+ * @summary JTabbedPane mnemonics don't work from outside the tabbed pane
+ * @author Oleg Mokhovikov
+ * @library ../../regtesthelpers
+ * @build Util
+ * @run main bug4624207
+ */
+import javax.swing.*;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+import java.awt.*;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
+import java.awt.event.KeyEvent;
+import sun.awt.SunToolkit;
+
+public class bug4624207 implements ChangeListener, FocusListener {
+
+    private static volatile boolean stateChanged = false;
+    private static volatile boolean focusGained = false;
+    private static JTextField txtField;
+    private static JTabbedPane tab;
+    private static Object listener;
+
+    public void stateChanged(ChangeEvent e) {
+        System.out.println("stateChanged called");
+        stateChanged = true;
+    }
+
+    public void focusGained(FocusEvent e) {
+        System.out.println("focusGained called");
+        focusGained = true;
+    }
+
+    public void focusLost(FocusEvent e) {
+        System.out.println("focusLost called");
+        focusGained = false;
+    }
+
+    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() {
+                txtField.requestFocus();
+            }
+        });
+
+        toolkit.realSync();
+
+        if (!focusGained) {
+            throw new RuntimeException("Couldn't gain focus for text field");
+        }
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            public void run() {
+                tab.addChangeListener((ChangeListener) listener);
+                txtField.removeFocusListener((FocusListener) listener);
+            }
+        });
+
+        toolkit.realSync();
+
+        if ("Aqua".equals(UIManager.getLookAndFeel().getID())) {
+            Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_ALT, KeyEvent.VK_B);
+        } else {
+            Util.hitKeys(robot, KeyEvent.VK_ALT, KeyEvent.VK_B);
+        }
+
+        toolkit.realSync();
+
+        if (!stateChanged || tab.getSelectedIndex() != 1) {
+            throw new RuntimeException("JTabbedPane mnemonics don't work from outside the tabbed pane");
+        }
+    }
+
+    private static void createAndShowGUI() {
+        tab = new JTabbedPane();
+        tab.add("Tab1", new JButton("Button1"));
+        tab.add("Tab2", new JButton("Button2"));
+        tab.setMnemonicAt(0, KeyEvent.VK_T);
+        tab.setMnemonicAt(1, KeyEvent.VK_B);
+
+        JFrame frame = new JFrame();
+        frame.getContentPane().add(tab, BorderLayout.CENTER);
+        txtField = new JTextField();
+        frame.getContentPane().add(txtField, BorderLayout.NORTH);
+        listener = new bug4624207();
+        txtField.addFocusListener((FocusListener) listener);
+        frame.pack();
+        frame.setVisible(true);
+    }
+}
diff --git a/jdk/test/javax/swing/JTable/6263446/bug6263446.java b/jdk/test/javax/swing/JTable/6263446/bug6263446.java
new file mode 100644
index 0000000..6d4c235
--- /dev/null
+++ b/jdk/test/javax/swing/JTable/6263446/bug6263446.java
@@ -0,0 +1,242 @@
+/*
+ * 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.*;
+import javax.swing.*;
+import javax.swing.table.*;
+import sun.awt.SunToolkit;
+
+public class bug6263446 {
+
+    private static JTable table;
+    private static final String FIRST = "AAAAA";
+    private static final String SECOND = "BB";
+    private static final String ALL = FIRST + " " + SECOND;
+    private static Robot robot;
+
+    public static void main(String[] args) throws Exception {
+        SunToolkit 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);
+        toolkit.realSync();
+
+        click(1);
+        toolkit.realSync();
+        assertEditing(false);
+
+        click(2);
+        toolkit.realSync();
+        checkSelectedText(null);
+
+        click(3);
+        toolkit.realSync();
+        checkSelectedText(FIRST);
+
+
+        click(4);
+        toolkit.realSync();
+        checkSelectedText(ALL);
+
+        setClickCountToStart(1);
+
+        click(1);
+        toolkit.realSync();
+        checkSelectedText(null);
+
+        click(2);
+        toolkit.realSync();
+        checkSelectedText(FIRST);
+
+        click(3);
+        toolkit.realSync();
+        checkSelectedText(ALL);
+
+        setClickCountToStart(3);
+
+        click(1);
+        toolkit.realSync();
+        assertEditing(false);
+
+        click(2);
+        toolkit.realSync();
+        assertEditing(false);
+
+        click(3);
+        toolkit.realSync();
+        checkSelectedText(null);
+
+        click(4);
+        toolkit.realSync();
+        checkSelectedText(FIRST);
+
+        click(5);
+        toolkit.realSync();
+        checkSelectedText(ALL);
+
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                table.editCellAt(0, 0);
+            }
+        });
+
+        toolkit.realSync();
+        assertEditing(true);
+
+        click(2);
+        toolkit.realSync();
+        checkSelectedText(FIRST);
+
+    }
+
+    private static void checkSelectedText(String sel) throws Exception {
+        assertEditing(true);
+        checkSelection(sel);
+        cancelCellEditing();
+        assertEditing(false);
+    }
+
+    private static void setClickCountToStart(final int clicks) throws Exception {
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                DefaultCellEditor editor =
+                        (DefaultCellEditor) table.getDefaultEditor(String.class);
+                editor.setClickCountToStart(clicks);
+            }
+        });
+
+    }
+
+    private static void cancelCellEditing() throws Exception {
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                table.getCellEditor().cancelCellEditing();
+            }
+        });
+    }
+
+    private static void checkSelection(final String sel) throws Exception {
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                DefaultCellEditor editor =
+                        (DefaultCellEditor) table.getDefaultEditor(String.class);
+                JTextField field = (JTextField) editor.getComponent();
+                String text = field.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.");
+                }
+            }
+        });
+    }
+
+    private static void assertEditing(final boolean editing) throws Exception {
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                if (editing && !table.isEditing()) {
+                    throw new RuntimeException("Table should be editing");
+                }
+                if (!editing && table.isEditing()) {
+                    throw new RuntimeException("Table should not be editing");
+                }
+            }
+        });
+    }
+
+    private static Point getClickPoint() throws Exception {
+        final Point[] result = new Point[1];
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                Rectangle rect = table.getCellRect(0, 0, false);
+                Point point = new Point(rect.x + rect.width / 5,
+                        rect.y + rect.height / 2);
+                SwingUtilities.convertPointToScreen(point, table);
+                result[0] = point;
+            }
+        });
+
+        return result[0];
+    }
+
+    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 TableModel createTableModel() {
+        String[] columnNames = {"Column 0"};
+        String[][] data = {{ALL}};
+
+        return new DefaultTableModel(data, columnNames);
+    }
+
+    private static void createAndShowGUI() {
+        JFrame frame = new JFrame("bug6263446");
+        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+        table = new JTable(createTableModel());
+        frame.add(table);
+        frame.pack();
+        frame.setVisible(true);
+    }
+}
diff --git a/jdk/test/javax/swing/PopupFactory/6276087/NonOpaquePopupMenuTest.java b/jdk/test/javax/swing/PopupFactory/6276087/NonOpaquePopupMenuTest.java
new file mode 100644
index 0000000..c816734
--- /dev/null
+++ b/jdk/test/javax/swing/PopupFactory/6276087/NonOpaquePopupMenuTest.java
@@ -0,0 +1,114 @@
+/*
+ * 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 6276087
+ * @author Romain Guy
+ * @summary Tests opacity of a popup menu.
+ */
+import java.awt.*;
+import java.awt.event.*;
+
+import javax.swing.*;
+import sun.awt.SunToolkit;
+
+public class NonOpaquePopupMenuTest extends JFrame {
+
+    private static JMenu fileMenu;
+
+    public NonOpaquePopupMenuTest() {
+        getContentPane().setBackground(java.awt.Color.RED);
+        JMenuBar menuBar = new JMenuBar();
+        fileMenu = new JMenu("File");
+        JMenuItem menuItem = new JMenuItem("New");
+        menuBar.add(fileMenu);
+        setJMenuBar(menuBar);
+
+        fileMenu.add(menuItem);
+        fileMenu.getPopupMenu().setOpaque(false);
+
+        setSize(new Dimension(640, 480));
+        setVisible(true);
+    }
+
+    public static void main(String[] args) throws Throwable {
+        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+        Robot robot = new Robot();
+        robot.setAutoDelay(250);
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                new NonOpaquePopupMenuTest();
+            }
+        });
+
+        toolkit.realSync();
+
+        Point p = getMenuClickPoint();
+        robot.mouseMove(p.x, p.y);
+        robot.mousePress(InputEvent.BUTTON1_MASK);
+
+        toolkit.realSync();
+
+        if (isParentOpaque()) {
+            throw new RuntimeException("Popup menu parent is opaque");
+        }
+
+    }
+
+    private static boolean isParentOpaque() throws Exception {
+        final boolean result[] = new boolean[1];
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                result[0] = fileMenu.getPopupMenu().getParent().isOpaque();
+            }
+        });
+
+        return result[0];
+    }
+
+    private static Point getMenuClickPoint() throws Exception {
+        final Point[] result = new Point[1];
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                Point p = fileMenu.getLocationOnScreen();
+                Dimension size = fileMenu.getSize();
+
+                result[0] = new Point(p.x + size.width / 2,
+                        p.y + size.height / 2);
+            }
+        });
+
+        return result[0];
+
+    }
+}
diff --git a/jdk/test/javax/swing/plaf/metal/MetalLookAndFeel/5073047/bug5073047.java b/jdk/test/javax/swing/plaf/metal/MetalLookAndFeel/5073047/bug5073047.java
new file mode 100644
index 0000000..ce7c803
--- /dev/null
+++ b/jdk/test/javax/swing/plaf/metal/MetalLookAndFeel/5073047/bug5073047.java
@@ -0,0 +1,53 @@
+/*
+ * 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 5073407
+ * @summary Tests 5073407
+ * @author Scott Violet
+ */
+
+import javax.swing.*;
+import javax.swing.plaf.*;
+import javax.swing.plaf.metal.*;
+
+public class bug5073047 {
+
+    public static void main(String[] args) throws Exception{
+        MyTheme theme = new MyTheme();
+        MetalLookAndFeel.setCurrentTheme(theme);
+        UIManager.setLookAndFeel(new MetalLookAndFeel());
+        if (UIManager.get("Button.font") != theme.ctf) {
+            throw new RuntimeException("Unexpected font");
+        }
+    }
+
+    private static class MyTheme extends DefaultMetalTheme {
+        public final FontUIResource ctf = new FontUIResource(
+                super.getControlTextFont().deriveFont(40.0f));
+        public FontUIResource getControlTextFont() {
+            return ctf;
+        }
+    }
+}
diff --git a/jdk/test/javax/swing/regtesthelpers/Util.java b/jdk/test/javax/swing/regtesthelpers/Util.java
index 6e61ad3..c7449d1 100644
--- a/jdk/test/javax/swing/regtesthelpers/Util.java
+++ b/jdk/test/javax/swing/regtesthelpers/Util.java
@@ -140,4 +140,17 @@
 
         return null;
     }
+
+     /**
+     * Hits keys by robot.
+     */
+    public static void hitKeys(Robot robot, int... keys) {
+        for (int i = 0; i < keys.length; i++) {
+            robot.keyPress(keys[i]);
+        }
+
+        for (int i = keys.length - 1; i >= 0; i--) {
+            robot.keyRelease(keys[i]);
+        }
+    }
 }
diff --git a/jdk/test/javax/swing/text/DefaultCaret/6938583/bug6938583.java b/jdk/test/javax/swing/text/DefaultCaret/6938583/bug6938583.java
new file mode 100644
index 0000000..c5c4871
--- /dev/null
+++ b/jdk/test/javax/swing/text/DefaultCaret/6938583/bug6938583.java
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ */
+
+/*
+ * Portions Copyright (c) 2011 IBM Corporation
+ */
+
+/*
+ * @test
+ * @bug 6938583
+ * @summary Unexpected NullPointerException when use CodeIM demo on windows
+ * @author LittleE
+ */
+
+import javax.swing.*;
+import javax.swing.text.DefaultCaret;
+import java.awt.event.MouseEvent;
+
+public class bug6938583 {
+    public static void main(String[] args) throws Exception {
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                JTextArea jta = new JTextArea();
+                DefaultCaret dc = new DefaultCaret();
+                jta.setCaret(dc);
+                dc.deinstall(jta);
+                dc.mouseClicked(new MouseEvent(jta, MouseEvent.MOUSE_CLICKED, 0, 0, 0, 0, 0, false));
+            }
+        });
+    }
+}
diff --git a/jdk/test/javax/swing/text/DefaultEditorKit/4278839/bug4278839.java b/jdk/test/javax/swing/text/DefaultEditorKit/4278839/bug4278839.java
new file mode 100644
index 0000000..9dbae2b
--- /dev/null
+++ b/jdk/test/javax/swing/text/DefaultEditorKit/4278839/bug4278839.java
@@ -0,0 +1,154 @@
+/*
+ * 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 Jan 16, 2003
+ * @bug 4278839
+ * @summary Incorrect cursor movement between words at the end of line
+ * @author Anton Nashatyrev
+ * @library ../../../regtesthelpers
+ * @build Util
+ * @run main bug4278839
+ */
+
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+import sun.awt.SunToolkit;
+
+public class bug4278839 extends JFrame {
+
+    private static boolean passed = true;
+    private static JTextArea area;
+    private static Robot robo;
+    private static SunToolkit toolkit;
+
+    public static void main(String[] args) {
+        try {
+
+            toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+            robo = new Robot();
+            robo.setAutoDelay(100);
+
+            SwingUtilities.invokeAndWait(new Runnable() {
+                @Override
+                public void run() {
+                    createAndShowGUI();
+                }
+            });
+
+            toolkit.realSync();
+
+            clickMouse();
+            toolkit.realSync();
+
+
+            if ("Aqua".equals(UIManager.getLookAndFeel().getID())) {
+                Util.hitKeys(robo, KeyEvent.VK_HOME);
+            } else {
+                Util.hitKeys(robo, KeyEvent.VK_CONTROL, KeyEvent.VK_HOME);
+            }
+            toolkit.realSync();
+
+            passed &= moveCaret(true) == 1;
+            passed &= moveCaret(true) == 5;
+            passed &= moveCaret(true) == 8;
+            passed &= moveCaret(true) == 9;
+            passed &= moveCaret(true) == 13;
+            passed &= moveCaret(true) == 16;
+            passed &= moveCaret(true) == 17;
+            passed &= moveCaret(false) == 16;
+            passed &= moveCaret(false) == 13;
+            passed &= moveCaret(false) == 9;
+            passed &= moveCaret(false) == 8;
+            passed &= moveCaret(false) == 5;
+            passed &= moveCaret(false) == 1;
+            passed &= moveCaret(false) == 0;
+
+        } catch (Exception e) {
+            throw new RuntimeException("Test failed because of an exception:",
+                    e);
+        }
+
+        if (!passed) {
+            throw new RuntimeException("Test failed.");
+        }
+    }
+
+    private static int moveCaret(boolean right) throws Exception {
+        Util.hitKeys(robo, getCtrlKey(),
+                right ? KeyEvent.VK_RIGHT : KeyEvent.VK_LEFT);
+        toolkit.realSync();
+
+        final int[] result = new int[1];
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                result[0] = area.getCaretPosition();
+            }
+        });
+
+        int pos = result[0];
+        return pos;
+    }
+
+    private static void clickMouse() throws Exception {
+        final Rectangle result[] = new Rectangle[1];
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
+            public void run() {
+                result[0] = new Rectangle(area.getLocationOnScreen(), area.getSize());
+            }
+        });
+
+        Rectangle rect = result[0];
+
+        robo.mouseMove(rect.x + rect.width / 2, rect.y + rect.width / 2);
+        robo.mousePress(InputEvent.BUTTON1_MASK);
+    }
+
+    /**
+     * Gets a control key related to the used Look & Feel
+     * Returns VK_ALT for Aqua and VK_CONTROL for others
+     */
+    public static int getCtrlKey() {
+
+        if ("Aqua".equals(UIManager.getLookAndFeel().getID())) {
+            return KeyEvent.VK_ALT;
+        }
+
+        return KeyEvent.VK_CONTROL;
+    }
+
+    private static void createAndShowGUI() {
+        JFrame frame = new JFrame();
+        frame.setTitle("Bug# 4278839");
+        frame.setSize(200, 200);
+        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+        area = new JTextArea("\naaa bbb\nccc ddd\n");
+        frame.getContentPane().add(new JScrollPane(area));
+        frame.setVisible(true);
+    }
+}
diff --git a/jdk/test/javax/swing/text/JTextComponent/5074573/bug5074573.java b/jdk/test/javax/swing/text/JTextComponent/5074573/bug5074573.java
new file mode 100644
index 0000000..579d471
--- /dev/null
+++ b/jdk/test/javax/swing/text/JTextComponent/5074573/bug5074573.java
@@ -0,0 +1,159 @@
+/*
+ * 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 5074573
+ * @summary tests delte-next-word and delete-prev-word actions for all text compnents and all look&feels
+ * @author Igor Kushnirskiy
+ * @run main bug5074573
+ */
+
+import java.util.*;
+import java.awt.Robot;
+import java.awt.Toolkit;
+import java.awt.event.*;
+import javax.swing.*;
+import javax.swing.text.*;
+import sun.awt.SunToolkit;
+
+public class bug5074573 {
+
+    private static JTextComponent textComponent;
+    final static String testString = "123 456 789";
+    final static String resultString = "456 ";
+    final static List<Class<? extends JTextComponent>> textClasses = Arrays.asList(
+            JTextArea.class, JEditorPane.class, JTextPane.class,
+            JTextField.class, JFormattedTextField.class, JPasswordField.class);
+
+    public static void main(String[] args) throws Exception {
+        for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
+            UIManager.setLookAndFeel(info.getClassName());
+            System.out.println(info);
+            for (Class<? extends JTextComponent> clazz : textClasses) {
+                boolean res = test(clazz);
+                if (!res && clazz != JPasswordField.class) {
+                    throw new RuntimeException("failed");
+                }
+            }
+        }
+    }
+
+    static boolean test(final Class<? extends JTextComponent> textComponentClass) throws Exception {
+        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+        Robot robot = new Robot();
+        robot.setAutoWaitForIdle(true);
+        robot.setAutoDelay(50);
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                initialize(textComponentClass);
+            }
+        });
+
+        toolkit.realSync();
+
+        // Remove selection from JTextField components for the Aqua Look & Feel
+        if (textComponent instanceof JTextField && "Aqua".equals(UIManager.getLookAndFeel().getID())) {
+            SwingUtilities.invokeAndWait(new Runnable() {
+
+                @Override
+                public void run() {
+                    Caret caret = textComponent.getCaret();
+                    int dot = caret.getDot();
+                    textComponent.select(dot, dot);
+                }
+            });
+
+            toolkit.realSync();
+        }
+
+        robot.keyPress(getCtrlKey());
+        robot.keyPress(KeyEvent.VK_BACK_SPACE);
+        robot.keyRelease(KeyEvent.VK_BACK_SPACE);
+        robot.keyRelease(getCtrlKey());
+        toolkit.realSync();
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+
+            @Override
+            public void run() {
+                Caret caret = textComponent.getCaret();
+                caret.setDot(0);
+            }
+        });
+        toolkit.realSync();
+
+        robot.keyPress(getCtrlKey());
+        robot.keyPress(KeyEvent.VK_DELETE);
+        robot.keyRelease(KeyEvent.VK_DELETE);
+        robot.keyRelease(getCtrlKey());
+        toolkit.realSync();
+
+        return resultString.equals(getText());
+    }
+
+    private static String getText() throws Exception {
+        final String[] result = new String[1];
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+            @Override
+            public void run() {
+                result[0] = textComponent.getText();
+            }
+        });
+
+        return result[0];
+    }
+
+    /**
+     * Gets a control key related to the used Look & Feel
+     * Returns VK_ALT for Aqua and VK_CONTROL for others
+     */
+    public static int getCtrlKey() {
+
+        if ("Aqua".equals(UIManager.getLookAndFeel().getID())) {
+            return KeyEvent.VK_ALT;
+        }
+
+        return KeyEvent.VK_CONTROL;
+    }
+
+    private static void initialize(Class<? extends JTextComponent> textComponentClass) {
+        try {
+            JFrame frame = new JFrame();
+            textComponent = textComponentClass.newInstance();
+            textComponent.setText(testString);
+            frame.add(textComponent);
+            frame.pack();
+            frame.setVisible(true);
+            textComponent.requestFocus();
+            Caret caret = textComponent.getCaret();
+            caret.setDot(textComponent.getDocument().getLength());
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+}
diff --git a/jdk/test/javax/swing/text/html/HTMLEditorKit/5043626/bug5043626.java b/jdk/test/javax/swing/text/html/HTMLEditorKit/5043626/bug5043626.java
new file mode 100644
index 0000000..7de8679
--- /dev/null
+++ b/jdk/test/javax/swing/text/html/HTMLEditorKit/5043626/bug5043626.java
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2007, 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 5043626
+ * @summary  Tests pressing Home or Ctrl+Home set cursor to invisible element <head>
+ * @author Alexander Potochkin
+ * @library ../../../../regtesthelpers
+ * @build Util
+ * @run main bug5043626
+ */
+
+import java.awt.Robot;
+import java.awt.Toolkit;
+import javax.swing.*;
+import javax.swing.text.Document;
+import javax.swing.text.BadLocationException;
+import java.awt.event.KeyEvent;
+import sun.awt.SunToolkit;
+
+public class bug5043626 {
+
+    private static Document doc;
+    private static Robot robot;
+
+    public static void main(String[] args) throws Exception {
+        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+        robot = new Robot();
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                createAndShowGUI();
+            }
+        });
+
+        toolkit.realSync();
+
+        Util.hitKeys(robot, KeyEvent.VK_HOME);
+        Util.hitKeys(robot, KeyEvent.VK_1);
+
+        toolkit.realSync();
+
+        String test = getText();
+
+        if (!"1test".equals(test)) {
+            throw new RuntimeException("Begin line action set cursor inside <head> tag");
+        }
+
+        Util.hitKeys(robot, KeyEvent.VK_HOME);
+        Util.hitKeys(robot, KeyEvent.VK_2);
+
+        toolkit.realSync();
+
+        test = getText();
+
+        if (!"21test".equals(test)) {
+            throw new RuntimeException("Begin action set cursor inside <head> tag");
+        }
+    }
+
+    private static String getText() throws Exception {
+        final String[] result = new String[1];
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                try {
+                    result[0] = doc.getText(0, doc.getLength()).trim();
+                } catch (BadLocationException ex) {
+                    ex.printStackTrace();
+                }
+            }
+        });
+
+        return result[0];
+    }
+
+    private static void createAndShowGUI() {
+        JFrame frame = new JFrame();
+        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+
+        JEditorPane editorPane = new JEditorPane();
+        editorPane.setContentType("text/html");
+        editorPane.setText("test");
+        editorPane.setEditable(true);
+        frame.add(editorPane);
+        frame.pack();
+        frame.setVisible(true);
+        doc = editorPane.getDocument();
+        editorPane.setCaretPosition(doc.getLength());
+    }
+}
diff --git a/jdk/test/sun/misc/JarIndex/metaInfFilenames/Basic.java b/jdk/test/sun/misc/JarIndex/metaInfFilenames/Basic.java
index 3892054..83485d5 100644
--- a/jdk/test/sun/misc/JarIndex/metaInfFilenames/Basic.java
+++ b/jdk/test/sun/misc/JarIndex/metaInfFilenames/Basic.java
@@ -154,8 +154,7 @@
     /* run javac <args> */
     static void compile(String... args) {
         debug("Running: javac " + Arrays.toString(args));
-        com.sun.tools.javac.Main compiler = new com.sun.tools.javac.Main();
-        if (compiler.compile(args) != 0) {
+        if (com.sun.tools.javac.Main.compile(args) != 0) {
              throw new RuntimeException("javac failed: args=" + Arrays.toString(args));
         }
     }
@@ -259,7 +258,7 @@
         URLClassLoader loader = getLoader(baseURL);
         httpServer.reset();
 
-        Class messageServiceClass = null;
+        Class<?> messageServiceClass = null;
         try {
             messageServiceClass = loader.loadClass(serviceClass);
         } catch (ClassNotFoundException cnfe) {
@@ -267,7 +266,7 @@
             throw new RuntimeException("Error in test: " + cnfe);
         }
 
-        Iterator<Class<?>> iterator = sun.misc.Service.providers(messageServiceClass, loader);
+        Iterator<?> iterator = sun.misc.Service.providers(messageServiceClass, loader);
         if (expectToFind && !iterator.hasNext()) {
             debug(messageServiceClass + " NOT found.");
             return false;
@@ -301,7 +300,7 @@
         URLClassLoader loader = getLoader(baseURL);
         httpServer.reset();
 
-        Class messageServiceClass = null;
+        Class<?> messageServiceClass = null;
         try {
             messageServiceClass = loader.loadClass(serviceClass);
         } catch (ClassNotFoundException cnfe) {
@@ -309,7 +308,7 @@
             throw new RuntimeException("Error in test: " + cnfe);
         }
 
-        Iterator<Class<?>> iterator = (ServiceLoader.load(messageServiceClass, loader)).iterator();
+        Iterator<?> iterator = (ServiceLoader.load(messageServiceClass, loader)).iterator();
         if (expectToFind && !iterator.hasNext()) {
             debug(messageServiceClass + " NOT found.");
             return false;
@@ -345,7 +344,7 @@
         URLClassLoader loader = getLoader(baseURL);
         httpServer.reset();
 
-        Class ADotAKlass = null;
+        Class<?> ADotAKlass = null;
         try {
             ADotAKlass = loader.loadClass("a.A");
         } catch (ClassNotFoundException cnfe) {
diff --git a/jdk/test/sun/security/krb5/auto/CrossRealm.java b/jdk/test/sun/security/krb5/auto/CrossRealm.java
index ecaafed..21927b6 100644
--- a/jdk/test/sun/security/krb5/auto/CrossRealm.java
+++ b/jdk/test/sun/security/krb5/auto/CrossRealm.java
@@ -65,7 +65,6 @@
                 "forwardable=true",
                 "[domain_realm]",
                 ".snake.hole=SNAKE.HOLE");
-        new File("krb5-localkdc.conf").deleteOnExit();
         System.setProperty("java.security.krb5.conf", "krb5-localkdc.conf");
     }
 
@@ -73,7 +72,6 @@
         Security.setProperty("auth.login.defaultCallbackHandler", "CrossRealm");
         System.setProperty("java.security.auth.login.config", "jaas-localkdc.conf");
         System.setProperty("javax.security.auth.useSubjectCredsOnly", "false");
-        new File("jaas-localkdc.conf").deleteOnExit();
         FileOutputStream fos = new FileOutputStream("jaas-localkdc.conf");
         fos.write(("com.sun.security.jgss.krb5.initiate {\n" +
                 "    com.sun.security.auth.module.Krb5LoginModule\n" +
diff --git a/jdk/test/sun/security/krb5/auto/HttpNegotiateServer.java b/jdk/test/sun/security/krb5/auto/HttpNegotiateServer.java
index aab6b92..19f3355 100644
--- a/jdk/test/sun/security/krb5/auto/HttpNegotiateServer.java
+++ b/jdk/test/sun/security/krb5/auto/HttpNegotiateServer.java
@@ -178,7 +178,6 @@
                 "    com.sun.security.auth.module.Krb5LoginModule required;\n};\n"
                 ).getBytes());
         fos.close();
-        f.deleteOnExit();
 
         HttpServer h1 = httpd("Negotiate", false,
                 "HTTP/" + WEB_HOST + "@" + REALM_WEB, KRB5_TAB);
diff --git a/jdk/test/sun/security/krb5/auto/KDC.java b/jdk/test/sun/security/krb5/auto/KDC.java
index 9d924f6..13cad02 100644
--- a/jdk/test/sun/security/krb5/auto/KDC.java
+++ b/jdk/test/sun/security/krb5/auto/KDC.java
@@ -1071,7 +1071,6 @@
                 }
                 cache.update(credentials);
                 cache.save();
-                new File(ccache).deleteOnExit();
             }
 
             return result;
diff --git a/jdk/test/sun/security/krb5/auto/OkAsDelegateXRealm.java b/jdk/test/sun/security/krb5/auto/OkAsDelegateXRealm.java
index e5c7527..7d85599 100644
--- a/jdk/test/sun/security/krb5/auto/OkAsDelegateXRealm.java
+++ b/jdk/test/sun/security/krb5/auto/OkAsDelegateXRealm.java
@@ -109,9 +109,6 @@
 
         System.setProperty("java.security.auth.login.config", "jaas-localkdc.conf");
 
-        new File("krb5-localkdc.conf").deleteOnExit();
-        new File("localkdc.ktab").deleteOnExit();
-        new File("jaas-localkdc.conf").deleteOnExit();
         Config.refresh();
 
         Context c = Context.fromJAAS("com.sun.security.jgss.krb5.initiate");
diff --git a/jdk/test/sun/security/krb5/auto/OneKDC.java b/jdk/test/sun/security/krb5/auto/OneKDC.java
index 79a8830..76841af 100644
--- a/jdk/test/sun/security/krb5/auto/OneKDC.java
+++ b/jdk/test/sun/security/krb5/auto/OneKDC.java
@@ -76,8 +76,6 @@
         Config.refresh();
 
         writeKtab(KTAB);
-        new File(KRB5_CONF).deleteOnExit();
-        new File(KTAB).deleteOnExit();
     }
 
     /**
@@ -114,7 +112,6 @@
                 "    isInitiator=false;\n};\n"
                 ).getBytes());
         fos.close();
-        f.deleteOnExit();
         Security.setProperty("auth.login.defaultCallbackHandler", "OneKDC$CallbackForClient");
     }
 
diff --git a/jdk/test/sun/security/krb5/auto/SSL.java b/jdk/test/sun/security/krb5/auto/SSL.java
index eca5350..496097b 100644
--- a/jdk/test/sun/security/krb5/auto/SSL.java
+++ b/jdk/test/sun/security/krb5/auto/SSL.java
@@ -96,7 +96,6 @@
                 "    storeKey=true;\n};\n"
                 ).getBytes());
         fos.close();
-        f.deleteOnExit();
 
         Context c;
         final Context s = Context.fromJAAS("ssl");
diff --git a/jdk/test/sun/security/krb5/auto/W83.java b/jdk/test/sun/security/krb5/auto/W83.java
index 5c5e9af..8ac419b 100644
--- a/jdk/test/sun/security/krb5/auto/W83.java
+++ b/jdk/test/sun/security/krb5/auto/W83.java
@@ -52,8 +52,6 @@
         Config.refresh();
 
         kdc.writeKtab(OneKDC.KTAB);
-        new File(OneKDC.KRB5_CONF).deleteOnExit();
-        new File(OneKDC.KTAB).deleteOnExit();
 
         KeyTab ktab = KeyTab.getInstance(OneKDC.KTAB);
         for (int etype: EType.getBuiltInDefaults()) {
diff --git a/jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngineResult/Deserialize.java b/jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngineResult/Deserialize.java
index e92c494..af116cd 100644
--- a/jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngineResult/Deserialize.java
+++ b/jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngineResult/Deserialize.java
@@ -42,7 +42,6 @@
         SSLEngineResult.Status obj = SSLEngineResult.Status.OK;
 
         File file = new File("deserial-test-file");
-        file.deleteOnExit();
 
         ObjectOutputStream oos = new ObjectOutputStream(
             new FileOutputStream(file));
diff --git a/langtools/src/share/classes/com/sun/source/tree/LambdaExpressionTree.java b/langtools/src/share/classes/com/sun/source/tree/LambdaExpressionTree.java
new file mode 100644
index 0000000..61ae45a
--- /dev/null
+++ b/langtools/src/share/classes/com/sun/source/tree/LambdaExpressionTree.java
@@ -0,0 +1,56 @@
+/*
+ * 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.  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 com.sun.source.tree;
+
+import java.util.List;
+
+/**
+ * A tree node for a lambda expression.
+ *
+ * For example:
+ * <pre>
+ *   ()->{}
+ *   (List<String> ls)->ls.size()
+ *   (x,y)-> { return x + y; }
+ * </pre>
+ */
+public interface LambdaExpressionTree extends ExpressionTree {
+
+    /**
+     * Lambda expressions come in two forms: (i) expression lambdas, whose body
+     * is an expression, and (ii) statement lambdas, whose body is a block
+     */
+    public enum BodyKind {
+        /** enum constant for expression lambdas */
+        EXPRESSION,
+        /** enum constant for statement lambdas */
+        STATEMENT;
+    }
+
+    List<? extends VariableTree> getParameters();
+    Tree getBody();
+    BodyKind getBodyKind();
+}
diff --git a/langtools/src/share/classes/com/sun/source/tree/MemberReferenceTree.java b/langtools/src/share/classes/com/sun/source/tree/MemberReferenceTree.java
new file mode 100644
index 0000000..68efd16
--- /dev/null
+++ b/langtools/src/share/classes/com/sun/source/tree/MemberReferenceTree.java
@@ -0,0 +1,58 @@
+/*
+ * 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.  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 com.sun.source.tree;
+
+import java.util.List;
+
+import javax.lang.model.element.Name;
+
+/**
+ * A tree node for a member reference expression.
+ *
+ * For example:
+ * <pre>
+ *   <em>expression</em> # <em>[ identifier | new ]</em>
+ * </pre>
+ *
+ * @see JSR 292
+ */
+public interface MemberReferenceTree extends ExpressionTree {
+
+    /**
+     * There are two kinds of member references: (i) method references and
+     * (ii) constructor references
+     */
+    public enum ReferenceMode {
+        /** enum constant for method references */
+        INVOKE,
+        /** enum constant for constructor references */
+        NEW
+    }
+    ReferenceMode getMode();
+    ExpressionTree getQualifierExpression();
+    Name getName();
+    List<? extends ExpressionTree> getTypeArguments();
+}
diff --git a/langtools/src/share/classes/com/sun/source/tree/Tree.java b/langtools/src/share/classes/com/sun/source/tree/Tree.java
index 5e26c18..a558e9e 100644
--- a/langtools/src/share/classes/com/sun/source/tree/Tree.java
+++ b/langtools/src/share/classes/com/sun/source/tree/Tree.java
@@ -132,6 +132,11 @@
         MEMBER_SELECT(MemberSelectTree.class),
 
         /**
+         * Used for instances of {@link MemberReferenceTree}.
+         */
+        MEMBER_REFERENCE(MemberReferenceTree.class),
+
+        /**
          * Used for instances of {@link ForLoopTree}.
          */
         FOR_LOOP(ForLoopTree.class),
@@ -187,6 +192,11 @@
         NEW_CLASS(NewClassTree.class),
 
         /**
+         * Used for instances of {@link LambdaExpressionTree}.
+         */
+        LAMBDA_EXPRESSION(LambdaExpressionTree.class),
+
+        /**
          * Used for instances of {@link ParenthesizedTree}.
          */
         PARENTHESIZED(ParenthesizedTree.class),
diff --git a/langtools/src/share/classes/com/sun/source/tree/TreeVisitor.java b/langtools/src/share/classes/com/sun/source/tree/TreeVisitor.java
index ffaf0c3..dd3cfcb 100644
--- a/langtools/src/share/classes/com/sun/source/tree/TreeVisitor.java
+++ b/langtools/src/share/classes/com/sun/source/tree/TreeVisitor.java
@@ -85,9 +85,11 @@
     R visitModifiers(ModifiersTree node, P p);
     R visitNewArray(NewArrayTree node, P p);
     R visitNewClass(NewClassTree node, P p);
+    R visitLambdaExpression(LambdaExpressionTree node, P p);
     R visitParenthesized(ParenthesizedTree node, P p);
     R visitReturn(ReturnTree node, P p);
     R visitMemberSelect(MemberSelectTree node, P p);
+    R visitMemberReference(MemberReferenceTree node, P p);
     R visitEmptyStatement(EmptyStatementTree node, P p);
     R visitSwitch(SwitchTree node, P p);
     R visitSynchronized(SynchronizedTree node, P p);
diff --git a/langtools/src/share/classes/com/sun/source/util/SimpleTreeVisitor.java b/langtools/src/share/classes/com/sun/source/util/SimpleTreeVisitor.java
index fc406b4..04e6916 100644
--- a/langtools/src/share/classes/com/sun/source/util/SimpleTreeVisitor.java
+++ b/langtools/src/share/classes/com/sun/source/util/SimpleTreeVisitor.java
@@ -172,6 +172,10 @@
         return defaultAction(node, p);
     }
 
+    public R visitLambdaExpression(LambdaExpressionTree node, P p) {
+        return defaultAction(node, p);
+    }
+
     public R visitParenthesized(ParenthesizedTree node, P p) {
         return defaultAction(node, p);
     }
@@ -208,6 +212,10 @@
         return defaultAction(node, p);
     }
 
+    public R visitMemberReference(MemberReferenceTree node, P p) {
+        return defaultAction(node, p);
+    }
+
     public R visitIdentifier(IdentifierTree node, P p) {
         return defaultAction(node, p);
     }
diff --git a/langtools/src/share/classes/com/sun/source/util/TreeScanner.java b/langtools/src/share/classes/com/sun/source/util/TreeScanner.java
index e87189d..3619f31 100644
--- a/langtools/src/share/classes/com/sun/source/util/TreeScanner.java
+++ b/langtools/src/share/classes/com/sun/source/util/TreeScanner.java
@@ -285,6 +285,12 @@
         return r;
     }
 
+    public R visitLambdaExpression(LambdaExpressionTree node, P p) {
+        R r = scan(node.getParameters(), p);
+        r = scanAndReduce(node.getBody(), p, r);
+        return r;
+    }
+
     public R visitParenthesized(ParenthesizedTree node, P p) {
         return scan(node.getExpression(), p);
     }
@@ -333,6 +339,12 @@
         return scan(node.getExpression(), p);
     }
 
+    public R visitMemberReference(MemberReferenceTree node, P p) {
+        R r = scan(node.getQualifierExpression(), p);
+        r = scanAndReduce(node.getTypeArguments(), p, r);
+        return r;
+    }
+
     public R visitIdentifier(IdentifierTree node, P p) {
         return null;
     }
diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Source.java b/langtools/src/share/classes/com/sun/tools/javac/code/Source.java
index 2a0948c..d469598 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Source.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Source.java
@@ -194,6 +194,12 @@
     public boolean allowObjectToPrimitiveCast() {
         return compareTo(JDK1_7) >= 0;
     }
+    public boolean allowLambda() {
+        return compareTo(JDK1_8) >= 0;
+    }
+    public boolean allowMethodReferences() {
+        return compareTo(JDK1_8) >= 0;
+    }
     public static SourceVersion toSourceVersion(Source source) {
         switch(source) {
         case JDK1_2:
diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java
index ebecb03..deb9484 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java
@@ -1975,6 +1975,16 @@
         result = check(tree, owntype, VAL, pkind, pt);
     }
 
+    @Override
+    public void visitLambda(JCLambda that) {
+        throw new UnsupportedOperationException("Lambda expression not supported yet");
+    }
+
+    @Override
+    public void visitReference(JCMemberReference that) {
+        throw new UnsupportedOperationException("Member references not supported yet");
+    }
+
     public void visitParens(JCParens tree) {
         Type owntype = attribTree(tree.expr, env, pkind, pt);
         result = check(tree, owntype, pkind, pkind, pt);
diff --git a/langtools/src/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java b/langtools/src/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java
index f9ce7a2..f094538 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java
@@ -637,6 +637,10 @@
                         lexError(pos, "unclosed.str.lit");
                     }
                     break loop;
+                case '#':
+                    reader.scanChar();
+                    tk = TokenKind.HASH;
+                    break loop;
                 default:
                     if (isSpecial(reader.ch)) {
                         scanOperator();
diff --git a/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java b/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java
index f2f49ae..81d6680 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java
@@ -27,6 +27,8 @@
 
 import java.util.*;
 
+import com.sun.source.tree.MemberReferenceTree.ReferenceMode;
+
 import com.sun.tools.javac.code.*;
 import com.sun.tools.javac.parser.Tokens.*;
 import com.sun.tools.javac.parser.Tokens.Comment.CommentStyle;
@@ -110,6 +112,10 @@
         this.allowDiamond = source.allowDiamond();
         this.allowMulticatch = source.allowMulticatch();
         this.allowStringFolding = fac.options.getBoolean("allowStringFolding", true);
+        this.allowLambda = source.allowLambda() &&
+                fac.options.isSet("allowLambda");
+        this.allowMethodReferences = source.allowMethodReferences() &&
+                fac.options.isSet("allowMethodReferences");
         this.keepDocComments = keepDocComments;
         docComments = keepDocComments ? new HashMap<JCTree,String>() : null;
         this.keepLineMap = keepLineMap;
@@ -166,6 +172,14 @@
      */
     boolean allowStringFolding;
 
+    /** Switch: should we recognize lambda expressions?
+     */
+    boolean allowLambda;
+
+    /** Switch: should we allow method/constructor references?
+     */
+    boolean allowMethodReferences;
+
     /** Switch: should we keep docComments?
      */
     boolean keepDocComments;
@@ -203,6 +217,30 @@
         token = S.token();
     }
 
+    protected boolean peekToken(TokenKind tk) {
+        return S.token(1).kind == tk;
+    }
+
+    protected boolean peekToken(TokenKind tk1, TokenKind tk2) {
+        return S.token(1).kind == tk1 &&
+                S.token(2).kind == tk2;
+    }
+
+    protected boolean peekToken(TokenKind tk1, TokenKind tk2, TokenKind tk3) {
+        return S.token(1).kind == tk1 &&
+                S.token(2).kind == tk2 &&
+                S.token(3).kind == tk3;
+    }
+
+    protected boolean peekToken(TokenKind... kinds) {
+        for (int lookahead = 0 ; lookahead < kinds.length ; lookahead++) {
+            if (S.token(lookahead + 1).kind != kinds[lookahead]) {
+                return false;
+            }
+        }
+        return true;
+    }
+
     /* ---------- error recovery -------------- */
 
     private JCErroneous errorTree;
@@ -749,7 +787,7 @@
             top++;
             topOp = token;
             nextToken();
-            odStack[top] = (topOp.kind == INSTANCEOF) ? parseType() : term3();
+            odStack[top] = (topOp.kind == INSTANCEOF) ? parseType() : term3NoParams();
             while (top > 0 && prec(topOp.kind) >= prec(token.kind)) {
                 odStack[top-1] = makeOp(topOp.pos, topOp.kind, odStack[top-1],
                                         odStack[top]);
@@ -849,7 +887,10 @@
      *                 | [TypeArguments] THIS [Arguments]
      *                 | [TypeArguments] SUPER SuperSuffix
      *                 | NEW [TypeArguments] Creator
+     *                 | "(" Arguments ")" "->" ( Expression | Block )
+     *                 | Ident "->" ( Expression | Block )
      *                 | Ident { "." Ident }
+     *                 | Expression3 MemberReferenceSuffix
      *                   [ "[" ( "]" BracketsOpt "." CLASS | Expression "]" )
      *                   | Arguments
      *                   | "." ( CLASS | THIS | [TypeArguments] SUPER Arguments | NEW [TypeArguments] InnerCreator )
@@ -890,60 +931,87 @@
                     mode = EXPR;
                     t = literal(names.hyphen, pos);
                 } else {
-                    t = term3();
+                    t = term3NoParams();
                     return F.at(pos).Unary(unoptag(tk), t);
                 }
             } else return illegal();
             break;
         case LPAREN:
             if (typeArgs == null && (mode & EXPR) != 0) {
-                nextToken();
-                mode = EXPR | TYPE | NOPARAMS;
-                t = term3();
-                if ((mode & TYPE) != 0 && token.kind == LT) {
-                    // Could be a cast to a parameterized type
-                    JCTree.Tag op = JCTree.Tag.LT;
-                    int pos1 = token.pos;
+                if (peekToken(FINAL) ||
+                        peekToken(RPAREN) ||
+                        peekToken(IDENTIFIER, COMMA) ||
+                        peekToken(IDENTIFIER, RPAREN, ARROW)) {
+                    //implicit n-ary lambda
+                    t = lambdaExpressionOrStatement(true, peekToken(FINAL), pos);
+                    break;
+                } else {
                     nextToken();
-                    mode &= (EXPR | TYPE);
-                    mode |= TYPEARG;
-                    JCExpression t1 = term3();
-                    if ((mode & TYPE) != 0 &&
-                        (token.kind == COMMA || token.kind == GT)) {
-                        mode = TYPE;
-                        ListBuffer<JCExpression> args = new ListBuffer<JCExpression>();
-                        args.append(t1);
-                        while (token.kind == COMMA) {
-                            nextToken();
-                            args.append(typeArgument());
-                        }
-                        accept(GT);
-                        t = toP(F.at(pos1).TypeApply(t, args.toList()));
-                        checkGenerics();
-                        while (token.kind == DOT) {
-                            nextToken();
+                    mode = EXPR | TYPE;
+                    t = term3NoParams();
+                    if ((mode & TYPE) != 0 && token.kind == LT) {
+                        // Could be a cast to a parameterized type
+                        JCTree.Tag op = JCTree.Tag.LT;
+                        int pos1 = token.pos;
+                        nextToken();
+                        mode &= (EXPR | TYPE);
+                        mode |= TYPEARG;
+                        JCExpression t1 = term3();
+                        if ((mode & TYPE) != 0 &&
+                            (token.kind == COMMA || token.kind == GT)) {
                             mode = TYPE;
-                            t = toP(F.at(token.pos).Select(t, ident()));
-                            t = typeArgumentsOpt(t);
+                            ListBuffer<JCExpression> args = new ListBuffer<JCExpression>();
+                            args.append(t1);
+                            while (token.kind == COMMA) {
+                                nextToken();
+                                args.append(typeArgument());
+                            }
+                            accept(GT);
+                            t = toP(F.at(pos1).TypeApply(t, args.toList()));
+                            checkGenerics();
+                            mode = EXPR | TYPE; //could be a lambda or a method ref or a cast to a type
+                            t = term3Rest(t, typeArgs);
+                            if (token.kind == IDENTIFIER || token.kind == ELLIPSIS) {
+                                //explicit lambda (w/ generic type)
+                                mode = EXPR;
+                                JCModifiers mods = F.at(token.pos).Modifiers(Flags.PARAMETER);
+                                if (token.kind == ELLIPSIS) {
+                                    mods.flags = Flags.VARARGS;
+                                    t = to(F.at(token.pos).TypeArray(t));
+                                    nextToken();
+                                }
+                                t = lambdaExpressionOrStatement(variableDeclaratorId(mods, t), pos);
+                                break;
+                            }
+                        } else {
+                            Assert.check((mode & EXPR) != 0);
+                            mode = EXPR;
+                            JCExpression e = term2Rest(t1, TreeInfo.shiftPrec);
+                            t = F.at(pos1).Binary(op, t, e);
+                            t = termRest(term1Rest(term2Rest(t, TreeInfo.orPrec)));
                         }
-                        t = bracketsOpt(toP(t));
-                    } else if ((mode & EXPR) != 0) {
+                    } else if ((mode & TYPE) != 0 &&
+                            (token.kind == IDENTIFIER || token.kind == ELLIPSIS)) {
+                        //explicit lambda (w/ non-generic type)
                         mode = EXPR;
-                        JCExpression e = term2Rest(t1, TreeInfo.shiftPrec);
-                        t = F.at(pos1).Binary(op, t, e);
-                        t = termRest(term1Rest(term2Rest(t, TreeInfo.orPrec)));
+                        JCModifiers mods = F.at(token.pos).Modifiers(Flags.PARAMETER);
+                        if (token.kind == ELLIPSIS) {
+                            mods.flags = Flags.VARARGS;
+                            t = to(F.at(token.pos).TypeArray(t));
+                            nextToken();
+                        }
+                        t = lambdaExpressionOrStatement(variableDeclaratorId(mods, t), pos);
+                        break;
                     } else {
-                        accept(GT);
+                        t = termRest(term1Rest(term2Rest(t, TreeInfo.orPrec)));
                     }
                 }
-                else {
-                    t = termRest(term1Rest(term2Rest(t, TreeInfo.orPrec)));
-                }
+
                 accept(RPAREN);
                 lastmode = mode;
                 mode = EXPR;
                 if ((lastmode & EXPR) == 0) {
-                    JCExpression t1 = term3();
+                    JCExpression t1 = term3NoParams();
                     return F.at(pos).TypeCast(t, t1);
                 } else if ((lastmode & TYPE) != 0) {
                     switch (token.kind) {
@@ -953,14 +1021,16 @@
                     case INTLITERAL: case LONGLITERAL: case FLOATLITERAL:
                     case DOUBLELITERAL: case CHARLITERAL: case STRINGLITERAL:
                     case TRUE: case FALSE: case NULL:
-                    case NEW: case IDENTIFIER: case ASSERT: case ENUM:
+                        case NEW: case IDENTIFIER: case ASSERT: case ENUM:
                     case BYTE: case SHORT: case CHAR: case INT:
                     case LONG: case FLOAT: case DOUBLE: case BOOLEAN: case VOID:
-                        JCExpression t1 = term3();
+                        JCExpression t1 = term3NoParams();
                         return F.at(pos).TypeCast(t, t1);
                     }
                 }
-            } else return illegal();
+            } else {
+                return illegal();
+            }
             t = toP(F.at(pos).Parens(t));
             break;
         case THIS:
@@ -1003,75 +1073,122 @@
             break;
         case IDENTIFIER: case ASSERT: case ENUM:
             if (typeArgs != null) return illegal();
-            t = toP(F.at(token.pos).Ident(ident()));
-            loop: while (true) {
-                pos = token.pos;
-                switch (token.kind) {
-                case LBRACKET:
-                    nextToken();
-                    if (token.kind == RBRACKET) {
+            if ((mode & EXPR) != 0 && peekToken(ARROW)) {
+                t = lambdaExpressionOrStatement(false, false, pos);
+            } else {
+                t = toP(F.at(token.pos).Ident(ident()));
+                loop: while (true) {
+                    pos = token.pos;
+                    switch (token.kind) {
+                    case LBRACKET:
                         nextToken();
-                        t = bracketsOpt(t);
-                        t = toP(F.at(pos).TypeArray(t));
-                        t = bracketsSuffix(t);
-                    } else {
+                        if (token.kind == RBRACKET) {
+                            nextToken();
+                            t = bracketsOpt(t);
+                            t = toP(F.at(pos).TypeArray(t));
+                            t = bracketsSuffix(t);
+                        } else {
+                            if ((mode & EXPR) != 0) {
+                                mode = EXPR;
+                                JCExpression t1 = term();
+                                t = to(F.at(pos).Indexed(t, t1));
+                            }
+                            accept(RBRACKET);
+                        }
+                        break loop;
+                    case LPAREN:
                         if ((mode & EXPR) != 0) {
                             mode = EXPR;
-                            JCExpression t1 = term();
-                            t = to(F.at(pos).Indexed(t, t1));
-                        }
-                        accept(RBRACKET);
-                    }
-                    break loop;
-                case LPAREN:
-                    if ((mode & EXPR) != 0) {
-                        mode = EXPR;
-                        t = arguments(typeArgs, t);
-                        typeArgs = null;
-                    }
-                    break loop;
-                case DOT:
-                    nextToken();
-                    int oldmode = mode;
-                    mode &= ~NOPARAMS;
-                    typeArgs = typeArgumentsOpt(EXPR);
-                    mode = oldmode;
-                    if ((mode & EXPR) != 0) {
-                        switch (token.kind) {
-                        case CLASS:
-                            if (typeArgs != null) return illegal();
-                            mode = EXPR;
-                            t = to(F.at(pos).Select(t, names._class));
-                            nextToken();
-                            break loop;
-                        case THIS:
-                            if (typeArgs != null) return illegal();
-                            mode = EXPR;
-                            t = to(F.at(pos).Select(t, names._this));
-                            nextToken();
-                            break loop;
-                        case SUPER:
-                            mode = EXPR;
-                            t = to(F.at(pos).Select(t, names._super));
-                            t = superSuffix(typeArgs, t);
+                            t = arguments(typeArgs, t);
                             typeArgs = null;
-                            break loop;
-                        case NEW:
-                            if (typeArgs != null) return illegal();
-                            mode = EXPR;
-                            int pos1 = token.pos;
-                            nextToken();
-                            if (token.kind == LT) typeArgs = typeArguments(false);
-                            t = innerCreator(pos1, typeArgs, t);
-                            typeArgs = null;
-                            break loop;
                         }
+                        break loop;
+                    case DOT:
+                        nextToken();
+                        int oldmode = mode;
+                        mode &= ~NOPARAMS;
+                        typeArgs = typeArgumentsOpt(EXPR);
+                        mode = oldmode;
+                        if ((mode & EXPR) != 0) {
+                            switch (token.kind) {
+                            case CLASS:
+                                if (typeArgs != null) return illegal();
+                                mode = EXPR;
+                                t = to(F.at(pos).Select(t, names._class));
+                                nextToken();
+                                break loop;
+                            case THIS:
+                                if (typeArgs != null) return illegal();
+                                mode = EXPR;
+                                t = to(F.at(pos).Select(t, names._this));
+                                nextToken();
+                                break loop;
+                            case SUPER:
+                                mode = EXPR;
+                                t = to(F.at(pos).Select(t, names._super));
+                                t = superSuffix(typeArgs, t);
+                                typeArgs = null;
+                                break loop;
+                            case NEW:
+                                if (typeArgs != null) return illegal();
+                                mode = EXPR;
+                                int pos1 = token.pos;
+                                nextToken();
+                                if (token.kind == LT) typeArgs = typeArguments(false);
+                                t = innerCreator(pos1, typeArgs, t);
+                                typeArgs = null;
+                                break loop;
+                            }
+                        }
+                        // typeArgs saved for next loop iteration.
+                        t = toP(F.at(pos).Select(t, ident()));
+                        break;
+//                    case LT:
+//                        if ((mode & (TYPE | NOPARAMS)) == 0) {
+//                            //could be an unbound method reference whose qualifier
+//                            //is a generic type i.e. A<S>#m
+//                            mode = EXPR | TYPE;
+//                            JCTree.Tag op = JCTree.Tag.LT;
+//                            int pos1 = token.pos;
+//                            nextToken();
+//                            mode |= EXPR | TYPE | TYPEARG;
+//                            JCExpression t1 = term3();
+//                            if ((mode & TYPE) != 0 &&
+//                                (token.kind == COMMA || token.kind == GT)) {
+//                                mode = TYPE;
+//                                ListBuffer<JCExpression> args = new ListBuffer<JCExpression>();
+//                                args.append(t1);
+//                                while (token.kind == COMMA) {
+//                                    nextToken();
+//                                    args.append(typeArgument());
+//                                }
+//                                accept(GT);
+//                                t = toP(F.at(pos1).TypeApply(t, args.toList()));
+//                                checkGenerics();
+//                                while (token.kind == DOT) {
+//                                    nextToken();
+//                                    mode = TYPE;
+//                                    t = toP(F.at(token.pos).Select(t, ident()));
+//                                    t = typeArgumentsOpt(t);
+//                                }
+//                                if (token.kind != HASH) {
+//                                    //method reference expected here
+//                                    t = illegal();
+//                                }
+//                                mode = EXPR;
+//                                break;
+//                            } else if ((mode & EXPR) != 0) {
+//                                //rollback - it was a binary expression
+//                                mode = EXPR;
+//                                JCExpression e = term2Rest(t1, TreeInfo.shiftPrec);
+//                                t = F.at(pos1).Binary(op, t, e);
+//                                t = termRest(term1Rest(term2Rest(t, TreeInfo.orPrec)));
+//                            }
+//                        }
+//                        break loop;
+                    default:
+                        break loop;
                     }
-                    // typeArgs saved for next loop iteration.
-                    t = toP(F.at(pos).Select(t, ident()));
-                    break;
-                default:
-                    break loop;
                 }
             }
             if (typeArgs != null) illegal();
@@ -1105,6 +1222,19 @@
         default:
             return illegal();
         }
+        return term3Rest(t, typeArgs);
+    }
+
+    JCExpression term3NoParams() {
+        try {
+            mode |= NOPARAMS;
+            return term3();
+        } finally {
+            mode &= ~NOPARAMS;
+        }
+    }
+
+    JCExpression term3Rest(JCExpression t, List<JCExpression> typeArgs) {
         if (typeArgs != null) illegal();
         while (true) {
             int pos1 = token.pos;
@@ -1149,6 +1279,11 @@
                     t = argumentsOpt(typeArgs, typeArgumentsOpt(t));
                     typeArgs = null;
                 }
+            } else if ((mode & EXPR) != 0 && token.kind == HASH) {
+                mode = EXPR;
+                if (typeArgs != null) return illegal();
+                accept(HASH);
+                t = memberReferenceSuffix(pos1, t);
             } else {
                 break;
             }
@@ -1162,12 +1297,59 @@
         return toP(t);
     }
 
+    JCExpression lambdaExpressionOrStatement(JCVariableDecl firstParam, int pos) {
+        ListBuffer<JCVariableDecl> params = new ListBuffer<JCVariableDecl>();
+        params.append(firstParam);
+        JCVariableDecl lastParam = firstParam;
+        while ((lastParam.mods.flags & Flags.VARARGS) == 0 && token.kind == COMMA) {
+            nextToken();
+            params.append(lastParam = formalParameter());
+        }
+        accept(RPAREN);
+        return lambdaExpressionOrStatementRest(params.toList(), pos);
+    }
+
+    JCExpression lambdaExpressionOrStatement(boolean hasParens, boolean explicitParams, int pos) {
+        List<JCVariableDecl> params = explicitParams ?
+                formalParameters() :
+                implicitParameters(hasParens);
+
+        return lambdaExpressionOrStatementRest(params, pos);
+    }
+
+    JCExpression lambdaExpressionOrStatementRest(List<JCVariableDecl> args, int pos) {
+        if (token.kind != ARROW) {
+            //better error recovery
+            return F.at(pos).Erroneous(args);
+        }
+
+        checkLambda();
+        accept(ARROW);
+
+        return token.kind == LBRACE ?
+            lambdaStatement(args, pos, pos) :
+            lambdaExpression(args, pos);
+    }
+
+    JCExpression lambdaStatement(List<JCVariableDecl> args, int pos, int pos2) {
+        JCBlock block = block(pos2, 0);
+        return toP(F.at(pos).Lambda(args, block));
+    }
+
+    JCExpression lambdaExpression(List<JCVariableDecl> args, int pos) {
+        JCTree expr = parseExpression();
+        return toP(F.at(pos).Lambda(args, expr));
+    }
+
     /** SuperSuffix = Arguments | "." [TypeArguments] Ident [Arguments]
      */
     JCExpression superSuffix(List<JCExpression> typeArgs, JCExpression t) {
         nextToken();
         if (token.kind == LPAREN || typeArgs != null) {
             t = arguments(typeArgs, t);
+        } else if (token.kind == HASH) {
+            if (typeArgs != null) return illegal();
+            t = memberReferenceSuffix(t);
         } else {
             int pos = token.pos;
             accept(DOT);
@@ -1377,6 +1559,36 @@
         return t;
     }
 
+    /**
+     * MemberReferenceSuffix = "#" [TypeArguments] Ident
+     *                       | "#" [TypeArguments] "new"
+     */
+    JCExpression memberReferenceSuffix(JCExpression t) {
+        int pos1 = token.pos;
+        accept(HASH);
+        return memberReferenceSuffix(pos1, t);
+    }
+
+    JCExpression memberReferenceSuffix(int pos1, JCExpression t) {
+        checkMethodReferences();
+        mode = EXPR;
+        List<JCExpression> typeArgs = null;
+        if (token.kind == LT) {
+            typeArgs = typeArguments(false);
+        }
+        Name refName = null;
+        ReferenceMode refMode = null;
+        if (token.kind == NEW) {
+            refMode = ReferenceMode.NEW;
+            refName = names.init;
+            nextToken();
+        } else {
+            refMode = ReferenceMode.INVOKE;
+            refName = ident();
+        }
+        return toP(F.at(t.getStartPosition()).Reference(refMode, refName, t, typeArgs));
+    }
+
     /** Creator = Qualident [TypeArguments] ( ArrayCreatorRest | ClassCreatorRest )
      */
     JCExpression creator(int newpos, List<JCExpression> typeArgs) {
@@ -2392,7 +2604,7 @@
      *  @param mods    The modifiers starting the class declaration
      *  @param dc       The documentation comment for the class, or null.
      */
-    JCClassDecl classDeclaration(JCModifiers mods, String dc) {
+    protected JCClassDecl classDeclaration(JCModifiers mods, String dc) {
         int pos = token.pos;
         accept(CLASS);
         Name name = ident();
@@ -2421,7 +2633,7 @@
      *  @param mods    The modifiers starting the interface declaration
      *  @param dc       The documentation comment for the interface, or null.
      */
-    JCClassDecl interfaceDeclaration(JCModifiers mods, String dc) {
+    protected JCClassDecl interfaceDeclaration(JCModifiers mods, String dc) {
         int pos = token.pos;
         accept(INTERFACE);
         Name name = ident();
@@ -2444,7 +2656,7 @@
      *  @param mods    The modifiers starting the enum declaration
      *  @param dc       The documentation comment for the enum, or null.
      */
-    JCClassDecl enumDeclaration(JCModifiers mods, String dc) {
+    protected JCClassDecl enumDeclaration(JCModifiers mods, String dc) {
         int pos = token.pos;
         accept(ENUM);
         Name name = ident();
@@ -2666,7 +2878,7 @@
      *  ConstructorDeclaratorRest =
      *      "(" FormalParameterListOpt ")" [THROWS TypeList] MethodBody
      */
-    JCTree methodDeclaratorRest(int pos,
+    protected JCTree methodDeclaratorRest(int pos,
                               JCModifiers mods,
                               JCExpression type,
                               Name name,
@@ -2779,6 +2991,24 @@
         return params.toList();
     }
 
+    List<JCVariableDecl> implicitParameters(boolean hasParens) {
+        if (hasParens) {
+            accept(LPAREN);
+        }
+        ListBuffer<JCVariableDecl> params = new ListBuffer<JCVariableDecl>();
+        if (token.kind != RPAREN && token.kind != ARROW) {
+            params.append(implicitParameter());
+            while (token.kind == COMMA) {
+                nextToken();
+                params.append(implicitParameter());
+            }
+        }
+        if (hasParens) {
+            accept(RPAREN);
+        }
+        return params.toList();
+    }
+
     JCModifiers optFinal(long flags) {
         JCModifiers mods = modifiersOpt();
         checkNoMods(mods.flags & ~(Flags.FINAL | Flags.DEPRECATED));
@@ -2801,6 +3031,11 @@
         return variableDeclaratorId(mods, type);
     }
 
+    protected JCVariableDecl implicitParameter() {
+        JCModifiers mods = F.at(token.pos).Modifiers(Flags.PARAMETER);
+        return variableDeclaratorId(mods, null);
+    }
+
 /* ---------- auxiliary methods -------------- */
 
     void error(int pos, String key, Object ... args) {
@@ -3024,6 +3259,18 @@
             allowTWR = true;
         }
     }
+    void checkLambda() {
+        if (!allowLambda) {
+            log.error(token.pos, "lambda.not.supported.in.source", source.name);
+            allowLambda = true;
+        }
+    }
+    void checkMethodReferences() {
+        if (!allowMethodReferences) {
+            log.error(token.pos, "method.references.not.supported.in.source", source.name);
+            allowMethodReferences = true;
+        }
+    }
 
     /*
      * a functional source tree and end position mappings
diff --git a/langtools/src/share/classes/com/sun/tools/javac/parser/Lexer.java b/langtools/src/share/classes/com/sun/tools/javac/parser/Lexer.java
index 57d7a98..ed428f8 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/parser/Lexer.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/parser/Lexer.java
@@ -50,6 +50,11 @@
     Token token();
 
     /**
+     * Return token with given lookahead.
+     */
+    Token token(int lookahead);
+
+    /**
      * Return the last character position of the previous token.
      */
     Token prevToken();
diff --git a/langtools/src/share/classes/com/sun/tools/javac/parser/Scanner.java b/langtools/src/share/classes/com/sun/tools/javac/parser/Scanner.java
index 41f50cb..93b2e8a 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/parser/Scanner.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/parser/Scanner.java
@@ -26,8 +26,9 @@
 package com.sun.tools.javac.parser;
 
 import java.nio.*;
+import java.util.List;
+import java.util.ArrayList;
 
-import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.util.Position.LineMap;
 import com.sun.tools.javac.parser.JavaTokenizer.*;
 
@@ -53,6 +54,10 @@
      */
     private Token prevToken;
 
+    /** Buffer of saved tokens (used during lookahead)
+     */
+    private List<Token> savedTokens = new ArrayList<Token>();
+
     private JavaTokenizer tokenizer;
     /**
      * Create a scanner from the input array.  This method might
@@ -80,16 +85,35 @@
     }
 
     public Token token() {
-        return token;
+        return token(0);
     }
 
+    public Token token(int lookahead) {
+        if (lookahead == 0) {
+            return token;
+        } else {
+            ensureLookahead(lookahead);
+            return savedTokens.get(lookahead - 1);
+        }
+    }
+    //where
+        private void ensureLookahead(int lookahead) {
+            for (int i = savedTokens.size() ; i < lookahead ; i ++) {
+                savedTokens.add(tokenizer.readToken());
+            }
+        }
+
     public Token prevToken() {
         return prevToken;
     }
 
     public void nextToken() {
         prevToken = token;
-        token = tokenizer.readToken();
+        if (!savedTokens.isEmpty()) {
+            token = savedTokens.remove(0);
+        } else {
+            token = tokenizer.readToken();
+        }
     }
 
     public Token split() {
diff --git a/langtools/src/share/classes/com/sun/tools/javac/parser/Tokens.java b/langtools/src/share/classes/com/sun/tools/javac/parser/Tokens.java
index db2e1ec..402e6db 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/parser/Tokens.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/parser/Tokens.java
@@ -176,6 +176,8 @@
         TRUE("true", Tag.NAMED),
         FALSE("false", Tag.NAMED),
         NULL("null", Tag.NAMED),
+        ARROW("->"),
+        HASH("#"),
         LPAREN("("),
         RPAREN(")"),
         LBRACE("{"),
diff --git a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties
index 75a2aaf..14f1d60 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties
+++ b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties
@@ -1945,6 +1945,16 @@
     strings in switch are not supported in -source {0}\n\
     (use -source 7 or higher to enable strings in switch)
 
+# 0: string
+compiler.err.lambda.not.supported.in.source=\
+    lambda expressions are not supported in -source {0}\n\
+    (use -source 8 or higher to enable lambda expressions)
+
+# 0: string
+compiler.err.method.references.not.supported.in.source=\
+    method references are not supported in -source {0}\n\
+    (use -source 8 or higher to enable method references)
+
 ########################################
 # Diagnostics for verbose resolution
 # used by Resolve (debug only)
diff --git a/langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java b/langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java
index 9fd4055..59fc37e 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java
@@ -41,6 +41,8 @@
 import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.parser.EndPosTable;
 import com.sun.source.tree.*;
+import com.sun.source.tree.LambdaExpressionTree.BodyKind;
+import com.sun.source.tree.MemberReferenceTree.ReferenceMode;
 
 import static com.sun.tools.javac.code.BoundKind.*;
 import static com.sun.tools.javac.tree.JCTree.Tag.*;
@@ -198,6 +200,10 @@
          */
         NEWARRAY,
 
+        /** Lambda expression, of type Lambda.
+         */
+        LAMBDA,
+
         /** Parenthesized subexpressions, of type Parens.
          */
         PARENS,
@@ -222,6 +228,10 @@
          */
         SELECT,
 
+        /** Member references, of type Reference.
+         */
+        REFERENCE,
+
         /** Simple identifiers, of type Ident.
          */
         IDENT,
@@ -1487,6 +1497,56 @@
     }
 
     /**
+     * A lambda expression.
+     */
+    public static class JCLambda extends JCExpression implements LambdaExpressionTree {
+
+        public List<JCVariableDecl> params;
+        public JCTree body;
+        public Type targetType;
+        public boolean canCompleteNormally = true;
+        public List<Type> inferredThrownTypes;
+
+        public JCLambda(List<JCVariableDecl> params,
+                        JCTree body) {
+            this.params = params;
+            this.body = body;
+        }
+        @Override
+        public Tag getTag() {
+            return LAMBDA;
+        }
+        @Override
+        public void accept(Visitor v) {
+            v.visitLambda(this);
+        }
+        @Override
+        public <R, D> R accept(TreeVisitor<R, D> v, D d) {
+            return v.visitLambdaExpression(this, d);
+        }
+        public Kind getKind() {
+            return Kind.LAMBDA_EXPRESSION;
+        }
+        public JCTree getBody() {
+            return body;
+        }
+        public java.util.List<? extends VariableTree> getParameters() {
+            return params;
+        }
+        @Override
+        public JCLambda setType(Type type) {
+            super.setType(type);
+            return this;
+        }
+        @Override
+        public BodyKind getBodyKind() {
+            return body.hasTag(BLOCK) ?
+                    BodyKind.STATEMENT :
+                    BodyKind.EXPRESSION;
+        }
+    }
+
+    /**
      * A parenthesized subexpression ( ... )
      */
     public static class JCParens extends JCExpression implements ParenthesizedTree {
@@ -1747,6 +1807,46 @@
     }
 
     /**
+     * Selects a member expression.
+     */
+    public static class JCMemberReference extends JCExpression implements MemberReferenceTree {
+        public ReferenceMode mode;
+        public Name name;
+        public JCExpression expr;
+        public List<JCExpression> typeargs;
+        public Type targetType;
+        public Symbol sym;
+
+        protected JCMemberReference(ReferenceMode mode, Name name, JCExpression expr, List<JCExpression> typeargs) {
+            this.mode = mode;
+            this.name = name;
+            this.expr = expr;
+            this.typeargs = typeargs;
+        }
+        @Override
+        public void accept(Visitor v) { v.visitReference(this); }
+
+        public Kind getKind() { return Kind.MEMBER_REFERENCE; }
+        @Override
+        public ReferenceMode getMode() { return mode; }
+        @Override
+        public JCExpression getQualifierExpression() { return expr; }
+        @Override
+        public Name getName() { return name; }
+        @Override
+        public List<JCExpression> getTypeArguments() { return typeargs; }
+
+        @Override
+        public <R,D> R accept(TreeVisitor<R,D> v, D d) {
+            return v.visitMemberReference(this, d);
+        }
+        @Override
+        public Tag getTag() {
+            return REFERENCE;
+        }
+    }
+
+    /**
      * An identifier
      * @param idname the name
      * @param sym the symbol
@@ -2271,6 +2371,7 @@
         public void visitApply(JCMethodInvocation that)      { visitTree(that); }
         public void visitNewClass(JCNewClass that)           { visitTree(that); }
         public void visitNewArray(JCNewArray that)           { visitTree(that); }
+        public void visitLambda(JCLambda that)               { visitTree(that); }
         public void visitParens(JCParens that)               { visitTree(that); }
         public void visitAssign(JCAssign that)               { visitTree(that); }
         public void visitAssignop(JCAssignOp that)           { visitTree(that); }
@@ -2280,6 +2381,7 @@
         public void visitTypeTest(JCInstanceOf that)         { visitTree(that); }
         public void visitIndexed(JCArrayAccess that)         { visitTree(that); }
         public void visitSelect(JCFieldAccess that)          { visitTree(that); }
+        public void visitReference(JCMemberReference that)   { visitTree(that); }
         public void visitIdent(JCIdent that)                 { visitTree(that); }
         public void visitLiteral(JCLiteral that)             { visitTree(that); }
         public void visitTypeIdent(JCPrimitiveTypeTree that) { visitTree(that); }
diff --git a/langtools/src/share/classes/com/sun/tools/javac/tree/Pretty.java b/langtools/src/share/classes/com/sun/tools/javac/tree/Pretty.java
index e781fd1..824fa59 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/Pretty.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/Pretty.java
@@ -28,6 +28,8 @@
 import java.io.*;
 import java.util.*;
 
+import com.sun.source.tree.MemberReferenceTree.ReferenceMode;
+
 import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.util.List;
 import com.sun.tools.javac.code.*;
@@ -907,6 +909,17 @@
         }
     }
 
+    public void visitLambda(JCLambda tree) {
+        try {
+            print("(");
+            printExprs(tree.params);
+            print(")->");
+            printExpr(tree.body);
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+    }
+
     public void visitParens(JCParens tree) {
         try {
             print("(");
@@ -1052,6 +1065,21 @@
         }
     }
 
+    public void visitReference(JCMemberReference tree) {
+        try {
+            printExpr(tree.expr);
+            print("#");
+            if (tree.typeargs != null) {
+                print("<");
+                printExprs(tree.typeargs);
+                print(">");
+            }
+            print(tree.getMode() == ReferenceMode.INVOKE ? tree.name : "new");
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+    }
+
     public void visitIdent(JCIdent tree) {
         try {
             print(tree.name);
diff --git a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeCopier.java b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeCopier.java
index 158abc4..f8efaa3 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeCopier.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeCopier.java
@@ -271,6 +271,13 @@
         return M.at(t.pos).NewClass(encl, typeargs, clazz, args, def);
     }
 
+    public JCTree visitLambdaExpression(LambdaExpressionTree node, P p) {
+        JCLambda t = (JCLambda) node;
+        List<JCVariableDecl> params = copy(t.params, p);
+        JCTree body = copy(t.body, p);
+        return M.at(t.pos).Lambda(params, body);
+    }
+
     public JCTree visitParenthesized(ParenthesizedTree node, P p) {
         JCParens t = (JCParens) node;
         JCExpression expr = copy(t.expr, p);
@@ -289,6 +296,13 @@
         return M.at(t.pos).Select(selected, t.name);
     }
 
+    public JCTree visitMemberReference(MemberReferenceTree node, P p) {
+        JCMemberReference t = (JCMemberReference) node;
+        JCExpression expr = copy(t.expr, p);
+        List<JCExpression> typeargs = copy(t.typeargs, p);
+        return M.at(t.pos).Reference(t.mode, t.name, expr, typeargs);
+    }
+
     public JCTree visitEmptyStatement(EmptyStatementTree node, P p) {
         JCSkip t = (JCSkip) node;
         return M.at(t.pos).Skip();
diff --git a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java
index d47d7a7..00eef07 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java
@@ -227,6 +227,34 @@
         }
     }
 
+    /**
+     * Return true if the AST corresponds to a static select of the kind A.B
+     */
+    public static boolean isStaticSelector(JCTree base, Names names) {
+        if (base == null)
+            return false;
+        switch (base.getTag()) {
+            case IDENT:
+                JCIdent id = (JCIdent)base;
+                return id.name != names._this &&
+                        id.name != names._super &&
+                        isStaticSym(base);
+            case SELECT:
+                return isStaticSym(base) &&
+                    isStaticSelector(((JCFieldAccess)base).selected, names);
+            case TYPEAPPLY:
+                return true;
+            default:
+                return false;
+        }
+    }
+    //where
+        private static boolean isStaticSym(JCTree tree) {
+            Symbol sym = symbol(tree);
+            return (sym.kind == Kinds.TYP ||
+                    sym.kind == Kinds.PCK);
+        }
+
     /** Return true if a tree represents the null literal. */
     public static boolean isNull(JCTree tree) {
         if (!tree.hasTag(LITERAL))
diff --git a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java
index 7f67302..6191f4b 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java
@@ -351,6 +351,14 @@
         return tree;
     }
 
+    public JCLambda Lambda(List<JCVariableDecl> params,
+                           JCTree body)
+    {
+        JCLambda tree = new JCLambda(params, body);
+        tree.pos = pos;
+        return tree;
+    }
+
     public JCParens Parens(JCExpression expr) {
         JCParens tree = new JCParens(expr);
         tree.pos = pos;
@@ -405,6 +413,13 @@
         return tree;
     }
 
+    public JCMemberReference Reference(JCMemberReference.ReferenceMode mode, Name name,
+            JCExpression expr, List<JCExpression> typeargs) {
+        JCMemberReference tree = new JCMemberReference(mode, name, expr, typeargs);
+        tree.pos = pos;
+        return tree;
+    }
+
     public JCIdent Ident(Name name) {
         JCIdent tree = new JCIdent(name, null);
         tree.pos = pos;
diff --git a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeScanner.java b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeScanner.java
index 1961966..9a7c321 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeScanner.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeScanner.java
@@ -212,6 +212,11 @@
         scan(tree.elems);
     }
 
+    public void visitLambda(JCLambda tree) {
+        scan(tree.body);
+        scan(tree.params);
+    }
+
     public void visitParens(JCParens tree) {
         scan(tree.expr);
     }
@@ -254,6 +259,11 @@
         scan(tree.selected);
     }
 
+    public void visitReference(JCMemberReference tree) {
+        scan(tree.expr);
+        scan(tree.typeargs);
+    }
+
     public void visitIdent(JCIdent tree) {
     }
 
diff --git a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeTranslator.java b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeTranslator.java
index f024a28..2bc9c7a 100644
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeTranslator.java
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeTranslator.java
@@ -282,6 +282,12 @@
         result = tree;
     }
 
+    public void visitLambda(JCLambda tree) {
+        tree.params = translate(tree.params);
+        tree.body = translate(tree.body);
+        result = tree;
+    }
+
     public void visitNewArray(JCNewArray tree) {
         tree.elemtype = translate(tree.elemtype);
         tree.dims = translate(tree.dims);
@@ -340,6 +346,11 @@
         result = tree;
     }
 
+    public void visitReference(JCMemberReference tree) {
+        tree.expr = translate(tree.expr);
+        result = tree;
+    }
+
     public void visitIdent(JCIdent tree) {
         result = tree;
     }
diff --git a/jdk/src/solaris/native/sun/awt/awt_PopupMenu.h b/langtools/test/tools/javac/T7120266.java
similarity index 68%
copy from jdk/src/solaris/native/sun/awt/awt_PopupMenu.h
copy to langtools/test/tools/javac/T7120266.java
index 3a6d0b7..f33db02 100644
--- a/jdk/src/solaris/native/sun/awt/awt_PopupMenu.h
+++ b/langtools/test/tools/javac/T7120266.java
@@ -1,12 +1,10 @@
 /*
- * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved.
+ * 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.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
+ * 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
@@ -23,7 +21,14 @@
  * questions.
  */
 
-/* methodsIDs for MPopupMenuPeer methods that may be accessed from C */
-struct MPopupMenuPeerIDs {
-  jmethodID destroyNativeWidgetAfterGettingTreeLock;
-};
+/*
+ * @test
+ * @bug 7120266
+ * @summary javac fails to compile hotspot code
+ * @compile T7120266.java
+ */
+
+class T7120266 {
+   void test(int i, int len) { that(i < len, "oopmap"); }
+   void that(boolean b, String s) { };
+}
diff --git a/langtools/test/tools/javac/diags/examples/CatchWithoutTry.java b/langtools/test/tools/javac/diags/examples/CatchWithoutTry.java
index 2fa7070..51eebed 100644
--- a/langtools/test/tools/javac/diags/examples/CatchWithoutTry.java
+++ b/langtools/test/tools/javac/diags/examples/CatchWithoutTry.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -23,7 +23,6 @@
 
 // key: compiler.err.catch.without.try
 // key: compiler.err.expected
-// key: compiler.err.not.stmt
 
 class CatchWithoutTry {
     void m() {
diff --git a/langtools/test/tools/javac/diags/examples/IllegalChar.java b/langtools/test/tools/javac/diags/examples/IllegalChar.java
index 003a7b0..28bf827 100644
--- a/langtools/test/tools/javac/diags/examples/IllegalChar.java
+++ b/langtools/test/tools/javac/diags/examples/IllegalChar.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -24,5 +24,5 @@
 // key: compiler.err.illegal.char
 
 class IllegalChar {
-    int i = #;
+    int i = `;
 }
diff --git a/jdk/src/solaris/native/sun/awt/awt_PopupMenu.h b/langtools/test/tools/javac/diags/examples/LambdaNotSupported.java
similarity index 68%
copy from jdk/src/solaris/native/sun/awt/awt_PopupMenu.h
copy to langtools/test/tools/javac/diags/examples/LambdaNotSupported.java
index 3a6d0b7..ea57fe4 100644
--- a/jdk/src/solaris/native/sun/awt/awt_PopupMenu.h
+++ b/langtools/test/tools/javac/diags/examples/LambdaNotSupported.java
@@ -1,12 +1,10 @@
 /*
- * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved.
+ * 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.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
+ * 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
@@ -23,7 +21,9 @@
  * questions.
  */
 
-/* methodsIDs for MPopupMenuPeer methods that may be accessed from C */
-struct MPopupMenuPeerIDs {
-  jmethodID destroyNativeWidgetAfterGettingTreeLock;
-};
+// key: compiler.err.lambda.not.supported.in.source
+// options: -source 7 -Xlint:-options
+
+class LambdaNotSupported {
+    S s = ()->{};
+}
diff --git a/jdk/src/solaris/native/sun/awt/awt_PopupMenu.h b/langtools/test/tools/javac/diags/examples/MethodReferencesNotSupported.java
similarity index 68%
copy from jdk/src/solaris/native/sun/awt/awt_PopupMenu.h
copy to langtools/test/tools/javac/diags/examples/MethodReferencesNotSupported.java
index 3a6d0b7..df31980 100644
--- a/jdk/src/solaris/native/sun/awt/awt_PopupMenu.h
+++ b/langtools/test/tools/javac/diags/examples/MethodReferencesNotSupported.java
@@ -1,12 +1,10 @@
 /*
- * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved.
+ * 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.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
+ * 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
@@ -23,7 +21,9 @@
  * questions.
  */
 
-/* methodsIDs for MPopupMenuPeer methods that may be accessed from C */
-struct MPopupMenuPeerIDs {
-  jmethodID destroyNativeWidgetAfterGettingTreeLock;
-};
+// key: compiler.err.method.references.not.supported.in.source
+// options: -source 7 -Xlint:-options
+
+class MethodReferencesNotSupported {
+    S s = A#foo;
+}
diff --git a/jdk/src/solaris/native/sun/awt/awt_PopupMenu.h b/langtools/test/tools/javac/diags/examples/NotAStatement.java
similarity index 68%
copy from jdk/src/solaris/native/sun/awt/awt_PopupMenu.h
copy to langtools/test/tools/javac/diags/examples/NotAStatement.java
index 3a6d0b7..39af85a 100644
--- a/jdk/src/solaris/native/sun/awt/awt_PopupMenu.h
+++ b/langtools/test/tools/javac/diags/examples/NotAStatement.java
@@ -1,12 +1,10 @@
 /*
- * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 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.
+ * 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
@@ -23,7 +21,10 @@
  * questions.
  */
 
-/* methodsIDs for MPopupMenuPeer methods that may be accessed from C */
-struct MPopupMenuPeerIDs {
-  jmethodID destroyNativeWidgetAfterGettingTreeLock;
-};
+// key: compiler.err.not.stmt
+
+class NotAStatement {
+    void m() {
+        x + 1;
+    }
+}
diff --git a/langtools/test/tools/javac/generics/rare/6665356/T6665356.out b/langtools/test/tools/javac/generics/rare/6665356/T6665356.out
index 62a62e6..4994352 100644
--- a/langtools/test/tools/javac/generics/rare/6665356/T6665356.out
+++ b/langtools/test/tools/javac/generics/rare/6665356/T6665356.out
@@ -1,5 +1,5 @@
 T6665356.java:17:37: compiler.err.improperly.formed.type.param.missing
 T6665356.java:18:40: compiler.err.improperly.formed.type.inner.raw.param
-T6665356.java:26:23: compiler.err.improperly.formed.type.param.missing
+T6665356.java:26:22: compiler.err.improperly.formed.type.param.missing
 T6665356.java:27:25: compiler.err.improperly.formed.type.inner.raw.param
 4 errors
diff --git a/langtools/test/tools/javac/lambda/LambdaParserTest.java b/langtools/test/tools/javac/lambda/LambdaParserTest.java
new file mode 100644
index 0000000..b686013
--- /dev/null
+++ b/langtools/test/tools/javac/lambda/LambdaParserTest.java
@@ -0,0 +1,276 @@
+/*
+ * 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 7115050
+ * @summary Add parser support for lambda expressions
+ */
+
+import com.sun.source.util.JavacTask;
+import java.net.URI;
+import java.util.Arrays;
+import javax.tools.Diagnostic;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+public class LambdaParserTest {
+
+    static int checkCount = 0;
+
+    enum LambdaKind {
+        NILARY_EXPR("()->x"),
+        NILARY_STMT("()->{ return x; }"),
+        ONEARY_SHORT_EXPR("x->x"),
+        ONEARY_SHORT_STMT("x->{ return x; }"),
+        ONEARY_EXPR("(#M1 #T1 x)->x"),
+        ONEARY_STMT("(#M1 #T1 x)->{ return x; }"),
+        TWOARY_EXPR("(#M1 #T1 x, #M2 #T2 y)->x"),
+        TWOARY_STMT("(#M1 #T1 x, #M2 #T2 y)->{ return x; }");
+
+        String lambdaTemplate;
+
+        LambdaKind(String lambdaTemplate) {
+            this.lambdaTemplate = lambdaTemplate;
+        }
+
+        String getLambdaString(LambdaParameterKind pk1, LambdaParameterKind pk2,
+                ModifierKind mk1, ModifierKind mk2) {
+            return lambdaTemplate.replaceAll("#M1", mk1.modifier)
+                    .replaceAll("#M2", mk2.modifier)
+                    .replaceAll("#T1", pk1.parameterType)
+                    .replaceAll("#T2", pk2.parameterType);
+        }
+
+        int arity() {
+            switch (this) {
+                case NILARY_EXPR:
+                case NILARY_STMT: return 0;
+                case ONEARY_SHORT_EXPR:
+                case ONEARY_SHORT_STMT:
+                case ONEARY_EXPR:
+                case ONEARY_STMT: return 1;
+                case TWOARY_EXPR:
+                case TWOARY_STMT: return 2;
+                default: throw new AssertionError("Invalid lambda kind " + this);
+            }
+        }
+
+        boolean isShort() {
+            return this == ONEARY_SHORT_EXPR ||
+                    this == ONEARY_SHORT_STMT;
+        }
+    }
+
+    enum LambdaParameterKind {
+        IMPLICIT(""),
+        EXPLIICT_SIMPLE("A"),
+        EXPLICIT_VARARGS("A..."),
+        EXPLICIT_GENERIC1("A<X>"),
+        EXPLICIT_GENERIC3("A<? extends X, ? super Y>");
+
+        String parameterType;
+
+        LambdaParameterKind(String parameterType) {
+            this.parameterType = parameterType;
+        }
+
+        boolean explicit() {
+            return this != IMPLICIT;
+        }
+    }
+
+    enum ModifierKind {
+        NONE(""),
+        FINAL("final"),
+        PUBLIC("public");
+
+        String modifier;
+
+        ModifierKind(String modifier) {
+            this.modifier = modifier;
+        }
+
+        boolean compatibleWith(LambdaParameterKind pk) {
+            switch (this) {
+                case PUBLIC: return false;
+                case FINAL: return pk != LambdaParameterKind.IMPLICIT;
+                case NONE: return true;
+                default: throw new AssertionError("Invalid modifier kind " + this);
+            }
+        }
+    }
+
+    enum ExprKind {
+        NONE("#L#S"),
+        SINGLE_PAREN1("(#L#S)"),
+        SINGLE_PAREN2("(#L)#S"),
+        DOUBLE_PAREN1("((#L#S))"),
+        DOUBLE_PAREN2("((#L)#S)"),
+        DOUBLE_PAREN3("((#L))#S");
+
+        String expressionTemplate;
+
+        ExprKind(String expressionTemplate) {
+            this.expressionTemplate = expressionTemplate;
+        }
+
+        String expressionString(LambdaParameterKind pk1, LambdaParameterKind pk2,
+                ModifierKind mk1, ModifierKind mk2, LambdaKind lk, SubExprKind sk) {
+            return expressionTemplate.replaceAll("#L", lk.getLambdaString(pk1, pk2, mk1, mk2))
+                    .replaceAll("#S", sk.subExpression);
+        }
+    }
+
+    enum SubExprKind {
+        NONE(""),
+        SELECT_FIELD(".f"),
+        SELECT_METHOD(".f()"),
+        SELECT_NEW(".new Foo()"),
+        POSTINC("++"),
+        POSTDEC("--");
+
+        String subExpression;
+
+        SubExprKind(String subExpression) {
+            this.subExpression = subExpression;
+        }
+    }
+
+    public static void main(String... args) throws Exception {
+
+        //create default shared JavaCompiler - reused across multiple compilations
+        JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
+        StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
+
+        for (LambdaKind lk : LambdaKind.values()) {
+            for (LambdaParameterKind pk1 : LambdaParameterKind.values()) {
+                if (lk.arity() < 1 && pk1 != LambdaParameterKind.IMPLICIT) continue;
+                for (LambdaParameterKind pk2 : LambdaParameterKind.values()) {
+                    if (lk.arity() < 2 && pk2 != LambdaParameterKind.IMPLICIT) continue;
+                    for (ModifierKind mk1 : ModifierKind.values()) {
+                        if (mk1 != ModifierKind.NONE && lk.isShort()) continue;
+                        if (lk.arity() < 1 && mk1 != ModifierKind.NONE) continue;
+                        for (ModifierKind mk2 : ModifierKind.values()) {
+                            if (lk.arity() < 2 && mk2 != ModifierKind.NONE) continue;
+                            for (SubExprKind sk : SubExprKind.values()) {
+                                for (ExprKind ek : ExprKind.values()) {
+                                    new LambdaParserTest(pk1, pk2, mk1, mk2, lk, sk, ek)
+                                            .run(comp, fm);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        System.out.println("Total check executed: " + checkCount);
+    }
+
+    LambdaParameterKind pk1;
+    LambdaParameterKind pk2;
+    ModifierKind mk1;
+    ModifierKind mk2;
+    LambdaKind lk;
+    SubExprKind sk;
+    ExprKind ek;
+    JavaSource source;
+    DiagnosticChecker diagChecker;
+
+    LambdaParserTest(LambdaParameterKind pk1, LambdaParameterKind pk2, ModifierKind mk1,
+            ModifierKind mk2, LambdaKind lk, SubExprKind sk, ExprKind ek) {
+        this.pk1 = pk1;
+        this.pk2 = pk2;
+        this.mk1 = mk1;
+        this.mk2 = mk2;
+        this.lk = lk;
+        this.sk = sk;
+        this.ek = ek;
+        this.source = new JavaSource();
+        this.diagChecker = new DiagnosticChecker();
+    }
+
+    class JavaSource extends SimpleJavaFileObject {
+
+        String template = "class Test {\n" +
+                          "   SAM s = #E;\n" +
+                          "}";
+
+        String source;
+
+        public JavaSource() {
+            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+            source = template.replaceAll("#E", ek.expressionString(pk1, pk2, mk1, mk2, lk, sk));
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return source;
+        }
+    }
+
+    void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception {
+        JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker,
+                Arrays.asList("-XDallowLambda"), null, Arrays.asList(source));
+        try {
+            ct.parse();
+        } catch (Throwable ex) {
+            throw new AssertionError("Error thron when parsing the following source:\n" + source.getCharContent(true));
+        }
+        check();
+    }
+
+    void check() {
+        checkCount++;
+
+        boolean errorExpected = (lk.arity() > 0 && !mk1.compatibleWith(pk1)) ||
+                (lk.arity() > 1 && !mk2.compatibleWith(pk2));
+
+        if (lk.arity() == 2 &&
+                (pk1.explicit() != pk2.explicit() ||
+                pk1 == LambdaParameterKind.EXPLICIT_VARARGS)) {
+            errorExpected = true;
+        }
+
+        if (errorExpected != diagChecker.errorFound) {
+            throw new Error("invalid diagnostics for source:\n" +
+                source.getCharContent(true) +
+                "\nFound error: " + diagChecker.errorFound +
+                "\nExpected error: " + errorExpected);
+        }
+    }
+
+    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
+
+        boolean errorFound;
+
+        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+            if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
+                errorFound = true;
+            }
+        }
+    }
+}
diff --git a/langtools/test/tools/javac/lambda/MethodReferenceParserTest.java b/langtools/test/tools/javac/lambda/MethodReferenceParserTest.java
new file mode 100644
index 0000000..00f7f33
--- /dev/null
+++ b/langtools/test/tools/javac/lambda/MethodReferenceParserTest.java
@@ -0,0 +1,234 @@
+/*
+ * 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 7115052
+ * @ignore 7120266
+ * @summary Add parser support for method references
+ */
+
+import com.sun.source.util.JavacTask;
+import java.net.URI;
+import java.util.Arrays;
+import javax.tools.Diagnostic;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+public class MethodReferenceParserTest {
+
+    static int checkCount = 0;
+
+    enum ReferenceKind {
+        METHOD_REF("#Q##Gm"),
+        CONSTRUCTOR_REF("#Q##Gnew"),
+        ERR_SUPER("#Q##Gsuper"),
+        ERR_METH0("#Q##Gm()"),
+        ERR_METH1("#Q##Gm(X)"),
+        ERR_CONSTR0("#Q##Gnew()"),
+        ERR_CONSTR1("#Q##Gnew(X)");
+
+        String referenceTemplate;
+
+        ReferenceKind(String referenceTemplate) {
+            this.referenceTemplate = referenceTemplate;
+        }
+
+        String getReferenceString(QualifierKind qk, GenericKind gk) {
+            return referenceTemplate
+                    .replaceAll("#Q", qk.qualifier)
+                    .replaceAll("#G", gk.typeParameters);
+        }
+
+        boolean erroneous() {
+            switch (this) {
+                case ERR_SUPER:
+                case ERR_METH0:
+                case ERR_METH1:
+                case ERR_CONSTR0:
+                case ERR_CONSTR1:
+                    return true;
+                default: return false;
+            }
+        }
+    }
+
+    enum GenericKind {
+        NONE(""),
+        ONE("<X>"),
+        TWO("<X,Y>");
+
+        String typeParameters;
+
+        GenericKind(String typeParameters) {
+            this.typeParameters = typeParameters;
+        }
+    }
+
+    enum QualifierKind {
+        THIS("this"),
+        SUPER("super"),
+        NEW("new Foo()"),
+        METHOD("m()"),
+        FIELD("a.f"),
+        UBOUND_SIMPLE("A"),
+        UNBOUND_GENERIC1("A<X>"),
+        UNBOUND_GENERIC2("A<X, Y>"),
+        UNBOUND_GENERIC3("A<? extends X, ? super Y>");
+
+        String qualifier;
+
+        QualifierKind(String qualifier) {
+            this.qualifier = qualifier;
+        }
+    }
+
+    enum ExprKind {
+        NONE("#R#S"),
+        SINGLE_PAREN1("(#R#S)"),
+        SINGLE_PAREN2("(#R)#S"),
+        DOUBLE_PAREN1("((#R#S))"),
+        DOUBLE_PAREN2("((#R)#S)"),
+        DOUBLE_PAREN3("((#R))#S");
+
+        String expressionTemplate;
+
+        ExprKind(String expressionTemplate) {
+            this.expressionTemplate = expressionTemplate;
+        }
+
+        String expressionString(ReferenceKind rk, QualifierKind qk, GenericKind gk, SubExprKind sk) {
+            return expressionTemplate
+                    .replaceAll("#R", rk.getReferenceString(qk, gk))
+                    .replaceAll("#S", sk.subExpression);
+        }
+    }
+
+    enum SubExprKind {
+        NONE(""),
+        SELECT_FIELD(".f"),
+        SELECT_METHOD(".f()"),
+        SELECT_NEW(".new Foo()"),
+        POSTINC("++"),
+        POSTDEC("--");
+
+        String subExpression;
+
+        SubExprKind(String subExpression) {
+            this.subExpression = subExpression;
+        }
+    }
+
+    public static void main(String... args) throws Exception {
+
+        //create default shared JavaCompiler - reused across multiple compilations
+        JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
+        StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
+
+        for (ReferenceKind rk : ReferenceKind.values()) {
+            for (QualifierKind qk : QualifierKind.values()) {
+                for (GenericKind gk : GenericKind.values()) {
+                    for (SubExprKind sk : SubExprKind.values()) {
+                        for (ExprKind ek : ExprKind.values()) {
+                            new MethodReferenceParserTest(rk, qk, gk, sk, ek).run(comp, fm);
+                        }
+                    }
+                }
+            }
+        }
+        System.out.println("Total check executed: " + checkCount);
+    }
+
+    ReferenceKind rk;
+    QualifierKind qk;
+    GenericKind gk;
+    SubExprKind sk;
+    ExprKind ek;
+    JavaSource source;
+    DiagnosticChecker diagChecker;
+
+    MethodReferenceParserTest(ReferenceKind rk, QualifierKind qk, GenericKind gk, SubExprKind sk, ExprKind ek) {
+        this.rk = rk;
+        this.qk = qk;
+        this.gk = gk;
+        this.sk = sk;
+        this.ek = ek;
+        this.source = new JavaSource();
+        this.diagChecker = new DiagnosticChecker();
+    }
+
+    class JavaSource extends SimpleJavaFileObject {
+
+        String template = "class Test {\n" +
+                          "   SAM s = #E;\n" +
+                          "}";
+
+        String source;
+
+        public JavaSource() {
+            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+            source = template.replaceAll("#E", ek.expressionString(rk, qk, gk, sk));
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return source;
+        }
+    }
+
+    void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception {
+        JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker,
+                Arrays.asList("-XDallowMethodReferences"), null, Arrays.asList(source));
+        try {
+            ct.parse();
+        } catch (Throwable ex) {
+            throw new AssertionError("Error thrown when parsing the following source:\n" + source.getCharContent(true));
+        }
+        check();
+    }
+
+    void check() {
+        checkCount++;
+
+        if (diagChecker.errorFound != rk.erroneous()) {
+            throw new Error("invalid diagnostics for source:\n" +
+                source.getCharContent(true) +
+                "\nFound error: " + diagChecker.errorFound +
+                "\nExpected error: " + rk.erroneous());
+        }
+    }
+
+    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
+
+        boolean errorFound;
+
+        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+            if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
+                errorFound = true;
+            }
+        }
+    }
+}
diff --git a/langtools/test/tools/javac/parser/netbeans/JavacParserTest.java b/langtools/test/tools/javac/parser/JavacParserTest.java
similarity index 78%
rename from langtools/test/tools/javac/parser/netbeans/JavacParserTest.java
rename to langtools/test/tools/javac/parser/JavacParserTest.java
index 79ce213..7cfd007 100644
--- a/langtools/test/tools/javac/parser/netbeans/JavacParserTest.java
+++ b/langtools/test/tools/javac/parser/JavacParserTest.java
@@ -25,13 +25,14 @@
  * @test
  * @bug 7073631
  * @summary tests error and diagnostics positions
- * @author  jan.lahoda@oracle.com
+ * @author  Jan Lahoda
  */
 
 import com.sun.source.tree.BinaryTree;
 import com.sun.source.tree.BlockTree;
 import com.sun.source.tree.ClassTree;
 import com.sun.source.tree.CompilationUnitTree;
+import com.sun.source.tree.ErroneousTree;
 import com.sun.source.tree.ExpressionStatementTree;
 import com.sun.source.tree.ExpressionTree;
 import com.sun.source.tree.MethodInvocationTree;
@@ -49,6 +50,7 @@
 import com.sun.tools.javac.tree.JCTree;
 import java.io.IOException;
 import java.net.URI;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.LinkedList;
 import java.util.List;
@@ -81,6 +83,34 @@
             return text;
         }
     }
+    /*
+     * converts Windows to Unix style LFs for comparing strings
+     */
+    private String normalize(String in) {
+        return in.replace(System.getProperty("line.separator"), "\n");
+    }
+
+    public CompilationUnitTree getCompilationUnitTree(String code) throws IOException {
+
+        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
+                null, Arrays.asList(new MyFileObject(code)));
+        CompilationUnitTree cut = ct.parse().iterator().next();
+        return cut;
+    }
+
+    public List<String> getErroneousTreeValues(ErroneousTree node) {
+
+        List<String> values = new ArrayList<>();
+        if (node.getErrorTrees() != null) {
+            for (Tree t : node.getErrorTrees()) {
+                values.add(t.toString());
+            }
+        } else {
+            throw new RuntimeException("ERROR: No Erroneous tree "
+                    + "has been created.");
+        }
+        return values;
+    }
 
     public void testPositionForSuperConstructorCalls() throws IOException {
         assert tool != null;
@@ -97,22 +127,28 @@
         ExpressionStatementTree es =
                 (ExpressionStatementTree) method.getBody().getStatements().get(0);
 
+        final int esStartPos = code.indexOf(es.toString());
+        final int esEndPos = esStartPos + es.toString().length();
         assertEquals("testPositionForSuperConstructorCalls",
-                72 - 24, pos.getStartPosition(cut, es));
+                esStartPos, pos.getStartPosition(cut, es));
         assertEquals("testPositionForSuperConstructorCalls",
-                80 - 24, pos.getEndPosition(cut, es));
+                esEndPos, pos.getEndPosition(cut, es));
 
         MethodInvocationTree mit = (MethodInvocationTree) es.getExpression();
 
+        final int mitStartPos = code.indexOf(mit.toString());
+        final int mitEndPos = mitStartPos + mit.toString().length();
         assertEquals("testPositionForSuperConstructorCalls",
-                72 - 24, pos.getStartPosition(cut, mit));
+                mitStartPos, pos.getStartPosition(cut, mit));
         assertEquals("testPositionForSuperConstructorCalls",
-                79 - 24, pos.getEndPosition(cut, mit));
+                mitEndPos, pos.getEndPosition(cut, mit));
 
+        final int methodStartPos = mitStartPos;
+        final int methodEndPos = methodStartPos + mit.getMethodSelect().toString().length();
         assertEquals("testPositionForSuperConstructorCalls",
-                72 - 24, pos.getStartPosition(cut, mit.getMethodSelect()));
+                methodStartPos, pos.getStartPosition(cut, mit.getMethodSelect()));
         assertEquals("testPositionForSuperConstructorCalls",
-                77 - 24, pos.getEndPosition(cut, mit.getMethodSelect()));
+                methodEndPos, pos.getEndPosition(cut, mit.getMethodSelect()));
 
     }
 
@@ -158,24 +194,21 @@
 
     public void testPreferredPositionForBinaryOp() throws IOException {
 
-        String code = "package test; public class Test {" +
-                "private void test() {" +
-                "Object o = null; boolean b = o != null && o instanceof String;" +
-                "} private Test() {}}";
+        String code = "package test; public class Test {"
+                + "private void test() {"
+                + "Object o = null; boolean b = o != null && o instanceof String;"
+                + "} private Test() {}}";
 
-        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
-                null, Arrays.asList(new MyFileObject(code)));
-        CompilationUnitTree cut = ct.parse().iterator().next();
-
+        CompilationUnitTree cut = getCompilationUnitTree(code);
         ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
         MethodTree method = (MethodTree) clazz.getMembers().get(0);
         VariableTree condSt = (VariableTree) method.getBody().getStatements().get(1);
         BinaryTree cond = (BinaryTree) condSt.getInitializer();
 
         JCTree condJC = (JCTree) cond;
-
-        assertEquals("testNewClassWithEnclosing",
-                117 - 24, condJC.pos);
+        int condStartPos = code.indexOf("&&");
+        assertEquals("testPreferredPositionForBinaryOp",
+                condStartPos, condJC.pos);
     }
 
     public void testPositionBrokenSource126732a() throws IOException {
@@ -599,9 +632,7 @@
         final String code = "package t; class Test { " +
                 "{ try (java.io.InputStream in = null) { } } }";
 
-        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
-                null, Arrays.asList(new MyFileObject(code)));
-        CompilationUnitTree cut = ct.parse().iterator().next();
+        CompilationUnitTree cut = getCompilationUnitTree(code);
 
         new TreeScanner<Void, Void>() {
             @Override
@@ -622,9 +653,7 @@
         final String code = "package t; class Test { " +
                 "{ java.io.InputStream in = null; } }";
 
-        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
-                null, Arrays.asList(new MyFileObject(code)));
-        CompilationUnitTree cut = ct.parse().iterator().next();
+        CompilationUnitTree cut = getCompilationUnitTree(code);
 
         new TreeScanner<Void, Void>() {
 
@@ -640,6 +669,138 @@
         }.scan(cut, null);
     }
 
+    // expected erroneous tree: int x = y;(ERROR);
+    public void testOperatorMissingError() throws IOException {
+
+        String code = "package test; public class ErrorTest { "
+                + "void method() { int x = y  z } }";
+        CompilationUnitTree cut = getCompilationUnitTree(code);
+        final List<String> values = new ArrayList<>();
+        final List<String> expectedValues =
+                new ArrayList<>(Arrays.asList("[z]"));
+
+        new TreeScanner<Void, Void>() {
+
+            @Override
+            public Void visitErroneous(ErroneousTree node, Void p) {
+
+                values.add(getErroneousTreeValues(node).toString());
+                return null;
+
+            }
+        }.scan(cut, null);
+
+        assertEquals("testSwitchError: The Erroneous tree "
+                + "error values: " + values
+                + " do not match expected error values: "
+                + expectedValues, values, expectedValues);
+    }
+
+    //expected erroneous tree:  String s = (ERROR);
+    public void testMissingParenthesisError() throws IOException {
+
+        String code = "package test; public class ErrorTest { "
+                + "void f() {String s = new String; } }";
+        CompilationUnitTree cut = getCompilationUnitTree(code);
+        final List<String> values = new ArrayList<>();
+        final List<String> expectedValues =
+                new ArrayList<>(Arrays.asList("[new String()]"));
+
+        new TreeScanner<Void, Void>() {
+
+            @Override
+            public Void visitErroneous(ErroneousTree node, Void p) {
+
+                values.add(getErroneousTreeValues(node).toString());
+                return null;
+            }
+        }.scan(cut, null);
+
+        assertEquals("testSwitchError: The Erroneous tree "
+                + "error values: " + values
+                + " do not match expected error values: "
+                + expectedValues, values, expectedValues);
+    }
+
+    //expected erroneous tree: package test; (ERROR)(ERROR)
+    public void testMissingClassError() throws IOException {
+
+        String code = "package Test; clas ErrorTest {  "
+                + "void f() {String s = new String(); } }";
+        CompilationUnitTree cut = getCompilationUnitTree(code);
+        final List<String> values = new ArrayList<>();
+        final List<String> expectedValues =
+                new ArrayList<>(Arrays.asList("[, clas]", "[]"));
+
+        new TreeScanner<Void, Void>() {
+
+            @Override
+            public Void visitErroneous(ErroneousTree node, Void p) {
+
+                values.add(getErroneousTreeValues(node).toString());
+                return null;
+            }
+        }.scan(cut, null);
+
+        assertEquals("testSwitchError: The Erroneous tree "
+                + "error values: " + values
+                + " do not match expected error values: "
+                + expectedValues, values, expectedValues);
+    }
+
+    //expected erroneous tree: void m1(int i) {(ERROR);{(ERROR);}
+    public void testSwitchError() throws IOException {
+
+        String code = "package test; public class ErrorTest { "
+                + "int numDays; void m1(int i) { switchh {i} { case 1: "
+                + "numDays = 31; break; } } }";
+        CompilationUnitTree cut = getCompilationUnitTree(code);
+        final List<String> values = new ArrayList<>();
+        final List<String> expectedValues =
+                new ArrayList<>(Arrays.asList("[switchh]", "[i]"));
+
+        new TreeScanner<Void, Void>() {
+
+            @Override
+            public Void visitErroneous(ErroneousTree node, Void p) {
+
+                values.add(getErroneousTreeValues(node).toString());
+                return null;
+            }
+        }.scan(cut, null);
+
+        assertEquals("testSwitchError: The Erroneous tree "
+                + "error values: " + values
+                + " do not match expected error values: "
+                + expectedValues, values, expectedValues);
+    }
+
+    //expected erroneous tree: class ErrorTest {(ERROR)
+    public void testMethodError() throws IOException {
+
+        String code = "package Test; class ErrorTest {  "
+                + "static final void f) {String s = new String(); } }";
+        CompilationUnitTree cut = getCompilationUnitTree(code);
+        final List<String> values = new ArrayList<>();
+        final List<String> expectedValues =
+                new ArrayList<>(Arrays.asList("[\nstatic final void f();]"));
+
+        new TreeScanner<Void, Void>() {
+
+            @Override
+            public Void visitErroneous(ErroneousTree node, Void p) {
+
+                values.add(normalize(getErroneousTreeValues(node).toString()));
+                return null;
+            }
+        }.scan(cut, null);
+
+        assertEquals("testMethodError: The Erroneous tree "
+                + "error value: " + values
+                + " does not match expected error values: "
+                + expectedValues, values, expectedValues);
+    }
+
     void testsNotWorking() throws IOException {
 
         // Fails with nb-javac, needs further investigation
@@ -661,7 +822,13 @@
         testStartPositionForMethodWithoutModifiers();
         testVarPos();
         testVariableInIfThen3();
+        testMissingExponent();
         testTryResourcePos();
+        testOperatorMissingError();
+        testMissingParenthesisError();
+        testMissingClassError();
+        testSwitchError();
+        testMethodError();
     }
 
     public static void main(String... args) throws IOException {
diff --git a/langtools/test/tools/javac/quid/T6999438.out b/langtools/test/tools/javac/quid/T6999438.out
index cd62668..04fdcfa 100644
--- a/langtools/test/tools/javac/quid/T6999438.out
+++ b/langtools/test/tools/javac/quid/T6999438.out
@@ -1,4 +1,4 @@
-T6999438.java:8:9: compiler.err.illegal.char: 35
+T6999438.java:8:8: compiler.err.expected: token.identifier
 T6999438.java:8:10: compiler.err.illegal.start.of.type
 T6999438.java:8:25: compiler.err.expected: token.identifier
 T6999438.java:8:26: compiler.err.expected: ';'