我正在编写一个函数,可以仅捕获特定类型的异常。
def myFunc[A <: Exception]() {
try {
println("Hello world") // or something else
} catch {
case a: A => // warning: abstract type pattern A is unchecked since it is eliminated by erasure
}
}
在这种情况下,绕过JVM类型擦除的正确方法是什么?