--- a/jdk/make/data/fontconfig/windows.fontconfig.properties Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/make/data/fontconfig/windows.fontconfig.properties Tue Apr 19 09:21:45 2016 -0700
@@ -37,6 +37,7 @@
allfonts.chinese-hkscs=MingLiU_HKSCS
allfonts.chinese-ms950-extb=MingLiU-ExtB
allfonts.devanagari=Mangal
+allfonts.kannada=Tunga
allfonts.dingbats=Wingdings
allfonts.lucida=Lucida Sans Regular
allfonts.symbol=Symbol
@@ -239,11 +240,11 @@
sequence.fallback=lucida,symbols,\
chinese-ms950,chinese-hkscs,chinese-ms936,chinese-gb18030,\
- japanese,korean,chinese-ms950-extb,chinese-ms936-extb,georgian
+ japanese,korean,chinese-ms950-extb,chinese-ms936-extb,georgian,kannada
# Exclusion Ranges
-exclusion.alphabetic=0700-1e9f,1f00-20ab,20ad-f8ff
+exclusion.alphabetic=0700-1e9f,1f00-2017,2020-20ab,20ad-20b8,20bb-20bc,20be-f8ff
exclusion.chinese-gb18030=0390-03d6,2200-22ef,2701-27be
exclusion.hebrew=0041-005a,0060-007a,007f-00ff,20ac-20ac
@@ -295,6 +296,7 @@
filename.Lucida_Sans_Regular=LucidaSansRegular.ttf
filename.Mangal=MANGAL.TTF
+filename.Tunga=TUNGA.TTF
filename.Symbol=SYMBOL.TTF
filename.Wingdings=WINGDING.TTF
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaFileSystemModel.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaFileSystemModel.java Tue Apr 19 09:21:45 2016 -0700
@@ -35,7 +35,6 @@
import javax.swing.filechooser.FileSystemView;
import javax.swing.table.AbstractTableModel;
-import sun.misc.ManagedLocalsThread;
/**
* NavServices-like implementation of a file Table
*
@@ -393,7 +392,7 @@
this.currentDirectory = currentDirectory;
this.fid = fid;
String name = "Aqua L&F File Loading Thread";
- this.loadThread = new ManagedLocalsThread(this, name);
+ this.loadThread = new Thread(null, this, name, 0, false);
this.loadThread.start();
}
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFrameDockIconUI.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFrameDockIconUI.java Tue Apr 19 09:21:45 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -40,28 +40,28 @@
* From MacDockIconUI
*
* A JRSUI L&F implementation of JInternalFrame.JDesktopIcon
- * @author
- * @version
*/
-public class AquaInternalFrameDockIconUI extends DesktopIconUI implements MouseListener, MouseMotionListener, ComponentListener {
- private static final String CACHED_FRAME_ICON_KEY = "apple.laf.internal.frameIcon";
+public final class AquaInternalFrameDockIconUI extends DesktopIconUI
+ implements MouseListener, MouseMotionListener {
- protected JInternalFrame.JDesktopIcon fDesktopIcon;
- protected JInternalFrame fFrame;
- protected ScaledImageLabel fIconPane;
- protected DockLabel fDockLabel;
- protected boolean fTrackingIcon = false;
+ private JInternalFrame.JDesktopIcon fDesktopIcon;
+ private JInternalFrame fFrame;
+ private ScaledImageLabel fIconPane;
+ private DockLabel fDockLabel;
+ private boolean fTrackingIcon;
public static ComponentUI createUI(final JComponent c) {
return new AquaInternalFrameDockIconUI();
}
+ @Override
public void installUI(final JComponent c) {
fDesktopIcon = (JInternalFrame.JDesktopIcon)c;
installComponents();
installListeners();
}
+ @Override
public void uninstallUI(final JComponent c) {
uninstallComponents();
uninstallListeners();
@@ -69,55 +69,54 @@
fFrame = null;
}
- protected void installComponents() {
+ private void installComponents() {
fFrame = fDesktopIcon.getInternalFrame();
fIconPane = new ScaledImageLabel();
fDesktopIcon.setLayout(new BorderLayout());
fDesktopIcon.add(fIconPane, BorderLayout.CENTER);
}
- protected void uninstallComponents() {
+ private void uninstallComponents() {
fDesktopIcon.setLayout(null);
fDesktopIcon.remove(fIconPane);
}
- protected void installListeners() {
+ private void installListeners() {
fDesktopIcon.addMouseListener(this);
fDesktopIcon.addMouseMotionListener(this);
- fFrame.addComponentListener(this);
}
- protected void uninstallListeners() {
- fFrame.removeComponentListener(this);
+ private void uninstallListeners() {
fDesktopIcon.removeMouseMotionListener(this);
fDesktopIcon.removeMouseListener(this);
}
+ @Override
public Dimension getMinimumSize(final JComponent c) {
return new Dimension(32, 32);
}
+ @Override
public Dimension getMaximumSize(final JComponent c) {
return new Dimension(128, 128);
}
+ @Override
public Dimension getPreferredSize(final JComponent c) {
return new Dimension(64, 64); //$ Dock preferred size
}
- public Insets getInsets(final JComponent c) {
- return new Insets(0, 0, 0, 0);
- }
-
void updateIcon() {
fIconPane.updateIcon();
}
+ @Override
public void mousePressed(final MouseEvent e) {
fTrackingIcon = fIconPane.mouseInIcon(e);
if (fTrackingIcon) fIconPane.repaint();
}
+ @Override
public void mouseReleased(final MouseEvent e) {// only when it's actually in the image
if (fFrame.isIconifiable() && fFrame.isIcon()) {
if (fTrackingIcon) {
@@ -137,6 +136,7 @@
if (fDockLabel != null && !fIconPane.getBounds().contains(e.getX(), e.getY())) fDockLabel.hide();
}
+ @Override
public void mouseEntered(final MouseEvent e) {
if ((e.getModifiers() & InputEvent.BUTTON1_MASK) != 0) return;
String title = fFrame.getTitle();
@@ -145,41 +145,27 @@
fDockLabel.show(fDesktopIcon);
}
+ @Override
public void mouseExited(final MouseEvent e) {
if (fDockLabel != null && (e.getModifiers() & InputEvent.BUTTON1_MASK) == 0) fDockLabel.hide();
}
+ @Override
public void mouseClicked(final MouseEvent e) { }
+ @Override
public void mouseDragged(final MouseEvent e) { }
+ @Override
public void mouseMoved(final MouseEvent e) { }
- public void componentHidden(final ComponentEvent e) { }
-
- public void componentMoved(final ComponentEvent e) { }
-
- public void componentResized(final ComponentEvent e) {
- fFrame.putClientProperty(CACHED_FRAME_ICON_KEY, null);
- }
-
- public void componentShown(final ComponentEvent e) {
- fFrame.putClientProperty(CACHED_FRAME_ICON_KEY, null);
- }
-
@SuppressWarnings("serial") // Superclass is not serializable across versions
- class ScaledImageLabel extends JLabel {
+ private final class ScaledImageLabel extends JLabel {
ScaledImageLabel() {
super(null, null, CENTER);
}
void updateIcon() {
- final Object priorIcon = fFrame.getClientProperty(CACHED_FRAME_ICON_KEY);
- if (priorIcon instanceof ImageIcon) {
- setIcon((ImageIcon)priorIcon);
- return;
- }
-
int width = fFrame.getWidth();
int height = fFrame.getHeight();
@@ -196,11 +182,10 @@
final float scale = (float)fDesktopIcon.getWidth() / (float)Math.max(width, height) * 0.89f;
// Sending in -1 for width xor height causes it to maintain aspect ratio
- final ImageIcon icon = new ImageIcon(fImage.getScaledInstance((int)(width * scale), -1, Image.SCALE_SMOOTH));
- fFrame.putClientProperty(CACHED_FRAME_ICON_KEY, icon);
- setIcon(icon);
+ setIcon(new ImageIcon(fImage.getScaledInstance((int)(width * scale), -1, Image.SCALE_SMOOTH)));
}
+ @Override
public void paint(final Graphics g) {
if (getIcon() == null) updateIcon();
@@ -222,13 +207,14 @@
return getBounds().contains(e.getX(), e.getY());
}
+ @Override
public Dimension getPreferredSize() {
return new Dimension(64, 64); //$ Dock preferred size
}
}
@SuppressWarnings("serial") // Superclass is not serializable across versions
- class DockLabel extends JLabel {
+ private static final class DockLabel extends JLabel {
static final int NUB_HEIGHT = 7;
static final int ROUND_ADDITIONAL_HEIGHT = 8;
static final int ROUND_ADDITIONAL_WIDTH = 12;
@@ -243,6 +229,7 @@
setSize(SwingUtilities.computeStringWidth(metrics, getText()) + ROUND_ADDITIONAL_WIDTH * 2, metrics.getAscent() + NUB_HEIGHT + ROUND_ADDITIONAL_HEIGHT);
}
+ @Override
public void paint(final Graphics g) {
final int width = getWidth();
final int height = getHeight();
@@ -303,6 +290,7 @@
}
}
+ @Override
@Deprecated
public void hide() {
final Container parent = getParent();
--- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTabbedPaneCopyFromBasicUI.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaTabbedPaneCopyFromBasicUI.java Tue Apr 19 09:21:45 2016 -0700
@@ -2183,50 +2183,21 @@
}
protected int preferredTabAreaHeight(final int tabPlacement, final int width) {
- final FontMetrics metrics = getFontMetrics();
final int tabCount = tabPane.getTabCount();
int total = 0;
if (tabCount > 0) {
- int rows = 1;
- int x = 0;
-
final int maxTabHeight = calculateMaxTabHeight(tabPlacement);
-
- for (int i = 0; i < tabCount; i++) {
- final int tabWidth = calculateTabWidth(tabPlacement, i, metrics);
-
- if (x != 0 && x + tabWidth > width) {
- rows++;
- x = 0;
- }
- x += tabWidth;
- }
- total = calculateTabAreaHeight(tabPlacement, rows, maxTabHeight);
+ total = calculateTabAreaHeight(tabPlacement, 1, maxTabHeight);
}
return total;
}
protected int preferredTabAreaWidth(final int tabPlacement, final int height) {
- final FontMetrics metrics = getFontMetrics();
final int tabCount = tabPane.getTabCount();
int total = 0;
if (tabCount > 0) {
- int columns = 1;
- int y = 0;
- final int fontHeight = metrics.getHeight();
-
maxTabWidth = calculateMaxTabWidth(tabPlacement);
-
- for (int i = 0; i < tabCount; i++) {
- final int tabHeight = calculateTabHeight(tabPlacement, i, fontHeight);
-
- if (y != 0 && y + tabHeight > height) {
- columns++;
- y = 0;
- }
- y += tabHeight;
- }
- total = calculateTabAreaWidth(tabPlacement, columns, maxTabWidth);
+ total = calculateTabAreaWidth(tabPlacement, 1, maxTabWidth);
}
return total;
}
--- a/jdk/src/java.desktop/macosx/classes/sun/font/CFontManager.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/macosx/classes/sun/font/CFontManager.java Tue Apr 19 09:21:45 2016 -0700
@@ -42,7 +42,6 @@
import sun.awt.HeadlessToolkit;
import sun.awt.util.ThreadGroupUtils;
import sun.lwawt.macosx.*;
-import sun.misc.ManagedLocalsThread;
public final class CFontManager extends SunFontManager {
private static Hashtable<String, Font2D> genericFonts = new Hashtable<String, Font2D>();
--- a/jdk/src/java.desktop/macosx/classes/sun/java2d/IntegerNIORaster.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/macosx/classes/sun/java2d/IntegerNIORaster.java Tue Apr 19 09:21:45 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -40,7 +40,7 @@
") cannot be <= 0");
}
// This is cribbed from java.awt.image.Raster.
- DataBuffer db = new DataBufferNIOInt(w * h);
+ DataBufferNIOInt db = new DataBufferNIOInt(w * h);
if (location == null) {
location = new Point(0, 0);
}
@@ -48,13 +48,11 @@
return new IntegerNIORaster(sppsm, db, location);
}
- public IntegerNIORaster(SampleModel sampleModel, DataBuffer dataBuffer, Point origin) {
+ public IntegerNIORaster(SampleModel sampleModel, DataBufferNIOInt dataBuffer, Point origin) {
// This is all cribbed from sun.awt.image.IntegerInterleavedRaster & sun.awt.image.IntegerComponentRaster
super(sampleModel, dataBuffer, new Rectangle(origin.x, origin.y, sampleModel.getWidth(), sampleModel.getHeight()), origin, null);
- if (!(dataBuffer instanceof DataBufferNIOInt)) {
- throw new RasterFormatException("IntegerNIORasters must have DataBufferNIOInt DataBuffers");
- }
- this.data = ((DataBufferNIOInt)dataBuffer).getBuffer();
+
+ this.data = dataBuffer.getBuffer();
}
public WritableRaster createCompatibleWritableRaster() {
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWToolkit.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWToolkit.java Tue Apr 19 09:21:45 2016 -0700
@@ -35,7 +35,6 @@
import java.util.*;
import sun.awt.*;
-import sun.misc.ManagedLocalsThread;
import sun.print.*;
import sun.awt.util.ThreadGroupUtils;
@@ -77,13 +76,14 @@
shutdown();
waitForRunState(STATE_CLEANUP);
};
- Thread shutdown = new ManagedLocalsThread(
- ThreadGroupUtils.getRootThreadGroup(), shutdownRunnable);
+ Thread shutdown = new Thread(
+ ThreadGroupUtils.getRootThreadGroup(), shutdownRunnable,
+ "AWT-Shutdown", 0, false);
shutdown.setContextClassLoader(null);
Runtime.getRuntime().addShutdownHook(shutdown);
String name = "AWT-LW";
- Thread toolkitThread = new ManagedLocalsThread(
- ThreadGroupUtils.getRootThreadGroup(), this, name);
+ Thread toolkitThread = new Thread(
+ ThreadGroupUtils.getRootThreadGroup(), this, name, 0, false);
toolkitThread.setDaemon(true);
toolkitThread.setPriority(Thread.NORM_PRIORITY + 1);
toolkitThread.start();
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDragSourceContextPeer.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDragSourceContextPeer.java Tue Apr 19 09:21:45 2016 -0700
@@ -44,7 +44,6 @@
import sun.lwawt.LWComponentPeer;
import sun.lwawt.LWWindowPeer;
import sun.lwawt.PlatformWindow;
-import sun.misc.ManagedLocalsThread;
public final class CDragSourceContextPeer extends SunDragSourceContextPeer {
@@ -181,7 +180,7 @@
}
}
};
- new ManagedLocalsThread(dragRunnable).start();
+ new Thread(null, dragRunnable, "Drag", 0, false).start();
} catch (Exception e) {
final long nativeDragSource = getNativeContext();
setNativeContext(0);
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CFileDialog.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CFileDialog.java Tue Apr 19 09:21:45 2016 -0700
@@ -37,7 +37,6 @@
import sun.awt.CausedFocusEvent.Cause;
import sun.awt.AWTAccessor;
import sun.java2d.pipe.Region;
-import sun.misc.ManagedLocalsThread;
import sun.security.action.GetBooleanAction;
class CFileDialog implements FileDialogPeer {
@@ -120,7 +119,7 @@
if (visible) {
// Java2 Dialog class requires peer to run code in a separate thread
// and handles keeping the call modal
- new ManagedLocalsThread(new Task()).start();
+ new Thread(null, new Task(), "FileDialog", 0, false).start();
}
// We hide ourself before "show" returns - setVisible(false)
// doesn't apply
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPrinterDialogPeer.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPrinterDialogPeer.java Tue Apr 19 09:21:45 2016 -0700
@@ -29,7 +29,6 @@
import java.awt.dnd.*;
import sun.lwawt.*;
-import sun.misc.ManagedLocalsThread;
public class CPrinterDialogPeer extends LWWindowPeer {
static {
@@ -59,7 +58,7 @@
printerDialog.setRetVal(printerDialog.showDialog());
printerDialog.setVisible(false);
};
- new ManagedLocalsThread(task).start();
+ new Thread(null, task, "PrintDialog", 0, false).start();
}
}
--- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPrinterJob.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPrinterJob.java Tue Apr 19 09:21:45 2016 -0700
@@ -36,6 +36,7 @@
import javax.print.*;
import javax.print.attribute.PrintRequestAttributeSet;
import javax.print.attribute.HashPrintRequestAttributeSet;
+import javax.print.attribute.standard.Copies;
import javax.print.attribute.standard.Media;
import javax.print.attribute.standard.MediaPrintableArea;
import javax.print.attribute.standard.MediaSize;
@@ -43,7 +44,6 @@
import javax.print.attribute.standard.PageRanges;
import sun.java2d.*;
-import sun.misc.ManagedLocalsThread;
import sun.print.*;
public final class CPrinterJob extends RasterPrinterJob {
@@ -194,10 +194,37 @@
// setPageRange will set firstPage and lastPage as called in getFirstPage
// and getLastPage
setPageRange(range[0][0] - 1, range[0][1] - 1);
+ } else {
+ // if rangeSelect is SunPageSelection.ALL
+ // then setPageRange appropriately
+ setPageRange(-1, -1);
}
}
}
+ private void setPageRangeAttribute(int from, int to, boolean isRangeSet) {
+ if (attributes != null) {
+ // since native Print use zero-based page indices,
+ // we need to store in 1-based format in attributes set
+ // but setPageRange again uses zero-based indices so it should be
+ // 1 less than pageRanges attribute
+ if (isRangeSet) {
+ attributes.add(new PageRanges(from+1, to+1));
+ attributes.add(SunPageSelection.RANGE);
+ setPageRange(from, to);
+ } else {
+ attributes.add(SunPageSelection.ALL);
+ }
+ }
+ }
+
+ private void setCopiesAttribute(int copies) {
+ if (attributes != null) {
+ attributes.add(new Copies(copies));
+ super.setCopies(copies);
+ }
+ }
+
volatile boolean onEventThread;
@Override
@@ -691,9 +718,15 @@
if (pageFormat != null) {
Printable printable = pageable.getPrintable(pageIndex);
if (printable != null) {
- BufferedImage bimg = new BufferedImage((int)Math.round(pageFormat.getWidth()), (int)Math.round(pageFormat.getHeight()), BufferedImage.TYPE_INT_ARGB_PRE);
- PeekGraphics peekGraphics = createPeekGraphics(bimg.createGraphics(), printerJob);
- Rectangle2D pageFormatArea = getPageFormatArea(pageFormat);
+ BufferedImage bimg =
+ new BufferedImage(
+ (int)Math.round(pageFormat.getWidth()),
+ (int)Math.round(pageFormat.getHeight()),
+ BufferedImage.TYPE_INT_ARGB_PRE);
+ PeekGraphics peekGraphics =
+ createPeekGraphics(bimg.createGraphics(), printerJob);
+ Rectangle2D pageFormatArea =
+ getPageFormatArea(pageFormat);
initPrinterGraphics(peekGraphics, pageFormatArea);
// Do the assignment here!
@@ -741,7 +774,8 @@
// upcall from native
private static void detachPrintLoop(final long target, final long arg) {
- new ManagedLocalsThread(() -> _safePrintLoop(target, arg)).start();
+ new Thread(null, () -> _safePrintLoop(target, arg),
+ "PrintLoop", 0, false).start();
}
private static native void _safePrintLoop(long target, long arg);
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CPrinterJob.m Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CPrinterJob.m Tue Apr 19 09:21:45 2016 -0700
@@ -312,9 +312,9 @@
static void nsPrintInfoToJavaPrinterJob(JNIEnv* env, NSPrintInfo* src, jobject dstPrinterJob, jobject dstPageable)
{
static JNF_MEMBER_CACHE(jm_setService, sjc_CPrinterJob, "setPrinterServiceFromNative", "(Ljava/lang/String;)V");
- static JNF_MEMBER_CACHE(jm_setCopies, sjc_CPrinterJob, "setCopies", "(I)V");
+ static JNF_MEMBER_CACHE(jm_setCopiesAttribute, sjc_CPrinterJob, "setCopiesAttribute", "(I)V");
static JNF_MEMBER_CACHE(jm_setCollated, sjc_CPrinterJob, "setCollated", "(Z)V");
- static JNF_MEMBER_CACHE(jm_setPageRange, sjc_CPrinterJob, "setPageRange", "(II)V");
+ static JNF_MEMBER_CACHE(jm_setPageRangeAttribute, sjc_CPrinterJob, "setPageRangeAttribute", "(IIZ)V");
// get the selected printer's name, and set the appropriate PrintService on the Java side
NSString *name = [[src printer] name];
@@ -327,7 +327,7 @@
NSNumber* nsCopies = [printingDictionary objectForKey:NSPrintCopies];
if ([nsCopies respondsToSelector:@selector(integerValue)])
{
- JNFCallVoidMethod(env, dstPrinterJob, jm_setCopies, [nsCopies integerValue]); // AWT_THREADING Safe (known object)
+ JNFCallVoidMethod(env, dstPrinterJob, jm_setCopiesAttribute, [nsCopies integerValue]); // AWT_THREADING Safe (known object)
}
NSNumber* nsCollated = [printingDictionary objectForKey:NSPrintMustCollate];
@@ -340,6 +340,7 @@
if ([nsPrintAllPages respondsToSelector:@selector(boolValue)])
{
jint jFirstPage = 0, jLastPage = java_awt_print_Pageable_UNKNOWN_NUMBER_OF_PAGES;
+ jboolean isRangeSet = false;
if (![nsPrintAllPages boolValue])
{
NSNumber* nsFirstPage = [printingDictionary objectForKey:NSPrintFirstPage];
@@ -353,9 +354,12 @@
{
jLastPage = [nsLastPage integerValue] - 1;
}
- }
+ isRangeSet = true;
+ }
+ JNFCallVoidMethod(env, dstPrinterJob, jm_setPageRangeAttribute,
+ jFirstPage, jLastPage, isRangeSet);
+ // AWT_THREADING Safe (known object)
- JNFCallVoidMethod(env, dstPrinterJob, jm_setPageRange, jFirstPage, jLastPage); // AWT_THREADING Safe (known object)
}
}
@@ -368,6 +372,8 @@
static JNF_MEMBER_CACHE(jm_isCollated, sjc_CPrinterJob, "isCollated", "()Z");
static JNF_MEMBER_CACHE(jm_getFromPage, sjc_CPrinterJob, "getFromPageAttrib", "()I");
static JNF_MEMBER_CACHE(jm_getToPage, sjc_CPrinterJob, "getToPageAttrib", "()I");
+ static JNF_MEMBER_CACHE(jm_getMinPage, sjc_CPrinterJob, "getMinPageAttrib", "()I");
+ static JNF_MEMBER_CACHE(jm_getMaxPage, sjc_CPrinterJob, "getMaxPageAttrib", "()I");
static JNF_MEMBER_CACHE(jm_getSelectAttrib, sjc_CPrinterJob, "getSelectAttrib", "()I");
static JNF_MEMBER_CACHE(jm_getNumberOfPages, jc_Pageable, "getNumberOfPages", "()I");
static JNF_MEMBER_CACHE(jm_getPageFormat, sjc_CPrinterJob, "getPageFormatFromAttributes", "()Ljava/awt/print/PageFormat;");
@@ -379,31 +385,33 @@
jboolean collated = JNFCallBooleanMethod(env, srcPrinterJob, jm_isCollated); // AWT_THREADING Safe (known object)
[printingDictionary setObject:[NSNumber numberWithBool:collated ? YES : NO] forKey:NSPrintMustCollate];
- jint jNumPages = JNFCallIntMethod(env, srcPageable, jm_getNumberOfPages); // AWT_THREADING Safe (!appKit)
- if (jNumPages != java_awt_print_Pageable_UNKNOWN_NUMBER_OF_PAGES)
- {
- jint selectID = JNFCallIntMethod(env, srcPrinterJob, jm_getSelectAttrib);
- if (selectID ==0) {
- [printingDictionary setObject:[NSNumber numberWithBool:YES] forKey:NSPrintAllPages];
- } else if (selectID == 2) {
- // In Mac 10.7, Print ALL is deselected if PrintSelection is YES whether
- // NSPrintAllPages is YES or NO
- [printingDictionary setObject:[NSNumber numberWithBool:NO] forKey:NSPrintAllPages];
- [printingDictionary setObject:[NSNumber numberWithBool:YES] forKey:NSPrintSelectionOnly];
- } else {
+ jint selectID = JNFCallIntMethod(env, srcPrinterJob, jm_getSelectAttrib);
+ jint fromPage = JNFCallIntMethod(env, srcPrinterJob, jm_getFromPage);
+ jint toPage = JNFCallIntMethod(env, srcPrinterJob, jm_getToPage);
+ if (selectID ==0) {
+ [printingDictionary setObject:[NSNumber numberWithBool:YES] forKey:NSPrintAllPages];
+ } else if (selectID == 2) {
+ // In Mac 10.7, Print ALL is deselected if PrintSelection is YES whether
+ // NSPrintAllPages is YES or NO
+ [printingDictionary setObject:[NSNumber numberWithBool:NO] forKey:NSPrintAllPages];
+ [printingDictionary setObject:[NSNumber numberWithBool:YES] forKey:NSPrintSelectionOnly];
+ } else {
+ jint minPage = JNFCallIntMethod(env, srcPrinterJob, jm_getMinPage);
+ jint maxPage = JNFCallIntMethod(env, srcPrinterJob, jm_getMaxPage);
+
+ // for PD_SELECTION or PD_NOSELECTION, check from/to page
+ // to determine which radio button to select
+ if (fromPage > minPage || toPage < maxPage) {
[printingDictionary setObject:[NSNumber numberWithBool:NO] forKey:NSPrintAllPages];
+ } else {
+ [printingDictionary setObject:[NSNumber numberWithBool:YES] forKey:NSPrintAllPages];
}
+ }
- jint fromPage = JNFCallIntMethod(env, srcPrinterJob, jm_getFromPage);
- jint toPage = JNFCallIntMethod(env, srcPrinterJob, jm_getToPage);
- // setting fromPage and toPage will not be shown in the dialog if printing All pages
- [printingDictionary setObject:[NSNumber numberWithInteger:fromPage] forKey:NSPrintFirstPage];
- [printingDictionary setObject:[NSNumber numberWithInteger:toPage] forKey:NSPrintLastPage];
- }
- else
- {
- [printingDictionary setObject:[NSNumber numberWithBool:YES] forKey:NSPrintAllPages];
- }
+ // setting fromPage and toPage will not be shown in the dialog if printing All pages
+ [printingDictionary setObject:[NSNumber numberWithInteger:fromPage] forKey:NSPrintFirstPage];
+ [printingDictionary setObject:[NSNumber numberWithInteger:toPage] forKey:NSPrintLastPage];
+
jobject page = JNFCallObjectMethod(env, srcPrinterJob, jm_getPageFormat);
if (page != NULL) {
javaPageFormatToNSPrintInfo(env, NULL, page, dst);
--- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CTrayIcon.m Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CTrayIcon.m Tue Apr 19 09:21:45 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -39,18 +39,21 @@
* If the image of the specified size won't fit into the status bar,
* then scale it down proprtionally. Otherwise, leave it as is.
*/
-static NSSize ScaledImageSizeForStatusBar(NSSize imageSize) {
+static NSSize ScaledImageSizeForStatusBar(NSSize imageSize, BOOL autosize) {
NSRect imageRect = NSMakeRect(0.0, 0.0, imageSize.width, imageSize.height);
// There is a black line at the bottom of the status bar
// that we don't want to cover with image pixels.
- CGFloat desiredHeight = [[NSStatusBar systemStatusBar] thickness] - 1.0;
- CGFloat scaleFactor = MIN(1.0, desiredHeight/imageSize.height);
-
- imageRect.size.width *= scaleFactor;
- imageRect.size.height *= scaleFactor;
+ CGFloat desiredSize = [[NSStatusBar systemStatusBar] thickness] - 1.0;
+ if (autosize) {
+ imageRect.size.width = desiredSize;
+ imageRect.size.height = desiredSize;
+ } else {
+ CGFloat scaleFactor = MIN(1.0, desiredSize/imageSize.height);
+ imageRect.size.width *= scaleFactor;
+ imageRect.size.height *= scaleFactor;
+ }
imageRect = NSIntegralRect(imageRect);
-
return imageRect.size;
}
@@ -101,9 +104,9 @@
return peer;
}
-- (void) setImage:(NSImage *) imagePtr sizing:(BOOL)autosize{
+- (void) setImage:(NSImage *) imagePtr sizing:(BOOL)autosize {
NSSize imageSize = [imagePtr size];
- NSSize scaledSize = ScaledImageSizeForStatusBar(imageSize);
+ NSSize scaledSize = ScaledImageSizeForStatusBar(imageSize, autosize);
if (imageSize.width != scaledSize.width ||
imageSize.height != scaledSize.height) {
[imagePtr setSize: scaledSize];
--- a/jdk/src/java.desktop/share/classes/com/sun/imageio/stream/StreamCloser.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/stream/StreamCloser.java Tue Apr 19 09:21:45 2016 -0700
@@ -26,7 +26,6 @@
package com.sun.imageio.stream;
import sun.awt.util.ThreadGroupUtils;
-import sun.misc.ManagedLocalsThread;
import java.io.IOException;
import java.security.AccessController;
@@ -92,8 +91,8 @@
* Make its parent the top-level thread group.
*/
ThreadGroup tg = ThreadGroupUtils.getRootThreadGroup();
- streamCloser = new ManagedLocalsThread(tg,
- streamCloserRunnable);
+ streamCloser = new Thread(tg, streamCloserRunnable,
+ "StreamCloser", 0, false);
/* Set context class loader to null in order to avoid
* keeping a strong reference to an application classloader.
*/
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java Tue Apr 19 09:21:45 2016 -0700
@@ -64,7 +64,6 @@
import sun.awt.OSInfo;
import sun.awt.shell.ShellFolder;
import sun.font.FontUtilities;
-import sun.misc.ManagedLocalsThread;
import sun.security.action.GetPropertyAction;
import sun.swing.DefaultLayoutStyle;
@@ -2053,7 +2052,7 @@
if (audioRunnable != null) {
// Runnable appears to block until completed playing, hence
// start up another thread to handle playing.
- new ManagedLocalsThread(audioRunnable).start();
+ new Thread(null, audioRunnable, "Audio", 0, false).start();
}
}
}
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/AudioFloatConverter.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/AudioFloatConverter.java Tue Apr 19 09:21:45 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
* 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,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
+
package com.sun.media.sound;
import java.nio.ByteBuffer;
@@ -319,8 +320,10 @@
float[] out_buff, int out_offset, int out_len) {
int ix = in_offset;
int ox = out_offset;
- for (int i = 0; i < out_len; i++)
- out_buff[ox++] = in_buff[ix++] * (1.0f / 127.0f);
+ for (int i = 0; i < out_len; i++) {
+ byte x = in_buff[ix++];
+ out_buff[ox++] = x > 0 ? x / 127.0f : x / 128.0f;
+ }
return out_buff;
}
@@ -328,8 +331,10 @@
byte[] out_buff, int out_offset) {
int ix = in_offset;
int ox = out_offset;
- for (int i = 0; i < in_len; i++)
- out_buff[ox++] = (byte) (in_buff[ix++] * 127.0f);
+ for (int i = 0; i < in_len; i++) {
+ final float x = in_buff[ix++];
+ out_buff[ox++] = (byte) (x > 0 ? x * 127 : x * 128);
+ }
return out_buff;
}
}
@@ -340,9 +345,10 @@
float[] out_buff, int out_offset, int out_len) {
int ix = in_offset;
int ox = out_offset;
- for (int i = 0; i < out_len; i++)
- out_buff[ox++] = ((in_buff[ix++] & 0xFF) - 127)
- * (1.0f / 127.0f);
+ for (int i = 0; i < out_len; i++) {
+ byte x = (byte) (in_buff[ix++] - 128);
+ out_buff[ox++] = x > 0 ? x / 127.0f : x / 128.0f;
+ }
return out_buff;
}
@@ -350,8 +356,10 @@
byte[] out_buff, int out_offset) {
int ix = in_offset;
int ox = out_offset;
- for (int i = 0; i < in_len; i++)
- out_buff[ox++] = (byte) (127 + in_buff[ix++] * 127.0f);
+ for (int i = 0; i < in_len; i++) {
+ float x = in_buff[ix++];
+ out_buff[ox++] = (byte) (128 + (x > 0 ? x * 127 : x * 128));
+ }
return out_buff;
}
}
@@ -369,10 +377,9 @@
int ix = in_offset;
int len = out_offset + out_len;
for (int ox = out_offset; ox < len; ox++) {
- out_buff[ox] = ((short) ((in_buff[ix++] & 0xFF) |
- (in_buff[ix++] << 8))) * (1.0f / 32767.0f);
+ short x = (short) (in_buff[ix++] & 0xFF | (in_buff[ix++] << 8));
+ out_buff[ox] = x > 0 ? x / 32767.0f : x / 32768.0f;
}
-
return out_buff;
}
@@ -381,7 +388,8 @@
int ox = out_offset;
int len = in_offset + in_len;
for (int ix = in_offset; ix < len; ix++) {
- int x = (int) (in_buff[ix] * 32767.0);
+ float f = in_buff[ix];
+ short x = (short) (f > 0 ? f * 32767 : f * 32768);
out_buff[ox++] = (byte) x;
out_buff[ox++] = (byte) (x >>> 8);
}
@@ -396,8 +404,8 @@
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < out_len; i++) {
- out_buff[ox++] = ((short) ((in_buff[ix++] << 8) |
- (in_buff[ix++] & 0xFF))) * (1.0f / 32767.0f);
+ short x = (short) ((in_buff[ix++] << 8) | (in_buff[ix++] & 0xFF));
+ out_buff[ox++] = x > 0 ? x / 32767.0f : x / 32768.0f;
}
return out_buff;
}
@@ -407,7 +415,8 @@
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < in_len; i++) {
- int x = (int) (in_buff[ix++] * 32767.0);
+ float f = in_buff[ix++];
+ short x = (short) (f > 0 ? f * 32767.0f : f * 32768.0f);
out_buff[ox++] = (byte) (x >>> 8);
out_buff[ox++] = (byte) x;
}
@@ -423,7 +432,8 @@
int ox = out_offset;
for (int i = 0; i < out_len; i++) {
int x = (in_buff[ix++] & 0xFF) | ((in_buff[ix++] & 0xFF) << 8);
- out_buff[ox++] = (x - 32767) * (1.0f / 32767.0f);
+ x -= 32768;
+ out_buff[ox++] = x > 0 ? x / 32767.0f : x / 32768.0f;
}
return out_buff;
}
@@ -433,7 +443,8 @@
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < in_len; i++) {
- int x = 32767 + (int) (in_buff[ix++] * 32767.0);
+ float f = in_buff[ix++];
+ int x = 32768 + (int) (f > 0 ? f * 32767 : f * 32768);
out_buff[ox++] = (byte) x;
out_buff[ox++] = (byte) (x >>> 8);
}
@@ -449,7 +460,8 @@
int ox = out_offset;
for (int i = 0; i < out_len; i++) {
int x = ((in_buff[ix++] & 0xFF) << 8) | (in_buff[ix++] & 0xFF);
- out_buff[ox++] = (x - 32767) * (1.0f / 32767.0f);
+ x -= 32768;
+ out_buff[ox++] = x > 0 ? x / 32767.0f : x / 32768.0f;
}
return out_buff;
}
@@ -459,7 +471,8 @@
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < in_len; i++) {
- int x = 32767 + (int) (in_buff[ix++] * 32767.0);
+ float f = in_buff[ix++];
+ int x = 32768 + (int) (f > 0 ? f * 32767 : f * 32768);
out_buff[ox++] = (byte) (x >>> 8);
out_buff[ox++] = (byte) x;
}
@@ -484,7 +497,7 @@
| ((in_buff[ix++] & 0xFF) << 16);
if (x > 0x7FFFFF)
x -= 0x1000000;
- out_buff[ox++] = x * (1.0f / (float)0x7FFFFF);
+ out_buff[ox++] = x > 0 ? x / 8388607.0f : x / 8388608.0f;
}
return out_buff;
}
@@ -494,7 +507,8 @@
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < in_len; i++) {
- int x = (int) (in_buff[ix++] * (float)0x7FFFFF);
+ float f = in_buff[ix++];
+ int x = (int) (f > 0 ? f * 8388607.0f : f * 8388608.0f);
if (x < 0)
x += 0x1000000;
out_buff[ox++] = (byte) x;
@@ -516,7 +530,7 @@
| ((in_buff[ix++] & 0xFF) << 8) | (in_buff[ix++] & 0xFF);
if (x > 0x7FFFFF)
x -= 0x1000000;
- out_buff[ox++] = x * (1.0f / (float)0x7FFFFF);
+ out_buff[ox++] = x > 0 ? x / 8388607.0f : x / 8388608.0f;
}
return out_buff;
}
@@ -526,7 +540,8 @@
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < in_len; i++) {
- int x = (int) (in_buff[ix++] * (float)0x7FFFFF);
+ float f = in_buff[ix++];
+ int x = (int) (f > 0 ? f * 8388607.0f : f * 8388608.0f);
if (x < 0)
x += 0x1000000;
out_buff[ox++] = (byte) (x >>> 16);
@@ -546,8 +561,8 @@
for (int i = 0; i < out_len; i++) {
int x = (in_buff[ix++] & 0xFF) | ((in_buff[ix++] & 0xFF) << 8)
| ((in_buff[ix++] & 0xFF) << 16);
- x -= 0x7FFFFF;
- out_buff[ox++] = x * (1.0f / (float)0x7FFFFF);
+ x -= 0x800000;
+ out_buff[ox++] = x > 0 ? x / 8388607.0f : x / 8388608.0f;
}
return out_buff;
}
@@ -557,8 +572,9 @@
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < in_len; i++) {
- int x = (int) (in_buff[ix++] * (float)0x7FFFFF);
- x += 0x7FFFFF;
+ float f = in_buff[ix++];
+ int x = (int) (f > 0 ? f * 8388607.0f : f * 8388608.0f);
+ x += 0x800000;
out_buff[ox++] = (byte) x;
out_buff[ox++] = (byte) (x >>> 8);
out_buff[ox++] = (byte) (x >>> 16);
@@ -576,8 +592,8 @@
for (int i = 0; i < out_len; i++) {
int x = ((in_buff[ix++] & 0xFF) << 16)
| ((in_buff[ix++] & 0xFF) << 8) | (in_buff[ix++] & 0xFF);
- x -= 0x7FFFFF;
- out_buff[ox++] = x * (1.0f / (float)0x7FFFFF);
+ x -= 0x800000;
+ out_buff[ox++] = x > 0 ? x / 8388607.0f : x / 8388608.0f;
}
return out_buff;
}
@@ -587,8 +603,9 @@
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < in_len; i++) {
- int x = (int) (in_buff[ix++] * (float)0x7FFFFF);
- x += 0x7FFFFF;
+ float f = in_buff[ix++];
+ int x = (int) (f > 0 ? f * 8388607.0f : f * 8388608.0f);
+ x += 8388608;
out_buff[ox++] = (byte) (x >>> 16);
out_buff[ox++] = (byte) (x >>> 8);
out_buff[ox++] = (byte) x;
@@ -673,7 +690,7 @@
int x = (in_buff[ix++] & 0xFF) | ((in_buff[ix++] & 0xFF) << 8) |
((in_buff[ix++] & 0xFF) << 16) |
((in_buff[ix++] & 0xFF) << 24);
- x -= 0x7FFFFFFF;
+ x -= 0x80000000;
out_buff[ox++] = x * (1.0f / (float)0x7FFFFFFF);
}
return out_buff;
@@ -685,7 +702,7 @@
int ox = out_offset;
for (int i = 0; i < in_len; i++) {
int x = (int) (in_buff[ix++] * (float)0x7FFFFFFF);
- x += 0x7FFFFFFF;
+ x += 0x80000000;
out_buff[ox++] = (byte) x;
out_buff[ox++] = (byte) (x >>> 8);
out_buff[ox++] = (byte) (x >>> 16);
@@ -706,7 +723,7 @@
int x = ((in_buff[ix++] & 0xFF) << 24) |
((in_buff[ix++] & 0xFF) << 16) |
((in_buff[ix++] & 0xFF) << 8) | (in_buff[ix++] & 0xFF);
- x -= 0x7FFFFFFF;
+ x -= 0x80000000;
out_buff[ox++] = x * (1.0f / (float)0x7FFFFFFF);
}
return out_buff;
@@ -718,7 +735,7 @@
int ox = out_offset;
for (int i = 0; i < in_len; i++) {
int x = (int) (in_buff[ix++] * (float)0x7FFFFFFF);
- x += 0x7FFFFFFF;
+ x += 0x80000000;
out_buff[ox++] = (byte) (x >>> 24);
out_buff[ox++] = (byte) (x >>> 16);
out_buff[ox++] = (byte) (x >>> 8);
@@ -737,7 +754,7 @@
// PCM 32+ bit, signed, little-endian
private static class AudioFloatConversion32xSL extends AudioFloatConverter {
- final int xbytes;
+ private final int xbytes;
AudioFloatConversion32xSL(int xbytes) {
this.xbytes = xbytes;
@@ -778,7 +795,7 @@
// PCM 32+ bit, signed, big-endian
private static class AudioFloatConversion32xSB extends AudioFloatConverter {
- final int xbytes;
+ private final int xbytes;
AudioFloatConversion32xSB(int xbytes) {
this.xbytes = xbytes;
@@ -820,7 +837,7 @@
// PCM 32+ bit, unsigned, little-endian
private static class AudioFloatConversion32xUL extends AudioFloatConverter {
- final int xbytes;
+ private final int xbytes;
AudioFloatConversion32xUL(int xbytes) {
this.xbytes = xbytes;
@@ -835,7 +852,7 @@
int x = (in_buff[ix++] & 0xFF) | ((in_buff[ix++] & 0xFF) << 8)
| ((in_buff[ix++] & 0xFF) << 16)
| ((in_buff[ix++] & 0xFF) << 24);
- x -= 0x7FFFFFFF;
+ x -= 0x80000000;
out_buff[ox++] = x * (1.0f / (float)0x7FFFFFFF);
}
return out_buff;
@@ -847,7 +864,7 @@
int ox = out_offset;
for (int i = 0; i < in_len; i++) {
int x = (int) (in_buff[ix++] * (float)0x7FFFFFFF);
- x += 0x7FFFFFFF;
+ x += 0x80000000;
for (int j = 0; j < xbytes; j++) {
out_buff[ox++] = 0;
}
@@ -863,7 +880,7 @@
// PCM 32+ bit, unsigned, big-endian
private static class AudioFloatConversion32xUB extends AudioFloatConverter {
- final int xbytes;
+ private final int xbytes;
AudioFloatConversion32xUB(int xbytes) {
this.xbytes = xbytes;
@@ -878,7 +895,7 @@
((in_buff[ix++] & 0xFF) << 16) |
((in_buff[ix++] & 0xFF) << 8) | (in_buff[ix++] & 0xFF);
ix += xbytes;
- x -= 2147483647;
+ x -= 0x80000000;
out_buff[ox++] = x * (1.0f / 2147483647.0f);
}
return out_buff;
@@ -889,8 +906,8 @@
int ix = in_offset;
int ox = out_offset;
for (int i = 0; i < in_len; i++) {
- int x = (int) (in_buff[ix++] * 2147483647.0);
- x += 2147483647;
+ int x = (int) (in_buff[ix++] * 2147483647.0f);
+ x += 0x80000000;
out_buff[ox++] = (byte) (x >>> 24);
out_buff[ox++] = (byte) (x >>> 16);
out_buff[ox++] = (byte) (x >>> 8);
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/JSSecurityManager.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/JSSecurityManager.java Tue Apr 19 09:21:45 2016 -0700
@@ -25,8 +25,6 @@
package com.sun.media.sound;
-import sun.misc.ManagedLocalsThread;
-
import java.io.BufferedInputStream;
import java.io.InputStream;
import java.io.File;
@@ -145,12 +143,11 @@
static Thread createThread(final Runnable runnable,
final String threadName,
final boolean isDaemon, final int priority,
- final boolean doStart) {
- Thread thread = new ManagedLocalsThread(runnable);
+ final boolean doStart)
+ {
+ String name = (threadName != null) ? threadName : "JSSM Thread";
+ Thread thread = new Thread(null, runnable, threadName, 0, false);
- if (threadName != null) {
- thread.setName(threadName);
- }
thread.setDaemon(isDaemon);
if (priority >= 0) {
thread.setPriority(priority);
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/JavaSoundAudioClip.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/JavaSoundAudioClip.java Tue Apr 19 09:21:45 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -232,7 +232,7 @@
} else if (sequencer != null) {
try {
sequencerloop = false;
- sequencer.addMetaEventListener(this);
+ sequencer.removeMetaEventListener(this);
sequencer.stop();
} catch (Exception e3) {
if (Printer.err) e3.printStackTrace();
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/SoftAudioPusher.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/SoftAudioPusher.java Tue Apr 19 09:21:45 2016 -0700
@@ -24,8 +24,6 @@
*/
package com.sun.media.sound;
-import sun.misc.ManagedLocalsThread;
-
import java.io.IOException;
import javax.sound.sampled.AudioInputStream;
@@ -55,7 +53,7 @@
if (active)
return;
active = true;
- audiothread = new ManagedLocalsThread(this);
+ audiothread = new Thread(null, this, "AudioPusher", 0, false);
audiothread.setDaemon(true);
audiothread.setPriority(Thread.MAX_PRIORITY);
audiothread.start();
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/SoftJitterCorrector.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/SoftJitterCorrector.java Tue Apr 19 09:21:45 2016 -0700
@@ -24,8 +24,6 @@
*/
package com.sun.media.sound;
-import sun.misc.ManagedLocalsThread;
-
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import java.io.EOFException;
@@ -216,7 +214,7 @@
}
};
- thread = new ManagedLocalsThread(runnable);
+ thread = new Thread(null, runnable, "JitterCorrector", 0, false);
thread.setDaemon(true);
thread.setPriority(Thread.MAX_PRIORITY);
thread.start();
--- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/SoftSynthesizer.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/SoftSynthesizer.java Tue Apr 19 09:21:45 2016 -0700
@@ -25,8 +25,6 @@
package com.sun.media.sound;
-import sun.misc.ManagedLocalsThread;
-
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
@@ -141,7 +139,7 @@
pusher = null;
jitter_stream = null;
sourceDataLine = null;
- new ManagedLocalsThread(runnable).start();
+ new Thread(null, runnable, "Synthesizer",0,false).start();
}
return len;
}
--- a/jdk/src/java.desktop/share/classes/java/awt/EventDispatchThread.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/java/awt/EventDispatchThread.java Tue Apr 19 09:21:45 2016 -0700
@@ -31,7 +31,6 @@
import java.util.ArrayList;
-import sun.misc.ManagedLocalsThread;
import sun.util.logging.PlatformLogger;
import sun.awt.dnd.SunDragSourceContextPeer;
@@ -55,7 +54,7 @@
*
* @since 1.1
*/
-class EventDispatchThread extends ManagedLocalsThread {
+class EventDispatchThread extends Thread {
private static final PlatformLogger eventLog = PlatformLogger.getLogger("java.awt.event.EventDispatchThread");
@@ -66,8 +65,16 @@
private ArrayList<EventFilter> eventFilters = new ArrayList<EventFilter>();
+ /**
+ * Must always call 5 args super-class constructor passing false
+ * to indicate not to inherit locals.
+ */
+ private EventDispatchThread() {
+ throw new UnsupportedOperationException("Must erase locals");
+ }
+
EventDispatchThread(ThreadGroup group, String name, EventQueue queue) {
- super(group, name);
+ super(group, null, name, 0, false);
setEventQueue(queue);
}
--- a/jdk/src/java.desktop/share/classes/java/awt/Font.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/java/awt/Font.java Tue Apr 19 09:21:45 2016 -0700
@@ -766,6 +766,49 @@
}
/**
+ * Returns true if any part of the specified text is from a
+ * complex script for which the implementation will need to invoke
+ * layout processing in order to render correctly when using
+ * {@link Graphics#drawString(String,int,int) drawString(String,int,int)}
+ * and other text rendering methods. Measurement of the text
+ * may similarly need the same extra processing.
+ * The {@code start} and {@code end} indices are provided so that
+ * the application can request only a subset of the text be considered.
+ * The last char index examined is at {@code "end-1"},
+ * i.e a request to examine the entire array would be
+ * <pre>
+ * {@code Font.textRequiresLayout(chars, 0, chars.length);}
+ * </pre>
+ * An application may find this information helpful in
+ * performance sensitive code.
+ * <p>
+ * Note that even if this method returns {@code false}, layout processing
+ * may still be invoked when used with any {@code Font}
+ * for which {@link #hasLayoutAttributes()} returns {@code true},
+ * so that method will need to be consulted for the specific font,
+ * in order to obtain an answer which accounts for such font attributes.
+ *
+ * @param chars the text.
+ * @param start the index of the first char to examine.
+ * @param end the ending index, exclusive.
+ * @return {@code true} if the specified text will need special layout.
+ * @throws NullPointerException if {@code chars} is null.
+ * @throws ArrayIndexOutOfBoundsException if {@code start} is negative or
+ * {@code end} is greater than the length of the {@code chars} array.
+ * @since 9
+ */
+ public static boolean textRequiresLayout(char[] chars,
+ int start, int end) {
+ if (chars == null) {
+ throw new NullPointerException("null char array");
+ }
+ if (start < 0 || end > chars.length) {
+ throw new ArrayIndexOutOfBoundsException("start < 0 or end > len");
+ }
+ return FontUtilities.isComplexScript(chars, start, end);
+ }
+
+ /**
* Returns a {@code Font} appropriate to the attributes.
* If {@code attributes} contains a {@code FONT} attribute
* with a valid {@code Font} as its value, it will be
--- a/jdk/src/java.desktop/share/classes/java/awt/image/PackedColorModel.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/java/awt/image/PackedColorModel.java Tue Apr 19 09:21:45 2016 -0700
@@ -404,9 +404,6 @@
PackedColorModel cm = (PackedColorModel) obj;
int numC = cm.getNumComponents();
- if (numC != numComponents) {
- return false;
- }
for(int i=0; i < numC; i++) {
if (maskArray[i] != cm.getMask(i)) {
return false;
--- a/jdk/src/java.desktop/share/classes/java/awt/image/Raster.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/java/awt/image/Raster.java Tue Apr 19 09:21:45 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -629,7 +629,8 @@
int scanlineStride,
int pixelStride,
int bandOffsets[],
- Point location) {
+ Point location)
+ {
if (dataBuffer == null) {
throw new NullPointerException("DataBuffer cannot be null");
}
@@ -645,15 +646,26 @@
bandOffsets);
switch(dataType) {
case DataBuffer.TYPE_BYTE:
- return new ByteInterleavedRaster(csm, dataBuffer, location);
+ if (dataBuffer instanceof DataBufferByte) {
+ return new ByteInterleavedRaster(csm,
+ (DataBufferByte) dataBuffer, location);
+ }
+ break;
case DataBuffer.TYPE_USHORT:
- return new ShortInterleavedRaster(csm, dataBuffer, location);
+ if (dataBuffer instanceof DataBufferUShort) {
+ return new ShortInterleavedRaster(csm,
+ (DataBufferUShort) dataBuffer, location);
+ }
+ break;
default:
throw new IllegalArgumentException("Unsupported data type " +
dataType);
}
+
+ // Create the generic raster
+ return new SunWritableRaster(csm, dataBuffer, location);
}
/**
@@ -691,7 +703,8 @@
int scanlineStride,
int bankIndices[],
int bandOffsets[],
- Point location) {
+ Point location)
+ {
if (dataBuffer == null) {
throw new NullPointerException("DataBuffer cannot be null");
}
@@ -713,18 +726,29 @@
switch(dataType) {
case DataBuffer.TYPE_BYTE:
- return new ByteBandedRaster(bsm, dataBuffer, location);
+ if (dataBuffer instanceof DataBufferByte) {
+ return new ByteBandedRaster(bsm,
+ (DataBufferByte) dataBuffer, location);
+ }
+ break;
case DataBuffer.TYPE_USHORT:
- return new ShortBandedRaster(bsm, dataBuffer, location);
+ if (dataBuffer instanceof DataBufferUShort) {
+ return new ShortBandedRaster(bsm,
+ (DataBufferUShort) dataBuffer, location);
+ }
+ break;
case DataBuffer.TYPE_INT:
- return new SunWritableRaster(bsm, dataBuffer, location);
+ break;
default:
throw new IllegalArgumentException("Unsupported data type " +
dataType);
}
+
+ // Create the generic raster
+ return new SunWritableRaster(bsm, dataBuffer, location);
}
/**
@@ -761,7 +785,8 @@
int w, int h,
int scanlineStride,
int bandMasks[],
- Point location) {
+ Point location)
+ {
if (dataBuffer == null) {
throw new NullPointerException("DataBuffer cannot be null");
}
@@ -776,18 +801,33 @@
switch(dataType) {
case DataBuffer.TYPE_BYTE:
- return new ByteInterleavedRaster(sppsm, dataBuffer, location);
+ if (dataBuffer instanceof DataBufferByte) {
+ return new ByteInterleavedRaster(sppsm,
+ (DataBufferByte) dataBuffer, location);
+ }
+ break;
case DataBuffer.TYPE_USHORT:
- return new ShortInterleavedRaster(sppsm, dataBuffer, location);
+ if (dataBuffer instanceof DataBufferUShort) {
+ return new ShortInterleavedRaster(sppsm,
+ (DataBufferUShort) dataBuffer, location);
+ }
+ break;
case DataBuffer.TYPE_INT:
- return new IntegerInterleavedRaster(sppsm, dataBuffer, location);
+ if (dataBuffer instanceof DataBufferInt) {
+ return new IntegerInterleavedRaster(sppsm,
+ (DataBufferInt) dataBuffer, location);
+ }
+ break;
default:
throw new IllegalArgumentException("Unsupported data type " +
dataType);
}
+
+ // Create the generic raster
+ return new SunWritableRaster(sppsm, dataBuffer, location);
}
/**
@@ -821,7 +861,8 @@
public static WritableRaster createPackedRaster(DataBuffer dataBuffer,
int w, int h,
int bitsPerPixel,
- Point location) {
+ Point location)
+ {
if (dataBuffer == null) {
throw new NullPointerException("DataBuffer cannot be null");
}
@@ -846,9 +887,10 @@
MultiPixelPackedSampleModel mppsm =
new MultiPixelPackedSampleModel(dataType, w, h, bitsPerPixel);
- if (dataType == DataBuffer.TYPE_BYTE &&
- (bitsPerPixel == 1 || bitsPerPixel == 2 || bitsPerPixel == 4)) {
- return new BytePackedRaster(mppsm, dataBuffer, location);
+ if (dataBuffer instanceof DataBufferByte &&
+ (bitsPerPixel == 1 || bitsPerPixel == 2 || bitsPerPixel == 4))
+ {
+ return new BytePackedRaster(mppsm, (DataBufferByte) dataBuffer, location);
} else {
return new SunWritableRaster(mppsm, dataBuffer, location);
}
@@ -878,7 +920,8 @@
*/
public static Raster createRaster(SampleModel sm,
DataBuffer db,
- Point location) {
+ Point location)
+ {
if ((sm == null) || (db == null)) {
throw new NullPointerException("SampleModel and DataBuffer cannot be null");
}
@@ -890,32 +933,53 @@
if (sm instanceof PixelInterleavedSampleModel) {
switch(dataType) {
- case DataBuffer.TYPE_BYTE:
- return new ByteInterleavedRaster(sm, db, location);
+ case DataBuffer.TYPE_BYTE:
+ if (db instanceof DataBufferByte) {
+ return new ByteInterleavedRaster(sm,
+ (DataBufferByte) db, location);
+ }
+ break;
- case DataBuffer.TYPE_USHORT:
- return new ShortInterleavedRaster(sm, db, location);
+ case DataBuffer.TYPE_USHORT:
+ if (db instanceof DataBufferUShort) {
+ return new ShortInterleavedRaster(sm,
+ (DataBufferUShort) db, location);
+ }
+ break;
}
} else if (sm instanceof SinglePixelPackedSampleModel) {
switch(dataType) {
- case DataBuffer.TYPE_BYTE:
- return new ByteInterleavedRaster(sm, db, location);
+ case DataBuffer.TYPE_BYTE:
+ if (db instanceof DataBufferByte) {
+ return new ByteInterleavedRaster(sm,
+ (DataBufferByte) db, location);
+ }
+ break;
- case DataBuffer.TYPE_USHORT:
- return new ShortInterleavedRaster(sm, db, location);
+ case DataBuffer.TYPE_USHORT:
+ if (db instanceof DataBufferUShort) {
+ return new ShortInterleavedRaster(sm,
+ (DataBufferUShort) db, location);
+ }
+ break;
- case DataBuffer.TYPE_INT:
- return new IntegerInterleavedRaster(sm, db, location);
+ case DataBuffer.TYPE_INT:
+ if (db instanceof DataBufferInt) {
+ return new IntegerInterleavedRaster(sm,
+ (DataBufferInt) db, location);
+ }
+ break;
}
} else if (sm instanceof MultiPixelPackedSampleModel &&
dataType == DataBuffer.TYPE_BYTE &&
- sm.getSampleSize(0) < 8) {
- return new BytePackedRaster(sm, db, location);
+ db instanceof DataBufferByte &&
+ sm.getSampleSize(0) < 8)
+ {
+ return new BytePackedRaster(sm, (DataBufferByte) db, location);
}
// we couldn't do anything special - do the generic thing
-
- return new Raster(sm,db,location);
+ return new Raster(sm, db, location);
}
/**
@@ -964,7 +1028,8 @@
*/
public static WritableRaster createWritableRaster(SampleModel sm,
DataBuffer db,
- Point location) {
+ Point location)
+ {
if ((sm == null) || (db == null)) {
throw new NullPointerException("SampleModel and DataBuffer cannot be null");
}
@@ -976,32 +1041,53 @@
if (sm instanceof PixelInterleavedSampleModel) {
switch(dataType) {
- case DataBuffer.TYPE_BYTE:
- return new ByteInterleavedRaster(sm, db, location);
+ case DataBuffer.TYPE_BYTE:
+ if (db instanceof DataBufferByte) {
+ return new ByteInterleavedRaster(sm,
+ (DataBufferByte) db, location);
+ }
+ break;
- case DataBuffer.TYPE_USHORT:
- return new ShortInterleavedRaster(sm, db, location);
+ case DataBuffer.TYPE_USHORT:
+ if (db instanceof DataBufferUShort) {
+ return new ShortInterleavedRaster(sm,
+ (DataBufferUShort) db, location);
+ }
+ break;
}
} else if (sm instanceof SinglePixelPackedSampleModel) {
switch(dataType) {
- case DataBuffer.TYPE_BYTE:
- return new ByteInterleavedRaster(sm, db, location);
+ case DataBuffer.TYPE_BYTE:
+ if (db instanceof DataBufferByte) {
+ return new ByteInterleavedRaster(sm,
+ (DataBufferByte) db, location);
+ }
+ break;
- case DataBuffer.TYPE_USHORT:
- return new ShortInterleavedRaster(sm, db, location);
+ case DataBuffer.TYPE_USHORT:
+ if (db instanceof DataBufferUShort) {
+ return new ShortInterleavedRaster(sm,
+ (DataBufferUShort) db, location);
+ }
+ break;
- case DataBuffer.TYPE_INT:
- return new IntegerInterleavedRaster(sm, db, location);
+ case DataBuffer.TYPE_INT:
+ if (db instanceof DataBufferInt) {
+ return new IntegerInterleavedRaster(sm,
+ (DataBufferInt) db, location);
+ }
+ break;
}
} else if (sm instanceof MultiPixelPackedSampleModel &&
dataType == DataBuffer.TYPE_BYTE &&
- sm.getSampleSize(0) < 8) {
- return new BytePackedRaster(sm, db, location);
+ db instanceof DataBufferByte &&
+ sm.getSampleSize(0) < 8)
+ {
+ return new BytePackedRaster(sm, (DataBufferByte) db, location);
}
// we couldn't do anything special - do the generic thing
-
- return new SunWritableRaster(sm,db,location);
+ return new SunWritableRaster(sm, db, location);
}
/**
--- a/jdk/src/java.desktop/share/classes/java/awt/image/renderable/RenderableImageProducer.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/java/awt/image/renderable/RenderableImageProducer.java Tue Apr 19 09:21:45 2016 -0700
@@ -35,8 +35,6 @@
package java.awt.image.renderable;
-import sun.misc.ManagedLocalsThread;
-
import java.awt.image.ColorModel;
import java.awt.image.DataBuffer;
import java.awt.image.ImageConsumer;
@@ -137,7 +135,7 @@
addConsumer(ic);
// Need to build a runnable object for the Thread.
String name = "RenderableImageProducer Thread";
- Thread thread = new ManagedLocalsThread(this, name);
+ Thread thread = new Thread(null, this, name, 0, false);
thread.start();
}
--- a/jdk/src/java.desktop/share/classes/javax/imageio/ImageIO.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/javax/imageio/ImageIO.java Tue Apr 19 09:21:45 2016 -0700
@@ -1294,7 +1294,8 @@
*
* @exception IllegalArgumentException if {@code input} is
* {@code null}.
- * @exception IOException if an error occurs during reading.
+ * @exception IOException if an error occurs during reading or when not
+ * able to create required ImageInputStream.
*/
public static BufferedImage read(File input) throws IOException {
if (input == null) {
@@ -1344,7 +1345,8 @@
*
* @exception IllegalArgumentException if {@code input} is
* {@code null}.
- * @exception IOException if an error occurs during reading.
+ * @exception IOException if an error occurs during reading or when not
+ * able to create required ImageInputStream.
*/
public static BufferedImage read(InputStream input) throws IOException {
if (input == null) {
@@ -1352,6 +1354,9 @@
}
ImageInputStream stream = createImageInputStream(input);
+ if (stream == null) {
+ throw new IIOException("Can't create an ImageInputStream!");
+ }
BufferedImage bi = read(stream);
if (bi == null) {
stream.close();
@@ -1384,7 +1389,8 @@
*
* @exception IllegalArgumentException if {@code input} is
* {@code null}.
- * @exception IOException if an error occurs during reading.
+ * @exception IOException if an error occurs during reading or when not
+ * able to create required ImageInputStream.
*/
public static BufferedImage read(URL input) throws IOException {
if (input == null) {
@@ -1398,6 +1404,14 @@
throw new IIOException("Can't get input stream from URL!", e);
}
ImageInputStream stream = createImageInputStream(istream);
+ if (stream == null) {
+ /* close the istream when stream is null so that if user has
+ * given filepath as URL he can delete it, otherwise stream will
+ * be open to that file and he will not be able to delete it.
+ */
+ istream.close();
+ throw new IIOException("Can't create an ImageInputStream!");
+ }
BufferedImage bi;
try {
bi = read(stream);
@@ -1510,7 +1524,8 @@
*
* @exception IllegalArgumentException if any parameter is
* {@code null}.
- * @exception IOException if an error occurs during writing.
+ * @exception IOException if an error occurs during writing or when not
+ * able to create required ImageOutputStream.
*/
public static boolean write(RenderedImage im,
String formatName,
@@ -1518,7 +1533,6 @@
if (output == null) {
throw new IllegalArgumentException("output == null!");
}
- ImageOutputStream stream = null;
ImageWriter writer = getWriter(im, formatName);
if (writer == null) {
@@ -1528,13 +1542,11 @@
return false;
}
- try {
- output.delete();
- stream = createImageOutputStream(output);
- } catch (IOException e) {
- throw new IIOException("Can't create output stream!", e);
+ output.delete();
+ ImageOutputStream stream = createImageOutputStream(output);
+ if (stream == null) {
+ throw new IIOException("Can't create an ImageOutputStream!");
}
-
try {
return doWrite(im, writer, stream);
} finally {
@@ -1562,7 +1574,8 @@
*
* @exception IllegalArgumentException if any parameter is
* {@code null}.
- * @exception IOException if an error occurs during writing.
+ * @exception IOException if an error occurs during writing or when not
+ * able to create required ImageOutputStream.
*/
public static boolean write(RenderedImage im,
String formatName,
@@ -1570,13 +1583,10 @@
if (output == null) {
throw new IllegalArgumentException("output == null!");
}
- ImageOutputStream stream = null;
- try {
- stream = createImageOutputStream(output);
- } catch (IOException e) {
- throw new IIOException("Can't create output stream!", e);
+ ImageOutputStream stream = createImageOutputStream(output);
+ if (stream == null) {
+ throw new IIOException("Can't create an ImageOutputStream!");
}
-
try {
return doWrite(im, getWriter(im, formatName), stream);
} finally {
--- a/jdk/src/java.desktop/share/classes/javax/swing/JFileChooser.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JFileChooser.java Tue Apr 19 09:21:45 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,13 +26,12 @@
import javax.swing.event.*;
import javax.swing.filechooser.*;
+import javax.swing.filechooser.FileFilter;
import javax.swing.plaf.FileChooserUI;
import javax.accessibility.*;
-import java.io.File;
-import java.io.ObjectOutputStream;
-import java.io.IOException;
+import java.io.*;
import java.util.Vector;
import java.awt.AWTEvent;
@@ -51,8 +50,6 @@
import java.beans.BeanProperty;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeEvent;
-import java.io.InvalidObjectException;
-import java.io.ObjectInputStream;
import java.lang.ref.WeakReference;
/**
@@ -390,19 +387,7 @@
}
private void installHierarchyListener() {
- addHierarchyListener(new HierarchyListener() {
- @Override
- public void hierarchyChanged(HierarchyEvent e) {
- if ((e.getChangeFlags() & HierarchyEvent.PARENT_CHANGED)
- == HierarchyEvent.PARENT_CHANGED) {
- JFileChooser fc = JFileChooser.this;
- JRootPane rootPane = SwingUtilities.getRootPane(fc);
- if (rootPane != null) {
- rootPane.setDefaultButton(fc.getUI().getDefaultButton(fc));
- }
- }
- }
- });
+ addHierarchyListener(new FCHierarchyListener());
}
private void installShowFilesListener() {
@@ -2055,4 +2040,18 @@
} // inner class AccessibleJFileChooser
+ private class FCHierarchyListener implements HierarchyListener,
+ Serializable {
+ @Override
+ public void hierarchyChanged(HierarchyEvent e) {
+ if ((e.getChangeFlags() & HierarchyEvent.PARENT_CHANGED)
+ == HierarchyEvent.PARENT_CHANGED) {
+ JFileChooser fc = JFileChooser.this;
+ JRootPane rootPane = SwingUtilities.getRootPane(fc);
+ if (rootPane != null) {
+ rootPane.setDefaultButton(fc.getUI().getDefaultButton(fc));
+ }
+ }
+ }
+ }
}
--- a/jdk/src/java.desktop/share/classes/javax/swing/JMenu.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JMenu.java Tue Apr 19 09:21:45 2016 -0700
@@ -1296,7 +1296,7 @@
* @return the array of menu items
*/
private MenuElement[] buildMenuElementArray(JMenu leaf) {
- Vector<MenuElement> elements = new Vector<MenuElement>();
+ Vector<MenuElement> elements = new Vector<>();
Component current = leaf.getPopupMenu();
JPopupMenu pop;
JMenu menu;
@@ -1314,11 +1314,14 @@
} else if (current instanceof JMenuBar) {
bar = (JMenuBar) current;
elements.insertElementAt(bar, 0);
- MenuElement me[] = new MenuElement[elements.size()];
- elements.copyInto(me);
- return me;
+ break;
+ } else {
+ break;
}
}
+ MenuElement me[] = new MenuElement[elements.size()];
+ elements.copyInto(me);
+ return me;
}
--- a/jdk/src/java.desktop/share/classes/javax/swing/JTable.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JTable.java Tue Apr 19 09:21:45 2016 -0700
@@ -56,7 +56,6 @@
import javax.print.attribute.*;
import javax.print.PrintService;
-import sun.misc.ManagedLocalsThread;
import sun.reflect.misc.ReflectUtil;
import sun.swing.SwingUtilities2;
@@ -6375,7 +6374,7 @@
};
// start printing on another thread
- Thread th = new ManagedLocalsThread(runnable);
+ Thread th = new Thread(null, runnable, "JTablePrint", 0, false);
th.start();
printingStatus.showModal(true);
--- a/jdk/src/java.desktop/share/classes/javax/swing/TimerQueue.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/javax/swing/TimerQueue.java Tue Apr 19 09:21:45 2016 -0700
@@ -36,7 +36,6 @@
import java.util.concurrent.locks.*;
import java.util.concurrent.atomic.AtomicLong;
import sun.awt.AppContext;
-import sun.misc.ManagedLocalsThread;
/**
* Internal class to manage all Timers using one thread.
@@ -101,8 +100,8 @@
final ThreadGroup threadGroup = AppContext.getAppContext().getThreadGroup();
AccessController.doPrivileged((PrivilegedAction<Object>) () -> {
String name = "TimerQueue";
- Thread timerThread = new ManagedLocalsThread(threadGroup,
- this, name);
+ Thread timerThread =
+ new Thread(threadGroup, this, name, 0, false);
timerThread.setDaemon(true);
timerThread.setPriority(Thread.NORM_PRIORITY);
timerThread.start();
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicDirectoryModel.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicDirectoryModel.java Tue Apr 19 09:21:45 2016 -0700
@@ -26,7 +26,6 @@
package javax.swing.plaf.basic;
import sun.awt.shell.ShellFolder;
-import sun.misc.ManagedLocalsThread;
import javax.swing.*;
import javax.swing.event.ListDataEvent;
@@ -271,7 +270,7 @@
this.currentDirectory = currentDirectory;
this.fid = fid;
String name = "Basic L&F File Loading Thread";
- this.loadThread = new ManagedLocalsThread(this, name);
+ this.loadThread = new Thread(null, this, name, 0, false);
this.loadThread.start();
}
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicPopupMenuUI.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicPopupMenuUI.java Tue Apr 19 09:21:45 2016 -0700
@@ -797,9 +797,11 @@
if (invoker instanceof JPopupMenu) {
invoker = ((JPopupMenu)invoker).getInvoker();
}
- grabbedWindow = invoker instanceof Window?
- (Window)invoker :
- SwingUtilities.getWindowAncestor(invoker);
+ grabbedWindow = (invoker == null)
+ ? null
+ : ((invoker instanceof Window)
+ ? (Window) invoker
+ : SwingUtilities.getWindowAncestor(invoker));
if(grabbedWindow != null) {
if(tk instanceof sun.awt.SunToolkit) {
((sun.awt.SunToolkit)tk).grab(grabbedWindow);
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/nimbus/NimbusStyle.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/nimbus/NimbusStyle.java Tue Apr 19 09:21:45 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -995,16 +995,7 @@
// StateInfo match, otherwise a StateInfo with
// SELECTED | ENABLED would match ENABLED, which we
// don't want.
-
- // This comes from BigInteger.bitCnt
- int bitCount = oState;
- bitCount -= (0xaaaaaaaa & bitCount) >>> 1;
- bitCount = (bitCount & 0x33333333) + ((bitCount >>> 2) &
- 0x33333333);
- bitCount = bitCount + (bitCount >>> 4) & 0x0f0f0f0f;
- bitCount += bitCount >>> 8;
- bitCount += bitCount >>> 16;
- bitCount = bitCount & 0xff;
+ int bitCount = Integer.bitCount(oState);
if (bitCount > bestCount) {
bestIndex = counter;
bestCount = bitCount;
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthStyle.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthStyle.java Tue Apr 19 09:21:45 2016 -0700
@@ -775,7 +775,7 @@
if (disabledColor == null || disabledColor instanceof UIResource) {
return getColorForState(context, type);
}
- } else if (c instanceof JLabel &&
+ } else if ((c instanceof JLabel || c instanceof JMenuItem) &&
(type == ColorType.FOREGROUND ||
type == ColorType.TEXT_FOREGROUND)) {
return getColorForState(context, type);
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/JTextComponent.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/JTextComponent.java Tue Apr 19 09:21:45 2016 -0700
@@ -70,7 +70,6 @@
import sun.awt.AppContext;
-import sun.misc.ManagedLocalsThread;
import sun.swing.PrintingStatus;
import sun.swing.SwingUtilities2;
import sun.swing.text.TextComponentPrintable;
@@ -2353,7 +2352,8 @@
runnablePrinting.run();
} else {
if (isEventDispatchThread) {
- new ManagedLocalsThread(runnablePrinting).start();
+ new Thread(null, runnablePrinting,
+ "JTextComponentPrint", 0, false ).start();
printingStatus.showModal(true);
} else {
printingStatus.showModal(false);
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/LayoutQueue.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/LayoutQueue.java Tue Apr 19 09:21:45 2016 -0700
@@ -26,7 +26,6 @@
import java.util.Vector;
import sun.awt.AppContext;
-import sun.misc.ManagedLocalsThread;
/**
* A queue of text layout tasks.
@@ -92,7 +91,7 @@
}
} while (work != null);
};
- worker = new ManagedLocalsThread(workerRunnable, "text-layout");
+ worker = new Thread(null, workerRunnable, "text-layout", 0, false);
worker.setPriority(Thread.MIN_PRIORITY);
worker.start();
}
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/html/CSS.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/html/CSS.java Tue Apr 19 09:21:45 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -1522,8 +1522,16 @@
current++;
}
last = current;
- while (current < length && !Character.isWhitespace
- (value.charAt(current))) {
+ int inParentheses = 0;
+ char ch;
+ while (current < length && (
+ !Character.isWhitespace(ch = value.charAt(current))
+ || inParentheses > 0)) {
+ if (ch == '(') {
+ inParentheses++;
+ } else if (ch == ')') {
+ inParentheses--;
+ }
current++;
}
if (last != current) {
--- a/jdk/src/java.desktop/share/classes/sun/applet/AppletClassLoader.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/sun/applet/AppletClassLoader.java Tue Apr 19 09:21:45 2016 -0700
@@ -52,7 +52,6 @@
import java.security.PermissionCollection;
import sun.awt.AppContext;
import sun.awt.SunToolkit;
-import sun.misc.ManagedLocalsThread;
import sun.net.www.ParseUtil;
import sun.security.util.SecurityConstants;
@@ -858,13 +857,20 @@
* this operation to complete before continuing, wait for the notifyAll()
* operation on the syncObject to occur.
*/
-class AppContextCreator extends ManagedLocalsThread {
+class AppContextCreator extends Thread {
Object syncObject = new Object();
AppContext appContext = null;
volatile boolean created = false;
+ /**
+ * Must call the 5-args super-class constructor to erase locals.
+ */
+ private AppContextCreator() {
+ throw new UnsupportedOperationException("Must erase locals");
+ }
+
AppContextCreator(ThreadGroup group) {
- super(group, "AppContextCreator");
+ super(group, null, "AppContextCreator", 0, false);
}
public void run() {
--- a/jdk/src/java.desktop/share/classes/sun/applet/AppletPanel.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/sun/applet/AppletPanel.java Tue Apr 19 09:21:45 2016 -0700
@@ -44,7 +44,6 @@
import sun.awt.EmbeddedFrame;
import sun.awt.SunToolkit;
import sun.awt.util.PerformanceLogger;
-import sun.misc.ManagedLocalsThread;
import sun.security.util.SecurityConstants;
/**
@@ -166,7 +165,7 @@
ThreadGroup appletGroup = loader.getThreadGroup();
- handler = new ManagedLocalsThread(appletGroup, this, "thread " + nm);
+ handler = new Thread(appletGroup, this, "thread " + nm, 0, false);
// set the context class loader for this thread
AccessController.doPrivileged(new PrivilegedAction<Object>() {
@Override
@@ -396,9 +395,8 @@
// until the loader thread terminates.
// (one way or another).
if (loaderThread == null) {
- // REMIND: do we want a name?
- //System.out.println("------------------- loading applet");
- setLoaderThread(new ManagedLocalsThread(this));
+ setLoaderThread(new Thread(null, this,
+ "AppletLoader", 0, false));
loaderThread.start();
// we get to go to sleep while this runs
loaderThread.join();
--- a/jdk/src/java.desktop/share/classes/sun/applet/AppletViewer.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/sun/applet/AppletViewer.java Tue Apr 19 09:21:45 2016 -0700
@@ -38,7 +38,6 @@
import java.security.PrivilegedAction;
import sun.awt.SunToolkit;
import sun.awt.AppContext;
-import sun.misc.ManagedLocalsThread;
/**
* A frame to show the applet tag in.
@@ -854,7 +853,7 @@
//
final AppletPanel p = panel;
- new ManagedLocalsThread(new Runnable()
+ new Thread(null, new Runnable()
{
@Override
public void run()
@@ -867,7 +866,8 @@
appletSystemExit();
}
}
- }).start();
+ },
+ "AppletCloser", 0, false).start();
}
/**
@@ -890,7 +890,7 @@
// spawn a new thread to avoid blocking the event queue
// when calling appletShutdown.
//
- new ManagedLocalsThread(new Runnable()
+ new Thread(null, new Runnable()
{
@Override
public void run()
@@ -901,7 +901,8 @@
}
appletSystemExit();
}
- }).start();
+ },
+ "AppletQuit", 0, false).start();
}
/**
--- a/jdk/src/java.desktop/share/classes/sun/awt/AWTAutoShutdown.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/sun/awt/AWTAutoShutdown.java Tue Apr 19 09:21:45 2016 -0700
@@ -34,7 +34,6 @@
import java.util.Set;
import sun.awt.util.ThreadGroupUtils;
-import sun.misc.ManagedLocalsThread;
import sun.util.logging.PlatformLogger;
/**
@@ -337,8 +336,8 @@
private void activateBlockerThread() {
AccessController.doPrivileged((PrivilegedAction<Thread>) () -> {
String name = "AWT-Shutdown";
- Thread thread = new ManagedLocalsThread(
- ThreadGroupUtils.getRootThreadGroup(), this, name);
+ Thread thread = new Thread(
+ ThreadGroupUtils.getRootThreadGroup(), this, name, 0, false);
thread.setContextClassLoader(null);
thread.setDaemon(false);
blockerThread = thread;
--- a/jdk/src/java.desktop/share/classes/sun/awt/AppContext.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/sun/awt/AppContext.java Tue Apr 19 09:21:45 2016 -0700
@@ -46,7 +46,6 @@
import jdk.internal.misc.JavaAWTAccess;
import jdk.internal.misc.SharedSecrets;
-import sun.misc.ManagedLocalsThread;
import sun.util.logging.PlatformLogger;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
@@ -598,8 +597,8 @@
}
public Thread run() {
- Thread t = new ManagedLocalsThread(appContext.getThreadGroup(),
- runnable, "AppContext Disposer");
+ Thread t = new Thread(appContext.getThreadGroup(),
+ runnable, "AppContext Disposer", 0, false);
t.setContextClassLoader(appContext.getContextClassLoader());
t.setPriority(Thread.NORM_PRIORITY + 1);
t.setDaemon(true);
--- a/jdk/src/java.desktop/share/classes/sun/awt/im/InputMethodManager.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/sun/awt/im/InputMethodManager.java Tue Apr 19 09:21:45 2016 -0700
@@ -55,7 +55,6 @@
import java.util.prefs.Preferences;
import sun.awt.InputMethodSupport;
import sun.awt.SunToolkit;
-import sun.misc.ManagedLocalsThread;
/**
* {@code InputMethodManager} is an abstract class that manages the input
@@ -166,7 +165,8 @@
// to choose from. Otherwise, just keep the instance.
if (imm.hasMultipleInputMethods()) {
imm.initialize();
- Thread immThread = new ManagedLocalsThread(imm, threadName);
+ Thread immThread =
+ new Thread(null, imm, threadName, 0, false);
immThread.setDaemon(true);
immThread.setPriority(Thread.NORM_PRIORITY + 1);
immThread.start();
--- a/jdk/src/java.desktop/share/classes/sun/awt/image/ByteBandedRaster.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/sun/awt/image/ByteBandedRaster.java Tue Apr 19 09:21:45 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -29,7 +29,6 @@
import java.awt.image.RasterFormatException;
import java.awt.image.SampleModel;
import java.awt.image.BandedSampleModel;
-import java.awt.image.DataBuffer;
import java.awt.image.DataBufferByte;
import java.awt.Rectangle;
import java.awt.Point;
@@ -74,10 +73,9 @@
* @param sampleModel The SampleModel that specifies the layout.
* @param origin The Point that specifies the origin.
*/
- public ByteBandedRaster(SampleModel sampleModel,
- Point origin) {
+ public ByteBandedRaster(SampleModel sampleModel, Point origin) {
this(sampleModel,
- sampleModel.createDataBuffer(),
+ (DataBufferByte) sampleModel.createDataBuffer(),
new Rectangle(origin.x,
origin.y,
sampleModel.getWidth(),
@@ -93,12 +91,13 @@
* initialized and must be a DataBufferShort compatible with SampleModel.
* SampleModel must be of type BandedSampleModel.
* @param sampleModel The SampleModel that specifies the layout.
- * @param dataBuffer The DataBufferShort that contains the image data.
+ * @param dataBuffer The DataBufferByte that contains the image data.
* @param origin The Point that specifies the origin.
*/
public ByteBandedRaster(SampleModel sampleModel,
- DataBuffer dataBuffer,
- Point origin) {
+ DataBufferByte dataBuffer,
+ Point origin)
+ {
this(sampleModel, dataBuffer,
new Rectangle(origin.x , origin.y,
sampleModel.getWidth(),
@@ -119,39 +118,33 @@
* Note that this constructor should generally be called by other
* constructors or create methods, it should not be used directly.
* @param sampleModel The SampleModel that specifies the layout.
- * @param dataBuffer The DataBufferShort that contains the image data.
+ * @param dataBuffer The DataBufferByte that contains the image data.
* @param aRegion The Rectangle that specifies the image area.
* @param origin The Point that specifies the origin.
* @param parent The parent (if any) of this raster.
*/
public ByteBandedRaster(SampleModel sampleModel,
- DataBuffer dataBuffer,
+ DataBufferByte dataBuffer,
Rectangle aRegion,
Point origin,
- ByteBandedRaster parent) {
-
+ ByteBandedRaster parent)
+ {
super(sampleModel, dataBuffer, aRegion, origin, parent);
this.maxX = minX + width;
this.maxY = minY + height;
- if (!(dataBuffer instanceof DataBufferByte)) {
- throw new RasterFormatException("ByteBandedRaster must have" +
- "byte DataBuffers");
- }
- DataBufferByte dbb = (DataBufferByte)dataBuffer;
-
if (sampleModel instanceof BandedSampleModel) {
BandedSampleModel bsm = (BandedSampleModel)sampleModel;
this.scanlineStride = bsm.getScanlineStride();
int bankIndices[] = bsm.getBankIndices();
int bandOffsets[] = bsm.getBandOffsets();
- int dOffsets[] = dbb.getOffsets();
+ int dOffsets[] = dataBuffer.getOffsets();
dataOffsets = new int[bankIndices.length];
data = new byte[bankIndices.length][];
int xOffset = aRegion.x - origin.x;
int yOffset = aRegion.y - origin.y;
for (int i = 0; i < bankIndices.length; i++) {
- data[i] = stealData(dbb, bankIndices[i]);
+ data[i] = stealData(dataBuffer, bankIndices[i]);
dataOffsets[i] = dOffsets[bankIndices[i]] +
xOffset + yOffset*scanlineStride + bandOffsets[i];
}
@@ -672,7 +665,7 @@
int deltaY = y0 - y;
return new ByteBandedRaster(sm,
- dataBuffer,
+ (DataBufferByte) dataBuffer,
new Rectangle(x0,y0,width,height),
new Point(sampleModelTranslateX+deltaX,
sampleModelTranslateY+deltaY),
--- a/jdk/src/java.desktop/share/classes/sun/awt/image/ByteComponentRaster.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/sun/awt/image/ByteComponentRaster.java Tue Apr 19 09:21:45 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,6 @@
import java.awt.image.SampleModel;
import java.awt.image.ComponentSampleModel;
import java.awt.image.SinglePixelPackedSampleModel;
-import java.awt.image.DataBuffer;
import java.awt.image.DataBufferByte;
import java.awt.Rectangle;
import java.awt.Point;
@@ -94,7 +93,7 @@
*/
public ByteComponentRaster(SampleModel sampleModel, Point origin) {
this(sampleModel,
- sampleModel.createDataBuffer(),
+ (DataBufferByte) sampleModel.createDataBuffer(),
new Rectangle(origin.x,
origin.y,
sampleModel.getWidth(),
@@ -111,12 +110,13 @@
* SampleModel must be of type SinglePixelPackedSampleModel
* or ComponentSampleModel.
* @param sampleModel The SampleModel that specifies the layout.
- * @param dataBuffer The DataBufferShort that contains the image data.
+ * @param dataBuffer The DataBufferByte that contains the image data.
* @param origin The Point that specifies the origin.
*/
public ByteComponentRaster(SampleModel sampleModel,
- DataBuffer dataBuffer,
- Point origin) {
+ DataBufferByte dataBuffer,
+ Point origin)
+ {
this(sampleModel,
dataBuffer,
new Rectangle(origin.x,
@@ -141,33 +141,28 @@
* Note that this constructor should generally be called by other
* constructors or create methods, it should not be used directly.
* @param sampleModel The SampleModel that specifies the layout.
- * @param dataBuffer The DataBufferShort that contains the image data.
+ * @param dataBuffer The DataBufferByte that contains the image data.
* @param aRegion The Rectangle that specifies the image area.
* @param origin The Point that specifies the origin.
* @param parent The parent (if any) of this raster.
*/
public ByteComponentRaster(SampleModel sampleModel,
- DataBuffer dataBuffer,
- Rectangle aRegion,
- Point origin,
- ByteComponentRaster parent) {
+ DataBufferByte dataBuffer,
+ Rectangle aRegion,
+ Point origin,
+ ByteComponentRaster parent)
+ {
super(sampleModel, dataBuffer, aRegion, origin, parent);
this.maxX = minX + width;
this.maxY = minY + height;
- if (!(dataBuffer instanceof DataBufferByte)) {
- throw new RasterFormatException("ByteComponentRasters must have " +
- "byte DataBuffers");
- }
-
- DataBufferByte dbb = (DataBufferByte)dataBuffer;
- this.data = stealData(dbb, 0);
- if (dbb.getNumBanks() != 1) {
+ this.data = stealData(dataBuffer, 0);
+ if (dataBuffer.getNumBanks() != 1) {
throw new
RasterFormatException("DataBuffer for ByteComponentRasters"+
" must only have 1 bank.");
}
- int dbOffset = dbb.getOffset();
+ int dbOffset = dataBuffer.getOffset();
if (sampleModel instanceof ComponentSampleModel) {
ComponentSampleModel ism = (ComponentSampleModel)sampleModel;
@@ -823,7 +818,7 @@
int deltaY = y0 - y;
return new ByteComponentRaster(sm,
- dataBuffer,
+ (DataBufferByte) dataBuffer,
new Rectangle(x0, y0, width, height),
new Point(sampleModelTranslateX+deltaX,
sampleModelTranslateY+deltaY),
--- a/jdk/src/java.desktop/share/classes/sun/awt/image/ByteInterleavedRaster.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/sun/awt/image/ByteInterleavedRaster.java Tue Apr 19 09:21:45 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -31,7 +31,6 @@
import java.awt.image.ComponentSampleModel;
import java.awt.image.PixelInterleavedSampleModel;
import java.awt.image.SinglePixelPackedSampleModel;
-import java.awt.image.DataBuffer;
import java.awt.image.DataBufferByte;
import java.awt.Rectangle;
import java.awt.Point;
@@ -87,7 +86,7 @@
*/
public ByteInterleavedRaster(SampleModel sampleModel, Point origin) {
this(sampleModel,
- sampleModel.createDataBuffer(),
+ (DataBufferByte) sampleModel.createDataBuffer(),
new Rectangle(origin.x,
origin.y,
sampleModel.getWidth(),
@@ -104,12 +103,13 @@
* SampleModel must be of type SinglePixelPackedSampleModel
* or InterleavedSampleModel.
* @param sampleModel The SampleModel that specifies the layout.
- * @param dataBuffer The DataBufferShort that contains the image data.
+ * @param dataBuffer The DataBufferByte that contains the image data.
* @param origin The Point that specifies the origin.
*/
public ByteInterleavedRaster(SampleModel sampleModel,
- DataBuffer dataBuffer,
- Point origin) {
+ DataBufferByte dataBuffer,
+ Point origin)
+ {
this(sampleModel,
dataBuffer,
new Rectangle(origin.x,
@@ -178,27 +178,22 @@
* Note that this constructor should generally be called by other
* constructors or create methods, it should not be used directly.
* @param sampleModel The SampleModel that specifies the layout.
- * @param dataBuffer The DataBufferShort that contains the image data.
+ * @param dataBuffer The DataBufferByte that contains the image data.
* @param aRegion The Rectangle that specifies the image area.
* @param origin The Point that specifies the origin.
* @param parent The parent (if any) of this raster.
*/
public ByteInterleavedRaster(SampleModel sampleModel,
- DataBuffer dataBuffer,
- Rectangle aRegion,
- Point origin,
- ByteInterleavedRaster parent) {
+ DataBufferByte dataBuffer,
+ Rectangle aRegion,
+ Point origin,
+ ByteInterleavedRaster parent)
+ {
super(sampleModel, dataBuffer, aRegion, origin, parent);
this.maxX = minX + width;
this.maxY = minY + height;
- if (!(dataBuffer instanceof DataBufferByte)) {
- throw new RasterFormatException("ByteInterleavedRasters must have " +
- "byte DataBuffers");
- }
-
- DataBufferByte dbb = (DataBufferByte)dataBuffer;
- this.data = stealData(dbb, 0);
+ this.data = stealData(dataBuffer, 0);
int xOffset = aRegion.x - origin.x;
int yOffset = aRegion.y - origin.y;
@@ -221,7 +216,7 @@
this.scanlineStride = sppsm.getScanlineStride();
this.pixelStride = 1;
this.dataOffsets = new int[1];
- this.dataOffsets[0] = dbb.getOffset();
+ this.dataOffsets[0] = dataBuffer.getOffset();
dataOffsets[0] += xOffset*pixelStride+yOffset*scanlineStride;
} else {
throw new RasterFormatException("ByteInterleavedRasters must " +
@@ -1259,7 +1254,7 @@
int deltaY = y0 - y;
return new ByteInterleavedRaster(sm,
- dataBuffer,
+ (DataBufferByte) dataBuffer,
new Rectangle(x0, y0, width, height),
new Point(sampleModelTranslateX+deltaX,
sampleModelTranslateY+deltaY),
--- a/jdk/src/java.desktop/share/classes/sun/awt/image/BytePackedRaster.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/sun/awt/image/BytePackedRaster.java Tue Apr 19 09:21:45 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -29,7 +29,6 @@
import java.awt.image.RasterFormatException;
import java.awt.image.SampleModel;
import java.awt.image.MultiPixelPackedSampleModel;
-import java.awt.image.DataBuffer;
import java.awt.image.DataBufferByte;
import java.awt.Rectangle;
import java.awt.Point;
@@ -89,10 +88,9 @@
* @param sampleModel The SampleModel that specifies the layout.
* @param origin The Point that specified the origin.
*/
- public BytePackedRaster(SampleModel sampleModel,
- Point origin) {
+ public BytePackedRaster(SampleModel sampleModel, Point origin) {
this(sampleModel,
- sampleModel.createDataBuffer(),
+ (DataBufferByte) sampleModel.createDataBuffer(),
new Rectangle(origin.x,
origin.y,
sampleModel.getWidth(),
@@ -108,12 +106,13 @@
* initialized and must be a DataBufferByte compatible with SampleModel.
* SampleModel must be of type MultiPixelPackedSampleModel.
* @param sampleModel The SampleModel that specifies the layout.
- * @param dataBuffer The DataBufferShort that contains the image data.
+ * @param dataBuffer The DataBufferByte that contains the image data.
* @param origin The Point that specifies the origin.
*/
public BytePackedRaster(SampleModel sampleModel,
- DataBuffer dataBuffer,
- Point origin) {
+ DataBufferByte dataBuffer,
+ Point origin)
+ {
this(sampleModel,
dataBuffer,
new Rectangle(origin.x,
@@ -137,7 +136,7 @@
* Note that this constructor should generally be called by other
* constructors or create methods, it should not be used directly.
* @param sampleModel The SampleModel that specifies the layout.
- * @param dataBuffer The DataBufferShort that contains the image data.
+ * @param dataBuffer The DataBufferByte that contains the image data.
* @param aRegion The Rectangle that specifies the image area.
* @param origin The Point that specifies the origin.
* @param parent The parent (if any) of this raster.
@@ -146,26 +145,22 @@
* to requirements of this Raster type.
*/
public BytePackedRaster(SampleModel sampleModel,
- DataBuffer dataBuffer,
+ DataBufferByte dataBuffer,
Rectangle aRegion,
Point origin,
- BytePackedRaster parent){
+ BytePackedRaster parent)
+ {
super(sampleModel,dataBuffer,aRegion,origin, parent);
this.maxX = minX + width;
this.maxY = minY + height;
- if (!(dataBuffer instanceof DataBufferByte)) {
- throw new RasterFormatException("BytePackedRasters must have" +
- "byte DataBuffers");
- }
- DataBufferByte dbb = (DataBufferByte)dataBuffer;
- this.data = stealData(dbb, 0);
- if (dbb.getNumBanks() != 1) {
+ this.data = stealData(dataBuffer, 0);
+ if (dataBuffer.getNumBanks() != 1) {
throw new
RasterFormatException("DataBuffer for BytePackedRasters"+
" must only have 1 bank.");
}
- int dbOffset = dbb.getOffset();
+ int dbOffset = dataBuffer.getOffset();
if (sampleModel instanceof MultiPixelPackedSampleModel) {
MultiPixelPackedSampleModel mppsm =
@@ -1322,7 +1317,7 @@
int deltaY = y0 - y;
return new BytePackedRaster(sm,
- dataBuffer,
+ (DataBufferByte) dataBuffer,
new Rectangle(x0, y0, width, height),
new Point(sampleModelTranslateX+deltaX,
sampleModelTranslateY+deltaY),
--- a/jdk/src/java.desktop/share/classes/sun/awt/image/ImageFetcher.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/sun/awt/image/ImageFetcher.java Tue Apr 19 09:21:45 2016 -0700
@@ -27,7 +27,6 @@
import java.util.Vector;
import sun.awt.AppContext;
-import sun.misc.ManagedLocalsThread;
/**
* An ImageFetcher is a thread used to fetch ImageFetchable objects.
@@ -42,7 +41,7 @@
* @author Jim Graham
* @author Fred Ecks
*/
-class ImageFetcher extends ManagedLocalsThread {
+class ImageFetcher extends Thread {
static final int HIGH_PRIORITY = 8;
static final int LOW_PRIORITY = 3;
static final int ANIM_PRIORITY = 2;
@@ -52,10 +51,17 @@
// queue before an ImageFetcher dies
/**
+ * We must only call the 5 args super() constructor passing
+ * in "false" to indicate to not inherit locals.
+ */
+ private ImageFetcher() {
+ throw new UnsupportedOperationException("Must erase locals");
+ }
+ /**
* Constructor for ImageFetcher -- only called by add() below.
*/
private ImageFetcher(ThreadGroup threadGroup, int index) {
- super(threadGroup, "Image Fetcher " + index);
+ super(threadGroup, null, "Image Fetcher " + index, 0, false);
setDaemon(true);
}
--- a/jdk/src/java.desktop/share/classes/sun/awt/image/IntegerComponentRaster.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/sun/awt/image/IntegerComponentRaster.java Tue Apr 19 09:21:45 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -29,7 +29,6 @@
import java.awt.image.RasterFormatException;
import java.awt.image.SampleModel;
import java.awt.image.SinglePixelPackedSampleModel;
-import java.awt.image.DataBuffer;
import java.awt.image.DataBufferInt;
import java.awt.Rectangle;
import java.awt.Point;
@@ -107,10 +106,9 @@
* @param sampleModel The SampleModel that specifies the layout.
* @param origin The Point that specified the origin.
*/
- public IntegerComponentRaster(SampleModel sampleModel,
- Point origin) {
+ public IntegerComponentRaster(SampleModel sampleModel, Point origin) {
this(sampleModel,
- sampleModel.createDataBuffer(),
+ (DataBufferInt) sampleModel.createDataBuffer(),
new Rectangle(origin.x,
origin.y,
sampleModel.getWidth(),
@@ -130,8 +128,9 @@
* @param origin The Point that specifies the origin.
*/
public IntegerComponentRaster(SampleModel sampleModel,
- DataBuffer dataBuffer,
- Point origin) {
+ DataBufferInt dataBuffer,
+ Point origin)
+ {
this(sampleModel,
dataBuffer,
new Rectangle(origin.x,
@@ -161,24 +160,21 @@
* @param parent The parent (if any) of this raster.
*/
public IntegerComponentRaster(SampleModel sampleModel,
- DataBuffer dataBuffer,
- Rectangle aRegion,
- Point origin,
- IntegerComponentRaster parent){
+ DataBufferInt dataBuffer,
+ Rectangle aRegion,
+ Point origin,
+ IntegerComponentRaster parent)
+ {
super(sampleModel,dataBuffer,aRegion,origin,parent);
this.maxX = minX + width;
this.maxY = minY + height;
- if (!(dataBuffer instanceof DataBufferInt)) {
- throw new RasterFormatException("IntegerComponentRasters must have" +
- "integer DataBuffers");
- }
- DataBufferInt dbi = (DataBufferInt)dataBuffer;
- if (dbi.getNumBanks() != 1) {
+
+ if (dataBuffer.getNumBanks() != 1) {
throw new
RasterFormatException("DataBuffer for IntegerComponentRasters"+
" must only have 1 bank.");
}
- this.data = stealData(dbi, 0);
+ this.data = stealData(dataBuffer, 0);
if (sampleModel instanceof SinglePixelPackedSampleModel) {
SinglePixelPackedSampleModel sppsm =
@@ -197,7 +193,7 @@
this.scanlineStride = sppsm.getScanlineStride();
this.pixelStride = 1;
this.dataOffsets = new int[1];
- this.dataOffsets[0] = dbi.getOffset();
+ this.dataOffsets[0] = dataBuffer.getOffset();
this.bandOffset = this.dataOffsets[0];
int xOffset = aRegion.x - origin.x;
int yOffset = aRegion.y - origin.y;
@@ -569,7 +565,7 @@
int deltaY = y0 - y;
return new IntegerComponentRaster(sm,
- dataBuffer,
+ (DataBufferInt) dataBuffer,
new Rectangle(x0,y0,width,height),
new Point(sampleModelTranslateX+deltaX,
sampleModelTranslateY+deltaY),
--- a/jdk/src/java.desktop/share/classes/sun/awt/image/IntegerInterleavedRaster.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/sun/awt/image/IntegerInterleavedRaster.java Tue Apr 19 09:21:45 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -29,7 +29,6 @@
import java.awt.image.RasterFormatException;
import java.awt.image.SampleModel;
import java.awt.image.SinglePixelPackedSampleModel;
-import java.awt.image.DataBuffer;
import java.awt.image.DataBufferInt;
import java.awt.Rectangle;
import java.awt.Point;
@@ -67,10 +66,9 @@
* @param sampleModel The SampleModel that specifies the layout.
* @param origin The Point that specified the origin.
*/
- public IntegerInterleavedRaster(SampleModel sampleModel,
- Point origin) {
+ public IntegerInterleavedRaster(SampleModel sampleModel, Point origin) {
this(sampleModel,
- sampleModel.createDataBuffer(),
+ (DataBufferInt) sampleModel.createDataBuffer(),
new Rectangle(origin.x,
origin.y,
sampleModel.getWidth(),
@@ -90,8 +88,9 @@
* @param origin The Point that specifies the origin.
*/
public IntegerInterleavedRaster(SampleModel sampleModel,
- DataBuffer dataBuffer,
- Point origin) {
+ DataBufferInt dataBuffer,
+ Point origin)
+ {
this(sampleModel,
dataBuffer,
new Rectangle(origin.x,
@@ -121,19 +120,16 @@
* @param parent The parent (if any) of this raster.
*/
public IntegerInterleavedRaster(SampleModel sampleModel,
- DataBuffer dataBuffer,
- Rectangle aRegion,
- Point origin,
- IntegerInterleavedRaster parent){
+ DataBufferInt dataBuffer,
+ Rectangle aRegion,
+ Point origin,
+ IntegerInterleavedRaster parent)
+ {
super(sampleModel,dataBuffer,aRegion,origin,parent);
this.maxX = minX + width;
this.maxY = minY + height;
- if (!(dataBuffer instanceof DataBufferInt)) {
- throw new RasterFormatException("IntegerInterleavedRasters must have" +
- "integer DataBuffers");
- }
- DataBufferInt dbi = (DataBufferInt)dataBuffer;
- this.data = stealData(dbi, 0);
+
+ this.data = stealData(dataBuffer, 0);
if (sampleModel instanceof SinglePixelPackedSampleModel) {
SinglePixelPackedSampleModel sppsm =
@@ -141,7 +137,7 @@
this.scanlineStride = sppsm.getScanlineStride();
this.pixelStride = 1;
this.dataOffsets = new int[1];
- this.dataOffsets[0] = dbi.getOffset();
+ this.dataOffsets[0] = dataBuffer.getOffset();
this.bandOffset = this.dataOffsets[0];
int xOffset = aRegion.x - origin.x;
int yOffset = aRegion.y - origin.y;
@@ -481,7 +477,7 @@
int deltaY = y0 - y;
return new IntegerInterleavedRaster(sm,
- dataBuffer,
+ (DataBufferInt) dataBuffer,
new Rectangle(x0,y0,width,height),
new Point(sampleModelTranslateX+deltaX,
sampleModelTranslateY+deltaY),
--- a/jdk/src/java.desktop/share/classes/sun/awt/image/ShortBandedRaster.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/sun/awt/image/ShortBandedRaster.java Tue Apr 19 09:21:45 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -29,7 +29,6 @@
import java.awt.image.RasterFormatException;
import java.awt.image.SampleModel;
import java.awt.image.BandedSampleModel;
-import java.awt.image.DataBuffer;
import java.awt.image.DataBufferUShort;
import java.awt.Rectangle;
import java.awt.Point;
@@ -72,10 +71,9 @@
* @param sampleModel The SampleModel that specifies the layout.
* @param origin The Point that specified the origin.
*/
- public ShortBandedRaster(SampleModel sampleModel,
- Point origin) {
+ public ShortBandedRaster(SampleModel sampleModel, Point origin) {
this(sampleModel,
- sampleModel.createDataBuffer(),
+ (DataBufferUShort) sampleModel.createDataBuffer(),
new Rectangle(origin.x,
origin.y,
sampleModel.getWidth(),
@@ -95,8 +93,9 @@
* @param origin The Point that specifies the origin.
*/
public ShortBandedRaster(SampleModel sampleModel,
- DataBuffer dataBuffer,
- Point origin) {
+ DataBufferUShort dataBuffer,
+ Point origin)
+ {
this(sampleModel, dataBuffer,
new Rectangle(origin.x, origin.y,
sampleModel.getWidth(),
@@ -123,32 +122,27 @@
* @param parent The parent (if any) of this raster.
*/
public ShortBandedRaster(SampleModel sampleModel,
- DataBuffer dataBuffer,
- Rectangle aRegion,
- Point origin,
- ShortBandedRaster parent) {
-
+ DataBufferUShort dataBuffer,
+ Rectangle aRegion,
+ Point origin,
+ ShortBandedRaster parent)
+ {
super(sampleModel, dataBuffer, aRegion, origin, parent);
this.maxX = minX + width;
this.maxY = minY + height;
- if (!(dataBuffer instanceof DataBufferUShort)) {
- throw new RasterFormatException("ShortBandedRaster must have " +
- "ushort DataBuffers");
- }
- DataBufferUShort dbus = (DataBufferUShort)dataBuffer;
if (sampleModel instanceof BandedSampleModel) {
BandedSampleModel bsm = (BandedSampleModel)sampleModel;
this.scanlineStride = bsm.getScanlineStride();
int bankIndices[] = bsm.getBankIndices();
int bandOffsets[] = bsm.getBandOffsets();
- int dOffsets[] = dbus.getOffsets();
+ int dOffsets[] = dataBuffer.getOffsets();
dataOffsets = new int[bankIndices.length];
data = new short[bankIndices.length][];
int xOffset = aRegion.x - origin.x;
int yOffset = aRegion.y - origin.y;
for (int i = 0; i < bankIndices.length; i++) {
- data[i] = stealData(dbus, bankIndices[i]);
+ data[i] = stealData(dataBuffer, bankIndices[i]);
dataOffsets[i] = dOffsets[bankIndices[i]] +
xOffset + yOffset*scanlineStride + bandOffsets[i];
}
@@ -670,7 +664,7 @@
int deltaY = y0 - y;
return new ShortBandedRaster(sm,
- dataBuffer,
+ (DataBufferUShort) dataBuffer,
new Rectangle(x0, y0, width, height),
new Point(sampleModelTranslateX+deltaX,
sampleModelTranslateY+deltaY),
--- a/jdk/src/java.desktop/share/classes/sun/awt/image/ShortComponentRaster.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/sun/awt/image/ShortComponentRaster.java Tue Apr 19 09:21:45 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,6 @@
import java.awt.image.SampleModel;
import java.awt.image.ComponentSampleModel;
import java.awt.image.SinglePixelPackedSampleModel;
-import java.awt.image.DataBuffer;
import java.awt.image.DataBufferUShort;
import java.awt.Rectangle;
import java.awt.Point;
@@ -94,7 +93,7 @@
*/
public ShortComponentRaster(SampleModel sampleModel, Point origin) {
this(sampleModel,
- sampleModel.createDataBuffer(),
+ (DataBufferUShort) sampleModel.createDataBuffer(),
new Rectangle(origin.x,
origin.y,
sampleModel.getWidth(),
@@ -115,8 +114,9 @@
* @param origin The Point that specifies the origin.
*/
public ShortComponentRaster(SampleModel sampleModel,
- DataBuffer dataBuffer,
- Point origin) {
+ DataBufferUShort dataBuffer,
+ Point origin)
+ {
this(sampleModel,
dataBuffer,
new Rectangle(origin.x,
@@ -146,28 +146,22 @@
* @param parent The parent (if any) of this raster.
*/
public ShortComponentRaster(SampleModel sampleModel,
- DataBuffer dataBuffer,
- Rectangle aRegion,
- Point origin,
- ShortComponentRaster parent) {
-
+ DataBufferUShort dataBuffer,
+ Rectangle aRegion,
+ Point origin,
+ ShortComponentRaster parent)
+ {
super(sampleModel, dataBuffer, aRegion, origin, parent);
this.maxX = minX + width;
this.maxY = minY + height;
- if(!(dataBuffer instanceof DataBufferUShort)) {
- throw new RasterFormatException("ShortComponentRasters must have "+
- "short DataBuffers");
- }
-
- DataBufferUShort dbus = (DataBufferUShort)dataBuffer;
- this.data = stealData(dbus, 0);
- if (dbus.getNumBanks() != 1) {
+ this.data = stealData(dataBuffer, 0);
+ if (dataBuffer.getNumBanks() != 1) {
throw new
RasterFormatException("DataBuffer for ShortComponentRasters"+
" must only have 1 bank.");
}
- int dbOffset = dbus.getOffset();
+ int dbOffset = dataBuffer.getOffset();
if (sampleModel instanceof ComponentSampleModel) {
ComponentSampleModel csm = (ComponentSampleModel)sampleModel;
@@ -758,7 +752,7 @@
int deltaY = y0 - y;
return new ShortComponentRaster(sm,
- dataBuffer,
+ (DataBufferUShort) dataBuffer,
new Rectangle(x0, y0, width, height),
new Point(sampleModelTranslateX+deltaX,
sampleModelTranslateY+deltaY),
--- a/jdk/src/java.desktop/share/classes/sun/awt/image/ShortInterleavedRaster.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/sun/awt/image/ShortInterleavedRaster.java Tue Apr 19 09:21:45 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -31,7 +31,6 @@
import java.awt.image.ComponentSampleModel;
import java.awt.image.PixelInterleavedSampleModel;
import java.awt.image.SinglePixelPackedSampleModel;
-import java.awt.image.DataBuffer;
import java.awt.image.DataBufferUShort;
import java.awt.Rectangle;
import java.awt.Point;
@@ -71,7 +70,7 @@
*/
public ShortInterleavedRaster(SampleModel sampleModel, Point origin) {
this(sampleModel,
- sampleModel.createDataBuffer(),
+ (DataBufferUShort) sampleModel.createDataBuffer(),
new Rectangle(origin.x,
origin.y,
sampleModel.getWidth(),
@@ -92,8 +91,9 @@
* @param origin The Point that specifies the origin.
*/
public ShortInterleavedRaster(SampleModel sampleModel,
- DataBuffer dataBuffer,
- Point origin) {
+ DataBufferUShort dataBuffer,
+ Point origin)
+ {
this(sampleModel,
dataBuffer,
new Rectangle(origin.x,
@@ -123,22 +123,17 @@
* @param parent The parent (if any) of this raster.
*/
public ShortInterleavedRaster(SampleModel sampleModel,
- DataBuffer dataBuffer,
- Rectangle aRegion,
- Point origin,
- ShortInterleavedRaster parent) {
+ DataBufferUShort dataBuffer,
+ Rectangle aRegion,
+ Point origin,
+ ShortInterleavedRaster parent)
+ {
super(sampleModel, dataBuffer, aRegion, origin, parent);
this.maxX = minX + width;
this.maxY = minY + height;
- if(!(dataBuffer instanceof DataBufferUShort)) {
- throw new RasterFormatException("ShortInterleavedRasters must "+
- "have ushort DataBuffers");
- }
-
- DataBufferUShort dbus = (DataBufferUShort)dataBuffer;
- this.data = stealData(dbus, 0);
+ this.data = stealData(dataBuffer, 0);
// REMIND: need case for interleaved ComponentSampleModel
if ((sampleModel instanceof PixelInterleavedSampleModel) ||
@@ -160,7 +155,7 @@
this.scanlineStride = sppsm.getScanlineStride();
this.pixelStride = 1;
this.dataOffsets = new int[1];
- this.dataOffsets[0] = dbus.getOffset();
+ this.dataOffsets[0] = dataBuffer.getOffset();
int xOffset = aRegion.x - origin.x;
int yOffset = aRegion.y - origin.y;
dataOffsets[0] += xOffset+yOffset*scanlineStride;
@@ -730,7 +725,7 @@
int deltaY = y0 - y;
return new ShortInterleavedRaster(sm,
- dataBuffer,
+ (DataBufferUShort) dataBuffer,
new Rectangle(x0, y0, width, height),
new Point(sampleModelTranslateX+deltaX,
sampleModelTranslateY+deltaY),
--- a/jdk/src/java.desktop/share/classes/sun/font/CreatedFontTracker.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/sun/font/CreatedFontTracker.java Tue Apr 19 09:21:45 2016 -0700
@@ -36,7 +36,6 @@
import sun.awt.AppContext;
import sun.awt.util.ThreadGroupUtils;
-import sun.misc.ManagedLocalsThread;
public class CreatedFontTracker {
@@ -122,8 +121,8 @@
* Make its parent the top-level thread group.
*/
ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
- t = new ManagedLocalsThread(rootTG,
- TempFileDeletionHook::runHooks);
+ t = new Thread(rootTG, TempFileDeletionHook::runHooks,
+ "TempFontFileDeleter", 0, false);
/* Set context class loader to null in order to avoid
* keeping a strong reference to an application classloader.
*/
--- a/jdk/src/java.desktop/share/classes/sun/font/FontUtilities.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/sun/font/FontUtilities.java Tue Apr 19 09:21:45 2016 -0700
@@ -183,6 +183,25 @@
}
/**
+ * Return true if there any characters which would trigger layout.
+ * This method considers supplementary characters to be simple,
+ * since we do not presently invoke layout on any code points in
+ * outside the BMP.
+ */
+ public static boolean isComplexScript(char [] chs, int start, int limit) {
+
+ for (int i = start; i < limit; i++) {
+ if (chs[i] < MIN_LAYOUT_CHARCODE) {
+ continue;
+ }
+ else if (isComplexCharCode(chs[i])) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
* If there is anything in the text which triggers a case
* where char->glyph does not map 1:1 in straightforward
* left->right ordering, then this method returns true.
--- a/jdk/src/java.desktop/share/classes/sun/font/SunFontManager.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/sun/font/SunFontManager.java Tue Apr 19 09:21:45 2016 -0700
@@ -55,7 +55,6 @@
import sun.awt.SunToolkit;
import sun.awt.util.ThreadGroupUtils;
import sun.java2d.FontSupport;
-import sun.misc.ManagedLocalsThread;
import sun.util.logging.PlatformLogger;
/**
@@ -2513,8 +2512,8 @@
};
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
- fileCloser = new ManagedLocalsThread(rootTG,
- fileCloserRunnable);
+ fileCloser = new Thread(rootTG, fileCloserRunnable,
+ "FileCloser", 0, false);
fileCloser.setContextClassLoader(null);
Runtime.getRuntime().addShutdownHook(fileCloser);
return null;
--- a/jdk/src/java.desktop/share/classes/sun/java2d/Disposer.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/sun/java2d/Disposer.java Tue Apr 19 09:21:45 2016 -0700
@@ -26,7 +26,6 @@
package sun.java2d;
import sun.awt.util.ThreadGroupUtils;
-import sun.misc.ManagedLocalsThread;
import java.lang.ref.Reference;
import java.lang.ref.ReferenceQueue;
@@ -85,7 +84,7 @@
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
String name = "Java2D Disposer";
ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
- Thread t = new ManagedLocalsThread(rootTG, disposerInstance, name);
+ Thread t = new Thread(rootTG, disposerInstance, name, 0, false);
t.setContextClassLoader(null);
t.setDaemon(true);
t.setPriority(Thread.MAX_PRIORITY);
--- a/jdk/src/java.desktop/share/classes/sun/java2d/loops/GraphicsPrimitive.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/sun/java2d/loops/GraphicsPrimitive.java Tue Apr 19 09:21:45 2016 -0700
@@ -48,7 +48,6 @@
import java.security.AccessController;
import java.security.PrivilegedAction;
-import sun.misc.ManagedLocalsThread;
import sun.security.action.GetPropertyAction;
/**
@@ -420,8 +419,9 @@
public static void setShutdownHook() {
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
TraceReporter t = new TraceReporter();
- Thread thread = new ManagedLocalsThread(
- ThreadGroupUtils.getRootThreadGroup(), t);
+ Thread thread = new Thread(
+ ThreadGroupUtils.getRootThreadGroup(), t,
+ "TraceReporter", 0, false);
thread.setContextClassLoader(null);
Runtime.getRuntime().addShutdownHook(thread);
return null;
--- a/jdk/src/java.desktop/share/classes/sun/java2d/opengl/OGLRenderQueue.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/sun/java2d/opengl/OGLRenderQueue.java Tue Apr 19 09:21:45 2016 -0700
@@ -28,7 +28,6 @@
import sun.awt.util.ThreadGroupUtils;
import sun.java2d.pipe.RenderBuffer;
import sun.java2d.pipe.RenderQueue;
-import sun.misc.ManagedLocalsThread;
import static sun.java2d.pipe.BufferedOpCodes.*;
import java.security.AccessController;
@@ -161,7 +160,8 @@
public QueueFlusher() {
String name = "Java2D Queue Flusher";
- thread = new ManagedLocalsThread(ThreadGroupUtils.getRootThreadGroup(), this, name);
+ thread = new Thread(ThreadGroupUtils.getRootThreadGroup(),
+ this, name, 0, false);
thread.setDaemon(true);
thread.setPriority(Thread.MAX_PRIORITY);
thread.start();
--- a/jdk/src/java.desktop/share/classes/sun/print/PrintJob2D.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/sun/print/PrintJob2D.java Tue Apr 19 09:21:45 2016 -0700
@@ -71,7 +71,6 @@
import javax.print.attribute.standard.MediaSizeName;
import javax.print.attribute.standard.PageRanges;
-import sun.misc.ManagedLocalsThread;
import sun.print.SunPageSelection;
import sun.print.SunMinMaxPage;
@@ -483,8 +482,30 @@
pageFormat.setOrientation(PageFormat.LANDSCAPE);
} else {
pageFormat.setOrientation(PageFormat.PORTRAIT);
+ }
+
+ PageRanges pageRangesAttr
+ = (PageRanges) attributes.get(PageRanges.class);
+ if (pageRangesAttr != null) {
+ // Get the PageRanges from print dialog.
+ int[][] range = pageRangesAttr.getMembers();
+
+ int prevFromPage = this.jobAttributes.getFromPage();
+ int prevToPage = this.jobAttributes.getToPage();
+
+ int currFromPage = range[0][0];
+ int currToPage = range[range.length - 1][1];
+
+ // if from < to update fromPage first followed by toPage
+ // else update toPage first followed by fromPage
+ if (currFromPage < prevToPage) {
+ this.jobAttributes.setFromPage(currFromPage);
+ this.jobAttributes.setToPage(currToPage);
+ } else {
+ this.jobAttributes.setToPage(currToPage);
+ this.jobAttributes.setFromPage(currFromPage);
}
-
+ }
printerJob.setPrintable(this, pageFormat);
}
@@ -987,7 +1008,8 @@
}
private void startPrinterJobThread() {
- printerJobThread = new ManagedLocalsThread(this, "printerJobThread");
+ printerJobThread =
+ new Thread(null, this, "printerJobThread", 0, false);
printerJobThread.start();
}
--- a/jdk/src/java.desktop/share/classes/sun/print/ServiceNotifier.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/sun/print/ServiceNotifier.java Tue Apr 19 09:21:45 2016 -0700
@@ -25,8 +25,6 @@
package sun.print;
-import sun.misc.ManagedLocalsThread;
-
import java.util.Vector;
import javax.print.PrintService;
@@ -42,15 +40,19 @@
* to obtain the state of the attributes and notifies the listeners of
* any changes.
*/
-class ServiceNotifier extends ManagedLocalsThread {
+class ServiceNotifier extends Thread {
private PrintService service;
private Vector<PrintServiceAttributeListener> listeners;
private boolean stop = false;
private PrintServiceAttributeSet lastSet;
+ /*
+ * If adding any other constructors, always call the 5-args
+ * super-class constructor passing "false" for inherit-locals.
+ */
ServiceNotifier(PrintService service) {
- super(service.getName() + " notifier");
+ super(null, null, service.getName() + " notifier", 0, false);
this.service = service;
listeners = new Vector<>();
try {
@@ -70,7 +72,7 @@
}
}
- void removeListener(PrintServiceAttributeListener listener) {
+ void removeListener(PrintServiceAttributeListener listener) {
synchronized (this) {
if (listener == null || listeners == null) {
return;
--- a/jdk/src/java.desktop/share/classes/sun/swing/plaf/synth/DefaultSynthStyle.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/share/classes/sun/swing/plaf/synth/DefaultSynthStyle.java Tue Apr 19 09:21:45 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -645,16 +645,7 @@
// StateInfo match, otherwise a StateInfo with
// SELECTED | ENABLED would match ENABLED, which we
// don't want.
-
- // This comes from BigInteger.bitCnt
- int bitCount = oState;
- bitCount -= (0xaaaaaaaa & bitCount) >>> 1;
- bitCount = (bitCount & 0x33333333) + ((bitCount >>> 2) &
- 0x33333333);
- bitCount = bitCount + (bitCount >>> 4) & 0x0f0f0f0f;
- bitCount += bitCount >>> 8;
- bitCount += bitCount >>> 16;
- bitCount = bitCount & 0xff;
+ int bitCount = Integer.bitCount(oState);
if (bitCount > bestCount) {
bestIndex = counter;
bestCount = bitCount;
@@ -883,21 +874,6 @@
}
/**
- * Returns the number of states that are similar between the
- * ComponentState this StateInfo represents and val.
- */
- private int getMatchCount(int val) {
- // This comes from BigInteger.bitCnt
- val &= state;
- val -= (0xaaaaaaaa & val) >>> 1;
- val = (val & 0x33333333) + ((val >>> 2) & 0x33333333);
- val = val + (val >>> 4) & 0x0f0f0f0f;
- val += val >>> 8;
- val += val >>> 16;
- return val & 0xff;
- }
-
- /**
* Creates and returns a copy of this StateInfo.
*
* @return Copy of this StateInfo.
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/GtkFileDialogPeer.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/GtkFileDialogPeer.java Tue Apr 19 09:21:45 2016 -0700
@@ -29,7 +29,6 @@
import java.io.File;
import java.io.FilenameFilter;
import sun.awt.AWTAccessor;
-import sun.misc.ManagedLocalsThread;
/**
* FileDialogPeer for the GtkFileChooser.
@@ -120,7 +119,7 @@
standaloneWindow = 0;
fd.setVisible(false);
};
- new ManagedLocalsThread(task).start();
+ new Thread(null, task, "ShowDialog", 0, false).start();
} else {
quit();
fd.setVisible(false);
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/InfoWindow.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/InfoWindow.java Tue Apr 19 09:21:45 2016 -0700
@@ -29,7 +29,6 @@
import java.awt.event.*;
import java.awt.peer.TrayIconPeer;
import sun.awt.*;
-import sun.misc.ManagedLocalsThread;
import java.awt.image.*;
import java.text.BreakIterator;
@@ -452,7 +451,7 @@
final Thread thread;
Displayer() {
- this.thread = new ManagedLocalsThread(this);
+ this.thread = new Thread(null, this, "Displayer", 0, false);
this.thread.setDaemon(true);
}
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XBaseMenuWindow.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XBaseMenuWindow.java Tue Apr 19 09:21:45 2016 -0700
@@ -1087,7 +1087,7 @@
}
} else {
//Invoke action event
- item.action(mouseEvent.getWhen());
+ item.action(mouseEvent.getWhen(), mouseEvent.getModifiers());
ungrabInput();
}
} else {
@@ -1200,7 +1200,7 @@
if (citem instanceof XMenuPeer) {
cwnd.selectItem(citem, true);
} else if (citem != null) {
- citem.action(event.getWhen());
+ citem.action(event.getWhen(), event.getModifiers());
ungrabInput();
}
break;
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XMenuItemPeer.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XMenuItemPeer.java Tue Apr 19 09:21:45 2016 -0700
@@ -323,11 +323,11 @@
* on menu item.
* @param when the timestamp of action event
*/
- void action(long when) {
+ void action(long when, int modifiers) {
if (!isSeparator() && isTargetItemEnabled()) {
XWindow.postEventStatic(new ActionEvent(target, ActionEvent.ACTION_PERFORMED,
getTargetActionCommand(), when,
- 0));
+ modifiers));
}
}
/************************************************
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XTaskbarPeer.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XTaskbarPeer.java Tue Apr 19 09:21:45 2016 -0700
@@ -29,7 +29,6 @@
import java.awt.Taskbar.Feature;
import java.awt.peer.TaskbarPeer;
import java.awt.event.ActionEvent;
-import sun.misc.ManagedLocalsThread;
import java.security.AccessController;
import sun.security.action.GetPropertyAction;
@@ -48,10 +47,8 @@
new GetPropertyAction("java.desktop.appName", ""));
nativeLibraryLoaded = init(dname);
if (nativeLibraryLoaded) {
- ManagedLocalsThread t
- = new ManagedLocalsThread(() -> {
- runloop();
- });
+ Thread t = new Thread(null, () -> { runloop(); },
+ "TaskBar", 0, false);
t.setDaemon(true);
t.start();
}
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java Tue Apr 19 09:21:45 2016 -0700
@@ -284,8 +284,8 @@
}
};
String name = "XToolkt-Shutdown-Thread";
- Thread shutdownThread = new ManagedLocalsThread(
- ThreadGroupUtils.getRootThreadGroup(), r, name);
+ Thread shutdownThread = new Thread(
+ ThreadGroupUtils.getRootThreadGroup(), r, name, 0, false);
shutdownThread.setContextClassLoader(null);
Runtime.getRuntime().addShutdownHook(shutdownThread);
return null;
@@ -332,8 +332,9 @@
toolkitThread = AccessController.doPrivileged((PrivilegedAction<Thread>) () -> {
String name = "AWT-XAWT";
- Thread thread = new ManagedLocalsThread(
- ThreadGroupUtils.getRootThreadGroup(), this, name);
+ Thread thread = new Thread(
+ ThreadGroupUtils.getRootThreadGroup(), this, name,
+ 0, false);
thread.setContextClassLoader(null);
thread.setPriority(Thread.NORM_PRIORITY + 1);
thread.setDaemon(true);
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11GraphicsDevice.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11GraphicsDevice.java Tue Apr 19 09:21:45 2016 -0700
@@ -44,7 +44,6 @@
import sun.awt.util.ThreadGroupUtils;
import sun.java2d.SunGraphicsEnvironment;
-import sun.misc.ManagedLocalsThread;
/**
* This is an implementation of a GraphicsDevice object for a single
@@ -442,8 +441,8 @@
}
};
String name = "Display-Change-Shutdown-Thread-" + screen;
- Thread t = new ManagedLocalsThread(
- ThreadGroupUtils.getRootThreadGroup(), r, name);
+ Thread t = new Thread(
+ ThreadGroupUtils.getRootThreadGroup(), r, name, 0, false);
t.setContextClassLoader(null);
Runtime.getRuntime().addShutdownHook(t);
return null;
--- a/jdk/src/java.desktop/unix/classes/sun/print/PrintServiceLookupProvider.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/unix/classes/sun/print/PrintServiceLookupProvider.java Tue Apr 19 09:21:45 2016 -0700
@@ -25,8 +25,6 @@
package sun.print;
-import sun.misc.ManagedLocalsThread;
-
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStream;
@@ -213,7 +211,8 @@
public PrintServiceLookupProvider() {
// start the printer listener thread
if (pollServices) {
- Thread thr = new ManagedLocalsThread(new PrinterChangeListener());
+ Thread thr = new Thread(null, new PrinterChangeListener(),
+ "PrinterListener", 0, false);
thr.setDaemon(true);
thr.start();
IPPPrintService.debug_println(debugPrefix+"polling turned on");
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_GraphicsEnv.c Tue Apr 19 09:21:45 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -1877,31 +1877,34 @@
AWT_LOCK();
- config = awt_XRRGetScreenInfo(awt_display,
- RootWindow(awt_display, screen));
- if (config != NULL) {
- Rotation rotation;
- short curRate;
- SizeID curSizeIndex;
- XRRScreenSize *sizes;
- int nsizes;
+ if (screen < ScreenCount(awt_display)) {
- curSizeIndex = awt_XRRConfigCurrentConfiguration(config, &rotation);
- sizes = awt_XRRConfigSizes(config, &nsizes);
- curRate = awt_XRRConfigCurrentRate(config);
+ config = awt_XRRGetScreenInfo(awt_display,
+ RootWindow(awt_display, screen));
+ if (config != NULL) {
+ Rotation rotation;
+ short curRate;
+ SizeID curSizeIndex;
+ XRRScreenSize *sizes;
+ int nsizes;
- if ((sizes != NULL) &&
- (curSizeIndex < nsizes))
- {
- XRRScreenSize curSize = sizes[curSizeIndex];
- displayMode = X11GD_CreateDisplayMode(env,
- curSize.width,
- curSize.height,
- BIT_DEPTH_MULTI,
- curRate);
+ curSizeIndex = awt_XRRConfigCurrentConfiguration(config, &rotation);
+ sizes = awt_XRRConfigSizes(config, &nsizes);
+ curRate = awt_XRRConfigCurrentRate(config);
+
+ if ((sizes != NULL) &&
+ (curSizeIndex < nsizes))
+ {
+ XRRScreenSize curSize = sizes[curSizeIndex];
+ displayMode = X11GD_CreateDisplayMode(env,
+ curSize.width,
+ curSize.height,
+ BIT_DEPTH_MULTI,
+ curRate);
+ }
+
+ awt_XRRFreeScreenConfigInfo(config);
}
-
- awt_XRRFreeScreenConfigInfo(config);
}
AWT_FLUSH_UNLOCK();
--- a/jdk/src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolderManager2.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolderManager2.java Tue Apr 19 09:21:45 2016 -0700
@@ -41,7 +41,6 @@
import static sun.awt.shell.Win32ShellFolder2.*;
import sun.awt.OSInfo;
import sun.awt.util.ThreadGroupUtils;
-import sun.misc.ManagedLocalsThread;
// NOTE: This class supersedes Win32ShellFolderManager, which was removed
// from distribution after version 1.4.2.
@@ -524,8 +523,9 @@
return null;
});
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
- Thread t = new ManagedLocalsThread(
- ThreadGroupUtils.getRootThreadGroup(), shutdownHook);
+ Thread t = new Thread(
+ ThreadGroupUtils.getRootThreadGroup(), shutdownHook,
+ "ShellFolder", 0, false);
Runtime.getRuntime().addShutdownHook(t);
return null;
});
@@ -548,8 +548,9 @@
* which will not get GCed before VM exit.
* Make its parent the top-level thread group.
*/
- Thread thread = new ManagedLocalsThread(
- ThreadGroupUtils.getRootThreadGroup(), comRun, name);
+ Thread thread = new Thread(
+ ThreadGroupUtils.getRootThreadGroup(), comRun, name,
+ 0, false);
thread.setDaemon(true);
return thread;
});
--- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WFileDialogPeer.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WFileDialogPeer.java Tue Apr 19 09:21:45 2016 -0700
@@ -36,7 +36,6 @@
import java.util.Vector;
import sun.awt.CausedFocusEvent;
import sun.awt.AWTAccessor;
-import sun.misc.ManagedLocalsThread;
final class WFileDialogPeer extends WWindowPeer implements FileDialogPeer {
@@ -98,7 +97,7 @@
@Override
public void show() {
- new ManagedLocalsThread(this::_show).start();
+ new Thread(null, this::_show, "FileDialog", 0, false).start();
}
@Override
--- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WPageDialogPeer.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WPageDialogPeer.java Tue Apr 19 09:21:45 2016 -0700
@@ -25,8 +25,6 @@
package sun.awt.windows;
-import sun.misc.ManagedLocalsThread;
-
final class WPageDialogPeer extends WPrintDialogPeer {
WPageDialogPeer(WPageDialog target) {
@@ -53,6 +51,6 @@
}
((WPrintDialog)target).setVisible(false);
};
- new ManagedLocalsThread(runnable).start();
+ new Thread(null, runnable, "PageDialog", 0, false).start();
}
}
--- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WPrintDialogPeer.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WPrintDialogPeer.java Tue Apr 19 09:21:45 2016 -0700
@@ -32,7 +32,6 @@
import java.util.Vector;
import sun.awt.CausedFocusEvent;
import sun.awt.AWTAccessor;
-import sun.misc.ManagedLocalsThread;
class WPrintDialogPeer extends WWindowPeer implements DialogPeer {
@@ -78,7 +77,7 @@
}
((WPrintDialog)target).setVisible(false);
};
- new ManagedLocalsThread(runnable).start();
+ new Thread(null, runnable, "PrintDialog", 0, false).start();
}
synchronized void setHWnd(long hwnd) {
--- a/jdk/src/java.desktop/windows/classes/sun/awt/windows/WToolkit.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/windows/classes/sun/awt/windows/WToolkit.java Tue Apr 19 09:21:45 2016 -0700
@@ -52,7 +52,6 @@
import sun.java2d.d3d.D3DRenderQueue;
import sun.java2d.opengl.OGLRenderQueue;
-import sun.misc.ManagedLocalsThread;
import sun.print.PrintJob2D;
import java.awt.dnd.DragSource;
@@ -256,7 +255,7 @@
(PrivilegedAction<ThreadGroup>) ThreadGroupUtils::getRootThreadGroup);
if (!startToolkitThread(this, rootTG)) {
String name = "AWT-Windows";
- Thread toolkitThread = new ManagedLocalsThread(rootTG, this, name);
+ Thread toolkitThread = new Thread(rootTG, this, name, 0, false);
toolkitThread.setDaemon(true);
toolkitThread.start();
}
@@ -283,8 +282,9 @@
private void registerShutdownHook() {
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
- Thread shutdown = new ManagedLocalsThread(
- ThreadGroupUtils.getRootThreadGroup(), this::shutdown);
+ Thread shutdown = new Thread(
+ ThreadGroupUtils.getRootThreadGroup(), this::shutdown,
+ "ToolkitShutdown", 0, false);
shutdown.setContextClassLoader(null);
Runtime.getRuntime().addShutdownHook(shutdown);
return null;
--- a/jdk/src/java.desktop/windows/classes/sun/java2d/d3d/D3DScreenUpdateManager.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/windows/classes/sun/java2d/d3d/D3DScreenUpdateManager.java Tue Apr 19 09:21:45 2016 -0700
@@ -49,7 +49,6 @@
import sun.java2d.windows.GDIWindowSurfaceData;
import sun.java2d.d3d.D3DSurfaceData.D3DWindowSurfaceData;
import sun.java2d.windows.WindowsFlags;
-import sun.misc.ManagedLocalsThread;
/**
* This class handles rendering to the screen with the D3D pipeline.
@@ -99,8 +98,9 @@
done = true;
wakeUpUpdateThread();
};
- Thread shutdown = new ManagedLocalsThread(
- ThreadGroupUtils.getRootThreadGroup(), shutdownRunnable);
+ Thread shutdown = new Thread(
+ ThreadGroupUtils.getRootThreadGroup(), shutdownRunnable,
+ "ScreenUpdater", 0, false);
shutdown.setContextClassLoader(null);
try {
Runtime.getRuntime().addShutdownHook(shutdown);
@@ -348,8 +348,9 @@
if (screenUpdater == null) {
screenUpdater = AccessController.doPrivileged((PrivilegedAction<Thread>) () -> {
String name = "D3D Screen Updater";
- Thread t = new ManagedLocalsThread(
- ThreadGroupUtils.getRootThreadGroup(), this, name);
+ Thread t = new Thread(
+ ThreadGroupUtils.getRootThreadGroup(), this, name,
+ 0, false);
// REMIND: should it be higher?
t.setPriority(Thread.NORM_PRIORITY + 2);
t.setDaemon(true);
--- a/jdk/src/java.desktop/windows/classes/sun/print/PrintServiceLookupProvider.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/windows/classes/sun/print/PrintServiceLookupProvider.java Tue Apr 19 09:21:45 2016 -0700
@@ -25,8 +25,6 @@
package sun.print;
-import sun.misc.ManagedLocalsThread;
-
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
@@ -99,7 +97,8 @@
return;
}
// start the printer listener thread
- Thread thr = new ManagedLocalsThread(new PrinterChangeListener());
+ Thread thr = new Thread(null, new PrinterChangeListener(),
+ "PrinterListener", 0, false);
thr.setDaemon(true);
thr.start();
} /* else condition ought to never happen! */
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Button.cpp Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Button.cpp Tue Apr 19 09:21:45 2016 -0700
@@ -187,7 +187,7 @@
AwtButton::NotifyListeners()
{
DoCallback("handleAction", "(JI)V", ::JVM_CurrentTimeMillis(NULL, 0),
- (jint)AwtComponent::GetJavaModifiers());
+ (jint)AwtComponent::GetActionModifiers());
}
MsgRouting
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp Tue Apr 19 09:21:45 2016 -0700
@@ -60,6 +60,7 @@
#include <java_awt_Insets.h>
#include <sun_awt_windows_WPanelPeer.h>
#include <java_awt_event_InputEvent.h>
+#include <java_awt_event_ActionEvent.h>
#include <java_awt_event_InputMethodEvent.h>
#include <sun_awt_windows_WInputMethod.h>
#include <java_awt_event_MouseEvent.h>
@@ -2587,6 +2588,27 @@
return java_awt_event_KeyEvent_KEY_LOCATION_LEFT;
}
+/* Returns Java ActionEvent modifieres.
+ * When creating ActionEvent, modifiers provided by ActionEvent
+ * class should be set.
+ */
+jint
+AwtComponent::GetActionModifiers()
+{
+ jint modifiers = GetJavaModifiers();
+
+ if (modifiers & java_awt_event_InputEvent_CTRL_DOWN_MASK) {
+ modifiers |= java_awt_event_ActionEvent_CTRL_MASK;
+ }
+ if (modifiers & java_awt_event_InputEvent_SHIFT_DOWN_MASK) {
+ modifiers |= java_awt_event_ActionEvent_SHIFT_MASK;
+ }
+ if (modifiers & java_awt_event_InputEvent_ALT_DOWN_MASK) {
+ modifiers |= java_awt_event_ActionEvent_ALT_MASK;
+ }
+ return modifiers;
+}
+
/* Returns Java extended InputEvent modifieres.
* Since ::GetKeyState returns current state and Java modifiers represent
* state before event, modifier on changed key are inverted.
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Component.h Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Component.h Tue Apr 19 09:21:45 2016 -0700
@@ -438,6 +438,7 @@
static void InitDynamicKeyMapTable();
static void BuildDynamicKeyMapTable();
static jint GetJavaModifiers();
+ static jint GetActionModifiers();
static jint GetButton(int mouseButton);
static UINT GetButtonMK(int mouseButton);
static UINT WindowsKeyToJavaKey(UINT windowsKey, UINT modifiers, UINT character, BOOL isDeadKey);
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_List.cpp Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_List.cpp Tue Apr 19 09:21:45 2016 -0700
@@ -536,7 +536,7 @@
else if (notifyCode == LBN_DBLCLK) {
DoCallback("handleAction", "(IJI)V", nCurrentSelection,
::JVM_CurrentTimeMillis(NULL, 0),
- (jint)AwtComponent::GetJavaModifiers());
+ (jint)AwtComponent::GetActionModifiers());
}
}
}
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_List.h Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_List.h Tue Apr 19 09:21:45 2016 -0700
@@ -56,6 +56,7 @@
}
INLINE void Deselect(int pos) {
if (isMultiSelect) {
+ SendListMessage(LB_SETCARETINDEX, pos, FALSE);
SendListMessage(LB_SETSEL, FALSE, pos);
}
else {
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_MenuItem.cpp Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_MenuItem.cpp Tue Apr 19 09:21:45 2016 -0700
@@ -667,7 +667,7 @@
DoCallback("handleAction", "(Z)V", ((nState & MF_CHECKED) == 0));
} else {
DoCallback("handleAction", "(JI)V", ::JVM_CurrentTimeMillis(NULL, 0),
- (jint)AwtComponent::GetJavaModifiers());
+ (jint)AwtComponent::GetActionModifiers());
}
}
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_TrayIcon.cpp Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_TrayIcon.cpp Tue Apr 19 09:21:45 2016 -0700
@@ -409,7 +409,7 @@
MSG msg;
AwtComponent::InitMessage(&msg, lastMessage, flags, MAKELPARAM(x, y), x, y);
SendActionEvent(java_awt_event_ActionEvent_ACTION_PERFORMED, ::JVM_CurrentTimeMillis(NULL, 0),
- AwtComponent::GetJavaModifiers(), &msg);
+ AwtComponent::GetActionModifiers(), &msg);
}
return mrConsume;
}
@@ -425,7 +425,7 @@
MSG msg;
AwtComponent::InitMessage(&msg, lastMessage, flags, MAKELPARAM(x, y), x, y);
SendActionEvent(java_awt_event_ActionEvent_ACTION_PERFORMED, ::JVM_CurrentTimeMillis(NULL, 0),
- AwtComponent::GetJavaModifiers(), &msg);
+ AwtComponent::GetActionModifiers(), &msg);
}
lastKeySelectTime = now;
@@ -442,7 +442,7 @@
MSG msg;
AwtComponent::InitMessage(&msg, lastMessage, flags, MAKELPARAM(x, y), x, y);
SendActionEvent(java_awt_event_ActionEvent_ACTION_PERFORMED, ::JVM_CurrentTimeMillis(NULL, 0),
- AwtComponent::GetJavaModifiers(), &msg);
+ AwtComponent::GetActionModifiers(), &msg);
}
return mrConsume;
}
--- a/jdk/src/jdk.accessibility/share/classes/com/sun/java/accessibility/util/Translator.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/jdk.accessibility/share/classes/com/sun/java/accessibility/util/Translator.java Tue Apr 19 09:21:45 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,13 +26,11 @@
package com.sun.java.accessibility.util;
-import java.lang.*;
+import com.sun.java.accessibility.util.internal.*;
import java.beans.*;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
-import java.awt.image.*;
-import java.security.AccessControlException;
// Do not import Swing classes. This module is intended to work
// with both Swing and AWT.
// import javax.swing.*;
@@ -77,12 +75,26 @@
if (c == null) {
return null;
}
- try {
- t = Class.forName("com.sun.java.accessibility.util.internal."
- + c.getSimpleName()
- + "Translator");
+ switch (c.getSimpleName()) {
+ case "Button":
+ t = ButtonTranslator.class;
+ break;
+ case "Checkbox":
+ t = CheckboxTranslator.class;
+ break;
+ case "Label":
+ t = LabelTranslator.class;
+ break;
+ case "List":
+ t = ListTranslator.class;
+ break;
+ case "TextComponent":
+ t = TextComponentTranslator.class;
+ break;
+ }
+ if (t != null) {
return t;
- } catch (Exception e) {
+ } else {
return getTranslatorClass(c.getSuperclass());
}
}
@@ -106,10 +118,6 @@
if (o instanceof Accessible) {
a = (Accessible)o;
} else {
- // About to "newInstance" an object of a class of a restricted package
- // so ensure the caller is allowed access to that package.
- String pkg = "com.sun.java.accessibility.util.internal";
- System.getSecurityManager().checkPackageAccess(pkg);
Class<?> translatorClass = getTranslatorClass(o.getClass());
if (translatorClass != null) {
try {
--- a/jdk/src/jdk.accessibility/windows/native/jaccesswalker/jaccesswalker.cpp Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/jdk.accessibility/windows/native/jaccesswalker/jaccesswalker.cpp Tue Apr 19 09:21:45 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -543,7 +543,7 @@
} else {
char s[LINE_BUFSIZE];
sprintf( s,
- "ERROR calling GetAccessibleContextInfo; vmID = %X, context = %X",
+ "ERROR calling GetAccessibleContextInfo; vmID = %X, context = %p",
vmID, context );
TVITEM tvi;
--- a/jdk/src/jdk.accessibility/windows/native/libwindowsaccessbridge/WinAccessBridge.cpp Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/src/jdk.accessibility/windows/native/libwindowsaccessbridge/WinAccessBridge.cpp Tue Apr 19 09:21:45 2016 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -1125,7 +1125,7 @@
PrintDebugString("WinAccessBridge::getAccessibleContextWithFocus(%p, %X, )", window, vmID);
// find vmID, etc. from HWND; ask that VM for the AC w/Focus
- HWND pkgVMID = (HWND)ABLongToHandle( pkg->rVMID ) ;
+ HWND pkgVMID;
if (getAccessibleContextFromHWND(window, (long *)&(pkgVMID), &(pkg->rAccessibleContext)) == TRUE) {
HWND destABWindow = javaVMs->findAccessBridgeWindow((long)pkgVMID); // ineffecient [[[FIXME]]]
if (sendMemoryPackage(buffer, sizeof(buffer), destABWindow) == TRUE) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Button/ActionEventTest/ActionEventTest.java Tue Apr 19 09:21:45 2016 -0700
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * 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 6191390
+ * @summary Verify that ActionEvent is received with correct modifiers set.
+ * @run main/manual ActionEventTest
+ */
+
+import java.awt.AWTException;
+import java.awt.FlowLayout;
+import java.awt.Frame;
+import java.awt.Button;
+import java.awt.TextArea;
+import java.awt.Robot;
+import java.awt.Point;
+import java.awt.event.InputEvent;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.KeyEvent;
+
+public class ActionEventTest extends Frame {
+ Button button;
+ Robot robot;
+ TextArea instructions;
+ public static boolean isProgInterruption = false;
+ static Thread mainThread = null;
+ static int sleepTime = 300000;
+
+ public ActionEventTest() {
+ try {
+ robot = new Robot();
+ } catch(AWTException e) {
+ throw new RuntimeException(e.getMessage());
+ }
+
+ button = new Button("ClickMe");
+ button.setEnabled(true);
+
+ instructions = new TextArea(10, 50);
+ instructions.setText(
+ " This is a manual test\n" +
+ " Keep the Alt, Shift & Ctrl Keys pressed &\n" +
+ " Click 'ClickMe' button with left mouse button\n" +
+ " Test exits automatically after mouse click.");
+
+ add(button);
+ add(instructions);
+ setSize(400,400);
+ setLayout(new FlowLayout());
+ pack();
+ setVisible(true);
+ robot.waitForIdle();
+
+ button.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent ae) {
+ int md = ae.getModifiers();
+ int expectedMask = ActionEvent.ALT_MASK | ActionEvent.CTRL_MASK
+ | ActionEvent.SHIFT_MASK;
+
+ isProgInterruption = true;
+ mainThread.interrupt();
+ if ((md & expectedMask) != expectedMask) {
+ throw new RuntimeException("Action Event modifiers"
+ + " are not set correctly.");
+ }
+ }
+ });
+ }
+
+ public static void main(String args[]) throws Exception {
+ mainThread = Thread.currentThread();
+ ActionEventTest test = new ActionEventTest();
+ try {
+ mainThread.sleep(sleepTime);
+ } catch (InterruptedException e) {
+ if (!isProgInterruption) {
+ throw e;
+ }
+ }
+ test.dispose();
+ if (!isProgInterruption) {
+ throw new RuntimeException("Timed out after " + sleepTime / 1000
+ + " seconds");
+ }
+ }
+}
--- a/jdk/test/java/awt/Component/CompEventOnHiddenComponent/CompEventOnHiddenComponent.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/test/java/awt/Component/CompEventOnHiddenComponent/CompEventOnHiddenComponent.java Tue Apr 19 09:21:45 2016 -0700
@@ -25,7 +25,7 @@
/*
@test
- @bug 6383903
+ @bug 6383903 8144166
@summary REGRESSION: componentMoved is now getting called for some hidden components
@author andrei.dmitriev: area=awt.component
@run main CompEventOnHiddenComponent
--- a/jdk/test/java/awt/FontClass/CreateFont/CreateFontArrayTest.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/test/java/awt/FontClass/CreateFont/CreateFontArrayTest.java Tue Apr 19 09:21:45 2016 -0700
@@ -23,9 +23,9 @@
/*
* @test
- * @bug 8055463
+ * @bug 8055463 8153272
* @summary Test createFont APIs
- * @run CreateFontArrayTest
+ * @run main CreateFontArrayTest
*/
import java.awt.Font;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/FontClass/TextRequiresLayoutTest.java Tue Apr 19 09:21:45 2016 -0700
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * 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 8146324
+ * @summary Test Font.textRequiresLayout
+ */
+
+import java.awt.Font;
+
+public class TextRequiresLayoutTest {
+
+ public static void main(String args[]) {
+
+ String simpleStr = "Hello World";
+ String complexStr = "\u0641\u0642\u0643";
+ char[] simpleChars = simpleStr.toCharArray();
+ char[] complexChars = complexStr.toCharArray();
+
+ if (Font.textRequiresLayout(simpleChars, 0, simpleChars.length)) {
+ throw new RuntimeException("Simple text should not need layout");
+ }
+
+ if (!Font.textRequiresLayout(complexChars, 0, complexChars.length)) {
+ throw new RuntimeException("Complex text should need layout");
+ }
+
+ if (Font.textRequiresLayout(complexChars, 0, 0)) {
+ throw new RuntimeException("Empty text should not need layout");
+ }
+
+ boolean except = false;
+ try {
+ Font.textRequiresLayout(null, 0, 0);
+ } catch (NullPointerException npe) {
+ except = true;
+ }
+ if (!except) {
+ throw new RuntimeException("No expected IllegalArgumentException");
+ }
+
+ except = false;
+ try {
+ Font.textRequiresLayout(complexChars, -1, 0);
+ } catch (ArrayIndexOutOfBoundsException aioobe) {
+ except = true;
+ }
+ if (!except) {
+ throw new
+ RuntimeException("No expected ArrayIndexOutOfBoundsException");
+ }
+
+ except = false;
+ try {
+ Font.textRequiresLayout(complexChars, 0, complexChars.length+1);
+ } catch (ArrayIndexOutOfBoundsException aioobe) {
+ except = true;
+ }
+ if (!except) {
+ throw new
+ RuntimeException("No expected ArrayIndexOutOfBoundsException");
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/List/ActionEventTest/ActionEventTest.java Tue Apr 19 09:21:45 2016 -0700
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * 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 6191390
+ * @summary Verify that ActionEvent is received with correct modifiers set.
+ * @run main ActionEventTest
+ */
+
+import java.awt.AWTException;
+import java.awt.FlowLayout;
+import java.awt.Frame;
+import java.awt.List;
+import java.awt.Robot;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.KeyEvent;
+
+public class ActionEventTest extends Frame {
+ List list;
+ Robot robot;
+
+ public ActionEventTest() {
+ try {
+ robot = new Robot();
+ } catch(AWTException e) {
+ throw new RuntimeException(e.getMessage());
+ }
+
+ list = new List(1, false);
+ list.add("0");
+ add(list);
+ setSize(400,400);
+ setLayout(new FlowLayout());
+ pack();
+ setVisible(true);
+ robot.waitForIdle();
+ }
+
+ void performTest() {
+ list.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent ae) {
+ int md = ae.getModifiers();
+ int expectedMask = ActionEvent.ALT_MASK | ActionEvent.CTRL_MASK
+ | ActionEvent.SHIFT_MASK;
+
+ if ((md & expectedMask) != expectedMask) {
+
+ robot.keyRelease(KeyEvent.VK_ALT);
+ robot.keyRelease(KeyEvent.VK_SHIFT);
+ robot.keyRelease(KeyEvent.VK_CONTROL);
+ dispose();
+ throw new RuntimeException("Action Event modifiers are not"
+ + " set correctly.");
+ }
+ }
+ });
+
+ list.select(0);
+ robot.keyPress(KeyEvent.VK_ALT);
+ robot.keyPress(KeyEvent.VK_SHIFT);
+ robot.keyPress(KeyEvent.VK_CONTROL);
+ // Press Enter on list item, to generate action event.
+ robot.keyPress(KeyEvent.VK_ENTER);
+ robot.keyRelease(KeyEvent.VK_ENTER);
+ robot.waitForIdle();
+ robot.keyRelease(KeyEvent.VK_ALT);
+ robot.keyRelease(KeyEvent.VK_SHIFT);
+ robot.keyRelease(KeyEvent.VK_CONTROL);
+ robot.waitForIdle();
+ }
+
+ public static void main(String args[]) {
+ ActionEventTest test = new ActionEventTest();
+ test.performTest();
+ test.dispose();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/List/ItemEventTest/ItemEventTest.java Tue Apr 19 09:21:45 2016 -0700
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * 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 8033936
+ * @summary Verify that correct ItemEvent is received while selection &
+ * deselection of multi select List items.
+ */
+
+import java.awt.AWTException;
+import java.awt.Event;
+import java.awt.FlowLayout;
+import java.awt.Frame;
+import java.awt.List;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.Robot;
+import java.awt.event.KeyEvent;
+import java.awt.event.InputEvent;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+
+public class ItemEventTest extends Frame
+{
+ List list;
+ final String expectedSelectionOrder;
+ StringBuilder actualSelectionOrder;
+ Robot robot;
+
+ public ItemEventTest()
+ {
+ try {
+ robot = new Robot();
+ } catch(AWTException e) {
+ throw new RuntimeException(e.getMessage());
+ }
+ expectedSelectionOrder = "01230123";
+
+ list = new List(4, true);
+ list.add("0");
+ list.add("1");
+ list.add("2");
+ list.add("3");
+
+ add(list);
+ setSize(400,400);
+ setLayout(new FlowLayout());
+ pack();
+ setVisible(true);
+ robot.waitForIdle();
+ }
+
+ @Override
+ public boolean handleEvent(Event e) {
+ if (e.target instanceof List) {
+ if (e.id == Event.LIST_DESELECT || e.id == Event.LIST_SELECT) {
+ actualSelectionOrder.append(e.arg);
+ }
+ }
+ return true;
+ }
+
+ void testHandleEvent() {
+ // When no ItemListener is added to List, parent's handleEvent is
+ // called with ItemEvent.
+ performTest();
+ }
+
+ void testItemListener() {
+ list.addItemListener(new ItemListener() {
+ @Override
+ public void itemStateChanged(ItemEvent ie) {
+ actualSelectionOrder.append(ie.getItem());
+ }
+ });
+ performTest();
+ }
+
+ void performTest() {
+ actualSelectionOrder = new StringBuilder();
+ Point loc = list.getLocationOnScreen();
+ Rectangle rect = list.getBounds();
+ int dY = rect.height / list.getItemCount();
+ loc = new Point(loc.x + 10, loc.y + 5);
+
+ String osName = System.getProperty("os.name");
+ boolean isMac = osName.contains("Mac") || osName.contains("mac");
+ if(isMac) {
+ robot.keyPress(KeyEvent.VK_META);
+ }
+
+ // First loop to select & Second loop to deselect the list items.
+ for (int j = 0; j < 2; ++j) {
+ for (int i = 0; i < list.getItemCount(); ++i) {
+ robot.mouseMove(loc.x, loc.y + i * dY);
+ robot.mousePress(InputEvent.BUTTON1_MASK);
+ robot.delay(100);
+ robot.mouseRelease(InputEvent.BUTTON1_MASK);
+ robot.waitForIdle();
+ }
+ }
+
+ if(isMac) {
+ robot.keyRelease(KeyEvent.VK_META);
+ }
+
+ if (!expectedSelectionOrder.equals(actualSelectionOrder.toString())) {
+ dispose();
+ throw new RuntimeException("ItemEvent for selection & deselection"
+ + " of multi select List's item is not correct"
+ + " Expected : " + expectedSelectionOrder
+ + " Actual : " + actualSelectionOrder);
+ }
+ }
+
+ public static void main(String args[]) {
+ ItemEventTest test = new ItemEventTest();
+ test.testHandleEvent();
+ test.testItemListener();
+ test.dispose();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/MenuBar/ActionEventTest/ActionEventTest.java Tue Apr 19 09:21:45 2016 -0700
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * 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 6191390
+ * @summary Verify that ActionEvent is received with correct modifiers set.
+ * @run main/manual ActionEventTest
+ */
+
+import java.awt.Frame;
+import java.awt.Menu;
+import java.awt.MenuBar;
+import java.awt.MenuItem;
+import java.awt.TextArea;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+public final class ActionEventTest extends Frame {
+
+ MenuBar menuBar;
+ TextArea instructions;
+ public static boolean isProgInterruption = false;
+ static Thread mainThread = null;
+ static int sleepTime = 300000;
+
+ public ActionEventTest() {
+ menuBar = new MenuBar();
+ Menu menu = new Menu("Menu1");
+ MenuItem menuItem = new MenuItem("MenuItem");
+
+ menuItem.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent ae) {
+ System.out.println("actionPerformed");
+ int md = ae.getModifiers();
+ int expectedMask = ActionEvent.ALT_MASK | ActionEvent.CTRL_MASK
+ | ActionEvent.SHIFT_MASK;
+
+ isProgInterruption = true;
+ mainThread.interrupt();
+ if ((md & expectedMask) != expectedMask) {
+ throw new RuntimeException("Action Event modifiers are not"
+ + " set correctly.");
+ }
+ }
+ });
+ menu.add(menuItem);
+ menuBar.add(menu);
+ setMenuBar(menuBar);
+
+ instructions = new TextArea(10, 50);
+ instructions.setText(
+ " This is a manual test\n" +
+ " Keep the Alt, Shift & Ctrl Keys pressed while doing next steps\n" +
+ " Click 'Menu1' Menu from the Menu Bar\n" +
+ " It will show 'MenuItem'\n" +
+ " Left mouse Click the 'MenuItem'\n" +
+ " Test exits automatically after mouse click.");
+ add(instructions);
+
+ setSize(400, 400);
+ setVisible(true);
+ validate();
+ }
+
+
+ public static void main(final String[] args) throws Exception {
+ mainThread = Thread.currentThread();
+ ActionEventTest test = new ActionEventTest();
+ try {
+ mainThread.sleep(sleepTime);
+ } catch (InterruptedException e) {
+ if (!isProgInterruption) {
+ throw e;
+ }
+ }
+ test.dispose();
+ if (!isProgInterruption) {
+ throw new RuntimeException("Timed out after " + sleepTime / 1000
+ + " seconds");
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/PrintJob/JobAttrUpdateTest.java Tue Apr 19 09:21:45 2016 -0700
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * 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 6357905
+ * @summary JobAttributes.getFromPage() and getToPage() always returns 1
+ * @run main/manual JobAttrUpdateTest
+ */
+import java.awt.BorderLayout;
+import java.awt.FlowLayout;
+import java.awt.JobAttributes;
+import java.awt.PrintJob;
+import java.awt.Toolkit;
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JTextArea;
+import javax.swing.SwingUtilities;
+
+public class JobAttrUpdateTest {
+
+ private static Thread mainThread;
+ private static boolean testPassed;
+ private static boolean testGeneratedInterrupt;
+
+ public static void main(String[] args) throws Exception {
+ SwingUtilities.invokeAndWait(() -> {
+ doTest(JobAttrUpdateTest::printTest);
+ });
+ mainThread = Thread.currentThread();
+ try {
+ Thread.sleep(30000);
+ } catch (InterruptedException e) {
+ if (!testPassed && testGeneratedInterrupt) {
+ throw new RuntimeException(""
+ + "JobAttributes.getFromPage(),getToPage() not updated correctly");
+ }
+ }
+ if (!testGeneratedInterrupt) {
+ throw new RuntimeException("user has not executed the test");
+ }
+ }
+
+ private static void printTest() {
+ JobAttributes ja = new JobAttributes();
+
+ Toolkit tk = Toolkit.getDefaultToolkit();
+ // ja.setToPage(4);
+ // ja.setFromPage(3);
+ // show dialog
+ PrintJob pjob = tk.getPrintJob(new JFrame(), "test", ja, null);
+ if (pjob == null) {
+ return;
+ }
+
+
+ if (ja.getDefaultSelection() == JobAttributes.DefaultSelectionType.RANGE) {
+ int fromPage = ja.getFromPage();
+ int toPage = ja.getToPage();
+ if (fromPage != 2 || toPage != 3) {
+ fail();
+ } else {
+ pass();
+ }
+ }
+ }
+
+ public static synchronized void pass() {
+ testPassed = true;
+ testGeneratedInterrupt = true;
+ mainThread.interrupt();
+ }
+
+ public static synchronized void fail() {
+ testPassed = false;
+ testGeneratedInterrupt = true;
+ mainThread.interrupt();
+ }
+
+ private static void doTest(Runnable action) {
+ String description
+ = " A print dialog will be shown.\n "
+ + " Please select Pages within Page-range.\n"
+ + " and enter From 2 and To 3. Then Select OK.";
+
+ final JDialog dialog = new JDialog();
+ dialog.setTitle("JobAttribute Updation Test");
+ JTextArea textArea = new JTextArea(description);
+ textArea.setEditable(false);
+ final JButton testButton = new JButton("Start Test");
+
+ testButton.addActionListener((e) -> {
+ testButton.setEnabled(false);
+ action.run();
+ });
+ JPanel mainPanel = new JPanel(new BorderLayout());
+ mainPanel.add(textArea, BorderLayout.CENTER);
+ JPanel buttonPanel = new JPanel(new FlowLayout());
+ buttonPanel.add(testButton);
+ mainPanel.add(buttonPanel, BorderLayout.SOUTH);
+ dialog.add(mainPanel);
+ dialog.pack();
+ dialog.setVisible(true);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/TrayIcon/ActionEventTest/ActionEventTest.java Tue Apr 19 09:21:45 2016 -0700
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * 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 6191390
+ * @summary Verify that ActionEvent is received with correct modifiers set.
+ * @library ../../../../lib/testlibrary ../
+ * @build ExtendedRobot SystemTrayIconHelper
+ */
+
+import java.awt.Image;
+import java.awt.TrayIcon;
+import java.awt.SystemTray;
+import java.awt.Robot;
+import java.awt.EventQueue;
+import java.awt.Point;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
+import java.awt.image.BufferedImage;
+
+public class ActionEventTest {
+
+ Image image;
+ TrayIcon icon;
+ Robot robot;
+
+ public static void main(String[] args) throws Exception {
+ if (!SystemTray.isSupported()) {
+ System.out.println("SystemTray not supported on the platform." +
+ " Marking the test passed.");
+ } else {
+ if (System.getProperty("os.name").toLowerCase().startsWith("win")) {
+ System.err.println(
+ "Test can fail on Windows platform\n"+
+ "On Windows 7, by default icon hides behind icon pool\n" +
+ "Due to which test might fail\n" +
+ "Set \"Right mouse click\" -> " +
+ "\"Customize notification icons\" -> \"Always show " +
+ "all icons and notifications on the taskbar\" true " +
+ "to avoid this problem.\nOR change behavior only for " +
+ "Java SE tray icon and rerun test.");
+ }
+
+ ActionEventTest test = new ActionEventTest();
+ test.doTest();
+ test.clear();
+ }
+ }
+
+ public ActionEventTest() throws Exception {
+ robot = new Robot();
+ EventQueue.invokeAndWait(this::initializeGUI);
+ }
+
+ private void initializeGUI() {
+
+ icon = new TrayIcon(
+ new BufferedImage(20, 20, BufferedImage.TYPE_INT_RGB), "ti");
+ icon.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent ae) {
+ int md = ae.getModifiers();
+ int expectedMask = ActionEvent.ALT_MASK | ActionEvent.CTRL_MASK
+ | ActionEvent.SHIFT_MASK;
+
+ if ((md & expectedMask) != expectedMask) {
+ clear();
+ throw new RuntimeException("Action Event modifiers are not"
+ + " set correctly.");
+ }
+ }
+ });
+
+ try {
+ SystemTray.getSystemTray().add(icon);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void clear() {
+ SystemTray.getSystemTray().remove(icon);
+ }
+
+ void doTest() throws Exception {
+ robot.keyPress(KeyEvent.VK_ALT);
+ robot.keyPress(KeyEvent.VK_SHIFT);
+ robot.keyPress(KeyEvent.VK_CONTROL);
+
+ Point iconPosition = SystemTrayIconHelper.getTrayIconLocation(icon);
+ if (iconPosition == null) {
+ throw new RuntimeException("Unable to find the icon location!");
+ }
+
+ robot.mouseMove(iconPosition.x, iconPosition.y);
+ robot.waitForIdle();
+
+ robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
+ robot.delay(100);
+ robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
+ robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
+ robot.delay(100);
+ robot.waitForIdle();
+ robot.keyRelease(KeyEvent.VK_ALT);
+ robot.keyRelease(KeyEvent.VK_SHIFT);
+ robot.keyRelease(KeyEvent.VK_CONTROL);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/font/MonospacedGlyphWidth/MonospacedGlyphWidthTest.java Tue Apr 19 09:21:45 2016 -0700
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * 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 8073400
+ * @summary Some Monospaced logical fonts have a different width
+ * @author Dmitry Markov
+ * @run main MonospacedGlyphWidthTest
+ */
+import java.awt.*;
+import java.awt.font.FontRenderContext;
+
+public class MonospacedGlyphWidthTest {
+ private static final int START_INDEX = 0x2018;
+ private static final int END_INDEX = 0x201F;
+
+ public static void main(String[] args) {
+ Font font = new Font(Font.MONOSPACED, Font.PLAIN, 12);
+ double width = getCharWidth(font, 'a');
+
+ for (int i = START_INDEX; i <= END_INDEX; i++) {
+ if (width != getCharWidth(font, (char)i)) {
+ throw new RuntimeException("Test Failed: characters have different width!");
+ }
+ }
+ System.out.println("Test Passed!");
+ }
+
+ private static double getCharWidth(Font font, char c) {
+ FontRenderContext fontRenderContext = new FontRenderContext(null, false, false);
+ return font.getStringBounds(new char[] {c}, 0, 1, fontRenderContext).getWidth();
+ }
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/image/RasterCreationTest.java Tue Apr 19 09:21:45 2016 -0700
@@ -0,0 +1,352 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * 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.Point;
+import java.awt.image.DataBuffer;
+import java.awt.image.DataBufferByte;
+import java.awt.image.DataBufferDouble;
+import java.awt.image.DataBufferFloat;
+import java.awt.image.DataBufferInt;
+import java.awt.image.DataBufferShort;
+import java.awt.image.DataBufferUShort;
+import java.awt.image.Raster;
+import java.awt.image.SampleModel;
+import java.awt.image.MultiPixelPackedSampleModel;
+import java.awt.image.PixelInterleavedSampleModel;
+import java.awt.image.SinglePixelPackedSampleModel;
+
+/*
+ * @test
+ * @bug 6353518
+ * @summary Test possible combinations of Raster creation
+ * Test fails if any of Raster.createXXX() method throws exception.
+ */
+public class RasterCreationTest {
+
+ public static void main(String[] args) {
+
+ final int width = 10;
+ final int height = 5;
+ final int imageSize = width * height;
+ Point location = new Point(0, 0);
+ int[] bandOffsets = {0};
+ int[] bitMask = {0x00ff0000, 0x0000ff00, 0xff, 0x0};
+
+ SampleModel[] inputSampleModels = {
+ new PixelInterleavedSampleModel(DataBuffer.TYPE_BYTE,
+ 1, 1, 1, 1, bandOffsets),
+ new PixelInterleavedSampleModel(DataBuffer.TYPE_USHORT,
+ 1, 1, 1, 1, bandOffsets),
+ new PixelInterleavedSampleModel(DataBuffer.TYPE_INT,
+ 1, 1, 1, 1, bandOffsets),
+ new SinglePixelPackedSampleModel(DataBuffer.TYPE_BYTE,
+ width, height, bitMask),
+ new SinglePixelPackedSampleModel(DataBuffer.TYPE_USHORT,
+ width, height, bitMask),
+ new SinglePixelPackedSampleModel(DataBuffer.TYPE_INT,
+ width, height, bitMask),
+ new MultiPixelPackedSampleModel(DataBuffer.TYPE_BYTE,
+ width, height, 4),
+ new MultiPixelPackedSampleModel(DataBuffer.TYPE_USHORT,
+ width, height, 2),
+ new MultiPixelPackedSampleModel(DataBuffer.TYPE_INT,
+ width, height, 2)
+ };
+
+ // ---------------------------------------------------------------------
+ // Test ability to create Raster & WritableRaster with DataBuffer
+ // classes
+ // ---------------------------------------------------------------------
+ DataBuffer[] inputDataBuffer = {
+ new DataBufferByte(imageSize),
+ new DataBufferUShort(imageSize),
+ new DataBufferInt(imageSize, 1),
+ new DataBufferShort(imageSize),
+ new DataBufferFloat(imageSize),
+ new DataBufferDouble(imageSize)
+ };
+
+ for (SampleModel sm : inputSampleModels) {
+ for (DataBuffer db : inputDataBuffer) {
+ // Test Raster creation
+ Raster.createRaster(sm, db, location);
+
+ // Test writableRaster creation
+ Raster.createWritableRaster(sm, db, location);
+ Raster.createWritableRaster(sm, location);
+ }
+ }
+
+ // ---------------------------------------------------------------------
+ // Test ability to create Raster & WritableRaster with custom DataBuffer
+ // classes
+ // ---------------------------------------------------------------------
+ DataBuffer[] myDataBuffer = {
+ new MyDataBufferByte(imageSize),
+ new MyDataBufferUShort(imageSize),
+ new MyDataBufferInt(imageSize),
+ new MyDataBufferShort(imageSize),
+ new MyDataBufferDouble(imageSize),
+ new MyDataBufferFloat(imageSize)
+ };
+
+ for (SampleModel sm : inputSampleModels) {
+ for (DataBuffer db : myDataBuffer) {
+ // Test Raster creation
+ Raster.createRaster(sm, db, location);
+
+ // Test writableRaster creation
+ Raster.createWritableRaster(sm, db, location);
+ Raster.createWritableRaster(sm, location);
+ }
+ }
+
+ // ---------------------------------------------------------------------
+ // Test ability to create InterleavedRaster
+ // ---------------------------------------------------------------------
+ int[] interleavedInputDataTypes = {
+ DataBuffer.TYPE_BYTE,
+ DataBuffer.TYPE_USHORT
+ };
+
+ int numBands = 1;
+
+ for (int i : interleavedInputDataTypes) {
+ Raster.createInterleavedRaster(i, width, height, 1, location);
+ Raster.createInterleavedRaster(i, width, height, width * numBands,
+ numBands, bandOffsets, location);
+ }
+
+ for (int i = 0; i < interleavedInputDataTypes.length ; i++) {
+ DataBuffer d1 = inputDataBuffer[i];
+ DataBuffer d2 = myDataBuffer[i];
+
+ Raster.createInterleavedRaster(d1, width, height, width * numBands,
+ numBands, bandOffsets, location);
+ Raster.createInterleavedRaster(d2, width, height, width * numBands,
+ numBands, bandOffsets, location);
+ }
+
+ // ---------------------------------------------------------------------
+ // Test ability to create BandedRaster
+ // ---------------------------------------------------------------------
+ int[] bankIndices = new int[numBands];
+ bankIndices[0] = 0;
+
+ int[] bandedInputDataTypes = {
+ DataBuffer.TYPE_BYTE,
+ DataBuffer.TYPE_USHORT,
+ DataBuffer.TYPE_INT
+ };
+
+ for (int i : bandedInputDataTypes) {
+ Raster.createBandedRaster(i, width, height, 1, location);
+ Raster.createBandedRaster(i, width, height, width,
+ bankIndices, bandOffsets, location);
+ }
+
+ for (int i = 0; i < bandedInputDataTypes.length; i++) {
+ DataBuffer d1 = inputDataBuffer[i];
+ DataBuffer d2 = myDataBuffer[i];
+
+ Raster.createBandedRaster(d1, width, height, width,
+ bankIndices, bandOffsets, location);
+ Raster.createBandedRaster(d2, width, height, width,
+ bankIndices, bandOffsets, location);
+ }
+
+ // ---------------------------------------------------------------------
+ // Test ability to create PackedRaster
+ // ---------------------------------------------------------------------
+ int[] bandMasks = new int[numBands];
+ bandMasks[0] = 0;
+
+ int packedInputDataTypes[] = {
+ DataBuffer.TYPE_BYTE,
+ DataBuffer.TYPE_USHORT,
+ DataBuffer.TYPE_INT
+ };
+
+ for (int i : packedInputDataTypes) {
+ Raster.createPackedRaster(i, width, height, bandMasks, location);
+
+ for (int bits = 1; bits < 5; bits *= 2) {
+ Raster.createPackedRaster(i, width, height, 1, bits, location);
+ }
+ }
+
+ for (int i = 0; i < packedInputDataTypes.length; i++) {
+ DataBuffer d1 = inputDataBuffer[i];
+ DataBuffer d2 = myDataBuffer[i];
+
+ for (int bits = 1; bits < 5; bits *= 2) {
+ Raster.createPackedRaster(d1, width, height, bits, location);
+ Raster.createPackedRaster(d2, width, height, bits, location);
+ }
+
+ Raster.createPackedRaster(d1, width, height, 1,bandMasks, location);
+ Raster.createPackedRaster(d2, width, height, 1,bandMasks, location);
+ }
+ }
+}
+
+// ---------------------------------------------------------------------
+// Custom DataBuffer classes for testing purpose
+// ---------------------------------------------------------------------
+final class MyDataBufferByte extends DataBuffer {
+
+ byte[] data;
+ byte[][] bankdata;
+
+ public MyDataBufferByte(int size) {
+ super(TYPE_BYTE, size);
+ data = new byte[size];
+ bankdata = new byte[1][];
+ bankdata[0] = data;
+ }
+
+ @Override
+ public int getElem(int bank, int i) {
+ return bankdata[bank][i + offsets[bank]];
+ }
+
+ @Override
+ public void setElem(int bank, int i, int val) {
+ bankdata[bank][i + offsets[bank]] = (byte) val;
+ }
+}
+
+final class MyDataBufferDouble extends DataBuffer {
+
+ double[] data;
+ double[][] bankdata;
+
+ public MyDataBufferDouble(int size) {
+ super(TYPE_DOUBLE, size);
+ data = new double[size];
+ bankdata = new double[1][];
+ bankdata[0] = data;
+ }
+
+ @Override
+ public int getElem(int bank, int i) {
+ return (int) bankdata[bank][i + offsets[bank]];
+ }
+
+ @Override
+ public void setElem(int bank, int i, int val) {
+ bankdata[bank][i + offsets[bank]] = (double) val;
+ }
+}
+
+final class MyDataBufferFloat extends DataBuffer {
+
+ float[] data;
+ float[][] bankdata;
+
+ public MyDataBufferFloat(int size) {
+ super(TYPE_FLOAT, size);
+ data = new float[size];
+ bankdata = new float[1][];
+ bankdata[0] = data;
+ }
+
+ @Override
+ public int getElem(int bank, int i) {
+ return (int) bankdata[bank][i + offsets[bank]];
+ }
+
+ @Override
+ public void setElem(int bank, int i, int val) {
+ bankdata[bank][i + offsets[bank]] = (float) val;
+ }
+}
+
+final class MyDataBufferShort extends DataBuffer {
+
+ short[] data;
+ short[][] bankdata;
+
+ public MyDataBufferShort(int size) {
+ super(TYPE_SHORT, size);
+ data = new short[size];
+ bankdata = new short[1][];
+ bankdata[0] = data;
+ }
+
+ @Override
+ public int getElem(int bank, int i) {
+ return bankdata[bank][i + offsets[bank]];
+ }
+
+ @Override
+ public void setElem(int bank, int i, int val) {
+ bankdata[bank][i + offsets[bank]] = (short) val;
+ }
+}
+
+final class MyDataBufferUShort extends DataBuffer {
+
+ short[] data;
+ short[][] bankdata;
+
+ public MyDataBufferUShort(int size) {
+ super(TYPE_USHORT, size);
+ data = new short[size];
+ bankdata = new short[1][];
+ bankdata[0] = data;
+ }
+
+ @Override
+ public int getElem(int bank, int i) {
+ return bankdata[bank][i + offsets[bank]];
+ }
+
+ @Override
+ public void setElem(int bank, int i, int val) {
+ bankdata[bank][i + offsets[bank]] = (short) val;
+ }
+}
+
+final class MyDataBufferInt extends DataBuffer {
+
+ int[] data;
+ int[][] bankdata;
+
+ public MyDataBufferInt(int size) {
+ super(TYPE_INT, size);
+ data = new int[size];
+ bankdata = new int[1][];
+ bankdata[0] = data;
+ }
+
+ @Override
+ public int getElem(int bank, int i) {
+ return bankdata[bank][i + offsets[bank]];
+ }
+
+ @Override
+ public void setElem(int bank, int i, int val) {
+ bankdata[bank][i + offsets[bank]] = (int) val;
+ }
+}
--- a/jdk/test/java/awt/image/multiresolution/MultiResolutionTrayIconTest/MultiResolutionTrayIconTest.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/test/java/awt/image/multiresolution/MultiResolutionTrayIconTest/MultiResolutionTrayIconTest.java Tue Apr 19 09:21:45 2016 -0700
@@ -24,8 +24,7 @@
/*
@test
- @bug 8150176
- @ignore 8150176
+ @bug 8150176 8151773
@summary Check if correct resolution variant is used for tray icon.
@author a.stepanov
@run applet/manual=yesno MultiResolutionTrayIconTest.html
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/print/PrinterJob/DlgAttrsBug.java Tue Apr 19 09:21:45 2016 -0700
@@ -0,0 +1,152 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * 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 8061258
+ * @summary PrinterJob's native Print Dialog does not reflect
+ * specified Copies or Page Ranges
+ * @run main/manual DlgAttrsBug
+ */
+import java.awt.BorderLayout;
+import java.awt.FlowLayout;
+import java.awt.Graphics;
+import java.awt.print.PageFormat;
+import java.awt.print.Printable;
+import java.awt.print.PrinterException;
+import java.awt.print.PrinterJob;
+import javax.print.attribute.HashPrintRequestAttributeSet;
+import javax.print.attribute.PrintRequestAttributeSet;
+import javax.print.attribute.standard.Copies;
+import javax.print.attribute.standard.PageRanges;
+import javax.print.attribute.standard.DialogTypeSelection;
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JPanel;
+import javax.swing.JTextArea;
+import javax.swing.SwingUtilities;
+
+
+public class DlgAttrsBug implements Printable {
+ private static Thread mainThread;
+ private static boolean testPassed;
+ private static boolean testGeneratedInterrupt;
+
+ public static void main(String[] args) throws Exception {
+ SwingUtilities.invokeAndWait(() -> {
+ doTest(DlgAttrsBug::printTest);
+ });
+ mainThread = Thread.currentThread();
+ try {
+ Thread.sleep(30000);
+ } catch (InterruptedException e) {
+ if (!testPassed && testGeneratedInterrupt) {
+ throw new RuntimeException("Print Dialog does not " +
+ "reflect Copies or Page Ranges");
+ }
+ }
+ if (!testGeneratedInterrupt) {
+ throw new RuntimeException("user has not executed the test");
+ }
+ }
+
+ private static void printTest() {
+ PrinterJob job = PrinterJob.getPrinterJob();
+ if (job.getPrintService() == null) {
+ System.out.println("No printers. Test cannot continue");
+ return;
+ }
+ job.setPrintable(new DlgAttrsBug());
+ PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
+ aset.add(new Copies(5));
+ aset.add(new PageRanges(3,4));
+ aset.add(DialogTypeSelection.NATIVE);
+ job.printDialog(aset);
+ }
+
+ public static synchronized void pass() {
+ testPassed = true;
+ testGeneratedInterrupt = true;
+ mainThread.interrupt();
+ }
+
+ public static synchronized void fail() {
+ testPassed = false;
+ testGeneratedInterrupt = true;
+ mainThread.interrupt();
+ }
+
+ private static void doTest(Runnable action) {
+ String description
+ = " Visual inspection of print dialog is required.\n"
+ + " A print dialog will be shown.\n "
+ + " Please verify Copies 5 is selected.\n"
+ + " Also verify, Page Range is selected with "
+ + " from page 3 and to Page 4.\n"
+ + " If ok, press PASS else press FAIL";
+
+ final JDialog dialog = new JDialog();
+ dialog.setTitle("printSelectionTest");
+ JTextArea textArea = new JTextArea(description);
+ textArea.setEditable(false);
+ final JButton testButton = new JButton("Start Test");
+ final JButton passButton = new JButton("PASS");
+ passButton.setEnabled(false);
+ passButton.addActionListener((e) -> {
+ dialog.dispose();
+ pass();
+ });
+ final JButton failButton = new JButton("FAIL");
+ failButton.setEnabled(false);
+ failButton.addActionListener((e) -> {
+ dialog.dispose();
+ fail();
+ });
+ testButton.addActionListener((e) -> {
+ testButton.setEnabled(false);
+ action.run();
+ passButton.setEnabled(true);
+ failButton.setEnabled(true);
+ });
+ JPanel mainPanel = new JPanel(new BorderLayout());
+ mainPanel.add(textArea, BorderLayout.CENTER);
+ JPanel buttonPanel = new JPanel(new FlowLayout());
+ buttonPanel.add(testButton);
+ buttonPanel.add(passButton);
+ buttonPanel.add(failButton);
+ mainPanel.add(buttonPanel, BorderLayout.SOUTH);
+ dialog.add(mainPanel);
+ dialog.pack();
+ dialog.setVisible(true);
+ }
+
+ public int print(Graphics g, PageFormat pf, int pi)
+ throws PrinterException {
+ System.out.println("pi = " + pi);
+ if (pi >= 5) {
+ return NO_SUCH_PAGE;
+ }
+ g.drawString("Page : " + (pi+1), 200, 200);
+ return PAGE_EXISTS;
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/print/PrinterJob/PrintAttributeUpdateTest.java Tue Apr 19 09:21:45 2016 -0700
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * 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 8042713
+ @summary Print Dialog does not update attribute set with page range
+ @run main/manual PrintAttributeUpdateTest
+ */
+import java.awt.Component;
+import java.awt.Graphics;
+import java.awt.print.PageFormat;
+import java.awt.print.Pageable;
+import java.awt.print.Printable;
+import java.awt.print.PrinterJob;
+import javax.print.attribute.Attribute;
+import javax.print.attribute.HashPrintRequestAttributeSet;
+import javax.print.attribute.standard.DialogTypeSelection;
+import javax.print.attribute.standard.PageRanges;
+import javax.swing.JOptionPane;
+import javax.swing.SwingUtilities;
+
+public class PrintAttributeUpdateTest implements Pageable, Printable {
+
+ public static void main(String args[]) throws Exception {
+ String[] instructions
+ = {
+ "Select Pages Range From instead of All in print dialog. ",
+ "Then select Print"
+ };
+ SwingUtilities.invokeAndWait(() -> {
+ JOptionPane.showMessageDialog((Component) null,
+ instructions, "Instructions",
+ JOptionPane.INFORMATION_MESSAGE);
+ });
+ HashPrintRequestAttributeSet as = new HashPrintRequestAttributeSet();
+ PrinterJob j = PrinterJob.getPrinterJob();
+ j.setPageable(new PrintAttributeUpdateTest());
+ as.add(DialogTypeSelection.NATIVE);
+ j.printDialog(as);
+ if (as.containsKey(PageRanges.class) == false) {
+ throw new RuntimeException("Print Dialog did not update "
+ + " attribute set with page range");
+ }
+ Attribute attrs[] = as.toArray();
+ for (int i = 0; i < attrs.length; i++) {
+ System.out.println("attr " + attrs[i]);
+ }
+ j.print(as);
+ }
+
+ public int getNumberOfPages() {
+ return UNKNOWN_NUMBER_OF_PAGES;
+ }
+
+ public PageFormat getPageFormat(int pageIndex) {
+ PageFormat pf = new PageFormat();
+ return pf;
+ }
+
+ public Printable getPrintable(int pageIndex) {
+ return this;
+ }
+
+ public int print(Graphics g, PageFormat pgFmt, int pi) {
+ g.drawString("Page : " + (pi + 1), 200, 200);
+
+ return PAGE_EXISTS;
+ }
+
+}
--- a/jdk/test/java/awt/xembed/server/TestXEmbedServerJava.java Mon Apr 18 09:38:38 2016 -0700
+++ b/jdk/test/java/awt/xembed/server/TestXEmbedServerJava.java Tue Apr 19 09:21:45 2016 -0700
@@ -76,7 +76,23 @@
public Process startClient(Rectangle[] bounds, long window) {
try {
String java_home = System.getProperty("java.home");
- return Runtime.getRuntime().exec(java_home + "/bin/java -XaddExports:java.desktop/sun.awt.X11=ALL-UNNAMED JavaClient " + window);
+ boolean hasModules = true;
+ try {
+ Class.class.getMethod("getModule");
+ }catch(Exception hasModulesEx) {
+ hasModules = false;
+ }
+ if (hasModules) {
+ System.out.println(java_home +
+ "/bin/java -XaddExports:java.desktop/sun.awt.X11=ALL-UNNAMED "+
+ "-XaddExports:java.desktop/sun.awt=ALL-UNNAMED JavaClient " + window);
+ return Runtime.getRuntime().exec(java_home +
+ "/bin/java -XaddExports:java.desktop/sun.awt.X11=ALL-UNNAMED "+
+ "-XaddExports:java.desktop/sun.awt=ALL-UNNAMED JavaClient " + window);
+ }else{
+ System.out.println(java_home + "/bin/java JavaClient " + window);
+ return Runtime.getRuntime().exec(java_home + "/bin/java JavaClient " + window);
+ }
} catch (IOException ex1) {
ex1.printStackTrace();
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/imageio/plugins/tiff/MultiPageImageTIFFFieldTest.java Tue Apr 19 09:21:45 2016 -0700
@@ -0,0 +1,378 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * 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
+ * @ignore 8148454
+ * @bug 8152183 8148454
+ * @author a.stepanov
+ * @summary check that TIFFields are derived properly for multi-page tiff
+ * @run main MultiPageImageTIFFFieldTest
+ */
+
+import java.awt.*;
+import java.awt.color.*;
+import java.awt.image.BufferedImage;
+import java.io.*;
+import javax.imageio.*;
+import javax.imageio.metadata.*;
+import javax.imageio.stream.*;
+import javax.imageio.plugins.tiff.*;
+
+
+public class MultiPageImageTIFFFieldTest {
+
+ private final static String FILENAME = "test.tiff";
+ private final static int W1 = 20, H1 = 40, W2 = 100, H2 = 15;
+ private final static Color C1 = Color.BLACK, C2 = Color.RED;
+
+ private final static int N_WIDTH = BaselineTIFFTagSet.TAG_IMAGE_WIDTH;
+ private final static int N_HEIGHT = BaselineTIFFTagSet.TAG_IMAGE_LENGTH;
+
+ private static final String DESCRIPTION_1[] = {"Description-1", "abc ABC"};
+ private static final String DESCRIPTION_2[] = {"Description-2", "1-2-3"};
+ private final static int N_DESCRIPTION =
+ BaselineTIFFTagSet.TAG_IMAGE_DESCRIPTION;
+
+ private final static String EXIF_DATA_1[] = {"2001:01:01 00:00:01"};
+ private final static String EXIF_DATA_2[] = {"2002:02:02 00:00:02"};
+ private final static int N_EXIF = ExifTIFFTagSet.TAG_DATE_TIME_ORIGINAL;
+
+ private final static String GPS_DATA[] = {
+ ExifGPSTagSet.STATUS_MEASUREMENT_IN_PROGRESS};
+ private final static int N_GPS = ExifGPSTagSet.TAG_GPS_STATUS;
+
+ private final static short FAX_DATA =
+ FaxTIFFTagSet.CLEAN_FAX_DATA_ERRORS_UNCORRECTED;
+ private final static int N_FAX = FaxTIFFTagSet.TAG_CLEAN_FAX_DATA;
+
+ private static final byte[] ICC_PROFILE_2 =
+ ICC_ProfileRGB.getInstance(ColorSpace.CS_sRGB).getData();
+ private static final int N_ICC = BaselineTIFFTagSet.TAG_ICC_PROFILE;
+
+ private static final int N_BPS = BaselineTIFFTagSet.TAG_BITS_PER_SAMPLE;
+
+ private static final int
+ COMPRESSION_1 = BaselineTIFFTagSet.COMPRESSION_DEFLATE,
+ COMPRESSION_2 = BaselineTIFFTagSet.COMPRESSION_LZW;
+ private static final int N_COMPRESSION = BaselineTIFFTagSet.TAG_COMPRESSION;
+
+ private static final int
+ GRAY_1 = BaselineTIFFTagSet.PHOTOMETRIC_INTERPRETATION_WHITE_IS_ZERO,
+ GRAY_2 = BaselineTIFFTagSet.PHOTOMETRIC_INTERPRETATION_BLACK_IS_ZERO,
+ RGB = BaselineTIFFTagSet.PHOTOMETRIC_INTERPRETATION_RGB;
+
+ private static final int N_PHOTO =
+ BaselineTIFFTagSet.TAG_PHOTOMETRIC_INTERPRETATION;
+
+ private ImageWriter getTIFFWriter() {
+
+ java.util.Iterator<ImageWriter> writers =
+ ImageIO.getImageWritersByFormatName("TIFF");
+ if (!writers.hasNext()) {
+ throw new RuntimeException("No writers available for TIFF format");
+ }
+ return writers.next();
+ }
+
+ private ImageReader getTIFFReader() {
+
+ java.util.Iterator<ImageReader> readers =
+ ImageIO.getImageReadersByFormatName("TIFF");
+ if (!readers.hasNext()) {
+ throw new RuntimeException("No readers available for TIFF format");
+ }
+ return readers.next();
+ }
+
+ private void addASCIIField(TIFFDirectory d,
+ String name,
+ String data[],
+ int num) {
+
+ d.addTIFFField(new TIFFField(
+ new TIFFTag(name, num, 1 << TIFFTag.TIFF_ASCII),
+ TIFFTag.TIFF_ASCII, data.length, data));
+ }
+
+ private void checkASCIIField(TIFFDirectory d,
+ String what,
+ String data[],
+ int num) {
+
+ String notFound = what + " field was not found";
+ check(d.containsTIFFField(num), notFound);
+ TIFFField f = d.getTIFFField(num);
+ check(f.getType() == TIFFTag.TIFF_ASCII, "field type != ASCII");
+ check(f.getCount() == data.length, "invalid " + what + " data count");
+ for (int i = 0; i < data.length; i++) {
+ check(f.getValueAsString(i).equals(data[i]),
+ "invalid " + what + " data");
+ }
+ }
+
+ private void writeImage() throws Exception {
+
+ OutputStream s = new BufferedOutputStream(new FileOutputStream(FILENAME));
+ try (ImageOutputStream ios = ImageIO.createImageOutputStream(s)) {
+
+ ImageWriter writer = getTIFFWriter();
+ writer.setOutput(ios);
+
+ BufferedImage img1 =
+ new BufferedImage(W1, H1, BufferedImage.TYPE_BYTE_GRAY);
+ Graphics g = img1.getGraphics();
+ g.setColor(C1);
+ g.fillRect(0, 0, W1, H1);
+ g.dispose();
+
+ BufferedImage img2 =
+ new BufferedImage(W2, H2, BufferedImage.TYPE_INT_RGB);
+ g = img2.getGraphics();
+ g.setColor(C2);
+ g.fillRect(0, 0, W2, H2);
+ g.dispose();
+
+ ImageWriteParam param1 = writer.getDefaultWriteParam();
+ param1.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
+ param1.setCompressionType("Deflate");
+ param1.setCompressionQuality(0.5f);
+
+ ImageWriteParam param2 = writer.getDefaultWriteParam();
+ param2.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
+ param2.setCompressionType("LZW");
+ param2.setCompressionQuality(0.5f);
+
+ IIOMetadata
+ md1 = writer.getDefaultImageMetadata(
+ new ImageTypeSpecifier(img1), param1),
+ md2 = writer.getDefaultImageMetadata(
+ new ImageTypeSpecifier(img2), param2);
+
+ TIFFDirectory
+ dir1 = TIFFDirectory.createFromMetadata(md1),
+ dir2 = TIFFDirectory.createFromMetadata(md2);
+
+ addASCIIField(dir1, "ImageDescription", DESCRIPTION_1, N_DESCRIPTION);
+ addASCIIField(dir2, "ImageDescription", DESCRIPTION_2, N_DESCRIPTION);
+
+ addASCIIField(dir1, "GPSStatus", GPS_DATA, N_GPS);
+ addASCIIField(dir2, "GPSStatus", GPS_DATA, N_GPS);
+
+ addASCIIField(dir1, "DateTimeOriginal", EXIF_DATA_1, N_EXIF);
+ addASCIIField(dir2, "DateTimeOriginal", EXIF_DATA_2, N_EXIF);
+
+ TIFFTag faxTag = new TIFFTag(
+ "CleanFaxData", N_FAX, 1 << TIFFTag.TIFF_SHORT);
+ dir1.addTIFFField(new TIFFField(faxTag, FAX_DATA));
+ dir2.addTIFFField(new TIFFField(faxTag, FAX_DATA));
+
+ dir2.addTIFFField(new TIFFField(
+ new TIFFTag("ICC Profile", N_ICC, 1 << TIFFTag.TIFF_UNDEFINED),
+ TIFFTag.TIFF_UNDEFINED, ICC_PROFILE_2.length, ICC_PROFILE_2));
+
+ writer.prepareWriteSequence(null);
+ writer.writeToSequence(
+ new IIOImage(img1, null, dir1.getAsMetadata()), param1);
+ writer.writeToSequence(
+ new IIOImage(img2, null, dir2.getAsMetadata()), param2);
+ writer.endWriteSequence();
+
+ ios.flush();
+ writer.dispose();
+ }
+ s.close();
+ }
+
+ private void checkBufferedImages(BufferedImage im1, BufferedImage im2) {
+
+ check(im1.getWidth() == W1, "invalid width for image 1");
+ check(im1.getHeight() == H1, "invalid height for image 1");
+ check(im2.getWidth() == W2, "invalid width for image 2");
+ check(im2.getHeight() == H2, "invalid height for image 2");
+
+ Color
+ c1 = new Color(im1.getRGB(W1 / 2, H1 / 2)),
+ c2 = new Color(im2.getRGB(W2 / 2, H2 / 2));
+
+ check(c1.equals(C1), "invalid image 1 color");
+ check(c2.equals(C2), "invalid image 2 color");
+ }
+
+ private void readAndCheckImage() throws Exception {
+
+ ImageReader reader = getTIFFReader();
+
+ ImageInputStream s = ImageIO.createImageInputStream(new File(FILENAME));
+ reader.setInput(s, false, true);
+
+ int ni = reader.getNumImages(true);
+ check(ni == 2, "invalid number of images");
+
+ // check TIFFImageReadParam for multipage image
+ TIFFImageReadParam
+ param1 = new TIFFImageReadParam(), param2 = new TIFFImageReadParam();
+
+ param1.addAllowedTagSet(ExifTIFFTagSet.getInstance());
+ param1.addAllowedTagSet(ExifGPSTagSet.getInstance());
+
+ param2.addAllowedTagSet(ExifTIFFTagSet.getInstance());
+ param2.addAllowedTagSet(GeoTIFFTagSet.getInstance());
+
+ // FaxTIFFTagSet is allowed by default
+ param2.removeAllowedTagSet(FaxTIFFTagSet.getInstance());
+
+
+ // read images and metadata
+ IIOImage i1 = reader.readAll(0, param1), i2 = reader.readAll(1, param2);
+ BufferedImage
+ bi1 = (BufferedImage) i1.getRenderedImage(),
+ bi2 = (BufferedImage) i2.getRenderedImage();
+
+ // check rendered images, just in case
+ checkBufferedImages(bi1, bi2);
+
+ TIFFDirectory
+ dir1 = TIFFDirectory.createFromMetadata(i1.getMetadata()),
+ dir2 = TIFFDirectory.createFromMetadata(i2.getMetadata());
+
+ // check ASCII fields
+ checkASCIIField(
+ dir1, "image 1 description", DESCRIPTION_1, N_DESCRIPTION);
+ checkASCIIField(
+ dir2, "image 2 description", DESCRIPTION_2, N_DESCRIPTION);
+
+ checkASCIIField(dir1, "image 1 datetime", EXIF_DATA_1, N_EXIF);
+ checkASCIIField(dir2, "image 2 datetime", EXIF_DATA_2, N_EXIF);
+
+ // check sizes
+ TIFFField f = dir1.getTIFFField(N_WIDTH);
+ check((f.getCount() == 1) && (f.getAsInt(0) == W1),
+ "invalid width field for image 1");
+ f = dir2.getTIFFField(N_WIDTH);
+ check((f.getCount() == 1) && (f.getAsInt(0) == W2),
+ "invalid width field for image 2");
+
+ f = dir1.getTIFFField(N_HEIGHT);
+ check((f.getCount() == 1) && (f.getAsInt(0) == H1),
+ "invalid height field for image 1");
+ f = dir2.getTIFFField(N_HEIGHT);
+ check((f.getCount() == 1) && (f.getAsInt(0) == H2),
+ "invalid height field for image 2");
+
+ // check fax data
+ check(dir1.containsTIFFField(N_FAX), "image 2 TIFF directory " +
+ "must contain clean fax data");
+ f = dir1.getTIFFField(N_FAX);
+ check(
+ (f.getCount() == 1) && f.isIntegral() && (f.getAsInt(0) == FAX_DATA),
+ "invalid clean fax data");
+
+ check(!dir2.containsTIFFField(N_FAX), "image 2 TIFF directory " +
+ "must not contain fax fields");
+
+ // check GPS data
+ checkASCIIField(dir1, "GPS status", GPS_DATA, N_GPS);
+
+ check(!dir2.containsTIFFField(N_GPS), "image 2 TIFF directory " +
+ "must not contain GPS fields");
+
+ // check ICC profile data
+ check(!dir1.containsTIFFField(N_ICC), "image 1 TIFF directory "
+ + "must not contain ICC Profile field");
+ check(dir2.containsTIFFField(N_ICC), "image 2 TIFF directory "
+ + "must contain ICC Profile field");
+
+ f = dir2.getTIFFField(N_ICC);
+ check(f.getType() == TIFFTag.TIFF_UNDEFINED,
+ "invalid ICC profile field type");
+ int cnt = f.getCount();
+ byte icc[] = f.getAsBytes();
+ check((cnt == ICC_PROFILE_2.length) && (cnt == icc.length),
+ "invalid ICC profile");
+ for (int i = 0; i < cnt; i++) {
+ check(icc[i] == ICC_PROFILE_2[i], "invalid ICC profile data");
+ }
+
+ // check component sizes
+ check(dir1.getTIFFField(N_BPS).isIntegral() &&
+ dir2.getTIFFField(N_BPS).isIntegral(),
+ "invalid bits per sample type");
+ int sz1[] = bi1.getColorModel().getComponentSize(),
+ sz2[] = bi2.getColorModel().getComponentSize(),
+ bps1[] = dir1.getTIFFField(N_BPS).getAsInts(),
+ bps2[] = dir2.getTIFFField(N_BPS).getAsInts();
+
+ check((bps1.length == sz1.length) && (bps2.length == sz2.length),
+ "invalid component size count");
+
+ for (int i = 0; i < bps1.length; i++) {
+ check(bps1[i] == sz1[i], "image 1: invalid bits per sample data");
+ }
+
+ for (int i = 0; i < bps2.length; i++) {
+ check(bps2[i] == sz2[i], "image 2: invalid bits per sample data");
+ }
+
+ // check compression data
+ check(dir1.containsTIFFField(N_COMPRESSION) &&
+ dir2.containsTIFFField(N_COMPRESSION),
+ "compression info lost");
+ f = dir1.getTIFFField(N_COMPRESSION);
+ check(f.isIntegral() && (f.getCount() == 1) &&
+ (f.getAsInt(0) == COMPRESSION_1), "invalid image 1 compression data");
+
+ f = dir2.getTIFFField(N_COMPRESSION);
+ check(f.isIntegral() && (f.getCount() == 1) &&
+ (f.getAsInt(0) == COMPRESSION_2), "invalid image 2 compression data");
+
+ // check photometric interpretation
+ f = dir1.getTIFFField(N_PHOTO);
+ check(f.isIntegral() && (f.getCount() == 1) &&
+ ((f.getAsInt(0) == GRAY_1) || (f.getAsInt(0) == GRAY_2)),
+ "invalid photometric interpretation for image 1");
+
+ f = dir2.getTIFFField(N_PHOTO);
+ check(f.isIntegral() && (f.getCount() == 1) && (f.getAsInt(0) == RGB),
+ "invalid photometric interpretation for image 2");
+ }
+
+ public void run() {
+
+ try {
+ writeImage();
+ readAndCheckImage();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private void check(boolean ok, String msg) {
+
+ if (!ok) { throw new RuntimeException(msg); }
+ }
+
+ public static void main(String[] args) {
+ (new MultiPageImageTIFFFieldTest()).run();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/imageio/plugins/tiff/TIFFDirectoryTest.java Tue Apr 19 09:21:45 2016 -0700
@@ -0,0 +1,266 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * 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 8149028
+ * @author a.stepanov
+ * @summary some simple checks for TIFFDirectory
+ * @run main TIFFDirectoryTest
+ */
+
+import java.util.List;
+import java.util.ArrayList;
+import javax.imageio.metadata.*;
+import javax.imageio.plugins.tiff.*;
+
+
+public class TIFFDirectoryTest {
+
+ private static void check(boolean ok, String msg) {
+ if (!ok) { throw new RuntimeException(msg); }
+ }
+
+ private void run() {
+
+ int type = TIFFTag.TIFF_LONG, dt = 1 << type;
+ int n0 = 1000, n1 = 1001, n2 = 1002, n3 = 1003;
+
+ TIFFTag tag1 = new TIFFTag(Integer.toString(n1), n1, dt);
+ TIFFTag tag2 = new TIFFTag(Integer.toString(n2), n2, dt);
+ TIFFTag tag3 = new TIFFTag(Integer.toString(n3), n3, dt);
+ TIFFTag parent = new TIFFTag(Integer.toString(n0), n0, dt);
+
+ // tag sets array must not be null
+ boolean ok = false;
+ try { new TIFFDirectory(null, parent); }
+ catch (NullPointerException e) { ok = true; }
+ check(ok, "can construct TIFFDirectory with null tagsets array");
+
+ // but can be empty
+ TIFFTagSet emptySets[] = {};
+ TIFFDirectory d = new TIFFDirectory(emptySets, parent);
+ check(d.getTagSets().length == 0, "invalid number of tag sets");
+ check(d.getParentTag().getName().equals(Integer.toString(n0)) &&
+ (d.getParentTag().getNumber() == n0), "invalid parent tag");
+
+
+ // add tags
+ List<TIFFTag> tags = new ArrayList<>();
+ tags.add(tag1);
+ tags.add(tag2);
+ TIFFTagSet ts1 = new TIFFTagSet(tags);
+
+ tags.clear();
+ tags.add(tag3);
+ TIFFTagSet ts2 = new TIFFTagSet(tags);
+
+ TIFFTagSet sets[] = {ts1, ts2};
+ d = new TIFFDirectory(sets, parent);
+
+ check(d.getTagSets().length == sets.length, "invalid number of tag sets");
+
+ // check getTag()
+ for (int i = n1; i <= n3; i++) {
+ TIFFTag t = d.getTag(i);
+ check(t.getNumber() == i, "invalid tag number");
+ check(t.getName().equals(Integer.toString(i)), "invalid tag name");
+ check(t.getDataTypes() == dt, "invalid tag data types");
+ }
+
+ TIFFDirectory d2;
+ try { d2 = d.clone(); }
+ catch (CloneNotSupportedException e) { throw new RuntimeException(e); }
+
+ // check removeTagSet()
+ d.removeTagSet(ts2);
+ check(d.getTagSets().length == 1, "invalid number of tag sets");
+ check(d.getTagSets()[0].getTag(n1).getName().equals(Integer.toString(n1)),
+ "invalid tag name");
+ check(d.getTagSets()[0].getTag(n2).getName().equals(Integer.toString(n2)),
+ "invalid tag name");
+
+ d.removeTagSet(ts1);
+ check(d.getTagSets().length == 0, "invalid number of tag sets");
+
+ // check cloned data
+ check(d2.getTagSets().length == sets.length,
+ "invalid number of tag sets");
+ TIFFTagSet sets2[] = d2.getTagSets();
+ check(sets2.length == sets.length, "invalid number of tag sets");
+ check(
+ (sets2[0].getTag(Integer.toString(n1)).getNumber() == n1) &&
+ (sets2[0].getTag(Integer.toString(n2)).getNumber() == n2) &&
+ (sets2[0].getTag(Integer.toString(n0)) == null) &&
+ (sets2[1].getTag(Integer.toString(n3)).getNumber() == n3) &&
+ (sets2[1].getTag(Integer.toString(n0)) == null), "invalid data");
+
+ check(
+ (sets2[0].getTag(Integer.toString(n1)).getDataTypes() == dt) &&
+ (sets2[0].getTag(Integer.toString(n2)).getDataTypes() == dt) &&
+ (sets2[1].getTag(Integer.toString(n3)).getDataTypes() == dt),
+ "invalid data type");
+
+ // must not be able to call removeTagSet with null argument
+ ok = false;
+ try { d.removeTagSet(null); }
+ catch (NullPointerException e) { ok = true; }
+ check(ok, "must not be able to use null as an argument for remove");
+
+ // check parent tag
+ check( d.getParentTag().getName().equals(Integer.toString(n0)) &&
+ d2.getParentTag().getName().equals(Integer.toString(n0)),
+ "invalid parent tag name");
+
+ check(( d.getParentTag().getNumber() == n0) &&
+ (d2.getParentTag().getNumber() == n0),
+ "invalid parent tag number");
+
+ check(( d.getParentTag().getDataTypes() == dt) &&
+ (d2.getParentTag().getDataTypes() == dt),
+ "invalid parent data type");
+
+ d.addTagSet(ts1);
+ d.addTagSet(ts2);
+
+ // add the same tag set twice and check that nothing changed
+ d.addTagSet(ts2);
+
+ check(d.getTagSets().length == 2, "invalid number of tag sets");
+
+ // check field operations
+ check(d.getNumTIFFFields() == 0, "invalid TIFFFields number");
+ check(d.getTIFFField(Integer.MAX_VALUE) == null,
+ "must return null TIFFField");
+
+ long offset = 4L;
+ long a[] = {Long.MIN_VALUE, 0, Long.MAX_VALUE};
+ int v = 100500;
+ TIFFField
+ f1 = new TIFFField(tag1, type, offset, d),
+ f2 = new TIFFField(tag2, v),
+ f3 = new TIFFField(tag3, type, a.length, a);
+
+ d.addTIFFField(f1);
+ d.addTIFFField(f2);
+ d.addTIFFField(f3);
+
+ check(d.containsTIFFField(n1) &&
+ d.containsTIFFField(n2) &&
+ d.containsTIFFField(n3) &&
+ !d.containsTIFFField(n0), "invalid containsTIFFField() results");
+
+ check(d.getTIFFField(n0) == null, "can get unadded field");
+
+ check(d.getNumTIFFFields() == 3, "invalid TIFFFields number");
+
+ check(d.getTIFFField(n1).getCount() == 1, "invalid TIFFField count");
+ check(d.getTIFFField(n1).getAsLong(0) == offset, "invalid offset");
+
+ check(d.getTIFFField(n2).getCount() == 1, "invalid TIFFField count");
+ check(d.getTIFFField(n2).getAsInt(0) == v, "invalid TIFFField value");
+
+ check(d.getTIFFField(n3).getCount() == a.length,
+ "invalid TIFFField count");
+ for (int i = 0; i < a.length; ++i) {
+ check(d.getTIFFField(n3).getAsLong(i) == a[i],
+ "invalid TIFFField value");
+ }
+
+ TIFFField nested = d.getTIFFField(n1).getDirectory().getTIFFField(n1);
+ check(nested.getTag().getNumber() == n1, "invalid tag number");
+ check(nested.getCount() == 1, "invalid field count");
+ check(nested.getAsLong(0) == offset, "invalid offset");
+
+ // check that the field is overwritten correctly
+ int v2 = 1 << 16;
+ d.addTIFFField(new TIFFField(tag3, v2));
+ check(d.getTIFFField(n3).getCount() == 1, "invalid TIFFField count");
+ check(d.getTIFFField(n3).getAsInt(0)== v2, "invalid TIFFField value");
+ check(d.getNumTIFFFields() == 3, "invalid TIFFFields number");
+
+ // check removeTIFFField()
+ d.removeTIFFField(n3);
+ check(d.getNumTIFFFields() == 2, "invalid TIFFFields number");
+ check(d.getTIFFField(n3) == null, "can get removed field");
+
+ d.removeTIFFFields();
+ check((d.getTIFFField(n1) == null) && (d.getTIFFField(n2) == null),
+ "can get removed field");
+ check((d.getNumTIFFFields() == 0) && (d.getTIFFFields().length == 0),
+ "invalid TIFFFields number");
+
+ // check that array returned by getTIFFFields() is sorted
+ // by tag number (as it stated in the docs)
+ d.addTIFFField(f3);
+ d.addTIFFField(f1);
+ d.addTIFFField(f2);
+
+ TIFFField fa[] = d.getTIFFFields();
+ check(fa.length == 3, "invalid number of fields");
+ check((fa[0].getTagNumber() == n1) &&
+ (fa[1].getTagNumber() == n2) &&
+ (fa[2].getTagNumber() == n3),
+ "array of the fields must be sorted by tag number");
+
+ d.removeTIFFFields();
+ d.addTIFFField(f2);
+
+ // test getAsMetaData / createFromMetadata
+ try {
+ d2 = TIFFDirectory.createFromMetadata(d.getAsMetadata());
+ } catch (IIOInvalidTreeException e) {
+ throw new RuntimeException(e);
+ }
+
+ // check new data
+ check(d2.getTagSets().length == sets.length,
+ "invalid number of tag sets");
+ sets2 = d2.getTagSets();
+ check(sets2.length == sets.length, "invalid number of tag sets");
+ check(
+ (sets2[0].getTag(Integer.toString(n1)).getNumber() == n1) &&
+ (sets2[0].getTag(Integer.toString(n2)).getNumber() == n2) &&
+ (sets2[0].getTag(Integer.toString(n0)) == null) &&
+ (sets2[1].getTag(Integer.toString(n3)).getNumber() == n3) &&
+ (sets2[1].getTag(Integer.toString(n0)) == null), "invalid data");
+
+ check(
+ (sets2[0].getTag(Integer.toString(n1)).getDataTypes() == dt) &&
+ (sets2[0].getTag(Integer.toString(n2)).getDataTypes() == dt) &&
+ (sets2[1].getTag(Integer.toString(n3)).getDataTypes() == dt),
+ "invalid data type");
+
+ check(!d2.containsTIFFField(n1) &&
+ d2.containsTIFFField(n2) &&
+ !d2.containsTIFFField(n3), "invalid containsTIFFField() results");
+ check(d2.getTIFFField(n2).getCount() == 1, "invalid TIFFField count");
+ check(d2.getTIFFField(n2).getAsInt(0) == v, "invalid TIFFField value");
+
+ check((d2.getParentTag().getNumber() == n0) &&
+ d2.getParentTag().getName().equals(Integer.toString(n0)),
+ "invalid parent tag");
+ }
+
+ public static void main(String[] args) { (new TIFFDirectoryTest()).run(); }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/imageio/plugins/tiff/TIFFDirectoryWriteReadTest.java Tue Apr 19 09:21:45 2016 -0700
@@ -0,0 +1,256 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * 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 8149028
+ * @author a.stepanov
+ * @summary a simple write-read test for TIFFDirectory
+ * @run main TIFFDirectoryWriteReadTest
+ */
+
+import java.awt.*;
+import java.awt.color.*;
+import java.awt.image.BufferedImage;
+import java.io.*;
+import javax.imageio.*;
+import javax.imageio.metadata.*;
+import javax.imageio.stream.*;
+import javax.imageio.plugins.tiff.*;
+
+
+public class TIFFDirectoryWriteReadTest {
+
+ private final static String FILENAME = "test.tiff";
+ private final static int SZ = 100;
+ private final static Color C = Color.RED;
+
+ private static final String COPYRIGHT[] = {"Copyright 123ABC.."};
+ private static final String DESCRIPTION[] = {"Test Image", "Description"};
+ private static final String SOFTWARE[] = {"test", "software", "123"};
+
+ private static final long RES_X[][] = {{2, 1}}, RES_Y[][] = {{1, 1}};
+
+ private static final byte[] ICC_PROFILE =
+ ICC_ProfileRGB.getInstance(ColorSpace.CS_sRGB).getData();
+
+
+ private ImageWriter getTIFFWriter() {
+
+ java.util.Iterator<ImageWriter> writers =
+ ImageIO.getImageWritersByFormatName("TIFF");
+ if (!writers.hasNext()) {
+ throw new RuntimeException("No writers available for TIFF format");
+ }
+ return writers.next();
+ }
+
+ private ImageReader getTIFFReader() {
+
+ java.util.Iterator<ImageReader> readers =
+ ImageIO.getImageReadersByFormatName("TIFF");
+ if (!readers.hasNext()) {
+ throw new RuntimeException("No readers available for TIFF format");
+ }
+ return readers.next();
+ }
+
+ private void addASCIIField(TIFFDirectory d,
+ String name,
+ String data[],
+ int num) {
+
+ d.addTIFFField(new TIFFField(
+ new TIFFTag(name, num, 1 << TIFFTag.TIFF_ASCII),
+ TIFFTag.TIFF_ASCII, data.length, data));
+ }
+
+ private void checkASCIIField(TIFFDirectory d,
+ String what,
+ String data[],
+ int num) {
+
+ String notFound = what + " field was not found";
+ check(d.containsTIFFField(num), notFound);
+ TIFFField f = d.getTIFFField(num);
+ check(f.getType() == TIFFTag.TIFF_ASCII, "field type != ASCII");
+ check(f.getCount() == data.length, "invalid " + what + " data count");
+ for (int i = 0; i < data.length; i++) {
+ check(f.getValueAsString(i).equals(data[i]),
+ "invalid " + what + " data");
+ }
+ }
+
+ private void writeImage() throws Exception {
+
+ OutputStream s = new BufferedOutputStream(new FileOutputStream(FILENAME));
+ try (ImageOutputStream ios = ImageIO.createImageOutputStream(s)) {
+
+ ImageWriter writer = getTIFFWriter();
+ writer.setOutput(ios);
+
+ BufferedImage img = new BufferedImage(
+ SZ, SZ, BufferedImage.TYPE_INT_RGB);
+ Graphics g = img.getGraphics();
+ g.setColor(C);
+ g.fillRect(0, 0, SZ, SZ);
+ g.dispose();
+
+ IIOMetadata metadata = writer.getDefaultImageMetadata(
+ new ImageTypeSpecifier(img), writer.getDefaultWriteParam());
+
+ TIFFDirectory dir = TIFFDirectory.createFromMetadata(metadata);
+
+ addASCIIField(dir, "Copyright",
+ COPYRIGHT, BaselineTIFFTagSet.TAG_COPYRIGHT);
+
+ addASCIIField(dir, "ImageDescription",
+ DESCRIPTION, BaselineTIFFTagSet.TAG_IMAGE_DESCRIPTION);
+
+ addASCIIField(dir, "Software",
+ SOFTWARE, BaselineTIFFTagSet.TAG_SOFTWARE);
+
+ dir.addTIFFField(new TIFFField(
+ new TIFFTag("XResolution", BaselineTIFFTagSet.TAG_X_RESOLUTION,
+ 1 << TIFFTag.TIFF_RATIONAL), TIFFTag.TIFF_RATIONAL, 1, RES_X));
+ dir.addTIFFField(new TIFFField(
+ new TIFFTag("YResolution", BaselineTIFFTagSet.TAG_Y_RESOLUTION,
+ 1 << TIFFTag.TIFF_RATIONAL), TIFFTag.TIFF_RATIONAL, 1, RES_Y));
+
+ dir.addTIFFField(new TIFFField(
+ new TIFFTag("ICC Profile", BaselineTIFFTagSet.TAG_ICC_PROFILE,
+ 1 << TIFFTag.TIFF_UNDEFINED),
+ TIFFTag.TIFF_UNDEFINED, ICC_PROFILE.length, ICC_PROFILE));
+
+ IIOMetadata data = dir.getAsMetadata();
+ writer.write(new IIOImage(img, null, data));
+
+ ios.flush();
+ writer.dispose();
+ }
+ s.close();
+ }
+
+
+
+ private void readAndCheckImage() throws Exception {
+
+ ImageReader reader = getTIFFReader();
+
+ ImageInputStream s = ImageIO.createImageInputStream(new File(FILENAME));
+ reader.setInput(s);
+
+ int ni = reader.getNumImages(true);
+ check(ni == 1, "invalid number of images");
+
+ // check image
+ BufferedImage img = reader.read(0);
+ check(img.getWidth() == SZ && img.getHeight() == SZ,
+ "invalid image size");
+
+ Color c = new Color(img.getRGB(SZ / 2, SZ / 2));
+ check(C.equals(c), "invalid image color");
+
+ IIOMetadata metadata = reader.readAll(0, null).getMetadata();
+ TIFFDirectory dir = TIFFDirectory.createFromMetadata(metadata);
+
+ reader.dispose();
+ s.close();
+
+ // ===== perform tag checks =====
+
+ checkASCIIField(dir, "copyright", COPYRIGHT,
+ BaselineTIFFTagSet.TAG_COPYRIGHT);
+
+ checkASCIIField(dir, "description", DESCRIPTION,
+ BaselineTIFFTagSet.TAG_IMAGE_DESCRIPTION);
+
+ checkASCIIField(dir, "software", SOFTWARE,
+ BaselineTIFFTagSet.TAG_SOFTWARE);
+
+ TIFFField f = dir.getTIFFField(BaselineTIFFTagSet.TAG_IMAGE_WIDTH);
+ check(f.getCount() == 1, "invalid width field count");
+ int w = f.getAsInt(0);
+ check(w == SZ, "invalid width");
+
+ f = dir.getTIFFField(BaselineTIFFTagSet.TAG_IMAGE_LENGTH);
+ check(f.getCount() == 1, "invalid height field count");
+ int h = f.getAsInt(0);
+ check(h == SZ, "invalid height");
+
+ f = dir.getTIFFField(BaselineTIFFTagSet.TAG_BITS_PER_SAMPLE);
+ // RGB: 3 x 8 bits for R, G and B components
+ int bps[] = f.getAsInts();
+ check((f.getCount() == 3) && (bps.length == 3), "invalid BPS count");
+ for (int b: bps) { check(b == 8, "invalid bits per sample"); }
+
+ // RGB: PhotometricInterpretation = 2
+ f = dir.getTIFFField(BaselineTIFFTagSet.TAG_PHOTOMETRIC_INTERPRETATION);
+ check(f.getCount() == 1, "invalid count");
+ check(f.getAsInt(0) == BaselineTIFFTagSet.PHOTOMETRIC_INTERPRETATION_RGB,
+ "invalid photometric interpretation value");
+
+ String rat = " resolution must be rational";
+ f = dir.getTIFFField(BaselineTIFFTagSet.TAG_X_RESOLUTION);
+ check(f.getType() == TIFFTag.TIFF_RATIONAL, "x" + rat);
+ check(f.getCount() == 1 &&
+ f.getAsInt(0) == (int) (RES_X[0][0] / RES_X[0][1]),
+ "invalid x resolution");
+
+ f = dir.getTIFFField(BaselineTIFFTagSet.TAG_Y_RESOLUTION);
+ check(f.getType() == TIFFTag.TIFF_RATIONAL, "y" + rat);
+ check(f.getCount() == 1 &&
+ f.getAsInt(0) == (int) (RES_Y[0][0] / RES_Y[0][1]),
+ "invalid y resolution");
+
+ f = dir.getTIFFField(BaselineTIFFTagSet.TAG_ICC_PROFILE);
+ check(f.getType() == TIFFTag.TIFF_UNDEFINED,
+ "invalid ICC profile field type");
+ int cnt = f.getCount();
+ byte icc[] = f.getAsBytes();
+ check((cnt == ICC_PROFILE.length) && (cnt == icc.length),
+ "invalid ICC profile");
+ for (int i = 0; i < cnt; i++) {
+ check(icc[i] == ICC_PROFILE[i], "invalid ICC profile");
+ }
+ }
+
+ public void run() {
+
+ try {
+ writeImage();
+ readAndCheckImage();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+
+ }
+
+ private void check(boolean ok, String msg) {
+ if (!ok) { throw new RuntimeException(msg); }
+ }
+
+ public static void main(String[] args) {
+ (new TIFFDirectoryWriteReadTest()).run();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/imageio/plugins/tiff/TIFFFieldTest.java Tue Apr 19 09:21:45 2016 -0700
@@ -0,0 +1,502 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * 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 8152183
+ * @author a.stepanov
+ * @summary Some checks for TIFFField methods
+ * @run main TIFFFieldTest
+ */
+
+import java.util.List;
+import java.util.ArrayList;
+import javax.imageio.metadata.IIOMetadataNode;
+import javax.imageio.plugins.tiff.*;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+
+public class TIFFFieldTest {
+
+ private final static String NAME = "tag"; // tag name
+ private final static int NUM = 12345; // tag number
+ private final static int MIN_TYPE = TIFFTag.MIN_DATATYPE;
+ private final static int MAX_TYPE = TIFFTag.MAX_DATATYPE;
+ private final static String CONSTRUCT = "can construct TIFFField with ";
+
+ private void check(boolean ok, String msg) {
+ if (!ok) { throw new RuntimeException(msg); }
+ }
+
+ private void testConstructors() {
+
+ // test constructors
+
+ TIFFTag tag = new TIFFTag(
+ NAME, NUM, 1 << TIFFTag.TIFF_SHORT | 1 << TIFFTag.TIFF_LONG);
+ TIFFField f;
+
+ // constructor: TIFFField(tag, value)
+ boolean ok = false;
+ try { new TIFFField(null, 0); }
+ catch (NullPointerException e) { ok = true; }
+ check(ok, CONSTRUCT + "null tag");
+
+ ok = false;
+ try { new TIFFField(tag, -1); }
+ catch (IllegalArgumentException e) { ok = true; }
+ check(ok, CONSTRUCT + "invalid count");
+
+ // check value type recognition
+ int v = 1 << 16;
+ f = new TIFFField(tag, v - 1);
+ check(f.getType() == TIFFTag.TIFF_SHORT, "must be treated as short");
+ check(f.isIntegral(), "must be integral");
+ f = new TIFFField(tag, v);
+ check(f.getType() == TIFFTag.TIFF_LONG, "must be treated as long");
+
+ // other checks
+ check(f.getAsLongs().length == 1, "invalid long[] size");
+ check(f.isIntegral(), "must be integral");
+ check((f.getDirectory() == null) && !f.hasDirectory(),
+ "must not have directory");
+ check(f.getValueAsString(0).equals(String.valueOf(v)),
+ "invalid string representation of value");
+ check(f.getTag().getNumber() == f.getTagNumber(),
+ "invalid tag number");
+ check(f.getCount() == 1, "invalid count");
+ check(f.getTagNumber() == NUM, "invalid tag number");
+
+ // constructor: TIFFField(tag, type, count)
+ int type = TIFFTag.TIFF_SHORT;
+
+ ok = false;
+ try { new TIFFField(null, type, 1); }
+ catch (NullPointerException e) { ok = true; }
+ check(ok, CONSTRUCT + "null tag");
+
+ ok = false;
+ try { new TIFFField(tag, MAX_TYPE + 1, 1); }
+ catch (IllegalArgumentException e) { ok = true; }
+ check(ok, CONSTRUCT + "invalid type tag");
+
+ // check that count == 1 for TIFF_IFD_POINTER
+ ok = false;
+ try { new TIFFField(tag, TIFFTag.TIFF_IFD_POINTER, 0); }
+ catch (IllegalArgumentException e) { ok = true; }
+ check(ok, "only count = 1 should be allowed for IFDPointer");
+
+ ok = false;
+ try { new TIFFField(tag, TIFFTag.TIFF_IFD_POINTER, 2); }
+ catch (IllegalArgumentException e) { ok = true; }
+ check(ok, "only count = 1 should be allowed for IFDPointer");
+
+ // check that count == 0 is not allowed for TIFF_RATIONAL, TIFF_SRATIONAL
+ // (see fix for JDK-8149120)
+ ok = false;
+ try { new TIFFField(tag, TIFFTag.TIFF_RATIONAL, 0); }
+ catch (IllegalArgumentException e) { ok = true; }
+ check(ok, "count = 0 should not be allowed for Rational");
+
+ ok = false;
+ try { new TIFFField(tag, TIFFTag.TIFF_SRATIONAL, 0); }
+ catch (IllegalArgumentException e) { ok = true; }
+ check(ok, "count = 0 should not be allowed for SRational");
+
+ ok = false;
+ try { new TIFFField(tag, type, -1); }
+ catch (IllegalArgumentException e) { ok = true; }
+ check(ok, CONSTRUCT + "with invalid data count");
+
+ f = new TIFFField(tag, type, 0);
+ check(f.getCount() == 0, "invalid count");
+ check(!f.hasDirectory(), "must not have directory");
+
+ // constructor: TIFFField(tag, type, count, data)
+ double a[] = {0.1, 0.2, 0.3};
+ ok = false;
+ try { new TIFFField(null, TIFFTag.TIFF_DOUBLE, a.length, a); }
+ catch (NullPointerException e) { ok = true; }
+ check(ok, CONSTRUCT + "null tag");
+
+ ok = false;
+ try { new TIFFField(tag, type, a.length - 1, a); }
+ catch (IllegalArgumentException e) { ok = true; }
+ check(ok, CONSTRUCT + "invalid data count");
+
+ String a2[] = {"one", "two"};
+ ok = false;
+ try { new TIFFField(tag, type, 2, a2); }
+ catch (IllegalArgumentException e) { ok = true; }
+ check(ok, CONSTRUCT + "invalid data type");
+ check((f.getDirectory() == null) && !f.hasDirectory(),
+ "must not have directory");
+
+ // constructor: TIFFField(tag, type, offset, dir)
+ List<TIFFTag> tags = new ArrayList<>();
+ tags.add(tag);
+ TIFFTagSet sets[] = {new TIFFTagSet(tags)};
+ TIFFDirectory dir = new TIFFDirectory(sets, null);
+
+ ok = false;
+ try { new TIFFField(null, type, 4L, dir); }
+ catch (NullPointerException e) { ok = true; }
+ check(ok, CONSTRUCT + "null tag");
+
+ ok = false;
+ try { new TIFFField(tag, type, 0L, dir); }
+ catch (IllegalArgumentException e) { ok = true; }
+ check(ok, CONSTRUCT + "non-positive offset");
+
+ long offset = 4;
+
+ for (int t = MIN_TYPE; t <= MAX_TYPE; t++) {
+
+ tag = new TIFFTag(NAME, NUM, 1 << t);
+
+ // only TIFF_LONG and TIFF_IFD_POINTER types are allowed
+ if (t == TIFFTag.TIFF_LONG || t == TIFFTag.TIFF_IFD_POINTER) {
+
+ f = new TIFFField(tag, t, offset, dir);
+ check(f.hasDirectory(), "must have directory");
+
+ check(f.getDirectory().getTag(NUM).getName().equals(NAME),
+ "invalid tag name");
+
+ check(f.getCount() == 1, "invalid count");
+ check(f.getAsLong(0) == offset, "invalid offset");
+ } else {
+ ok = false;
+ try { new TIFFField(tag, t, offset, dir); }
+ catch (IllegalArgumentException e) { ok = true; }
+ check(ok, CONSTRUCT + "invalid data type");
+ }
+ }
+
+ type = TIFFTag.TIFF_IFD_POINTER;
+ tag = new TIFFTag(NAME, NUM, 1 << type);
+ ok = false;
+ try { new TIFFField(tag, type, offset, null); }
+ catch (NullPointerException e) { ok = true; }
+ check(ok, CONSTRUCT + "null TIFFDirectory");
+
+ type = TIFFTag.TIFF_LONG;
+ tag = new TIFFTag(NAME, NUM, 1 << type);
+ ok = false;
+ try { new TIFFField(tag, type, offset, null); }
+ catch (NullPointerException e) { ok = true; }
+ check(ok, CONSTRUCT + "null TIFFDirectory");
+ }
+
+ private void testTypes() {
+
+ // test getTypeName(), getTypeByName() methods
+
+ boolean ok = false;
+ try { TIFFField.getTypeName(MIN_TYPE - 1); }
+ catch (IllegalArgumentException e) { ok = true; }
+ check(ok, "invalid data type number used");
+
+ ok = false;
+ try { TIFFField.getTypeName(MAX_TYPE + 1); }
+ catch (IllegalArgumentException e) { ok = true; }
+ check(ok, "invalid data type number used");
+
+ for (int type = MIN_TYPE; type <= MAX_TYPE; type++) {
+ String name = TIFFField.getTypeName(type);
+ check(TIFFField.getTypeByName(name) == type, "invalid type");
+ }
+
+ for (int type = MIN_TYPE; type <= MAX_TYPE; type++) {
+
+ TIFFTag tag = new TIFFTag(NAME, NUM, 1 << type);
+ TIFFField f = new TIFFField(tag, type, 1);
+ check(f.getType() == type, "invalid type");
+
+ // check that invalid data types can not be used
+ for (int type2 = MIN_TYPE; type2 <= MAX_TYPE; ++type2) {
+ if (type2 != type) {
+ ok = false;
+ try { new TIFFField(tag, type2, 1); } // invalid type
+ catch (IllegalArgumentException e) { ok = true; }
+ check(ok, "invalid type was successfully set");
+ }
+ }
+ }
+ }
+
+ private void testGetAs() {
+
+ // test getAs...() methods
+
+ int type = TIFFTag.TIFF_SHORT;
+ TIFFTag tag = new TIFFTag(NAME, NUM, 1 << TIFFTag.TIFF_SHORT);
+
+ short v = 123;
+ TIFFField f = new TIFFField(tag, v);
+
+ check(f.getAsInt(0) == (int) v, "invalid int value");
+ check(f.getAsLong(0) == (long) v, "invalid long value");
+ check(f.getAsFloat(0) == (float) v, "invalid float value");
+ check(f.getAsDouble(0) == (double) v, "invalid double value");
+ check(f.getValueAsString(0).equals(Short.toString(v)),
+ "invalid string representation");
+
+ check(f.getAsInts().length == 1, "inavlid array size");
+ check((int) v == f.getAsInts()[0], "invalid int value");
+
+ float fa[] = {0.01f, 1.01f};
+ type = TIFFTag.TIFF_FLOAT;
+ f = new TIFFField(
+ new TIFFTag(NAME, NUM, 1 << type), type, fa.length, fa);
+ check(f.getCount() == fa.length, "invalid count");
+ float fa2[] = f.getAsFloats();
+ check(fa2.length == fa.length, "invalid array size");
+
+ for (int i = 0; i < fa.length; i++) {
+ check(fa2[i] == fa[i], "invalid value");
+ check(f.getAsDouble(i) == fa[i], "invalid value");
+ check(f.getAsInt(i) == (int) fa[i], "invalid value"); // cast to int
+ check(f.getValueAsString(i).equals(Float.toString(fa[i])),
+ "invalid string representation");
+ }
+
+ byte ba[] = {-1, -10, -100};
+ type = TIFFTag.TIFF_BYTE;
+ f = new TIFFField(
+ new TIFFTag(NAME, NUM, 1 << type), type, ba.length, ba);
+ check(f.getCount() == ba.length, "invalid count");
+ byte ba2[] = f.getAsBytes();
+ check(ba2.length == ba.length, "invalid count");
+
+ for (int i = 0; i < ba.length; i++) {
+ check(ba[i] == ba2[i], "invalid value");
+ check(ba[i] == (byte) f.getAsDouble(i), "invalid value");
+ check(ba[i] == (byte) f.getAsLong(i), "invalid value");
+
+ int unsigned = ba[i] & 0xff;
+ check(f.getAsInt(i) == unsigned, "must be treated as unsigned");
+ }
+
+ char ca[] = {'a', 'z', 0xffff};
+ type = TIFFTag.TIFF_SHORT;
+ f = new TIFFField(
+ new TIFFTag(NAME, NUM, 1 << type), type, ca.length, ca);
+ check(f.getCount() == ca.length, "invalid count");
+ char ca2[] = f.getAsChars();
+ check(ba2.length == ba.length, "invalid count");
+
+ for (int i = 0; i < ca.length; i++) {
+ check(ca[i] == ca2[i], "invalid value");
+ check(ca[i] == (char) f.getAsDouble(i), "invalid value");
+ check(ca[i] == (char) f.getAsLong(i), "invalid value");
+ check(ca[i] == (char) f.getAsInt(i), "invalid value");
+ }
+
+ type = TIFFTag.TIFF_DOUBLE;
+ double da[] = {0.1, 0.2, 0.3};
+ f = new TIFFField(
+ new TIFFTag(NAME, NUM, 1 << type), type, da.length, da);
+ check(!f.isIntegral(), "isIntegral must be false");
+
+ double da2[] = f.getAsDoubles();
+ check(f.getData() instanceof double[], "invalid data type");
+ double da3[] = (double[]) f.getData();
+ check((da.length == da2.length) &&
+ (da.length == da2.length) &&
+ (da.length == f.getCount()),
+ "invalid data count");
+ for (int i = 0; i < da.length; ++i) {
+ check(da[i] == da2[i], "invalid data");
+ check(da[i] == da3[i], "invalid data");
+ }
+
+ boolean ok = false;
+ try { f.getAsShorts(); }
+ catch (ClassCastException e) { ok = true; }
+ check(ok, "invalid data cast");
+
+ ok = false;
+ try { f.getAsRationals(); }
+ catch (ClassCastException e) { ok = true; }
+ check(ok, "invalid data cast");
+
+ ok = false;
+ try { TIFFField.createArrayForType(TIFFTag.MIN_DATATYPE - 1, 1); }
+ catch (IllegalArgumentException e) { ok = true; }
+ check(ok, "can create array with invalid datatype");
+
+ ok = false;
+ try { TIFFField.createArrayForType(TIFFTag.MAX_DATATYPE + 1, 1); }
+ catch (IllegalArgumentException e) { ok = true; }
+ check(ok, "can create array with invalid datatype");
+
+ ok = false;
+ try { TIFFField.createArrayForType(TIFFTag.TIFF_FLOAT, -1); }
+ catch (IllegalArgumentException e) { ok = true; }
+ check(ok, "can create array with negative count");
+
+ int n = 3;
+ Object
+ RA = TIFFField.createArrayForType(TIFFTag.TIFF_RATIONAL, n),
+ SRA = TIFFField.createArrayForType(TIFFTag.TIFF_SRATIONAL, n);
+ check(RA instanceof long[][], "invalid data type");
+ check(SRA instanceof int[][], "invalid data type");
+
+ long ra[][] = (long[][]) RA;
+ int sra[][] = (int[][]) SRA;
+ check((ra.length == n) && (sra.length == n), "invalid data size");
+ for (int i = 0; i < n; i++) {
+ check((ra[i].length == 2) && (sra[i].length == 2),
+ "invalid data size");
+ ra[i][0] = 1; ra[i][1] = 5 + i;
+ sra[i][0] = -1; sra[i][1] = 5 + i;
+ }
+
+ type = TIFFTag.TIFF_RATIONAL;
+ TIFFField f1 = new TIFFField(
+ new TIFFTag(NAME, NUM, 1 << type), type, n, ra);
+ type = TIFFTag.TIFF_SRATIONAL;
+ TIFFField f2 = new TIFFField(
+ new TIFFTag(NAME, NUM, 1 << type), type, n, sra);
+
+ check((f1.getCount() == ra.length) && (f2.getCount() == sra.length),
+ "invalid data count");
+
+ check(f1.getAsRationals().length == n, "invalid data count");
+ check(f2.getAsSRationals().length == n, "invalid data count");
+ for (int i = 0; i < n; i++) {
+ long r[] = f1.getAsRational(i);
+ check(r.length == 2, "invalid data format");
+ check((r[0] == 1) && (r[1] == i + 5), "invalid data");
+
+ int sr[] = f2.getAsSRational(i);
+ check(sr.length == 2, "invalid data format");
+ check((sr[0] == -1) && (sr[1] == i + 5), "invalid data");
+
+ // check string representation
+ String s = Long.toString(r[0]) + "/" + Long.toString(r[1]);
+ check(s.equals(f1.getValueAsString(i)),
+ "invalid string representation");
+
+ s = Integer.toString(sr[0]) + "/" + Integer.toString(sr[1]);
+ check(s.equals(f2.getValueAsString(i)),
+ "invalid string representation");
+
+ // see the documentation for getAsInt:
+ // TIFF_SRATIONAL or TIFF_RATIONAL format are evaluated
+ // by dividing the numerator into the denominator using
+ // double-precision arithmetic and then casting to int
+ check(f1.getAsInt(i) == (int)(r[0] / r[1]),
+ "invalid result for getAsInt");
+ check(f2.getAsInt(i) == (int)(r[0] / r[1]),
+ "invalid result for getAsInt");
+ }
+
+ ok = false;
+ try { f1.getAsRational(ra.length); }
+ catch (ArrayIndexOutOfBoundsException e) { ok = true; }
+ check(ok, "invalid index");
+
+ String sa[] = {"-1.e-25", "22", "-1.23E5"};
+ type = TIFFTag.TIFF_ASCII;
+ f = new TIFFField(
+ new TIFFTag(NAME, NUM, 1 << type), type, sa.length, sa);
+
+ // test clone() method
+ TIFFField cloned = null;
+ try { cloned = f.clone(); } catch (CloneNotSupportedException e) {
+ throw new RuntimeException(e);
+ }
+
+ check(f.getCount() == cloned.getCount(), "invalid cloned field count");
+
+ check(f.getCount() == sa.length, "invalid data count");
+ for (int i = 0; i < sa.length; i++) {
+ check(sa[i].equals(f.getAsString(i)), "invalid data");
+ // see docs: "data in TIFF_ASCII format will be parsed as by
+ // the Double.parseDouble method, with the result cast to int"
+ check(f.getAsInt(i) ==
+ (int) Double.parseDouble(sa[i]), "invalid data");
+ check(f.getAsDouble(i) == Double.parseDouble(sa[i]), "invalid data");
+
+ check(sa[i].equals(cloned.getAsString(i)), "invalid cloned data");
+ }
+ }
+
+ private void testCreateFromNode() {
+
+ int type = TIFFTag.TIFF_LONG;
+
+ List<TIFFTag> tags = new ArrayList<>();
+ int v = 1234567;
+ TIFFTag tag = new TIFFTag(NAME, NUM, 1 << type);
+ tags.add(tag);
+ TIFFTagSet ts = new TIFFTagSet(tags);
+
+ boolean ok = false;
+ try { TIFFField.createFromMetadataNode(ts, null); }
+ catch (NullPointerException e) { ok = true; }
+ check(ok, "can create TIFFField from a null node");
+
+ TIFFField f = new TIFFField(tag, v);
+ Node node = f.getAsNativeNode();
+ check(node.getNodeName().equals(f.getClass().getSimpleName()),
+ "invalid node name");
+
+ NamedNodeMap attrs = node.getAttributes();
+ for (int i = 0; i < attrs.getLength(); i++) {
+ String an = attrs.item(i).getNodeName().toLowerCase();
+ String av = attrs.item(i).getNodeValue();
+ if (an.contains("name")) {
+ check(av.equals(NAME), "invalid tag name");
+ } else if (an.contains("number")) {
+ check(av.equals(Integer.toString(NUM)), "invalid tag number");
+ }
+ }
+
+ // invalid node
+ IIOMetadataNode nok = new IIOMetadataNode("NOK");
+
+ ok = false;
+ try { TIFFField.createFromMetadataNode(ts, nok); }
+ catch (IllegalArgumentException e) { ok = true; }
+ check(ok, CONSTRUCT + "invalid node name");
+
+ TIFFField f2 = TIFFField.createFromMetadataNode(ts, node);
+ check(f2.getType() == type, "invalid type");
+ check(f2.getTagNumber() == NUM, "invalid tag number");
+ check(f2.getTag().getName().equals(NAME), "invalid tag name");
+ check(f2.getCount() == 1, "invalid count");
+ check(f2.getAsInt(0) == v, "invalid value");
+ }
+
+ public static void main(String[] args) {
+
+ TIFFFieldTest test = new TIFFFieldTest();
+ test.testConstructors();
+ test.testCreateFromNode();
+ test.testTypes();
+ test.testGetAs();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/imageio/plugins/tiff/TIFFImageReadParamTest.java Tue Apr 19 09:21:45 2016 -0700
@@ -0,0 +1,275 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * 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 8149028
+ * @author a.stepanov
+ * @summary check TIFFDirectory manipulation
+ * by means of TIFFImageReadParam
+ * @run main TIFFImageReadParamTest
+ */
+
+
+import java.awt.Color;
+import java.awt.Graphics;
+import java.awt.image.BufferedImage;
+import java.io.*;
+import javax.imageio.*;
+import javax.imageio.metadata.IIOMetadata;
+import javax.imageio.plugins.tiff.*;
+import javax.imageio.stream.ImageInputStream;
+import javax.imageio.stream.ImageOutputStream;
+
+public class TIFFImageReadParamTest {
+
+ private final static String FILENAME = "test.tiff";
+ private final static int SZ = 100;
+ private final static Color C = Color.RED;
+
+ private final static String GEO_DATA = "test params";
+ private final static int GEO_N = GeoTIFFTagSet.TAG_GEO_ASCII_PARAMS;
+
+ private final static String EXIF_DATA = "2000:01:01 00:00:01";
+ private final static int EXIF_N = ExifTIFFTagSet.TAG_DATE_TIME_ORIGINAL;
+
+ private final static String GPS_DATA =
+ ExifGPSTagSet.STATUS_MEASUREMENT_IN_PROGRESS;
+ private final static int GPS_N = ExifGPSTagSet.TAG_GPS_STATUS;
+
+ private final static short FAX_DATA =
+ FaxTIFFTagSet.CLEAN_FAX_DATA_ERRORS_UNCORRECTED;
+ private final static int FAX_N = FaxTIFFTagSet.TAG_CLEAN_FAX_DATA;
+
+ private ImageWriter getTIFFWriter() {
+
+ java.util.Iterator<ImageWriter> writers =
+ ImageIO.getImageWritersByFormatName("TIFF");
+ if (!writers.hasNext()) {
+ throw new RuntimeException("No writers available for TIFF format");
+ }
+ return writers.next();
+ }
+
+ private ImageReader getTIFFReader() {
+
+ java.util.Iterator<ImageReader> readers =
+ ImageIO.getImageReadersByFormatName("TIFF");
+ if (!readers.hasNext()) {
+ throw new RuntimeException("No readers available for TIFF format");
+ }
+ return readers.next();
+ }
+
+ private void check(boolean ok, String msg) {
+ if (!ok) { throw new RuntimeException(msg); }
+ }
+
+ private void addASCIIField(TIFFDirectory d,
+ String name,
+ String data,
+ int num) {
+
+ String a[] = {data};
+ d.addTIFFField(new TIFFField(
+ new TIFFTag(name, num, 1 << TIFFTag.TIFF_ASCII),
+ TIFFTag.TIFF_ASCII, 1, a));
+ }
+
+ private void checkASCIIValue(TIFFDirectory d,
+ String what,
+ String data,
+ int num) {
+
+ TIFFField f = d.getTIFFField(num);
+ check(f.getType() == TIFFTag.TIFF_ASCII, "field type != ASCII");
+ check(f.getCount() == 1, "invalid " + what + " data count");
+ check(f.getValueAsString(0).equals(data),
+ "invalid " + what + " data");
+ }
+
+
+ private void writeImage() throws Exception {
+
+ OutputStream s = new BufferedOutputStream(new FileOutputStream(FILENAME));
+ try (ImageOutputStream ios = ImageIO.createImageOutputStream(s)) {
+ ImageWriter writer = getTIFFWriter();
+ writer.setOutput(ios);
+
+ BufferedImage img =
+ new BufferedImage(SZ, SZ, BufferedImage.TYPE_INT_RGB);
+ Graphics g = img.getGraphics();
+ g.setColor(C);
+ g.fillRect(0, 0, SZ, SZ);
+ g.dispose();
+
+ IIOMetadata metadata = writer.getDefaultImageMetadata(
+ new ImageTypeSpecifier(img), writer.getDefaultWriteParam());
+
+ TIFFDirectory dir = TIFFDirectory.createFromMetadata(metadata);
+
+ // add some extension tags
+ addASCIIField(dir, "GeoAsciiParamsTag", GEO_DATA, GEO_N);
+ addASCIIField(dir, "DateTimeOriginal", EXIF_DATA, EXIF_N);
+ addASCIIField(dir, "GPSStatus", GPS_DATA, GPS_N);
+
+ dir.addTIFFField(new TIFFField(new TIFFTag(
+ "CleanFaxData", FAX_N, 1 << TIFFTag.TIFF_SHORT), FAX_DATA));
+
+ IIOMetadata data = dir.getAsMetadata();
+
+ writer.write(new IIOImage(img, null, data));
+
+ ios.flush();
+ writer.dispose();
+ }
+ }
+
+ private void checkImage(BufferedImage img) {
+
+ check(img.getWidth() == SZ, "invalid image width");
+ check(img.getHeight() == SZ, "invalid image height");
+ Color c = new Color(img.getRGB(SZ / 2, SZ / 2));
+ check(c.equals(C), "invalid image color");
+ }
+
+ private TIFFDirectory getDir(TIFFTagSet[] add,
+ TIFFTagSet[] remove) throws Exception {
+
+ ImageReader reader = getTIFFReader();
+
+ ImageInputStream s = ImageIO.createImageInputStream(new File(FILENAME));
+ reader.setInput(s, false, true);
+
+ int ni = reader.getNumImages(true);
+ check(ni == 1, "invalid number of images: " + ni);
+
+ TIFFImageReadParam param = new TIFFImageReadParam();
+ for (TIFFTagSet ts: add) { param.addAllowedTagSet(ts); }
+ for (TIFFTagSet ts: remove) { param.removeAllowedTagSet(ts); }
+
+ IIOImage img = reader.readAll(0, param);
+
+ // just in case, check image
+ checkImage((BufferedImage) img.getRenderedImage());
+
+ IIOMetadata metadata = img.getMetadata();
+ TIFFDirectory dir = TIFFDirectory.createFromMetadata(metadata);
+
+ reader.dispose();
+ s.close();
+
+ return dir;
+ }
+
+ private void simpleChecks() {
+
+ TIFFImageReadParam param = new TIFFImageReadParam();
+
+ java.util.List<TIFFTagSet> allowed = param.getAllowedTagSets();
+
+ // see docs
+ check(allowed.contains(BaselineTIFFTagSet.getInstance()),
+ "must contain BaselineTIFFTagSet");
+ check(allowed.contains(FaxTIFFTagSet.getInstance()),
+ "must contain FaxTIFFTagSet");
+ check(allowed.contains(ExifParentTIFFTagSet.getInstance()),
+ "must contain ExifParentTIFFTagSet");
+ check(allowed.contains(GeoTIFFTagSet.getInstance()),
+ "must contain GeoTIFFTagSet");
+
+ TIFFTagSet gps = ExifGPSTagSet.getInstance();
+ param.addAllowedTagSet(gps);
+ check(param.getAllowedTagSets().contains(gps),
+ "must contain ExifGPSTagSet");
+
+ param.removeAllowedTagSet(gps);
+ check(!param.getAllowedTagSets().contains(gps),
+ "must not contain ExifGPSTagSet");
+
+ // check that repeating remove goes properly
+ param.removeAllowedTagSet(gps);
+
+ boolean ok = false;
+ try { param.addAllowedTagSet(null); }
+ catch (IllegalArgumentException e) { ok = true; }
+ check(ok, "must not be able to add null tag set");
+
+ ok = false;
+ try { param.removeAllowedTagSet(null); }
+ catch (IllegalArgumentException e) { ok = true; }
+ check(ok, "must not be able to remove null tag set");
+ }
+
+ private void run() {
+
+ simpleChecks();
+
+ try {
+
+ writeImage();
+
+ TIFFTagSet
+ empty[] = {},
+ geo[] = { GeoTIFFTagSet.getInstance() },
+ exif[] = { ExifTIFFTagSet.getInstance() },
+ gps[] = { ExifGPSTagSet.getInstance() },
+ fax[] = { FaxTIFFTagSet.getInstance() };
+
+ // default param state
+ TIFFDirectory dir = getDir(empty, empty);
+ // Geo and Fax are default allowed tag sets
+ check(dir.containsTIFFField(GEO_N), "must contain Geo field");
+ checkASCIIValue(dir, "Geo", GEO_DATA, GEO_N);
+ check(dir.containsTIFFField(FAX_N), "must contain Fax field");
+ check(
+ (dir.getTIFFField(FAX_N).getCount() == 1) &&
+ (dir.getTIFFField(FAX_N).getAsInt(0) == FAX_DATA),
+ "invalid Fax field value");
+
+ // corresponding tag sets are non-default
+ check(!dir.containsTIFFField(EXIF_N), "must not contain Geo field");
+ check(!dir.containsTIFFField(GPS_N), "must not contain GPS field");
+
+ // remove Fax
+ dir = getDir(empty, fax);
+ check(!dir.containsTIFFField(FAX_N), "must not contain Fax field");
+
+ // add EXIF, remove Geo
+ dir = getDir(exif, geo);
+ check(dir.containsTIFFField(EXIF_N), "must contain EXIF field");
+ checkASCIIValue(dir, "EXIF", EXIF_DATA, EXIF_N);
+ check(!dir.containsTIFFField(GEO_N), "must not contain Geo field");
+
+ // add GPS
+ dir = getDir(gps, empty);
+ check(dir.containsTIFFField(GPS_N), "must contain GPS field");
+ checkASCIIValue(dir, "GPS", GPS_DATA, GPS_N);
+
+ } catch (Exception e) { throw new RuntimeException(e); }
+ }
+
+ public static void main(String[] args) {
+ (new TIFFImageReadParamTest()).run();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/imageio/stream/NullStreamCheckTest.java Tue Apr 19 09:21:45 2016 -0700
@@ -0,0 +1,202 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * 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 8044289
+ * @summary Test verifies that when some of the read() and write() methods
+ * are not able to get stream from createImageInputStream() and
+ * createImageOutputStream() are we doing null check for stream
+ * and throwing IOException as per specification.
+ * @run main NullStreamCheckTest
+ */
+
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import javax.imageio.ImageIO;
+import javax.imageio.spi.IIORegistry;
+import javax.imageio.spi.ImageInputStreamSpi;
+import javax.imageio.spi.ImageOutputStreamSpi;
+
+public class NullStreamCheckTest {
+
+ // get ImageIORegistry default instance.
+ private static final IIORegistry localRegistry = IIORegistry.
+ getDefaultInstance();
+ // stream variables needed for input and output.
+ static LocalOutputStream outputStream = new LocalOutputStream();
+ static LocalInputStream inputStream = new LocalInputStream();
+
+ static final int width = 50, height = 50;
+
+ // input and output BufferedImage needed while read and write.
+ static BufferedImage inputImage = new BufferedImage(width, height,
+ BufferedImage.TYPE_INT_ARGB);
+
+ // creates test file needed for read and write in local directory.
+ private static File createTestFile(String name) throws IOException {
+ String sep = System.getProperty("file.separator");
+ String dir = System.getProperty("test.src", ".");
+ String filePath = dir+sep;
+ File directory = new File(filePath);
+ File tmpTestFile = File.createTempFile(name, ".png", directory);
+ directory.delete();
+ return tmpTestFile;
+ }
+
+ /* if we catch expected IOException message return
+ * false otherwise return true.
+ */
+ private static boolean verifyOutputExceptionMessage(IOException ex) {
+ String message = ex.getMessage();
+ return (!message.equals("Can't create an ImageOutputStream!"));
+ }
+
+ /* if we catch expected IOException message return
+ * false otherwise return true.
+ */
+ private static boolean verifyInputExceptionMessage(IOException ex) {
+ String message = ex.getMessage();
+ return (!message.equals("Can't create an ImageInputStream!"));
+ }
+
+ private static void verifyFileWrite() throws IOException {
+ File outputTestFile = createTestFile("outputTestFile");
+ try {
+ ImageIO.write(inputImage, "png", outputTestFile);
+ } catch (IOException ex) {
+ if (verifyOutputExceptionMessage(ex))
+ throw ex;
+ } finally {
+ outputTestFile.delete();
+ }
+ }
+
+ private static void verifyStreamWrite() throws IOException {
+ try {
+ ImageIO.write(inputImage, "png", outputStream);
+ } catch (IOException ex) {
+ if (verifyOutputExceptionMessage(ex))
+ throw ex;
+ } finally {
+ try {
+ outputStream.close();
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+ }
+
+ private static void verifyFileRead() throws IOException {
+ File inputTestFile = createTestFile("inputTestFile");
+ try {
+ ImageIO.read(inputTestFile);
+ } catch (IOException ex) {
+ if (verifyInputExceptionMessage(ex))
+ throw ex;
+ } finally {
+ inputTestFile.delete();
+ }
+ }
+
+ private static void verifyStreamRead() throws IOException {
+ try {
+ ImageIO.read(inputStream);
+ } catch (IOException ex) {
+ if (verifyInputExceptionMessage(ex))
+ throw ex;
+ } finally {
+ try {
+ inputStream.close();
+ } catch (IOException ex) {
+ throw ex;
+ }
+ }
+ }
+
+ private static void verifyUrlRead() throws IOException {
+ URL url;
+ File inputTestUrlFile = createTestFile("inputTestFile");
+ try {
+ try {
+ url = inputTestUrlFile.toURI().toURL();
+ } catch (MalformedURLException ex) {
+ throw ex;
+ }
+
+ try {
+ ImageIO.read(url);
+ } catch (IOException ex) {
+ if (verifyInputExceptionMessage(ex))
+ throw ex;
+ }
+ } finally {
+ inputTestUrlFile.delete();
+ }
+ }
+
+ public static void main(String[] args) throws IOException,
+ MalformedURLException {
+
+ /* deregister ImageOutputStreamSpi so that we creatImageOutputStream
+ * returns null while writing.
+ */
+ localRegistry.deregisterAll(ImageOutputStreamSpi.class);
+ /* verify possible ImageIO.write() scenario's for null stream output
+ * from createImageOutputStream() API in ImageIO class.
+ */
+ verifyFileWrite();
+ verifyStreamWrite();
+
+ /* deregister ImageInputStreamSpi so that we creatImageInputStream
+ * returns null while reading.
+ */
+ localRegistry.deregisterAll(ImageInputStreamSpi.class);
+ /* verify possible ImageIO.read() scenario's for null stream output
+ * from createImageInputStream API in ImageIO class.
+ */
+ verifyFileRead();
+ verifyStreamRead();
+ verifyUrlRead();
+ }
+
+ static class LocalOutputStream extends OutputStream {
+
+ @Override
+ public void write(int i) throws IOException {
+ }
+ }
+
+ static class LocalInputStream extends InputStream {
+
+ @Override
+ public int read() throws IOException {
+ return 0;
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/sound/midi/Gervill/AudioFloatConverter/Bits16ToFromFloatArray.java Tue Apr 19 09:21:45 2016 -0700
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * 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.util.Arrays;
+
+import javax.sound.sampled.AudioFormat;
+import javax.sound.sampled.AudioFormat.Encoding;
+
+import com.sun.media.sound.AudioFloatConverter;
+
+import static javax.sound.sampled.AudioFormat.Encoding.*;
+
+/**
+ * @test
+ * @bug 8152501
+ * @modules java.desktop/com.sun.media.sound
+ */
+public final class Bits16ToFromFloatArray {
+
+ private static final int SIZE = 16;
+
+ private static final float[] FLOATS = {-1.0f, 0, 1.0f};
+
+ private static short MID_U = (short) (Short.MAX_VALUE + 1);
+ private static short MAX_U = -1;
+
+ // BIG ENDIAN
+ private static final byte[] SIGNED_BIG = {
+ (byte) (Short.MIN_VALUE >> 8), (byte) (Short.MIN_VALUE & 0xff), 0,
+ 0, (byte) (Short.MAX_VALUE >> 8), (byte) (Short.MAX_VALUE & 0xff)
+ };
+
+ private static final byte[] UNSIGNED_BIG = {
+ 0, 0, (byte) (MID_U >> 8), (byte) (MID_U & 0xff),
+ (byte) (MAX_U >> 8), (byte) (MAX_U >> 8)
+ };
+
+ // LITTLE ENDIAN
+ private static final byte[] SIGNED_LITTLE = {
+ (byte) (Short.MIN_VALUE & 0xff), (byte) (Short.MIN_VALUE >> 8), 0,
+ 0, (byte) (Short.MAX_VALUE & 0xff), (byte) (Short.MAX_VALUE >> 8)
+ };
+
+ private static final byte[] UNSIGNED_LITTLE = {
+ 0, 0, (byte) (MID_U & 0xff), (byte) (MID_U >> 8),
+ (byte) (MAX_U >> 8), (byte) (MAX_U >> 8)
+ };
+
+ public static void main(final String[] args) {
+ test(PCM_UNSIGNED, UNSIGNED_BIG, true);
+ test(PCM_UNSIGNED, UNSIGNED_LITTLE, false);
+ test(PCM_SIGNED, SIGNED_LITTLE, false);
+ test(PCM_SIGNED, SIGNED_BIG, true);
+ }
+
+ private static void test(final Encoding enc, final byte[] expected,
+ boolean end) {
+ System.err.println("enc = " + enc);
+ AudioFormat af = new AudioFormat(enc, 44100, SIZE, 1, SIZE / 8, 44100,
+ end);
+ byte[] bytes = new byte[FLOATS.length * af.getFrameSize()];
+ AudioFloatConverter conv = AudioFloatConverter.getConverter(af);
+
+ conv.toByteArray(FLOATS, bytes);
+
+ if (!Arrays.equals(bytes, expected)) {
+ System.err.println("Actual: " + Arrays.toString(bytes));
+ System.err.println("Expected: " + Arrays.toString(expected));
+ throw new RuntimeException();
+ }
+
+ float[] floats = new float[bytes.length / af.getFrameSize()];
+ conv.toFloatArray(bytes, floats);
+
+ if (!Arrays.equals(floats, FLOATS)) {
+ System.err.println("Actual: " + Arrays.toString(floats));
+ System.err.println("Expected: " + Arrays.toString(FLOATS));
+ throw new RuntimeException();
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/sound/midi/Gervill/AudioFloatConverter/Bits24ToFromFloatArray.java Tue Apr 19 09:21:45 2016 -0700
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * 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.util.Arrays;
+
+import javax.sound.sampled.AudioFormat;
+import javax.sound.sampled.AudioFormat.Encoding;
+
+import com.sun.media.sound.AudioFloatConverter;
+
+import static javax.sound.sampled.AudioFormat.Encoding.PCM_SIGNED;
+import static javax.sound.sampled.AudioFormat.Encoding.PCM_UNSIGNED;
+
+/**
+ * @test
+ * @bug 8152501
+ * @modules java.desktop/com.sun.media.sound
+ */
+public final class Bits24ToFromFloatArray {
+
+ private static final int SIZE = 24;
+
+ private static final float[] FLOATS = {-1.0f, 0, 1.0f};
+
+ private static int MIN_S = -8_388_608;
+ private static int MAX_S = 8_388_607;
+
+ private static int MID_U = 0xFFFFFF / 2 + 1;
+ private static int MAX_U = 0xFFFFFF;
+
+ // BIG ENDIAN
+ private static final byte[] SIGNED_BIG = {
+ (byte) ((MIN_S >> 16) & 0xff),
+ (byte) ((MIN_S >> 8) & 0xff),
+ (byte) ((MIN_S >> 0) & 0xff),
+ 0, 0, 0,
+ (byte) ((MAX_S >> 16) & 0xff),
+ (byte) ((MAX_S >> 8) & 0xff),
+ (byte) ((MAX_S >> 0) & 0xff),
+ };
+
+ private static final byte[] UNSIGNED_BIG = {
+ 0, 0, 0,
+ (byte) ((MID_U >> 16) & 0xff),
+ (byte) ((MID_U >> 8) & 0xff),
+ (byte) ((MID_U >> 0) & 0xff),
+ (byte) ((MAX_U >> 16) & 0xff),
+ (byte) ((MAX_U >> 8) & 0xff),
+ (byte) ((MAX_U >> 0) & 0xff),
+
+ };
+
+ // LITTLE ENDIAN
+ private static final byte[] SIGNED_LITTLE = {
+ (byte) ((MIN_S >> 0) & 0xff),
+ (byte) ((MIN_S >> 8) & 0xff),
+ (byte) ((MIN_S >> 16) & 0xff),
+ 0, 0, 0,
+ (byte) ((MAX_S >> 0) & 0xff),
+ (byte) ((MAX_S >> 8) & 0xff),
+ (byte) ((MAX_S >> 16) & 0xff),
+ };
+
+ private static final byte[] UNSIGNED_LITTLE = {
+ 0, 0, 0,
+ (byte) ((MID_U >> 0) & 0xff),
+ (byte) ((MID_U >> 8) & 0xff),
+ (byte) ((MID_U >> 16) & 0xff),
+ (byte) ((MAX_U >> 0) & 0xff),
+ (byte) ((MAX_U >> 8) & 0xff),
+ (byte) ((MAX_U >> 16) & 0xff),
+ };
+
+ public static void main(final String[] args) {
+ test(PCM_UNSIGNED, UNSIGNED_BIG, true);
+ test(PCM_UNSIGNED, UNSIGNED_LITTLE, false);
+ test(PCM_SIGNED, SIGNED_LITTLE, false);
+ test(PCM_SIGNED, SIGNED_BIG, true);
+ }
+
+ private static void test(final Encoding enc, final byte[] expected,
+ boolean end) {
+ System.err.println(enc);
+ AudioFormat af = new AudioFormat(enc, 44100, SIZE, 1, SIZE / 8, 44100,
+ end);
+ byte[] bytes = new byte[FLOATS.length * af.getFrameSize()];
+ AudioFloatConverter conv = AudioFloatConverter.getConverter(af);
+
+ conv.toByteArray(FLOATS, bytes);
+
+ if (!Arrays.equals(bytes, expected)) {
+ System.err.println("Actual: " + Arrays.toString(bytes));
+ System.err.println("Expected: " + Arrays.toString(expected));
+ throw new RuntimeException();
+ }
+
+ float[] floats = new float[bytes.length / af.getFrameSize()];
+ conv.toFloatArray(bytes, floats);
+
+ if (!Arrays.equals(floats, FLOATS)) {
+ System.err.println("Actual: " + Arrays.toString(floats));
+ System.err.println("Expected: " + Arrays.toString(FLOATS));
+ throw new RuntimeException();
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/sound/midi/Gervill/AudioFloatConverter/Bits32ToFromFloatArray.java Tue Apr 19 09:21:45 2016 -0700
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * 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.util.Arrays;
+
+import javax.sound.sampled.AudioFormat;
+import javax.sound.sampled.AudioFormat.Encoding;
+
+import com.sun.media.sound.AudioFloatConverter;
+
+import static javax.sound.sampled.AudioFormat.Encoding.PCM_SIGNED;
+import static javax.sound.sampled.AudioFormat.Encoding.PCM_UNSIGNED;
+
+/**
+ * @test
+ * @bug 8152501
+ * @modules java.desktop/com.sun.media.sound
+ */
+public final class Bits32ToFromFloatArray {
+
+ private static final int SIZE = 32;
+
+ private static final float[] FLOATS = {-1.0f, 0, 1.0f};
+
+ private static int MID_U = (int) (Integer.MAX_VALUE + 1);
+ private static int MAX_U = -1;
+
+ // BIG ENDIAN
+ private static final byte[] SIGNED_BIG = {
+ (byte) ((Integer.MIN_VALUE >> 24) & 0xff),
+ (byte) ((Integer.MIN_VALUE >> 16) & 0xff),
+ (byte) ((Integer.MIN_VALUE >> 8) & 0xff),
+ (byte) ((Integer.MIN_VALUE >> 0) & 0xff),
+ 0, 0, 0, 0,
+ (byte) ((Integer.MAX_VALUE >> 24) & 0xff),
+ (byte) ((Integer.MAX_VALUE >> 16) & 0xff),
+ (byte) ((Integer.MAX_VALUE >> 8) & 0xff),
+ (byte) ((Integer.MAX_VALUE >> 0) & 0xff),
+ };
+
+ private static final byte[] UNSIGNED_BIG = {
+ 0, 0, 0, 0,
+ (byte) ((MID_U >> 24) & 0xff),
+ (byte) ((MID_U >> 16) & 0xff),
+ (byte) ((MID_U >> 8) & 0xff),
+ (byte) ((MID_U >> 0) & 0xff),
+ (byte) ((MAX_U >> 24) & 0xff),
+ (byte) ((MAX_U >> 16) & 0xff),
+ (byte) ((MAX_U >> 8) & 0xff),
+ (byte) ((MAX_U >> 0) & 0xff),
+
+ };
+
+ // LITTLE ENDIAN
+ private static final byte[] SIGNED_LITTLE = {
+ (byte) ((Integer.MIN_VALUE >> 0) & 0xff),
+ (byte) ((Integer.MIN_VALUE >> 8) & 0xff),
+ (byte) ((Integer.MIN_VALUE >> 16) & 0xff),
+ (byte) ((Integer.MIN_VALUE >> 24) & 0xff),
+ 0, 0, 0, 0,
+ (byte) ((Integer.MAX_VALUE >> 0) & 0xff),
+ (byte) ((Integer.MAX_VALUE >> 8) & 0xff),
+ (byte) ((Integer.MAX_VALUE >> 16) & 0xff),
+ (byte) ((Integer.MAX_VALUE >> 24) & 0xff),
+ };
+
+ private static final byte[] UNSIGNED_LITTLE = {
+ 0, 0, 0, 0,
+ (byte) ((MID_U >> 0) & 0xff),
+ (byte) ((MID_U >> 8) & 0xff),
+ (byte) ((MID_U >> 16) & 0xff),
+ (byte) ((MID_U >> 24) & 0xff),
+ (byte) ((MAX_U >> 0) & 0xff),
+ (byte) ((MAX_U >> 8) & 0xff),
+ (byte) ((MAX_U >> 16) & 0xff),
+ (byte) ((MAX_U >> 24) & 0xff),
+ };
+
+ public static void main(final String[] args) {
+ test(PCM_UNSIGNED, UNSIGNED_BIG, true);
+ test(PCM_UNSIGNED, UNSIGNED_LITTLE, false);
+ test(PCM_SIGNED, SIGNED_LITTLE, false);
+ test(PCM_SIGNED, SIGNED_BIG, true);
+ }
+
+ private static void test(final Encoding enc, final byte[] expected,
+ boolean end) {
+ AudioFormat af = new AudioFormat(enc, 44100, SIZE, 1, SIZE / 8, 44100,
+ end);
+ byte[] bytes = new byte[FLOATS.length * af.getFrameSize()];
+ AudioFloatConverter conv = AudioFloatConverter.getConverter(af);
+
+ conv.toByteArray(FLOATS, bytes);
+
+ if (!Arrays.equals(bytes, expected)) {
+ System.err.println("Actual: " + Arrays.toString(bytes));
+ System.err.println("Expected: " + Arrays.toString(expected));
+ throw new RuntimeException();
+ }
+
+ float[] floats = new float[bytes.length / af.getFrameSize()];
+ conv.toFloatArray(bytes, floats);
+
+ if (!Arrays.equals(floats, FLOATS)) {
+ System.err.println("Actual: " + Arrays.toString(floats));
+ System.err.println("Expected: " + Arrays.toString(FLOATS));
+ throw new RuntimeException();
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/sound/midi/Gervill/AudioFloatConverter/Bits64ToFromFloatArray.java Tue Apr 19 09:21:45 2016 -0700
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * 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.util.Arrays;
+
+import javax.sound.sampled.AudioFormat;
+import javax.sound.sampled.AudioFormat.Encoding;
+
+import com.sun.media.sound.AudioFloatConverter;
+
+import static javax.sound.sampled.AudioFormat.Encoding.PCM_SIGNED;
+import static javax.sound.sampled.AudioFormat.Encoding.PCM_UNSIGNED;
+
+/**
+ * @test
+ * @bug 8152501
+ * @modules java.desktop/com.sun.media.sound
+ */
+public final class Bits64ToFromFloatArray {
+
+ private static final int SIZE = 64;
+
+ private static final float[] FLOATS = {-1.0f, 0, 1.0f};
+
+ private static long MID_U = (long) (Long.MAX_VALUE + 1);
+ private static long MAX_U = -1;
+
+ // BIG ENDIAN
+ private static final byte[] SIGNED_BIG = {
+ (byte) ((Long.MIN_VALUE >> 56) & 0xff),
+ (byte) ((Long.MIN_VALUE >> 48) & 0xff),
+ (byte) ((Long.MIN_VALUE >> 40) & 0xff),
+ (byte) ((Long.MIN_VALUE >> 32) & 0xff),
+ 0, 0, 0, 0, // current javasound impl will ignore this
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ (byte) ((Long.MAX_VALUE >> 56) & 0xff),
+ (byte) ((Long.MAX_VALUE >> 48) & 0xff),
+ (byte) ((Long.MAX_VALUE >> 40) & 0xff),
+ (byte) ((Long.MAX_VALUE >> 32) & 0xff),
+ 0, 0, 0, 0, // current javasound impl will ignore this
+ };
+
+ private static final byte[] UNSIGNED_BIG = {
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ (byte) ((MID_U >> 56) & 0xff),
+ (byte) ((MID_U >> 48) & 0xff),
+ (byte) ((MID_U >> 40) & 0xff),
+ (byte) ((MID_U >> 32) & 0xff),
+ 0, 0, 0, 0, // current javasound impl will ignore this
+ (byte) ((MAX_U >> 56) & 0xff),
+ (byte) ((MAX_U >> 48) & 0xff),
+ (byte) ((MAX_U >> 40) & 0xff),
+ (byte) ((MAX_U >> 32) & 0xff),
+ 0, 0, 0, 0, // current javasound impl will ignore this
+ };
+
+ // LITTLE ENDIAN
+ private static final byte[] SIGNED_LITTLE = {
+ 0, 0, 0, 0, // current javasound impl will ignore this
+ (byte) ((Long.MIN_VALUE >> 32) & 0xff),
+ (byte) ((Long.MIN_VALUE >> 40) & 0xff),
+ (byte) ((Long.MIN_VALUE >> 48) & 0xff),
+ (byte) ((Long.MIN_VALUE >> 56) & 0xff),
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0, // current javasound impl will ignore this
+ (byte) ((Long.MAX_VALUE >> 32) & 0xff),
+ (byte) ((Long.MAX_VALUE >> 40) & 0xff),
+ (byte) ((Long.MAX_VALUE >> 48) & 0xff),
+ (byte) ((Long.MAX_VALUE >> 56) & 0xff),
+ };
+
+ private static final byte[] UNSIGNED_LITTLE = {
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0, // current javasound impl will ignore this
+ (byte) ((MID_U >> 32) & 0xff),
+ (byte) ((MID_U >> 40) & 0xff),
+ (byte) ((MID_U >> 48) & 0xff),
+ (byte) ((MID_U >> 56) & 0xff),
+ 0, 0, 0, 0, // current javasound impl will ignore this
+ (byte) ((MAX_U >> 32) & 0xff),
+ (byte) ((MAX_U >> 40) & 0xff),
+ (byte) ((MAX_U >> 48) & 0xff),
+ (byte) ((MAX_U >> 56) & 0xff),
+ };
+
+ public static void main(final String[] args) {
+ test(PCM_UNSIGNED, UNSIGNED_BIG, true);
+ test(PCM_UNSIGNED, UNSIGNED_LITTLE, false);
+ test(PCM_SIGNED, SIGNED_LITTLE, false);
+ test(PCM_SIGNED, SIGNED_BIG, true);
+ }
+
+ private static void test(final Encoding enc, final byte[] expected,
+ boolean end) {
+ System.err.println(enc);
+ AudioFormat af = new AudioFormat(enc, 44100, SIZE, 1, SIZE / 8, 44100,
+ end);
+ byte[] bytes = new byte[FLOATS.length * af.getFrameSize()];
+ AudioFloatConverter conv = AudioFloatConverter.getConverter(af);
+
+ conv.toByteArray(FLOATS, bytes);
+
+ if (!Arrays.equals(bytes, expected)) {
+ System.err.println("Actual: " + Arrays.toString(bytes));
+ System.err.println("Expected: " + Arrays.toString(expected));
+ throw new RuntimeException();
+ }
+
+ float[] floats = new float[bytes.length / af.getFrameSize()];
+ conv.toFloatArray(bytes, floats);
+
+ if (!Arrays.equals(floats, FLOATS)) {
+ System.err.println("Actual: " + Arrays.toString(floats));
+ System.err.println("Expected: " + Arrays.toString(FLOATS));
+ throw new RuntimeException();
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/sound/midi/Gervill/AudioFloatConverter/Bits8ToFromFloatArray.java Tue Apr 19 09:21:45 2016 -0700
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * 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.util.Arrays;
+
+import javax.sound.sampled.AudioFormat;
+import javax.sound.sampled.AudioFormat.Encoding;
+
+import com.sun.media.sound.AudioFloatConverter;
+
+import static javax.sound.sampled.AudioFormat.Encoding.*;
+
+/**
+ * @test
+ * @bug 8152501
+ * @modules java.desktop/com.sun.media.sound
+ */
+public final class Bits8ToFromFloatArray {
+
+ private static final int SIZE = 8;
+
+ private static final float[] FLOATS = {-1.0f, 0, 1.0f};
+
+ private static final byte[] SIGNED = {Byte.MIN_VALUE, 0, Byte.MAX_VALUE};
+
+ private static final byte[] UNSIGNED = {
+ 0, (byte) (Byte.MAX_VALUE + 1), (byte) -1
+ };
+
+ public static void main(final String[] args) {
+ test(PCM_UNSIGNED, UNSIGNED);
+ test(PCM_SIGNED, SIGNED);
+ }
+
+ private static void test(final Encoding enc, final byte[] expected) {
+ AudioFormat af = new AudioFormat(enc, 44100, SIZE, 1, SIZE / 8, 44100,
+ true);
+ byte[] bytes = new byte[FLOATS.length * af.getFrameSize()];
+ AudioFloatConverter conv = AudioFloatConverter.getConverter(af);
+
+ conv.toByteArray(FLOATS, bytes);
+
+ if (!Arrays.equals(bytes, expected)) {
+ System.err.println("Actual: " + Arrays.toString(bytes));
+ System.err.println("Expected: " + Arrays.toString(expected));
+ throw new RuntimeException();
+ }
+
+ float[] floats = new float[bytes.length / af.getFrameSize()];
+ conv.toFloatArray(bytes, floats);
+
+ if (!Arrays.equals(floats, FLOATS)) {
+ System.err.println("Actual: " + Arrays.toString(floats));
+ System.err.println("Expected: " + Arrays.toString(FLOATS));
+ throw new RuntimeException();
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JFileChooser/DeserializedJFileChooser/DeserializedJFileChooserTest.java Tue Apr 19 09:21:45 2016 -0700
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * 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 8146301
+ * @summary Enter key does not work in a deserialized JFileChooser.
+ * @run main DeserializedJFileChooserTest
+ */
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.KeyEvent;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+public class DeserializedJFileChooserTest {
+
+ private static int state = -1;
+ private static JFileChooser deserialized;
+
+ public static void main(String[] args) throws Exception {
+ SwingUtilities.invokeLater( () -> {
+ try {
+ JFileChooser jfc = new JFileChooser();
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(bos);
+ oos.writeObject(jfc);
+ oos.close();
+ ByteArrayInputStream bis =
+ new ByteArrayInputStream(bos.toByteArray());
+ ObjectInputStream ois = new ObjectInputStream(bis);
+ deserialized = (JFileChooser) ois.readObject();
+ state = deserialized.showOpenDialog(null);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ });
+ Robot robot = new Robot();
+ robot.setAutoDelay(50);
+ robot.waitForIdle();
+ robot.keyPress(KeyEvent.VK_A);
+ robot.keyRelease(KeyEvent.VK_A);
+ robot.keyPress(KeyEvent.VK_ENTER);
+ robot.keyRelease(KeyEvent.VK_ENTER);
+ robot.waitForIdle();
+ robot.delay(1000);
+ if (state != JFileChooser.APPROVE_OPTION) {
+ deserialized.cancelSelection();
+ throw new RuntimeException("Failed");
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JInternalFrame/DockIconRepaint/DockIconRepaint.java Tue Apr 19 09:21:45 2016 -0700
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * 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.Color;
+import java.awt.EventQueue;
+import java.awt.Graphics;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.Robot;
+import java.beans.PropertyVetoException;
+
+import javax.swing.JDesktopPane;
+import javax.swing.JFrame;
+import javax.swing.JInternalFrame;
+import javax.swing.JPanel;
+
+/**
+ * @test
+ * @bug 8144166
+ * @requires (os.family == "mac")
+ */
+public final class DockIconRepaint {
+
+ private static volatile Color color;
+
+ private static JFrame frame;
+
+ private static JInternalFrame jif;
+
+ private static Robot robot;
+
+ private static Point iconLoc;
+
+ private static Rectangle iconBounds;
+
+ public static void main(final String[] args) throws Exception {
+ robot = new Robot();
+ EventQueue.invokeAndWait(DockIconRepaint::createUI);
+ try {
+ robot.waitForIdle();
+ color = Color.BLUE;
+ test();
+ color = Color.RED;
+ test();
+ color = Color.GREEN;
+ test();
+ } finally {
+ frame.dispose();
+ }
+ }
+
+ private static void test() throws Exception {
+ // maximize the frame to force repaint
+ EventQueue.invokeAndWait(() -> {
+ try {
+ jif.setIcon(false);
+ jif.setMaximum(true);
+ } catch (PropertyVetoException e) {
+ throw new RuntimeException(e);
+ }
+ });
+ robot.waitForIdle();
+ Thread.sleep(1000);
+ // minimize the frame to dock, the icon should be up2date
+ EventQueue.invokeAndWait(() -> {
+ try {
+ jif.setIcon(true);
+ } catch (PropertyVetoException e) {
+ throw new RuntimeException(e);
+ }
+ iconLoc = jif.getDesktopIcon().getLocationOnScreen();
+ iconBounds = jif.getDesktopIcon().getBounds();
+ });
+ robot.waitForIdle();
+ Thread.sleep(1000);
+
+ final Color c = robot.getPixelColor(iconLoc.x + iconBounds.width / 2,
+ iconLoc.y + iconBounds.height / 2);
+ if (c.getRGB() != color.getRGB()) {
+ System.err.println("Exp: " + Integer.toHexString(color.getRGB()));
+ System.err.println("Actual: " + Integer.toHexString(c.getRGB()));
+ throw new RuntimeException("Wrong color.");
+ }
+ }
+
+ private static void createUI() {
+ frame = new JFrame();
+ frame.setUndecorated(true);
+ frame.setSize(300, 300);
+ frame.setLocationRelativeTo(null);
+ final JDesktopPane pane = new JDesktopPane();
+ final JPanel panel = new JPanel() {
+ @Override
+ protected void paintComponent(Graphics g) {
+ g.setColor(color);
+ g.fillRect(0, 0, getWidth(), getHeight());
+ }
+ };
+ jif = new JInternalFrame();
+ jif.add(panel);
+ jif.setVisible(true);
+ jif.setSize(300, 300);
+ pane.add(jif);
+ frame.add(pane);
+ frame.setVisible(true);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JPopupMenu/6949414/JPopupMenuEndlessLoopTest.java Tue Apr 19 09:21:45 2016 -0700
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import javax.swing.JMenu;
+import javax.swing.JMenuItem;
+import javax.swing.JPopupMenu;
+import javax.swing.MenuElement;
+import javax.swing.MenuSelectionManager;
+import javax.swing.SwingUtilities;
+
+/**
+ * @test
+ * @bug 6949414 6424606
+ * @summary JMenu.buildMenuElementArray() endless loop
+ * @run main/timeout=5 JPopupMenuEndlessLoopTest
+ */
+public class JPopupMenuEndlessLoopTest {
+
+ public static void main(String[] args) throws Exception {
+ SwingUtilities.invokeAndWait(() -> {
+
+ JPopupMenu popup = new JPopupMenu("Popup Menu");
+ JMenu menu = new JMenu("Menu");
+ menu.add(new JMenuItem("Menu Item"));
+ popup.add(menu);
+ menu.doClick();
+ MenuElement[] elems = MenuSelectionManager
+ .defaultManager().getSelectedPath();
+
+ if (elems == null || elems.length == 0) {
+ throw new RuntimeException("Empty Selection");
+ }
+
+ if (elems[0] != popup || elems[1] != menu) {
+ throw new RuntimeException("Necessary menus are not selected!");
+ }
+ });
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JTabbedPane/8137169/ScrollableTabbedPaneTest.java Tue Apr 19 09:21:45 2016 -0700
@@ -0,0 +1,182 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * 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 8137169
+ * @summary verifies TabbedScrollPane minimum height for all Look and Feels
+ * @library ../../regtesthelpers
+ * @build Util
+ * @run main ScrollableTabbedPaneTest
+ */
+
+import java.awt.Robot;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JTabbedPane;
+import javax.swing.SwingConstants;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import javax.swing.UnsupportedLookAndFeelException;
+
+public class ScrollableTabbedPaneTest {
+
+ private static JFrame frame;
+ private static JTabbedPane pane;
+ private static Robot robot;
+ private static volatile String errorString = "";
+
+ public static void main(String[] args) throws Exception {
+ robot = new Robot();
+ robot.delay(1000);
+ UIManager.LookAndFeelInfo[] lookAndFeelArray
+ = UIManager.getInstalledLookAndFeels();
+ for (UIManager.LookAndFeelInfo lookAndFeelItem : lookAndFeelArray) {
+ executeCase(lookAndFeelItem.getClassName(),
+ lookAndFeelItem.getName());
+ }
+ if (!"".equals(errorString)) {
+ throw new RuntimeException("Error Log:\n" + errorString);
+ }
+ }
+
+ private static void executeCase(String lookAndFeelString, String shortLAF)
+ throws Exception {
+ if (tryLookAndFeel(lookAndFeelString)) {
+ createUI(shortLAF);
+ stepsToExecute(shortLAF);
+
+ createLeftUI(shortLAF);
+ stepsToExecute(shortLAF);
+
+ createRightUI(shortLAF);
+ stepsToExecute(shortLAF);
+ }
+ }
+
+ private static void stepsToExecute(String shortLAF) throws Exception {
+ robot.delay(100);
+ runTestCase(shortLAF);
+ robot.delay(1000);
+ cleanUp();
+ robot.delay(1000);
+ }
+
+ private static boolean tryLookAndFeel(String lookAndFeelString)
+ throws Exception {
+ try {
+ UIManager.setLookAndFeel(
+ lookAndFeelString);
+
+ } catch (UnsupportedLookAndFeelException
+ | ClassNotFoundException
+ | InstantiationException
+ | IllegalAccessException e) {
+ return false;
+ }
+ return true;
+ }
+
+ private static void cleanUp() throws Exception {
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ frame.dispose();
+ }
+ });
+ }
+
+ private static void createUI(final String shortLAF)
+ throws Exception {
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ frame = new JFrame(shortLAF);
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ frame.setVisible(true);
+ pane = new JTabbedPane();
+ pane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
+ frame.add(pane);
+ frame.setSize(500, 500);
+ }
+ });
+ }
+ private static void createLeftUI(final String shortLAF)
+ throws Exception {
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ frame = new JFrame(shortLAF);
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ frame.setVisible(true);
+ pane = new JTabbedPane();
+ pane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
+ pane.setTabPlacement(SwingConstants.LEFT);
+ frame.add(pane);
+ frame.setSize(500, 500);
+ }
+ });
+ }
+
+ private static void createRightUI(final String shortLAF)
+ throws Exception {
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ frame = new JFrame(shortLAF);
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ frame.setVisible(true);
+ pane = new JTabbedPane();
+ pane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
+ pane.setTabPlacement(SwingConstants.RIGHT);
+ frame.add(pane);
+ frame.setSize(500, 500);
+ }
+ });
+ }
+
+ private static void runTestCase(String shortLAF) throws Exception {
+ SwingUtilities.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ int i = 0;
+ int value= 0;
+ do {
+ String title = "Tab" + (i + 1);
+ pane.addTab(title, new JPanel());
+ int tempValue = pane.getMinimumSize().height;
+ if(value==0) {
+ value = tempValue;
+ }
+ if(value != tempValue) {
+ String error = "[" + shortLAF
+ + "]: [Error]: TabbedScrollPane fails";
+ errorString += error;
+ }
+
+ ++i;
+ } while (i < 10);
+ }
+ });
+ }
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/LookAndFeel/6897701/JMenuItemsTest.java Tue Apr 19 09:21:45 2016 -0700
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * 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 6897701
+ * @summary Verify JMenu and JMenuItem Disabled state for Nimbus LAF
+ * @run main JMenuItemsTest
+ */
+import java.awt.Color;
+import java.awt.Rectangle;
+import java.awt.image.BufferedImage;
+import javax.swing.JFrame;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.JMenuItem;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+
+public class JMenuItemsTest {
+
+ private static JFrame mainFrame;
+ private static JMenu disabledMenu;
+ private static JMenuItem disabledMenuItem;
+
+ public JMenuItemsTest() {
+ createUI();
+ }
+
+ private void createUI() {
+
+ mainFrame = new JFrame("Test");
+
+ disabledMenu = new JMenu("Disabled Menu");
+ disabledMenu.setForeground(Color.BLUE);
+ disabledMenu.setEnabled(false);
+
+ disabledMenuItem = new JMenuItem("Disabled MenuItem");
+ disabledMenuItem.setForeground(Color.BLUE);
+ disabledMenuItem.setEnabled(false);
+
+ JMenuBar menuBar = new JMenuBar();
+ menuBar = new JMenuBar();
+ menuBar.add(disabledMenu);
+ menuBar.add(disabledMenuItem);
+
+ mainFrame.add(menuBar);
+ mainFrame.pack();
+ mainFrame.setVisible(true);
+ }
+
+ private void dispose() {
+ mainFrame.dispose();
+ }
+
+ private void testDisabledStateOfJMenu() {
+
+ // Test disabled JMenu state
+ Rectangle rect = disabledMenu.getBounds();
+ BufferedImage image = new BufferedImage(rect.width, rect.height,
+ BufferedImage.TYPE_INT_ARGB);
+ disabledMenu.paint(image.getGraphics());
+ int y = image.getHeight() / 2;
+ for (int x = 0; x < image.getWidth(); x++) {
+ Color c = new Color(image.getRGB(x, y));
+ if (c.equals(Color.BLUE)) {
+ dispose();
+ throw new RuntimeException("JMenu Disabled"
+ + " State not Valid.");
+ }
+ }
+
+ }
+
+ private void testDisabledStateOfJMenuItem() {
+
+ // Test disabled JMenuItem state
+ Rectangle rect = disabledMenuItem.getBounds();
+ BufferedImage image = new BufferedImage(rect.width, rect.height,
+ BufferedImage.TYPE_INT_ARGB);
+ disabledMenuItem.paint(image.getGraphics());
+ int y = image.getHeight() / 2;
+ for (int x = 0; x < image.getWidth(); x++) {
+ Color c = new Color(image.getRGB(x, y));
+ if (c.equals(Color.BLUE)) {
+ dispose();
+ throw new RuntimeException("JMenuItem Disabled"
+ + " State not Valid.");
+ }
+ }
+
+ }
+
+ public static void main(String[] args) throws Exception {
+ UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
+ SwingUtilities.invokeAndWait(() -> {
+
+ try {
+ JMenuItemsTest obj = new JMenuItemsTest();
+ obj.testDisabledStateOfJMenu();
+ obj.testDisabledStateOfJMenuItem();
+ obj.dispose();
+
+ } catch (Exception ex) {
+ throw ex;
+ }
+
+ });
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/text/html/CSS/ColorValue/RGBColorValueTest.java Tue Apr 19 09:21:45 2016 -0700
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8149631
+ * @summary rgb(...) CSS color values are not parsed properly
+ * @run main RGBColorValueTest
+ */
+
+import javax.swing.text.AttributeSet;
+import javax.swing.text.html.StyleSheet;
+
+import static javax.swing.text.html.CSS.Attribute.*;
+
+public class RGBColorValueTest {
+
+ public static void main(String[] args) {
+ StyleSheet styleSheet = new StyleSheet();
+ AttributeSet attributeSet = styleSheet.
+ getDeclaration("border-color: rgb(1, 2, 3) rgb(1, 2, 4);");
+ if (!attributeSet.getAttribute(BORDER_TOP_COLOR).toString()
+ .equals("rgb(1, 2, 3)") ||
+ !attributeSet.getAttribute(BORDER_BOTTOM_COLOR).toString()
+ .equals("rgb(1, 2, 3)") ||
+ !attributeSet.getAttribute(BORDER_RIGHT_COLOR).toString()
+ .equals("rgb(1, 2, 4)") ||
+ !attributeSet.getAttribute(BORDER_LEFT_COLOR).toString()
+ .equals("rgb(1, 2, 4)") ) {
+ throw new RuntimeException("Failed");
+ }
+ }
+}