Hallo,
ich habe eine Frage an diejenigen unter Euch, die sich mit der Java Language Specification (Java SE 8 Edition) auskennen. Ich meine nämlich dort einen Fehler entdeckt zu haben. Auf S.348 heißt es zum Thema Exceptions:
"It is a compile-time error if a catch clause can catch checked exception class E1 and it is not the case that the try block corresponding to the catch clause can throw a checked exception class that is a subclass or superclass of E1, unless E1 is Exception or a superclass of Exception."
Aber fehlt in der Aufzählung nicht die Klasse E1 selbst? Müsste es nicht vielmehr heißen:
"...that is E1 (!) or a subclass or superclass of E1..." ?
E1 ist zwar Subtyp und auch Supertyp von E1 (die Subtyp-Relation ist reflexiv) aber E1 ist nicht Subklasse oder Superklasse von E1, also müsste E1 doch noch zusätzlich erwähnt werden. Oder es müsste heißen:
"...that is a subtype or supertype of E1..."
In dem darauffolgen Beispiel heißt es:
...
try {
throw new FileNotFoundException();
// Statement "can throw" FileNotFoundException.
// It is not the case that statement "can throw"
// a subtype or supertype of FileNotFoundException.
} catch (FileNotFoundException fnfe) {
// ... Handle exception ...
}
...
Aber FileNotFoundException ist doch auch "a subtype or supertype of FileNotFoundException".
Hier müsste es doch dann heißen:
"// It is not the case that statement "can throw"
// a subclass(!) or superclass(!) of FileNotFoundException."
Meine Frage ist, ob hier nicht 2 mal subclass und superclass mit subtype und supertype verwechselt wurde. Oder habe ich etwas falsch verstanden? Ich danke Euch für Eure Hilfe und bin gespannt auf Eure Antworten!
ich habe eine Frage an diejenigen unter Euch, die sich mit der Java Language Specification (Java SE 8 Edition) auskennen. Ich meine nämlich dort einen Fehler entdeckt zu haben. Auf S.348 heißt es zum Thema Exceptions:
"It is a compile-time error if a catch clause can catch checked exception class E1 and it is not the case that the try block corresponding to the catch clause can throw a checked exception class that is a subclass or superclass of E1, unless E1 is Exception or a superclass of Exception."
Aber fehlt in der Aufzählung nicht die Klasse E1 selbst? Müsste es nicht vielmehr heißen:
"...that is E1 (!) or a subclass or superclass of E1..." ?
E1 ist zwar Subtyp und auch Supertyp von E1 (die Subtyp-Relation ist reflexiv) aber E1 ist nicht Subklasse oder Superklasse von E1, also müsste E1 doch noch zusätzlich erwähnt werden. Oder es müsste heißen:
"...that is a subtype or supertype of E1..."
In dem darauffolgen Beispiel heißt es:
...
try {
throw new FileNotFoundException();
// Statement "can throw" FileNotFoundException.
// It is not the case that statement "can throw"
// a subtype or supertype of FileNotFoundException.
} catch (FileNotFoundException fnfe) {
// ... Handle exception ...
}
...
Aber FileNotFoundException ist doch auch "a subtype or supertype of FileNotFoundException".
Hier müsste es doch dann heißen:
"// It is not the case that statement "can throw"
// a subclass(!) or superclass(!) of FileNotFoundException."
Meine Frage ist, ob hier nicht 2 mal subclass und superclass mit subtype und supertype verwechselt wurde. Oder habe ich etwas falsch verstanden? Ich danke Euch für Eure Hilfe und bin gespannt auf Eure Antworten!