changeset 11147:97f84f962051

Merge
author asaha
date Tue, 28 Jul 2015 23:12:54 -0700
parents 95d338b6617a be5faa9c7704
children b3773a2b6bf6
files .hgtags make/lib/Awt2dLibraries.gmk
diffstat 12 files changed, 620 insertions(+), 237 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Thu Jul 23 10:59:55 2015 -0700
+++ b/.hgtags	Tue Jul 28 23:12:54 2015 -0700
@@ -464,3 +464,4 @@
 3ee40ba7525d6d5ee201a475b967ca2e5c3c9ab3 jdk8u65-b06
 e9f82302d5fdef8a0976640e09363895e9dcde3c jdk8u66-b00
 64d7bd4e98150447916f210e3bfd6875a4c2728a jdk8u66-b01
+d8210091911b14930192abd3138ee37c281fb632 jdk8u66-b02
--- a/make/lib/Awt2dLibraries.gmk	Thu Jul 23 10:59:55 2015 -0700
+++ b/make/lib/Awt2dLibraries.gmk	Tue Jul 28 23:12:54 2015 -0700
@@ -763,6 +763,102 @@
 
 ##########################################################################################
 
+ifeq ($(BUILD_HEADLESS), true)
+  # Mac and Windows only use the native AWT lib, do not build libawt_headless
+  ifeq ($(findstring $(OPENJDK_TARGET_OS), windows macosx),)
+
+    LIBAWT_HEADLESS_DIRS := $(JDK_TOPDIR)/src/share/native/sun/font \
+        $(JDK_TOPDIR)/src/share/native/sun/java2d/opengl \
+        $(JDK_TOPDIR)/src/solaris/native/sun/font \
+        $(JDK_TOPDIR)/src/solaris/native/sun/awt \
+        $(JDK_TOPDIR)/src/solaris/native/sun/java2d/opengl \
+        $(JDK_TOPDIR)/src/solaris/native/sun/java2d/x11
+
+    ifeq ($(OPENJDK_TARGET_OS), macosx)
+      LIBAWT_HEADLESS_DIRS += $(JDK_TOPDIR)/src/macosx/native/sun/font
+    endif
+
+    LIBAWT_HEADLESS_CFLAGS := -DHEADLESS=true \
+        -DPACKAGE_PATH=\"$(PACKAGE_PATH)\" \
+        $(CUPS_CFLAGS) \
+        $(X_CFLAGS) \
+        -I$(JDK_TOPDIR)/src/share/native/sun/java2d \
+        -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/java2d \
+        -I$(JDK_TOPDIR)/src/share/native/sun/java2d/loops \
+        -I$(JDK_TOPDIR)/src/share/native/sun/java2d/pipe \
+        -I$(JDK_TOPDIR)/src/share/native/sun/awt/image \
+        -I$(JDK_TOPDIR)/src/share/native/sun/awt/image/cvutils \
+        -I$(JDK_TOPDIR)/src/share/native/sun/awt/debug \
+        -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/jdga \
+        $(foreach dir, $(LIBAWT_HEADLESS_DIRS), -I$(dir))
+
+    LIBAWT_HEADLESS_FILES := \
+        awt_Font.c \
+        HeadlessToolkit.c \
+        fontpath.c \
+        VDrawingArea.c \
+        X11Color.c \
+        X11Renderer.c \
+        X11PMBlitLoops.c \
+        X11SurfaceData.c \
+        X11FontScaler_md.c \
+        X11TextRenderer_md.c \
+        OGLBlitLoops.c \
+        OGLBufImgOps.c \
+        OGLContext.c \
+        OGLFuncs.c \
+        OGLMaskBlit.c \
+        OGLMaskFill.c \
+        OGLPaints.c \
+        OGLRenderQueue.c \
+        OGLRenderer.c \
+        OGLSurfaceData.c \
+        OGLTextRenderer.c \
+        OGLVertexCache.c \
+        GLXGraphicsConfig.c \
+        GLXSurfaceData.c \
+        AccelGlyphCache.c \
+        CUPSfuncs.c
+
+    LIBAWT_HEADLESS_REORDER :=
+    ifeq ($(OPENJDK_TARGET_OS), solaris)
+      ifneq ($(OPENJDK_TARGET_CPU), x86_64)
+        LIBAWT_HEADLESS_REORDER := $(JDK_TOPDIR)/make/mapfiles/libawt_headless/reorder-$(OPENJDK_TARGET_CPU)
+      endif
+    endif
+
+    $(eval $(call SetupNativeCompilation,BUILD_LIBAWT_HEADLESS, \
+        LIBRARY := awt_headless, \
+        OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
+        SRC := $(LIBAWT_HEADLESS_DIRS), \
+        INCLUDE_FILES := $(LIBAWT_HEADLESS_FILES), \
+        LANG := C, \
+        OPTIMIZATION := LOW, \
+        CFLAGS := $(CFLAGS_JDKLIB) $(LIBAWT_HEADLESS_CFLAGS), \
+        MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libawt_headless/mapfile-vers, \
+        LDFLAGS := $(LDFLAGS_JDKLIB) \
+            $(call SET_SHARED_LIBRARY_ORIGIN), \
+        LDFLAGS_linux := $(call SET_SHARED_LIBRARY_ORIGIN,/..), \
+        LDFLAGS_solaris := $(call SET_SHARED_LIBRARY_ORIGIN,/..) \
+            -R/usr/dt/lib$(OPENJDK_TARGET_CPU_ISADIR) \
+            -R$(OPENWIN_LIB)$(OPENJDK_TARGET_CPU_ISADIR), \
+        LDFLAGS_macosx := $(call SET_SHARED_LIBRARY_ORIGIN)., \
+        REORDER := $(LIBAWT_HEADLESS_REORDER), \
+        LDFLAGS_SUFFIX_linux := -ljvm -lawt -lm $(LIBDL) -ljava, \
+        LDFLAGS_SUFFIX_aix := -ljvm -lawt -ljava,\
+        LDFLAGS_SUFFIX_solaris := $(LIBDL) -ljvm -lawt -lm -ljava $(LIBCXX) -lc, \
+        OBJECT_DIR := $(JDK_OUTPUTDIR)/objs/libawt_headless, \
+        DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES)))
+
+    $(BUILD_LIBAWT_HEADLESS): $(BUILD_LIBAWT)
+
+    BUILD_LIBRARIES += $(BUILD_LIBAWT_HEADLESS)
+
+  endif
+endif
+
+##########################################################################################
+
 ifndef OPENJDK
   FONT_HEADERS := -I$(JDK_TOPDIR)/src/closed/share/native/sun/font/t2k
   BUILD_LIBFONTMANAGER_MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libfontmanager/mapfile-vers
