• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

About SecurityException

 
Edwin Dalorzo
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am working on the URLyBird assignment. I have read the instructions carefully again, and this time I found this statement:


Any unimplemented exceptions in this interface must all be created as member classes of the suncertify.db package. Each must have a zero argument constructor and a second constructor that takes a String that serves as the exception's description.


It says "any unimplemented exceptions". The thing is that the SecurityException is already part of the java.lang package, although it is not a checked exception.

But, given the statement above, I was wondering if I should implement the java.db.SecurityException.

I have to admit that I have already implemented a checked exception named java.db.SecurityException, but now I am having second thoughts about it.

What do you guys think?
 
Markus Hopper
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you have to implement your own java.db.SecurityException
 
David A. Scott
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just used the one from java.lang.

It's there to be used surely.

Can anyone give a reason why this was wrong?

David
 
Chris Hurst
Ranch Hand
Posts: 443
3
C++ Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I used the one from java.lang I may need to hunt the instrcutions out and ready carefully (B&S)
 
David A. Scott
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The only thing I can think is that the SecurityException is declared in the supplied interface which is not necessary for unchecked exceptions. But this doesn't mean it's invalid to do so.

Anyone?
 
Herman Schelti
Ranch Hand
Posts: 387
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

about SecurityException.

Javadoc says: "Thrown by the security manager to indicate a security violation".(SecurityManager is also a class in java.lang)

That's why I decided not to use this exception, but I made my own SecurityException in the suncertify.db package.


Herman
 
Edwin Dalorzo
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think I will join David and Herman for the two very good reasons they have provided:

  • The java.lang.SecurityException definition in Javadoc is not compliant with purpose of the suncerify.db.SecurityException documented in the assigment instructions. A java.lang.SecurityException must be thrown by the SecurityManager, while the suncerify.db.SecurityException is thrown in the context of the locking mechanism to ensure that a lock is not hold by another client.
  • The fact that the SecurityException is explicitly declared in the method signature of the provided Data interface conveys the idea that this is a different exception from the java.lang.SecurityException, which is actually an unchecked exception.



  • Thanks for you feedback, guys. Like you, I had already implemented the suncertify.db.SecurityException. Now I will simply stick to my design.

    Warm regards,
    Edwin Dalorzo
     
    Gabriel Vargas
    Ranch Hand
    Posts: 145
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi ranchers,

    There is a lot o threads about SecurityException, and, my conclusion is no correct answer!, it depends of your choices. There are good threads about that.

    NX: SecurityException unchecked or checked?

    Using java.lang.SecurityException

    B&S - Implication of SecurityException in DB interface methods

    I hope it helps.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic