提交 3304a305 编写于 作者: L lana

Merge

...@@ -224,3 +224,5 @@ c4908732fef5235f1b98cafe0ce507771ef7892c jdk8-b98 ...@@ -224,3 +224,5 @@ c4908732fef5235f1b98cafe0ce507771ef7892c jdk8-b98
5be9c5bfcfe9b2a40412b4fb364377d49de014eb jdk8-b100 5be9c5bfcfe9b2a40412b4fb364377d49de014eb jdk8-b100
6901612328239fbd471d20823113c1cf3fdaebee jdk8-b101 6901612328239fbd471d20823113c1cf3fdaebee jdk8-b101
8ed8e2b4b90e0ac9aa5b3efef51cd576a9db96a9 jdk8-b102 8ed8e2b4b90e0ac9aa5b3efef51cd576a9db96a9 jdk8-b102
e0f6039c0290b7381042a6fec3100a69a5a67e37 jdk8-b103
f1d8d15bfcb5ada858a942f8a31f6598f23214d1 jdk8-b104
...@@ -296,7 +296,7 @@ static unichar AWTKeyToMacShortcut(jint awtKey, BOOL doShift) { ...@@ -296,7 +296,7 @@ static unichar AWTKeyToMacShortcut(jint awtKey, BOOL doShift) {
case java_awt_event_KeyEvent_VK_HELP : macKey = NSHelpFunctionKey; break; case java_awt_event_KeyEvent_VK_HELP : macKey = NSHelpFunctionKey; break;
case java_awt_event_KeyEvent_VK_TAB : macKey = NSTabCharacter; break; case java_awt_event_KeyEvent_VK_TAB : macKey = NSTabCharacter; break;
case java_awt_event_KeyEvent_VK_ENTER : macKey = NSCarriageReturnCharacter; break; case java_awt_event_KeyEvent_VK_ENTER : macKey = NSNewlineCharacter; break;
case java_awt_event_KeyEvent_VK_BACK_SPACE : macKey = NSBackspaceCharacter; break; case java_awt_event_KeyEvent_VK_BACK_SPACE : macKey = NSBackspaceCharacter; break;
case java_awt_event_KeyEvent_VK_DELETE : macKey = NSDeleteCharacter; break; case java_awt_event_KeyEvent_VK_DELETE : macKey = NSDeleteCharacter; break;
case java_awt_event_KeyEvent_VK_CLEAR : macKey = NSClearDisplayFunctionKey; break; case java_awt_event_KeyEvent_VK_CLEAR : macKey = NSClearDisplayFunctionKey; break;
......
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
package com.sun.media.sound; package com.sun.media.sound;
import java.util.Arrays;
import javax.sound.sampled.*; import javax.sound.sampled.*;
/** /**
...@@ -46,11 +48,11 @@ public final class DataPusher implements Runnable { ...@@ -46,11 +48,11 @@ public final class DataPusher implements Runnable {
private final AudioFormat format; private final AudioFormat format;
// stream as source data // stream as source data
private AudioInputStream ais = null; private final AudioInputStream ais;
// byte array as source data // byte array as source data
private byte[] audioData = null; private final byte[] audioData;
private int audioDataByteLength = 0; private final int audioDataByteLength;
private int pos; private int pos;
private int newPos = -1; private int newPos = -1;
private boolean looping; private boolean looping;
...@@ -67,16 +69,22 @@ public final class DataPusher implements Runnable { ...@@ -67,16 +69,22 @@ public final class DataPusher implements Runnable {
private final int BUFFER_SIZE = 16384; private final int BUFFER_SIZE = 16384;
public DataPusher(SourceDataLine sourceLine, AudioFormat format, byte[] audioData, int byteLength) { public DataPusher(SourceDataLine sourceLine, AudioFormat format, byte[] audioData, int byteLength) {
this.audioData = audioData; this(sourceLine, format, null, audioData, byteLength);
this.audioDataByteLength = byteLength;
this.format = format;
this.source = sourceLine;
} }
public DataPusher(SourceDataLine sourceLine, AudioInputStream ais) { public DataPusher(SourceDataLine sourceLine, AudioInputStream ais) {
this(sourceLine, ais.getFormat(), ais, null, 0);
}
private DataPusher(final SourceDataLine source, final AudioFormat format,
final AudioInputStream ais, final byte[] audioData,
final int audioDataByteLength) {
this.source = source;
this.format = format;
this.ais = ais; this.ais = ais;
this.format = ais.getFormat(); this.audioDataByteLength = audioDataByteLength;
this.source = sourceLine; this.audioData = audioData == null ? null : Arrays.copyOf(audioData,
audioData.length);
} }
public synchronized void start() { public synchronized void start() {
......
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
*/ */
package com.sun.media.sound; package com.sun.media.sound;
import java.util.Arrays;
/** /**
* A standard director who chooses performers * A standard director who chooses performers
* by there keyfrom,keyto,velfrom,velto properties. * by there keyfrom,keyto,velfrom,velto properties.
...@@ -32,17 +34,16 @@ package com.sun.media.sound; ...@@ -32,17 +34,16 @@ package com.sun.media.sound;
*/ */
public final class ModelStandardDirector implements ModelDirector { public final class ModelStandardDirector implements ModelDirector {
ModelPerformer[] performers; private final ModelPerformer[] performers;
ModelDirectedPlayer player; private final ModelDirectedPlayer player;
boolean noteOnUsed = false; private boolean noteOnUsed = false;
boolean noteOffUsed = false; private boolean noteOffUsed = false;
public ModelStandardDirector(ModelPerformer[] performers, public ModelStandardDirector(final ModelPerformer[] performers,
ModelDirectedPlayer player) { final ModelDirectedPlayer player) {
this.performers = performers; this.performers = Arrays.copyOf(performers, performers.length);
this.player = player; this.player = player;
for (int i = 0; i < performers.length; i++) { for (final ModelPerformer p : this.performers) {
ModelPerformer p = performers[i];
if (p.isReleaseTriggered()) { if (p.isReleaseTriggered()) {
noteOffUsed = true; noteOffUsed = true;
} else { } else {
......
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
*/ */
package com.sun.media.sound; package com.sun.media.sound;
import java.util.Arrays;
/** /**
* A standard indexed director who chooses performers * A standard indexed director who chooses performers
* by there keyfrom,keyto,velfrom,velto properties. * by there keyfrom,keyto,velfrom,velto properties.
...@@ -32,22 +34,21 @@ package com.sun.media.sound; ...@@ -32,22 +34,21 @@ package com.sun.media.sound;
*/ */
public final class ModelStandardIndexedDirector implements ModelDirector { public final class ModelStandardIndexedDirector implements ModelDirector {
ModelPerformer[] performers; private final ModelPerformer[] performers;
ModelDirectedPlayer player; private final ModelDirectedPlayer player;
boolean noteOnUsed = false; private boolean noteOnUsed = false;
boolean noteOffUsed = false; private boolean noteOffUsed = false;
// Variables needed for index // Variables needed for index
byte[][] trantables; private byte[][] trantables;
int[] counters; private int[] counters;
int[][] mat; private int[][] mat;
public ModelStandardIndexedDirector(ModelPerformer[] performers, public ModelStandardIndexedDirector(final ModelPerformer[] performers,
ModelDirectedPlayer player) { final ModelDirectedPlayer player) {
this.performers = performers; this.performers = Arrays.copyOf(performers, performers.length);
this.player = player; this.player = player;
for (int i = 0; i < performers.length; i++) { for (final ModelPerformer p : this.performers) {
ModelPerformer p = performers[i];
if (p.isReleaseTriggered()) { if (p.isReleaseTriggered()) {
noteOffUsed = true; noteOffUsed = true;
} else { } else {
......
...@@ -38,7 +38,7 @@ import javax.sound.sampled.LineEvent; ...@@ -38,7 +38,7 @@ import javax.sound.sampled.LineEvent;
import javax.sound.sampled.LineUnavailableException; import javax.sound.sampled.LineUnavailableException;
/** /**
* Clip implemention for the SoftMixingMixer. * Clip implementation for the SoftMixingMixer.
* *
* @author Karl Helgason * @author Karl Helgason
*/ */
...@@ -357,7 +357,9 @@ public final class SoftMixingClip extends SoftMixingDataLine implements Clip { ...@@ -357,7 +357,9 @@ public final class SoftMixingClip extends SoftMixingDataLine implements Clip {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Buffer size does not represent an integral number of sample frames!"); "Buffer size does not represent an integral number of sample frames!");
this.data = data; if (data != null) {
this.data = Arrays.copyOf(data, data.length);
}
this.offset = offset; this.offset = offset;
this.bufferSize = bufferSize; this.bufferSize = bufferSize;
this.format = format; this.format = format;
......
...@@ -2426,7 +2426,8 @@ public abstract class KeyboardFocusManager ...@@ -2426,7 +2426,8 @@ public abstract class KeyboardFocusManager
focusLog.finest("Request {0}", String.valueOf(hwFocusRequest)); focusLog.finest("Request {0}", String.valueOf(hwFocusRequest));
} }
if (hwFocusRequest == null && if (hwFocusRequest == null &&
heavyweight == nativeFocusOwner) heavyweight == nativeFocusOwner &&
heavyweight.getContainingWindow() == nativeFocusedWindow)
{ {
if (descendant == currentFocusOwner) { if (descendant == currentFocusOwner) {
// Redundant request. // Redundant request.
......
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
package javax.sound.sampled; package javax.sound.sampled;
import java.util.Arrays;
/** /**
* <code>DataLine</code> adds media-related functionality to its * <code>DataLine</code> adds media-related functionality to its
* superinterface, <code>{@link Line}</code>. This functionality includes * superinterface, <code>{@link Line}</code>. This functionality includes
...@@ -282,9 +284,9 @@ public interface DataLine extends Line { ...@@ -282,9 +284,9 @@ public interface DataLine extends Line {
*/ */
public static class Info extends Line.Info { public static class Info extends Line.Info {
private AudioFormat[] formats; private final AudioFormat[] formats;
private int minBufferSize; private final int minBufferSize;
private int maxBufferSize; private final int maxBufferSize;
/** /**
* Constructs a data line's info object from the specified information, * Constructs a data line's info object from the specified information,
...@@ -304,7 +306,7 @@ public interface DataLine extends Line { ...@@ -304,7 +306,7 @@ public interface DataLine extends Line {
if (formats == null) { if (formats == null) {
this.formats = new AudioFormat[0]; this.formats = new AudioFormat[0];
} else { } else {
this.formats = formats; this.formats = Arrays.copyOf(formats, formats.length);
} }
this.minBufferSize = minBufferSize; this.minBufferSize = minBufferSize;
...@@ -329,8 +331,7 @@ public interface DataLine extends Line { ...@@ -329,8 +331,7 @@ public interface DataLine extends Line {
if (format == null) { if (format == null) {
this.formats = new AudioFormat[0]; this.formats = new AudioFormat[0];
} else { } else {
AudioFormat[] formats = { format }; this.formats = new AudioFormat[]{format};
this.formats = formats;
} }
this.minBufferSize = bufferSize; this.minBufferSize = bufferSize;
...@@ -373,10 +374,7 @@ public interface DataLine extends Line { ...@@ -373,10 +374,7 @@ public interface DataLine extends Line {
* @see #isFormatSupported(AudioFormat) * @see #isFormatSupported(AudioFormat)
*/ */
public AudioFormat[] getFormats() { public AudioFormat[] getFormats() {
return Arrays.copyOf(formats, formats.length);
AudioFormat[] returnedArray = new AudioFormat[formats.length];
System.arraycopy(formats, 0, returnedArray, 0, formats.length);
return returnedArray;
} }
/** /**
......
...@@ -1185,14 +1185,13 @@ public class JLabel extends JComponent implements SwingConstants, Accessible ...@@ -1185,14 +1185,13 @@ public class JLabel extends JComponent implements SwingConstants, Accessible
} }
/** /**
* Determine the bounding box of the character at the given * Returns the bounding box of the character at the given
* index into the string. The bounds are returned in local * index in the string. The bounds are returned in local
* coordinates. If the index is invalid an empty rectangle is * coordinates. If the index is invalid, <code>null</code> is returned.
* returned.
* *
* @param i the index into the String * @param i the index into the String
* @return the screen coordinates of the character's the bounding box, * @return the screen coordinates of the character's bounding box.
* if index is invalid returns an empty rectangle. * If the index is invalid, <code>null</code> is returned.
* @since 1.3 * @since 1.3
*/ */
public Rectangle getCharacterBounds(int i) { public Rectangle getCharacterBounds(int i) {
......
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
package sun.audio; package sun.audio;
import java.io.*; import java.io.*;
import java.util.Arrays;
import javax.sound.sampled.*; import javax.sound.sampled.*;
...@@ -65,12 +67,11 @@ public final class AudioData { ...@@ -65,12 +67,11 @@ public final class AudioData {
/** /**
* Constructor * Constructor
*/ */
public AudioData(byte buffer[]) { public AudioData(final byte[] buffer) {
// if we cannot extract valid format information, we resort to assuming
this.buffer = buffer; // the data will be 8k mono u-law in order to provide maximal backwards
// if we cannot extract valid format information, we resort to assuming the data will be 8k mono u-law // compatibility....
// in order to provide maximal backwards compatibility.... this(DEFAULT_FORMAT, buffer);
this.format = DEFAULT_FORMAT;
// okay, we need to extract the format and the byte buffer of data // okay, we need to extract the format and the byte buffer of data
try { try {
...@@ -90,9 +91,10 @@ public final class AudioData { ...@@ -90,9 +91,10 @@ public final class AudioData {
* Non-public constructor; this is the one we use in ADS and CADS * Non-public constructor; this is the one we use in ADS and CADS
* constructors. * constructors.
*/ */
AudioData(AudioFormat format, byte[] buffer) { AudioData(final AudioFormat format, final byte[] buffer) {
this.format = format; this.format = format;
this.buffer = buffer; if (buffer != null) {
this.buffer = Arrays.copyOf(buffer, buffer.length);
}
} }
} }
...@@ -98,8 +98,7 @@ public class ClipboardTransferable implements Transferable { ...@@ -98,8 +98,7 @@ public class ClipboardTransferable implements Transferable {
} }
flavors = DataTransferer.getInstance(). flavors = DataTransferer.getInstance().
setToSortedDataFlavorArray(flavorsToData.keySet(), setToSortedDataFlavorArray(flavorsToData.keySet());
flavorsForFormats);
} }
} finally { } finally {
clipboard.closeClipboard(); clipboard.closeClipboard();
......
...@@ -2405,15 +2405,6 @@ search: ...@@ -2405,15 +2405,6 @@ search:
return retval; return retval;
} }
/**
* Helper function to reduce a Map with DataFlavor keys to a DataFlavor
* array. The array will be sorted according to
* <code>DataFlavorComparator</code>.
*/
public static DataFlavor[] keysToDataFlavorArray(Map map) {
return setToSortedDataFlavorArray(map.keySet(), map);
}
/** /**
* Helper function to convert a Set of DataFlavors to a sorted array. * Helper function to convert a Set of DataFlavors to a sorted array.
* The array will be sorted according to <code>DataFlavorComparator</code>. * The array will be sorted according to <code>DataFlavorComparator</code>.
...@@ -2427,24 +2418,6 @@ search: ...@@ -2427,24 +2418,6 @@ search:
return flavors; return flavors;
} }
/**
* Helper function to convert a Set of DataFlavors to a sorted array.
* The array will be sorted according to a
* <code>DataFlavorComparator</code> created with the specified
* flavor-to-native map as an argument.
*/
public static DataFlavor[] setToSortedDataFlavorArray
(Set flavorsSet, Map flavorToNativeMap)
{
DataFlavor[] flavors = new DataFlavor[flavorsSet.size()];
flavorsSet.toArray(flavors);
Comparator comparator =
new DataFlavorComparator(flavorToNativeMap,
IndexedComparator.SELECT_WORST);
Arrays.sort(flavors, comparator);
return flavors;
}
/** /**
* Helper function to convert an InputStream to a byte[] array. * Helper function to convert an InputStream to a byte[] array.
*/ */
...@@ -2724,11 +2697,9 @@ search: ...@@ -2724,11 +2697,9 @@ search:
* application/x-java-* MIME types. Unknown application types are preferred * application/x-java-* MIME types. Unknown application types are preferred
* because if the user provides his own data flavor, it will likely be the * because if the user provides his own data flavor, it will likely be the
* most descriptive one. For flavors which are otherwise equal, the * most descriptive one. For flavors which are otherwise equal, the
* flavors' native formats are compared, with greater long values * flavors' string representation are compared in the alphabetical order.
* taking precedence.
*/ */
public static class DataFlavorComparator extends IndexedComparator { public static class DataFlavorComparator extends IndexedComparator {
protected final Map flavorToFormatMap;
private final CharsetComparator charsetComparator; private final CharsetComparator charsetComparator;
...@@ -2864,20 +2835,6 @@ search: ...@@ -2864,20 +2835,6 @@ search:
super(order); super(order);
charsetComparator = new CharsetComparator(order); charsetComparator = new CharsetComparator(order);
flavorToFormatMap = Collections.EMPTY_MAP;
}
public DataFlavorComparator(Map map) {
this(map, SELECT_BEST);
}
public DataFlavorComparator(Map map, boolean order) {
super(order);
charsetComparator = new CharsetComparator(order);
HashMap hashMap = new HashMap(map.size());
hashMap.putAll(map);
flavorToFormatMap = Collections.unmodifiableMap(hashMap);
} }
public int compare(Object obj1, Object obj2) { public int compare(Object obj1, Object obj2) {
...@@ -2973,10 +2930,9 @@ search: ...@@ -2973,10 +2930,9 @@ search:
} }
} }
// As a last resort, take the DataFlavor with the greater integer // The flavours are not equal but still not distinguishable.
// format. // Compare String representations in alphabetical order
return compareLongs(flavorToFormatMap, flavor1, flavor2, return flavor1.getMimeType().compareTo(flavor2.getMimeType());
UNKNOWN_OBJECT_LOSES_L);
} }
} }
......
...@@ -339,6 +339,8 @@ public class PSPrinterJob extends RasterPrinterJob { ...@@ -339,6 +339,8 @@ public class PSPrinterJob extends RasterPrinterJob {
*/ */
private static Properties mFontProps = null; private static Properties mFontProps = null;
private static boolean isMac;
/* Class static initialiser block */ /* Class static initialiser block */
static { static {
//enable priviledges so initProps can access system properties, //enable priviledges so initProps can access system properties,
...@@ -347,6 +349,8 @@ public class PSPrinterJob extends RasterPrinterJob { ...@@ -347,6 +349,8 @@ public class PSPrinterJob extends RasterPrinterJob {
new java.security.PrivilegedAction() { new java.security.PrivilegedAction() {
public Object run() { public Object run() {
mFontProps = initProps(); mFontProps = initProps();
String osName = System.getProperty("os.name");
isMac = osName.startsWith("Mac");
return null; return null;
} }
}); });
...@@ -473,6 +477,12 @@ public class PSPrinterJob extends RasterPrinterJob { ...@@ -473,6 +477,12 @@ public class PSPrinterJob extends RasterPrinterJob {
PrintService pServ = getPrintService(); PrintService pServ = getPrintService();
if (pServ != null) { if (pServ != null) {
mDestination = pServ.getName(); mDestination = pServ.getName();
if (isMac) {
PrintServiceAttributeSet psaSet = pServ.getAttributes() ;
if (psaSet != null) {
mDestination = psaSet.get(PrinterName.class).toString();
}
}
} }
} }
} }
...@@ -771,6 +781,12 @@ public class PSPrinterJob extends RasterPrinterJob { ...@@ -771,6 +781,12 @@ public class PSPrinterJob extends RasterPrinterJob {
PrintService pServ = getPrintService(); PrintService pServ = getPrintService();
if (pServ != null) { if (pServ != null) {
mDestination = pServ.getName(); mDestination = pServ.getName();
if (isMac) {
PrintServiceAttributeSet psaSet = pServ.getAttributes();
if (psaSet != null) {
mDestination = psaSet.get(PrinterName.class).toString() ;
}
}
} }
PrinterSpooler spooler = new PrinterSpooler(); PrinterSpooler spooler = new PrinterSpooler();
java.security.AccessController.doPrivileged(spooler); java.security.AccessController.doPrivileged(spooler);
......
...@@ -71,13 +71,17 @@ JNIEXPORT jlong JNICALL Java_sun_font_NullFontScaler_getGlyphImage ...@@ -71,13 +71,17 @@ JNIEXPORT jlong JNICALL Java_sun_font_NullFontScaler_getGlyphImage
void initLCDGammaTables(); void initLCDGammaTables();
/* placeholder for extern variable */ /* placeholder for extern variable */
static int initialisedFontIDs = 0;
FontManagerNativeIDs sunFontIDs; FontManagerNativeIDs sunFontIDs;
JNIEXPORT void JNICALL static void initFontIDs(JNIEnv *env) {
Java_sun_font_SunFontManager_initIDs
(JNIEnv *env, jclass cls) { jclass tmpClass;
jclass tmpClass = (*env)->FindClass(env, "sun/font/TrueTypeFont"); if (initialisedFontIDs) {
return;
}
tmpClass = (*env)->FindClass(env, "sun/font/TrueTypeFont");
sunFontIDs.ttReadBlockMID = sunFontIDs.ttReadBlockMID =
(*env)->GetMethodID(env, tmpClass, "readBlock", (*env)->GetMethodID(env, tmpClass, "readBlock",
"(Ljava/nio/ByteBuffer;II)I"); "(Ljava/nio/ByteBuffer;II)I");
...@@ -173,9 +177,20 @@ Java_sun_font_SunFontManager_initIDs ...@@ -173,9 +177,20 @@ Java_sun_font_SunFontManager_initIDs
(*env)->GetFieldID(env, tmpClass, "lcdSubPixPos", "Z"); (*env)->GetFieldID(env, tmpClass, "lcdSubPixPos", "Z");
initLCDGammaTables(); initLCDGammaTables();
initialisedFontIDs = 1;
} }
JNIEXPORT FontManagerNativeIDs getSunFontIDs() { JNIEXPORT void JNICALL
Java_sun_font_SunFontManager_initIDs
(JNIEnv *env, jclass cls) {
initFontIDs(env);
}
JNIEXPORT FontManagerNativeIDs getSunFontIDs(JNIEnv *env) {
initFontIDs(env);
return sunFontIDs; return sunFontIDs;
} }
......
...@@ -84,7 +84,7 @@ typedef struct FontManagerNativeIDs { ...@@ -84,7 +84,7 @@ typedef struct FontManagerNativeIDs {
/* Note: we share variable in the context of fontmanager lib /* Note: we share variable in the context of fontmanager lib
but we need access method to use it from separate rasterizer lib */ but we need access method to use it from separate rasterizer lib */
extern FontManagerNativeIDs sunFontIDs; extern FontManagerNativeIDs sunFontIDs;
JNIEXPORT FontManagerNativeIDs getSunFontIDs(); JNIEXPORT FontManagerNativeIDs getSunFontIDs(JNIEnv* env);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -245,7 +245,7 @@ public class UnixPrintServiceLookup extends PrintServiceLookup ...@@ -245,7 +245,7 @@ public class UnixPrintServiceLookup extends PrintServiceLookup
continue; continue;
} }
if ((defaultPrintService != null) if ((defaultPrintService != null)
&& printers[p].equals(defaultPrintService.getName())) { && printers[p].equals(getPrinterDestName(defaultPrintService))) {
printerList.add(defaultPrintService); printerList.add(defaultPrintService);
defaultIndex = printerList.size() - 1; defaultIndex = printerList.size() - 1;
} else { } else {
...@@ -270,11 +270,12 @@ public class UnixPrintServiceLookup extends PrintServiceLookup ...@@ -270,11 +270,12 @@ public class UnixPrintServiceLookup extends PrintServiceLookup
} else { } else {
int j; int j;
for (j=0; j<printServices.length; j++) { for (j=0; j<printServices.length; j++) {
if ((printServices[j] != null) && if (printServices[j] != null) {
(printers[p].equals(printServices[j].getName()))) { if (printers[p].equals(getPrinterDestName(printServices[j]))) {
printerList.add(printServices[j]); printerList.add(printServices[j]);
printServices[j] = null; printServices[j] = null;
break; break;
}
} }
} }
...@@ -360,6 +361,17 @@ public class UnixPrintServiceLookup extends PrintServiceLookup ...@@ -360,6 +361,17 @@ public class UnixPrintServiceLookup extends PrintServiceLookup
return true; return true;
} }
/*
* Gets the printer name compatible with the list of printers returned by
* the system when we query default or all the available printers.
*/
private String getPrinterDestName(PrintService ps) {
if (isMac()) {
return ((IPPPrintService)ps).getDest();
}
return ps.getName();
}
/* On a network with many (hundreds) of network printers, it /* On a network with many (hundreds) of network printers, it
* can save several seconds if you know all you want is a particular * can save several seconds if you know all you want is a particular
* printer, to ask for that printer rather than retrieving all printers. * printer, to ask for that printer rather than retrieving all printers.
...@@ -369,10 +381,12 @@ public class UnixPrintServiceLookup extends PrintServiceLookup ...@@ -369,10 +381,12 @@ public class UnixPrintServiceLookup extends PrintServiceLookup
if (name == null || name.equals("") || !checkPrinterName(name)) { if (name == null || name.equals("") || !checkPrinterName(name)) {
return null; return null;
} }
/* check is all printers are already available */ /* check if all printers are already available */
if (printServices != null) { if (printServices != null) {
for (PrintService printService : printServices) { for (PrintService printService : printServices) {
if (printService.getName().equals(name)) { PrinterName printerName =
(PrinterName)printService.getAttribute(PrinterName.class);
if (printerName.getValue().equals(name)) {
return printService; return printService;
} }
} }
...@@ -567,7 +581,7 @@ public class UnixPrintServiceLookup extends PrintServiceLookup ...@@ -567,7 +581,7 @@ public class UnixPrintServiceLookup extends PrintServiceLookup
defaultPrintService = null; defaultPrintService = null;
if (printServices != null) { if (printServices != null) {
for (int j=0; j<printServices.length; j++) { for (int j=0; j<printServices.length; j++) {
if (defaultPrinter.equals(printServices[j].getName())) { if (defaultPrinter.equals(getPrinterDestName(printServices[j]))) {
defaultPrintService = printServices[j]; defaultPrintService = printServices[j];
break; break;
} }
......
/* /*
* Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -346,13 +346,19 @@ JNIEXPORT jobject JNICALL ...@@ -346,13 +346,19 @@ JNIEXPORT jobject JNICALL
awt_GetComponent(JNIEnv* env, void* platformInfo) awt_GetComponent(JNIEnv* env, void* platformInfo)
{ {
Window window = (Window)platformInfo; Window window = (Window)platformInfo;
Widget widget = NULL;
jobject peer = NULL; jobject peer = NULL;
jobject target = NULL; jobject target = NULL;
AWT_LOCK(); AWT_LOCK();
target = (*env)->GetObjectField(env, peer, targetID); if (window != None) {
peer = JNU_CallStaticMethodByName(env, NULL, "sun/awt/X11/XToolkit",
"windowToXWindow", "(J)Lsun/awt/X11/XBaseWindow;", (jlong)window).l;
}
if ((peer != NULL) &&
(JNU_IsInstanceOfByName(env, peer, "sun/awt/X11/XWindow") == 1)) {
target = (*env)->GetObjectField(env, peer, targetID);
}
if (target == NULL) { if (target == NULL) {
JNU_ThrowNullPointerException(env, "NullPointerException"); JNU_ThrowNullPointerException(env, "NullPointerException");
...@@ -360,7 +366,6 @@ JNIEXPORT jobject JNICALL ...@@ -360,7 +366,6 @@ JNIEXPORT jobject JNICALL
return (jobject)NULL; return (jobject)NULL;
} }
AWT_UNLOCK(); AWT_UNLOCK();
return target; return target;
......
...@@ -67,14 +67,15 @@ Java_sun_java2d_opengl_WGLSurfaceData_initOps(JNIEnv *env, jobject wglsd, ...@@ -67,14 +67,15 @@ Java_sun_java2d_opengl_WGLSurfaceData_initOps(JNIEnv *env, jobject wglsd,
J2dTraceLn(J2D_TRACE_INFO, "WGLSurfaceData_initOps"); J2dTraceLn(J2D_TRACE_INFO, "WGLSurfaceData_initOps");
if (oglsdo == NULL) {
JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed.");
return;
}
if (wglsdo == NULL) { if (wglsdo == NULL) {
JNU_ThrowOutOfMemoryError(env, "creating native wgl ops"); JNU_ThrowOutOfMemoryError(env, "creating native wgl ops");
return; return;
} }
if (oglsdo == NULL) {
free(wglsdo);
JNU_ThrowOutOfMemoryError(env, "Initialization of SurfaceData failed.");
return;
}
oglsdo->privOps = wglsdo; oglsdo->privOps = wglsdo;
......
...@@ -391,9 +391,16 @@ Java_sun_awt_windows_WCustomCursor_createCursorIndirect( ...@@ -391,9 +391,16 @@ Java_sun_awt_windows_WCustomCursor_createCursorIndirect(
DASSERT(hCursor); DASSERT(hCursor);
AwtCursor::setPData(self, ptr_to_jlong(new AwtCursor(env, hCursor, self, xHotSpot, try {
yHotSpot, nW, nH, nSS, cols, AwtCursor::setPData(self, ptr_to_jlong(new AwtCursor(env, hCursor, self, xHotSpot,
(BYTE *)andMaskPtr))); yHotSpot, nW, nH, nSS, cols,
(BYTE *)andMaskPtr)));
} catch (...) {
if (cols) {
delete[] cols;
}
throw;
}
CATCH_BAD_ALLOC; CATCH_BAD_ALLOC;
} }
......
...@@ -510,6 +510,11 @@ void AwtFont::LoadMetrics(JNIEnv *env, jobject fontMetrics) ...@@ -510,6 +510,11 @@ void AwtFont::LoadMetrics(JNIEnv *env, jobject fontMetrics)
jobject font = env->GetObjectField(fontMetrics, AwtFont::fontID); jobject font = env->GetObjectField(fontMetrics, AwtFont::fontID);
AwtFont* awtFont = AwtFont::GetFont(env, font); AwtFont* awtFont = AwtFont::GetFont(env, font);
if (!awtFont) {
/* failed to get font */
return;
}
HDC hDC = ::GetDC(0); HDC hDC = ::GetDC(0);
DASSERT(hDC != NULL); DASSERT(hDC != NULL);
......
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
@test
@bug 8013611
@summary Tests showing a modal dialog with requesting focus in frame.
@author Anton.Tarasov: area=awt.focus
@library ../../regtesthelpers
@build Util
@run main JDK8013611
*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import test.java.awt.regtesthelpers.Util;
import java.awt.*;
public class JDK8013611 extends JFrame {
static JTextField textField = new JTextField("text");
static JButton button1 = new JButton("button1");
static JButton button2 = new JButton("button2");
static Robot robot;
static JDialog dialog;
static JButton button3 = new JButton("button3");
public static void main(String[] args) {
robot = Util.createRobot();
JDK8013611 frame = new JDK8013611();
frame.setLayout(new FlowLayout());
frame.add(textField);
frame.add(button1);
frame.add(button2);
frame.pack();
dialog = new JDialog(frame, true);
dialog.add(button3);
dialog.pack();
textField.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
dialog.setVisible(true);
}
});
button1.addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent e) {
button2.requestFocusInWindow();
}
});
frame.setVisible(true);
frame.test();
}
public void test() {
if (!testFocused(textField)) {
Util.clickOnComp(textField, robot);
if (!testFocused(textField)) {
throw new RuntimeException("Error: couldn't focus " + textField);
}
}
robot.keyPress(KeyEvent.VK_TAB);
robot.delay(50);
robot.keyRelease(KeyEvent.VK_TAB);
if (!testFocused(button3)) {
throw new RuntimeException("Test failed: dialog didn't get focus!");
}
System.out.println("Test passed.");
}
boolean testFocused(Component c) {
for (int i=0; i<10; i++) {
if (KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner() == c) {
return true;
}
Util.waitForIdle(robot);
}
return false;
}
}
...@@ -37,7 +37,7 @@ import sun.java2d.SunGraphics2D; ...@@ -37,7 +37,7 @@ import sun.java2d.SunGraphics2D;
*/ */
public final class Test8004859 { public final class Test8004859 {
private static Shape[] clips = {new Rectangle(0, 0, 1, 1), new Rectangle( private static Shape[] clips = {new Rectangle(0, 0, -1, -1), new Rectangle(
100, 100, -100, -100)}; 100, 100, -100, -100)};
private static boolean status = true; private static boolean status = true;
......
...@@ -35,11 +35,12 @@ import java.awt.event.*; ...@@ -35,11 +35,12 @@ import java.awt.event.*;
import javax.swing.*; import javax.swing.*;
public class ActionListenerCalledTwiceTest { public class ActionListenerCalledTwiceTest {
static String menuItems[] = { "Item1", "Item2", "Item3" }; static String menuItems[] = { "Item1", "Item2", "Item3", "Item4" };
static KeyStroke keyStrokes[] = { static KeyStroke keyStrokes[] = {
KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.META_MASK), KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.META_MASK),
KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0),
KeyStroke.getKeyStroke(KeyEvent.VK_UP, InputEvent.SHIFT_MASK), KeyStroke.getKeyStroke(KeyEvent.VK_UP, InputEvent.SHIFT_MASK),
KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.META_MASK)
}; };
static volatile int listenerCallCounter = 0; static volatile int listenerCallCounter = 0;
......
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
@bug 7173464
@summary Clipboard.getAvailableDataFlavors: Comparison method violates contract
@author Petr Pchelko
@run main DataFlavorComparatorTest
*/
import sun.awt.datatransfer.DataTransferer;
import java.awt.datatransfer.DataFlavor;
public class DataFlavorComparatorTest {
public static void main(String[] args) {
DataTransferer.DataFlavorComparator comparator = new DataTransferer.DataFlavorComparator();
DataFlavor flavor1 = DataFlavor.imageFlavor;
DataFlavor flavor2 = DataFlavor.selectionHtmlFlavor;
if (comparator.compare(flavor1, flavor2) == 0) {
throw new RuntimeException(flavor1.getMimeType() + " and " + flavor2.getMimeType() +
" should not be equal");
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册