MCPcopy Create free account
hub / github.com/antlr/codebuff / newProxy

Method newProxy

output/java_guava/1.4.16/SimpleTimeLimiter.java:81–110  ·  view source on GitHub ↗
(
    final T target,
    Class<T> interfaceType,
    final long timeoutDuration,
    final TimeUnit timeoutUnit)

Source from the content-addressed store, hash-verified

79 }
80
81 @Override
82 public <T> T newProxy(
83 final T target,
84 Class<T> interfaceType,
85 final long timeoutDuration,
86 final TimeUnit timeoutUnit) {
87 checkNotNull(target);
88 checkNotNull(interfaceType);
89 checkNotNull(timeoutUnit);
90 checkArgument(timeoutDuration > 0, "bad timeout: %s", timeoutDuration);
91 checkArgument(interfaceType.isInterface(), "interfaceType must be an interface type");
92 final Set<Method> interruptibleMethods = findInterruptibleMethods(interfaceType);
93 InvocationHandler handler = new InvocationHandler() {
94 @Override
95 public Object invoke(Object obj, final Method method, final Object[] args) throws Throwable {
96 Callable<Object> callable = new Callable<Object>() {
97 @Override
98 public Object call() throws Exception {
99 try {
100 return method.invoke(target, args);
101 } catch (InvocationTargetException e) {
102 throw throwCause(e, false);
103 }
104 }
105 };
106 return callWithTimeout(callable, timeoutDuration, timeoutUnit, interruptibleMethods.contains(method));
107 }
108 };
109 return newProxy(interfaceType, handler);
110 }
111
112 // TODO: should this actually throw only ExecutionException?
113

Callers

nothing calls this directly

Calls 4

checkNotNullMethod · 0.45
checkArgumentMethod · 0.45
castMethod · 0.45

Tested by

no test coverage detected