Merge
diff --git a/.hgtags b/.hgtags
index 116dcf0..7be0eb3 100644
--- a/.hgtags
+++ b/.hgtags
@@ -210,3 +210,5 @@
7989cd0cc3a9149864589438ee2c949015d8aa9a jdk8-b86
d5228e624826a10ccc5b05f30ad8d839b58fe48d jdk8-b87
8dbb4b159e04de3c447c9242c70505e71f8624c7 jdk8-b88
+845025546e35519fbb8970e79fc2a834063a5e19 jdk8-b89
+c63eda8f63008a4398d2c22ac8d72f7fef6f9238 jdk8-b90
diff --git a/make/sun/awt/mapfile-vers b/make/sun/awt/mapfile-vers
index 5c6cfea..f68ef5c 100644
--- a/make/sun/awt/mapfile-vers
+++ b/make/sun/awt/mapfile-vers
@@ -87,6 +87,7 @@
Java_sun_java2d_pipe_ShapeSpanIterator_skipDownTo;
Java_java_awt_Dimension_initIDs;
+ Java_java_awt_Choice_initIDs;
Java_java_awt_event_MouseEvent_initIDs;
Java_java_awt_image_DataBufferInt_initIDs;
Java_java_awt_image_SinglePixelPackedSampleModel_initIDs;
diff --git a/make/sun/awt/mapfile-vers-bsd b/make/sun/awt/mapfile-vers-bsd
index f606b3f..dcc59f0 100644
--- a/make/sun/awt/mapfile-vers-bsd
+++ b/make/sun/awt/mapfile-vers-bsd
@@ -87,6 +87,7 @@
Java_sun_java2d_pipe_ShapeSpanIterator_skipDownTo;
Java_java_awt_Dimension_initIDs;
+ Java_java_awt_Choice_initIDs;
Java_java_awt_event_MouseEvent_initIDs;
Java_java_awt_image_DataBufferInt_initIDs;
Java_java_awt_image_SinglePixelPackedSampleModel_initIDs;
diff --git a/make/sun/awt/mapfile-vers-linux b/make/sun/awt/mapfile-vers-linux
index b7033b8..03f0cc0 100644
--- a/make/sun/awt/mapfile-vers-linux
+++ b/make/sun/awt/mapfile-vers-linux
@@ -87,6 +87,7 @@
Java_sun_java2d_pipe_ShapeSpanIterator_skipDownTo;
Java_java_awt_Dimension_initIDs;
+ Java_java_awt_Choice_initIDs;
Java_java_awt_event_MouseEvent_initIDs;
Java_java_awt_image_DataBufferInt_initIDs;
Java_java_awt_image_SinglePixelPackedSampleModel_initIDs;
diff --git a/makefiles/mapfiles/libawt/mapfile-vers b/makefiles/mapfiles/libawt/mapfile-vers
index 924a282..8af9d14 100644
--- a/makefiles/mapfiles/libawt/mapfile-vers
+++ b/makefiles/mapfiles/libawt/mapfile-vers
@@ -86,6 +86,7 @@
Java_sun_java2d_pipe_ShapeSpanIterator_setRule;
Java_sun_java2d_pipe_ShapeSpanIterator_skipDownTo;
+ Java_java_awt_Choice_initIDs;
Java_java_awt_Dimension_initIDs;
Java_java_awt_event_MouseEvent_initIDs;
Java_java_awt_image_DataBufferInt_initIDs;
diff --git a/makefiles/mapfiles/libawt/mapfile-vers-linux b/makefiles/mapfiles/libawt/mapfile-vers-linux
index 2514670..b0bfb1c 100644
--- a/makefiles/mapfiles/libawt/mapfile-vers-linux
+++ b/makefiles/mapfiles/libawt/mapfile-vers-linux
@@ -86,6 +86,7 @@
Java_sun_java2d_pipe_ShapeSpanIterator_setRule;
Java_sun_java2d_pipe_ShapeSpanIterator_skipDownTo;
+ Java_java_awt_Choice_initIDs;
Java_java_awt_Dimension_initIDs;
Java_java_awt_event_MouseEvent_initIDs;
Java_java_awt_image_DataBufferInt_initIDs;
diff --git a/src/macosx/classes/sun/lwawt/LWScrollBarPeer.java b/src/macosx/classes/sun/lwawt/LWScrollBarPeer.java
index dff48a4..f5cb0d5 100644
--- a/src/macosx/classes/sun/lwawt/LWScrollBarPeer.java
+++ b/src/macosx/classes/sun/lwawt/LWScrollBarPeer.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -56,6 +56,8 @@
void initializeImpl() {
super.initializeImpl();
final Scrollbar target = getTarget();
+ setLineIncrement(target.getUnitIncrement());
+ setPageIncrement(target.getBlockIncrement());
setValues(target.getValue(), target.getVisibleAmount(),
target.getMinimum(), target.getMaximum());
diff --git a/src/macosx/classes/sun/lwawt/LWToolkit.java b/src/macosx/classes/sun/lwawt/LWToolkit.java
index cad6e43..6ff3530 100644
--- a/src/macosx/classes/sun/lwawt/LWToolkit.java
+++ b/src/macosx/classes/sun/lwawt/LWToolkit.java
@@ -53,7 +53,12 @@
private Clipboard clipboard;
private MouseInfoPeer mouseInfoPeer;
- public LWToolkit() {
+ /**
+ * Dynamic Layout Resize client code setting.
+ */
+ private volatile boolean dynamicLayoutSetting = true;
+
+ protected LWToolkit() {
}
/*
@@ -561,4 +566,37 @@
((LWWindowPeer)w.getPeer()).ungrab(false);
}
}
+
+ @Override
+ protected final Object lazilyLoadDesktopProperty(final String name) {
+ if (name.equals("awt.dynamicLayoutSupported")) {
+ return isDynamicLayoutSupported();
+ }
+ return super.lazilyLoadDesktopProperty(name);
+ }
+
+ @Override
+ public final void setDynamicLayout(final boolean dynamic) {
+ dynamicLayoutSetting = dynamic;
+ }
+
+ @Override
+ protected final boolean isDynamicLayoutSet() {
+ return dynamicLayoutSetting;
+ }
+
+ @Override
+ public final boolean isDynamicLayoutActive() {
+ // "Live resizing" is active by default and user's data is ignored.
+ return isDynamicLayoutSupported();
+ }
+
+ /**
+ * Returns true if dynamic layout of Containers on resize is supported by
+ * the underlying operating system and/or window manager.
+ */
+ protected final boolean isDynamicLayoutSupported() {
+ // "Live resizing" is supported by default.
+ return true;
+ }
}
diff --git a/src/macosx/classes/sun/lwawt/macosx/CPrinterJob.java b/src/macosx/classes/sun/lwawt/macosx/CPrinterJob.java
index 791182c..e198024 100644
--- a/src/macosx/classes/sun/lwawt/macosx/CPrinterJob.java
+++ b/src/macosx/classes/sun/lwawt/macosx/CPrinterJob.java
@@ -35,6 +35,7 @@
import javax.print.*;
import javax.print.attribute.PrintRequestAttributeSet;
+import javax.print.attribute.HashPrintRequestAttributeSet;
import sun.java2d.*;
import sun.print.*;
@@ -96,6 +97,14 @@
return false;
}
+ if (attributes == null) {
+ attributes = new HashPrintRequestAttributeSet();
+ }
+
+ if (getPrintService() instanceof StreamPrintService) {
+ return super.printDialog(attributes);
+ }
+
return jobSetup(getPageable(), checkAllowedToPrintToFile());
}
@@ -130,6 +139,10 @@
return page;
}
+ if (getPrintService() instanceof StreamPrintService) {
+ return super.pageDialog(page);
+ }
+
PageFormat pageClone = (PageFormat) page.clone();
boolean doIt = pageSetup(pageClone, null);
return doIt ? pageClone : page;
diff --git a/src/macosx/native/sun/awt/AWTSurfaceLayers.m b/src/macosx/native/sun/awt/AWTSurfaceLayers.m
index 6e9fbbc..d12908c 100644
--- a/src/macosx/native/sun/awt/AWTSurfaceLayers.m
+++ b/src/macosx/native/sun/awt/AWTSurfaceLayers.m
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,6 +28,7 @@
#import "LWCToolkit.h"
#import <JavaNativeFoundation/JavaNativeFoundation.h>
+#import <QuartzCore/CATransaction.h>
@implementation AWTSurfaceLayers
@@ -74,14 +75,12 @@
}
- (void) setBounds:(CGRect)rect {
- layer.anchorPoint = CGPointMake(0, 0);
-
// translates values to the coordinate system of the "root" layer
- CGFloat newY = windowLayer.bounds.size.height - rect.origin.y - rect.size.height;
- CGRect newRect = CGRectMake(rect.origin.x, newY, rect.size.width, rect.size.height);
-
- layer.frame = newRect;
-
+ rect.origin.y = windowLayer.bounds.size.height - rect.origin.y - rect.size.height;
+ [CATransaction begin];
+ [CATransaction setDisableActions:YES];
+ layer.frame = rect;
+ [CATransaction commit];
[AWTSurfaceLayers repaintLayersRecursively:layer];
}
diff --git a/src/macosx/native/sun/java2d/opengl/CGLLayer.m b/src/macosx/native/sun/java2d/opengl/CGLLayer.m
index e0074eb..f300ea4 100644
--- a/src/macosx/native/sun/java2d/opengl/CGLLayer.m
+++ b/src/macosx/native/sun/java2d/opengl/CGLLayer.m
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -64,11 +64,13 @@
//Disable CALayer's default animation
NSMutableDictionary * actions = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
+ [NSNull null], @"anchorPoint",
[NSNull null], @"bounds",
[NSNull null], @"contents",
[NSNull null], @"contentsScale",
[NSNull null], @"onOrderIn",
[NSNull null], @"onOrderOut",
+ [NSNull null], @"position",
[NSNull null], @"sublayers",
nil];
self.actions = actions;
diff --git a/src/share/classes/com/sun/imageio/plugins/gif/GIFImageReader.java b/src/share/classes/com/sun/imageio/plugins/gif/GIFImageReader.java
index d281e11..0fbdefb 100644
--- a/src/share/classes/com/sun/imageio/plugins/gif/GIFImageReader.java
+++ b/src/share/classes/com/sun/imageio/plugins/gif/GIFImageReader.java
@@ -790,16 +790,12 @@
}
private void startPass(int pass) {
- if (updateListeners == null) {
+ if (updateListeners == null || !imageMetadata.interlaceFlag) {
return;
}
- int y = 0;
- int yStep = 1;
- if (imageMetadata.interlaceFlag) {
- y = interlaceOffset[interlacePass];
- yStep = interlaceIncrement[interlacePass];
- }
+ int y = interlaceOffset[interlacePass];
+ int yStep = interlaceIncrement[interlacePass];
int[] vals = ReaderUtil.
computeUpdatedPixels(sourceRegion,
diff --git a/src/share/classes/java/awt/Component.java b/src/share/classes/java/awt/Component.java
index 0dfb999..846ea97 100644
--- a/src/share/classes/java/awt/Component.java
+++ b/src/share/classes/java/awt/Component.java
@@ -1671,6 +1671,15 @@
/* do nothing */
}
+ /*
+ * Delete references from LightweithDispatcher of a heavyweight parent
+ */
+ void clearLightweightDispatcherOnRemove(Component removedComponent) {
+ if (parent != null) {
+ parent.clearLightweightDispatcherOnRemove(removedComponent);
+ }
+ }
+
/**
* @deprecated As of JDK version 1.1,
* replaced by <code>setVisible(boolean)</code>.
@@ -6974,6 +6983,8 @@
}
synchronized (getTreeLock()) {
+ clearLightweightDispatcherOnRemove(this);
+
if (isFocusOwner() && KeyboardFocusManager.isAutoFocusTransferEnabledFor(this)) {
transferFocus(true);
}
diff --git a/src/share/classes/java/awt/Container.java b/src/share/classes/java/awt/Container.java
index 1118852..1525a74 100644
--- a/src/share/classes/java/awt/Container.java
+++ b/src/share/classes/java/awt/Container.java
@@ -3306,6 +3306,16 @@
}
}
+ @Override
+ void clearLightweightDispatcherOnRemove(Component removedComponent) {
+ if (dispatcher != null) {
+ dispatcher.removeReferences(removedComponent);
+ } else {
+ //It is a Lightweight Container, should clear parent`s Dispatcher
+ super.clearLightweightDispatcherOnRemove(removedComponent);
+ }
+ }
+
final Container getTraversalRoot() {
if (isFocusCycleRoot()) {
return findTraversalRoot();
@@ -4411,6 +4421,7 @@
//System.out.println("Disposing lw dispatcher");
stopListeningForOtherDrags();
mouseEventTarget = null;
+ targetLastEntered = null;
}
/**
@@ -4502,6 +4513,7 @@
// MOUSE_CLICKED.
if (!isMouseGrab(e) && id != MouseEvent.MOUSE_CLICKED) {
mouseEventTarget = (mouseOver != nativeContainer) ? mouseOver: null;
+ isCleaned = false;
}
if (mouseEventTarget != null) {
@@ -4545,10 +4557,14 @@
retargetMouseEvent(mouseOver, id, e);
break;
}
- //Consuming of wheel events is implemented in "retargetMouseEvent".
- if (id != MouseEvent.MOUSE_WHEEL) {
- e.consume();
- }
+ //Consuming of wheel events is implemented in "retargetMouseEvent".
+ if (id != MouseEvent.MOUSE_WHEEL) {
+ e.consume();
+ }
+ } else if (isCleaned && id != MouseEvent.MOUSE_WHEEL) {
+ //After mouseEventTarget was removed and cleaned should consume all events
+ //until new mouseEventTarget is found
+ e.consume();
}
return e.isConsumed();
}
@@ -4892,6 +4908,11 @@
private transient Component targetLastEntered;
/**
+ * Indicates whether {@code mouseEventTarget} was removed and nulled
+ */
+ private transient boolean isCleaned;
+
+ /**
* Is the mouse over the native container
*/
private transient boolean isMouseInNativeContainer = false;
@@ -4925,4 +4946,14 @@
AWTEvent.MOUSE_EVENT_MASK |
AWTEvent.MOUSE_MOTION_EVENT_MASK |
AWTEvent.MOUSE_WHEEL_EVENT_MASK;
+
+ void removeReferences(Component removedComponent) {
+ if (mouseEventTarget == removedComponent) {
+ isCleaned = true;
+ mouseEventTarget = null;
+ }
+ if (targetLastEntered == removedComponent) {
+ targetLastEntered = null;
+ }
+ }
}
diff --git a/src/share/classes/java/util/Base64.java b/src/share/classes/java/util/Base64.java
index efb1459..2dbaf92 100644
--- a/src/share/classes/java/util/Base64.java
+++ b/src/share/classes/java/util/Base64.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
diff --git a/src/share/classes/java/util/StringJoiner.java b/src/share/classes/java/util/StringJoiner.java
index 48ceb56..bb6f4c6 100644
--- a/src/share/classes/java/util/StringJoiner.java
+++ b/src/share/classes/java/util/StringJoiner.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
diff --git a/src/share/classes/sun/font/FileFontStrike.java b/src/share/classes/sun/font/FileFontStrike.java
index 6762241..2a8cde5 100644
--- a/src/share/classes/sun/font/FileFontStrike.java
+++ b/src/share/classes/sun/font/FileFontStrike.java
@@ -747,14 +747,9 @@
return origMinX;
}
- long pixelData;
- if (StrikeCache.nativeAddressSize == 4) {
- pixelData = 0xffffffff &
- StrikeCache.unsafe.getInt(ptr + StrikeCache.pixelDataOffset);
- } else {
- pixelData =
- StrikeCache.unsafe.getLong(ptr + StrikeCache.pixelDataOffset);
- }
+ long pixelData =
+ StrikeCache.unsafe.getAddress(ptr + StrikeCache.pixelDataOffset);
+
if (pixelData == 0L) {
return origMinX;
}
diff --git a/src/share/classes/sun/font/GlyphList.java b/src/share/classes/sun/font/GlyphList.java
index c02c7c4..5044604 100644
--- a/src/share/classes/sun/font/GlyphList.java
+++ b/src/share/classes/sun/font/GlyphList.java
@@ -361,16 +361,10 @@
graybits = new byte[len];
}
}
- long pixelDataAddress;
- if (StrikeCache.nativeAddressSize == 4) {
- pixelDataAddress = 0xffffffff &
- StrikeCache.unsafe.getInt(images[glyphindex] +
+ long pixelDataAddress =
+ StrikeCache.unsafe.getAddress(images[glyphindex] +
StrikeCache.pixelDataOffset);
- } else {
- pixelDataAddress =
- StrikeCache.unsafe.getLong(images[glyphindex] +
- StrikeCache.pixelDataOffset);
- }
+
if (pixelDataAddress == 0L) {
return graybits;
}
diff --git a/src/share/classes/sun/print/RasterPrinterJob.java b/src/share/classes/sun/print/RasterPrinterJob.java
index 24bece5..1752016 100644
--- a/src/share/classes/sun/print/RasterPrinterJob.java
+++ b/src/share/classes/sun/print/RasterPrinterJob.java
@@ -607,13 +607,17 @@
protected void updatePageAttributes(PrintService service,
PageFormat page) {
+ if (this.attributes == null) {
+ this.attributes = new HashPrintRequestAttributeSet();
+ }
+
updateAttributesWithPageFormat(service, page, this.attributes);
}
protected void updateAttributesWithPageFormat(PrintService service,
PageFormat page,
- PrintRequestAttributeSet attributes) {
- if (service == null || page == null) {
+ PrintRequestAttributeSet pageAttributes) {
+ if (service == null || page == null || pageAttributes == null) {
return;
}
@@ -653,13 +657,10 @@
orient = OrientationRequested.PORTRAIT;
}
- if (attributes == null) {
- attributes = new HashPrintRequestAttributeSet();
- }
if (media != null) {
- attributes.add(media);
+ pageAttributes.add(media);
}
- attributes.add(orient);
+ pageAttributes.add(orient);
float ix = (float)(page.getPaper().getImageableX()/DPI);
float iw = (float)(page.getPaper().getImageableWidth()/DPI);
@@ -667,7 +668,7 @@
float ih = (float)(page.getPaper().getImageableHeight()/DPI);
if (ix < 0) ix = 0f; if (iy < 0) iy = 0f;
try {
- attributes.add(new MediaPrintableArea(ix, iy, iw, ih,
+ pageAttributes.add(new MediaPrintableArea(ix, iy, iw, ih,
MediaPrintableArea.INCH));
} catch (IllegalArgumentException iae) {
}
diff --git a/src/share/classes/sun/swing/JLightweightFrame.java b/src/share/classes/sun/swing/JLightweightFrame.java
index 162186f..a9ac437 100644
--- a/src/share/classes/sun/swing/JLightweightFrame.java
+++ b/src/share/classes/sun/swing/JLightweightFrame.java
@@ -35,6 +35,7 @@
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import java.awt.image.DataBufferInt;
+import java.security.AccessController;
import javax.swing.JLayeredPane;
import javax.swing.JPanel;
@@ -43,6 +44,7 @@
import javax.swing.RootPaneContainer;
import sun.awt.LightweightFrame;
+import sun.security.action.GetPropertyAction;
/**
* The frame serves as a lightweight container which paints its content
@@ -66,11 +68,27 @@
private BufferedImage bbImage;
/**
+ * {@code copyBufferEnabled}, true by default, defines the following strategy.
+ * A duplicating (copy) buffer is created for the original pixel buffer.
+ * The copy buffer is synchronized with the original buffer every time the
+ * latter changes. {@code JLightweightFrame} passes the copy buffer array
+ * to the {@link LightweightContent#imageBufferReset} method. The code spot
+ * which synchronizes two buffers becomes the only critical section guarded
+ * by the lock (managed with the {@link LightweightContent#paintLock()},
+ * {@link LightweightContent#paintUnlock()} methods).
+ */
+ private boolean copyBufferEnabled;
+ private int[] copyBuffer;
+
+ /**
* Constructs a new, initially invisible {@code JLightweightFrame}
* instance.
*/
public JLightweightFrame() {
super();
+ copyBufferEnabled = "true".equals(AccessController.
+ doPrivileged(new GetPropertyAction("jlf.copyBufferEnabled", "true")));
+
add(rootPane, BorderLayout.CENTER);
setFocusTraversalPolicy(new LayoutFocusTraversalPolicy());
if (getGraphicsConfiguration().isTranslucencyCapable()) {
@@ -124,16 +142,37 @@
if (content != null) content.focusUngrabbed();
}
+ private void syncCopyBuffer(boolean reset, int x, int y, int w, int h) {
+ content.paintLock();
+ try {
+ int[] srcBuffer = ((DataBufferInt)bbImage.getRaster().getDataBuffer()).getData();
+ if (reset) {
+ copyBuffer = new int[srcBuffer.length];
+ }
+ int linestride = bbImage.getWidth();
+
+ for (int i=0; i<h; i++) {
+ int from = (y + i) * linestride + x;
+ System.arraycopy(srcBuffer, from, copyBuffer, from, w);
+ }
+ } finally {
+ content.paintUnlock();
+ }
+ }
+
private void initInterior() {
contentPane = new JPanel() {
@Override
public void paint(Graphics g) {
- content.paintLock();
+ if (!copyBufferEnabled) {
+ content.paintLock();
+ }
try {
super.paint(g);
final Rectangle clip = g.getClipBounds() != null ?
- g.getClipBounds() : new Rectangle(0, 0, contentPane.getWidth(), contentPane.getHeight());
+ g.getClipBounds() :
+ new Rectangle(0, 0, contentPane.getWidth(), contentPane.getHeight());
clip.x = Math.max(0, clip.x);
clip.y = Math.max(0, clip.y);
@@ -143,11 +182,16 @@
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
+ if (copyBufferEnabled) {
+ syncCopyBuffer(false, clip.x, clip.y, clip.width, clip.height);
+ }
content.imageUpdated(clip.x, clip.y, clip.width, clip.height);
}
});
} finally {
- content.paintUnlock();
+ if (!copyBufferEnabled) {
+ content.paintUnlock();
+ }
}
}
@Override
@@ -167,8 +211,9 @@
if (width == 0 || height == 0) {
return;
}
-
- content.paintLock();
+ if (!copyBufferEnabled) {
+ content.paintLock();
+ }
try {
if ((bbImage == null) || (width != bbImage.getWidth()) || (height != bbImage.getHeight())) {
boolean createBB = true;
@@ -204,14 +249,21 @@
oldBB.flush();
}
}
- DataBufferInt dataBuf = (DataBufferInt)bbImage.getRaster().getDataBuffer();
- content.imageBufferReset(dataBuf.getData(), 0, 0, width, height, bbImage.getWidth());
- } else {
- content.imageReshaped(0, 0, width, height);
+ int[] pixels = ((DataBufferInt)bbImage.getRaster().getDataBuffer()).getData();
+ if (copyBufferEnabled) {
+ syncCopyBuffer(true, 0, 0, width, height);
+ pixels = copyBuffer;
+ }
+ content.imageBufferReset(pixels, 0, 0, width, height, bbImage.getWidth());
+ return;
}
}
+ content.imageReshaped(0, 0, width, height);
+
} finally {
- content.paintUnlock();
+ if (!copyBufferEnabled) {
+ content.paintUnlock();
+ }
}
}
diff --git a/src/solaris/classes/sun/font/XRGlyphCacheEntry.java b/src/solaris/classes/sun/font/XRGlyphCacheEntry.java
index 3ed0401..18ece2b 100644
--- a/src/solaris/classes/sun/font/XRGlyphCacheEntry.java
+++ b/src/solaris/classes/sun/font/XRGlyphCacheEntry.java
@@ -69,11 +69,28 @@
}
public static int getGlyphID(long glyphInfoPtr) {
- return (int) StrikeCache.unsafe.getInt(glyphInfoPtr + StrikeCache.cacheCellOffset);
+ // We need to access the GlyphID with Unsafe.getAddress() because the
+ // corresponding field in the underlying C data-structure is of type
+ // 'void*' (see field 'cellInfo' of struct 'GlyphInfo'
+ // in src/share/native/sun/font/fontscalerdefs.h).
+ // On 64-bit Big-endian architectures it would be wrong to access this
+ // field with Unsafe.getInt().
+ return (int) StrikeCache.unsafe.getAddress(glyphInfoPtr +
+ StrikeCache.cacheCellOffset);
}
public static void setGlyphID(long glyphInfoPtr, int id) {
- StrikeCache.unsafe.putInt(glyphInfoPtr + StrikeCache.cacheCellOffset, id);
+ // We need to access the GlyphID with Unsafe.putAddress() because the
+ // corresponding field in the underlying C data-structure is of type
+ // 'void*' (see field 'cellInfo' of struct 'GlyphInfo' in
+ // src/share/native/sun/font/fontscalerdefs.h).
+ // On 64-bit Big-endian architectures it would be wrong to write this
+ // field with Unsafe.putInt() because it is also accessed from native
+ // code as a 'long'.
+ // See Java_sun_java2d_xr_XRBackendNative_XRAddGlyphsNative()
+ // in src/solaris/native/sun/java2d/x11/XRBackendNative.c
+ StrikeCache.unsafe.putAddress(glyphInfoPtr +
+ StrikeCache.cacheCellOffset, (long)id);
}
public int getGlyphID() {
@@ -105,12 +122,9 @@
}
public void writePixelData(ByteArrayOutputStream os, boolean uploadAsLCD) {
- long pixelDataAddress;
- if (StrikeCache.nativeAddressSize == 4) {
- pixelDataAddress = 0xffffffff & StrikeCache.unsafe.getInt(glyphInfoPtr + StrikeCache.pixelDataOffset);
- } else {
- pixelDataAddress = StrikeCache.unsafe.getLong(glyphInfoPtr + StrikeCache.pixelDataOffset);
- }
+ long pixelDataAddress =
+ StrikeCache.unsafe.getAddress(glyphInfoPtr +
+ StrikeCache.pixelDataOffset);
if (pixelDataAddress == 0L) {
return;
}
diff --git a/src/solaris/native/sun/java2d/x11/XRBackendNative.c b/src/solaris/native/sun/java2d/x11/XRBackendNative.c
index 0f8d0a8..3b38bba 100644
--- a/src/solaris/native/sun/java2d/x11/XRBackendNative.c
+++ b/src/solaris/native/sun/java2d/x11/XRBackendNative.c
@@ -742,7 +742,12 @@
for (i=0; i < glyphCnt; i++) {
GlyphInfo *jginfo = (GlyphInfo *) jlong_to_ptr(glyphInfoPtrs[i]);
- gid[i] = (Glyph) (0x0ffffffffL & ((unsigned long)(jginfo->cellInfo)));
+ // 'jginfo->cellInfo' is of type 'void*'
+ // (see definition of 'GlyphInfo' in fontscalerdefs.h)
+ // 'Glyph' is typedefed to 'unsigned long'
+ // (see http://www.x.org/releases/X11R7.7/doc/libXrender/libXrender.txt)
+ // Maybe we should assert that (sizeof(void*) == sizeof(Glyph)) ?
+ gid[i] = (Glyph) (jginfo->cellInfo);
xginfo[i].x = (-jginfo->topLeftX);
xginfo[i].y = (-jginfo->topLeftY);
xginfo[i].width = jginfo->width;
diff --git a/src/windows/native/sun/java2d/d3d/D3DBadHardware.h b/src/windows/native/sun/java2d/d3d/D3DBadHardware.h
index 5160b16..379a167 100644
--- a/src/windows/native/sun/java2d/d3d/D3DBadHardware.h
+++ b/src/windows/native/sun/java2d/d3d/D3DBadHardware.h
@@ -51,9 +51,105 @@
static const ADAPTER_INFO badHardware[] = {
- // any Intel chip
- // Reason: workaround for 6620073, 6612195, 6620073
- { 0x8086, ALL_DEVICEIDS, NO_VERSION, OS_ALL },
+ // Intel HD
+ // Clarkdale (Desktop) GMA HD Lines
+ { 0x8086, 0x0042, D_VERSION(6,14,10,5337), OS_WINXP | OS_WINXP_64 },
+ { 0x8086, 0x0042, D_VERSION(8,15,10,2302), OS_VISTA | OS_WINDOWS7 },
+ // Arrandale (Mobile) GMA HD Lines
+ { 0x8086, 0x0046, D_VERSION(6,14,10,5337), OS_WINXP | OS_WINXP_64 },
+ { 0x8086, 0x0046, D_VERSION(8,15,10,2302), OS_VISTA | OS_WINDOWS7 },
+ // Sandy Bridge GMA HD Lines
+ { 0x8086, 0x0102, D_VERSION(6,14,10,5337), OS_WINXP | OS_WINXP_64 },
+ { 0x8086, 0x0102, D_VERSION(8,15,10,2302), OS_VISTA | OS_WINDOWS7 },
+ { 0x8086, 0x0106, D_VERSION(6,14,10,5337), OS_WINXP | OS_WINXP_64 },
+ { 0x8086, 0x0106, D_VERSION(8,15,10,2302), OS_VISTA | OS_WINDOWS7 },
+ { 0x8086, 0x0112, D_VERSION(6,14,10,5337), OS_WINXP | OS_WINXP_64 },
+ { 0x8086, 0x0112, D_VERSION(8,15,10,2302), OS_VISTA | OS_WINDOWS7 },
+ { 0x8086, 0x0116, D_VERSION(6,14,10,5337), OS_WINXP | OS_WINXP_64 },
+ { 0x8086, 0x0116, D_VERSION(8,15,10,2302), OS_VISTA | OS_WINDOWS7 },
+ { 0x8086, 0x0122, D_VERSION(6,14,10,5337), OS_WINXP | OS_WINXP_64 },
+ { 0x8086, 0x0122, D_VERSION(8,15,10,2302), OS_VISTA | OS_WINDOWS7 },
+ { 0x8086, 0x0126, D_VERSION(6,14,10,5337), OS_WINXP | OS_WINXP_64 },
+ { 0x8086, 0x0126, D_VERSION(8,15,10,2302), OS_VISTA | OS_WINDOWS7 },
+ { 0x8086, 0x010A, D_VERSION(6,14,10,5337), OS_WINXP | OS_WINXP_64 },
+ { 0x8086, 0x010A, D_VERSION(8,15,10,2302), OS_VISTA | OS_WINDOWS7 },
+
+ // Reason: workaround for 6620073, 6612195
+ // Intel 740
+ { 0x8086, 0x7800, NO_VERSION, OS_ALL },
+ { 0x8086, 0x1240, NO_VERSION, OS_ALL },
+ { 0x8086, 0x7121, NO_VERSION, OS_ALL },
+ { 0x8086, 0x7123, NO_VERSION, OS_ALL },
+ { 0x8086, 0x7125, NO_VERSION, OS_ALL },
+ { 0x8086, 0x1132, NO_VERSION, OS_ALL },
+ // IEG
+ { 0x8086, 0x2562, NO_VERSION, OS_ALL },
+ { 0x8086, 0x3577, NO_VERSION, OS_ALL },
+ { 0x8086, 0x2572, NO_VERSION, OS_ALL },
+ { 0x8086, 0x3582, NO_VERSION, OS_ALL },
+ { 0x8086, 0x358E, NO_VERSION, OS_ALL },
+ // GMA
+ { 0x8086, 0x2582, NO_VERSION, OS_ALL },
+ { 0x8086, 0x2782, NO_VERSION, OS_ALL },
+ { 0x8086, 0x2592, NO_VERSION, OS_ALL },
+ { 0x8086, 0x2792, NO_VERSION, OS_ALL },
+ { 0x8086, 0x2772, NO_VERSION, OS_ALL },
+ { 0x8086, 0x2776, NO_VERSION, OS_ALL },
+ { 0x8086, 0x27A2, NO_VERSION, OS_ALL },
+ { 0x8086, 0x27A6, NO_VERSION, OS_ALL },
+ { 0x8086, 0x27AE, NO_VERSION, OS_ALL },
+ { 0x8086, 0x29D2, NO_VERSION, OS_ALL },
+ { 0x8086, 0x29D3, NO_VERSION, OS_ALL },
+ { 0x8086, 0x29B2, NO_VERSION, OS_ALL },
+ { 0x8086, 0x29B3, NO_VERSION, OS_ALL },
+ { 0x8086, 0x29C2, NO_VERSION, OS_ALL },
+ { 0x8086, 0x29C3, NO_VERSION, OS_ALL },
+ { 0x8086, 0xA001, NO_VERSION, OS_ALL },
+ { 0x8086, 0xA002, NO_VERSION, OS_ALL },
+ { 0x8086, 0xA011, NO_VERSION, OS_ALL },
+ { 0x8086, 0xA012, NO_VERSION, OS_ALL },
+ // GMA
+ { 0x8086, 0x2972, NO_VERSION, OS_ALL },
+ { 0x8086, 0x2973, NO_VERSION, OS_ALL },
+ { 0x8086, 0x2992, NO_VERSION, OS_ALL },
+ { 0x8086, 0x2993, NO_VERSION, OS_ALL },
+ { 0x8086, 0x29A2, NO_VERSION, OS_ALL },
+ { 0x8086, 0x29A3, NO_VERSION, OS_ALL },
+ { 0x8086, 0x2982, NO_VERSION, OS_ALL },
+ { 0x8086, 0x2983, NO_VERSION, OS_ALL },
+ { 0x8086, 0x2A02, NO_VERSION, OS_ALL },
+ { 0x8086, 0x2A03, NO_VERSION, OS_ALL },
+ { 0x8086, 0x2A12, NO_VERSION, OS_ALL },
+ { 0x8086, 0x2A13, NO_VERSION, OS_ALL },
+
+ // Eaglelake (Desktop) GMA 4500 Lines
+ { 0x8086, 0x2E42, D_VERSION(6,14,10,5303), OS_WINXP | OS_WINXP_64 },
+ { 0x8086, 0x2E42, D_VERSION(8,15,10,2302), OS_VISTA | OS_WINDOWS7 },
+ { 0x8086, 0x2E43, D_VERSION(6,14,10,5303), OS_WINXP | OS_WINXP_64 },
+ { 0x8086, 0x2E43, D_VERSION(8,15,10,2302), OS_VISTA | OS_WINDOWS7 },
+ { 0x8086, 0x2E92, D_VERSION(6,14,10,5303), OS_WINXP | OS_WINXP_64 },
+ { 0x8086, 0x2E92, D_VERSION(8,15,10,2302), OS_VISTA | OS_WINDOWS7 },
+ { 0x8086, 0x2E93, D_VERSION(6,14,10,5303), OS_WINXP | OS_WINXP_64 },
+ { 0x8086, 0x2E93, D_VERSION(8,15,10,2302), OS_VISTA | OS_WINDOWS7 },
+ { 0x8086, 0x2E12, D_VERSION(6,14,10,5303), OS_WINXP | OS_WINXP_64 },
+ { 0x8086, 0x2E12, D_VERSION(8,15,10,2302), OS_VISTA | OS_WINDOWS7 },
+ { 0x8086, 0x2E13, D_VERSION(6,14,10,5303), OS_WINXP | OS_WINXP_64 },
+ { 0x8086, 0x2E13, D_VERSION(8,15,10,2302), OS_VISTA | OS_WINDOWS7 },
+ // Eaglelake (Desktop) GMA X4500 Lines
+ { 0x8086, 0x2E32, D_VERSION(6,14,10,5303), OS_WINXP | OS_WINXP_64 },
+ { 0x8086, 0x2E32, D_VERSION(8,15,10,2302), OS_VISTA | OS_WINDOWS7 },
+ { 0x8086, 0x2E33, D_VERSION(6,14,10,5303), OS_WINXP | OS_WINXP_64 },
+ { 0x8086, 0x2E33, D_VERSION(8,15,10,2302), OS_VISTA | OS_WINDOWS7 },
+ { 0x8086, 0x2E22, D_VERSION(6,14,10,5303), OS_WINXP | OS_WINXP_64 },
+ { 0x8086, 0x2E22, D_VERSION(8,15,10,2302), OS_VISTA | OS_WINDOWS7 },
+ // Eaglelake (Desktop) GMA X4500HD Lines
+ { 0x8086, 0x2E23, D_VERSION(6,14,10,5303), OS_WINXP | OS_WINXP_64 },
+ { 0x8086, 0x2E23, D_VERSION(8,15,10,2302), OS_VISTA | OS_WINDOWS7 },
+ // Cantiga (Mobile) GMA 4500MHD Lines
+ { 0x8086, 0x2A42, D_VERSION(6,14,10,5303), OS_WINXP | OS_WINXP_64 },
+ { 0x8086, 0x2A42, D_VERSION(8,15,10,2302), OS_VISTA | OS_WINDOWS7 },
+ { 0x8086, 0x2A43, D_VERSION(6,14,10,5303), OS_WINXP | OS_WINXP_64 },
+ { 0x8086, 0x2A43, D_VERSION(8,15,10,2302), OS_VISTA | OS_WINDOWS7 },
// ATI Mobility Radeon X1600, X1400, X1450, X1300, X1350
// Reason: workaround for 6613066, 6687166
diff --git a/test/java/awt/LightweightDispatcher/LWDispatcherMemoryLeakTest.java b/test/java/awt/LightweightDispatcher/LWDispatcherMemoryLeakTest.java
new file mode 100644
index 0000000..706ae38
--- /dev/null
+++ b/test/java/awt/LightweightDispatcher/LWDispatcherMemoryLeakTest.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.awt.AWTException;
+import java.awt.FlowLayout;
+import java.awt.Robot;
+import java.lang.ref.Reference;
+import java.lang.ref.WeakReference;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.SwingUtilities;
+import test.java.awt.regtesthelpers.Util;
+
+/*
+ @test
+ @bug 7079254
+ @summary Toolkit eventListener leaks memory
+ @library ../regtesthelpers
+ @build Util
+ @compile LWDispatcherMemoryLeakTest.java
+ @run main/othervm -Xmx10M LWDispatcherMemoryLeakTest
+ */
+public class LWDispatcherMemoryLeakTest {
+
+ private static JFrame frame;
+ private static WeakReference<JButton> button;
+ private static WeakReference<JPanel> p;
+
+ public static void init() throws Throwable {
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ frame = new JFrame();
+ frame.setLayout(new FlowLayout());
+ button = new WeakReference<JButton>(new JButton("Text"));
+ p = new WeakReference<JPanel>(new JPanel(new FlowLayout()));
+ p.get().add(button.get());
+ frame.add(p.get());
+
+ frame.setBounds(500, 400, 200, 200);
+ frame.setVisible(true);
+ }
+ });
+
+ Util.waitTillShown(button.get());
+ Util.clickOnComp(button.get(), new Robot());
+
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ frame.remove(p.get());
+ }
+ });
+
+ Util.waitForIdle(null);
+ assertGC();
+ }
+
+ public static void assertGC() throws Throwable {
+ List<byte[]> alloc = new ArrayList<byte[]>();
+ int size = 10 * 1024;
+ while (true) {
+ try {
+ alloc.add(new byte[size]);
+ } catch (OutOfMemoryError err) {
+ break;
+ }
+ }
+ alloc = null;
+ if (button.get() != null) {
+ throw new Exception("Test failed: JButton was not collected");
+ }
+ }
+
+ public static void main(String args[]) throws Throwable {
+ init();
+ }
+}
diff --git a/test/java/awt/TrayIcon/DragEventSource/DragEventSource.java b/test/java/awt/TrayIcon/DragEventSource/DragEventSource.java
index ddd0123..8a669c8 100644
--- a/test/java/awt/TrayIcon/DragEventSource/DragEventSource.java
+++ b/test/java/awt/TrayIcon/DragEventSource/DragEventSource.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -64,6 +64,21 @@
}
private static void init() {
+
+ boolean isSupported = SystemTray.isSupported();
+ System.out.println("is SysTray Supported: " + isSupported);
+
+ if (!isSupported) {
+ String[] instructions =
+ {
+ "The test cannot be run because SystemTray is not supported.",
+ "Simply press PASS button."
+ };
+ Sysout.createDialog( );
+ Sysout.printInstructions( instructions );
+ return;
+ }
+
String[] instructions =
{
"Use see a Frame with a button in it.",
@@ -79,8 +94,8 @@
frame.setLayout(new FlowLayout());
tray = SystemTray.getSystemTray();
- boolean isSupported = tray.isSupported();
- System.out.println("is SysTray Supported: " + isSupported);
+
+
TrayIcon icons[] = tray.getTrayIcons();
System.out.println(icons.length);
diff --git a/test/java/awt/datatransfer/HTMLDataFlavors/HTMLDataFlavorTest.java b/test/java/awt/datatransfer/HTMLDataFlavors/HTMLDataFlavorTest.java
index fa2206b..1fe616a 100644
--- a/test/java/awt/datatransfer/HTMLDataFlavors/HTMLDataFlavorTest.java
+++ b/test/java/awt/datatransfer/HTMLDataFlavors/HTMLDataFlavorTest.java
@@ -43,6 +43,11 @@
public static void main(String[] args) throws IOException, UnsupportedFlavorException {
+ if (sun.awt.OSInfo.getOSType() != sun.awt.OSInfo.OSType.WINDOWS) {
+ System.err.println("This test is for MS Windows only. Considered passed.");
+ return;
+ }
+
dataFlavors.put(DataFlavor.allHtmlFlavor, HtmlTransferable.ALL_HTML_AS_STRING);
dataFlavors.put(DataFlavor.fragmentHtmlFlavor, HtmlTransferable.FRAGMENT_HTML_AS_STRING);
dataFlavors.put(DataFlavor.selectionHtmlFlavor, HtmlTransferable.SELECTION_HTML_AS_STRING);
diff --git a/test/java/lang/CharSequence/DefaultTest.java b/test/java/lang/CharSequence/DefaultTest.java
index cad50b3..dd51ce6 100644
--- a/test/java/lang/CharSequence/DefaultTest.java
+++ b/test/java/lang/CharSequence/DefaultTest.java
@@ -1,12 +1,10 @@
/*
- * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
+ * 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
diff --git a/test/java/util/StringJoiner/StringJoinerTest.java b/test/java/util/StringJoiner/StringJoinerTest.java
index 5ebee43..3dfdb35 100644
--- a/test/java/util/StringJoiner/StringJoinerTest.java
+++ b/test/java/util/StringJoiner/StringJoinerTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
diff --git a/test/javax/imageio/plugins/gif/GIFPassListenerTest.java b/test/javax/imageio/plugins/gif/GIFPassListenerTest.java
new file mode 100644
index 0000000..fac84d8
--- /dev/null
+++ b/test/javax/imageio/plugins/gif/GIFPassListenerTest.java
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 4892259
+ *
+ * @summary Verify that calls to IIOReadUpdateListener passStarted and
+ * passComplete are consistent.
+ *
+ * @run main GIFPassListenerTest
+ */
+
+import java.awt.image.*;
+import java.io.*;
+import java.util.*;
+import javax.imageio.*;
+import javax.imageio.event.*;
+import javax.imageio.stream.*;
+
+public class GIFPassListenerTest {
+
+ private static ImageInputStream createTestImageStream(boolean progressive) throws IOException {
+ ByteArrayOutputStream output = new ByteArrayOutputStream();
+ Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName("gif");
+ if (!writers.hasNext()) {
+ return null;
+ }
+ ImageWriter writer = writers.next();
+ ImageWriteParam param = writer.getDefaultWriteParam();
+ param.setProgressiveMode(progressive ?
+ ImageWriteParam.MODE_DEFAULT : ImageWriteParam.MODE_DISABLED);
+ ImageOutputStream imageOutput = ImageIO.createImageOutputStream(output);
+ writer.setOutput(imageOutput);
+ BufferedImage image = new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB);
+ writer.write(null, new IIOImage(image, null, null), param);
+ imageOutput.flush();
+ ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray());
+ return ImageIO.createImageInputStream(input);
+ }
+
+ private static void checkImage(boolean progressive) throws Exception {
+ ImageInputStream iis = createTestImageStream(progressive);
+ ImageReader reader = ImageIO.getImageReaders(iis).next();
+ reader.setInput(iis);
+ ReadUpdateHandler handler = new ReadUpdateHandler();
+ reader.addIIOReadUpdateListener(handler);
+ reader.readAll(null);
+ if (handler.isPassStarted) {
+ throw new RuntimeException("passStarted without passComplete.");
+ }
+ if (progressive && (handler.numPasses == 0)) {
+ throw new RuntimeException("passStarted wasn't called for progressive image");
+ }
+ if (!progressive && (handler.numPasses != 0)) {
+ throw new RuntimeException("passStarted was called for non-progressive image");
+ }
+ iis.close();
+ }
+
+ public static void main(String args[]) throws Exception {
+ checkImage(true);
+ checkImage(false);
+ }
+
+ private static class ReadUpdateHandler implements IIOReadUpdateListener {
+ public boolean isPassStarted = false;
+ public int numPasses = 0;
+
+ @Override
+ public void imageUpdate(ImageReader source, BufferedImage theImage, int minX, int minY,
+ int width, int height, int periodX, int periodY, int[] bands) {
+ }
+
+ @Override
+ public void passStarted(ImageReader source, BufferedImage theImage, int pass, int minPass,
+ int maxPass, int minX, int minY, int periodX, int periodY, int[] bands) {
+ if (isPassStarted) {
+ throw new RuntimeException("reentered passStarted!");
+ }
+ isPassStarted = true;
+ numPasses++;
+ }
+
+ @Override
+ public void passComplete(ImageReader source, BufferedImage theImage) {
+ if (!isPassStarted) {
+ throw new RuntimeException("passComplete without passStarted!");
+ }
+ isPassStarted = false;
+ }
+
+ @Override
+ public void thumbnailPassStarted(ImageReader source, BufferedImage theThumbnail, int pass,
+ int minPass, int maxPass, int minX, int minY, int periodX, int periodY, int[] bands) {
+ }
+
+ @Override
+ public void thumbnailPassComplete(ImageReader source, BufferedImage theThumbnail) {
+ }
+
+ @Override
+ public void thumbnailUpdate(ImageReader source, BufferedImage theThumbnail, int minX, int minY,
+ int width, int height, int periodX, int periodY, int[] bands) {
+ }
+ }
+}