Java 7 的组合/多捕获块是否有正式名称?
Is there an official name for Java 7's combined / multi-catch block?
在讨论 multiple-catch / combined catch 块 here 时,术语 "multiple catch block," 含义不明确 Java 7 特征:
try { .. } catch (ExceptionA | ExceptionB ex) { .. }
和"multiple catch blocks,"字面上的意思,多个catch块:
} catch (ExceptionA exa) { ..
} catch (ExceptionB exb) { .. }
我研究过 Java 7 功能是否有一个特定的官方名称,可以用来清楚地区分它与捕获多个异常的旧样式。但是,Oracle sources don't seem to name this feature anywhere, while some other sources (like Eclipse and SO) 称其为 "multi-catch" 块。
是否有正式的 Oracle 为该功能命名的名称?
Java Language Specification section 14.20 指的是 uni-catch 和 multi-catch 子句,这是官方的.
A catch clause whose exception parameter is denoted as a single class type is called a uni-catch clause.
A catch clause whose exception parameter is denoted as a union of types is called a multi-catch clause.
当然,在 Java 7 之前没有 multi-catch 子句,因此在引入 multi-catch 之前术语 "uni-catch" 从来都不是必需的。
术语 multi-catch 不同于具有多个(多个)catch 子句。
在讨论 multiple-catch / combined catch 块 here 时,术语 "multiple catch block," 含义不明确 Java 7 特征:
try { .. } catch (ExceptionA | ExceptionB ex) { .. }
和"multiple catch blocks,"字面上的意思,多个catch块:
} catch (ExceptionA exa) { ..
} catch (ExceptionB exb) { .. }
我研究过 Java 7 功能是否有一个特定的官方名称,可以用来清楚地区分它与捕获多个异常的旧样式。但是,Oracle sources don't seem to name this feature anywhere, while some other sources (like Eclipse and SO) 称其为 "multi-catch" 块。
是否有正式的 Oracle 为该功能命名的名称?
Java Language Specification section 14.20 指的是 uni-catch 和 multi-catch 子句,这是官方的.
A catch clause whose exception parameter is denoted as a single class type is called a uni-catch clause.
A catch clause whose exception parameter is denoted as a union of types is called a multi-catch clause.
当然,在 Java 7 之前没有 multi-catch 子句,因此在引入 multi-catch 之前术语 "uni-catch" 从来都不是必需的。
术语 multi-catch 不同于具有多个(多个)catch 子句。