Merge pull request #857 from akka/wip-2688-switch-to-s.c.u.unsafe-detection-√
#2688 - Switching to s.c.u.Unsafe.instance for akka.util.Unsafe.instance
This commit is contained in:
commit
2866ecfa85
1 changed files with 1 additions and 19 deletions
|
|
@ -5,27 +5,9 @@
|
|||
|
||||
package akka.util;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
/**
|
||||
* INTERNAL API
|
||||
*/
|
||||
public final class Unsafe {
|
||||
public final static sun.misc.Unsafe instance;
|
||||
static {
|
||||
try {
|
||||
sun.misc.Unsafe found = null;
|
||||
for(Field field : sun.misc.Unsafe.class.getDeclaredFields()) {
|
||||
if (field.getType() == sun.misc.Unsafe.class) {
|
||||
field.setAccessible(true);
|
||||
found = (sun.misc.Unsafe) field.get(null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found == null) throw new IllegalStateException("Can't find instance of sun.misc.Unsafe");
|
||||
else instance = found;
|
||||
} catch(Throwable t) {
|
||||
throw new ExceptionInInitializerError(t);
|
||||
}
|
||||
}
|
||||
public final static sun.misc.Unsafe instance = scala.concurrent.util.Unsafe.instance;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue