337 |
|
* @return a callable object |
338 |
|
* @throws NullPointerException if action null |
339 |
|
*/ |
340 |
< |
public static Callable<Object> callable(PrivilegedAction action) { |
340 |
> |
public static Callable<Object> callable(PrivilegedAction<?> action) { |
341 |
|
if (action == null) |
342 |
|
throw new NullPointerException(); |
343 |
< |
return new PrivilegedActionAdapter(action); |
343 |
> |
return new PrivilegedActionAdapter<Object>(action); |
344 |
|
} |
345 |
|
|
346 |
|
/** |
351 |
|
* @return a callable object |
352 |
|
* @throws NullPointerException if action null |
353 |
|
*/ |
354 |
< |
public static Callable<Object> callable(PrivilegedExceptionAction action) { |
354 |
> |
public static Callable<Object> callable(PrivilegedExceptionAction<?> action) { |
355 |
|
if (action == null) |
356 |
|
throw new NullPointerException(); |
357 |
< |
return new PrivilegedExceptionActionAdapter(action); |
357 |
> |
return new PrivilegedExceptionActionAdapter<Object>(action); |
358 |
|
} |
359 |
|
|
360 |
|
/** |
374 |
|
public static <T> Callable<T> privilegedCallable(Callable<T> callable) { |
375 |
|
if (callable == null) |
376 |
|
throw new NullPointerException(); |
377 |
< |
return new PrivilegedCallable(callable); |
377 |
> |
return new PrivilegedCallable<T>(callable); |
378 |
|
} |
379 |
|
|
380 |
|
/** |
398 |
|
public static <T> Callable<T> privilegedCallableUsingCurrentClassLoader(Callable<T> callable) { |
399 |
|
if (callable == null) |
400 |
|
throw new NullPointerException(); |
401 |
< |
return new PrivilegedCallableUsingCurrentClassLoader(callable); |
401 |
> |
return new PrivilegedCallableUsingCurrentClassLoader<T>(callable); |
402 |
|
} |
403 |
|
|
404 |
|
// Non-public classes supporting the public methods |
422 |
|
/** |
423 |
|
* A callable that runs given privileged action and returns its result |
424 |
|
*/ |
425 |
< |
static final class PrivilegedActionAdapter implements Callable<Object> { |
425 |
> |
static final class PrivilegedActionAdapter<T> implements Callable<Object> { |
426 |
|
PrivilegedActionAdapter(PrivilegedAction action) { |
427 |
|
this.action = action; |
428 |
|
} |
435 |
|
/** |
436 |
|
* A callable that runs given privileged exception action and returns its result |
437 |
|
*/ |
438 |
< |
static final class PrivilegedExceptionActionAdapter implements Callable<Object> { |
438 |
> |
static final class PrivilegedExceptionActionAdapter<T> implements Callable<Object> { |
439 |
|
PrivilegedExceptionActionAdapter(PrivilegedExceptionAction action) { |
440 |
|
this.action = action; |
441 |
|
} |
460 |
|
} |
461 |
|
|
462 |
|
public T call() throws Exception { |
463 |
< |
AccessController.doPrivileged(new PrivilegedAction() { |
464 |
< |
public Object run() { |
463 |
> |
AccessController.doPrivileged(new PrivilegedAction<T>() { |
464 |
> |
public T run() { |
465 |
|
try { |
466 |
|
result = task.call(); |
467 |
|
} catch (Exception ex) { |
496 |
|
} |
497 |
|
|
498 |
|
public T call() throws Exception { |
499 |
< |
AccessController.doPrivileged(new PrivilegedAction() { |
500 |
< |
public Object run() { |
499 |
> |
AccessController.doPrivileged(new PrivilegedAction<T>() { |
500 |
> |
public T run() { |
501 |
|
ClassLoader savedcl = null; |
502 |
|
Thread t = Thread.currentThread(); |
503 |
|
try { |
570 |
|
public Thread newThread(final Runnable r) { |
571 |
|
return super.newThread(new Runnable() { |
572 |
|
public void run() { |
573 |
< |
AccessController.doPrivileged(new PrivilegedAction() { |
573 |
> |
AccessController.doPrivileged(new PrivilegedAction<Object>() { |
574 |
|
public Object run() { |
575 |
|
Thread.currentThread().setContextClassLoader(ccl); |
576 |
|
r.run(); |