@@ -843,7 +939,7 @@
 $(BUILD_LIBFONTMANAGER): $(BUILD_LIBAWT)
 
 ifneq (, $(findstring $(OPENJDK_TARGET_OS), solaris aix))
-  $(BUILD_LIBFONTMANAGER): $(BUILD_LIBAWT_XAWT)
+  $(BUILD_LIBFONTMANAGER): $(BUILD_LIBAWT_HEADLESS)
 endif
 
 BUILD_LIBRARIES += $(BUILD_LIBFONTMANAGER)
@@ -888,7 +984,7 @@
           $(call SET_SHARED_LIBRARY_ORIGIN), \
       LDFLAGS_windows := user32.lib $(JDK_OUTPUTDIR)/objs/libfontmanager/fontmanager.lib, \
       LDFLAGS_SUFFIX_posix := $(LIBM) $(LIBCXX) -lfontmanager -ljava -ljvm -lc, \
-      LDFLAGS_SUFFIX_solaris := -lawt -lawt_xawt, \
+      LDFLAGS_SUFFIX_solaris := -lawt -lawt_headless, \
       VERSIONINFO_RESOURCE := $(JDK_TOPDIR)/src/windows/resource/version.rc, \
       RC_FLAGS := $(RC_FLAGS) \
           -D "JDK_FNAME=t2k.dll" \
@@ -1090,102 +1186,6 @@
 
 ##########################################################################################
 
-ifeq ($(BUILD_HEADLESS), true)
-  # Mac and Windows only use the native AWT lib, do not build libawt_headless
-  ifeq ($(findstring $(OPENJDK_TARGET_OS), windows macosx),)
-
-    LIBAWT_HEADLESS_DIRS := $(JDK_TOPDIR)/src/share/native/sun/font \
-        $(JDK_TOPDIR)/src/share/native/sun/java2d/opengl \
-        $(JDK_TOPDIR)/src/solaris/native/sun/font \
-        $(JDK_TOPDIR)/src/solaris/native/sun/awt \
-        $(JDK_TOPDIR)/src/solaris/native/sun/java2d/opengl \
-        $(JDK_TOPDIR)/src/solaris/native/sun/java2d/x11
-
-    ifeq ($(OPENJDK_TARGET_OS), macosx)
-      LIBAWT_HEADLESS_DIRS += $(JDK_TOPDIR)/src/macosx/native/sun/font
-    endif
-
-    LIBAWT_HEADLESS_CFLAGS := -DHEADLESS=true \
-        -DPACKAGE_PATH=\"$(PACKAGE_PATH)\" \
-        $(CUPS_CFLAGS) \
-        $(X_CFLAGS) \
-        -I$(JDK_TOPDIR)/src/share/native/sun/java2d \
-        -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/java2d \
-        -I$(JDK_TOPDIR)/src/share/native/sun/java2d/loops \
-        -I$(JDK_TOPDIR)/src/share/native/sun/java2d/pipe \
-        -I$(JDK_TOPDIR)/src/share/native/sun/awt/image \
-        -I$(JDK_TOPDIR)/src/share/native/sun/awt/image/cvutils \
-        -I$(JDK_TOPDIR)/src/share/native/sun/awt/debug \
-        -I$(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/sun/jdga \
-        $(foreach dir, $(LIBAWT_HEADLESS_DIRS), -I$(dir))
-
-    LIBAWT_HEADLESS_FILES := \
-        awt_Font.c \
-        HeadlessToolkit.c \
-        fontpath.c \
-        VDrawingArea.c \
-        X11Color.c \
-        X11Renderer.c \
-        X11PMBlitLoops.c \
-        X11SurfaceData.c \
-        X11FontScaler_md.c \
-        X11TextRenderer_md.c \
-        OGLBlitLoops.c \
-        OGLBufImgOps.c \
-        OGLContext.c \
-        OGLFuncs.c \
-        OGLMaskBlit.c \
-        OGLMaskFill.c \
-        OGLPaints.c \
-        OGLRenderQueue.c \
-        OGLRenderer.c \
-        OGLSurfaceData.c \
-        OGLTextRenderer.c \
-        OGLVertexCache.c \
-        GLXGraphicsConfig.c \
-        GLXSurfaceData.c \
-        AccelGlyphCache.c \
-        CUPSfuncs.c
-
-    LIBAWT_HEADLESS_REORDER :=
-    ifeq ($(OPENJDK_TARGET_OS), solaris)
-      ifneq ($(OPENJDK_TARGET_CPU), x86_64)
-        LIBAWT_HEADLESS_REORDER := $(JDK_TOPDIR)/make/mapfiles/libawt_headless/reorder-$(OPENJDK_TARGET_CPU)
-      endif
-    endif
-
-    $(eval $(call SetupNativeCompilation,BUILD_LIBAWT_HEADLESS, \
-        LIBRARY := awt_headless, \
-        OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
-        SRC := $(LIBAWT_HEADLESS_DIRS), \
-        INCLUDE_FILES := $(LIBAWT_HEADLESS_FILES), \
-        LANG := C, \
-        OPTIMIZATION := LOW, \
-        CFLAGS := $(CFLAGS_JDKLIB) $(LIBAWT_HEADLESS_CFLAGS), \
-        MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libawt_headless/mapfile-vers, \
-        LDFLAGS := $(LDFLAGS_JDKLIB) \
-            $(call SET_SHARED_LIBRARY_ORIGIN), \
-        LDFLAGS_linux := $(call SET_SHARED_LIBRARY_ORIGIN,/..), \
-        LDFLAGS_solaris := $(call SET_SHARED_LIBRARY_ORIGIN,/..) \
-            -R/usr/dt/lib$(OPENJDK_TARGET_CPU_ISADIR) \
-            -R$(OPENWIN_LIB)$(OPENJDK_TARGET_CPU_ISADIR), \
-        LDFLAGS_macosx := $(call SET_SHARED_LIBRARY_ORIGIN)., \
-        REORDER := $(LIBAWT_HEADLESS_REORDER), \
-        LDFLAGS_SUFFIX_linux := -ljvm -lawt -lm $(LIBDL) -ljava, \
-        LDFLAGS_SUFFIX_aix := -ljvm -lawt -ljava,\
-        LDFLAGS_SUFFIX_solaris := $(LIBDL) -ljvm -lawt -lm -ljava $(LIBCXX) -lc, \
-        OBJECT_DIR := $(JDK_OUTPUTDIR)/objs/libawt_headless, \
-        DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES)))
-
-    $(BUILD_LIBAWT_HEADLESS): $(BUILD_LIBAWT)
-
-    BUILD_LIBRARIES += $(BUILD_LIBAWT_HEADLESS)
-
-  endif
-endif
-
-##########################################################################################
-
 ifndef BUILD_HEADLESS_ONLY
   LIBSPLASHSCREEN_DIRS := \
     $(JDK_TOPDIR)/src/share/native/sun/awt/image/jpeg \
