javac是否有可能为以下过程生成无法访问的字节码?
public void ex06(String name) throws Exception {
File config = new File(name);
try (FileOutputStream fos = new FileOutputStream(config);
PrintWriter writer = new PrintWriter(new OutputStreamWriter(
fos , "rw"))) {
bar();
}
}
当我查看字节码的异常表(javap -v)时,有以下条目看起来很奇怪:
43 48 86 Class java/lang/Throwable
43 48 95 any
和
21 135 170 Class java/lang/Throwable
21 135 179 any
现在的问题是,只有类型"任何"的例外情况下,某些代码才可以访问。而不是Throwable被抓住了。有没有可能发生这种情况的情况?
======编辑====== 谢谢你到目前为止的答案。让我再举一条证据表明我真的不理解异常处理: 请考虑以下过程
Object constraintsLock;
private String[] constraints;
private String constraint;
public void fp01() {
// Add this constraint to the set for our web application
synchronized (constraintsLock) {
String results[] =
new String[constraints.length + 1];
for (int i = 0; i < constraints.length; i++)
results[i] = constraints[i];
results[constraints.length] = constraint;
constraints = results;
}
}
如果您查看字节码:
65: astore 4
67: aload_1
68: monitorexit
69: aload 4
和异常表
Exception table:
from to target type
7 62 65 any
65 69 65 any
这是否意味着这个家伙可以永远循环?