• Post Reply Bookmark Topic Watch Topic
  • New Topic

RemoteException Problem

 
James Du
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, all
I just wrote a test interface that extends java.rmi.Remote with a simple method without throws RemoteException. I compiled the unit expecting that an error could occur stating that all the methods in the interface must throws the RemoteException, but the unit compiled fine! Could anyone give an explanation?
I saw the following statement in the RMI specification:
Each method declaration in a remote interface must satisfy the requirements of a remote method declaration as follows:
- A remote method declaration must include the exception java.rmi.RemoteException (or one of its superclasses such as java.io.IOException or java.lang.Exception) in its throws clause, in addition to any application-specific exceptions (note that application specific exceptions do not have to extend java.rmi.RemoteException).

thanks in advance
-James
 
gautam shah
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by James Du:
Hi, all
I just wrote a test interface that extends java.rmi.Remote with a simple method without throws RemoteException. I compiled the unit expecting that an error could occur stating that all the methods in the interface must throws the RemoteException, but the unit compiled fine! Could anyone give an explanation?
I saw the following statement in the RMI specification:

thanks in advance
-James


if u want that compiler should bark on ur code then just make concrete implementation of your remore interface and then do RMIC on that. after that u could easily get what the spec means. .
 
Abdul Salam
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By rules an interface can extend other interfaces.
Let us say "myInterface" extends "java.rmi.Remote"(for no genuine reason) and it has a method which does not throw RemoteException.
"myImpl" is the implementation class.I don't want to use "myImpl" remotely,so it does not extend "UnicastRemoteObject".Now if I compile and run "myImpl" ,it should work.
For this reason it does not warn you at compile time.
But with "rmic" your intention to use "myInterface" remotely is clearer.So rmic issues a warning about invalid interface.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!