--- a/src/macosx/classes/sun/lwawt/macosx/CDataTransferer.java	Thu Jul 23 10:59:55 2015 -0700
+++ b/src/macosx/classes/sun/lwawt/macosx/CDataTransferer.java	Tue Jul 28 23:12:54 2015 -0700
@@ -52,7 +52,9 @@
         "RICH_TEXT",
         "HTML",
         "PDF",
-        "URL"
+        "URL",
+        "PNG",
+        "JFIF"
     };
 
     static {
@@ -74,8 +76,8 @@
     public static final int CF_HTML        = 5;
     public static final int CF_PDF         = 6;
     public static final int CF_URL         = 7;
-    public static final int CF_PNG         = 10;
-    public static final int CF_JPEG        = 11;
+    public static final int CF_PNG         = 8;
+    public static final int CF_JPEG        = 9;
 
     private CDataTransferer() {}
 
@@ -204,20 +206,9 @@
         return handler;
     }
 
-    private native byte[] imageDataToPlatformImageBytes(int[] rData, int nW, int nH);
     @Override
     protected byte[] imageToPlatformBytes(Image image, long format) {
-        int w = image.getWidth(null);
-        int h = image.getHeight(null);
-        BufferedImage bimage = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB_PRE);
-        Graphics g = bimage.getGraphics();
-        g.drawImage(image, 0, 0, w, h, null);
-        g.dispose();
-        Raster raster = bimage.getRaster();
-        DataBuffer buffer = raster.getDataBuffer();
-        return imageDataToPlatformImageBytes(((DataBufferInt)buffer).getData(),
-                                             raster.getWidth(),
-                                             raster.getHeight());
+        return CImage.getCreator().getPlatformImageBytes(image);
     }
 
     private static native String[] nativeDragQueryFile(final byte[] bytes);
@@ -228,14 +219,9 @@
         return nativeDragQueryFile(bytes);
     }
 
-    private native Image getImageForByteStream(byte[] bytes);
-    /**
-     * Translates a byte array which contains
-     * platform-specific image data in the given format into an Image.
-     */
     @Override
     protected Image platformImageBytesToImage(byte[] bytes, long format) throws IOException {
-        return getImageForByteStream(bytes);
+        return CImage.getCreator().createImageFromPlatformImageBytes(bytes);
     }
 
     @Override
--- a/src/macosx/classes/sun/lwawt/macosx/CImage.java	Thu Jul 23 10:59:55 2015 -0700
+++ b/src/macosx/classes/sun/lwawt/macosx/CImage.java	Tue Jul 28 23:12:54 2015 -0700
@@ -38,11 +38,13 @@
 
 public class CImage extends CFRetainedResource {
     private static native long nativeCreateNSImageFromArray(int[] buffer, int w, int h);
+    private static native long nativeCreateNSImageFromBytes(byte[] buffer);
     private static native long nativeCreateNSImageFromArrays(int[][] buffers, int w[], int h[]);
     private static native long nativeCreateNSImageFromFileContents(String file);
     private static native long nativeCreateNSImageOfFileFromLaunchServices(String file);
     private static native long nativeCreateNSImageFromImageName(String name);
     private static native long nativeCreateNSImageFromIconSelector(int selector);
+    private static native byte[] nativeGetPlatformImageBytes(int[] buffer, int w, int h);
     private static native void nativeCopyNSImageIntoArray(long image, int[] buffer, int sw, int sh, int dw, int dh);
     private static native Dimension2D nativeGetNSImageSize(long image);
     private static native void nativeSetNSImageSize(long image, double w, double h);
@@ -50,7 +52,7 @@
     private static native Dimension2D[] nativeGetNSImageRepresentationSizes(long image, double w, double h);
 
     static Creator creator = new Creator();
-    static Creator getCreator() {
+    public static Creator getCreator() {
         return creator;
     }
 
@@ -136,6 +138,23 @@
             return ((DataBufferInt)bimg.getRaster().getDataBuffer()).getData();
         }
 
+        public byte[] getPlatformImageBytes(final Image image) {
+            int[] buffer = imageToArray(image, false);
+
+            if (buffer == null) {
+                return null;
+            }
+
+            return nativeGetPlatformImageBytes(buffer, image.getWidth(null), image.getHeight(null));
+        }
+
+        /**
+         * Translates a byte array which contains platform-specific image data in the given format into an Image.
+         */
+        public Image createImageFromPlatformImageBytes(final byte[] buffer) {
+            return createImageUsingNativeSize(nativeCreateNSImageFromBytes(buffer));
+        }
+
         // This is used to create a CImage from a Image
         public CImage createFromImage(final Image image) {
             return createFromImage(image, true);
--- a/src/macosx/native/sun/awt/CDataTransferer.m	Thu Jul 23 10:59:55 2015 -0700
+++ b/src/macosx/native/sun/awt/CDataTransferer.m	Tue Jul 28 23:12:54 2015 -0700
@@ -54,6 +54,10 @@
                               forKey:[NSNumber numberWithLong:sun_lwawt_macosx_CDataTransferer_CF_PDF]];
         [sStandardMappings setObject:NSURLPboardType
                               forKey:[NSNumber numberWithLong:sun_lwawt_macosx_CDataTransferer_CF_URL]];
+        [sStandardMappings setObject:NSPasteboardTypePNG
+                              forKey:[NSNumber numberWithLong:sun_lwawt_macosx_CDataTransferer_CF_PNG]];
+        [sStandardMappings setObject:(NSString*)kUTTypeJPEG
+                              forKey:[NSNumber numberWithLong:sun_lwawt_macosx_CDataTransferer_CF_JPEG]];
     }
     return sStandardMappings;
 }
@@ -126,108 +130,6 @@
     return returnValue;
 }
 
-/*
- * Class:     sun_lwawt_macosx_CDataTransferer
- * Method:    imageDataToPlatformImageBytes
- * Signature: ([III)[B
-     */
-JNIEXPORT jbyteArray JNICALL Java_sun_lwawt_macosx_CDataTransferer_imageDataToPlatformImageBytes
-(JNIEnv *env, jobject obj, jintArray inPixelData, jint inWidth, jint inHeight)
-{
-    jbyteArray returnValue = nil;
-JNF_COCOA_ENTER(env);
-    UInt32 *rawImageData = (UInt32 *)(*env)->GetPrimitiveArrayCritical(env, inPixelData, 0);
-
-    // The pixel data is in premultiplied ARGB format. That's exactly what
-    // we need for the bitmap image rep.
-    if (rawImageData != NULL) {
-        NSBitmapImageRep *imageRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
-                                                                             pixelsWide:inWidth
-                                                                             pixelsHigh:inHeight
-                                                                          bitsPerSample:8
-                                                                        samplesPerPixel:4
-                                                                               hasAlpha:YES
-                                                                               isPlanar:NO
-                                                                         colorSpaceName:NSCalibratedRGBColorSpace
-                                                                            bytesPerRow:(inWidth*4)
-                                                                           bitsPerPixel:32];
-
-        // Conver the ARGB data into RGBA data that the bitmap can draw.
-        unsigned char *destData = [imageRep bitmapData];
-        unsigned char *currentRowBase;
-        jint x, y;
-
-        for (y = 0; y < inHeight; y++) {
-            currentRowBase = destData + y * (inWidth * 4);
-            unsigned char *currElement = currentRowBase;
-            for (x = 0; x < inWidth; x++) {
-                UInt32 currPixel = rawImageData[y * inWidth + x];
-                *currElement++ = ((currPixel & 0xFF0000) >> 16);
-                *currElement++ = ((currPixel & 0xFF00) >> 8);
-                *currElement++ = (currPixel & 0xFF);
-                *currElement++ = ((currPixel & 0xFF000000) >> 24);
-            }
-        }
-
-        (*env)->ReleasePrimitiveArrayCritical(env, inPixelData, rawImageData, JNI_ABORT);
-        NSData *tiffImage = [imageRep TIFFRepresentation];
-        jsize tiffSize = (jsize)[tiffImage length]; // #warning 64-bit: -length returns NSUInteger, but NewByteArray takes jsize
-        returnValue = (*env)->NewByteArray(env, tiffSize);
-        CHECK_NULL_RETURN(returnValue, nil);
-        jbyte *tiffData = (jbyte *)(*env)->GetPrimitiveArrayCritical(env, returnValue, 0);
-        CHECK_NULL_RETURN(tiffData, nil);
-        [tiffImage getBytes:tiffData];
-        (*env)->ReleasePrimitiveArrayCritical(env, returnValue, tiffData, 0); // Do not use JNI_COMMIT, as that will not free the buffer copy when +ProtectJavaHeap is on.
-        [imageRep release];
-    }
-JNF_COCOA_EXIT(env);
-    return returnValue;
-
-}
-
-static jobject getImageForByteStream(JNIEnv *env, jbyteArray sourceData)
-{
-    CHECK_NULL_RETURN(sourceData, NULL);
-
-    jsize sourceSize = (*env)->GetArrayLength(env, sourceData);
-    if (sourceSize == 0) return NULL;
-
-    jbyte *sourceBytes = (*env)->GetPrimitiveArrayCritical(env, sourceData, NULL);
-    CHECK_NULL_RETURN(sourceBytes, NULL);
-    NSData *rawData = [NSData dataWithBytes:sourceBytes length:sourceSize];
-
-    NSImage *newImage = [[NSImage alloc] initWithData:rawData];
-    if (newImage) CFRetain(newImage); // GC
-    [newImage release];
-
-    (*env)->ReleasePrimitiveArrayCritical(env, sourceData, sourceBytes, JNI_ABORT);
-    CHECK_NULL_RETURN(newImage, NULL);
-
-    // The ownership of the NSImage is passed to the new CImage jobject. No need to release it.
-    static JNF_CLASS_CACHE(jc_CImage, "sun/lwawt/macosx/CImage");
-    static JNF_STATIC_MEMBER_CACHE(jm_CImage_getCreator, jc_CImage, "getCreator", "()Lsun/lwawt/macosx/CImage$Creator;");
-    jobject creator = JNFCallStaticObjectMethod(env, jm_CImage_getCreator);
-
-    static JNF_CLASS_CACHE(jc_CImage_Generator, "sun/lwawt/macosx/CImage$Creator");
-    static JNF_MEMBER_CACHE(jm_CImage_Generator_createImageUsingNativeSize, jc_CImage_Generator, "createImageUsingNativeSize", "(J)Ljava/awt/image/BufferedImage;");
-    return JNFCallObjectMethod(env, creator, jm_CImage_Generator_createImageUsingNativeSize, ptr_to_jlong(newImage)); // AWT_THREADING Safe (known object)
-}
-
-/*
- * Class:     sun_lwawt_macosx_CDataTransferer
- * Method:    getImageForByteStream
- * Signature: ([B)Ljava/awt/Image;
- */
-JNIEXPORT jobject JNICALL Java_sun_lwawt_macosx_CDataTransferer_getImageForByteStream
-  (JNIEnv *env, jobject obj, jbyteArray sourceData)
-{
-    jobject img = NULL;
-JNF_COCOA_ENTER(env);
-    img = getImageForByteStream(env, sourceData);
-JNF_COCOA_EXIT(env);
-    return img;
-}
-
 static jobjectArray CreateJavaFilenameArray(JNIEnv *env, NSArray *filenameArray)
 {
     NSUInteger filenameCount = [filenameArray count];
--- a/src/macosx/native/sun/awt/CDragSource.m	Thu Jul 23 10:59:55 2015 -0700
+++ b/src/macosx/native/sun/awt/CDragSource.m	Tue Jul 28 23:12:54 2015 -0700
@@ -318,8 +318,7 @@
 
                     // This is a good approximation if not perfect. A conclusive search would
                     // have to be done matching all defined strings in AppKit's commonStrings.h.
-                    if ([type hasPrefix:@"NS"] || [type hasPrefix:@"NeXT"])
-                        hasNSTypeData = true;
+                    hasNSTypeData = [type hasPrefix:@"NS"] || [type hasPrefix:@"NeXT"] || [type hasPrefix:@"public."];
                 }
             }
         }
