aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes B&S: How to difference between my and JDK's SecurityException? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "B&S: How to difference between my and JDK Watch "B&S: How to difference between my and JDK New topic
Author

B&S: How to difference between my and JDK's SecurityException?

Darya Akbari
Ranch Hand

Joined: Aug 21, 2004
Posts: 1855
Hi all,

I have a problem with my SecurityException during compilation.

My data interface class DB.java looks like:



The implementing class Data.java looks like:



Now, when I try to compile I get the error:


.\suncertify\db\Data.java:42: update(int,java.lang.String[],long) in suncertify.db.Data cannot implement update(int,java.lang.String[],long) in suncertify.db.DB; overridden method does not throw suncertify.db.SecurityException


How can I make sure that the compiler take my SecurityException (suncertify.db.SecurityException)
[ May 25, 2005: Message edited by: Darya Akbari ]

SCJP, SCJD, SCWCD, SCBCD
Frans Janssen
Ranch Hand

Joined: Dec 29, 2004
Posts: 357
Hi Darya,

Probably your compiler assumes java.lang.SecurityException in your DB interface. I would not know how to prevent that, without making changes to the interface.
(I tried, but I cannot reproduce your error here.)

You might therefore consider not to create your own SecurityException class. According to the following statement you need not make exceptions that already exist:
Any unimplemented exceptions in this interface must all be created as member classes of the suncertify.db package.


Frans.


SCJP 1.4, SCJD
Wei-ju Wu
Ranch Hand

Joined: Feb 16, 2005
Posts: 147
Hi Frans and Darya,

I just remembered this thread:

Security Exception

which relates to Darya's question. At that time it did not come to my mind that this could be another problem if java.lang.SecurityException is not used

So I guess the easiest way would really be to simply reuse the JDK exception.

Wei-ju
[ May 25, 2005: Message edited by: Wei-ju Wu ]

"The UrlyBird catches the certificate. And he's gonna FlyByNight"<br /> <br />SCJP 1.2/5.0, SCJD, SCBCD, SCWCD, SCEA
Darya Akbari
Ranch Hand

Joined: Aug 21, 2004
Posts: 1855
Hi Frans and Wei-ju,

I agree with you Frans that possibly we should use JDK's SecurityException but the following which Wei-ju is referring to Security Exception is still an open thread.

Since a security manager is the one who throws JDK's SecurityExcepion (java.lang.SecurityException) I stuck here because it's also said in the assignment that a security manager must not be used.

Nevertheless you both have passed SCJD and that is another reason to go for java.lang.SecurityException . But honestly I don't understand it

Regards,
Darya
Lara McCarver
Ranch Hand

Joined: Dec 09, 2003
Posts: 118


.\suncertify\db\Data.java:42: update(int,java.lang.String[],long) in suncertify.db.Data cannot implement update(int,java.lang.String[],long) in suncertify.db.DB; overridden method does not throw suncertify.db.SecurityException



I am sorry for editting this so many times. As others have suggested, I would use Sun's implementation of SecurityException... what do you gain by making your own? If you do want to use your own, I think it would be OK to specify the precise exception within the interface method of your Data class:

update(...)
throws RecordNotFoundException, suncertify.db.SecurityException {
...}

If you do this, you are still using the DB interface... just clarifying what it means, but I don't think the clarification is actually changing the signature.
[ May 25, 2005: Message edited by: Lara McCarver ]
Darya Akbari
Ranch Hand

Joined: Aug 21, 2004
Posts: 1855
Hi Lara,

the only reason why I was going for my own SecurityException was because of the security manager issue as decribed in SecurityException

As Frans said, I don't dare to change the signature of the given data interface

Regards,
Darya
Ken Boyd
Ranch Hand

Joined: Dec 10, 2003
Posts: 329
You can create SecurityException.java under suncertify.db and use that in Data.java class instead of java.lang.SecurityException...

anything wrong in doing that...


SCJP, SCWCD, SCBCD, SCJD, BB Java2 and JSP1.1
Frans Janssen
Ranch Hand

Joined: Dec 29, 2004
Posts: 357
Nevertheless you both have passed SCJD and that is another reason to go for java.lang.SecurityException

My assignment's interface didn't have SecurityExceptions. So if I passed it, it is not because of my idea how to handle the SecurityException issue...

Frans.
Frans Janssen
Ranch Hand

Joined: Dec 29, 2004
Posts: 357
Back to your original problem: which compiler are you using? Because according to the Java language specification, the compiler should use your SecurityException in both the interface and the Data class.

I tried the JBuilder compiler and Sun's compiler, but with neither can I reproduce your compiler error.

Frans.
Darya Akbari
Ranch Hand

Joined: Aug 21, 2004
Posts: 1855
Hi Frans,

don't ask me why the heck it now compiles. I changed code back and fore and can't now reproduce the error by myself

So my own SecurityException is back in place and my doubts on JDK's SecurityException either

Thanks spending your time on the issue.

Regards,
Darya
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: B&S: How to difference between my and JDK's SecurityException?