public final class Throwables extends Object
// get root cause 无限循环问题
Throwable e1 = new RuntimeException();
Throwable e2 = new RuntimeException();
//Fields.put(e1, "cause", e2);
//Fields.put(e2, "cause", e1);
e1.initCause(e2);
e2.initCause(e1);
Throwable e = e1;
while (e.getCause() != null) {
e = e.getCause();
System.out.println(e + ": " + System.identityHashCode(e));
}
| 限定符和类型 | 类和说明 |
|---|---|
static interface |
Throwables.ThrowingCallable<R,T extends Throwable>
Lambda function checked exception
|
static interface |
Throwables.ThrowingConsumer<E,T extends Throwable>
Lambda function checked exception
|
static interface |
Throwables.ThrowingFunction<E,R,T extends Throwable>
Lambda function checked exception
|
static interface |
Throwables.ThrowingRunnable<T extends Throwable> |
static interface |
Throwables.ThrowingSupplier<R,T extends Throwable>
Lambda function checked exception
|
| 构造器和说明 |
|---|
Throwables() |
Copyright © 2025. All rights reserved.