提交 b74bb9c1 编写于 作者: P pchelko

8029893: Remove reflection from DataTransferer.getInstance

Reviewed-by: anthony, serb
上级 d245e832
...@@ -89,7 +89,7 @@ public class CDataTransferer extends DataTransferer { ...@@ -89,7 +89,7 @@ public class CDataTransferer extends DataTransferer {
private static CDataTransferer fTransferer; private static CDataTransferer fTransferer;
public static synchronized CDataTransferer getInstanceImpl() { static synchronized CDataTransferer getInstanceImpl() {
if (fTransferer == null) { if (fTransferer == null) {
fTransferer = new CDataTransferer(); fTransferer = new CDataTransferer();
} }
......
/* /*
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2014, 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
...@@ -42,6 +42,7 @@ import java.util.concurrent.Callable; ...@@ -42,6 +42,7 @@ import java.util.concurrent.Callable;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import sun.awt.*; import sun.awt.*;
import sun.awt.datatransfer.DataTransferer;
import sun.lwawt.*; import sun.lwawt.*;
import sun.lwawt.LWWindowPeer.PeerType; import sun.lwawt.LWWindowPeer.PeerType;
import sun.security.action.GetBooleanAction; import sun.security.action.GetBooleanAction;
...@@ -112,8 +113,6 @@ public final class LWCToolkit extends LWToolkit { ...@@ -112,8 +113,6 @@ public final class LWCToolkit extends LWToolkit {
private static final boolean inAWT; private static final boolean inAWT;
public LWCToolkit() { public LWCToolkit() {
SunToolkit.setDataTransfererClassName("sun.lwawt.macosx.CDataTransferer");
areExtraMouseButtonsEnabled = Boolean.parseBoolean(System.getProperty("sun.awt.enableExtraMouseButtons", "true")); areExtraMouseButtonsEnabled = Boolean.parseBoolean(System.getProperty("sun.awt.enableExtraMouseButtons", "true"));
//set system property if not yet assigned //set system property if not yet assigned
System.setProperty("sun.awt.enableExtraMouseButtons", ""+areExtraMouseButtonsEnabled); System.setProperty("sun.awt.enableExtraMouseButtons", ""+areExtraMouseButtonsEnabled);
...@@ -441,6 +440,11 @@ public final class LWCToolkit extends LWToolkit { ...@@ -441,6 +440,11 @@ public final class LWCToolkit extends LWToolkit {
return true; return true;
} }
@Override
public DataTransferer getDataTransferer() {
return CDataTransferer.getInstanceImpl();
}
@Override @Override
public boolean isAlwaysOnTopSupported() { public boolean isAlwaysOnTopSupported() {
return true; return true;
......
/* /*
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1996, 2014, 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
...@@ -570,7 +570,7 @@ public class DataFlavor implements Externalizable, Cloneable { ...@@ -570,7 +570,7 @@ public class DataFlavor implements Externalizable, Cloneable {
if (DataTransferer.isFlavorCharsetTextType(this) && if (DataTransferer.isFlavorCharsetTextType(this) &&
(isRepresentationClassInputStream() || (isRepresentationClassInputStream() ||
isRepresentationClassByteBuffer() || isRepresentationClassByteBuffer() ||
DataTransferer.byteArrayClass.equals(representationClass))) byte[].class.equals(representationClass)))
{ {
params += ";charset=" + DataTransferer.getTextCharset(this); params += ";charset=" + DataTransferer.getTextCharset(this);
} }
...@@ -1015,7 +1015,7 @@ public class DataFlavor implements Externalizable, Cloneable { ...@@ -1015,7 +1015,7 @@ public class DataFlavor implements Externalizable, Cloneable {
!(isRepresentationClassReader() || !(isRepresentationClassReader() ||
String.class.equals(representationClass) || String.class.equals(representationClass) ||
isRepresentationClassCharBuffer() || isRepresentationClassCharBuffer() ||
DataTransferer.charArrayClass.equals(representationClass))) char[].class.equals(representationClass)))
{ {
String thisCharset = String thisCharset =
DataTransferer.canonicalName(getParameter("charset")); DataTransferer.canonicalName(getParameter("charset"));
...@@ -1100,8 +1100,7 @@ public class DataFlavor implements Externalizable, Cloneable { ...@@ -1100,8 +1100,7 @@ public class DataFlavor implements Externalizable, Cloneable {
!(isRepresentationClassReader() || !(isRepresentationClassReader() ||
String.class.equals(representationClass) || String.class.equals(representationClass) ||
isRepresentationClassCharBuffer() || isRepresentationClassCharBuffer() ||
DataTransferer.charArrayClass.equals char[].class.equals(representationClass)))
(representationClass)))
{ {
String charset = String charset =
DataTransferer.canonicalName(getParameter("charset")); DataTransferer.canonicalName(getParameter("charset"));
......
/* /*
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2014, 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
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
package sun.awt; package sun.awt;
import sun.awt.datatransfer.DataTransferer;
import java.awt.*; import java.awt.*;
import java.awt.dnd.*; import java.awt.dnd.*;
import java.awt.dnd.peer.DragSourceContextPeer; import java.awt.dnd.peer.DragSourceContextPeer;
...@@ -184,6 +186,11 @@ public class HToolkit extends SunToolkit ...@@ -184,6 +186,11 @@ public class HToolkit extends SunToolkit
return false; return false;
} }
@Override
public DataTransferer getDataTransferer() {
return null;
}
public GlobalCursorManager getGlobalCursorManager() public GlobalCursorManager getGlobalCursorManager()
throws HeadlessException { throws HeadlessException {
throw new HeadlessException(); throw new HeadlessException();
......
/* /*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2014, 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
...@@ -46,6 +46,7 @@ import java.util.concurrent.locks.Condition; ...@@ -46,6 +46,7 @@ import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantLock;
import sun.awt.datatransfer.DataTransferer;
import sun.security.util.SecurityConstants; import sun.security.util.SecurityConstants;
import sun.util.logging.PlatformLogger; import sun.util.logging.PlatformLogger;
import sun.misc.SoftCache; import sun.misc.SoftCache;
...@@ -203,6 +204,8 @@ public abstract class SunToolkit extends Toolkit ...@@ -203,6 +204,8 @@ public abstract class SunToolkit extends Toolkit
public abstract boolean isTraySupported(); public abstract boolean isTraySupported();
public abstract DataTransferer getDataTransferer();
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public abstract FontPeer getFontPeer(String name, int style); public abstract FontPeer getFontPeer(String name, int style);
...@@ -1191,19 +1194,6 @@ public abstract class SunToolkit extends Toolkit ...@@ -1191,19 +1194,6 @@ public abstract class SunToolkit extends Toolkit
return getStartupLocale(); return getStartupLocale();
} }
private static String dataTransfererClassName = null;
protected static void setDataTransfererClassName(String className) {
dataTransfererClassName = className;
}
public static String getDataTransfererClassName() {
if (dataTransfererClassName == null) {
Toolkit.getDefaultToolkit(); // transferer set during toolkit init
}
return dataTransfererClassName;
}
// Support for window closing event notifications // Support for window closing event notifications
private transient WindowClosingListener windowClosingListener = null; private transient WindowClosingListener windowClosingListener = null;
/** /**
......
/* /*
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2014, 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
...@@ -25,10 +25,10 @@ ...@@ -25,10 +25,10 @@
package sun.awt.datatransfer; package sun.awt.datatransfer;
import java.awt.AWTError;
import java.awt.EventQueue; import java.awt.EventQueue;
import java.awt.Image;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.FlavorMap; import java.awt.datatransfer.FlavorMap;
...@@ -137,16 +137,6 @@ import java.io.FilePermission; ...@@ -137,16 +137,6 @@ import java.io.FilePermission;
*/ */
public abstract class DataTransferer { public abstract class DataTransferer {
/**
* Cached value of Class.forName("[C");
*/
public static final Class charArrayClass;
/**
* Cached value of Class.forName("[B");
*/
public static final Class byteArrayClass;
/** /**
* The <code>DataFlavor</code> representing plain text with Unicode * The <code>DataFlavor</code> representing plain text with Unicode
* encoding, where: * encoding, where:
...@@ -241,15 +231,6 @@ public abstract class DataTransferer { ...@@ -241,15 +231,6 @@ public abstract class DataTransferer {
private static final PlatformLogger dtLog = PlatformLogger.getLogger("sun.awt.datatransfer.DataTransfer"); private static final PlatformLogger dtLog = PlatformLogger.getLogger("sun.awt.datatransfer.DataTransfer");
static { static {
Class tCharArrayClass = null, tByteArrayClass = null;
try {
tCharArrayClass = Class.forName("[C");
tByteArrayClass = Class.forName("[B");
} catch (ClassNotFoundException cannotHappen) {
}
charArrayClass = tCharArrayClass;
byteArrayClass = tByteArrayClass;
DataFlavor tPlainTextStringFlavor = null; DataFlavor tPlainTextStringFlavor = null;
try { try {
tPlainTextStringFlavor = new DataFlavor tPlainTextStringFlavor = new DataFlavor
...@@ -290,63 +271,8 @@ public abstract class DataTransferer { ...@@ -290,63 +271,8 @@ public abstract class DataTransferer {
* that in a headless environment, there may be no DataTransferer instance; * that in a headless environment, there may be no DataTransferer instance;
* instead, null will be returned. * instead, null will be returned.
*/ */
public static DataTransferer getInstance() { public static synchronized DataTransferer getInstance() {
synchronized (DataTransferer.class) { return ((SunToolkit) Toolkit.getDefaultToolkit()).getDataTransferer();
if (transferer == null) {
final String name = SunToolkit.getDataTransfererClassName();
if (name != null) {
PrivilegedAction<DataTransferer> action = new PrivilegedAction<DataTransferer>()
{
public DataTransferer run() {
Class cls = null;
Method method = null;
DataTransferer ret = null;
try {
cls = Class.forName(name);
} catch (ClassNotFoundException e) {
ClassLoader cl = ClassLoader.
getSystemClassLoader();
if (cl != null) {
try {
cls = cl.loadClass(name);
} catch (ClassNotFoundException ee) {
ee.printStackTrace();
throw new AWTError("DataTransferer not found: " + name);
}
}
}
if (cls != null) {
try {
method = cls.getDeclaredMethod("getInstanceImpl");
method.setAccessible(true);
} catch (NoSuchMethodException e) {
e.printStackTrace();
throw new AWTError("Cannot instantiate DataTransferer: " + name);
} catch (SecurityException e) {
e.printStackTrace();
throw new AWTError("Access is denied for DataTransferer: " + name);
}
}
if (method != null) {
try {
ret = (DataTransferer) method.invoke(null);
} catch (InvocationTargetException e) {
e.printStackTrace();
throw new AWTError("Cannot instantiate DataTransferer: " + name);
} catch (IllegalAccessException e) {
e.printStackTrace();
throw new AWTError("Cannot access DataTransferer: " + name);
}
}
return ret;
}
};
transferer = AccessController.doPrivileged(action);
}
}
}
return transferer;
} }
/** /**
...@@ -459,14 +385,14 @@ public abstract class DataTransferer { ...@@ -459,14 +385,14 @@ public abstract class DataTransferer {
if (flavor.isRepresentationClassReader() || if (flavor.isRepresentationClassReader() ||
String.class.equals(rep_class) || String.class.equals(rep_class) ||
flavor.isRepresentationClassCharBuffer() || flavor.isRepresentationClassCharBuffer() ||
DataTransferer.charArrayClass.equals(rep_class)) char[].class.equals(rep_class))
{ {
return true; return true;
} }
if (!(flavor.isRepresentationClassInputStream() || if (!(flavor.isRepresentationClassInputStream() ||
flavor.isRepresentationClassByteBuffer() || flavor.isRepresentationClassByteBuffer() ||
DataTransferer.byteArrayClass.equals(rep_class))) { byte[].class.equals(rep_class))) {
return false; return false;
} }
...@@ -490,8 +416,7 @@ public abstract class DataTransferer { ...@@ -490,8 +416,7 @@ public abstract class DataTransferer {
return (flavor.isRepresentationClassInputStream() || return (flavor.isRepresentationClassInputStream() ||
flavor.isRepresentationClassByteBuffer() || flavor.isRepresentationClassByteBuffer() ||
DataTransferer.byteArrayClass. byte[].class.equals(flavor.getRepresentationClass()));
equals(flavor.getRepresentationClass()));
} }
/** /**
...@@ -1243,7 +1168,7 @@ search: ...@@ -1243,7 +1168,7 @@ search:
format); format);
// Source data is a char array. Convert to a String and recur. // Source data is a char array. Convert to a String and recur.
} else if (charArrayClass.equals(flavor.getRepresentationClass())) { } else if (char[].class.equals(flavor.getRepresentationClass())) {
if (!(isFlavorCharsetTextType(flavor) && isTextFormat(format))) { if (!(isFlavorCharsetTextType(flavor) && isTextFormat(format))) {
throw new IOException throw new IOException
("cannot transfer non-text data as char array"); ("cannot transfer non-text data as char array");
...@@ -1274,7 +1199,7 @@ search: ...@@ -1274,7 +1199,7 @@ search:
// Source data is a byte array. For arbitrary flavors, simply return // Source data is a byte array. For arbitrary flavors, simply return
// the array. For text flavors, decode back to a String and recur to // the array. For text flavors, decode back to a String and recur to
// reencode according to the requested format. // reencode according to the requested format.
} else if (byteArrayClass.equals(flavor.getRepresentationClass())) { } else if (byte[].class.equals(flavor.getRepresentationClass())) {
byte[] bytes = (byte[])obj; byte[] bytes = (byte[])obj;
if (isFlavorCharsetTextType(flavor) && isTextFormat(format)) { if (isFlavorCharsetTextType(flavor) && isTextFormat(format)) {
...@@ -1651,7 +1576,7 @@ search: ...@@ -1651,7 +1576,7 @@ search:
// Target data is a char array. Recur to obtain String and convert to // Target data is a char array. Recur to obtain String and convert to
// char array. // char array.
} else if (charArrayClass.equals(flavor.getRepresentationClass())) { } else if (char[].class.equals(flavor.getRepresentationClass())) {
if (!(isFlavorCharsetTextType(flavor) && isTextFormat(format))) { if (!(isFlavorCharsetTextType(flavor) && isTextFormat(format))) {
throw new IOException throw new IOException
("cannot transfer non-text data as char array"); ("cannot transfer non-text data as char array");
...@@ -1679,7 +1604,7 @@ search: ...@@ -1679,7 +1604,7 @@ search:
// the raw bytes. For text flavors, convert to a String to strip // the raw bytes. For text flavors, convert to a String to strip
// terminators and search-and-replace EOLN, then reencode according to // terminators and search-and-replace EOLN, then reencode according to
// the requested flavor. // the requested flavor.
} else if (byteArrayClass.equals(flavor.getRepresentationClass())) { } else if (byte[].class.equals(flavor.getRepresentationClass())) {
if (isFlavorCharsetTextType(flavor) && isTextFormat(format)) { if (isFlavorCharsetTextType(flavor) && isTextFormat(format)) {
theObject = translateBytesToString( theObject = translateBytesToString(
bytes, format, localeTransferable bytes, format, localeTransferable
...@@ -1807,7 +1732,7 @@ search: ...@@ -1807,7 +1732,7 @@ search:
theObject = constructFlavoredObject(reader, flavor, Reader.class); theObject = constructFlavoredObject(reader, flavor, Reader.class);
// Target data is a byte array // Target data is a byte array
} else if (byteArrayClass.equals(flavor.getRepresentationClass())) { } else if (byte[].class.equals(flavor.getRepresentationClass())) {
if(isFlavorCharsetTextType(flavor) && isTextFormat(format)) { if(isFlavorCharsetTextType(flavor) && isTextFormat(format)) {
theObject = translateBytesToString(inputStreamToByteArray(str), format, localeTransferable) theObject = translateBytesToString(inputStreamToByteArray(str), format, localeTransferable)
.getBytes(DataTransferer.getTextCharset(flavor)); .getBytes(DataTransferer.getTextCharset(flavor));
...@@ -2857,7 +2782,7 @@ search: ...@@ -2857,7 +2782,7 @@ search:
HashMap decodedTextRepresentationsMap = new HashMap(4, 1.0f); HashMap decodedTextRepresentationsMap = new HashMap(4, 1.0f);
decodedTextRepresentationsMap.put decodedTextRepresentationsMap.put
(DataTransferer.charArrayClass, Integer.valueOf(0)); (char[].class, Integer.valueOf(0));
decodedTextRepresentationsMap.put decodedTextRepresentationsMap.put
(java.nio.CharBuffer.class, Integer.valueOf(1)); (java.nio.CharBuffer.class, Integer.valueOf(1));
decodedTextRepresentationsMap.put decodedTextRepresentationsMap.put
...@@ -2873,7 +2798,7 @@ search: ...@@ -2873,7 +2798,7 @@ search:
HashMap encodedTextRepresentationsMap = new HashMap(3, 1.0f); HashMap encodedTextRepresentationsMap = new HashMap(3, 1.0f);
encodedTextRepresentationsMap.put encodedTextRepresentationsMap.put
(DataTransferer.byteArrayClass, Integer.valueOf(0)); (byte[].class, Integer.valueOf(0));
encodedTextRepresentationsMap.put encodedTextRepresentationsMap.put
(java.nio.ByteBuffer.class, Integer.valueOf(1)); (java.nio.ByteBuffer.class, Integer.valueOf(1));
encodedTextRepresentationsMap.put encodedTextRepresentationsMap.put
......
/* /*
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2014, 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
...@@ -77,11 +77,9 @@ public class XDataTransferer extends DataTransferer { ...@@ -77,11 +77,9 @@ public class XDataTransferer extends DataTransferer {
private static XDataTransferer transferer; private static XDataTransferer transferer;
static XDataTransferer getInstanceImpl() { static synchronized XDataTransferer getInstanceImpl() {
synchronized (XDataTransferer.class) { if (transferer == null) {
if (transferer == null) { transferer = new XDataTransferer();
transferer = new XDataTransferer();
}
} }
return transferer; return transferer;
} }
...@@ -411,7 +409,7 @@ public class XDataTransferer extends DataTransferer { ...@@ -411,7 +409,7 @@ public class XDataTransferer extends DataTransferer {
if (df.getRepresentationClass() != null && if (df.getRepresentationClass() != null &&
(df.isRepresentationClassInputStream() || (df.isRepresentationClassInputStream() ||
df.isRepresentationClassByteBuffer() || df.isRepresentationClassByteBuffer() ||
byteArrayClass.equals(df.getRepresentationClass()))) { byte[].class.equals(df.getRepresentationClass()))) {
natives.add(mimeType); natives.add(mimeType);
} }
......
/* /*
* Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2002, 2014, 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
...@@ -47,6 +47,7 @@ import java.util.*; ...@@ -47,6 +47,7 @@ import java.util.*;
import javax.swing.LookAndFeel; import javax.swing.LookAndFeel;
import javax.swing.UIDefaults; import javax.swing.UIDefaults;
import sun.awt.*; import sun.awt.*;
import sun.awt.datatransfer.DataTransferer;
import sun.font.FontConfigManager; import sun.font.FontConfigManager;
import sun.java2d.SunGraphicsEnvironment; import sun.java2d.SunGraphicsEnvironment;
import sun.misc.PerformanceLogger; import sun.misc.PerformanceLogger;
...@@ -300,8 +301,6 @@ public final class XToolkit extends UNIXToolkit implements Runnable { ...@@ -300,8 +301,6 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
return awtAppClassName; return awtAppClassName;
} }
static final String DATA_TRANSFERER_CLASS_NAME = "sun.awt.X11.XDataTransferer";
public XToolkit() { public XToolkit() {
super(); super();
if (PerformanceLogger.loggingEnabled()) { if (PerformanceLogger.loggingEnabled()) {
...@@ -323,7 +322,6 @@ public final class XToolkit extends UNIXToolkit implements Runnable { ...@@ -323,7 +322,6 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
init(); init();
XWM.init(); XWM.init();
SunToolkit.setDataTransfererClassName(DATA_TRANSFERER_CLASS_NAME);
PrivilegedAction<Thread> action = new PrivilegedAction() { PrivilegedAction<Thread> action = new PrivilegedAction() {
public Thread run() { public Thread run() {
...@@ -1125,6 +1123,11 @@ public final class XToolkit extends UNIXToolkit implements Runnable { ...@@ -1125,6 +1123,11 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
return false; return false;
} }
@Override
public DataTransferer getDataTransferer() {
return XDataTransferer.getInstanceImpl();
}
/** /**
* Returns the supported cursor size * Returns the supported cursor size
*/ */
......
/* /*
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2014, 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
...@@ -159,13 +159,9 @@ public class WDataTransferer extends DataTransferer { ...@@ -159,13 +159,9 @@ public class WDataTransferer extends DataTransferer {
private static WDataTransferer transferer; private static WDataTransferer transferer;
public static WDataTransferer getInstanceImpl() { static synchronized WDataTransferer getInstanceImpl() {
if (transferer == null) { if (transferer == null) {
synchronized (WDataTransferer.class) { transferer = new WDataTransferer();
if (transferer == null) {
transferer = new WDataTransferer();
}
}
} }
return transferer; return transferer;
} }
......
/* /*
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1996, 2014, 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
...@@ -41,6 +41,7 @@ import sun.awt.LightweightFrame; ...@@ -41,6 +41,7 @@ import sun.awt.LightweightFrame;
import sun.awt.SunToolkit; import sun.awt.SunToolkit;
import sun.awt.Win32GraphicsDevice; import sun.awt.Win32GraphicsDevice;
import sun.awt.Win32GraphicsEnvironment; import sun.awt.Win32GraphicsEnvironment;
import sun.awt.datatransfer.DataTransferer;
import sun.java2d.d3d.D3DRenderQueue; import sun.java2d.d3d.D3DRenderQueue;
import sun.java2d.opengl.OGLRenderQueue; import sun.java2d.opengl.OGLRenderQueue;
...@@ -210,8 +211,6 @@ public class WToolkit extends SunToolkit implements Runnable { ...@@ -210,8 +211,6 @@ public class WToolkit extends SunToolkit implements Runnable {
*/ */
public native void embeddedEventLoopIdleProcessing(); public native void embeddedEventLoopIdleProcessing();
public static final String DATA_TRANSFERER_CLASS_NAME = "sun.awt.windows.WDataTransferer";
static class ToolkitDisposer implements sun.java2d.DisposerRecord { static class ToolkitDisposer implements sun.java2d.DisposerRecord {
public void dispose() { public void dispose() {
WToolkit.postDispose(); WToolkit.postDispose();
...@@ -255,8 +254,6 @@ public class WToolkit extends SunToolkit implements Runnable { ...@@ -255,8 +254,6 @@ public class WToolkit extends SunToolkit implements Runnable {
// swallow the exception // swallow the exception
} }
SunToolkit.setDataTransfererClassName(DATA_TRANSFERER_CLASS_NAME);
// Enabled "live resizing" by default. It remains controlled // Enabled "live resizing" by default. It remains controlled
// by the native system though. // by the native system though.
setDynamicLayout(true); setDynamicLayout(true);
...@@ -514,6 +511,11 @@ public class WToolkit extends SunToolkit implements Runnable { ...@@ -514,6 +511,11 @@ public class WToolkit extends SunToolkit implements Runnable {
return true; return true;
} }
@Override
public DataTransferer getDataTransferer() {
return WDataTransferer.getInstanceImpl();
}
public KeyboardFocusManagerPeer getKeyboardFocusManagerPeer() public KeyboardFocusManagerPeer getKeyboardFocusManagerPeer()
throws HeadlessException throws HeadlessException
{ {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册