launderthrowable.java
来自「java concurrency in practice 源码. JAVA」· Java 代码 · 共 25 行
JAVA
25 行
package net.jcip.examples;/** * StaticUtilities * * @author Brian Goetz and Tim Peierls */public class LaunderThrowable { /** * Coerce an unchecked Throwable to a RuntimeException * <p/> * If the Throwable is an Error, throw it; if it is a * RuntimeException return it, otherwise throw IllegalStateException */ public static RuntimeException launderThrowable(Throwable t) { if (t instanceof RuntimeException) return (RuntimeException) t; else if (t instanceof Error) throw (Error) t; else throw new IllegalStateException("Not unchecked", t); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?