This commit is contained in:
David Dehaven 2016-04-19 09:21:45 -07:00
commit 51f3901064
121 changed files with 5379 additions and 683 deletions

View File

@ -37,6 +37,7 @@ allfonts.chinese-gb18030-extb=SimSun-ExtB
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.allfonts.x-windows-874=alphabetic,thai,dingbats,symbol
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.GulimChe=gulim.TTC
filename.Lucida_Sans_Regular=LucidaSansRegular.ttf
filename.Mangal=MANGAL.TTF
filename.Tunga=TUNGA.TTF
filename.Symbol=SYMBOL.TTF
filename.Wingdings=WINGDING.TTF

View File

@ -35,7 +35,6 @@ import javax.swing.event.ListDataEvent;
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 @@ class AquaFileSystemModel extends AbstractTableModel implements PropertyChangeLi
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();
}

View File

@ -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 @@ import sun.swing.SwingUtilities2;
* 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 @@ public class AquaInternalFrameDockIconUI extends DesktopIconUI implements MouseL
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 @@ public class AquaInternalFrameDockIconUI extends DesktopIconUI implements MouseL
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 @@ public class AquaInternalFrameDockIconUI extends DesktopIconUI implements MouseL
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 @@ public class AquaInternalFrameDockIconUI extends DesktopIconUI implements MouseL
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 @@ public class AquaInternalFrameDockIconUI extends DesktopIconUI implements MouseL
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 @@ public class AquaInternalFrameDockIconUI extends DesktopIconUI implements MouseL
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 @@ public class AquaInternalFrameDockIconUI extends DesktopIconUI implements MouseL
}
}
@Override
@Deprecated
public void hide() {
final Container parent = getParent();

View File

@ -2183,50 +2183,21 @@ public class AquaTabbedPaneCopyFromBasicUI extends TabbedPaneUI implements Swing
}
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;
}

View File

@ -42,7 +42,6 @@ import sun.awt.FontConfiguration;
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>();

View File

