--- a/.hgtags Thu Dec 15 15:47:47 2011 -0800
+++ b/.hgtags Thu Dec 15 15:57:51 2011 -0800
@@ -137,3 +137,4 @@
4cc0ef72c812943743ef4765f1100e2fbe2b1a08 jdk8-b13
9ffaa48dbfb0f5936c2b789867d0785faec7071d jdk8-b14
b5060eae3b32fd9f884a09774338cd8186d7fafa jdk8-b15
+736a63b854f321c7824b7e47890135f80aee05e3 jdk8-b16
--- a/jdk/make/common/Defs-embedded.gmk Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/make/common/Defs-embedded.gmk Thu Dec 15 15:57:51 2011 -0800
@@ -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
--- a/jdk/make/common/Defs.gmk Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/make/common/Defs.gmk Thu Dec 15 15:57:51 2011 -0800
@@ -202,7 +202,7 @@
#
# zlib version
#
-ZLIB_VERSION = 1.2.3
+ZLIB_VERSION = 1.2.5
#
--- a/jdk/make/common/Rules.gmk Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/make/common/Rules.gmk Thu Dec 15 15:57:51 2011 -0800
@@ -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::
--- a/jdk/make/java/zip/FILES_c.gmk Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/make/java/zip/FILES_c.gmk Thu Dec 15 15:57:51 2011 -0800
@@ -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 \
--- a/jdk/make/java/zip/mapfile-vers Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/make/java/zip/mapfile-vers Thu Dec 15 15:57:51 2011 -0800
@@ -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;
--- a/jdk/make/sun/awt/FILES_c_unix.gmk Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/make/sun/awt/FILES_c_unix.gmk Thu Dec 15 15:57:51 2011 -0800
@@ -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 \
--- a/jdk/make/sun/awt/FILES_export_unix.gmk Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/make/sun/awt/FILES_export_unix.gmk Thu Dec 15 15:57:51 2011 -0800
@@ -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 \
--- a/jdk/make/sun/awt/mapfile-mawt-vers Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/make/sun/awt/mapfile-mawt-vers Thu Dec 15 15:57:51 2011 -0800
@@ -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;
--- a/jdk/make/sun/awt/mapfile-vers-linux Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/make/sun/awt/mapfile-vers-linux Thu Dec 15 15:57:51 2011 -0800
@@ -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;
--- a/jdk/make/sun/awt/mawt.gmk Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/make/sun/awt/mawt.gmk Thu Dec 15 15:57:51 2011 -0800
@@ -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)
--- a/jdk/make/sun/motif12/reorder-i586 Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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;
--- a/jdk/make/sun/motif12/reorder-sparc Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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;
--- a/jdk/make/sun/motif12/reorder-sparcv9 Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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;
--- a/jdk/make/sun/splashscreen/FILES_c.gmk Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/make/sun/splashscreen/FILES_c.gmk Thu Dec 15 15:57:51 2011 -0800
@@ -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 \
--- a/jdk/make/sun/xawt/mapfile-vers Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/make/sun/xawt/mapfile-vers Thu Dec 15 15:57:51 2011 -0800
@@ -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;
--- a/jdk/src/share/classes/com/sun/beans/finder/AbstractFinder.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/com/sun/beans/finder/AbstractFinder.java Thu Dec 15 15:57:51 2011 -0800
@@ -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
--- a/jdk/src/share/classes/com/sun/beans/finder/ConstructorFinder.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/com/sun/beans/finder/ConstructorFinder.java Thu Dec 15 15:57:51 2011 -0800
@@ -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
--- a/jdk/src/share/classes/com/sun/beans/finder/MethodFinder.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/com/sun/beans/finder/MethodFinder.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
}
}
--- a/jdk/src/share/classes/com/sun/media/sound/JSSecurityManager.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/com/sun/media/sound/JSSecurityManager.java Thu Dec 15 15:57:51 2011 -0800
@@ -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
--- a/jdk/src/share/classes/com/sun/net/httpserver/spi/HttpServerProvider.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/com/sun/net/httpserver/spi/HttpServerProvider.java Thu Dec 15 15:57:51 2011 -0800
@@ -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
--- a/jdk/src/share/classes/com/sun/rowset/CachedRowSetImpl.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/com/sun/rowset/CachedRowSetImpl.java Thu Dec 15 15:57:51 2011 -0800
@@ -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++;
--- a/jdk/src/share/classes/com/sun/rowset/FilteredRowSetImpl.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/com/sun/rowset/FilteredRowSetImpl.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
}
--- a/jdk/src/share/classes/com/sun/rowset/JdbcRowSetImpl.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/com/sun/rowset/JdbcRowSetImpl.java Thu Dec 15 15:57:51 2011 -0800
@@ -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.
--- a/jdk/src/share/classes/com/sun/rowset/JdbcRowSetResourceBundle.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/com/sun/rowset/JdbcRowSetResourceBundle.java Thu Dec 15 15:57:51 2011 -0800
@@ -135,6 +135,7 @@
* @return an enumeration of keys which have messages tranlated to
* corresponding locales.
*/
+ @SuppressWarnings("rawtypes")
public Enumeration getKeys() {
return propResBundle.getKeys();
}
--- a/jdk/src/share/classes/com/sun/rowset/JoinRowSetImpl.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/com/sun/rowset/JoinRowSetImpl.java Thu Dec 15 15:57:51 2011 -0800
@@ -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();
}
--- a/jdk/src/share/classes/com/sun/rowset/WebRowSetImpl.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/com/sun/rowset/WebRowSetImpl.java Thu Dec 15 15:57:51 2011 -0800
@@ -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();
--- a/jdk/src/share/classes/com/sun/rowset/internal/CachedRowSetReader.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/com/sun/rowset/internal/CachedRowSetReader.java Thu Dec 15 15:57:51 2011 -0800
@@ -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());
}
--- a/jdk/src/share/classes/com/sun/rowset/internal/CachedRowSetWriter.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/com/sun/rowset/internal/CachedRowSetWriter.java Thu Dec 15 15:57:51 2011 -0800
@@ -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
--- a/jdk/src/share/classes/com/sun/rowset/internal/Row.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/com/sun/rowset/internal/Row.java Thu Dec 15 15:57:51 2011 -0800
@@ -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;
--- a/jdk/src/share/classes/com/sun/rowset/internal/SyncResolverImpl.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/com/sun/rowset/internal/SyncResolverImpl.java Thu Dec 15 15:57:51 2011 -0800
@@ -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();
}
--- a/jdk/src/share/classes/com/sun/rowset/internal/WebRowSetXmlWriter.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/com/sun/rowset/internal/WebRowSetXmlWriter.java Thu Dec 15 15:57:51 2011 -0800
@@ -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 {
--- a/jdk/src/share/classes/com/sun/rowset/internal/XmlReaderContentHandler.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/com/sun/rowset/internal/XmlReaderContentHandler.java Thu Dec 15 15:57:51 2011 -0800
@@ -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:
--- a/jdk/src/share/classes/java/applet/Applet.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/applet/Applet.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
}
--- a/jdk/src/share/classes/java/awt/Component.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/awt/Component.java Thu Dec 15 15:57:51 2011 -0800
@@ -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();
--- a/jdk/src/share/classes/java/awt/Container.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/awt/Container.java Thu Dec 15 15:57:51 2011 -0800
@@ -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();
}
--- a/jdk/src/share/classes/java/awt/font/StyledParagraph.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/awt/font/StyledParagraph.java Thu Dec 15 15:57:51 2011 -0800
@@ -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) {
--- a/jdk/src/share/classes/java/awt/font/TextAttribute.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/awt/font/TextAttribute.java Thu Dec 15 15:57:51 2011 -0800
@@ -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 {
--- a/jdk/src/share/classes/java/awt/font/TextLayout.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/awt/font/TextLayout.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
--- a/jdk/src/share/classes/java/awt/font/TextLine.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/awt/font/TextLine.java Thu Dec 15 15:57:51 2011 -0800
@@ -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;
--- a/jdk/src/share/classes/java/awt/font/TextMeasurer.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/awt/font/TextMeasurer.java Thu Dec 15 15:57:51 2011 -0800
@@ -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();
}
--- a/jdk/src/share/classes/java/awt/geom/Path2D.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/awt/geom/Path2D.java Thu Dec 15 15:57:51 2011 -0800
@@ -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)
--- a/jdk/src/share/classes/java/awt/im/InputMethodHighlight.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/awt/im/InputMethodHighlight.java Thu Dec 15 15:57:51 2011 -0800
@@ -190,6 +190,6 @@
private boolean selected;
private int state;
private int variation;
- private Map style;
+ private Map<TextAttribute, ?> style;
};
--- a/jdk/src/share/classes/java/beans/BeanDescriptor.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/beans/BeanDescriptor.java Thu Dec 15 15:57:51 2011 -0800
@@ -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) {
--- a/jdk/src/share/classes/java/beans/Beans.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/beans/Beans.java Thu Dec 15 15:57:51 2011 -0800
@@ -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;
}
--- a/jdk/src/share/classes/java/beans/ChangeListenerMap.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/beans/ChangeListenerMap.java Thu Dec 15 15:57:51 2011 -0800
@@ -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();
}
--- a/jdk/src/share/classes/java/beans/DefaultPersistenceDelegate.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/beans/DefaultPersistenceDelegate.java Thu Dec 15 15:57:51 2011 -0800
@@ -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()))
--- a/jdk/src/share/classes/java/beans/Encoder.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/beans/Encoder.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
}
--- a/jdk/src/share/classes/java/beans/EventHandler.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/beans/EventHandler.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
}
}
--- a/jdk/src/share/classes/java/beans/EventSetDescriptor.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/beans/EventSetDescriptor.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
}
--- a/jdk/src/share/classes/java/beans/FeatureDescriptor.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/beans/FeatureDescriptor.java Thu Dec 15 15:57:51 2011 -0800
@@ -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());
}
--- a/jdk/src/share/classes/java/beans/IndexedPropertyDescriptor.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/beans/IndexedPropertyDescriptor.java Thu Dec 15 15:57:51 2011 -0800
@@ -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: "
--- a/jdk/src/share/classes/java/beans/Introspector.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/beans/Introspector.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
}
/**
--- a/jdk/src/share/classes/java/beans/MetaData.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/beans/MetaData.java Thu Dec 15 15:57:51 2011 -0800
@@ -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) {
--- a/jdk/src/share/classes/java/beans/MethodDescriptor.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/beans/MethodDescriptor.java Thu Dec 15 15:57:51 2011 -0800
@@ -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 {
--- a/jdk/src/share/classes/java/beans/NameGenerator.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/beans/NameGenerator.java Thu Dec 15 15:57:51 2011 -0800
@@ -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;
--- a/jdk/src/share/classes/java/beans/PersistenceDelegate.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/beans/PersistenceDelegate.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
}
--- a/jdk/src/share/classes/java/beans/PropertyChangeEvent.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/beans/PropertyChangeEvent.java Thu Dec 15 15:57:51 2011 -0800
@@ -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;
--- a/jdk/src/share/classes/java/beans/PropertyChangeSupport.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/beans/PropertyChangeSupport.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
--- a/jdk/src/share/classes/java/beans/PropertyDescriptor.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/beans/PropertyDescriptor.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
--- a/jdk/src/share/classes/java/beans/PropertyEditorManager.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/beans/PropertyEditorManager.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
}
}
--- a/jdk/src/share/classes/java/beans/PropertyEditorSupport.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/beans/PropertyEditorSupport.java Thu Dec 15 15:57:51 2011 -0800
@@ -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;
}
--- a/jdk/src/share/classes/java/beans/ReflectionUtils.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/beans/ReflectionUtils.java Thu Dec 15 15:57:51 2011 -0800
@@ -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 {
--- a/jdk/src/share/classes/java/beans/SimpleBeanInfo.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/beans/SimpleBeanInfo.java Thu Dec 15 15:57:51 2011 -0800
@@ -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) {
--- a/jdk/src/share/classes/java/beans/Statement.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/beans/Statement.java Thu Dec 15 15:57:51 2011 -0800
@@ -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();
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/java/beans/ThreadGroupContext.java Thu Dec 15 15:57:51 2011 -0800
@@ -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;
+ }
+}
--- a/jdk/src/share/classes/java/beans/VetoableChangeSupport.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/beans/VetoableChangeSupport.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
--- a/jdk/src/share/classes/java/beans/XMLEncoder.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/beans/XMLEncoder.java Thu Dec 15 15:57:51 2011 -0800
@@ -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();
--- a/jdk/src/share/classes/java/beans/beancontext/BeanContext.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/beans/beancontext/BeanContext.java Thu Dec 15 15:57:51 2011 -0800
@@ -53,6 +53,7 @@
* @see java.util.Collection
*/
+@SuppressWarnings("rawtypes")
public interface BeanContext extends BeanContextChild, Collection, DesignMode, Visibility {
/**
--- a/jdk/src/share/classes/java/beans/beancontext/BeanContextMembershipEvent.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/beans/beancontext/BeanContextMembershipEvent.java Thu Dec 15 15:57:51 2011 -0800
@@ -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;
}
--- a/jdk/src/share/classes/java/io/ExpiringCache.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/io/ExpiringCache.java Thu Dec 15 15:57:51 2011 -0800
@@ -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++) {
--- a/jdk/src/share/classes/java/io/File.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/io/File.java Thu Dec 15 15:57:51 2011 -0800
@@ -2006,7 +2006,7 @@
throws IOException
{
s.defaultWriteObject();
- s.writeChar(this.separatorChar); // Add the separator character
+ s.writeChar(separatorChar); // Add the separator character
}
/**
--- a/jdk/src/share/classes/java/io/LineNumberInputStream.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/io/LineNumberInputStream.java Thu Dec 15 15:57:51 2011 -0800
@@ -87,6 +87,7 @@
* @see java.io.FilterInputStream#in
* @see java.io.LineNumberInputStream#getLineNumber()
*/
+ @SuppressWarnings("fallthrough")
public int read() throws IOException {
int c = pushBack;
--- a/jdk/src/share/classes/java/io/LineNumberReader.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/io/LineNumberReader.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
--- a/jdk/src/share/classes/java/io/ObjectInputStream.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/io/ObjectInputStream.java Thu Dec 15 15:57:51 2011 -0800
@@ -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
}
--- a/jdk/src/share/classes/java/io/ObjectOutputStream.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/io/ObjectOutputStream.java Thu Dec 15 15:57:51 2011 -0800
@@ -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 +
--- a/jdk/src/share/classes/java/io/ObjectStreamClass.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/io/ObjectStreamClass.java Thu Dec 15 15:57:51 2011 -0800
@@ -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(
--- a/jdk/src/share/classes/java/io/RandomAccessFile.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/io/RandomAccessFile.java Thu Dec 15 15:57:51 2011 -0800
@@ -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];
--- a/jdk/src/share/classes/java/io/SequenceInputStream.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/io/SequenceInputStream.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
--- a/jdk/src/share/classes/java/lang/ClassLoader.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/lang/ClassLoader.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
--- a/jdk/src/share/classes/java/lang/Enum.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/lang/Enum.java Thu Dec 15 15:57:51 2011 -0800
@@ -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;
}
/**
--- a/jdk/src/share/classes/java/lang/Package.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/lang/Package.java Thu Dec 15 15:57:51 2011 -0800
@@ -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;
}
--- a/jdk/src/share/classes/java/lang/Runtime.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/lang/Runtime.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
--- a/jdk/src/share/classes/java/lang/SecurityManager.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/lang/SecurityManager.java Thu Dec 15 15:57:51 2011 -0800
@@ -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
--- a/jdk/src/share/classes/java/lang/String.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/lang/String.java Thu Dec 15 15:57:51 2011 -0800
@@ -1245,6 +1245,9 @@
}
return n1 - n2;
}
+
+ /** Replaces the de-serialized object. */
+ private Object readResolve() { return CASE_INSENSITIVE_ORDER; }
}
/**
--- a/jdk/src/share/classes/java/lang/System.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/lang/System.java Thu Dec 15 15:57:51 2011 -0800
@@ -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>>
--- a/jdk/src/share/classes/java/lang/Thread.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/lang/Thread.java Thu Dec 15 15:57:51 2011 -0800
@@ -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) {
--- a/jdk/src/share/classes/java/lang/ThreadGroup.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/lang/ThreadGroup.java Thu Dec 15 15:57:51 2011 -0800
@@ -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;
--- a/jdk/src/share/classes/java/lang/instrument/ClassDefinition.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/lang/instrument/ClassDefinition.java Thu Dec 15 15:57:51 2011 -0800
@@ -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
--- a/jdk/src/share/classes/java/lang/management/ManagementFactory.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/lang/management/ManagementFactory.java Thu Dec 15 15:57:51 2011 -0800
@@ -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 =
--- a/jdk/src/share/classes/java/lang/management/PlatformComponent.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/lang/management/PlatformComponent.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
}
--- a/jdk/src/share/classes/java/net/HttpCookie.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/net/HttpCookie.java Thu Dec 15 15:57:51 2011 -0800
@@ -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.
- *
- * @return a <code>String</code> containing the comment,
- * or <code>null</code> if none
+ * {@code null} if the cookie has no comment.
*
- * @see #setComment
+ * @return a {@code String} containing the comment, or {@code null} if none
*
+ * @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</code> specifying the comment url
- * to display to the user
+ * @param purpose
+ * a {@code String} 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</code> containing the domain name
- * within which this cookie is visible;
- * form is according to RFC 2965
+ * @param pattern
+ * a {@code String} 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.
- *
- * @return a <code>String</code> containing the domain name
+ * Returns the domain name set for this cookie. The form of the domain name
+ * is set by RFC 2965.
*
- * @see #setDomain
+ * @return a {@code String} containing the domain name
*
+ * @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</code> specifying a path
- *
+ * @param uri
+ * a {@code String} 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</code> specifying a path that contains
- * a servlet name, for example, <i>/catalog</i>
+ * @return a {@code String} 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 <tt>v</tt> is neither 0 nor 1
+ * @throws IllegalArgumentException
+ * if {@code v} 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>
- * or = hostname.local if not
+ *
+ * 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.
- *
- * @param value the <code>String</code> to be tested
+ * Tests a string and returns true if the string counts as a token.
*
- * @return <code>true</code> if the <code>String</code> is
- * a token; <code>false</code> if it is not
+ * @param value
+ * the {@code String} to be tested
+ *
+ * @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;
}
--- a/jdk/src/share/classes/java/net/InetAddress.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/net/InetAddress.java Thu Dec 15 15:57:51 2011 -0800
@@ -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.
--- a/jdk/src/share/classes/java/rmi/MarshalledObject.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/rmi/MarshalledObject.java Thu Dec 15 15:57:51 2011 -0800
@@ -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)
--- a/jdk/src/share/classes/java/rmi/dgc/VMID.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/rmi/dgc/VMID.java Thu Dec 15 15:57:51 2011 -0800
@@ -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));
}
--- a/jdk/src/share/classes/java/rmi/server/LogStream.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/rmi/server/LogStream.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
}
--- a/jdk/src/share/classes/java/rmi/server/RemoteObject.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/rmi/server/RemoteObject.java Thu Dec 15 15:57:51 2011 -0800
@@ -436,7 +436,7 @@
*/
String internalRefClassName =
RemoteRef.packagePrefix + "." + refClassName;
- Class refClass = Class.forName(internalRefClassName);
+ Class<?> refClass = Class.forName(internalRefClassName);
try {
ref = (RemoteRef) refClass.newInstance();
--- a/jdk/src/share/classes/java/sql/Date.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/sql/Date.java Thu Dec 15 15:57:51 2011 -0800
@@ -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;
--- a/jdk/src/share/classes/java/sql/DriverManager.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/sql/DriverManager.java Thu Dec 15 15:57:51 2011 -0800
@@ -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 + "]");
}
--- a/jdk/src/share/classes/java/sql/Time.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/sql/Time.java Thu Dec 15 15:57:51 2011 -0800
@@ -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();
--- a/jdk/src/share/classes/java/sql/Timestamp.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/sql/Timestamp.java Thu Dec 15 15:57:51 2011 -0800
@@ -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;
--- a/jdk/src/share/classes/java/util/Currency.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/util/Currency.java Thu Dec 15 15:57:51 2011 -0800
@@ -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;
}
/**
--- a/jdk/src/share/classes/java/util/Date.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/util/Date.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
--- a/jdk/src/share/classes/java/util/Formatter.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/util/Formatter.java Thu Dec 15 15:57:51 2011 -0800
@@ -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());
--- a/jdk/src/share/classes/java/util/GregorianCalendar.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/util/GregorianCalendar.java Thu Dec 15 15:57:51 2011 -0800
@@ -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;
}
--- a/jdk/src/share/classes/java/util/JapaneseImperialCalendar.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/util/JapaneseImperialCalendar.java Thu Dec 15 15:57:51 2011 -0800
@@ -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;
}
--- a/jdk/src/share/classes/java/util/PropertyPermission.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/util/PropertyPermission.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
}
}
--- a/jdk/src/share/classes/java/util/ResourceBundle.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/util/ResourceBundle.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
--- a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicBoolean.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicBoolean.java Thu Dec 15 15:57:51 2011 -0800
@@ -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;
--- a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicInteger.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicInteger.java Thu Dec 15 15:57:51 2011 -0800
@@ -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();
--- a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicIntegerArray.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicIntegerArray.java Thu Dec 15 15:57:51 2011 -0800
@@ -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.
--- a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java Thu Dec 15 15:57:51 2011 -0800
@@ -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");
--- a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicLong.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicLong.java Thu Dec 15 15:57:51 2011 -0800
@@ -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() {
--- a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicLongArray.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicLongArray.java Thu Dec 15 15:57:51 2011 -0800
@@ -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.
--- a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java Thu Dec 15 15:57:51 2011 -0800
@@ -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");
--- a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicReference.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicReference.java Thu Dec 15 15:57:51 2011 -0800
@@ -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;
--- a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicReferenceArray.java Thu Dec 15 15:57:51 2011 -0800
@@ -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;
}
--- a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
--- a/jdk/src/share/classes/java/util/concurrent/atomic/AtomicStampedReference.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/util/concurrent/atomic/AtomicStampedReference.java Thu Dec 15 15:57:51 2011 -0800
@@ -155,7 +155,6 @@
casPair(current, Pair.of(newReference, newStamp)));
}
-
/**
* Unconditionally sets the value of both the reference and stamp.
*
--- a/jdk/src/share/classes/java/util/jar/JarVerifier.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/util/jar/JarVerifier.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
}
--- a/jdk/src/share/classes/java/util/jar/JavaUtilJarAccessImpl.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/util/jar/JavaUtilJarAccessImpl.java Thu Dec 15 15:57:51 2011 -0800
@@ -57,7 +57,7 @@
jar.setEagerValidation(eager);
}
- public List getManifestDigests(JarFile jar) {
+ public List<Object> getManifestDigests(JarFile jar) {
return jar.getManifestDigests();
}
}
--- a/jdk/src/share/classes/java/util/zip/Adler32.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/util/zip/Adler32.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
}
--- a/jdk/src/share/classes/java/util/zip/CRC32.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/java/util/zip/CRC32.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
}
--- a/jdk/src/share/classes/javax/script/ScriptEngineManager.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/javax/script/ScriptEngineManager.java Thu Dec 15 15:57:51 2011 -0800
@@ -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;
}
--- a/jdk/src/share/classes/javax/security/auth/kerberos/ServicePermission.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/javax/security/auth/kerberos/ServicePermission.java Thu Dec 15 15:57:51 2011 -0800
@@ -369,7 +369,7 @@
switch(a[i-matchlen]) {
case ',':
seencomma = true;
- /*FALLTHROUGH*/
+ break;
case ' ': case '\r': case '\n':
case '\f': case '\t':
break;
--- a/jdk/src/share/classes/javax/sql/StatementEvent.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/javax/sql/StatementEvent.java Thu Dec 15 15:57:51 2011 -0800
@@ -42,6 +42,7 @@
*/
public class StatementEvent extends EventObject {
+ static final long serialVersionUID = -8089573731826608315L;
private SQLException exception;
private PreparedStatement statement;
--- a/jdk/src/share/classes/javax/sql/rowset/BaseRowSet.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/javax/sql/rowset/BaseRowSet.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
}
}
}
--- a/jdk/src/share/classes/javax/sql/rowset/RowSetMetaDataImpl.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/javax/sql/rowset/RowSetMetaDataImpl.java Thu Dec 15 15:57:51 2011 -0800
@@ -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;
}
}
--- a/jdk/src/share/classes/javax/sql/rowset/RowSetProvider.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/javax/sql/rowset/RowSetProvider.java Thu Dec 15 15:57:51 2011 -0800
@@ -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) {
--- a/jdk/src/share/classes/javax/sql/rowset/serial/SQLInputImpl.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/javax/sql/rowset/serial/SQLInputImpl.java Thu Dec 15 15:57:51 2011 -0800
@@ -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;
}
}
--- a/jdk/src/share/classes/javax/sql/rowset/serial/SQLOutputImpl.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/javax/sql/rowset/serial/SQLOutputImpl.java Thu Dec 15 15:57:51 2011 -0800
@@ -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");
}
--- a/jdk/src/share/classes/javax/sql/rowset/serial/SerialArray.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/javax/sql/rowset/serial/SerialArray.java Thu Dec 15 15:57:51 2011 -0800
@@ -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:
- ;
}
--- a/jdk/src/share/classes/javax/sql/rowset/serial/SerialBlob.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/javax/sql/rowset/serial/SerialBlob.java Thu Dec 15 15:57:51 2011 -0800
@@ -207,7 +207,7 @@
*/
public java.io.InputStream getBinaryStream() throws SerialException {
InputStream stream = new ByteArrayInputStream(buf);
- return (java.io.InputStream)stream;
+ return stream;
}
/**
--- a/jdk/src/share/classes/javax/sql/rowset/serial/SerialJavaObject.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/javax/sql/rowset/serial/SerialJavaObject.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
}
--- a/jdk/src/share/classes/javax/sql/rowset/serial/SerialRef.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/javax/sql/rowset/serial/SerialRef.java Thu Dec 15 15:57:51 2011 -0800
@@ -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 {
--- a/jdk/src/share/classes/javax/sql/rowset/serial/SerialStruct.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/javax/sql/rowset/serial/SerialStruct.java Thu Dec 15 15:57:51 2011 -0800
@@ -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 {
--- a/jdk/src/share/classes/javax/sql/rowset/spi/SyncFactory.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/javax/sql/rowset/spi/SyncFactory.java Thu Dec 15 15:57:51 2011 -0800
@@ -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 ?
--- a/jdk/src/share/classes/javax/swing/text/DefaultCaret.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/javax/swing/text/DefaultCaret.java Thu Dec 15 15:57:51 2011 -0800
@@ -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()) {
--- a/jdk/src/share/classes/sun/awt/im/CompositionArea.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/awt/im/CompositionArea.java Thu Dec 15 15:57:51 2011 -0800
@@ -313,4 +313,7 @@
compositionWindow.pack();
}
+ // Proclaim serial compatibility with 1.7.0
+ private static final long serialVersionUID = -1057247068746557444L;
+
}
--- a/jdk/src/share/classes/sun/awt/im/CompositionAreaHandler.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/awt/im/CompositionAreaHandler.java Thu Dec 15 15:57:51 2011 -0800
@@ -257,7 +257,7 @@
*/
InputMethodRequests getClientInputMethodRequests() {
if (clientComponent != null) {
- return (InputMethodRequests) clientComponent.getInputMethodRequests();
+ return clientComponent.getInputMethodRequests();
}
return null;
--- a/jdk/src/share/classes/sun/awt/im/InputContext.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/awt/im/InputContext.java Thu Dec 15 15:57:51 2011 -0800
@@ -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();
--- a/jdk/src/share/classes/sun/awt/im/InputMethodContext.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/awt/im/InputMethodContext.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
}
--- a/jdk/src/share/classes/sun/awt/im/InputMethodJFrame.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/awt/im/InputMethodJFrame.java Thu Dec 15 15:57:51 2011 -0800
@@ -68,4 +68,7 @@
return super.getInputContext();
}
}
+
+ // Proclaim serial compatibility with 1.7.0
+ private static final long serialVersionUID = -4705856747771842549L;
}
--- a/jdk/src/share/classes/sun/awt/im/InputMethodManager.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/awt/im/InputMethodManager.java Thu Dec 15 15:57:51 2011 -0800
@@ -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();
}
});
--- a/jdk/src/share/classes/sun/awt/im/SimpleInputMethodWindow.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/awt/im/SimpleInputMethodWindow.java Thu Dec 15 15:57:51 2011 -0800
@@ -61,4 +61,7 @@
return super.getInputContext();
}
}
+
+ // Proclaim serial compatibility with 1.7.0
+ private static final long serialVersionUID = 5093376647036461555L;
}
--- a/jdk/src/share/classes/sun/awt/image/BufImgSurfaceData.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/awt/image/BufImgSurfaceData.java Thu Dec 15 15:57:51 2011 -0800
@@ -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;
}
--- a/jdk/src/share/classes/sun/instrument/InstrumentationImpl.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/instrument/InstrumentationImpl.java Thu Dec 15 15:57:51 2011 -0800
@@ -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) {
--- a/jdk/src/share/classes/sun/instrument/TransformerManager.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/instrument/TransformerManager.java Thu Dec 15 15:57:51 2011 -0800
@@ -169,7 +169,7 @@
public byte[]
transform( ClassLoader loader,
String classname,
- Class classBeingRedefined,
+ Class<?> classBeingRedefined,
ProtectionDomain protectionDomain,
byte[] classfileBuffer) {
boolean someoneTouchedTheBytecode = false;
--- a/jdk/src/share/classes/sun/java2d/SunGraphics2D.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/java2d/SunGraphics2D.java Thu Dec 15 15:57:51 2011 -0800
@@ -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 ||
--- a/jdk/src/share/classes/sun/java2d/SurfaceData.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/java2d/SurfaceData.java Thu Dec 15 15:57:51 2011 -0800
@@ -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 {
--- a/jdk/src/share/classes/sun/java2d/SurfaceDataProxy.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/java2d/SurfaceDataProxy.java Thu Dec 15 15:57:51 2011 -0800
@@ -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 {
--- a/jdk/src/share/classes/sun/java2d/loops/GraphicsPrimitive.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/java2d/loops/GraphicsPrimitive.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
--- a/jdk/src/share/classes/sun/java2d/loops/SurfaceType.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/java2d/loops/SurfaceType.java Thu Dec 15 15:57:51 2011 -0800
@@ -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) {
--- a/jdk/src/share/classes/sun/java2d/opengl/OGLBufImgOps.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/java2d/opengl/OGLBufImgOps.java Thu Dec 15 15:57:51 2011 -0800
@@ -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;
--- a/jdk/src/share/classes/sun/java2d/opengl/OGLDrawImage.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/java2d/opengl/OGLDrawImage.java Thu Dec 15 15:57:51 2011 -0800
@@ -60,7 +60,7 @@
SurfaceData dstData = sg.surfaceData;
SurfaceData srcData =
dstData.getSourceSurfaceData(img,
- sg.TRANSFORM_GENERIC,
+ SunGraphics2D.TRANSFORM_GENERIC,
sg.imageComp,
bgColor);
--- a/jdk/src/share/classes/sun/java2d/opengl/OGLPaints.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/java2d/opengl/OGLPaints.java Thu Dec 15 15:57:51 2011 -0800
@@ -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;
--- a/jdk/src/share/classes/sun/java2d/opengl/OGLSurfaceData.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/java2d/opengl/OGLSurfaceData.java Thu Dec 15 15:57:51 2011 -0800
@@ -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;
--- a/jdk/src/share/classes/sun/java2d/pipe/AAShapePipe.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/java2d/pipe/AAShapePipe.java Thu Dec 15 15:57:51 2011 -0800
@@ -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];
--- a/jdk/src/share/classes/sun/java2d/pipe/BufferedPaints.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/java2d/pipe/BufferedPaints.java Thu Dec 15 15:57:51 2011 -0800
@@ -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 !=
--- a/jdk/src/share/classes/sun/java2d/pipe/BufferedRenderPipe.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/java2d/pipe/BufferedRenderPipe.java Thu Dec 15 15:57:51 2011 -0800
@@ -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
--- a/jdk/src/share/classes/sun/java2d/pipe/DrawImage.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/java2d/pipe/DrawImage.java Thu Dec 15 15:57:51 2011 -0800
@@ -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
--- a/jdk/src/share/classes/sun/java2d/pipe/GlyphListPipe.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/java2d/pipe/GlyphListPipe.java Thu Dec 15 15:57:51 2011 -0800
@@ -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];
--- a/jdk/src/share/classes/sun/java2d/pipe/LoopPipe.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/java2d/pipe/LoopPipe.java Thu Dec 15 15:57:51 2011 -0800
@@ -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...
--- a/jdk/src/share/classes/sun/java2d/pipe/RenderingEngine.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/java2d/pipe/RenderingEngine.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
}
--- a/jdk/src/share/classes/sun/launcher/LauncherHelper.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/launcher/LauncherHelper.java Thu Dec 15 15:57:51 2011 -0800
@@ -428,7 +428,7 @@
if (t != null) {
t.printStackTrace();
} else {
- Thread.currentThread().dumpStack();
+ Thread.dumpStack();
}
}
System.exit(1);
--- a/jdk/src/share/classes/sun/management/counter/perf/PerfInstrumentation.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/management/counter/perf/PerfInstrumentation.java Thu Dec 15 15:57:51 2011 -0800
@@ -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;
--- a/jdk/src/share/classes/sun/management/jmxremote/ConnectorBootstrap.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/management/jmxremote/ConnectorBootstrap.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
--- a/jdk/src/share/classes/sun/misc/BASE64Decoder.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/misc/BASE64Decoder.java Thu Dec 15 15:57:51 2011 -0800
@@ -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
{
--- a/jdk/src/share/classes/sun/misc/CEFormatException.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/misc/CEFormatException.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
+ }
}
+
--- a/jdk/src/share/classes/sun/misc/CEStreamExhausted.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/misc/CEStreamExhausted.java Thu Dec 15 15:57:51 2011 -0800
@@ -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;
+}
+
--- a/jdk/src/share/classes/sun/misc/ClassLoaderUtil.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/misc/ClassLoaderUtil.java Thu Dec 15 15:57:51 2011 -0800
@@ -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
--- a/jdk/src/share/classes/sun/misc/CompoundEnumeration.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/misc/CompoundEnumeration.java Thu Dec 15 15:57:51 2011 -0800
@@ -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();
}
}
--- a/jdk/src/share/classes/sun/misc/ExtensionDependency.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/misc/ExtensionDependency.java Thu Dec 15 15:57:51 2011 -0800
@@ -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
--- a/jdk/src/share/classes/sun/misc/ExtensionInstallationException.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/misc/ExtensionInstallationException.java Thu Dec 15 15:57:51 2011 -0800
@@ -34,6 +34,8 @@
public class ExtensionInstallationException extends Exception {
+ static final long serialVersionUID = 3139688306909345924L;
+
/*
* <p>
* Construct a new exception with an exception reason
--- a/jdk/src/share/classes/sun/misc/FloatingDecimal.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/misc/FloatingDecimal.java Thu Dec 15 15:57:51 2011 -0800
@@ -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) |
--- a/jdk/src/share/classes/sun/misc/FormattedFloatingDecimal.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/misc/FormattedFloatingDecimal.java Thu Dec 15 15:57:51 2011 -0800
@@ -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];
}
};
--- a/jdk/src/share/classes/sun/misc/InvalidJarIndexException.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/misc/InvalidJarIndexException.java Thu Dec 15 15:57:51 2011 -0800
@@ -38,6 +38,8 @@
public
class InvalidJarIndexException extends RuntimeException {
+ static final long serialVersionUID = -6159797516569680148L;
+
/**
* Constructs an <code>InvalidJarIndexException</code> with no
* detail message.
--- a/jdk/src/share/classes/sun/misc/JarIndex.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/misc/JarIndex.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
}
--- a/jdk/src/share/classes/sun/misc/JavaLangAccess.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/misc/JavaLangAccess.java Thu Dec 15 15:57:51 2011 -0800
@@ -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
--- a/jdk/src/share/classes/sun/misc/JavaUtilJarAccess.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/misc/JavaUtilJarAccess.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
}
--- a/jdk/src/share/classes/sun/misc/LRUCache.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/misc/LRUCache.java Thu Dec 15 15:57:51 2011 -0800
@@ -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];
--- a/jdk/src/share/classes/sun/misc/Launcher.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/misc/Launcher.java Thu Dec 15 15:57:51 2011 -0800
@@ -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 +
--- a/jdk/src/share/classes/sun/misc/ProxyGenerator.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/misc/ProxyGenerator.java Thu Dec 15 15:57:51 2011 -0800
@@ -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;
--- a/jdk/src/share/classes/sun/misc/Queue.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/misc/Queue.java Thu Dec 15 15:57:51 2011 -0800
@@ -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;
}
--- a/jdk/src/share/classes/sun/misc/RequestProcessor.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/misc/RequestProcessor.java Thu Dec 15 15:57:51 2011 -0800
@@ -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>();
}
}
--- a/jdk/src/share/classes/sun/misc/Service.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/misc/Service.java Thu Dec 15 15:57:51 2011 -0800
@@ -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();
--- a/jdk/src/share/classes/sun/misc/ServiceConfigurationError.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/misc/ServiceConfigurationError.java Thu Dec 15 15:57:51 2011 -0800
@@ -43,6 +43,8 @@
public class ServiceConfigurationError extends Error {
+ static final long serialVersionUID = 8769866263384244465L;
+
/**
* Constructs a new instance with the specified detail string.
*/
--- a/jdk/src/share/classes/sun/misc/Signal.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/misc/Signal.java Thu Dec 15 15:57:51 2011 -0800
@@ -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() {
--- a/jdk/src/share/classes/sun/misc/URLClassPath.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/misc/URLClassPath.java Thu Dec 15 15:57:51 2011 -0800
@@ -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;
--- a/jdk/src/share/classes/sun/misc/Unsafe.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/misc/Unsafe.java Thu Dec 15 15:57:51 2011 -0800
@@ -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}. */
--- a/jdk/src/share/classes/sun/misc/VM.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/misc/VM.java Thu Dec 15 15:57:51 2011 -0800
@@ -48,6 +48,7 @@
return suspended;
}
+ @SuppressWarnings("deprecation")
public static boolean allowThreadSuspension(ThreadGroup g, boolean b) {
return g.allowThreadSuspension(b);
}
--- a/jdk/src/share/classes/sun/net/RegisteredDomain.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/net/RegisteredDomain.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
--- a/jdk/src/share/classes/sun/net/ftp/FtpClientProvider.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/net/ftp/FtpClientProvider.java Thu Dec 15 15:57:51 2011 -0800
@@ -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;
}
--- a/jdk/src/share/classes/sun/net/www/protocol/jar/Handler.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/net/www/protocol/jar/Handler.java Thu Dec 15 15:57:51 2011 -0800
@@ -123,6 +123,7 @@
@Override
+ @SuppressWarnings("deprecation")
protected void parseURL(URL url, String spec,
int start, int limit) {
String file = null;
--- a/jdk/src/share/classes/sun/nio/ch/SocketAdaptor.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/nio/ch/SocketAdaptor.java Thu Dec 15 15:57:51 2011 -0800
@@ -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() {
--- a/jdk/src/share/classes/sun/security/provider/certpath/ssl/SSLServerCertStore.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/security/provider/certpath/ssl/SSLServerCertStore.java Thu Dec 15 15:57:51 2011 -0800
@@ -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() {
+ return new X509Certificate[0];
+ }
- public X509Certificate[] getAcceptedIssuers() {
+ @Override
+ public void checkClientTrusted(X509Certificate[] chain,
+ String authType) throws CertificateException {
+
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void checkClientTrusted(X509Certificate[] chain, String authType,
+ Socket socket) throws CertificateException {
+
throw new UnsupportedOperationException();
}
- public void checkClientTrusted(X509Certificate[] chain,
- String authType)
- throws CertificateException
- {
+ @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();
}
}
--- a/jdk/src/share/classes/sun/text/CompactByteArray.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/text/CompactByteArray.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
--- a/jdk/src/share/classes/sun/text/IntHashtable.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/text/IntHashtable.java Thu Dec 15 15:57:51 2011 -0800
@@ -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;
}
--- a/jdk/src/share/classes/sun/text/bidi/BidiBase.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/text/bidi/BidiBase.java Thu Dec 15 15:57:51 2011 -0800
@@ -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)
{
--- a/jdk/src/share/classes/sun/text/normalizer/ICUData.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/text/normalizer/ICUData.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
}
});
--- a/jdk/src/share/classes/sun/text/normalizer/NormalizerBase.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/text/normalizer/NormalizerBase.java Thu Dec 15 15:57:51 2011 -0800
@@ -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 */
--- a/jdk/src/share/classes/sun/text/normalizer/NormalizerImpl.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/text/normalizer/NormalizerImpl.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
}
--- a/jdk/src/share/classes/sun/text/normalizer/SymbolTable.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/text/normalizer/SymbolTable.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
}
--- a/jdk/src/share/classes/sun/text/normalizer/UnicodeSet.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/text/normalizer/UnicodeSet.java Thu Dec 15 15:57:51 2011 -0800
@@ -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;
}
--- a/jdk/src/share/classes/sun/text/normalizer/UnicodeSetIterator.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/text/normalizer/UnicodeSetIterator.java Thu Dec 15 15:57:51 2011 -0800
@@ -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
--- a/jdk/src/share/classes/sun/text/normalizer/VersionInfo.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/text/normalizer/VersionInfo.java Thu Dec 15 15:57:51 2011 -0800
@@ -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
*/
--- a/jdk/src/share/classes/sun/tools/attach/HotSpotAttachProvider.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/tools/attach/HotSpotAttachProvider.java Thu Dec 15 15:57:51 2011 -0800
@@ -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();
}
}
}
--- a/jdk/src/share/classes/sun/tools/jinfo/JInfo.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/tools/jinfo/JInfo.java Thu Dec 15 15:57:51 2011 -0800
@@ -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:");
--- a/jdk/src/share/classes/sun/tools/jmap/JMap.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/tools/jmap/JMap.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
}
--- a/jdk/src/share/classes/sun/tools/jps/Jps.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/tools/jps/Jps.java Thu Dec 15 15:57:51 2011 -0800
@@ -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));
--- a/jdk/src/share/classes/sun/tools/jstack/JStack.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/tools/jstack/JStack.java Thu Dec 15 15:57:51 2011 -0800
@@ -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
--- a/jdk/src/share/classes/sun/tools/serialver/SerialVer.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/tools/serialver/SerialVer.java Thu Dec 15 15:57:51 2011 -0800
@@ -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.");
}
--- a/jdk/src/share/classes/sun/util/LocaleServiceProviderPool.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/util/LocaleServiceProviderPool.java Thu Dec 15 15:57:51 2011 -0800
@@ -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) {
--- a/jdk/src/share/classes/sun/util/calendar/BaseCalendar.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/util/calendar/BaseCalendar.java Thu Dec 15 15:57:51 2011 -0800
@@ -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++;
--- a/jdk/src/share/classes/sun/util/calendar/CalendarSystem.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/util/calendar/CalendarSystem.java Thu Dec 15 15:57:51 2011 -0800
@@ -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) {
--- a/jdk/src/share/classes/sun/util/calendar/LocalGregorianCalendar.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/util/calendar/LocalGregorianCalendar.java Thu Dec 15 15:57:51 2011 -0800
@@ -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();
--- a/jdk/src/share/classes/sun/util/calendar/ZoneInfo.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/util/calendar/ZoneInfo.java Thu Dec 15 15:57:51 2011 -0800
@@ -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;
}
--- a/jdk/src/share/classes/sun/util/calendar/ZoneInfoFile.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/util/calendar/ZoneInfoFile.java Thu Dec 15 15:57:51 2011 -0800
@@ -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() {
+ }
}
--- a/jdk/src/share/classes/sun/util/resources/LocaleData.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/util/resources/LocaleData.java Thu Dec 15 15:57:51 2011 -0800
@@ -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());
--- a/jdk/src/share/classes/sun/util/resources/OpenListResourceBundle.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/util/resources/OpenListResourceBundle.java Thu Dec 15 15:57:51 2011 -0800
@@ -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;
}
--- a/jdk/src/share/classes/sun/util/resources/TimeZoneNamesBundle.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNamesBundle.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
}
/**
--- a/jdk/src/share/native/java/io/io_util.c Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/native/java/io/io_util.c Thu Dec 15 15:57:51 2011 -0800
@@ -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");
--- a/jdk/src/share/native/java/util/zip/Adler32.c Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/native/java/util/zip/Adler32.c Thu Dec 15 15:57:51 2011 -0800
@@ -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;
+}
+
+
--- a/jdk/src/share/native/java/util/zip/CRC32.c Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/share/native/java/util/zip/CRC32.c Thu Dec 15 15:57:51 2011 -0800
@@ -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;
+}
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/ChangeLog Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,855 +0,0 @@
-
- ChangeLog file for zlib
-
-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)
-- Update testzlib, vstudio, masmx64, and masmx86 in contrib [Vollant]
-
-Changes in 1.2.2.4 (11 July 2005)
-- Add inflatePrime() function for starting inflation at bit boundary
-- Avoid some Visual C warnings in deflate.c
-- Avoid more silly Visual C warnings in inflate.c and inftrees.c for 64-bit
- 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
- 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]
-- Move declarations of gf2 functions to right place in crc32.c [Oberhumer]
-- Add cast in trees.c t avoid a warning [Oberhumer]
-- Avoid some warnings in fitblk.c, gun.c, gzjoin.c in examples [Oberhumer]
-- Update make_vms.com [Zinser]
-- Initialize state->write in inflateReset() since copied in inflate_fast()
-- Be more strict on incomplete code sets in inflate_table() and increase
- ENOUGH and MAXD -- this repairs a possible security vulnerability for
- invalid inflate input. Thanks to Tavis Ormandy and Markus Oberhumer for
- discovering the vulnerability and providing test cases.
-- Add ia64 support to configure for HP-UX [Smith]
-- Add error return to gzread() for format or i/o error [Levin]
-- Use malloc.h for OS/2 [Necasek]
-
-Changes in 1.2.2.3 (27 May 2005)
-- Replace 1U constants in inflate.c and inftrees.c for 64-bit compile
-- Typecast fread() return values in gzio.c [Vollant]
-- Remove trailing space in minigzip.c outmode (VC++ can't deal with it)
-- Fix crc check bug in gzread() after gzungetc() [Heiner]
-- Add the deflateTune() function to adjust internal compression parameters
-- Add a fast gzip decompressor, gun.c, to examples (use of inflateBack)
-- Remove an incorrect assertion in examples/zpipe.c
-- Add C++ wrapper in infback9.h [Donais]
-- Fix bug in inflateCopy() when decoding fixed codes
-- Note in zlib.h how much deflateSetDictionary() actually uses
-- Remove USE_DICT_HEAD in deflate.c (would mess up inflate if used)
-- Add _WIN32_WCE to define WIN32 in zconf.in.h [Spencer]
-- Don't include stderr.h or errno.h for _WIN32_WCE in zutil.h [Spencer]
-- Add gzdirect() function to indicate transparent reads
-- Update contrib/minizip [Vollant]
-- Fix compilation of deflate.c when both ASMV and FASTEST [Oberhumer]
-- Add casts in crc32.c to avoid warnings [Oberhumer]
-- Add contrib/masmx64 [Vollant]
-- Update contrib/asm586, asm686, masmx86, testzlib, vstudio [Vollant]
-
-Changes in 1.2.2.2 (30 December 2004)
-- Replace structure assignments in deflate.c and inflate.c with zmemcpy to
- avoid implicit memcpy calls (portability for no-library compilation)
-- Increase sprintf() buffer size in gzdopen() to allow for large numbers
-- Add INFLATE_STRICT to check distances against zlib header
-- Improve WinCE errno handling and comments [Chang]
-- Remove comment about no gzip header processing in FAQ
-- Add Z_FIXED strategy option to deflateInit2() to force fixed trees
-- Add updated make_vms.com [Coghlan], update README
-- Create a new "examples" directory, move gzappend.c there, add zpipe.c,
- fitblk.c, gzlog.[ch], gzjoin.c, and zlib_how.html.
-- Add FAQ entry and comments in deflate.c on uninitialized memory access
-- Add Solaris 9 make options in configure [Gilbert]
-- Allow strerror() usage in gzio.c for STDC
-- Fix DecompressBuf in contrib/delphi/ZLib.pas [ManChesTer]
-- Update contrib/masmx86/inffas32.asm and gvmat32.asm [Vollant]
-- Use z_off_t for adler32_combine() and crc32_combine() lengths
-- Make adler32() much faster for small len
-- Use OS_CODE in deflate() default gzip header
-
-Changes in 1.2.2.1 (31 October 2004)
-- Allow inflateSetDictionary() call for raw inflate
-- Fix inflate header crc check bug for file names and comments
-- Add deflateSetHeader() and gz_header structure for custom gzip headers
-- Add inflateGetheader() to retrieve gzip headers
-- Add crc32_combine() and adler32_combine() functions
-- Add alloc_func, free_func, in_func, out_func to Z_PREFIX list
-- Use zstreamp consistently in zlib.h (inflate_back functions)
-- Remove GUNZIP condition from definition of inflate_mode in inflate.h
- and in contrib/inflate86/inffast.S [Truta, Anderson]
-- Add support for AMD64 in contrib/inflate86/inffas86.c [Anderson]
-- Update projects/README.projects and projects/visualc6 [Truta]
-- Update win32/DLL_FAQ.txt [Truta]
-- Avoid warning under NO_GZCOMPRESS in gzio.c; fix typo [Truta]
-- Deprecate Z_ASCII; use Z_TEXT instead [Truta]
-- Use a new algorithm for setting strm->data_type in trees.c [Truta]
-- Do not define an exit() prototype in zutil.c unless DEBUG defined
-- Remove prototype of exit() from zutil.c, example.c, minigzip.c [Truta]
-- Add comment in zlib.h for Z_NO_FLUSH parameter to deflate()
-- Fix Darwin build version identification [Peterson]
-
-Changes in 1.2.2 (3 October 2004)
-- Update zlib.h comments on gzip in-memory processing
-- Set adler to 1 in inflateReset() to support Java test suite [Walles]
-- Add contrib/dotzlib [Ravn]
-- Update win32/DLL_FAQ.txt [Truta]
-- Update contrib/minizip [Vollant]
-- Move contrib/visual-basic.txt to old/ [Truta]
-- Fix assembler builds in projects/visualc6/ [Truta]
-
-Changes in 1.2.1.2 (9 September 2004)
-- Update INDEX file
-- Fix trees.c to update strm->data_type (no one ever noticed!)
-- Fix bug in error case in inflate.c, infback.c, and infback9.c [Brown]
-- Add "volatile" to crc table flag declaration (for DYNAMIC_CRC_TABLE)
-- Add limited multitasking protection to DYNAMIC_CRC_TABLE
-- Add NO_vsnprintf for VMS in zutil.h [Mozilla]
-- Don't declare strerror() under VMS [Mozilla]
-- Add comment to DYNAMIC_CRC_TABLE to use get_crc_table() to initialize
-- Update contrib/ada [Anisimkov]
-- Update contrib/minizip [Vollant]
-- Fix configure to not hardcode directories for Darwin [Peterson]
-- Fix gzio.c to not return error on empty files [Brown]
-- Fix indentation; update version in contrib/delphi/ZLib.pas and
- contrib/pascal/zlibpas.pas [Truta]
-- Update mkasm.bat in contrib/masmx86 [Truta]
-- Update contrib/untgz [Truta]
-- Add projects/README.projects [Truta]
-- Add project for MS Visual C++ 6.0 in projects/visualc6 [Cadieux, Truta]
-- Update win32/DLL_FAQ.txt [Truta]
-- Update list of Z_PREFIX symbols in zconf.h [Randers-Pehrson, Truta]
-- Remove an unnecessary assignment to curr in inftrees.c [Truta]
-- Add OS/2 to exe builds in configure [Poltorak]
-- Remove err dummy parameter in zlib.h [Kientzle]
-
-Changes in 1.2.1.1 (9 January 2004)
-- Update email address in README
-- Several FAQ updates
-- Fix a big fat bug in inftrees.c that prevented decoding valid
- dynamic blocks with only literals and no distance codes --
- Thanks to "Hot Emu" for the bug report and sample file
-- Add a note to puff.c on no distance codes case.
-
-Changes in 1.2.1 (17 November 2003)
-- Remove a tab in contrib/gzappend/gzappend.c
-- Update some interfaces in contrib for new zlib functions
-- Update zlib version number in some contrib entries
-- Add Windows CE definition for ptrdiff_t in zutil.h [Mai, Truta]
-- Support shared libraries on Hurd and KFreeBSD [Brown]
-- Fix error in NO_DIVIDE option of adler32.c
-
-Changes in 1.2.0.8 (4 November 2003)
-- Update version in contrib/delphi/ZLib.pas and contrib/pascal/zlibpas.pas
-- Add experimental NO_DIVIDE #define in adler32.c
- - Possibly faster on some processors (let me know if it is)
-- Correct Z_BLOCK to not return on first inflate call if no wrap
-- Fix strm->data_type on inflate() return to correctly indicate EOB
-- Add deflatePrime() function for appending in the middle of a byte
-- Add contrib/gzappend for an example of appending to a stream
-- Update win32/DLL_FAQ.txt [Truta]
-- Delete Turbo C comment in README [Truta]
-- Improve some indentation in zconf.h [Truta]
-- Fix infinite loop on bad input in configure script [Church]
-- Fix gzeof() for concatenated gzip files [Johnson]
-- Add example to contrib/visual-basic.txt [Michael B.]
-- Add -p to mkdir's in Makefile.in [vda]
-- Fix configure to properly detect presence or lack of printf functions
-- Add AS400 support [Monnerat]
-- Add a little Cygwin support [Wilson]
-
-Changes in 1.2.0.7 (21 September 2003)
-- Correct some debug formats in contrib/infback9
-- Cast a type in a debug statement in trees.c
-- Change search and replace delimiter in configure from % to # [Beebe]
-- Update contrib/untgz to 0.2 with various fixes [Truta]
-- Add build support for Amiga [Nikl]
-- Remove some directories in old that have been updated to 1.2
-- Add dylib building for Mac OS X in configure and Makefile.in
-- Remove old distribution stuff from Makefile
-- Update README to point to DLL_FAQ.txt, and add comment on Mac OS X
-- Update links in README
-
-Changes in 1.2.0.6 (13 September 2003)
-- Minor FAQ updates
-- Update contrib/minizip to 1.00 [Vollant]
-- Remove test of gz functions in example.c when GZ_COMPRESS defined [Truta]
-- Update POSTINC comment for 68060 [Nikl]
-- Add contrib/infback9 with deflate64 decoding (unsupported)
-- For MVS define NO_vsnprintf and undefine FAR [van Burik]
-- Add pragma for fdopen on MVS [van Burik]
-
-Changes in 1.2.0.5 (8 September 2003)
-- Add OF to inflateBackEnd() declaration in zlib.h
-- Remember start when using gzdopen in the middle of a file
-- Use internal off_t counters in gz* functions to properly handle seeks
-- Perform more rigorous check for distance-too-far in inffast.c
-- Add Z_BLOCK flush option to return from inflate at block boundary
-- Set strm->data_type on return from inflate
- - Indicate bits unused, if at block boundary, and if in last block
-- Replace size_t with ptrdiff_t in crc32.c, and check for correct size
-- Add condition so old NO_DEFLATE define still works for compatibility
-- FAQ update regarding the Windows DLL [Truta]
-- INDEX update: add qnx entry, remove aix entry [Truta]
-- Install zlib.3 into mandir [Wilson]
-- Move contrib/zlib_dll_FAQ.txt to win32/DLL_FAQ.txt; update [Truta]
-- Adapt the zlib interface to the new DLL convention guidelines [Truta]
-- Introduce ZLIB_WINAPI macro to allow the export of functions using
- the WINAPI calling convention, for Visual Basic [Vollant, Truta]
-- Update msdos and win32 scripts and makefiles [Truta]
-- Export symbols by name, not by ordinal, in win32/zlib.def [Truta]
-- Add contrib/ada [Anisimkov]
-- Move asm files from contrib/vstudio/vc70_32 to contrib/asm386 [Truta]
-- Rename contrib/asm386 to contrib/masmx86 [Truta, Vollant]
-- Add contrib/masm686 [Truta]
-- Fix offsets in contrib/inflate86 and contrib/masmx86/inffas32.asm
- [Truta, Vollant]
-- Update contrib/delphi; rename to contrib/pascal; add example [Truta]
-- Remove contrib/delphi2; add a new contrib/delphi [Truta]
-- Avoid inclusion of the nonstandard <memory.h> in contrib/iostream,
- and fix some method prototypes [Truta]
-- Fix the ZCR_SEED2 constant to avoid warnings in contrib/minizip
- [Truta]
-- Avoid the use of backslash (\) in contrib/minizip [Vollant]
-- Fix file time handling in contrib/untgz; update makefiles [Truta]
-- Update contrib/vstudio/vc70_32 to comply with the new DLL guidelines
- [Vollant]
-- Remove contrib/vstudio/vc15_16 [Vollant]
-- Rename contrib/vstudio/vc70_32 to contrib/vstudio/vc7 [Truta]
-- Update README.contrib [Truta]
-- Invert the assignment order of match_head and s->prev[...] in
- INSERT_STRING [Truta]
-- Compare TOO_FAR with 32767 instead of 32768, to avoid 16-bit warnings
- [Truta]
-- Compare function pointers with 0, not with NULL or Z_NULL [Truta]
-- Fix prototype of syncsearch in inflate.c [Truta]
-- Introduce ASMINF macro to be enabled when using an ASM implementation
- of inflate_fast [Truta]
-- Change NO_DEFLATE to NO_GZCOMPRESS [Truta]
-- Modify test_gzio in example.c to take a single file name as a
- parameter [Truta]
-- Exit the example.c program if gzopen fails [Truta]
-- Add type casts around strlen in example.c [Truta]
-- Remove casting to sizeof in minigzip.c; give a proper type
- to the variable compared with SUFFIX_LEN [Truta]
-- Update definitions of STDC and STDC99 in zconf.h [Truta]
-- Synchronize zconf.h with the new Windows DLL interface [Truta]
-- Use SYS16BIT instead of __32BIT__ to distinguish between
- 16- and 32-bit platforms [Truta]
-- Use far memory allocators in small 16-bit memory models for
- Turbo C [Truta]
-- Add info about the use of ASMV, ASMINF and ZLIB_WINAPI in
- zlibCompileFlags [Truta]
-- Cygwin has vsnprintf [Wilson]
-- In Windows16, OS_CODE is 0, as in MSDOS [Truta]
-- In Cygwin, OS_CODE is 3 (Unix), not 11 (Windows32) [Wilson]
-
-Changes in 1.2.0.4 (10 August 2003)
-- Minor FAQ updates
-- Be more strict when checking inflateInit2's windowBits parameter
-- Change NO_GUNZIP compile option to NO_GZIP to cover deflate as well
-- Add gzip wrapper option to deflateInit2 using windowBits
-- Add updated QNX rule in configure and qnx directory [Bonnefoy]
-- Make inflate distance-too-far checks more rigorous
-- Clean up FAR usage in inflate
-- Add casting to sizeof() in gzio.c and minigzip.c
-
-Changes in 1.2.0.3 (19 July 2003)
-- Fix silly error in gzungetc() implementation [Vollant]
-- Update contrib/minizip and contrib/vstudio [Vollant]
-- Fix printf format in example.c
-- Correct cdecl support in zconf.in.h [Anisimkov]
-- Minor FAQ updates
-
-Changes in 1.2.0.2 (13 July 2003)
-- Add ZLIB_VERNUM in zlib.h for numerical preprocessor comparisons
-- Attempt to avoid warnings in crc32.c for pointer-int conversion
-- Add AIX to configure, remove aix directory [Bakker]
-- Add some casts to minigzip.c
-- Improve checking after insecure sprintf() or vsprintf() calls
-- Remove #elif's from crc32.c
-- Change leave label to inf_leave in inflate.c and infback.c to avoid
- library conflicts
-- Remove inflate gzip decoding by default--only enable gzip decoding by
- special request for stricter backward compatibility
-- Add zlibCompileFlags() function to return compilation information
-- More typecasting in deflate.c to avoid warnings
-- Remove leading underscore from _Capital #defines [Truta]
-- Fix configure to link shared library when testing
-- Add some Windows CE target adjustments [Mai]
-- Remove #define ZLIB_DLL in zconf.h [Vollant]
-- Add zlib.3 [Rodgers]
-- Update RFC URL in deflate.c and algorithm.txt [Mai]
-- Add zlib_dll_FAQ.txt to contrib [Truta]
-- Add UL to some constants [Truta]
-- Update minizip and vstudio [Vollant]
-- Remove vestigial NEED_DUMMY_RETURN from zconf.in.h
-- Expand use of NO_DUMMY_DECL to avoid all dummy structures
-- Added iostream3 to contrib [Schwardt]
-- Replace rewind() with fseek() for WinCE [Truta]
-- Improve setting of zlib format compression level flags
- - Report 0 for huffman and rle strategies and for level == 0 or 1
- - Report 2 only for level == 6
-- Only deal with 64K limit when necessary at compile time [Truta]
-- Allow TOO_FAR check to be turned off at compile time [Truta]
-- Add gzclearerr() function [Souza]
-- Add gzungetc() function
-
-Changes in 1.2.0.1 (17 March 2003)
-- Add Z_RLE strategy for run-length encoding [Truta]
- - When Z_RLE requested, restrict matches to distance one
- - Update zlib.h, minigzip.c, gzopen(), gzdopen() for Z_RLE
-- Correct FASTEST compilation to allow level == 0
-- Clean up what gets compiled for FASTEST
-- Incorporate changes to zconf.in.h [Vollant]
- - Refine detection of Turbo C need for dummy returns
- - Refine ZLIB_DLL compilation
- - Include additional header file on VMS for off_t typedef
-- Try to use _vsnprintf where it supplants vsprintf [Vollant]
-- Add some casts in inffast.c
-- Enchance comments in zlib.h on what happens if gzprintf() tries to
- write more than 4095 bytes before compression
-- Remove unused state from inflateBackEnd()
-- Remove exit(0) from minigzip.c, example.c
-- Get rid of all those darn tabs
-- Add "check" target to Makefile.in that does the same thing as "test"
-- Add "mostlyclean" and "maintainer-clean" targets to Makefile.in
-- Update contrib/inflate86 [Anderson]
-- Update contrib/testzlib, contrib/vstudio, contrib/minizip [Vollant]
-- Add msdos and win32 directories with makefiles [Truta]
-- More additions and improvements to the FAQ
-
-Changes in 1.2.0 (9 March 2003)
-- New and improved inflate code
- - About 20% faster
- - Does not allocate 32K window unless and until needed
- - Automatically detects and decompresses gzip streams
- - Raw inflate no longer needs an extra dummy byte at end
- - Added inflateBack functions using a callback interface--even faster
- than inflate, useful for file utilities (gzip, zip)
- - Added inflateCopy() function to record state for random access on
- externally generated deflate streams (e.g. in gzip files)
- - More readable code (I hope)
-- New and improved crc32()
- - About 50% faster, thanks to suggestions from Rodney Brown
-- Add deflateBound() and compressBound() functions
-- Fix memory leak in deflateInit2()
-- Permit setting dictionary for raw deflate (for parallel deflate)
-- Fix const declaration for gzwrite()
-- Check for some malloc() failures in gzio.c
-- Fix bug in gzopen() on single-byte file 0x1f
-- Fix bug in gzread() on concatenated file with 0x1f at end of buffer
- and next buffer doesn't start with 0x8b
-- Fix uncompress() to return Z_DATA_ERROR on truncated input
-- Free memory at end of example.c
-- Remove MAX #define in trees.c (conflicted with some libraries)
-- Fix static const's in deflate.c, gzio.c, and zutil.[ch]
-- Declare malloc() and free() in gzio.c if STDC not defined
-- Use malloc() instead of calloc() in zutil.c if int big enough
-- Define STDC for AIX
-- Add aix/ with approach for compiling shared library on AIX
-- Add HP-UX support for shared libraries in configure
-- Add OpenUNIX support for shared libraries in configure
-- Use $cc instead of gcc to build shared library
-- Make prefix directory if needed when installing
-- Correct Macintosh avoidance of typedef Byte in zconf.h
-- Correct Turbo C memory allocation when under Linux
-- Use libz.a instead of -lz in Makefile (assure use of compiled library)
-- Update configure to check for snprintf or vsnprintf functions and their
- return value, warn during make if using an insecure function
-- Fix configure problem with compile-time knowledge of HAVE_UNISTD_H that
- is lost when library is used--resolution is to build new zconf.h
-- Documentation improvements (in zlib.h):
- - Document raw deflate and inflate
- - Update RFCs URL
- - Point out that zlib and gzip formats are different
- - Note that Z_BUF_ERROR is not fatal
- - Document string limit for gzprintf() and possible buffer overflow
- - Note requirement on avail_out when flushing
- - Note permitted values of flush parameter of inflate()
-- Add some FAQs (and even answers) to the FAQ
-- Add contrib/inflate86/ for x86 faster inflate
-- Add contrib/blast/ for PKWare Data Compression Library decompression
-- Add contrib/puff/ simple inflate for deflate format description
-
-Changes in 1.1.4 (11 March 2002)
-- ZFREE was repeated on same allocation on some error conditions.
- This creates a security problem described in
- http://www.zlib.org/advisory-2002-03-11.txt
-- Returned incorrect error (Z_MEM_ERROR) on some invalid data
-- Avoid accesses before window for invalid distances with inflate window
- less than 32K.
-- force windowBits > 8 to avoid a bug in the encoder for a window size
- of 256 bytes. (A complete fix will be available in 1.1.5).
-
-Changes in 1.1.3 (9 July 1998)
-- fix "an inflate input buffer bug that shows up on rare but persistent
- occasions" (Mark)
-- fix gzread and gztell for concatenated .gz files (Didier Le Botlan)
-- fix gzseek(..., SEEK_SET) in write mode
-- fix crc check after a gzeek (Frank Faubert)
-- fix miniunzip when the last entry in a zip file is itself a zip file
- (J Lillge)
-- add contrib/asm586 and contrib/asm686 (Brian Raiter)
- See http://www.muppetlabs.com/~breadbox/software/assembly.html
-- add support for Delphi 3 in contrib/delphi (Bob Dellaca)
-- add support for C++Builder 3 and Delphi 3 in contrib/delphi2 (Davide Moretti)
-- do not exit prematurely in untgz if 0 at start of block (Magnus Holmgren)
-- use macro EXTERN instead of extern to support DLL for BeOS (Sander Stoks)
-- added a FAQ file
-
-- Support gzdopen on Mac with Metrowerks (Jason Linhart)
-- Do not redefine Byte on Mac (Brad Pettit & Jason Linhart)
-- define SEEK_END too if SEEK_SET is not defined (Albert Chin-A-Young)
-- avoid some warnings with Borland C (Tom Tanner)
-- fix a problem in contrib/minizip/zip.c for 16-bit MSDOS (Gilles Vollant)
-- emulate utime() for WIN32 in contrib/untgz (Gilles Vollant)
-- allow several arguments to configure (Tim Mooney, Frodo Looijaard)
-- use libdir and includedir in Makefile.in (Tim Mooney)
-- support shared libraries on OSF1 V4 (Tim Mooney)
-- remove so_locations in "make clean" (Tim Mooney)
-- fix maketree.c compilation error (Glenn, Mark)
-- Python interface to zlib now in Python 1.5 (Jeremy Hylton)
-- new Makefile.riscos (Rich Walker)
-- initialize static descriptors in trees.c for embedded targets (Nick Smith)
-- use "foo-gz" in example.c for RISCOS and VMS (Nick Smith)
-- add the OS/2 files in Makefile.in too (Andrew Zabolotny)
-- fix fdopen and halloc macros for Microsoft C 6.0 (Tom Lane)
-- fix maketree.c to allow clean compilation of inffixed.h (Mark)
-- fix parameter check in deflateCopy (Gunther Nikl)
-- cleanup trees.c, use compressed_len only in debug mode (Christian Spieler)
-- Many portability patches by Christian Spieler:
- . zutil.c, zutil.h: added "const" for zmem*
- . Make_vms.com: fixed some typos
- . Make_vms.com: msdos/Makefile.*: removed zutil.h from some dependency lists
- . msdos/Makefile.msc: remove "default rtl link library" info from obj files
- . msdos/Makefile.*: use model-dependent name for the built zlib library
- . msdos/Makefile.emx, nt/Makefile.emx, nt/Makefile.gcc:
- new makefiles, for emx (DOS/OS2), emx&rsxnt and mingw32 (Windows 9x / NT)
-- use define instead of typedef for Bytef also for MSC small/medium (Tom Lane)
-- replace __far with _far for better portability (Christian Spieler, Tom Lane)
-- fix test for errno.h in configure (Tim Newsham)
-
-Changes in 1.1.2 (19 March 98)
-- added contrib/minzip, mini zip and unzip based on zlib (Gilles Vollant)
- See http://www.winimage.com/zLibDll/unzip.html
-- preinitialize the inflate tables for fixed codes, to make the code
- completely thread safe (Mark)
-- some simplifications and slight speed-up to the inflate code (Mark)
-- fix gzeof on non-compressed files (Allan Schrum)
-- add -std1 option in configure for OSF1 to fix gzprintf (Martin Mokrejs)
-- use default value of 4K for Z_BUFSIZE for 16-bit MSDOS (Tim Wegner + Glenn)
-- added os2/Makefile.def and os2/zlib.def (Andrew Zabolotny)
-- add shared lib support for UNIX_SV4.2MP (MATSUURA Takanori)
-- do not wrap extern "C" around system includes (Tom Lane)
-- mention zlib binding for TCL in README (Andreas Kupries)
-- added amiga/Makefile.pup for Amiga powerUP SAS/C PPC (Andreas Kleinert)
-- allow "make install prefix=..." even after configure (Glenn Randers-Pehrson)
-- allow "configure --prefix $HOME" (Tim Mooney)
-- remove warnings in example.c and gzio.c (Glenn Randers-Pehrson)
-- move Makefile.sas to amiga/Makefile.sas
-
-Changes in 1.1.1 (27 Feb 98)
-- fix macros _tr_tally_* in deflate.h for debug mode (Glenn Randers-Pehrson)
-- remove block truncation heuristic which had very marginal effect for zlib
- (smaller lit_bufsize than in gzip 1.2.4) and degraded a little the
- compression ratio on some files. This also allows inlining _tr_tally for
- matches in deflate_slow.
-- added msdos/Makefile.w32 for WIN32 Microsoft Visual C++ (Bob Frazier)
-
-Changes in 1.1.0 (24 Feb 98)
-- do not return STREAM_END prematurely in inflate (John Bowler)
-- revert to the zlib 1.0.8 inflate to avoid the gcc 2.8.0 bug (Jeremy Buhler)
-- compile with -DFASTEST to get compression code optimized for speed only
-- in minigzip, try mmap'ing the input file first (Miguel Albrecht)
-- increase size of I/O buffers in minigzip.c and gzio.c (not a big gain
- on Sun but significant on HP)
-
-- add a pointer to experimental unzip library in README (Gilles Vollant)
-- initialize variable gcc in configure (Chris Herborth)
-
-Changes in 1.0.9 (17 Feb 1998)
-- added gzputs and gzgets functions
-- do not clear eof flag in gzseek (Mark Diekhans)
-- fix gzseek for files in transparent mode (Mark Diekhans)
-- do not assume that vsprintf returns the number of bytes written (Jens Krinke)
-- replace EXPORT with ZEXPORT to avoid conflict with other programs
-- added compress2 in zconf.h, zlib.def, zlib.dnt
-- new asm code from Gilles Vollant in contrib/asm386
-- simplify the inflate code (Mark):
- . Replace ZALLOC's in huft_build() with single ZALLOC in inflate_blocks_new()
- . ZALLOC the length list in inflate_trees_fixed() instead of using stack
- . ZALLOC the value area for huft_build() instead of using stack
- . Simplify Z_FINISH check in inflate()
-
-- Avoid gcc 2.8.0 comparison bug a little differently than zlib 1.0.8
-- in inftrees.c, avoid cc -O bug on HP (Farshid Elahi)
-- in zconf.h move the ZLIB_DLL stuff earlier to avoid problems with
- the declaration of FAR (Gilles VOllant)
-- install libz.so* with mode 755 (executable) instead of 644 (Marc Lehmann)
-- read_buf buf parameter of type Bytef* instead of charf*
-- zmemcpy parameters are of type Bytef*, not charf* (Joseph Strout)
-- do not redeclare unlink in minigzip.c for WIN32 (John Bowler)
-- fix check for presence of directories in "make install" (Ian Willis)
-
-Changes in 1.0.8 (27 Jan 1998)
-- fixed offsets in contrib/asm386/gvmat32.asm (Gilles Vollant)
-- fix gzgetc and gzputc for big endian systems (Markus Oberhumer)
-- added compress2() to allow setting the compression level
-- include sys/types.h to get off_t on some systems (Marc Lehmann & QingLong)
-- use constant arrays for the static trees in trees.c instead of computing
- them at run time (thanks to Ken Raeburn for this suggestion). To create
- trees.h, compile with GEN_TREES_H and run "make test".
-- check return code of example in "make test" and display result
-- pass minigzip command line options to file_compress
-- simplifying code of inflateSync to avoid gcc 2.8 bug
-
-- support CC="gcc -Wall" in configure -s (QingLong)
-- avoid a flush caused by ftell in gzopen for write mode (Ken Raeburn)
-- fix test for shared library support to avoid compiler warnings
-- zlib.lib -> zlib.dll in msdos/zlib.rc (Gilles Vollant)
-- check for TARGET_OS_MAC in addition to MACOS (Brad Pettit)
-- do not use fdopen for Metrowerks on Mac (Brad Pettit))
-- add checks for gzputc and gzputc in example.c
-- avoid warnings in gzio.c and deflate.c (Andreas Kleinert)
-- use const for the CRC table (Ken Raeburn)
-- fixed "make uninstall" for shared libraries
-- use Tracev instead of Trace in infblock.c
-- in example.c use correct compressed length for test_sync
-- suppress +vnocompatwarnings in configure for HPUX (not always supported)
-
-Changes in 1.0.7 (20 Jan 1998)
-- fix gzseek which was broken in write mode
-- return error for gzseek to negative absolute position
-- fix configure for Linux (Chun-Chung Chen)
-- increase stack space for MSC (Tim Wegner)
-- get_crc_table and inflateSyncPoint are EXPORTed (Gilles Vollant)
-- define EXPORTVA for gzprintf (Gilles Vollant)
-- added man page zlib.3 (Rick Rodgers)
-- for contrib/untgz, fix makedir() and improve Makefile
-
-- check gzseek in write mode in example.c
-- allocate extra buffer for seeks only if gzseek is actually called
-- avoid signed/unsigned comparisons (Tim Wegner, Gilles Vollant)
-- add inflateSyncPoint in zconf.h
-- fix list of exported functions in nt/zlib.dnt and mdsos/zlib.def
-
-Changes in 1.0.6 (19 Jan 1998)
-- add functions gzprintf, gzputc, gzgetc, gztell, gzeof, gzseek, gzrewind and
- gzsetparams (thanks to Roland Giersig and Kevin Ruland for some of this code)
-- Fix a deflate bug occurring only with compression level 0 (thanks to
- Andy Buckler for finding this one).
-- In minigzip, pass transparently also the first byte for .Z files.
-- return Z_BUF_ERROR instead of Z_OK if output buffer full in uncompress()
-- check Z_FINISH in inflate (thanks to Marc Schluper)
-- Implement deflateCopy (thanks to Adam Costello)
-- make static libraries by default in configure, add --shared option.
-- move MSDOS or Windows specific files to directory msdos
-- suppress the notion of partial flush to simplify the interface
- (but the symbol Z_PARTIAL_FLUSH is kept for compatibility with 1.0.4)
-- suppress history buffer provided by application to simplify the interface
- (this feature was not implemented anyway in 1.0.4)
-- next_in and avail_in must be initialized before calling inflateInit or
- inflateInit2
-- add EXPORT in all exported functions (for Windows DLL)
-- added Makefile.nt (thanks to Stephen Williams)
-- added the unsupported "contrib" directory:
- contrib/asm386/ by Gilles Vollant <info@winimage.com>
- 386 asm code replacing longest_match().
- contrib/iostream/ by Kevin Ruland <kevin@rodin.wustl.edu>
- A C++ I/O streams interface to the zlib gz* functions
- contrib/iostream2/ by Tyge Løvset <Tyge.Lovset@cmr.no>
- Another C++ I/O streams interface
- contrib/untgz/ by "Pedro A. Aranda Guti\irrez" <paag@tid.es>
- A very simple tar.gz file extractor using zlib
- contrib/visual-basic.txt by Carlos Rios <c_rios@sonda.cl>
- How to use compress(), uncompress() and the gz* functions from VB.
-- pass params -f (filtered data), -h (huffman only), -1 to -9 (compression
- level) in minigzip (thanks to Tom Lane)
-
-- use const for rommable constants in deflate
-- added test for gzseek and gztell in example.c
-- add undocumented function inflateSyncPoint() (hack for Paul Mackerras)
-- add undocumented function zError to convert error code to string
- (for Tim Smithers)
-- Allow compilation of gzio with -DNO_DEFLATE to avoid the compression code.
-- Use default memcpy for Symantec MSDOS compiler.
-- Add EXPORT keyword for check_func (needed for Windows DLL)
-- add current directory to LD_LIBRARY_PATH for "make test"
-- create also a link for libz.so.1
-- added support for FUJITSU UXP/DS (thanks to Toshiaki Nomura)
-- use $(SHAREDLIB) instead of libz.so in Makefile.in (for HPUX)
-- added -soname for Linux in configure (Chun-Chung Chen,
-- assign numbers to the exported functions in zlib.def (for Windows DLL)
-- add advice in zlib.h for best usage of deflateSetDictionary
-- work around compiler bug on Atari (cast Z_NULL in call of s->checkfn)
-- allow compilation with ANSI keywords only enabled for TurboC in large model
-- avoid "versionString"[0] (Borland bug)
-- add NEED_DUMMY_RETURN for Borland
-- use variable z_verbose for tracing in debug mode (L. Peter Deutsch).
-- allow compilation with CC
-- defined STDC for OS/2 (David Charlap)
-- limit external names to 8 chars for MVS (Thomas Lund)
-- in minigzip.c, use static buffers only for 16-bit systems
-- fix suffix check for "minigzip -d foo.gz"
-- do not return an error for the 2nd of two consecutive gzflush() (Felix Lee)
-- use _fdopen instead of fdopen for MSC >= 6.0 (Thomas Fanslau)
-- added makelcc.bat for lcc-win32 (Tom St Denis)
-- in Makefile.dj2, use copy and del instead of install and rm (Frank Donahoe)
-- Avoid expanded $Id$. Use "rcs -kb" or "cvs admin -kb" to avoid Id expansion.
-- check for unistd.h in configure (for off_t)
-- remove useless check parameter in inflate_blocks_free
-- avoid useless assignment of s->check to itself in inflate_blocks_new
-- do not flush twice in gzclose (thanks to Ken Raeburn)
-- rename FOPEN as F_OPEN to avoid clash with /usr/include/sys/file.h
-- use NO_ERRNO_H instead of enumeration of operating systems with errno.h
-- work around buggy fclose on pipes for HP/UX
-- support zlib DLL with BORLAND C++ 5.0 (thanks to Glenn Randers-Pehrson)
-- fix configure if CC is already equal to gcc
-
-Changes in 1.0.5 (3 Jan 98)
-- Fix inflate to terminate gracefully when fed corrupted or invalid data
-- Use const for rommable constants in inflate
-- Eliminate memory leaks on error conditions in inflate
-- Removed some vestigial code in inflate
-- Update web address in README
-
-Changes in 1.0.4 (24 Jul 96)
-- In very rare conditions, deflate(s, Z_FINISH) could fail to produce an EOF
- bit, so the decompressor could decompress all the correct data but went
- on to attempt decompressing extra garbage data. This affected minigzip too.
-- zlibVersion and gzerror return const char* (needed for DLL)
-- port to RISCOS (no fdopen, no multiple dots, no unlink, no fileno)
-- use z_error only for DEBUG (avoid problem with DLLs)
-
-Changes in 1.0.3 (2 Jul 96)
-- use z_streamp instead of z_stream *, which is now a far pointer in MSDOS
- small and medium models; this makes the library incompatible with previous
- versions for these models. (No effect in large model or on other systems.)
-- return OK instead of BUF_ERROR if previous deflate call returned with
- avail_out as zero but there is nothing to do
-- added memcmp for non STDC compilers
-- define NO_DUMMY_DECL for more Mac compilers (.h files merged incorrectly)
-- define __32BIT__ if __386__ or i386 is defined (pb. with Watcom and SCO)
-- better check for 16-bit mode MSC (avoids problem with Symantec)
-
-Changes in 1.0.2 (23 May 96)
-- added Windows DLL support
-- added a function zlibVersion (for the DLL support)
-- fixed declarations using Bytef in infutil.c (pb with MSDOS medium model)
-- Bytef is define's instead of typedef'd only for Borland C
-- avoid reading uninitialized memory in example.c
-- mention in README that the zlib format is now RFC1950
-- updated Makefile.dj2
-- added algorithm.doc
-
-Changes in 1.0.1 (20 May 96) [1.0 skipped to avoid confusion]
-- fix array overlay in deflate.c which sometimes caused bad compressed data
-- fix inflate bug with empty stored block
-- fix MSDOS medium model which was broken in 0.99
-- fix deflateParams() which could generated bad compressed data.
-- Bytef is define'd instead of typedef'ed (work around Borland bug)
-- added an INDEX file
-- new makefiles for DJGPP (Makefile.dj2), 32-bit Borland (Makefile.b32),
- Watcom (Makefile.wat), Amiga SAS/C (Makefile.sas)
-- speed up adler32 for modern machines without auto-increment
-- added -ansi for IRIX in configure
-- static_init_done in trees.c is an int
-- define unlink as delete for VMS
-- fix configure for QNX
-- add configure branch for SCO and HPUX
-- avoid many warnings (unused variables, dead assignments, etc...)
-- no fdopen for BeOS
-- fix the Watcom fix for 32 bit mode (define FAR as empty)
-- removed redefinition of Byte for MKWERKS
-- work around an MWKERKS bug (incorrect merge of all .h files)
-
-Changes in 0.99 (27 Jan 96)
-- allow preset dictionary shared between compressor and decompressor
-- allow compression level 0 (no compression)
-- add deflateParams in zlib.h: allow dynamic change of compression level
- and compression strategy.
-- test large buffers and deflateParams in example.c
-- add optional "configure" to build zlib as a shared library
-- suppress Makefile.qnx, use configure instead
-- fixed deflate for 64-bit systems (detected on Cray)
-- fixed inflate_blocks for 64-bit systems (detected on Alpha)
-- declare Z_DEFLATED in zlib.h (possible parameter for deflateInit2)
-- always return Z_BUF_ERROR when deflate() has nothing to do
-- deflateInit and inflateInit are now macros to allow version checking
-- prefix all global functions and types with z_ with -DZ_PREFIX
-- make falloc completely reentrant (inftrees.c)
-- fixed very unlikely race condition in ct_static_init
-- free in reverse order of allocation to help memory manager
-- use zlib-1.0/* instead of zlib/* inside the tar.gz
-- make zlib warning-free with "gcc -O3 -Wall -Wwrite-strings -Wpointer-arith
- -Wconversion -Wstrict-prototypes -Wmissing-prototypes"
-- allow gzread on concatenated .gz files
-- deflateEnd now returns Z_DATA_ERROR if it was premature
-- deflate is finally (?) fully deterministic (no matches beyond end of input)
-- Document Z_SYNC_FLUSH
-- add uninstall in Makefile
-- Check for __cpluplus in zlib.h
-- Better test in ct_align for partial flush
-- avoid harmless warnings for Borland C++
-- initialize hash_head in deflate.c
-- avoid warning on fdopen (gzio.c) for HP cc -Aa
-- include stdlib.h for STDC compilers
-- include errno.h for Cray
-- ignore error if ranlib doesn't exist
-- call ranlib twice for NeXTSTEP
-- use exec_prefix instead of prefix for libz.a
-- renamed ct_* as _tr_* to avoid conflict with applications
-- clear z->msg in inflateInit2 before any error return
-- initialize opaque in example.c, gzio.c, deflate.c and inflate.c
-- fixed typo in zconf.h (_GNUC__ => __GNUC__)
-- check for WIN32 in zconf.h and zutil.c (avoid farmalloc in 32-bit mode)
-- fix typo in Make_vms.com (f$trnlnm -> f$getsyi)
-- in fcalloc, normalize pointer if size > 65520 bytes
-- don't use special fcalloc for 32 bit Borland C++
-- use STDC instead of __GO32__ to avoid redeclaring exit, calloc, etc...
-- use Z_BINARY instead of BINARY
-- document that gzclose after gzdopen will close the file
-- allow "a" as mode in gzopen.
-- fix error checking in gzread
-- allow skipping .gz extra-field on pipes
-- added reference to Perl interface in README
-- put the crc table in FAR data (I dislike more and more the medium model :)
-- added get_crc_table
-- added a dimension to all arrays (Borland C can't count).
-- workaround Borland C bug in declaration of inflate_codes_new & inflate_fast
-- guard against multiple inclusion of *.h (for precompiled header on Mac)
-- Watcom C pretends to be Microsoft C small model even in 32 bit mode.
-- don't use unsized arrays to avoid silly warnings by Visual C++:
- warning C4746: 'inflate_mask' : unsized array treated as '__far'
- (what's wrong with far data in far model?).
-- define enum out of inflate_blocks_state to allow compilation with C++
-
-Changes in 0.95 (16 Aug 95)
-- fix MSDOS small and medium model (now easier to adapt to any compiler)
-- inlined send_bits
-- fix the final (:-) bug for deflate with flush (output was correct but
- not completely flushed in rare occasions).
-- default window size is same for compression and decompression
- (it's now sufficient to set MAX_WBITS in zconf.h).
-- voidp -> voidpf and voidnp -> voidp (for consistency with other
- typedefs and because voidnp was not near in large model).
-
-Changes in 0.94 (13 Aug 95)
-- support MSDOS medium model
-- fix deflate with flush (could sometimes generate bad output)
-- fix deflateReset (zlib header was incorrectly suppressed)
-- added support for VMS
-- allow a compression level in gzopen()
-- gzflush now calls fflush
-- For deflate with flush, flush even if no more input is provided.
-- rename libgz.a as libz.a
-- avoid complex expression in infcodes.c triggering Turbo C bug
-- work around a problem with gcc on Alpha (in INSERT_STRING)
-- don't use inline functions (problem with some gcc versions)
-- allow renaming of Byte, uInt, etc... with #define.
-- avoid warning about (unused) pointer before start of array in deflate.c
-- avoid various warnings in gzio.c, example.c, infblock.c, adler32.c, zutil.c
-- avoid reserved word 'new' in trees.c
-
-Changes in 0.93 (25 June 95)
-- temporarily disable inline functions
-- make deflate deterministic
-- give enough lookahead for PARTIAL_FLUSH
-- Set binary mode for stdin/stdout in minigzip.c for OS/2
-- don't even use signed char in inflate (not portable enough)
-- fix inflate memory leak for segmented architectures
-
-Changes in 0.92 (3 May 95)
-- don't assume that char is signed (problem on SGI)
-- Clear bit buffer when starting a stored block
-- no memcpy on Pyramid
-- suppressed inftest.c
-- optimized fill_window, put longest_match inline for gcc
-- optimized inflate on stored blocks.
-- untabify all sources to simplify patches
-
-Changes in 0.91 (2 May 95)
-- Default MEM_LEVEL is 8 (not 9 for Unix) as documented in zlib.h
-- Document the memory requirements in zconf.h
-- added "make install"
-- fix sync search logic in inflateSync
-- deflate(Z_FULL_FLUSH) now works even if output buffer too short
-- after inflateSync, don't scare people with just "lo world"
-- added support for DJGPP
-
-Changes in 0.9 (1 May 95)
-- don't assume that zalloc clears the allocated memory (the TurboC bug
- was Mark's bug after all :)
-- let again gzread copy uncompressed data unchanged (was working in 0.71)
-- deflate(Z_FULL_FLUSH), inflateReset and inflateSync are now fully implemented
-- added a test of inflateSync in example.c
-- moved MAX_WBITS to zconf.h because users might want to change that.
-- document explicitly that zalloc(64K) on MSDOS must return a normalized
- pointer (zero offset)
-- added Makefiles for Microsoft C, Turbo C, Borland C++
-- faster crc32()
-
-Changes in 0.8 (29 April 95)
-- added fast inflate (inffast.c)
-- deflate(Z_FINISH) now returns Z_STREAM_END when done. Warning: this
- is incompatible with previous versions of zlib which returned Z_OK.
-- work around a TurboC compiler bug (bad code for b << 0, see infutil.h)
- (actually that was not a compiler bug, see 0.81 above)
-- gzread no longer reads one extra byte in certain cases
-- In gzio destroy(), don't reference a freed structure
-- avoid many warnings for MSDOS
-- avoid the ERROR symbol which is used by MS Windows
-
-Changes in 0.71 (14 April 95)
-- Fixed more MSDOS compilation problems :( There is still a bug with
- TurboC large model.
-
-Changes in 0.7 (14 April 95)
-- Added full inflate support.
-- Simplified the crc32() interface. The pre- and post-conditioning
- (one's complement) is now done inside crc32(). WARNING: this is
- incompatible with previous versions; see zlib.h for the new usage.
-
-Changes in 0.61 (12 April 95)
-- workaround for a bug in TurboC. example and minigzip now work on MSDOS.
-
-Changes in 0.6 (11 April 95)
-- added minigzip.c
-- added gzdopen to reopen a file descriptor as gzFile
-- added transparent reading of non-gziped files in gzread.
-- fixed bug in gzread (don't read crc as data)
-- fixed bug in destroy (gzio.c) (don't return Z_STREAM_END for gzclose).
-- don't allocate big arrays in the stack (for MSDOS)
-- fix some MSDOS compilation problems
-
-Changes in 0.5:
-- do real compression in deflate.c. Z_PARTIAL_FLUSH is supported but
- not yet Z_FULL_FLUSH.
-- support decompression but only in a single step (forced Z_FINISH)
-- added opaque object for zalloc and zfree.
-- added deflateReset and inflateReset
-- added a variable zlib_version for consistency checking.
-- renamed the 'filter' parameter of deflateInit2 as 'strategy'.
- Added Z_FILTERED and Z_HUFFMAN_ONLY constants.
-
-Changes in 0.4:
-- avoid "zip" everywhere, use zlib instead of ziplib.
-- suppress Z_BLOCK_FLUSH, interpret Z_PARTIAL_FLUSH as block flush
- if compression method == 8.
-- added adler32 and crc32
-- renamed deflateOptions as deflateInit2, call one or the other but not both
-- added the method parameter for deflateInit2.
-- added inflateInit2
-- simplied considerably deflateInit and inflateInit by not supporting
- user-provided history buffer. This is supported only in deflateInit2
- and inflateInit2.
-
-Changes in 0.3:
-- prefix all macro names with Z_
-- use Z_FINISH instead of deflateEnd to finish compression.
-- added Z_HUFFMAN_ONLY
-- added gzerror()
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/README Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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.
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/compress.c Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,103 +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.
- */
-
-/* compress.c -- compress a memory buffer
- * Copyright (C) 1995-2003 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* @(#) $Id$ */
-
-#define ZLIB_INTERNAL
-#include "zlib.h"
-
-/* ===========================================================================
- 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 0.1% larger than sourceLen plus
- 12 bytes. 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.
-*/
-int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
- Bytef *dest;
- uLongf *destLen;
- const Bytef *source;
- uLong sourceLen;
- int level;
-{
- z_stream stream;
- int err;
-
- stream.next_in = (Bytef*)source;
- stream.avail_in = (uInt)sourceLen;
-#ifdef MAXSEG_64K
- /* Check for source > 64K on 16-bit machine: */
- if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
-#endif
- stream.next_out = dest;
- stream.avail_out = (uInt)*destLen;
- if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
-
- stream.zalloc = (alloc_func)0;
- stream.zfree = (free_func)0;
- stream.opaque = (voidpf)0;
-
- err = deflateInit(&stream, level);
- if (err != Z_OK) return err;
-
- err = deflate(&stream, Z_FINISH);
- if (err != Z_STREAM_END) {
- deflateEnd(&stream);
- return err == Z_OK ? Z_BUF_ERROR : err;
- }
- *destLen = (uLong)stream.total_out;
-
- err = deflateEnd(&stream);
- return err;
-}
-
-/* ===========================================================================
- */
-int ZEXPORT compress (dest, destLen, source, sourceLen)
- Bytef *dest;
- uLongf *destLen;
- const Bytef *source;
- uLong sourceLen;
-{
- return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
-}
-
-/* ===========================================================================
- If the default memLevel or windowBits for deflateInit() is changed, then
- this function needs to be updated.
- */
-uLong ZEXPORT compressBound (sourceLen)
- uLong sourceLen;
-{
- return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + 11;
-}
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/crc32.h Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,465 +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.
- */
-
-/* crc32.h -- tables for rapid CRC calculation
- * Generated automatically by crc32.c
- */
-
-local const unsigned long FAR crc_table[TBLS][256] =
-{
- {
- 0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL,
- 0x706af48fUL, 0xe963a535UL, 0x9e6495a3UL, 0x0edb8832UL, 0x79dcb8a4UL,
- 0xe0d5e91eUL, 0x97d2d988UL, 0x09b64c2bUL, 0x7eb17cbdUL, 0xe7b82d07UL,
- 0x90bf1d91UL, 0x1db71064UL, 0x6ab020f2UL, 0xf3b97148UL, 0x84be41deUL,
- 0x1adad47dUL, 0x6ddde4ebUL, 0xf4d4b551UL, 0x83d385c7UL, 0x136c9856UL,
- 0x646ba8c0UL, 0xfd62f97aUL, 0x8a65c9ecUL, 0x14015c4fUL, 0x63066cd9UL,
- 0xfa0f3d63UL, 0x8d080df5UL, 0x3b6e20c8UL, 0x4c69105eUL, 0xd56041e4UL,
- 0xa2677172UL, 0x3c03e4d1UL, 0x4b04d447UL, 0xd20d85fdUL, 0xa50ab56bUL,
- 0x35b5a8faUL, 0x42b2986cUL, 0xdbbbc9d6UL, 0xacbcf940UL, 0x32d86ce3UL,
- 0x45df5c75UL, 0xdcd60dcfUL, 0xabd13d59UL, 0x26d930acUL, 0x51de003aUL,
- 0xc8d75180UL, 0xbfd06116UL, 0x21b4f4b5UL, 0x56b3c423UL, 0xcfba9599UL,
- 0xb8bda50fUL, 0x2802b89eUL, 0x5f058808UL, 0xc60cd9b2UL, 0xb10be924UL,
- 0x2f6f7c87UL, 0x58684c11UL, 0xc1611dabUL, 0xb6662d3dUL, 0x76dc4190UL,
- 0x01db7106UL, 0x98d220bcUL, 0xefd5102aUL, 0x71b18589UL, 0x06b6b51fUL,
- 0x9fbfe4a5UL, 0xe8b8d433UL, 0x7807c9a2UL, 0x0f00f934UL, 0x9609a88eUL,
- 0xe10e9818UL, 0x7f6a0dbbUL, 0x086d3d2dUL, 0x91646c97UL, 0xe6635c01UL,
- 0x6b6b51f4UL, 0x1c6c6162UL, 0x856530d8UL, 0xf262004eUL, 0x6c0695edUL,
- 0x1b01a57bUL, 0x8208f4c1UL, 0xf50fc457UL, 0x65b0d9c6UL, 0x12b7e950UL,
- 0x8bbeb8eaUL, 0xfcb9887cUL, 0x62dd1ddfUL, 0x15da2d49UL, 0x8cd37cf3UL,
- 0xfbd44c65UL, 0x4db26158UL, 0x3ab551ceUL, 0xa3bc0074UL, 0xd4bb30e2UL,
- 0x4adfa541UL, 0x3dd895d7UL, 0xa4d1c46dUL, 0xd3d6f4fbUL, 0x4369e96aUL,
- 0x346ed9fcUL, 0xad678846UL, 0xda60b8d0UL, 0x44042d73UL, 0x33031de5UL,
- 0xaa0a4c5fUL, 0xdd0d7cc9UL, 0x5005713cUL, 0x270241aaUL, 0xbe0b1010UL,
- 0xc90c2086UL, 0x5768b525UL, 0x206f85b3UL, 0xb966d409UL, 0xce61e49fUL,
- 0x5edef90eUL, 0x29d9c998UL, 0xb0d09822UL, 0xc7d7a8b4UL, 0x59b33d17UL,
- 0x2eb40d81UL, 0xb7bd5c3bUL, 0xc0ba6cadUL, 0xedb88320UL, 0x9abfb3b6UL,
- 0x03b6e20cUL, 0x74b1d29aUL, 0xead54739UL, 0x9dd277afUL, 0x04db2615UL,
- 0x73dc1683UL, 0xe3630b12UL, 0x94643b84UL, 0x0d6d6a3eUL, 0x7a6a5aa8UL,
- 0xe40ecf0bUL, 0x9309ff9dUL, 0x0a00ae27UL, 0x7d079eb1UL, 0xf00f9344UL,
- 0x8708a3d2UL, 0x1e01f268UL, 0x6906c2feUL, 0xf762575dUL, 0x806567cbUL,
- 0x196c3671UL, 0x6e6b06e7UL, 0xfed41b76UL, 0x89d32be0UL, 0x10da7a5aUL,
- 0x67dd4accUL, 0xf9b9df6fUL, 0x8ebeeff9UL, 0x17b7be43UL, 0x60b08ed5UL,
- 0xd6d6a3e8UL, 0xa1d1937eUL, 0x38d8c2c4UL, 0x4fdff252UL, 0xd1bb67f1UL,
- 0xa6bc5767UL, 0x3fb506ddUL, 0x48b2364bUL, 0xd80d2bdaUL, 0xaf0a1b4cUL,
- 0x36034af6UL, 0x41047a60UL, 0xdf60efc3UL, 0xa867df55UL, 0x316e8eefUL,
- 0x4669be79UL, 0xcb61b38cUL, 0xbc66831aUL, 0x256fd2a0UL, 0x5268e236UL,
- 0xcc0c7795UL, 0xbb0b4703UL, 0x220216b9UL, 0x5505262fUL, 0xc5ba3bbeUL,
- 0xb2bd0b28UL, 0x2bb45a92UL, 0x5cb36a04UL, 0xc2d7ffa7UL, 0xb5d0cf31UL,
- 0x2cd99e8bUL, 0x5bdeae1dUL, 0x9b64c2b0UL, 0xec63f226UL, 0x756aa39cUL,
- 0x026d930aUL, 0x9c0906a9UL, 0xeb0e363fUL, 0x72076785UL, 0x05005713UL,
- 0x95bf4a82UL, 0xe2b87a14UL, 0x7bb12baeUL, 0x0cb61b38UL, 0x92d28e9bUL,
- 0xe5d5be0dUL, 0x7cdcefb7UL, 0x0bdbdf21UL, 0x86d3d2d4UL, 0xf1d4e242UL,
- 0x68ddb3f8UL, 0x1fda836eUL, 0x81be16cdUL, 0xf6b9265bUL, 0x6fb077e1UL,
- 0x18b74777UL, 0x88085ae6UL, 0xff0f6a70UL, 0x66063bcaUL, 0x11010b5cUL,
- 0x8f659effUL, 0xf862ae69UL, 0x616bffd3UL, 0x166ccf45UL, 0xa00ae278UL,
- 0xd70dd2eeUL, 0x4e048354UL, 0x3903b3c2UL, 0xa7672661UL, 0xd06016f7UL,
- 0x4969474dUL, 0x3e6e77dbUL, 0xaed16a4aUL, 0xd9d65adcUL, 0x40df0b66UL,
- 0x37d83bf0UL, 0xa9bcae53UL, 0xdebb9ec5UL, 0x47b2cf7fUL, 0x30b5ffe9UL,
- 0xbdbdf21cUL, 0xcabac28aUL, 0x53b39330UL, 0x24b4a3a6UL, 0xbad03605UL,
- 0xcdd70693UL, 0x54de5729UL, 0x23d967bfUL, 0xb3667a2eUL, 0xc4614ab8UL,
- 0x5d681b02UL, 0x2a6f2b94UL, 0xb40bbe37UL, 0xc30c8ea1UL, 0x5a05df1bUL,
- 0x2d02ef8dUL
-#ifdef BYFOUR
- },
- {
- 0x00000000UL, 0x191b3141UL, 0x32366282UL, 0x2b2d53c3UL, 0x646cc504UL,
- 0x7d77f445UL, 0x565aa786UL, 0x4f4196c7UL, 0xc8d98a08UL, 0xd1c2bb49UL,
- 0xfaefe88aUL, 0xe3f4d9cbUL, 0xacb54f0cUL, 0xb5ae7e4dUL, 0x9e832d8eUL,
- 0x87981ccfUL, 0x4ac21251UL, 0x53d92310UL, 0x78f470d3UL, 0x61ef4192UL,
- 0x2eaed755UL, 0x37b5e614UL, 0x1c98b5d7UL, 0x05838496UL, 0x821b9859UL,
- 0x9b00a918UL, 0xb02dfadbUL, 0xa936cb9aUL, 0xe6775d5dUL, 0xff6c6c1cUL,
- 0xd4413fdfUL, 0xcd5a0e9eUL, 0x958424a2UL, 0x8c9f15e3UL, 0xa7b24620UL,
- 0xbea97761UL, 0xf1e8e1a6UL, 0xe8f3d0e7UL, 0xc3de8324UL, 0xdac5b265UL,
- 0x5d5daeaaUL, 0x44469febUL, 0x6f6bcc28UL, 0x7670fd69UL, 0x39316baeUL,
- 0x202a5aefUL, 0x0b07092cUL, 0x121c386dUL, 0xdf4636f3UL, 0xc65d07b2UL,
- 0xed705471UL, 0xf46b6530UL, 0xbb2af3f7UL, 0xa231c2b6UL, 0x891c9175UL,
- 0x9007a034UL, 0x179fbcfbUL, 0x0e848dbaUL, 0x25a9de79UL, 0x3cb2ef38UL,
- 0x73f379ffUL, 0x6ae848beUL, 0x41c51b7dUL, 0x58de2a3cUL, 0xf0794f05UL,
- 0xe9627e44UL, 0xc24f2d87UL, 0xdb541cc6UL, 0x94158a01UL, 0x8d0ebb40UL,
- 0xa623e883UL, 0xbf38d9c2UL, 0x38a0c50dUL, 0x21bbf44cUL, 0x0a96a78fUL,
- 0x138d96ceUL, 0x5ccc0009UL, 0x45d73148UL, 0x6efa628bUL, 0x77e153caUL,
- 0xbabb5d54UL, 0xa3a06c15UL, 0x888d3fd6UL, 0x91960e97UL, 0xded79850UL,
- 0xc7cca911UL, 0xece1fad2UL, 0xf5facb93UL, 0x7262d75cUL, 0x6b79e61dUL,
- 0x4054b5deUL, 0x594f849fUL, 0x160e1258UL, 0x0f152319UL, 0x243870daUL,
- 0x3d23419bUL, 0x65fd6ba7UL, 0x7ce65ae6UL, 0x57cb0925UL, 0x4ed03864UL,
- 0x0191aea3UL, 0x188a9fe2UL, 0x33a7cc21UL, 0x2abcfd60UL, 0xad24e1afUL,
- 0xb43fd0eeUL, 0x9f12832dUL, 0x8609b26cUL, 0xc94824abUL, 0xd05315eaUL,
- 0xfb7e4629UL, 0xe2657768UL, 0x2f3f79f6UL, 0x362448b7UL, 0x1d091b74UL,
- 0x04122a35UL, 0x4b53bcf2UL, 0x52488db3UL, 0x7965de70UL, 0x607eef31UL,
- 0xe7e6f3feUL, 0xfefdc2bfUL, 0xd5d0917cUL, 0xcccba03dUL, 0x838a36faUL,
- 0x9a9107bbUL, 0xb1bc5478UL, 0xa8a76539UL, 0x3b83984bUL, 0x2298a90aUL,
- 0x09b5fac9UL, 0x10aecb88UL, 0x5fef5d4fUL, 0x46f46c0eUL, 0x6dd93fcdUL,
- 0x74c20e8cUL, 0xf35a1243UL, 0xea412302UL, 0xc16c70c1UL, 0xd8774180UL,
- 0x9736d747UL, 0x8e2de606UL, 0xa500b5c5UL, 0xbc1b8484UL, 0x71418a1aUL,
- 0x685abb5bUL, 0x4377e898UL, 0x5a6cd9d9UL, 0x152d4f1eUL, 0x0c367e5fUL,
- 0x271b2d9cUL, 0x3e001cddUL, 0xb9980012UL, 0xa0833153UL, 0x8bae6290UL,
- 0x92b553d1UL, 0xddf4c516UL, 0xc4eff457UL, 0xefc2a794UL, 0xf6d996d5UL,
- 0xae07bce9UL, 0xb71c8da8UL, 0x9c31de6bUL, 0x852aef2aUL, 0xca6b79edUL,
- 0xd37048acUL, 0xf85d1b6fUL, 0xe1462a2eUL, 0x66de36e1UL, 0x7fc507a0UL,
- 0x54e85463UL, 0x4df36522UL, 0x02b2f3e5UL, 0x1ba9c2a4UL, 0x30849167UL,
- 0x299fa026UL, 0xe4c5aeb8UL, 0xfdde9ff9UL, 0xd6f3cc3aUL, 0xcfe8fd7bUL,
- 0x80a96bbcUL, 0x99b25afdUL, 0xb29f093eUL, 0xab84387fUL, 0x2c1c24b0UL,
- 0x350715f1UL, 0x1e2a4632UL, 0x07317773UL, 0x4870e1b4UL, 0x516bd0f5UL,
- 0x7a468336UL, 0x635db277UL, 0xcbfad74eUL, 0xd2e1e60fUL, 0xf9ccb5ccUL,
- 0xe0d7848dUL, 0xaf96124aUL, 0xb68d230bUL, 0x9da070c8UL, 0x84bb4189UL,
- 0x03235d46UL, 0x1a386c07UL, 0x31153fc4UL, 0x280e0e85UL, 0x674f9842UL,
- 0x7e54a903UL, 0x5579fac0UL, 0x4c62cb81UL, 0x8138c51fUL, 0x9823f45eUL,
- 0xb30ea79dUL, 0xaa1596dcUL, 0xe554001bUL, 0xfc4f315aUL, 0xd7626299UL,
- 0xce7953d8UL, 0x49e14f17UL, 0x50fa7e56UL, 0x7bd72d95UL, 0x62cc1cd4UL,
- 0x2d8d8a13UL, 0x3496bb52UL, 0x1fbbe891UL, 0x06a0d9d0UL, 0x5e7ef3ecUL,
- 0x4765c2adUL, 0x6c48916eUL, 0x7553a02fUL, 0x3a1236e8UL, 0x230907a9UL,
- 0x0824546aUL, 0x113f652bUL, 0x96a779e4UL, 0x8fbc48a5UL, 0xa4911b66UL,
- 0xbd8a2a27UL, 0xf2cbbce0UL, 0xebd08da1UL, 0xc0fdde62UL, 0xd9e6ef23UL,
- 0x14bce1bdUL, 0x0da7d0fcUL, 0x268a833fUL, 0x3f91b27eUL, 0x70d024b9UL,
- 0x69cb15f8UL, 0x42e6463bUL, 0x5bfd777aUL, 0xdc656bb5UL, 0xc57e5af4UL,
- 0xee530937UL, 0xf7483876UL, 0xb809aeb1UL, 0xa1129ff0UL, 0x8a3fcc33UL,
- 0x9324fd72UL
- },
- {
- 0x00000000UL, 0x01c26a37UL, 0x0384d46eUL, 0x0246be59UL, 0x0709a8dcUL,
- 0x06cbc2ebUL, 0x048d7cb2UL, 0x054f1685UL, 0x0e1351b8UL, 0x0fd13b8fUL,
- 0x0d9785d6UL, 0x0c55efe1UL, 0x091af964UL, 0x08d89353UL, 0x0a9e2d0aUL,
- 0x0b5c473dUL, 0x1c26a370UL, 0x1de4c947UL, 0x1fa2771eUL, 0x1e601d29UL,
- 0x1b2f0bacUL, 0x1aed619bUL, 0x18abdfc2UL, 0x1969b5f5UL, 0x1235f2c8UL,
- 0x13f798ffUL, 0x11b126a6UL, 0x10734c91UL, 0x153c5a14UL, 0x14fe3023UL,
- 0x16b88e7aUL, 0x177ae44dUL, 0x384d46e0UL, 0x398f2cd7UL, 0x3bc9928eUL,
- 0x3a0bf8b9UL, 0x3f44ee3cUL, 0x3e86840bUL, 0x3cc03a52UL, 0x3d025065UL,
- 0x365e1758UL, 0x379c7d6fUL, 0x35dac336UL, 0x3418a901UL, 0x3157bf84UL,
- 0x3095d5b3UL, 0x32d36beaUL, 0x331101ddUL, 0x246be590UL, 0x25a98fa7UL,
- 0x27ef31feUL, 0x262d5bc9UL, 0x23624d4cUL, 0x22a0277bUL, 0x20e69922UL,
- 0x2124f315UL, 0x2a78b428UL, 0x2bbade1fUL, 0x29fc6046UL, 0x283e0a71UL,
- 0x2d711cf4UL, 0x2cb376c3UL, 0x2ef5c89aUL, 0x2f37a2adUL, 0x709a8dc0UL,
- 0x7158e7f7UL, 0x731e59aeUL, 0x72dc3399UL, 0x7793251cUL, 0x76514f2bUL,
- 0x7417f172UL, 0x75d59b45UL, 0x7e89dc78UL, 0x7f4bb64fUL, 0x7d0d0816UL,
- 0x7ccf6221UL, 0x798074a4UL, 0x78421e93UL, 0x7a04a0caUL, 0x7bc6cafdUL,
- 0x6cbc2eb0UL, 0x6d7e4487UL, 0x6f38fadeUL, 0x6efa90e9UL, 0x6bb5866cUL,
- 0x6a77ec5bUL, 0x68315202UL, 0x69f33835UL, 0x62af7f08UL, 0x636d153fUL,
- 0x612bab66UL, 0x60e9c151UL, 0x65a6d7d4UL, 0x6464bde3UL, 0x662203baUL,
- 0x67e0698dUL, 0x48d7cb20UL, 0x4915a117UL, 0x4b531f4eUL, 0x4a917579UL,
- 0x4fde63fcUL, 0x4e1c09cbUL, 0x4c5ab792UL, 0x4d98dda5UL, 0x46c49a98UL,
- 0x4706f0afUL, 0x45404ef6UL, 0x448224c1UL, 0x41cd3244UL, 0x400f5873UL,
- 0x4249e62aUL, 0x438b8c1dUL, 0x54f16850UL, 0x55330267UL, 0x5775bc3eUL,
- 0x56b7d609UL, 0x53f8c08cUL, 0x523aaabbUL, 0x507c14e2UL, 0x51be7ed5UL,
- 0x5ae239e8UL, 0x5b2053dfUL, 0x5966ed86UL, 0x58a487b1UL, 0x5deb9134UL,
- 0x5c29fb03UL, 0x5e6f455aUL, 0x5fad2f6dUL, 0xe1351b80UL, 0xe0f771b7UL,
- 0xe2b1cfeeUL, 0xe373a5d9UL, 0xe63cb35cUL, 0xe7fed96bUL, 0xe5b86732UL,
- 0xe47a0d05UL, 0xef264a38UL, 0xeee4200fUL, 0xeca29e56UL, 0xed60f461UL,
- 0xe82fe2e4UL, 0xe9ed88d3UL, 0xebab368aUL, 0xea695cbdUL, 0xfd13b8f0UL,
- 0xfcd1d2c7UL, 0xfe976c9eUL, 0xff5506a9UL, 0xfa1a102cUL, 0xfbd87a1bUL,
- 0xf99ec442UL, 0xf85cae75UL, 0xf300e948UL, 0xf2c2837fUL, 0xf0843d26UL,
- 0xf1465711UL, 0xf4094194UL, 0xf5cb2ba3UL, 0xf78d95faUL, 0xf64fffcdUL,
- 0xd9785d60UL, 0xd8ba3757UL, 0xdafc890eUL, 0xdb3ee339UL, 0xde71f5bcUL,
- 0xdfb39f8bUL, 0xddf521d2UL, 0xdc374be5UL, 0xd76b0cd8UL, 0xd6a966efUL,
- 0xd4efd8b6UL, 0xd52db281UL, 0xd062a404UL, 0xd1a0ce33UL, 0xd3e6706aUL,
- 0xd2241a5dUL, 0xc55efe10UL, 0xc49c9427UL, 0xc6da2a7eUL, 0xc7184049UL,
- 0xc25756ccUL, 0xc3953cfbUL, 0xc1d382a2UL, 0xc011e895UL, 0xcb4dafa8UL,
- 0xca8fc59fUL, 0xc8c97bc6UL, 0xc90b11f1UL, 0xcc440774UL, 0xcd866d43UL,
- 0xcfc0d31aUL, 0xce02b92dUL, 0x91af9640UL, 0x906dfc77UL, 0x922b422eUL,
- 0x93e92819UL, 0x96a63e9cUL, 0x976454abUL, 0x9522eaf2UL, 0x94e080c5UL,
- 0x9fbcc7f8UL, 0x9e7eadcfUL, 0x9c381396UL, 0x9dfa79a1UL, 0x98b56f24UL,
- 0x99770513UL, 0x9b31bb4aUL, 0x9af3d17dUL, 0x8d893530UL, 0x8c4b5f07UL,
- 0x8e0de15eUL, 0x8fcf8b69UL, 0x8a809decUL, 0x8b42f7dbUL, 0x89044982UL,
- 0x88c623b5UL, 0x839a6488UL, 0x82580ebfUL, 0x801eb0e6UL, 0x81dcdad1UL,
- 0x8493cc54UL, 0x8551a663UL, 0x8717183aUL, 0x86d5720dUL, 0xa9e2d0a0UL,
- 0xa820ba97UL, 0xaa6604ceUL, 0xaba46ef9UL, 0xaeeb787cUL, 0xaf29124bUL,
- 0xad6fac12UL, 0xacadc625UL, 0xa7f18118UL, 0xa633eb2fUL, 0xa4755576UL,
- 0xa5b73f41UL, 0xa0f829c4UL, 0xa13a43f3UL, 0xa37cfdaaUL, 0xa2be979dUL,
- 0xb5c473d0UL, 0xb40619e7UL, 0xb640a7beUL, 0xb782cd89UL, 0xb2cddb0cUL,
- 0xb30fb13bUL, 0xb1490f62UL, 0xb08b6555UL, 0xbbd72268UL, 0xba15485fUL,
- 0xb853f606UL, 0xb9919c31UL, 0xbcde8ab4UL, 0xbd1ce083UL, 0xbf5a5edaUL,
- 0xbe9834edUL
- },
- {
- 0x00000000UL, 0xb8bc6765UL, 0xaa09c88bUL, 0x12b5afeeUL, 0x8f629757UL,
- 0x37def032UL, 0x256b5fdcUL, 0x9dd738b9UL, 0xc5b428efUL, 0x7d084f8aUL,
- 0x6fbde064UL, 0xd7018701UL, 0x4ad6bfb8UL, 0xf26ad8ddUL, 0xe0df7733UL,
- 0x58631056UL, 0x5019579fUL, 0xe8a530faUL, 0xfa109f14UL, 0x42acf871UL,
- 0xdf7bc0c8UL, 0x67c7a7adUL, 0x75720843UL, 0xcdce6f26UL, 0x95ad7f70UL,
- 0x2d111815UL, 0x3fa4b7fbUL, 0x8718d09eUL, 0x1acfe827UL, 0xa2738f42UL,
- 0xb0c620acUL, 0x087a47c9UL, 0xa032af3eUL, 0x188ec85bUL, 0x0a3b67b5UL,
- 0xb28700d0UL, 0x2f503869UL, 0x97ec5f0cUL, 0x8559f0e2UL, 0x3de59787UL,
- 0x658687d1UL, 0xdd3ae0b4UL, 0xcf8f4f5aUL, 0x7733283fUL, 0xeae41086UL,
- 0x525877e3UL, 0x40edd80dUL, 0xf851bf68UL, 0xf02bf8a1UL, 0x48979fc4UL,
- 0x5a22302aUL, 0xe29e574fUL, 0x7f496ff6UL, 0xc7f50893UL, 0xd540a77dUL,
- 0x6dfcc018UL, 0x359fd04eUL, 0x8d23b72bUL, 0x9f9618c5UL, 0x272a7fa0UL,
- 0xbafd4719UL, 0x0241207cUL, 0x10f48f92UL, 0xa848e8f7UL, 0x9b14583dUL,
- 0x23a83f58UL, 0x311d90b6UL, 0x89a1f7d3UL, 0x1476cf6aUL, 0xaccaa80fUL,
- 0xbe7f07e1UL, 0x06c36084UL, 0x5ea070d2UL, 0xe61c17b7UL, 0xf4a9b859UL,
- 0x4c15df3cUL, 0xd1c2e785UL, 0x697e80e0UL, 0x7bcb2f0eUL, 0xc377486bUL,
- 0xcb0d0fa2UL, 0x73b168c7UL, 0x6104c729UL, 0xd9b8a04cUL, 0x446f98f5UL,
- 0xfcd3ff90UL, 0xee66507eUL, 0x56da371bUL, 0x0eb9274dUL, 0xb6054028UL,
- 0xa4b0efc6UL, 0x1c0c88a3UL, 0x81dbb01aUL, 0x3967d77fUL, 0x2bd27891UL,
- 0x936e1ff4UL, 0x3b26f703UL, 0x839a9066UL, 0x912f3f88UL, 0x299358edUL,
- 0xb4446054UL, 0x0cf80731UL, 0x1e4da8dfUL, 0xa6f1cfbaUL, 0xfe92dfecUL,
- 0x462eb889UL, 0x549b1767UL, 0xec277002UL, 0x71f048bbUL, 0xc94c2fdeUL,
- 0xdbf98030UL, 0x6345e755UL, 0x6b3fa09cUL, 0xd383c7f9UL, 0xc1366817UL,
- 0x798a0f72UL, 0xe45d37cbUL, 0x5ce150aeUL, 0x4e54ff40UL, 0xf6e89825UL,
- 0xae8b8873UL, 0x1637ef16UL, 0x048240f8UL, 0xbc3e279dUL, 0x21e91f24UL,
- 0x99557841UL, 0x8be0d7afUL, 0x335cb0caUL, 0xed59b63bUL, 0x55e5d15eUL,
- 0x47507eb0UL, 0xffec19d5UL, 0x623b216cUL, 0xda874609UL, 0xc832e9e7UL,
- 0x708e8e82UL, 0x28ed9ed4UL, 0x9051f9b1UL, 0x82e4565fUL, 0x3a58313aUL,
- 0xa78f0983UL, 0x1f336ee6UL, 0x0d86c108UL, 0xb53aa66dUL, 0xbd40e1a4UL,
- 0x05fc86c1UL, 0x1749292fUL, 0xaff54e4aUL, 0x322276f3UL, 0x8a9e1196UL,
- 0x982bbe78UL, 0x2097d91dUL, 0x78f4c94bUL, 0xc048ae2eUL, 0xd2fd01c0UL,
- 0x6a4166a5UL, 0xf7965e1cUL, 0x4f2a3979UL, 0x5d9f9697UL, 0xe523f1f2UL,
- 0x4d6b1905UL, 0xf5d77e60UL, 0xe762d18eUL, 0x5fdeb6ebUL, 0xc2098e52UL,
- 0x7ab5e937UL, 0x680046d9UL, 0xd0bc21bcUL, 0x88df31eaUL, 0x3063568fUL,
- 0x22d6f961UL, 0x9a6a9e04UL, 0x07bda6bdUL, 0xbf01c1d8UL, 0xadb46e36UL,
- 0x15080953UL, 0x1d724e9aUL, 0xa5ce29ffUL, 0xb77b8611UL, 0x0fc7e174UL,
- 0x9210d9cdUL, 0x2aacbea8UL, 0x38191146UL, 0x80a57623UL, 0xd8c66675UL,
- 0x607a0110UL, 0x72cfaefeUL, 0xca73c99bUL, 0x57a4f122UL, 0xef189647UL,
- 0xfdad39a9UL, 0x45115eccUL, 0x764dee06UL, 0xcef18963UL, 0xdc44268dUL,
- 0x64f841e8UL, 0xf92f7951UL, 0x41931e34UL, 0x5326b1daUL, 0xeb9ad6bfUL,
- 0xb3f9c6e9UL, 0x0b45a18cUL, 0x19f00e62UL, 0xa14c6907UL, 0x3c9b51beUL,
- 0x842736dbUL, 0x96929935UL, 0x2e2efe50UL, 0x2654b999UL, 0x9ee8defcUL,
- 0x8c5d7112UL, 0x34e11677UL, 0xa9362eceUL, 0x118a49abUL, 0x033fe645UL,
- 0xbb838120UL, 0xe3e09176UL, 0x5b5cf613UL, 0x49e959fdUL, 0xf1553e98UL,
- 0x6c820621UL, 0xd43e6144UL, 0xc68bceaaUL, 0x7e37a9cfUL, 0xd67f4138UL,
- 0x6ec3265dUL, 0x7c7689b3UL, 0xc4caeed6UL, 0x591dd66fUL, 0xe1a1b10aUL,
- 0xf3141ee4UL, 0x4ba87981UL, 0x13cb69d7UL, 0xab770eb2UL, 0xb9c2a15cUL,
- 0x017ec639UL, 0x9ca9fe80UL, 0x241599e5UL, 0x36a0360bUL, 0x8e1c516eUL,
- 0x866616a7UL, 0x3eda71c2UL, 0x2c6fde2cUL, 0x94d3b949UL, 0x090481f0UL,
- 0xb1b8e695UL, 0xa30d497bUL, 0x1bb12e1eUL, 0x43d23e48UL, 0xfb6e592dUL,
- 0xe9dbf6c3UL, 0x516791a6UL, 0xccb0a91fUL, 0x740cce7aUL, 0x66b96194UL,
- 0xde0506f1UL
- },
- {
- 0x00000000UL, 0x96300777UL, 0x2c610eeeUL, 0xba510999UL, 0x19c46d07UL,
- 0x8ff46a70UL, 0x35a563e9UL, 0xa395649eUL, 0x3288db0eUL, 0xa4b8dc79UL,
- 0x1ee9d5e0UL, 0x88d9d297UL, 0x2b4cb609UL, 0xbd7cb17eUL, 0x072db8e7UL,
- 0x911dbf90UL, 0x6410b71dUL, 0xf220b06aUL, 0x4871b9f3UL, 0xde41be84UL,
- 0x7dd4da1aUL, 0xebe4dd6dUL, 0x51b5d4f4UL, 0xc785d383UL, 0x56986c13UL,
- 0xc0a86b64UL, 0x7af962fdUL, 0xecc9658aUL, 0x4f5c0114UL, 0xd96c0663UL,
- 0x633d0ffaUL, 0xf50d088dUL, 0xc8206e3bUL, 0x5e10694cUL, 0xe44160d5UL,
- 0x727167a2UL, 0xd1e4033cUL, 0x47d4044bUL, 0xfd850dd2UL, 0x6bb50aa5UL,
- 0xfaa8b535UL, 0x6c98b242UL, 0xd6c9bbdbUL, 0x40f9bcacUL, 0xe36cd832UL,
- 0x755cdf45UL, 0xcf0dd6dcUL, 0x593dd1abUL, 0xac30d926UL, 0x3a00de51UL,
- 0x8051d7c8UL, 0x1661d0bfUL, 0xb5f4b421UL, 0x23c4b356UL, 0x9995bacfUL,
- 0x0fa5bdb8UL, 0x9eb80228UL, 0x0888055fUL, 0xb2d90cc6UL, 0x24e90bb1UL,
- 0x877c6f2fUL, 0x114c6858UL, 0xab1d61c1UL, 0x3d2d66b6UL, 0x9041dc76UL,
- 0x0671db01UL, 0xbc20d298UL, 0x2a10d5efUL, 0x8985b171UL, 0x1fb5b606UL,
- 0xa5e4bf9fUL, 0x33d4b8e8UL, 0xa2c90778UL, 0x34f9000fUL, 0x8ea80996UL,
- 0x18980ee1UL, 0xbb0d6a7fUL, 0x2d3d6d08UL, 0x976c6491UL, 0x015c63e6UL,
- 0xf4516b6bUL, 0x62616c1cUL, 0xd8306585UL, 0x4e0062f2UL, 0xed95066cUL,
- 0x7ba5011bUL, 0xc1f40882UL, 0x57c40ff5UL, 0xc6d9b065UL, 0x50e9b712UL,
- 0xeab8be8bUL, 0x7c88b9fcUL, 0xdf1ddd62UL, 0x492dda15UL, 0xf37cd38cUL,
- 0x654cd4fbUL, 0x5861b24dUL, 0xce51b53aUL, 0x7400bca3UL, 0xe230bbd4UL,
- 0x41a5df4aUL, 0xd795d83dUL, 0x6dc4d1a4UL, 0xfbf4d6d3UL, 0x6ae96943UL,
- 0xfcd96e34UL, 0x468867adUL, 0xd0b860daUL, 0x732d0444UL, 0xe51d0333UL,
- 0x5f4c0aaaUL, 0xc97c0dddUL, 0x3c710550UL, 0xaa410227UL, 0x10100bbeUL,
- 0x86200cc9UL, 0x25b56857UL, 0xb3856f20UL, 0x09d466b9UL, 0x9fe461ceUL,
- 0x0ef9de5eUL, 0x98c9d929UL, 0x2298d0b0UL, 0xb4a8d7c7UL, 0x173db359UL,
- 0x810db42eUL, 0x3b5cbdb7UL, 0xad6cbac0UL, 0x2083b8edUL, 0xb6b3bf9aUL,
- 0x0ce2b603UL, 0x9ad2b174UL, 0x3947d5eaUL, 0xaf77d29dUL, 0x1526db04UL,
- 0x8316dc73UL, 0x120b63e3UL, 0x843b6494UL, 0x3e6a6d0dUL, 0xa85a6a7aUL,
- 0x0bcf0ee4UL, 0x9dff0993UL, 0x27ae000aUL, 0xb19e077dUL, 0x44930ff0UL,
- 0xd2a30887UL, 0x68f2011eUL, 0xfec20669UL, 0x5d5762f7UL, 0xcb676580UL,
- 0x71366c19UL, 0xe7066b6eUL, 0x761bd4feUL, 0xe02bd389UL, 0x5a7ada10UL,
- 0xcc4add67UL, 0x6fdfb9f9UL, 0xf9efbe8eUL, 0x43beb717UL, 0xd58eb060UL,
- 0xe8a3d6d6UL, 0x7e93d1a1UL, 0xc4c2d838UL, 0x52f2df4fUL, 0xf167bbd1UL,
- 0x6757bca6UL, 0xdd06b53fUL, 0x4b36b248UL, 0xda2b0dd8UL, 0x4c1b0aafUL,
- 0xf64a0336UL, 0x607a0441UL, 0xc3ef60dfUL, 0x55df67a8UL, 0xef8e6e31UL,
- 0x79be6946UL, 0x8cb361cbUL, 0x1a8366bcUL, 0xa0d26f25UL, 0x36e26852UL,
- 0x95770cccUL, 0x03470bbbUL, 0xb9160222UL, 0x2f260555UL, 0xbe3bbac5UL,
- 0x280bbdb2UL, 0x925ab42bUL, 0x046ab35cUL, 0xa7ffd7c2UL, 0x31cfd0b5UL,
- 0x8b9ed92cUL, 0x1daede5bUL, 0xb0c2649bUL, 0x26f263ecUL, 0x9ca36a75UL,
- 0x0a936d02UL, 0xa906099cUL, 0x3f360eebUL, 0x85670772UL, 0x13570005UL,
- 0x824abf95UL, 0x147ab8e2UL, 0xae2bb17bUL, 0x381bb60cUL, 0x9b8ed292UL,
- 0x0dbed5e5UL, 0xb7efdc7cUL, 0x21dfdb0bUL, 0xd4d2d386UL, 0x42e2d4f1UL,
- 0xf8b3dd68UL, 0x6e83da1fUL, 0xcd16be81UL, 0x5b26b9f6UL, 0xe177b06fUL,
- 0x7747b718UL, 0xe65a0888UL, 0x706a0fffUL, 0xca3b0666UL, 0x5c0b0111UL,
- 0xff9e658fUL, 0x69ae62f8UL, 0xd3ff6b61UL, 0x45cf6c16UL, 0x78e20aa0UL,
- 0xeed20dd7UL, 0x5483044eUL, 0xc2b30339UL, 0x612667a7UL, 0xf71660d0UL,
- 0x4d476949UL, 0xdb776e3eUL, 0x4a6ad1aeUL, 0xdc5ad6d9UL, 0x660bdf40UL,
- 0xf03bd837UL, 0x53aebca9UL, 0xc59ebbdeUL, 0x7fcfb247UL, 0xe9ffb530UL,
- 0x1cf2bdbdUL, 0x8ac2bacaUL, 0x3093b353UL, 0xa6a3b424UL, 0x0536d0baUL,
- 0x9306d7cdUL, 0x2957de54UL, 0xbf67d923UL, 0x2e7a66b3UL, 0xb84a61c4UL,
- 0x021b685dUL, 0x942b6f2aUL, 0x37be0bb4UL, 0xa18e0cc3UL, 0x1bdf055aUL,
- 0x8def022dUL
- },
- {
- 0x00000000UL, 0x41311b19UL, 0x82623632UL, 0xc3532d2bUL, 0x04c56c64UL,
- 0x45f4777dUL, 0x86a75a56UL, 0xc796414fUL, 0x088ad9c8UL, 0x49bbc2d1UL,
- 0x8ae8effaUL, 0xcbd9f4e3UL, 0x0c4fb5acUL, 0x4d7eaeb5UL, 0x8e2d839eUL,
- 0xcf1c9887UL, 0x5112c24aUL, 0x1023d953UL, 0xd370f478UL, 0x9241ef61UL,
- 0x55d7ae2eUL, 0x14e6b537UL, 0xd7b5981cUL, 0x96848305UL, 0x59981b82UL,
- 0x18a9009bUL, 0xdbfa2db0UL, 0x9acb36a9UL, 0x5d5d77e6UL, 0x1c6c6cffUL,
- 0xdf3f41d4UL, 0x9e0e5acdUL, 0xa2248495UL, 0xe3159f8cUL, 0x2046b2a7UL,
- 0x6177a9beUL, 0xa6e1e8f1UL, 0xe7d0f3e8UL, 0x2483dec3UL, 0x65b2c5daUL,
- 0xaaae5d5dUL, 0xeb9f4644UL, 0x28cc6b6fUL, 0x69fd7076UL, 0xae6b3139UL,
- 0xef5a2a20UL, 0x2c09070bUL, 0x6d381c12UL, 0xf33646dfUL, 0xb2075dc6UL,
- 0x715470edUL, 0x30656bf4UL, 0xf7f32abbUL, 0xb6c231a2UL, 0x75911c89UL,
- 0x34a00790UL, 0xfbbc9f17UL, 0xba8d840eUL, 0x79dea925UL, 0x38efb23cUL,
- 0xff79f373UL, 0xbe48e86aUL, 0x7d1bc541UL, 0x3c2ade58UL, 0x054f79f0UL,
- 0x447e62e9UL, 0x872d4fc2UL, 0xc61c54dbUL, 0x018a1594UL, 0x40bb0e8dUL,
- 0x83e823a6UL, 0xc2d938bfUL, 0x0dc5a038UL, 0x4cf4bb21UL, 0x8fa7960aUL,
- 0xce968d13UL, 0x0900cc5cUL, 0x4831d745UL, 0x8b62fa6eUL, 0xca53e177UL,
- 0x545dbbbaUL, 0x156ca0a3UL, 0xd63f8d88UL, 0x970e9691UL, 0x5098d7deUL,
- 0x11a9ccc7UL, 0xd2fae1ecUL, 0x93cbfaf5UL, 0x5cd76272UL, 0x1de6796bUL,
- 0xdeb55440UL, 0x9f844f59UL, 0x58120e16UL, 0x1923150fUL, 0xda703824UL,
- 0x9b41233dUL, 0xa76bfd65UL, 0xe65ae67cUL, 0x2509cb57UL, 0x6438d04eUL,
- 0xa3ae9101UL, 0xe29f8a18UL, 0x21cca733UL, 0x60fdbc2aUL, 0xafe124adUL,
- 0xeed03fb4UL, 0x2d83129fUL, 0x6cb20986UL, 0xab2448c9UL, 0xea1553d0UL,
- 0x29467efbUL, 0x687765e2UL, 0xf6793f2fUL, 0xb7482436UL, 0x741b091dUL,
- 0x352a1204UL, 0xf2bc534bUL, 0xb38d4852UL, 0x70de6579UL, 0x31ef7e60UL,
- 0xfef3e6e7UL, 0xbfc2fdfeUL, 0x7c91d0d5UL, 0x3da0cbccUL, 0xfa368a83UL,
- 0xbb07919aUL, 0x7854bcb1UL, 0x3965a7a8UL, 0x4b98833bUL, 0x0aa99822UL,
- 0xc9fab509UL, 0x88cbae10UL, 0x4f5def5fUL, 0x0e6cf446UL, 0xcd3fd96dUL,
- 0x8c0ec274UL, 0x43125af3UL, 0x022341eaUL, 0xc1706cc1UL, 0x804177d8UL,
- 0x47d73697UL, 0x06e62d8eUL, 0xc5b500a5UL, 0x84841bbcUL, 0x1a8a4171UL,
- 0x5bbb5a68UL, 0x98e87743UL, 0xd9d96c5aUL, 0x1e4f2d15UL, 0x5f7e360cUL,
- 0x9c2d1b27UL, 0xdd1c003eUL, 0x120098b9UL, 0x533183a0UL, 0x9062ae8bUL,
- 0xd153b592UL, 0x16c5f4ddUL, 0x57f4efc4UL, 0x94a7c2efUL, 0xd596d9f6UL,
- 0xe9bc07aeUL, 0xa88d1cb7UL, 0x6bde319cUL, 0x2aef2a85UL, 0xed796bcaUL,
- 0xac4870d3UL, 0x6f1b5df8UL, 0x2e2a46e1UL, 0xe136de66UL, 0xa007c57fUL,
- 0x6354e854UL, 0x2265f34dUL, 0xe5f3b202UL, 0xa4c2a91bUL, 0x67918430UL,
- 0x26a09f29UL, 0xb8aec5e4UL, 0xf99fdefdUL, 0x3accf3d6UL, 0x7bfde8cfUL,
- 0xbc6ba980UL, 0xfd5ab299UL, 0x3e099fb2UL, 0x7f3884abUL, 0xb0241c2cUL,
- 0xf1150735UL, 0x32462a1eUL, 0x73773107UL, 0xb4e17048UL, 0xf5d06b51UL,
- 0x3683467aUL, 0x77b25d63UL, 0x4ed7facbUL, 0x0fe6e1d2UL, 0xccb5ccf9UL,
- 0x8d84d7e0UL, 0x4a1296afUL, 0x0b238db6UL, 0xc870a09dUL, 0x8941bb84UL,
- 0x465d2303UL, 0x076c381aUL, 0xc43f1531UL, 0x850e0e28UL, 0x42984f67UL,
- 0x03a9547eUL, 0xc0fa7955UL, 0x81cb624cUL, 0x1fc53881UL, 0x5ef42398UL,
- 0x9da70eb3UL, 0xdc9615aaUL, 0x1b0054e5UL, 0x5a314ffcUL, 0x996262d7UL,
- 0xd85379ceUL, 0x174fe149UL, 0x567efa50UL, 0x952dd77bUL, 0xd41ccc62UL,
- 0x138a8d2dUL, 0x52bb9634UL, 0x91e8bb1fUL, 0xd0d9a006UL, 0xecf37e5eUL,
- 0xadc26547UL, 0x6e91486cUL, 0x2fa05375UL, 0xe836123aUL, 0xa9070923UL,
- 0x6a542408UL, 0x2b653f11UL, 0xe479a796UL, 0xa548bc8fUL, 0x661b91a4UL,
- 0x272a8abdUL, 0xe0bccbf2UL, 0xa18dd0ebUL, 0x62defdc0UL, 0x23efe6d9UL,
- 0xbde1bc14UL, 0xfcd0a70dUL, 0x3f838a26UL, 0x7eb2913fUL, 0xb924d070UL,
- 0xf815cb69UL, 0x3b46e642UL, 0x7a77fd5bUL, 0xb56b65dcUL, 0xf45a7ec5UL,
- 0x370953eeUL, 0x763848f7UL, 0xb1ae09b8UL, 0xf09f12a1UL, 0x33cc3f8aUL,
- 0x72fd2493UL
- },
- {
- 0x00000000UL, 0x376ac201UL, 0x6ed48403UL, 0x59be4602UL, 0xdca80907UL,
- 0xebc2cb06UL, 0xb27c8d04UL, 0x85164f05UL, 0xb851130eUL, 0x8f3bd10fUL,
- 0xd685970dUL, 0xe1ef550cUL, 0x64f91a09UL, 0x5393d808UL, 0x0a2d9e0aUL,
- 0x3d475c0bUL, 0x70a3261cUL, 0x47c9e41dUL, 0x1e77a21fUL, 0x291d601eUL,
- 0xac0b2f1bUL, 0x9b61ed1aUL, 0xc2dfab18UL, 0xf5b56919UL, 0xc8f23512UL,
- 0xff98f713UL, 0xa626b111UL, 0x914c7310UL, 0x145a3c15UL, 0x2330fe14UL,
- 0x7a8eb816UL, 0x4de47a17UL, 0xe0464d38UL, 0xd72c8f39UL, 0x8e92c93bUL,
- 0xb9f80b3aUL, 0x3cee443fUL, 0x0b84863eUL, 0x523ac03cUL, 0x6550023dUL,
- 0x58175e36UL, 0x6f7d9c37UL, 0x36c3da35UL, 0x01a91834UL, 0x84bf5731UL,
- 0xb3d59530UL, 0xea6bd332UL, 0xdd011133UL, 0x90e56b24UL, 0xa78fa925UL,
- 0xfe31ef27UL, 0xc95b2d26UL, 0x4c4d6223UL, 0x7b27a022UL, 0x2299e620UL,
- 0x15f32421UL, 0x28b4782aUL, 0x1fdeba2bUL, 0x4660fc29UL, 0x710a3e28UL,
- 0xf41c712dUL, 0xc376b32cUL, 0x9ac8f52eUL, 0xada2372fUL, 0xc08d9a70UL,
- 0xf7e75871UL, 0xae591e73UL, 0x9933dc72UL, 0x1c259377UL, 0x2b4f5176UL,
- 0x72f11774UL, 0x459bd575UL, 0x78dc897eUL, 0x4fb64b7fUL, 0x16080d7dUL,
- 0x2162cf7cUL, 0xa4748079UL, 0x931e4278UL, 0xcaa0047aUL, 0xfdcac67bUL,
- 0xb02ebc6cUL, 0x87447e6dUL, 0xdefa386fUL, 0xe990fa6eUL, 0x6c86b56bUL,
- 0x5bec776aUL, 0x02523168UL, 0x3538f369UL, 0x087faf62UL, 0x3f156d63UL,
- 0x66ab2b61UL, 0x51c1e960UL, 0xd4d7a665UL, 0xe3bd6464UL, 0xba032266UL,
- 0x8d69e067UL, 0x20cbd748UL, 0x17a11549UL, 0x4e1f534bUL, 0x7975914aUL,
- 0xfc63de4fUL, 0xcb091c4eUL, 0x92b75a4cUL, 0xa5dd984dUL, 0x989ac446UL,
- 0xaff00647UL, 0xf64e4045UL, 0xc1248244UL, 0x4432cd41UL, 0x73580f40UL,
- 0x2ae64942UL, 0x1d8c8b43UL, 0x5068f154UL, 0x67023355UL, 0x3ebc7557UL,
- 0x09d6b756UL, 0x8cc0f853UL, 0xbbaa3a52UL, 0xe2147c50UL, 0xd57ebe51UL,
- 0xe839e25aUL, 0xdf53205bUL, 0x86ed6659UL, 0xb187a458UL, 0x3491eb5dUL,
- 0x03fb295cUL, 0x5a456f5eUL, 0x6d2fad5fUL, 0x801b35e1UL, 0xb771f7e0UL,
- 0xeecfb1e2UL, 0xd9a573e3UL, 0x5cb33ce6UL, 0x6bd9fee7UL, 0x3267b8e5UL,
- 0x050d7ae4UL, 0x384a26efUL, 0x0f20e4eeUL, 0x569ea2ecUL, 0x61f460edUL,
- 0xe4e22fe8UL, 0xd388ede9UL, 0x8a36abebUL, 0xbd5c69eaUL, 0xf0b813fdUL,
- 0xc7d2d1fcUL, 0x9e6c97feUL, 0xa90655ffUL, 0x2c101afaUL, 0x1b7ad8fbUL,
- 0x42c49ef9UL, 0x75ae5cf8UL, 0x48e900f3UL, 0x7f83c2f2UL, 0x263d84f0UL,
- 0x115746f1UL, 0x944109f4UL, 0xa32bcbf5UL, 0xfa958df7UL, 0xcdff4ff6UL,
- 0x605d78d9UL, 0x5737bad8UL, 0x0e89fcdaUL, 0x39e33edbUL, 0xbcf571deUL,
- 0x8b9fb3dfUL, 0xd221f5ddUL, 0xe54b37dcUL, 0xd80c6bd7UL, 0xef66a9d6UL,
- 0xb6d8efd4UL, 0x81b22dd5UL, 0x04a462d0UL, 0x33cea0d1UL, 0x6a70e6d3UL,
- 0x5d1a24d2UL, 0x10fe5ec5UL, 0x27949cc4UL, 0x7e2adac6UL, 0x494018c7UL,
- 0xcc5657c2UL, 0xfb3c95c3UL, 0xa282d3c1UL, 0x95e811c0UL, 0xa8af4dcbUL,
- 0x9fc58fcaUL, 0xc67bc9c8UL, 0xf1110bc9UL, 0x740744ccUL, 0x436d86cdUL,
- 0x1ad3c0cfUL, 0x2db902ceUL, 0x4096af91UL, 0x77fc6d90UL, 0x2e422b92UL,
- 0x1928e993UL, 0x9c3ea696UL, 0xab546497UL, 0xf2ea2295UL, 0xc580e094UL,
- 0xf8c7bc9fUL, 0xcfad7e9eUL, 0x9613389cUL, 0xa179fa9dUL, 0x246fb598UL,
- 0x13057799UL, 0x4abb319bUL, 0x7dd1f39aUL, 0x3035898dUL, 0x075f4b8cUL,
- 0x5ee10d8eUL, 0x698bcf8fUL, 0xec9d808aUL, 0xdbf7428bUL, 0x82490489UL,
- 0xb523c688UL, 0x88649a83UL, 0xbf0e5882UL, 0xe6b01e80UL, 0xd1dadc81UL,
- 0x54cc9384UL, 0x63a65185UL, 0x3a181787UL, 0x0d72d586UL, 0xa0d0e2a9UL,
- 0x97ba20a8UL, 0xce0466aaUL, 0xf96ea4abUL, 0x7c78ebaeUL, 0x4b1229afUL,
- 0x12ac6fadUL, 0x25c6adacUL, 0x1881f1a7UL, 0x2feb33a6UL, 0x765575a4UL,
- 0x413fb7a5UL, 0xc429f8a0UL, 0xf3433aa1UL, 0xaafd7ca3UL, 0x9d97bea2UL,
- 0xd073c4b5UL, 0xe71906b4UL, 0xbea740b6UL, 0x89cd82b7UL, 0x0cdbcdb2UL,
- 0x3bb10fb3UL, 0x620f49b1UL, 0x55658bb0UL, 0x6822d7bbUL, 0x5f4815baUL,
- 0x06f653b8UL, 0x319c91b9UL, 0xb48adebcUL, 0x83e01cbdUL, 0xda5e5abfUL,
- 0xed3498beUL
- },
- {
- 0x00000000UL, 0x6567bcb8UL, 0x8bc809aaUL, 0xeeafb512UL, 0x5797628fUL,
- 0x32f0de37UL, 0xdc5f6b25UL, 0xb938d79dUL, 0xef28b4c5UL, 0x8a4f087dUL,
- 0x64e0bd6fUL, 0x018701d7UL, 0xb8bfd64aUL, 0xddd86af2UL, 0x3377dfe0UL,
- 0x56106358UL, 0x9f571950UL, 0xfa30a5e8UL, 0x149f10faUL, 0x71f8ac42UL,
- 0xc8c07bdfUL, 0xada7c767UL, 0x43087275UL, 0x266fcecdUL, 0x707fad95UL,
- 0x1518112dUL, 0xfbb7a43fUL, 0x9ed01887UL, 0x27e8cf1aUL, 0x428f73a2UL,
- 0xac20c6b0UL, 0xc9477a08UL, 0x3eaf32a0UL, 0x5bc88e18UL, 0xb5673b0aUL,
- 0xd00087b2UL, 0x6938502fUL, 0x0c5fec97UL, 0xe2f05985UL, 0x8797e53dUL,
- 0xd1878665UL, 0xb4e03addUL, 0x5a4f8fcfUL, 0x3f283377UL, 0x8610e4eaUL,
- 0xe3775852UL, 0x0dd8ed40UL, 0x68bf51f8UL, 0xa1f82bf0UL, 0xc49f9748UL,
- 0x2a30225aUL, 0x4f579ee2UL, 0xf66f497fUL, 0x9308f5c7UL, 0x7da740d5UL,
- 0x18c0fc6dUL, 0x4ed09f35UL, 0x2bb7238dUL, 0xc518969fUL, 0xa07f2a27UL,
- 0x1947fdbaUL, 0x7c204102UL, 0x928ff410UL, 0xf7e848a8UL, 0x3d58149bUL,
- 0x583fa823UL, 0xb6901d31UL, 0xd3f7a189UL, 0x6acf7614UL, 0x0fa8caacUL,
- 0xe1077fbeUL, 0x8460c306UL, 0xd270a05eUL, 0xb7171ce6UL, 0x59b8a9f4UL,
- 0x3cdf154cUL, 0x85e7c2d1UL, 0xe0807e69UL, 0x0e2fcb7bUL, 0x6b4877c3UL,
- 0xa20f0dcbUL, 0xc768b173UL, 0x29c70461UL, 0x4ca0b8d9UL, 0xf5986f44UL,
- 0x90ffd3fcUL, 0x7e5066eeUL, 0x1b37da56UL, 0x4d27b90eUL, 0x284005b6UL,
- 0xc6efb0a4UL, 0xa3880c1cUL, 0x1ab0db81UL, 0x7fd76739UL, 0x9178d22bUL,
- 0xf41f6e93UL, 0x03f7263bUL, 0x66909a83UL, 0x883f2f91UL, 0xed589329UL,
- 0x546044b4UL, 0x3107f80cUL, 0xdfa84d1eUL, 0xbacff1a6UL, 0xecdf92feUL,
- 0x89b82e46UL, 0x67179b54UL, 0x027027ecUL, 0xbb48f071UL, 0xde2f4cc9UL,
- 0x3080f9dbUL, 0x55e74563UL, 0x9ca03f6bUL, 0xf9c783d3UL, 0x176836c1UL,
- 0x720f8a79UL, 0xcb375de4UL, 0xae50e15cUL, 0x40ff544eUL, 0x2598e8f6UL,
- 0x73888baeUL, 0x16ef3716UL, 0xf8408204UL, 0x9d273ebcUL, 0x241fe921UL,
- 0x41785599UL, 0xafd7e08bUL, 0xcab05c33UL, 0x3bb659edUL, 0x5ed1e555UL,
- 0xb07e5047UL, 0xd519ecffUL, 0x6c213b62UL, 0x094687daUL, 0xe7e932c8UL,
- 0x828e8e70UL, 0xd49eed28UL, 0xb1f95190UL, 0x5f56e482UL, 0x3a31583aUL,
- 0x83098fa7UL, 0xe66e331fUL, 0x08c1860dUL, 0x6da63ab5UL, 0xa4e140bdUL,
- 0xc186fc05UL, 0x2f294917UL, 0x4a4ef5afUL, 0xf3762232UL, 0x96119e8aUL,
- 0x78be2b98UL, 0x1dd99720UL, 0x4bc9f478UL, 0x2eae48c0UL, 0xc001fdd2UL,
- 0xa566416aUL, 0x1c5e96f7UL, 0x79392a4fUL, 0x97969f5dUL, 0xf2f123e5UL,
- 0x05196b4dUL, 0x607ed7f5UL, 0x8ed162e7UL, 0xebb6de5fUL, 0x528e09c2UL,
- 0x37e9b57aUL, 0xd9460068UL, 0xbc21bcd0UL, 0xea31df88UL, 0x8f566330UL,
- 0x61f9d622UL, 0x049e6a9aUL, 0xbda6bd07UL, 0xd8c101bfUL, 0x366eb4adUL,
- 0x53090815UL, 0x9a4e721dUL, 0xff29cea5UL, 0x11867bb7UL, 0x74e1c70fUL,
- 0xcdd91092UL, 0xa8beac2aUL, 0x46111938UL, 0x2376a580UL, 0x7566c6d8UL,
- 0x10017a60UL, 0xfeaecf72UL, 0x9bc973caUL, 0x22f1a457UL, 0x479618efUL,
- 0xa939adfdUL, 0xcc5e1145UL, 0x06ee4d76UL, 0x6389f1ceUL, 0x8d2644dcUL,
- 0xe841f864UL, 0x51792ff9UL, 0x341e9341UL, 0xdab12653UL, 0xbfd69aebUL,
- 0xe9c6f9b3UL, 0x8ca1450bUL, 0x620ef019UL, 0x07694ca1UL, 0xbe519b3cUL,
- 0xdb362784UL, 0x35999296UL, 0x50fe2e2eUL, 0x99b95426UL, 0xfcdee89eUL,
- 0x12715d8cUL, 0x7716e134UL, 0xce2e36a9UL, 0xab498a11UL, 0x45e63f03UL,
- 0x208183bbUL, 0x7691e0e3UL, 0x13f65c5bUL, 0xfd59e949UL, 0x983e55f1UL,
- 0x2106826cUL, 0x44613ed4UL, 0xaace8bc6UL, 0xcfa9377eUL, 0x38417fd6UL,
- 0x5d26c36eUL, 0xb389767cUL, 0xd6eecac4UL, 0x6fd61d59UL, 0x0ab1a1e1UL,
- 0xe41e14f3UL, 0x8179a84bUL, 0xd769cb13UL, 0xb20e77abUL, 0x5ca1c2b9UL,
- 0x39c67e01UL, 0x80fea99cUL, 0xe5991524UL, 0x0b36a036UL, 0x6e511c8eUL,
- 0xa7166686UL, 0xc271da3eUL, 0x2cde6f2cUL, 0x49b9d394UL, 0xf0810409UL,
- 0x95e6b8b1UL, 0x7b490da3UL, 0x1e2eb11bUL, 0x483ed243UL, 0x2d596efbUL,
- 0xc3f6dbe9UL, 0xa6916751UL, 0x1fa9b0ccUL, 0x7ace0c74UL, 0x9461b966UL,
- 0xf10605deUL
-#endif
- }
-};
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/deflate.c Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1760 +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.
- */
-
-/* deflate.c -- compress data using the deflation algorithm
- * Copyright (C) 1995-2005 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/*
- * ALGORITHM
- *
- * The "deflation" process depends on being able to identify portions
- * of the input text which are identical to earlier input (within a
- * sliding window trailing behind the input currently being processed).
- *
- * The most straightforward technique turns out to be the fastest for
- * most input files: try all possible matches and select the longest.
- * The key feature of this algorithm is that insertions into the string
- * dictionary are very simple and thus fast, and deletions are avoided
- * completely. Insertions are performed at each input character, whereas
- * string matches are performed only when the previous match ends. So it
- * is preferable to spend more time in matches to allow very fast string
- * insertions and avoid deletions. The matching algorithm for small
- * strings is inspired from that of Rabin & Karp. A brute force approach
- * is used to find longer strings when a small match has been found.
- * A similar algorithm is used in comic (by Jan-Mark Wams) and freeze
- * (by Leonid Broukhis).
- * A previous version of this file used a more sophisticated algorithm
- * (by Fiala and Greene) which is guaranteed to run in linear amortized
- * time, but has a larger average cost, uses more memory and is patented.
- * However the F&G algorithm may be faster for some highly redundant
- * files if the parameter max_chain_length (described below) is too large.
- *
- * ACKNOWLEDGEMENTS
- *
- * The idea of lazy evaluation of matches is due to Jan-Mark Wams, and
- * I found it in 'freeze' written by Leonid Broukhis.
- * Thanks to many people for bug reports and testing.
- *
- * REFERENCES
- *
- * Deutsch, L.P.,"DEFLATE Compressed Data Format Specification".
- * Available in http://www.ietf.org/rfc/rfc1951.txt
- *
- * A description of the Rabin and Karp algorithm is given in the book
- * "Algorithms" by R. Sedgewick, Addison-Wesley, p252.
- *
- * Fiala,E.R., and Greene,D.H.
- * Data Compression with Finite Windows, Comm.ACM, 32,4 (1989) 490-595
- *
- */
-
-/* @(#) $Id$ */
-
-#include "deflate.h"
-
-const char deflate_copyright[] =
- " deflate 1.2.3 Copyright 1995-2005 Jean-loup Gailly ";
-/*
- 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
- include such an acknowledgment, I would appreciate that you keep this
- copyright string in the executable of your product.
- */
-
-/* ===========================================================================
- * Function prototypes.
- */
-typedef enum {
- need_more, /* block not completed, need more input or more output */
- block_done, /* block flush performed */
- finish_started, /* finish started, need only more output at next deflate */
- finish_done /* finish done, accept no more input or output */
-} block_state;
-
-typedef block_state (*compress_func) OF((deflate_state *s, int flush));
-/* Compression function. Returns the block state after the call. */
-
-local void fill_window OF((deflate_state *s));
-local block_state deflate_stored OF((deflate_state *s, int flush));
-local block_state deflate_fast OF((deflate_state *s, int flush));
-#ifndef FASTEST
-local block_state deflate_slow OF((deflate_state *s, int flush));
-#endif
-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,
- int length));
-#endif
-
-/* ===========================================================================
- * Local data
- */
-
-#define NIL 0
-/* Tail of hash chains */
-
-#ifndef TOO_FAR
-# define TOO_FAR 4096
-#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
- * found for specific files.
- */
-typedef struct config_s {
- ush good_length; /* reduce lazy search above this match length */
- ush max_lazy; /* do not perform lazy search above this match length */
- ush nice_length; /* quit search above this match length */
- ush max_chain;
- compress_func func;
-} config;
-
-#ifdef FASTEST
-local const config configuration_table[2] = {
-/* good lazy nice chain */
-/* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */
-/* 1 */ {4, 4, 8, 4, deflate_fast}}; /* max speed, no lazy matches */
-#else
-local const config configuration_table[10] = {
-/* good lazy nice chain */
-/* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */
-/* 1 */ {4, 4, 8, 4, deflate_fast}, /* max speed, no lazy matches */
-/* 2 */ {4, 5, 16, 8, deflate_fast},
-/* 3 */ {4, 6, 32, 32, deflate_fast},
-
-/* 4 */ {4, 4, 16, 16, deflate_slow}, /* lazy matches */
-/* 5 */ {8, 16, 32, 32, deflate_slow},
-/* 6 */ {8, 16, 128, 128, deflate_slow},
-/* 7 */ {8, 32, 128, 256, deflate_slow},
-/* 8 */ {32, 128, 258, 1024, deflate_slow},
-/* 9 */ {32, 258, 258, 4096, deflate_slow}}; /* max compression */
-#endif
-
-/* Note: the deflate() code requires max_lazy >= MIN_MATCH and max_chain >= 4
- * For deflate_fast() (levels <= 3) good is ignored and lazy has a different
- * meaning.
- */
-
-#define EQUAL 0
-/* result of memcmp for equal strings */
-
-#ifndef NO_DUMMY_DECL
-struct static_tree_desc_s {int dummy;}; /* for buggy compilers */
-#endif
-
-/* ===========================================================================
- * Update a hash value with the given input byte
- * IN assertion: all calls to to UPDATE_HASH are made with consecutive
- * input characters, so that a running hash key can be computed from the
- * previous key instead of complete recalculation each time.
- */
-#define UPDATE_HASH(s,h,c) (h = (((h)<<s->hash_shift) ^ (c)) & s->hash_mask)
-
-
-/* ===========================================================================
- * Insert string str in the dictionary and set match_head to the previous head
- * of the hash chain (the most recent string with same hash key). Return
- * the previous length of the hash chain.
- * If this file is compiled with -DFASTEST, the compression level is forced
- * to 1, and no hash chains are maintained.
- * IN assertion: all calls to to INSERT_STRING are made with consecutive
- * input characters and the first MIN_MATCH bytes of str are valid
- * (except for the last MIN_MATCH-1 bytes of the input file).
- */
-#ifdef FASTEST
-#define INSERT_STRING(s, str, match_head) \
- (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \
- match_head = s->head[s->ins_h], \
- s->head[s->ins_h] = (Pos)(str))
-#else
-#define INSERT_STRING(s, str, match_head) \
- (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \
- match_head = s->prev[(str) & s->w_mask] = s->head[s->ins_h], \
- s->head[s->ins_h] = (Pos)(str))
-#endif
-
-/* ===========================================================================
- * Initialize the hash table (avoiding 64K overflow for 16 bit systems).
- * prev[] will be initialized on the fly.
- */
-#define CLEAR_HASH(s) \
- s->head[s->hash_size-1] = NIL; \
- zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head));
-
-/* ========================================================================= */
-int ZEXPORT deflateInit_(strm, level, version, stream_size)
- z_streamp strm;
- int level;
- const char *version;
- int stream_size;
-{
- return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL,
- Z_DEFAULT_STRATEGY, version, stream_size);
- /* To do: ignore strm->next_in if we use it as window */
-}
-
-/* ========================================================================= */
-int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
- version, stream_size)
- z_streamp strm;
- int level;
- int method;
- int windowBits;
- int memLevel;
- int strategy;
- const char *version;
- int stream_size;
-{
- deflate_state *s;
- int wrap = 1;
- static const char my_version[] = ZLIB_VERSION;
-
- ushf *overlay;
- /* We overlay pending_buf and d_buf+l_buf. This works since the average
- * output size for (length,distance) codes is <= 24 bits.
- */
-
- if (version == Z_NULL || version[0] != my_version[0] ||
- stream_size != sizeof(z_stream)) {
- return Z_VERSION_ERROR;
- }
- if (strm == Z_NULL) return Z_STREAM_ERROR;
-
- strm->msg = Z_NULL;
- if (strm->zalloc == (alloc_func)0) {
- strm->zalloc = zcalloc;
- strm->opaque = (voidpf)0;
- }
- if (strm->zfree == (free_func)0) strm->zfree = zcfree;
-
-#ifdef FASTEST
- if (level != 0) level = 1;
-#else
- if (level == Z_DEFAULT_COMPRESSION) level = 6;
-#endif
-
- if (windowBits < 0) { /* suppress zlib wrapper */
- wrap = 0;
- windowBits = -windowBits;
- }
-#ifdef GZIP
- else if (windowBits > 15) {
- wrap = 2; /* write gzip wrapper instead */
- windowBits -= 16;
- }
-#endif
- if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED ||
- windowBits < 8 || windowBits > 15 || level < 0 || level > 9 ||
- strategy < 0 || strategy > Z_FIXED) {
- return Z_STREAM_ERROR;
- }
- if (windowBits == 8) windowBits = 9; /* until 256-byte window bug fixed */
- s = (deflate_state *) ZALLOC(strm, 1, sizeof(deflate_state));
- if (s == Z_NULL) return Z_MEM_ERROR;
- strm->state = (struct internal_state FAR *)s;
- s->strm = strm;
-
- s->wrap = wrap;
- s->gzhead = Z_NULL;
- s->w_bits = windowBits;
- s->w_size = 1 << s->w_bits;
- s->w_mask = s->w_size - 1;
-
- s->hash_bits = memLevel + 7;
- s->hash_size = 1 << s->hash_bits;
- s->hash_mask = s->hash_size - 1;
- s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH);
-
- s->window = (Bytef *) ZALLOC(strm, s->w_size, 2*sizeof(Byte));
- s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos));
- s->head = (Posf *) ZALLOC(strm, s->hash_size, sizeof(Pos));
-
- s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */
-
- overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2);
- s->pending_buf = (uchf *) overlay;
- s->pending_buf_size = (ulg)s->lit_bufsize * (sizeof(ush)+2L);
-
- if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL ||
- s->pending_buf == Z_NULL) {
- s->status = FINISH_STATE;
- strm->msg = (char*)ERR_MSG(Z_MEM_ERROR);
- deflateEnd (strm);
- return Z_MEM_ERROR;
- }
- s->d_buf = overlay + s->lit_bufsize/sizeof(ush);
- s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize;
-
- s->level = level;
- s->strategy = strategy;
- s->method = (Byte)method;
-
- return deflateReset(strm);
-}
-
-/* ========================================================================= */
-int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
- z_streamp strm;
- const Bytef *dictionary;
- uInt dictLength;
-{
- deflate_state *s;
- uInt length = dictLength;
- uInt n;
- IPos hash_head = 0;
-
- if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL ||
- strm->state->wrap == 2 ||
- (strm->state->wrap == 1 && strm->state->status != INIT_STATE))
- return Z_STREAM_ERROR;
-
- s = strm->state;
- if (s->wrap)
- strm->adler = adler32(strm->adler, dictionary, dictLength);
-
- if (length < MIN_MATCH) return Z_OK;
- if (length > MAX_DIST(s)) {
- length = MAX_DIST(s);
- dictionary += dictLength - length; /* use the tail of the dictionary */
- }
- zmemcpy(s->window, dictionary, length);
- s->strstart = length;
- s->block_start = (long)length;
-
- /* Insert all strings in the hash table (except for the last two bytes).
- * s->lookahead stays null, so s->ins_h will be recomputed at the next
- * call of fill_window.
- */
- s->ins_h = s->window[0];
- UPDATE_HASH(s, s->ins_h, s->window[1]);
- for (n = 0; n <= length - MIN_MATCH; n++) {
- INSERT_STRING(s, n, hash_head);
- }
- if (hash_head) hash_head = 0; /* to make compiler happy */
- return Z_OK;
-}
-
-/* ========================================================================= */
-int ZEXPORT deflateReset (strm)
- z_streamp strm;
-{
- deflate_state *s;
-
- if (strm == Z_NULL || strm->state == Z_NULL ||
- strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) {
- return Z_STREAM_ERROR;
- }
-
- strm->total_in = strm->total_out = 0;
- strm->msg = Z_NULL; /* use zfree if we ever allocate msg dynamically */
- strm->data_type = Z_UNKNOWN;
-
- s = (deflate_state *)strm->state;
- s->pending = 0;
- s->pending_out = s->pending_buf;
-
- if (s->wrap < 0) {
- s->wrap = -s->wrap; /* was made negative by deflate(..., Z_FINISH); */
- }
- s->status = s->wrap ? INIT_STATE : BUSY_STATE;
- strm->adler =
-#ifdef GZIP
- s->wrap == 2 ? crc32(0L, Z_NULL, 0) :
-#endif
- adler32(0L, Z_NULL, 0);
- s->last_flush = Z_NO_FLUSH;
-
- _tr_init(s);
- lm_init(s);
-
- return Z_OK;
-}
-
-/* ========================================================================= */
-int ZEXPORT deflateSetHeader (strm, head)
- z_streamp strm;
- gz_headerp head;
-{
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- if (strm->state->wrap != 2) return Z_STREAM_ERROR;
- strm->state->gzhead = head;
- return Z_OK;
-}
-
-/* ========================================================================= */
-int ZEXPORT deflatePrime (strm, bits, value)
- z_streamp strm;
- int bits;
- int value;
-{
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- strm->state->bi_valid = bits;
- strm->state->bi_buf = (ush)(value & ((1 << bits) - 1));
- return Z_OK;
-}
-
-/* ========================================================================= */
-int ZEXPORT deflateParams(strm, level, strategy)
- z_streamp strm;
- int level;
- int strategy;
-{
- deflate_state *s;
- compress_func func;
- int err = Z_OK;
-
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- s = strm->state;
-
-#ifdef FASTEST
- if (level != 0) level = 1;
-#else
- if (level == Z_DEFAULT_COMPRESSION) level = 6;
-#endif
- if (level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED) {
- return Z_STREAM_ERROR;
- }
- func = configuration_table[s->level].func;
-
- if (func != configuration_table[level].func && strm->total_in != 0) {
- /* Flush the last buffer: */
- err = deflate(strm, Z_PARTIAL_FLUSH);
- }
- if (s->level != level) {
- s->level = level;
- s->max_lazy_match = configuration_table[level].max_lazy;
- s->good_match = configuration_table[level].good_length;
- s->nice_match = configuration_table[level].nice_length;
- s->max_chain_length = configuration_table[level].max_chain;
- }
- s->strategy = strategy;
- return err;
-}
-
-/* ========================================================================= */
-int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain)
- z_streamp strm;
- int good_length;
- int max_lazy;
- int nice_length;
- int max_chain;
-{
- deflate_state *s;
-
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- s = strm->state;
- s->good_match = good_length;
- s->max_lazy_match = max_lazy;
- s->nice_match = nice_length;
- s->max_chain_length = max_chain;
- return Z_OK;
-}
-
-/* =========================================================================
- * For the default windowBits of 15 and memLevel of 8, this function returns
- * a close to exact, as well as small, upper bound on the compressed size.
- * They are coded as constants here for a reason--if the #define's are
- * changed, then this function needs to be changed as well. The return
- * value for 15 and 8 only works for those exact settings.
- *
- * For any setting other than those defaults for windowBits and memLevel,
- * the value returned is a conservative worst case for the maximum expansion
- * 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.
- */
-uLong ZEXPORT deflateBound(strm, sourceLen)
- z_streamp strm;
- uLong sourceLen;
-{
- deflate_state *s;
- uLong destLen;
-
- /* conservative upper bound */
- destLen = sourceLen +
- ((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 11;
-
- /* if can't get parameters, return conservative bound */
- if (strm == Z_NULL || strm->state == Z_NULL)
- return destLen;
-
- /* if not default parameters, return conservative bound */
- s = strm->state;
- if (s->w_bits != 15 || s->hash_bits != 8 + 7)
- return destLen;
-
- /* default settings: return tight bound for that case */
- return compressBound(sourceLen);
-}
-
-/* =========================================================================
- * Put a short in the pending buffer. The 16-bit value is put in MSB order.
- * IN assertion: the stream state is correct and there is enough room in
- * pending_buf.
- */
-local void putShortMSB (s, b)
- deflate_state *s;
- uInt b;
-{
- put_byte(s, (Byte)(b >> 8));
- put_byte(s, (Byte)(b & 0xff));
-}
-
-/* =========================================================================
- * Flush as much pending output as possible. All deflate() output goes
- * through this function so some applications may wish to modify it
- * to avoid allocating a large strm->next_out buffer and copying into it.
- * (See also read_buf()).
- */
-local void flush_pending(strm)
- z_streamp strm;
-{
- unsigned len = strm->state->pending;
-
- if (len > strm->avail_out) len = strm->avail_out;
- if (len == 0) return;
-
- zmemcpy(strm->next_out, strm->state->pending_out, len);
- strm->next_out += len;
- strm->state->pending_out += len;
- strm->total_out += len;
- strm->avail_out -= len;
- strm->state->pending -= len;
- if (strm->state->pending == 0) {
- strm->state->pending_out = strm->state->pending_buf;
- }
-}
-
-/* ========================================================================= */
-int ZEXPORT deflate (strm, flush)
- z_streamp strm;
- int flush;
-{
- int old_flush; /* value of flush param for previous deflate call */
- deflate_state *s;
-
- if (strm == Z_NULL || strm->state == Z_NULL ||
- flush > Z_FINISH || flush < 0) {
- return Z_STREAM_ERROR;
- }
- s = strm->state;
-
- if (strm->next_out == Z_NULL ||
- (strm->next_in == Z_NULL && strm->avail_in != 0) ||
- (s->status == FINISH_STATE && flush != Z_FINISH)) {
- ERR_RETURN(strm, Z_STREAM_ERROR);
- }
- if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR);
-
- s->strm = strm; /* just in case */
- old_flush = s->last_flush;
- s->last_flush = flush;
-
- /* Write the header */
- if (s->status == INIT_STATE) {
-#ifdef GZIP
- if (s->wrap == 2) {
- strm->adler = crc32(0L, Z_NULL, 0);
- put_byte(s, 31);
- put_byte(s, 139);
- put_byte(s, 8);
- if (s->gzhead == NULL) {
- put_byte(s, 0);
- put_byte(s, 0);
- put_byte(s, 0);
- put_byte(s, 0);
- put_byte(s, 0);
- put_byte(s, s->level == 9 ? 2 :
- (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
- 4 : 0));
- put_byte(s, OS_CODE);
- s->status = BUSY_STATE;
- }
- else {
- put_byte(s, (s->gzhead->text ? 1 : 0) +
- (s->gzhead->hcrc ? 2 : 0) +
- (s->gzhead->extra == Z_NULL ? 0 : 4) +
- (s->gzhead->name == Z_NULL ? 0 : 8) +
- (s->gzhead->comment == Z_NULL ? 0 : 16)
- );
- put_byte(s, (Byte)(s->gzhead->time & 0xff));
- put_byte(s, (Byte)((s->gzhead->time >> 8) & 0xff));
- put_byte(s, (Byte)((s->gzhead->time >> 16) & 0xff));
- put_byte(s, (Byte)((s->gzhead->time >> 24) & 0xff));
- put_byte(s, s->level == 9 ? 2 :
- (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
- 4 : 0));
- put_byte(s, s->gzhead->os & 0xff);
- if (s->gzhead->extra != NULL) {
- put_byte(s, s->gzhead->extra_len & 0xff);
- put_byte(s, (s->gzhead->extra_len >> 8) & 0xff);
- }
- if (s->gzhead->hcrc)
- strm->adler = crc32(strm->adler, s->pending_buf,
- s->pending);
- s->gzindex = 0;
- s->status = EXTRA_STATE;
- }
- }
- else
-#endif
- {
- uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8;
- uInt level_flags;
-
- if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2)
- level_flags = 0;
- else if (s->level < 6)
- level_flags = 1;
- else if (s->level == 6)
- level_flags = 2;
- else
- level_flags = 3;
- header |= (level_flags << 6);
- if (s->strstart != 0) header |= PRESET_DICT;
- header += 31 - (header % 31);
-
- s->status = BUSY_STATE;
- putShortMSB(s, header);
-
- /* Save the adler32 of the preset dictionary: */
- if (s->strstart != 0) {
- putShortMSB(s, (uInt)(strm->adler >> 16));
- putShortMSB(s, (uInt)(strm->adler & 0xffff));
- }
- strm->adler = adler32(0L, Z_NULL, 0);
- }
- }
-#ifdef GZIP
- if (s->status == EXTRA_STATE) {
- if (s->gzhead->extra != NULL) {
- uInt beg = s->pending; /* start of bytes to update crc */
-
- while (s->gzindex < (s->gzhead->extra_len & 0xffff)) {
- if (s->pending == s->pending_buf_size) {
- if (s->gzhead->hcrc && s->pending > beg)
- strm->adler = crc32(strm->adler, s->pending_buf + beg,
- s->pending - beg);
- flush_pending(strm);
- beg = s->pending;
- if (s->pending == s->pending_buf_size)
- break;
- }
- put_byte(s, s->gzhead->extra[s->gzindex]);
- s->gzindex++;
- }
- if (s->gzhead->hcrc && s->pending > beg)
- strm->adler = crc32(strm->adler, s->pending_buf + beg,
- s->pending - beg);
- if (s->gzindex == s->gzhead->extra_len) {
- s->gzindex = 0;
- s->status = NAME_STATE;
- }
- }
- else
- s->status = NAME_STATE;
- }
- if (s->status == NAME_STATE) {
- if (s->gzhead->name != NULL) {
- uInt beg = s->pending; /* start of bytes to update crc */
- int val;
-
- do {
- if (s->pending == s->pending_buf_size) {
- if (s->gzhead->hcrc && s->pending > beg)
- strm->adler = crc32(strm->adler, s->pending_buf + beg,
- s->pending - beg);
- flush_pending(strm);
- beg = s->pending;
- if (s->pending == s->pending_buf_size) {
- val = 1;
- break;
- }
- }
- val = s->gzhead->name[s->gzindex++];
- put_byte(s, val);
- } while (val != 0);
- if (s->gzhead->hcrc && s->pending > beg)
- strm->adler = crc32(strm->adler, s->pending_buf + beg,
- s->pending - beg);
- if (val == 0) {
- s->gzindex = 0;
- s->status = COMMENT_STATE;
- }
- }
- else
- s->status = COMMENT_STATE;
- }
- if (s->status == COMMENT_STATE) {
- if (s->gzhead->comment != NULL) {
- uInt beg = s->pending; /* start of bytes to update crc */
- int val;
-
- do {
- if (s->pending == s->pending_buf_size) {
- if (s->gzhead->hcrc && s->pending > beg)
- strm->adler = crc32(strm->adler, s->pending_buf + beg,
- s->pending - beg);
- flush_pending(strm);
- beg = s->pending;
- if (s->pending == s->pending_buf_size) {
- val = 1;
- break;
- }
- }
- val = s->gzhead->comment[s->gzindex++];
- put_byte(s, val);
- } while (val != 0);
- if (s->gzhead->hcrc && s->pending > beg)
- strm->adler = crc32(strm->adler, s->pending_buf + beg,
- s->pending - beg);
- if (val == 0)
- s->status = HCRC_STATE;
- }
- else
- s->status = HCRC_STATE;
- }
- if (s->status == HCRC_STATE) {
- if (s->gzhead->hcrc) {
- if (s->pending + 2 > s->pending_buf_size)
- flush_pending(strm);
- if (s->pending + 2 <= s->pending_buf_size) {
- put_byte(s, (Byte)(strm->adler & 0xff));
- put_byte(s, (Byte)((strm->adler >> 8) & 0xff));
- strm->adler = crc32(0L, Z_NULL, 0);
- s->status = BUSY_STATE;
- }
- }
- else
- s->status = BUSY_STATE;
- }
-#endif
-
- /* Flush as much pending output as possible */
- if (s->pending != 0) {
- flush_pending(strm);
- if (strm->avail_out == 0) {
- /* Since avail_out is 0, deflate will be called again with
- * more output space, but possibly with both pending and
- * avail_in equal to zero. There won't be anything to do,
- * but this is not an error situation so make sure we
- * return OK instead of BUF_ERROR at next call of deflate:
- */
- s->last_flush = -1;
- return Z_OK;
- }
-
- /* Make sure there is something to do and avoid duplicate consecutive
- * flushes. For repeated and useless calls with Z_FINISH, we keep
- * returning Z_STREAM_END instead of Z_BUF_ERROR.
- */
- } else if (strm->avail_in == 0 && flush <= old_flush &&
- flush != Z_FINISH) {
- ERR_RETURN(strm, Z_BUF_ERROR);
- }
-
- /* User must not provide more input after the first FINISH: */
- if (s->status == FINISH_STATE && strm->avail_in != 0) {
- ERR_RETURN(strm, Z_BUF_ERROR);
- }
-
- /* Start a new block or continue the current one.
- */
- if (strm->avail_in != 0 || s->lookahead != 0 ||
- (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) {
- block_state bstate;
-
- bstate = (*(configuration_table[s->level].func))(s, flush);
-
- if (bstate == finish_started || bstate == finish_done) {
- s->status = FINISH_STATE;
- }
- if (bstate == need_more || bstate == finish_started) {
- if (strm->avail_out == 0) {
- s->last_flush = -1; /* avoid BUF_ERROR next call, see above */
- }
- return Z_OK;
- /* If flush != Z_NO_FLUSH && avail_out == 0, the next call
- * of deflate should use the same flush parameter to make sure
- * that the flush is complete. So we don't have to output an
- * empty block here, this will be done at next call. This also
- * ensures that for a very small output buffer, we emit at most
- * one empty block.
- */
- }
- if (bstate == block_done) {
- if (flush == Z_PARTIAL_FLUSH) {
- _tr_align(s);
- } else { /* 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 */
- }
- }
- flush_pending(strm);
- if (strm->avail_out == 0) {
- s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */
- return Z_OK;
- }
- }
- }
- Assert(strm->avail_out > 0, "bug2");
-
- if (flush != Z_FINISH) return Z_OK;
- if (s->wrap <= 0) return Z_STREAM_END;
-
- /* Write the trailer */
-#ifdef GZIP
- if (s->wrap == 2) {
- put_byte(s, (Byte)(strm->adler & 0xff));
- put_byte(s, (Byte)((strm->adler >> 8) & 0xff));
- put_byte(s, (Byte)((strm->adler >> 16) & 0xff));
- put_byte(s, (Byte)((strm->adler >> 24) & 0xff));
- put_byte(s, (Byte)(strm->total_in & 0xff));
- put_byte(s, (Byte)((strm->total_in >> 8) & 0xff));
- put_byte(s, (Byte)((strm->total_in >> 16) & 0xff));
- put_byte(s, (Byte)((strm->total_in >> 24) & 0xff));
- }
- else
-#endif
- {
- putShortMSB(s, (uInt)(strm->adler >> 16));
- putShortMSB(s, (uInt)(strm->adler & 0xffff));
- }
- flush_pending(strm);
- /* If avail_out is zero, the application will call deflate again
- * to flush the rest.
- */
- if (s->wrap > 0) s->wrap = -s->wrap; /* write the trailer only once! */
- return s->pending != 0 ? Z_OK : Z_STREAM_END;
-}
-
-/* ========================================================================= */
-int ZEXPORT deflateEnd (strm)
- z_streamp strm;
-{
- int status;
-
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
-
- status = strm->state->status;
- if (status != INIT_STATE &&
- status != EXTRA_STATE &&
- status != NAME_STATE &&
- status != COMMENT_STATE &&
- status != HCRC_STATE &&
- status != BUSY_STATE &&
- status != FINISH_STATE) {
- return Z_STREAM_ERROR;
- }
-
- /* Deallocate in reverse order of allocations: */
- TRY_FREE(strm, strm->state->pending_buf);
- TRY_FREE(strm, strm->state->head);
- TRY_FREE(strm, strm->state->prev);
- TRY_FREE(strm, strm->state->window);
-
- ZFREE(strm, strm->state);
- strm->state = Z_NULL;
-
- return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK;
-}
-
-/* =========================================================================
- * Copy the source state to the destination state.
- * To simplify the source, this is not supported for 16-bit MSDOS (which
- * doesn't have enough memory anyway to duplicate compression states).
- */
-int ZEXPORT deflateCopy (dest, source)
- z_streamp dest;
- z_streamp source;
-{
-#ifdef MAXSEG_64K
- return Z_STREAM_ERROR;
-#else
- deflate_state *ds;
- deflate_state *ss;
- ushf *overlay;
-
-
- if (source == Z_NULL || dest == Z_NULL || source->state == Z_NULL) {
- return Z_STREAM_ERROR;
- }
-
- ss = source->state;
-
- zmemcpy(dest, source, sizeof(z_stream));
-
- ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state));
- if (ds == Z_NULL) return Z_MEM_ERROR;
- dest->state = (struct internal_state FAR *) ds;
- zmemcpy(ds, ss, sizeof(deflate_state));
- ds->strm = dest;
-
- ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte));
- ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos));
- ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos));
- overlay = (ushf *) ZALLOC(dest, ds->lit_bufsize, sizeof(ush)+2);
- ds->pending_buf = (uchf *) overlay;
-
- if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL ||
- ds->pending_buf == Z_NULL) {
- deflateEnd (dest);
- return Z_MEM_ERROR;
- }
- /* following zmemcpy do not work for 16-bit MSDOS */
- zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte));
- zmemcpy(ds->prev, ss->prev, ds->w_size * sizeof(Pos));
- zmemcpy(ds->head, ss->head, ds->hash_size * sizeof(Pos));
- zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size);
-
- ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf);
- ds->d_buf = overlay + ds->lit_bufsize/sizeof(ush);
- ds->l_buf = ds->pending_buf + (1+sizeof(ush))*ds->lit_bufsize;
-
- ds->l_desc.dyn_tree = ds->dyn_ltree;
- ds->d_desc.dyn_tree = ds->dyn_dtree;
- ds->bl_desc.dyn_tree = ds->bl_tree;
-
- return Z_OK;
-#endif /* MAXSEG_64K */
-}
-
-/* ===========================================================================
- * Read a new buffer from the current input stream, update the adler32
- * and total number of bytes read. All deflate() input goes through
- * this function so some applications may wish to modify it to avoid
- * allocating a large strm->next_in buffer and copying from it.
- * (See also flush_pending()).
- */
-local int read_buf(strm, buf, size)
- z_streamp strm;
- Bytef *buf;
- unsigned size;
-{
- unsigned len = strm->avail_in;
-
- if (len > size) len = size;
- if (len == 0) return 0;
-
- strm->avail_in -= len;
-
- if (strm->state->wrap == 1) {
- strm->adler = adler32(strm->adler, strm->next_in, len);
- }
-#ifdef GZIP
- else if (strm->state->wrap == 2) {
- strm->adler = crc32(strm->adler, strm->next_in, len);
- }
-#endif
- zmemcpy(buf, strm->next_in, len);
- strm->next_in += len;
- strm->total_in += len;
-
- return (int)len;
-}
-
-/* ===========================================================================
- * Initialize the "longest match" routines for a new zlib stream
- */
-local void lm_init (s)
- deflate_state *s;
-{
- s->window_size = (ulg)2L*s->w_size;
-
- CLEAR_HASH(s);
-
- /* Set the default configuration parameters:
- */
- s->max_lazy_match = configuration_table[s->level].max_lazy;
- s->good_match = configuration_table[s->level].good_length;
- s->nice_match = configuration_table[s->level].nice_length;
- s->max_chain_length = configuration_table[s->level].max_chain;
-
- s->strstart = 0;
- s->block_start = 0L;
- s->lookahead = 0;
- s->match_length = s->prev_length = MIN_MATCH-1;
- s->match_available = 0;
- s->ins_h = 0;
-#ifndef FASTEST
-#ifdef ASMV
- match_init(); /* initialize the asm code */
-#endif
-#endif
-}
-
-#ifndef FASTEST
-/* ===========================================================================
- * Set match_start to the longest match starting at the given string and
- * return its length. Matches shorter or equal to prev_length are discarded,
- * in which case the result is equal to prev_length and match_start is
- * garbage.
- * IN assertions: cur_match is the head of the hash chain for the current
- * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1
- * OUT assertion: the match length is not greater than s->lookahead.
- */
-#ifndef ASMV
-/* For 80x86 and 680x0, an optimized version will be provided in match.asm or
- * match.S. The code will be functionally equivalent.
- */
-local uInt longest_match(s, cur_match)
- deflate_state *s;
- IPos cur_match; /* current match */
-{
- unsigned chain_length = s->max_chain_length;/* max hash chain length */
- register Bytef *scan = s->window + s->strstart; /* current string */
- register Bytef *match; /* matched string */
- register int len; /* length of current match */
- int best_len = s->prev_length; /* best match length so far */
- int nice_match = s->nice_match; /* stop if match long enough */
- IPos limit = s->strstart > (IPos)MAX_DIST(s) ?
- s->strstart - (IPos)MAX_DIST(s) : NIL;
- /* Stop when cur_match becomes <= limit. To simplify the code,
- * we prevent matches with the string of window index 0.
- */
- Posf *prev = s->prev;
- uInt wmask = s->w_mask;
-
-#ifdef UNALIGNED_OK
- /* Compare two bytes at a time. Note: this is not always beneficial.
- * Try with and without -DUNALIGNED_OK to check.
- */
- register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1;
- register ush scan_start = *(ushf*)scan;
- register ush scan_end = *(ushf*)(scan+best_len-1);
-#else
- register Bytef *strend = s->window + s->strstart + MAX_MATCH;
- register Byte scan_end1 = scan[best_len-1];
- register Byte scan_end = scan[best_len];
-#endif
-
- /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
- * It is easy to get rid of this optimization if necessary.
- */
- Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever");
-
- /* Do not waste too much time if we already have a good match: */
- if (s->prev_length >= s->good_match) {
- chain_length >>= 2;
- }
- /* Do not look for matches beyond the end of the input. This is necessary
- * to make deflate deterministic.
- */
- if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead;
-
- Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
-
- do {
- Assert(cur_match < s->strstart, "no future");
- match = s->window + cur_match;
-
- /* Skip to next match if the match length cannot increase
- * or if the match length is less than 2. Note that the checks below
- * for insufficient lookahead only occur occasionally for performance
- * reasons. Therefore uninitialized memory will be accessed, and
- * conditional jumps will be made that depend on those values.
- * However the length of the match is limited to the lookahead, so
- * the output of deflate is not affected by the uninitialized values.
- */
-#if (defined(UNALIGNED_OK) && MAX_MATCH == 258)
- /* This code assumes sizeof(unsigned short) == 2. Do not use
- * UNALIGNED_OK if your compiler uses a different size.
- */
- if (*(ushf*)(match+best_len-1) != scan_end ||
- *(ushf*)match != scan_start) continue;
-
- /* It is not necessary to compare scan[2] and match[2] since they are
- * always equal when the other bytes match, given that the hash keys
- * are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at
- * strstart+3, +5, ... up to strstart+257. We check for insufficient
- * lookahead only every 4th comparison; the 128th check will be made
- * at strstart+257. If MAX_MATCH-2 is not a multiple of 8, it is
- * necessary to put more guard bytes at the end of the window, or
- * to check more often for insufficient lookahead.
- */
- Assert(scan[2] == match[2], "scan[2]?");
- scan++, match++;
- do {
- } while (*(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
- *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
- *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
- *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
- scan < strend);
- /* The funny "do {}" generates better code on most compilers */
-
- /* Here, scan <= window+strstart+257 */
- Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
- if (*scan == *match) scan++;
-
- len = (MAX_MATCH - 1) - (int)(strend-scan);
- scan = strend - (MAX_MATCH-1);
-
-#else /* UNALIGNED_OK */
-
- if (match[best_len] != scan_end ||
- match[best_len-1] != scan_end1 ||
- *match != *scan ||
- *++match != scan[1]) continue;
-
- /* The check at best_len-1 can be removed because it will be made
- * again later. (This heuristic is not always a win.)
- * It is not necessary to compare scan[2] and match[2] since they
- * are always equal when the other bytes match, given that
- * the hash keys are equal and that HASH_BITS >= 8.
- */
- scan += 2, match++;
- Assert(*scan == *match, "match[2]?");
-
- /* We check for insufficient lookahead only every 8th comparison;
- * the 256th check will be made at strstart+258.
- */
- do {
- } while (*++scan == *++match && *++scan == *++match &&
- *++scan == *++match && *++scan == *++match &&
- *++scan == *++match && *++scan == *++match &&
- *++scan == *++match && *++scan == *++match &&
- scan < strend);
-
- Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
-
- len = MAX_MATCH - (int)(strend - scan);
- scan = strend - MAX_MATCH;
-
-#endif /* UNALIGNED_OK */
-
- if (len > best_len) {
- s->match_start = cur_match;
- best_len = len;
- if (len >= nice_match) break;
-#ifdef UNALIGNED_OK
- scan_end = *(ushf*)(scan+best_len-1);
-#else
- scan_end1 = scan[best_len-1];
- scan_end = scan[best_len];
-#endif
- }
- } while ((cur_match = prev[cur_match & wmask]) > limit
- && --chain_length != 0);
-
- if ((uInt)best_len <= s->lookahead) return (uInt)best_len;
- return s->lookahead;
-}
-#endif /* ASMV */
-#endif /* FASTEST */
-
-/* ---------------------------------------------------------------------------
- * Optimized version for level == 1 or strategy == Z_RLE only
- */
-local uInt longest_match_fast(s, cur_match)
- deflate_state *s;
- IPos cur_match; /* current match */
-{
- register Bytef *scan = s->window + s->strstart; /* current string */
- register Bytef *match; /* matched string */
- register int len; /* length of current match */
- register Bytef *strend = s->window + s->strstart + MAX_MATCH;
-
- /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
- * It is easy to get rid of this optimization if necessary.
- */
- Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever");
-
- Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
-
- Assert(cur_match < s->strstart, "no future");
-
- match = s->window + cur_match;
-
- /* Return failure if the match length is less than 2:
- */
- if (match[0] != scan[0] || match[1] != scan[1]) return MIN_MATCH-1;
-
- /* The check at best_len-1 can be removed because it will be made
- * again later. (This heuristic is not always a win.)
- * It is not necessary to compare scan[2] and match[2] since they
- * are always equal when the other bytes match, given that
- * the hash keys are equal and that HASH_BITS >= 8.
- */
- scan += 2, match += 2;
- Assert(*scan == *match, "match[2]?");
-
- /* We check for insufficient lookahead only every 8th comparison;
- * the 256th check will be made at strstart+258.
- */
- do {
- } while (*++scan == *++match && *++scan == *++match &&
- *++scan == *++match && *++scan == *++match &&
- *++scan == *++match && *++scan == *++match &&
- *++scan == *++match && *++scan == *++match &&
- scan < strend);
-
- Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
-
- len = MAX_MATCH - (int)(strend - scan);
-
- if (len < MIN_MATCH) return MIN_MATCH - 1;
-
- s->match_start = cur_match;
- return (uInt)len <= s->lookahead ? (uInt)len : s->lookahead;
-}
-
-#ifdef DEBUG
-/* ===========================================================================
- * Check that the match at match_start is indeed a match.
- */
-local void check_match(s, start, match, length)
- deflate_state *s;
- IPos start, match;
- int length;
-{
- /* check that the match is indeed a match */
- if (zmemcmp(s->window + match,
- s->window + start, length) != EQUAL) {
- fprintf(stderr, " start %u, match %u, length %d\n",
- start, match, length);
- do {
- fprintf(stderr, "%c%c", s->window[match++], s->window[start++]);
- } while (--length != 0);
- z_error("invalid match");
- }
- if (z_verbose > 1) {
- fprintf(stderr,"\\[%d,%d]", start-match, length);
- do { putc(s->window[start++], stderr); } while (--length != 0);
- }
-}
-#else
-# define check_match(s, start, match, length)
-#endif /* DEBUG */
-
-/* ===========================================================================
- * Fill the window when the lookahead becomes insufficient.
- * Updates strstart and lookahead.
- *
- * IN assertion: lookahead < MIN_LOOKAHEAD
- * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD
- * At least one byte has been read, or avail_in == 0; reads are
- * performed for at least two bytes (required for the zip translate_eol
- * option -- not supported here).
- */
-local void fill_window(s)
- deflate_state *s;
-{
- register unsigned n, m;
- register Posf *p;
- unsigned more; /* Amount of free space at the end of the window. */
- uInt wsize = s->w_size;
-
- do {
- more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart);
-
- /* Deal with !@#$% 64K limit: */
- if (sizeof(int) <= 2) {
- if (more == 0 && s->strstart == 0 && s->lookahead == 0) {
- more = wsize;
-
- } else if (more == (unsigned)(-1)) {
- /* Very unlikely, but possible on 16 bit machine if
- * strstart == 0 && lookahead == 1 (input done a byte at time)
- */
- more--;
- }
- }
-
- /* If the window is almost full and there is insufficient lookahead,
- * move the upper half to the lower one to make room in the upper half.
- */
- if (s->strstart >= wsize+MAX_DIST(s)) {
-
- zmemcpy(s->window, s->window+wsize, (unsigned)wsize);
- s->match_start -= wsize;
- s->strstart -= wsize; /* we now have strstart >= MAX_DIST */
- s->block_start -= (long) wsize;
-
- /* Slide the hash table (could be avoided with 32 bit values
- at the expense of memory usage). We slide even when level == 0
- to keep the hash table consistent if we switch back to level > 0
- 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 {
- m = *--p;
- *p = (Pos)(m >= wsize ? m-wsize : NIL);
- } while (--n);
-
- n = wsize;
-#ifndef FASTEST
- p = &s->prev[n];
- do {
- m = *--p;
- *p = (Pos)(m >= wsize ? m-wsize : NIL);
- /* If n is not on any hash chain, prev[n] is garbage but
- * its value will never be used.
- */
- } while (--n);
-#endif
- more += wsize;
- }
- if (s->strm->avail_in == 0) return;
-
- /* If there was no sliding:
- * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 &&
- * more == window_size - lookahead - strstart
- * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1)
- * => more >= window_size - 2*WSIZE + 2
- * In the BIG_MEM or MMAP case (not yet supported),
- * window_size == input_size + MIN_LOOKAHEAD &&
- * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD.
- * Otherwise, window_size == 2*WSIZE so more >= 2.
- * If there was sliding, more >= WSIZE. So in all cases, more >= 2.
- */
- Assert(more >= 2, "more < 2");
-
- n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more);
- s->lookahead += n;
-
- /* Initialize the hash value now that we have some input: */
- if (s->lookahead >= MIN_MATCH) {
- s->ins_h = s->window[s->strstart];
- UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]);
-#if MIN_MATCH != 3
- Call UPDATE_HASH() MIN_MATCH-3 more times
-#endif
- }
- /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage,
- * but this is not important since only literal bytes will be emitted.
- */
-
- } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0);
-}
-
-/* ===========================================================================
- * 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) { \
- _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)); \
- 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; \
-}
-
-/* ===========================================================================
- * Copy without compression as much as possible from the input stream, return
- * the current block state.
- * This function does not insert new strings in the dictionary since
- * uncompressible data is probably not useful. This function is used
- * only for the level=0 compression option.
- * NOTE: this function should be optimized to avoid extra copying from
- * window to pending_buf.
- */
-local block_state deflate_stored(s, flush)
- deflate_state *s;
- int flush;
-{
- /* Stored blocks are limited to 0xffff bytes, pending_buf is limited
- * to pending_buf_size, and each stored block has a 5 byte header:
- */
- ulg max_block_size = 0xffff;
- ulg max_start;
-
- if (max_block_size > s->pending_buf_size - 5) {
- max_block_size = s->pending_buf_size - 5;
- }
-
- /* Copy as much as possible from input to output: */
- for (;;) {
- /* Fill the window as much as possible: */
- if (s->lookahead <= 1) {
-
- Assert(s->strstart < s->w_size+MAX_DIST(s) ||
- s->block_start >= (long)s->w_size, "slide too late");
-
- fill_window(s);
- if (s->lookahead == 0 && flush == Z_NO_FLUSH) return need_more;
-
- if (s->lookahead == 0) break; /* flush the current block */
- }
- Assert(s->block_start >= 0L, "block gone");
-
- s->strstart += s->lookahead;
- s->lookahead = 0;
-
- /* Emit a stored block if pending_buf will be full: */
- max_start = s->block_start + max_block_size;
- if (s->strstart == 0 || (ulg)s->strstart >= max_start) {
- /* strstart == 0 is possible when wraparound on 16-bit machine */
- s->lookahead = (uInt)(s->strstart - max_start);
- s->strstart = (uInt)max_start;
- FLUSH_BLOCK(s, 0);
- }
- /* Flush if we may have to slide, otherwise block_start may become
- * negative and the data will be gone:
- */
- if (s->strstart - (uInt)s->block_start >= MAX_DIST(s)) {
- FLUSH_BLOCK(s, 0);
- }
- }
- FLUSH_BLOCK(s, flush == Z_FINISH);
- return flush == Z_FINISH ? finish_done : block_done;
-}
-
-/* ===========================================================================
- * Compress as much as possible from the input stream, return the current
- * block state.
- * This function does not perform lazy evaluation of matches and inserts
- * new strings in the dictionary only for unmatched strings or for short
- * matches. It is used only for the fast compression options.
- */
-local block_state deflate_fast(s, flush)
- deflate_state *s;
- int flush;
-{
- IPos hash_head = NIL; /* head of the hash chain */
- int bflush; /* set if current block must be flushed */
-
- for (;;) {
- /* Make sure that we always have enough lookahead, except
- * at the end of the input file. We need MAX_MATCH bytes
- * for the next match, plus MIN_MATCH bytes to insert the
- * string following the next match.
- */
- if (s->lookahead < MIN_LOOKAHEAD) {
- fill_window(s);
- if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
- return need_more;
- }
- if (s->lookahead == 0) break; /* flush the current block */
- }
-
- /* Insert the string window[strstart .. strstart+2] in the
- * dictionary, and set hash_head to the head of the hash chain:
- */
- if (s->lookahead >= MIN_MATCH) {
- INSERT_STRING(s, s->strstart, hash_head);
- }
-
- /* Find the longest match, discarding those <= prev_length.
- * At this point we have always match_length < MIN_MATCH
- */
- if (hash_head != NIL && s->strstart - hash_head <= MAX_DIST(s)) {
- /* To simplify the code, we prevent matches with the string
- * 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 */
- }
- if (s->match_length >= MIN_MATCH) {
- check_match(s, s->strstart, s->match_start, s->match_length);
-
- _tr_tally_dist(s, s->strstart - s->match_start,
- s->match_length - MIN_MATCH, bflush);
-
- s->lookahead -= s->match_length;
-
- /* Insert new strings in the hash table only if the match length
- * is not too large. This saves time but degrades compression.
- */
-#ifndef FASTEST
- if (s->match_length <= s->max_insert_length &&
- s->lookahead >= MIN_MATCH) {
- s->match_length--; /* string at strstart already in table */
- do {
- s->strstart++;
- INSERT_STRING(s, s->strstart, hash_head);
- /* strstart never exceeds WSIZE-MAX_MATCH, so there are
- * always MIN_MATCH bytes ahead.
- */
- } while (--s->match_length != 0);
- s->strstart++;
- } else
-#endif
- {
- s->strstart += s->match_length;
- s->match_length = 0;
- s->ins_h = s->window[s->strstart];
- UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]);
-#if MIN_MATCH != 3
- Call UPDATE_HASH() MIN_MATCH-3 more times
-#endif
- /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not
- * matter since it will be recomputed at next deflate call.
- */
- }
- } else {
- /* No match, output a literal byte */
- 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;
-}
-
-#ifndef FASTEST
-/* ===========================================================================
- * Same as above, but achieves better compression. We use a lazy
- * evaluation for matches: a match is finally adopted only if there is
- * no better match at the next window position.
- */
-local block_state deflate_slow(s, flush)
- deflate_state *s;
- int flush;
-{
- IPos hash_head = NIL; /* head of hash chain */
- int bflush; /* set if current block must be flushed */
-
- /* Process the input block. */
- for (;;) {
- /* Make sure that we always have enough lookahead, except
- * at the end of the input file. We need MAX_MATCH bytes
- * for the next match, plus MIN_MATCH bytes to insert the
- * string following the next match.
- */
- if (s->lookahead < MIN_LOOKAHEAD) {
- fill_window(s);
- if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
- return need_more;
- }
- if (s->lookahead == 0) break; /* flush the current block */
- }
-
- /* Insert the string window[strstart .. strstart+2] in the
- * dictionary, and set hash_head to the head of the hash chain:
- */
- if (s->lookahead >= MIN_MATCH) {
- INSERT_STRING(s, s->strstart, hash_head);
- }
-
- /* Find the longest match, discarding those <= prev_length.
- */
- s->prev_length = s->match_length, s->prev_match = s->match_start;
- s->match_length = MIN_MATCH-1;
-
- if (hash_head != NIL && s->prev_length < s->max_lazy_match &&
- s->strstart - hash_head <= MAX_DIST(s)) {
- /* To simplify the code, we prevent matches with the string
- * 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 */
-
- if (s->match_length <= 5 && (s->strategy == Z_FILTERED
-#if TOO_FAR <= 32767
- || (s->match_length == MIN_MATCH &&
- s->strstart - s->match_start > TOO_FAR)
-#endif
- )) {
-
- /* If prev_match is also MIN_MATCH, match_start is garbage
- * but we will ignore the current match anyway.
- */
- s->match_length = MIN_MATCH-1;
- }
- }
- /* If there was a match at the previous step and the current
- * match is not better, output the previous match:
- */
- if (s->prev_length >= MIN_MATCH && s->match_length <= s->prev_length) {
- uInt max_insert = s->strstart + s->lookahead - MIN_MATCH;
- /* Do not insert strings in hash table beyond this. */
-
- check_match(s, s->strstart-1, s->prev_match, s->prev_length);
-
- _tr_tally_dist(s, s->strstart -1 - s->prev_match,
- s->prev_length - MIN_MATCH, bflush);
-
- /* Insert in hash table all strings up to the end of the match.
- * strstart-1 and strstart are already inserted. If there is not
- * enough lookahead, the last two strings are not inserted in
- * the hash table.
- */
- s->lookahead -= s->prev_length-1;
- s->prev_length -= 2;
- do {
- if (++s->strstart <= max_insert) {
- INSERT_STRING(s, s->strstart, hash_head);
- }
- } while (--s->prev_length != 0);
- s->match_available = 0;
- s->match_length = MIN_MATCH-1;
- s->strstart++;
-
- if (bflush) FLUSH_BLOCK(s, 0);
-
- } else if (s->match_available) {
- /* If there was no match at the previous position, output a
- * single literal. If there was a match but the current match
- * is longer, truncate the previous match to a single literal.
- */
- Tracevv((stderr,"%c", s->window[s->strstart-1]));
- _tr_tally_lit(s, s->window[s->strstart-1], bflush);
- if (bflush) {
- FLUSH_BLOCK_ONLY(s, 0);
- }
- s->strstart++;
- s->lookahead--;
- if (s->strm->avail_out == 0) return need_more;
- } else {
- /* There is no previous match to compare with, wait for
- * the next step to decide.
- */
- s->match_available = 1;
- s->strstart++;
- s->lookahead--;
- }
- }
- Assert (flush != Z_NO_FLUSH, "no flush?");
- if (s->match_available) {
- Tracevv((stderr,"%c", s->window[s->strstart-1]));
- _tr_tally_lit(s, s->window[s->strstart-1], bflush);
- s->match_available = 0;
- }
- FLUSH_BLOCK(s, flush == Z_FINISH);
- return flush == Z_FINISH ? finish_done : block_done;
-}
-#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
- * deflate switches away from Z_RLE.)
- */
-local block_state deflate_rle(s, flush)
- 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 */
-
- for (;;) {
- /* Make sure that we always have enough lookahead, except
- * at the end of the input file. We need MAX_MATCH bytes
- * for the longest encodable run.
- */
- if (s->lookahead < MAX_MATCH) {
- fill_window(s);
- if (s->lookahead < MAX_MATCH && flush == Z_NO_FLUSH) {
- return need_more;
- }
- if (s->lookahead == 0) break; /* flush the current block */
- }
-
- /* 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;
- scan = s->window + s->strstart - 1;
- prev = *scan++;
- do {
- if (*scan++ != prev)
- break;
- } while (++run < max);
- }
-
- /* 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;
- } else {
- /* No match, output a literal byte */
- 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;
-}
-#endif
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/deflate.h Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,355 +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.
- */
-
-/* deflate.h -- internal compression state
- * Copyright (C) 1995-2004 Jean-loup Gailly
- * 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.
- */
-
-/* @(#) $Id$ */
-
-#ifndef DEFLATE_H
-#define DEFLATE_H
-
-#include "zutil.h"
-
-/* define NO_GZIP when compiling if you want to disable gzip header and
- trailer creation by deflate(). NO_GZIP would be used to avoid linking in
- the crc code when it is not needed. For shared libraries, gzip encoding
- should be left enabled. */
-#ifndef NO_GZIP
-# define GZIP
-#endif
-
-/* ===========================================================================
- * Internal compression state.
- */
-
-#define LENGTH_CODES 29
-/* number of length codes, not counting the special END_BLOCK code */
-
-#define LITERALS 256
-/* number of literal bytes 0..255 */
-
-#define L_CODES (LITERALS+1+LENGTH_CODES)
-/* number of Literal or Length codes, including the END_BLOCK code */
-
-#define D_CODES 30
-/* number of distance codes */
-
-#define BL_CODES 19
-/* number of codes used to transfer the bit lengths */
-
-#define HEAP_SIZE (2*L_CODES+1)
-/* maximum heap size */
-
-#define MAX_BITS 15
-/* All codes must not exceed MAX_BITS bits */
-
-#define INIT_STATE 42
-#define EXTRA_STATE 69
-#define NAME_STATE 73
-#define COMMENT_STATE 91
-#define HCRC_STATE 103
-#define BUSY_STATE 113
-#define FINISH_STATE 666
-/* Stream status */
-
-
-/* Data structure describing a single value and its code string. */
-typedef struct ct_data_s {
- union {
- ush freq; /* frequency count */
- ush code; /* bit string */
- } fc;
- union {
- ush dad; /* father node in Huffman tree */
- ush len; /* length of bit string */
- } dl;
-} FAR ct_data;
-
-#define Freq fc.freq
-#define Code fc.code
-#define Dad dl.dad
-#define Len dl.len
-
-typedef struct static_tree_desc_s static_tree_desc;
-
-typedef struct tree_desc_s {
- ct_data *dyn_tree; /* the dynamic tree */
- int max_code; /* largest code with non zero frequency */
- static_tree_desc *stat_desc; /* the corresponding static tree */
-} FAR tree_desc;
-
-typedef ush Pos;
-typedef Pos FAR Posf;
-typedef unsigned IPos;
-
-/* A Pos is an index in the character window. We use short instead of int to
- * save space in the various tables. IPos is used only for parameter passing.
- */
-
-typedef struct internal_state {
- z_streamp strm; /* pointer back to this zlib stream */
- int status; /* as the name implies */
- Bytef *pending_buf; /* output still pending */
- ulg pending_buf_size; /* size of pending_buf */
- Bytef *pending_out; /* next pending byte to output to the stream */
- uInt pending; /* nb of bytes in the pending buffer */
- int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
- gz_headerp gzhead; /* gzip header information to write */
- uInt gzindex; /* where in extra, name, or comment */
- Byte method; /* STORED (for zip only) or DEFLATED */
- int last_flush; /* value of flush param for previous deflate call */
-
- /* used by deflate.c: */
-
- uInt w_size; /* LZ77 window size (32K by default) */
- uInt w_bits; /* log2(w_size) (8..16) */
- uInt w_mask; /* w_size - 1 */
-
- Bytef *window;
- /* Sliding window. Input bytes are read into the second half of the window,
- * and move to the first half later to keep a dictionary of at least wSize
- * bytes. With this organization, matches are limited to a distance of
- * wSize-MAX_MATCH bytes, but this ensures that IO is always
- * performed with a length multiple of the block size. Also, it limits
- * the window size to 64K, which is quite useful on MSDOS.
- * To do: use the user input buffer as sliding window.
- */
-
- ulg window_size;
- /* Actual size of window: 2*wSize, except when the user input buffer
- * is directly used as sliding window.
- */
-
- Posf *prev;
- /* Link to older string with same hash index. To limit the size of this
- * array to 64K, this link is maintained only for the last 32K strings.
- * An index in this array is thus a window index modulo 32K.
- */
-
- Posf *head; /* Heads of the hash chains or NIL. */
-
- uInt ins_h; /* hash index of string to be inserted */
- uInt hash_size; /* number of elements in hash table */
- uInt hash_bits; /* log2(hash_size) */
- uInt hash_mask; /* hash_size-1 */
-
- uInt hash_shift;
- /* Number of bits by which ins_h must be shifted at each input
- * step. It must be such that after MIN_MATCH steps, the oldest
- * byte no longer takes part in the hash key, that is:
- * hash_shift * MIN_MATCH >= hash_bits
- */
-
- long block_start;
- /* Window position at the beginning of the current output block. Gets
- * negative when the window is moved backwards.
- */
-
- uInt match_length; /* length of best match */
- IPos prev_match; /* previous match */
- int match_available; /* set if previous match exists */
- uInt strstart; /* start of string to insert */
- uInt match_start; /* start of matching string */
- uInt lookahead; /* number of valid bytes ahead in window */
-
- uInt prev_length;
- /* Length of the best match at previous step. Matches not greater than this
- * are discarded. This is used in the lazy match evaluation.
- */
-
- uInt max_chain_length;
- /* To speed up deflation, hash chains are never searched beyond this
- * length. A higher limit improves compression ratio but degrades the
- * speed.
- */
-
- uInt max_lazy_match;
- /* Attempt to find a better match only when the current match is strictly
- * smaller than this value. This mechanism is used only for compression
- * levels >= 4.
- */
-# define max_insert_length max_lazy_match
- /* Insert new strings in the hash table only if the match length is not
- * greater than this length. This saves time but degrades compression.
- * max_insert_length is used only for compression levels <= 3.
- */
-
- int level; /* compression level (1..9) */
- int strategy; /* favor or force Huffman coding*/
-
- uInt good_match;
- /* Use a faster search when the previous match is longer than this */
-
- int nice_match; /* Stop searching when current match exceeds this */
-
- /* used by trees.c: */
- /* Didn't use ct_data typedef below to supress compiler warning */
- struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */
- struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */
- struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */
-
- struct tree_desc_s l_desc; /* desc. for literal tree */
- struct tree_desc_s d_desc; /* desc. for distance tree */
- struct tree_desc_s bl_desc; /* desc. for bit length tree */
-
- ush bl_count[MAX_BITS+1];
- /* number of codes at each bit length for an optimal tree */
-
- int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */
- int heap_len; /* number of elements in the heap */
- int heap_max; /* element of largest frequency */
- /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used.
- * The same heap array is used to build all trees.
- */
-
- uch depth[2*L_CODES+1];
- /* Depth of each subtree used as tie breaker for trees of equal frequency
- */
-
- uchf *l_buf; /* buffer for literals or lengths */
-
- uInt lit_bufsize;
- /* Size of match buffer for literals/lengths. There are 4 reasons for
- * limiting lit_bufsize to 64K:
- * - frequencies can be kept in 16 bit counters
- * - if compression is not successful for the first block, all input
- * data is still in the window so we can still emit a stored block even
- * when input comes from standard input. (This can also be done for
- * all blocks if lit_bufsize is not greater than 32K.)
- * - if compression is not successful for a file smaller than 64K, we can
- * even emit a stored file instead of a stored block (saving 5 bytes).
- * This is applicable only for zip (not gzip or zlib).
- * - creating new Huffman trees less frequently may not provide fast
- * adaptation to changes in the input data statistics. (Take for
- * example a binary file with poorly compressible code followed by
- * a highly compressible string table.) Smaller buffer sizes give
- * fast adaptation but have of course the overhead of transmitting
- * trees more frequently.
- * - I can't count above 4
- */
-
- uInt last_lit; /* running index in l_buf */
-
- ushf *d_buf;
- /* Buffer for distances. To simplify the code, d_buf and l_buf have
- * the same number of elements. To use different lengths, an extra flag
- * array would be necessary.
- */
-
- ulg opt_len; /* bit length of current block with optimal trees */
- ulg static_len; /* bit length of current block with static trees */
- uInt matches; /* number of string matches in current block */
- int last_eob_len; /* bit length of EOB code for last block */
-
-#ifdef DEBUG
- ulg compressed_len; /* total bit length of compressed file mod 2^32 */
- ulg bits_sent; /* bit length of compressed data sent mod 2^32 */
-#endif
-
- ush bi_buf;
- /* Output buffer. bits are inserted starting at the bottom (least
- * significant bits).
- */
- int bi_valid;
- /* Number of valid bits in bi_buf. All bits above the last valid bit
- * are always zero.
- */
-
-} FAR deflate_state;
-
-/* Output a byte on the stream.
- * IN assertion: there is enough room in pending_buf.
- */
-#define put_byte(s, c) {s->pending_buf[s->pending++] = (c);}
-
-
-#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.
- */
-
-#define MAX_DIST(s) ((s)->w_size-MIN_LOOKAHEAD)
-/* In order to simplify the code, particularly on 16 bit machines, match
- * distances are limited to MAX_DIST instead of WSIZE.
- */
-
- /* 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));
-
-#define d_code(dist) \
- ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)])
-/* Mapping from a distance to a distance code. dist is the distance - 1 and
- * must not have side effects. _dist_code[256] and _dist_code[257] are never
- * used.
- */
-
-#ifndef DEBUG
-/* Inline versions of _tr_tally for speed: */
-
-#if defined(GEN_TREES_H) || !defined(STDC)
- extern uch _length_code[];
- extern uch _dist_code[];
-#else
- extern const uch _length_code[];
- extern const uch _dist_code[];
-#endif
-
-# define _tr_tally_lit(s, c, flush) \
- { uch cc = (c); \
- s->d_buf[s->last_lit] = 0; \
- s->l_buf[s->last_lit++] = cc; \
- s->dyn_ltree[cc].Freq++; \
- flush = (s->last_lit == s->lit_bufsize-1); \
- }
-# define _tr_tally_dist(s, distance, length, flush) \
- { uch len = (length); \
- ush dist = (distance); \
- s->d_buf[s->last_lit] = dist; \
- s->l_buf[s->last_lit++] = len; \
- dist--; \
- s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \
- s->dyn_dtree[d_code(dist)].Freq++; \
- flush = (s->last_lit == s->lit_bufsize-1); \
- }
-#else
-# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c)
-# define _tr_tally_dist(s, distance, length, flush) \
- flush = _tr_tally(s, distance, length)
-#endif
-
-#endif /* DEFLATE_H */
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/gzio.c Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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);
-}
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/infback.c Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,647 +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.
- */
-
-/* infback.c -- inflate using a call-back interface
- * Copyright (C) 1995-2005 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/*
- This code is largely copied from inflate.c. Normally either infback.o or
- inflate.o would be linked into an application--not both. The interface
- with inffast.c is retained so that optimized assembler-coded versions of
- inflate_fast() can be used with either inflate.c or infback.c.
- */
-
-#include "zutil.h"
-#include "inftrees.h"
-#include "inflate.h"
-#include "inffast.h"
-
-/* function prototypes */
-local void fixedtables OF((struct inflate_state FAR *state));
-
-/*
- strm provides memory allocation functions in zalloc and zfree, or
- Z_NULL to use the library memory allocation functions.
-
- windowBits is in the range 8..15, and window is a user-supplied
- window and output buffer that is 2**windowBits bytes.
- */
-int ZEXPORT inflateBackInit_(strm, windowBits, window, version, stream_size)
-z_streamp strm;
-int windowBits;
-unsigned char FAR *window;
-const char *version;
-int stream_size;
-{
- struct inflate_state FAR *state;
-
- if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
- stream_size != (int)(sizeof(z_stream)))
- return Z_VERSION_ERROR;
- if (strm == Z_NULL || window == Z_NULL ||
- windowBits < 8 || windowBits > 15)
- return Z_STREAM_ERROR;
- strm->msg = Z_NULL; /* in case we return an error */
- if (strm->zalloc == (alloc_func)0) {
- strm->zalloc = zcalloc;
- strm->opaque = (voidpf)0;
- }
- if (strm->zfree == (free_func)0) strm->zfree = zcfree;
- state = (struct inflate_state FAR *)ZALLOC(strm, 1,
- sizeof(struct inflate_state));
- if (state == Z_NULL) return Z_MEM_ERROR;
- Tracev((stderr, "inflate: allocated\n"));
- strm->state = (struct internal_state FAR *)state;
- state->dmax = 32768U;
- state->wbits = windowBits;
- state->wsize = 1U << windowBits;
- state->window = window;
- state->write = 0;
- state->whave = 0;
- 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.
- If BUILDFIXED is defined, then instead this routine builds the tables the
- first time it's called, and returns those tables the first time and
- thereafter. This reduces the size of the code by about 2K bytes, in
- exchange for a little execution time. However, BUILDFIXED should not be
- used for threaded applications, since the rewriting of the tables and virgin
- may not be thread-safe.
- */
-local void fixedtables(state)
-struct inflate_state FAR *state;
-{
-#ifdef BUILDFIXED
- static int virgin = 1;
- static code *lenfix, *distfix;
- static code fixed[544];
-
- /* build fixed huffman tables if first call (may not be thread safe) */
- if (virgin) {
- unsigned sym, bits;
- static code *next;
-
- /* literal/length table */
- sym = 0;
- while (sym < 144) state->lens[sym++] = 8;
- while (sym < 256) state->lens[sym++] = 9;
- while (sym < 280) state->lens[sym++] = 7;
- while (sym < 288) state->lens[sym++] = 8;
- next = fixed;
- lenfix = next;
- bits = 9;
- inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work);
-
- /* distance table */
- sym = 0;
- while (sym < 32) state->lens[sym++] = 5;
- distfix = next;
- bits = 5;
- inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work);
-
- /* do this just once */
- virgin = 0;
- }
-#else /* !BUILDFIXED */
-# include "inffixed.h"
-#endif /* BUILDFIXED */
- state->lencode = lenfix;
- state->lenbits = 9;
- state->distcode = distfix;
- state->distbits = 5;
-}
-
-/* Macros for inflateBack(): */
-
-/* Load returned state from inflate_fast() */
-#define LOAD() \
- do { \
- put = strm->next_out; \
- left = strm->avail_out; \
- next = strm->next_in; \
- have = strm->avail_in; \
- hold = state->hold; \
- bits = state->bits; \
- } while (0)
-
-/* Set state from registers for inflate_fast() */
-#define RESTORE() \
- do { \
- strm->next_out = put; \
- strm->avail_out = left; \
- strm->next_in = next; \
- strm->avail_in = have; \
- state->hold = hold; \
- state->bits = bits; \
- } while (0)
-
-/* Clear the input bit accumulator */
-#define INITBITS() \
- do { \
- hold = 0; \
- bits = 0; \
- } while (0)
-
-/* Assure that some input is available. If input is requested, but denied,
- then return a Z_BUF_ERROR from inflateBack(). */
-#define PULL() \
- do { \
- if (have == 0) { \
- have = in(in_desc, &next); \
- if (have == 0) { \
- next = Z_NULL; \
- ret = Z_BUF_ERROR; \
- goto inf_leave; \
- } \
- } \
- } while (0)
-
-/* Get a byte of input into the bit accumulator, or return from inflateBack()
- with an error if there is no input available. */
-#define PULLBYTE() \
- do { \
- PULL(); \
- have--; \
- hold += (unsigned long)(*next++) << bits; \
- bits += 8; \
- } while (0)
-
-/* Assure that there are at least n bits in the bit accumulator. If there is
- not enough available input to do that, then return from inflateBack() with
- an error. */
-#define NEEDBITS(n) \
- do { \
- while (bits < (unsigned)(n)) \
- PULLBYTE(); \
- } while (0)
-
-/* Return the low n bits of the bit accumulator (n < 16) */
-#define BITS(n) \
- ((unsigned)hold & ((1U << (n)) - 1))
-
-/* Remove n bits from the bit accumulator */
-#define DROPBITS(n) \
- do { \
- hold >>= (n); \
- bits -= (unsigned)(n); \
- } while (0)
-
-/* Remove zero to seven bits as needed to go to a byte boundary */
-#define BYTEBITS() \
- do { \
- hold >>= bits & 7; \
- bits -= bits & 7; \
- } while (0)
-
-/* Assure that some output space is available, by writing out the window
- if it's full. If the write fails, return from inflateBack() with a
- Z_BUF_ERROR. */
-#define ROOM() \
- do { \
- if (left == 0) { \
- put = state->window; \
- left = state->wsize; \
- state->whave = left; \
- if (out(out_desc, put, left)) { \
- ret = Z_BUF_ERROR; \
- goto inf_leave; \
- } \
- } \
- } while (0)
-
-/*
- strm provides the memory allocation functions and window buffer on input,
- and provides information on the unused input on return. For Z_DATA_ERROR
- returns, strm will also provide an error message.
-
- in() and out() are the call-back input and output functions. When
- inflateBack() needs more input, it calls in(). When inflateBack() has
- filled the window with output, or when it completes with data in the
- window, it calls out() to write out the data. The application must not
- change the provided input until in() is called again or inflateBack()
- returns. The application must not change the window/output buffer until
- inflateBack() returns.
-
- in() and out() are called with a descriptor parameter provided in the
- inflateBack() call. This parameter can be a structure that provides the
- information required to do the read or write, as well as accumulated
- information on the input and output such as totals and check values.
-
- in() should return zero on failure. out() should return non-zero on
- failure. If either in() or out() fails, than inflateBack() returns a
- Z_BUF_ERROR. strm->next_in can be checked for Z_NULL to see whether it
- was in() or out() that caused in the error. Otherwise, inflateBack()
- returns Z_STREAM_END on success, Z_DATA_ERROR for an deflate format
- error, or Z_MEM_ERROR if it could not allocate memory for the state.
- inflateBack() can also return Z_STREAM_ERROR if the input parameters
- are not correct, i.e. strm is Z_NULL or the state was not initialized.
- */
-int ZEXPORT inflateBack(strm, in, in_desc, out, out_desc)
-z_streamp strm;
-in_func in;
-void FAR *in_desc;
-out_func out;
-void FAR *out_desc;
-{
- struct inflate_state FAR *state;
- unsigned char FAR *next; /* next input */
- unsigned char FAR *put; /* next output */
- unsigned have, left; /* available input and output */
- unsigned long hold; /* bit buffer */
- 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 last; /* parent table entry */
- unsigned len; /* length to copy for repeats, bits to drop */
- int ret; /* return code */
- static const unsigned short order[19] = /* permutation of code lengths */
- {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
-
- /* Check that the strm exists and that the state was initialized */
- if (strm == Z_NULL || strm->state == Z_NULL)
- return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)strm->state;
-
- /* Reset the state */
- strm->msg = Z_NULL;
- state->mode = TYPE;
- state->last = 0;
- state->whave = 0;
- next = strm->next_in;
- have = next != Z_NULL ? strm->avail_in : 0;
- hold = 0;
- bits = 0;
- put = state->window;
- left = state->wsize;
-
- /* Inflate until end of block marked as last */
- for (;;)
- switch (state->mode) {
- case TYPE:
- /* determine and dispatch block type */
- if (state->last) {
- BYTEBITS();
- state->mode = DONE;
- break;
- }
- NEEDBITS(3);
- state->last = BITS(1);
- DROPBITS(1);
- switch (BITS(2)) {
- case 0: /* stored block */
- Tracev((stderr, "inflate: stored block%s\n",
- state->last ? " (last)" : ""));
- state->mode = STORED;
- break;
- case 1: /* fixed block */
- fixedtables(state);
- Tracev((stderr, "inflate: fixed codes block%s\n",
- state->last ? " (last)" : ""));
- state->mode = LEN; /* decode codes */
- break;
- case 2: /* dynamic block */
- Tracev((stderr, "inflate: dynamic codes block%s\n",
- state->last ? " (last)" : ""));
- state->mode = TABLE;
- break;
- case 3:
- strm->msg = (char *)"invalid block type";
- state->mode = BAD;
- }
- DROPBITS(2);
- break;
-
- case STORED:
- /* get and verify stored block length */
- BYTEBITS(); /* go to byte boundary */
- NEEDBITS(32);
- if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
- strm->msg = (char *)"invalid stored block lengths";
- state->mode = BAD;
- break;
- }
- state->length = (unsigned)hold & 0xffff;
- Tracev((stderr, "inflate: stored length %u\n",
- state->length));
- INITBITS();
-
- /* copy stored block from input to output */
- while (state->length != 0) {
- copy = state->length;
- PULL();
- ROOM();
- if (copy > have) copy = have;
- if (copy > left) copy = left;
- zmemcpy(put, next, copy);
- have -= copy;
- next += copy;
- left -= copy;
- put += copy;
- state->length -= copy;
- }
- Tracev((stderr, "inflate: stored end\n"));
- state->mode = TYPE;
- break;
-
- case TABLE:
- /* get dynamic table entries descriptor */
- NEEDBITS(14);
- state->nlen = BITS(5) + 257;
- DROPBITS(5);
- state->ndist = BITS(5) + 1;
- DROPBITS(5);
- state->ncode = BITS(4) + 4;
- DROPBITS(4);
-#ifndef PKZIP_BUG_WORKAROUND
- if (state->nlen > 286 || state->ndist > 30) {
- strm->msg = (char *)"too many length or distance symbols";
- state->mode = BAD;
- break;
- }
-#endif
- Tracev((stderr, "inflate: table sizes ok\n"));
-
- /* get code length code lengths (not a typo) */
- state->have = 0;
- while (state->have < state->ncode) {
- NEEDBITS(3);
- state->lens[order[state->have++]] = (unsigned short)BITS(3);
- DROPBITS(3);
- }
- while (state->have < 19)
- state->lens[order[state->have++]] = 0;
- state->next = state->codes;
- state->lencode = (code const FAR *)(state->next);
- state->lenbits = 7;
- ret = inflate_table(CODES, state->lens, 19, &(state->next),
- &(state->lenbits), state->work);
- if (ret) {
- strm->msg = (char *)"invalid code lengths set";
- state->mode = BAD;
- break;
- }
- Tracev((stderr, "inflate: code lengths ok\n"));
-
- /* get length and distance code code lengths */
- state->have = 0;
- while (state->have < state->nlen + state->ndist) {
- for (;;) {
- this = state->lencode[BITS(state->lenbits)];
- if ((unsigned)(this.bits) <= bits) break;
- PULLBYTE();
- }
- if (this.val < 16) {
- NEEDBITS(this.bits);
- DROPBITS(this.bits);
- state->lens[state->have++] = this.val;
- }
- else {
- if (this.val == 16) {
- NEEDBITS(this.bits + 2);
- DROPBITS(this.bits);
- if (state->have == 0) {
- strm->msg = (char *)"invalid bit length repeat";
- state->mode = BAD;
- break;
- }
- len = (unsigned)(state->lens[state->have - 1]);
- copy = 3 + BITS(2);
- DROPBITS(2);
- }
- else if (this.val == 17) {
- NEEDBITS(this.bits + 3);
- DROPBITS(this.bits);
- len = 0;
- copy = 3 + BITS(3);
- DROPBITS(3);
- }
- else {
- NEEDBITS(this.bits + 7);
- DROPBITS(this.bits);
- len = 0;
- copy = 11 + BITS(7);
- DROPBITS(7);
- }
- if (state->have + copy > state->nlen + state->ndist) {
- strm->msg = (char *)"invalid bit length repeat";
- state->mode = BAD;
- break;
- }
- while (copy--)
- state->lens[state->have++] = (unsigned short)len;
- }
- }
-
- /* handle error breaks in while */
- if (state->mode == BAD) break;
-
- /* build code tables */
- state->next = state->codes;
- state->lencode = (code const FAR *)(state->next);
- state->lenbits = 9;
- ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
- &(state->lenbits), state->work);
- if (ret) {
- strm->msg = (char *)"invalid literal/lengths set";
- state->mode = BAD;
- break;
- }
- state->distcode = (code const FAR *)(state->next);
- state->distbits = 6;
- ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
- &(state->next), &(state->distbits), state->work);
- if (ret) {
- strm->msg = (char *)"invalid distances set";
- state->mode = BAD;
- break;
- }
- Tracev((stderr, "inflate: codes ok\n"));
- state->mode = LEN;
-
- case LEN:
- /* use inflate_fast() if we have enough input and output */
- if (have >= 6 && left >= 258) {
- RESTORE();
- if (state->whave < state->wsize)
- state->whave = state->wsize - left;
- inflate_fast(strm, state->wsize);
- LOAD();
- break;
- }
-
- /* get a literal, length, or end-of-block code */
- for (;;) {
- this = state->lencode[BITS(state->lenbits)];
- if ((unsigned)(this.bits) <= bits) break;
- PULLBYTE();
- }
- if (this.op && (this.op & 0xf0) == 0) {
- last = this;
- for (;;) {
- this = state->lencode[last.val +
- (BITS(last.bits + last.op) >> last.bits)];
- if ((unsigned)(last.bits + this.bits) <= bits) break;
- PULLBYTE();
- }
- DROPBITS(last.bits);
- }
- DROPBITS(this.bits);
- state->length = (unsigned)this.val;
-
- /* process literal */
- if (this.op == 0) {
- Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ?
- "inflate: literal '%c'\n" :
- "inflate: literal 0x%02x\n", this.val));
- ROOM();
- *put++ = (unsigned char)(state->length);
- left--;
- state->mode = LEN;
- break;
- }
-
- /* process end of block */
- if (this.op & 32) {
- Tracevv((stderr, "inflate: end of block\n"));
- state->mode = TYPE;
- break;
- }
-
- /* invalid code */
- if (this.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;
- if (state->extra != 0) {
- NEEDBITS(state->extra);
- state->length += BITS(state->extra);
- DROPBITS(state->extra);
- }
- Tracevv((stderr, "inflate: length %u\n", state->length));
-
- /* get distance code */
- for (;;) {
- this = state->distcode[BITS(state->distbits)];
- if ((unsigned)(this.bits) <= bits) break;
- PULLBYTE();
- }
- if ((this.op & 0xf0) == 0) {
- last = this;
- for (;;) {
- this = state->distcode[last.val +
- (BITS(last.bits + last.op) >> last.bits)];
- if ((unsigned)(last.bits + this.bits) <= bits) break;
- PULLBYTE();
- }
- DROPBITS(last.bits);
- }
- DROPBITS(this.bits);
- if (this.op & 64) {
- strm->msg = (char *)"invalid distance code";
- state->mode = BAD;
- break;
- }
- state->offset = (unsigned)this.val;
-
- /* get distance extra bits, if any */
- state->extra = (unsigned)(this.op) & 15;
- if (state->extra != 0) {
- NEEDBITS(state->extra);
- state->offset += BITS(state->extra);
- DROPBITS(state->extra);
- }
- if (state->offset > state->wsize - (state->whave < state->wsize ?
- left : 0)) {
- strm->msg = (char *)"invalid distance too far back";
- state->mode = BAD;
- break;
- }
- Tracevv((stderr, "inflate: distance %u\n", state->offset));
-
- /* copy match from window to output */
- do {
- ROOM();
- copy = state->wsize - state->offset;
- if (copy < left) {
- from = put + copy;
- copy = left - copy;
- }
- else {
- from = put - state->offset;
- copy = left;
- }
- if (copy > state->length) copy = state->length;
- state->length -= copy;
- left -= copy;
- do {
- *put++ = *from++;
- } while (--copy);
- } while (state->length != 0);
- break;
-
- case DONE:
- /* inflate stream terminated properly -- write leftover output */
- ret = Z_STREAM_END;
- if (left < state->wsize) {
- if (out(out_desc, state->window, state->wsize - left))
- ret = Z_BUF_ERROR;
- }
- goto inf_leave;
-
- case BAD:
- ret = Z_DATA_ERROR;
- goto inf_leave;
-
- default: /* can't happen, but makes compilers happy */
- ret = Z_STREAM_ERROR;
- goto inf_leave;
- }
-
- /* Return unused input */
- inf_leave:
- strm->next_in = next;
- strm->avail_in = have;
- return ret;
-}
-
-int ZEXPORT inflateBackEnd(strm)
-z_streamp strm;
-{
- if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
- return Z_STREAM_ERROR;
- ZFREE(strm, strm->state);
- strm->state = Z_NULL;
- Tracev((stderr, "inflate: end\n"));
- return Z_OK;
-}
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/inffast.c Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,342 +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.
- */
-
-/* inffast.c -- fast decoding
- * Copyright (C) 1995-2004 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-#include "zutil.h"
-#include "inftrees.h"
-#include "inflate.h"
-#include "inffast.h"
-
-#ifndef ASMINF
-
-/* Allow machine dependent optimization for post-increment or pre-increment.
- Based on testing to date,
- Pre-increment preferred for:
- - PowerPC G3 (Adler)
- - MIPS R5000 (Randers-Pehrson)
- Post-increment preferred for:
- - none
- No measurable difference:
- - Pentium III (Anderson)
- - M68060 (Nikl)
- */
-#ifdef POSTINC
-# define OFF 0
-# define PUP(a) *(a)++
-#else
-# define OFF 1
-# define PUP(a) *++(a)
-#endif
-
-/*
- Decode literal, length, and distance codes and write out the resulting
- literal and match bytes until either not enough input or output is
- available, an end-of-block is encountered, or a data error is encountered.
- When large enough input and output buffers are supplied to inflate(), for
- example, a 16K input buffer and a 64K output buffer, more than 95% of the
- inflate execution time is spent in this routine.
-
- Entry assumptions:
-
- state->mode == LEN
- strm->avail_in >= 6
- strm->avail_out >= 258
- start >= strm->avail_out
- state->bits < 8
-
- On return, state->mode is one of:
-
- LEN -- ran out of enough output space or enough available input
- TYPE -- reached end of block code, inflate() to interpret next block
- BAD -- error in block data
-
- Notes:
-
- - The maximum input bits used by a length/distance pair is 15 bits for the
- length code, 5 bits for the length extra, 15 bits for the distance code,
- and 13 bits for the distance extra. This totals 48 bits, or six bytes.
- Therefore if strm->avail_in >= 6, then there is enough input to avoid
- checking for available input while decoding.
-
- - The maximum bytes that a single length/distance pair can output is 258
- bytes, which is the maximum length that can be coded. inflate_fast()
- requires strm->avail_out >= 258 for each loop to avoid checking for
- output space.
- */
-void inflate_fast(strm, start)
-z_streamp strm;
-unsigned start; /* inflate()'s starting value for strm->avail_out */
-{
- struct inflate_state FAR *state;
- unsigned char FAR *in; /* local strm->next_in */
- unsigned char FAR *last; /* while in < last, enough input available */
- unsigned char FAR *out; /* local strm->next_out */
- unsigned char FAR *beg; /* inflate()'s initial strm->next_out */
- unsigned char FAR *end; /* while out < end, enough space available */
-#ifdef INFLATE_STRICT
- unsigned dmax; /* maximum distance from zlib header */
-#endif
- unsigned wsize; /* window size or zero if not using window */
- unsigned whave; /* valid bytes in the window */
- unsigned write; /* window write index */
- unsigned char FAR *window; /* allocated sliding window, if wsize != 0 */
- unsigned long hold; /* local strm->hold */
- unsigned bits; /* local strm->bits */
- code const FAR *lcode; /* local strm->lencode */
- 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 */
- unsigned op; /* code bits, operation, extra bits, or */
- /* window position, window bytes to copy */
- unsigned len; /* match length, unused bytes */
- unsigned dist; /* match distance */
- unsigned char FAR *from; /* where to copy match from */
-
- /* copy state to local variables */
- state = (struct inflate_state FAR *)strm->state;
- in = strm->next_in - OFF;
- last = in + (strm->avail_in - 5);
- out = strm->next_out - OFF;
- beg = out - (start - strm->avail_out);
- end = out + (strm->avail_out - 257);
-#ifdef INFLATE_STRICT
- dmax = state->dmax;
-#endif
- wsize = state->wsize;
- whave = state->whave;
- write = state->write;
- window = state->window;
- hold = state->hold;
- bits = state->bits;
- lcode = state->lencode;
- dcode = state->distcode;
- lmask = (1U << state->lenbits) - 1;
- dmask = (1U << state->distbits) - 1;
-
- /* decode literals and length/distances until end-of-block or not enough
- input data or output space */
- do {
- if (bits < 15) {
- hold += (unsigned long)(PUP(in)) << bits;
- bits += 8;
- hold += (unsigned long)(PUP(in)) << bits;
- bits += 8;
- }
- this = lcode[hold & lmask];
- dolen:
- op = (unsigned)(this.bits);
- hold >>= op;
- bits -= op;
- op = (unsigned)(this.op);
- if (op == 0) { /* literal */
- Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ?
- "inflate: literal '%c'\n" :
- "inflate: literal 0x%02x\n", this.val));
- PUP(out) = (unsigned char)(this.val);
- }
- else if (op & 16) { /* length base */
- len = (unsigned)(this.val);
- op &= 15; /* number of extra bits */
- if (op) {
- if (bits < op) {
- hold += (unsigned long)(PUP(in)) << bits;
- bits += 8;
- }
- len += (unsigned)hold & ((1U << op) - 1);
- hold >>= op;
- bits -= op;
- }
- Tracevv((stderr, "inflate: length %u\n", len));
- if (bits < 15) {
- hold += (unsigned long)(PUP(in)) << bits;
- bits += 8;
- hold += (unsigned long)(PUP(in)) << bits;
- bits += 8;
- }
- this = dcode[hold & dmask];
- dodist:
- op = (unsigned)(this.bits);
- hold >>= op;
- bits -= op;
- op = (unsigned)(this.op);
- if (op & 16) { /* distance base */
- dist = (unsigned)(this.val);
- op &= 15; /* number of extra bits */
- if (bits < op) {
- hold += (unsigned long)(PUP(in)) << bits;
- bits += 8;
- if (bits < op) {
- hold += (unsigned long)(PUP(in)) << bits;
- bits += 8;
- }
- }
- dist += (unsigned)hold & ((1U << op) - 1);
-#ifdef INFLATE_STRICT
- if (dist > dmax) {
- strm->msg = (char *)"invalid distance too far back";
- state->mode = BAD;
- break;
- }
-#endif
- hold >>= op;
- bits -= op;
- Tracevv((stderr, "inflate: distance %u\n", dist));
- op = (unsigned)(out - beg); /* max distance in output */
- 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;
- }
- from = window - OFF;
- if (write == 0) { /* very common case */
- from += wsize - op;
- if (op < len) { /* some from window */
- len -= op;
- do {
- PUP(out) = PUP(from);
- } while (--op);
- from = out - dist; /* rest from output */
- }
- }
- else if (write < op) { /* wrap around window */
- from += wsize + write - op;
- op -= write;
- 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;
- len -= op;
- do {
- PUP(out) = PUP(from);
- } while (--op);
- from = out - dist; /* rest from output */
- }
- }
- }
- else { /* contiguous in window */
- from += write - op;
- if (op < len) { /* some from window */
- len -= op;
- do {
- PUP(out) = PUP(from);
- } while (--op);
- from = out - dist; /* rest from output */
- }
- }
- while (len > 2) {
- PUP(out) = PUP(from);
- PUP(out) = PUP(from);
- PUP(out) = PUP(from);
- len -= 3;
- }
- if (len) {
- PUP(out) = PUP(from);
- if (len > 1)
- PUP(out) = PUP(from);
- }
- }
- else {
- from = out - dist; /* copy direct from output */
- do { /* minimum length is three */
- PUP(out) = PUP(from);
- PUP(out) = PUP(from);
- PUP(out) = PUP(from);
- len -= 3;
- } while (len > 2);
- if (len) {
- PUP(out) = PUP(from);
- if (len > 1)
- PUP(out) = PUP(from);
- }
- }
- }
- else if ((op & 64) == 0) { /* 2nd level distance code */
- this = dcode[this.val + (hold & ((1U << op) - 1))];
- goto dodist;
- }
- else {
- strm->msg = (char *)"invalid distance code";
- state->mode = BAD;
- break;
- }
- }
- else if ((op & 64) == 0) { /* 2nd level length code */
- this = lcode[this.val + (hold & ((1U << op) - 1))];
- goto dolen;
- }
- else if (op & 32) { /* end-of-block */
- Tracevv((stderr, "inflate: end of block\n"));
- state->mode = TYPE;
- break;
- }
- else {
- strm->msg = (char *)"invalid literal/length code";
- state->mode = BAD;
- break;
- }
- } while (in < last && out < end);
-
- /* return unused bytes (on entry, bits < 8, so in won't go too far back) */
- len = bits >> 3;
- in -= len;
- bits -= len << 3;
- hold &= (1U << bits) - 1;
-
- /* update state and return */
- strm->next_in = in + OFF;
- strm->next_out = out + OFF;
- strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last));
- strm->avail_out = (unsigned)(out < end ?
- 257 + (end - out) : 257 - (out - end));
- state->hold = hold;
- state->bits = bits;
- return;
-}
-
-/*
- 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
- - 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
- - Swapping literal/length else
- - Swapping window/direct else
- - Larger unrolled copy loops (three is about right)
- - Moving len -= 3 statement into middle of loop
- */
-
-#endif /* !ASMINF */
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/inffast.h Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +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.
- */
-
-/* inffast.h -- header to use inffast.c
- * Copyright (C) 1995-2003 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.
- */
-
-void inflate_fast OF((z_streamp strm, unsigned start));
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/inffixed.h Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,118 +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.
- */
-
- /* inffixed.h -- table for decoding fixed codes
- * Generated automatically by makefixed().
- */
-
- /* 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.
- */
-
- static const code lenfix[512] = {
- {96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48},
- {0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128},
- {0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59},
- {0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176},
- {0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20},
- {21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100},
- {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8},
- {0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216},
- {18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76},
- {0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114},
- {0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2},
- {0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148},
- {20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42},
- {0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86},
- {0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15},
- {0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236},
- {16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62},
- {0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142},
- {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31},
- {0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162},
- {0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25},
- {0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105},
- {0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4},
- {0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202},
- {17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69},
- {0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125},
- {0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13},
- {0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195},
- {19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35},
- {0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91},
- {0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19},
- {0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246},
- {16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55},
- {0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135},
- {0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99},
- {0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190},
- {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16},
- {20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96},
- {0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6},
- {0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209},
- {17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72},
- {0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116},
- {0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4},
- {0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153},
- {20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44},
- {0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82},
- {0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11},
- {0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229},
- {16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58},
- {0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138},
- {0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51},
- {0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173},
- {0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30},
- {0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110},
- {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0},
- {0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195},
- {16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65},
- {0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121},
- {0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9},
- {0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258},
- {19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37},
- {0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93},
- {0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23},
- {0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251},
- {16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51},
- {0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131},
- {0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67},
- {0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183},
- {0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23},
- {64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103},
- {0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9},
- {0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223},
- {18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79},
- {0,9,255}
- };
-
- static const code distfix[32] = {
- {16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025},
- {21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193},
- {18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385},
- {19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577},
- {16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073},
- {22,5,193},{64,5,0}
- };
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/inflate.c Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1392 +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.
- */
-
-/* inflate.c -- zlib decompression
- * Copyright (C) 1995-2005 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/*
- * Change history:
- *
- * 1.2.beta0 24 Nov 2002
- * - First version -- complete rewrite of inflate to simplify code, avoid
- * creation of window when not needed, minimize use of window when it is
- * needed, make inffast.c even faster, implement gzip decoding, and to
- * improve code readability and style over the previous zlib inflate code
- *
- * 1.2.beta1 25 Nov 2002
- * - Use pointers for available input and output checking in inffast.c
- * - Remove input and output counters in inffast.c
- * - Change inffast.c entry and loop from avail_in >= 7 to >= 6
- * - Remove unnecessary second byte pull from length extra in inffast.c
- * - Unroll direct copy to three copies per loop in inffast.c
- *
- * 1.2.beta2 4 Dec 2002
- * - Change external routine names to reduce potential conflicts
- * - Correct filename to inffixed.h for fixed tables in inflate.c
- * - Make hbuf[] unsigned char to match parameter type in inflate.c
- * - Change strm->next_out[-state->offset] to *(strm->next_out - state->offset)
- * to avoid negation problem on Alphas (64 bit) in inflate.c
- *
- * 1.2.beta3 22 Dec 2002
- * - Add comments on state->bits assertion in inffast.c
- * - Add comments on op field in inftrees.h
- * - Fix bug in reuse of allocated window after inflateReset()
- * - Remove bit fields--back to byte structure for speed
- * - Remove distance extra == 0 check in inflate_fast()--only helps for lengths
- * - Change post-increments to pre-increments in inflate_fast(), PPC biased?
- * - Add compile time option, POSTINC, to use post-increments instead (Intel?)
- * - Make MATCH copy in inflate() much faster for when inflate_fast() not used
- * - Use local copies of stream next and avail values, as well as local bit
- * buffer and bit count in inflate()--for speed when inflate_fast() not used
- *
- * 1.2.beta4 1 Jan 2003
- * - Split ptr - 257 statements in inflate_table() to avoid compiler warnings
- * - Move a comment on output buffer sizes from inffast.c to inflate.c
- * - Add comments in inffast.c to introduce the inflate_fast() routine
- * - 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()
- * - 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()
- * - Added inflateBackInit(), inflateBack(), and inflateBackEnd() in new
- * source file infback.c to provide a call-back interface to inflate for
- * programs like gzip and unzip -- uses window as output buffer to avoid
- * window copying
- *
- * 1.2.beta5 1 Jan 2003
- * - Improved inflateBack() interface to allow the caller to provide initial
- * input in strm.
- * - Fixed stored blocks bug in inflateBack()
- *
- * 1.2.beta6 4 Jan 2003
- * - Added comments in inffast.c on effectiveness of POSTINC
- * - Typecasting all around to reduce compiler warnings
- * - Changed loops from while (1) or do {} while (1) to for (;;), again to
- * make compilers happy
- * - Changed type of window in inflateBackInit() to unsigned char *
- *
- * 1.2.beta7 27 Jan 2003
- * - Changed many types to unsigned or unsigned short to avoid warnings
- * - Added inflateCopy() function
- *
- * 1.2.0 9 Mar 2003
- * - Changed inflateBack() interface to provide separate opaque descriptors
- * for the in() and out() functions
- * - Changed inflateBack() argument and in_func typedef to swap the length
- * and buffer address return values for the input function
- * - Check next_in and next_out for Z_NULL on entry to inflate()
- *
- * The history for versions after 1.2.0 are in ChangeLog in zlib distribution.
- */
-
-#include "zutil.h"
-#include "inftrees.h"
-#include "inflate.h"
-#include "inffast.h"
-
-#ifdef MAKEFIXED
-# ifndef BUILDFIXED
-# define BUILDFIXED
-# endif
-#endif
-
-/* function prototypes */
-local void fixedtables OF((struct inflate_state FAR *state));
-local int updatewindow OF((z_streamp strm, unsigned out));
-#ifdef BUILDFIXED
- void makefixed OF((void));
-#endif
-local unsigned syncsearch OF((unsigned FAR *have, unsigned char FAR *buf,
- unsigned len));
-
-int ZEXPORT inflateReset(strm)
-z_streamp strm;
-{
- struct inflate_state FAR *state;
-
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)strm->state;
- strm->total_in = strm->total_out = state->total = 0;
- strm->msg = Z_NULL;
- strm->adler = 1; /* to support ill-conceived Java test suite */
- state->mode = HEAD;
- state->last = 0;
- state->havedict = 0;
- state->dmax = 32768U;
- state->head = Z_NULL;
- state->wsize = 0;
- state->whave = 0;
- state->write = 0;
- state->hold = 0;
- state->bits = 0;
- state->lencode = state->distcode = state->next = state->codes;
- Tracev((stderr, "inflate: reset\n"));
- return Z_OK;
-}
-
-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 > 16 || state->bits + bits > 32) return Z_STREAM_ERROR;
- value &= (1L << bits) - 1;
- state->hold += value << state->bits;
- state->bits += bits;
- return Z_OK;
-}
-
-int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size)
-z_streamp strm;
-int windowBits;
-const char *version;
-int stream_size;
-{
- struct inflate_state FAR *state;
-
- if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
- stream_size != (int)(sizeof(z_stream)))
- return Z_VERSION_ERROR;
- if (strm == Z_NULL) return Z_STREAM_ERROR;
- strm->msg = Z_NULL; /* in case we return an error */
- if (strm->zalloc == (alloc_func)0) {
- strm->zalloc = zcalloc;
- strm->opaque = (voidpf)0;
- }
- if (strm->zfree == (free_func)0) strm->zfree = zcfree;
- state = (struct inflate_state FAR *)
- ZALLOC(strm, 1, sizeof(struct inflate_state));
- 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) {
- ZFREE(strm, state);
- strm->state = Z_NULL;
- return Z_STREAM_ERROR;
- }
- state->wbits = (unsigned)windowBits;
- state->window = Z_NULL;
- return inflateReset(strm);
-}
-
-int ZEXPORT inflateInit_(strm, version, stream_size)
-z_streamp strm;
-const char *version;
-int stream_size;
-{
- return inflateInit2_(strm, DEF_WBITS, version, stream_size);
-}
-
-/*
- Return state with length and distance decoding tables and index sizes set to
- fixed code decoding. Normally this returns fixed tables from inffixed.h.
- If BUILDFIXED is defined, then instead this routine builds the tables the
- first time it's called, and returns those tables the first time and
- thereafter. This reduces the size of the code by about 2K bytes, in
- exchange for a little execution time. However, BUILDFIXED should not be
- used for threaded applications, since the rewriting of the tables and virgin
- may not be thread-safe.
- */
-local void fixedtables(state)
-struct inflate_state FAR *state;
-{
-#ifdef BUILDFIXED
- static int virgin = 1;
- static code *lenfix, *distfix;
- static code fixed[544];
-
- /* build fixed huffman tables if first call (may not be thread safe) */
- if (virgin) {
- unsigned sym, bits;
- static code *next;
-
- /* literal/length table */
- sym = 0;
- while (sym < 144) state->lens[sym++] = 8;
- while (sym < 256) state->lens[sym++] = 9;
- while (sym < 280) state->lens[sym++] = 7;
- while (sym < 288) state->lens[sym++] = 8;
- next = fixed;
- lenfix = next;
- bits = 9;
- inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work);
-
- /* distance table */
- sym = 0;
- while (sym < 32) state->lens[sym++] = 5;
- distfix = next;
- bits = 5;
- inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work);
-
- /* do this just once */
- virgin = 0;
- }
-#else /* !BUILDFIXED */
-# include "inffixed.h"
-#endif /* BUILDFIXED */
- state->lencode = lenfix;
- state->lenbits = 9;
- state->distcode = distfix;
- state->distbits = 5;
-}
-
-#ifdef MAKEFIXED
-#include <stdio.h>
-
-/*
- Write out the inffixed.h that is #include'd above. Defining MAKEFIXED also
- defines BUILDFIXED, so the tables are built on the fly. makefixed() writes
- those tables to stdout, which would be piped to inffixed.h. A small program
- can simply call makefixed to do this:
-
- void makefixed(void);
-
- int main(void)
- {
- makefixed();
- return 0;
- }
-
- Then that can be linked with zlib built with MAKEFIXED defined and run:
-
- a.out > inffixed.h
- */
-void makefixed()
-{
- unsigned low, size;
- struct inflate_state state;
-
- fixedtables(&state);
- puts(" /* inffixed.h -- table for decoding fixed codes");
- puts(" * Generated automatically by makefixed().");
- puts(" */");
- puts("");
- puts(" /* WARNING: this file should *not* be used by applications.");
- puts(" It is part of the implementation of this library and is");
- puts(" subject to change. Applications should only use zlib.h.");
- puts(" */");
- puts("");
- size = 1U << 9;
- printf(" static const code lenfix[%u] = {", size);
- low = 0;
- for (;;) {
- if ((low % 7) == 0) printf("\n ");
- printf("{%u,%u,%d}", state.lencode[low].op, state.lencode[low].bits,
- state.lencode[low].val);
- if (++low == size) break;
- putchar(',');
- }
- puts("\n };");
- size = 1U << 5;
- printf("\n static const code distfix[%u] = {", size);
- low = 0;
- for (;;) {
- if ((low % 6) == 0) printf("\n ");
- printf("{%u,%u,%d}", state.distcode[low].op, state.distcode[low].bits,
- state.distcode[low].val);
- if (++low == size) break;
- putchar(',');
- }
- puts("\n };");
-}
-#endif /* MAKEFIXED */
-
-/*
- Update the window with the last wsize (normally 32K) bytes written before
- returning. If window does not exist yet, create it. This is only called
- when a window is already in use, or when output has been written during this
- inflate call, but the end of the deflate stream has not been reached yet.
- It is also called to create a window for dictionary data when a dictionary
- is loaded.
-
- Providing output buffers larger than 32K to inflate() should provide a speed
- advantage, since only the last 32K of output is copied to the sliding window
- upon return from inflate(), and since all distances after the first 32K of
- output will fall in the output data, making match copies simpler and faster.
- The advantage may be dependent on the size of the processor's data caches.
- */
-local int updatewindow(strm, out)
-z_streamp strm;
-unsigned out;
-{
- struct inflate_state FAR *state;
- unsigned copy, dist;
-
- state = (struct inflate_state FAR *)strm->state;
-
- /* if it hasn't been done already, allocate space for the window */
- if (state->window == Z_NULL) {
- state->window = (unsigned char FAR *)
- ZALLOC(strm, 1U << state->wbits,
- sizeof(unsigned char));
- if (state->window == Z_NULL) return 1;
- }
-
- /* if window not in use yet, initialize */
- if (state->wsize == 0) {
- state->wsize = 1U << state->wbits;
- state->write = 0;
- state->whave = 0;
- }
-
- /* copy state->wsize or less output bytes into the circular window */
- copy = out - strm->avail_out;
- if (copy >= state->wsize) {
- zmemcpy(state->window, strm->next_out - state->wsize, state->wsize);
- state->write = 0;
- state->whave = state->wsize;
- }
- else {
- dist = state->wsize - state->write;
- if (dist > copy) dist = copy;
- zmemcpy(state->window + state->write, strm->next_out - copy, dist);
- copy -= dist;
- if (copy) {
- zmemcpy(state->window, strm->next_out - copy, copy);
- state->write = copy;
- state->whave = state->wsize;
- }
- else {
- state->write += dist;
- if (state->write == state->wsize) state->write = 0;
- if (state->whave < state->wsize) state->whave += dist;
- }
- }
- return 0;
-}
-
-/* Macros for inflate(): */
-
-/* check function to use adler32() for zlib or crc32() for gzip */
-#ifdef GUNZIP
-# define UPDATE(check, buf, len) \
- (state->flags ? crc32(check, buf, len) : adler32(check, buf, len))
-#else
-# define UPDATE(check, buf, len) adler32(check, buf, len)
-#endif
-
-/* check macros for header crc */
-#ifdef GUNZIP
-# define CRC2(check, word) \
- do { \
- hbuf[0] = (unsigned char)(word); \
- hbuf[1] = (unsigned char)((word) >> 8); \
- check = crc32(check, hbuf, 2); \
- } while (0)
-
-# define CRC4(check, word) \
- do { \
- hbuf[0] = (unsigned char)(word); \
- hbuf[1] = (unsigned char)((word) >> 8); \
- hbuf[2] = (unsigned char)((word) >> 16); \
- hbuf[3] = (unsigned char)((word) >> 24); \
- check = crc32(check, hbuf, 4); \
- } while (0)
-#endif
-
-/* Load registers with state in inflate() for speed */
-#define LOAD() \
- do { \
- put = strm->next_out; \
- left = strm->avail_out; \
- next = strm->next_in; \
- have = strm->avail_in; \
- hold = state->hold; \
- bits = state->bits; \
- } while (0)
-
-/* Restore state from registers in inflate() */
-#define RESTORE() \
- do { \
- strm->next_out = put; \
- strm->avail_out = left; \
- strm->next_in = next; \
- strm->avail_in = have; \
- state->hold = hold; \
- state->bits = bits; \
- } while (0)
-
-/* Clear the input bit accumulator */
-#define INITBITS() \
- do { \
- hold = 0; \
- bits = 0; \
- } while (0)
-
-/* Get a byte of input into the bit accumulator, or return from inflate()
- if there is no input available. */
-#define PULLBYTE() \
- do { \
- if (have == 0) goto inf_leave; \
- have--; \
- hold += (unsigned long)(*next++) << bits; \
- bits += 8; \
- } while (0)
-
-/* Assure that there are at least n bits in the bit accumulator. If there is
- not enough available input to do that, then return from inflate(). */
-#define NEEDBITS(n) \
- do { \
- while (bits < (unsigned)(n)) \
- PULLBYTE(); \
- } while (0)
-
-/* Return the low n bits of the bit accumulator (n < 16) */
-#define BITS(n) \
- ((unsigned)hold & ((1U << (n)) - 1))
-
-/* Remove n bits from the bit accumulator */
-#define DROPBITS(n) \
- do { \
- hold >>= (n); \
- bits -= (unsigned)(n); \
- } while (0)
-
-/* Remove zero to seven bits as needed to go to a byte boundary */
-#define BYTEBITS() \
- do { \
- hold >>= bits & 7; \
- bits -= bits & 7; \
- } while (0)
-
-/* Reverse the bytes in a 32-bit value */
-#define REVERSE(q) \
- ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
- (((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
-
-/*
- inflate() uses a state machine to process as much input data and generate as
- much output data as possible before returning. The state machine is
- structured roughly as follows:
-
- for (;;) switch (state) {
- ...
- case STATEn:
- if (not enough input data or output space to make progress)
- return;
- ... make progress ...
- state = STATEm;
- break;
- ...
- }
-
- so when inflate() is called again, the same case is attempted again, and
- if the appropriate resources are provided, the machine proceeds to the
- next state. The NEEDBITS() macro is usually the way the state evaluates
- whether it can proceed or should return. NEEDBITS() does the return if
- the requested bits are not available. The typical use of the BITS macros
- is:
-
- NEEDBITS(n);
- ... do something with BITS(n) ...
- DROPBITS(n);
-
- where NEEDBITS(n) either returns from inflate() if there isn't enough
- input left to load n bits into the accumulator, or it continues. BITS(n)
- gives the low n bits in the accumulator. When done, DROPBITS(n) drops
- the low n bits off the accumulator. INITBITS() clears the accumulator
- and sets the number of available bits to zero. BYTEBITS() discards just
- enough bits to put the accumulator on a byte boundary. After BYTEBITS()
- and a NEEDBITS(8), then BITS(8) would return the next byte in the stream.
-
- NEEDBITS(n) uses PULLBYTE() to get an available byte of input, or to return
- if there is no input available. The decoding of variable length codes uses
- PULLBYTE() directly in order to pull just enough bytes to decode the next
- code, and no more.
-
- Some states loop until they get enough input, making sure that enough
- state information is maintained to continue the loop where it left off
- if NEEDBITS() returns in the loop. For example, want, need, and keep
- would all have to actually be part of the saved state in case NEEDBITS()
- returns:
-
- case STATEw:
- while (want < need) {
- NEEDBITS(n);
- keep[want++] = BITS(n);
- DROPBITS(n);
- }
- state = STATEx;
- case STATEx:
-
- As shown above, if the next state is also the next case, then the break
- is omitted.
-
- A state may also return if there is not enough output space available to
- complete that state. Those states are copying stored data, writing a
- literal byte, and copying a matching string.
-
- When returning, a "goto inf_leave" is used to update the total counters,
- update the check value, and determine whether any progress has been made
- during that inflate() call in order to return the proper return code.
- Progress is defined as a change in either strm->avail_in or strm->avail_out.
- When there is a window, goto inf_leave will update the window with the last
- output written. If a goto inf_leave occurs in the middle of decompression
- and there is no window currently, goto inf_leave will create one and copy
- output to the window for the next call of inflate().
-
- In this implementation, the flush parameter of inflate() only affects the
- return code (per zlib.h). inflate() always writes as much as possible to
- strm->next_out, given the space available and the provided input--the effect
- documented in zlib.h of Z_SYNC_FLUSH. Furthermore, inflate() always defers
- the allocation of and copying into a sliding window until necessary, which
- provides the effect documented in zlib.h for Z_FINISH when the entire input
- stream available. So the only thing the flush parameter actually does is:
- when flush is set to Z_FINISH, inflate() cannot return Z_OK. Instead it
- will return Z_BUF_ERROR if it has not reached the end of the stream.
- */
-
-int ZEXPORT inflate(strm, flush)
-z_streamp strm;
-int flush;
-{
- struct inflate_state FAR *state;
- unsigned char FAR *next; /* next input */
- unsigned char FAR *put; /* next output */
- unsigned have, left; /* available input and output */
- unsigned long hold; /* bit buffer */
- unsigned bits; /* bits in bit buffer */
- 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 last; /* parent table entry */
- unsigned len; /* length to copy for repeats, bits to drop */
- int ret; /* return code */
-#ifdef GUNZIP
- unsigned char hbuf[4]; /* buffer for gzip header crc calculation */
-#endif
- static const unsigned short order[19] = /* permutation of code lengths */
- {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
-
- if (strm == Z_NULL || strm->state == Z_NULL || strm->next_out == Z_NULL ||
- (strm->next_in == Z_NULL && strm->avail_in != 0))
- return Z_STREAM_ERROR;
-
- state = (struct inflate_state FAR *)strm->state;
- if (state->mode == TYPE) state->mode = TYPEDO; /* skip check */
- LOAD();
- in = have;
- out = left;
- ret = Z_OK;
- for (;;)
- switch (state->mode) {
- case HEAD:
- if (state->wrap == 0) {
- state->mode = TYPEDO;
- break;
- }
- NEEDBITS(16);
-#ifdef GUNZIP
- if ((state->wrap & 2) && hold == 0x8b1f) { /* gzip header */
- state->check = crc32(0L, Z_NULL, 0);
- CRC2(state->check, hold);
- INITBITS();
- state->mode = FLAGS;
- break;
- }
- state->flags = 0; /* expect zlib header */
- if (state->head != Z_NULL)
- state->head->done = -1;
- if (!(state->wrap & 1) || /* check if zlib header allowed */
-#else
- if (
-#endif
- ((BITS(8) << 8) + (hold >> 8)) % 31) {
- strm->msg = (char *)"incorrect header check";
- state->mode = BAD;
- break;
- }
- if (BITS(4) != Z_DEFLATED) {
- strm->msg = (char *)"unknown compression method";
- state->mode = BAD;
- break;
- }
- DROPBITS(4);
- len = BITS(4) + 8;
- if (len > state->wbits) {
- strm->msg = (char *)"invalid window size";
- state->mode = BAD;
- break;
- }
- state->dmax = 1U << len;
- Tracev((stderr, "inflate: zlib header ok\n"));
- strm->adler = state->check = adler32(0L, Z_NULL, 0);
- state->mode = hold & 0x200 ? DICTID : TYPE;
- INITBITS();
- break;
-#ifdef GUNZIP
- case FLAGS:
- NEEDBITS(16);
- state->flags = (int)(hold);
- if ((state->flags & 0xff) != Z_DEFLATED) {
- strm->msg = (char *)"unknown compression method";
- state->mode = BAD;
- break;
- }
- if (state->flags & 0xe000) {
- strm->msg = (char *)"unknown header flags set";
- state->mode = BAD;
- break;
- }
- if (state->head != Z_NULL)
- state->head->text = (int)((hold >> 8) & 1);
- if (state->flags & 0x0200) CRC2(state->check, hold);
- INITBITS();
- state->mode = TIME;
- case TIME:
- NEEDBITS(32);
- if (state->head != Z_NULL)
- state->head->time = hold;
- if (state->flags & 0x0200) CRC4(state->check, hold);
- INITBITS();
- state->mode = OS;
- case OS:
- NEEDBITS(16);
- if (state->head != Z_NULL) {
- state->head->xflags = (int)(hold & 0xff);
- state->head->os = (int)(hold >> 8);
- }
- if (state->flags & 0x0200) CRC2(state->check, hold);
- INITBITS();
- state->mode = EXLEN;
- case EXLEN:
- if (state->flags & 0x0400) {
- NEEDBITS(16);
- state->length = (unsigned)(hold);
- if (state->head != Z_NULL)
- state->head->extra_len = (unsigned)hold;
- if (state->flags & 0x0200) CRC2(state->check, hold);
- INITBITS();
- }
- else if (state->head != Z_NULL)
- state->head->extra = Z_NULL;
- state->mode = EXTRA;
- case EXTRA:
- if (state->flags & 0x0400) {
- copy = state->length;
- if (copy > have) copy = have;
- if (copy) {
- if (state->head != Z_NULL &&
- state->head->extra != Z_NULL) {
- len = state->head->extra_len - state->length;
- zmemcpy(state->head->extra + len, next,
- len + copy > state->head->extra_max ?
- state->head->extra_max - len : copy);
- }
- if (state->flags & 0x0200)
- state->check = crc32(state->check, next, copy);
- have -= copy;
- next += copy;
- state->length -= copy;
- }
- if (state->length) goto inf_leave;
- }
- state->length = 0;
- state->mode = NAME;
- case NAME:
- if (state->flags & 0x0800) {
- if (have == 0) goto inf_leave;
- copy = 0;
- do {
- len = (unsigned)(next[copy++]);
- if (state->head != Z_NULL &&
- state->head->name != Z_NULL &&
- state->length < state->head->name_max)
- state->head->name[state->length++] = len;
- } while (len && copy < have);
- if (state->flags & 0x0200)
- state->check = crc32(state->check, next, copy);
- have -= copy;
- next += copy;
- if (len) goto inf_leave;
- }
- else if (state->head != Z_NULL)
- state->head->name = Z_NULL;
- state->length = 0;
- state->mode = COMMENT;
- case COMMENT:
- if (state->flags & 0x1000) {
- if (have == 0) goto inf_leave;
- copy = 0;
- do {
- len = (unsigned)(next[copy++]);
- if (state->head != Z_NULL &&
- state->head->comment != Z_NULL &&
- state->length < state->head->comm_max)
- state->head->comment[state->length++] = len;
- } while (len && copy < have);
- if (state->flags & 0x0200)
- state->check = crc32(state->check, next, copy);
- have -= copy;
- next += copy;
- if (len) goto inf_leave;
- }
- else if (state->head != Z_NULL)
- state->head->comment = Z_NULL;
- state->mode = HCRC;
- case HCRC:
- if (state->flags & 0x0200) {
- NEEDBITS(16);
- if (hold != (state->check & 0xffff)) {
- strm->msg = (char *)"header crc mismatch";
- state->mode = BAD;
- break;
- }
- INITBITS();
- }
- if (state->head != Z_NULL) {
- state->head->hcrc = (int)((state->flags >> 9) & 1);
- state->head->done = 1;
- }
- strm->adler = state->check = crc32(0L, Z_NULL, 0);
- state->mode = TYPE;
- break;
-#endif
- case DICTID:
- NEEDBITS(32);
- strm->adler = state->check = REVERSE(hold);
- INITBITS();
- state->mode = DICT;
- case DICT:
- if (state->havedict == 0) {
- RESTORE();
- return Z_NEED_DICT;
- }
- strm->adler = state->check = adler32(0L, Z_NULL, 0);
- state->mode = TYPE;
- case TYPE:
- if (flush == Z_BLOCK) goto inf_leave;
- case TYPEDO:
- if (state->last) {
- BYTEBITS();
- state->mode = CHECK;
- break;
- }
- NEEDBITS(3);
- state->last = BITS(1);
- DROPBITS(1);
- switch (BITS(2)) {
- case 0: /* stored block */
- Tracev((stderr, "inflate: stored block%s\n",
- state->last ? " (last)" : ""));
- state->mode = STORED;
- break;
- case 1: /* fixed block */
- fixedtables(state);
- Tracev((stderr, "inflate: fixed codes block%s\n",
- state->last ? " (last)" : ""));
- state->mode = LEN; /* decode codes */
- break;
- case 2: /* dynamic block */
- Tracev((stderr, "inflate: dynamic codes block%s\n",
- state->last ? " (last)" : ""));
- state->mode = TABLE;
- break;
- case 3:
- strm->msg = (char *)"invalid block type";
- state->mode = BAD;
- }
- DROPBITS(2);
- break;
- case STORED:
- BYTEBITS(); /* go to byte boundary */
- NEEDBITS(32);
- if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
- strm->msg = (char *)"invalid stored block lengths";
- state->mode = BAD;
- break;
- }
- state->length = (unsigned)hold & 0xffff;
- Tracev((stderr, "inflate: stored length %u\n",
- state->length));
- INITBITS();
- state->mode = COPY;
- case COPY:
- copy = state->length;
- if (copy) {
- if (copy > have) copy = have;
- if (copy > left) copy = left;
- if (copy == 0) goto inf_leave;
- zmemcpy(put, next, copy);
- have -= copy;
- next += copy;
- left -= copy;
- put += copy;
- state->length -= copy;
- break;
- }
- Tracev((stderr, "inflate: stored end\n"));
- state->mode = TYPE;
- break;
- case TABLE:
- NEEDBITS(14);
- state->nlen = BITS(5) + 257;
- DROPBITS(5);
- state->ndist = BITS(5) + 1;
- DROPBITS(5);
- state->ncode = BITS(4) + 4;
- DROPBITS(4);
-#ifndef PKZIP_BUG_WORKAROUND
- if (state->nlen > 286 || state->ndist > 30) {
- strm->msg = (char *)"too many length or distance symbols";
- state->mode = BAD;
- break;
- }
-#endif
- Tracev((stderr, "inflate: table sizes ok\n"));
- state->have = 0;
- state->mode = LENLENS;
- case LENLENS:
- while (state->have < state->ncode) {
- NEEDBITS(3);
- state->lens[order[state->have++]] = (unsigned short)BITS(3);
- DROPBITS(3);
- }
- while (state->have < 19)
- state->lens[order[state->have++]] = 0;
- state->next = state->codes;
- state->lencode = (code const FAR *)(state->next);
- state->lenbits = 7;
- ret = inflate_table(CODES, state->lens, 19, &(state->next),
- &(state->lenbits), state->work);
- if (ret) {
- strm->msg = (char *)"invalid code lengths set";
- state->mode = BAD;
- break;
- }
- Tracev((stderr, "inflate: code lengths ok\n"));
- state->have = 0;
- state->mode = CODELENS;
- case CODELENS:
- while (state->have < state->nlen + state->ndist) {
- for (;;) {
- this = state->lencode[BITS(state->lenbits)];
- if ((unsigned)(this.bits) <= bits) break;
- PULLBYTE();
- }
- if (this.val < 16) {
- NEEDBITS(this.bits);
- DROPBITS(this.bits);
- state->lens[state->have++] = this.val;
- }
- else {
- if (this.val == 16) {
- NEEDBITS(this.bits + 2);
- DROPBITS(this.bits);
- if (state->have == 0) {
- strm->msg = (char *)"invalid bit length repeat";
- state->mode = BAD;
- break;
- }
- len = state->lens[state->have - 1];
- copy = 3 + BITS(2);
- DROPBITS(2);
- }
- else if (this.val == 17) {
- NEEDBITS(this.bits + 3);
- DROPBITS(this.bits);
- len = 0;
- copy = 3 + BITS(3);
- DROPBITS(3);
- }
- else {
- NEEDBITS(this.bits + 7);
- DROPBITS(this.bits);
- len = 0;
- copy = 11 + BITS(7);
- DROPBITS(7);
- }
- if (state->have + copy > state->nlen + state->ndist) {
- strm->msg = (char *)"invalid bit length repeat";
- state->mode = BAD;
- break;
- }
- while (copy--)
- state->lens[state->have++] = (unsigned short)len;
- }
- }
-
- /* handle error breaks in while */
- if (state->mode == BAD) break;
-
- /* build code tables */
- state->next = state->codes;
- state->lencode = (code const FAR *)(state->next);
- state->lenbits = 9;
- ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
- &(state->lenbits), state->work);
- if (ret) {
- strm->msg = (char *)"invalid literal/lengths set";
- state->mode = BAD;
- break;
- }
- state->distcode = (code const FAR *)(state->next);
- state->distbits = 6;
- ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
- &(state->next), &(state->distbits), state->work);
- if (ret) {
- strm->msg = (char *)"invalid distances set";
- state->mode = BAD;
- break;
- }
- Tracev((stderr, "inflate: codes ok\n"));
- state->mode = LEN;
- case LEN:
- if (have >= 6 && left >= 258) {
- RESTORE();
- inflate_fast(strm, out);
- LOAD();
- break;
- }
- for (;;) {
- this = state->lencode[BITS(state->lenbits)];
- if ((unsigned)(this.bits) <= bits) break;
- PULLBYTE();
- }
- if (this.op && (this.op & 0xf0) == 0) {
- last = this;
- for (;;) {
- this = state->lencode[last.val +
- (BITS(last.bits + last.op) >> last.bits)];
- if ((unsigned)(last.bits + this.bits) <= bits) break;
- PULLBYTE();
- }
- DROPBITS(last.bits);
- }
- DROPBITS(this.bits);
- state->length = (unsigned)this.val;
- if ((int)(this.op) == 0) {
- Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ?
- "inflate: literal '%c'\n" :
- "inflate: literal 0x%02x\n", this.val));
- state->mode = LIT;
- break;
- }
- if (this.op & 32) {
- Tracevv((stderr, "inflate: end of block\n"));
- state->mode = TYPE;
- break;
- }
- if (this.op & 64) {
- strm->msg = (char *)"invalid literal/length code";
- state->mode = BAD;
- break;
- }
- state->extra = (unsigned)(this.op) & 15;
- state->mode = LENEXT;
- case LENEXT:
- if (state->extra) {
- NEEDBITS(state->extra);
- state->length += BITS(state->extra);
- DROPBITS(state->extra);
- }
- Tracevv((stderr, "inflate: length %u\n", state->length));
- state->mode = DIST;
- case DIST:
- for (;;) {
- this = state->distcode[BITS(state->distbits)];
- if ((unsigned)(this.bits) <= bits) break;
- PULLBYTE();
- }
- if ((this.op & 0xf0) == 0) {
- last = this;
- for (;;) {
- this = state->distcode[last.val +
- (BITS(last.bits + last.op) >> last.bits)];
- if ((unsigned)(last.bits + this.bits) <= bits) break;
- PULLBYTE();
- }
- DROPBITS(last.bits);
- }
- DROPBITS(this.bits);
- if (this.op & 64) {
- strm->msg = (char *)"invalid distance code";
- state->mode = BAD;
- break;
- }
- state->offset = (unsigned)this.val;
- state->extra = (unsigned)(this.op) & 15;
- state->mode = DISTEXT;
- case DISTEXT:
- if (state->extra) {
- NEEDBITS(state->extra);
- state->offset += BITS(state->extra);
- DROPBITS(state->extra);
- }
-#ifdef INFLATE_STRICT
- if (state->offset > state->dmax) {
- strm->msg = (char *)"invalid distance too far back";
- state->mode = BAD;
- 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:
- if (left == 0) goto inf_leave;
- copy = out - left;
- if (state->offset > copy) { /* copy from window */
- copy = state->offset - copy;
- if (copy > state->write) {
- copy -= state->write;
- from = state->window + (state->wsize - copy);
- }
- else
- from = state->window + (state->write - copy);
- if (copy > state->length) copy = state->length;
- }
- else { /* copy from output */
- from = put - state->offset;
- copy = state->length;
- }
- if (copy > left) copy = left;
- left -= copy;
- state->length -= copy;
- do {
- *put++ = *from++;
- } while (--copy);
- if (state->length == 0) state->mode = LEN;
- break;
- case LIT:
- if (left == 0) goto inf_leave;
- *put++ = (unsigned char)(state->length);
- left--;
- state->mode = LEN;
- break;
- case CHECK:
- if (state->wrap) {
- NEEDBITS(32);
- out -= left;
- strm->total_out += out;
- state->total += out;
- if (out)
- strm->adler = state->check =
- UPDATE(state->check, put - out, out);
- out = left;
- if ((
-#ifdef GUNZIP
- state->flags ? hold :
-#endif
- REVERSE(hold)) != state->check) {
- strm->msg = (char *)"incorrect data check";
- state->mode = BAD;
- break;
- }
- INITBITS();
- Tracev((stderr, "inflate: check matches trailer\n"));
- }
-#ifdef GUNZIP
- state->mode = LENGTH;
- case LENGTH:
- if (state->wrap && state->flags) {
- NEEDBITS(32);
- if (hold != (state->total & 0xffffffffUL)) {
- strm->msg = (char *)"incorrect length check";
- state->mode = BAD;
- break;
- }
- INITBITS();
- Tracev((stderr, "inflate: length matches trailer\n"));
- }
-#endif
- state->mode = DONE;
- case DONE:
- ret = Z_STREAM_END;
- goto inf_leave;
- case BAD:
- ret = Z_DATA_ERROR;
- goto inf_leave;
- case MEM:
- return Z_MEM_ERROR;
- case SYNC:
- default:
- return Z_STREAM_ERROR;
- }
-
- /*
- Return from inflate(), updating the total counts and the check value.
- If there was no progress during the inflate() call, return a buffer
- error. Call updatewindow() to create and/or update the window state.
- Note: a memory error from inflate() is non-recoverable.
- */
- inf_leave:
- RESTORE();
- if (state->wsize || (state->mode < CHECK && out != strm->avail_out))
- if (updatewindow(strm, out)) {
- state->mode = MEM;
- return Z_MEM_ERROR;
- }
- in -= strm->avail_in;
- out -= strm->avail_out;
- strm->total_in += in;
- strm->total_out += out;
- state->total += out;
- if (state->wrap && out)
- 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);
- if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)
- ret = Z_BUF_ERROR;
- return ret;
-}
-
-int ZEXPORT inflateEnd(strm)
-z_streamp strm;
-{
- struct inflate_state FAR *state;
- if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
- return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)strm->state;
- if (state->window != Z_NULL) ZFREE(strm, state->window);
- ZFREE(strm, strm->state);
- strm->state = Z_NULL;
- Tracev((stderr, "inflate: end\n"));
- return Z_OK;
-}
-
-int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength)
-z_streamp strm;
-const Bytef *dictionary;
-uInt dictLength;
-{
- struct inflate_state FAR *state;
- unsigned long id;
-
- /* check state */
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)strm->state;
- if (state->wrap != 0 && state->mode != DICT)
- return Z_STREAM_ERROR;
-
- /* check for correct dictionary id */
- if (state->mode == DICT) {
- id = adler32(0L, Z_NULL, 0);
- id = adler32(id, dictionary, dictLength);
- if (id != state->check)
- return Z_DATA_ERROR;
- }
-
- /* copy dictionary to window */
- if (updatewindow(strm, strm->avail_out)) {
- state->mode = MEM;
- return Z_MEM_ERROR;
- }
- if (dictLength > state->wsize) {
- zmemcpy(state->window, dictionary + dictLength - state->wsize,
- state->wsize);
- state->whave = state->wsize;
- }
- else {
- zmemcpy(state->window + state->wsize - dictLength, dictionary,
- dictLength);
- state->whave = dictLength;
- }
- state->havedict = 1;
- Tracev((stderr, "inflate: dictionary set\n"));
- return Z_OK;
-}
-
-int ZEXPORT inflateGetHeader(strm, head)
-z_streamp strm;
-gz_headerp head;
-{
- struct inflate_state FAR *state;
-
- /* check state */
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)strm->state;
- if ((state->wrap & 2) == 0) return Z_STREAM_ERROR;
-
- /* save header structure */
- state->head = head;
- head->done = 0;
- return Z_OK;
-}
-
-/*
- Search buf[0..len-1] for the pattern: 0, 0, 0xff, 0xff. Return when found
- or when out of input. When called, *have is the number of pattern bytes
- found in order so far, in 0..3. On return *have is updated to the new
- state. If on return *have equals four, then the pattern was found and the
- return value is how many bytes were read including the last byte of the
- pattern. If *have is less than four, then the pattern has not been found
- yet and the return value is len. In the latter case, syncsearch() can be
- called again with more data and the *have state. *have is initialized to
- zero for the first call.
- */
-local unsigned syncsearch(have, buf, len)
-unsigned FAR *have;
-unsigned char FAR *buf;
-unsigned len;
-{
- unsigned got;
- unsigned next;
-
- got = *have;
- next = 0;
- while (next < len && got < 4) {
- if ((int)(buf[next]) == (got < 2 ? 0 : 0xff))
- got++;
- else if (buf[next])
- got = 0;
- else
- got = 4 - got;
- next++;
- }
- *have = got;
- return next;
-}
-
-int ZEXPORT inflateSync(strm)
-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 */
- unsigned char buf[4]; /* to restore bit buffer to byte string */
- struct inflate_state FAR *state;
-
- /* check parameters */
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)strm->state;
- if (strm->avail_in == 0 && state->bits < 8) return Z_BUF_ERROR;
-
- /* if first time, start search in bit buffer */
- if (state->mode != SYNC) {
- state->mode = SYNC;
- state->hold <<= state->bits & 7;
- state->bits -= state->bits & 7;
- len = 0;
- while (state->bits >= 8) {
- buf[len++] = (unsigned char)(state->hold);
- state->hold >>= 8;
- state->bits -= 8;
- }
- state->have = 0;
- syncsearch(&(state->have), buf, len);
- }
-
- /* search available input */
- len = syncsearch(&(state->have), strm->next_in, strm->avail_in);
- strm->avail_in -= len;
- strm->next_in += len;
- strm->total_in += len;
-
- /* return no joy or set up to restart inflate() on a new block */
- if (state->have != 4) return Z_DATA_ERROR;
- in = strm->total_in; out = strm->total_out;
- inflateReset(strm);
- strm->total_in = in; strm->total_out = out;
- state->mode = TYPE;
- return Z_OK;
-}
-
-/*
- Returns true if inflate is currently at the end of a block generated by
- Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP
- implementation to provide an additional safety check. PPP uses
- Z_SYNC_FLUSH but removes the length bytes of the resulting empty stored
- block. When decompressing, PPP checks that at the end of input packet,
- inflate is waiting for these length bytes.
- */
-int ZEXPORT inflateSyncPoint(strm)
-z_streamp strm;
-{
- struct inflate_state FAR *state;
-
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)strm->state;
- return state->mode == STORED && state->bits == 0;
-}
-
-int ZEXPORT inflateCopy(dest, source)
-z_streamp dest;
-z_streamp source;
-{
- struct inflate_state FAR *state;
- struct inflate_state FAR *copy;
- unsigned char FAR *window;
- unsigned wsize;
-
- /* check input */
- if (dest == Z_NULL || source == Z_NULL || source->state == Z_NULL ||
- source->zalloc == (alloc_func)0 || source->zfree == (free_func)0)
- return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)source->state;
-
- /* allocate space */
- copy = (struct inflate_state FAR *)
- ZALLOC(source, 1, sizeof(struct inflate_state));
- if (copy == Z_NULL) return Z_MEM_ERROR;
- window = Z_NULL;
- if (state->window != Z_NULL) {
- window = (unsigned char FAR *)
- ZALLOC(source, 1U << state->wbits, sizeof(unsigned char));
- if (window == Z_NULL) {
- ZFREE(source, copy);
- return Z_MEM_ERROR;
- }
- }
-
- /* copy state */
- zmemcpy(dest, source, sizeof(z_stream));
- zmemcpy(copy, state, sizeof(struct inflate_state));
- if (state->lencode >= state->codes &&
- state->lencode <= state->codes + ENOUGH - 1) {
- copy->lencode = copy->codes + (state->lencode - state->codes);
- copy->distcode = copy->codes + (state->distcode - state->codes);
- }
- copy->next = copy->codes + (state->next - state->codes);
- if (window != Z_NULL) {
- wsize = 1U << state->wbits;
- zmemcpy(window, state->window, wsize);
- }
- copy->window = window;
- dest->state = (struct internal_state FAR *)copy;
- return Z_OK;
-}
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/inflate.h Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,139 +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.
- */
-
-/* inflate.h -- internal inflate state definition
- * Copyright (C) 1995-2004 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.
- */
-
-/* define NO_GZIP when compiling if you want to disable gzip header and
- trailer decoding by inflate(). NO_GZIP would be used to avoid linking in
- the crc code when it is not needed. For shared libraries, gzip decoding
- should be left enabled. */
-#ifndef NO_GZIP
-# define GUNZIP
-#endif
-
-/* Possible inflate modes between inflate() calls */
-typedef enum {
- HEAD, /* i: waiting for magic header */
- FLAGS, /* i: waiting for method and flags (gzip) */
- TIME, /* i: waiting for modification time (gzip) */
- OS, /* i: waiting for extra flags and operating system (gzip) */
- EXLEN, /* i: waiting for extra length (gzip) */
- EXTRA, /* i: waiting for extra bytes (gzip) */
- NAME, /* i: waiting for end of file name (gzip) */
- COMMENT, /* i: waiting for end of comment (gzip) */
- HCRC, /* i: waiting for header crc (gzip) */
- DICTID, /* i: waiting for dictionary check value */
- DICT, /* waiting for inflateSetDictionary() call */
- 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: 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 */
- LENEXT, /* i: waiting for length extra bits */
- DIST, /* i: waiting for distance code */
- DISTEXT, /* i: waiting for distance extra bits */
- MATCH, /* o: waiting for output space to copy string */
- LIT, /* o: waiting for output space to write literal */
- CHECK, /* i: waiting for 32-bit check value */
- LENGTH, /* i: waiting for 32-bit length (gzip) */
- DONE, /* finished check, done -- remain here until reset */
- BAD, /* got a data error -- remain here until reset */
- MEM, /* got an inflate() memory error -- remain here until reset */
- SYNC /* looking for synchronization bytes to restart inflate() */
-} inflate_mode;
-
-/*
- State transitions between above modes -
-
- (most modes can go to the BAD or MEM mode -- not shown for clarity)
-
- Process header:
- HEAD -> (gzip) or (zlib)
- (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME
- NAME -> COMMENT -> HCRC -> TYPE
- (zlib) -> DICTID or TYPE
- DICTID -> DICT -> TYPE
- Read deflate blocks:
- TYPE -> STORED or TABLE or LEN or CHECK
- STORED -> COPY -> TYPE
- TABLE -> LENLENS -> CODELENS -> LEN
- Read deflate codes:
- LEN -> LENEXT or LIT or TYPE
- LENEXT -> DIST -> DISTEXT -> MATCH -> LEN
- LIT -> LEN
- Process trailer:
- CHECK -> LENGTH -> DONE
- */
-
-/* state maintained between inflate() calls. Approximately 7K bytes. */
-struct inflate_state {
- inflate_mode mode; /* current inflate mode */
- int last; /* true if processing last block */
- int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
- int havedict; /* true if dictionary provided */
- int flags; /* gzip header method and flags (0 if zlib) */
- unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */
- unsigned long check; /* protected copy of check value */
- unsigned long total; /* protected copy of output count */
- gz_headerp head; /* where to save gzip header information */
- /* sliding window */
- 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 char FAR *window; /* allocated sliding window, if needed */
- /* bit accumulator */
- unsigned long hold; /* input bit accumulator */
- unsigned bits; /* number of bits in "in" */
- /* for string and stored block copying */
- unsigned length; /* literal or length of data to copy */
- unsigned offset; /* distance back to copy string from */
- /* for table and code decoding */
- unsigned extra; /* extra bits needed */
- /* fixed and dynamic code tables */
- code const FAR *lencode; /* starting table for length/literal codes */
- code const FAR *distcode; /* starting table for distance codes */
- unsigned lenbits; /* index bits for lencode */
- unsigned distbits; /* index bits for distcode */
- /* dynamic table building */
- unsigned ncode; /* number of code length code lengths */
- unsigned nlen; /* number of length code lengths */
- unsigned ndist; /* number of distance code lengths */
- unsigned have; /* number of code lengths in lens[] */
- code FAR *next; /* next available space in codes[] */
- 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 */
-};
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/inftrees.c Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,353 +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.
- */
-
-/* inftrees.c -- generate Huffman trees for efficient decoding
- * Copyright (C) 1995-2005 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-#include "zutil.h"
-#include "inftrees.h"
-
-#define MAXBITS 15
-
-const char inflate_copyright[] =
- " inflate 1.2.3 Copyright 1995-2005 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
- include such an acknowledgment, I would appreciate that you keep this
- copyright string in the executable of your product.
- */
-
-/*
- Build a set of tables to decode the provided canonical Huffman code.
- The code lengths are lens[0..codes-1]. The result starts at *table,
- whose indices are 0..2^bits-1. work is a writable array of at least
- lens shorts, which is used as a work area. type is the type of code
- to be generated, CODES, LENS, or DISTS. On return, zero is success,
- -1 is an invalid code, and +1 means that ENOUGH isn't enough. table
- on return points to the next available entry's address. bits is the
- requested root table index bits, and on return it is the actual root
- 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)
-codetype type;
-unsigned short FAR *lens;
-unsigned codes;
-code FAR * FAR *table;
-unsigned FAR *bits;
-unsigned short FAR *work;
-{
- unsigned len; /* a code's length in bits */
- unsigned sym; /* index of code symbols */
- unsigned min, max; /* minimum and maximum code lengths */
- unsigned root; /* number of index bits for root table */
- unsigned curr; /* number of index bits for current table */
- unsigned drop; /* code bits to drop for sub-table */
- int left; /* number of prefix codes available */
- unsigned used; /* code entries in table used */
- unsigned huff; /* Huffman code */
- unsigned incr; /* for incrementing code, index */
- 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 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 */
- int end; /* use base and extra for symbol > end */
- unsigned short count[MAXBITS+1]; /* number of codes of each length */
- unsigned short offs[MAXBITS+1]; /* offsets in table for each length */
- static const unsigned short lbase[31] = { /* Length codes 257..285 base */
- 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
- 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};
- 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,
- 8193, 12289, 16385, 24577, 0, 0};
- static const unsigned short dext[32] = { /* Distance codes 0..29 extra */
- 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,
- 23, 23, 24, 24, 25, 25, 26, 26, 27, 27,
- 28, 28, 29, 29, 64, 64};
-
- /*
- Process a set of code lengths to create a canonical Huffman code. The
- code lengths are lens[0..codes-1]. Each length corresponds to the
- symbols 0..codes-1. The Huffman code is generated by first sorting the
- symbols by length from short to long, and retaining the symbol order
- for codes with equal lengths. Then the code starts with all zero bits
- for the first code of the shortest length, and the codes are integer
- increments for the same length, and zeros are appended as the length
- increases. For the deflate format, these bits are stored backwards
- from their more natural integer increment ordering, and so when the
- decoding tables are built in the large loop below, the integer codes
- are incremented backwards.
-
- This routine assumes, but does not check, that all of the entries in
- lens[] are in the range 0..MAXBITS. The caller must assure this.
- 1..MAXBITS is interpreted as that code length. zero means that that
- symbol does not occur in this code.
-
- The codes are sorted by computing a count of codes for each length,
- creating from that a table of starting indices for each length in the
- sorted table, and then entering the symbols in order in the sorted
- table. The sorted table is work[], with that space being provided by
- the caller.
-
- The length counts are used for other purposes as well, i.e. finding
- the minimum and maximum length codes, determining if there are any
- codes at all, checking for a valid set of lengths, and looking ahead
- at length counts to determine sub-table sizes when building the
- decoding tables.
- */
-
- /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */
- for (len = 0; len <= MAXBITS; len++)
- count[len] = 0;
- for (sym = 0; sym < codes; sym++)
- count[lens[sym]]++;
-
- /* bound code lengths, force root to be within code lengths */
- root = *bits;
- for (max = MAXBITS; max >= 1; max--)
- 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;
- *bits = 1;
- return 0; /* no symbols, but wait for decoding to report error */
- }
- for (min = 1; min <= MAXBITS; min++)
- if (count[min] != 0) break;
- if (root < min) root = min;
-
- /* check for an over-subscribed or incomplete set of lengths */
- left = 1;
- for (len = 1; len <= MAXBITS; len++) {
- left <<= 1;
- left -= count[len];
- if (left < 0) return -1; /* over-subscribed */
- }
- if (left > 0 && (type == CODES || max != 1))
- return -1; /* incomplete set */
-
- /* generate offsets into symbol table for each length for sorting */
- offs[1] = 0;
- for (len = 1; len < MAXBITS; len++)
- offs[len + 1] = offs[len] + count[len];
-
- /* sort symbols by length, by symbol order within each length */
- for (sym = 0; sym < codes; sym++)
- if (lens[sym] != 0) work[offs[lens[sym]]++] = (unsigned short)sym;
-
- /*
- Create and fill in decoding tables. In this loop, the table being
- filled is at next and has curr index bits. The code being used is huff
- with length len. That code is converted to an index by dropping drop
- bits off of the bottom. For codes where len is less than drop + curr,
- those top drop + curr - len bits are incremented through all values to
- fill the table with replicated entries.
-
- root is the number of index bits for the root table. When len exceeds
- root, sub-tables are created pointed to by the root entry with an index
- of the low root bits of huff. This is saved in low to check for when a
- new sub-table should be started. drop is zero when the root table is
- being filled, and drop is root when sub-tables are being filled.
-
- When a new sub-table is needed, it is necessary to look ahead in the
- code lengths to determine what size sub-table is needed. The length
- counts are used for this, and so count[] is decremented as codes are
- 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.
-
- sym increments through all symbols, and the loop terminates when
- all codes of length max, i.e. all codes, have been processed. This
- routine permits incomplete codes, so another loop after this one fills
- in the rest of the decoding tables with invalid code markers.
- */
-
- /* set up for code type */
- switch (type) {
- case CODES:
- base = extra = work; /* dummy value--not used */
- end = 19;
- break;
- case LENS:
- base = lbase;
- base -= 257;
- extra = lext;
- extra -= 257;
- end = 256;
- break;
- default: /* DISTS */
- base = dbase;
- extra = dext;
- end = -1;
- }
-
- /* initialize state for loop */
- huff = 0; /* starting code */
- sym = 0; /* starting code symbol */
- len = min; /* starting code length */
- next = *table; /* current table to fill in */
- curr = root; /* current table index bits */
- drop = 0; /* current bits to drop from code for index */
- low = (unsigned)(-1); /* trigger new sub-table when len > root */
- used = 1U << root; /* use root table entries */
- mask = used - 1; /* mask for comparing low */
-
- /* check available table space */
- if (type == LENS && used >= ENOUGH - MAXD)
- return 1;
-
- /* process all codes and make table entries */
- for (;;) {
- /* create table entry */
- this.bits = (unsigned char)(len - drop);
- if ((int)(work[sym]) < end) {
- this.op = (unsigned char)0;
- this.val = work[sym];
- }
- else if ((int)(work[sym]) > end) {
- this.op = (unsigned char)(extra[work[sym]]);
- this.val = base[work[sym]];
- }
- else {
- this.op = (unsigned char)(32 + 64); /* end of block */
- this.val = 0;
- }
-
- /* replicate for those indices with low len bits equal to huff */
- incr = 1U << (len - drop);
- fill = 1U << curr;
- min = fill; /* save offset to next table */
- do {
- fill -= incr;
- next[(huff >> drop) + fill] = this;
- } while (fill != 0);
-
- /* backwards increment the len-bit code huff */
- incr = 1U << (len - 1);
- while (huff & incr)
- incr >>= 1;
- if (incr != 0) {
- huff &= incr - 1;
- huff += incr;
- }
- else
- huff = 0;
-
- /* go to next symbol, update count, len */
- sym++;
- if (--(count[len]) == 0) {
- if (len == max) break;
- len = lens[work[sym]];
- }
-
- /* create new sub-table if needed */
- if (len > root && (huff & mask) != low) {
- /* if first time, transition to sub-tables */
- if (drop == 0)
- drop = root;
-
- /* increment past last table */
- next += min; /* here min is 1 << curr */
-
- /* determine length of next table */
- curr = len - drop;
- left = (int)(1 << curr);
- while (curr + drop < max) {
- left -= count[curr + drop];
- if (left <= 0) break;
- curr++;
- left <<= 1;
- }
-
- /* check for enough space */
- used += 1U << curr;
- if (type == LENS && used >= ENOUGH - MAXD)
- return 1;
-
- /* point entry in root table to sub-table */
- low = huff & mask;
- (*table)[low].op = (unsigned char)curr;
- (*table)[low].bits = (unsigned char)root;
- (*table)[low].val = (unsigned short)(next - *table);
- }
- }
-
- /*
- Fill in rest of table for incomplete codes. This loop is similar to the
- loop above in incrementing huff for table indices. It is assumed that
- len is equal to curr + drop, so there is no loop needed to increment
- 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;
- 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;
- }
-
- /* put invalid code marker in table */
- next[huff >> drop] = this;
-
- /* backwards increment the len-bit code huff */
- incr = 1U << (len - 1);
- while (huff & incr)
- incr >>= 1;
- if (incr != 0) {
- huff &= incr - 1;
- huff += incr;
- }
- else
- huff = 0;
- }
-
- /* set return parameters */
- *table += used;
- *bits = root;
- return 0;
-}
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/inftrees.h Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,79 +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.
- */
-
-/* inftrees.h -- header to use inftrees.c
- * Copyright (C) 1995-2005 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.
- */
-
-/* Structure for decoding tables. Each entry provides either the
- information needed to do the operation requested by the code that
- indexed that table entry, or it provides a pointer to another
- table that indexes more bits of the code. op indicates whether
- the entry is a pointer to another table, a literal, a length or
- distance, an end-of-block, or an invalid code. For a table
- pointer, the low four bits of op is the number of index bits of
- that table. For a length or distance, the low four bits of op
- is the number of extra bits to get after the code. bits is
- the number of bits in this code or part of the code to drop off
- of the bit buffer. val is the actual byte to output in the case
- of a literal, the base length or distance, or the offset from
- the current table to the next table. Each entry is four bytes. */
-typedef struct {
- unsigned char op; /* operation, extra bits, table bits */
- unsigned char bits; /* bits in this part of the code */
- unsigned short val; /* offset in table or code value */
-} code;
-
-/* op values as set by inflate_table():
- 00000000 - literal
- 0000tttt - table link, tttt != 0 is the number of table index bits
- 0001eeee - length or distance, eeee is the number of extra bits
- 01100000 - end of block
- 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
-
-/* Type of code to build for inftable() */
-typedef enum {
- CODES,
- LENS,
- DISTS
-} codetype;
-
-extern int inflate_table OF((codetype type, unsigned short FAR *lens,
- unsigned codes, code FAR * FAR *table,
- unsigned FAR *bits, unsigned short FAR *work));
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/patches/ChangeLog_java Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-(1)renamed
- adler32.c -> zadler32.c
- zcrc32c -> zcrc32.c
-
-(2)added _LP64 to make uLong a 32-bit int on 64-bit platform
- zconf.h:
- uLong -> 32-bit int
-
-(3)updated crc32.c/crc32()
- unsigned long -> uLong
-
-(4)updated zlib.h (to support > 4G zipfile):
- total_in/out: uLong -> long long
-
-(5)updated upinflate.c/inflateSync()
- unsigned long in, out; --> long long in, out;
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/patches/crc32.c.diff Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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;
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/patches/inflate.c.diff Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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;
-
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/patches/zconf.h.diff Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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 */
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/patches/zlib.h.diff Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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
- }
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/trees.c Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1243 +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.
- */
-
-/* trees.c -- output deflated data using Huffman coding
- * Copyright (C) 1995-2005 Jean-loup Gailly
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/*
- * ALGORITHM
- *
- * The "deflation" process uses several Huffman trees. The more
- * common source values are represented by shorter bit sequences.
- *
- * Each code tree is stored in a compressed form which is itself
- * a Huffman encoding of the lengths of all the code strings (in
- * ascending order by source values). The actual code strings are
- * reconstructed from the lengths in the inflate process, as described
- * in the deflate specification.
- *
- * REFERENCES
- *
- * Deutsch, L.P.,"'Deflate' Compressed Data Format Specification".
- * Available in ftp.uu.net:/pub/archiving/zip/doc/deflate-1.1.doc
- *
- * Storer, James A.
- * Data Compression: Methods and Theory, pp. 49-50.
- * Computer Science Press, 1988. ISBN 0-7167-8156-5.
- *
- * Sedgewick, R.
- * Algorithms, p290.
- * Addison-Wesley, 1983. ISBN 0-201-06672-6.
- */
-
-/* @(#) $Id$ */
-
-/* #define GEN_TREES_H */
-
-#include "deflate.h"
-
-#ifdef DEBUG
-# include <ctype.h>
-#endif
-
-/* ===========================================================================
- * Constants
- */
-
-#define MAX_BL_BITS 7
-/* Bit length codes must not exceed MAX_BL_BITS bits */
-
-#define END_BLOCK 256
-/* end of block literal code */
-
-#define REP_3_6 16
-/* repeat previous bit length 3-6 times (2 bits of repeat count) */
-
-#define REPZ_3_10 17
-/* repeat a zero length 3-10 times (3 bits of repeat count) */
-
-#define REPZ_11_138 18
-/* repeat a zero length 11-138 times (7 bits of repeat count) */
-
-local const int extra_lbits[LENGTH_CODES] /* extra bits for each length code */
- = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0};
-
-local const int extra_dbits[D_CODES] /* extra bits for each distance code */
- = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13};
-
-local const int extra_blbits[BL_CODES]/* extra bits for each bit length code */
- = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7};
-
-local const uch bl_order[BL_CODES]
- = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15};
-/* The lengths of the bit length codes are sent in order of decreasing
- * probability, to avoid transmitting the lengths for unused bit length codes.
- */
-
-#define Buf_size (8 * 2*sizeof(char))
-/* Number of bits used within bi_buf. (bi_buf might be implemented on
- * more than 16 bits on some systems.)
- */
-
-/* ===========================================================================
- * Local data. These are initialized only once.
- */
-
-#define DIST_CODE_LEN 512 /* see definition of array dist_code below */
-
-#if defined(GEN_TREES_H) || !defined(STDC)
-/* non ANSI compilers may not accept trees.h */
-
-local ct_data static_ltree[L_CODES+2];
-/* The static literal tree. Since the bit lengths are imposed, there is no
- * need for the L_CODES extra codes used during heap construction. However
- * The codes 286 and 287 are needed to build a canonical tree (see _tr_init
- * below).
- */
-
-local ct_data static_dtree[D_CODES];
-/* The static distance tree. (Actually a trivial tree since all codes use
- * 5 bits.)
- */
-
-uch _dist_code[DIST_CODE_LEN];
-/* Distance codes. The first 256 values correspond to the distances
- * 3 .. 258, the last 256 values correspond to the top 8 bits of
- * the 15 bit distances.
- */
-
-uch _length_code[MAX_MATCH-MIN_MATCH+1];
-/* length code for each normalized match length (0 == MIN_MATCH) */
-
-local int base_length[LENGTH_CODES];
-/* First normalized length for each code (0 = MIN_MATCH) */
-
-local int base_dist[D_CODES];
-/* First normalized distance for each code (0 = distance of 1) */
-
-#else
-# include "trees.h"
-#endif /* GEN_TREES_H */
-
-struct static_tree_desc_s {
- const ct_data *static_tree; /* static tree or NULL */
- const intf *extra_bits; /* extra bits for each code or NULL */
- int extra_base; /* base index for extra_bits */
- int elems; /* max number of elements in the tree */
- int max_length; /* max bit length for the codes */
-};
-
-local static_tree_desc static_l_desc =
-{static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS};
-
-local static_tree_desc static_d_desc =
-{static_dtree, extra_dbits, 0, D_CODES, MAX_BITS};
-
-local static_tree_desc static_bl_desc =
-{(const ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS};
-
-/* ===========================================================================
- * Local (static) routines in this file.
- */
-
-local void tr_static_init OF((void));
-local void init_block OF((deflate_state *s));
-local void pqdownheap OF((deflate_state *s, ct_data *tree, int k));
-local void gen_bitlen OF((deflate_state *s, tree_desc *desc));
-local void gen_codes OF((ct_data *tree, int max_code, ushf *bl_count));
-local void build_tree OF((deflate_state *s, tree_desc *desc));
-local void scan_tree OF((deflate_state *s, ct_data *tree, int max_code));
-local void send_tree OF((deflate_state *s, ct_data *tree, int max_code));
-local int build_bl_tree OF((deflate_state *s));
-local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes,
- 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 unsigned bi_reverse OF((unsigned value, int length));
-local void bi_windup OF((deflate_state *s));
-local void bi_flush OF((deflate_state *s));
-local void copy_block OF((deflate_state *s, charf *buf, unsigned len,
- int header));
-
-#ifdef GEN_TREES_H
-local void gen_trees_header OF((void));
-#endif
-
-#ifndef DEBUG
-# define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len)
- /* Send a code of the given tree. c and tree must not have side effects */
-
-#else /* DEBUG */
-# define send_code(s, c, tree) \
- { if (z_verbose>2) fprintf(stderr,"\ncd %3d ",(c)); \
- send_bits(s, tree[c].Code, tree[c].Len); }
-#endif
-
-/* ===========================================================================
- * Output a short LSB first on the stream.
- * IN assertion: there is enough room in pendingBuf.
- */
-#define put_short(s, w) { \
- put_byte(s, (uch)((w) & 0xff)); \
- put_byte(s, (uch)((ush)(w) >> 8)); \
-}
-
-/* ===========================================================================
- * Send a value on a given number of bits.
- * IN assertion: length <= 16 and value fits in length bits.
- */
-#ifdef DEBUG
-local void send_bits OF((deflate_state *s, int value, int length));
-
-local void send_bits(s, value, length)
- deflate_state *s;
- int value; /* value to send */
- int length; /* number of bits */
-{
- Tracevv((stderr," l %2d v %4x ", length, value));
- Assert(length > 0 && length <= 15, "invalid length");
- s->bits_sent += (ulg)length;
-
- /* If not enough room in bi_buf, use (valid) bits from bi_buf and
- * (16 - bi_valid) bits from value, leaving (width - (16-bi_valid))
- * unused bits in value.
- */
- if (s->bi_valid > (int)Buf_size - length) {
- s->bi_buf |= (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_valid += length;
- }
-}
-#else /* !DEBUG */
-
-#define send_bits(s, value, length) \
-{ int len = length;\
- if (s->bi_valid > (int)Buf_size - len) {\
- int val = value;\
- s->bi_buf |= (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_valid += len;\
- }\
-}
-#endif /* DEBUG */
-
-
-/* the arguments must not have side effects */
-
-/* ===========================================================================
- * Initialize the various 'constant' tables.
- */
-local void tr_static_init()
-{
-#if defined(GEN_TREES_H) || !defined(STDC)
- static int static_init_done = 0;
- int n; /* iterates over tree elements */
- int bits; /* bit counter */
- int length; /* length value */
- int code; /* code value */
- int dist; /* distance index */
- ush bl_count[MAX_BITS+1];
- /* number of codes at each bit length for an optimal tree */
-
- if (static_init_done) return;
-
- /* For some embedded targets, global variables are not initialized: */
- 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;
-
- /* Initialize the mapping length (0..255) -> length code (0..28) */
- length = 0;
- for (code = 0; code < LENGTH_CODES-1; code++) {
- base_length[code] = length;
- for (n = 0; n < (1<<extra_lbits[code]); n++) {
- _length_code[length++] = (uch)code;
- }
- }
- Assert (length == 256, "tr_static_init: length != 256");
- /* Note that the length 255 (match length 258) can be represented
- * in two different ways: code 284 + 5 bits or code 285, so we
- * overwrite length_code[255] to use the best encoding:
- */
- _length_code[length-1] = (uch)code;
-
- /* Initialize the mapping dist (0..32K) -> dist code (0..29) */
- dist = 0;
- for (code = 0 ; code < 16; code++) {
- base_dist[code] = dist;
- for (n = 0; n < (1<<extra_dbits[code]); n++) {
- _dist_code[dist++] = (uch)code;
- }
- }
- Assert (dist == 256, "tr_static_init: dist != 256");
- dist >>= 7; /* from now on, all distances are divided by 128 */
- for ( ; code < D_CODES; code++) {
- base_dist[code] = dist << 7;
- for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) {
- _dist_code[256 + dist++] = (uch)code;
- }
- }
- Assert (dist == 256, "tr_static_init: 256+dist != 512");
-
- /* Construct the codes of the static literal tree */
- for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0;
- n = 0;
- while (n <= 143) static_ltree[n++].Len = 8, bl_count[8]++;
- while (n <= 255) static_ltree[n++].Len = 9, bl_count[9]++;
- while (n <= 279) static_ltree[n++].Len = 7, bl_count[7]++;
- while (n <= 287) static_ltree[n++].Len = 8, bl_count[8]++;
- /* Codes 286 and 287 do not exist, but we must include them in the
- * tree construction to get a canonical Huffman tree (longest code
- * all ones)
- */
- gen_codes((ct_data *)static_ltree, L_CODES+1, bl_count);
-
- /* The static distance tree is trivial: */
- for (n = 0; n < D_CODES; n++) {
- static_dtree[n].Len = 5;
- static_dtree[n].Code = bi_reverse((unsigned)n, 5);
- }
- static_init_done = 1;
-
-# ifdef GEN_TREES_H
- gen_trees_header();
-# endif
-#endif /* defined(GEN_TREES_H) || !defined(STDC) */
-}
-
-/* ===========================================================================
- * Genererate the file trees.h describing the static trees.
- */
-#ifdef GEN_TREES_H
-# ifndef DEBUG
-# include <stdio.h>
-# endif
-
-# define SEPARATOR(i, last, width) \
- ((i) == (last)? "\n};\n\n" : \
- ((i) % (width) == (width)-1 ? ",\n" : ", "))
-
-void gen_trees_header()
-{
- FILE *header = fopen("trees.h", "w");
- int i;
-
- Assert (header != NULL, "Can't open trees.h");
- fprintf(header,
- "/* header created automatically with -DGEN_TREES_H */\n\n");
-
- fprintf(header, "local const ct_data static_ltree[L_CODES+2] = {\n");
- for (i = 0; i < L_CODES+2; i++) {
- fprintf(header, "{{%3u},{%3u}}%s", static_ltree[i].Code,
- static_ltree[i].Len, SEPARATOR(i, L_CODES+1, 5));
- }
-
- fprintf(header, "local const ct_data static_dtree[D_CODES] = {\n");
- for (i = 0; i < D_CODES; i++) {
- fprintf(header, "{{%2u},{%2u}}%s", static_dtree[i].Code,
- static_dtree[i].Len, SEPARATOR(i, D_CODES-1, 5));
- }
-
- fprintf(header, "const uch _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");
- for (i = 0; i < MAX_MATCH-MIN_MATCH+1; i++) {
- fprintf(header, "%2u%s", _length_code[i],
- SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20));
- }
-
- fprintf(header, "local const int base_length[LENGTH_CODES] = {\n");
- for (i = 0; i < LENGTH_CODES; i++) {
- fprintf(header, "%1u%s", base_length[i],
- SEPARATOR(i, LENGTH_CODES-1, 20));
- }
-
- fprintf(header, "local const int base_dist[D_CODES] = {\n");
- for (i = 0; i < D_CODES; i++) {
- fprintf(header, "%5u%s", base_dist[i],
- SEPARATOR(i, D_CODES-1, 10));
- }
-
- fclose(header);
-}
-#endif /* GEN_TREES_H */
-
-/* ===========================================================================
- * Initialize the tree data structures for a new zlib stream.
- */
-void _tr_init(s)
- deflate_state *s;
-{
- tr_static_init();
-
- s->l_desc.dyn_tree = s->dyn_ltree;
- s->l_desc.stat_desc = &static_l_desc;
-
- s->d_desc.dyn_tree = s->dyn_dtree;
- s->d_desc.stat_desc = &static_d_desc;
-
- s->bl_desc.dyn_tree = s->bl_tree;
- s->bl_desc.stat_desc = &static_bl_desc;
-
- s->bi_buf = 0;
- s->bi_valid = 0;
- s->last_eob_len = 8; /* enough lookahead for inflate */
-#ifdef DEBUG
- s->compressed_len = 0L;
- s->bits_sent = 0L;
-#endif
-
- /* Initialize the first block of the first file: */
- init_block(s);
-}
-
-/* ===========================================================================
- * Initialize a new block.
- */
-local void init_block(s)
- deflate_state *s;
-{
- int n; /* iterates over tree elements */
-
- /* Initialize the trees. */
- for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0;
- for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0;
- for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0;
-
- s->dyn_ltree[END_BLOCK].Freq = 1;
- s->opt_len = s->static_len = 0L;
- s->last_lit = s->matches = 0;
-}
-
-#define SMALLEST 1
-/* Index within the heap array of least frequent node in the Huffman tree */
-
-
-/* ===========================================================================
- * Remove the smallest element from the heap and recreate the heap with
- * one less element. Updates heap and heap_len.
- */
-#define pqremove(s, tree, top) \
-{\
- top = s->heap[SMALLEST]; \
- s->heap[SMALLEST] = s->heap[s->heap_len--]; \
- pqdownheap(s, tree, SMALLEST); \
-}
-
-/* ===========================================================================
- * Compares to subtrees, using the tree depth as tie breaker when
- * the subtrees have equal frequency. This minimizes the worst case length.
- */
-#define smaller(tree, n, m, depth) \
- (tree[n].Freq < tree[m].Freq || \
- (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m]))
-
-/* ===========================================================================
- * Restore the heap property by moving down the tree starting at node k,
- * exchanging a node with the smallest of its two sons if necessary, stopping
- * when the heap property is re-established (each father smaller than its
- * two sons).
- */
-local void pqdownheap(s, tree, k)
- deflate_state *s;
- ct_data *tree; /* the tree to restore */
- int k; /* node to move down */
-{
- int v = s->heap[k];
- int j = k << 1; /* left son of k */
- while (j <= s->heap_len) {
- /* Set j to the smallest of the two sons: */
- if (j < s->heap_len &&
- smaller(tree, s->heap[j+1], s->heap[j], s->depth)) {
- j++;
- }
- /* Exit if v is smaller than both sons */
- if (smaller(tree, v, s->heap[j], s->depth)) break;
-
- /* Exchange v with the smallest son */
- s->heap[k] = s->heap[j]; k = j;
-
- /* And continue down the tree, setting j to the left son of k */
- j <<= 1;
- }
- s->heap[k] = v;
-}
-
-/* ===========================================================================
- * Compute the optimal bit lengths for a tree and update the total bit length
- * for the current block.
- * IN assertion: the fields freq and dad are set, heap[heap_max] and
- * above are the tree nodes sorted by increasing frequency.
- * OUT assertions: the field len is set to the optimal bit length, the
- * array bl_count contains the frequencies for each bit length.
- * The length opt_len is updated; static_len is also updated if stree is
- * not null.
- */
-local void gen_bitlen(s, desc)
- deflate_state *s;
- tree_desc *desc; /* the tree descriptor */
-{
- ct_data *tree = desc->dyn_tree;
- int max_code = desc->max_code;
- const ct_data *stree = desc->stat_desc->static_tree;
- const intf *extra = desc->stat_desc->extra_bits;
- int base = desc->stat_desc->extra_base;
- int max_length = desc->stat_desc->max_length;
- int h; /* heap index */
- int n, m; /* iterate over the tree elements */
- int bits; /* bit length */
- int xbits; /* extra bits */
- ush f; /* frequency */
- int overflow = 0; /* number of elements with bit length too large */
-
- for (bits = 0; bits <= MAX_BITS; bits++) s->bl_count[bits] = 0;
-
- /* In a first pass, compute the optimal bit lengths (which may
- * overflow in the case of the bit length tree).
- */
- tree[s->heap[s->heap_max]].Len = 0; /* root of the heap */
-
- for (h = s->heap_max+1; h < HEAP_SIZE; h++) {
- n = s->heap[h];
- bits = tree[tree[n].Dad].Len + 1;
- if (bits > max_length) bits = max_length, overflow++;
- tree[n].Len = (ush)bits;
- /* We overwrite tree[n].Dad which is no longer needed */
-
- if (n > max_code) continue; /* not a leaf node */
-
- s->bl_count[bits]++;
- xbits = 0;
- if (n >= base) xbits = extra[n-base];
- f = tree[n].Freq;
- s->opt_len += (ulg)f * (bits + xbits);
- if (stree) s->static_len += (ulg)f * (stree[n].Len + xbits);
- }
- if (overflow == 0) return;
-
- Trace((stderr,"\nbit length overflow\n"));
- /* This happens for example on obj2 and pic of the Calgary corpus */
-
- /* Find the first bit length which could increase: */
- do {
- bits = max_length-1;
- while (s->bl_count[bits] == 0) bits--;
- s->bl_count[bits]--; /* move one leaf down the tree */
- s->bl_count[bits+1] += 2; /* move one overflow item as its brother */
- s->bl_count[max_length]--;
- /* The brother of the overflow item also moves one step up,
- * but this does not affect bl_count[max_length]
- */
- overflow -= 2;
- } while (overflow > 0);
-
- /* Now recompute all bit lengths, scanning in increasing frequency.
- * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all
- * lengths instead of fixing only the wrong ones. This idea is taken
- * from 'ar' written by Haruhiko Okumura.)
- */
- for (bits = max_length; bits != 0; bits--) {
- n = s->bl_count[bits];
- while (n != 0) {
- m = s->heap[--h];
- if (m > max_code) continue;
- if ((unsigned) tree[m].Len != (unsigned) bits) {
- Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits));
- s->opt_len += ((long)bits - (long)tree[m].Len)
- *(long)tree[m].Freq;
- tree[m].Len = (ush)bits;
- }
- n--;
- }
- }
-}
-
-/* ===========================================================================
- * Generate the codes for a given tree and bit counts (which need not be
- * optimal).
- * IN assertion: the array bl_count contains the bit length statistics for
- * the given tree and the field len is set for all tree elements.
- * OUT assertion: the field code is set for all tree elements of non
- * zero code length.
- */
-local void gen_codes (tree, max_code, bl_count)
- ct_data *tree; /* the tree to decorate */
- int max_code; /* largest code with non zero frequency */
- ushf *bl_count; /* number of codes at each bit length */
-{
- ush next_code[MAX_BITS+1]; /* next code value for each bit length */
- ush code = 0; /* running code value */
- int bits; /* bit index */
- int n; /* code index */
-
- /* The distribution counts are first used to generate the code values
- * without bit reversal.
- */
- for (bits = 1; bits <= MAX_BITS; bits++) {
- next_code[bits] = code = (code + bl_count[bits-1]) << 1;
- }
- /* Check that the bit counts in bl_count are consistent. The last code
- * must be all ones.
- */
- Assert (code + bl_count[MAX_BITS]-1 == (1<<MAX_BITS)-1,
- "inconsistent bit counts");
- Tracev((stderr,"\ngen_codes: max_code %d ", max_code));
-
- for (n = 0; n <= max_code; n++) {
- int len = tree[n].Len;
- if (len == 0) continue;
- /* Now reverse the bits */
- tree[n].Code = bi_reverse(next_code[len]++, len);
-
- Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ",
- n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len]-1));
- }
-}
-
-/* ===========================================================================
- * Construct one Huffman tree and assigns the code bit strings and lengths.
- * Update the total bit length for the current block.
- * IN assertion: the field freq is set for all tree elements.
- * OUT assertions: the fields len and code are set to the optimal bit length
- * and corresponding code. The length opt_len is updated; static_len is
- * also updated if stree is not null. The field max_code is set.
- */
-local void build_tree(s, desc)
- deflate_state *s;
- tree_desc *desc; /* the tree descriptor */
-{
- ct_data *tree = desc->dyn_tree;
- const ct_data *stree = desc->stat_desc->static_tree;
- int elems = desc->stat_desc->elems;
- int n, m; /* iterate over heap elements */
- int max_code = -1; /* largest code with non zero frequency */
- int node; /* new node being created */
-
- /* Construct the initial heap, with least frequent element in
- * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1].
- * heap[0] is not used.
- */
- s->heap_len = 0, s->heap_max = HEAP_SIZE;
-
- for (n = 0; n < elems; n++) {
- if (tree[n].Freq != 0) {
- s->heap[++(s->heap_len)] = max_code = n;
- s->depth[n] = 0;
- } else {
- tree[n].Len = 0;
- }
- }
-
- /* The pkzip format requires that at least one distance code exists,
- * and that at least one bit should be sent even if there is only one
- * possible code. So to avoid special checks later on we force at least
- * two codes of non zero frequency.
- */
- while (s->heap_len < 2) {
- node = s->heap[++(s->heap_len)] = (max_code < 2 ? ++max_code : 0);
- tree[node].Freq = 1;
- s->depth[node] = 0;
- s->opt_len--; if (stree) s->static_len -= stree[node].Len;
- /* node is 0 or 1 so it does not have extra bits */
- }
- desc->max_code = max_code;
-
- /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree,
- * establish sub-heaps of increasing lengths:
- */
- for (n = s->heap_len/2; n >= 1; n--) pqdownheap(s, tree, n);
-
- /* Construct the Huffman tree by repeatedly combining the least two
- * frequent nodes.
- */
- node = elems; /* next internal node of the tree */
- do {
- pqremove(s, tree, n); /* n = node of least frequency */
- m = s->heap[SMALLEST]; /* m = node of next least frequency */
-
- s->heap[--(s->heap_max)] = n; /* keep the nodes sorted by frequency */
- s->heap[--(s->heap_max)] = m;
-
- /* Create a new node father of n and m */
- tree[node].Freq = tree[n].Freq + tree[m].Freq;
- s->depth[node] = (uch)((s->depth[n] >= s->depth[m] ?
- s->depth[n] : s->depth[m]) + 1);
- tree[n].Dad = tree[m].Dad = (ush)node;
-#ifdef DUMP_BL_TREE
- if (tree == s->bl_tree) {
- fprintf(stderr,"\nnode %d(%d), sons %d(%d) %d(%d)",
- node, tree[node].Freq, n, tree[n].Freq, m, tree[m].Freq);
- }
-#endif
- /* and insert the new node in the heap */
- s->heap[SMALLEST] = node++;
- pqdownheap(s, tree, SMALLEST);
-
- } while (s->heap_len >= 2);
-
- s->heap[--(s->heap_max)] = s->heap[SMALLEST];
-
- /* At this point, the fields freq and dad are set. We can now
- * generate the bit lengths.
- */
- gen_bitlen(s, (tree_desc *)desc);
-
- /* The field len is now set, we can generate the bit codes */
- gen_codes ((ct_data *)tree, max_code, s->bl_count);
-}
-
-/* ===========================================================================
- * Scan a literal or distance tree to determine the frequencies of the codes
- * in the bit length tree.
- */
-local void scan_tree (s, tree, max_code)
- deflate_state *s;
- ct_data *tree; /* the tree to be scanned */
- int max_code; /* and its largest code of non zero frequency */
-{
- int n; /* iterates over all tree elements */
- int prevlen = -1; /* last emitted length */
- int curlen; /* length of current code */
- int nextlen = tree[0].Len; /* length of next code */
- int count = 0; /* repeat count of the current code */
- int max_count = 7; /* max repeat count */
- int min_count = 4; /* min repeat count */
-
- if (nextlen == 0) max_count = 138, min_count = 3;
- tree[max_code+1].Len = (ush)0xffff; /* guard */
-
- for (n = 0; n <= max_code; n++) {
- curlen = nextlen; nextlen = tree[n+1].Len;
- if (++count < max_count && curlen == nextlen) {
- continue;
- } else if (count < min_count) {
- s->bl_tree[curlen].Freq += count;
- } else if (curlen != 0) {
- if (curlen != prevlen) s->bl_tree[curlen].Freq++;
- s->bl_tree[REP_3_6].Freq++;
- } else if (count <= 10) {
- s->bl_tree[REPZ_3_10].Freq++;
- } else {
- s->bl_tree[REPZ_11_138].Freq++;
- }
- count = 0; prevlen = curlen;
- if (nextlen == 0) {
- max_count = 138, min_count = 3;
- } else if (curlen == nextlen) {
- max_count = 6, min_count = 3;
- } else {
- max_count = 7, min_count = 4;
- }
- }
-}
-
-/* ===========================================================================
- * Send a literal or distance tree in compressed form, using the codes in
- * bl_tree.
- */
-local void send_tree (s, tree, max_code)
- deflate_state *s;
- ct_data *tree; /* the tree to be scanned */
- int max_code; /* and its largest code of non zero frequency */
-{
- int n; /* iterates over all tree elements */
- int prevlen = -1; /* last emitted length */
- int curlen; /* length of current code */
- int nextlen = tree[0].Len; /* length of next code */
- int count = 0; /* repeat count of the current code */
- int max_count = 7; /* max repeat count */
- int min_count = 4; /* min repeat count */
-
- /* tree[max_code+1].Len = -1; */ /* guard already set */
- if (nextlen == 0) max_count = 138, min_count = 3;
-
- for (n = 0; n <= max_code; n++) {
- curlen = nextlen; nextlen = tree[n+1].Len;
- if (++count < max_count && curlen == nextlen) {
- continue;
- } else if (count < min_count) {
- do { send_code(s, curlen, s->bl_tree); } while (--count != 0);
-
- } else if (curlen != 0) {
- if (curlen != prevlen) {
- send_code(s, curlen, s->bl_tree); count--;
- }
- Assert(count >= 3 && count <= 6, " 3_6?");
- send_code(s, REP_3_6, s->bl_tree); send_bits(s, count-3, 2);
-
- } else if (count <= 10) {
- send_code(s, REPZ_3_10, s->bl_tree); send_bits(s, count-3, 3);
-
- } else {
- send_code(s, REPZ_11_138, s->bl_tree); send_bits(s, count-11, 7);
- }
- count = 0; prevlen = curlen;
- if (nextlen == 0) {
- max_count = 138, min_count = 3;
- } else if (curlen == nextlen) {
- max_count = 6, min_count = 3;
- } else {
- max_count = 7, min_count = 4;
- }
- }
-}
-
-/* ===========================================================================
- * Construct the Huffman tree for the bit lengths and return the index in
- * bl_order of the last bit length code to send.
- */
-local int build_bl_tree(s)
- deflate_state *s;
-{
- int max_blindex; /* index of last bit length code of non zero freq */
-
- /* Determine the bit length frequencies for literal and distance trees */
- scan_tree(s, (ct_data *)s->dyn_ltree, s->l_desc.max_code);
- scan_tree(s, (ct_data *)s->dyn_dtree, s->d_desc.max_code);
-
- /* Build the bit length tree: */
- build_tree(s, (tree_desc *)(&(s->bl_desc)));
- /* opt_len now includes the length of the tree representations, except
- * the lengths of the bit lengths codes and the 5+5+4 bits for the counts.
- */
-
- /* Determine the number of bit length codes to send. The pkzip format
- * requires that at least 4 bit length codes be sent. (appnote.txt says
- * 3 but the actual value used is 4.)
- */
- for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) {
- if (s->bl_tree[bl_order[max_blindex]].Len != 0) break;
- }
- /* Update opt_len to include the bit length tree and counts */
- s->opt_len += 3*(max_blindex+1) + 5+5+4;
- Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld",
- s->opt_len, s->static_len));
-
- return max_blindex;
-}
-
-/* ===========================================================================
- * Send the header for a block using dynamic Huffman trees: the counts, the
- * lengths of the bit length codes, the literal tree and the distance tree.
- * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4.
- */
-local void send_all_trees(s, lcodes, dcodes, blcodes)
- deflate_state *s;
- int lcodes, dcodes, blcodes; /* number of codes for each tree */
-{
- int rank; /* index in bl_order */
-
- Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes");
- Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES,
- "too many codes");
- Tracev((stderr, "\nbl counts: "));
- send_bits(s, lcodes-257, 5); /* not +255 as stated in appnote.txt */
- send_bits(s, dcodes-1, 5);
- send_bits(s, blcodes-4, 4); /* not -3 as stated in appnote.txt */
- for (rank = 0; rank < blcodes; rank++) {
- Tracev((stderr, "\nbl code %2d ", bl_order[rank]));
- send_bits(s, s->bl_tree[bl_order[rank]].Len, 3);
- }
- Tracev((stderr, "\nbl tree: sent %ld", s->bits_sent));
-
- send_tree(s, (ct_data *)s->dyn_ltree, lcodes-1); /* literal tree */
- Tracev((stderr, "\nlit tree: sent %ld", s->bits_sent));
-
- send_tree(s, (ct_data *)s->dyn_dtree, dcodes-1); /* distance tree */
- Tracev((stderr, "\ndist tree: sent %ld", s->bits_sent));
-}
-
-/* ===========================================================================
- * Send a stored block
- */
-void _tr_stored_block(s, buf, stored_len, eof)
- 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 */
-{
- send_bits(s, (STORED_BLOCK<<1)+eof, 3); /* send block type */
-#ifdef DEBUG
- s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L;
- s->compressed_len += (stored_len + 4) << 3;
-#endif
- copy_block(s, buf, (unsigned)stored_len, 1); /* with header */
-}
-
-/* ===========================================================================
- * Send one empty static block to give enough lookahead for inflate.
- * This takes 10 bits, of which 7 may remain in the bit buffer.
- * The current inflate code requires 9 bits of lookahead. If the
- * last two codes for the previous block (real code plus EOB) were coded
- * on 5 bits or less, inflate may have only 5+3 bits of lookahead to decode
- * the last real code. In this case we send two empty static blocks instead
- * of one. (There are no problems if the previous block is stored or fixed.)
- * To simplify the code, we assume the worst case of last real code encoded
- * on one bit only.
- */
-void _tr_align(s)
- deflate_state *s;
-{
- send_bits(s, STATIC_TREES<<1, 3);
- send_code(s, END_BLOCK, static_ltree);
-#ifdef DEBUG
- s->compressed_len += 10L; /* 3 for block type, 7 for EOB */
-#endif
- bi_flush(s);
- /* Of the 10 bits for the empty block, we have already sent
- * (10 - bi_valid) bits. The lookahead for the last real code (before
- * the EOB of the previous block) was thus at least one plus the length
- * of the EOB plus what we have just sent of the empty static block.
- */
- if (1 + s->last_eob_len + 10 - s->bi_valid < 9) {
- send_bits(s, STATIC_TREES<<1, 3);
- send_code(s, END_BLOCK, static_ltree);
-#ifdef DEBUG
- s->compressed_len += 10L;
-#endif
- bi_flush(s);
- }
- s->last_eob_len = 7;
-}
-
-/* ===========================================================================
- * 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)
- 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 */
-{
- 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 */
-
- /* Build the Huffman trees unless a stored block is forced */
- 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);
-
- /* Construct the literal and distance trees */
- build_tree(s, (tree_desc *)(&(s->l_desc)));
- Tracev((stderr, "\nlit data: dyn %ld, stat %ld", s->opt_len,
- s->static_len));
-
- build_tree(s, (tree_desc *)(&(s->d_desc)));
- Tracev((stderr, "\ndist data: dyn %ld, stat %ld", s->opt_len,
- s->static_len));
- /* At this point, opt_len and static_len are the total bit lengths of
- * the compressed block data, excluding the tree representations.
- */
-
- /* Build the bit length tree for the above two trees, and get the index
- * in bl_order of the last bit length code to send.
- */
- max_blindex = build_bl_tree(s);
-
- /* Determine the best encoding. Compute the block lengths in bytes. */
- opt_lenb = (s->opt_len+3+7)>>3;
- static_lenb = (s->static_len+3+7)>>3;
-
- Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ",
- opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len,
- s->last_lit));
-
- if (static_lenb <= opt_lenb) opt_lenb = static_lenb;
-
- } else {
- Assert(buf != (char*)0, "lost buf");
- opt_lenb = static_lenb = stored_len + 5; /* force a stored block */
- }
-
-#ifdef FORCE_STORED
- if (buf != (char*)0) { /* force stored block */
-#else
- if (stored_len+4 <= opt_lenb && buf != (char*)0) {
- /* 4: two words for the lengths */
-#endif
- /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE.
- * Otherwise we can't have processed more than WSIZE input bytes since
- * the last block flush, because compression would have been
- * 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);
-
-#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);
- 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_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);
-#ifdef DEBUG
- s->compressed_len += 3 + s->opt_len;
-#endif
- }
- Assert (s->compressed_len == s->bits_sent, "bad compressed size");
- /* The above check is made mod 2^32, for files larger than 512 MB
- * and uLong implemented on 32 bits.
- */
- init_block(s);
-
- if (eof) {
- 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));
-}
-
-/* ===========================================================================
- * Save the match info and tally the frequency counts. Return true if
- * the current block must be flushed.
- */
-int _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) */
-{
- s->d_buf[s->last_lit] = (ush)dist;
- s->l_buf[s->last_lit++] = (uch)lc;
- if (dist == 0) {
- /* lc is the unmatched char */
- s->dyn_ltree[lc].Freq++;
- } else {
- s->matches++;
- /* Here, lc is the match length - MIN_MATCH */
- dist--; /* dist = match distance - 1 */
- Assert((ush)dist < (ush)MAX_DIST(s) &&
- (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) &&
- (ush)d_code(dist) < (ush)D_CODES, "_tr_tally: bad match");
-
- s->dyn_ltree[_length_code[lc]+LITERALS+1].Freq++;
- s->dyn_dtree[d_code(dist)].Freq++;
- }
-
-#ifdef TRUNCATE_BLOCK
- /* Try to guess if it is profitable to stop the current block here */
- if ((s->last_lit & 0x1fff) == 0 && s->level > 2) {
- /* Compute an upper bound for the compressed length */
- ulg out_length = (ulg)s->last_lit*8L;
- ulg in_length = (ulg)((long)s->strstart - s->block_start);
- int dcode;
- for (dcode = 0; dcode < D_CODES; dcode++) {
- out_length += (ulg)s->dyn_dtree[dcode].Freq *
- (5L+extra_dbits[dcode]);
- }
- out_length >>= 3;
- Tracev((stderr,"\nlast_lit %u, in %ld, out ~%ld(%ld%%) ",
- s->last_lit, in_length, out_length,
- 100L - out_length*100L/in_length));
- if (s->matches < s->last_lit/2 && out_length < in_length/2) return 1;
- }
-#endif
- return (s->last_lit == s->lit_bufsize-1);
- /* We avoid equality with lit_bufsize because of wraparound at 64K
- * on 16 bit machines and because stored blocks are restricted to
- * 64K-1 bytes.
- */
-}
-
-/* ===========================================================================
- * Send the block data compressed using the given Huffman trees
- */
-local void compress_block(s, ltree, dtree)
- deflate_state *s;
- ct_data *ltree; /* literal tree */
- ct_data *dtree; /* distance tree */
-{
- unsigned dist; /* distance of matched string */
- int lc; /* match length or unmatched char (if dist == 0) */
- unsigned lx = 0; /* running index in l_buf */
- unsigned code; /* the code to send */
- int extra; /* number of extra bits to send */
-
- if (s->last_lit != 0) do {
- dist = s->d_buf[lx];
- lc = s->l_buf[lx++];
- if (dist == 0) {
- send_code(s, lc, ltree); /* send a literal byte */
- Tracecv(isgraph(lc), (stderr," '%c' ", lc));
- } else {
- /* Here, lc is the match length - MIN_MATCH */
- code = _length_code[lc];
- send_code(s, code+LITERALS+1, ltree); /* send the length code */
- extra = extra_lbits[code];
- if (extra != 0) {
- lc -= base_length[code];
- send_bits(s, lc, extra); /* send the extra length bits */
- }
- dist--; /* dist is now the match distance - 1 */
- code = d_code(dist);
- Assert (code < D_CODES, "bad d_code");
-
- send_code(s, code, dtree); /* send the distance code */
- extra = extra_dbits[code];
- if (extra != 0) {
- dist -= base_dist[code];
- send_bits(s, dist, extra); /* send the extra distance bits */
- }
- } /* literal or match pair ? */
-
- /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */
- Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx,
- "pendingBuf overflow");
-
- } while (lx < s->last_lit);
-
- send_code(s, END_BLOCK, ltree);
- s->last_eob_len = ltree[END_BLOCK].Len;
-}
-
-/* ===========================================================================
- * 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.
- * IN assertion: the fields Freq of dyn_ltree are set.
- */
-local void set_data_type(s)
- deflate_state *s;
-{
- int n;
-
- for (n = 0; n < 9; 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;
-}
-
-/* ===========================================================================
- * Reverse the first len bits of a code, using straightforward code (a faster
- * method would use a table)
- * IN assertion: 1 <= len <= 15
- */
-local unsigned bi_reverse(code, len)
- unsigned code; /* the value to invert */
- int len; /* its bit length */
-{
- register unsigned res = 0;
- do {
- res |= code & 1;
- code >>= 1, res <<= 1;
- } while (--len > 0);
- return res >> 1;
-}
-
-/* ===========================================================================
- * Flush the bit buffer, keeping at most 7 bits in it.
- */
-local void bi_flush(s)
- deflate_state *s;
-{
- if (s->bi_valid == 16) {
- put_short(s, s->bi_buf);
- s->bi_buf = 0;
- s->bi_valid = 0;
- } else if (s->bi_valid >= 8) {
- put_byte(s, (Byte)s->bi_buf);
- s->bi_buf >>= 8;
- s->bi_valid -= 8;
- }
-}
-
-/* ===========================================================================
- * Flush the bit buffer and align the output on a byte boundary
- */
-local void bi_windup(s)
- deflate_state *s;
-{
- if (s->bi_valid > 8) {
- put_short(s, s->bi_buf);
- } else if (s->bi_valid > 0) {
- put_byte(s, (Byte)s->bi_buf);
- }
- s->bi_buf = 0;
- s->bi_valid = 0;
-#ifdef DEBUG
- s->bits_sent = (s->bits_sent+7) & ~7;
-#endif
-}
-
-/* ===========================================================================
- * Copy a stored block, storing first the length and its
- * one's complement if requested.
- */
-local void copy_block(s, buf, len, header)
- deflate_state *s;
- charf *buf; /* the input data */
- unsigned len; /* its length */
- int header; /* true if block header must be written */
-{
- bi_windup(s); /* align on byte boundary */
- s->last_eob_len = 8; /* enough lookahead for inflate */
-
- if (header) {
- put_short(s, (ush)len);
- put_short(s, (ush)~len);
-#ifdef DEBUG
- s->bits_sent += 2*16;
-#endif
- }
-#ifdef DEBUG
- s->bits_sent += (ulg)len<<3;
-#endif
- while (len--) {
- put_byte(s, *buf++);
- }
-}
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/trees.h Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,152 +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.
- */
-
-/* header created automatically with -DGEN_TREES_H */
-
-local const ct_data static_ltree[L_CODES+2] = {
-{{ 12},{ 8}}, {{140},{ 8}}, {{ 76},{ 8}}, {{204},{ 8}}, {{ 44},{ 8}},
-{{172},{ 8}}, {{108},{ 8}}, {{236},{ 8}}, {{ 28},{ 8}}, {{156},{ 8}},
-{{ 92},{ 8}}, {{220},{ 8}}, {{ 60},{ 8}}, {{188},{ 8}}, {{124},{ 8}},
-{{252},{ 8}}, {{ 2},{ 8}}, {{130},{ 8}}, {{ 66},{ 8}}, {{194},{ 8}},
-{{ 34},{ 8}}, {{162},{ 8}}, {{ 98},{ 8}}, {{226},{ 8}}, {{ 18},{ 8}},
-{{146},{ 8}}, {{ 82},{ 8}}, {{210},{ 8}}, {{ 50},{ 8}}, {{178},{ 8}},
-{{114},{ 8}}, {{242},{ 8}}, {{ 10},{ 8}}, {{138},{ 8}}, {{ 74},{ 8}},
-{{202},{ 8}}, {{ 42},{ 8}}, {{170},{ 8}}, {{106},{ 8}}, {{234},{ 8}},
-{{ 26},{ 8}}, {{154},{ 8}}, {{ 90},{ 8}}, {{218},{ 8}}, {{ 58},{ 8}},
-{{186},{ 8}}, {{122},{ 8}}, {{250},{ 8}}, {{ 6},{ 8}}, {{134},{ 8}},
-{{ 70},{ 8}}, {{198},{ 8}}, {{ 38},{ 8}}, {{166},{ 8}}, {{102},{ 8}},
-{{230},{ 8}}, {{ 22},{ 8}}, {{150},{ 8}}, {{ 86},{ 8}}, {{214},{ 8}},
-{{ 54},{ 8}}, {{182},{ 8}}, {{118},{ 8}}, {{246},{ 8}}, {{ 14},{ 8}},
-{{142},{ 8}}, {{ 78},{ 8}}, {{206},{ 8}}, {{ 46},{ 8}}, {{174},{ 8}},
-{{110},{ 8}}, {{238},{ 8}}, {{ 30},{ 8}}, {{158},{ 8}}, {{ 94},{ 8}},
-{{222},{ 8}}, {{ 62},{ 8}}, {{190},{ 8}}, {{126},{ 8}}, {{254},{ 8}},
-{{ 1},{ 8}}, {{129},{ 8}}, {{ 65},{ 8}}, {{193},{ 8}}, {{ 33},{ 8}},
-{{161},{ 8}}, {{ 97},{ 8}}, {{225},{ 8}}, {{ 17},{ 8}}, {{145},{ 8}},
-{{ 81},{ 8}}, {{209},{ 8}}, {{ 49},{ 8}}, {{177},{ 8}}, {{113},{ 8}},
-{{241},{ 8}}, {{ 9},{ 8}}, {{137},{ 8}}, {{ 73},{ 8}}, {{201},{ 8}},
-{{ 41},{ 8}}, {{169},{ 8}}, {{105},{ 8}}, {{233},{ 8}}, {{ 25},{ 8}},
-{{153},{ 8}}, {{ 89},{ 8}}, {{217},{ 8}}, {{ 57},{ 8}}, {{185},{ 8}},
-{{121},{ 8}}, {{249},{ 8}}, {{ 5},{ 8}}, {{133},{ 8}}, {{ 69},{ 8}},
-{{197},{ 8}}, {{ 37},{ 8}}, {{165},{ 8}}, {{101},{ 8}}, {{229},{ 8}},
-{{ 21},{ 8}}, {{149},{ 8}}, {{ 85},{ 8}}, {{213},{ 8}}, {{ 53},{ 8}},
-{{181},{ 8}}, {{117},{ 8}}, {{245},{ 8}}, {{ 13},{ 8}}, {{141},{ 8}},
-{{ 77},{ 8}}, {{205},{ 8}}, {{ 45},{ 8}}, {{173},{ 8}}, {{109},{ 8}},
-{{237},{ 8}}, {{ 29},{ 8}}, {{157},{ 8}}, {{ 93},{ 8}}, {{221},{ 8}},
-{{ 61},{ 8}}, {{189},{ 8}}, {{125},{ 8}}, {{253},{ 8}}, {{ 19},{ 9}},
-{{275},{ 9}}, {{147},{ 9}}, {{403},{ 9}}, {{ 83},{ 9}}, {{339},{ 9}},
-{{211},{ 9}}, {{467},{ 9}}, {{ 51},{ 9}}, {{307},{ 9}}, {{179},{ 9}},
-{{435},{ 9}}, {{115},{ 9}}, {{371},{ 9}}, {{243},{ 9}}, {{499},{ 9}},
-{{ 11},{ 9}}, {{267},{ 9}}, {{139},{ 9}}, {{395},{ 9}}, {{ 75},{ 9}},
-{{331},{ 9}}, {{203},{ 9}}, {{459},{ 9}}, {{ 43},{ 9}}, {{299},{ 9}},
-{{171},{ 9}}, {{427},{ 9}}, {{107},{ 9}}, {{363},{ 9}}, {{235},{ 9}},
-{{491},{ 9}}, {{ 27},{ 9}}, {{283},{ 9}}, {{155},{ 9}}, {{411},{ 9}},
-{{ 91},{ 9}}, {{347},{ 9}}, {{219},{ 9}}, {{475},{ 9}}, {{ 59},{ 9}},
-{{315},{ 9}}, {{187},{ 9}}, {{443},{ 9}}, {{123},{ 9}}, {{379},{ 9}},
-{{251},{ 9}}, {{507},{ 9}}, {{ 7},{ 9}}, {{263},{ 9}}, {{135},{ 9}},
-{{391},{ 9}}, {{ 71},{ 9}}, {{327},{ 9}}, {{199},{ 9}}, {{455},{ 9}},
-{{ 39},{ 9}}, {{295},{ 9}}, {{167},{ 9}}, {{423},{ 9}}, {{103},{ 9}},
-{{359},{ 9}}, {{231},{ 9}}, {{487},{ 9}}, {{ 23},{ 9}}, {{279},{ 9}},
-{{151},{ 9}}, {{407},{ 9}}, {{ 87},{ 9}}, {{343},{ 9}}, {{215},{ 9}},
-{{471},{ 9}}, {{ 55},{ 9}}, {{311},{ 9}}, {{183},{ 9}}, {{439},{ 9}},
-{{119},{ 9}}, {{375},{ 9}}, {{247},{ 9}}, {{503},{ 9}}, {{ 15},{ 9}},
-{{271},{ 9}}, {{143},{ 9}}, {{399},{ 9}}, {{ 79},{ 9}}, {{335},{ 9}},
-{{207},{ 9}}, {{463},{ 9}}, {{ 47},{ 9}}, {{303},{ 9}}, {{175},{ 9}},
-{{431},{ 9}}, {{111},{ 9}}, {{367},{ 9}}, {{239},{ 9}}, {{495},{ 9}},
-{{ 31},{ 9}}, {{287},{ 9}}, {{159},{ 9}}, {{415},{ 9}}, {{ 95},{ 9}},
-{{351},{ 9}}, {{223},{ 9}}, {{479},{ 9}}, {{ 63},{ 9}}, {{319},{ 9}},
-{{191},{ 9}}, {{447},{ 9}}, {{127},{ 9}}, {{383},{ 9}}, {{255},{ 9}},
-{{511},{ 9}}, {{ 0},{ 7}}, {{ 64},{ 7}}, {{ 32},{ 7}}, {{ 96},{ 7}},
-{{ 16},{ 7}}, {{ 80},{ 7}}, {{ 48},{ 7}}, {{112},{ 7}}, {{ 8},{ 7}},
-{{ 72},{ 7}}, {{ 40},{ 7}}, {{104},{ 7}}, {{ 24},{ 7}}, {{ 88},{ 7}},
-{{ 56},{ 7}}, {{120},{ 7}}, {{ 4},{ 7}}, {{ 68},{ 7}}, {{ 36},{ 7}},
-{{100},{ 7}}, {{ 20},{ 7}}, {{ 84},{ 7}}, {{ 52},{ 7}}, {{116},{ 7}},
-{{ 3},{ 8}}, {{131},{ 8}}, {{ 67},{ 8}}, {{195},{ 8}}, {{ 35},{ 8}},
-{{163},{ 8}}, {{ 99},{ 8}}, {{227},{ 8}}
-};
-
-local const ct_data static_dtree[D_CODES] = {
-{{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}},
-{{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}},
-{{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}},
-{{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}},
-{{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}},
-{{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}}
-};
-
-const uch _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,
-11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
-12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13,
-13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
-13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
-14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
-14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
-14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15,
-15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
-15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
-15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17,
-18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22,
-23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
-24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
-26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
-26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27,
-27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
-27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
-28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
-29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
-29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
-29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29
-};
-
-const uch _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,
-19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
-21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22,
-22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23,
-23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
-24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
-25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
-25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26,
-26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
-26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
-27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28
-};
-
-local const int base_length[LENGTH_CODES] = {
-0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56,
-64, 80, 96, 112, 128, 160, 192, 224, 0
-};
-
-local const int base_dist[D_CODES] = {
- 0, 1, 2, 3, 4, 6, 8, 12, 16, 24,
- 32, 48, 64, 96, 128, 192, 256, 384, 512, 768,
- 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576
-};
-
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/uncompr.c Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,85 +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.
- */
-
-/* uncompr.c -- decompress a memory buffer
- * Copyright (C) 1995-2003 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* @(#) $Id$ */
-
-#define ZLIB_INTERNAL
-#include "zlib.h"
-
-/* ===========================================================================
- 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.
-*/
-int ZEXPORT uncompress (dest, destLen, source, sourceLen)
- Bytef *dest;
- uLongf *destLen;
- const Bytef *source;
- uLong sourceLen;
-{
- z_stream stream;
- int err;
-
- stream.next_in = (Bytef*)source;
- stream.avail_in = (uInt)sourceLen;
- /* Check for source > 64K on 16-bit machine: */
- if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
-
- stream.next_out = dest;
- stream.avail_out = (uInt)*destLen;
- if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
-
- stream.zalloc = (alloc_func)0;
- stream.zfree = (free_func)0;
-
- err = inflateInit(&stream);
- if (err != Z_OK) return err;
-
- err = inflate(&stream, Z_FINISH);
- if (err != Z_STREAM_END) {
- inflateEnd(&stream);
- if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0))
- return Z_DATA_ERROR;
- return err;
- }
- *destLen = (uLong)stream.total_out;
-
- err = inflateEnd(&stream);
- return err;
-}
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/zadler32.c Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,173 +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.
- */
-
-/* adler32.c -- compute the Adler-32 checksum of a data stream
- * Copyright (C) 1995-2004 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* @(#) $Id$ */
-
-#define ZLIB_INTERNAL
-#include "zlib.h"
-
-#define BASE 65521UL /* largest prime smaller than 65536 */
-#define NMAX 5552
-/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
-
-#define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;}
-#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1);
-#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2);
-#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4);
-#define DO16(buf) DO8(buf,0); DO8(buf,8);
-
-/* use NO_DIVIDE if your processor does not do division in hardware */
-#ifdef NO_DIVIDE
-# define MOD(a) \
- do { \
- if (a >= (BASE << 16)) a -= (BASE << 16); \
- if (a >= (BASE << 15)) a -= (BASE << 15); \
- if (a >= (BASE << 14)) a -= (BASE << 14); \
- if (a >= (BASE << 13)) a -= (BASE << 13); \
- if (a >= (BASE << 12)) a -= (BASE << 12); \
- if (a >= (BASE << 11)) a -= (BASE << 11); \
- if (a >= (BASE << 10)) a -= (BASE << 10); \
- if (a >= (BASE << 9)) a -= (BASE << 9); \
- if (a >= (BASE << 8)) a -= (BASE << 8); \
- if (a >= (BASE << 7)) a -= (BASE << 7); \
- if (a >= (BASE << 6)) a -= (BASE << 6); \
- if (a >= (BASE << 5)) a -= (BASE << 5); \
- if (a >= (BASE << 4)) a -= (BASE << 4); \
- if (a >= (BASE << 3)) a -= (BASE << 3); \
- if (a >= (BASE << 2)) a -= (BASE << 2); \
- if (a >= (BASE << 1)) a -= (BASE << 1); \
- if (a >= BASE) a -= BASE; \
- } while (0)
-# define MOD4(a) \
- do { \
- if (a >= (BASE << 4)) a -= (BASE << 4); \
- if (a >= (BASE << 3)) a -= (BASE << 3); \
- if (a >= (BASE << 2)) a -= (BASE << 2); \
- if (a >= (BASE << 1)) a -= (BASE << 1); \
- if (a >= BASE) a -= BASE; \
- } while (0)
-#else
-# define MOD(a) a %= BASE
-# define MOD4(a) a %= BASE
-#endif
-
-/* ========================================================================= */
-uLong ZEXPORT adler32(adler, buf, len)
- uLong adler;
- const Bytef *buf;
- uInt len;
-{
- unsigned long sum2;
- unsigned n;
-
- /* split Adler-32 into component sums */
- sum2 = (adler >> 16) & 0xffff;
- adler &= 0xffff;
-
- /* in case user likes doing a byte at a time, keep it fast */
- if (len == 1) {
- adler += buf[0];
- if (adler >= BASE)
- adler -= BASE;
- sum2 += adler;
- if (sum2 >= BASE)
- sum2 -= BASE;
- return adler | (sum2 << 16);
- }
-
- /* initial Adler-32 value (deferred check for len == 1 speed) */
- if (buf == Z_NULL)
- return 1L;
-
- /* in case short lengths are provided, keep it somewhat fast */
- if (len < 16) {
- while (len--) {
- adler += *buf++;
- sum2 += adler;
- }
- if (adler >= BASE)
- adler -= BASE;
- MOD4(sum2); /* only added so many BASE's */
- return adler | (sum2 << 16);
- }
-
- /* do length NMAX blocks -- requires just one modulo operation */
- while (len >= NMAX) {
- len -= NMAX;
- n = NMAX / 16; /* NMAX is divisible by 16 */
- do {
- DO16(buf); /* 16 sums unrolled */
- buf += 16;
- } while (--n);
- MOD(adler);
- MOD(sum2);
- }
-
- /* do remaining bytes (less than NMAX, still just one modulo) */
- if (len) { /* avoid modulos if none remaining */
- while (len >= 16) {
- len -= 16;
- DO16(buf);
- buf += 16;
- }
- while (len--) {
- adler += *buf++;
- sum2 += adler;
- }
- MOD(adler);
- MOD(sum2);
- }
-
- /* return recombined sums */
- return adler | (sum2 << 16);
-}
-
-/* ========================================================================= */
-uLong ZEXPORT adler32_combine(adler1, adler2, len2)
- uLong adler1;
- uLong adler2;
- z_off_t len2;
-{
- unsigned long sum1;
- unsigned long sum2;
- unsigned rem;
-
- /* the derivation of this formula is left as an exercise for the reader */
- rem = (unsigned)(len2 % BASE);
- sum1 = adler1 & 0xffff;
- sum2 = rem * sum1;
- 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;
- return sum1 | (sum2 << 16);
-}
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/zconf.h Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,363 +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.
- */
-
-/* zconf.h -- configuration of the zlib compression library
- * Copyright (C) 1995-2005 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* @(#) $Id$ */
-
-#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.
- */
-#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
-# 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 get_crc_table z_get_crc_table
-# define zError z_zError
-
-# define alloc_func z_alloc_func
-# define free_func z_free_func
-# define in_func z_in_func
-# define out_func z_out_func
-# define Byte z_Byte
-# define uInt z_uInt
-# define uLong z_uLong
-# define Bytef z_Bytef
-# define charf z_charf
-# define intf z_intf
-# define uIntf z_uIntf
-# define uLongf z_uLongf
-# define voidpf z_voidpf
-# define voidp z_voidp
-#endif
-
-#if defined(__MSDOS__) && !defined(MSDOS)
-# define MSDOS
-#endif
-#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)
-# define OS2
-#endif
-#if defined(_WINDOWS) && !defined(WINDOWS)
-# define WINDOWS
-#endif
-#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)
-# ifndef WIN32
-# define WIN32
-# endif
-#endif
-#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)
-# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)
-# ifndef SYS16BIT
-# define SYS16BIT
-# endif
-# endif
-#endif
-
-/*
- * Compile with -DMAXSEG_64K if the alloc function cannot allocate more
- * than 64k bytes at a time (needed on systems with 16-bit int).
- */
-#ifdef SYS16BIT
-# define MAXSEG_64K
-#endif
-#ifdef MSDOS
-# define UNALIGNED_OK
-#endif
-
-#ifdef __STDC_VERSION__
-# ifndef STDC
-# define STDC
-# endif
-# if __STDC_VERSION__ >= 199901L
-# ifndef STDC99
-# define STDC99
-# endif
-# endif
-#endif
-#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
-# define STDC
-#endif
-#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
-# define STDC
-#endif
-#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))
-# define STDC
-#endif
-#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))
-# define STDC
-#endif
-
-#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */
-# define STDC
-#endif
-
-#ifndef STDC
-# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
-# define const /* note: need a more gentle solution here */
-# endif
-#endif
-
-/* Some Mac compilers merge all .h files incorrectly: */
-#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)
-# define NO_DUMMY_DECL
-#endif
-
-/* Maximum value for memLevel in deflateInit2 */
-#ifndef MAX_MEM_LEVEL
-# ifdef MAXSEG_64K
-# define MAX_MEM_LEVEL 8
-# else
-# define MAX_MEM_LEVEL 9
-# endif
-#endif
-
-/* Maximum value for windowBits in deflateInit2 and inflateInit2.
- * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
- * created by gzip. (Files created by minigzip can still be extracted by
- * gzip.)
- */
-#ifndef MAX_WBITS
-# define MAX_WBITS 15 /* 32K LZ77 window */
-#endif
-
-/* The memory requirements for deflate are (in bytes):
- (1 << (windowBits+2)) + (1 << (memLevel+9))
- that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
- plus a few kilobytes for small objects. For example, if you want to reduce
- the default memory requirements from 256K to 128K, compile with
- make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
- Of course this will generally degrade compression (there's no free lunch).
-
- The memory requirements for inflate are (in bytes) 1 << windowBits
- that is, 32K for windowBits=15 (default value) plus a few kilobytes
- for small objects.
-*/
-
- /* Type declarations */
-
-#ifndef OF /* function prototypes */
-# ifdef STDC
-# define OF(args) args
-# else
-# define OF(args) ()
-# endif
-#endif
-
-/* The following definitions for FAR are needed only for MSDOS mixed
- * model programming (small or medium model with some far allocations).
- * This was tested only with MSC; for other MSDOS compilers you may have
- * to define NO_MEMCPY in zutil.h. If you don't need the mixed model,
- * just define FAR to be empty.
- */
-#ifdef SYS16BIT
-# if defined(M_I86SM) || defined(M_I86MM)
- /* MSC small or medium model */
-# define SMALL_MEDIUM
-# ifdef _MSC_VER
-# define FAR _far
-# else
-# define FAR far
-# endif
-# endif
-# if (defined(__SMALL__) || defined(__MEDIUM__))
- /* Turbo C small or medium model */
-# define SMALL_MEDIUM
-# ifdef __BORLANDC__
-# define FAR _far
-# else
-# define FAR far
-# endif
-# endif
-#endif
-
-#if defined(WINDOWS) || defined(WIN32)
- /* If building or using zlib as a DLL, define ZLIB_DLL.
- * This is not mandatory, but it offers a little performance increase.
- */
-# ifdef ZLIB_DLL
-# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
-# ifdef ZLIB_INTERNAL
-# define ZEXTERN extern __declspec(dllexport)
-# else
-# define ZEXTERN extern __declspec(dllimport)
-# endif
-# endif
-# endif /* ZLIB_DLL */
- /* If building or using zlib with the WINAPI/WINAPIV calling convention,
- * define ZLIB_WINAPI.
- * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
- */
-# ifdef ZLIB_WINAPI
-# ifdef FAR
-# undef FAR
-# endif
-# include <windows.h>
- /* No need for _export, use ZLIB.DEF instead. */
- /* For complete Windows compatibility, use WINAPI, not __stdcall. */
-# define ZEXPORT WINAPI
-# ifdef WIN32
-# define ZEXPORTVA WINAPIV
-# else
-# define ZEXPORTVA FAR CDECL
-# endif
-# endif
-#endif
-
-#if defined (__BEOS__)
-# ifdef ZLIB_DLL
-# ifdef ZLIB_INTERNAL
-# define ZEXPORT __declspec(dllexport)
-# define ZEXPORTVA __declspec(dllexport)
-# else
-# define ZEXPORT __declspec(dllimport)
-# define ZEXPORTVA __declspec(dllimport)
-# endif
-# endif
-#endif
-
-#ifndef ZEXTERN
-# define ZEXTERN extern
-#endif
-#ifndef ZEXPORT
-# define ZEXPORT
-#endif
-#ifndef ZEXPORTVA
-# define ZEXPORTVA
-#endif
-
-#ifndef FAR
-# define FAR
-#endif
-
-#if !defined(__MACTYPES__)
-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 */
-# define Bytef Byte FAR
-#else
- typedef Byte FAR Bytef;
-#endif
-typedef char FAR charf;
-typedef int FAR intf;
-typedef uInt FAR uIntf;
-typedef uLong FAR uLongf;
-
-#ifdef STDC
- typedef void const *voidpc;
- typedef void FAR *voidpf;
- typedef void *voidp;
-#else
- typedef Byte const *voidpc;
- typedef Byte FAR *voidpf;
- 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
-#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(__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")
-#endif
-
-#endif /* ZCONF_H */
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/zcrc32.c Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,447 +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.
- */
-
-/* crc32.c -- compute the CRC-32 of a data stream
- * Copyright (C) 1995-2005 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
- * CRC methods: exclusive-oring 32 bits of data at a time, and pre-computing
- * tables for updating the shift register in one step with three exclusive-ors
- * instead of four steps with four exclusive-ors. This results in about a
- * factor of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3.
- */
-
-/* @(#) $Id$ */
-
-/*
- Note on the use of DYNAMIC_CRC_TABLE: there is no mutex or semaphore
- protection on the static variables used to control the first-use generation
- of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should
- first call get_crc_table() to initialize the tables before allowing more than
- one thread to use crc32().
- */
-
-#ifdef MAKECRCH
-# include <stdio.h>
-# ifndef DYNAMIC_CRC_TABLE
-# define DYNAMIC_CRC_TABLE
-# endif /* !DYNAMIC_CRC_TABLE */
-#endif /* MAKECRCH */
-
-#include "zutil.h" /* for STDC and FAR definitions */
-
-#define local static
-
-/* Find a four-byte integer type for crc32_little() and crc32_big(). */
-#ifndef NOBYFOUR
-# ifdef STDC /* need ANSI C limits.h to determine sizes */
-# include <limits.h>
-# define BYFOUR
-# if (UINT_MAX == 0xffffffffUL)
- typedef unsigned int u4;
-# else
-# if (ULONG_MAX == 0xffffffffUL)
- typedef unsigned long u4;
-# else
-# if (USHRT_MAX == 0xffffffffUL)
- typedef unsigned short u4;
-# else
-# undef BYFOUR /* can't find a four-byte integer type! */
-# endif
-# endif
-# endif
-# endif /* STDC */
-#endif /* !NOBYFOUR */
-
-/* Definitions for doing the crc four data bytes at a time. */
-#ifdef BYFOUR
-# define REV(w) (((w)>>24)+(((w)>>8)&0xff00)+ \
- (((w)&0xff00)<<8)+(((w)&0xff)<<24))
- local unsigned long crc32_little OF((unsigned long,
- const unsigned char FAR *, unsigned));
- local unsigned long crc32_big OF((unsigned long,
- const unsigned char FAR *, unsigned));
-# define TBLS 8
-#else
-# define TBLS 1
-#endif /* BYFOUR */
-
-/* Local functions for crc concatenation */
-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));
-
-#ifdef DYNAMIC_CRC_TABLE
-
-local volatile int crc_table_empty = 1;
-local unsigned long FAR crc_table[TBLS][256];
-local void make_crc_table OF((void));
-#ifdef MAKECRCH
- local void write_table OF((FILE *, const unsigned long FAR *));
-#endif /* MAKECRCH */
-/*
- Generate tables for a byte-wise 32-bit CRC calculation on the polynomial:
- x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1.
-
- Polynomials over GF(2) are represented in binary, one bit per coefficient,
- with the lowest powers in the most significant bit. Then adding polynomials
- is just exclusive-or, and multiplying a polynomial by x is a right shift by
- one. If we call the above polynomial p, and represent a byte as the
- polynomial q, also with the lowest power in the most significant bit (so the
- byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p,
- where a mod b means the remainder after dividing a by b.
-
- This calculation is done using the shift-register method of multiplying and
- taking the remainder. The register is initialized to zero, and for each
- incoming bit, x^32 is added mod p to the register if the bit is a one (where
- x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by
- x (which is shifting right by one and adding x^32 mod p if the bit shifted
- out is a one). We start with the highest power (least significant bit) of
- q and repeat for all eight bits of q.
-
- The first table is simply the CRC of all possible eight bit values. This is
- all the information needed to generate CRCs on data a byte at a time for all
- combinations of CRC register values and incoming bytes. The remaining tables
- allow for word-at-a-time CRC calculation for both big-endian and little-
- endian machines, where a word is four bytes.
-*/
-local void make_crc_table()
-{
- unsigned long c;
- int n, k;
- unsigned long poly; /* polynomial exclusive-or pattern */
- /* terms of polynomial defining this crc (except x^32): */
- static volatile int first = 1; /* flag to limit concurrent making */
- static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
-
- /* See if another task is already doing this (not thread-safe, but better
- than nothing -- significantly reduces duration of vulnerability in
- case the advice about DYNAMIC_CRC_TABLE is ignored) */
- if (first) {
- first = 0;
-
- /* make exclusive-or pattern from polynomial (0xedb88320UL) */
- poly = 0UL;
- for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++)
- poly |= 1UL << (31 - p[n]);
-
- /* generate a crc for every 8-bit value */
- for (n = 0; n < 256; n++) {
- c = (unsigned long)n;
- for (k = 0; k < 8; k++)
- c = c & 1 ? poly ^ (c >> 1) : c >> 1;
- crc_table[0][n] = c;
- }
-
-#ifdef BYFOUR
- /* generate crc for each value followed by one, two, and three zeros,
- and then the byte reversal of those as well as the first table */
- for (n = 0; n < 256; n++) {
- c = crc_table[0][n];
- crc_table[4][n] = REV(c);
- for (k = 1; k < 4; k++) {
- c = crc_table[0][c & 0xff] ^ (c >> 8);
- crc_table[k][n] = c;
- crc_table[k + 4][n] = REV(c);
- }
- }
-#endif /* BYFOUR */
-
- crc_table_empty = 0;
- }
- else { /* not first */
- /* wait for the other guy to finish (not efficient, but rare) */
- while (crc_table_empty)
- ;
- }
-
-#ifdef MAKECRCH
- /* write out CRC tables to crc32.h */
- {
- FILE *out;
-
- out = fopen("crc32.h", "w");
- if (out == NULL) return;
- fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n");
- fprintf(out, " * Generated automatically by crc32.c\n */\n\n");
- fprintf(out, "local const unsigned long FAR ");
- fprintf(out, "crc_table[TBLS][256] =\n{\n {\n");
- write_table(out, crc_table[0]);
-# ifdef BYFOUR
- fprintf(out, "#ifdef BYFOUR\n");
- for (k = 1; k < 8; k++) {
- fprintf(out, " },\n {\n");
- write_table(out, crc_table[k]);
- }
- fprintf(out, "#endif\n");
-# endif /* BYFOUR */
- fprintf(out, " }\n};\n");
- fclose(out);
- }
-#endif /* MAKECRCH */
-}
-
-#ifdef MAKECRCH
-local void write_table(out, table)
- FILE *out;
- const unsigned long FAR *table;
-{
- int n;
-
- for (n = 0; n < 256; n++)
- fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : " ", table[n],
- n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", "));
-}
-#endif /* MAKECRCH */
-
-#else /* !DYNAMIC_CRC_TABLE */
-/* ========================================================================
- * Tables of CRC-32s of all single-byte values, made by make_crc_table().
- */
-#include "crc32.h"
-#endif /* DYNAMIC_CRC_TABLE */
-
-/* =========================================================================
- * This function can be used by asm versions of crc32()
- */
-const unsigned long FAR * ZEXPORT get_crc_table()
-{
-#ifdef DYNAMIC_CRC_TABLE
- if (crc_table_empty)
- make_crc_table();
-#endif /* DYNAMIC_CRC_TABLE */
- return (const unsigned long FAR *)crc_table;
-}
-
-/* ========================================================================= */
-#define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8)
-#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1
-
-/* ========================================================================= */
-uLong ZEXPORT crc32(crc, buf, len)
- uLong crc;
- const unsigned char FAR *buf;
- unsigned len;
-{
- if (buf == Z_NULL) return 0UL;
-
-#ifdef DYNAMIC_CRC_TABLE
- if (crc_table_empty)
- make_crc_table();
-#endif /* DYNAMIC_CRC_TABLE */
-
-#ifdef BYFOUR
- if (sizeof(void *) == sizeof(ptrdiff_t)) {
- u4 endian;
-
- endian = 1;
- if (*((unsigned char *)(&endian)))
- return (uLong)crc32_little(crc, buf, len);
- else
- return (uLong)crc32_big(crc, buf, len);
- }
-#endif /* BYFOUR */
- crc = crc ^ 0xffffffffUL;
- while (len >= 8) {
- DO8;
- len -= 8;
- }
- if (len) do {
- DO1;
- } while (--len);
- return crc ^ 0xffffffffUL;
-}
-
-#ifdef BYFOUR
-
-/* ========================================================================= */
-#define DOLIT4 c ^= *buf4++; \
- c = crc_table[3][c & 0xff] ^ crc_table[2][(c >> 8) & 0xff] ^ \
- crc_table[1][(c >> 16) & 0xff] ^ crc_table[0][c >> 24]
-#define DOLIT32 DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4
-
-/* ========================================================================= */
-local unsigned long crc32_little(crc, buf, len)
- unsigned long crc;
- const unsigned char FAR *buf;
- unsigned len;
-{
- register u4 c;
- register const u4 FAR *buf4;
-
- c = (u4)crc;
- c = ~c;
- while (len && ((ptrdiff_t)buf & 3)) {
- c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);
- len--;
- }
-
- buf4 = (const u4 FAR *)(const void FAR *)buf;
- while (len >= 32) {
- DOLIT32;
- len -= 32;
- }
- while (len >= 4) {
- DOLIT4;
- len -= 4;
- }
- buf = (const unsigned char FAR *)buf4;
-
- if (len) do {
- c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);
- } while (--len);
- c = ~c;
- return (unsigned long)c;
-}
-
-/* ========================================================================= */
-#define DOBIG4 c ^= *++buf4; \
- c = crc_table[4][c & 0xff] ^ crc_table[5][(c >> 8) & 0xff] ^ \
- crc_table[6][(c >> 16) & 0xff] ^ crc_table[7][c >> 24]
-#define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4
-
-/* ========================================================================= */
-local unsigned long crc32_big(crc, buf, len)
- unsigned long crc;
- const unsigned char FAR *buf;
- unsigned len;
-{
- register u4 c;
- register const u4 FAR *buf4;
-
- c = REV((u4)crc);
- c = ~c;
- while (len && ((ptrdiff_t)buf & 3)) {
- c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
- len--;
- }
-
- buf4 = (const u4 FAR *)(const void FAR *)buf;
- buf4--;
- while (len >= 32) {
- DOBIG32;
- len -= 32;
- }
- while (len >= 4) {
- DOBIG4;
- len -= 4;
- }
- buf4++;
- buf = (const unsigned char FAR *)buf4;
-
- if (len) do {
- c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
- } while (--len);
- c = ~c;
- return (unsigned long)(REV(c));
-}
-
-#endif /* BYFOUR */
-
-#define GF2_DIM 32 /* dimension of GF(2) vectors (length of CRC) */
-
-/* ========================================================================= */
-local unsigned long gf2_matrix_times(mat, vec)
- unsigned long *mat;
- unsigned long vec;
-{
- unsigned long sum;
-
- sum = 0;
- while (vec) {
- if (vec & 1)
- sum ^= *mat;
- vec >>= 1;
- mat++;
- }
- return sum;
-}
-
-/* ========================================================================= */
-local void gf2_matrix_square(square, mat)
- unsigned long *square;
- unsigned long *mat;
-{
- int n;
-
- for (n = 0; n < GF2_DIM; n++)
- square[n] = gf2_matrix_times(mat, mat[n]);
-}
-
-/* ========================================================================= */
-uLong ZEXPORT crc32_combine(crc1, crc2, len2)
- uLong crc1;
- uLong crc2;
- z_off_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)
- return crc1;
-
- /* put operator for one zero bit in odd */
- odd[0] = 0xedb88320UL; /* CRC-32 polynomial */
- row = 1;
- for (n = 1; n < GF2_DIM; n++) {
- odd[n] = row;
- row <<= 1;
- }
-
- /* put operator for two zero bits in even */
- gf2_matrix_square(even, odd);
-
- /* put operator for four zero bits in odd */
- gf2_matrix_square(odd, even);
-
- /* apply len2 zeros to crc1 (first square will put the operator for one
- zero byte, eight zero bits, in even) */
- do {
- /* apply zeros operator for this bit of len2 */
- gf2_matrix_square(even, odd);
- if (len2 & 1)
- crc1 = gf2_matrix_times(even, crc1);
- len2 >>= 1;
-
- /* if no more bits set, then done */
- if (len2 == 0)
- break;
-
- /* another iteration of the loop with odd and even swapped */
- gf2_matrix_square(odd, even);
- if (len2 & 1)
- crc1 = gf2_matrix_times(odd, crc1);
- len2 >>= 1;
-
- /* if no more bits set, then done */
- } while (len2 != 0);
-
- /* return combined crc */
- crc1 ^= crc2;
- return crc1;
-}
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/zlib.h Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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 */
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/zutil.c Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,342 +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.
- */
-
-/* zutil.c -- target dependent utility functions for the compression library
- * Copyright (C) 1995-2005 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* @(#) $Id$ */
-
-#include "zutil.h"
-
-#ifndef NO_DUMMY_DECL
-struct internal_state {int dummy;}; /* for buggy compilers */
-#endif
-
-const char * const z_errmsg[10] = {
-"need dictionary", /* Z_NEED_DICT 2 */
-"stream end", /* Z_STREAM_END 1 */
-"", /* Z_OK 0 */
-"file error", /* Z_ERRNO (-1) */
-"stream error", /* Z_STREAM_ERROR (-2) */
-"data error", /* Z_DATA_ERROR (-3) */
-"insufficient memory", /* Z_MEM_ERROR (-4) */
-"buffer error", /* Z_BUF_ERROR (-5) */
-"incompatible version",/* Z_VERSION_ERROR (-6) */
-""};
-
-
-const char * ZEXPORT zlibVersion()
-{
- return ZLIB_VERSION;
-}
-
-uLong ZEXPORT zlibCompileFlags()
-{
- uLong flags;
-
- flags = 0;
- switch (sizeof(uInt)) {
- case 2: break;
- case 4: flags += 1; break;
- case 8: flags += 2; break;
- default: flags += 3;
- }
- switch (sizeof(uLong)) {
- case 2: break;
- case 4: flags += 1 << 2; break;
- case 8: flags += 2 << 2; break;
- default: flags += 3 << 2;
- }
- switch (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)) {
- case 2: break;
- case 4: flags += 1 << 6; break;
- case 8: flags += 2 << 6; break;
- default: flags += 3 << 6;
- }
-#ifdef DEBUG
- flags += 1 << 8;
-#endif
-#if defined(ASMV) || defined(ASMINF)
- flags += 1 << 9;
-#endif
-#ifdef ZLIB_WINAPI
- flags += 1 << 10;
-#endif
-#ifdef BUILDFIXED
- flags += 1 << 12;
-#endif
-#ifdef DYNAMIC_CRC_TABLE
- flags += 1 << 13;
-#endif
-#ifdef NO_GZCOMPRESS
- flags += 1L << 16;
-#endif
-#ifdef NO_GZIP
- flags += 1L << 17;
-#endif
-#ifdef PKZIP_BUG_WORKAROUND
- flags += 1L << 20;
-#endif
-#ifdef FASTEST
- flags += 1L << 21;
-#endif
-#ifdef STDC
-# ifdef NO_vsnprintf
- flags += 1L << 25;
-# ifdef HAS_vsprintf_void
- flags += 1L << 26;
-# endif
-# else
-# ifdef HAS_vsnprintf_void
- flags += 1L << 26;
-# endif
-# endif
-#else
- flags += 1L << 24;
-# ifdef NO_snprintf
- flags += 1L << 25;
-# ifdef HAS_sprintf_void
- flags += 1L << 26;
-# endif
-# else
-# ifdef HAS_snprintf_void
- flags += 1L << 26;
-# endif
-# endif
-#endif
- return flags;
-}
-
-#ifdef DEBUG
-
-# ifndef verbose
-# define verbose 0
-# endif
-int z_verbose = verbose;
-
-void z_error (m)
- char *m;
-{
- fprintf(stderr, "%s\n", m);
- exit(1);
-}
-#endif
-
-/* exported to allow conversion of error code to string for compress() and
- * uncompress()
- */
-const char * ZEXPORT zError(err)
- int err;
-{
- return ERR_MSG(err);
-}
-
-#if defined(_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.
- */
- int errno = 0;
-#endif
-
-#ifndef HAVE_MEMCPY
-
-void zmemcpy(dest, source, len)
- Bytef* dest;
- const Bytef* source;
- uInt len;
-{
- if (len == 0) return;
- do {
- *dest++ = *source++; /* ??? to be unrolled */
- } while (--len != 0);
-}
-
-int zmemcmp(s1, s2, len)
- const Bytef* s1;
- const Bytef* s2;
- uInt len;
-{
- uInt j;
-
- for (j = 0; j < len; j++) {
- if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1;
- }
- return 0;
-}
-
-void zmemzero(dest, len)
- Bytef* dest;
- uInt len;
-{
- if (len == 0) return;
- do {
- *dest++ = 0; /* ??? to be unrolled */
- } while (--len != 0);
-}
-#endif
-
-
-#ifdef SYS16BIT
-
-#ifdef __TURBOC__
-/* Turbo C in 16-bit mode */
-
-# define MY_ZCALLOC
-
-/* Turbo C malloc() does not allow dynamic allocation of 64K bytes
- * and farmalloc(64K) returns a pointer with an offset of 8, so we
- * must fix the pointer. Warning: the pointer must be put back to its
- * original form in order to free it, use zcfree().
- */
-
-#define MAX_PTR 10
-/* 10*64K = 640K */
-
-local int next_ptr = 0;
-
-typedef struct ptr_table_s {
- voidpf org_ptr;
- voidpf new_ptr;
-} ptr_table;
-
-local ptr_table table[MAX_PTR];
-/* This table is used to remember the original form of pointers
- * to large buffers (64K). Such pointers are normalized with a zero offset.
- * Since MSDOS is not a preemptive multitasking OS, this table is not
- * protected from concurrent access. This hack doesn't work anyway on
- * a protected system like OS/2. Use Microsoft C instead.
- */
-
-voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
-{
- voidpf buf = opaque; /* just to make some compilers happy */
- ulg bsize = (ulg)items*size;
-
- /* If we allocate less than 65520 bytes, we assume that farmalloc
- * will return a usable pointer which doesn't have to be normalized.
- */
- if (bsize < 65520L) {
- buf = farmalloc(bsize);
- if (*(ush*)&buf != 0) return buf;
- } else {
- buf = farmalloc(bsize + 16L);
- }
- if (buf == NULL || next_ptr >= MAX_PTR) return NULL;
- table[next_ptr].org_ptr = buf;
-
- /* Normalize the pointer to seg:0 */
- *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4;
- *(ush*)&buf = 0;
- table[next_ptr++].new_ptr = buf;
- return buf;
-}
-
-void zcfree (voidpf opaque, voidpf ptr)
-{
- int n;
- if (*(ush*)&ptr != 0) { /* object < 64K */
- farfree(ptr);
- return;
- }
- /* Find the original pointer */
- for (n = 0; n < next_ptr; n++) {
- if (ptr != table[n].new_ptr) continue;
-
- farfree(table[n].org_ptr);
- while (++n < next_ptr) {
- table[n-1] = table[n];
- }
- next_ptr--;
- return;
- }
- ptr = opaque; /* just to make some compilers happy */
- Assert(0, "zcfree: ptr not found");
-}
-
-#endif /* __TURBOC__ */
-
-
-#ifdef M_I86
-/* Microsoft C in 16-bit mode */
-
-# define MY_ZCALLOC
-
-#if (!defined(_MSC_VER) || (_MSC_VER <= 600))
-# define _halloc halloc
-# define _hfree hfree
-#endif
-
-voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
-{
- if (opaque) opaque = 0; /* to make compiler happy */
- return _halloc((long)items, size);
-}
-
-void zcfree (voidpf opaque, voidpf ptr)
-{
- if (opaque) opaque = 0; /* to make compiler happy */
- _hfree(ptr);
-}
-
-#endif /* M_I86 */
-
-#endif /* SYS16BIT */
-
-
-#ifndef MY_ZCALLOC /* Any system without a special alloc function */
-
-#ifndef STDC
-extern voidp malloc OF((uInt size));
-extern voidp calloc OF((uInt items, uInt size));
-extern void free OF((voidpf ptr));
-#endif
-
-voidpf zcalloc (opaque, items, size)
- voidpf opaque;
- unsigned items;
- unsigned size;
-{
- if (opaque) items += size - size; /* make compiler happy */
- return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) :
- (voidpf)calloc(items, size);
-}
-
-void zcfree (opaque, ptr)
- voidpf opaque;
- voidpf ptr;
-{
- free(ptr);
- if (opaque) return; /* make compiler happy */
-}
-
-#endif /* MY_ZCALLOC */
--- a/jdk/src/share/native/java/util/zip/zlib-1.2.3/zutil.h Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,294 +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.
- */
-
-/* zutil.h -- internal interface and configuration of the compression library
- * Copyright (C) 1995-2005 Jean-loup Gailly.
- * 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.
- */
-
-/* @(#) $Id$ */
-
-#ifndef ZUTIL_H
-#define ZUTIL_H
-
-#define ZLIB_INTERNAL
-#include "zlib.h"
-
-#ifdef STDC
-# ifndef _WIN32_WCE
-# 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
-#endif
-/* compile with -Dlocal if your debugger can't find static symbols */
-
-typedef unsigned char uch;
-typedef uch FAR uchf;
-typedef unsigned short ush;
-typedef ush FAR ushf;
-typedef unsigned long ulg;
-
-extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
-/* (size given to avoid silly warnings with Visual C++) */
-
-#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
-
-#define ERR_RETURN(strm,err) \
- return (strm->msg = (char*)ERR_MSG(err), (err))
-/* To be used only when the state is known to be valid */
-
- /* common constants */
-
-#ifndef DEF_WBITS
-# define DEF_WBITS MAX_WBITS
-#endif
-/* default windowBits for decompression. MAX_WBITS is for compression only */
-
-#if MAX_MEM_LEVEL >= 8
-# define DEF_MEM_LEVEL 8
-#else
-# define DEF_MEM_LEVEL MAX_MEM_LEVEL
-#endif
-/* default memLevel */
-
-#define STORED_BLOCK 0
-#define STATIC_TREES 1
-#define DYN_TREES 2
-/* The three kinds of block type */
-
-#define MIN_MATCH 3
-#define MAX_MATCH 258
-/* The minimum and maximum match lengths */
-
-#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
-
- /* target dependencies */
-
-#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
-# define OS_CODE 0x00
-# if defined(__TURBOC__) || defined(__BORLANDC__)
-# 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 );
-# else
-# include <alloc.h>
-# endif
-# else /* MSC or DJGPP */
-# include <malloc.h>
-# endif
-#endif
-
-#ifdef AMIGA
-# define OS_CODE 0x01
-#endif
-
-#if defined(VAXC) || defined(VMS)
-# define OS_CODE 0x02
-# define F_OPEN(name, mode) \
- fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
-#endif
-
-#if defined(ATARI) || defined(atarist)
-# define OS_CODE 0x05
-#endif
-
-#ifdef OS2
-# define OS_CODE 0x06
-# ifdef M_I86
- #include <malloc.h>
-# endif
-#endif
-
-#if defined(MACOS) || defined(TARGET_OS_MAC)
-# define OS_CODE 0x07
-# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
-# include <unix.h> /* for fdopen */
-# else
-# ifndef fdopen
-# define fdopen(fd,mode) NULL /* No fdopen() */
-# endif
-# endif
-#endif
-
-#ifdef TOPS20
-# define OS_CODE 0x0a
-#endif
-
-#ifdef WIN32
-# ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */
-# define OS_CODE 0x0b
-# endif
-#endif
-
-#ifdef __50SERIES /* Prime/PRIMOS */
-# define OS_CODE 0x0f
-#endif
-
-#if defined(_BEOS_) || defined(RISCOS)
-# define fdopen(fd,mode) NULL /* No fdopen() */
-#endif
-
-#if (defined(_MSC_VER) && (_MSC_VER > 600))
-# if defined(_WIN32_WCE)
-# define fdopen(fd,mode) NULL /* No fdopen() */
-# ifndef _PTRDIFF_T_DEFINED
- typedef int ptrdiff_t;
-# define _PTRDIFF_T_DEFINED
-# endif
-# else
-# define fdopen(fd,type) _fdopen(fd,type)
-# endif
-#endif
-
- /* common defaults */
-
-#ifndef OS_CODE
-# define OS_CODE 0x03 /* assume Unix */
-#endif
-
-#ifndef F_OPEN
-# define F_OPEN(name, mode) fopen((name), (mode))
-#endif
-
- /* functions */
-
-#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550)
-# ifndef HAVE_VSNPRINTF
-# define HAVE_VSNPRINTF
-# endif
-#endif
-#if defined(__CYGWIN__)
-# ifndef HAVE_VSNPRINTF
-# define HAVE_VSNPRINTF
-# endif
-#endif
-#ifndef HAVE_VSNPRINTF
-# ifdef MSDOS
- /* vsnprintf may exist on some MS-DOS compilers (DJGPP?),
- but for now we just assume it doesn't. */
-# define NO_vsnprintf
-# endif
-# ifdef __TURBOC__
-# define NO_vsnprintf
-# 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
-# endif
-# endif
-# ifdef __SASC
-# define NO_vsnprintf
-# endif
-#endif
-#ifdef VMS
-# define NO_vsnprintf
-#endif
-
-#if defined(pyr)
-# define NO_MEMCPY
-#endif
-#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
- /* Use our own functions for small and medium model with MSC <= 5.0.
- * You may have to use the same strategy for Borland C (untested).
- * The __SC__ check is for Symantec.
- */
-# define NO_MEMCPY
-#endif
-#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
-# define HAVE_MEMCPY
-#endif
-#ifdef HAVE_MEMCPY
-# ifdef SMALL_MEDIUM /* MSDOS small or medium model */
-# define zmemcpy _fmemcpy
-# define zmemcmp _fmemcmp
-# define zmemzero(dest, len) _fmemset(dest, 0, len)
-# else
-# define zmemcpy memcpy
-# define zmemcmp memcmp
-# 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));
-#endif
-
-/* Diagnostic functions */
-#ifdef DEBUG
-# include <stdio.h>
- extern int z_verbose;
- extern void 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 ;}
-# define Tracevv(x) {if (z_verbose>1) fprintf x ;}
-# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
-# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
-#else
-# define Assert(cond,msg)
-# define Trace(x)
-# define Tracev(x)
-# define Tracevv(x)
-# define Tracec(c,x)
-# define Tracecv(c,x)
-#endif
-
-
-voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size));
-void zcfree OF((voidpf opaque, voidpf ptr));
-
-#define ZALLOC(strm, items, size) \
- (*((strm)->zalloc))((strm)->opaque, (items), (size))
-#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
-#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
-
-#endif /* ZUTIL_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/ChangeLog Thu Dec 15 15:57:51 2011 -0800
@@ -0,0 +1,1208 @@
+
+ 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)
+- Update testzlib, vstudio, masmx64, and masmx86 in contrib [Vollant]
+
+Changes in 1.2.2.4 (11 July 2005)
+- Add inflatePrime() function for starting inflation at bit boundary
+- Avoid some Visual C warnings in deflate.c
+- Avoid more silly Visual C warnings in inflate.c and inftrees.c for 64-bit
+ compile
+- Fix some spelling errors in comments [Betts]
+- Correct inflateInit2() error return documentation in zlib.h
+- 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]
+- Move declarations of gf2 functions to right place in crc32.c [Oberhumer]
+- Add cast in trees.c t avoid a warning [Oberhumer]
+- Avoid some warnings in fitblk.c, gun.c, gzjoin.c in examples [Oberhumer]
+- Update make_vms.com [Zinser]
+- Initialize state->write in inflateReset() since copied in inflate_fast()
+- Be more strict on incomplete code sets in inflate_table() and increase
+ ENOUGH and MAXD -- this repairs a possible security vulnerability for
+ invalid inflate input. Thanks to Tavis Ormandy and Markus Oberhumer for
+ discovering the vulnerability and providing test cases.
+- Add ia64 support to configure for HP-UX [Smith]
+- Add error return to gzread() for format or i/o error [Levin]
+- Use malloc.h for OS/2 [Necasek]
+
+Changes in 1.2.2.3 (27 May 2005)
+- Replace 1U constants in inflate.c and inftrees.c for 64-bit compile
+- Typecast fread() return values in gzio.c [Vollant]
+- Remove trailing space in minigzip.c outmode (VC++ can't deal with it)
+- Fix crc check bug in gzread() after gzungetc() [Heiner]
+- Add the deflateTune() function to adjust internal compression parameters
+- Add a fast gzip decompressor, gun.c, to examples (use of inflateBack)
+- Remove an incorrect assertion in examples/zpipe.c
+- Add C++ wrapper in infback9.h [Donais]
+- Fix bug in inflateCopy() when decoding fixed codes
+- Note in zlib.h how much deflateSetDictionary() actually uses
+- Remove USE_DICT_HEAD in deflate.c (would mess up inflate if used)
+- Add _WIN32_WCE to define WIN32 in zconf.in.h [Spencer]
+- Don't include stderr.h or errno.h for _WIN32_WCE in zutil.h [Spencer]
+- Add gzdirect() function to indicate transparent reads
+- Update contrib/minizip [Vollant]
+- Fix compilation of deflate.c when both ASMV and FASTEST [Oberhumer]
+- Add casts in crc32.c to avoid warnings [Oberhumer]
+- Add contrib/masmx64 [Vollant]
+- Update contrib/asm586, asm686, masmx86, testzlib, vstudio [Vollant]
+
+Changes in 1.2.2.2 (30 December 2004)
+- Replace structure assignments in deflate.c and inflate.c with zmemcpy to
+ avoid implicit memcpy calls (portability for no-library compilation)
+- Increase sprintf() buffer size in gzdopen() to allow for large numbers
+- Add INFLATE_STRICT to check distances against zlib header
+- Improve WinCE errno handling and comments [Chang]
+- Remove comment about no gzip header processing in FAQ
+- Add Z_FIXED strategy option to deflateInit2() to force fixed trees
+- Add updated make_vms.com [Coghlan], update README
+- Create a new "examples" directory, move gzappend.c there, add zpipe.c,
+ fitblk.c, gzlog.[ch], gzjoin.c, and zlib_how.html.
+- Add FAQ entry and comments in deflate.c on uninitialized memory access
+- Add Solaris 9 make options in configure [Gilbert]
+- Allow strerror() usage in gzio.c for STDC
+- Fix DecompressBuf in contrib/delphi/ZLib.pas [ManChesTer]
+- Update contrib/masmx86/inffas32.asm and gvmat32.asm [Vollant]
+- Use z_off_t for adler32_combine() and crc32_combine() lengths
+- Make adler32() much faster for small len
+- Use OS_CODE in deflate() default gzip header
+
+Changes in 1.2.2.1 (31 October 2004)
+- Allow inflateSetDictionary() call for raw inflate
+- Fix inflate header crc check bug for file names and comments
+- Add deflateSetHeader() and gz_header structure for custom gzip headers
+- Add inflateGetheader() to retrieve gzip headers
+- Add crc32_combine() and adler32_combine() functions
+- Add alloc_func, free_func, in_func, out_func to Z_PREFIX list
+- Use zstreamp consistently in zlib.h (inflate_back functions)
+- Remove GUNZIP condition from definition of inflate_mode in inflate.h
+ and in contrib/inflate86/inffast.S [Truta, Anderson]
+- Add support for AMD64 in contrib/inflate86/inffas86.c [Anderson]
+- Update projects/README.projects and projects/visualc6 [Truta]
+- Update win32/DLL_FAQ.txt [Truta]
+- Avoid warning under NO_GZCOMPRESS in gzio.c; fix typo [Truta]
+- Deprecate Z_ASCII; use Z_TEXT instead [Truta]
+- Use a new algorithm for setting strm->data_type in trees.c [Truta]
+- Do not define an exit() prototype in zutil.c unless DEBUG defined
+- Remove prototype of exit() from zutil.c, example.c, minigzip.c [Truta]
+- Add comment in zlib.h for Z_NO_FLUSH parameter to deflate()
+- Fix Darwin build version identification [Peterson]
+
+Changes in 1.2.2 (3 October 2004)
+- Update zlib.h comments on gzip in-memory processing
+- Set adler to 1 in inflateReset() to support Java test suite [Walles]
+- Add contrib/dotzlib [Ravn]
+- Update win32/DLL_FAQ.txt [Truta]
+- Update contrib/minizip [Vollant]
+- Move contrib/visual-basic.txt to old/ [Truta]
+- Fix assembler builds in projects/visualc6/ [Truta]
+
+Changes in 1.2.1.2 (9 September 2004)
+- Update INDEX file
+- Fix trees.c to update strm->data_type (no one ever noticed!)
+- Fix bug in error case in inflate.c, infback.c, and infback9.c [Brown]
+- Add "volatile" to crc table flag declaration (for DYNAMIC_CRC_TABLE)
+- Add limited multitasking protection to DYNAMIC_CRC_TABLE
+- Add NO_vsnprintf for VMS in zutil.h [Mozilla]
+- Don't declare strerror() under VMS [Mozilla]
+- Add comment to DYNAMIC_CRC_TABLE to use get_crc_table() to initialize
+- Update contrib/ada [Anisimkov]
+- Update contrib/minizip [Vollant]
+- Fix configure to not hardcode directories for Darwin [Peterson]
+- Fix gzio.c to not return error on empty files [Brown]
+- Fix indentation; update version in contrib/delphi/ZLib.pas and
+ contrib/pascal/zlibpas.pas [Truta]
+- Update mkasm.bat in contrib/masmx86 [Truta]
+- Update contrib/untgz [Truta]
+- Add projects/README.projects [Truta]
+- Add project for MS Visual C++ 6.0 in projects/visualc6 [Cadieux, Truta]
+- Update win32/DLL_FAQ.txt [Truta]
+- Update list of Z_PREFIX symbols in zconf.h [Randers-Pehrson, Truta]
+- Remove an unnecessary assignment to curr in inftrees.c [Truta]
+- Add OS/2 to exe builds in configure [Poltorak]
+- Remove err dummy parameter in zlib.h [Kientzle]
+
+Changes in 1.2.1.1 (9 January 2004)
+- Update email address in README
+- Several FAQ updates
+- Fix a big fat bug in inftrees.c that prevented decoding valid
+ dynamic blocks with only literals and no distance codes --
+ Thanks to "Hot Emu" for the bug report and sample file
+- Add a note to puff.c on no distance codes case.
+
+Changes in 1.2.1 (17 November 2003)
+- Remove a tab in contrib/gzappend/gzappend.c
+- Update some interfaces in contrib for new zlib functions
+- Update zlib version number in some contrib entries
+- Add Windows CE definition for ptrdiff_t in zutil.h [Mai, Truta]
+- Support shared libraries on Hurd and KFreeBSD [Brown]
+- Fix error in NO_DIVIDE option of adler32.c
+
+Changes in 1.2.0.8 (4 November 2003)
+- Update version in contrib/delphi/ZLib.pas and contrib/pascal/zlibpas.pas
+- Add experimental NO_DIVIDE #define in adler32.c
+ - Possibly faster on some processors (let me know if it is)
+- Correct Z_BLOCK to not return on first inflate call if no wrap
+- Fix strm->data_type on inflate() return to correctly indicate EOB
+- Add deflatePrime() function for appending in the middle of a byte
+- Add contrib/gzappend for an example of appending to a stream
+- Update win32/DLL_FAQ.txt [Truta]
+- Delete Turbo C comment in README [Truta]
+- Improve some indentation in zconf.h [Truta]
+- Fix infinite loop on bad input in configure script [Church]
+- Fix gzeof() for concatenated gzip files [Johnson]
+- Add example to contrib/visual-basic.txt [Michael B.]
+- Add -p to mkdir's in Makefile.in [vda]
+- Fix configure to properly detect presence or lack of printf functions
+- Add AS400 support [Monnerat]
+- Add a little Cygwin support [Wilson]
+
+Changes in 1.2.0.7 (21 September 2003)
+- Correct some debug formats in contrib/infback9
+- Cast a type in a debug statement in trees.c
+- Change search and replace delimiter in configure from % to # [Beebe]
+- Update contrib/untgz to 0.2 with various fixes [Truta]
+- Add build support for Amiga [Nikl]
+- Remove some directories in old that have been updated to 1.2
+- Add dylib building for Mac OS X in configure and Makefile.in
+- Remove old distribution stuff from Makefile
+- Update README to point to DLL_FAQ.txt, and add comment on Mac OS X
+- Update links in README
+
+Changes in 1.2.0.6 (13 September 2003)
+- Minor FAQ updates
+- Update contrib/minizip to 1.00 [Vollant]
+- Remove test of gz functions in example.c when GZ_COMPRESS defined [Truta]
+- Update POSTINC comment for 68060 [Nikl]
+- Add contrib/infback9 with deflate64 decoding (unsupported)
+- For MVS define NO_vsnprintf and undefine FAR [van Burik]
+- Add pragma for fdopen on MVS [van Burik]
+
+Changes in 1.2.0.5 (8 September 2003)
+- Add OF to inflateBackEnd() declaration in zlib.h
+- Remember start when using gzdopen in the middle of a file
+- Use internal off_t counters in gz* functions to properly handle seeks
+- Perform more rigorous check for distance-too-far in inffast.c
+- Add Z_BLOCK flush option to return from inflate at block boundary
+- Set strm->data_type on return from inflate
+ - Indicate bits unused, if at block boundary, and if in last block
+- Replace size_t with ptrdiff_t in crc32.c, and check for correct size
+- Add condition so old NO_DEFLATE define still works for compatibility
+- FAQ update regarding the Windows DLL [Truta]
+- INDEX update: add qnx entry, remove aix entry [Truta]
+- Install zlib.3 into mandir [Wilson]
+- Move contrib/zlib_dll_FAQ.txt to win32/DLL_FAQ.txt; update [Truta]
+- Adapt the zlib interface to the new DLL convention guidelines [Truta]
+- Introduce ZLIB_WINAPI macro to allow the export of functions using
+ the WINAPI calling convention, for Visual Basic [Vollant, Truta]
+- Update msdos and win32 scripts and makefiles [Truta]
+- Export symbols by name, not by ordinal, in win32/zlib.def [Truta]
+- Add contrib/ada [Anisimkov]
+- Move asm files from contrib/vstudio/vc70_32 to contrib/asm386 [Truta]
+- Rename contrib/asm386 to contrib/masmx86 [Truta, Vollant]
+- Add contrib/masm686 [Truta]
+- Fix offsets in contrib/inflate86 and contrib/masmx86/inffas32.asm
+ [Truta, Vollant]
+- Update contrib/delphi; rename to contrib/pascal; add example [Truta]
+- Remove contrib/delphi2; add a new contrib/delphi [Truta]
+- Avoid inclusion of the nonstandard <memory.h> in contrib/iostream,
+ and fix some method prototypes [Truta]
+- Fix the ZCR_SEED2 constant to avoid warnings in contrib/minizip
+ [Truta]
+- Avoid the use of backslash (\) in contrib/minizip [Vollant]
+- Fix file time handling in contrib/untgz; update makefiles [Truta]
+- Update contrib/vstudio/vc70_32 to comply with the new DLL guidelines
+ [Vollant]
+- Remove contrib/vstudio/vc15_16 [Vollant]
+- Rename contrib/vstudio/vc70_32 to contrib/vstudio/vc7 [Truta]
+- Update README.contrib [Truta]
+- Invert the assignment order of match_head and s->prev[...] in
+ INSERT_STRING [Truta]
+- Compare TOO_FAR with 32767 instead of 32768, to avoid 16-bit warnings
+ [Truta]
+- Compare function pointers with 0, not with NULL or Z_NULL [Truta]
+- Fix prototype of syncsearch in inflate.c [Truta]
+- Introduce ASMINF macro to be enabled when using an ASM implementation
+ of inflate_fast [Truta]
+- Change NO_DEFLATE to NO_GZCOMPRESS [Truta]
+- Modify test_gzio in example.c to take a single file name as a
+ parameter [Truta]
+- Exit the example.c program if gzopen fails [Truta]
+- Add type casts around strlen in example.c [Truta]
+- Remove casting to sizeof in minigzip.c; give a proper type
+ to the variable compared with SUFFIX_LEN [Truta]
+- Update definitions of STDC and STDC99 in zconf.h [Truta]
+- Synchronize zconf.h with the new Windows DLL interface [Truta]
+- Use SYS16BIT instead of __32BIT__ to distinguish between
+ 16- and 32-bit platforms [Truta]
+- Use far memory allocators in small 16-bit memory models for
+ Turbo C [Truta]
+- Add info about the use of ASMV, ASMINF and ZLIB_WINAPI in
+ zlibCompileFlags [Truta]
+- Cygwin has vsnprintf [Wilson]
+- In Windows16, OS_CODE is 0, as in MSDOS [Truta]
+- In Cygwin, OS_CODE is 3 (Unix), not 11 (Windows32) [Wilson]
+
+Changes in 1.2.0.4 (10 August 2003)
+- Minor FAQ updates
+- Be more strict when checking inflateInit2's windowBits parameter
+- Change NO_GUNZIP compile option to NO_GZIP to cover deflate as well
+- Add gzip wrapper option to deflateInit2 using windowBits
+- Add updated QNX rule in configure and qnx directory [Bonnefoy]
+- Make inflate distance-too-far checks more rigorous
+- Clean up FAR usage in inflate
+- Add casting to sizeof() in gzio.c and minigzip.c
+
+Changes in 1.2.0.3 (19 July 2003)
+- Fix silly error in gzungetc() implementation [Vollant]
+- Update contrib/minizip and contrib/vstudio [Vollant]
+- Fix printf format in example.c
+- Correct cdecl support in zconf.in.h [Anisimkov]
+- Minor FAQ updates
+
+Changes in 1.2.0.2 (13 July 2003)
+- Add ZLIB_VERNUM in zlib.h for numerical preprocessor comparisons
+- Attempt to avoid warnings in crc32.c for pointer-int conversion
+- Add AIX to configure, remove aix directory [Bakker]
+- Add some casts to minigzip.c
+- Improve checking after insecure sprintf() or vsprintf() calls
+- Remove #elif's from crc32.c
+- Change leave label to inf_leave in inflate.c and infback.c to avoid
+ library conflicts
+- Remove inflate gzip decoding by default--only enable gzip decoding by
+ special request for stricter backward compatibility
+- Add zlibCompileFlags() function to return compilation information
+- More typecasting in deflate.c to avoid warnings
+- Remove leading underscore from _Capital #defines [Truta]
+- Fix configure to link shared library when testing
+- Add some Windows CE target adjustments [Mai]
+- Remove #define ZLIB_DLL in zconf.h [Vollant]
+- Add zlib.3 [Rodgers]
+- Update RFC URL in deflate.c and algorithm.txt [Mai]
+- Add zlib_dll_FAQ.txt to contrib [Truta]
+- Add UL to some constants [Truta]
+- Update minizip and vstudio [Vollant]
+- Remove vestigial NEED_DUMMY_RETURN from zconf.in.h
+- Expand use of NO_DUMMY_DECL to avoid all dummy structures
+- Added iostream3 to contrib [Schwardt]
+- Replace rewind() with fseek() for WinCE [Truta]
+- Improve setting of zlib format compression level flags
+ - Report 0 for huffman and rle strategies and for level == 0 or 1
+ - Report 2 only for level == 6
+- Only deal with 64K limit when necessary at compile time [Truta]
+- Allow TOO_FAR check to be turned off at compile time [Truta]
+- Add gzclearerr() function [Souza]
+- Add gzungetc() function
+
+Changes in 1.2.0.1 (17 March 2003)
+- Add Z_RLE strategy for run-length encoding [Truta]
+ - When Z_RLE requested, restrict matches to distance one
+ - Update zlib.h, minigzip.c, gzopen(), gzdopen() for Z_RLE
+- Correct FASTEST compilation to allow level == 0
+- Clean up what gets compiled for FASTEST
+- Incorporate changes to zconf.in.h [Vollant]
+ - Refine detection of Turbo C need for dummy returns
+ - Refine ZLIB_DLL compilation
+ - Include additional header file on VMS for off_t typedef
+- Try to use _vsnprintf where it supplants vsprintf [Vollant]
+- Add some casts in inffast.c
+- Enchance comments in zlib.h on what happens if gzprintf() tries to
+ write more than 4095 bytes before compression
+- Remove unused state from inflateBackEnd()
+- Remove exit(0) from minigzip.c, example.c
+- Get rid of all those darn tabs
+- Add "check" target to Makefile.in that does the same thing as "test"
+- Add "mostlyclean" and "maintainer-clean" targets to Makefile.in
+- Update contrib/inflate86 [Anderson]
+- Update contrib/testzlib, contrib/vstudio, contrib/minizip [Vollant]
+- Add msdos and win32 directories with makefiles [Truta]
+- More additions and improvements to the FAQ
+
+Changes in 1.2.0 (9 March 2003)
+- New and improved inflate code
+ - About 20% faster
+ - Does not allocate 32K window unless and until needed
+ - Automatically detects and decompresses gzip streams
+ - Raw inflate no longer needs an extra dummy byte at end
+ - Added inflateBack functions using a callback interface--even faster
+ than inflate, useful for file utilities (gzip, zip)
+ - Added inflateCopy() function to record state for random access on
+ externally generated deflate streams (e.g. in gzip files)
+ - More readable code (I hope)
+- New and improved crc32()
+ - About 50% faster, thanks to suggestions from Rodney Brown
+- Add deflateBound() and compressBound() functions
+- Fix memory leak in deflateInit2()
+- Permit setting dictionary for raw deflate (for parallel deflate)
+- Fix const declaration for gzwrite()
+- Check for some malloc() failures in gzio.c
+- Fix bug in gzopen() on single-byte file 0x1f
+- Fix bug in gzread() on concatenated file with 0x1f at end of buffer
+ and next buffer doesn't start with 0x8b
+- Fix uncompress() to return Z_DATA_ERROR on truncated input
+- Free memory at end of example.c
+- Remove MAX #define in trees.c (conflicted with some libraries)
+- Fix static const's in deflate.c, gzio.c, and zutil.[ch]
+- Declare malloc() and free() in gzio.c if STDC not defined
+- Use malloc() instead of calloc() in zutil.c if int big enough
+- Define STDC for AIX
+- Add aix/ with approach for compiling shared library on AIX
+- Add HP-UX support for shared libraries in configure
+- Add OpenUNIX support for shared libraries in configure
+- Use $cc instead of gcc to build shared library
+- Make prefix directory if needed when installing
+- Correct Macintosh avoidance of typedef Byte in zconf.h
+- Correct Turbo C memory allocation when under Linux
+- Use libz.a instead of -lz in Makefile (assure use of compiled library)
+- Update configure to check for snprintf or vsnprintf functions and their
+ return value, warn during make if using an insecure function
+- Fix configure problem with compile-time knowledge of HAVE_UNISTD_H that
+ is lost when library is used--resolution is to build new zconf.h
+- Documentation improvements (in zlib.h):
+ - Document raw deflate and inflate
+ - Update RFCs URL
+ - Point out that zlib and gzip formats are different
+ - Note that Z_BUF_ERROR is not fatal
+ - Document string limit for gzprintf() and possible buffer overflow
+ - Note requirement on avail_out when flushing
+ - Note permitted values of flush parameter of inflate()
+- Add some FAQs (and even answers) to the FAQ
+- Add contrib/inflate86/ for x86 faster inflate
+- Add contrib/blast/ for PKWare Data Compression Library decompression
+- Add contrib/puff/ simple inflate for deflate format description
+
+Changes in 1.1.4 (11 March 2002)
+- ZFREE was repeated on same allocation on some error conditions.
+ This creates a security problem described in
+ http://www.zlib.org/advisory-2002-03-11.txt
+- Returned incorrect error (Z_MEM_ERROR) on some invalid data
+- Avoid accesses before window for invalid distances with inflate window
+ less than 32K.
+- force windowBits > 8 to avoid a bug in the encoder for a window size
+ of 256 bytes. (A complete fix will be available in 1.1.5).
+
+Changes in 1.1.3 (9 July 1998)
+- fix "an inflate input buffer bug that shows up on rare but persistent
+ occasions" (Mark)
+- fix gzread and gztell for concatenated .gz files (Didier Le Botlan)
+- fix gzseek(..., SEEK_SET) in write mode
+- fix crc check after a gzeek (Frank Faubert)
+- fix miniunzip when the last entry in a zip file is itself a zip file
+ (J Lillge)
+- add contrib/asm586 and contrib/asm686 (Brian Raiter)
+ See http://www.muppetlabs.com/~breadbox/software/assembly.html
+- add support for Delphi 3 in contrib/delphi (Bob Dellaca)
+- add support for C++Builder 3 and Delphi 3 in contrib/delphi2 (Davide Moretti)
+- do not exit prematurely in untgz if 0 at start of block (Magnus Holmgren)
+- use macro EXTERN instead of extern to support DLL for BeOS (Sander Stoks)
+- added a FAQ file
+
+- Support gzdopen on Mac with Metrowerks (Jason Linhart)
+- Do not redefine Byte on Mac (Brad Pettit & Jason Linhart)
+- define SEEK_END too if SEEK_SET is not defined (Albert Chin-A-Young)
+- avoid some warnings with Borland C (Tom Tanner)
+- fix a problem in contrib/minizip/zip.c for 16-bit MSDOS (Gilles Vollant)
+- emulate utime() for WIN32 in contrib/untgz (Gilles Vollant)
+- allow several arguments to configure (Tim Mooney, Frodo Looijaard)
+- use libdir and includedir in Makefile.in (Tim Mooney)
+- support shared libraries on OSF1 V4 (Tim Mooney)
+- remove so_locations in "make clean" (Tim Mooney)
+- fix maketree.c compilation error (Glenn, Mark)
+- Python interface to zlib now in Python 1.5 (Jeremy Hylton)
+- new Makefile.riscos (Rich Walker)
+- initialize static descriptors in trees.c for embedded targets (Nick Smith)
+- use "foo-gz" in example.c for RISCOS and VMS (Nick Smith)
+- add the OS/2 files in Makefile.in too (Andrew Zabolotny)
+- fix fdopen and halloc macros for Microsoft C 6.0 (Tom Lane)
+- fix maketree.c to allow clean compilation of inffixed.h (Mark)
+- fix parameter check in deflateCopy (Gunther Nikl)
+- cleanup trees.c, use compressed_len only in debug mode (Christian Spieler)
+- Many portability patches by Christian Spieler:
+ . zutil.c, zutil.h: added "const" for zmem*
+ . Make_vms.com: fixed some typos
+ . Make_vms.com: msdos/Makefile.*: removed zutil.h from some dependency lists
+ . msdos/Makefile.msc: remove "default rtl link library" info from obj files
+ . msdos/Makefile.*: use model-dependent name for the built zlib library
+ . msdos/Makefile.emx, nt/Makefile.emx, nt/Makefile.gcc:
+ new makefiles, for emx (DOS/OS2), emx&rsxnt and mingw32 (Windows 9x / NT)
+- use define instead of typedef for Bytef also for MSC small/medium (Tom Lane)
+- replace __far with _far for better portability (Christian Spieler, Tom Lane)
+- fix test for errno.h in configure (Tim Newsham)
+
+Changes in 1.1.2 (19 March 98)
+- added contrib/minzip, mini zip and unzip based on zlib (Gilles Vollant)
+ See http://www.winimage.com/zLibDll/unzip.html
+- preinitialize the inflate tables for fixed codes, to make the code
+ completely thread safe (Mark)
+- some simplifications and slight speed-up to the inflate code (Mark)
+- fix gzeof on non-compressed files (Allan Schrum)
+- add -std1 option in configure for OSF1 to fix gzprintf (Martin Mokrejs)
+- use default value of 4K for Z_BUFSIZE for 16-bit MSDOS (Tim Wegner + Glenn)
+- added os2/Makefile.def and os2/zlib.def (Andrew Zabolotny)
+- add shared lib support for UNIX_SV4.2MP (MATSUURA Takanori)
+- do not wrap extern "C" around system includes (Tom Lane)
+- mention zlib binding for TCL in README (Andreas Kupries)
+- added amiga/Makefile.pup for Amiga powerUP SAS/C PPC (Andreas Kleinert)
+- allow "make install prefix=..." even after configure (Glenn Randers-Pehrson)
+- allow "configure --prefix $HOME" (Tim Mooney)
+- remove warnings in example.c and gzio.c (Glenn Randers-Pehrson)
+- move Makefile.sas to amiga/Makefile.sas
+
+Changes in 1.1.1 (27 Feb 98)
+- fix macros _tr_tally_* in deflate.h for debug mode (Glenn Randers-Pehrson)
+- remove block truncation heuristic which had very marginal effect for zlib
+ (smaller lit_bufsize than in gzip 1.2.4) and degraded a little the
+ compression ratio on some files. This also allows inlining _tr_tally for
+ matches in deflate_slow.
+- added msdos/Makefile.w32 for WIN32 Microsoft Visual C++ (Bob Frazier)
+
+Changes in 1.1.0 (24 Feb 98)
+- do not return STREAM_END prematurely in inflate (John Bowler)
+- revert to the zlib 1.0.8 inflate to avoid the gcc 2.8.0 bug (Jeremy Buhler)
+- compile with -DFASTEST to get compression code optimized for speed only
+- in minigzip, try mmap'ing the input file first (Miguel Albrecht)
+- increase size of I/O buffers in minigzip.c and gzio.c (not a big gain
+ on Sun but significant on HP)
+
+- add a pointer to experimental unzip library in README (Gilles Vollant)
+- initialize variable gcc in configure (Chris Herborth)
+
+Changes in 1.0.9 (17 Feb 1998)
+- added gzputs and gzgets functions
+- do not clear eof flag in gzseek (Mark Diekhans)
+- fix gzseek for files in transparent mode (Mark Diekhans)
+- do not assume that vsprintf returns the number of bytes written (Jens Krinke)
+- replace EXPORT with ZEXPORT to avoid conflict with other programs
+- added compress2 in zconf.h, zlib.def, zlib.dnt
+- new asm code from Gilles Vollant in contrib/asm386
+- simplify the inflate code (Mark):
+ . Replace ZALLOC's in huft_build() with single ZALLOC in inflate_blocks_new()
+ . ZALLOC the length list in inflate_trees_fixed() instead of using stack
+ . ZALLOC the value area for huft_build() instead of using stack
+ . Simplify Z_FINISH check in inflate()
+
+- Avoid gcc 2.8.0 comparison bug a little differently than zlib 1.0.8
+- in inftrees.c, avoid cc -O bug on HP (Farshid Elahi)
+- in zconf.h move the ZLIB_DLL stuff earlier to avoid problems with
+ the declaration of FAR (Gilles VOllant)
+- install libz.so* with mode 755 (executable) instead of 644 (Marc Lehmann)
+- read_buf buf parameter of type Bytef* instead of charf*
+- zmemcpy parameters are of type Bytef*, not charf* (Joseph Strout)
+- do not redeclare unlink in minigzip.c for WIN32 (John Bowler)
+- fix check for presence of directories in "make install" (Ian Willis)
+
+Changes in 1.0.8 (27 Jan 1998)
+- fixed offsets in contrib/asm386/gvmat32.asm (Gilles Vollant)
+- fix gzgetc and gzputc for big endian systems (Markus Oberhumer)
+- added compress2() to allow setting the compression level
+- include sys/types.h to get off_t on some systems (Marc Lehmann & QingLong)
+- use constant arrays for the static trees in trees.c instead of computing
+ them at run time (thanks to Ken Raeburn for this suggestion). To create
+ trees.h, compile with GEN_TREES_H and run "make test".
+- check return code of example in "make test" and display result
+- pass minigzip command line options to file_compress
+- simplifying code of inflateSync to avoid gcc 2.8 bug
+
+- support CC="gcc -Wall" in configure -s (QingLong)
+- avoid a flush caused by ftell in gzopen for write mode (Ken Raeburn)
+- fix test for shared library support to avoid compiler warnings
+- zlib.lib -> zlib.dll in msdos/zlib.rc (Gilles Vollant)
+- check for TARGET_OS_MAC in addition to MACOS (Brad Pettit)
+- do not use fdopen for Metrowerks on Mac (Brad Pettit))
+- add checks for gzputc and gzputc in example.c
+- avoid warnings in gzio.c and deflate.c (Andreas Kleinert)
+- use const for the CRC table (Ken Raeburn)
+- fixed "make uninstall" for shared libraries
+- use Tracev instead of Trace in infblock.c
+- in example.c use correct compressed length for test_sync
+- suppress +vnocompatwarnings in configure for HPUX (not always supported)
+
+Changes in 1.0.7 (20 Jan 1998)
+- fix gzseek which was broken in write mode
+- return error for gzseek to negative absolute position
+- fix configure for Linux (Chun-Chung Chen)
+- increase stack space for MSC (Tim Wegner)
+- get_crc_table and inflateSyncPoint are EXPORTed (Gilles Vollant)
+- define EXPORTVA for gzprintf (Gilles Vollant)
+- added man page zlib.3 (Rick Rodgers)
+- for contrib/untgz, fix makedir() and improve Makefile
+
+- check gzseek in write mode in example.c
+- allocate extra buffer for seeks only if gzseek is actually called
+- avoid signed/unsigned comparisons (Tim Wegner, Gilles Vollant)
+- add inflateSyncPoint in zconf.h
+- fix list of exported functions in nt/zlib.dnt and mdsos/zlib.def
+
+Changes in 1.0.6 (19 Jan 1998)
+- add functions gzprintf, gzputc, gzgetc, gztell, gzeof, gzseek, gzrewind and
+ gzsetparams (thanks to Roland Giersig and Kevin Ruland for some of this code)
+- Fix a deflate bug occurring only with compression level 0 (thanks to
+ Andy Buckler for finding this one).
+- In minigzip, pass transparently also the first byte for .Z files.
+- return Z_BUF_ERROR instead of Z_OK if output buffer full in uncompress()
+- check Z_FINISH in inflate (thanks to Marc Schluper)
+- Implement deflateCopy (thanks to Adam Costello)
+- make static libraries by default in configure, add --shared option.
+- move MSDOS or Windows specific files to directory msdos
+- suppress the notion of partial flush to simplify the interface
+ (but the symbol Z_PARTIAL_FLUSH is kept for compatibility with 1.0.4)
+- suppress history buffer provided by application to simplify the interface
+ (this feature was not implemented anyway in 1.0.4)
+- next_in and avail_in must be initialized before calling inflateInit or
+ inflateInit2
+- add EXPORT in all exported functions (for Windows DLL)
+- added Makefile.nt (thanks to Stephen Williams)
+- added the unsupported "contrib" directory:
+ contrib/asm386/ by Gilles Vollant <info@winimage.com>
+ 386 asm code replacing longest_match().
+ contrib/iostream/ by Kevin Ruland <kevin@rodin.wustl.edu>
+ A C++ I/O streams interface to the zlib gz* functions
+ contrib/iostream2/ by Tyge Løvset <Tyge.Lovset@cmr.no>
+ Another C++ I/O streams interface
+ contrib/untgz/ by "Pedro A. Aranda Guti\irrez" <paag@tid.es>
+ A very simple tar.gz file extractor using zlib
+ contrib/visual-basic.txt by Carlos Rios <c_rios@sonda.cl>
+ How to use compress(), uncompress() and the gz* functions from VB.
+- pass params -f (filtered data), -h (huffman only), -1 to -9 (compression
+ level) in minigzip (thanks to Tom Lane)
+
+- use const for rommable constants in deflate
+- added test for gzseek and gztell in example.c
+- add undocumented function inflateSyncPoint() (hack for Paul Mackerras)
+- add undocumented function zError to convert error code to string
+ (for Tim Smithers)
+- Allow compilation of gzio with -DNO_DEFLATE to avoid the compression code.
+- Use default memcpy for Symantec MSDOS compiler.
+- Add EXPORT keyword for check_func (needed for Windows DLL)
+- add current directory to LD_LIBRARY_PATH for "make test"
+- create also a link for libz.so.1
+- added support for FUJITSU UXP/DS (thanks to Toshiaki Nomura)
+- use $(SHAREDLIB) instead of libz.so in Makefile.in (for HPUX)
+- added -soname for Linux in configure (Chun-Chung Chen,
+- assign numbers to the exported functions in zlib.def (for Windows DLL)
+- add advice in zlib.h for best usage of deflateSetDictionary
+- work around compiler bug on Atari (cast Z_NULL in call of s->checkfn)
+- allow compilation with ANSI keywords only enabled for TurboC in large model
+- avoid "versionString"[0] (Borland bug)
+- add NEED_DUMMY_RETURN for Borland
+- use variable z_verbose for tracing in debug mode (L. Peter Deutsch).
+- allow compilation with CC
+- defined STDC for OS/2 (David Charlap)
+- limit external names to 8 chars for MVS (Thomas Lund)
+- in minigzip.c, use static buffers only for 16-bit systems
+- fix suffix check for "minigzip -d foo.gz"
+- do not return an error for the 2nd of two consecutive gzflush() (Felix Lee)
+- use _fdopen instead of fdopen for MSC >= 6.0 (Thomas Fanslau)
+- added makelcc.bat for lcc-win32 (Tom St Denis)
+- in Makefile.dj2, use copy and del instead of install and rm (Frank Donahoe)
+- Avoid expanded $Id$. Use "rcs -kb" or "cvs admin -kb" to avoid Id expansion.
+- check for unistd.h in configure (for off_t)
+- remove useless check parameter in inflate_blocks_free
+- avoid useless assignment of s->check to itself in inflate_blocks_new
+- do not flush twice in gzclose (thanks to Ken Raeburn)
+- rename FOPEN as F_OPEN to avoid clash with /usr/include/sys/file.h
+- use NO_ERRNO_H instead of enumeration of operating systems with errno.h
+- work around buggy fclose on pipes for HP/UX
+- support zlib DLL with BORLAND C++ 5.0 (thanks to Glenn Randers-Pehrson)
+- fix configure if CC is already equal to gcc
+
+Changes in 1.0.5 (3 Jan 98)
+- Fix inflate to terminate gracefully when fed corrupted or invalid data
+- Use const for rommable constants in inflate
+- Eliminate memory leaks on error conditions in inflate
+- Removed some vestigial code in inflate
+- Update web address in README
+
+Changes in 1.0.4 (24 Jul 96)
+- In very rare conditions, deflate(s, Z_FINISH) could fail to produce an EOF
+ bit, so the decompressor could decompress all the correct data but went
+ on to attempt decompressing extra garbage data. This affected minigzip too.
+- zlibVersion and gzerror return const char* (needed for DLL)
+- port to RISCOS (no fdopen, no multiple dots, no unlink, no fileno)
+- use z_error only for DEBUG (avoid problem with DLLs)
+
+Changes in 1.0.3 (2 Jul 96)
+- use z_streamp instead of z_stream *, which is now a far pointer in MSDOS
+ small and medium models; this makes the library incompatible with previous
+ versions for these models. (No effect in large model or on other systems.)
+- return OK instead of BUF_ERROR if previous deflate call returned with
+ avail_out as zero but there is nothing to do
+- added memcmp for non STDC compilers
+- define NO_DUMMY_DECL for more Mac compilers (.h files merged incorrectly)
+- define __32BIT__ if __386__ or i386 is defined (pb. with Watcom and SCO)
+- better check for 16-bit mode MSC (avoids problem with Symantec)
+
+Changes in 1.0.2 (23 May 96)
+- added Windows DLL support
+- added a function zlibVersion (for the DLL support)
+- fixed declarations using Bytef in infutil.c (pb with MSDOS medium model)
+- Bytef is define's instead of typedef'd only for Borland C
+- avoid reading uninitialized memory in example.c
+- mention in README that the zlib format is now RFC1950
+- updated Makefile.dj2
+- added algorithm.doc
+
+Changes in 1.0.1 (20 May 96) [1.0 skipped to avoid confusion]
+- fix array overlay in deflate.c which sometimes caused bad compressed data
+- fix inflate bug with empty stored block
+- fix MSDOS medium model which was broken in 0.99
+- fix deflateParams() which could generated bad compressed data.
+- Bytef is define'd instead of typedef'ed (work around Borland bug)
+- added an INDEX file
+- new makefiles for DJGPP (Makefile.dj2), 32-bit Borland (Makefile.b32),
+ Watcom (Makefile.wat), Amiga SAS/C (Makefile.sas)
+- speed up adler32 for modern machines without auto-increment
+- added -ansi for IRIX in configure
+- static_init_done in trees.c is an int
+- define unlink as delete for VMS
+- fix configure for QNX
+- add configure branch for SCO and HPUX
+- avoid many warnings (unused variables, dead assignments, etc...)
+- no fdopen for BeOS
+- fix the Watcom fix for 32 bit mode (define FAR as empty)
+- removed redefinition of Byte for MKWERKS
+- work around an MWKERKS bug (incorrect merge of all .h files)
+
+Changes in 0.99 (27 Jan 96)
+- allow preset dictionary shared between compressor and decompressor
+- allow compression level 0 (no compression)
+- add deflateParams in zlib.h: allow dynamic change of compression level
+ and compression strategy.
+- test large buffers and deflateParams in example.c
+- add optional "configure" to build zlib as a shared library
+- suppress Makefile.qnx, use configure instead
+- fixed deflate for 64-bit systems (detected on Cray)
+- fixed inflate_blocks for 64-bit systems (detected on Alpha)
+- declare Z_DEFLATED in zlib.h (possible parameter for deflateInit2)
+- always return Z_BUF_ERROR when deflate() has nothing to do
+- deflateInit and inflateInit are now macros to allow version checking
+- prefix all global functions and types with z_ with -DZ_PREFIX
+- make falloc completely reentrant (inftrees.c)
+- fixed very unlikely race condition in ct_static_init
+- free in reverse order of allocation to help memory manager
+- use zlib-1.0/* instead of zlib/* inside the tar.gz
+- make zlib warning-free with "gcc -O3 -Wall -Wwrite-strings -Wpointer-arith
+ -Wconversion -Wstrict-prototypes -Wmissing-prototypes"
+- allow gzread on concatenated .gz files
+- deflateEnd now returns Z_DATA_ERROR if it was premature
+- deflate is finally (?) fully deterministic (no matches beyond end of input)
+- Document Z_SYNC_FLUSH
+- add uninstall in Makefile
+- Check for __cpluplus in zlib.h
+- Better test in ct_align for partial flush
+- avoid harmless warnings for Borland C++
+- initialize hash_head in deflate.c
+- avoid warning on fdopen (gzio.c) for HP cc -Aa
+- include stdlib.h for STDC compilers
+- include errno.h for Cray
+- ignore error if ranlib doesn't exist
+- call ranlib twice for NeXTSTEP
+- use exec_prefix instead of prefix for libz.a
+- renamed ct_* as _tr_* to avoid conflict with applications
+- clear z->msg in inflateInit2 before any error return
+- initialize opaque in example.c, gzio.c, deflate.c and inflate.c
+- fixed typo in zconf.h (_GNUC__ => __GNUC__)
+- check for WIN32 in zconf.h and zutil.c (avoid farmalloc in 32-bit mode)
+- fix typo in Make_vms.com (f$trnlnm -> f$getsyi)
+- in fcalloc, normalize pointer if size > 65520 bytes
+- don't use special fcalloc for 32 bit Borland C++
+- use STDC instead of __GO32__ to avoid redeclaring exit, calloc, etc...
+- use Z_BINARY instead of BINARY
+- document that gzclose after gzdopen will close the file
+- allow "a" as mode in gzopen.
+- fix error checking in gzread
+- allow skipping .gz extra-field on pipes
+- added reference to Perl interface in README
+- put the crc table in FAR data (I dislike more and more the medium model :)
+- added get_crc_table
+- added a dimension to all arrays (Borland C can't count).
+- workaround Borland C bug in declaration of inflate_codes_new & inflate_fast
+- guard against multiple inclusion of *.h (for precompiled header on Mac)
+- Watcom C pretends to be Microsoft C small model even in 32 bit mode.
+- don't use unsized arrays to avoid silly warnings by Visual C++:
+ warning C4746: 'inflate_mask' : unsized array treated as '__far'
+ (what's wrong with far data in far model?).
+- define enum out of inflate_blocks_state to allow compilation with C++
+
+Changes in 0.95 (16 Aug 95)
+- fix MSDOS small and medium model (now easier to adapt to any compiler)
+- inlined send_bits
+- fix the final (:-) bug for deflate with flush (output was correct but
+ not completely flushed in rare occasions).
+- default window size is same for compression and decompression
+ (it's now sufficient to set MAX_WBITS in zconf.h).
+- voidp -> voidpf and voidnp -> voidp (for consistency with other
+ typedefs and because voidnp was not near in large model).
+
+Changes in 0.94 (13 Aug 95)
+- support MSDOS medium model
+- fix deflate with flush (could sometimes generate bad output)
+- fix deflateReset (zlib header was incorrectly suppressed)
+- added support for VMS
+- allow a compression level in gzopen()
+- gzflush now calls fflush
+- For deflate with flush, flush even if no more input is provided.
+- rename libgz.a as libz.a
+- avoid complex expression in infcodes.c triggering Turbo C bug
+- work around a problem with gcc on Alpha (in INSERT_STRING)
+- don't use inline functions (problem with some gcc versions)
+- allow renaming of Byte, uInt, etc... with #define.
+- avoid warning about (unused) pointer before start of array in deflate.c
+- avoid various warnings in gzio.c, example.c, infblock.c, adler32.c, zutil.c
+- avoid reserved word 'new' in trees.c
+
+Changes in 0.93 (25 June 95)
+- temporarily disable inline functions
+- make deflate deterministic
+- give enough lookahead for PARTIAL_FLUSH
+- Set binary mode for stdin/stdout in minigzip.c for OS/2
+- don't even use signed char in inflate (not portable enough)
+- fix inflate memory leak for segmented architectures
+
+Changes in 0.92 (3 May 95)
+- don't assume that char is signed (problem on SGI)
+- Clear bit buffer when starting a stored block
+- no memcpy on Pyramid
+- suppressed inftest.c
+- optimized fill_window, put longest_match inline for gcc
+- optimized inflate on stored blocks.
+- untabify all sources to simplify patches
+
+Changes in 0.91 (2 May 95)
+- Default MEM_LEVEL is 8 (not 9 for Unix) as documented in zlib.h
+- Document the memory requirements in zconf.h
+- added "make install"
+- fix sync search logic in inflateSync
+- deflate(Z_FULL_FLUSH) now works even if output buffer too short
+- after inflateSync, don't scare people with just "lo world"
+- added support for DJGPP
+
+Changes in 0.9 (1 May 95)
+- don't assume that zalloc clears the allocated memory (the TurboC bug
+ was Mark's bug after all :)
+- let again gzread copy uncompressed data unchanged (was working in 0.71)
+- deflate(Z_FULL_FLUSH), inflateReset and inflateSync are now fully implemented
+- added a test of inflateSync in example.c
+- moved MAX_WBITS to zconf.h because users might want to change that.
+- document explicitly that zalloc(64K) on MSDOS must return a normalized
+ pointer (zero offset)
+- added Makefiles for Microsoft C, Turbo C, Borland C++
+- faster crc32()
+
+Changes in 0.8 (29 April 95)
+- added fast inflate (inffast.c)
+- deflate(Z_FINISH) now returns Z_STREAM_END when done. Warning: this
+ is incompatible with previous versions of zlib which returned Z_OK.
+- work around a TurboC compiler bug (bad code for b << 0, see infutil.h)
+ (actually that was not a compiler bug, see 0.81 above)
+- gzread no longer reads one extra byte in certain cases
+- In gzio destroy(), don't reference a freed structure
+- avoid many warnings for MSDOS
+- avoid the ERROR symbol which is used by MS Windows
+
+Changes in 0.71 (14 April 95)
+- Fixed more MSDOS compilation problems :( There is still a bug with
+ TurboC large model.
+
+Changes in 0.7 (14 April 95)
+- Added full inflate support.
+- Simplified the crc32() interface. The pre- and post-conditioning
+ (one's complement) is now done inside crc32(). WARNING: this is
+ incompatible with previous versions; see zlib.h for the new usage.
+
+Changes in 0.61 (12 April 95)
+- workaround for a bug in TurboC. example and minigzip now work on MSDOS.
+
+Changes in 0.6 (11 April 95)
+- added minigzip.c
+- added gzdopen to reopen a file descriptor as gzFile
+- added transparent reading of non-gziped files in gzread.
+- fixed bug in gzread (don't read crc as data)
+- fixed bug in destroy (gzio.c) (don't return Z_STREAM_END for gzclose).
+- don't allocate big arrays in the stack (for MSDOS)
+- fix some MSDOS compilation problems
+
+Changes in 0.5:
+- do real compression in deflate.c. Z_PARTIAL_FLUSH is supported but
+ not yet Z_FULL_FLUSH.
+- support decompression but only in a single step (forced Z_FINISH)
+- added opaque object for zalloc and zfree.
+- added deflateReset and inflateReset
+- added a variable zlib_version for consistency checking.
+- renamed the 'filter' parameter of deflateInit2 as 'strategy'.
+ Added Z_FILTERED and Z_HUFFMAN_ONLY constants.
+
+Changes in 0.4:
+- avoid "zip" everywhere, use zlib instead of ziplib.
+- suppress Z_BLOCK_FLUSH, interpret Z_PARTIAL_FLUSH as block flush
+ if compression method == 8.
+- added adler32 and crc32
+- renamed deflateOptions as deflateInit2, call one or the other but not both
+- added the method parameter for deflateInit2.
+- added inflateInit2
+- simplied considerably deflateInit and inflateInit by not supporting
+ user-provided history buffer. This is supported only in deflateInit2
+ and inflateInit2.
+
+Changes in 0.3:
+- prefix all macro names with Z_
+- use Z_FINISH instead of deflateEnd to finish compression.
+- added Z_HUFFMAN_ONLY
+- added gzerror()
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/README Thu Dec 15 15:57:51 2011 -0800
@@ -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.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/compress.c Thu Dec 15 15:57:51 2011 -0800
@@ -0,0 +1,104 @@
+/*
+ * 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.
+ */
+
+/* compress.c -- compress a memory buffer
+ * Copyright (C) 1995-2005 Jean-loup Gailly.
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+/* @(#) $Id$ */
+
+#define ZLIB_INTERNAL
+#include "zlib.h"
+
+/* ===========================================================================
+ 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 0.1% larger than sourceLen plus
+ 12 bytes. 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.
+*/
+int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
+ Bytef *dest;
+ uLongf *destLen;
+ const Bytef *source;
+ uLong sourceLen;
+ int level;
+{
+ z_stream stream;
+ int err;
+
+ stream.next_in = (Bytef*)source;
+ stream.avail_in = (uInt)sourceLen;
+#ifdef MAXSEG_64K
+ /* Check for source > 64K on 16-bit machine: */
+ if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
+#endif
+ stream.next_out = dest;
+ stream.avail_out = (uInt)*destLen;
+ if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
+
+ stream.zalloc = (alloc_func)0;
+ stream.zfree = (free_func)0;
+ stream.opaque = (voidpf)0;
+
+ err = deflateInit(&stream, level);
+ if (err != Z_OK) return err;
+
+ err = deflate(&stream, Z_FINISH);
+ if (err != Z_STREAM_END) {
+ deflateEnd(&stream);
+ return err == Z_OK ? Z_BUF_ERROR : err;
+ }
+ *destLen = (uLong)stream.total_out;
+
+ err = deflateEnd(&stream);
+ return err;
+}
+
+/* ===========================================================================
+ */
+int ZEXPORT compress (dest, destLen, source, sourceLen)
+ Bytef *dest;
+ uLongf *destLen;
+ const Bytef *source;
+ uLong sourceLen;
+{
+ return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
+}
+
+/* ===========================================================================
+ If the default memLevel or windowBits for deflateInit() is changed, then
+ this function needs to be updated.
+ */
+uLong ZEXPORT compressBound (sourceLen)
+ uLong sourceLen;
+{
+ return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
+ (sourceLen >> 25) + 13;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/crc32.h Thu Dec 15 15:57:51 2011 -0800
@@ -0,0 +1,465 @@
+/*
+ * 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.
+ */
+
+/* crc32.h -- tables for rapid CRC calculation
+ * Generated automatically by crc32.c
+ */
+
+local const unsigned long FAR crc_table[TBLS][256] =
+{
+ {
+ 0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL,
+ 0x706af48fUL, 0xe963a535UL, 0x9e6495a3UL, 0x0edb8832UL, 0x79dcb8a4UL,
+ 0xe0d5e91eUL, 0x97d2d988UL, 0x09b64c2bUL, 0x7eb17cbdUL, 0xe7b82d07UL,
+ 0x90bf1d91UL, 0x1db71064UL, 0x6ab020f2UL, 0xf3b97148UL, 0x84be41deUL,
+ 0x1adad47dUL, 0x6ddde4ebUL, 0xf4d4b551UL, 0x83d385c7UL, 0x136c9856UL,
+ 0x646ba8c0UL, 0xfd62f97aUL, 0x8a65c9ecUL, 0x14015c4fUL, 0x63066cd9UL,
+ 0xfa0f3d63UL, 0x8d080df5UL, 0x3b6e20c8UL, 0x4c69105eUL, 0xd56041e4UL,
+ 0xa2677172UL, 0x3c03e4d1UL, 0x4b04d447UL, 0xd20d85fdUL, 0xa50ab56bUL,
+ 0x35b5a8faUL, 0x42b2986cUL, 0xdbbbc9d6UL, 0xacbcf940UL, 0x32d86ce3UL,
+ 0x45df5c75UL, 0xdcd60dcfUL, 0xabd13d59UL, 0x26d930acUL, 0x51de003aUL,
+ 0xc8d75180UL, 0xbfd06116UL, 0x21b4f4b5UL, 0x56b3c423UL, 0xcfba9599UL,
+ 0xb8bda50fUL, 0x2802b89eUL, 0x5f058808UL, 0xc60cd9b2UL, 0xb10be924UL,
+ 0x2f6f7c87UL, 0x58684c11UL, 0xc1611dabUL, 0xb6662d3dUL, 0x76dc4190UL,
+ 0x01db7106UL, 0x98d220bcUL, 0xefd5102aUL, 0x71b18589UL, 0x06b6b51fUL,
+ 0x9fbfe4a5UL, 0xe8b8d433UL, 0x7807c9a2UL, 0x0f00f934UL, 0x9609a88eUL,
+ 0xe10e9818UL, 0x7f6a0dbbUL, 0x086d3d2dUL, 0x91646c97UL, 0xe6635c01UL,
+ 0x6b6b51f4UL, 0x1c6c6162UL, 0x856530d8UL, 0xf262004eUL, 0x6c0695edUL,
+ 0x1b01a57bUL, 0x8208f4c1UL, 0xf50fc457UL, 0x65b0d9c6UL, 0x12b7e950UL,
+ 0x8bbeb8eaUL, 0xfcb9887cUL, 0x62dd1ddfUL, 0x15da2d49UL, 0x8cd37cf3UL,
+ 0xfbd44c65UL, 0x4db26158UL, 0x3ab551ceUL, 0xa3bc0074UL, 0xd4bb30e2UL,
+ 0x4adfa541UL, 0x3dd895d7UL, 0xa4d1c46dUL, 0xd3d6f4fbUL, 0x4369e96aUL,
+ 0x346ed9fcUL, 0xad678846UL, 0xda60b8d0UL, 0x44042d73UL, 0x33031de5UL,
+ 0xaa0a4c5fUL, 0xdd0d7cc9UL, 0x5005713cUL, 0x270241aaUL, 0xbe0b1010UL,
+ 0xc90c2086UL, 0x5768b525UL, 0x206f85b3UL, 0xb966d409UL, 0xce61e49fUL,
+ 0x5edef90eUL, 0x29d9c998UL, 0xb0d09822UL, 0xc7d7a8b4UL, 0x59b33d17UL,
+ 0x2eb40d81UL, 0xb7bd5c3bUL, 0xc0ba6cadUL, 0xedb88320UL, 0x9abfb3b6UL,
+ 0x03b6e20cUL, 0x74b1d29aUL, 0xead54739UL, 0x9dd277afUL, 0x04db2615UL,
+ 0x73dc1683UL, 0xe3630b12UL, 0x94643b84UL, 0x0d6d6a3eUL, 0x7a6a5aa8UL,
+ 0xe40ecf0bUL, 0x9309ff9dUL, 0x0a00ae27UL, 0x7d079eb1UL, 0xf00f9344UL,
+ 0x8708a3d2UL, 0x1e01f268UL, 0x6906c2feUL, 0xf762575dUL, 0x806567cbUL,
+ 0x196c3671UL, 0x6e6b06e7UL, 0xfed41b76UL, 0x89d32be0UL, 0x10da7a5aUL,
+ 0x67dd4accUL, 0xf9b9df6fUL, 0x8ebeeff9UL, 0x17b7be43UL, 0x60b08ed5UL,
+ 0xd6d6a3e8UL, 0xa1d1937eUL, 0x38d8c2c4UL, 0x4fdff252UL, 0xd1bb67f1UL,
+ 0xa6bc5767UL, 0x3fb506ddUL, 0x48b2364bUL, 0xd80d2bdaUL, 0xaf0a1b4cUL,
+ 0x36034af6UL, 0x41047a60UL, 0xdf60efc3UL, 0xa867df55UL, 0x316e8eefUL,
+ 0x4669be79UL, 0xcb61b38cUL, 0xbc66831aUL, 0x256fd2a0UL, 0x5268e236UL,
+ 0xcc0c7795UL, 0xbb0b4703UL, 0x220216b9UL, 0x5505262fUL, 0xc5ba3bbeUL,
+ 0xb2bd0b28UL, 0x2bb45a92UL, 0x5cb36a04UL, 0xc2d7ffa7UL, 0xb5d0cf31UL,
+ 0x2cd99e8bUL, 0x5bdeae1dUL, 0x9b64c2b0UL, 0xec63f226UL, 0x756aa39cUL,
+ 0x026d930aUL, 0x9c0906a9UL, 0xeb0e363fUL, 0x72076785UL, 0x05005713UL,
+ 0x95bf4a82UL, 0xe2b87a14UL, 0x7bb12baeUL, 0x0cb61b38UL, 0x92d28e9bUL,
+ 0xe5d5be0dUL, 0x7cdcefb7UL, 0x0bdbdf21UL, 0x86d3d2d4UL, 0xf1d4e242UL,
+ 0x68ddb3f8UL, 0x1fda836eUL, 0x81be16cdUL, 0xf6b9265bUL, 0x6fb077e1UL,
+ 0x18b74777UL, 0x88085ae6UL, 0xff0f6a70UL, 0x66063bcaUL, 0x11010b5cUL,
+ 0x8f659effUL, 0xf862ae69UL, 0x616bffd3UL, 0x166ccf45UL, 0xa00ae278UL,
+ 0xd70dd2eeUL, 0x4e048354UL, 0x3903b3c2UL, 0xa7672661UL, 0xd06016f7UL,
+ 0x4969474dUL, 0x3e6e77dbUL, 0xaed16a4aUL, 0xd9d65adcUL, 0x40df0b66UL,
+ 0x37d83bf0UL, 0xa9bcae53UL, 0xdebb9ec5UL, 0x47b2cf7fUL, 0x30b5ffe9UL,
+ 0xbdbdf21cUL, 0xcabac28aUL, 0x53b39330UL, 0x24b4a3a6UL, 0xbad03605UL,
+ 0xcdd70693UL, 0x54de5729UL, 0x23d967bfUL, 0xb3667a2eUL, 0xc4614ab8UL,
+ 0x5d681b02UL, 0x2a6f2b94UL, 0xb40bbe37UL, 0xc30c8ea1UL, 0x5a05df1bUL,
+ 0x2d02ef8dUL
+#ifdef BYFOUR
+ },
+ {
+ 0x00000000UL, 0x191b3141UL, 0x32366282UL, 0x2b2d53c3UL, 0x646cc504UL,
+ 0x7d77f445UL, 0x565aa786UL, 0x4f4196c7UL, 0xc8d98a08UL, 0xd1c2bb49UL,
+ 0xfaefe88aUL, 0xe3f4d9cbUL, 0xacb54f0cUL, 0xb5ae7e4dUL, 0x9e832d8eUL,
+ 0x87981ccfUL, 0x4ac21251UL, 0x53d92310UL, 0x78f470d3UL, 0x61ef4192UL,
+ 0x2eaed755UL, 0x37b5e614UL, 0x1c98b5d7UL, 0x05838496UL, 0x821b9859UL,
+ 0x9b00a918UL, 0xb02dfadbUL, 0xa936cb9aUL, 0xe6775d5dUL, 0xff6c6c1cUL,
+ 0xd4413fdfUL, 0xcd5a0e9eUL, 0x958424a2UL, 0x8c9f15e3UL, 0xa7b24620UL,
+ 0xbea97761UL, 0xf1e8e1a6UL, 0xe8f3d0e7UL, 0xc3de8324UL, 0xdac5b265UL,
+ 0x5d5daeaaUL, 0x44469febUL, 0x6f6bcc28UL, 0x7670fd69UL, 0x39316baeUL,
+ 0x202a5aefUL, 0x0b07092cUL, 0x121c386dUL, 0xdf4636f3UL, 0xc65d07b2UL,
+ 0xed705471UL, 0xf46b6530UL, 0xbb2af3f7UL, 0xa231c2b6UL, 0x891c9175UL,
+ 0x9007a034UL, 0x179fbcfbUL, 0x0e848dbaUL, 0x25a9de79UL, 0x3cb2ef38UL,
+ 0x73f379ffUL, 0x6ae848beUL, 0x41c51b7dUL, 0x58de2a3cUL, 0xf0794f05UL,
+ 0xe9627e44UL, 0xc24f2d87UL, 0xdb541cc6UL, 0x94158a01UL, 0x8d0ebb40UL,
+ 0xa623e883UL, 0xbf38d9c2UL, 0x38a0c50dUL, 0x21bbf44cUL, 0x0a96a78fUL,
+ 0x138d96ceUL, 0x5ccc0009UL, 0x45d73148UL, 0x6efa628bUL, 0x77e153caUL,
+ 0xbabb5d54UL, 0xa3a06c15UL, 0x888d3fd6UL, 0x91960e97UL, 0xded79850UL,
+ 0xc7cca911UL, 0xece1fad2UL, 0xf5facb93UL, 0x7262d75cUL, 0x6b79e61dUL,
+ 0x4054b5deUL, 0x594f849fUL, 0x160e1258UL, 0x0f152319UL, 0x243870daUL,
+ 0x3d23419bUL, 0x65fd6ba7UL, 0x7ce65ae6UL, 0x57cb0925UL, 0x4ed03864UL,
+ 0x0191aea3UL, 0x188a9fe2UL, 0x33a7cc21UL, 0x2abcfd60UL, 0xad24e1afUL,
+ 0xb43fd0eeUL, 0x9f12832dUL, 0x8609b26cUL, 0xc94824abUL, 0xd05315eaUL,
+ 0xfb7e4629UL, 0xe2657768UL, 0x2f3f79f6UL, 0x362448b7UL, 0x1d091b74UL,
+ 0x04122a35UL, 0x4b53bcf2UL, 0x52488db3UL, 0x7965de70UL, 0x607eef31UL,
+ 0xe7e6f3feUL, 0xfefdc2bfUL, 0xd5d0917cUL, 0xcccba03dUL, 0x838a36faUL,
+ 0x9a9107bbUL, 0xb1bc5478UL, 0xa8a76539UL, 0x3b83984bUL, 0x2298a90aUL,
+ 0x09b5fac9UL, 0x10aecb88UL, 0x5fef5d4fUL, 0x46f46c0eUL, 0x6dd93fcdUL,
+ 0x74c20e8cUL, 0xf35a1243UL, 0xea412302UL, 0xc16c70c1UL, 0xd8774180UL,
+ 0x9736d747UL, 0x8e2de606UL, 0xa500b5c5UL, 0xbc1b8484UL, 0x71418a1aUL,
+ 0x685abb5bUL, 0x4377e898UL, 0x5a6cd9d9UL, 0x152d4f1eUL, 0x0c367e5fUL,
+ 0x271b2d9cUL, 0x3e001cddUL, 0xb9980012UL, 0xa0833153UL, 0x8bae6290UL,
+ 0x92b553d1UL, 0xddf4c516UL, 0xc4eff457UL, 0xefc2a794UL, 0xf6d996d5UL,
+ 0xae07bce9UL, 0xb71c8da8UL, 0x9c31de6bUL, 0x852aef2aUL, 0xca6b79edUL,
+ 0xd37048acUL, 0xf85d1b6fUL, 0xe1462a2eUL, 0x66de36e1UL, 0x7fc507a0UL,
+ 0x54e85463UL, 0x4df36522UL, 0x02b2f3e5UL, 0x1ba9c2a4UL, 0x30849167UL,
+ 0x299fa026UL, 0xe4c5aeb8UL, 0xfdde9ff9UL, 0xd6f3cc3aUL, 0xcfe8fd7bUL,
+ 0x80a96bbcUL, 0x99b25afdUL, 0xb29f093eUL, 0xab84387fUL, 0x2c1c24b0UL,
+ 0x350715f1UL, 0x1e2a4632UL, 0x07317773UL, 0x4870e1b4UL, 0x516bd0f5UL,
+ 0x7a468336UL, 0x635db277UL, 0xcbfad74eUL, 0xd2e1e60fUL, 0xf9ccb5ccUL,
+ 0xe0d7848dUL, 0xaf96124aUL, 0xb68d230bUL, 0x9da070c8UL, 0x84bb4189UL,
+ 0x03235d46UL, 0x1a386c07UL, 0x31153fc4UL, 0x280e0e85UL, 0x674f9842UL,
+ 0x7e54a903UL, 0x5579fac0UL, 0x4c62cb81UL, 0x8138c51fUL, 0x9823f45eUL,
+ 0xb30ea79dUL, 0xaa1596dcUL, 0xe554001bUL, 0xfc4f315aUL, 0xd7626299UL,
+ 0xce7953d8UL, 0x49e14f17UL, 0x50fa7e56UL, 0x7bd72d95UL, 0x62cc1cd4UL,
+ 0x2d8d8a13UL, 0x3496bb52UL, 0x1fbbe891UL, 0x06a0d9d0UL, 0x5e7ef3ecUL,
+ 0x4765c2adUL, 0x6c48916eUL, 0x7553a02fUL, 0x3a1236e8UL, 0x230907a9UL,
+ 0x0824546aUL, 0x113f652bUL, 0x96a779e4UL, 0x8fbc48a5UL, 0xa4911b66UL,
+ 0xbd8a2a27UL, 0xf2cbbce0UL, 0xebd08da1UL, 0xc0fdde62UL, 0xd9e6ef23UL,
+ 0x14bce1bdUL, 0x0da7d0fcUL, 0x268a833fUL, 0x3f91b27eUL, 0x70d024b9UL,
+ 0x69cb15f8UL, 0x42e6463bUL, 0x5bfd777aUL, 0xdc656bb5UL, 0xc57e5af4UL,
+ 0xee530937UL, 0xf7483876UL, 0xb809aeb1UL, 0xa1129ff0UL, 0x8a3fcc33UL,
+ 0x9324fd72UL
+ },
+ {
+ 0x00000000UL, 0x01c26a37UL, 0x0384d46eUL, 0x0246be59UL, 0x0709a8dcUL,
+ 0x06cbc2ebUL, 0x048d7cb2UL, 0x054f1685UL, 0x0e1351b8UL, 0x0fd13b8fUL,
+ 0x0d9785d6UL, 0x0c55efe1UL, 0x091af964UL, 0x08d89353UL, 0x0a9e2d0aUL,
+ 0x0b5c473dUL, 0x1c26a370UL, 0x1de4c947UL, 0x1fa2771eUL, 0x1e601d29UL,
+ 0x1b2f0bacUL, 0x1aed619bUL, 0x18abdfc2UL, 0x1969b5f5UL, 0x1235f2c8UL,
+ 0x13f798ffUL, 0x11b126a6UL, 0x10734c91UL, 0x153c5a14UL, 0x14fe3023UL,
+ 0x16b88e7aUL, 0x177ae44dUL, 0x384d46e0UL, 0x398f2cd7UL, 0x3bc9928eUL,
+ 0x3a0bf8b9UL, 0x3f44ee3cUL, 0x3e86840bUL, 0x3cc03a52UL, 0x3d025065UL,
+ 0x365e1758UL, 0x379c7d6fUL, 0x35dac336UL, 0x3418a901UL, 0x3157bf84UL,
+ 0x3095d5b3UL, 0x32d36beaUL, 0x331101ddUL, 0x246be590UL, 0x25a98fa7UL,
+ 0x27ef31feUL, 0x262d5bc9UL, 0x23624d4cUL, 0x22a0277bUL, 0x20e69922UL,
+ 0x2124f315UL, 0x2a78b428UL, 0x2bbade1fUL, 0x29fc6046UL, 0x283e0a71UL,
+ 0x2d711cf4UL, 0x2cb376c3UL, 0x2ef5c89aUL, 0x2f37a2adUL, 0x709a8dc0UL,
+ 0x7158e7f7UL, 0x731e59aeUL, 0x72dc3399UL, 0x7793251cUL, 0x76514f2bUL,
+ 0x7417f172UL, 0x75d59b45UL, 0x7e89dc78UL, 0x7f4bb64fUL, 0x7d0d0816UL,
+ 0x7ccf6221UL, 0x798074a4UL, 0x78421e93UL, 0x7a04a0caUL, 0x7bc6cafdUL,
+ 0x6cbc2eb0UL, 0x6d7e4487UL, 0x6f38fadeUL, 0x6efa90e9UL, 0x6bb5866cUL,
+ 0x6a77ec5bUL, 0x68315202UL, 0x69f33835UL, 0x62af7f08UL, 0x636d153fUL,
+ 0x612bab66UL, 0x60e9c151UL, 0x65a6d7d4UL, 0x6464bde3UL, 0x662203baUL,
+ 0x67e0698dUL, 0x48d7cb20UL, 0x4915a117UL, 0x4b531f4eUL, 0x4a917579UL,
+ 0x4fde63fcUL, 0x4e1c09cbUL, 0x4c5ab792UL, 0x4d98dda5UL, 0x46c49a98UL,
+ 0x4706f0afUL, 0x45404ef6UL, 0x448224c1UL, 0x41cd3244UL, 0x400f5873UL,
+ 0x4249e62aUL, 0x438b8c1dUL, 0x54f16850UL, 0x55330267UL, 0x5775bc3eUL,
+ 0x56b7d609UL, 0x53f8c08cUL, 0x523aaabbUL, 0x507c14e2UL, 0x51be7ed5UL,
+ 0x5ae239e8UL, 0x5b2053dfUL, 0x5966ed86UL, 0x58a487b1UL, 0x5deb9134UL,
+ 0x5c29fb03UL, 0x5e6f455aUL, 0x5fad2f6dUL, 0xe1351b80UL, 0xe0f771b7UL,
+ 0xe2b1cfeeUL, 0xe373a5d9UL, 0xe63cb35cUL, 0xe7fed96bUL, 0xe5b86732UL,
+ 0xe47a0d05UL, 0xef264a38UL, 0xeee4200fUL, 0xeca29e56UL, 0xed60f461UL,
+ 0xe82fe2e4UL, 0xe9ed88d3UL, 0xebab368aUL, 0xea695cbdUL, 0xfd13b8f0UL,
+ 0xfcd1d2c7UL, 0xfe976c9eUL, 0xff5506a9UL, 0xfa1a102cUL, 0xfbd87a1bUL,
+ 0xf99ec442UL, 0xf85cae75UL, 0xf300e948UL, 0xf2c2837fUL, 0xf0843d26UL,
+ 0xf1465711UL, 0xf4094194UL, 0xf5cb2ba3UL, 0xf78d95faUL, 0xf64fffcdUL,
+ 0xd9785d60UL, 0xd8ba3757UL, 0xdafc890eUL, 0xdb3ee339UL, 0xde71f5bcUL,
+ 0xdfb39f8bUL, 0xddf521d2UL, 0xdc374be5UL, 0xd76b0cd8UL, 0xd6a966efUL,
+ 0xd4efd8b6UL, 0xd52db281UL, 0xd062a404UL, 0xd1a0ce33UL, 0xd3e6706aUL,
+ 0xd2241a5dUL, 0xc55efe10UL, 0xc49c9427UL, 0xc6da2a7eUL, 0xc7184049UL,
+ 0xc25756ccUL, 0xc3953cfbUL, 0xc1d382a2UL, 0xc011e895UL, 0xcb4dafa8UL,
+ 0xca8fc59fUL, 0xc8c97bc6UL, 0xc90b11f1UL, 0xcc440774UL, 0xcd866d43UL,
+ 0xcfc0d31aUL, 0xce02b92dUL, 0x91af9640UL, 0x906dfc77UL, 0x922b422eUL,
+ 0x93e92819UL, 0x96a63e9cUL, 0x976454abUL, 0x9522eaf2UL, 0x94e080c5UL,
+ 0x9fbcc7f8UL, 0x9e7eadcfUL, 0x9c381396UL, 0x9dfa79a1UL, 0x98b56f24UL,
+ 0x99770513UL, 0x9b31bb4aUL, 0x9af3d17dUL, 0x8d893530UL, 0x8c4b5f07UL,
+ 0x8e0de15eUL, 0x8fcf8b69UL, 0x8a809decUL, 0x8b42f7dbUL, 0x89044982UL,
+ 0x88c623b5UL, 0x839a6488UL, 0x82580ebfUL, 0x801eb0e6UL, 0x81dcdad1UL,
+ 0x8493cc54UL, 0x8551a663UL, 0x8717183aUL, 0x86d5720dUL, 0xa9e2d0a0UL,
+ 0xa820ba97UL, 0xaa6604ceUL, 0xaba46ef9UL, 0xaeeb787cUL, 0xaf29124bUL,
+ 0xad6fac12UL, 0xacadc625UL, 0xa7f18118UL, 0xa633eb2fUL, 0xa4755576UL,
+ 0xa5b73f41UL, 0xa0f829c4UL, 0xa13a43f3UL, 0xa37cfdaaUL, 0xa2be979dUL,
+ 0xb5c473d0UL, 0xb40619e7UL, 0xb640a7beUL, 0xb782cd89UL, 0xb2cddb0cUL,
+ 0xb30fb13bUL, 0xb1490f62UL, 0xb08b6555UL, 0xbbd72268UL, 0xba15485fUL,
+ 0xb853f606UL, 0xb9919c31UL, 0xbcde8ab4UL, 0xbd1ce083UL, 0xbf5a5edaUL,
+ 0xbe9834edUL
+ },
+ {
+ 0x00000000UL, 0xb8bc6765UL, 0xaa09c88bUL, 0x12b5afeeUL, 0x8f629757UL,
+ 0x37def032UL, 0x256b5fdcUL, 0x9dd738b9UL, 0xc5b428efUL, 0x7d084f8aUL,
+ 0x6fbde064UL, 0xd7018701UL, 0x4ad6bfb8UL, 0xf26ad8ddUL, 0xe0df7733UL,
+ 0x58631056UL, 0x5019579fUL, 0xe8a530faUL, 0xfa109f14UL, 0x42acf871UL,
+ 0xdf7bc0c8UL, 0x67c7a7adUL, 0x75720843UL, 0xcdce6f26UL, 0x95ad7f70UL,
+ 0x2d111815UL, 0x3fa4b7fbUL, 0x8718d09eUL, 0x1acfe827UL, 0xa2738f42UL,
+ 0xb0c620acUL, 0x087a47c9UL, 0xa032af3eUL, 0x188ec85bUL, 0x0a3b67b5UL,
+ 0xb28700d0UL, 0x2f503869UL, 0x97ec5f0cUL, 0x8559f0e2UL, 0x3de59787UL,
+ 0x658687d1UL, 0xdd3ae0b4UL, 0xcf8f4f5aUL, 0x7733283fUL, 0xeae41086UL,
+ 0x525877e3UL, 0x40edd80dUL, 0xf851bf68UL, 0xf02bf8a1UL, 0x48979fc4UL,
+ 0x5a22302aUL, 0xe29e574fUL, 0x7f496ff6UL, 0xc7f50893UL, 0xd540a77dUL,
+ 0x6dfcc018UL, 0x359fd04eUL, 0x8d23b72bUL, 0x9f9618c5UL, 0x272a7fa0UL,
+ 0xbafd4719UL, 0x0241207cUL, 0x10f48f92UL, 0xa848e8f7UL, 0x9b14583dUL,
+ 0x23a83f58UL, 0x311d90b6UL, 0x89a1f7d3UL, 0x1476cf6aUL, 0xaccaa80fUL,
+ 0xbe7f07e1UL, 0x06c36084UL, 0x5ea070d2UL, 0xe61c17b7UL, 0xf4a9b859UL,
+ 0x4c15df3cUL, 0xd1c2e785UL, 0x697e80e0UL, 0x7bcb2f0eUL, 0xc377486bUL,
+ 0xcb0d0fa2UL, 0x73b168c7UL, 0x6104c729UL, 0xd9b8a04cUL, 0x446f98f5UL,
+ 0xfcd3ff90UL, 0xee66507eUL, 0x56da371bUL, 0x0eb9274dUL, 0xb6054028UL,
+ 0xa4b0efc6UL, 0x1c0c88a3UL, 0x81dbb01aUL, 0x3967d77fUL, 0x2bd27891UL,
+ 0x936e1ff4UL, 0x3b26f703UL, 0x839a9066UL, 0x912f3f88UL, 0x299358edUL,
+ 0xb4446054UL, 0x0cf80731UL, 0x1e4da8dfUL, 0xa6f1cfbaUL, 0xfe92dfecUL,
+ 0x462eb889UL, 0x549b1767UL, 0xec277002UL, 0x71f048bbUL, 0xc94c2fdeUL,
+ 0xdbf98030UL, 0x6345e755UL, 0x6b3fa09cUL, 0xd383c7f9UL, 0xc1366817UL,
+ 0x798a0f72UL, 0xe45d37cbUL, 0x5ce150aeUL, 0x4e54ff40UL, 0xf6e89825UL,
+ 0xae8b8873UL, 0x1637ef16UL, 0x048240f8UL, 0xbc3e279dUL, 0x21e91f24UL,
+ 0x99557841UL, 0x8be0d7afUL, 0x335cb0caUL, 0xed59b63bUL, 0x55e5d15eUL,
+ 0x47507eb0UL, 0xffec19d5UL, 0x623b216cUL, 0xda874609UL, 0xc832e9e7UL,
+ 0x708e8e82UL, 0x28ed9ed4UL, 0x9051f9b1UL, 0x82e4565fUL, 0x3a58313aUL,
+ 0xa78f0983UL, 0x1f336ee6UL, 0x0d86c108UL, 0xb53aa66dUL, 0xbd40e1a4UL,
+ 0x05fc86c1UL, 0x1749292fUL, 0xaff54e4aUL, 0x322276f3UL, 0x8a9e1196UL,
+ 0x982bbe78UL, 0x2097d91dUL, 0x78f4c94bUL, 0xc048ae2eUL, 0xd2fd01c0UL,
+ 0x6a4166a5UL, 0xf7965e1cUL, 0x4f2a3979UL, 0x5d9f9697UL, 0xe523f1f2UL,
+ 0x4d6b1905UL, 0xf5d77e60UL, 0xe762d18eUL, 0x5fdeb6ebUL, 0xc2098e52UL,
+ 0x7ab5e937UL, 0x680046d9UL, 0xd0bc21bcUL, 0x88df31eaUL, 0x3063568fUL,
+ 0x22d6f961UL, 0x9a6a9e04UL, 0x07bda6bdUL, 0xbf01c1d8UL, 0xadb46e36UL,
+ 0x15080953UL, 0x1d724e9aUL, 0xa5ce29ffUL, 0xb77b8611UL, 0x0fc7e174UL,
+ 0x9210d9cdUL, 0x2aacbea8UL, 0x38191146UL, 0x80a57623UL, 0xd8c66675UL,
+ 0x607a0110UL, 0x72cfaefeUL, 0xca73c99bUL, 0x57a4f122UL, 0xef189647UL,
+ 0xfdad39a9UL, 0x45115eccUL, 0x764dee06UL, 0xcef18963UL, 0xdc44268dUL,
+ 0x64f841e8UL, 0xf92f7951UL, 0x41931e34UL, 0x5326b1daUL, 0xeb9ad6bfUL,
+ 0xb3f9c6e9UL, 0x0b45a18cUL, 0x19f00e62UL, 0xa14c6907UL, 0x3c9b51beUL,
+ 0x842736dbUL, 0x96929935UL, 0x2e2efe50UL, 0x2654b999UL, 0x9ee8defcUL,
+ 0x8c5d7112UL, 0x34e11677UL, 0xa9362eceUL, 0x118a49abUL, 0x033fe645UL,
+ 0xbb838120UL, 0xe3e09176UL, 0x5b5cf613UL, 0x49e959fdUL, 0xf1553e98UL,
+ 0x6c820621UL, 0xd43e6144UL, 0xc68bceaaUL, 0x7e37a9cfUL, 0xd67f4138UL,
+ 0x6ec3265dUL, 0x7c7689b3UL, 0xc4caeed6UL, 0x591dd66fUL, 0xe1a1b10aUL,
+ 0xf3141ee4UL, 0x4ba87981UL, 0x13cb69d7UL, 0xab770eb2UL, 0xb9c2a15cUL,
+ 0x017ec639UL, 0x9ca9fe80UL, 0x241599e5UL, 0x36a0360bUL, 0x8e1c516eUL,
+ 0x866616a7UL, 0x3eda71c2UL, 0x2c6fde2cUL, 0x94d3b949UL, 0x090481f0UL,
+ 0xb1b8e695UL, 0xa30d497bUL, 0x1bb12e1eUL, 0x43d23e48UL, 0xfb6e592dUL,
+ 0xe9dbf6c3UL, 0x516791a6UL, 0xccb0a91fUL, 0x740cce7aUL, 0x66b96194UL,
+ 0xde0506f1UL
+ },
+ {
+ 0x00000000UL, 0x96300777UL, 0x2c610eeeUL, 0xba510999UL, 0x19c46d07UL,
+ 0x8ff46a70UL, 0x35a563e9UL, 0xa395649eUL, 0x3288db0eUL, 0xa4b8dc79UL,
+ 0x1ee9d5e0UL, 0x88d9d297UL, 0x2b4cb609UL, 0xbd7cb17eUL, 0x072db8e7UL,
+ 0x911dbf90UL, 0x6410b71dUL, 0xf220b06aUL, 0x4871b9f3UL, 0xde41be84UL,
+ 0x7dd4da1aUL, 0xebe4dd6dUL, 0x51b5d4f4UL, 0xc785d383UL, 0x56986c13UL,
+ 0xc0a86b64UL, 0x7af962fdUL, 0xecc9658aUL, 0x4f5c0114UL, 0xd96c0663UL,
+ 0x633d0ffaUL, 0xf50d088dUL, 0xc8206e3bUL, 0x5e10694cUL, 0xe44160d5UL,
+ 0x727167a2UL, 0xd1e4033cUL, 0x47d4044bUL, 0xfd850dd2UL, 0x6bb50aa5UL,
+ 0xfaa8b535UL, 0x6c98b242UL, 0xd6c9bbdbUL, 0x40f9bcacUL, 0xe36cd832UL,
+ 0x755cdf45UL, 0xcf0dd6dcUL, 0x593dd1abUL, 0xac30d926UL, 0x3a00de51UL,
+ 0x8051d7c8UL, 0x1661d0bfUL, 0xb5f4b421UL, 0x23c4b356UL, 0x9995bacfUL,
+ 0x0fa5bdb8UL, 0x9eb80228UL, 0x0888055fUL, 0xb2d90cc6UL, 0x24e90bb1UL,
+ 0x877c6f2fUL, 0x114c6858UL, 0xab1d61c1UL, 0x3d2d66b6UL, 0x9041dc76UL,
+ 0x0671db01UL, 0xbc20d298UL, 0x2a10d5efUL, 0x8985b171UL, 0x1fb5b606UL,
+ 0xa5e4bf9fUL, 0x33d4b8e8UL, 0xa2c90778UL, 0x34f9000fUL, 0x8ea80996UL,
+ 0x18980ee1UL, 0xbb0d6a7fUL, 0x2d3d6d08UL, 0x976c6491UL, 0x015c63e6UL,
+ 0xf4516b6bUL, 0x62616c1cUL, 0xd8306585UL, 0x4e0062f2UL, 0xed95066cUL,
+ 0x7ba5011bUL, 0xc1f40882UL, 0x57c40ff5UL, 0xc6d9b065UL, 0x50e9b712UL,
+ 0xeab8be8bUL, 0x7c88b9fcUL, 0xdf1ddd62UL, 0x492dda15UL, 0xf37cd38cUL,
+ 0x654cd4fbUL, 0x5861b24dUL, 0xce51b53aUL, 0x7400bca3UL, 0xe230bbd4UL,
+ 0x41a5df4aUL, 0xd795d83dUL, 0x6dc4d1a4UL, 0xfbf4d6d3UL, 0x6ae96943UL,
+ 0xfcd96e34UL, 0x468867adUL, 0xd0b860daUL, 0x732d0444UL, 0xe51d0333UL,
+ 0x5f4c0aaaUL, 0xc97c0dddUL, 0x3c710550UL, 0xaa410227UL, 0x10100bbeUL,
+ 0x86200cc9UL, 0x25b56857UL, 0xb3856f20UL, 0x09d466b9UL, 0x9fe461ceUL,
+ 0x0ef9de5eUL, 0x98c9d929UL, 0x2298d0b0UL, 0xb4a8d7c7UL, 0x173db359UL,
+ 0x810db42eUL, 0x3b5cbdb7UL, 0xad6cbac0UL, 0x2083b8edUL, 0xb6b3bf9aUL,
+ 0x0ce2b603UL, 0x9ad2b174UL, 0x3947d5eaUL, 0xaf77d29dUL, 0x1526db04UL,
+ 0x8316dc73UL, 0x120b63e3UL, 0x843b6494UL, 0x3e6a6d0dUL, 0xa85a6a7aUL,
+ 0x0bcf0ee4UL, 0x9dff0993UL, 0x27ae000aUL, 0xb19e077dUL, 0x44930ff0UL,
+ 0xd2a30887UL, 0x68f2011eUL, 0xfec20669UL, 0x5d5762f7UL, 0xcb676580UL,
+ 0x71366c19UL, 0xe7066b6eUL, 0x761bd4feUL, 0xe02bd389UL, 0x5a7ada10UL,
+ 0xcc4add67UL, 0x6fdfb9f9UL, 0xf9efbe8eUL, 0x43beb717UL, 0xd58eb060UL,
+ 0xe8a3d6d6UL, 0x7e93d1a1UL, 0xc4c2d838UL, 0x52f2df4fUL, 0xf167bbd1UL,
+ 0x6757bca6UL, 0xdd06b53fUL, 0x4b36b248UL, 0xda2b0dd8UL, 0x4c1b0aafUL,
+ 0xf64a0336UL, 0x607a0441UL, 0xc3ef60dfUL, 0x55df67a8UL, 0xef8e6e31UL,
+ 0x79be6946UL, 0x8cb361cbUL, 0x1a8366bcUL, 0xa0d26f25UL, 0x36e26852UL,
+ 0x95770cccUL, 0x03470bbbUL, 0xb9160222UL, 0x2f260555UL, 0xbe3bbac5UL,
+ 0x280bbdb2UL, 0x925ab42bUL, 0x046ab35cUL, 0xa7ffd7c2UL, 0x31cfd0b5UL,
+ 0x8b9ed92cUL, 0x1daede5bUL, 0xb0c2649bUL, 0x26f263ecUL, 0x9ca36a75UL,
+ 0x0a936d02UL, 0xa906099cUL, 0x3f360eebUL, 0x85670772UL, 0x13570005UL,
+ 0x824abf95UL, 0x147ab8e2UL, 0xae2bb17bUL, 0x381bb60cUL, 0x9b8ed292UL,
+ 0x0dbed5e5UL, 0xb7efdc7cUL, 0x21dfdb0bUL, 0xd4d2d386UL, 0x42e2d4f1UL,
+ 0xf8b3dd68UL, 0x6e83da1fUL, 0xcd16be81UL, 0x5b26b9f6UL, 0xe177b06fUL,
+ 0x7747b718UL, 0xe65a0888UL, 0x706a0fffUL, 0xca3b0666UL, 0x5c0b0111UL,
+ 0xff9e658fUL, 0x69ae62f8UL, 0xd3ff6b61UL, 0x45cf6c16UL, 0x78e20aa0UL,
+ 0xeed20dd7UL, 0x5483044eUL, 0xc2b30339UL, 0x612667a7UL, 0xf71660d0UL,
+ 0x4d476949UL, 0xdb776e3eUL, 0x4a6ad1aeUL, 0xdc5ad6d9UL, 0x660bdf40UL,
+ 0xf03bd837UL, 0x53aebca9UL, 0xc59ebbdeUL, 0x7fcfb247UL, 0xe9ffb530UL,
+ 0x1cf2bdbdUL, 0x8ac2bacaUL, 0x3093b353UL, 0xa6a3b424UL, 0x0536d0baUL,
+ 0x9306d7cdUL, 0x2957de54UL, 0xbf67d923UL, 0x2e7a66b3UL, 0xb84a61c4UL,
+ 0x021b685dUL, 0x942b6f2aUL, 0x37be0bb4UL, 0xa18e0cc3UL, 0x1bdf055aUL,
+ 0x8def022dUL
+ },
+ {
+ 0x00000000UL, 0x41311b19UL, 0x82623632UL, 0xc3532d2bUL, 0x04c56c64UL,
+ 0x45f4777dUL, 0x86a75a56UL, 0xc796414fUL, 0x088ad9c8UL, 0x49bbc2d1UL,
+ 0x8ae8effaUL, 0xcbd9f4e3UL, 0x0c4fb5acUL, 0x4d7eaeb5UL, 0x8e2d839eUL,
+ 0xcf1c9887UL, 0x5112c24aUL, 0x1023d953UL, 0xd370f478UL, 0x9241ef61UL,
+ 0x55d7ae2eUL, 0x14e6b537UL, 0xd7b5981cUL, 0x96848305UL, 0x59981b82UL,
+ 0x18a9009bUL, 0xdbfa2db0UL, 0x9acb36a9UL, 0x5d5d77e6UL, 0x1c6c6cffUL,
+ 0xdf3f41d4UL, 0x9e0e5acdUL, 0xa2248495UL, 0xe3159f8cUL, 0x2046b2a7UL,
+ 0x6177a9beUL, 0xa6e1e8f1UL, 0xe7d0f3e8UL, 0x2483dec3UL, 0x65b2c5daUL,
+ 0xaaae5d5dUL, 0xeb9f4644UL, 0x28cc6b6fUL, 0x69fd7076UL, 0xae6b3139UL,
+ 0xef5a2a20UL, 0x2c09070bUL, 0x6d381c12UL, 0xf33646dfUL, 0xb2075dc6UL,
+ 0x715470edUL, 0x30656bf4UL, 0xf7f32abbUL, 0xb6c231a2UL, 0x75911c89UL,
+ 0x34a00790UL, 0xfbbc9f17UL, 0xba8d840eUL, 0x79dea925UL, 0x38efb23cUL,
+ 0xff79f373UL, 0xbe48e86aUL, 0x7d1bc541UL, 0x3c2ade58UL, 0x054f79f0UL,
+ 0x447e62e9UL, 0x872d4fc2UL, 0xc61c54dbUL, 0x018a1594UL, 0x40bb0e8dUL,
+ 0x83e823a6UL, 0xc2d938bfUL, 0x0dc5a038UL, 0x4cf4bb21UL, 0x8fa7960aUL,
+ 0xce968d13UL, 0x0900cc5cUL, 0x4831d745UL, 0x8b62fa6eUL, 0xca53e177UL,
+ 0x545dbbbaUL, 0x156ca0a3UL, 0xd63f8d88UL, 0x970e9691UL, 0x5098d7deUL,
+ 0x11a9ccc7UL, 0xd2fae1ecUL, 0x93cbfaf5UL, 0x5cd76272UL, 0x1de6796bUL,
+ 0xdeb55440UL, 0x9f844f59UL, 0x58120e16UL, 0x1923150fUL, 0xda703824UL,
+ 0x9b41233dUL, 0xa76bfd65UL, 0xe65ae67cUL, 0x2509cb57UL, 0x6438d04eUL,
+ 0xa3ae9101UL, 0xe29f8a18UL, 0x21cca733UL, 0x60fdbc2aUL, 0xafe124adUL,
+ 0xeed03fb4UL, 0x2d83129fUL, 0x6cb20986UL, 0xab2448c9UL, 0xea1553d0UL,
+ 0x29467efbUL, 0x687765e2UL, 0xf6793f2fUL, 0xb7482436UL, 0x741b091dUL,
+ 0x352a1204UL, 0xf2bc534bUL, 0xb38d4852UL, 0x70de6579UL, 0x31ef7e60UL,
+ 0xfef3e6e7UL, 0xbfc2fdfeUL, 0x7c91d0d5UL, 0x3da0cbccUL, 0xfa368a83UL,
+ 0xbb07919aUL, 0x7854bcb1UL, 0x3965a7a8UL, 0x4b98833bUL, 0x0aa99822UL,
+ 0xc9fab509UL, 0x88cbae10UL, 0x4f5def5fUL, 0x0e6cf446UL, 0xcd3fd96dUL,
+ 0x8c0ec274UL, 0x43125af3UL, 0x022341eaUL, 0xc1706cc1UL, 0x804177d8UL,
+ 0x47d73697UL, 0x06e62d8eUL, 0xc5b500a5UL, 0x84841bbcUL, 0x1a8a4171UL,
+ 0x5bbb5a68UL, 0x98e87743UL, 0xd9d96c5aUL, 0x1e4f2d15UL, 0x5f7e360cUL,
+ 0x9c2d1b27UL, 0xdd1c003eUL, 0x120098b9UL, 0x533183a0UL, 0x9062ae8bUL,
+ 0xd153b592UL, 0x16c5f4ddUL, 0x57f4efc4UL, 0x94a7c2efUL, 0xd596d9f6UL,
+ 0xe9bc07aeUL, 0xa88d1cb7UL, 0x6bde319cUL, 0x2aef2a85UL, 0xed796bcaUL,
+ 0xac4870d3UL, 0x6f1b5df8UL, 0x2e2a46e1UL, 0xe136de66UL, 0xa007c57fUL,
+ 0x6354e854UL, 0x2265f34dUL, 0xe5f3b202UL, 0xa4c2a91bUL, 0x67918430UL,
+ 0x26a09f29UL, 0xb8aec5e4UL, 0xf99fdefdUL, 0x3accf3d6UL, 0x7bfde8cfUL,
+ 0xbc6ba980UL, 0xfd5ab299UL, 0x3e099fb2UL, 0x7f3884abUL, 0xb0241c2cUL,
+ 0xf1150735UL, 0x32462a1eUL, 0x73773107UL, 0xb4e17048UL, 0xf5d06b51UL,
+ 0x3683467aUL, 0x77b25d63UL, 0x4ed7facbUL, 0x0fe6e1d2UL, 0xccb5ccf9UL,
+ 0x8d84d7e0UL, 0x4a1296afUL, 0x0b238db6UL, 0xc870a09dUL, 0x8941bb84UL,
+ 0x465d2303UL, 0x076c381aUL, 0xc43f1531UL, 0x850e0e28UL, 0x42984f67UL,
+ 0x03a9547eUL, 0xc0fa7955UL, 0x81cb624cUL, 0x1fc53881UL, 0x5ef42398UL,
+ 0x9da70eb3UL, 0xdc9615aaUL, 0x1b0054e5UL, 0x5a314ffcUL, 0x996262d7UL,
+ 0xd85379ceUL, 0x174fe149UL, 0x567efa50UL, 0x952dd77bUL, 0xd41ccc62UL,
+ 0x138a8d2dUL, 0x52bb9634UL, 0x91e8bb1fUL, 0xd0d9a006UL, 0xecf37e5eUL,
+ 0xadc26547UL, 0x6e91486cUL, 0x2fa05375UL, 0xe836123aUL, 0xa9070923UL,
+ 0x6a542408UL, 0x2b653f11UL, 0xe479a796UL, 0xa548bc8fUL, 0x661b91a4UL,
+ 0x272a8abdUL, 0xe0bccbf2UL, 0xa18dd0ebUL, 0x62defdc0UL, 0x23efe6d9UL,
+ 0xbde1bc14UL, 0xfcd0a70dUL, 0x3f838a26UL, 0x7eb2913fUL, 0xb924d070UL,
+ 0xf815cb69UL, 0x3b46e642UL, 0x7a77fd5bUL, 0xb56b65dcUL, 0xf45a7ec5UL,
+ 0x370953eeUL, 0x763848f7UL, 0xb1ae09b8UL, 0xf09f12a1UL, 0x33cc3f8aUL,
+ 0x72fd2493UL
+ },
+ {
+ 0x00000000UL, 0x376ac201UL, 0x6ed48403UL, 0x59be4602UL, 0xdca80907UL,
+ 0xebc2cb06UL, 0xb27c8d04UL, 0x85164f05UL, 0xb851130eUL, 0x8f3bd10fUL,
+ 0xd685970dUL, 0xe1ef550cUL, 0x64f91a09UL, 0x5393d808UL, 0x0a2d9e0aUL,
+ 0x3d475c0bUL, 0x70a3261cUL, 0x47c9e41dUL, 0x1e77a21fUL, 0x291d601eUL,
+ 0xac0b2f1bUL, 0x9b61ed1aUL, 0xc2dfab18UL, 0xf5b56919UL, 0xc8f23512UL,
+ 0xff98f713UL, 0xa626b111UL, 0x914c7310UL, 0x145a3c15UL, 0x2330fe14UL,
+ 0x7a8eb816UL, 0x4de47a17UL, 0xe0464d38UL, 0xd72c8f39UL, 0x8e92c93bUL,
+ 0xb9f80b3aUL, 0x3cee443fUL, 0x0b84863eUL, 0x523ac03cUL, 0x6550023dUL,
+ 0x58175e36UL, 0x6f7d9c37UL, 0x36c3da35UL, 0x01a91834UL, 0x84bf5731UL,
+ 0xb3d59530UL, 0xea6bd332UL, 0xdd011133UL, 0x90e56b24UL, 0xa78fa925UL,
+ 0xfe31ef27UL, 0xc95b2d26UL, 0x4c4d6223UL, 0x7b27a022UL, 0x2299e620UL,
+ 0x15f32421UL, 0x28b4782aUL, 0x1fdeba2bUL, 0x4660fc29UL, 0x710a3e28UL,
+ 0xf41c712dUL, 0xc376b32cUL, 0x9ac8f52eUL, 0xada2372fUL, 0xc08d9a70UL,
+ 0xf7e75871UL, 0xae591e73UL, 0x9933dc72UL, 0x1c259377UL, 0x2b4f5176UL,
+ 0x72f11774UL, 0x459bd575UL, 0x78dc897eUL, 0x4fb64b7fUL, 0x16080d7dUL,
+ 0x2162cf7cUL, 0xa4748079UL, 0x931e4278UL, 0xcaa0047aUL, 0xfdcac67bUL,
+ 0xb02ebc6cUL, 0x87447e6dUL, 0xdefa386fUL, 0xe990fa6eUL, 0x6c86b56bUL,
+ 0x5bec776aUL, 0x02523168UL, 0x3538f369UL, 0x087faf62UL, 0x3f156d63UL,
+ 0x66ab2b61UL, 0x51c1e960UL, 0xd4d7a665UL, 0xe3bd6464UL, 0xba032266UL,
+ 0x8d69e067UL, 0x20cbd748UL, 0x17a11549UL, 0x4e1f534bUL, 0x7975914aUL,
+ 0xfc63de4fUL, 0xcb091c4eUL, 0x92b75a4cUL, 0xa5dd984dUL, 0x989ac446UL,
+ 0xaff00647UL, 0xf64e4045UL, 0xc1248244UL, 0x4432cd41UL, 0x73580f40UL,
+ 0x2ae64942UL, 0x1d8c8b43UL, 0x5068f154UL, 0x67023355UL, 0x3ebc7557UL,
+ 0x09d6b756UL, 0x8cc0f853UL, 0xbbaa3a52UL, 0xe2147c50UL, 0xd57ebe51UL,
+ 0xe839e25aUL, 0xdf53205bUL, 0x86ed6659UL, 0xb187a458UL, 0x3491eb5dUL,
+ 0x03fb295cUL, 0x5a456f5eUL, 0x6d2fad5fUL, 0x801b35e1UL, 0xb771f7e0UL,
+ 0xeecfb1e2UL, 0xd9a573e3UL, 0x5cb33ce6UL, 0x6bd9fee7UL, 0x3267b8e5UL,
+ 0x050d7ae4UL, 0x384a26efUL, 0x0f20e4eeUL, 0x569ea2ecUL, 0x61f460edUL,
+ 0xe4e22fe8UL, 0xd388ede9UL, 0x8a36abebUL, 0xbd5c69eaUL, 0xf0b813fdUL,
+ 0xc7d2d1fcUL, 0x9e6c97feUL, 0xa90655ffUL, 0x2c101afaUL, 0x1b7ad8fbUL,
+ 0x42c49ef9UL, 0x75ae5cf8UL, 0x48e900f3UL, 0x7f83c2f2UL, 0x263d84f0UL,
+ 0x115746f1UL, 0x944109f4UL, 0xa32bcbf5UL, 0xfa958df7UL, 0xcdff4ff6UL,
+ 0x605d78d9UL, 0x5737bad8UL, 0x0e89fcdaUL, 0x39e33edbUL, 0xbcf571deUL,
+ 0x8b9fb3dfUL, 0xd221f5ddUL, 0xe54b37dcUL, 0xd80c6bd7UL, 0xef66a9d6UL,
+ 0xb6d8efd4UL, 0x81b22dd5UL, 0x04a462d0UL, 0x33cea0d1UL, 0x6a70e6d3UL,
+ 0x5d1a24d2UL, 0x10fe5ec5UL, 0x27949cc4UL, 0x7e2adac6UL, 0x494018c7UL,
+ 0xcc5657c2UL, 0xfb3c95c3UL, 0xa282d3c1UL, 0x95e811c0UL, 0xa8af4dcbUL,
+ 0x9fc58fcaUL, 0xc67bc9c8UL, 0xf1110bc9UL, 0x740744ccUL, 0x436d86cdUL,
+ 0x1ad3c0cfUL, 0x2db902ceUL, 0x4096af91UL, 0x77fc6d90UL, 0x2e422b92UL,
+ 0x1928e993UL, 0x9c3ea696UL, 0xab546497UL, 0xf2ea2295UL, 0xc580e094UL,
+ 0xf8c7bc9fUL, 0xcfad7e9eUL, 0x9613389cUL, 0xa179fa9dUL, 0x246fb598UL,
+ 0x13057799UL, 0x4abb319bUL, 0x7dd1f39aUL, 0x3035898dUL, 0x075f4b8cUL,
+ 0x5ee10d8eUL, 0x698bcf8fUL, 0xec9d808aUL, 0xdbf7428bUL, 0x82490489UL,
+ 0xb523c688UL, 0x88649a83UL, 0xbf0e5882UL, 0xe6b01e80UL, 0xd1dadc81UL,
+ 0x54cc9384UL, 0x63a65185UL, 0x3a181787UL, 0x0d72d586UL, 0xa0d0e2a9UL,
+ 0x97ba20a8UL, 0xce0466aaUL, 0xf96ea4abUL, 0x7c78ebaeUL, 0x4b1229afUL,
+ 0x12ac6fadUL, 0x25c6adacUL, 0x1881f1a7UL, 0x2feb33a6UL, 0x765575a4UL,
+ 0x413fb7a5UL, 0xc429f8a0UL, 0xf3433aa1UL, 0xaafd7ca3UL, 0x9d97bea2UL,
+ 0xd073c4b5UL, 0xe71906b4UL, 0xbea740b6UL, 0x89cd82b7UL, 0x0cdbcdb2UL,
+ 0x3bb10fb3UL, 0x620f49b1UL, 0x55658bb0UL, 0x6822d7bbUL, 0x5f4815baUL,
+ 0x06f653b8UL, 0x319c91b9UL, 0xb48adebcUL, 0x83e01cbdUL, 0xda5e5abfUL,
+ 0xed3498beUL
+ },
+ {
+ 0x00000000UL, 0x6567bcb8UL, 0x8bc809aaUL, 0xeeafb512UL, 0x5797628fUL,
+ 0x32f0de37UL, 0xdc5f6b25UL, 0xb938d79dUL, 0xef28b4c5UL, 0x8a4f087dUL,
+ 0x64e0bd6fUL, 0x018701d7UL, 0xb8bfd64aUL, 0xddd86af2UL, 0x3377dfe0UL,
+ 0x56106358UL, 0x9f571950UL, 0xfa30a5e8UL, 0x149f10faUL, 0x71f8ac42UL,
+ 0xc8c07bdfUL, 0xada7c767UL, 0x43087275UL, 0x266fcecdUL, 0x707fad95UL,
+ 0x1518112dUL, 0xfbb7a43fUL, 0x9ed01887UL, 0x27e8cf1aUL, 0x428f73a2UL,
+ 0xac20c6b0UL, 0xc9477a08UL, 0x3eaf32a0UL, 0x5bc88e18UL, 0xb5673b0aUL,
+ 0xd00087b2UL, 0x6938502fUL, 0x0c5fec97UL, 0xe2f05985UL, 0x8797e53dUL,
+ 0xd1878665UL, 0xb4e03addUL, 0x5a4f8fcfUL, 0x3f283377UL, 0x8610e4eaUL,
+ 0xe3775852UL, 0x0dd8ed40UL, 0x68bf51f8UL, 0xa1f82bf0UL, 0xc49f9748UL,
+ 0x2a30225aUL, 0x4f579ee2UL, 0xf66f497fUL, 0x9308f5c7UL, 0x7da740d5UL,
+ 0x18c0fc6dUL, 0x4ed09f35UL, 0x2bb7238dUL, 0xc518969fUL, 0xa07f2a27UL,
+ 0x1947fdbaUL, 0x7c204102UL, 0x928ff410UL, 0xf7e848a8UL, 0x3d58149bUL,
+ 0x583fa823UL, 0xb6901d31UL, 0xd3f7a189UL, 0x6acf7614UL, 0x0fa8caacUL,
+ 0xe1077fbeUL, 0x8460c306UL, 0xd270a05eUL, 0xb7171ce6UL, 0x59b8a9f4UL,
+ 0x3cdf154cUL, 0x85e7c2d1UL, 0xe0807e69UL, 0x0e2fcb7bUL, 0x6b4877c3UL,
+ 0xa20f0dcbUL, 0xc768b173UL, 0x29c70461UL, 0x4ca0b8d9UL, 0xf5986f44UL,
+ 0x90ffd3fcUL, 0x7e5066eeUL, 0x1b37da56UL, 0x4d27b90eUL, 0x284005b6UL,
+ 0xc6efb0a4UL, 0xa3880c1cUL, 0x1ab0db81UL, 0x7fd76739UL, 0x9178d22bUL,
+ 0xf41f6e93UL, 0x03f7263bUL, 0x66909a83UL, 0x883f2f91UL, 0xed589329UL,
+ 0x546044b4UL, 0x3107f80cUL, 0xdfa84d1eUL, 0xbacff1a6UL, 0xecdf92feUL,
+ 0x89b82e46UL, 0x67179b54UL, 0x027027ecUL, 0xbb48f071UL, 0xde2f4cc9UL,
+ 0x3080f9dbUL, 0x55e74563UL, 0x9ca03f6bUL, 0xf9c783d3UL, 0x176836c1UL,
+ 0x720f8a79UL, 0xcb375de4UL, 0xae50e15cUL, 0x40ff544eUL, 0x2598e8f6UL,
+ 0x73888baeUL, 0x16ef3716UL, 0xf8408204UL, 0x9d273ebcUL, 0x241fe921UL,
+ 0x41785599UL, 0xafd7e08bUL, 0xcab05c33UL, 0x3bb659edUL, 0x5ed1e555UL,
+ 0xb07e5047UL, 0xd519ecffUL, 0x6c213b62UL, 0x094687daUL, 0xe7e932c8UL,
+ 0x828e8e70UL, 0xd49eed28UL, 0xb1f95190UL, 0x5f56e482UL, 0x3a31583aUL,
+ 0x83098fa7UL, 0xe66e331fUL, 0x08c1860dUL, 0x6da63ab5UL, 0xa4e140bdUL,
+ 0xc186fc05UL, 0x2f294917UL, 0x4a4ef5afUL, 0xf3762232UL, 0x96119e8aUL,
+ 0x78be2b98UL, 0x1dd99720UL, 0x4bc9f478UL, 0x2eae48c0UL, 0xc001fdd2UL,
+ 0xa566416aUL, 0x1c5e96f7UL, 0x79392a4fUL, 0x97969f5dUL, 0xf2f123e5UL,
+ 0x05196b4dUL, 0x607ed7f5UL, 0x8ed162e7UL, 0xebb6de5fUL, 0x528e09c2UL,
+ 0x37e9b57aUL, 0xd9460068UL, 0xbc21bcd0UL, 0xea31df88UL, 0x8f566330UL,
+ 0x61f9d622UL, 0x049e6a9aUL, 0xbda6bd07UL, 0xd8c101bfUL, 0x366eb4adUL,
+ 0x53090815UL, 0x9a4e721dUL, 0xff29cea5UL, 0x11867bb7UL, 0x74e1c70fUL,
+ 0xcdd91092UL, 0xa8beac2aUL, 0x46111938UL, 0x2376a580UL, 0x7566c6d8UL,
+ 0x10017a60UL, 0xfeaecf72UL, 0x9bc973caUL, 0x22f1a457UL, 0x479618efUL,
+ 0xa939adfdUL, 0xcc5e1145UL, 0x06ee4d76UL, 0x6389f1ceUL, 0x8d2644dcUL,
+ 0xe841f864UL, 0x51792ff9UL, 0x341e9341UL, 0xdab12653UL, 0xbfd69aebUL,
+ 0xe9c6f9b3UL, 0x8ca1450bUL, 0x620ef019UL, 0x07694ca1UL, 0xbe519b3cUL,
+ 0xdb362784UL, 0x35999296UL, 0x50fe2e2eUL, 0x99b95426UL, 0xfcdee89eUL,
+ 0x12715d8cUL, 0x7716e134UL, 0xce2e36a9UL, 0xab498a11UL, 0x45e63f03UL,
+ 0x208183bbUL, 0x7691e0e3UL, 0x13f65c5bUL, 0xfd59e949UL, 0x983e55f1UL,
+ 0x2106826cUL, 0x44613ed4UL, 0xaace8bc6UL, 0xcfa9377eUL, 0x38417fd6UL,
+ 0x5d26c36eUL, 0xb389767cUL, 0xd6eecac4UL, 0x6fd61d59UL, 0x0ab1a1e1UL,
+ 0xe41e14f3UL, 0x8179a84bUL, 0xd769cb13UL, 0xb20e77abUL, 0x5ca1c2b9UL,
+ 0x39c67e01UL, 0x80fea99cUL, 0xe5991524UL, 0x0b36a036UL, 0x6e511c8eUL,
+ 0xa7166686UL, 0xc271da3eUL, 0x2cde6f2cUL, 0x49b9d394UL, 0xf0810409UL,
+ 0x95e6b8b1UL, 0x7b490da3UL, 0x1e2eb11bUL, 0x483ed243UL, 0x2d596efbUL,
+ 0xc3f6dbe9UL, 0xa6916751UL, 0x1fa9b0ccUL, 0x7ace0c74UL, 0x9461b966UL,
+ 0xf10605deUL
+#endif
+ }
+};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/deflate.c Thu Dec 15 15:57:51 2011 -0800
@@ -0,0 +1,1858 @@
+/*
+ * 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.
+ */
+
+/* deflate.c -- compress data using the deflation algorithm
+ * Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+/*
+ * ALGORITHM
+ *
+ * The "deflation" process depends on being able to identify portions
+ * of the input text which are identical to earlier input (within a
+ * sliding window trailing behind the input currently being processed).
+ *
+ * The most straightforward technique turns out to be the fastest for
+ * most input files: try all possible matches and select the longest.
+ * The key feature of this algorithm is that insertions into the string
+ * dictionary are very simple and thus fast, and deletions are avoided
+ * completely. Insertions are performed at each input character, whereas
+ * string matches are performed only when the previous match ends. So it
+ * is preferable to spend more time in matches to allow very fast string
+ * insertions and avoid deletions. The matching algorithm for small
+ * strings is inspired from that of Rabin & Karp. A brute force approach
+ * is used to find longer strings when a small match has been found.
+ * A similar algorithm is used in comic (by Jan-Mark Wams) and freeze
+ * (by Leonid Broukhis).
+ * A previous version of this file used a more sophisticated algorithm
+ * (by Fiala and Greene) which is guaranteed to run in linear amortized
+ * time, but has a larger average cost, uses more memory and is patented.
+ * However the F&G algorithm may be faster for some highly redundant
+ * files if the parameter max_chain_length (described below) is too large.
+ *
+ * ACKNOWLEDGEMENTS
+ *
+ * The idea of lazy evaluation of matches is due to Jan-Mark Wams, and
+ * I found it in 'freeze' written by Leonid Broukhis.
+ * Thanks to many people for bug reports and testing.
+ *
+ * REFERENCES
+ *
+ * Deutsch, L.P.,"DEFLATE Compressed Data Format Specification".
+ * Available in http://www.ietf.org/rfc/rfc1951.txt
+ *
+ * A description of the Rabin and Karp algorithm is given in the book
+ * "Algorithms" by R. Sedgewick, Addison-Wesley, p252.
+ *
+ * Fiala,E.R., and Greene,D.H.
+ * Data Compression with Finite Windows, Comm.ACM, 32,4 (1989) 490-595
+ *
+ */
+
+/* @(#) $Id$ */
+
+#include "deflate.h"
+
+const char deflate_copyright[] =
+ " 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
+ include such an acknowledgment, I would appreciate that you keep this
+ copyright string in the executable of your product.
+ */
+
+/* ===========================================================================
+ * Function prototypes.
+ */
+typedef enum {
+ need_more, /* block not completed, need more input or more output */
+ block_done, /* block flush performed */
+ finish_started, /* finish started, need only more output at next deflate */
+ finish_done /* finish done, accept no more input or output */
+} block_state;
+
+typedef block_state (*compress_func) OF((deflate_state *s, int flush));
+/* Compression function. Returns the block state after the call. */
+
+local void fill_window OF((deflate_state *s));
+local block_state deflate_stored OF((deflate_state *s, int flush));
+local block_state deflate_fast OF((deflate_state *s, int flush));
+#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));
+#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
+
+#ifdef DEBUG
+local void check_match OF((deflate_state *s, IPos start, IPos match,
+ int length));
+#endif
+
+/* ===========================================================================
+ * Local data
+ */
+
+#define NIL 0
+/* Tail of hash chains */
+
+#ifndef TOO_FAR
+# define TOO_FAR 4096
+#endif
+/* Matches of length 3 are discarded if their distance exceeds TOO_FAR */
+
+/* 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
+ * found for specific files.
+ */
+typedef struct config_s {
+ ush good_length; /* reduce lazy search above this match length */
+ ush max_lazy; /* do not perform lazy search above this match length */
+ ush nice_length; /* quit search above this match length */
+ ush max_chain;
+ compress_func func;
+} config;
+
+#ifdef FASTEST
+local const config configuration_table[2] = {
+/* good lazy nice chain */
+/* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */
+/* 1 */ {4, 4, 8, 4, deflate_fast}}; /* max speed, no lazy matches */
+#else
+local const config configuration_table[10] = {
+/* good lazy nice chain */
+/* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */
+/* 1 */ {4, 4, 8, 4, deflate_fast}, /* max speed, no lazy matches */
+/* 2 */ {4, 5, 16, 8, deflate_fast},
+/* 3 */ {4, 6, 32, 32, deflate_fast},
+
+/* 4 */ {4, 4, 16, 16, deflate_slow}, /* lazy matches */
+/* 5 */ {8, 16, 32, 32, deflate_slow},
+/* 6 */ {8, 16, 128, 128, deflate_slow},
+/* 7 */ {8, 32, 128, 256, deflate_slow},
+/* 8 */ {32, 128, 258, 1024, deflate_slow},
+/* 9 */ {32, 258, 258, 4096, deflate_slow}}; /* max compression */
+#endif
+
+/* Note: the deflate() code requires max_lazy >= MIN_MATCH and max_chain >= 4
+ * For deflate_fast() (levels <= 3) good is ignored and lazy has a different
+ * meaning.
+ */
+
+#define EQUAL 0
+/* result of memcmp for equal strings */
+
+#ifndef NO_DUMMY_DECL
+struct static_tree_desc_s {int dummy;}; /* for buggy compilers */
+#endif
+
+/* ===========================================================================
+ * Update a hash value with the given input byte
+ * IN assertion: all calls to to UPDATE_HASH are made with consecutive
+ * input characters, so that a running hash key can be computed from the
+ * previous key instead of complete recalculation each time.
+ */
+#define UPDATE_HASH(s,h,c) (h = (((h)<<s->hash_shift) ^ (c)) & s->hash_mask)
+
+
+/* ===========================================================================
+ * Insert string str in the dictionary and set match_head to the previous head
+ * of the hash chain (the most recent string with same hash key). Return
+ * the previous length of the hash chain.
+ * If this file is compiled with -DFASTEST, the compression level is forced
+ * to 1, and no hash chains are maintained.
+ * IN assertion: all calls to to INSERT_STRING are made with consecutive
+ * input characters and the first MIN_MATCH bytes of str are valid
+ * (except for the last MIN_MATCH-1 bytes of the input file).
+ */
+#ifdef FASTEST
+#define INSERT_STRING(s, str, match_head) \
+ (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \
+ match_head = s->head[s->ins_h], \
+ s->head[s->ins_h] = (Pos)(str))
+#else
+#define INSERT_STRING(s, str, match_head) \
+ (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \
+ match_head = s->prev[(str) & s->w_mask] = s->head[s->ins_h], \
+ s->head[s->ins_h] = (Pos)(str))
+#endif
+
+/* ===========================================================================
+ * Initialize the hash table (avoiding 64K overflow for 16 bit systems).
+ * prev[] will be initialized on the fly.
+ */
+#define CLEAR_HASH(s) \
+ s->head[s->hash_size-1] = NIL; \
+ zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head));
+
+/* ========================================================================= */
+int ZEXPORT deflateInit_(strm, level, version, stream_size)
+ z_streamp strm;
+ int level;
+ const char *version;
+ int stream_size;
+{
+ return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL,
+ Z_DEFAULT_STRATEGY, version, stream_size);
+ /* To do: ignore strm->next_in if we use it as window */
+}
+
+/* ========================================================================= */
+int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
+ version, stream_size)
+ z_streamp strm;
+ int level;
+ int method;
+ int windowBits;
+ int memLevel;
+ int strategy;
+ const char *version;
+ int stream_size;
+{
+ deflate_state *s;
+ int wrap = 1;
+ static const char my_version[] = ZLIB_VERSION;
+
+ ushf *overlay;
+ /* We overlay pending_buf and d_buf+l_buf. This works since the average
+ * output size for (length,distance) codes is <= 24 bits.
+ */
+
+ if (version == Z_NULL || version[0] != my_version[0] ||
+ stream_size != sizeof(z_stream)) {
+ return Z_VERSION_ERROR;
+ }
+ if (strm == Z_NULL) return Z_STREAM_ERROR;
+
+ strm->msg = Z_NULL;
+ if (strm->zalloc == (alloc_func)0) {
+ strm->zalloc = zcalloc;
+ strm->opaque = (voidpf)0;
+ }
+ if (strm->zfree == (free_func)0) strm->zfree = zcfree;
+
+#ifdef FASTEST
+ if (level != 0) level = 1;
+#else
+ if (level == Z_DEFAULT_COMPRESSION) level = 6;
+#endif
+
+ if (windowBits < 0) { /* suppress zlib wrapper */
+ wrap = 0;
+ windowBits = -windowBits;
+ }
+#ifdef GZIP
+ else if (windowBits > 15) {
+ wrap = 2; /* write gzip wrapper instead */
+ windowBits -= 16;
+ }
+#endif
+ if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED ||
+ windowBits < 8 || windowBits > 15 || level < 0 || level > 9 ||
+ strategy < 0 || strategy > Z_FIXED) {
+ return Z_STREAM_ERROR;
+ }
+ if (windowBits == 8) windowBits = 9; /* until 256-byte window bug fixed */
+ s = (deflate_state *) ZALLOC(strm, 1, sizeof(deflate_state));
+ if (s == Z_NULL) return Z_MEM_ERROR;
+ strm->state = (struct internal_state FAR *)s;
+ s->strm = strm;
+
+ s->wrap = wrap;
+ s->gzhead = Z_NULL;
+ s->w_bits = windowBits;
+ s->w_size = 1 << s->w_bits;
+ s->w_mask = s->w_size - 1;
+
+ s->hash_bits = memLevel + 7;
+ s->hash_size = 1 << s->hash_bits;
+ s->hash_mask = s->hash_size - 1;
+ s->hash_shift = ((s->hash_bits+MIN_MATCH-1)/MIN_MATCH);
+
+ s->window = (Bytef *) ZALLOC(strm, s->w_size, 2*sizeof(Byte));
+ 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);
+ s->pending_buf = (uchf *) overlay;
+ s->pending_buf_size = (ulg)s->lit_bufsize * (sizeof(ush)+2L);
+
+ if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL ||
+ s->pending_buf == Z_NULL) {
+ s->status = FINISH_STATE;
+ strm->msg = (char*)ERR_MSG(Z_MEM_ERROR);
+ deflateEnd (strm);
+ return Z_MEM_ERROR;
+ }
+ s->d_buf = overlay + s->lit_bufsize/sizeof(ush);
+ s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize;
+
+ s->level = level;
+ s->strategy = strategy;
+ s->method = (Byte)method;
+
+ return deflateReset(strm);
+}
+
+/* ========================================================================= */
+int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
+ z_streamp strm;
+ const Bytef *dictionary;
+ uInt dictLength;
+{
+ deflate_state *s;
+ uInt length = dictLength;
+ uInt n;
+ IPos hash_head = 0;
+
+ if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL ||
+ strm->state->wrap == 2 ||
+ (strm->state->wrap == 1 && strm->state->status != INIT_STATE))
+ return Z_STREAM_ERROR;
+
+ s = strm->state;
+ if (s->wrap)
+ strm->adler = adler32(strm->adler, dictionary, dictLength);
+
+ if (length < MIN_MATCH) return Z_OK;
+ if (length > s->w_size) {
+ length = s->w_size;
+ dictionary += dictLength - length; /* use the tail of the dictionary */
+ }
+ zmemcpy(s->window, dictionary, length);
+ s->strstart = length;
+ s->block_start = (long)length;
+
+ /* Insert all strings in the hash table (except for the last two bytes).
+ * s->lookahead stays null, so s->ins_h will be recomputed at the next
+ * call of fill_window.
+ */
+ s->ins_h = s->window[0];
+ UPDATE_HASH(s, s->ins_h, s->window[1]);
+ for (n = 0; n <= length - MIN_MATCH; n++) {
+ INSERT_STRING(s, n, hash_head);
+ }
+ if (hash_head) hash_head = 0; /* to make compiler happy */
+ return Z_OK;
+}
+
+/* ========================================================================= */
+int ZEXPORT deflateReset (strm)
+ z_streamp strm;
+{
+ deflate_state *s;
+
+ if (strm == Z_NULL || strm->state == Z_NULL ||
+ strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) {
+ return Z_STREAM_ERROR;
+ }
+
+ strm->total_in = strm->total_out = 0;
+ strm->msg = Z_NULL; /* use zfree if we ever allocate msg dynamically */
+ strm->data_type = Z_UNKNOWN;
+
+ s = (deflate_state *)strm->state;
+ s->pending = 0;
+ s->pending_out = s->pending_buf;
+
+ if (s->wrap < 0) {
+ s->wrap = -s->wrap; /* was made negative by deflate(..., Z_FINISH); */
+ }
+ s->status = s->wrap ? INIT_STATE : BUSY_STATE;
+ strm->adler =
+#ifdef GZIP
+ s->wrap == 2 ? crc32(0L, Z_NULL, 0) :
+#endif
+ adler32(0L, Z_NULL, 0);
+ s->last_flush = Z_NO_FLUSH;
+
+ _tr_init(s);
+ lm_init(s);
+
+ return Z_OK;
+}
+
+/* ========================================================================= */
+int ZEXPORT deflateSetHeader (strm, head)
+ z_streamp strm;
+ gz_headerp head;
+{
+ if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+ if (strm->state->wrap != 2) return Z_STREAM_ERROR;
+ strm->state->gzhead = head;
+ return Z_OK;
+}
+
+/* ========================================================================= */
+int ZEXPORT deflatePrime (strm, bits, value)
+ z_streamp strm;
+ int bits;
+ int value;
+{
+ if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+ strm->state->bi_valid = bits;
+ strm->state->bi_buf = (ush)(value & ((1 << bits) - 1));
+ return Z_OK;
+}
+
+/* ========================================================================= */
+int ZEXPORT deflateParams(strm, level, strategy)
+ z_streamp strm;
+ int level;
+ int strategy;
+{
+ deflate_state *s;
+ compress_func func;
+ int err = Z_OK;
+
+ if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+ s = strm->state;
+
+#ifdef FASTEST
+ if (level != 0) level = 1;
+#else
+ if (level == Z_DEFAULT_COMPRESSION) level = 6;
+#endif
+ if (level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED) {
+ return Z_STREAM_ERROR;
+ }
+ func = configuration_table[s->level].func;
+
+ if ((strategy != s->strategy || func != configuration_table[level].func) &&
+ strm->total_in != 0) {
+ /* Flush the last buffer: */
+ err = deflate(strm, Z_BLOCK);
+ }
+ if (s->level != level) {
+ s->level = level;
+ s->max_lazy_match = configuration_table[level].max_lazy;
+ s->good_match = configuration_table[level].good_length;
+ s->nice_match = configuration_table[level].nice_length;
+ s->max_chain_length = configuration_table[level].max_chain;
+ }
+ s->strategy = strategy;
+ return err;
+}
+
+/* ========================================================================= */
+int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain)
+ z_streamp strm;
+ int good_length;
+ int max_lazy;
+ int nice_length;
+ int max_chain;
+{
+ deflate_state *s;
+
+ if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+ s = strm->state;
+ s->good_match = good_length;
+ s->max_lazy_match = max_lazy;
+ s->nice_match = nice_length;
+ s->max_chain_length = max_chain;
+ return Z_OK;
+}
+
+/* =========================================================================
+ * For the default windowBits of 15 and memLevel of 8, this function returns
+ * a close to exact, as well as small, upper bound on the compressed size.
+ * They are coded as constants here for a reason--if the #define's are
+ * changed, then this function needs to be changed as well. The return
+ * value for 15 and 8 only works for those exact settings.
+ *
+ * For any setting other than those defaults for windowBits and memLevel,
+ * the value returned is a conservative worst case for the maximum expansion
+ * 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. 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 complen, wraplen;
+ Bytef *str;
+
+ /* conservative upper bound for compressed data */
+ complen = sourceLen +
+ ((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 5;
+
+ /* if can't get parameters, return conservative bound plus zlib wrapper */
+ if (strm == Z_NULL || strm->state == Z_NULL)
+ 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 */
+ if (s->w_bits != 15 || s->hash_bits != 8 + 7)
+ return complen + wraplen;
+
+ /* default settings: return tight bound for that case */
+ return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
+ (sourceLen >> 25) + 13 - 6 + wraplen;
+}
+
+/* =========================================================================
+ * Put a short in the pending buffer. The 16-bit value is put in MSB order.
+ * IN assertion: the stream state is correct and there is enough room in
+ * pending_buf.
+ */
+local void putShortMSB (s, b)
+ deflate_state *s;
+ uInt b;
+{
+ put_byte(s, (Byte)(b >> 8));
+ put_byte(s, (Byte)(b & 0xff));
+}
+
+/* =========================================================================
+ * Flush as much pending output as possible. All deflate() output goes
+ * through this function so some applications may wish to modify it
+ * to avoid allocating a large strm->next_out buffer and copying into it.
+ * (See also read_buf()).
+ */
+local void flush_pending(strm)
+ z_streamp strm;
+{
+ unsigned len = strm->state->pending;
+
+ if (len > strm->avail_out) len = strm->avail_out;
+ if (len == 0) return;
+
+ zmemcpy(strm->next_out, strm->state->pending_out, len);
+ strm->next_out += len;
+ strm->state->pending_out += len;
+ strm->total_out += len;
+ strm->avail_out -= len;
+ strm->state->pending -= len;
+ if (strm->state->pending == 0) {
+ strm->state->pending_out = strm->state->pending_buf;
+ }
+}
+
+/* ========================================================================= */
+int ZEXPORT deflate (strm, flush)
+ z_streamp strm;
+ int flush;
+{
+ int old_flush; /* value of flush param for previous deflate call */
+ deflate_state *s;
+
+ if (strm == Z_NULL || strm->state == Z_NULL ||
+ flush > Z_BLOCK || flush < 0) {
+ return Z_STREAM_ERROR;
+ }
+ s = strm->state;
+
+ if (strm->next_out == Z_NULL ||
+ (strm->next_in == Z_NULL && strm->avail_in != 0) ||
+ (s->status == FINISH_STATE && flush != Z_FINISH)) {
+ ERR_RETURN(strm, Z_STREAM_ERROR);
+ }
+ if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR);
+
+ s->strm = strm; /* just in case */
+ old_flush = s->last_flush;
+ s->last_flush = flush;
+
+ /* Write the header */
+ if (s->status == INIT_STATE) {
+#ifdef GZIP
+ if (s->wrap == 2) {
+ strm->adler = crc32(0L, Z_NULL, 0);
+ put_byte(s, 31);
+ put_byte(s, 139);
+ put_byte(s, 8);
+ if (s->gzhead == Z_NULL) {
+ put_byte(s, 0);
+ put_byte(s, 0);
+ put_byte(s, 0);
+ put_byte(s, 0);
+ put_byte(s, 0);
+ put_byte(s, s->level == 9 ? 2 :
+ (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
+ 4 : 0));
+ put_byte(s, OS_CODE);
+ s->status = BUSY_STATE;
+ }
+ else {
+ put_byte(s, (s->gzhead->text ? 1 : 0) +
+ (s->gzhead->hcrc ? 2 : 0) +
+ (s->gzhead->extra == Z_NULL ? 0 : 4) +
+ (s->gzhead->name == Z_NULL ? 0 : 8) +
+ (s->gzhead->comment == Z_NULL ? 0 : 16)
+ );
+ put_byte(s, (Byte)(s->gzhead->time & 0xff));
+ put_byte(s, (Byte)((s->gzhead->time >> 8) & 0xff));
+ put_byte(s, (Byte)((s->gzhead->time >> 16) & 0xff));
+ put_byte(s, (Byte)((s->gzhead->time >> 24) & 0xff));
+ put_byte(s, s->level == 9 ? 2 :
+ (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
+ 4 : 0));
+ put_byte(s, s->gzhead->os & 0xff);
+ if (s->gzhead->extra != Z_NULL) {
+ put_byte(s, s->gzhead->extra_len & 0xff);
+ put_byte(s, (s->gzhead->extra_len >> 8) & 0xff);
+ }
+ if (s->gzhead->hcrc)
+ strm->adler = crc32(strm->adler, s->pending_buf,
+ s->pending);
+ s->gzindex = 0;
+ s->status = EXTRA_STATE;
+ }
+ }
+ else
+#endif
+ {
+ uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8;
+ uInt level_flags;
+
+ if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2)
+ level_flags = 0;
+ else if (s->level < 6)
+ level_flags = 1;
+ else if (s->level == 6)
+ level_flags = 2;
+ else
+ level_flags = 3;
+ header |= (level_flags << 6);
+ if (s->strstart != 0) header |= PRESET_DICT;
+ header += 31 - (header % 31);
+
+ s->status = BUSY_STATE;
+ putShortMSB(s, header);
+
+ /* Save the adler32 of the preset dictionary: */
+ if (s->strstart != 0) {
+ putShortMSB(s, (uInt)(strm->adler >> 16));
+ putShortMSB(s, (uInt)(strm->adler & 0xffff));
+ }
+ strm->adler = adler32(0L, Z_NULL, 0);
+ }
+ }
+#ifdef GZIP
+ if (s->status == EXTRA_STATE) {
+ if (s->gzhead->extra != Z_NULL) {
+ uInt beg = s->pending; /* start of bytes to update crc */
+
+ while (s->gzindex < (s->gzhead->extra_len & 0xffff)) {
+ if (s->pending == s->pending_buf_size) {
+ if (s->gzhead->hcrc && s->pending > beg)
+ strm->adler = crc32(strm->adler, s->pending_buf + beg,
+ s->pending - beg);
+ flush_pending(strm);
+ beg = s->pending;
+ if (s->pending == s->pending_buf_size)
+ break;
+ }
+ put_byte(s, s->gzhead->extra[s->gzindex]);
+ s->gzindex++;
+ }
+ if (s->gzhead->hcrc && s->pending > beg)
+ strm->adler = crc32(strm->adler, s->pending_buf + beg,
+ s->pending - beg);
+ if (s->gzindex == s->gzhead->extra_len) {
+ s->gzindex = 0;
+ s->status = NAME_STATE;
+ }
+ }
+ else
+ s->status = NAME_STATE;
+ }
+ if (s->status == NAME_STATE) {
+ if (s->gzhead->name != Z_NULL) {
+ uInt beg = s->pending; /* start of bytes to update crc */
+ int val;
+
+ do {
+ if (s->pending == s->pending_buf_size) {
+ if (s->gzhead->hcrc && s->pending > beg)
+ strm->adler = crc32(strm->adler, s->pending_buf + beg,
+ s->pending - beg);
+ flush_pending(strm);
+ beg = s->pending;
+ if (s->pending == s->pending_buf_size) {
+ val = 1;
+ break;
+ }
+ }
+ val = s->gzhead->name[s->gzindex++];
+ put_byte(s, val);
+ } while (val != 0);
+ if (s->gzhead->hcrc && s->pending > beg)
+ strm->adler = crc32(strm->adler, s->pending_buf + beg,
+ s->pending - beg);
+ if (val == 0) {
+ s->gzindex = 0;
+ s->status = COMMENT_STATE;
+ }
+ }
+ else
+ s->status = COMMENT_STATE;
+ }
+ if (s->status == COMMENT_STATE) {
+ if (s->gzhead->comment != Z_NULL) {
+ uInt beg = s->pending; /* start of bytes to update crc */
+ int val;
+
+ do {
+ if (s->pending == s->pending_buf_size) {
+ if (s->gzhead->hcrc && s->pending > beg)
+ strm->adler = crc32(strm->adler, s->pending_buf + beg,
+ s->pending - beg);
+ flush_pending(strm);
+ beg = s->pending;
+ if (s->pending == s->pending_buf_size) {
+ val = 1;
+ break;
+ }
+ }
+ val = s->gzhead->comment[s->gzindex++];
+ put_byte(s, val);
+ } while (val != 0);
+ if (s->gzhead->hcrc && s->pending > beg)
+ strm->adler = crc32(strm->adler, s->pending_buf + beg,
+ s->pending - beg);
+ if (val == 0)
+ s->status = HCRC_STATE;
+ }
+ else
+ s->status = HCRC_STATE;
+ }
+ if (s->status == HCRC_STATE) {
+ if (s->gzhead->hcrc) {
+ if (s->pending + 2 > s->pending_buf_size)
+ flush_pending(strm);
+ if (s->pending + 2 <= s->pending_buf_size) {
+ put_byte(s, (Byte)(strm->adler & 0xff));
+ put_byte(s, (Byte)((strm->adler >> 8) & 0xff));
+ strm->adler = crc32(0L, Z_NULL, 0);
+ s->status = BUSY_STATE;
+ }
+ }
+ else
+ s->status = BUSY_STATE;
+ }
+#endif
+
+ /* Flush as much pending output as possible */
+ if (s->pending != 0) {
+ flush_pending(strm);
+ if (strm->avail_out == 0) {
+ /* Since avail_out is 0, deflate will be called again with
+ * more output space, but possibly with both pending and
+ * avail_in equal to zero. There won't be anything to do,
+ * but this is not an error situation so make sure we
+ * return OK instead of BUF_ERROR at next call of deflate:
+ */
+ s->last_flush = -1;
+ return Z_OK;
+ }
+
+ /* Make sure there is something to do and avoid duplicate consecutive
+ * flushes. For repeated and useless calls with Z_FINISH, we keep
+ * returning Z_STREAM_END instead of Z_BUF_ERROR.
+ */
+ } else if (strm->avail_in == 0 && flush <= old_flush &&
+ flush != Z_FINISH) {
+ ERR_RETURN(strm, Z_BUF_ERROR);
+ }
+
+ /* User must not provide more input after the first FINISH: */
+ if (s->status == FINISH_STATE && strm->avail_in != 0) {
+ ERR_RETURN(strm, Z_BUF_ERROR);
+ }
+
+ /* Start a new block or continue the current one.
+ */
+ if (strm->avail_in != 0 || s->lookahead != 0 ||
+ (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) {
+ block_state bstate;
+
+ 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;
+ }
+ if (bstate == need_more || bstate == finish_started) {
+ if (strm->avail_out == 0) {
+ s->last_flush = -1; /* avoid BUF_ERROR next call, see above */
+ }
+ return Z_OK;
+ /* If flush != Z_NO_FLUSH && avail_out == 0, the next call
+ * of deflate should use the same flush parameter to make sure
+ * that the flush is complete. So we don't have to output an
+ * empty block here, this will be done at next call. This also
+ * ensures that for a very small output buffer, we emit at most
+ * one empty block.
+ */
+ }
+ if (bstate == block_done) {
+ if (flush == Z_PARTIAL_FLUSH) {
+ _tr_align(s);
+ } 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);
+ if (strm->avail_out == 0) {
+ s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */
+ return Z_OK;
+ }
+ }
+ }
+ Assert(strm->avail_out > 0, "bug2");
+
+ if (flush != Z_FINISH) return Z_OK;
+ if (s->wrap <= 0) return Z_STREAM_END;
+
+ /* Write the trailer */
+#ifdef GZIP
+ if (s->wrap == 2) {
+ put_byte(s, (Byte)(strm->adler & 0xff));
+ put_byte(s, (Byte)((strm->adler >> 8) & 0xff));
+ put_byte(s, (Byte)((strm->adler >> 16) & 0xff));
+ put_byte(s, (Byte)((strm->adler >> 24) & 0xff));
+ put_byte(s, (Byte)(strm->total_in & 0xff));
+ put_byte(s, (Byte)((strm->total_in >> 8) & 0xff));
+ put_byte(s, (Byte)((strm->total_in >> 16) & 0xff));
+ put_byte(s, (Byte)((strm->total_in >> 24) & 0xff));
+ }
+ else
+#endif
+ {
+ putShortMSB(s, (uInt)(strm->adler >> 16));
+ putShortMSB(s, (uInt)(strm->adler & 0xffff));
+ }
+ flush_pending(strm);
+ /* If avail_out is zero, the application will call deflate again
+ * to flush the rest.
+ */
+ if (s->wrap > 0) s->wrap = -s->wrap; /* write the trailer only once! */
+ return s->pending != 0 ? Z_OK : Z_STREAM_END;
+}
+
+/* ========================================================================= */
+int ZEXPORT deflateEnd (strm)
+ z_streamp strm;
+{
+ int status;
+
+ if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+
+ status = strm->state->status;
+ if (status != INIT_STATE &&
+ status != EXTRA_STATE &&
+ status != NAME_STATE &&
+ status != COMMENT_STATE &&
+ status != HCRC_STATE &&
+ status != BUSY_STATE &&
+ status != FINISH_STATE) {
+ return Z_STREAM_ERROR;
+ }
+
+ /* Deallocate in reverse order of allocations: */
+ TRY_FREE(strm, strm->state->pending_buf);
+ TRY_FREE(strm, strm->state->head);
+ TRY_FREE(strm, strm->state->prev);
+ TRY_FREE(strm, strm->state->window);
+
+ ZFREE(strm, strm->state);
+ strm->state = Z_NULL;
+
+ return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK;
+}
+
+/* =========================================================================
+ * Copy the source state to the destination state.
+ * To simplify the source, this is not supported for 16-bit MSDOS (which
+ * doesn't have enough memory anyway to duplicate compression states).
+ */
+int ZEXPORT deflateCopy (dest, source)
+ z_streamp dest;
+ z_streamp source;
+{
+#ifdef MAXSEG_64K
+ return Z_STREAM_ERROR;
+#else
+ deflate_state *ds;
+ deflate_state *ss;
+ ushf *overlay;
+
+
+ if (source == Z_NULL || dest == Z_NULL || source->state == Z_NULL) {
+ return Z_STREAM_ERROR;
+ }
+
+ ss = source->state;
+
+ zmemcpy(dest, source, sizeof(z_stream));
+
+ ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state));
+ if (ds == Z_NULL) return Z_MEM_ERROR;
+ dest->state = (struct internal_state FAR *) ds;
+ zmemcpy(ds, ss, sizeof(deflate_state));
+ ds->strm = dest;
+
+ ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte));
+ ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos));
+ ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos));
+ overlay = (ushf *) ZALLOC(dest, ds->lit_bufsize, sizeof(ush)+2);
+ ds->pending_buf = (uchf *) overlay;
+
+ if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL ||
+ ds->pending_buf == Z_NULL) {
+ deflateEnd (dest);
+ return Z_MEM_ERROR;
+ }
+ /* following zmemcpy do not work for 16-bit MSDOS */
+ zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte));
+ zmemcpy(ds->prev, ss->prev, ds->w_size * sizeof(Pos));
+ zmemcpy(ds->head, ss->head, ds->hash_size * sizeof(Pos));
+ zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size);
+
+ ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf);
+ ds->d_buf = overlay + ds->lit_bufsize/sizeof(ush);
+ ds->l_buf = ds->pending_buf + (1+sizeof(ush))*ds->lit_bufsize;
+
+ ds->l_desc.dyn_tree = ds->dyn_ltree;
+ ds->d_desc.dyn_tree = ds->dyn_dtree;
+ ds->bl_desc.dyn_tree = ds->bl_tree;
+
+ return Z_OK;
+#endif /* MAXSEG_64K */
+}
+
+/* ===========================================================================
+ * Read a new buffer from the current input stream, update the adler32
+ * and total number of bytes read. All deflate() input goes through
+ * this function so some applications may wish to modify it to avoid
+ * allocating a large strm->next_in buffer and copying from it.
+ * (See also flush_pending()).
+ */
+local int read_buf(strm, buf, size)
+ z_streamp strm;
+ Bytef *buf;
+ unsigned size;
+{
+ unsigned len = strm->avail_in;
+
+ if (len > size) len = size;
+ if (len == 0) return 0;
+
+ strm->avail_in -= len;
+
+ if (strm->state->wrap == 1) {
+ strm->adler = adler32(strm->adler, strm->next_in, len);
+ }
+#ifdef GZIP
+ else if (strm->state->wrap == 2) {
+ strm->adler = crc32(strm->adler, strm->next_in, len);
+ }
+#endif
+ zmemcpy(buf, strm->next_in, len);
+ strm->next_in += len;
+ strm->total_in += len;
+
+ return (int)len;
+}
+
+/* ===========================================================================
+ * Initialize the "longest match" routines for a new zlib stream
+ */
+local void lm_init (s)
+ deflate_state *s;
+{
+ s->window_size = (ulg)2L*s->w_size;
+
+ CLEAR_HASH(s);
+
+ /* Set the default configuration parameters:
+ */
+ s->max_lazy_match = configuration_table[s->level].max_lazy;
+ s->good_match = configuration_table[s->level].good_length;
+ s->nice_match = configuration_table[s->level].nice_length;
+ s->max_chain_length = configuration_table[s->level].max_chain;
+
+ s->strstart = 0;
+ s->block_start = 0L;
+ s->lookahead = 0;
+ s->match_length = s->prev_length = MIN_MATCH-1;
+ s->match_available = 0;
+ s->ins_h = 0;
+#ifndef FASTEST
+#ifdef ASMV
+ match_init(); /* initialize the asm code */
+#endif
+#endif
+}
+
+#ifndef FASTEST
+/* ===========================================================================
+ * Set match_start to the longest match starting at the given string and
+ * return its length. Matches shorter or equal to prev_length are discarded,
+ * in which case the result is equal to prev_length and match_start is
+ * garbage.
+ * IN assertions: cur_match is the head of the hash chain for the current
+ * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1
+ * OUT assertion: the match length is not greater than s->lookahead.
+ */
+#ifndef ASMV
+/* For 80x86 and 680x0, an optimized version will be provided in match.asm or
+ * match.S. The code will be functionally equivalent.
+ */
+local uInt longest_match(s, cur_match)
+ deflate_state *s;
+ IPos cur_match; /* current match */
+{
+ unsigned chain_length = s->max_chain_length;/* max hash chain length */
+ register Bytef *scan = s->window + s->strstart; /* current string */
+ register Bytef *match; /* matched string */
+ register int len; /* length of current match */
+ int best_len = s->prev_length; /* best match length so far */
+ int nice_match = s->nice_match; /* stop if match long enough */
+ IPos limit = s->strstart > (IPos)MAX_DIST(s) ?
+ s->strstart - (IPos)MAX_DIST(s) : NIL;
+ /* Stop when cur_match becomes <= limit. To simplify the code,
+ * we prevent matches with the string of window index 0.
+ */
+ Posf *prev = s->prev;
+ uInt wmask = s->w_mask;
+
+#ifdef UNALIGNED_OK
+ /* Compare two bytes at a time. Note: this is not always beneficial.
+ * Try with and without -DUNALIGNED_OK to check.
+ */
+ register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1;
+ register ush scan_start = *(ushf*)scan;
+ register ush scan_end = *(ushf*)(scan+best_len-1);
+#else
+ register Bytef *strend = s->window + s->strstart + MAX_MATCH;
+ register Byte scan_end1 = scan[best_len-1];
+ register Byte scan_end = scan[best_len];
+#endif
+
+ /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
+ * It is easy to get rid of this optimization if necessary.
+ */
+ Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever");
+
+ /* Do not waste too much time if we already have a good match: */
+ if (s->prev_length >= s->good_match) {
+ chain_length >>= 2;
+ }
+ /* Do not look for matches beyond the end of the input. This is necessary
+ * to make deflate deterministic.
+ */
+ if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead;
+
+ Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
+
+ do {
+ Assert(cur_match < s->strstart, "no future");
+ match = s->window + cur_match;
+
+ /* Skip to next match if the match length cannot increase
+ * or if the match length is less than 2. Note that the checks below
+ * for insufficient lookahead only occur occasionally for performance
+ * reasons. Therefore uninitialized memory will be accessed, and
+ * conditional jumps will be made that depend on those values.
+ * However the length of the match is limited to the lookahead, so
+ * the output of deflate is not affected by the uninitialized values.
+ */
+#if (defined(UNALIGNED_OK) && MAX_MATCH == 258)
+ /* This code assumes sizeof(unsigned short) == 2. Do not use
+ * UNALIGNED_OK if your compiler uses a different size.
+ */
+ if (*(ushf*)(match+best_len-1) != scan_end ||
+ *(ushf*)match != scan_start) continue;
+
+ /* It is not necessary to compare scan[2] and match[2] since they are
+ * always equal when the other bytes match, given that the hash keys
+ * are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at
+ * strstart+3, +5, ... up to strstart+257. We check for insufficient
+ * lookahead only every 4th comparison; the 128th check will be made
+ * at strstart+257. If MAX_MATCH-2 is not a multiple of 8, it is
+ * necessary to put more guard bytes at the end of the window, or
+ * to check more often for insufficient lookahead.
+ */
+ Assert(scan[2] == match[2], "scan[2]?");
+ scan++, match++;
+ do {
+ } while (*(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
+ *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
+ *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
+ *(ushf*)(scan+=2) == *(ushf*)(match+=2) &&
+ scan < strend);
+ /* The funny "do {}" generates better code on most compilers */
+
+ /* Here, scan <= window+strstart+257 */
+ Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
+ if (*scan == *match) scan++;
+
+ len = (MAX_MATCH - 1) - (int)(strend-scan);
+ scan = strend - (MAX_MATCH-1);
+
+#else /* UNALIGNED_OK */
+
+ if (match[best_len] != scan_end ||
+ match[best_len-1] != scan_end1 ||
+ *match != *scan ||
+ *++match != scan[1]) continue;
+
+ /* The check at best_len-1 can be removed because it will be made
+ * again later. (This heuristic is not always a win.)
+ * It is not necessary to compare scan[2] and match[2] since they
+ * are always equal when the other bytes match, given that
+ * the hash keys are equal and that HASH_BITS >= 8.
+ */
+ scan += 2, match++;
+ Assert(*scan == *match, "match[2]?");
+
+ /* We check for insufficient lookahead only every 8th comparison;
+ * the 256th check will be made at strstart+258.
+ */
+ do {
+ } while (*++scan == *++match && *++scan == *++match &&
+ *++scan == *++match && *++scan == *++match &&
+ *++scan == *++match && *++scan == *++match &&
+ *++scan == *++match && *++scan == *++match &&
+ scan < strend);
+
+ Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
+
+ len = MAX_MATCH - (int)(strend - scan);
+ scan = strend - MAX_MATCH;
+
+#endif /* UNALIGNED_OK */
+
+ if (len > best_len) {
+ s->match_start = cur_match;
+ best_len = len;
+ if (len >= nice_match) break;
+#ifdef UNALIGNED_OK
+ scan_end = *(ushf*)(scan+best_len-1);
+#else
+ scan_end1 = scan[best_len-1];
+ scan_end = scan[best_len];
+#endif
+ }
+ } while ((cur_match = prev[cur_match & wmask]) > limit
+ && --chain_length != 0);
+
+ if ((uInt)best_len <= s->lookahead) return (uInt)best_len;
+ return s->lookahead;
+}
+#endif /* ASMV */
+
+#else /* FASTEST */
+
+/* ---------------------------------------------------------------------------
+ * Optimized version for FASTEST only
+ */
+local uInt longest_match(s, cur_match)
+ deflate_state *s;
+ IPos cur_match; /* current match */
+{
+ register Bytef *scan = s->window + s->strstart; /* current string */
+ register Bytef *match; /* matched string */
+ register int len; /* length of current match */
+ register Bytef *strend = s->window + s->strstart + MAX_MATCH;
+
+ /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
+ * It is easy to get rid of this optimization if necessary.
+ */
+ Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever");
+
+ Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead");
+
+ Assert(cur_match < s->strstart, "no future");
+
+ match = s->window + cur_match;
+
+ /* Return failure if the match length is less than 2:
+ */
+ if (match[0] != scan[0] || match[1] != scan[1]) return MIN_MATCH-1;
+
+ /* The check at best_len-1 can be removed because it will be made
+ * again later. (This heuristic is not always a win.)
+ * It is not necessary to compare scan[2] and match[2] since they
+ * are always equal when the other bytes match, given that
+ * the hash keys are equal and that HASH_BITS >= 8.
+ */
+ scan += 2, match += 2;
+ Assert(*scan == *match, "match[2]?");
+
+ /* We check for insufficient lookahead only every 8th comparison;
+ * the 256th check will be made at strstart+258.
+ */
+ do {
+ } while (*++scan == *++match && *++scan == *++match &&
+ *++scan == *++match && *++scan == *++match &&
+ *++scan == *++match && *++scan == *++match &&
+ *++scan == *++match && *++scan == *++match &&
+ scan < strend);
+
+ Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan");
+
+ len = MAX_MATCH - (int)(strend - scan);
+
+ if (len < MIN_MATCH) return MIN_MATCH - 1;
+
+ s->match_start = cur_match;
+ return (uInt)len <= s->lookahead ? (uInt)len : s->lookahead;
+}
+
+#endif /* FASTEST */
+
+#ifdef DEBUG
+/* ===========================================================================
+ * Check that the match at match_start is indeed a match.
+ */
+local void check_match(s, start, match, length)
+ deflate_state *s;
+ IPos start, match;
+ int length;
+{
+ /* check that the match is indeed a match */
+ if (zmemcmp(s->window + match,
+ s->window + start, length) != EQUAL) {
+ fprintf(stderr, " start %u, match %u, length %d\n",
+ start, match, length);
+ do {
+ fprintf(stderr, "%c%c", s->window[match++], s->window[start++]);
+ } while (--length != 0);
+ z_error("invalid match");
+ }
+ if (z_verbose > 1) {
+ fprintf(stderr,"\\[%d,%d]", start-match, length);
+ do { putc(s->window[start++], stderr); } while (--length != 0);
+ }
+}
+#else
+# define check_match(s, start, match, length)
+#endif /* DEBUG */
+
+/* ===========================================================================
+ * Fill the window when the lookahead becomes insufficient.
+ * Updates strstart and lookahead.
+ *
+ * IN assertion: lookahead < MIN_LOOKAHEAD
+ * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD
+ * At least one byte has been read, or avail_in == 0; reads are
+ * performed for at least two bytes (required for the zip translate_eol
+ * option -- not supported here).
+ */
+local void fill_window(s)
+ deflate_state *s;
+{
+ register unsigned n, m;
+ register Posf *p;
+ unsigned more; /* Amount of free space at the end of the window. */
+ uInt wsize = s->w_size;
+
+ do {
+ more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart);
+
+ /* Deal with !@#$% 64K limit: */
+ if (sizeof(int) <= 2) {
+ if (more == 0 && s->strstart == 0 && s->lookahead == 0) {
+ more = wsize;
+
+ } else if (more == (unsigned)(-1)) {
+ /* Very unlikely, but possible on 16 bit machine if
+ * strstart == 0 && lookahead == 1 (input done a byte at time)
+ */
+ more--;
+ }
+ }
+
+ /* If the window is almost full and there is insufficient lookahead,
+ * move the upper half to the lower one to make room in the upper half.
+ */
+ if (s->strstart >= wsize+MAX_DIST(s)) {
+
+ zmemcpy(s->window, s->window+wsize, (unsigned)wsize);
+ s->match_start -= wsize;
+ s->strstart -= wsize; /* we now have strstart >= MAX_DIST */
+ s->block_start -= (long) wsize;
+
+ /* Slide the hash table (could be avoided with 32 bit values
+ at the expense of memory usage). We slide even when level == 0
+ to keep the hash table consistent if we switch back to level > 0
+ later. (Using level 0 permanently is not an optimal usage of
+ zlib, so we don't care about this pathological case.)
+ */
+ n = s->hash_size;
+ p = &s->head[n];
+ do {
+ m = *--p;
+ *p = (Pos)(m >= wsize ? m-wsize : NIL);
+ } while (--n);
+
+ n = wsize;
+#ifndef FASTEST
+ p = &s->prev[n];
+ do {
+ m = *--p;
+ *p = (Pos)(m >= wsize ? m-wsize : NIL);
+ /* If n is not on any hash chain, prev[n] is garbage but
+ * its value will never be used.
+ */
+ } while (--n);
+#endif
+ more += wsize;
+ }
+ if (s->strm->avail_in == 0) return;
+
+ /* If there was no sliding:
+ * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 &&
+ * more == window_size - lookahead - strstart
+ * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1)
+ * => more >= window_size - 2*WSIZE + 2
+ * In the BIG_MEM or MMAP case (not yet supported),
+ * window_size == input_size + MIN_LOOKAHEAD &&
+ * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD.
+ * Otherwise, window_size == 2*WSIZE so more >= 2.
+ * If there was sliding, more >= WSIZE. So in all cases, more >= 2.
+ */
+ Assert(more >= 2, "more < 2");
+
+ n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more);
+ s->lookahead += n;
+
+ /* Initialize the hash value now that we have some input: */
+ if (s->lookahead >= MIN_MATCH) {
+ s->ins_h = s->window[s->strstart];
+ UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]);
+#if MIN_MATCH != 3
+ Call UPDATE_HASH() MIN_MATCH-3 more times
+#endif
+ }
+ /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage,
+ * but this is not important since only literal bytes will be emitted.
+ */
+
+ } 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, 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), \
+ (last)); \
+ s->block_start = s->strstart; \
+ flush_pending(s->strm); \
+ Tracev((stderr,"[FLUSH]")); \
+}
+
+/* Same but force premature exit if necessary. */
+#define FLUSH_BLOCK(s, last) { \
+ FLUSH_BLOCK_ONLY(s, last); \
+ if (s->strm->avail_out == 0) return (last) ? finish_started : need_more; \
+}
+
+/* ===========================================================================
+ * Copy without compression as much as possible from the input stream, return
+ * the current block state.
+ * This function does not insert new strings in the dictionary since
+ * uncompressible data is probably not useful. This function is used
+ * only for the level=0 compression option.
+ * NOTE: this function should be optimized to avoid extra copying from
+ * window to pending_buf.
+ */
+local block_state deflate_stored(s, flush)
+ deflate_state *s;
+ int flush;
+{
+ /* Stored blocks are limited to 0xffff bytes, pending_buf is limited
+ * to pending_buf_size, and each stored block has a 5 byte header:
+ */
+ ulg max_block_size = 0xffff;
+ ulg max_start;
+
+ if (max_block_size > s->pending_buf_size - 5) {
+ max_block_size = s->pending_buf_size - 5;
+ }
+
+ /* Copy as much as possible from input to output: */
+ for (;;) {
+ /* Fill the window as much as possible: */
+ if (s->lookahead <= 1) {
+
+ Assert(s->strstart < s->w_size+MAX_DIST(s) ||
+ s->block_start >= (long)s->w_size, "slide too late");
+
+ fill_window(s);
+ if (s->lookahead == 0 && flush == Z_NO_FLUSH) return need_more;
+
+ if (s->lookahead == 0) break; /* flush the current block */
+ }
+ Assert(s->block_start >= 0L, "block gone");
+
+ s->strstart += s->lookahead;
+ s->lookahead = 0;
+
+ /* Emit a stored block if pending_buf will be full: */
+ max_start = s->block_start + max_block_size;
+ if (s->strstart == 0 || (ulg)s->strstart >= max_start) {
+ /* strstart == 0 is possible when wraparound on 16-bit machine */
+ s->lookahead = (uInt)(s->strstart - max_start);
+ s->strstart = (uInt)max_start;
+ FLUSH_BLOCK(s, 0);
+ }
+ /* Flush if we may have to slide, otherwise block_start may become
+ * negative and the data will be gone:
+ */
+ if (s->strstart - (uInt)s->block_start >= MAX_DIST(s)) {
+ FLUSH_BLOCK(s, 0);
+ }
+ }
+ FLUSH_BLOCK(s, flush == Z_FINISH);
+ return flush == Z_FINISH ? finish_done : block_done;
+}
+
+/* ===========================================================================
+ * Compress as much as possible from the input stream, return the current
+ * block state.
+ * This function does not perform lazy evaluation of matches and inserts
+ * new strings in the dictionary only for unmatched strings or for short
+ * matches. It is used only for the fast compression options.
+ */
+local block_state deflate_fast(s, flush)
+ deflate_state *s;
+ int flush;
+{
+ IPos hash_head; /* head of the hash chain */
+ int bflush; /* set if current block must be flushed */
+
+ for (;;) {
+ /* Make sure that we always have enough lookahead, except
+ * at the end of the input file. We need MAX_MATCH bytes
+ * for the next match, plus MIN_MATCH bytes to insert the
+ * string following the next match.
+ */
+ if (s->lookahead < MIN_LOOKAHEAD) {
+ fill_window(s);
+ if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
+ return need_more;
+ }
+ if (s->lookahead == 0) break; /* flush the current block */
+ }
+
+ /* 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);
+ }
+
+ /* Find the longest match, discarding those <= prev_length.
+ * At this point we have always match_length < MIN_MATCH
+ */
+ if (hash_head != NIL && s->strstart - hash_head <= MAX_DIST(s)) {
+ /* To simplify the code, we prevent matches with the string
+ * of window index 0 (in particular we have to avoid a match
+ * of the string with itself at the start of the input file).
+ */
+ 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);
+
+ _tr_tally_dist(s, s->strstart - s->match_start,
+ s->match_length - MIN_MATCH, bflush);
+
+ s->lookahead -= s->match_length;
+
+ /* Insert new strings in the hash table only if the match length
+ * is not too large. This saves time but degrades compression.
+ */
+#ifndef FASTEST
+ if (s->match_length <= s->max_insert_length &&
+ s->lookahead >= MIN_MATCH) {
+ s->match_length--; /* string at strstart already in table */
+ do {
+ s->strstart++;
+ INSERT_STRING(s, s->strstart, hash_head);
+ /* strstart never exceeds WSIZE-MAX_MATCH, so there are
+ * always MIN_MATCH bytes ahead.
+ */
+ } while (--s->match_length != 0);
+ s->strstart++;
+ } else
+#endif
+ {
+ s->strstart += s->match_length;
+ s->match_length = 0;
+ s->ins_h = s->window[s->strstart];
+ UPDATE_HASH(s, s->ins_h, s->window[s->strstart+1]);
+#if MIN_MATCH != 3
+ Call UPDATE_HASH() MIN_MATCH-3 more times
+#endif
+ /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not
+ * matter since it will be recomputed at next deflate call.
+ */
+ }
+ } else {
+ /* No match, output a literal byte */
+ 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;
+}
+
+#ifndef FASTEST
+/* ===========================================================================
+ * Same as above, but achieves better compression. We use a lazy
+ * evaluation for matches: a match is finally adopted only if there is
+ * no better match at the next window position.
+ */
+local block_state deflate_slow(s, flush)
+ deflate_state *s;
+ int flush;
+{
+ IPos hash_head; /* head of hash chain */
+ int bflush; /* set if current block must be flushed */
+
+ /* Process the input block. */
+ for (;;) {
+ /* Make sure that we always have enough lookahead, except
+ * at the end of the input file. We need MAX_MATCH bytes
+ * for the next match, plus MIN_MATCH bytes to insert the
+ * string following the next match.
+ */
+ if (s->lookahead < MIN_LOOKAHEAD) {
+ fill_window(s);
+ if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
+ return need_more;
+ }
+ if (s->lookahead == 0) break; /* flush the current block */
+ }
+
+ /* 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);
+ }
+
+ /* Find the longest match, discarding those <= prev_length.
+ */
+ s->prev_length = s->match_length, s->prev_match = s->match_start;
+ s->match_length = MIN_MATCH-1;
+
+ if (hash_head != NIL && s->prev_length < s->max_lazy_match &&
+ s->strstart - hash_head <= MAX_DIST(s)) {
+ /* To simplify the code, we prevent matches with the string
+ * of window index 0 (in particular we have to avoid a match
+ * of the string with itself at the start of the input file).
+ */
+ 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
+ || (s->match_length == MIN_MATCH &&
+ s->strstart - s->match_start > TOO_FAR)
+#endif
+ )) {
+
+ /* If prev_match is also MIN_MATCH, match_start is garbage
+ * but we will ignore the current match anyway.
+ */
+ s->match_length = MIN_MATCH-1;
+ }
+ }
+ /* If there was a match at the previous step and the current
+ * match is not better, output the previous match:
+ */
+ if (s->prev_length >= MIN_MATCH && s->match_length <= s->prev_length) {
+ uInt max_insert = s->strstart + s->lookahead - MIN_MATCH;
+ /* Do not insert strings in hash table beyond this. */
+
+ check_match(s, s->strstart-1, s->prev_match, s->prev_length);
+
+ _tr_tally_dist(s, s->strstart -1 - s->prev_match,
+ s->prev_length - MIN_MATCH, bflush);
+
+ /* Insert in hash table all strings up to the end of the match.
+ * strstart-1 and strstart are already inserted. If there is not
+ * enough lookahead, the last two strings are not inserted in
+ * the hash table.
+ */
+ s->lookahead -= s->prev_length-1;
+ s->prev_length -= 2;
+ do {
+ if (++s->strstart <= max_insert) {
+ INSERT_STRING(s, s->strstart, hash_head);
+ }
+ } while (--s->prev_length != 0);
+ s->match_available = 0;
+ s->match_length = MIN_MATCH-1;
+ s->strstart++;
+
+ if (bflush) FLUSH_BLOCK(s, 0);
+
+ } else if (s->match_available) {
+ /* If there was no match at the previous position, output a
+ * single literal. If there was a match but the current match
+ * is longer, truncate the previous match to a single literal.
+ */
+ Tracevv((stderr,"%c", s->window[s->strstart-1]));
+ _tr_tally_lit(s, s->window[s->strstart-1], bflush);
+ if (bflush) {
+ FLUSH_BLOCK_ONLY(s, 0);
+ }
+ s->strstart++;
+ s->lookahead--;
+ if (s->strm->avail_out == 0) return need_more;
+ } else {
+ /* There is no previous match to compare with, wait for
+ * the next step to decide.
+ */
+ s->match_available = 1;
+ s->strstart++;
+ s->lookahead--;
+ }
+ }
+ Assert (flush != Z_NO_FLUSH, "no flush?");
+ if (s->match_available) {
+ Tracevv((stderr,"%c", s->window[s->strstart-1]));
+ _tr_tally_lit(s, s->window[s->strstart-1], bflush);
+ s->match_available = 0;
+ }
+ FLUSH_BLOCK(s, flush == Z_FINISH);
+ return flush == Z_FINISH ? finish_done : block_done;
+}
+#endif /* FASTEST */
+
+/* ===========================================================================
+ * 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
+ * deflate switches away from Z_RLE.)
+ */
+local block_state deflate_rle(s, flush)
+ deflate_state *s;
+ int flush;
+{
+ 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
+ * at the end of the input file. We need MAX_MATCH bytes
+ * for the longest encodable run.
+ */
+ if (s->lookahead < MAX_MATCH) {
+ fill_window(s);
+ if (s->lookahead < MAX_MATCH && flush == Z_NO_FLUSH) {
+ return need_more;
+ }
+ if (s->lookahead == 0) break; /* flush the current block */
+ }
+
+ /* See how many times the previous byte repeats */
+ s->match_length = 0;
+ if (s->lookahead >= MIN_MATCH && s->strstart > 0) {
+ scan = s->window + s->strstart - 1;
+ 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 (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]));
+ _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;
+}
+
+/* ===========================================================================
+ * 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;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/deflate.h Thu Dec 15 15:57:51 2011 -0800
@@ -0,0 +1,366 @@
+/*
+ * 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.
+ */
+
+/* deflate.h -- internal compression state
+ * Copyright (C) 1995-2010 Jean-loup Gailly
+ * 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.
+ */
+
+/* @(#) $Id$ */
+
+#ifndef DEFLATE_H
+#define DEFLATE_H
+
+#include "zutil.h"
+
+/* define NO_GZIP when compiling if you want to disable gzip header and
+ trailer creation by deflate(). NO_GZIP would be used to avoid linking in
+ the crc code when it is not needed. For shared libraries, gzip encoding
+ should be left enabled. */
+#ifndef NO_GZIP
+# define GZIP
+#endif
+
+/* ===========================================================================
+ * Internal compression state.
+ */
+
+#define LENGTH_CODES 29
+/* number of length codes, not counting the special END_BLOCK code */
+
+#define LITERALS 256
+/* number of literal bytes 0..255 */
+
+#define L_CODES (LITERALS+1+LENGTH_CODES)
+/* number of Literal or Length codes, including the END_BLOCK code */
+
+#define D_CODES 30
+/* number of distance codes */
+
+#define BL_CODES 19
+/* number of codes used to transfer the bit lengths */
+
+#define HEAP_SIZE (2*L_CODES+1)
+/* maximum heap size */
+
+#define MAX_BITS 15
+/* All codes must not exceed MAX_BITS bits */
+
+#define INIT_STATE 42
+#define EXTRA_STATE 69
+#define NAME_STATE 73
+#define COMMENT_STATE 91
+#define HCRC_STATE 103
+#define BUSY_STATE 113
+#define FINISH_STATE 666
+/* Stream status */
+
+
+/* Data structure describing a single value and its code string. */
+typedef struct ct_data_s {
+ union {
+ ush freq; /* frequency count */
+ ush code; /* bit string */
+ } fc;
+ union {
+ ush dad; /* father node in Huffman tree */
+ ush len; /* length of bit string */
+ } dl;
+} FAR ct_data;
+
+#define Freq fc.freq
+#define Code fc.code
+#define Dad dl.dad
+#define Len dl.len
+
+typedef struct static_tree_desc_s static_tree_desc;
+
+typedef struct tree_desc_s {
+ ct_data *dyn_tree; /* the dynamic tree */
+ int max_code; /* largest code with non zero frequency */
+ static_tree_desc *stat_desc; /* the corresponding static tree */
+} FAR tree_desc;
+
+typedef ush Pos;
+typedef Pos FAR Posf;
+typedef unsigned IPos;
+
+/* A Pos is an index in the character window. We use short instead of int to
+ * save space in the various tables. IPos is used only for parameter passing.
+ */
+
+typedef struct internal_state {
+ z_streamp strm; /* pointer back to this zlib stream */
+ int status; /* as the name implies */
+ Bytef *pending_buf; /* output still pending */
+ ulg pending_buf_size; /* size of pending_buf */
+ Bytef *pending_out; /* next pending byte to output to the stream */
+ uInt pending; /* nb of bytes in the pending buffer */
+ int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
+ gz_headerp gzhead; /* gzip header information to write */
+ uInt gzindex; /* where in extra, name, or comment */
+ Byte method; /* STORED (for zip only) or DEFLATED */
+ int last_flush; /* value of flush param for previous deflate call */
+
+ /* used by deflate.c: */
+
+ uInt w_size; /* LZ77 window size (32K by default) */
+ uInt w_bits; /* log2(w_size) (8..16) */
+ uInt w_mask; /* w_size - 1 */
+
+ Bytef *window;
+ /* Sliding window. Input bytes are read into the second half of the window,
+ * and move to the first half later to keep a dictionary of at least wSize
+ * bytes. With this organization, matches are limited to a distance of
+ * wSize-MAX_MATCH bytes, but this ensures that IO is always
+ * performed with a length multiple of the block size. Also, it limits
+ * the window size to 64K, which is quite useful on MSDOS.
+ * To do: use the user input buffer as sliding window.
+ */
+
+ ulg window_size;
+ /* Actual size of window: 2*wSize, except when the user input buffer
+ * is directly used as sliding window.
+ */
+
+ Posf *prev;
+ /* Link to older string with same hash index. To limit the size of this
+ * array to 64K, this link is maintained only for the last 32K strings.
+ * An index in this array is thus a window index modulo 32K.
+ */
+
+ Posf *head; /* Heads of the hash chains or NIL. */
+
+ uInt ins_h; /* hash index of string to be inserted */
+ uInt hash_size; /* number of elements in hash table */
+ uInt hash_bits; /* log2(hash_size) */
+ uInt hash_mask; /* hash_size-1 */
+
+ uInt hash_shift;
+ /* Number of bits by which ins_h must be shifted at each input
+ * step. It must be such that after MIN_MATCH steps, the oldest
+ * byte no longer takes part in the hash key, that is:
+ * hash_shift * MIN_MATCH >= hash_bits
+ */
+
+ long block_start;
+ /* Window position at the beginning of the current output block. Gets
+ * negative when the window is moved backwards.
+ */
+
+ uInt match_length; /* length of best match */
+ IPos prev_match; /* previous match */
+ int match_available; /* set if previous match exists */
+ uInt strstart; /* start of string to insert */
+ uInt match_start; /* start of matching string */
+ uInt lookahead; /* number of valid bytes ahead in window */
+
+ uInt prev_length;
+ /* Length of the best match at previous step. Matches not greater than this
+ * are discarded. This is used in the lazy match evaluation.
+ */
+
+ uInt max_chain_length;
+ /* To speed up deflation, hash chains are never searched beyond this
+ * length. A higher limit improves compression ratio but degrades the
+ * speed.
+ */
+
+ uInt max_lazy_match;
+ /* Attempt to find a better match only when the current match is strictly
+ * smaller than this value. This mechanism is used only for compression
+ * levels >= 4.
+ */
+# define max_insert_length max_lazy_match
+ /* Insert new strings in the hash table only if the match length is not
+ * greater than this length. This saves time but degrades compression.
+ * max_insert_length is used only for compression levels <= 3.
+ */
+
+ int level; /* compression level (1..9) */
+ int strategy; /* favor or force Huffman coding*/
+
+ uInt good_match;
+ /* Use a faster search when the previous match is longer than this */
+
+ int nice_match; /* Stop searching when current match exceeds this */
+
+ /* used by trees.c: */
+ /* Didn't use ct_data typedef below to supress compiler warning */
+ struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */
+ struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */
+ struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */
+
+ struct tree_desc_s l_desc; /* desc. for literal tree */
+ struct tree_desc_s d_desc; /* desc. for distance tree */
+ struct tree_desc_s bl_desc; /* desc. for bit length tree */
+
+ ush bl_count[MAX_BITS+1];
+ /* number of codes at each bit length for an optimal tree */
+
+ int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */
+ int heap_len; /* number of elements in the heap */
+ int heap_max; /* element of largest frequency */
+ /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used.
+ * The same heap array is used to build all trees.
+ */
+
+ uch depth[2*L_CODES+1];
+ /* Depth of each subtree used as tie breaker for trees of equal frequency
+ */
+
+ uchf *l_buf; /* buffer for literals or lengths */
+
+ uInt lit_bufsize;
+ /* Size of match buffer for literals/lengths. There are 4 reasons for
+ * limiting lit_bufsize to 64K:
+ * - frequencies can be kept in 16 bit counters
+ * - if compression is not successful for the first block, all input
+ * data is still in the window so we can still emit a stored block even
+ * when input comes from standard input. (This can also be done for
+ * all blocks if lit_bufsize is not greater than 32K.)
+ * - if compression is not successful for a file smaller than 64K, we can
+ * even emit a stored file instead of a stored block (saving 5 bytes).
+ * This is applicable only for zip (not gzip or zlib).
+ * - creating new Huffman trees less frequently may not provide fast
+ * adaptation to changes in the input data statistics. (Take for
+ * example a binary file with poorly compressible code followed by
+ * a highly compressible string table.) Smaller buffer sizes give
+ * fast adaptation but have of course the overhead of transmitting
+ * trees more frequently.
+ * - I can't count above 4
+ */
+
+ uInt last_lit; /* running index in l_buf */
+
+ ushf *d_buf;
+ /* Buffer for distances. To simplify the code, d_buf and l_buf have
+ * the same number of elements. To use different lengths, an extra flag
+ * array would be necessary.
+ */
+
+ ulg opt_len; /* bit length of current block with optimal trees */
+ ulg static_len; /* bit length of current block with static trees */
+ uInt matches; /* number of string matches in current block */
+ int last_eob_len; /* bit length of EOB code for last block */
+
+#ifdef DEBUG
+ ulg compressed_len; /* total bit length of compressed file mod 2^32 */
+ ulg bits_sent; /* bit length of compressed data sent mod 2^32 */
+#endif
+
+ ush bi_buf;
+ /* Output buffer. bits are inserted starting at the bottom (least
+ * significant bits).
+ */
+ int bi_valid;
+ /* Number of valid bits in bi_buf. All bits above the last valid bit
+ * 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.
+ * IN assertion: there is enough room in pending_buf.
+ */
+#define put_byte(s, c) {s->pending_buf[s->pending++] = (c);}
+
+
+#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.
+ */
+
+#define MAX_DIST(s) ((s)->w_size-MIN_LOOKAHEAD)
+/* In order to simplify the code, particularly on 16 bit machines, match
+ * 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 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)])
+/* Mapping from a distance to a distance code. dist is the distance - 1 and
+ * must not have side effects. _dist_code[256] and _dist_code[257] are never
+ * used.
+ */
+
+#ifndef DEBUG
+/* Inline versions of _tr_tally for speed: */
+
+#if defined(GEN_TREES_H) || !defined(STDC)
+ extern uch ZLIB_INTERNAL _length_code[];
+ extern uch ZLIB_INTERNAL _dist_code[];
+#else
+ extern const uch ZLIB_INTERNAL _length_code[];
+ extern const uch ZLIB_INTERNAL _dist_code[];
+#endif
+
+# define _tr_tally_lit(s, c, flush) \
+ { uch cc = (c); \
+ s->d_buf[s->last_lit] = 0; \
+ s->l_buf[s->last_lit++] = cc; \
+ s->dyn_ltree[cc].Freq++; \
+ flush = (s->last_lit == s->lit_bufsize-1); \
+ }
+# define _tr_tally_dist(s, distance, length, flush) \
+ { uch len = (length); \
+ ush dist = (distance); \
+ s->d_buf[s->last_lit] = dist; \
+ s->l_buf[s->last_lit++] = len; \
+ dist--; \
+ s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \
+ s->dyn_dtree[d_code(dist)].Freq++; \
+ flush = (s->last_lit == s->lit_bufsize-1); \
+ }
+#else
+# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c)
+# define _tr_tally_dist(s, distance, length, flush) \
+ flush = _tr_tally(s, distance, length)
+#endif
+
+#endif /* DEFLATE_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/gzclose.c Thu Dec 15 15:57:51 2011 -0800
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+
+/* gzclose.c -- zlib gzclose() function
+ * Copyright (C) 2004, 2010 Mark Adler
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+#include "gzguts.h"
+
+/* 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
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/gzguts.h Thu Dec 15 15:57:51 2011 -0800
@@ -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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/gzlib.c Thu Dec 15 15:57:51 2011 -0800
@@ -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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/gzread.c Thu Dec 15 15:57:51 2011 -0800
@@ -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;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/gzwrite.c Thu Dec 15 15:57:51 2011 -0800
@@ -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;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/infback.c Thu Dec 15 15:57:51 2011 -0800
@@ -0,0 +1,656 @@
+/*
+ * 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.
+ */
+
+/* infback.c -- inflate using a call-back interface
+ * Copyright (C) 1995-2009 Mark Adler
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+/*
+ This code is largely copied from inflate.c. Normally either infback.o or
+ inflate.o would be linked into an application--not both. The interface
+ with inffast.c is retained so that optimized assembler-coded versions of
+ inflate_fast() can be used with either inflate.c or infback.c.
+ */
+
+#include "zutil.h"
+#include "inftrees.h"
+#include "inflate.h"
+#include "inffast.h"
+
+/* function prototypes */
+local void fixedtables OF((struct inflate_state FAR *state));
+
+/*
+ strm provides memory allocation functions in zalloc and zfree, or
+ Z_NULL to use the library memory allocation functions.
+
+ windowBits is in the range 8..15, and window is a user-supplied
+ window and output buffer that is 2**windowBits bytes.
+ */
+int ZEXPORT inflateBackInit_(strm, windowBits, window, version, stream_size)
+z_streamp strm;
+int windowBits;
+unsigned char FAR *window;
+const char *version;
+int stream_size;
+{
+ struct inflate_state FAR *state;
+
+ if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
+ stream_size != (int)(sizeof(z_stream)))
+ return Z_VERSION_ERROR;
+ if (strm == Z_NULL || window == Z_NULL ||
+ windowBits < 8 || windowBits > 15)
+ return Z_STREAM_ERROR;
+ strm->msg = Z_NULL; /* in case we return an error */
+ if (strm->zalloc == (alloc_func)0) {
+ strm->zalloc = zcalloc;
+ strm->opaque = (voidpf)0;
+ }
+ if (strm->zfree == (free_func)0) strm->zfree = zcfree;
+ state = (struct inflate_state FAR *)ZALLOC(strm, 1,
+ sizeof(struct inflate_state));
+ if (state == Z_NULL) return Z_MEM_ERROR;
+ Tracev((stderr, "inflate: allocated\n"));
+ strm->state = (struct internal_state FAR *)state;
+ state->dmax = 32768U;
+ state->wbits = windowBits;
+ state->wsize = 1U << windowBits;
+ state->window = window;
+ state->wnext = 0;
+ state->whave = 0;
+ 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.
+ If BUILDFIXED is defined, then instead this routine builds the tables the
+ first time it's called, and returns those tables the first time and
+ thereafter. This reduces the size of the code by about 2K bytes, in
+ exchange for a little execution time. However, BUILDFIXED should not be
+ used for threaded applications, since the rewriting of the tables and virgin
+ may not be thread-safe.
+ */
+local void fixedtables(state)
+struct inflate_state FAR *state;
+{
+#ifdef BUILDFIXED
+ static int virgin = 1;
+ static code *lenfix, *distfix;
+ static code fixed[544];
+
+ /* build fixed huffman tables if first call (may not be thread safe) */
+ if (virgin) {
+ unsigned sym, bits;
+ static code *next;
+
+ /* literal/length table */
+ sym = 0;
+ while (sym < 144) state->lens[sym++] = 8;
+ while (sym < 256) state->lens[sym++] = 9;
+ while (sym < 280) state->lens[sym++] = 7;
+ while (sym < 288) state->lens[sym++] = 8;
+ next = fixed;
+ lenfix = next;
+ bits = 9;
+ inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work);
+
+ /* distance table */
+ sym = 0;
+ while (sym < 32) state->lens[sym++] = 5;
+ distfix = next;
+ bits = 5;
+ inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work);
+
+ /* do this just once */
+ virgin = 0;
+ }
+#else /* !BUILDFIXED */
+# include "inffixed.h"
+#endif /* BUILDFIXED */
+ state->lencode = lenfix;
+ state->lenbits = 9;
+ state->distcode = distfix;
+ state->distbits = 5;
+}
+
+/* Macros for inflateBack(): */
+
+/* Load returned state from inflate_fast() */
+#define LOAD() \
+ do { \
+ put = strm->next_out; \
+ left = strm->avail_out; \
+ next = strm->next_in; \
+ have = strm->avail_in; \
+ hold = state->hold; \
+ bits = state->bits; \
+ } while (0)
+
+/* Set state from registers for inflate_fast() */
+#define RESTORE() \
+ do { \
+ strm->next_out = put; \
+ strm->avail_out = left; \
+ strm->next_in = next; \
+ strm->avail_in = have; \
+ state->hold = hold; \
+ state->bits = bits; \
+ } while (0)
+
+/* Clear the input bit accumulator */
+#define INITBITS() \
+ do { \
+ hold = 0; \
+ bits = 0; \
+ } while (0)
+
+/* Assure that some input is available. If input is requested, but denied,
+ then return a Z_BUF_ERROR from inflateBack(). */
+#define PULL() \
+ do { \
+ if (have == 0) { \
+ have = in(in_desc, &next); \
+ if (have == 0) { \
+ next = Z_NULL; \
+ ret = Z_BUF_ERROR; \
+ goto inf_leave; \
+ } \
+ } \
+ } while (0)
+
+/* Get a byte of input into the bit accumulator, or return from inflateBack()
+ with an error if there is no input available. */
+#define PULLBYTE() \
+ do { \
+ PULL(); \
+ have--; \
+ hold += (unsigned long)(*next++) << bits; \
+ bits += 8; \
+ } while (0)
+
+/* Assure that there are at least n bits in the bit accumulator. If there is
+ not enough available input to do that, then return from inflateBack() with
+ an error. */
+#define NEEDBITS(n) \
+ do { \
+ while (bits < (unsigned)(n)) \
+ PULLBYTE(); \
+ } while (0)
+
+/* Return the low n bits of the bit accumulator (n < 16) */
+#define BITS(n) \
+ ((unsigned)hold & ((1U << (n)) - 1))
+
+/* Remove n bits from the bit accumulator */
+#define DROPBITS(n) \
+ do { \
+ hold >>= (n); \
+ bits -= (unsigned)(n); \
+ } while (0)
+
+/* Remove zero to seven bits as needed to go to a byte boundary */
+#define BYTEBITS() \
+ do { \
+ hold >>= bits & 7; \
+ bits -= bits & 7; \
+ } while (0)
+
+/* Assure that some output space is available, by writing out the window
+ if it's full. If the write fails, return from inflateBack() with a
+ Z_BUF_ERROR. */
+#define ROOM() \
+ do { \
+ if (left == 0) { \
+ put = state->window; \
+ left = state->wsize; \
+ state->whave = left; \
+ if (out(out_desc, put, left)) { \
+ ret = Z_BUF_ERROR; \
+ goto inf_leave; \
+ } \
+ } \
+ } while (0)
+
+/*
+ strm provides the memory allocation functions and window buffer on input,
+ and provides information on the unused input on return. For Z_DATA_ERROR
+ returns, strm will also provide an error message.
+
+ in() and out() are the call-back input and output functions. When
+ inflateBack() needs more input, it calls in(). When inflateBack() has
+ filled the window with output, or when it completes with data in the
+ window, it calls out() to write out the data. The application must not
+ change the provided input until in() is called again or inflateBack()
+ returns. The application must not change the window/output buffer until
+ inflateBack() returns.
+
+ in() and out() are called with a descriptor parameter provided in the
+ inflateBack() call. This parameter can be a structure that provides the
+ information required to do the read or write, as well as accumulated
+ information on the input and output such as totals and check values.
+
+ in() should return zero on failure. out() should return non-zero on
+ failure. If either in() or out() fails, than inflateBack() returns a
+ Z_BUF_ERROR. strm->next_in can be checked for Z_NULL to see whether it
+ was in() or out() that caused in the error. Otherwise, inflateBack()
+ returns Z_STREAM_END on success, Z_DATA_ERROR for an deflate format
+ error, or Z_MEM_ERROR if it could not allocate memory for the state.
+ inflateBack() can also return Z_STREAM_ERROR if the input parameters
+ are not correct, i.e. strm is Z_NULL or the state was not initialized.
+ */
+int ZEXPORT inflateBack(strm, in, in_desc, out, out_desc)
+z_streamp strm;
+in_func in;
+void FAR *in_desc;
+out_func out;
+void FAR *out_desc;
+{
+ struct inflate_state FAR *state;
+ unsigned char FAR *next; /* next input */
+ unsigned char FAR *put; /* next output */
+ unsigned have, left; /* available input and output */
+ unsigned long hold; /* bit buffer */
+ 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 here; /* current decoding table entry */
+ code last; /* parent table entry */
+ unsigned len; /* length to copy for repeats, bits to drop */
+ int ret; /* return code */
+ static const unsigned short order[19] = /* permutation of code lengths */
+ {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
+
+ /* Check that the strm exists and that the state was initialized */
+ if (strm == Z_NULL || strm->state == Z_NULL)
+ return Z_STREAM_ERROR;
+ state = (struct inflate_state FAR *)strm->state;
+
+ /* Reset the state */
+ strm->msg = Z_NULL;
+ state->mode = TYPE;
+ state->last = 0;
+ state->whave = 0;
+ next = strm->next_in;
+ have = next != Z_NULL ? strm->avail_in : 0;
+ hold = 0;
+ bits = 0;
+ put = state->window;
+ left = state->wsize;
+
+ /* Inflate until end of block marked as last */
+ for (;;)
+ switch (state->mode) {
+ case TYPE:
+ /* determine and dispatch block type */
+ if (state->last) {
+ BYTEBITS();
+ state->mode = DONE;
+ break;
+ }
+ NEEDBITS(3);
+ state->last = BITS(1);
+ DROPBITS(1);
+ switch (BITS(2)) {
+ case 0: /* stored block */
+ Tracev((stderr, "inflate: stored block%s\n",
+ state->last ? " (last)" : ""));
+ state->mode = STORED;
+ break;
+ case 1: /* fixed block */
+ fixedtables(state);
+ Tracev((stderr, "inflate: fixed codes block%s\n",
+ state->last ? " (last)" : ""));
+ state->mode = LEN; /* decode codes */
+ break;
+ case 2: /* dynamic block */
+ Tracev((stderr, "inflate: dynamic codes block%s\n",
+ state->last ? " (last)" : ""));
+ state->mode = TABLE;
+ break;
+ case 3:
+ strm->msg = (char *)"invalid block type";
+ state->mode = BAD;
+ }
+ DROPBITS(2);
+ break;
+
+ case STORED:
+ /* get and verify stored block length */
+ BYTEBITS(); /* go to byte boundary */
+ NEEDBITS(32);
+ if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
+ strm->msg = (char *)"invalid stored block lengths";
+ state->mode = BAD;
+ break;
+ }
+ state->length = (unsigned)hold & 0xffff;
+ Tracev((stderr, "inflate: stored length %u\n",
+ state->length));
+ INITBITS();
+
+ /* copy stored block from input to output */
+ while (state->length != 0) {
+ copy = state->length;
+ PULL();
+ ROOM();
+ if (copy > have) copy = have;
+ if (copy > left) copy = left;
+ zmemcpy(put, next, copy);
+ have -= copy;
+ next += copy;
+ left -= copy;
+ put += copy;
+ state->length -= copy;
+ }
+ Tracev((stderr, "inflate: stored end\n"));
+ state->mode = TYPE;
+ break;
+
+ case TABLE:
+ /* get dynamic table entries descriptor */
+ NEEDBITS(14);
+ state->nlen = BITS(5) + 257;
+ DROPBITS(5);
+ state->ndist = BITS(5) + 1;
+ DROPBITS(5);
+ state->ncode = BITS(4) + 4;
+ DROPBITS(4);
+#ifndef PKZIP_BUG_WORKAROUND
+ if (state->nlen > 286 || state->ndist > 30) {
+ strm->msg = (char *)"too many length or distance symbols";
+ state->mode = BAD;
+ break;
+ }
+#endif
+ Tracev((stderr, "inflate: table sizes ok\n"));
+
+ /* get code length code lengths (not a typo) */
+ state->have = 0;
+ while (state->have < state->ncode) {
+ NEEDBITS(3);
+ state->lens[order[state->have++]] = (unsigned short)BITS(3);
+ DROPBITS(3);
+ }
+ while (state->have < 19)
+ state->lens[order[state->have++]] = 0;
+ state->next = state->codes;
+ state->lencode = (code const FAR *)(state->next);
+ state->lenbits = 7;
+ ret = inflate_table(CODES, state->lens, 19, &(state->next),
+ &(state->lenbits), state->work);
+ if (ret) {
+ strm->msg = (char *)"invalid code lengths set";
+ state->mode = BAD;
+ break;
+ }
+ Tracev((stderr, "inflate: code lengths ok\n"));
+
+ /* get length and distance code code lengths */
+ state->have = 0;
+ while (state->have < state->nlen + state->ndist) {
+ for (;;) {
+ here = state->lencode[BITS(state->lenbits)];
+ if ((unsigned)(here.bits) <= bits) break;
+ PULLBYTE();
+ }
+ if (here.val < 16) {
+ NEEDBITS(here.bits);
+ DROPBITS(here.bits);
+ state->lens[state->have++] = here.val;
+ }
+ else {
+ 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;
+ break;
+ }
+ len = (unsigned)(state->lens[state->have - 1]);
+ copy = 3 + BITS(2);
+ DROPBITS(2);
+ }
+ else if (here.val == 17) {
+ NEEDBITS(here.bits + 3);
+ DROPBITS(here.bits);
+ len = 0;
+ copy = 3 + BITS(3);
+ DROPBITS(3);
+ }
+ else {
+ NEEDBITS(here.bits + 7);
+ DROPBITS(here.bits);
+ len = 0;
+ copy = 11 + BITS(7);
+ DROPBITS(7);
+ }
+ if (state->have + copy > state->nlen + state->ndist) {
+ strm->msg = (char *)"invalid bit length repeat";
+ state->mode = BAD;
+ break;
+ }
+ while (copy--)
+ state->lens[state->have++] = (unsigned short)len;
+ }
+ }
+
+ /* handle error breaks in while */
+ if (state->mode == BAD) break;
+
+ /* 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;
+ ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
+ &(state->lenbits), state->work);
+ if (ret) {
+ strm->msg = (char *)"invalid literal/lengths set";
+ state->mode = BAD;
+ break;
+ }
+ state->distcode = (code const FAR *)(state->next);
+ state->distbits = 6;
+ ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
+ &(state->next), &(state->distbits), state->work);
+ if (ret) {
+ strm->msg = (char *)"invalid distances set";
+ state->mode = BAD;
+ break;
+ }
+ Tracev((stderr, "inflate: codes ok\n"));
+ state->mode = LEN;
+
+ case LEN:
+ /* use inflate_fast() if we have enough input and output */
+ if (have >= 6 && left >= 258) {
+ RESTORE();
+ if (state->whave < state->wsize)
+ state->whave = state->wsize - left;
+ inflate_fast(strm, state->wsize);
+ LOAD();
+ break;
+ }
+
+ /* get a literal, length, or end-of-block code */
+ for (;;) {
+ here = state->lencode[BITS(state->lenbits)];
+ if ((unsigned)(here.bits) <= bits) break;
+ PULLBYTE();
+ }
+ if (here.op && (here.op & 0xf0) == 0) {
+ last = here;
+ for (;;) {
+ here = state->lencode[last.val +
+ (BITS(last.bits + last.op) >> last.bits)];
+ if ((unsigned)(last.bits + here.bits) <= bits) break;
+ PULLBYTE();
+ }
+ DROPBITS(last.bits);
+ }
+ DROPBITS(here.bits);
+ state->length = (unsigned)here.val;
+
+ /* process literal */
+ if (here.op == 0) {
+ Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
+ "inflate: literal '%c'\n" :
+ "inflate: literal 0x%02x\n", here.val));
+ ROOM();
+ *put++ = (unsigned char)(state->length);
+ left--;
+ state->mode = LEN;
+ break;
+ }
+
+ /* process end of block */
+ if (here.op & 32) {
+ Tracevv((stderr, "inflate: end of block\n"));
+ state->mode = TYPE;
+ break;
+ }
+
+ /* invalid code */
+ 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)(here.op) & 15;
+ if (state->extra != 0) {
+ NEEDBITS(state->extra);
+ state->length += BITS(state->extra);
+ DROPBITS(state->extra);
+ }
+ Tracevv((stderr, "inflate: length %u\n", state->length));
+
+ /* get distance code */
+ for (;;) {
+ here = state->distcode[BITS(state->distbits)];
+ if ((unsigned)(here.bits) <= bits) break;
+ PULLBYTE();
+ }
+ if ((here.op & 0xf0) == 0) {
+ last = here;
+ for (;;) {
+ here = state->distcode[last.val +
+ (BITS(last.bits + last.op) >> last.bits)];
+ if ((unsigned)(last.bits + here.bits) <= bits) break;
+ PULLBYTE();
+ }
+ DROPBITS(last.bits);
+ }
+ DROPBITS(here.bits);
+ if (here.op & 64) {
+ strm->msg = (char *)"invalid distance code";
+ state->mode = BAD;
+ break;
+ }
+ state->offset = (unsigned)here.val;
+
+ /* get distance extra bits, if any */
+ state->extra = (unsigned)(here.op) & 15;
+ if (state->extra != 0) {
+ NEEDBITS(state->extra);
+ state->offset += BITS(state->extra);
+ DROPBITS(state->extra);
+ }
+ if (state->offset > state->wsize - (state->whave < state->wsize ?
+ left : 0)) {
+ strm->msg = (char *)"invalid distance too far back";
+ state->mode = BAD;
+ break;
+ }
+ Tracevv((stderr, "inflate: distance %u\n", state->offset));
+
+ /* copy match from window to output */
+ do {
+ ROOM();
+ copy = state->wsize - state->offset;
+ if (copy < left) {
+ from = put + copy;
+ copy = left - copy;
+ }
+ else {
+ from = put - state->offset;
+ copy = left;
+ }
+ if (copy > state->length) copy = state->length;
+ state->length -= copy;
+ left -= copy;
+ do {
+ *put++ = *from++;
+ } while (--copy);
+ } while (state->length != 0);
+ break;
+
+ case DONE:
+ /* inflate stream terminated properly -- write leftover output */
+ ret = Z_STREAM_END;
+ if (left < state->wsize) {
+ if (out(out_desc, state->window, state->wsize - left))
+ ret = Z_BUF_ERROR;
+ }
+ goto inf_leave;
+
+ case BAD:
+ ret = Z_DATA_ERROR;
+ goto inf_leave;
+
+ default: /* can't happen, but makes compilers happy */
+ ret = Z_STREAM_ERROR;
+ goto inf_leave;
+ }
+
+ /* Return unused input */
+ inf_leave:
+ strm->next_in = next;
+ strm->avail_in = have;
+ return ret;
+}
+
+int ZEXPORT inflateBackEnd(strm)
+z_streamp strm;
+{
+ if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
+ return Z_STREAM_ERROR;
+ ZFREE(strm, strm->state);
+ strm->state = Z_NULL;
+ Tracev((stderr, "inflate: end\n"));
+ return Z_OK;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/inffast.c Thu Dec 15 15:57:51 2011 -0800
@@ -0,0 +1,364 @@
+/*
+ * 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.
+ */
+
+/* inffast.c -- fast decoding
+ * Copyright (C) 1995-2008, 2010 Mark Adler
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+#include "zutil.h"
+#include "inftrees.h"
+#include "inflate.h"
+#include "inffast.h"
+
+#ifndef ASMINF
+
+/* Allow machine dependent optimization for post-increment or pre-increment.
+ Based on testing to date,
+ Pre-increment preferred for:
+ - PowerPC G3 (Adler)
+ - MIPS R5000 (Randers-Pehrson)
+ Post-increment preferred for:
+ - none
+ No measurable difference:
+ - Pentium III (Anderson)
+ - M68060 (Nikl)
+ */
+#ifdef POSTINC
+# define OFF 0
+# define PUP(a) *(a)++
+#else
+# define OFF 1
+# define PUP(a) *++(a)
+#endif
+
+/*
+ Decode literal, length, and distance codes and write out the resulting
+ literal and match bytes until either not enough input or output is
+ available, an end-of-block is encountered, or a data error is encountered.
+ When large enough input and output buffers are supplied to inflate(), for
+ example, a 16K input buffer and a 64K output buffer, more than 95% of the
+ inflate execution time is spent in this routine.
+
+ Entry assumptions:
+
+ state->mode == LEN
+ strm->avail_in >= 6
+ strm->avail_out >= 258
+ start >= strm->avail_out
+ state->bits < 8
+
+ On return, state->mode is one of:
+
+ LEN -- ran out of enough output space or enough available input
+ TYPE -- reached end of block code, inflate() to interpret next block
+ BAD -- error in block data
+
+ Notes:
+
+ - The maximum input bits used by a length/distance pair is 15 bits for the
+ length code, 5 bits for the length extra, 15 bits for the distance code,
+ and 13 bits for the distance extra. This totals 48 bits, or six bytes.
+ Therefore if strm->avail_in >= 6, then there is enough input to avoid
+ checking for available input while decoding.
+
+ - The maximum bytes that a single length/distance pair can output is 258
+ bytes, which is the maximum length that can be coded. inflate_fast()
+ requires strm->avail_out >= 258 for each loop to avoid checking for
+ output space.
+ */
+void ZLIB_INTERNAL inflate_fast(strm, start)
+z_streamp strm;
+unsigned start; /* inflate()'s starting value for strm->avail_out */
+{
+ struct inflate_state FAR *state;
+ unsigned char FAR *in; /* local strm->next_in */
+ unsigned char FAR *last; /* while in < last, enough input available */
+ unsigned char FAR *out; /* local strm->next_out */
+ unsigned char FAR *beg; /* inflate()'s initial strm->next_out */
+ unsigned char FAR *end; /* while out < end, enough space available */
+#ifdef INFLATE_STRICT
+ unsigned dmax; /* maximum distance from zlib header */
+#endif
+ unsigned wsize; /* window size or zero if not using window */
+ unsigned whave; /* valid bytes in the window */
+ 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 */
+ code const FAR *lcode; /* local strm->lencode */
+ 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 here; /* retrieved table entry */
+ unsigned op; /* code bits, operation, extra bits, or */
+ /* window position, window bytes to copy */
+ unsigned len; /* match length, unused bytes */
+ unsigned dist; /* match distance */
+ unsigned char FAR *from; /* where to copy match from */
+
+ /* copy state to local variables */
+ state = (struct inflate_state FAR *)strm->state;
+ in = strm->next_in - OFF;
+ last = in + (strm->avail_in - 5);
+ out = strm->next_out - OFF;
+ beg = out - (start - strm->avail_out);
+ end = out + (strm->avail_out - 257);
+#ifdef INFLATE_STRICT
+ dmax = state->dmax;
+#endif
+ wsize = state->wsize;
+ whave = state->whave;
+ wnext = state->wnext;
+ window = state->window;
+ hold = state->hold;
+ bits = state->bits;
+ lcode = state->lencode;
+ dcode = state->distcode;
+ lmask = (1U << state->lenbits) - 1;
+ dmask = (1U << state->distbits) - 1;
+
+ /* decode literals and length/distances until end-of-block or not enough
+ input data or output space */
+ do {
+ if (bits < 15) {
+ hold += (unsigned long)(PUP(in)) << bits;
+ bits += 8;
+ hold += (unsigned long)(PUP(in)) << bits;
+ bits += 8;
+ }
+ here = lcode[hold & lmask];
+ dolen:
+ op = (unsigned)(here.bits);
+ hold >>= op;
+ bits -= op;
+ op = (unsigned)(here.op);
+ if (op == 0) { /* literal */
+ Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
+ "inflate: literal '%c'\n" :
+ "inflate: literal 0x%02x\n", here.val));
+ PUP(out) = (unsigned char)(here.val);
+ }
+ else if (op & 16) { /* length base */
+ len = (unsigned)(here.val);
+ op &= 15; /* number of extra bits */
+ if (op) {
+ if (bits < op) {
+ hold += (unsigned long)(PUP(in)) << bits;
+ bits += 8;
+ }
+ len += (unsigned)hold & ((1U << op) - 1);
+ hold >>= op;
+ bits -= op;
+ }
+ Tracevv((stderr, "inflate: length %u\n", len));
+ if (bits < 15) {
+ hold += (unsigned long)(PUP(in)) << bits;
+ bits += 8;
+ hold += (unsigned long)(PUP(in)) << bits;
+ bits += 8;
+ }
+ here = dcode[hold & dmask];
+ dodist:
+ op = (unsigned)(here.bits);
+ hold >>= op;
+ bits -= op;
+ op = (unsigned)(here.op);
+ if (op & 16) { /* distance base */
+ dist = (unsigned)(here.val);
+ op &= 15; /* number of extra bits */
+ if (bits < op) {
+ hold += (unsigned long)(PUP(in)) << bits;
+ bits += 8;
+ if (bits < op) {
+ hold += (unsigned long)(PUP(in)) << bits;
+ bits += 8;
+ }
+ }
+ dist += (unsigned)hold & ((1U << op) - 1);
+#ifdef INFLATE_STRICT
+ if (dist > dmax) {
+ strm->msg = (char *)"invalid distance too far back";
+ state->mode = BAD;
+ break;
+ }
+#endif
+ hold >>= op;
+ bits -= op;
+ Tracevv((stderr, "inflate: distance %u\n", dist));
+ op = (unsigned)(out - beg); /* max distance in output */
+ if (dist > op) { /* see if copy from window */
+ op = dist - op; /* distance back in window */
+ if (op > whave) {
+ 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 (wnext == 0) { /* very common case */
+ from += wsize - op;
+ if (op < len) { /* some from window */
+ len -= op;
+ do {
+ PUP(out) = PUP(from);
+ } while (--op);
+ from = out - dist; /* rest from output */
+ }
+ }
+ 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 (wnext < len) { /* some from start of window */
+ op = wnext;
+ len -= op;
+ do {
+ PUP(out) = PUP(from);
+ } while (--op);
+ from = out - dist; /* rest from output */
+ }
+ }
+ }
+ else { /* contiguous in window */
+ from += wnext - op;
+ if (op < len) { /* some from window */
+ len -= op;
+ do {
+ PUP(out) = PUP(from);
+ } while (--op);
+ from = out - dist; /* rest from output */
+ }
+ }
+ while (len > 2) {
+ PUP(out) = PUP(from);
+ PUP(out) = PUP(from);
+ PUP(out) = PUP(from);
+ len -= 3;
+ }
+ if (len) {
+ PUP(out) = PUP(from);
+ if (len > 1)
+ PUP(out) = PUP(from);
+ }
+ }
+ else {
+ from = out - dist; /* copy direct from output */
+ do { /* minimum length is three */
+ PUP(out) = PUP(from);
+ PUP(out) = PUP(from);
+ PUP(out) = PUP(from);
+ len -= 3;
+ } while (len > 2);
+ if (len) {
+ PUP(out) = PUP(from);
+ if (len > 1)
+ PUP(out) = PUP(from);
+ }
+ }
+ }
+ else if ((op & 64) == 0) { /* 2nd level distance code */
+ here = dcode[here.val + (hold & ((1U << op) - 1))];
+ goto dodist;
+ }
+ else {
+ strm->msg = (char *)"invalid distance code";
+ state->mode = BAD;
+ break;
+ }
+ }
+ else if ((op & 64) == 0) { /* 2nd level length code */
+ here = lcode[here.val + (hold & ((1U << op) - 1))];
+ goto dolen;
+ }
+ else if (op & 32) { /* end-of-block */
+ Tracevv((stderr, "inflate: end of block\n"));
+ state->mode = TYPE;
+ break;
+ }
+ else {
+ strm->msg = (char *)"invalid literal/length code";
+ state->mode = BAD;
+ break;
+ }
+ } while (in < last && out < end);
+
+ /* return unused bytes (on entry, bits < 8, so in won't go too far back) */
+ len = bits >> 3;
+ in -= len;
+ bits -= len << 3;
+ hold &= (1U << bits) - 1;
+
+ /* update state and return */
+ strm->next_in = in + OFF;
+ strm->next_out = out + OFF;
+ strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last));
+ strm->avail_out = (unsigned)(out < end ?
+ 257 + (end - out) : 257 - (out - end));
+ state->hold = hold;
+ state->bits = bits;
+ return;
+}
+
+/*
+ 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 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
+ - Swapping literal/length else
+ - Swapping window/direct else
+ - Larger unrolled copy loops (three is about right)
+ - Moving len -= 3 statement into middle of loop
+ */
+
+#endif /* !ASMINF */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/inffast.h Thu Dec 15 15:57:51 2011 -0800
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+
+/* inffast.h -- header to use inffast.c
+ * Copyright (C) 1995-2003, 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.
+ */
+
+void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start));
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/inffixed.h Thu Dec 15 15:57:51 2011 -0800
@@ -0,0 +1,118 @@
+/*
+ * 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.
+ */
+
+ /* inffixed.h -- table for decoding fixed codes
+ * Generated automatically by makefixed().
+ */
+
+ /* 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.
+ */
+
+ static const code lenfix[512] = {
+ {96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48},
+ {0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128},
+ {0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59},
+ {0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176},
+ {0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20},
+ {21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100},
+ {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8},
+ {0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216},
+ {18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76},
+ {0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114},
+ {0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2},
+ {0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148},
+ {20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42},
+ {0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86},
+ {0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15},
+ {0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236},
+ {16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62},
+ {0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142},
+ {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31},
+ {0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162},
+ {0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25},
+ {0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105},
+ {0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4},
+ {0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202},
+ {17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69},
+ {0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125},
+ {0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13},
+ {0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195},
+ {19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35},
+ {0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91},
+ {0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19},
+ {0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246},
+ {16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55},
+ {0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135},
+ {0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99},
+ {0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190},
+ {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16},
+ {20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96},
+ {0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6},
+ {0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209},
+ {17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72},
+ {0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116},
+ {0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4},
+ {0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153},
+ {20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44},
+ {0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82},
+ {0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11},
+ {0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229},
+ {16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58},
+ {0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138},
+ {0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51},
+ {0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173},
+ {0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30},
+ {0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110},
+ {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0},
+ {0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195},
+ {16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65},
+ {0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121},
+ {0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9},
+ {0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258},
+ {19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37},
+ {0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93},
+ {0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23},
+ {0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251},
+ {16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51},
+ {0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131},
+ {0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67},
+ {0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183},
+ {0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23},
+ {64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103},
+ {0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9},
+ {0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223},
+ {18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79},
+ {0,9,255}
+ };
+
+ static const code distfix[32] = {
+ {16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025},
+ {21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193},
+ {18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385},
+ {19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577},
+ {16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073},
+ {22,5,193},{64,5,0}
+ };
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/inflate.c Thu Dec 15 15:57:51 2011 -0800
@@ -0,0 +1,1504 @@
+/*
+ * 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.
+ */
+
+/* inflate.c -- zlib decompression
+ * Copyright (C) 1995-2010 Mark Adler
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+/*
+ * Change history:
+ *
+ * 1.2.beta0 24 Nov 2002
+ * - First version -- complete rewrite of inflate to simplify code, avoid
+ * creation of window when not needed, minimize use of window when it is
+ * needed, make inffast.c even faster, implement gzip decoding, and to
+ * improve code readability and style over the previous zlib inflate code
+ *
+ * 1.2.beta1 25 Nov 2002
+ * - Use pointers for available input and output checking in inffast.c
+ * - Remove input and output counters in inffast.c
+ * - Change inffast.c entry and loop from avail_in >= 7 to >= 6
+ * - Remove unnecessary second byte pull from length extra in inffast.c
+ * - Unroll direct copy to three copies per loop in inffast.c
+ *
+ * 1.2.beta2 4 Dec 2002
+ * - Change external routine names to reduce potential conflicts
+ * - Correct filename to inffixed.h for fixed tables in inflate.c
+ * - Make hbuf[] unsigned char to match parameter type in inflate.c
+ * - Change strm->next_out[-state->offset] to *(strm->next_out - state->offset)
+ * to avoid negation problem on Alphas (64 bit) in inflate.c
+ *
+ * 1.2.beta3 22 Dec 2002
+ * - Add comments on state->bits assertion in inffast.c
+ * - Add comments on op field in inftrees.h
+ * - Fix bug in reuse of allocated window after inflateReset()
+ * - Remove bit fields--back to byte structure for speed
+ * - Remove distance extra == 0 check in inflate_fast()--only helps for lengths
+ * - Change post-increments to pre-increments in inflate_fast(), PPC biased?
+ * - Add compile time option, POSTINC, to use post-increments instead (Intel?)
+ * - Make MATCH copy in inflate() much faster for when inflate_fast() not used
+ * - Use local copies of stream next and avail values, as well as local bit
+ * buffer and bit count in inflate()--for speed when inflate_fast() not used
+ *
+ * 1.2.beta4 1 Jan 2003
+ * - Split ptr - 257 statements in inflate_table() to avoid compiler warnings
+ * - Move a comment on output buffer sizes from inffast.c to inflate.c
+ * - Add comments in inffast.c to introduce the inflate_fast() routine
+ * - 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 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()
+ * - Added inflateBackInit(), inflateBack(), and inflateBackEnd() in new
+ * source file infback.c to provide a call-back interface to inflate for
+ * programs like gzip and unzip -- uses window as output buffer to avoid
+ * window copying
+ *
+ * 1.2.beta5 1 Jan 2003
+ * - Improved inflateBack() interface to allow the caller to provide initial
+ * input in strm.
+ * - Fixed stored blocks bug in inflateBack()
+ *
+ * 1.2.beta6 4 Jan 2003
+ * - Added comments in inffast.c on effectiveness of POSTINC
+ * - Typecasting all around to reduce compiler warnings
+ * - Changed loops from while (1) or do {} while (1) to for (;;), again to
+ * make compilers happy
+ * - Changed type of window in inflateBackInit() to unsigned char *
+ *
+ * 1.2.beta7 27 Jan 2003
+ * - Changed many types to unsigned or unsigned short to avoid warnings
+ * - Added inflateCopy() function
+ *
+ * 1.2.0 9 Mar 2003
+ * - Changed inflateBack() interface to provide separate opaque descriptors
+ * for the in() and out() functions
+ * - Changed inflateBack() argument and in_func typedef to swap the length
+ * and buffer address return values for the input function
+ * - Check next_in and next_out for Z_NULL on entry to inflate()
+ *
+ * The history for versions after 1.2.0 are in ChangeLog in zlib distribution.
+ */
+
+#include "zutil.h"
+#include "inftrees.h"
+#include "inflate.h"
+#include "inffast.h"
+
+#ifdef MAKEFIXED
+# ifndef BUILDFIXED
+# define BUILDFIXED
+# endif
+#endif
+
+/* function prototypes */
+local void fixedtables OF((struct inflate_state FAR *state));
+local int updatewindow OF((z_streamp strm, unsigned out));
+#ifdef BUILDFIXED
+ void makefixed OF((void));
+#endif
+local unsigned syncsearch OF((unsigned FAR *have, unsigned char FAR *buf,
+ unsigned len));
+
+int ZEXPORT inflateReset(strm)
+z_streamp strm;
+{
+ struct inflate_state FAR *state;
+
+ if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+ state = (struct inflate_state FAR *)strm->state;
+ strm->total_in = strm->total_out = state->total = 0;
+ strm->msg = Z_NULL;
+ strm->adler = 1; /* to support ill-conceived Java test suite */
+ state->mode = HEAD;
+ state->last = 0;
+ state->havedict = 0;
+ state->dmax = 32768U;
+ state->head = Z_NULL;
+ state->wsize = 0;
+ state->whave = 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 inflateReset2(strm, windowBits)
+z_streamp strm;
+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;
+
+ /* 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)
+z_streamp strm;
+int windowBits;
+const char *version;
+int stream_size;
+{
+ int ret;
+ struct inflate_state FAR *state;
+
+ if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
+ stream_size != (int)(sizeof(z_stream)))
+ return Z_VERSION_ERROR;
+ if (strm == Z_NULL) return Z_STREAM_ERROR;
+ strm->msg = Z_NULL; /* in case we return an error */
+ if (strm->zalloc == (alloc_func)0) {
+ strm->zalloc = zcalloc;
+ strm->opaque = (voidpf)0;
+ }
+ if (strm->zfree == (free_func)0) strm->zfree = zcfree;
+ state = (struct inflate_state FAR *)
+ ZALLOC(strm, 1, sizeof(struct inflate_state));
+ if (state == Z_NULL) return Z_MEM_ERROR;
+ Tracev((stderr, "inflate: allocated\n"));
+ strm->state = (struct internal_state FAR *)state;
+ state->window = Z_NULL;
+ ret = inflateReset2(strm, windowBits);
+ if (ret != Z_OK) {
+ ZFREE(strm, state);
+ strm->state = Z_NULL;
+ }
+ return ret;
+}
+
+int ZEXPORT inflateInit_(strm, version, stream_size)
+z_streamp strm;
+const char *version;
+int stream_size;
+{
+ 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.
+ If BUILDFIXED is defined, then instead this routine builds the tables the
+ first time it's called, and returns those tables the first time and
+ thereafter. This reduces the size of the code by about 2K bytes, in
+ exchange for a little execution time. However, BUILDFIXED should not be
+ used for threaded applications, since the rewriting of the tables and virgin
+ may not be thread-safe.
+ */
+local void fixedtables(state)
+struct inflate_state FAR *state;
+{
+#ifdef BUILDFIXED
+ static int virgin = 1;
+ static code *lenfix, *distfix;
+ static code fixed[544];
+
+ /* build fixed huffman tables if first call (may not be thread safe) */
+ if (virgin) {
+ unsigned sym, bits;
+ static code *next;
+
+ /* literal/length table */
+ sym = 0;
+ while (sym < 144) state->lens[sym++] = 8;
+ while (sym < 256) state->lens[sym++] = 9;
+ while (sym < 280) state->lens[sym++] = 7;
+ while (sym < 288) state->lens[sym++] = 8;
+ next = fixed;
+ lenfix = next;
+ bits = 9;
+ inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work);
+
+ /* distance table */
+ sym = 0;
+ while (sym < 32) state->lens[sym++] = 5;
+ distfix = next;
+ bits = 5;
+ inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work);
+
+ /* do this just once */
+ virgin = 0;
+ }
+#else /* !BUILDFIXED */
+# include "inffixed.h"
+#endif /* BUILDFIXED */
+ state->lencode = lenfix;
+ state->lenbits = 9;
+ state->distcode = distfix;
+ state->distbits = 5;
+}
+
+#ifdef MAKEFIXED
+#include <stdio.h>
+
+/*
+ Write out the inffixed.h that is #include'd above. Defining MAKEFIXED also
+ defines BUILDFIXED, so the tables are built on the fly. makefixed() writes
+ those tables to stdout, which would be piped to inffixed.h. A small program
+ can simply call makefixed to do this:
+
+ void makefixed(void);
+
+ int main(void)
+ {
+ makefixed();
+ return 0;
+ }
+
+ Then that can be linked with zlib built with MAKEFIXED defined and run:
+
+ a.out > inffixed.h
+ */
+void makefixed()
+{
+ unsigned low, size;
+ struct inflate_state state;
+
+ fixedtables(&state);
+ puts(" /* inffixed.h -- table for decoding fixed codes");
+ puts(" * Generated automatically by makefixed().");
+ puts(" */");
+ puts("");
+ puts(" /* WARNING: this file should *not* be used by applications.");
+ puts(" It is part of the implementation of this library and is");
+ puts(" subject to change. Applications should only use zlib.h.");
+ puts(" */");
+ puts("");
+ size = 1U << 9;
+ printf(" static const code lenfix[%u] = {", size);
+ low = 0;
+ for (;;) {
+ if ((low % 7) == 0) printf("\n ");
+ printf("{%u,%u,%d}", state.lencode[low].op, state.lencode[low].bits,
+ state.lencode[low].val);
+ if (++low == size) break;
+ putchar(',');
+ }
+ puts("\n };");
+ size = 1U << 5;
+ printf("\n static const code distfix[%u] = {", size);
+ low = 0;
+ for (;;) {
+ if ((low % 6) == 0) printf("\n ");
+ printf("{%u,%u,%d}", state.distcode[low].op, state.distcode[low].bits,
+ state.distcode[low].val);
+ if (++low == size) break;
+ putchar(',');
+ }
+ puts("\n };");
+}
+#endif /* MAKEFIXED */
+
+/*
+ Update the window with the last wsize (normally 32K) bytes written before
+ returning. If window does not exist yet, create it. This is only called
+ when a window is already in use, or when output has been written during this
+ inflate call, but the end of the deflate stream has not been reached yet.
+ It is also called to create a window for dictionary data when a dictionary
+ is loaded.
+
+ Providing output buffers larger than 32K to inflate() should provide a speed
+ advantage, since only the last 32K of output is copied to the sliding window
+ upon return from inflate(), and since all distances after the first 32K of
+ output will fall in the output data, making match copies simpler and faster.
+ The advantage may be dependent on the size of the processor's data caches.
+ */
+local int updatewindow(strm, out)
+z_streamp strm;
+unsigned out;
+{
+ struct inflate_state FAR *state;
+ unsigned copy, dist;
+
+ state = (struct inflate_state FAR *)strm->state;
+
+ /* if it hasn't been done already, allocate space for the window */
+ if (state->window == Z_NULL) {
+ state->window = (unsigned char FAR *)
+ ZALLOC(strm, 1U << state->wbits,
+ sizeof(unsigned char));
+ if (state->window == Z_NULL) return 1;
+ }
+
+ /* if window not in use yet, initialize */
+ if (state->wsize == 0) {
+ state->wsize = 1U << state->wbits;
+ state->wnext = 0;
+ state->whave = 0;
+ }
+
+ /* copy state->wsize or less output bytes into the circular window */
+ copy = out - strm->avail_out;
+ if (copy >= state->wsize) {
+ zmemcpy(state->window, strm->next_out - state->wsize, state->wsize);
+ state->wnext = 0;
+ state->whave = state->wsize;
+ }
+ else {
+ dist = state->wsize - state->wnext;
+ if (dist > copy) dist = copy;
+ zmemcpy(state->window + state->wnext, strm->next_out - copy, dist);
+ copy -= dist;
+ if (copy) {
+ zmemcpy(state->window, strm->next_out - copy, copy);
+ state->wnext = copy;
+ state->whave = state->wsize;
+ }
+ else {
+ state->wnext += dist;
+ if (state->wnext == state->wsize) state->wnext = 0;
+ if (state->whave < state->wsize) state->whave += dist;
+ }
+ }
+ return 0;
+}
+
+/* Macros for inflate(): */
+
+/* check function to use adler32() for zlib or crc32() for gzip */
+#ifdef GUNZIP
+# define UPDATE(check, buf, len) \
+ (state->flags ? crc32(check, buf, len) : adler32(check, buf, len))
+#else
+# define UPDATE(check, buf, len) adler32(check, buf, len)
+#endif
+
+/* check macros for header crc */
+#ifdef GUNZIP
+# define CRC2(check, word) \
+ do { \
+ hbuf[0] = (unsigned char)(word); \
+ hbuf[1] = (unsigned char)((word) >> 8); \
+ check = crc32(check, hbuf, 2); \
+ } while (0)
+
+# define CRC4(check, word) \
+ do { \
+ hbuf[0] = (unsigned char)(word); \
+ hbuf[1] = (unsigned char)((word) >> 8); \
+ hbuf[2] = (unsigned char)((word) >> 16); \
+ hbuf[3] = (unsigned char)((word) >> 24); \
+ check = crc32(check, hbuf, 4); \
+ } while (0)
+#endif
+
+/* Load registers with state in inflate() for speed */
+#define LOAD() \
+ do { \
+ put = strm->next_out; \
+ left = strm->avail_out; \
+ next = strm->next_in; \
+ have = strm->avail_in; \
+ hold = state->hold; \
+ bits = state->bits; \
+ } while (0)
+
+/* Restore state from registers in inflate() */
+#define RESTORE() \
+ do { \
+ strm->next_out = put; \
+ strm->avail_out = left; \
+ strm->next_in = next; \
+ strm->avail_in = have; \
+ state->hold = hold; \
+ state->bits = bits; \
+ } while (0)
+
+/* Clear the input bit accumulator */
+#define INITBITS() \
+ do { \
+ hold = 0; \
+ bits = 0; \
+ } while (0)
+
+/* Get a byte of input into the bit accumulator, or return from inflate()
+ if there is no input available. */
+#define PULLBYTE() \
+ do { \
+ if (have == 0) goto inf_leave; \
+ have--; \
+ hold += (unsigned long)(*next++) << bits; \
+ bits += 8; \
+ } while (0)
+
+/* Assure that there are at least n bits in the bit accumulator. If there is
+ not enough available input to do that, then return from inflate(). */
+#define NEEDBITS(n) \
+ do { \
+ while (bits < (unsigned)(n)) \
+ PULLBYTE(); \
+ } while (0)
+
+/* Return the low n bits of the bit accumulator (n < 16) */
+#define BITS(n) \
+ ((unsigned)hold & ((1U << (n)) - 1))
+
+/* Remove n bits from the bit accumulator */
+#define DROPBITS(n) \
+ do { \
+ hold >>= (n); \
+ bits -= (unsigned)(n); \
+ } while (0)
+
+/* Remove zero to seven bits as needed to go to a byte boundary */
+#define BYTEBITS() \
+ do { \
+ hold >>= bits & 7; \
+ bits -= bits & 7; \
+ } while (0)
+
+/* Reverse the bytes in a 32-bit value */
+#define REVERSE(q) \
+ ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
+ (((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
+
+/*
+ inflate() uses a state machine to process as much input data and generate as
+ much output data as possible before returning. The state machine is
+ structured roughly as follows:
+
+ for (;;) switch (state) {
+ ...
+ case STATEn:
+ if (not enough input data or output space to make progress)
+ return;
+ ... make progress ...
+ state = STATEm;
+ break;
+ ...
+ }
+
+ so when inflate() is called again, the same case is attempted again, and
+ if the appropriate resources are provided, the machine proceeds to the
+ next state. The NEEDBITS() macro is usually the way the state evaluates
+ whether it can proceed or should return. NEEDBITS() does the return if
+ the requested bits are not available. The typical use of the BITS macros
+ is:
+
+ NEEDBITS(n);
+ ... do something with BITS(n) ...
+ DROPBITS(n);
+
+ where NEEDBITS(n) either returns from inflate() if there isn't enough
+ input left to load n bits into the accumulator, or it continues. BITS(n)
+ gives the low n bits in the accumulator. When done, DROPBITS(n) drops
+ the low n bits off the accumulator. INITBITS() clears the accumulator
+ and sets the number of available bits to zero. BYTEBITS() discards just
+ enough bits to put the accumulator on a byte boundary. After BYTEBITS()
+ and a NEEDBITS(8), then BITS(8) would return the next byte in the stream.
+
+ NEEDBITS(n) uses PULLBYTE() to get an available byte of input, or to return
+ if there is no input available. The decoding of variable length codes uses
+ PULLBYTE() directly in order to pull just enough bytes to decode the next
+ code, and no more.
+
+ Some states loop until they get enough input, making sure that enough
+ state information is maintained to continue the loop where it left off
+ if NEEDBITS() returns in the loop. For example, want, need, and keep
+ would all have to actually be part of the saved state in case NEEDBITS()
+ returns:
+
+ case STATEw:
+ while (want < need) {
+ NEEDBITS(n);
+ keep[want++] = BITS(n);
+ DROPBITS(n);
+ }
+ state = STATEx;
+ case STATEx:
+
+ As shown above, if the next state is also the next case, then the break
+ is omitted.
+
+ A state may also return if there is not enough output space available to
+ complete that state. Those states are copying stored data, writing a
+ literal byte, and copying a matching string.
+
+ When returning, a "goto inf_leave" is used to update the total counters,
+ update the check value, and determine whether any progress has been made
+ during that inflate() call in order to return the proper return code.
+ Progress is defined as a change in either strm->avail_in or strm->avail_out.
+ When there is a window, goto inf_leave will update the window with the last
+ output written. If a goto inf_leave occurs in the middle of decompression
+ and there is no window currently, goto inf_leave will create one and copy
+ output to the window for the next call of inflate().
+
+ In this implementation, the flush parameter of inflate() only affects the
+ return code (per zlib.h). inflate() always writes as much as possible to
+ strm->next_out, given the space available and the provided input--the effect
+ documented in zlib.h of Z_SYNC_FLUSH. Furthermore, inflate() always defers
+ the allocation of and copying into a sliding window until necessary, which
+ provides the effect documented in zlib.h for Z_FINISH when the entire input
+ stream available. So the only thing the flush parameter actually does is:
+ when flush is set to Z_FINISH, inflate() cannot return Z_OK. Instead it
+ will return Z_BUF_ERROR if it has not reached the end of the stream.
+ */
+
+int ZEXPORT inflate(strm, flush)
+z_streamp strm;
+int flush;
+{
+ struct inflate_state FAR *state;
+ unsigned char FAR *next; /* next input */
+ unsigned char FAR *put; /* next output */
+ unsigned have, left; /* available input and output */
+ unsigned long hold; /* bit buffer */
+ unsigned bits; /* bits in bit buffer */
+ 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 here; /* current decoding table entry */
+ code last; /* parent table entry */
+ unsigned len; /* length to copy for repeats, bits to drop */
+ int ret; /* return code */
+#ifdef GUNZIP
+ unsigned char hbuf[4]; /* buffer for gzip header crc calculation */
+#endif
+ static const unsigned short order[19] = /* permutation of code lengths */
+ {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
+
+ if (strm == Z_NULL || strm->state == Z_NULL || strm->next_out == Z_NULL ||
+ (strm->next_in == Z_NULL && strm->avail_in != 0))
+ return Z_STREAM_ERROR;
+
+ state = (struct inflate_state FAR *)strm->state;
+ if (state->mode == TYPE) state->mode = TYPEDO; /* skip check */
+ LOAD();
+ in = have;
+ out = left;
+ ret = Z_OK;
+ for (;;)
+ switch (state->mode) {
+ case HEAD:
+ if (state->wrap == 0) {
+ state->mode = TYPEDO;
+ break;
+ }
+ NEEDBITS(16);
+#ifdef GUNZIP
+ if ((state->wrap & 2) && hold == 0x8b1f) { /* gzip header */
+ state->check = crc32(0L, Z_NULL, 0);
+ CRC2(state->check, hold);
+ INITBITS();
+ state->mode = FLAGS;
+ break;
+ }
+ state->flags = 0; /* expect zlib header */
+ if (state->head != Z_NULL)
+ state->head->done = -1;
+ if (!(state->wrap & 1) || /* check if zlib header allowed */
+#else
+ if (
+#endif
+ ((BITS(8) << 8) + (hold >> 8)) % 31) {
+ strm->msg = (char *)"incorrect header check";
+ state->mode = BAD;
+ break;
+ }
+ if (BITS(4) != Z_DEFLATED) {
+ strm->msg = (char *)"unknown compression method";
+ state->mode = BAD;
+ break;
+ }
+ DROPBITS(4);
+ len = BITS(4) + 8;
+ if (state->wbits == 0)
+ state->wbits = len;
+ else if (len > state->wbits) {
+ strm->msg = (char *)"invalid window size";
+ state->mode = BAD;
+ break;
+ }
+ state->dmax = 1U << len;
+ Tracev((stderr, "inflate: zlib header ok\n"));
+ strm->adler = state->check = adler32(0L, Z_NULL, 0);
+ state->mode = hold & 0x200 ? DICTID : TYPE;
+ INITBITS();
+ break;
+#ifdef GUNZIP
+ case FLAGS:
+ NEEDBITS(16);
+ state->flags = (int)(hold);
+ if ((state->flags & 0xff) != Z_DEFLATED) {
+ strm->msg = (char *)"unknown compression method";
+ state->mode = BAD;
+ break;
+ }
+ if (state->flags & 0xe000) {
+ strm->msg = (char *)"unknown header flags set";
+ state->mode = BAD;
+ break;
+ }
+ if (state->head != Z_NULL)
+ state->head->text = (int)((hold >> 8) & 1);
+ if (state->flags & 0x0200) CRC2(state->check, hold);
+ INITBITS();
+ state->mode = TIME;
+ case TIME:
+ NEEDBITS(32);
+ if (state->head != Z_NULL)
+ state->head->time = hold;
+ if (state->flags & 0x0200) CRC4(state->check, hold);
+ INITBITS();
+ state->mode = OS;
+ case OS:
+ NEEDBITS(16);
+ if (state->head != Z_NULL) {
+ state->head->xflags = (int)(hold & 0xff);
+ state->head->os = (int)(hold >> 8);
+ }
+ if (state->flags & 0x0200) CRC2(state->check, hold);
+ INITBITS();
+ state->mode = EXLEN;
+ case EXLEN:
+ if (state->flags & 0x0400) {
+ NEEDBITS(16);
+ state->length = (unsigned)(hold);
+ if (state->head != Z_NULL)
+ state->head->extra_len = (unsigned)hold;
+ if (state->flags & 0x0200) CRC2(state->check, hold);
+ INITBITS();
+ }
+ else if (state->head != Z_NULL)
+ state->head->extra = Z_NULL;
+ state->mode = EXTRA;
+ case EXTRA:
+ if (state->flags & 0x0400) {
+ copy = state->length;
+ if (copy > have) copy = have;
+ if (copy) {
+ if (state->head != Z_NULL &&
+ state->head->extra != Z_NULL) {
+ len = state->head->extra_len - state->length;
+ zmemcpy(state->head->extra + len, next,
+ len + copy > state->head->extra_max ?
+ state->head->extra_max - len : copy);
+ }
+ if (state->flags & 0x0200)
+ state->check = crc32(state->check, next, copy);
+ have -= copy;
+ next += copy;
+ state->length -= copy;
+ }
+ if (state->length) goto inf_leave;
+ }
+ state->length = 0;
+ state->mode = NAME;
+ case NAME:
+ if (state->flags & 0x0800) {
+ if (have == 0) goto inf_leave;
+ copy = 0;
+ do {
+ len = (unsigned)(next[copy++]);
+ if (state->head != Z_NULL &&
+ state->head->name != Z_NULL &&
+ state->length < state->head->name_max)
+ state->head->name[state->length++] = len;
+ } while (len && copy < have);
+ if (state->flags & 0x0200)
+ state->check = crc32(state->check, next, copy);
+ have -= copy;
+ next += copy;
+ if (len) goto inf_leave;
+ }
+ else if (state->head != Z_NULL)
+ state->head->name = Z_NULL;
+ state->length = 0;
+ state->mode = COMMENT;
+ case COMMENT:
+ if (state->flags & 0x1000) {
+ if (have == 0) goto inf_leave;
+ copy = 0;
+ do {
+ len = (unsigned)(next[copy++]);
+ if (state->head != Z_NULL &&
+ state->head->comment != Z_NULL &&
+ state->length < state->head->comm_max)
+ state->head->comment[state->length++] = len;
+ } while (len && copy < have);
+ if (state->flags & 0x0200)
+ state->check = crc32(state->check, next, copy);
+ have -= copy;
+ next += copy;
+ if (len) goto inf_leave;
+ }
+ else if (state->head != Z_NULL)
+ state->head->comment = Z_NULL;
+ state->mode = HCRC;
+ case HCRC:
+ if (state->flags & 0x0200) {
+ NEEDBITS(16);
+ if (hold != (state->check & 0xffff)) {
+ strm->msg = (char *)"header crc mismatch";
+ state->mode = BAD;
+ break;
+ }
+ INITBITS();
+ }
+ if (state->head != Z_NULL) {
+ state->head->hcrc = (int)((state->flags >> 9) & 1);
+ state->head->done = 1;
+ }
+ strm->adler = state->check = crc32(0L, Z_NULL, 0);
+ state->mode = TYPE;
+ break;
+#endif
+ case DICTID:
+ NEEDBITS(32);
+ strm->adler = state->check = REVERSE(hold);
+ INITBITS();
+ state->mode = DICT;
+ case DICT:
+ if (state->havedict == 0) {
+ RESTORE();
+ return Z_NEED_DICT;
+ }
+ strm->adler = state->check = adler32(0L, Z_NULL, 0);
+ state->mode = TYPE;
+ case TYPE:
+ if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave;
+ case TYPEDO:
+ if (state->last) {
+ BYTEBITS();
+ state->mode = CHECK;
+ break;
+ }
+ NEEDBITS(3);
+ state->last = BITS(1);
+ DROPBITS(1);
+ switch (BITS(2)) {
+ case 0: /* stored block */
+ Tracev((stderr, "inflate: stored block%s\n",
+ state->last ? " (last)" : ""));
+ state->mode = STORED;
+ break;
+ case 1: /* fixed block */
+ fixedtables(state);
+ Tracev((stderr, "inflate: fixed codes block%s\n",
+ state->last ? " (last)" : ""));
+ 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",
+ state->last ? " (last)" : ""));
+ state->mode = TABLE;
+ break;
+ case 3:
+ strm->msg = (char *)"invalid block type";
+ state->mode = BAD;
+ }
+ DROPBITS(2);
+ break;
+ case STORED:
+ BYTEBITS(); /* go to byte boundary */
+ NEEDBITS(32);
+ if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
+ strm->msg = (char *)"invalid stored block lengths";
+ state->mode = BAD;
+ break;
+ }
+ state->length = (unsigned)hold & 0xffff;
+ 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;
+ if (copy) {
+ if (copy > have) copy = have;
+ if (copy > left) copy = left;
+ if (copy == 0) goto inf_leave;
+ zmemcpy(put, next, copy);
+ have -= copy;
+ next += copy;
+ left -= copy;
+ put += copy;
+ state->length -= copy;
+ break;
+ }
+ Tracev((stderr, "inflate: stored end\n"));
+ state->mode = TYPE;
+ break;
+ case TABLE:
+ NEEDBITS(14);
+ state->nlen = BITS(5) + 257;
+ DROPBITS(5);
+ state->ndist = BITS(5) + 1;
+ DROPBITS(5);
+ state->ncode = BITS(4) + 4;
+ DROPBITS(4);
+#ifndef PKZIP_BUG_WORKAROUND
+ if (state->nlen > 286 || state->ndist > 30) {
+ strm->msg = (char *)"too many length or distance symbols";
+ state->mode = BAD;
+ break;
+ }
+#endif
+ Tracev((stderr, "inflate: table sizes ok\n"));
+ state->have = 0;
+ state->mode = LENLENS;
+ case LENLENS:
+ while (state->have < state->ncode) {
+ NEEDBITS(3);
+ state->lens[order[state->have++]] = (unsigned short)BITS(3);
+ DROPBITS(3);
+ }
+ while (state->have < 19)
+ state->lens[order[state->have++]] = 0;
+ state->next = state->codes;
+ state->lencode = (code const FAR *)(state->next);
+ state->lenbits = 7;
+ ret = inflate_table(CODES, state->lens, 19, &(state->next),
+ &(state->lenbits), state->work);
+ if (ret) {
+ strm->msg = (char *)"invalid code lengths set";
+ state->mode = BAD;
+ break;
+ }
+ Tracev((stderr, "inflate: code lengths ok\n"));
+ state->have = 0;
+ state->mode = CODELENS;
+ case CODELENS:
+ while (state->have < state->nlen + state->ndist) {
+ for (;;) {
+ here = state->lencode[BITS(state->lenbits)];
+ if ((unsigned)(here.bits) <= bits) break;
+ PULLBYTE();
+ }
+ if (here.val < 16) {
+ NEEDBITS(here.bits);
+ DROPBITS(here.bits);
+ state->lens[state->have++] = here.val;
+ }
+ else {
+ 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;
+ break;
+ }
+ len = state->lens[state->have - 1];
+ copy = 3 + BITS(2);
+ DROPBITS(2);
+ }
+ else if (here.val == 17) {
+ NEEDBITS(here.bits + 3);
+ DROPBITS(here.bits);
+ len = 0;
+ copy = 3 + BITS(3);
+ DROPBITS(3);
+ }
+ else {
+ NEEDBITS(here.bits + 7);
+ DROPBITS(here.bits);
+ len = 0;
+ copy = 11 + BITS(7);
+ DROPBITS(7);
+ }
+ if (state->have + copy > state->nlen + state->ndist) {
+ strm->msg = (char *)"invalid bit length repeat";
+ state->mode = BAD;
+ break;
+ }
+ while (copy--)
+ state->lens[state->have++] = (unsigned short)len;
+ }
+ }
+
+ /* handle error breaks in while */
+ if (state->mode == BAD) break;
+
+ /* 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;
+ ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
+ &(state->lenbits), state->work);
+ if (ret) {
+ strm->msg = (char *)"invalid literal/lengths set";
+ state->mode = BAD;
+ break;
+ }
+ state->distcode = (code const FAR *)(state->next);
+ state->distbits = 6;
+ ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
+ &(state->next), &(state->distbits), state->work);
+ if (ret) {
+ strm->msg = (char *)"invalid distances set";
+ state->mode = BAD;
+ 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 (;;) {
+ here = state->lencode[BITS(state->lenbits)];
+ if ((unsigned)(here.bits) <= bits) break;
+ PULLBYTE();
+ }
+ if (here.op && (here.op & 0xf0) == 0) {
+ last = here;
+ for (;;) {
+ here = state->lencode[last.val +
+ (BITS(last.bits + last.op) >> last.bits)];
+ if ((unsigned)(last.bits + here.bits) <= bits) break;
+ PULLBYTE();
+ }
+ DROPBITS(last.bits);
+ state->back += last.bits;
+ }
+ 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", here.val));
+ state->mode = LIT;
+ break;
+ }
+ if (here.op & 32) {
+ Tracevv((stderr, "inflate: end of block\n"));
+ state->back = -1;
+ state->mode = TYPE;
+ break;
+ }
+ if (here.op & 64) {
+ strm->msg = (char *)"invalid literal/length code";
+ state->mode = BAD;
+ break;
+ }
+ 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 (;;) {
+ here = state->distcode[BITS(state->distbits)];
+ if ((unsigned)(here.bits) <= bits) break;
+ PULLBYTE();
+ }
+ if ((here.op & 0xf0) == 0) {
+ last = here;
+ for (;;) {
+ here = state->distcode[last.val +
+ (BITS(last.bits + last.op) >> last.bits)];
+ if ((unsigned)(last.bits + here.bits) <= bits) break;
+ PULLBYTE();
+ }
+ DROPBITS(last.bits);
+ state->back += last.bits;
+ }
+ DROPBITS(here.bits);
+ state->back += here.bits;
+ if (here.op & 64) {
+ strm->msg = (char *)"invalid distance code";
+ state->mode = BAD;
+ break;
+ }
+ 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) {
+ strm->msg = (char *)"invalid distance too far back";
+ state->mode = BAD;
+ break;
+ }
+#endif
+ Tracevv((stderr, "inflate: distance %u\n", state->offset));
+ state->mode = MATCH;
+ case MATCH:
+ if (left == 0) goto inf_leave;
+ copy = out - left;
+ if (state->offset > copy) { /* copy from window */
+ copy = state->offset - copy;
+ 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->wnext - copy);
+ if (copy > state->length) copy = state->length;
+ }
+ else { /* copy from output */
+ from = put - state->offset;
+ copy = state->length;
+ }
+ if (copy > left) copy = left;
+ left -= copy;
+ state->length -= copy;
+ do {
+ *put++ = *from++;
+ } while (--copy);
+ if (state->length == 0) state->mode = LEN;
+ break;
+ case LIT:
+ if (left == 0) goto inf_leave;
+ *put++ = (unsigned char)(state->length);
+ left--;
+ state->mode = LEN;
+ break;
+ case CHECK:
+ if (state->wrap) {
+ NEEDBITS(32);
+ out -= left;
+ strm->total_out += out;
+ state->total += out;
+ if (out)
+ strm->adler = state->check =
+ UPDATE(state->check, put - out, out);
+ out = left;
+ if ((
+#ifdef GUNZIP
+ state->flags ? hold :
+#endif
+ REVERSE(hold)) != state->check) {
+ strm->msg = (char *)"incorrect data check";
+ state->mode = BAD;
+ break;
+ }
+ INITBITS();
+ Tracev((stderr, "inflate: check matches trailer\n"));
+ }
+#ifdef GUNZIP
+ state->mode = LENGTH;
+ case LENGTH:
+ if (state->wrap && state->flags) {
+ NEEDBITS(32);
+ if (hold != (state->total & 0xffffffffUL)) {
+ strm->msg = (char *)"incorrect length check";
+ state->mode = BAD;
+ break;
+ }
+ INITBITS();
+ Tracev((stderr, "inflate: length matches trailer\n"));
+ }
+#endif
+ state->mode = DONE;
+ case DONE:
+ ret = Z_STREAM_END;
+ goto inf_leave;
+ case BAD:
+ ret = Z_DATA_ERROR;
+ goto inf_leave;
+ case MEM:
+ return Z_MEM_ERROR;
+ case SYNC:
+ default:
+ return Z_STREAM_ERROR;
+ }
+
+ /*
+ Return from inflate(), updating the total counts and the check value.
+ If there was no progress during the inflate() call, return a buffer
+ error. Call updatewindow() to create and/or update the window state.
+ Note: a memory error from inflate() is non-recoverable.
+ */
+ inf_leave:
+ RESTORE();
+ if (state->wsize || (state->mode < CHECK && out != strm->avail_out))
+ if (updatewindow(strm, out)) {
+ state->mode = MEM;
+ return Z_MEM_ERROR;
+ }
+ in -= strm->avail_in;
+ out -= strm->avail_out;
+ strm->total_in += in;
+ strm->total_out += out;
+ state->total += out;
+ if (state->wrap && out)
+ 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 == LEN_ || state->mode == COPY_ ? 256 : 0);
+ if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)
+ ret = Z_BUF_ERROR;
+ return ret;
+}
+
+int ZEXPORT inflateEnd(strm)
+z_streamp strm;
+{
+ struct inflate_state FAR *state;
+ if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
+ return Z_STREAM_ERROR;
+ state = (struct inflate_state FAR *)strm->state;
+ if (state->window != Z_NULL) ZFREE(strm, state->window);
+ ZFREE(strm, strm->state);
+ strm->state = Z_NULL;
+ Tracev((stderr, "inflate: end\n"));
+ return Z_OK;
+}
+
+int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength)
+z_streamp strm;
+const Bytef *dictionary;
+uInt dictLength;
+{
+ struct inflate_state FAR *state;
+ unsigned long id;
+
+ /* check state */
+ if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+ state = (struct inflate_state FAR *)strm->state;
+ if (state->wrap != 0 && state->mode != DICT)
+ return Z_STREAM_ERROR;
+
+ /* check for correct dictionary id */
+ if (state->mode == DICT) {
+ id = adler32(0L, Z_NULL, 0);
+ id = adler32(id, dictionary, dictLength);
+ if (id != state->check)
+ return Z_DATA_ERROR;
+ }
+
+ /* copy dictionary to window */
+ if (updatewindow(strm, strm->avail_out)) {
+ state->mode = MEM;
+ return Z_MEM_ERROR;
+ }
+ if (dictLength > state->wsize) {
+ zmemcpy(state->window, dictionary + dictLength - state->wsize,
+ state->wsize);
+ state->whave = state->wsize;
+ }
+ else {
+ zmemcpy(state->window + state->wsize - dictLength, dictionary,
+ dictLength);
+ state->whave = dictLength;
+ }
+ state->havedict = 1;
+ Tracev((stderr, "inflate: dictionary set\n"));
+ return Z_OK;
+}
+
+int ZEXPORT inflateGetHeader(strm, head)
+z_streamp strm;
+gz_headerp head;
+{
+ struct inflate_state FAR *state;
+
+ /* check state */
+ if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+ state = (struct inflate_state FAR *)strm->state;
+ if ((state->wrap & 2) == 0) return Z_STREAM_ERROR;
+
+ /* save header structure */
+ state->head = head;
+ head->done = 0;
+ return Z_OK;
+}
+
+/*
+ Search buf[0..len-1] for the pattern: 0, 0, 0xff, 0xff. Return when found
+ or when out of input. When called, *have is the number of pattern bytes
+ found in order so far, in 0..3. On return *have is updated to the new
+ state. If on return *have equals four, then the pattern was found and the
+ return value is how many bytes were read including the last byte of the
+ pattern. If *have is less than four, then the pattern has not been found
+ yet and the return value is len. In the latter case, syncsearch() can be
+ called again with more data and the *have state. *have is initialized to
+ zero for the first call.
+ */
+local unsigned syncsearch(have, buf, len)
+unsigned FAR *have;
+unsigned char FAR *buf;
+unsigned len;
+{
+ unsigned got;
+ unsigned next;
+
+ got = *have;
+ next = 0;
+ while (next < len && got < 4) {
+ if ((int)(buf[next]) == (got < 2 ? 0 : 0xff))
+ got++;
+ else if (buf[next])
+ got = 0;
+ else
+ got = 4 - got;
+ next++;
+ }
+ *have = got;
+ return next;
+}
+
+int ZEXPORT inflateSync(strm)
+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 */
+ unsigned char buf[4]; /* to restore bit buffer to byte string */
+ struct inflate_state FAR *state;
+
+ /* check parameters */
+ if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+ state = (struct inflate_state FAR *)strm->state;
+ if (strm->avail_in == 0 && state->bits < 8) return Z_BUF_ERROR;
+
+ /* if first time, start search in bit buffer */
+ if (state->mode != SYNC) {
+ state->mode = SYNC;
+ state->hold <<= state->bits & 7;
+ state->bits -= state->bits & 7;
+ len = 0;
+ while (state->bits >= 8) {
+ buf[len++] = (unsigned char)(state->hold);
+ state->hold >>= 8;
+ state->bits -= 8;
+ }
+ state->have = 0;
+ syncsearch(&(state->have), buf, len);
+ }
+
+ /* search available input */
+ len = syncsearch(&(state->have), strm->next_in, strm->avail_in);
+ strm->avail_in -= len;
+ strm->next_in += len;
+ strm->total_in += len;
+
+ /* return no joy or set up to restart inflate() on a new block */
+ if (state->have != 4) return Z_DATA_ERROR;
+ in = strm->total_in; out = strm->total_out;
+ inflateReset(strm);
+ strm->total_in = in; strm->total_out = out;
+ state->mode = TYPE;
+ return Z_OK;
+}
+
+/*
+ Returns true if inflate is currently at the end of a block generated by
+ Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP
+ implementation to provide an additional safety check. PPP uses
+ Z_SYNC_FLUSH but removes the length bytes of the resulting empty stored
+ block. When decompressing, PPP checks that at the end of input packet,
+ inflate is waiting for these length bytes.
+ */
+int ZEXPORT inflateSyncPoint(strm)
+z_streamp strm;
+{
+ struct inflate_state FAR *state;
+
+ if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
+ state = (struct inflate_state FAR *)strm->state;
+ return state->mode == STORED && state->bits == 0;
+}
+
+int ZEXPORT inflateCopy(dest, source)
+z_streamp dest;
+z_streamp source;
+{
+ struct inflate_state FAR *state;
+ struct inflate_state FAR *copy;
+ unsigned char FAR *window;
+ unsigned wsize;
+
+ /* check input */
+ if (dest == Z_NULL || source == Z_NULL || source->state == Z_NULL ||
+ source->zalloc == (alloc_func)0 || source->zfree == (free_func)0)
+ return Z_STREAM_ERROR;
+ state = (struct inflate_state FAR *)source->state;
+
+ /* allocate space */
+ copy = (struct inflate_state FAR *)
+ ZALLOC(source, 1, sizeof(struct inflate_state));
+ if (copy == Z_NULL) return Z_MEM_ERROR;
+ window = Z_NULL;
+ if (state->window != Z_NULL) {
+ window = (unsigned char FAR *)
+ ZALLOC(source, 1U << state->wbits, sizeof(unsigned char));
+ if (window == Z_NULL) {
+ ZFREE(source, copy);
+ return Z_MEM_ERROR;
+ }
+ }
+
+ /* copy state */
+ zmemcpy(dest, source, sizeof(z_stream));
+ zmemcpy(copy, state, sizeof(struct inflate_state));
+ if (state->lencode >= state->codes &&
+ state->lencode <= state->codes + ENOUGH - 1) {
+ copy->lencode = copy->codes + (state->lencode - state->codes);
+ copy->distcode = copy->codes + (state->distcode - state->codes);
+ }
+ copy->next = copy->codes + (state->next - state->codes);
+ if (window != Z_NULL) {
+ wsize = 1U << state->wbits;
+ zmemcpy(window, state->window, wsize);
+ }
+ copy->window = window;
+ 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));
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/inflate.h Thu Dec 15 15:57:51 2011 -0800
@@ -0,0 +1,146 @@
+/*
+ * 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.
+ */
+
+/* inflate.h -- internal inflate state definition
+ * Copyright (C) 1995-2009 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.
+ */
+
+/* define NO_GZIP when compiling if you want to disable gzip header and
+ trailer decoding by inflate(). NO_GZIP would be used to avoid linking in
+ the crc code when it is not needed. For shared libraries, gzip decoding
+ should be left enabled. */
+#ifndef NO_GZIP
+# define GUNZIP
+#endif
+
+/* Possible inflate modes between inflate() calls */
+typedef enum {
+ HEAD, /* i: waiting for magic header */
+ FLAGS, /* i: waiting for method and flags (gzip) */
+ TIME, /* i: waiting for modification time (gzip) */
+ OS, /* i: waiting for extra flags and operating system (gzip) */
+ EXLEN, /* i: waiting for extra length (gzip) */
+ EXTRA, /* i: waiting for extra bytes (gzip) */
+ NAME, /* i: waiting for end of file name (gzip) */
+ COMMENT, /* i: waiting for end of comment (gzip) */
+ HCRC, /* i: waiting for header crc (gzip) */
+ DICTID, /* i: waiting for dictionary check value */
+ DICT, /* waiting for inflateSetDictionary() call */
+ 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: 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 */
+ MATCH, /* o: waiting for output space to copy string */
+ LIT, /* o: waiting for output space to write literal */
+ CHECK, /* i: waiting for 32-bit check value */
+ LENGTH, /* i: waiting for 32-bit length (gzip) */
+ DONE, /* finished check, done -- remain here until reset */
+ BAD, /* got a data error -- remain here until reset */
+ MEM, /* got an inflate() memory error -- remain here until reset */
+ SYNC /* looking for synchronization bytes to restart inflate() */
+} inflate_mode;
+
+/*
+ State transitions between above modes -
+
+ (most modes can go to BAD or MEM on error -- not shown for clarity)
+
+ Process header:
+ 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 -> 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
+ Process trailer:
+ CHECK -> LENGTH -> DONE
+ */
+
+/* state maintained between inflate() calls. Approximately 10K bytes. */
+struct inflate_state {
+ inflate_mode mode; /* current inflate mode */
+ int last; /* true if processing last block */
+ int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
+ int havedict; /* true if dictionary provided */
+ int flags; /* gzip header method and flags (0 if zlib) */
+ unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */
+ unsigned long check; /* protected copy of check value */
+ unsigned long total; /* protected copy of output count */
+ gz_headerp head; /* where to save gzip header information */
+ /* sliding window */
+ 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 wnext; /* window write index */
+ unsigned char FAR *window; /* allocated sliding window, if needed */
+ /* bit accumulator */
+ unsigned long hold; /* input bit accumulator */
+ unsigned bits; /* number of bits in "in" */
+ /* for string and stored block copying */
+ unsigned length; /* literal or length of data to copy */
+ unsigned offset; /* distance back to copy string from */
+ /* for table and code decoding */
+ unsigned extra; /* extra bits needed */
+ /* fixed and dynamic code tables */
+ code const FAR *lencode; /* starting table for length/literal codes */
+ code const FAR *distcode; /* starting table for distance codes */
+ unsigned lenbits; /* index bits for lencode */
+ unsigned distbits; /* index bits for distcode */
+ /* dynamic table building */
+ unsigned ncode; /* number of code length code lengths */
+ unsigned nlen; /* number of length code lengths */
+ unsigned ndist; /* number of distance code lengths */
+ unsigned have; /* number of code lengths in lens[] */
+ code FAR *next; /* next available space in codes[] */
+ 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 */
+};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/inftrees.c Thu Dec 15 15:57:51 2011 -0800
@@ -0,0 +1,354 @@
+/*
+ * 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.
+ */
+
+/* inftrees.c -- generate Huffman trees for efficient decoding
+ * Copyright (C) 1995-2010 Mark Adler
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+#include "zutil.h"
+#include "inftrees.h"
+
+#define MAXBITS 15
+
+const char inflate_copyright[] =
+ " 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
+ include such an acknowledgment, I would appreciate that you keep this
+ copyright string in the executable of your product.
+ */
+
+/*
+ Build a set of tables to decode the provided canonical Huffman code.
+ The code lengths are lens[0..codes-1]. The result starts at *table,
+ whose indices are 0..2^bits-1. work is a writable array of at least
+ lens shorts, which is used as a work area. type is the type of code
+ to be generated, CODES, LENS, or DISTS. On return, zero is success,
+ -1 is an invalid code, and +1 means that ENOUGH isn't enough. table
+ on return points to the next available entry's address. bits is the
+ requested root table index bits, and on return it is the actual root
+ 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 ZLIB_INTERNAL inflate_table(type, lens, codes, table, bits, work)
+codetype type;
+unsigned short FAR *lens;
+unsigned codes;
+code FAR * FAR *table;
+unsigned FAR *bits;
+unsigned short FAR *work;
+{
+ unsigned len; /* a code's length in bits */
+ unsigned sym; /* index of code symbols */
+ unsigned min, max; /* minimum and maximum code lengths */
+ unsigned root; /* number of index bits for root table */
+ unsigned curr; /* number of index bits for current table */
+ unsigned drop; /* code bits to drop for sub-table */
+ int left; /* number of prefix codes available */
+ unsigned used; /* code entries in table used */
+ unsigned huff; /* Huffman code */
+ unsigned incr; /* for incrementing code, index */
+ unsigned fill; /* index for replicating entries */
+ unsigned low; /* low bits for current root entry */
+ unsigned mask; /* mask for low root bits */
+ 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 */
+ int end; /* use base and extra for symbol > end */
+ unsigned short count[MAXBITS+1]; /* number of codes of each length */
+ unsigned short offs[MAXBITS+1]; /* offsets in table for each length */
+ static const unsigned short lbase[31] = { /* Length codes 257..285 base */
+ 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
+ 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, 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,
+ 8193, 12289, 16385, 24577, 0, 0};
+ static const unsigned short dext[32] = { /* Distance codes 0..29 extra */
+ 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,
+ 23, 23, 24, 24, 25, 25, 26, 26, 27, 27,
+ 28, 28, 29, 29, 64, 64};
+
+ /*
+ Process a set of code lengths to create a canonical Huffman code. The
+ code lengths are lens[0..codes-1]. Each length corresponds to the
+ symbols 0..codes-1. The Huffman code is generated by first sorting the
+ symbols by length from short to long, and retaining the symbol order
+ for codes with equal lengths. Then the code starts with all zero bits
+ for the first code of the shortest length, and the codes are integer
+ increments for the same length, and zeros are appended as the length
+ increases. For the deflate format, these bits are stored backwards
+ from their more natural integer increment ordering, and so when the
+ decoding tables are built in the large loop below, the integer codes
+ are incremented backwards.
+
+ This routine assumes, but does not check, that all of the entries in
+ lens[] are in the range 0..MAXBITS. The caller must assure this.
+ 1..MAXBITS is interpreted as that code length. zero means that that
+ symbol does not occur in this code.
+
+ The codes are sorted by computing a count of codes for each length,
+ creating from that a table of starting indices for each length in the
+ sorted table, and then entering the symbols in order in the sorted
+ table. The sorted table is work[], with that space being provided by
+ the caller.
+
+ The length counts are used for other purposes as well, i.e. finding
+ the minimum and maximum length codes, determining if there are any
+ codes at all, checking for a valid set of lengths, and looking ahead
+ at length counts to determine sub-table sizes when building the
+ decoding tables.
+ */
+
+ /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */
+ for (len = 0; len <= MAXBITS; len++)
+ count[len] = 0;
+ for (sym = 0; sym < codes; sym++)
+ count[lens[sym]]++;
+
+ /* bound code lengths, force root to be within code lengths */
+ root = *bits;
+ for (max = MAXBITS; max >= 1; max--)
+ if (count[max] != 0) break;
+ if (root > max) root = max;
+ if (max == 0) { /* no symbols to code at all */
+ 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 < max; min++)
+ if (count[min] != 0) break;
+ if (root < min) root = min;
+
+ /* check for an over-subscribed or incomplete set of lengths */
+ left = 1;
+ for (len = 1; len <= MAXBITS; len++) {
+ left <<= 1;
+ left -= count[len];
+ if (left < 0) return -1; /* over-subscribed */
+ }
+ if (left > 0 && (type == CODES || max != 1))
+ return -1; /* incomplete set */
+
+ /* generate offsets into symbol table for each length for sorting */
+ offs[1] = 0;
+ for (len = 1; len < MAXBITS; len++)
+ offs[len + 1] = offs[len] + count[len];
+
+ /* sort symbols by length, by symbol order within each length */
+ for (sym = 0; sym < codes; sym++)
+ if (lens[sym] != 0) work[offs[lens[sym]]++] = (unsigned short)sym;
+
+ /*
+ Create and fill in decoding tables. In this loop, the table being
+ filled is at next and has curr index bits. The code being used is huff
+ with length len. That code is converted to an index by dropping drop
+ bits off of the bottom. For codes where len is less than drop + curr,
+ those top drop + curr - len bits are incremented through all values to
+ fill the table with replicated entries.
+
+ root is the number of index bits for the root table. When len exceeds
+ root, sub-tables are created pointed to by the root entry with an index
+ of the low root bits of huff. This is saved in low to check for when a
+ new sub-table should be started. drop is zero when the root table is
+ being filled, and drop is root when sub-tables are being filled.
+
+ When a new sub-table is needed, it is necessary to look ahead in the
+ code lengths to determine what size sub-table is needed. The length
+ counts are used for this, and so count[] is decremented as codes are
+ entered in the tables.
+
+ used keeps track of how many table entries have been allocated from the
+ 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
+ routine permits incomplete codes, so another loop after this one fills
+ in the rest of the decoding tables with invalid code markers.
+ */
+
+ /* set up for code type */
+ switch (type) {
+ case CODES:
+ base = extra = work; /* dummy value--not used */
+ end = 19;
+ break;
+ case LENS:
+ base = lbase;
+ base -= 257;
+ extra = lext;
+ extra -= 257;
+ end = 256;
+ break;
+ default: /* DISTS */
+ base = dbase;
+ extra = dext;
+ end = -1;
+ }
+
+ /* initialize state for loop */
+ huff = 0; /* starting code */
+ sym = 0; /* starting code symbol */
+ len = min; /* starting code length */
+ next = *table; /* current table to fill in */
+ curr = root; /* current table index bits */
+ drop = 0; /* current bits to drop from code for index */
+ low = (unsigned)(-1); /* trigger new sub-table when len > root */
+ used = 1U << root; /* use root table entries */
+ mask = used - 1; /* mask for comparing low */
+
+ /* check available table space */
+ if ((type == LENS && used >= ENOUGH_LENS) ||
+ (type == DISTS && used >= ENOUGH_DISTS))
+ return 1;
+
+ /* process all codes and make table entries */
+ for (;;) {
+ /* create table entry */
+ here.bits = (unsigned char)(len - drop);
+ if ((int)(work[sym]) < end) {
+ here.op = (unsigned char)0;
+ here.val = work[sym];
+ }
+ else if ((int)(work[sym]) > end) {
+ here.op = (unsigned char)(extra[work[sym]]);
+ here.val = base[work[sym]];
+ }
+ else {
+ here.op = (unsigned char)(32 + 64); /* end of block */
+ here.val = 0;
+ }
+
+ /* replicate for those indices with low len bits equal to huff */
+ incr = 1U << (len - drop);
+ fill = 1U << curr;
+ min = fill; /* save offset to next table */
+ do {
+ fill -= incr;
+ next[(huff >> drop) + fill] = here;
+ } while (fill != 0);
+
+ /* backwards increment the len-bit code huff */
+ incr = 1U << (len - 1);
+ while (huff & incr)
+ incr >>= 1;
+ if (incr != 0) {
+ huff &= incr - 1;
+ huff += incr;
+ }
+ else
+ huff = 0;
+
+ /* go to next symbol, update count, len */
+ sym++;
+ if (--(count[len]) == 0) {
+ if (len == max) break;
+ len = lens[work[sym]];
+ }
+
+ /* create new sub-table if needed */
+ if (len > root && (huff & mask) != low) {
+ /* if first time, transition to sub-tables */
+ if (drop == 0)
+ drop = root;
+
+ /* increment past last table */
+ next += min; /* here min is 1 << curr */
+
+ /* determine length of next table */
+ curr = len - drop;
+ left = (int)(1 << curr);
+ while (curr + drop < max) {
+ left -= count[curr + drop];
+ if (left <= 0) break;
+ curr++;
+ left <<= 1;
+ }
+
+ /* check for enough space */
+ used += 1U << curr;
+ if ((type == LENS && used >= ENOUGH_LENS) ||
+ (type == DISTS && used >= ENOUGH_DISTS))
+ return 1;
+
+ /* point entry in root table to sub-table */
+ low = huff & mask;
+ (*table)[low].op = (unsigned char)curr;
+ (*table)[low].bits = (unsigned char)root;
+ (*table)[low].val = (unsigned short)(next - *table);
+ }
+ }
+
+ /*
+ Fill in rest of table for incomplete codes. This loop is similar to the
+ loop above in incrementing huff for table indices. It is assumed that
+ len is equal to curr + drop, so there is no loop needed to increment
+ 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.
+ */
+ 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;
+ here.bits = (unsigned char)len;
+ }
+
+ /* put invalid code marker in table */
+ next[huff >> drop] = here;
+
+ /* backwards increment the len-bit code huff */
+ incr = 1U << (len - 1);
+ while (huff & incr)
+ incr >>= 1;
+ if (incr != 0) {
+ huff &= incr - 1;
+ huff += incr;
+ }
+ else
+ huff = 0;
+ }
+
+ /* set return parameters */
+ *table += used;
+ *bits = root;
+ return 0;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/inftrees.h Thu Dec 15 15:57:51 2011 -0800
@@ -0,0 +1,86 @@
+/*
+ * 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.
+ */
+
+/* inftrees.h -- header to use inftrees.c
+ * Copyright (C) 1995-2005, 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.
+ */
+
+/* Structure for decoding tables. Each entry provides either the
+ information needed to do the operation requested by the code that
+ indexed that table entry, or it provides a pointer to another
+ table that indexes more bits of the code. op indicates whether
+ the entry is a pointer to another table, a literal, a length or
+ distance, an end-of-block, or an invalid code. For a table
+ pointer, the low four bits of op is the number of index bits of
+ that table. For a length or distance, the low four bits of op
+ is the number of extra bits to get after the code. bits is
+ the number of bits in this code or part of the code to drop off
+ of the bit buffer. val is the actual byte to output in the case
+ of a literal, the base length or distance, or the offset from
+ the current table to the next table. Each entry is four bytes. */
+typedef struct {
+ unsigned char op; /* operation, extra bits, table bits */
+ unsigned char bits; /* bits in this part of the code */
+ unsigned short val; /* offset in table or code value */
+} code;
+
+/* op values as set by inflate_table():
+ 00000000 - literal
+ 0000tttt - table link, tttt != 0 is the number of table index bits
+ 0001eeee - length or distance, eeee is the number of extra bits
+ 01100000 - end of block
+ 01000000 - invalid code
+ */
+
+/* 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 inflate_table() */
+typedef enum {
+ CODES,
+ LENS,
+ DISTS
+} codetype;
+
+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));
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/patches/ChangeLog_java Thu Dec 15 15:57:51 2011 -0800
@@ -0,0 +1,19 @@
+(1)renamed
+ adler32.c -> zadler32.c
+ zcrc32c -> zcrc32.c
+
+(2)added _LP64 to make uLong a 32-bit int on 64-bit platform
+ zconf.h:
+ uLong -> 32-bit int
+
+(3)updated crc32.c/crc32()
+ unsigned long -> uLong
+
+(4)updated zlib.h (to support > 4G zipfile):
+ total_in/out: uLong -> long long
+
+(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;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/trees.c Thu Dec 15 15:57:51 2011 -0800
@@ -0,0 +1,1268 @@
+/*
+ * 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.
+ */
+
+/* trees.c -- output deflated data using Huffman coding
+ * 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
+ */
+
+/*
+ * ALGORITHM
+ *
+ * The "deflation" process uses several Huffman trees. The more
+ * common source values are represented by shorter bit sequences.
+ *
+ * Each code tree is stored in a compressed form which is itself
+ * a Huffman encoding of the lengths of all the code strings (in
+ * ascending order by source values). The actual code strings are
+ * reconstructed from the lengths in the inflate process, as described
+ * in the deflate specification.
+ *
+ * REFERENCES
+ *
+ * Deutsch, L.P.,"'Deflate' Compressed Data Format Specification".
+ * Available in ftp.uu.net:/pub/archiving/zip/doc/deflate-1.1.doc
+ *
+ * Storer, James A.
+ * Data Compression: Methods and Theory, pp. 49-50.
+ * Computer Science Press, 1988. ISBN 0-7167-8156-5.
+ *
+ * Sedgewick, R.
+ * Algorithms, p290.
+ * Addison-Wesley, 1983. ISBN 0-201-06672-6.
+ */
+
+/* @(#) $Id$ */
+
+/* #define GEN_TREES_H */
+
+#include "deflate.h"
+
+#ifdef DEBUG
+# include <ctype.h>
+#endif
+
+/* ===========================================================================
+ * Constants
+ */
+
+#define MAX_BL_BITS 7
+/* Bit length codes must not exceed MAX_BL_BITS bits */
+
+#define END_BLOCK 256
+/* end of block literal code */
+
+#define REP_3_6 16
+/* repeat previous bit length 3-6 times (2 bits of repeat count) */
+
+#define REPZ_3_10 17
+/* repeat a zero length 3-10 times (3 bits of repeat count) */
+
+#define REPZ_11_138 18
+/* repeat a zero length 11-138 times (7 bits of repeat count) */
+
+local const int extra_lbits[LENGTH_CODES] /* extra bits for each length code */
+ = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0};
+
+local const int extra_dbits[D_CODES] /* extra bits for each distance code */
+ = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13};
+
+local const int extra_blbits[BL_CODES]/* extra bits for each bit length code */
+ = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7};
+
+local const uch bl_order[BL_CODES]
+ = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15};
+/* The lengths of the bit length codes are sent in order of decreasing
+ * probability, to avoid transmitting the lengths for unused bit length codes.
+ */
+
+#define Buf_size (8 * 2*sizeof(char))
+/* Number of bits used within bi_buf. (bi_buf might be implemented on
+ * more than 16 bits on some systems.)
+ */
+
+/* ===========================================================================
+ * Local data. These are initialized only once.
+ */
+
+#define DIST_CODE_LEN 512 /* see definition of array dist_code below */
+
+#if defined(GEN_TREES_H) || !defined(STDC)
+/* non ANSI compilers may not accept trees.h */
+
+local ct_data static_ltree[L_CODES+2];
+/* The static literal tree. Since the bit lengths are imposed, there is no
+ * need for the L_CODES extra codes used during heap construction. However
+ * The codes 286 and 287 are needed to build a canonical tree (see _tr_init
+ * below).
+ */
+
+local ct_data static_dtree[D_CODES];
+/* The static distance tree. (Actually a trivial tree since all codes use
+ * 5 bits.)
+ */
+
+uch _dist_code[DIST_CODE_LEN];
+/* Distance codes. The first 256 values correspond to the distances
+ * 3 .. 258, the last 256 values correspond to the top 8 bits of
+ * the 15 bit distances.
+ */
+
+uch _length_code[MAX_MATCH-MIN_MATCH+1];
+/* length code for each normalized match length (0 == MIN_MATCH) */
+
+local int base_length[LENGTH_CODES];
+/* First normalized length for each code (0 = MIN_MATCH) */
+
+local int base_dist[D_CODES];
+/* First normalized distance for each code (0 = distance of 1) */
+
+#else
+# include "trees.h"
+#endif /* GEN_TREES_H */
+
+struct static_tree_desc_s {
+ const ct_data *static_tree; /* static tree or NULL */
+ const intf *extra_bits; /* extra bits for each code or NULL */
+ int extra_base; /* base index for extra_bits */
+ int elems; /* max number of elements in the tree */
+ int max_length; /* max bit length for the codes */
+};
+
+local static_tree_desc static_l_desc =
+{static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS};
+
+local static_tree_desc static_d_desc =
+{static_dtree, extra_dbits, 0, D_CODES, MAX_BITS};
+
+local static_tree_desc static_bl_desc =
+{(const ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS};
+
+/* ===========================================================================
+ * Local (static) routines in this file.
+ */
+
+local void tr_static_init OF((void));
+local void init_block OF((deflate_state *s));
+local void pqdownheap OF((deflate_state *s, ct_data *tree, int k));
+local void gen_bitlen OF((deflate_state *s, tree_desc *desc));
+local void gen_codes OF((ct_data *tree, int max_code, ushf *bl_count));
+local void build_tree OF((deflate_state *s, tree_desc *desc));
+local void scan_tree OF((deflate_state *s, ct_data *tree, int max_code));
+local void send_tree OF((deflate_state *s, ct_data *tree, int max_code));
+local int build_bl_tree OF((deflate_state *s));
+local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes,
+ int blcodes));
+local void compress_block OF((deflate_state *s, ct_data *ltree,
+ ct_data *dtree));
+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));
+local void copy_block OF((deflate_state *s, charf *buf, unsigned len,
+ int header));
+
+#ifdef GEN_TREES_H
+local void gen_trees_header OF((void));
+#endif
+
+#ifndef DEBUG
+# define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len)
+ /* Send a code of the given tree. c and tree must not have side effects */
+
+#else /* DEBUG */
+# define send_code(s, c, tree) \
+ { if (z_verbose>2) fprintf(stderr,"\ncd %3d ",(c)); \
+ send_bits(s, tree[c].Code, tree[c].Len); }
+#endif
+
+/* ===========================================================================
+ * Output a short LSB first on the stream.
+ * IN assertion: there is enough room in pendingBuf.
+ */
+#define put_short(s, w) { \
+ put_byte(s, (uch)((w) & 0xff)); \
+ put_byte(s, (uch)((ush)(w) >> 8)); \
+}
+
+/* ===========================================================================
+ * Send a value on a given number of bits.
+ * IN assertion: length <= 16 and value fits in length bits.
+ */
+#ifdef DEBUG
+local void send_bits OF((deflate_state *s, int value, int length));
+
+local void send_bits(s, value, length)
+ deflate_state *s;
+ int value; /* value to send */
+ int length; /* number of bits */
+{
+ Tracevv((stderr," l %2d v %4x ", length, value));
+ Assert(length > 0 && length <= 15, "invalid length");
+ s->bits_sent += (ulg)length;
+
+ /* If not enough room in bi_buf, use (valid) bits from bi_buf and
+ * (16 - bi_valid) bits from value, leaving (width - (16-bi_valid))
+ * unused bits in value.
+ */
+ if (s->bi_valid > (int)Buf_size - length) {
+ 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 |= (ush)value << s->bi_valid;
+ s->bi_valid += length;
+ }
+}
+#else /* !DEBUG */
+
+#define send_bits(s, value, length) \
+{ int len = length;\
+ if (s->bi_valid > (int)Buf_size - len) {\
+ int val = value;\
+ 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 |= (ush)(value) << s->bi_valid;\
+ s->bi_valid += len;\
+ }\
+}
+#endif /* DEBUG */
+
+
+/* the arguments must not have side effects */
+
+/* ===========================================================================
+ * Initialize the various 'constant' tables.
+ */
+local void tr_static_init()
+{
+#if defined(GEN_TREES_H) || !defined(STDC)
+ static int static_init_done = 0;
+ int n; /* iterates over tree elements */
+ int bits; /* bit counter */
+ int length; /* length value */
+ int code; /* code value */
+ int dist; /* distance index */
+ ush bl_count[MAX_BITS+1];
+ /* number of codes at each bit length for an optimal tree */
+
+ 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;
+ for (code = 0; code < LENGTH_CODES-1; code++) {
+ base_length[code] = length;
+ for (n = 0; n < (1<<extra_lbits[code]); n++) {
+ _length_code[length++] = (uch)code;
+ }
+ }
+ Assert (length == 256, "tr_static_init: length != 256");
+ /* Note that the length 255 (match length 258) can be represented
+ * in two different ways: code 284 + 5 bits or code 285, so we
+ * overwrite length_code[255] to use the best encoding:
+ */
+ _length_code[length-1] = (uch)code;
+
+ /* Initialize the mapping dist (0..32K) -> dist code (0..29) */
+ dist = 0;
+ for (code = 0 ; code < 16; code++) {
+ base_dist[code] = dist;
+ for (n = 0; n < (1<<extra_dbits[code]); n++) {
+ _dist_code[dist++] = (uch)code;
+ }
+ }
+ Assert (dist == 256, "tr_static_init: dist != 256");
+ dist >>= 7; /* from now on, all distances are divided by 128 */
+ for ( ; code < D_CODES; code++) {
+ base_dist[code] = dist << 7;
+ for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) {
+ _dist_code[256 + dist++] = (uch)code;
+ }
+ }
+ Assert (dist == 256, "tr_static_init: 256+dist != 512");
+
+ /* Construct the codes of the static literal tree */
+ for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0;
+ n = 0;
+ while (n <= 143) static_ltree[n++].Len = 8, bl_count[8]++;
+ while (n <= 255) static_ltree[n++].Len = 9, bl_count[9]++;
+ while (n <= 279) static_ltree[n++].Len = 7, bl_count[7]++;
+ while (n <= 287) static_ltree[n++].Len = 8, bl_count[8]++;
+ /* Codes 286 and 287 do not exist, but we must include them in the
+ * tree construction to get a canonical Huffman tree (longest code
+ * all ones)
+ */
+ gen_codes((ct_data *)static_ltree, L_CODES+1, bl_count);
+
+ /* The static distance tree is trivial: */
+ for (n = 0; n < D_CODES; n++) {
+ static_dtree[n].Len = 5;
+ static_dtree[n].Code = bi_reverse((unsigned)n, 5);
+ }
+ static_init_done = 1;
+
+# ifdef GEN_TREES_H
+ gen_trees_header();
+# endif
+#endif /* defined(GEN_TREES_H) || !defined(STDC) */
+}
+
+/* ===========================================================================
+ * Genererate the file trees.h describing the static trees.
+ */
+#ifdef GEN_TREES_H
+# ifndef DEBUG
+# include <stdio.h>
+# endif
+
+# define SEPARATOR(i, last, width) \
+ ((i) == (last)? "\n};\n\n" : \
+ ((i) % (width) == (width)-1 ? ",\n" : ", "))
+
+void gen_trees_header()
+{
+ FILE *header = fopen("trees.h", "w");
+ int i;
+
+ Assert (header != NULL, "Can't open trees.h");
+ fprintf(header,
+ "/* header created automatically with -DGEN_TREES_H */\n\n");
+
+ fprintf(header, "local const ct_data static_ltree[L_CODES+2] = {\n");
+ for (i = 0; i < L_CODES+2; i++) {
+ fprintf(header, "{{%3u},{%3u}}%s", static_ltree[i].Code,
+ static_ltree[i].Len, SEPARATOR(i, L_CODES+1, 5));
+ }
+
+ fprintf(header, "local const ct_data static_dtree[D_CODES] = {\n");
+ for (i = 0; i < D_CODES; i++) {
+ fprintf(header, "{{%2u},{%2u}}%s", static_dtree[i].Code,
+ static_dtree[i].Len, SEPARATOR(i, D_CODES-1, 5));
+ }
+
+ 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 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));
+ }
+
+ fprintf(header, "local const int base_length[LENGTH_CODES] = {\n");
+ for (i = 0; i < LENGTH_CODES; i++) {
+ fprintf(header, "%1u%s", base_length[i],
+ SEPARATOR(i, LENGTH_CODES-1, 20));
+ }
+
+ fprintf(header, "local const int base_dist[D_CODES] = {\n");
+ for (i = 0; i < D_CODES; i++) {
+ fprintf(header, "%5u%s", base_dist[i],
+ SEPARATOR(i, D_CODES-1, 10));
+ }
+
+ fclose(header);
+}
+#endif /* GEN_TREES_H */
+
+/* ===========================================================================
+ * Initialize the tree data structures for a new zlib stream.
+ */
+void ZLIB_INTERNAL _tr_init(s)
+ deflate_state *s;
+{
+ tr_static_init();
+
+ s->l_desc.dyn_tree = s->dyn_ltree;
+ s->l_desc.stat_desc = &static_l_desc;
+
+ s->d_desc.dyn_tree = s->dyn_dtree;
+ s->d_desc.stat_desc = &static_d_desc;
+
+ s->bl_desc.dyn_tree = s->bl_tree;
+ s->bl_desc.stat_desc = &static_bl_desc;
+
+ s->bi_buf = 0;
+ s->bi_valid = 0;
+ s->last_eob_len = 8; /* enough lookahead for inflate */
+#ifdef DEBUG
+ s->compressed_len = 0L;
+ s->bits_sent = 0L;
+#endif
+
+ /* Initialize the first block of the first file: */
+ init_block(s);
+}
+
+/* ===========================================================================
+ * Initialize a new block.
+ */
+local void init_block(s)
+ deflate_state *s;
+{
+ int n; /* iterates over tree elements */
+
+ /* Initialize the trees. */
+ for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0;
+ for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0;
+ for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0;
+
+ s->dyn_ltree[END_BLOCK].Freq = 1;
+ s->opt_len = s->static_len = 0L;
+ s->last_lit = s->matches = 0;
+}
+
+#define SMALLEST 1
+/* Index within the heap array of least frequent node in the Huffman tree */
+
+
+/* ===========================================================================
+ * Remove the smallest element from the heap and recreate the heap with
+ * one less element. Updates heap and heap_len.
+ */
+#define pqremove(s, tree, top) \
+{\
+ top = s->heap[SMALLEST]; \
+ s->heap[SMALLEST] = s->heap[s->heap_len--]; \
+ pqdownheap(s, tree, SMALLEST); \
+}
+
+/* ===========================================================================
+ * Compares to subtrees, using the tree depth as tie breaker when
+ * the subtrees have equal frequency. This minimizes the worst case length.
+ */
+#define smaller(tree, n, m, depth) \
+ (tree[n].Freq < tree[m].Freq || \
+ (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m]))
+
+/* ===========================================================================
+ * Restore the heap property by moving down the tree starting at node k,
+ * exchanging a node with the smallest of its two sons if necessary, stopping
+ * when the heap property is re-established (each father smaller than its
+ * two sons).
+ */
+local void pqdownheap(s, tree, k)
+ deflate_state *s;
+ ct_data *tree; /* the tree to restore */
+ int k; /* node to move down */
+{
+ int v = s->heap[k];
+ int j = k << 1; /* left son of k */
+ while (j <= s->heap_len) {
+ /* Set j to the smallest of the two sons: */
+ if (j < s->heap_len &&
+ smaller(tree, s->heap[j+1], s->heap[j], s->depth)) {
+ j++;
+ }
+ /* Exit if v is smaller than both sons */
+ if (smaller(tree, v, s->heap[j], s->depth)) break;
+
+ /* Exchange v with the smallest son */
+ s->heap[k] = s->heap[j]; k = j;
+
+ /* And continue down the tree, setting j to the left son of k */
+ j <<= 1;
+ }
+ s->heap[k] = v;
+}
+
+/* ===========================================================================
+ * Compute the optimal bit lengths for a tree and update the total bit length
+ * for the current block.
+ * IN assertion: the fields freq and dad are set, heap[heap_max] and
+ * above are the tree nodes sorted by increasing frequency.
+ * OUT assertions: the field len is set to the optimal bit length, the
+ * array bl_count contains the frequencies for each bit length.
+ * The length opt_len is updated; static_len is also updated if stree is
+ * not null.
+ */
+local void gen_bitlen(s, desc)
+ deflate_state *s;
+ tree_desc *desc; /* the tree descriptor */
+{
+ ct_data *tree = desc->dyn_tree;
+ int max_code = desc->max_code;
+ const ct_data *stree = desc->stat_desc->static_tree;
+ const intf *extra = desc->stat_desc->extra_bits;
+ int base = desc->stat_desc->extra_base;
+ int max_length = desc->stat_desc->max_length;
+ int h; /* heap index */
+ int n, m; /* iterate over the tree elements */
+ int bits; /* bit length */
+ int xbits; /* extra bits */
+ ush f; /* frequency */
+ int overflow = 0; /* number of elements with bit length too large */
+
+ for (bits = 0; bits <= MAX_BITS; bits++) s->bl_count[bits] = 0;
+
+ /* In a first pass, compute the optimal bit lengths (which may
+ * overflow in the case of the bit length tree).
+ */
+ tree[s->heap[s->heap_max]].Len = 0; /* root of the heap */
+
+ for (h = s->heap_max+1; h < HEAP_SIZE; h++) {
+ n = s->heap[h];
+ bits = tree[tree[n].Dad].Len + 1;
+ if (bits > max_length) bits = max_length, overflow++;
+ tree[n].Len = (ush)bits;
+ /* We overwrite tree[n].Dad which is no longer needed */
+
+ if (n > max_code) continue; /* not a leaf node */
+
+ s->bl_count[bits]++;
+ xbits = 0;
+ if (n >= base) xbits = extra[n-base];
+ f = tree[n].Freq;
+ s->opt_len += (ulg)f * (bits + xbits);
+ if (stree) s->static_len += (ulg)f * (stree[n].Len + xbits);
+ }
+ if (overflow == 0) return;
+
+ Trace((stderr,"\nbit length overflow\n"));
+ /* This happens for example on obj2 and pic of the Calgary corpus */
+
+ /* Find the first bit length which could increase: */
+ do {
+ bits = max_length-1;
+ while (s->bl_count[bits] == 0) bits--;
+ s->bl_count[bits]--; /* move one leaf down the tree */
+ s->bl_count[bits+1] += 2; /* move one overflow item as its brother */
+ s->bl_count[max_length]--;
+ /* The brother of the overflow item also moves one step up,
+ * but this does not affect bl_count[max_length]
+ */
+ overflow -= 2;
+ } while (overflow > 0);
+
+ /* Now recompute all bit lengths, scanning in increasing frequency.
+ * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all
+ * lengths instead of fixing only the wrong ones. This idea is taken
+ * from 'ar' written by Haruhiko Okumura.)
+ */
+ for (bits = max_length; bits != 0; bits--) {
+ n = s->bl_count[bits];
+ while (n != 0) {
+ m = s->heap[--h];
+ if (m > max_code) continue;
+ if ((unsigned) tree[m].Len != (unsigned) bits) {
+ Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits));
+ s->opt_len += ((long)bits - (long)tree[m].Len)
+ *(long)tree[m].Freq;
+ tree[m].Len = (ush)bits;
+ }
+ n--;
+ }
+ }
+}
+
+/* ===========================================================================
+ * Generate the codes for a given tree and bit counts (which need not be
+ * optimal).
+ * IN assertion: the array bl_count contains the bit length statistics for
+ * the given tree and the field len is set for all tree elements.
+ * OUT assertion: the field code is set for all tree elements of non
+ * zero code length.
+ */
+local void gen_codes (tree, max_code, bl_count)
+ ct_data *tree; /* the tree to decorate */
+ int max_code; /* largest code with non zero frequency */
+ ushf *bl_count; /* number of codes at each bit length */
+{
+ ush next_code[MAX_BITS+1]; /* next code value for each bit length */
+ ush code = 0; /* running code value */
+ int bits; /* bit index */
+ int n; /* code index */
+
+ /* The distribution counts are first used to generate the code values
+ * without bit reversal.
+ */
+ for (bits = 1; bits <= MAX_BITS; bits++) {
+ next_code[bits] = code = (code + bl_count[bits-1]) << 1;
+ }
+ /* Check that the bit counts in bl_count are consistent. The last code
+ * must be all ones.
+ */
+ Assert (code + bl_count[MAX_BITS]-1 == (1<<MAX_BITS)-1,
+ "inconsistent bit counts");
+ Tracev((stderr,"\ngen_codes: max_code %d ", max_code));
+
+ for (n = 0; n <= max_code; n++) {
+ int len = tree[n].Len;
+ if (len == 0) continue;
+ /* Now reverse the bits */
+ tree[n].Code = bi_reverse(next_code[len]++, len);
+
+ Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ",
+ n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len]-1));
+ }
+}
+
+/* ===========================================================================
+ * Construct one Huffman tree and assigns the code bit strings and lengths.
+ * Update the total bit length for the current block.
+ * IN assertion: the field freq is set for all tree elements.
+ * OUT assertions: the fields len and code are set to the optimal bit length
+ * and corresponding code. The length opt_len is updated; static_len is
+ * also updated if stree is not null. The field max_code is set.
+ */
+local void build_tree(s, desc)
+ deflate_state *s;
+ tree_desc *desc; /* the tree descriptor */
+{
+ ct_data *tree = desc->dyn_tree;
+ const ct_data *stree = desc->stat_desc->static_tree;
+ int elems = desc->stat_desc->elems;
+ int n, m; /* iterate over heap elements */
+ int max_code = -1; /* largest code with non zero frequency */
+ int node; /* new node being created */
+
+ /* Construct the initial heap, with least frequent element in
+ * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1].
+ * heap[0] is not used.
+ */
+ s->heap_len = 0, s->heap_max = HEAP_SIZE;
+
+ for (n = 0; n < elems; n++) {
+ if (tree[n].Freq != 0) {
+ s->heap[++(s->heap_len)] = max_code = n;
+ s->depth[n] = 0;
+ } else {
+ tree[n].Len = 0;
+ }
+ }
+
+ /* The pkzip format requires that at least one distance code exists,
+ * and that at least one bit should be sent even if there is only one
+ * possible code. So to avoid special checks later on we force at least
+ * two codes of non zero frequency.
+ */
+ while (s->heap_len < 2) {
+ node = s->heap[++(s->heap_len)] = (max_code < 2 ? ++max_code : 0);
+ tree[node].Freq = 1;
+ s->depth[node] = 0;
+ s->opt_len--; if (stree) s->static_len -= stree[node].Len;
+ /* node is 0 or 1 so it does not have extra bits */
+ }
+ desc->max_code = max_code;
+
+ /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree,
+ * establish sub-heaps of increasing lengths:
+ */
+ for (n = s->heap_len/2; n >= 1; n--) pqdownheap(s, tree, n);
+
+ /* Construct the Huffman tree by repeatedly combining the least two
+ * frequent nodes.
+ */
+ node = elems; /* next internal node of the tree */
+ do {
+ pqremove(s, tree, n); /* n = node of least frequency */
+ m = s->heap[SMALLEST]; /* m = node of next least frequency */
+
+ s->heap[--(s->heap_max)] = n; /* keep the nodes sorted by frequency */
+ s->heap[--(s->heap_max)] = m;
+
+ /* Create a new node father of n and m */
+ tree[node].Freq = tree[n].Freq + tree[m].Freq;
+ s->depth[node] = (uch)((s->depth[n] >= s->depth[m] ?
+ s->depth[n] : s->depth[m]) + 1);
+ tree[n].Dad = tree[m].Dad = (ush)node;
+#ifdef DUMP_BL_TREE
+ if (tree == s->bl_tree) {
+ fprintf(stderr,"\nnode %d(%d), sons %d(%d) %d(%d)",
+ node, tree[node].Freq, n, tree[n].Freq, m, tree[m].Freq);
+ }
+#endif
+ /* and insert the new node in the heap */
+ s->heap[SMALLEST] = node++;
+ pqdownheap(s, tree, SMALLEST);
+
+ } while (s->heap_len >= 2);
+
+ s->heap[--(s->heap_max)] = s->heap[SMALLEST];
+
+ /* At this point, the fields freq and dad are set. We can now
+ * generate the bit lengths.
+ */
+ gen_bitlen(s, (tree_desc *)desc);
+
+ /* The field len is now set, we can generate the bit codes */
+ gen_codes ((ct_data *)tree, max_code, s->bl_count);
+}
+
+/* ===========================================================================
+ * Scan a literal or distance tree to determine the frequencies of the codes
+ * in the bit length tree.
+ */
+local void scan_tree (s, tree, max_code)
+ deflate_state *s;
+ ct_data *tree; /* the tree to be scanned */
+ int max_code; /* and its largest code of non zero frequency */
+{
+ int n; /* iterates over all tree elements */
+ int prevlen = -1; /* last emitted length */
+ int curlen; /* length of current code */
+ int nextlen = tree[0].Len; /* length of next code */
+ int count = 0; /* repeat count of the current code */
+ int max_count = 7; /* max repeat count */
+ int min_count = 4; /* min repeat count */
+
+ if (nextlen == 0) max_count = 138, min_count = 3;
+ tree[max_code+1].Len = (ush)0xffff; /* guard */
+
+ for (n = 0; n <= max_code; n++) {
+ curlen = nextlen; nextlen = tree[n+1].Len;
+ if (++count < max_count && curlen == nextlen) {
+ continue;
+ } else if (count < min_count) {
+ s->bl_tree[curlen].Freq += count;
+ } else if (curlen != 0) {
+ if (curlen != prevlen) s->bl_tree[curlen].Freq++;
+ s->bl_tree[REP_3_6].Freq++;
+ } else if (count <= 10) {
+ s->bl_tree[REPZ_3_10].Freq++;
+ } else {
+ s->bl_tree[REPZ_11_138].Freq++;
+ }
+ count = 0; prevlen = curlen;
+ if (nextlen == 0) {
+ max_count = 138, min_count = 3;
+ } else if (curlen == nextlen) {
+ max_count = 6, min_count = 3;
+ } else {
+ max_count = 7, min_count = 4;
+ }
+ }
+}
+
+/* ===========================================================================
+ * Send a literal or distance tree in compressed form, using the codes in
+ * bl_tree.
+ */
+local void send_tree (s, tree, max_code)
+ deflate_state *s;
+ ct_data *tree; /* the tree to be scanned */
+ int max_code; /* and its largest code of non zero frequency */
+{
+ int n; /* iterates over all tree elements */
+ int prevlen = -1; /* last emitted length */
+ int curlen; /* length of current code */
+ int nextlen = tree[0].Len; /* length of next code */
+ int count = 0; /* repeat count of the current code */
+ int max_count = 7; /* max repeat count */
+ int min_count = 4; /* min repeat count */
+
+ /* tree[max_code+1].Len = -1; */ /* guard already set */
+ if (nextlen == 0) max_count = 138, min_count = 3;
+
+ for (n = 0; n <= max_code; n++) {
+ curlen = nextlen; nextlen = tree[n+1].Len;
+ if (++count < max_count && curlen == nextlen) {
+ continue;
+ } else if (count < min_count) {
+ do { send_code(s, curlen, s->bl_tree); } while (--count != 0);
+
+ } else if (curlen != 0) {
+ if (curlen != prevlen) {
+ send_code(s, curlen, s->bl_tree); count--;
+ }
+ Assert(count >= 3 && count <= 6, " 3_6?");
+ send_code(s, REP_3_6, s->bl_tree); send_bits(s, count-3, 2);
+
+ } else if (count <= 10) {
+ send_code(s, REPZ_3_10, s->bl_tree); send_bits(s, count-3, 3);
+
+ } else {
+ send_code(s, REPZ_11_138, s->bl_tree); send_bits(s, count-11, 7);
+ }
+ count = 0; prevlen = curlen;
+ if (nextlen == 0) {
+ max_count = 138, min_count = 3;
+ } else if (curlen == nextlen) {
+ max_count = 6, min_count = 3;
+ } else {
+ max_count = 7, min_count = 4;
+ }
+ }
+}
+
+/* ===========================================================================
+ * Construct the Huffman tree for the bit lengths and return the index in
+ * bl_order of the last bit length code to send.
+ */
+local int build_bl_tree(s)
+ deflate_state *s;
+{
+ int max_blindex; /* index of last bit length code of non zero freq */
+
+ /* Determine the bit length frequencies for literal and distance trees */
+ scan_tree(s, (ct_data *)s->dyn_ltree, s->l_desc.max_code);
+ scan_tree(s, (ct_data *)s->dyn_dtree, s->d_desc.max_code);
+
+ /* Build the bit length tree: */
+ build_tree(s, (tree_desc *)(&(s->bl_desc)));
+ /* opt_len now includes the length of the tree representations, except
+ * the lengths of the bit lengths codes and the 5+5+4 bits for the counts.
+ */
+
+ /* Determine the number of bit length codes to send. The pkzip format
+ * requires that at least 4 bit length codes be sent. (appnote.txt says
+ * 3 but the actual value used is 4.)
+ */
+ for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) {
+ if (s->bl_tree[bl_order[max_blindex]].Len != 0) break;
+ }
+ /* Update opt_len to include the bit length tree and counts */
+ s->opt_len += 3*(max_blindex+1) + 5+5+4;
+ Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld",
+ s->opt_len, s->static_len));
+
+ return max_blindex;
+}
+
+/* ===========================================================================
+ * Send the header for a block using dynamic Huffman trees: the counts, the
+ * lengths of the bit length codes, the literal tree and the distance tree.
+ * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4.
+ */
+local void send_all_trees(s, lcodes, dcodes, blcodes)
+ deflate_state *s;
+ int lcodes, dcodes, blcodes; /* number of codes for each tree */
+{
+ int rank; /* index in bl_order */
+
+ Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes");
+ Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES,
+ "too many codes");
+ Tracev((stderr, "\nbl counts: "));
+ send_bits(s, lcodes-257, 5); /* not +255 as stated in appnote.txt */
+ send_bits(s, dcodes-1, 5);
+ send_bits(s, blcodes-4, 4); /* not -3 as stated in appnote.txt */
+ for (rank = 0; rank < blcodes; rank++) {
+ Tracev((stderr, "\nbl code %2d ", bl_order[rank]));
+ send_bits(s, s->bl_tree[bl_order[rank]].Len, 3);
+ }
+ Tracev((stderr, "\nbl tree: sent %ld", s->bits_sent));
+
+ send_tree(s, (ct_data *)s->dyn_ltree, lcodes-1); /* literal tree */
+ Tracev((stderr, "\nlit tree: sent %ld", s->bits_sent));
+
+ send_tree(s, (ct_data *)s->dyn_dtree, dcodes-1); /* distance tree */
+ Tracev((stderr, "\ndist tree: sent %ld", s->bits_sent));
+}
+
+/* ===========================================================================
+ * Send a stored block
+ */
+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 last; /* one if this is the last block for a file */
+{
+ 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;
+#endif
+ copy_block(s, buf, (unsigned)stored_len, 1); /* with header */
+}
+
+/* ===========================================================================
+ * Send one empty static block to give enough lookahead for inflate.
+ * This takes 10 bits, of which 7 may remain in the bit buffer.
+ * The current inflate code requires 9 bits of lookahead. If the
+ * last two codes for the previous block (real code plus EOB) were coded
+ * on 5 bits or less, inflate may have only 5+3 bits of lookahead to decode
+ * the last real code. In this case we send two empty static blocks instead
+ * of one. (There are no problems if the previous block is stored or fixed.)
+ * To simplify the code, we assume the worst case of last real code encoded
+ * on one bit only.
+ */
+void ZLIB_INTERNAL _tr_align(s)
+ deflate_state *s;
+{
+ send_bits(s, STATIC_TREES<<1, 3);
+ send_code(s, END_BLOCK, static_ltree);
+#ifdef DEBUG
+ s->compressed_len += 10L; /* 3 for block type, 7 for EOB */
+#endif
+ bi_flush(s);
+ /* Of the 10 bits for the empty block, we have already sent
+ * (10 - bi_valid) bits. The lookahead for the last real code (before
+ * the EOB of the previous block) was thus at least one plus the length
+ * of the EOB plus what we have just sent of the empty static block.
+ */
+ if (1 + s->last_eob_len + 10 - s->bi_valid < 9) {
+ send_bits(s, STATIC_TREES<<1, 3);
+ send_code(s, END_BLOCK, static_ltree);
+#ifdef DEBUG
+ s->compressed_len += 10L;
+#endif
+ bi_flush(s);
+ }
+ s->last_eob_len = 7;
+}
+
+/* ===========================================================================
+ * Determine the best encoding for the current block: dynamic trees, static
+ * trees or store, and output the encoded block to the zip file.
+ */
+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 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 */
+
+ /* Build the Huffman trees unless a stored block is forced */
+ if (s->level > 0) {
+
+ /* Check if the file is binary or text */
+ 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)));
+ Tracev((stderr, "\nlit data: dyn %ld, stat %ld", s->opt_len,
+ s->static_len));
+
+ build_tree(s, (tree_desc *)(&(s->d_desc)));
+ Tracev((stderr, "\ndist data: dyn %ld, stat %ld", s->opt_len,
+ s->static_len));
+ /* At this point, opt_len and static_len are the total bit lengths of
+ * the compressed block data, excluding the tree representations.
+ */
+
+ /* Build the bit length tree for the above two trees, and get the index
+ * in bl_order of the last bit length code to send.
+ */
+ max_blindex = build_bl_tree(s);
+
+ /* Determine the best encoding. Compute the block lengths in bytes. */
+ opt_lenb = (s->opt_len+3+7)>>3;
+ static_lenb = (s->static_len+3+7)>>3;
+
+ Tracev((stderr, "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u ",
+ opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len,
+ s->last_lit));
+
+ if (static_lenb <= opt_lenb) opt_lenb = static_lenb;
+
+ } else {
+ Assert(buf != (char*)0, "lost buf");
+ opt_lenb = static_lenb = stored_len + 5; /* force a stored block */
+ }
+
+#ifdef FORCE_STORED
+ if (buf != (char*)0) { /* force stored block */
+#else
+ if (stored_len+4 <= opt_lenb && buf != (char*)0) {
+ /* 4: two words for the lengths */
+#endif
+ /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE.
+ * Otherwise we can't have processed more than WSIZE input bytes since
+ * the last block flush, because compression would have been
+ * 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, 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)+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)+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);
+#ifdef DEBUG
+ s->compressed_len += 3 + s->opt_len;
+#endif
+ }
+ Assert (s->compressed_len == s->bits_sent, "bad compressed size");
+ /* The above check is made mod 2^32, for files larger than 512 MB
+ * and uLong implemented on 32 bits.
+ */
+ init_block(s);
+
+ 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*last));
+}
+
+/* ===========================================================================
+ * Save the match info and tally the frequency counts. Return true if
+ * the current block must be flushed.
+ */
+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) */
+{
+ s->d_buf[s->last_lit] = (ush)dist;
+ s->l_buf[s->last_lit++] = (uch)lc;
+ if (dist == 0) {
+ /* lc is the unmatched char */
+ s->dyn_ltree[lc].Freq++;
+ } else {
+ s->matches++;
+ /* Here, lc is the match length - MIN_MATCH */
+ dist--; /* dist = match distance - 1 */
+ Assert((ush)dist < (ush)MAX_DIST(s) &&
+ (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) &&
+ (ush)d_code(dist) < (ush)D_CODES, "_tr_tally: bad match");
+
+ s->dyn_ltree[_length_code[lc]+LITERALS+1].Freq++;
+ s->dyn_dtree[d_code(dist)].Freq++;
+ }
+
+#ifdef TRUNCATE_BLOCK
+ /* Try to guess if it is profitable to stop the current block here */
+ if ((s->last_lit & 0x1fff) == 0 && s->level > 2) {
+ /* Compute an upper bound for the compressed length */
+ ulg out_length = (ulg)s->last_lit*8L;
+ ulg in_length = (ulg)((long)s->strstart - s->block_start);
+ int dcode;
+ for (dcode = 0; dcode < D_CODES; dcode++) {
+ out_length += (ulg)s->dyn_dtree[dcode].Freq *
+ (5L+extra_dbits[dcode]);
+ }
+ out_length >>= 3;
+ Tracev((stderr,"\nlast_lit %u, in %ld, out ~%ld(%ld%%) ",
+ s->last_lit, in_length, out_length,
+ 100L - out_length*100L/in_length));
+ if (s->matches < s->last_lit/2 && out_length < in_length/2) return 1;
+ }
+#endif
+ return (s->last_lit == s->lit_bufsize-1);
+ /* We avoid equality with lit_bufsize because of wraparound at 64K
+ * on 16 bit machines and because stored blocks are restricted to
+ * 64K-1 bytes.
+ */
+}
+
+/* ===========================================================================
+ * Send the block data compressed using the given Huffman trees
+ */
+local void compress_block(s, ltree, dtree)
+ deflate_state *s;
+ ct_data *ltree; /* literal tree */
+ ct_data *dtree; /* distance tree */
+{
+ unsigned dist; /* distance of matched string */
+ int lc; /* match length or unmatched char (if dist == 0) */
+ unsigned lx = 0; /* running index in l_buf */
+ unsigned code; /* the code to send */
+ int extra; /* number of extra bits to send */
+
+ if (s->last_lit != 0) do {
+ dist = s->d_buf[lx];
+ lc = s->l_buf[lx++];
+ if (dist == 0) {
+ send_code(s, lc, ltree); /* send a literal byte */
+ Tracecv(isgraph(lc), (stderr," '%c' ", lc));
+ } else {
+ /* Here, lc is the match length - MIN_MATCH */
+ code = _length_code[lc];
+ send_code(s, code+LITERALS+1, ltree); /* send the length code */
+ extra = extra_lbits[code];
+ if (extra != 0) {
+ lc -= base_length[code];
+ send_bits(s, lc, extra); /* send the extra length bits */
+ }
+ dist--; /* dist is now the match distance - 1 */
+ code = d_code(dist);
+ Assert (code < D_CODES, "bad d_code");
+
+ send_code(s, code, dtree); /* send the distance code */
+ extra = extra_dbits[code];
+ if (extra != 0) {
+ dist -= base_dist[code];
+ send_bits(s, dist, extra); /* send the extra distance bits */
+ }
+ } /* literal or match pair ? */
+
+ /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */
+ Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx,
+ "pendingBuf overflow");
+
+ } while (lx < s->last_lit);
+
+ send_code(s, END_BLOCK, ltree);
+ s->last_eob_len = ltree[END_BLOCK].Len;
+}
+
+/* ===========================================================================
+ * 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 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;
+
+ /* 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)
+ 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;
+}
+
+/* ===========================================================================
+ * Reverse the first len bits of a code, using straightforward code (a faster
+ * method would use a table)
+ * IN assertion: 1 <= len <= 15
+ */
+local unsigned bi_reverse(code, len)
+ unsigned code; /* the value to invert */
+ int len; /* its bit length */
+{
+ register unsigned res = 0;
+ do {
+ res |= code & 1;
+ code >>= 1, res <<= 1;
+ } while (--len > 0);
+ return res >> 1;
+}
+
+/* ===========================================================================
+ * Flush the bit buffer, keeping at most 7 bits in it.
+ */
+local void bi_flush(s)
+ deflate_state *s;
+{
+ if (s->bi_valid == 16) {
+ put_short(s, s->bi_buf);
+ s->bi_buf = 0;
+ s->bi_valid = 0;
+ } else if (s->bi_valid >= 8) {
+ put_byte(s, (Byte)s->bi_buf);
+ s->bi_buf >>= 8;
+ s->bi_valid -= 8;
+ }
+}
+
+/* ===========================================================================
+ * Flush the bit buffer and align the output on a byte boundary
+ */
+local void bi_windup(s)
+ deflate_state *s;
+{
+ if (s->bi_valid > 8) {
+ put_short(s, s->bi_buf);
+ } else if (s->bi_valid > 0) {
+ put_byte(s, (Byte)s->bi_buf);
+ }
+ s->bi_buf = 0;
+ s->bi_valid = 0;
+#ifdef DEBUG
+ s->bits_sent = (s->bits_sent+7) & ~7;
+#endif
+}
+
+/* ===========================================================================
+ * Copy a stored block, storing first the length and its
+ * one's complement if requested.
+ */
+local void copy_block(s, buf, len, header)
+ deflate_state *s;
+ charf *buf; /* the input data */
+ unsigned len; /* its length */
+ int header; /* true if block header must be written */
+{
+ bi_windup(s); /* align on byte boundary */
+ s->last_eob_len = 8; /* enough lookahead for inflate */
+
+ if (header) {
+ put_short(s, (ush)len);
+ put_short(s, (ush)~len);
+#ifdef DEBUG
+ s->bits_sent += 2*16;
+#endif
+ }
+#ifdef DEBUG
+ s->bits_sent += (ulg)len<<3;
+#endif
+ while (len--) {
+ put_byte(s, *buf++);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/trees.h Thu Dec 15 15:57:51 2011 -0800
@@ -0,0 +1,152 @@
+/*
+ * 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.
+ */
+
+/* header created automatically with -DGEN_TREES_H */
+
+local const ct_data static_ltree[L_CODES+2] = {
+{{ 12},{ 8}}, {{140},{ 8}}, {{ 76},{ 8}}, {{204},{ 8}}, {{ 44},{ 8}},
+{{172},{ 8}}, {{108},{ 8}}, {{236},{ 8}}, {{ 28},{ 8}}, {{156},{ 8}},
+{{ 92},{ 8}}, {{220},{ 8}}, {{ 60},{ 8}}, {{188},{ 8}}, {{124},{ 8}},
+{{252},{ 8}}, {{ 2},{ 8}}, {{130},{ 8}}, {{ 66},{ 8}}, {{194},{ 8}},
+{{ 34},{ 8}}, {{162},{ 8}}, {{ 98},{ 8}}, {{226},{ 8}}, {{ 18},{ 8}},
+{{146},{ 8}}, {{ 82},{ 8}}, {{210},{ 8}}, {{ 50},{ 8}}, {{178},{ 8}},
+{{114},{ 8}}, {{242},{ 8}}, {{ 10},{ 8}}, {{138},{ 8}}, {{ 74},{ 8}},
+{{202},{ 8}}, {{ 42},{ 8}}, {{170},{ 8}}, {{106},{ 8}}, {{234},{ 8}},
+{{ 26},{ 8}}, {{154},{ 8}}, {{ 90},{ 8}}, {{218},{ 8}}, {{ 58},{ 8}},
+{{186},{ 8}}, {{122},{ 8}}, {{250},{ 8}}, {{ 6},{ 8}}, {{134},{ 8}},
+{{ 70},{ 8}}, {{198},{ 8}}, {{ 38},{ 8}}, {{166},{ 8}}, {{102},{ 8}},
+{{230},{ 8}}, {{ 22},{ 8}}, {{150},{ 8}}, {{ 86},{ 8}}, {{214},{ 8}},
+{{ 54},{ 8}}, {{182},{ 8}}, {{118},{ 8}}, {{246},{ 8}}, {{ 14},{ 8}},
+{{142},{ 8}}, {{ 78},{ 8}}, {{206},{ 8}}, {{ 46},{ 8}}, {{174},{ 8}},
+{{110},{ 8}}, {{238},{ 8}}, {{ 30},{ 8}}, {{158},{ 8}}, {{ 94},{ 8}},
+{{222},{ 8}}, {{ 62},{ 8}}, {{190},{ 8}}, {{126},{ 8}}, {{254},{ 8}},
+{{ 1},{ 8}}, {{129},{ 8}}, {{ 65},{ 8}}, {{193},{ 8}}, {{ 33},{ 8}},
+{{161},{ 8}}, {{ 97},{ 8}}, {{225},{ 8}}, {{ 17},{ 8}}, {{145},{ 8}},
+{{ 81},{ 8}}, {{209},{ 8}}, {{ 49},{ 8}}, {{177},{ 8}}, {{113},{ 8}},
+{{241},{ 8}}, {{ 9},{ 8}}, {{137},{ 8}}, {{ 73},{ 8}}, {{201},{ 8}},
+{{ 41},{ 8}}, {{169},{ 8}}, {{105},{ 8}}, {{233},{ 8}}, {{ 25},{ 8}},
+{{153},{ 8}}, {{ 89},{ 8}}, {{217},{ 8}}, {{ 57},{ 8}}, {{185},{ 8}},
+{{121},{ 8}}, {{249},{ 8}}, {{ 5},{ 8}}, {{133},{ 8}}, {{ 69},{ 8}},
+{{197},{ 8}}, {{ 37},{ 8}}, {{165},{ 8}}, {{101},{ 8}}, {{229},{ 8}},
+{{ 21},{ 8}}, {{149},{ 8}}, {{ 85},{ 8}}, {{213},{ 8}}, {{ 53},{ 8}},
+{{181},{ 8}}, {{117},{ 8}}, {{245},{ 8}}, {{ 13},{ 8}}, {{141},{ 8}},
+{{ 77},{ 8}}, {{205},{ 8}}, {{ 45},{ 8}}, {{173},{ 8}}, {{109},{ 8}},
+{{237},{ 8}}, {{ 29},{ 8}}, {{157},{ 8}}, {{ 93},{ 8}}, {{221},{ 8}},
+{{ 61},{ 8}}, {{189},{ 8}}, {{125},{ 8}}, {{253},{ 8}}, {{ 19},{ 9}},
+{{275},{ 9}}, {{147},{ 9}}, {{403},{ 9}}, {{ 83},{ 9}}, {{339},{ 9}},
+{{211},{ 9}}, {{467},{ 9}}, {{ 51},{ 9}}, {{307},{ 9}}, {{179},{ 9}},
+{{435},{ 9}}, {{115},{ 9}}, {{371},{ 9}}, {{243},{ 9}}, {{499},{ 9}},
+{{ 11},{ 9}}, {{267},{ 9}}, {{139},{ 9}}, {{395},{ 9}}, {{ 75},{ 9}},
+{{331},{ 9}}, {{203},{ 9}}, {{459},{ 9}}, {{ 43},{ 9}}, {{299},{ 9}},
+{{171},{ 9}}, {{427},{ 9}}, {{107},{ 9}}, {{363},{ 9}}, {{235},{ 9}},
+{{491},{ 9}}, {{ 27},{ 9}}, {{283},{ 9}}, {{155},{ 9}}, {{411},{ 9}},
+{{ 91},{ 9}}, {{347},{ 9}}, {{219},{ 9}}, {{475},{ 9}}, {{ 59},{ 9}},
+{{315},{ 9}}, {{187},{ 9}}, {{443},{ 9}}, {{123},{ 9}}, {{379},{ 9}},
+{{251},{ 9}}, {{507},{ 9}}, {{ 7},{ 9}}, {{263},{ 9}}, {{135},{ 9}},
+{{391},{ 9}}, {{ 71},{ 9}}, {{327},{ 9}}, {{199},{ 9}}, {{455},{ 9}},
+{{ 39},{ 9}}, {{295},{ 9}}, {{167},{ 9}}, {{423},{ 9}}, {{103},{ 9}},
+{{359},{ 9}}, {{231},{ 9}}, {{487},{ 9}}, {{ 23},{ 9}}, {{279},{ 9}},
+{{151},{ 9}}, {{407},{ 9}}, {{ 87},{ 9}}, {{343},{ 9}}, {{215},{ 9}},
+{{471},{ 9}}, {{ 55},{ 9}}, {{311},{ 9}}, {{183},{ 9}}, {{439},{ 9}},
+{{119},{ 9}}, {{375},{ 9}}, {{247},{ 9}}, {{503},{ 9}}, {{ 15},{ 9}},
+{{271},{ 9}}, {{143},{ 9}}, {{399},{ 9}}, {{ 79},{ 9}}, {{335},{ 9}},
+{{207},{ 9}}, {{463},{ 9}}, {{ 47},{ 9}}, {{303},{ 9}}, {{175},{ 9}},
+{{431},{ 9}}, {{111},{ 9}}, {{367},{ 9}}, {{239},{ 9}}, {{495},{ 9}},
+{{ 31},{ 9}}, {{287},{ 9}}, {{159},{ 9}}, {{415},{ 9}}, {{ 95},{ 9}},
+{{351},{ 9}}, {{223},{ 9}}, {{479},{ 9}}, {{ 63},{ 9}}, {{319},{ 9}},
+{{191},{ 9}}, {{447},{ 9}}, {{127},{ 9}}, {{383},{ 9}}, {{255},{ 9}},
+{{511},{ 9}}, {{ 0},{ 7}}, {{ 64},{ 7}}, {{ 32},{ 7}}, {{ 96},{ 7}},
+{{ 16},{ 7}}, {{ 80},{ 7}}, {{ 48},{ 7}}, {{112},{ 7}}, {{ 8},{ 7}},
+{{ 72},{ 7}}, {{ 40},{ 7}}, {{104},{ 7}}, {{ 24},{ 7}}, {{ 88},{ 7}},
+{{ 56},{ 7}}, {{120},{ 7}}, {{ 4},{ 7}}, {{ 68},{ 7}}, {{ 36},{ 7}},
+{{100},{ 7}}, {{ 20},{ 7}}, {{ 84},{ 7}}, {{ 52},{ 7}}, {{116},{ 7}},
+{{ 3},{ 8}}, {{131},{ 8}}, {{ 67},{ 8}}, {{195},{ 8}}, {{ 35},{ 8}},
+{{163},{ 8}}, {{ 99},{ 8}}, {{227},{ 8}}
+};
+
+local const ct_data static_dtree[D_CODES] = {
+{{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}},
+{{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}},
+{{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}},
+{{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}},
+{{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}},
+{{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}}
+};
+
+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,
+11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
+12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13,
+13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
+14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
+14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
+14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15,
+15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
+15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
+15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17,
+18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22,
+23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
+24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
+26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
+26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27,
+27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
+27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
+28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
+28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
+28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
+29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
+29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
+29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29
+};
+
+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,
+19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
+21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22,
+22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23,
+23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
+24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
+25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
+25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26,
+26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
+26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
+27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28
+};
+
+local const int base_length[LENGTH_CODES] = {
+0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56,
+64, 80, 96, 112, 128, 160, 192, 224, 0
+};
+
+local const int base_dist[D_CODES] = {
+ 0, 1, 2, 3, 4, 6, 8, 12, 16, 24,
+ 32, 48, 64, 96, 128, 192, 256, 384, 512, 768,
+ 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576
+};
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/uncompr.c Thu Dec 15 15:57:51 2011 -0800
@@ -0,0 +1,83 @@
+/*
+ * 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.
+ */
+
+/* uncompr.c -- decompress a memory buffer
+ * Copyright (C) 1995-2003, 2010 Jean-loup Gailly.
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+/* @(#) $Id$ */
+
+#define ZLIB_INTERNAL
+#include "zlib.h"
+
+/* ===========================================================================
+ 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.
+
+ 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.
+*/
+int ZEXPORT uncompress (dest, destLen, source, sourceLen)
+ Bytef *dest;
+ uLongf *destLen;
+ const Bytef *source;
+ uLong sourceLen;
+{
+ z_stream stream;
+ int err;
+
+ stream.next_in = (Bytef*)source;
+ stream.avail_in = (uInt)sourceLen;
+ /* Check for source > 64K on 16-bit machine: */
+ if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
+
+ stream.next_out = dest;
+ stream.avail_out = (uInt)*destLen;
+ if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
+
+ stream.zalloc = (alloc_func)0;
+ stream.zfree = (free_func)0;
+
+ err = inflateInit(&stream);
+ if (err != Z_OK) return err;
+
+ err = inflate(&stream, Z_FINISH);
+ if (err != Z_STREAM_END) {
+ inflateEnd(&stream);
+ if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0))
+ return Z_DATA_ERROR;
+ return err;
+ }
+ *destLen = (uLong)stream.total_out;
+
+ err = inflateEnd(&stream);
+ return err;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/zadler32.c Thu Dec 15 15:57:51 2011 -0800
@@ -0,0 +1,193 @@
+/*
+ * 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.
+ */
+
+/* adler32.c -- compute the Adler-32 checksum of a data stream
+ * Copyright (C) 1995-2007 Mark Adler
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+/* @(#) $Id$ */
+
+#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
+/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
+
+#define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;}
+#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1);
+#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2);
+#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4);
+#define DO16(buf) DO8(buf,0); DO8(buf,8);
+
+/* use NO_DIVIDE if your processor does not do division in hardware */
+#ifdef NO_DIVIDE
+# define MOD(a) \
+ do { \
+ if (a >= (BASE << 16)) a -= (BASE << 16); \
+ if (a >= (BASE << 15)) a -= (BASE << 15); \
+ if (a >= (BASE << 14)) a -= (BASE << 14); \
+ if (a >= (BASE << 13)) a -= (BASE << 13); \
+ if (a >= (BASE << 12)) a -= (BASE << 12); \
+ if (a >= (BASE << 11)) a -= (BASE << 11); \
+ if (a >= (BASE << 10)) a -= (BASE << 10); \
+ if (a >= (BASE << 9)) a -= (BASE << 9); \
+ if (a >= (BASE << 8)) a -= (BASE << 8); \
+ if (a >= (BASE << 7)) a -= (BASE << 7); \
+ if (a >= (BASE << 6)) a -= (BASE << 6); \
+ if (a >= (BASE << 5)) a -= (BASE << 5); \
+ if (a >= (BASE << 4)) a -= (BASE << 4); \
+ if (a >= (BASE << 3)) a -= (BASE << 3); \
+ if (a >= (BASE << 2)) a -= (BASE << 2); \
+ if (a >= (BASE << 1)) a -= (BASE << 1); \
+ if (a >= BASE) a -= BASE; \
+ } while (0)
+# define MOD4(a) \
+ do { \
+ if (a >= (BASE << 4)) a -= (BASE << 4); \
+ if (a >= (BASE << 3)) a -= (BASE << 3); \
+ if (a >= (BASE << 2)) a -= (BASE << 2); \
+ if (a >= (BASE << 1)) a -= (BASE << 1); \
+ if (a >= BASE) a -= BASE; \
+ } while (0)
+#else
+# define MOD(a) a %= BASE
+# define MOD4(a) a %= BASE
+#endif
+
+/* ========================================================================= */
+uLong ZEXPORT adler32(adler, buf, len)
+ uLong adler;
+ const Bytef *buf;
+ uInt len;
+{
+ unsigned long sum2;
+ unsigned n;
+
+ /* split Adler-32 into component sums */
+ sum2 = (adler >> 16) & 0xffff;
+ adler &= 0xffff;
+
+ /* in case user likes doing a byte at a time, keep it fast */
+ if (len == 1) {
+ adler += buf[0];
+ if (adler >= BASE)
+ adler -= BASE;
+ sum2 += adler;
+ if (sum2 >= BASE)
+ sum2 -= BASE;
+ return adler | (sum2 << 16);
+ }
+
+ /* initial Adler-32 value (deferred check for len == 1 speed) */
+ if (buf == Z_NULL)
+ return 1L;
+
+ /* in case short lengths are provided, keep it somewhat fast */
+ if (len < 16) {
+ while (len--) {
+ adler += *buf++;
+ sum2 += adler;
+ }
+ if (adler >= BASE)
+ adler -= BASE;
+ MOD4(sum2); /* only added so many BASE's */
+ return adler | (sum2 << 16);
+ }
+
+ /* do length NMAX blocks -- requires just one modulo operation */
+ while (len >= NMAX) {
+ len -= NMAX;
+ n = NMAX / 16; /* NMAX is divisible by 16 */
+ do {
+ DO16(buf); /* 16 sums unrolled */
+ buf += 16;
+ } while (--n);
+ MOD(adler);
+ MOD(sum2);
+ }
+
+ /* do remaining bytes (less than NMAX, still just one modulo) */
+ if (len) { /* avoid modulos if none remaining */
+ while (len >= 16) {
+ len -= 16;
+ DO16(buf);
+ buf += 16;
+ }
+ while (len--) {
+ adler += *buf++;
+ sum2 += adler;
+ }
+ MOD(adler);
+ MOD(sum2);
+ }
+
+ /* return recombined sums */
+ return adler | (sum2 << 16);
+}
+
+/* ========================================================================= */
+local uLong adler32_combine_(adler1, adler2, len2)
+ uLong adler1;
+ uLong adler2;
+ z_off64_t len2;
+{
+ unsigned long sum1;
+ unsigned long sum2;
+ unsigned rem;
+
+ /* the derivation of this formula is left as an exercise for the reader */
+ rem = (unsigned)(len2 % BASE);
+ sum1 = adler1 & 0xffff;
+ sum2 = rem * sum1;
+ 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;
+ 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);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/zconf.h Thu Dec 15 15:57:51 2011 -0800
@@ -0,0 +1,459 @@
+/*
+ * 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.
+ */
+
+/* zconf.h -- configuration of the zlib compression library
+ * Copyright (C) 1995-2010 Jean-loup Gailly.
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+/* @(#) $Id$ */
+
+#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.
+ * 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 /* 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 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
+
+/* all zlib typedefs in zlib.h and zconf.h */
+# define Byte z_Byte
+# 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 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)
+# define MSDOS
+#endif
+#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)
+# define OS2
+#endif
+#if defined(_WINDOWS) && !defined(WINDOWS)
+# define WINDOWS
+#endif
+#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)
+# ifndef WIN32
+# define WIN32
+# endif
+#endif
+#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)
+# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)
+# ifndef SYS16BIT
+# define SYS16BIT
+# endif
+# endif
+#endif
+
+/*
+ * Compile with -DMAXSEG_64K if the alloc function cannot allocate more
+ * than 64k bytes at a time (needed on systems with 16-bit int).
+ */
+#ifdef SYS16BIT
+# define MAXSEG_64K
+#endif
+#ifdef MSDOS
+# define UNALIGNED_OK
+#endif
+
+#ifdef __STDC_VERSION__
+# ifndef STDC
+# define STDC
+# endif
+# if __STDC_VERSION__ >= 199901L
+# ifndef STDC99
+# define STDC99
+# endif
+# endif
+#endif
+#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
+# define STDC
+#endif
+#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
+# define STDC
+#endif
+#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))
+# define STDC
+#endif
+#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))
+# define STDC
+#endif
+
+#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */
+# define STDC
+#endif
+
+#ifndef STDC
+# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
+# define const /* note: need a more gentle solution here */
+# endif
+#endif
+
+/* Some Mac compilers merge all .h files incorrectly: */
+#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)
+# define NO_DUMMY_DECL
+#endif
+
+/* Maximum value for memLevel in deflateInit2 */
+#ifndef MAX_MEM_LEVEL
+# ifdef MAXSEG_64K
+# define MAX_MEM_LEVEL 8
+# else
+# define MAX_MEM_LEVEL 9
+# endif
+#endif
+
+/* Maximum value for windowBits in deflateInit2 and inflateInit2.
+ * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
+ * created by gzip. (Files created by minigzip can still be extracted by
+ * gzip.)
+ */
+#ifndef MAX_WBITS
+# define MAX_WBITS 15 /* 32K LZ77 window */
+#endif
+
+/* The memory requirements for deflate are (in bytes):
+ (1 << (windowBits+2)) + (1 << (memLevel+9))
+ that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
+ plus a few kilobytes for small objects. For example, if you want to reduce
+ the default memory requirements from 256K to 128K, compile with
+ make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
+ Of course this will generally degrade compression (there's no free lunch).
+
+ The memory requirements for inflate are (in bytes) 1 << windowBits
+ that is, 32K for windowBits=15 (default value) plus a few kilobytes
+ for small objects.
+*/
+
+ /* Type declarations */
+
+#ifndef OF /* function prototypes */
+# ifdef STDC
+# define OF(args) args
+# else
+# define OF(args) ()
+# endif
+#endif
+
+/* The following definitions for FAR are needed only for MSDOS mixed
+ * model programming (small or medium model with some far allocations).
+ * This was tested only with MSC; for other MSDOS compilers you may have
+ * to define NO_MEMCPY in zutil.h. If you don't need the mixed model,
+ * just define FAR to be empty.
+ */
+#ifdef SYS16BIT
+# if defined(M_I86SM) || defined(M_I86MM)
+ /* MSC small or medium model */
+# define SMALL_MEDIUM
+# ifdef _MSC_VER
+# define FAR _far
+# else
+# define FAR far
+# endif
+# endif
+# if (defined(__SMALL__) || defined(__MEDIUM__))
+ /* Turbo C small or medium model */
+# define SMALL_MEDIUM
+# ifdef __BORLANDC__
+# define FAR _far
+# else
+# define FAR far
+# endif
+# endif
+#endif
+
+#if defined(WINDOWS) || defined(WIN32)
+ /* If building or using zlib as a DLL, define ZLIB_DLL.
+ * This is not mandatory, but it offers a little performance increase.
+ */
+# ifdef ZLIB_DLL
+# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
+# ifdef ZLIB_INTERNAL
+# define ZEXTERN extern __declspec(dllexport)
+# else
+# define ZEXTERN extern __declspec(dllimport)
+# endif
+# endif
+# endif /* ZLIB_DLL */
+ /* If building or using zlib with the WINAPI/WINAPIV calling convention,
+ * define ZLIB_WINAPI.
+ * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
+ */
+# ifdef ZLIB_WINAPI
+# ifdef FAR
+# undef FAR
+# endif
+# include <windows.h>
+ /* No need for _export, use ZLIB.DEF instead. */
+ /* For complete Windows compatibility, use WINAPI, not __stdcall. */
+# define ZEXPORT WINAPI
+# ifdef WIN32
+# define ZEXPORTVA WINAPIV
+# else
+# define ZEXPORTVA FAR CDECL
+# endif
+# endif
+#endif
+
+#if defined (__BEOS__)
+# ifdef ZLIB_DLL
+# ifdef ZLIB_INTERNAL
+# define ZEXPORT __declspec(dllexport)
+# define ZEXPORTVA __declspec(dllexport)
+# else
+# define ZEXPORT __declspec(dllimport)
+# define ZEXPORTVA __declspec(dllimport)
+# endif
+# endif
+#endif
+
+#ifndef ZEXTERN
+# define ZEXTERN extern
+#endif
+#ifndef ZEXPORT
+# define ZEXPORT
+#endif
+#ifndef ZEXPORTVA
+# define ZEXPORTVA
+#endif
+
+#ifndef FAR
+# define FAR
+#endif
+
+#if !defined(__MACTYPES__)
+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 */
+# define Bytef Byte FAR
+#else
+ typedef Byte FAR Bytef;
+#endif
+typedef char FAR charf;
+typedef int FAR intf;
+typedef uInt FAR uIntf;
+typedef uLong FAR uLongf;
+
+#ifdef STDC
+ typedef void const *voidpc;
+ typedef void FAR *voidpf;
+ typedef void *voidp;
+#else
+ typedef Byte const *voidpc;
+ typedef Byte FAR *voidpf;
+ typedef Byte *voidp;
+#endif
+
+#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
+#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")
+#endif
+
+#endif /* ZCONF_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/zcrc32.c Thu Dec 15 15:57:51 2011 -0800
@@ -0,0 +1,466 @@
+/*
+ * 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.
+ */
+
+/* crc32.c -- compute the CRC-32 of a data stream
+ * 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
+ * CRC methods: exclusive-oring 32 bits of data at a time, and pre-computing
+ * tables for updating the shift register in one step with three exclusive-ors
+ * instead of four steps with four exclusive-ors. This results in about a
+ * factor of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3.
+ */
+
+/* @(#) $Id$ */
+
+/*
+ Note on the use of DYNAMIC_CRC_TABLE: there is no mutex or semaphore
+ protection on the static variables used to control the first-use generation
+ of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should
+ first call get_crc_table() to initialize the tables before allowing more than
+ one thread to use crc32().
+ */
+
+#ifdef MAKECRCH
+# include <stdio.h>
+# ifndef DYNAMIC_CRC_TABLE
+# define DYNAMIC_CRC_TABLE
+# endif /* !DYNAMIC_CRC_TABLE */
+#endif /* MAKECRCH */
+
+#include "zutil.h" /* for STDC and FAR definitions */
+
+#define local static
+
+/* Find a four-byte integer type for crc32_little() and crc32_big(). */
+#ifndef NOBYFOUR
+# ifdef STDC /* need ANSI C limits.h to determine sizes */
+# include <limits.h>
+# define BYFOUR
+# if (UINT_MAX == 0xffffffffUL)
+ typedef unsigned int u4;
+# else
+# if (ULONG_MAX == 0xffffffffUL)
+ typedef unsigned long u4;
+# else
+# if (USHRT_MAX == 0xffffffffUL)
+ typedef unsigned short u4;
+# else
+# undef BYFOUR /* can't find a four-byte integer type! */
+# endif
+# endif
+# endif
+# endif /* STDC */
+#endif /* !NOBYFOUR */
+
+/* Definitions for doing the crc four data bytes at a time. */
+#ifdef BYFOUR
+# 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));
+ local unsigned long crc32_big OF((unsigned long,
+ const unsigned char FAR *, unsigned));
+# define TBLS 8
+#else
+# define TBLS 1
+#endif /* BYFOUR */
+
+/* Local functions for crc concatenation */
+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
+
+local volatile int crc_table_empty = 1;
+local unsigned long FAR crc_table[TBLS][256];
+local void make_crc_table OF((void));
+#ifdef MAKECRCH
+ local void write_table OF((FILE *, const unsigned long FAR *));
+#endif /* MAKECRCH */
+/*
+ Generate tables for a byte-wise 32-bit CRC calculation on the polynomial:
+ x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1.
+
+ Polynomials over GF(2) are represented in binary, one bit per coefficient,
+ with the lowest powers in the most significant bit. Then adding polynomials
+ is just exclusive-or, and multiplying a polynomial by x is a right shift by
+ one. If we call the above polynomial p, and represent a byte as the
+ polynomial q, also with the lowest power in the most significant bit (so the
+ byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p,
+ where a mod b means the remainder after dividing a by b.
+
+ This calculation is done using the shift-register method of multiplying and
+ taking the remainder. The register is initialized to zero, and for each
+ incoming bit, x^32 is added mod p to the register if the bit is a one (where
+ x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by
+ x (which is shifting right by one and adding x^32 mod p if the bit shifted
+ out is a one). We start with the highest power (least significant bit) of
+ q and repeat for all eight bits of q.
+
+ The first table is simply the CRC of all possible eight bit values. This is
+ all the information needed to generate CRCs on data a byte at a time for all
+ combinations of CRC register values and incoming bytes. The remaining tables
+ allow for word-at-a-time CRC calculation for both big-endian and little-
+ endian machines, where a word is four bytes.
+*/
+local void make_crc_table()
+{
+ unsigned long c;
+ int n, k;
+ unsigned long poly; /* polynomial exclusive-or pattern */
+ /* terms of polynomial defining this crc (except x^32): */
+ static volatile int first = 1; /* flag to limit concurrent making */
+ static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
+
+ /* See if another task is already doing this (not thread-safe, but better
+ than nothing -- significantly reduces duration of vulnerability in
+ case the advice about DYNAMIC_CRC_TABLE is ignored) */
+ if (first) {
+ first = 0;
+
+ /* make exclusive-or pattern from polynomial (0xedb88320UL) */
+ poly = 0UL;
+ for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++)
+ poly |= 1UL << (31 - p[n]);
+
+ /* generate a crc for every 8-bit value */
+ for (n = 0; n < 256; n++) {
+ c = (unsigned long)n;
+ for (k = 0; k < 8; k++)
+ c = c & 1 ? poly ^ (c >> 1) : c >> 1;
+ crc_table[0][n] = c;
+ }
+
+#ifdef BYFOUR
+ /* generate crc for each value followed by one, two, and three zeros,
+ and then the byte reversal of those as well as the first table */
+ for (n = 0; n < 256; n++) {
+ c = crc_table[0][n];
+ crc_table[4][n] = REV(c);
+ for (k = 1; k < 4; k++) {
+ c = crc_table[0][c & 0xff] ^ (c >> 8);
+ crc_table[k][n] = c;
+ crc_table[k + 4][n] = REV(c);
+ }
+ }
+#endif /* BYFOUR */
+
+ crc_table_empty = 0;
+ }
+ else { /* not first */
+ /* wait for the other guy to finish (not efficient, but rare) */
+ while (crc_table_empty)
+ ;
+ }
+
+#ifdef MAKECRCH
+ /* write out CRC tables to crc32.h */
+ {
+ FILE *out;
+
+ out = fopen("crc32.h", "w");
+ if (out == NULL) return;
+ fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n");
+ fprintf(out, " * Generated automatically by crc32.c\n */\n\n");
+ fprintf(out, "local const unsigned long FAR ");
+ fprintf(out, "crc_table[TBLS][256] =\n{\n {\n");
+ write_table(out, crc_table[0]);
+# ifdef BYFOUR
+ fprintf(out, "#ifdef BYFOUR\n");
+ for (k = 1; k < 8; k++) {
+ fprintf(out, " },\n {\n");
+ write_table(out, crc_table[k]);
+ }
+ fprintf(out, "#endif\n");
+# endif /* BYFOUR */
+ fprintf(out, " }\n};\n");
+ fclose(out);
+ }
+#endif /* MAKECRCH */
+}
+
+#ifdef MAKECRCH
+local void write_table(out, table)
+ FILE *out;
+ const unsigned long FAR *table;
+{
+ int n;
+
+ for (n = 0; n < 256; n++)
+ fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : " ", table[n],
+ n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", "));
+}
+#endif /* MAKECRCH */
+
+#else /* !DYNAMIC_CRC_TABLE */
+/* ========================================================================
+ * Tables of CRC-32s of all single-byte values, made by make_crc_table().
+ */
+#include "crc32.h"
+#endif /* DYNAMIC_CRC_TABLE */
+
+/* =========================================================================
+ * This function can be used by asm versions of crc32()
+ */
+const unsigned long FAR * ZEXPORT get_crc_table()
+{
+#ifdef DYNAMIC_CRC_TABLE
+ if (crc_table_empty)
+ make_crc_table();
+#endif /* DYNAMIC_CRC_TABLE */
+ return (const unsigned long FAR *)crc_table;
+}
+
+/* ========================================================================= */
+#define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8)
+#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1
+
+/* ========================================================================= */
+uLong ZEXPORT crc32(crc, buf, len)
+ uLong crc;
+ const unsigned char FAR *buf;
+ uInt len;
+{
+ if (buf == Z_NULL) return 0UL;
+
+#ifdef DYNAMIC_CRC_TABLE
+ if (crc_table_empty)
+ make_crc_table();
+#endif /* DYNAMIC_CRC_TABLE */
+
+#ifdef BYFOUR
+ if (sizeof(void *) == sizeof(ptrdiff_t)) {
+ u4 endian;
+
+ endian = 1;
+ if (*((unsigned char *)(&endian)))
+ return (uLong)crc32_little(crc, buf, len);
+ else
+ return (uLong)crc32_big(crc, buf, len);
+ }
+#endif /* BYFOUR */
+ crc = crc ^ 0xffffffffUL;
+ while (len >= 8) {
+ DO8;
+ len -= 8;
+ }
+ if (len) do {
+ DO1;
+ } while (--len);
+ return crc ^ 0xffffffffUL;
+}
+
+#ifdef BYFOUR
+
+/* ========================================================================= */
+#define DOLIT4 c ^= *buf4++; \
+ c = crc_table[3][c & 0xff] ^ crc_table[2][(c >> 8) & 0xff] ^ \
+ crc_table[1][(c >> 16) & 0xff] ^ crc_table[0][c >> 24]
+#define DOLIT32 DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4
+
+/* ========================================================================= */
+local unsigned long crc32_little(crc, buf, len)
+ unsigned long crc;
+ const unsigned char FAR *buf;
+ unsigned len;
+{
+ register u4 c;
+ register const u4 FAR *buf4;
+
+ c = (u4)crc;
+ c = ~c;
+ while (len && ((ptrdiff_t)buf & 3)) {
+ c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);
+ len--;
+ }
+
+ buf4 = (const u4 FAR *)(const void FAR *)buf;
+ while (len >= 32) {
+ DOLIT32;
+ len -= 32;
+ }
+ while (len >= 4) {
+ DOLIT4;
+ len -= 4;
+ }
+ buf = (const unsigned char FAR *)buf4;
+
+ if (len) do {
+ c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);
+ } while (--len);
+ c = ~c;
+ return (unsigned long)c;
+}
+
+/* ========================================================================= */
+#define DOBIG4 c ^= *++buf4; \
+ c = crc_table[4][c & 0xff] ^ crc_table[5][(c >> 8) & 0xff] ^ \
+ crc_table[6][(c >> 16) & 0xff] ^ crc_table[7][c >> 24]
+#define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4
+
+/* ========================================================================= */
+local unsigned long crc32_big(crc, buf, len)
+ unsigned long crc;
+ const unsigned char FAR *buf;
+ unsigned len;
+{
+ register u4 c;
+ register const u4 FAR *buf4;
+
+ c = REV((u4)crc);
+ c = ~c;
+ while (len && ((ptrdiff_t)buf & 3)) {
+ c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
+ len--;
+ }
+
+ buf4 = (const u4 FAR *)(const void FAR *)buf;
+ buf4--;
+ while (len >= 32) {
+ DOBIG32;
+ len -= 32;
+ }
+ while (len >= 4) {
+ DOBIG4;
+ len -= 4;
+ }
+ buf4++;
+ buf = (const unsigned char FAR *)buf4;
+
+ if (len) do {
+ c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
+ } while (--len);
+ c = ~c;
+ return (unsigned long)(REV(c));
+}
+
+#endif /* BYFOUR */
+
+#define GF2_DIM 32 /* dimension of GF(2) vectors (length of CRC) */
+
+/* ========================================================================= */
+local unsigned long gf2_matrix_times(mat, vec)
+ unsigned long *mat;
+ unsigned long vec;
+{
+ unsigned long sum;
+
+ sum = 0;
+ while (vec) {
+ if (vec & 1)
+ sum ^= *mat;
+ vec >>= 1;
+ mat++;
+ }
+ return sum;
+}
+
+/* ========================================================================= */
+local void gf2_matrix_square(square, mat)
+ unsigned long *square;
+ unsigned long *mat;
+{
+ int n;
+
+ for (n = 0; n < GF2_DIM; n++)
+ square[n] = gf2_matrix_times(mat, mat[n]);
+}
+
+/* ========================================================================= */
+local uLong crc32_combine_(crc1, crc2, len2)
+ uLong crc1;
+ uLong crc2;
+ 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 (also disallow negative lengths) */
+ if (len2 <= 0)
+ return crc1;
+
+ /* put operator for one zero bit in odd */
+ odd[0] = 0xedb88320UL; /* CRC-32 polynomial */
+ row = 1;
+ for (n = 1; n < GF2_DIM; n++) {
+ odd[n] = row;
+ row <<= 1;
+ }
+
+ /* put operator for two zero bits in even */
+ gf2_matrix_square(even, odd);
+
+ /* put operator for four zero bits in odd */
+ gf2_matrix_square(odd, even);
+
+ /* apply len2 zeros to crc1 (first square will put the operator for one
+ zero byte, eight zero bits, in even) */
+ do {
+ /* apply zeros operator for this bit of len2 */
+ gf2_matrix_square(even, odd);
+ if (len2 & 1)
+ crc1 = gf2_matrix_times(even, crc1);
+ len2 >>= 1;
+
+ /* if no more bits set, then done */
+ if (len2 == 0)
+ break;
+
+ /* another iteration of the loop with odd and even swapped */
+ gf2_matrix_square(odd, even);
+ if (len2 & 1)
+ crc1 = gf2_matrix_times(odd, crc1);
+ len2 >>= 1;
+
+ /* if no more bits set, then done */
+ } while (len2 != 0);
+
+ /* return combined crc */
+ 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);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/zlib.h Thu Dec 15 15:57:51 2011 -0800
@@ -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 */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/zutil.c Thu Dec 15 15:57:51 2011 -0800
@@ -0,0 +1,342 @@
+/*
+ * 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.
+ */
+
+/* zutil.c -- target dependent utility functions for the compression library
+ * Copyright (C) 1995-2005, 2010 Jean-loup Gailly.
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+/* @(#) $Id$ */
+
+#include "zutil.h"
+
+#ifndef NO_DUMMY_DECL
+struct internal_state {int dummy;}; /* for buggy compilers */
+#endif
+
+const char * const z_errmsg[10] = {
+"need dictionary", /* Z_NEED_DICT 2 */
+"stream end", /* Z_STREAM_END 1 */
+"", /* Z_OK 0 */
+"file error", /* Z_ERRNO (-1) */
+"stream error", /* Z_STREAM_ERROR (-2) */
+"data error", /* Z_DATA_ERROR (-3) */
+"insufficient memory", /* Z_MEM_ERROR (-4) */
+"buffer error", /* Z_BUF_ERROR (-5) */
+"incompatible version",/* Z_VERSION_ERROR (-6) */
+""};
+
+
+const char * ZEXPORT zlibVersion()
+{
+ return ZLIB_VERSION;
+}
+
+uLong ZEXPORT zlibCompileFlags()
+{
+ uLong flags;
+
+ flags = 0;
+ switch ((int)(sizeof(uInt))) {
+ case 2: break;
+ case 4: flags += 1; break;
+ case 8: flags += 2; break;
+ default: flags += 3;
+ }
+ switch ((int)(sizeof(uLong))) {
+ case 2: break;
+ case 4: flags += 1 << 2; break;
+ case 8: flags += 2 << 2; break;
+ default: flags += 3 << 2;
+ }
+ switch ((int)(sizeof(voidpf))) {
+ case 2: break;
+ case 4: flags += 1 << 4; break;
+ case 8: flags += 2 << 4; break;
+ default: flags += 3 << 4;
+ }
+ switch ((int)(sizeof(z_off_t))) {
+ case 2: break;
+ case 4: flags += 1 << 6; break;
+ case 8: flags += 2 << 6; break;
+ default: flags += 3 << 6;
+ }
+#ifdef DEBUG
+ flags += 1 << 8;
+#endif
+#if defined(ASMV) || defined(ASMINF)
+ flags += 1 << 9;
+#endif
+#ifdef ZLIB_WINAPI
+ flags += 1 << 10;
+#endif
+#ifdef BUILDFIXED
+ flags += 1 << 12;
+#endif
+#ifdef DYNAMIC_CRC_TABLE
+ flags += 1 << 13;
+#endif
+#ifdef NO_GZCOMPRESS
+ flags += 1L << 16;
+#endif
+#ifdef NO_GZIP
+ flags += 1L << 17;
+#endif
+#ifdef PKZIP_BUG_WORKAROUND
+ flags += 1L << 20;
+#endif
+#ifdef FASTEST
+ flags += 1L << 21;
+#endif
+#ifdef STDC
+# ifdef NO_vsnprintf
+ flags += 1L << 25;
+# ifdef HAS_vsprintf_void
+ flags += 1L << 26;
+# endif
+# else
+# ifdef HAS_vsnprintf_void
+ flags += 1L << 26;
+# endif
+# endif
+#else
+ flags += 1L << 24;
+# ifdef NO_snprintf
+ flags += 1L << 25;
+# ifdef HAS_sprintf_void
+ flags += 1L << 26;
+# endif
+# else
+# ifdef HAS_snprintf_void
+ flags += 1L << 26;
+# endif
+# endif
+#endif
+ return flags;
+}
+
+#ifdef DEBUG
+
+# ifndef verbose
+# define verbose 0
+# endif
+int ZLIB_INTERNAL z_verbose = verbose;
+
+void ZLIB_INTERNAL z_error (m)
+ char *m;
+{
+ fprintf(stderr, "%s\n", m);
+ exit(1);
+}
+#endif
+
+/* exported to allow conversion of error code to string for compress() and
+ * uncompress()
+ */
+const char * ZEXPORT zError(err)
+ int err;
+{
+ return ERR_MSG(err);
+}
+
+#if defined(_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.
+ */
+ int errno = 0;
+#endif
+
+#ifndef HAVE_MEMCPY
+
+void ZLIB_INTERNAL zmemcpy(dest, source, len)
+ Bytef* dest;
+ const Bytef* source;
+ uInt len;
+{
+ if (len == 0) return;
+ do {
+ *dest++ = *source++; /* ??? to be unrolled */
+ } while (--len != 0);
+}
+
+int ZLIB_INTERNAL zmemcmp(s1, s2, len)
+ const Bytef* s1;
+ const Bytef* s2;
+ uInt len;
+{
+ uInt j;
+
+ for (j = 0; j < len; j++) {
+ if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1;
+ }
+ return 0;
+}
+
+void ZLIB_INTERNAL zmemzero(dest, len)
+ Bytef* dest;
+ uInt len;
+{
+ if (len == 0) return;
+ do {
+ *dest++ = 0; /* ??? to be unrolled */
+ } while (--len != 0);
+}
+#endif
+
+
+#ifdef SYS16BIT
+
+#ifdef __TURBOC__
+/* Turbo C in 16-bit mode */
+
+# define MY_ZCALLOC
+
+/* Turbo C malloc() does not allow dynamic allocation of 64K bytes
+ * and farmalloc(64K) returns a pointer with an offset of 8, so we
+ * must fix the pointer. Warning: the pointer must be put back to its
+ * original form in order to free it, use zcfree().
+ */
+
+#define MAX_PTR 10
+/* 10*64K = 640K */
+
+local int next_ptr = 0;
+
+typedef struct ptr_table_s {
+ voidpf org_ptr;
+ voidpf new_ptr;
+} ptr_table;
+
+local ptr_table table[MAX_PTR];
+/* This table is used to remember the original form of pointers
+ * to large buffers (64K). Such pointers are normalized with a zero offset.
+ * Since MSDOS is not a preemptive multitasking OS, this table is not
+ * protected from concurrent access. This hack doesn't work anyway on
+ * a protected system like OS/2. Use Microsoft C instead.
+ */
+
+voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items, unsigned size)
+{
+ voidpf buf = opaque; /* just to make some compilers happy */
+ ulg bsize = (ulg)items*size;
+
+ /* If we allocate less than 65520 bytes, we assume that farmalloc
+ * will return a usable pointer which doesn't have to be normalized.
+ */
+ if (bsize < 65520L) {
+ buf = farmalloc(bsize);
+ if (*(ush*)&buf != 0) return buf;
+ } else {
+ buf = farmalloc(bsize + 16L);
+ }
+ if (buf == NULL || next_ptr >= MAX_PTR) return NULL;
+ table[next_ptr].org_ptr = buf;
+
+ /* Normalize the pointer to seg:0 */
+ *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4;
+ *(ush*)&buf = 0;
+ table[next_ptr++].new_ptr = buf;
+ return buf;
+}
+
+void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)
+{
+ int n;
+ if (*(ush*)&ptr != 0) { /* object < 64K */
+ farfree(ptr);
+ return;
+ }
+ /* Find the original pointer */
+ for (n = 0; n < next_ptr; n++) {
+ if (ptr != table[n].new_ptr) continue;
+
+ farfree(table[n].org_ptr);
+ while (++n < next_ptr) {
+ table[n-1] = table[n];
+ }
+ next_ptr--;
+ return;
+ }
+ ptr = opaque; /* just to make some compilers happy */
+ Assert(0, "zcfree: ptr not found");
+}
+
+#endif /* __TURBOC__ */
+
+
+#ifdef M_I86
+/* Microsoft C in 16-bit mode */
+
+# define MY_ZCALLOC
+
+#if (!defined(_MSC_VER) || (_MSC_VER <= 600))
+# define _halloc halloc
+# define _hfree hfree
+#endif
+
+voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, uInt items, uInt size)
+{
+ if (opaque) opaque = 0; /* to make compiler happy */
+ return _halloc((long)items, size);
+}
+
+void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)
+{
+ if (opaque) opaque = 0; /* to make compiler happy */
+ _hfree(ptr);
+}
+
+#endif /* M_I86 */
+
+#endif /* SYS16BIT */
+
+
+#ifndef MY_ZCALLOC /* Any system without a special alloc function */
+
+#ifndef STDC
+extern voidp malloc OF((uInt size));
+extern voidp calloc OF((uInt items, uInt size));
+extern void free OF((voidpf ptr));
+#endif
+
+voidpf ZLIB_INTERNAL zcalloc (opaque, items, size)
+ voidpf opaque;
+ unsigned items;
+ unsigned size;
+{
+ if (opaque) items += size - size; /* make compiler happy */
+ return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) :
+ (voidpf)calloc(items, size);
+}
+
+void ZLIB_INTERNAL zcfree (opaque, ptr)
+ voidpf opaque;
+ voidpf ptr;
+{
+ free(ptr);
+ if (opaque) return; /* make compiler happy */
+}
+
+#endif /* MY_ZCALLOC */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/native/java/util/zip/zlib-1.2.5/zutil.h Thu Dec 15 15:57:51 2011 -0800
@@ -0,0 +1,298 @@
+/*
+ * 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.
+ */
+
+/* zutil.h -- internal interface and configuration of the compression library
+ * Copyright (C) 1995-2010 Jean-loup Gailly.
+ * 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.
+ */
+
+/* @(#) $Id$ */
+
+#ifndef ZUTIL_H
+#define ZUTIL_H
+
+#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
+# if !(defined(_WIN32_WCE) && defined(_MSC_VER))
+# include <stddef.h>
+# endif
+# include <string.h>
+# include <stdlib.h>
+#endif
+
+#ifndef local
+# define local static
+#endif
+/* compile with -Dlocal if your debugger can't find static symbols */
+
+typedef unsigned char uch;
+typedef uch FAR uchf;
+typedef unsigned short ush;
+typedef ush FAR ushf;
+typedef unsigned long ulg;
+
+extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
+/* (size given to avoid silly warnings with Visual C++) */
+
+#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
+
+#define ERR_RETURN(strm,err) \
+ return (strm->msg = (char*)ERR_MSG(err), (err))
+/* To be used only when the state is known to be valid */
+
+ /* common constants */
+
+#ifndef DEF_WBITS
+# define DEF_WBITS MAX_WBITS
+#endif
+/* default windowBits for decompression. MAX_WBITS is for compression only */
+
+#if MAX_MEM_LEVEL >= 8
+# define DEF_MEM_LEVEL 8
+#else
+# define DEF_MEM_LEVEL MAX_MEM_LEVEL
+#endif
+/* default memLevel */
+
+#define STORED_BLOCK 0
+#define STATIC_TREES 1
+#define DYN_TREES 2
+/* The three kinds of block type */
+
+#define MIN_MATCH 3
+#define MAX_MATCH 258
+/* The minimum and maximum match lengths */
+
+#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
+
+ /* target dependencies */
+
+#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
+# define OS_CODE 0x00
+# if defined(__TURBOC__) || defined(__BORLANDC__)
+# 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 );
+# else
+# include <alloc.h>
+# endif
+# else /* MSC or DJGPP */
+# include <malloc.h>
+# endif
+#endif
+
+#ifdef AMIGA
+# define OS_CODE 0x01
+#endif
+
+#if defined(VAXC) || defined(VMS)
+# define OS_CODE 0x02
+# define F_OPEN(name, mode) \
+ fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
+#endif
+
+#if defined(ATARI) || defined(atarist)
+# define OS_CODE 0x05
+#endif
+
+#ifdef OS2
+# define OS_CODE 0x06
+# ifdef M_I86
+# include <malloc.h>
+# endif
+#endif
+
+#if defined(MACOS) || defined(TARGET_OS_MAC)
+# define OS_CODE 0x07
+# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
+# include <unix.h> /* for fdopen */
+# else
+# ifndef fdopen
+# define fdopen(fd,mode) NULL /* No fdopen() */
+# endif
+# endif
+#endif
+
+#ifdef TOPS20
+# define OS_CODE 0x0a
+#endif
+
+#ifdef WIN32
+# ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */
+# define OS_CODE 0x0b
+# endif
+#endif
+
+#ifdef __50SERIES /* Prime/PRIMOS */
+# define OS_CODE 0x0f
+#endif
+
+#if defined(_BEOS_) || defined(RISCOS)
+# define fdopen(fd,mode) NULL /* No fdopen() */
+#endif
+
+#if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX
+# if defined(_WIN32_WCE)
+# define fdopen(fd,mode) NULL /* No fdopen() */
+# ifndef _PTRDIFF_T_DEFINED
+ typedef int ptrdiff_t;
+# define _PTRDIFF_T_DEFINED
+# endif
+# else
+# define fdopen(fd,type) _fdopen(fd,type)
+# 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
+# define OS_CODE 0x03 /* assume Unix */
+#endif
+
+#ifndef F_OPEN
+# define F_OPEN(name, mode) fopen((name), (mode))
+#endif
+
+ /* functions */
+
+#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550)
+# ifndef HAVE_VSNPRINTF
+# define HAVE_VSNPRINTF
+# endif
+#endif
+#if defined(__CYGWIN__)
+# ifndef HAVE_VSNPRINTF
+# define HAVE_VSNPRINTF
+# endif
+#endif
+#ifndef HAVE_VSNPRINTF
+# ifdef MSDOS
+ /* vsnprintf may exist on some MS-DOS compilers (DJGPP?),
+ but for now we just assume it doesn't. */
+# define NO_vsnprintf
+# endif
+# ifdef __TURBOC__
+# define NO_vsnprintf
+# endif
+# ifdef WIN32
+ /* In Win32, vsnprintf is available as the "non-ANSI" _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
+# define NO_vsnprintf
+# endif
+#endif
+#ifdef VMS
+# define NO_vsnprintf
+#endif
+
+#if defined(pyr)
+# define NO_MEMCPY
+#endif
+#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
+ /* Use our own functions for small and medium model with MSC <= 5.0.
+ * You may have to use the same strategy for Borland C (untested).
+ * The __SC__ check is for Symantec.
+ */
+# define NO_MEMCPY
+#endif
+#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
+# define HAVE_MEMCPY
+#endif
+#ifdef HAVE_MEMCPY
+# ifdef SMALL_MEDIUM /* MSDOS small or medium model */
+# define zmemcpy _fmemcpy
+# define zmemcmp _fmemcmp
+# define zmemzero(dest, len) _fmemset(dest, 0, len)
+# else
+# define zmemcpy memcpy
+# define zmemcmp memcmp
+# define zmemzero(dest, len) memset(dest, 0, len)
+# endif
+#else
+ 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 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 ;}
+# define Tracevv(x) {if (z_verbose>1) fprintf x ;}
+# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
+# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
+#else
+# define Assert(cond,msg)
+# define Trace(x)
+# define Tracev(x)
+# define Tracevv(x)
+# define Tracec(c,x)
+# define Tracecv(c,x)
+#endif
+
+
+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))
+#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
+#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
+
+#endif /* ZUTIL_H */
--- a/jdk/src/solaris/classes/sun/awt/X11/ListHelper.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/solaris/classes/sun/awt/X11/ListHelper.java Thu Dec 15 15:57:51 2011 -0800
@@ -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
--- a/jdk/src/solaris/classes/sun/awt/X11/XEmbedCanvasPeer.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/solaris/classes/sun/awt/X11/XEmbedCanvasPeer.java Thu Dec 15 15:57:51 2011 -0800
@@ -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.*;
--- a/jdk/src/solaris/classes/sun/awt/X11/XEmbedChildProxyPeer.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/solaris/classes/sun/awt/X11/XEmbedChildProxyPeer.java Thu Dec 15 15:57:51 2011 -0800
@@ -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;
--- a/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java Thu Dec 15 15:57:51 2011 -0800
@@ -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;
}
--- a/jdk/src/solaris/classes/sun/awt/X11/XWindowPeer.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/solaris/classes/sun/awt/X11/XWindowPeer.java Thu Dec 15 15:57:51 2011 -0800
@@ -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();
--- a/jdk/src/solaris/classes/sun/awt/X11GraphicsDevice.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/solaris/classes/sun/awt/X11GraphicsDevice.java Thu Dec 15 15:57:51 2011 -0800
@@ -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();
--- a/jdk/src/solaris/classes/sun/awt/motif/AWTLockAccess.java Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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();
-}
--- a/jdk/src/solaris/classes/sun/awt/motif/MFontConfiguration.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/solaris/classes/sun/awt/motif/MFontConfiguration.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
--- a/jdk/src/solaris/classes/sun/awt/motif/MFontPeer.java Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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';
- }
-}
--- a/jdk/src/solaris/classes/sun/awt/motif/MToolkit.java Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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
--- a/jdk/src/solaris/classes/sun/awt/motif/MToolkitThreadBlockedHandler.java Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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();
-}
--- a/jdk/src/solaris/classes/sun/awt/motif/MWindowAttributes.java Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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;
- }
-}
--- a/jdk/src/solaris/classes/sun/awt/motif/X11FontMetrics.java Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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;
- }
-}
--- a/jdk/src/solaris/classes/sun/java2d/x11/X11Renderer.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/solaris/classes/sun/java2d/x11/X11Renderer.java Thu Dec 15 15:57:51 2011 -0800
@@ -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;
--- a/jdk/src/solaris/classes/sun/java2d/x11/X11SurfaceData.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/solaris/classes/sun/java2d/x11/X11SurfaceData.java Thu Dec 15 15:57:51 2011 -0800
@@ -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)))
{
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/solaris/native/sun/awt/HeadlessToolkit.c Thu Dec 15 15:57:51 2011 -0800
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+
+#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
--- a/jdk/src/solaris/native/sun/awt/MouseInfo.c Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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 ;
-
-}
--- a/jdk/src/solaris/native/sun/awt/XDrawingArea.c Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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;
-}
--- a/jdk/src/solaris/native/sun/awt/XDrawingArea.h Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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_ */
--- a/jdk/src/solaris/native/sun/awt/XDrawingAreaP.h Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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_ */
--- a/jdk/src/solaris/native/sun/awt/awt.h Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/solaris/native/sun/awt/awt.h Thu Dec 15 15:57:51 2011 -0800
@@ -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 */
--- a/jdk/src/solaris/native/sun/awt/awt_AWTEvent.c Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/solaris/native/sun/awt/awt_AWTEvent.c Thu Dec 15 15:57:51 2011 -0800
@@ -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
--- a/jdk/src/solaris/native/sun/awt/awt_Component.h Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/solaris/native/sun/awt/awt_Component.h Thu Dec 15 15:57:51 2011 -0800
@@ -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
-
--- a/jdk/src/solaris/native/sun/awt/awt_Cursor.h Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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 */
--- a/jdk/src/solaris/native/sun/awt/awt_DrawingSurface.c Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/solaris/native/sun/awt/awt_DrawingSurface.c Thu Dec 15 15:57:51 2011 -0800
@@ -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");
--- a/jdk/src/solaris/native/sun/awt/awt_Font.c Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/solaris/native/sun/awt/awt_Font.c Thu Dec 15 15:57:51 2011 -0800
@@ -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)
--- a/jdk/src/solaris/native/sun/awt/awt_Font.h Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/solaris/native/sun/awt/awt_Font.h Thu Dec 15 15:57:51 2011 -0800
@@ -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;
};
--- a/jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/solaris/native/sun/awt/awt_GraphicsEnv.c Thu Dec 15 15:57:51 2011 -0800
@@ -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)) {
--- a/jdk/src/solaris/native/sun/awt/awt_InputMethod.c Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/solaris/native/sun/awt/awt_InputMethod.c Thu Dec 15 15:57:51 2011 -0800
@@ -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
--- a/jdk/src/solaris/native/sun/awt/awt_KeyboardFocusManager.h Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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;
-};
--- a/jdk/src/solaris/native/sun/awt/awt_MToolkit.c Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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 */
--- a/jdk/src/solaris/native/sun/awt/awt_MToolkit.h Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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_ */
--- a/jdk/src/solaris/native/sun/awt/awt_MenuItem.h Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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;
-};
--- a/jdk/src/solaris/native/sun/awt/awt_PopupMenu.h Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +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.
- */
-
-/* methodsIDs for MPopupMenuPeer methods that may be accessed from C */
-struct MPopupMenuPeerIDs {
- jmethodID destroyNativeWidgetAfterGettingTreeLock;
-};
--- a/jdk/src/solaris/native/sun/awt/awt_Robot.c Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/solaris/native/sun/awt/awt_Robot.c Thu Dec 15 15:57:51 2011 -0800
@@ -28,7 +28,6 @@
#endif
#include "awt_p.h"
-#include "awt_Component.h"
#include "awt_GraphicsEnv.h"
#define XK_MISCELLANY
#include <X11/keysymdef.h>
--- a/jdk/src/solaris/native/sun/awt/awt_TopLevel.h Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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_ */
--- a/jdk/src/solaris/native/sun/awt/awt_Window.h Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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;
-};
--- a/jdk/src/solaris/native/sun/awt/awt_mgrsel.c Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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;
-}
--- a/jdk/src/solaris/native/sun/awt/awt_mgrsel.h Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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_ */
--- a/jdk/src/solaris/native/sun/awt/awt_motif.h Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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_ */
--- a/jdk/src/solaris/native/sun/awt/awt_p.h Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/solaris/native/sun/awt/awt_p.h Thu Dec 15 15:57:51 2011 -0800
@@ -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_ */
--- a/jdk/src/solaris/native/sun/awt/awt_util.c Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/solaris/native/sun/awt/awt_util.c Thu Dec 15 15:57:51 2011 -0800
@@ -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
-}
--- a/jdk/src/solaris/native/sun/awt/awt_util.h Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/solaris/native/sun/awt/awt_util.h Thu Dec 15 15:57:51 2011 -0800
@@ -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_ */
--- a/jdk/src/solaris/native/sun/awt/awt_wm.c Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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();
-}
--- a/jdk/src/solaris/native/sun/awt/awt_wm.h Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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_ */
--- a/jdk/src/solaris/native/sun/awt/awt_xembed.h Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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
--- a/jdk/src/solaris/native/sun/awt/awt_xembed_server.c Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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();
-}
--- a/jdk/src/solaris/native/sun/awt/awt_xembed_server.h Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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
--- a/jdk/src/solaris/native/sun/awt/canvas.h Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/solaris/native/sun/awt/canvas.h Thu Dec 15 15:57:51 2011 -0800
@@ -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_ */
--- a/jdk/src/solaris/native/sun/awt/multi_font.c Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/solaris/native/sun/awt/multi_font.c Thu Dec 15 15:57:51 2011 -0800
@@ -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;
--- a/jdk/src/solaris/native/sun/awt/multi_font.h Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/solaris/native/sun/awt/multi_font.h Thu Dec 15 15:57:51 2011 -0800
@@ -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,
--- a/jdk/src/solaris/native/sun/java2d/opengl/GLXSurfaceData.c Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/solaris/native/sun/java2d/opengl/GLXSurfaceData.c Thu Dec 15 15:57:51 2011 -0800
@@ -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;
--- a/jdk/src/solaris/native/sun/java2d/opengl/GLXSurfaceData.h Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/solaris/native/sun/java2d/opengl/GLXSurfaceData.h Thu Dec 15 15:57:51 2011 -0800
@@ -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;
--- a/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.c Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.c Thu Dec 15 15:57:51 2011 -0800
@@ -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,
- ¤t_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,
- ¤t_window,
- &ignore_children,
- &ignore_uint);
- XFree(ignore_children);
- }
-
- b->x1 = x1;
- b->y1 = y1;
- b->x2 = x2;
- b->y2 = y2;
-#endif
return TRUE;
}
--- a/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.h Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.h Thu Dec 15 15:57:51 2011 -0800
@@ -30,6 +30,10 @@
#include <jdga.h>
+#ifdef HEADLESS
+#include "GLXGraphicsConfig.h"
+#endif
+
#include <X11/extensions/Xrender.h>
/**
--- a/jdk/src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c Thu Dec 15 15:57:51 2011 -0800
@@ -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;
--- a/jdk/src/solaris/native/sun/xawt/XToolkit.c Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/solaris/native/sun/xawt/XToolkit.c Thu Dec 15 15:57:51 2011 -0800
@@ -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;
+}
--- a/jdk/src/windows/native/java/io/io_util_md.c Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/windows/native/java/io/io_util_md.c Thu Dec 15 15:57:51 2011 -0800
@@ -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);
}
--- a/jdk/src/windows/native/java/io/io_util_md.h Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/src/windows/native/java/io/io_util_md.h Thu Dec 15 15:57:51 2011 -0800
@@ -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);
--- a/jdk/test/ProblemList.txt Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/test/ProblemList.txt Thu Dec 15 15:57:51 2011 -0800
@@ -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
############################################################################
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/print/PaintSetEnabledDeadlock/PaintSetEnabledDeadlock.java Thu Dec 15 15:57:51 2011 -0800
@@ -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();
+ }
+ }
+}
--- a/jdk/test/java/beans/Beans/6669869/TestDesignTime.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/test/java/beans/Beans/6669869/TestDesignTime.java Thu Dec 15 15:57:51 2011 -0800
@@ -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");
}
--- a/jdk/test/java/beans/Beans/6669869/TestGuiAvailable.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/test/java/beans/Beans/6669869/TestGuiAvailable.java Thu Dec 15 15:57:51 2011 -0800
@@ -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");
}
--- a/jdk/test/java/beans/Introspector/6380849/TestBeanInfo.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/test/java/beans/Introspector/6380849/TestBeanInfo.java Thu Dec 15 15:57:51 2011 -0800
@@ -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;
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/beans/Introspector/7064279/Test7064279.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
+ }
+}
Binary file jdk/test/java/beans/Introspector/7064279/test.jar has changed
--- a/jdk/test/java/beans/Introspector/Test6660539.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/test/java/beans/Introspector/Test6660539.java Thu Dec 15 15:57:51 2011 -0800
@@ -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");
--- a/jdk/test/java/beans/Introspector/TestTypeResolver.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/test/java/beans/Introspector/TestTypeResolver.java Thu Dec 15 15:57:51 2011 -0800
@@ -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<?>> {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/beans/PropertyChangeSupport/Test7087429.java Thu Dec 15 15:57:51 2011 -0800
@@ -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");
+ }
+}
--- a/jdk/test/java/beans/PropertyEditor/6380849/TestPropertyEditor.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/test/java/beans/PropertyEditor/6380849/TestPropertyEditor.java Thu Dec 15 15:57:51 2011 -0800
@@ -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;
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/beans/PropertyEditor/Test7087876.java Thu Dec 15 15:57:51 2011 -0800
@@ -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() {
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/beans/XMLEncoder/Test7092744.java Thu Dec 15 15:57:51 2011 -0800
@@ -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;
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/String/CaseInsensitiveComparator.java Thu Dec 15 15:57:51 2011 -0800
@@ -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!");
+ }
+ }
+}
--- a/jdk/test/java/nio/channels/AsynchronousSocketChannel/Basic.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/test/java/nio/channels/AsynchronousSocketChannel/Basic.java Thu Dec 15 15:57:51 2011 -0800
@@ -63,7 +63,9 @@
testRead3();
testWrite1();
testWrite2();
- testTimeout();
+ // skip timeout tests until 7052549 is fixed
+ if (!System.getProperty("os.name").startsWith("Windows"))
+ testTimeout();
testShutdown();
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/MissingFormatArgumentException/GetFormatSpecifier.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
+ }
+ }
+ }
+}
--- a/jdk/test/java/util/ResourceBundle/Control/ExpirationTest.java Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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));
- }
- }
-}
--- a/jdk/test/java/util/ResourceBundle/Control/ExpirationTest.sh Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/zip/DeInflate.java Thu Dec 15 15:57:51 2011 -0800
@@ -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();
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/zip/TimeChecksum.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
+ }
+ }
+}
--- a/jdk/test/java/util/zip/ZipFile/ClearStaleZipFileInputStreams.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/test/java/util/zip/ZipFile/ClearStaleZipFileInputStreams.java Thu Dec 15 15:57:51 2011 -0800
@@ -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();
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JScrollBar/4865918/bug4865918.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JTabbedPane/4624207/bug4624207.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JTable/6263446/bug6263446.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/PopupFactory/6276087/NonOpaquePopupMenuTest.java Thu Dec 15 15:57:51 2011 -0800
@@ -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];
+
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/plaf/metal/MetalLookAndFeel/5073047/bug5073047.java Thu Dec 15 15:57:51 2011 -0800
@@ -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;
+ }
+ }
+}
--- a/jdk/test/javax/swing/regtesthelpers/Util.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/test/javax/swing/regtesthelpers/Util.java Thu Dec 15 15:57:51 2011 -0800
@@ -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]);
+ }
+ }
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/text/DefaultCaret/6938583/bug6938583.java Thu Dec 15 15:57:51 2011 -0800
@@ -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));
+ }
+ });
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/text/DefaultEditorKit/4278839/bug4278839.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/text/JTextComponent/5074573/bug5074573.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/text/html/HTMLEditorKit/5043626/bug5043626.java Thu Dec 15 15:57:51 2011 -0800
@@ -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());
+ }
+}
--- a/jdk/test/sun/misc/JarIndex/metaInfFilenames/Basic.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/test/sun/misc/JarIndex/metaInfFilenames/Basic.java Thu Dec 15 15:57:51 2011 -0800
@@ -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) {
--- a/jdk/test/sun/security/krb5/auto/CrossRealm.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/test/sun/security/krb5/auto/CrossRealm.java Thu Dec 15 15:57:51 2011 -0800
@@ -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" +
--- a/jdk/test/sun/security/krb5/auto/HttpNegotiateServer.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/test/sun/security/krb5/auto/HttpNegotiateServer.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
--- a/jdk/test/sun/security/krb5/auto/KDC.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/test/sun/security/krb5/auto/KDC.java Thu Dec 15 15:57:51 2011 -0800
@@ -1071,7 +1071,6 @@
}
cache.update(credentials);
cache.save();
- new File(ccache).deleteOnExit();
}
return result;
--- a/jdk/test/sun/security/krb5/auto/OkAsDelegateXRealm.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/test/sun/security/krb5/auto/OkAsDelegateXRealm.java Thu Dec 15 15:57:51 2011 -0800
@@ -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");
--- a/jdk/test/sun/security/krb5/auto/OneKDC.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/test/sun/security/krb5/auto/OneKDC.java Thu Dec 15 15:57:51 2011 -0800
@@ -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");
}
--- a/jdk/test/sun/security/krb5/auto/SSL.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/test/sun/security/krb5/auto/SSL.java Thu Dec 15 15:57:51 2011 -0800
@@ -96,7 +96,6 @@
" storeKey=true;\n};\n"
).getBytes());
fos.close();
- f.deleteOnExit();
Context c;
final Context s = Context.fromJAAS("ssl");
--- a/jdk/test/sun/security/krb5/auto/W83.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/test/sun/security/krb5/auto/W83.java Thu Dec 15 15:57:51 2011 -0800
@@ -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()) {
--- a/jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngineResult/Deserialize.java Thu Dec 15 15:47:47 2011 -0800
+++ b/jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngineResult/Deserialize.java Thu Dec 15 15:57:51 2011 -0800
@@ -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));
--- a/langtools/.hgtags Thu Dec 15 15:47:47 2011 -0800
+++ b/langtools/.hgtags Thu Dec 15 15:57:51 2011 -0800
@@ -137,4 +137,5 @@
ae25163501bc7477cd907e26a006a6f1b05fdb6d jdk8-b13
58f1325d72b2bacc901f5189ee5e4e81e81ea657 jdk8-b14
07599bd780cab1f40da7915e1dc6774629b0cf8c jdk8-b15
+1cbe86c11ba69521875c0b0357d7540781eb334d jdk8-b17
ec2c0973cc31e143cffc05ceb63d98fae76f97d4 jdk8-b16
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/source/tree/LambdaExpressionTree.java Thu Dec 15 15:57:51 2011 -0800
@@ -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();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/share/classes/com/sun/source/tree/MemberReferenceTree.java Thu Dec 15 15:57:51 2011 -0800
@@ -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();
+}
--- a/langtools/src/share/classes/com/sun/source/tree/Tree.java Thu Dec 15 15:47:47 2011 -0800
+++ b/langtools/src/share/classes/com/sun/source/tree/Tree.java Thu Dec 15 15:57:51 2011 -0800
@@ -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),
--- a/langtools/src/share/classes/com/sun/source/tree/TreeVisitor.java Thu Dec 15 15:47:47 2011 -0800
+++ b/langtools/src/share/classes/com/sun/source/tree/TreeVisitor.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
--- a/langtools/src/share/classes/com/sun/source/util/SimpleTreeVisitor.java Thu Dec 15 15:47:47 2011 -0800
+++ b/langtools/src/share/classes/com/sun/source/util/SimpleTreeVisitor.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
}
--- a/langtools/src/share/classes/com/sun/source/util/TreeScanner.java Thu Dec 15 15:47:47 2011 -0800
+++ b/langtools/src/share/classes/com/sun/source/util/TreeScanner.java Thu Dec 15 15:57:51 2011 -0800
@@ -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;
}
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Source.java Thu Dec 15 15:47:47 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Source.java Thu Dec 15 15:57:51 2011 -0800
@@ -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:
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java Thu Dec 15 15:47:47 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
--- a/langtools/src/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java Thu Dec 15 15:47:47 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java Thu Dec 15 15:57:51 2011 -0800
@@ -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();
--- a/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Thu Dec 15 15:47:47 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Thu Dec 15 15:57:51 2011 -0800
@@ -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) {
+ 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;
+ 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)));
+ }
+ } else if ((mode & TYPE) != 0 &&
+ (token.kind == IDENTIFIER || token.kind == ELLIPSIS)) {
+ //explicit lambda (w/ non-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();
- 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);
- }
- t = bracketsOpt(toP(t));
- } else if ((mode & EXPR) != 0) {
- mode = EXPR;
- JCExpression e = term2Rest(t1, TreeInfo.shiftPrec);
- t = F.at(pos1).Binary(op, t, e);
+ t = lambdaExpressionOrStatement(variableDeclaratorId(mods, t), pos);
+ break;
+ } else {
t = termRest(term1Rest(term2Rest(t, TreeInfo.orPrec)));
- } else {
- accept(GT);
}
}
- 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));
+ 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);
+ 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;
+ }
}
- accept(RBRACKET);
- }
- break loop;
- case LPAREN:
- if ((mode & EXPR) != 0) {
- mode = EXPR;
- t = arguments(typeArgs, t);
- typeArgs = null;
+ // 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;
}
- 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;
- 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
--- a/langtools/src/share/classes/com/sun/tools/javac/parser/Lexer.java Thu Dec 15 15:47:47 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/parser/Lexer.java Thu Dec 15 15:57:51 2011 -0800
@@ -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();
--- a/langtools/src/share/classes/com/sun/tools/javac/parser/Scanner.java Thu Dec 15 15:47:47 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/parser/Scanner.java Thu Dec 15 15:57:51 2011 -0800
@@ -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() {
--- a/langtools/src/share/classes/com/sun/tools/javac/parser/Tokens.java Thu Dec 15 15:47:47 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/parser/Tokens.java Thu Dec 15 15:57:51 2011 -0800
@@ -176,6 +176,8 @@
TRUE("true", Tag.NAMED),
FALSE("false", Tag.NAMED),
NULL("null", Tag.NAMED),
+ ARROW("->"),
+ HASH("#"),
LPAREN("("),
RPAREN(")"),
LBRACE("{"),
--- a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties Thu Dec 15 15:47:47 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties Thu Dec 15 15:57:51 2011 -0800
@@ -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)
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java Thu Dec 15 15:47:47 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java Thu Dec 15 15:57:51 2011 -0800
@@ -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); }
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/Pretty.java Thu Dec 15 15:47:47 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/Pretty.java Thu Dec 15 15:57:51 2011 -0800
@@ -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);
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeCopier.java Thu Dec 15 15:47:47 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeCopier.java Thu Dec 15 15:57:51 2011 -0800
@@ -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();
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java Thu Dec 15 15:47:47 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java Thu Dec 15 15:57:51 2011 -0800
@@ -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))
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java Thu Dec 15 15:47:47 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java Thu Dec 15 15:57:51 2011 -0800
@@ -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;
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeScanner.java Thu Dec 15 15:47:47 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeScanner.java Thu Dec 15 15:57:51 2011 -0800
@@ -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) {
}
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeTranslator.java Thu Dec 15 15:47:47 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeTranslator.java Thu Dec 15 15:57:51 2011 -0800
@@ -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;
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T7120266.java Thu Dec 15 15:57:51 2011 -0800
@@ -0,0 +1,34 @@
+/*
+ * 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 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) { };
+}
--- a/langtools/test/tools/javac/diags/examples/CatchWithoutTry.java Thu Dec 15 15:47:47 2011 -0800
+++ b/langtools/test/tools/javac/diags/examples/CatchWithoutTry.java Thu Dec 15 15:57:51 2011 -0800
@@ -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() {
--- a/langtools/test/tools/javac/diags/examples/IllegalChar.java Thu Dec 15 15:47:47 2011 -0800
+++ b/langtools/test/tools/javac/diags/examples/IllegalChar.java Thu Dec 15 15:57:51 2011 -0800
@@ -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 = `;
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/LambdaNotSupported.java Thu Dec 15 15:57:51 2011 -0800
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ */
+
+// key: compiler.err.lambda.not.supported.in.source
+// options: -source 7 -Xlint:-options
+
+class LambdaNotSupported {
+ S s = ()->{};
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/MethodReferencesNotSupported.java Thu Dec 15 15:57:51 2011 -0800
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ */
+
+// key: compiler.err.method.references.not.supported.in.source
+// options: -source 7 -Xlint:-options
+
+class MethodReferencesNotSupported {
+ S s = A#foo;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/NotAStatement.java Thu Dec 15 15:57:51 2011 -0800
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.not.stmt
+
+class NotAStatement {
+ void m() {
+ x + 1;
+ }
+}
--- a/langtools/test/tools/javac/generics/rare/6665356/T6665356.out Thu Dec 15 15:47:47 2011 -0800
+++ b/langtools/test/tools/javac/generics/rare/6665356/T6665356.out Thu Dec 15 15:57:51 2011 -0800
@@ -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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/LambdaParserTest.java Thu Dec 15 15:57:51 2011 -0800
@@ -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;
+ }
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/MethodReferenceParserTest.java Thu Dec 15 15:57:51 2011 -0800
@@ -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;
+ }
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/parser/JavacParserTest.java Thu Dec 15 15:57:51 2011 -0800
@@ -0,0 +1,883 @@
+/*
+ * 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 7073631
+ * @summary tests error and diagnostics positions
+ * @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;
+import com.sun.source.tree.MethodTree;
+import com.sun.source.tree.ModifiersTree;
+import com.sun.source.tree.StatementTree;
+import com.sun.source.tree.Tree;
+import com.sun.source.tree.Tree.Kind;
+import com.sun.source.tree.VariableTree;
+import com.sun.source.tree.WhileLoopTree;
+import com.sun.source.util.SourcePositions;
+import com.sun.source.util.TreeScanner;
+import com.sun.source.util.Trees;
+import com.sun.tools.javac.api.JavacTaskImpl;
+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;
+import javax.tools.Diagnostic;
+import javax.tools.DiagnosticCollector;
+import javax.tools.DiagnosticListener;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.ToolProvider;
+
+public class JavacParserTest extends TestCase {
+ final JavaCompiler tool;
+ public JavacParserTest(String testName) {
+ tool = ToolProvider.getSystemJavaCompiler();
+ System.out.println("java.home=" + System.getProperty("java.home"));
+ }
+
+ static class MyFileObject extends SimpleJavaFileObject {
+
+ private String text;
+
+ public MyFileObject(String text) {
+ super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+ this.text = text;
+ }
+
+ @Override
+ public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+ 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;
+
+ String code = "package test; public class Test {public Test() {super();}}";
+
+ JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
+ null, Arrays.asList(new MyFileObject(code)));
+ CompilationUnitTree cut = ct.parse().iterator().next();
+ SourcePositions pos = Trees.instance(ct).getSourcePositions();
+
+ MethodTree method =
+ (MethodTree) ((ClassTree) cut.getTypeDecls().get(0)).getMembers().get(0);
+ ExpressionStatementTree es =
+ (ExpressionStatementTree) method.getBody().getStatements().get(0);
+
+ final int esStartPos = code.indexOf(es.toString());
+ final int esEndPos = esStartPos + es.toString().length();
+ assertEquals("testPositionForSuperConstructorCalls",
+ esStartPos, pos.getStartPosition(cut, es));
+ assertEquals("testPositionForSuperConstructorCalls",
+ 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",
+ mitStartPos, pos.getStartPosition(cut, mit));
+ assertEquals("testPositionForSuperConstructorCalls",
+ mitEndPos, pos.getEndPosition(cut, mit));
+
+ final int methodStartPos = mitStartPos;
+ final int methodEndPos = methodStartPos + mit.getMethodSelect().toString().length();
+ assertEquals("testPositionForSuperConstructorCalls",
+ methodStartPos, pos.getStartPosition(cut, mit.getMethodSelect()));
+ assertEquals("testPositionForSuperConstructorCalls",
+ methodEndPos, pos.getEndPosition(cut, mit.getMethodSelect()));
+
+ }
+
+ public void testPositionForEnumModifiers() throws IOException {
+
+ String code = "package test; public enum Test {A;}";
+
+ JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
+ null, Arrays.asList(new MyFileObject(code)));
+ CompilationUnitTree cut = ct.parse().iterator().next();
+ SourcePositions pos = Trees.instance(ct).getSourcePositions();
+
+ ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
+ ModifiersTree mt = clazz.getModifiers();
+
+ assertEquals("testPositionForEnumModifiers",
+ 38 - 24, pos.getStartPosition(cut, mt));
+ assertEquals("testPositionForEnumModifiers",
+ 44 - 24, pos.getEndPosition(cut, mt));
+ }
+
+ public void testNewClassWithEnclosing() throws IOException {
+
+
+ String code = "package test; class Test { " +
+ "class d {} private void method() { " +
+ "Object o = Test.this.new d(); } }";
+
+ JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
+ null, Arrays.asList(new MyFileObject(code)));
+ CompilationUnitTree cut = ct.parse().iterator().next();
+ SourcePositions pos = Trees.instance(ct).getSourcePositions();
+
+ ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
+ ExpressionTree est =
+ ((VariableTree) ((MethodTree) clazz.getMembers().get(1)).getBody().getStatements().get(0)).getInitializer();
+
+ assertEquals("testNewClassWithEnclosing",
+ 97 - 24, pos.getStartPosition(cut, est));
+ assertEquals("testNewClassWithEnclosing",
+ 114 - 24, pos.getEndPosition(cut, est));
+ }
+
+ 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() {}}";
+
+ 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;
+ int condStartPos = code.indexOf("&&");
+ assertEquals("testPreferredPositionForBinaryOp",
+ condStartPos, condJC.pos);
+ }
+
+ public void testPositionBrokenSource126732a() throws IOException {
+ String[] commands = new String[]{
+ "return Runnable()",
+ "do { } while (true)",
+ "throw UnsupportedOperationException()",
+ "assert true",
+ "1 + 1",};
+
+ for (String command : commands) {
+
+ String code = "package test;\n"
+ + "public class Test {\n"
+ + " public static void test() {\n"
+ + " " + command + " {\n"
+ + " new Runnable() {\n"
+ + " };\n"
+ + " }\n"
+ + "}";
+ JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null,
+ null, null, Arrays.asList(new MyFileObject(code)));
+ CompilationUnitTree cut = ct.parse().iterator().next();
+
+ ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
+ MethodTree method = (MethodTree) clazz.getMembers().get(0);
+ List<? extends StatementTree> statements =
+ method.getBody().getStatements();
+
+ StatementTree ret = statements.get(0);
+ StatementTree block = statements.get(1);
+
+ Trees t = Trees.instance(ct);
+ int len = code.indexOf(command + " {") + (command + " ").length();
+ assertEquals(command, len,
+ t.getSourcePositions().getEndPosition(cut, ret));
+ assertEquals(command, len,
+ t.getSourcePositions().getStartPosition(cut, block));
+ }
+ }
+
+ public void testPositionBrokenSource126732b() throws IOException {
+ String[] commands = new String[]{
+ "break",
+ "break A",
+ "continue ",
+ "continue A",};
+
+ for (String command : commands) {
+
+ String code = "package test;\n"
+ + "public class Test {\n"
+ + " public static void test() {\n"
+ + " while (true) {\n"
+ + " " + command + " {\n"
+ + " new Runnable() {\n"
+ + " };\n"
+ + " }\n"
+ + " }\n"
+ + "}";
+
+ JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null,
+ null, null, Arrays.asList(new MyFileObject(code)));
+ CompilationUnitTree cut = ct.parse().iterator().next();
+
+ ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
+ MethodTree method = (MethodTree) clazz.getMembers().get(0);
+ List<? extends StatementTree> statements =
+ ((BlockTree) ((WhileLoopTree) method.getBody().getStatements().get(0)).getStatement()).getStatements();
+
+ StatementTree ret = statements.get(0);
+ StatementTree block = statements.get(1);
+
+ Trees t = Trees.instance(ct);
+ int len = code.indexOf(command + " {") + (command + " ").length();
+ assertEquals(command, len,
+ t.getSourcePositions().getEndPosition(cut, ret));
+ assertEquals(command, len,
+ t.getSourcePositions().getStartPosition(cut, block));
+ }
+ }
+
+ public void testErrorRecoveryForEnhancedForLoop142381() throws IOException {
+
+ String code = "package test; class Test { " +
+ "private void method() { " +
+ "java.util.Set<String> s = null; for (a : s) {} } }";
+
+ final List<Diagnostic<? extends JavaFileObject>> errors =
+ new LinkedList<Diagnostic<? extends JavaFileObject>>();
+
+ JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null,
+ new DiagnosticListener<JavaFileObject>() {
+ public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+ errors.add(diagnostic);
+ }
+ }, null, null, Arrays.asList(new MyFileObject(code)));
+
+ CompilationUnitTree cut = ct.parse().iterator().next();
+
+ ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
+ StatementTree forStatement =
+ ((MethodTree) clazz.getMembers().get(0)).getBody().getStatements().get(1);
+
+ assertEquals("testErrorRecoveryForEnhancedForLoop142381",
+ Kind.ENHANCED_FOR_LOOP, forStatement.getKind());
+ assertFalse("testErrorRecoveryForEnhancedForLoop142381", errors.isEmpty());
+ }
+
+ public void testPositionAnnotationNoPackage187551() throws IOException {
+
+ String code = "\n@interface Test {}";
+
+ JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
+ null, Arrays.asList(new MyFileObject(code)));
+
+ CompilationUnitTree cut = ct.parse().iterator().next();
+ ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
+ Trees t = Trees.instance(ct);
+
+ assertEquals("testPositionAnnotationNoPackage187551",
+ 1, t.getSourcePositions().getStartPosition(cut, clazz));
+ }
+
+ public void testPositionsSane() throws IOException {
+ performPositionsSanityTest("package test; class Test { " +
+ "private void method() { " +
+ "java.util.List<? extends java.util.List<? extends String>> l; " +
+ "} }");
+ performPositionsSanityTest("package test; class Test { " +
+ "private void method() { " +
+ "java.util.List<? super java.util.List<? super String>> l; " +
+ "} }");
+ performPositionsSanityTest("package test; class Test { " +
+ "private void method() { " +
+ "java.util.List<? super java.util.List<?>> l; } }");
+ }
+
+ private void performPositionsSanityTest(String code) throws IOException {
+
+ final List<Diagnostic<? extends JavaFileObject>> errors =
+ new LinkedList<Diagnostic<? extends JavaFileObject>>();
+
+ JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null,
+ new DiagnosticListener<JavaFileObject>() {
+
+ public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+ errors.add(diagnostic);
+ }
+ }, null, null, Arrays.asList(new MyFileObject(code)));
+
+ final CompilationUnitTree cut = ct.parse().iterator().next();
+ final Trees trees = Trees.instance(ct);
+
+ new TreeScanner<Void, Void>() {
+
+ private long parentStart = 0;
+ private long parentEnd = Integer.MAX_VALUE;
+
+ @Override
+ public Void scan(Tree node, Void p) {
+ if (node == null) {
+ return null;
+ }
+
+ long start = trees.getSourcePositions().getStartPosition(cut, node);
+
+ if (start == (-1)) {
+ return null; //synthetic tree
+ }
+ assertTrue(node.toString() + ":" + start + "/" + parentStart,
+ parentStart <= start);
+
+ long prevParentStart = parentStart;
+
+ parentStart = start;
+
+ long end = trees.getSourcePositions().getEndPosition(cut, node);
+
+ assertTrue(node.toString() + ":" + end + "/" + parentEnd,
+ end <= parentEnd);
+
+ long prevParentEnd = parentEnd;
+
+ parentEnd = end;
+
+ super.scan(node, p);
+
+ parentStart = prevParentStart;
+ parentEnd = prevParentEnd;
+
+ return null;
+ }
+
+ private void assertTrue(String message, boolean b) {
+ if (!b) fail(message);
+ }
+ }.scan(cut, null);
+ }
+
+ public void testCorrectWilcardPositions() throws IOException {
+ performWildcardPositionsTest("package test; import java.util.List; " +
+ "class Test { private void method() { List<? extends List<? extends String>> l; } }",
+
+ Arrays.asList("List<? extends List<? extends String>> l;",
+ "List<? extends List<? extends String>>",
+ "List",
+ "? extends List<? extends String>",
+ "List<? extends String>",
+ "List",
+ "? extends String",
+ "String"));
+ performWildcardPositionsTest("package test; import java.util.List; " +
+ "class Test { private void method() { List<? super List<? super String>> l; } }",
+
+ Arrays.asList("List<? super List<? super String>> l;",
+ "List<? super List<? super String>>",
+ "List",
+ "? super List<? super String>",
+ "List<? super String>",
+ "List",
+ "? super String",
+ "String"));
+ performWildcardPositionsTest("package test; import java.util.List; " +
+ "class Test { private void method() { List<? super List<?>> l; } }",
+
+ Arrays.asList("List<? super List<?>> l;",
+ "List<? super List<?>>",
+ "List",
+ "? super List<?>",
+ "List<?>",
+ "List",
+ "?"));
+ performWildcardPositionsTest("package test; import java.util.List; " +
+ "class Test { private void method() { " +
+ "List<? extends List<? extends List<? extends String>>> l; } }",
+
+ Arrays.asList("List<? extends List<? extends List<? extends String>>> l;",
+ "List<? extends List<? extends List<? extends String>>>",
+ "List",
+ "? extends List<? extends List<? extends String>>",
+ "List<? extends List<? extends String>>",
+ "List",
+ "? extends List<? extends String>",
+ "List<? extends String>",
+ "List",
+ "? extends String",
+ "String"));
+ performWildcardPositionsTest("package test; import java.util.List; " +
+ "class Test { private void method() { " +
+ "List<? extends List<? extends List<? extends String >>> l; } }",
+ Arrays.asList("List<? extends List<? extends List<? extends String >>> l;",
+ "List<? extends List<? extends List<? extends String >>>",
+ "List",
+ "? extends List<? extends List<? extends String >>",
+ "List<? extends List<? extends String >>",
+ "List",
+ "? extends List<? extends String >",
+ "List<? extends String >",
+ "List",
+ "? extends String",
+ "String"));
+ }
+
+ public void performWildcardPositionsTest(final String code,
+ List<String> golden) throws IOException {
+
+ final List<Diagnostic<? extends JavaFileObject>> errors =
+ new LinkedList<Diagnostic<? extends JavaFileObject>>();
+
+ JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null,
+ new DiagnosticListener<JavaFileObject>() {
+ public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+ errors.add(diagnostic);
+ }
+ }, null, null, Arrays.asList(new MyFileObject(code)));
+
+ final CompilationUnitTree cut = ct.parse().iterator().next();
+ final List<String> content = new LinkedList<String>();
+ final Trees trees = Trees.instance(ct);
+
+ new TreeScanner<Void, Void>() {
+ @Override
+ public Void scan(Tree node, Void p) {
+ if (node == null) {
+ return null;
+ }
+ long start = trees.getSourcePositions().getStartPosition(cut, node);
+
+ if (start == (-1)) {
+ return null; //synthetic tree
+ }
+ long end = trees.getSourcePositions().getEndPosition(cut, node);
+ String s = code.substring((int) start, (int) end);
+ content.add(s);
+
+ return super.scan(node, p);
+ }
+ }.scan(((MethodTree) ((ClassTree) cut.getTypeDecls().get(0)).getMembers().get(0)).getBody().getStatements().get(0), null);
+
+ assertEquals("performWildcardPositionsTest",golden.toString(),
+ content.toString());
+ }
+
+ public void testStartPositionForMethodWithoutModifiers() throws IOException {
+
+ String code = "package t; class Test { <T> void t() {} }";
+
+ JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
+ null, Arrays.asList(new MyFileObject(code)));
+ CompilationUnitTree cut = ct.parse().iterator().next();
+ ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
+ MethodTree mt = (MethodTree) clazz.getMembers().get(0);
+ Trees t = Trees.instance(ct);
+ int start = (int) t.getSourcePositions().getStartPosition(cut, mt);
+ int end = (int) t.getSourcePositions().getEndPosition(cut, mt);
+
+ assertEquals("testStartPositionForMethodWithoutModifiers",
+ "<T> void t() {}", code.substring(start, end));
+ }
+
+ public void testStartPositionEnumConstantInit() throws IOException {
+
+ String code = "package t; enum Test { AAA; }";
+
+ JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
+ null, Arrays.asList(new MyFileObject(code)));
+ CompilationUnitTree cut = ct.parse().iterator().next();
+ ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
+ VariableTree enumAAA = (VariableTree) clazz.getMembers().get(0);
+ Trees t = Trees.instance(ct);
+ int start = (int) t.getSourcePositions().getStartPosition(cut,
+ enumAAA.getInitializer());
+
+ assertEquals("testStartPositionEnumConstantInit", -1, start);
+ }
+
+ public void testVariableInIfThen1() throws IOException {
+
+ String code = "package t; class Test { " +
+ "private static void t(String name) { " +
+ "if (name != null) String nn = name.trim(); } }";
+
+ DiagnosticCollector<JavaFileObject> coll =
+ new DiagnosticCollector<JavaFileObject>();
+
+ JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, coll, null,
+ null, Arrays.asList(new MyFileObject(code)));
+
+ ct.parse();
+
+ List<String> codes = new LinkedList<String>();
+
+ for (Diagnostic<? extends JavaFileObject> d : coll.getDiagnostics()) {
+ codes.add(d.getCode());
+ }
+
+ assertEquals("testVariableInIfThen1",
+ Arrays.<String>asList("compiler.err.variable.not.allowed"),
+ codes);
+ }
+
+ public void testVariableInIfThen2() throws IOException {
+
+ String code = "package t; class Test { " +
+ "private static void t(String name) { " +
+ "if (name != null) class X {} } }";
+ DiagnosticCollector<JavaFileObject> coll =
+ new DiagnosticCollector<JavaFileObject>();
+ JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, coll, null,
+ null, Arrays.asList(new MyFileObject(code)));
+
+ ct.parse();
+
+ List<String> codes = new LinkedList<String>();
+
+ for (Diagnostic<? extends JavaFileObject> d : coll.getDiagnostics()) {
+ codes.add(d.getCode());
+ }
+
+ assertEquals("testVariableInIfThen2",
+ Arrays.<String>asList("compiler.err.class.not.allowed"), codes);
+ }
+
+ public void testVariableInIfThen3() throws IOException {
+
+ String code = "package t; class Test { "+
+ "private static void t(String name) { " +
+ "if (name != null) abstract } }";
+ DiagnosticCollector<JavaFileObject> coll =
+ new DiagnosticCollector<JavaFileObject>();
+ JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, coll, null,
+ null, Arrays.asList(new MyFileObject(code)));
+
+ ct.parse();
+
+ List<String> codes = new LinkedList<String>();
+
+ for (Diagnostic<? extends JavaFileObject> d : coll.getDiagnostics()) {
+ codes.add(d.getCode());
+ }
+
+ assertEquals("testVariableInIfThen3",
+ Arrays.<String>asList("compiler.err.illegal.start.of.expr"),
+ codes);
+ }
+
+ //see javac bug #6882235, NB bug #98234:
+ public void testMissingExponent() throws IOException {
+
+ String code = "\nclass Test { { System.err.println(0e); } }";
+
+ JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
+ null, Arrays.asList(new MyFileObject(code)));
+
+ assertNotNull(ct.parse().iterator().next());
+ }
+
+ public void testTryResourcePos() throws IOException {
+
+ final String code = "package t; class Test { " +
+ "{ try (java.io.InputStream in = null) { } } }";
+
+ CompilationUnitTree cut = getCompilationUnitTree(code);
+
+ new TreeScanner<Void, Void>() {
+ @Override
+ public Void visitVariable(VariableTree node, Void p) {
+ if ("in".contentEquals(node.getName())) {
+ JCTree.JCVariableDecl var = (JCTree.JCVariableDecl) node;
+ System.out.println(node.getName() + "," + var.pos);
+ assertEquals("testTryResourcePos", "in = null) { } } }",
+ code.substring(var.pos));
+ }
+ return super.visitVariable(node, p);
+ }
+ }.scan(cut, null);
+ }
+
+ public void testVarPos() throws IOException {
+
+ final String code = "package t; class Test { " +
+ "{ java.io.InputStream in = null; } }";
+
+ CompilationUnitTree cut = getCompilationUnitTree(code);
+
+ new TreeScanner<Void, Void>() {
+
+ @Override
+ public Void visitVariable(VariableTree node, Void p) {
+ if ("in".contentEquals(node.getName())) {
+ JCTree.JCVariableDecl var = (JCTree.JCVariableDecl) node;
+ assertEquals("testVarPos","in = null; } }",
+ code.substring(var.pos));
+ }
+ return super.visitVariable(node, p);
+ }
+ }.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
+ testPositionBrokenSource126732a();
+ testPositionBrokenSource126732b();
+
+ // Fails, these tests yet to be addressed
+ testVariableInIfThen1();
+ testVariableInIfThen2();
+ testPositionForEnumModifiers();
+ testStartPositionEnumConstantInit();
+ }
+ void testPositions() throws IOException {
+ testPositionsSane();
+ testCorrectWilcardPositions();
+ testPositionAnnotationNoPackage187551();
+ testPositionForSuperConstructorCalls();
+ testPreferredPositionForBinaryOp();
+ testStartPositionForMethodWithoutModifiers();
+ testVarPos();
+ testVariableInIfThen3();
+ testMissingExponent();
+ testTryResourcePos();
+ testOperatorMissingError();
+ testMissingParenthesisError();
+ testMissingClassError();
+ testSwitchError();
+ testMethodError();
+ }
+
+ public static void main(String... args) throws IOException {
+ JavacParserTest jpt = new JavacParserTest("JavacParserTest");
+ jpt.testPositions();
+ System.out.println("PASS");
+ }
+}
+
+abstract class TestCase {
+
+ void assertEquals(String message, int i, int pos) {
+ if (i != pos) {
+ fail(message);
+ }
+ }
+
+ void assertFalse(String message, boolean empty) {
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ void assertEquals(String message, int i, long l) {
+ if (i != l) {
+ fail(message + ":" + i + ":" + l);
+ }
+ }
+
+ void assertEquals(String message, Object o1, Object o2) {
+ System.out.println(o1);
+ System.out.println(o2);
+ if (o1 != null && o2 != null && !o1.equals(o2)) {
+ fail(message);
+ }
+ if (o1 == null && o2 != null) {
+ fail(message);
+ }
+ }
+
+ void assertNotNull(Object o) {
+ if (o == null) {
+ fail();
+ }
+ }
+
+ void fail() {
+ fail("test failed");
+ }
+
+ void fail(String message) {
+ throw new RuntimeException(message);
+ }
+}
--- a/langtools/test/tools/javac/parser/netbeans/JavacParserTest.java Thu Dec 15 15:47:47 2011 -0800
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,716 +0,0 @@
-/*
- * 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 7073631
- * @summary tests error and diagnostics positions
- * @author jan.lahoda@oracle.com
- */
-
-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.ExpressionStatementTree;
-import com.sun.source.tree.ExpressionTree;
-import com.sun.source.tree.MethodInvocationTree;
-import com.sun.source.tree.MethodTree;
-import com.sun.source.tree.ModifiersTree;
-import com.sun.source.tree.StatementTree;
-import com.sun.source.tree.Tree;
-import com.sun.source.tree.Tree.Kind;
-import com.sun.source.tree.VariableTree;
-import com.sun.source.tree.WhileLoopTree;
-import com.sun.source.util.SourcePositions;
-import com.sun.source.util.TreeScanner;
-import com.sun.source.util.Trees;
-import com.sun.tools.javac.api.JavacTaskImpl;
-import com.sun.tools.javac.tree.JCTree;
-import java.io.IOException;
-import java.net.URI;
-import java.util.Arrays;
-import java.util.LinkedList;
-import java.util.List;
-import javax.tools.Diagnostic;
-import javax.tools.DiagnosticCollector;
-import javax.tools.DiagnosticListener;
-import javax.tools.JavaCompiler;
-import javax.tools.JavaFileObject;
-import javax.tools.SimpleJavaFileObject;
-import javax.tools.ToolProvider;
-
-public class JavacParserTest extends TestCase {
- final JavaCompiler tool;
- public JavacParserTest(String testName) {
- tool = ToolProvider.getSystemJavaCompiler();
- System.out.println("java.home=" + System.getProperty("java.home"));
- }
-
- static class MyFileObject extends SimpleJavaFileObject {
-
- private String text;
-
- public MyFileObject(String text) {
- super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
- this.text = text;
- }
-
- @Override
- public CharSequence getCharContent(boolean ignoreEncodingErrors) {
- return text;
- }
- }
-
- public void testPositionForSuperConstructorCalls() throws IOException {
- assert tool != null;
-
- String code = "package test; public class Test {public Test() {super();}}";
-
- JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
- null, Arrays.asList(new MyFileObject(code)));
- CompilationUnitTree cut = ct.parse().iterator().next();
- SourcePositions pos = Trees.instance(ct).getSourcePositions();
-
- MethodTree method =
- (MethodTree) ((ClassTree) cut.getTypeDecls().get(0)).getMembers().get(0);
- ExpressionStatementTree es =
- (ExpressionStatementTree) method.getBody().getStatements().get(0);
-
- assertEquals("testPositionForSuperConstructorCalls",
- 72 - 24, pos.getStartPosition(cut, es));
- assertEquals("testPositionForSuperConstructorCalls",
- 80 - 24, pos.getEndPosition(cut, es));
-
- MethodInvocationTree mit = (MethodInvocationTree) es.getExpression();
-
- assertEquals("testPositionForSuperConstructorCalls",
- 72 - 24, pos.getStartPosition(cut, mit));
- assertEquals("testPositionForSuperConstructorCalls",
- 79 - 24, pos.getEndPosition(cut, mit));
-
- assertEquals("testPositionForSuperConstructorCalls",
- 72 - 24, pos.getStartPosition(cut, mit.getMethodSelect()));
- assertEquals("testPositionForSuperConstructorCalls",
- 77 - 24, pos.getEndPosition(cut, mit.getMethodSelect()));
-
- }
-
- public void testPositionForEnumModifiers() throws IOException {
-
- String code = "package test; public enum Test {A;}";
-
- JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
- null, Arrays.asList(new MyFileObject(code)));
- CompilationUnitTree cut = ct.parse().iterator().next();
- SourcePositions pos = Trees.instance(ct).getSourcePositions();
-
- ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
- ModifiersTree mt = clazz.getModifiers();
-
- assertEquals("testPositionForEnumModifiers",
- 38 - 24, pos.getStartPosition(cut, mt));
- assertEquals("testPositionForEnumModifiers",
- 44 - 24, pos.getEndPosition(cut, mt));
- }
-
- public void testNewClassWithEnclosing() throws IOException {
-
-
- String code = "package test; class Test { " +
- "class d {} private void method() { " +
- "Object o = Test.this.new d(); } }";
-
- JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
- null, Arrays.asList(new MyFileObject(code)));
- CompilationUnitTree cut = ct.parse().iterator().next();
- SourcePositions pos = Trees.instance(ct).getSourcePositions();
-
- ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
- ExpressionTree est =
- ((VariableTree) ((MethodTree) clazz.getMembers().get(1)).getBody().getStatements().get(0)).getInitializer();
-
- assertEquals("testNewClassWithEnclosing",
- 97 - 24, pos.getStartPosition(cut, est));
- assertEquals("testNewClassWithEnclosing",
- 114 - 24, pos.getEndPosition(cut, est));
- }
-
- 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() {}}";
-
- JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
- null, Arrays.asList(new MyFileObject(code)));
- CompilationUnitTree cut = ct.parse().iterator().next();
-
- 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);
- }
-
- public void testPositionBrokenSource126732a() throws IOException {
- String[] commands = new String[]{
- "return Runnable()",
- "do { } while (true)",
- "throw UnsupportedOperationException()",
- "assert true",
- "1 + 1",};
-
- for (String command : commands) {
-
- String code = "package test;\n"
- + "public class Test {\n"
- + " public static void test() {\n"
- + " " + command + " {\n"
- + " new Runnable() {\n"
- + " };\n"
- + " }\n"
- + "}";
- JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null,
- null, null, Arrays.asList(new MyFileObject(code)));
- CompilationUnitTree cut = ct.parse().iterator().next();
-
- ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
- MethodTree method = (MethodTree) clazz.getMembers().get(0);
- List<? extends StatementTree> statements =
- method.getBody().getStatements();
-
- StatementTree ret = statements.get(0);
- StatementTree block = statements.get(1);
-
- Trees t = Trees.instance(ct);
- int len = code.indexOf(command + " {") + (command + " ").length();
- assertEquals(command, len,
- t.getSourcePositions().getEndPosition(cut, ret));
- assertEquals(command, len,
- t.getSourcePositions().getStartPosition(cut, block));
- }
- }
-
- public void testPositionBrokenSource126732b() throws IOException {
- String[] commands = new String[]{
- "break",
- "break A",
- "continue ",
- "continue A",};
-
- for (String command : commands) {
-
- String code = "package test;\n"
- + "public class Test {\n"
- + " public static void test() {\n"
- + " while (true) {\n"
- + " " + command + " {\n"
- + " new Runnable() {\n"
- + " };\n"
- + " }\n"
- + " }\n"
- + "}";
-
- JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null,
- null, null, Arrays.asList(new MyFileObject(code)));
- CompilationUnitTree cut = ct.parse().iterator().next();
-
- ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
- MethodTree method = (MethodTree) clazz.getMembers().get(0);
- List<? extends StatementTree> statements =
- ((BlockTree) ((WhileLoopTree) method.getBody().getStatements().get(0)).getStatement()).getStatements();
-
- StatementTree ret = statements.get(0);
- StatementTree block = statements.get(1);
-
- Trees t = Trees.instance(ct);
- int len = code.indexOf(command + " {") + (command + " ").length();
- assertEquals(command, len,
- t.getSourcePositions().getEndPosition(cut, ret));
- assertEquals(command, len,
- t.getSourcePositions().getStartPosition(cut, block));
- }
- }
-
- public void testErrorRecoveryForEnhancedForLoop142381() throws IOException {
-
- String code = "package test; class Test { " +
- "private void method() { " +
- "java.util.Set<String> s = null; for (a : s) {} } }";
-
- final List<Diagnostic<? extends JavaFileObject>> errors =
- new LinkedList<Diagnostic<? extends JavaFileObject>>();
-
- JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null,
- new DiagnosticListener<JavaFileObject>() {
- public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
- errors.add(diagnostic);
- }
- }, null, null, Arrays.asList(new MyFileObject(code)));
-
- CompilationUnitTree cut = ct.parse().iterator().next();
-
- ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
- StatementTree forStatement =
- ((MethodTree) clazz.getMembers().get(0)).getBody().getStatements().get(1);
-
- assertEquals("testErrorRecoveryForEnhancedForLoop142381",
- Kind.ENHANCED_FOR_LOOP, forStatement.getKind());
- assertFalse("testErrorRecoveryForEnhancedForLoop142381", errors.isEmpty());
- }
-
- public void testPositionAnnotationNoPackage187551() throws IOException {
-
- String code = "\n@interface Test {}";
-
- JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
- null, Arrays.asList(new MyFileObject(code)));
-
- CompilationUnitTree cut = ct.parse().iterator().next();
- ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
- Trees t = Trees.instance(ct);
-
- assertEquals("testPositionAnnotationNoPackage187551",
- 1, t.getSourcePositions().getStartPosition(cut, clazz));
- }
-
- public void testPositionsSane() throws IOException {
- performPositionsSanityTest("package test; class Test { " +
- "private void method() { " +
- "java.util.List<? extends java.util.List<? extends String>> l; " +
- "} }");
- performPositionsSanityTest("package test; class Test { " +
- "private void method() { " +
- "java.util.List<? super java.util.List<? super String>> l; " +
- "} }");
- performPositionsSanityTest("package test; class Test { " +
- "private void method() { " +
- "java.util.List<? super java.util.List<?>> l; } }");
- }
-
- private void performPositionsSanityTest(String code) throws IOException {
-
- final List<Diagnostic<? extends JavaFileObject>> errors =
- new LinkedList<Diagnostic<? extends JavaFileObject>>();
-
- JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null,
- new DiagnosticListener<JavaFileObject>() {
-
- public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
- errors.add(diagnostic);
- }
- }, null, null, Arrays.asList(new MyFileObject(code)));
-
- final CompilationUnitTree cut = ct.parse().iterator().next();
- final Trees trees = Trees.instance(ct);
-
- new TreeScanner<Void, Void>() {
-
- private long parentStart = 0;
- private long parentEnd = Integer.MAX_VALUE;
-
- @Override
- public Void scan(Tree node, Void p) {
- if (node == null) {
- return null;
- }
-
- long start = trees.getSourcePositions().getStartPosition(cut, node);
-
- if (start == (-1)) {
- return null; //synthetic tree
- }
- assertTrue(node.toString() + ":" + start + "/" + parentStart,
- parentStart <= start);
-
- long prevParentStart = parentStart;
-
- parentStart = start;
-
- long end = trees.getSourcePositions().getEndPosition(cut, node);
-
- assertTrue(node.toString() + ":" + end + "/" + parentEnd,
- end <= parentEnd);
-
- long prevParentEnd = parentEnd;
-
- parentEnd = end;
-
- super.scan(node, p);
-
- parentStart = prevParentStart;
- parentEnd = prevParentEnd;
-
- return null;
- }
-
- private void assertTrue(String message, boolean b) {
- if (!b) fail(message);
- }
- }.scan(cut, null);
- }
-
- public void testCorrectWilcardPositions() throws IOException {
- performWildcardPositionsTest("package test; import java.util.List; " +
- "class Test { private void method() { List<? extends List<? extends String>> l; } }",
-
- Arrays.asList("List<? extends List<? extends String>> l;",
- "List<? extends List<? extends String>>",
- "List",
- "? extends List<? extends String>",
- "List<? extends String>",
- "List",
- "? extends String",
- "String"));
- performWildcardPositionsTest("package test; import java.util.List; " +
- "class Test { private void method() { List<? super List<? super String>> l; } }",
-
- Arrays.asList("List<? super List<? super String>> l;",
- "List<? super List<? super String>>",
- "List",
- "? super List<? super String>",
- "List<? super String>",
- "List",
- "? super String",
- "String"));
- performWildcardPositionsTest("package test; import java.util.List; " +
- "class Test { private void method() { List<? super List<?>> l; } }",
-
- Arrays.asList("List<? super List<?>> l;",
- "List<? super List<?>>",
- "List",
- "? super List<?>",
- "List<?>",
- "List",
- "?"));
- performWildcardPositionsTest("package test; import java.util.List; " +
- "class Test { private void method() { " +
- "List<? extends List<? extends List<? extends String>>> l; } }",
-
- Arrays.asList("List<? extends List<? extends List<? extends String>>> l;",
- "List<? extends List<? extends List<? extends String>>>",
- "List",
- "? extends List<? extends List<? extends String>>",
- "List<? extends List<? extends String>>",
- "List",
- "? extends List<? extends String>",
- "List<? extends String>",
- "List",
- "? extends String",
- "String"));
- performWildcardPositionsTest("package test; import java.util.List; " +
- "class Test { private void method() { " +
- "List<? extends List<? extends List<? extends String >>> l; } }",
- Arrays.asList("List<? extends List<? extends List<? extends String >>> l;",
- "List<? extends List<? extends List<? extends String >>>",
- "List",
- "? extends List<? extends List<? extends String >>",
- "List<? extends List<? extends String >>",
- "List",
- "? extends List<? extends String >",
- "List<? extends String >",
- "List",
- "? extends String",
- "String"));
- }
-
- public void performWildcardPositionsTest(final String code,
- List<String> golden) throws IOException {
-
- final List<Diagnostic<? extends JavaFileObject>> errors =
- new LinkedList<Diagnostic<? extends JavaFileObject>>();
-
- JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null,
- new DiagnosticListener<JavaFileObject>() {
- public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
- errors.add(diagnostic);
- }
- }, null, null, Arrays.asList(new MyFileObject(code)));
-
- final CompilationUnitTree cut = ct.parse().iterator().next();
- final List<String> content = new LinkedList<String>();
- final Trees trees = Trees.instance(ct);
-
- new TreeScanner<Void, Void>() {
- @Override
- public Void scan(Tree node, Void p) {
- if (node == null) {
- return null;
- }
- long start = trees.getSourcePositions().getStartPosition(cut, node);
-
- if (start == (-1)) {
- return null; //synthetic tree
- }
- long end = trees.getSourcePositions().getEndPosition(cut, node);
- String s = code.substring((int) start, (int) end);
- content.add(s);
-
- return super.scan(node, p);
- }
- }.scan(((MethodTree) ((ClassTree) cut.getTypeDecls().get(0)).getMembers().get(0)).getBody().getStatements().get(0), null);
-
- assertEquals("performWildcardPositionsTest",golden.toString(),
- content.toString());
- }
-
- public void testStartPositionForMethodWithoutModifiers() throws IOException {
-
- String code = "package t; class Test { <T> void t() {} }";
-
- JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
- null, Arrays.asList(new MyFileObject(code)));
- CompilationUnitTree cut = ct.parse().iterator().next();
- ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
- MethodTree mt = (MethodTree) clazz.getMembers().get(0);
- Trees t = Trees.instance(ct);
- int start = (int) t.getSourcePositions().getStartPosition(cut, mt);
- int end = (int) t.getSourcePositions().getEndPosition(cut, mt);
-
- assertEquals("testStartPositionForMethodWithoutModifiers",
- "<T> void t() {}", code.substring(start, end));
- }
-
- public void testStartPositionEnumConstantInit() throws IOException {
-
- String code = "package t; enum Test { AAA; }";
-
- JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
- null, Arrays.asList(new MyFileObject(code)));
- CompilationUnitTree cut = ct.parse().iterator().next();
- ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
- VariableTree enumAAA = (VariableTree) clazz.getMembers().get(0);
- Trees t = Trees.instance(ct);
- int start = (int) t.getSourcePositions().getStartPosition(cut,
- enumAAA.getInitializer());
-
- assertEquals("testStartPositionEnumConstantInit", -1, start);
- }
-
- public void testVariableInIfThen1() throws IOException {
-
- String code = "package t; class Test { " +
- "private static void t(String name) { " +
- "if (name != null) String nn = name.trim(); } }";
-
- DiagnosticCollector<JavaFileObject> coll =
- new DiagnosticCollector<JavaFileObject>();
-
- JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, coll, null,
- null, Arrays.asList(new MyFileObject(code)));
-
- ct.parse();
-
- List<String> codes = new LinkedList<String>();
-
- for (Diagnostic<? extends JavaFileObject> d : coll.getDiagnostics()) {
- codes.add(d.getCode());
- }
-
- assertEquals("testVariableInIfThen1",
- Arrays.<String>asList("compiler.err.variable.not.allowed"),
- codes);
- }
-
- public void testVariableInIfThen2() throws IOException {
-
- String code = "package t; class Test { " +
- "private static void t(String name) { " +
- "if (name != null) class X {} } }";
- DiagnosticCollector<JavaFileObject> coll =
- new DiagnosticCollector<JavaFileObject>();
- JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, coll, null,
- null, Arrays.asList(new MyFileObject(code)));
-
- ct.parse();
-
- List<String> codes = new LinkedList<String>();
-
- for (Diagnostic<? extends JavaFileObject> d : coll.getDiagnostics()) {
- codes.add(d.getCode());
- }
-
- assertEquals("testVariableInIfThen2",
- Arrays.<String>asList("compiler.err.class.not.allowed"), codes);
- }
-
- public void testVariableInIfThen3() throws IOException {
-
- String code = "package t; class Test { "+
- "private static void t(String name) { " +
- "if (name != null) abstract } }";
- DiagnosticCollector<JavaFileObject> coll =
- new DiagnosticCollector<JavaFileObject>();
- JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, coll, null,
- null, Arrays.asList(new MyFileObject(code)));
-
- ct.parse();
-
- List<String> codes = new LinkedList<String>();
-
- for (Diagnostic<? extends JavaFileObject> d : coll.getDiagnostics()) {
- codes.add(d.getCode());
- }
-
- assertEquals("testVariableInIfThen3",
- Arrays.<String>asList("compiler.err.illegal.start.of.expr"),
- codes);
- }
-
- //see javac bug #6882235, NB bug #98234:
- public void testMissingExponent() throws IOException {
-
- String code = "\nclass Test { { System.err.println(0e); } }";
-
- JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
- null, Arrays.asList(new MyFileObject(code)));
-
- assertNotNull(ct.parse().iterator().next());
- }
-
- public void testTryResourcePos() throws IOException {
-
- 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();
-
- new TreeScanner<Void, Void>() {
- @Override
- public Void visitVariable(VariableTree node, Void p) {
- if ("in".contentEquals(node.getName())) {
- JCTree.JCVariableDecl var = (JCTree.JCVariableDecl) node;
- System.out.println(node.getName() + "," + var.pos);
- assertEquals("testTryResourcePos", "in = null) { } } }",
- code.substring(var.pos));
- }
- return super.visitVariable(node, p);
- }
- }.scan(cut, null);
- }
-
- public void testVarPos() throws IOException {
-
- 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();
-
- new TreeScanner<Void, Void>() {
-
- @Override
- public Void visitVariable(VariableTree node, Void p) {
- if ("in".contentEquals(node.getName())) {
- JCTree.JCVariableDecl var = (JCTree.JCVariableDecl) node;
- assertEquals("testVarPos","in = null; } }",
- code.substring(var.pos));
- }
- return super.visitVariable(node, p);
- }
- }.scan(cut, null);
- }
-
- void testsNotWorking() throws IOException {
-
- // Fails with nb-javac, needs further investigation
- testPositionBrokenSource126732a();
- testPositionBrokenSource126732b();
-
- // Fails, these tests yet to be addressed
- testVariableInIfThen1();
- testVariableInIfThen2();
- testPositionForEnumModifiers();
- testStartPositionEnumConstantInit();
- }
- void testPositions() throws IOException {
- testPositionsSane();
- testCorrectWilcardPositions();
- testPositionAnnotationNoPackage187551();
- testPositionForSuperConstructorCalls();
- testPreferredPositionForBinaryOp();
- testStartPositionForMethodWithoutModifiers();
- testVarPos();
- testVariableInIfThen3();
- testTryResourcePos();
- }
-
- public static void main(String... args) throws IOException {
- JavacParserTest jpt = new JavacParserTest("JavacParserTest");
- jpt.testPositions();
- System.out.println("PASS");
- }
-}
-
-abstract class TestCase {
-
- void assertEquals(String message, int i, int pos) {
- if (i != pos) {
- fail(message);
- }
- }
-
- void assertFalse(String message, boolean empty) {
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- void assertEquals(String message, int i, long l) {
- if (i != l) {
- fail(message + ":" + i + ":" + l);
- }
- }
-
- void assertEquals(String message, Object o1, Object o2) {
- System.out.println(o1);
- System.out.println(o2);
- if (o1 != null && o2 != null && !o1.equals(o2)) {
- fail(message);
- }
- if (o1 == null && o2 != null) {
- fail(message);
- }
- }
-
- void assertNotNull(Object o) {
- if (o == null) {
- fail();
- }
- }
-
- void fail() {
- fail("test failed");
- }
-
- void fail(String message) {
- throw new RuntimeException(message);
- }
-}
--- a/langtools/test/tools/javac/quid/T6999438.out Thu Dec 15 15:47:47 2011 -0800
+++ b/langtools/test/tools/javac/quid/T6999438.out Thu Dec 15 15:57:51 2011 -0800
@@ -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: ';'