允许Java注释的语义将它们放在在函数体内的某个位置,例如,注释特定的函数调用,语句或表达式?
例如:
class MyClass {
void theFunc(Thing thing) {
String s = null;
@Catching(NullPointerException) //<< annotation ?
s = thing.getProp().getSub().getElem().getItem();
if(s==null)
System.out.println("null, you fool");
}
}
缩写经常写的(太常见,绝对!):
class MyClass {
void theFunc(Thing thing) {
String s = null;
try {
s = thing.getProp().getSub().getElem().getItem();
} catch(NullPointerException ex) { }
if(s==null)
System.out.println("null, you fool");
}
}
如果嵌入式注释的概念可行吗?或类似的东西?