textbender.g.lang
Class ThreadSafe.U

java.lang.Object
  extended by ThreadSafe.U
Enclosing class:
ThreadSafe

@ThreadSafe
public static final class ThreadSafe.U
extends Object

Thread-safety utilities. Includes utility methods for accessors to test the safety of code, prior to accessing it. For tests that code can use, after access, see ThreadRestricted.


Method Summary
static void disableChecking()
           
static boolean isCheckingEnabled()
          Returns true if thread-safety checks are actually performed (normal situation); false if they were disabled in this classloader's runtime.
static boolean isThreadSafe(Class objectType, Method method)
          Tests whether a method is effectively annotated thread safe.
static boolean isThreadSafe(Object o, String publicMethodName, Class... methodParameterTypes)
          Tests whether a public method is effectively annotated thread safe.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isCheckingEnabled

public static boolean isCheckingEnabled()
Returns true if thread-safety checks are actually performed (normal situation); false if they were disabled in this classloader's runtime. This flag affects the various thread-safety tests; if checking is disabled, they will always test positive (thread safe).

Checking may be disabled by code that lacks permission to read annotations. For instance, an unsigned applet may disable checking to avoid having AccessControlExceptions thrown by underlying library code that makes use of these tests.

See Also:
disableChecking()

disableChecking

public static void disableChecking()

isThreadSafe

public static boolean isThreadSafe(Class objectType,
                                   Method method)
Tests whether a method is effectively annotated thread safe.

Parameters:
objectType - actual (runtime) type of the object on which the method is called
method - of the object (declared or inherited)
Returns:
true iff the method is effectively annotated thread safe; or if checking is disabled

isThreadSafe

public static boolean isThreadSafe(Object o,
                                   String publicMethodName,
                                   Class... methodParameterTypes)
Tests whether a public method is effectively annotated thread safe.

Returns:
true iff the method is effectively annotated thread safe; or if checking is disabled
Throws:
IllegalArgumentException - if there is no such public method, per Class.getMethod()