--- a/src/macosx/native/sun/awt/CDropTarget.m	Thu Jul 23 10:59:55 2015 -0700
+++ b/src/macosx/native/sun/awt/CDropTarget.m	Tue Jul 28 23:12:54 2015 -0700
@@ -106,6 +106,7 @@
         NSFilenamesPboardType,
         NSPostScriptPboardType,
         NSTIFFPboardType,
+        NSPasteboardTypePNG,
         NSRTFPboardType,
         NSTabularTextPboardType,
         NSFontPboardType,
@@ -119,6 +120,7 @@
         NSVCardPboardType,
         NSFilesPromisePboardType,
         [DnDUtilities javaPboardType],
+        (NSString*)kUTTypeJPEG,
         nil];
 
     // Enable dragging events over this object:
--- a/src/macosx/native/sun/awt/CImage.m	Thu Jul 23 10:59:55 2015 -0700
+++ b/src/macosx/native/sun/awt/CImage.m	Tue Jul 28 23:12:54 2015 -0700
@@ -112,7 +112,7 @@
     jlong result = 0L;
 
 JNF_COCOA_ENTER(env);
-
+    
     NSBitmapImageRep* imageRep = CImage_CreateImageRep(env, buffer, width, height);
     if (imageRep) {
         NSImage *nsImage = [[NSImage alloc] initWithSize:NSMakeSize(width, height)];
@@ -435,4 +435,64 @@
 JNF_COCOA_EXIT(env);
 
     return jreturnArray;
-}
\ No newline at end of file
+}
+
+/*
+ * Class:     sun_lwawt_macosx_CImage
+ * Method:    nativeGetPlatformImageBytes
+ * Signature: ([III)[B
+ */
+JNIEXPORT jbyteArray JNICALL Java_sun_lwawt_macosx_CImage_nativeGetPlatformImageBytes
+(JNIEnv *env, jclass klass, jintArray buffer, jint width, jint height)
+{
+    jbyteArray result = 0L;
+    
+    JNF_COCOA_ENTER(env);
+    
+    NSBitmapImageRep* imageRep = [CImage_CreateImageRep(env, buffer, width, height) autorelease];
+    if (imageRep) {
+        NSData *tiffImage = [imageRep TIFFRepresentation];
+        jsize tiffSize = (jsize)[tiffImage length];
+        result = (*env)->NewByteArray(env, tiffSize);
+        CHECK_NULL_RETURN(result, nil);
+        jbyte *tiffData = (jbyte *)(*env)->GetPrimitiveArrayCritical(env, result, 0);
+        CHECK_NULL_RETURN(tiffData, nil);
+        [tiffImage getBytes:tiffData];
+        (*env)->ReleasePrimitiveArrayCritical(env, result, tiffData, 0);
+    }
+    
+    JNF_COCOA_EXIT(env);
+    
+    return result;
+}
+
+/*
+ * Class:     sun_lwawt_macosx_CImage
+ * Method:    nativeCreateNSImageFromBytes
+ * Signature: ([B)J
+ */
+JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CImage_nativeCreateNSImageFromBytes
+(JNIEnv *env, jclass klass, jbyteArray sourceData)
+{
+    jlong result = 0L;
+    CHECK_NULL_RETURN(sourceData, 0L);
+    
+    JNF_COCOA_ENTER(env);
+    
+    jsize sourceSize = (*env)->GetArrayLength(env, sourceData);
+    if (sourceSize == 0) return 0L;
+    
+    jbyte *sourceBytes = (*env)->GetPrimitiveArrayCritical(env, sourceData, NULL);
+    CHECK_NULL_RETURN(sourceBytes, 0L);
+    NSData *rawData = [NSData dataWithBytes:sourceBytes length:sourceSize];    
+    NSImage *newImage = [[NSImage alloc] initWithData:rawData];
+    
+    (*env)->ReleasePrimitiveArrayCritical(env, sourceData, sourceBytes, JNI_ABORT);
+    CHECK_NULL_RETURN(newImage, 0L);
+    
+    result = ptr_to_jlong(newImage);
+    JNF_COCOA_EXIT(env);
+    
+    return result;
+}
+
--- a/src/solaris/classes/sun/awt/X11GraphicsDevice.java	Thu Jul 23 10:59:55 2015 -0700
+++ b/src/solaris/classes/sun/awt/X11GraphicsDevice.java	Tue Jul 28 23:12:54 2015 -0700
@@ -318,6 +318,7 @@
     @Override
     public boolean isDisplayChangeSupported() {
         return (isFullScreenSupported()
+                && (getFullScreenWindow() != null)
                 && !((X11GraphicsEnvironment) GraphicsEnvironment
                         .getLocalGraphicsEnvironment()).runningXinerama());
     }
