Re: JavaMemoryModel: Interaction between the memory model and exceptions

From: Jeremy Manson (jmanson@cs.umd.edu)
Date: Fri Apr 09 2004 - 22:41:50 EDT


> Bill Pugh wrote:
> > The only thing which is a little tricky here are asynchronous exceptions,
> > such as ThreadDeath and OutOfMemory. Are those exceptions required to be
> > precise?
> > The Real-time Java people have probably looked at this in more detail.
>
> All exceptions are required to be precise according to the JLS.
>
> OutOfMemoryError and StackOverflowError are not asynchronous exceptions -
> they can only occur synchronously in response to program actions.
>
> The only async exceptions are those caused by Thread.stop and internal VM
> errors. For the latter the correctness of the exception throw semantics
> seems to pale in the face of the fact that the VM is broken.
>

Although it is worth pointing out that the JLS actually does require them to
be precise (11.3.1-2). They did think about optimization, here, though:

The Java platform permits a small but bounded amount of execution to occur
before an asynchronous exception is thrown. This delay is permitted to allow
optimized code to detect and throw these exceptions at points where it is
practical to handle them while obeying the semantics of the Java programming
language.

                                        Jeremy
-------------------------------
JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel



This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:01:03 EDT