ARM and repeating exceptions

Aleksey Shipilev aleksey.shipilev at gmail.com
Tue May 22 03:07:16 PDT 2012


Hi,

There is some understandable, but still weird behavior in ARM. Should
the code cache or throw the same exception on some op(), and close(),
then ARM block will throw IllegalArgumentException. The minimal test
case is [1]. I think it can be fixed with simple fix in javac
desugaring scheme, placing additional check if exception from close()
is actually the original exception, and not trying to suppress it.

Thanks,
Aleksey.

[1]

import java.io.IOException;

public class ArmTest {

    // fails with IllegalArgumentException at Throwable.addSuppressed()
    public static void main(String[] args) {
        try (MyAutoCloseable worker = new MyAutoCloseable()) {
            worker.doWork();
        } catch (IOException e) {
            throw new IllegalStateException("Chained", e);
        }
    }

    private static class MyAutoCloseable implements AutoCloseable {
        private static final IOException EXCEPTION = new IOException();
        public void doWork() throws IOException { throw EXCEPTION; }
        public void close() throws IOException { throw EXCEPTION; }
    }
}



More information about the compiler-dev mailing list