--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XClipboard.java Wed Jun 03 18:26:06 2015 -0700
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XClipboard.java Thu Jun 04 15:24:30 2015 +0300
@@ -156,19 +156,24 @@
isSelectionNotifyProcessed = true;
boolean mustSchedule = false;
- synchronized (XClipboard.classLock) {
- if (targetsAtom2Clipboard == null) {
- targetsAtom2Clipboard = new HashMap<Long, XClipboard>(2);
+ XToolkit.awtLock();
+ try {
+ synchronized (XClipboard.classLock) {
+ if (targetsAtom2Clipboard == null) {
+ targetsAtom2Clipboard = new HashMap<Long, XClipboard>(2);
+ }
+ mustSchedule = targetsAtom2Clipboard.isEmpty();
+ targetsAtom2Clipboard.put(getTargetsPropertyAtom().getAtom(), this);
+ if (mustSchedule) {
+ XToolkit.addEventDispatcher(XWindow.getXAWTRootWindow().getWindow(),
+ new SelectionNotifyHandler());
+ }
}
- mustSchedule = targetsAtom2Clipboard.isEmpty();
- targetsAtom2Clipboard.put(getTargetsPropertyAtom().getAtom(), this);
if (mustSchedule) {
- XToolkit.addEventDispatcher(XWindow.getXAWTRootWindow().getWindow(),
- new SelectionNotifyHandler());
+ XToolkit.schedule(new CheckChangeTimerTask(), XClipboard.getPollInterval());
}
- }
- if (mustSchedule) {
- XToolkit.schedule(new CheckChangeTimerTask(), XClipboard.getPollInterval());
+ } finally {
+ XToolkit.awtUnlock();
}
}
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XRootWindow.java Wed Jun 03 18:26:06 2015 -0700
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XRootWindow.java Thu Jun 04 15:24:30 2015 +0300
@@ -31,18 +31,22 @@
* common logical ancestor
*/
class XRootWindow extends XBaseWindow {
- private static XRootWindow xawtRootWindow = null;
- static XRootWindow getInstance() {
- XToolkit.awtLock();
- try {
- if (xawtRootWindow == null) {
+ private static class LazyHolder {
+ private static final XRootWindow xawtRootWindow;
+
+ static {
+ XToolkit.awtLock();
+ try {
xawtRootWindow = new XRootWindow();
xawtRootWindow.init(xawtRootWindow.getDelayedParams().delete(DELAYED));
+ } finally {
+ XToolkit.awtUnlock();
}
- return xawtRootWindow;
- } finally {
- XToolkit.awtUnlock();
}
+
+ }
+ static XRootWindow getInstance() {
+ return LazyHolder.xawtRootWindow;
}
private XRootWindow() {