• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 1855
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Darya Akbari
Ranch Hand
Posts: 1855
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator



.\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
Posts: 1855
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 329
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
 
Frans Janssen
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 357
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 1855
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
They worship nothing. They say it's because nothing lasts forever. Like this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic