FileDocCategorySizeDatePackage
LangAccess.javaAPI DocAndroid 1.5 API5071Wed May 06 22:41:04 BST 2009org.apache.harmony.kernel.vm

LangAccess

public abstract class LangAccess extends Object
Bridge into java.lang from other trusted parts of the core library. Trusted packages either get seeded with an instance of this class directly or may call {@link #getInstance} on this class, to allow them to call into what would otherwise be package-scope functionality in java.lang.

Fields Summary
private static LangAccess
theInstance
unique instance of this class
Constructors Summary
Methods Summary
public abstract T[]getEnumValuesInOrder(java.lang.Class clazz)
Gets a shared array of the enum constants of a given class in declaration (ordinal) order. It is not safe to hand out this array to any user code.

param
clazz non-null; the class in question
return
null-ok; the class's list of enumerated constants in declaration order or null if the given class is not an enumeration

public static org.apache.harmony.kernel.vm.LangAccessgetInstance()
Gets the unique instance of this class. This is only allowed in very limited situations.

        /*
         * Only code on the bootclasspath is allowed to get at the
         * instance.
         */
        ClassLoader calling = VMStack.getCallingClassLoader2();
        ClassLoader current = LangAccess.class.getClassLoader();

        if ((calling != null) && (calling != current)) {
            throw new SecurityException("LangAccess access denied");
        }

        if (theInstance == null) {
            throw new UnsupportedOperationException("not yet initialized");
        }
        
        return theInstance;
    
public abstract voidparkFor(long nanos)
Parks the current thread for a particular number of nanoseconds, or indefinitely. If not indefinitely, this method unparks the thread after the given number of nanoseconds if no other thread unparks it first. If the thread has been "preemptively unparked," this method cancels that unparking and returns immediately. This method may also return spuriously (that is, without the thread being told to unpark and without the indicated amount of time elapsing).

See {@link java.util.concurrent.locks.LockSupport} for more in-depth information of the behavior of this method.

param
nanos number of nanoseconds to park for or 0 to park indefinitely
throws
IllegalArgumentException thrown if nanos < 0

public abstract voidparkUntil(long time)
Parks the current thread until the specified system time. This method attempts to unpark the current thread immediately after System.currentTimeMillis() reaches the specified value, if no other thread unparks it first. If the thread has been "preemptively unparked," this method cancels that unparking and returns immediately. This method may also return spuriously (that is, without the thread being told to unpark and without the indicated amount of time elapsing).

See {@link java.util.concurrent.locks.LockSupport} for more in-depth information of the behavior of this method.

param
time the time after which the thread should be unparked, in absolute milliseconds-since-the-epoch

public static voidsetInstance(org.apache.harmony.kernel.vm.LangAccess instance)
Sets the unique instance of this class. This may only be done once.

param
instance non-null; the instance


                           
         
        if (theInstance != null) {
            throw new UnsupportedOperationException("already initialized");
        }

        theInstance = instance;
    
public abstract voidunpark(java.lang.Thread thread)
Unparks the given thread. This unblocks the thread it if it was previously parked, or indicates that the thread is "preemptively unparked" if it wasn't already parked. The latter means that the next time the thread is told to park, it will merely clear its latent park bit and carry on without blocking.

See {@link java.util.concurrent.locks.LockSupport} for more in-depth information of the behavior of this method.

param
thread non-null; the thread to unpark