提交 223f2c15 编写于 作者: S son

6636369: sun.awt.datatransfer.DataTransferer contains double-check idiom

Summary: double-check has been removed
Reviewed-by: dav
上级 7e500f20
/* /*
* Copyright 2000-2007 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2000-2008 Sun Microsystems, Inc. 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
...@@ -270,17 +270,16 @@ public abstract class DataTransferer { ...@@ -270,17 +270,16 @@ public abstract class DataTransferer {
* instead, null will be returned. * instead, null will be returned.
*/ */
public static DataTransferer getInstance() { public static DataTransferer getInstance() {
if (transferer == null) {
synchronized (DataTransferer.class) { synchronized (DataTransferer.class) {
if (transferer == null) { if (transferer == null) {
final String name = SunToolkit. final String name = SunToolkit.getDataTransfererClassName();
getDataTransfererClassName();
if (name != null) { if (name != null) {
PrivilegedAction action = new PrivilegedAction() { PrivilegedAction<DataTransferer> action = new PrivilegedAction<DataTransferer>()
public Object run() { {
public DataTransferer run() {
Class cls = null; Class cls = null;
Method method = null; Method method = null;
Object ret = null; DataTransferer ret = null;
try { try {
cls = Class.forName(name); cls = Class.forName(name);
...@@ -298,8 +297,7 @@ public abstract class DataTransferer { ...@@ -298,8 +297,7 @@ public abstract class DataTransferer {
} }
if (cls != null) { if (cls != null) {
try { try {
method = cls.getDeclaredMethod method = cls.getDeclaredMethod("getInstanceImpl");
("getInstanceImpl");
method.setAccessible(true); method.setAccessible(true);
} catch (NoSuchMethodException e) { } catch (NoSuchMethodException e) {
e.printStackTrace(); e.printStackTrace();
...@@ -311,7 +309,7 @@ public abstract class DataTransferer { ...@@ -311,7 +309,7 @@ public abstract class DataTransferer {
} }
if (method != null) { if (method != null) {
try { try {
ret = method.invoke(null); ret = (DataTransferer) method.invoke(null);
} catch (InvocationTargetException e) { } catch (InvocationTargetException e) {
e.printStackTrace(); e.printStackTrace();
throw new AWTError("Cannot instantiate DataTransferer: " + name); throw new AWTError("Cannot instantiate DataTransferer: " + name);
...@@ -323,9 +321,7 @@ public abstract class DataTransferer { ...@@ -323,9 +321,7 @@ public abstract class DataTransferer {
return ret; return ret;
} }
}; };
transferer = (DataTransferer) transferer = AccessController.doPrivileged(action);
AccessController.doPrivileged(action);
}
} }
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册