@ -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 @@ public class IntegerNIORaster extends SunWritableRaster {
") 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 @@ public class IntegerNIORaster extends SunWritableRaster {
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() {

View File

@ -35,7 +35,6 @@ import java.security.*;
import java.util.*;
import sun.awt.*;
import sun.misc.ManagedLocalsThread;
import sun.print.*;
import sun.awt.util.ThreadGroupUtils;
@ -77,13 +76,14 @@ public abstract class LWToolkit extends SunToolkit implements Runnable {
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();

View File

@ -44,7 +44,6 @@ import sun.awt.dnd.*;
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 @@ public final class CDragSourceContextPeer extends SunDragSourceContextPeer {
}
}
};
new ManagedLocalsThread(dragRunnable).start();
new Thread(null, dragRunnable, "Drag", 0, false).start();
} catch (Exception e) {
final long nativeDragSource = getNativeContext();
setNativeContext(0);

View File

@ -37,7 +37,6 @@ import java.io.*;
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 @@ class CFileDialog implements FileDialogPeer {
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

View File

@ -29,7 +29,6 @@ import java.awt.*;
import java.awt.dnd.*;
import sun.lwawt.*;
import sun.misc.ManagedLocalsThread;
public class CPrinterDialogPeer extends LWWindowPeer {
static {
@ -59,7 +58,7 @@ public class CPrinterDialogPeer extends LWWindowPeer {
printerDialog.setRetVal(printerDialog.showDialog());
printerDialog.setVisible(false);
};
new ManagedLocalsThread(task).start();
new Thread(null, task, "PrintDialog", 0, false).start();
}
}

View File

@ -36,6 +36,7 @@ import java.security.PrivilegedAction;
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.MediaSizeName;
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 @@ public final class CPrinterJob extends RasterPrinterJob {
// 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 @@ public final class CPrinterJob extends RasterPrinterJob {
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 @@ public final class CPrinterJob extends RasterPrinterJob {
// 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);

View File

@ -312,9 +312,9 @@ static void javaPageFormatToNSPrintInfo(JNIEnv* env, jobject srcPrintJob, jobjec
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 @@ static void nsPrintInfoToJavaPrinterJob(JNIEnv* env, NSPrintInfo* src, jobject d
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 @@ static void nsPrintInfoToJavaPrinterJob(JNIEnv* env, NSPrintInfo* src, jobject d
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 @@ static void nsPrintInfoToJavaPrinterJob(JNIEnv* env, NSPrintInfo* src, jobject d
{
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 void javaPrinterJobToNSPrintInfo(JNIEnv* env, jobject srcPrinterJob, jobj
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 @@ static void javaPrinterJobToNSPrintInfo(JNIEnv* env, jobject srcPrinterJob, jobj
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 {
[printingDictionary setObject:[NSNumber numberWithBool:NO] 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
{
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];
}
}
// 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);

View File

@ -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 @@ static NSSize ScaledImageSizeForStatusBar(NSSize imageSize) {
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];

View File

@ -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 @@ public class StreamCloser {
* 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.
*/

View File

@ -64,7 +64,6 @@ import sun.awt.SunToolkit;
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 @@ public class WindowsLookAndFeel extends BasicLookAndFeel
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();
}
}
}

View File

@ -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 @@ public abstract class AudioFloatConverter {
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 @@ public abstract class AudioFloatConverter {
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 @@ public abstract class AudioFloatConverter {
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 @@ public abstract class AudioFloatConverter {
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 @@ public abstract class AudioFloatConverter {
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 @@ public abstract class AudioFloatConverter {
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 @@ public abstract class AudioFloatConverter {
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 @@ public abstract class AudioFloatConverter {
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 @@ public abstract class AudioFloatConverter {
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 @@ public abstract class AudioFloatConverter {
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 @@ public abstract class AudioFloatConverter {
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 @@ public abstract class AudioFloatConverter {
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 @@ public abstract class AudioFloatConverter {
| ((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 @@ public abstract class AudioFloatConverter {
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 @@ public abstract class AudioFloatConverter {
| ((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 @@ public abstract class AudioFloatConverter {
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 @@ public abstract class AudioFloatConverter {
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 @@ public abstract class AudioFloatConverter {
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 @@ public abstract class AudioFloatConverter {
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 @@ public abstract class AudioFloatConverter {
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 @@ public abstract class AudioFloatConverter {
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 @@ public abstract class AudioFloatConverter {
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 @@ public abstract class AudioFloatConverter {
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 @@ public abstract class AudioFloatConverter {
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 @@ public abstract class AudioFloatConverter {
// 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 @@ public abstract class AudioFloatConverter {
// 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 @@ public abstract class AudioFloatConverter {
// 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 @@ public abstract class AudioFloatConverter {
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 @@ public abstract class AudioFloatConverter {
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 @@ public abstract class AudioFloatConverter {
// 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 @@ public abstract class AudioFloatConverter {
((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 @@ public abstract class AudioFloatConverter {
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);

View File

@ -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 @@ final class JSSecurityManager {
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);

View File

@ -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 @@ public final class JavaSoundAudioClip implements AudioClip, MetaEventListener, L
} else if (sequencer != null) {
try {
sequencerloop = false;
sequencer.addMetaEventListener(this);
sequencer.removeMetaEventListener(this);
sequencer.stop();
} catch (Exception e3) {
if (Printer.err) e3.printStackTrace();

View File

@ -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 @@ public final class SoftAudioPusher implements Runnable {
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();

View File

@ -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 @@ public final class SoftJitterCorrector extends AudioInputStream {
}
};
thread = new ManagedLocalsThread(runnable);
thread = new Thread(null, runnable, "JitterCorrector", 0, false);
thread.setDaemon(true);
thread.setPriority(Thread.MAX_PRIORITY);
thread.start();

View File

@ -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 @@ public final class SoftSynthesizer implements AudioSynthesizer,
pusher = null;
jitter_stream = null;
sourceDataLine = null;
new ManagedLocalsThread(runnable).start();
new Thread(null, runnable, "Synthesizer",0,false).start();
}
return len;
}

View File

@ -31,7 +31,6 @@ import java.awt.event.WindowEvent;
import java.util.ArrayList;
import sun.misc.ManagedLocalsThread;
import sun.util.logging.PlatformLogger;
import sun.awt.dnd.SunDragSourceContextPeer;
@ -55,7 +54,7 @@ import sun.awt.dnd.SunDragSourceContextPeer;
*
* @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 @@ class EventDispatchThread extends ManagedLocalsThread {
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);
}

View File

@ -765,6 +765,49 @@ public class Font implements java.io.Serializable
this.hasLayoutAttributes = values.anyNonDefault(LAYOUT_MASK);
}
/**
* 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

View File

@ -404,9 +404,6 @@ public abstract class PackedColorModel extends ColorModel {
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;

View File

@ -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 @@ public class Raster {
int scanlineStride,
int pixelStride,
int bandOffsets[],
Point location) {
Point location)
{
if (dataBuffer == null) {
throw new NullPointerException("DataBuffer cannot be null");
}
@ -645,15 +646,26 @@ public class Raster {
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 @@ public class Raster {
int scanlineStride,
int bankIndices[],
int bandOffsets[],
Point location) {
Point location)
{
if (dataBuffer == null) {
throw new NullPointerException("DataBuffer cannot be null");
}
@ -713,18 +726,29 @@ public class Raster {
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 @@ public class Raster {
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 @@ public class Raster {
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 class Raster {
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 @@ public class Raster {
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 class Raster {
*/
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 @@ public class Raster {
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 class Raster {
*/
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 @@ public class Raster {
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);
}
/**

View File

@ -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 @@ public class RenderableImageProducer implements ImageProducer, Runnable {
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();
}

View File

@ -1294,7 +1294,8 @@ public final class ImageIO {
*
* @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 @@ public final class ImageIO {
*
* @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 @@ public final class ImageIO {
}
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 @@ public final class ImageIO {
*
* @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 @@ public final class ImageIO {
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 @@ public final class ImageIO {
*
* @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 @@ public final class ImageIO {
if (output == null) {
throw new IllegalArgumentException("output == null!");
}
ImageOutputStream stream = null;
ImageWriter writer = getWriter(im, formatName);
if (writer == null) {
@ -1528,13 +1542,11 @@ public final class ImageIO {
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 @@ public final class ImageIO {
*
* @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 @@ public final class ImageIO {
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 {

View File

@ -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 @@ package javax.swing;
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.JavaBean;
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 @@ public class JFileChooser extends JComponent implements Accessible {
}
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 @@ public class JFileChooser extends JComponent implements Accessible {
} // 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));
}
}
}
}
}

View File

@ -1296,7 +1296,7 @@ public class JMenu extends JMenuItem implements Accessible,MenuElement
* @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 @@ public class JMenu extends JMenuItem implements Accessible,MenuElement
} 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;
}

View File

@ -56,7 +56,6 @@ import java.util.List;
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 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
};
// start printing on another thread
Thread th = new ManagedLocalsThread(runnable);
Thread th = new Thread(null, runnable, "JTablePrint", 0, false);
th.start();
printingStatus.showModal(true);

View File

@ -36,7 +36,6 @@ import java.util.concurrent.*;
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 @@ class TimerQueue implements Runnable
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();

View File

@ -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 @@ public class BasicDirectoryModel extends AbstractListModel<Object> implements Pr
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();
}

View File

@ -797,9 +797,11 @@ public class BasicPopupMenuUI extends PopupMenuUI {
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);

View File

@ -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 @@ public final class NimbusStyle extends SynthStyle {
// 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;

View File

@ -775,7 +775,7 @@ public abstract class SynthStyle {
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);

View File

@ -70,7 +70,6 @@ import javax.print.attribute.*;
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 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
runnablePrinting.run();
} else {
if (isEventDispatchThread) {
new ManagedLocalsThread(runnablePrinting).start();
new Thread(null, runnablePrinting,
"JTextComponentPrint", 0, false ).start();
printingStatus.showModal(true);
} else {
printingStatus.showModal(false);

View File

@ -26,7 +26,6 @@ package javax.swing.text;
import java.util.Vector;
import sun.awt.AppContext;
import sun.misc.ManagedLocalsThread;
/**
* A queue of text layout tasks.
@ -92,7 +91,7 @@ public class LayoutQueue {
}
} 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();
}

View File

@ -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 @@ public class CSS implements Serializable {
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) {

View File

@ -52,7 +52,6 @@ import java.security.Permission;
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 @@ public void grab() {
* 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() {

View File

@ -44,7 +44,6 @@ import sun.awt.AppContext;
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 @@ abstract class AppletPanel extends Panel implements AppletStub, Runnable {
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 @@ abstract class AppletPanel extends Panel implements AppletStub, Runnable {
// 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();

View File

@ -38,7 +38,6 @@ import java.security.AccessController;
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 @@ public class AppletViewer extends Frame implements AppletContext, Printable {
//
final AppletPanel p = panel;
new ManagedLocalsThread(new Runnable()
new Thread(null, new Runnable()
{
@Override
public void run()
@ -867,7 +866,8 @@ public class AppletViewer extends Frame implements AppletContext, Printable {
appletSystemExit();
}
}
}).start();
},
"AppletCloser", 0, false).start();
}
/**
@ -890,7 +890,7 @@ public class AppletViewer extends Frame implements AppletContext, Printable {
// 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 @@ public class AppletViewer extends Frame implements AppletContext, Printable {
}
appletSystemExit();
}
}).start();
},
"AppletQuit", 0, false).start();
}
/**

View File

@ -34,7 +34,6 @@ import java.util.Map;
import java.util.Set;
import sun.awt.util.ThreadGroupUtils;
import sun.misc.ManagedLocalsThread;
import sun.util.logging.PlatformLogger;
/**
@ -337,8 +336,8 @@ public final class AWTAutoShutdown implements Runnable {
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;

View File

@ -46,7 +46,6 @@ import java.lang.ref.SoftReference;
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 final class AppContext {
}
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);

View File

@ -55,7 +55,6 @@ import java.util.prefs.BackingStoreException;
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 @@ public abstract class InputMethodManager {
// 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();

View File

@ -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.WritableRaster;
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 @@ public class ByteBandedRaster extends SunWritableRaster {
* @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 @@ public class ByteBandedRaster extends SunWritableRaster {
* 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 @@ public class ByteBandedRaster extends SunWritableRaster {
* 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 @@ public class ByteBandedRaster extends SunWritableRaster {
int deltaY = y0 - y;
return new ByteBandedRaster(sm,
dataBuffer,
(DataBufferByte) dataBuffer,
new Rectangle(x0,y0,width,height),
new Point(sampleModelTranslateX+deltaX,
sampleModelTranslateY+deltaY),

View File

@ -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.RasterFormatException;
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 class ByteComponentRaster extends SunWritableRaster {
*/
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 @@ public class ByteComponentRaster extends SunWritableRaster {
* 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 @@ public class ByteComponentRaster extends SunWritableRaster {
* 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 @@ public class ByteComponentRaster extends SunWritableRaster {
int deltaY = y0 - y;
return new ByteComponentRaster(sm,
dataBuffer,
(DataBufferByte) dataBuffer,
new Rectangle(x0, y0, width, height),
new Point(sampleModelTranslateX+deltaX,
sampleModelTranslateY+deltaY),

View File

@ -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.SampleModel;
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 class ByteInterleavedRaster extends ByteComponentRaster {
*/
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 @@ public class ByteInterleavedRaster extends ByteComponentRaster {
* 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 @@ public class ByteInterleavedRaster extends ByteComponentRaster {
* 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 @@ public class ByteInterleavedRaster extends ByteComponentRaster {
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 @@ public class ByteInterleavedRaster extends ByteComponentRaster {
int deltaY = y0 - y;
return new ByteInterleavedRaster(sm,
dataBuffer,
(DataBufferByte) dataBuffer,
new Rectangle(x0, y0, width, height),
new Point(sampleModelTranslateX+deltaX,
sampleModelTranslateY+deltaY),

View File

@ -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.WritableRaster;
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 @@ public class BytePackedRaster extends SunWritableRaster {
* @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 @@ public class BytePackedRaster extends SunWritableRaster {
* 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 @@ public class BytePackedRaster extends SunWritableRaster {
* 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 @@ public class BytePackedRaster extends SunWritableRaster {
* 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 @@ public class BytePackedRaster extends SunWritableRaster {
int deltaY = y0 - y;
return new BytePackedRaster(sm,
dataBuffer,
(DataBufferByte) dataBuffer,
new Rectangle(x0, y0, width, height),
new Point(sampleModelTranslateX+deltaX,
sampleModelTranslateY+deltaY),

View File

@ -27,7 +27,6 @@ package sun.awt.image;
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 @@ import sun.misc.ManagedLocalsThread;
* @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;
@ -51,11 +50,18 @@ class ImageFetcher extends ManagedLocalsThread {
// ImageFetchable to be added to the
// 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);
}

View File

@ -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.WritableRaster;
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 @@ public class IntegerComponentRaster extends SunWritableRaster {
* @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 @@ public class IntegerComponentRaster extends SunWritableRaster {
* @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 @@ public class IntegerComponentRaster extends SunWritableRaster {
* @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 @@ public class IntegerComponentRaster extends SunWritableRaster {
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 @@ public class IntegerComponentRaster extends SunWritableRaster {
int deltaY = y0 - y;
return new IntegerComponentRaster(sm,
dataBuffer,
(DataBufferInt) dataBuffer,
new Rectangle(x0,y0,width,height),
new Point(sampleModelTranslateX+deltaX,
sampleModelTranslateY+deltaY),

View File

@ -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.WritableRaster;
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 @@ public class IntegerInterleavedRaster extends IntegerComponentRaster {
* @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 @@ public class IntegerInterleavedRaster extends IntegerComponentRaster {
* @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 @@ public class IntegerInterleavedRaster extends IntegerComponentRaster {
* @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 @@ public class IntegerInterleavedRaster extends IntegerComponentRaster {
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 @@ public class IntegerInterleavedRaster extends IntegerComponentRaster {
int deltaY = y0 - y;
return new IntegerInterleavedRaster(sm,
dataBuffer,
(DataBufferInt) dataBuffer,
new Rectangle(x0,y0,width,height),
new Point(sampleModelTranslateX+deltaX,
sampleModelTranslateY+deltaY),

View File

@ -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.WritableRaster;
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 @@ public class ShortBandedRaster extends SunWritableRaster {
* @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 @@ public class ShortBandedRaster extends SunWritableRaster {
* @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 @@ public class ShortBandedRaster extends SunWritableRaster {
* @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 @@ public class ShortBandedRaster extends SunWritableRaster {
int deltaY = y0 - y;
return new ShortBandedRaster(sm,
dataBuffer,
(DataBufferUShort) dataBuffer,
new Rectangle(x0, y0, width, height),
new Point(sampleModelTranslateX+deltaX,
sampleModelTranslateY+deltaY),

View File

@ -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.RasterFormatException;
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 class ShortComponentRaster extends SunWritableRaster {
*/
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 @@ public class ShortComponentRaster extends SunWritableRaster {
* @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 @@ public class ShortComponentRaster extends SunWritableRaster {
* @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 @@ public class ShortComponentRaster extends SunWritableRaster {
int deltaY = y0 - y;
return new ShortComponentRaster(sm,
dataBuffer,
(DataBufferUShort) dataBuffer,
new Rectangle(x0, y0, width, height),
new Point(sampleModelTranslateX+deltaX,
sampleModelTranslateY+deltaY),

View File

@ -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.SampleModel;
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 class ShortInterleavedRaster extends ShortComponentRaster {
*/
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 @@ public class ShortInterleavedRaster extends ShortComponentRaster {
* @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 @@ public class ShortInterleavedRaster extends ShortComponentRaster {
* @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 @@ public class ShortInterleavedRaster extends ShortComponentRaster {
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 @@ public class ShortInterleavedRaster extends ShortComponentRaster {
int deltaY = y0 - y;
return new ShortInterleavedRaster(sm,
dataBuffer,
(DataBufferUShort) dataBuffer,
new Rectangle(x0, y0, width, height),
new Point(sampleModelTranslateX+deltaX,
sampleModelTranslateY+deltaY),

View File

@ -36,7 +36,6 @@ import java.util.concurrent.TimeUnit;
import sun.awt.AppContext;
import sun.awt.util.ThreadGroupUtils;
import sun.misc.ManagedLocalsThread;
public class CreatedFontTracker {
@ -122,8 +121,8 @@ public class CreatedFontTracker {
* 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.
*/

View File

@ -182,6 +182,25 @@ public final class FontUtilities {
return FontAccess.getFontAccess().getFont2D(font);
}
/**
* 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

View File

@ -55,7 +55,6 @@ import sun.awt.FontConfiguration;
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 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
};
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;

View File

@ -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 @@ public class Disposer implements Runnable {
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);

View File

@ -48,7 +48,6 @@ import java.io.FileNotFoundException;
import java.security.AccessController;
import java.security.PrivilegedAction;
import sun.misc.ManagedLocalsThread;
import sun.security.action.GetPropertyAction;
/**
@ -420,8 +419,9 @@ public abstract class GraphicsPrimitive {
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;

View File

@ -28,7 +28,6 @@ package sun.java2d.opengl;
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 class OGLRenderQueue extends RenderQueue {
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();

View File

@ -71,7 +71,6 @@ import javax.print.attribute.standard.OrientationRequested;
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 @@ public class PrintJob2D extends PrintJob implements Printable, Runnable {
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 @@ public class PrintJob2D extends PrintJob implements Printable, Runnable {
}
private void startPrinterJobThread() {
printerJobThread = new ManagedLocalsThread(this, "printerJobThread");
printerJobThread =
new Thread(null, this, "printerJobThread", 0, false);
printerJobThread.start();
}

View File

@ -25,8 +25,6 @@
package sun.print;
import sun.misc.ManagedLocalsThread;
import java.util.Vector;
import javax.print.PrintService;
@ -42,15 +40,19 @@ import javax.print.event.PrintServiceAttributeListener;
* 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 @@ class ServiceNotifier extends ManagedLocalsThread {
}
}
void removeListener(PrintServiceAttributeListener listener) {
void removeListener(PrintServiceAttributeListener listener) {
synchronized (this) {
if (listener == null || listeners == null) {
return;

View File

@ -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 @@ public class DefaultSynthStyle extends SynthStyle implements Cloneable {
// 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;
@ -882,21 +873,6 @@ public class DefaultSynthStyle extends SynthStyle implements Cloneable {
return state;
}
/**
* 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.
*

View File

@ -29,7 +29,6 @@ import java.awt.peer.FileDialogPeer;
import java.io.File;
import java.io.FilenameFilter;
import sun.awt.AWTAccessor;
import sun.misc.ManagedLocalsThread;
/**
* FileDialogPeer for the GtkFileChooser.
@ -120,7 +119,7 @@ final class GtkFileDialogPeer extends XDialogPeer implements FileDialogPeer {
standaloneWindow = 0;
fd.setVisible(false);
};
new ManagedLocalsThread(task).start();
new Thread(null, task, "ShowDialog", 0, false).start();
} else {
quit();
fd.setVisible(false);

View File

@ -29,7 +29,6 @@ import java.awt.*;
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 @@ public abstract class InfoWindow extends Window {
final Thread thread;
Displayer() {
this.thread = new ManagedLocalsThread(this);
this.thread = new Thread(null, this, "Displayer", 0, false);
this.thread.setDaemon(true);
}

View File

@ -1087,7 +1087,7 @@ public abstract class XBaseMenuWindow extends XWindow {
}
} else {
//Invoke action event
item.action(mouseEvent.getWhen());
item.action(mouseEvent.getWhen(), mouseEvent.getModifiers());
ungrabInput();
}
} else {
@ -1200,7 +1200,7 @@ public abstract class XBaseMenuWindow extends XWindow {
if (citem instanceof XMenuPeer) {
cwnd.selectItem(citem, true);
} else if (citem != null) {
citem.action(event.getWhen());
citem.action(event.getWhen(), event.getModifiers());
ungrabInput();
}
break;

View File

@ -323,11 +323,11 @@ public class XMenuItemPeer implements MenuItemPeer {
* 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));
}
}
/************************************************

View File

@ -29,7 +29,6 @@ import java.awt.PopupMenu;
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 @@ final class XTaskbarPeer implements TaskbarPeer {
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();
}

View File

@ -284,8 +284,8 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
}
};
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 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
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);

View File

@ -44,7 +44,6 @@ import sun.java2d.loops.SurfaceType;
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 @@ public final class X11GraphicsDevice extends GraphicsDevice
}
};
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;

View File

@ -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 class PrintServiceLookupProvider extends PrintServiceLookup
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");

View File

@ -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 @@ Java_sun_awt_X11GraphicsDevice_getCurrentDisplayMode
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();

View File

@ -41,7 +41,6 @@ import java.util.stream.Stream;
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 @@ final class Win32ShellFolderManager2 extends ShellFolderManager {
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 @@ final class Win32ShellFolderManager2 extends ShellFolderManager {
* 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;
});

View File

@ -36,7 +36,6 @@ import java.util.MissingResourceException;
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 @@ final class WFileDialogPeer extends WWindowPeer implements FileDialogPeer {
@Override
public void show() {
new ManagedLocalsThread(this::_show).start();
new Thread(null, this::_show, "FileDialog", 0, false).start();
}
@Override

View File

@ -25,8 +25,6 @@
package sun.awt.windows;
import sun.misc.ManagedLocalsThread;
final class WPageDialogPeer extends WPrintDialogPeer {
WPageDialogPeer(WPageDialog target) {
@ -53,6 +51,6 @@ final class WPageDialogPeer extends WPrintDialogPeer {
}
((WPrintDialog)target).setVisible(false);
};
new ManagedLocalsThread(runnable).start();
new Thread(null, runnable, "PageDialog", 0, false).start();
}
}

View File

@ -32,7 +32,6 @@ import java.awt.dnd.DropTarget;
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 @@ class WPrintDialogPeer extends WWindowPeer implements DialogPeer {
}
((WPrintDialog)target).setVisible(false);
};
new ManagedLocalsThread(runnable).start();
new Thread(null, runnable, "PrintDialog", 0, false).start();
}
synchronized void setHWnd(long hwnd) {

View File

@ -52,7 +52,6 @@ import sun.awt.datatransfer.DataTransferer;
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 @@ public final class WToolkit extends SunToolkit implements Runnable {
(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 @@ public final class WToolkit extends SunToolkit implements Runnable {
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;

View File

@ -49,7 +49,6 @@ import sun.java2d.SurfaceData;
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 @@ public class D3DScreenUpdateManager extends ScreenUpdateManager
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 @@ public class D3DScreenUpdateManager extends ScreenUpdateManager
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);

View File

@ -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 @@ public class PrintServiceLookupProvider extends PrintServiceLookup {
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! */

View File

@ -187,7 +187,7 @@ void
AwtButton::NotifyListeners()
{
DoCallback("handleAction", "(JI)V", ::JVM_CurrentTimeMillis(NULL, 0),
(jint)AwtComponent::GetJavaModifiers());
(jint)AwtComponent::GetActionModifiers());
}
MsgRouting

View File

@ -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 @@ jint AwtComponent::GetShiftKeyLocation(UINT vkey, UINT flags)
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.

View File

@ -438,6 +438,7 @@ public:
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);

View File

@ -536,7 +536,7 @@ AwtList::WmNotify(UINT notifyCode)
else if (notifyCode == LBN_DBLCLK) {
DoCallback("handleAction", "(IJI)V", nCurrentSelection,
::JVM_CurrentTimeMillis(NULL, 0),
(jint)AwtComponent::GetJavaModifiers());
(jint)AwtComponent::GetActionModifiers());
}
}
}

View File

@ -56,6 +56,7 @@ public:
}
INLINE void Deselect(int pos) {
if (isMultiSelect) {
SendListMessage(LB_SETCARETINDEX, pos, FALSE);
SendListMessage(LB_SETSEL, FALSE, pos);
}
else {

View File

@ -667,7 +667,7 @@ void AwtMenuItem::DoCommand()
DoCallback("handleAction", "(Z)V", ((nState & MF_CHECKED) == 0));
} else {
DoCallback("handleAction", "(JI)V", ::JVM_CurrentTimeMillis(NULL, 0),
(jint)AwtComponent::GetJavaModifiers());
(jint)AwtComponent::GetActionModifiers());
}
}

View File

@ -409,7 +409,7 @@ MsgRouting AwtTrayIcon::WmBalloonUserClick(UINT flags, int x, int y)
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 @@ MsgRouting AwtTrayIcon::WmKeySelect(UINT flags, int x, int y)
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 @@ MsgRouting AwtTrayIcon::WmSelect(UINT flags, int x, int y)
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;
}

View File

@ -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 @@ public class Translator extends AccessibleContext
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 @@ public class Translator extends AccessibleContext
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 {

View File

@ -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 @@ void Jaccesswalker::addComponentNodes(long vmID, AccessibleContext context,
} 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;

View File

@ -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 @@ WinAccessBridge::getAccessibleContextWithFocus(HWND window, long *vmID, JOBJECT6
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) {

View File

@ -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");
}
}
}

View File

@ -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

View File

@ -23,9 +23,9 @@
/*
* @test
* @bug 8055463
* @bug 8055463 8153272
* @summary Test createFont APIs
* @run CreateFontArrayTest
* @run main CreateFontArrayTest
*/
import java.awt.Font;

View File

@ -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");
}
}
}

View File

@ -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();
}
}

View File

@ -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();
}
}

View File

@ -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");
}
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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();
}
}

View File

@ -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;
}
}

Some files were not shown because too many files have changed in this diff Show More