Community
Participate
Working Groups
Create empty class that inherits UnicastRemoteObject. You get an error "Unhandled exception type java.rmi.RemoteException". javac produces much better error message "A default constructor cannot be created for this class because the constructor of its superclass throws the exception java.rmi.RemoteException. Define the constructor for this class explicitly."
Which version of javac have you been tested ? 1.3.1 and 1.4 only report poorly: package p1; import java.io.IOException; public class X extends Y { } class Y { Y() throws IOException { } } D:\>javac p1\X.java -d \test p1\X.java:5: unreported exception java.io.IOException; must be caught or declared to be thrown public class X extends Y { ^ 1 error
Anyway, improved error messages for unbound/visibility/ambiguity + unhandled exceptions on both default constructors and implicit super constructor calls. "Default constructor cannot handle exception type java.io.IOException thrown by implicit super constructor. Must define an explicit constructor" Fixed
I checked it with 1.2.2 (sometimes it's good to have an old compiler as well. Otherwise I'd have searched for a reason for hours).
here is the console output: comp:~>javac test.java test.java:4: A default constructor cannot be created for this class because the constructor of its superclass throws the exception java.rmi.RemoteException. Define the constructor for this class explicitly. public class test extends UnicastRemoteObject { ^ 1 error
Closing, fixed.