From ecc323233e2ff4f005e0d2b7ac62487954678977 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Mon, 11 Jun 2012 10:19:30 -0400 Subject: Forkjoin and fjbg are now always compiled in the build. * forkjoin.done/forkjoine.clean can test forkjoin source * fjbg.done/fjbg.clean can test fjbg source. --- src/forkjoin/scala/concurrent/util/Unsafe.java | 35 ++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/forkjoin/scala/concurrent/util/Unsafe.java (limited to 'src/forkjoin') diff --git a/src/forkjoin/scala/concurrent/util/Unsafe.java b/src/forkjoin/scala/concurrent/util/Unsafe.java new file mode 100644 index 0000000000..0cd48758d5 --- /dev/null +++ b/src/forkjoin/scala/concurrent/util/Unsafe.java @@ -0,0 +1,35 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +package scala.concurrent.util; + + + +import java.lang.reflect.Field; + + + +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); + } + } +} -- cgit v1.2.3