AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

override eroor

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Help
View previous topic :: View next topic  
Author Message
Daniel
Guest





PostPosted: Fri Jun 17, 2005 7:14 am    Post subject: override eroor Reply with quote



I want to implement rmi and get this error

test/PatientGui.java [151:1] getEnToonData() in test.PatientGui cannot
override getEnToonData() in test.ViewModel; overridden method does not throw
java.rmi.RemoteException

Public class PatientGui
void getEnToonData() throws java.rmi.RemoteException
{
:
}

Public Class ViewModel

void getEnToonData()
{
System.out.println("Moet nog gemaakt worden in de sub-class");
}

If i remove the throws java.rmi.RemoteException, the compiler tells me it
should be thrown.

How can i solve this?
Thanks

Daniel



Back to top
Fred L. Kleinschmidt
Guest





PostPosted: Fri Jun 17, 2005 2:50 pm    Post subject: Re: override eroor Reply with quote





Daniel wrote:
Quote:

I want to implement rmi and get this error

test/PatientGui.java [151:1] getEnToonData() in test.PatientGui cannot
override getEnToonData() in test.ViewModel; overridden method does not throw
java.rmi.RemoteException

Public class PatientGui
void getEnToonData() throws java.rmi.RemoteException
{
:
}

Public Class ViewModel

void getEnToonData()
{
System.out.println("Moet nog gemaakt worden in de sub-class");
}

If i remove the throws java.rmi.RemoteException, the compiler tells me it
should be thrown.

How can i solve this?
Thanks

Daniel

Show us how you REALLY coded this, not the incomplete typing above (as
you show it here, there is no overridden method, since neither class
extends the other). As it is, we can only guess what mistakes you might
have made.

--
Fred L. Kleinschmidt
Boeing Associate Technical Fellow
Technical Architect, Common User Interface Services
M/S 2R-94 (206)544-5225

Back to top
Dale King
Guest





PostPosted: Sat Jun 18, 2005 1:42 am    Post subject: Re: override eroor Reply with quote



Daniel wrote:
Quote:
I want to implement rmi and get this error

test/PatientGui.java [151:1] getEnToonData() in test.PatientGui cannot
override getEnToonData() in test.ViewModel; overridden method does not throw
java.rmi.RemoteException

Public class PatientGui
void getEnToonData() throws java.rmi.RemoteException
{
:
}

Public Class ViewModel

void getEnToonData()
{
System.out.println("Moet nog gemaakt worden in de sub-class");
}

If i remove the throws java.rmi.RemoteException, the compiler tells me it
should be thrown.

How can i solve this?

The issue is not specific to RemoteException, but with your design not
allowing for the possibility of unexpected behavior. Your ViewModel says
that it cannot throw a checked exception which RemoteException is and
that it must return data. What you need to think about is what is
supposed to happen if a subclass of ViewModel encounters a failure and
can't actually get the EnToonData?

Should it ignore any errors and return data anyway? This is usually not
desired, but if so you would have to catch the exception in the subclass
and return something.

Should it throw an unchecked (aka run-time) exception? In this case you
would catch the exception in the subclass and throw a runtime exception
(one that does not extend Exception). If you are using 1.4 or later you
would probably want to use the chained exception facility to point to
the RemoteException (see
<http://java.sun.com/j2se/1.5.0/docs/guide/lang/chained-exceptions.html>).

The most likely scenario is that your design should account for the fact
that this method can throw excpeptions and declare that the method in
ViewModel can throw a checked exception that users of that method have
to handle. This should not be RemoteException because that ties you to
RMI. You probably want to make your own exception class and declare that
it throws that. Your subclass would then do like the previous case
except that you use this exception class rather than the runtime exception.

--
Dale King

Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.