--- a/src/windows/native/sun/security/krb5/NativeCreds.c	Thu Jul 23 10:59:55 2015 -0700
+++ b/src/windows/native/sun/security/krb5/NativeCreds.c	Tue Jul 28 23:12:54 2015 -0700
@@ -389,7 +389,7 @@
     jobject authTime, renewTillTime, hostAddresses = NULL;
     KERB_EXTERNAL_TICKET *msticket;
     int found = 0;
-    FILETIME Now, EndTime, LocalEndTime;
+    FILETIME Now, EndTime;
 
     int i, netypes;
     jint *etypes = NULL;
@@ -476,8 +476,7 @@
             GetSystemTimeAsFileTime(&Now);
             EndTime.dwLowDateTime = msticket->EndTime.LowPart;
             EndTime.dwHighDateTime = msticket->EndTime.HighPart;
-            FileTimeToLocalFileTime(&EndTime, &LocalEndTime);
-            if (CompareFileTime(&Now, &LocalEndTime) < 0) {
+            if (CompareFileTime(&Now, &EndTime) < 0) {
                 for (i=0; i<netypes; i++) {
                     if (etypes[i] == msticket->SessionKey.KeyType) {
                         found = 1;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/dnd/ImageTransferTest/ImageTransferTest.java	Tue Jul 28 23:12:54 2015 -0700
@@ -0,0 +1,412 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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 4397404 4720930
+  @summary tests that images of all supported native image formats are transfered properly
+  @library ../../regtesthelpers/process/
+  @build ProcessResults ProcessCommunicator
+  @author gas@sparc.spb.su area=Clipboard
+  @run main ImageTransferTest
+*/
+
+import sun.awt.OSInfo;
+import sun.awt.SunToolkit;
+import test.java.awt.regtesthelpers.process.ProcessCommunicator;
+import test.java.awt.regtesthelpers.process.ProcessResults;
+
+import java.awt.*;
+import java.awt.datatransfer.DataFlavor;
+import java.awt.datatransfer.SystemFlavorMap;
+import java.awt.datatransfer.Transferable;
+import java.awt.datatransfer.UnsupportedFlavorException;
+import java.awt.dnd.DnDConstants;
+import java.awt.dnd.DragSource;
+import java.awt.dnd.DragSourceAdapter;
+import java.awt.dnd.DragSourceDropEvent;
+import java.awt.dnd.DragSourceListener;
+import java.awt.dnd.DropTarget;
+import java.awt.dnd.DropTargetAdapter;
+import java.awt.dnd.DropTargetDropEvent;
+import java.awt.event.InputEvent;
+import java.awt.image.BufferedImage;
+import java.awt.image.MemoryImageSource;
+import java.util.stream.Stream;
+
+public class ImageTransferTest {
+    public static void main(String[] arg) throws Exception {
+        ImageDragSource ids = new ImageDragSource();
+        ids.frame.setLocation(100, 100);
+        ids.frame.setVisible(true);
+        Util.sync();
+        String classpath = System.getProperty("java.class.path");
+        String[] args = new String[ids.formats.length + 4];
+        args[0] = "200";
+        args[1] = "100";
+        args[2] = args[3] = "150";
+
+        System.arraycopy(ids.formats, 0, args, 4, ids.formats.length);
+        ProcessResults pres = ProcessCommunicator.executeChildProcess(ImageDropTarget.class, classpath, args);
+
+        if (pres.getStdErr() != null && pres.getStdErr().length() > 0) {
+            System.err.println("========= Child VM System.err ========");
+            System.err.print(pres.getStdErr());
+            System.err.println("======================================");
+        }
+
+        if (pres.getStdOut() != null && pres.getStdOut().length() > 0) {
+            System.err.println("========= Child VM System.out ========");
+            System.err.print(pres.getStdOut());
+            System.err.println("======================================");
+        }
+
+        boolean failed = false;
+        String passedFormats = "";
+        String failedFormats = "";
+
+        for (int i = 0; i < ids.passedArray.length; i++) {
+            if (ids.passedArray[i]) passedFormats += ids.formats[i] + " ";
+            else {
+                failed = true;
+                failedFormats += ids.formats[i] + " ";
+            }
+        }
+
+        if (failed) {
+            throw new RuntimeException("test failed: images in following " +
+                    "native formats are not transferred properly: " + failedFormats);
+        } else {
+            System.err.println("images in following " +
+                    "native formats are transferred properly: " + passedFormats);
+        }
+    }
+}
+
+
+class Util {
+    public static void sync() {
+        ((SunToolkit) Toolkit.getDefaultToolkit()).realSync();
+        try {
+            Thread.sleep(500);
+        } catch (InterruptedException e) {
+            throw new RuntimeException(e);
+        }
+    }
+}
+
+abstract class ImageTransferer {
+    Image image;
+    String[] formats;
+    int fi; // current format index
+    Frame frame = new Frame();
+
+
+    ImageTransferer() {
+        image = createImage();
+        frame.setSize(100, 100);
+    }
+
+    private static Image createImage() {
+        int w = 100;
+        int h = 100;
+        int[] pix = new int[w * h];
+
+        int index = 0;
+        for (int y = 0; y < h; y++) {
+            for (int x = 0; x < w; x++) {
+                int red = 127;
+                int green = 127;
+                int blue = y > h / 2 ? 127 : 0;
+                int alpha = 255;
+                if (x < w / 4 && y < h / 4) {
+                    alpha = 0;
+                    red = 0;
+                }
+                pix[index++] = (alpha << 24) | (red << 16) | (green << 8) | blue;
+            }
+        }
+        return Toolkit.getDefaultToolkit().createImage(new MemoryImageSource(w, h, pix, 0, w));
+    }
+
+
+    static String[] retrieveFormatsToTest() {
+        SystemFlavorMap sfm = (SystemFlavorMap) SystemFlavorMap.getDefaultFlavorMap();
+        java.util.List<String> ln = sfm.getNativesForFlavor(DataFlavor.imageFlavor);
+        if (OSInfo.OSType.WINDOWS.equals(OSInfo.getOSType()) && !ln.contains("METAFILEPICT")) {
+            // for test failing on JDK without this fix
+            ln.add("METAFILEPICT");
+        }
+        return ln.toArray(new String[ln.size()]);
+    }
+
+    static void leaveFormat(String format) {
+        SystemFlavorMap sfm = (SystemFlavorMap) SystemFlavorMap.getDefaultFlavorMap();
+        sfm.setFlavorsForNative(format, new DataFlavor[]{DataFlavor.imageFlavor});
+        sfm.setNativesForFlavor(DataFlavor.imageFlavor, new String[]{format});
+    }
+
+
+    boolean areImagesIdentical(Image im1, Image im2) {
+        if (formats[fi].equals("JFIF") || formats[fi].equals("image/jpeg") ||
+                formats[fi].equals("GIF") || formats[fi].equals("image/gif")) {
+            // JFIF and GIF are lossy formats
+            return true;
+        }
+        int[] ib1 = getImageData(im1);
+        int[] ib2 = getImageData(im2);
+
+        if (ib1.length != ib2.length) {
+            return false;
+        }
+
+        if (formats[fi].equals("PNG") ||
+                formats[fi].equals("image/png") ||
+                formats[fi].equals("image/x-png")) {
+            // check alpha as well
+            for (int i = 0; i < ib1.length; i++) {
+                if (ib1[i] != ib2[i]) {
+                    System.err.println("different pixels: " +
+                            Integer.toHexString(ib1[i]) + " " +
+                            Integer.toHexString(ib2[i]));
+                    return false;
+                }
+            }
+        } else {
+            for (int i = 0; i < ib1.length; i++) {
+                if ((ib1[i] & 0x00FFFFFF) != (ib2[i] & 0x00FFFFFF)) {
+                    System.err.println("different pixels: " +
+                            Integer.toHexString(ib1[i]) + " " +
+                            Integer.toHexString(ib2[i]));
+                    return false;
+                }
+            }
+        }
+        return true;
+    }
+
+    private static int[] getImageData(Image image) {
+        int width = image.getWidth(null);
+        int height = image.getHeight(null);
+        BufferedImage bimage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
+        Graphics2D g2d = bimage.createGraphics();
+        try {
+            g2d.drawImage(image, 0, 0, width, height, null);
+        } finally {
+            g2d.dispose();
+        }
+        return bimage.getRGB(0, 0, width, height, null, 0, width);
+    }
+
+    public static int sign(int n) {
+        return n < 0 ? -1 : n == 0 ? 0 : 1;
+    }
+
+}
+
+
+class ImageDragSource extends ImageTransferer {
+    boolean[] passedArray;
+
+    ImageDragSource() {
+        formats = retrieveFormatsToTest();
+        passedArray = new boolean[formats.length];
+        final DragSourceListener dsl = new DragSourceAdapter() {
+            public void dragDropEnd(DragSourceDropEvent e) {
+                System.err.println("Drop was successful=" + e.getDropSuccess());
+                notifyTransferSuccess(e.getDropSuccess());
+                if (++fi < formats.length) {
+                    leaveFormat(formats[fi]);
+                }
+            }
+        };
+
+        new DragSource().createDefaultDragGestureRecognizer(frame,
+                DnDConstants.ACTION_COPY,
+                dge -> dge.startDrag(null, new ImageSelection(image), dsl));
+        leaveFormat(formats[fi]);
+    }
+
+
+    void notifyTransferSuccess(boolean status) {
+        passedArray[fi] = status;
+    }
+}
+
+
+class ImageDropTarget extends ImageTransferer {
+    private final Robot robot;
+    private static Point startPoint, endPoint = new Point(250, 150);
+
+    ImageDropTarget() throws AWTException {
+        DropTargetAdapter dropTargetAdapter = new DropTargetAdapter() {
+            @Override
+            public void drop(DropTargetDropEvent dtde) {
+                checkImage(dtde);
+                startImageDrag();
+            }
+        };
+        new DropTarget(frame, dropTargetAdapter);
+        robot = new Robot();
+    }
+
+
+    void checkImage(DropTargetDropEvent dtde) {
+        final Transferable t = dtde.getTransferable();
+        if (t.isDataFlavorSupported(DataFlavor.imageFlavor)) {
+            dtde.acceptDrop(DnDConstants.ACTION_COPY);
+            Image im;
+            try {
+                im = (Image) t.getTransferData(DataFlavor.imageFlavor);
+                System.err.println("getTransferData was successful");
+            } catch (Exception e) {
+                System.err.println("Can't getTransferData: " + e);
+                dtde.dropComplete(false);
+                notifyTransferSuccess(false);
+                return;
+            }
+
+            if (im == null) {
+                System.err.println("getTransferData returned null");
+                dtde.dropComplete(false);
+                notifyTransferSuccess(false);
+            } else if (areImagesIdentical(image, im)) {
+                dtde.dropComplete(true);
+                notifyTransferSuccess(true);
+            } else {
+                System.err.println("transferred image is different from initial image");
+                dtde.dropComplete(false);
+                notifyTransferSuccess(false);
+            }
+
+        } else {
+            System.err.println("imageFlavor is not supported by Transferable");
+            dtde.rejectDrop();
+            notifyTransferSuccess(false);
+        }
+    }
+
+    void startImageDrag() {
+        leaveFormat(formats[fi]);
+        new Thread(() -> {
+            try {
+                Thread.sleep(1000);
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+                // Exit from the child process
+                System.exit(1);
+            }
+            robot.mouseMove(startPoint.x, startPoint.y);
+            robot.mousePress(InputEvent.BUTTON1_MASK);
+            for (Point p = new Point(startPoint); !p.equals(endPoint);
+                 p.translate(sign(endPoint.x - p.x), sign(endPoint.y - p.y))) {
+                robot.mouseMove(p.x, p.y);
+                try {
+                    Thread.sleep(50);
+                } catch (InterruptedException e) {
+                    e.printStackTrace();
+                }
+            }
+
+            robot.mouseRelease(InputEvent.BUTTON1_MASK);
+        }).start();
+    }
+
+    void notifyTransferSuccess(boolean status) {
+        if (status) {
+            System.err.println("format passed: " + formats[fi]);
+        } else {
+            System.err.println("format failed: " + formats[fi]);
+            System.exit(1);
+        }
+        if (fi < formats.length - 1) {
+            leaveFormat(formats[++fi]);
+        } else {
+            new Thread(() -> {
+                try {
+                    Thread.sleep(500);
+                } catch (InterruptedException e) {
+                    e.printStackTrace();
+                }
+                System.exit(0);
+            }).start();
+        }
+    }
+
+
+    public static void main(String[] args) {
+        try {
+            ImageDropTarget idt = new ImageDropTarget();
+
+            int x = Integer.parseInt(args[0]);
+            int y = Integer.parseInt(args[1]);
+            startPoint = new Point(Integer.parseInt(args[2]), Integer.parseInt(args[3]));
+
+            idt.formats = new String[args.length - 4];
+            System.arraycopy(args, 4, idt.formats, 0, args.length - 4);
+            leaveFormat(idt.formats[0]);
+
+            idt.frame.setLocation(x, y);
+            idt.frame.setVisible(true);
+            Util.sync();
+
+            idt.startImageDrag();
+        } catch (Throwable e) {
+            e.printStackTrace();
+            System.exit(1);
+        }
+    }
+
+}
+
+
+class ImageSelection implements Transferable {
+    private static final int IMAGE = 0;
+    private static final DataFlavor[] flavors = {DataFlavor.imageFlavor};
+    private Image data;
+
+    public ImageSelection(Image data) {
+        this.data = data;
+    }
+
+    @Override
+    public DataFlavor[] getTransferDataFlavors() {
+        // returning flavors itself would allow client code to modify
+        // our internal behavior
+        return flavors.clone();
+    }
+
+    @Override
+    public boolean isDataFlavorSupported(DataFlavor flavor) {
+        return Stream.of(flavor).anyMatch(flavor::equals);
+    }
+
+    @Override
+    public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException {
+        if (flavor.equals(flavors[IMAGE])) {
+            return data;
+        } else {
+            throw new UnsupportedFlavorException(flavor);
+        }
+    }
+}
--- a/test/javax/swing/JFileChooser/8002077/bug8002077.java	Thu Jul 23 10:59:55 2015 -0700
+++ b/test/javax/swing/JFileChooser/8002077/bug8002077.java	Tue Jul 28 23:12:54 2015 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -47,6 +47,8 @@
         for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
             if ("Nimbus".equals(info.getName())) {
                 UIManager.setLookAndFeel(info.getClassName());
+                UIManager.put("FileChooser.openButtonMnemonic", KeyEvent.VK_O);
+                UIManager.put("FileChooser.saveButtonMnemonic", KeyEvent.VK_S);
                 runTest();
                 break;
             }
@@ -58,24 +60,24 @@
         Robot robot = new Robot();
         robot.setAutoDelay(50);
 
-        SwingUtilities.invokeLater(new Runnable() {
-            public void run() {
-                fileChooserState = new JFileChooser().showSaveDialog(null);
-            }
-        });
+        SwingUtilities.invokeLater(() ->
+                fileChooserState = new JFileChooser().showSaveDialog(null));
         toolkit.realSync();
 
         Util.hitMnemonics(robot, KeyEvent.VK_N);
         toolkit.realSync();
 
-        robot.keyPress(KeyEvent.VK_A);
-        robot.keyRelease(KeyEvent.VK_A);
+        Util.hitKeys(robot, KeyEvent.VK_A);
         toolkit.realSync();
 
         Util.hitMnemonics(robot, KeyEvent.VK_S);
         toolkit.realSync();
 
         if (fileChooserState != JFileChooser.APPROVE_OPTION) {
+            // Close the dialog
+            Util.hitKeys(robot, KeyEvent.VK_ESCAPE);
+            toolkit.realSync();
+
             throw new RuntimeException("Save button is not pressed!");
         }
     }