Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can I modify the interface?

 
David Kachen
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I want to add some methods throws IllegalArgumentException. In the implementation, I plan to check the parameters and if with them that something is wrong, I will throw IllegalArgumentException. It is admissible?

Best Regards..
 
Carlos Morillo
Ranch Hand
Posts: 221
Java Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi David,


Yes, you can do that, but there is no need to change the signature of the Sun interface methods,
since IllegalArgumentException extends RuntimeException and therefore it is NOT a checked Exception.

Hope this helps,


Carlos.
 
David Kachen
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Carlos, you are right..
But I mean a javadoc. In the javadoc I need to list all possible situations.
If I pre-suppose that IllegalArgumentException may be thrown, I need to describe it in the javadoc.
Such changes are allowed?
 
Carlos Morillo
Ranch Hand
Posts: 221
Java Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, there is no need.
You only document checked exceptions.
 
Roel De Nijs
Sheriff
Posts: 10232
129
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No changes are allowed to Sun's interface! Creating your own interface and redefining each method could be an option (and that's what I did)

 
Roel De Nijs
Sheriff
Posts: 10232
129
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Carlos Morillo wrote:You only document checked exceptions.

I also documented in javadoc the unchecked exceptions, although I didn't mention them in the method signatures. Just like for example the compareTo method from class Date.
 
David Kachen
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not going to change the method signature, I just want to competently write Javadoc.
 
David Kachen
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Roel, I understood you.

Thank you all
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic