Daniel Thoma: Frage zu Vector

Beitrag lesen

Hallo Martin Jung,

Ja, was da steht, weiß ich auch.
war nicht belehrend gemeint, sondern als Kontextinformation für Mitleser (Archiv ...).

Ja, ich wollte auch nur klarstellen, dass mich das tatsächliche Verhalten interessiert hat. Ist etwas schroff ausgefallen.

Das meinte ich ja: Man _kann_ evtl. ganz normal weiterarbeiten, dies ist aber dann _bereits_ im Sinne der Spezifikation (im Gegensatz zu einem Bug in einer VM-Implementierung) nicht mehr garantiert. Derartigen Code betrachte ich daher als fehlerhafte Implementierung.

All exceptions in the Java programming language are precise: when the transfer of control takes place, all effects of the statements executed and expressions evaluated before the point from which the exception is thrown must appear to have taken place. No expressions, statements, or parts thereof that occur after the point from which the exception is thrown may appear to have been evaluated. If optimized code has speculatively executed some of the expressions or statements which follow the point at which the exception occurs, such code must be prepared to hide this speculative execution from the user-visible state of the program.
(Java VM Spec 2.16.2 Handling an Exception)

Nach eine Ausnahme muss also _immer_ der Zustand hergestellt sein, der vor der Ausnahme herrschte. Somit ist das Verhalten der VM auch von der Spezifikation garantiert.
Mit dem von Dir zitierten Satz ist folglich wohl eher gemeint, dass die VM die eine Anweisung nicht korrekt umsetzen kann, aber sehr wohl korrekt weiterarbeiten.
Normalerweise ist es natürlich kein besonders guter Stil so eine Ausnahme abzufangen, aber für einen Browser könnte es z.B. durchaus interessant sein, so eine Absturz durch ein Applet zu verhindern.

Grüße

Daniel