Handling of undeclared checked exceptions

When thinking about conversion issues in a planned Java extension, the following question came up, where I could not find information about. Maybe you can tell me:

If bytecode is created for a method (by a compiler extension) not declaring any exceptions, and within this bytecode a method is called that throws checked exceptions, will the virtual machine complain or forward those exception?

[407 byte] By [stefan.schulza] at [2007-11-26 20:23:34]
# 1

You can test this and you don't need anything special to do it.

Steps

1. Class A and B. Methd B.doit() throws unchecked exception. A.doit2() calls B.doit()

2. Modify B.doit() to throw a checked exception.

3. Compile only B.

4. Run A and see what happens.

I suspect checked exceptions are a compile time problem, not runtime. But that is just a guess. You could read the verification sections of the VM/Lang to find out specifically what it should do.

jschella at 2007-7-10 0:49:38 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 2
You are right. Thanks. Why didn't I think of this?So I did the test and it throws the exception as expected in opposite to the compiler complaining about unresolved compilation problems when I try to compile it later on. My question is answered. :)
stefan.schulza at 2007-7-10 0:49:38 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 3
No (known) existing implementation of a JVM verifies the correctness of the throws clauses at class load time or at run time. It's a compiler thing only.
Hotlicksa at 2007-7-10 0:49:38 > top of Java-index,Java HotSpot Virtual Machine,Specifications...