Use AtomicInteger.class ClassLoader for Unsafe dection. See #102

This commit is contained in:
norman 2011-12-07 13:14:42 +01:00
parent 766525431d
commit 5cb865c4ce

View File

@ -15,6 +15,8 @@
*/
package org.jboss.netty.util;
import java.util.concurrent.atomic.AtomicInteger;
/**
* Utility which checks if {@value #UNSAFE} class can be found in the classpath
@ -28,6 +30,7 @@ package org.jboss.netty.util;
public class UnsafeDetectUtil {
private static final String UNSAFE = "sun.misc.Unsafe";
private static final boolean UNSAFE_FOUND = isUnsafeFound(AtomicInteger.class.getClassLoader());
public static boolean isUnsafeFound(ClassLoader loader) {
try {
@ -39,7 +42,7 @@ public class UnsafeDetectUtil {
}
public static boolean isUnsafeFound() {
return isUnsafeFound(UnsafeDetectUtil.class.getClassLoader());
return UNSAFE_FOUND;
}
private UnsafeDetectUtil() {