Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#83 Reject throws clauses with runtime ex

release_3.1
closed
Check (274)
7
2012-10-10
2002-07-09
Paul Guyot
No

Java convention style says that it's a bad practice to put
RuntimeException 's in throws clauses and that they must
be in javadoc instead.
What about rejecting these clauses?

Note: requires that bug 579053 is fixed.

Discussion

  • Oliver Burn
    Oliver Burn
    2002-07-11

    Logged In: YES
    user_id=218824

    this is supported in the current release (2.3). See my
    comments in 579053.

     
  • Paul Guyot
    Paul Guyot
    2002-07-11

    Logged In: YES
    user_id=163572

    Actually, I wonder if it's not a mistake again, but I don't seem to
    see this feature implemented.

    Let's say that there is a method that throws two exceptions,
    UncheckedException and CheckedException. Indeed,
    checkstyle can know about it and doesn't complain if there are
    two @throws javadoc tags and only one exception in the throws
    clause. But it doesn't complain either if there is two exceptions in
    the throws clause while Sun says it's a bad practice.

    "(It is considered poor programming practice to include
    unchecked exceptions in the throws clause.)"
    http://java.sun.com/j2se/javadoc/writingdoccomments/index.html#
    throwstag

     
  • Oliver Burn
    Oliver Burn
    2002-07-11

    Logged In: YES
    user_id=218824

    ok - if I understand correctly, you are saying that if the option
    checkUnusedThrows is on, then report if an exception
    documented in a throws statement is a subclass of
    RuntimeException.

    It does make sense.

     
  • Logged In: YES
    user_id=746148

    RFE implemented by RedundantThrowsCheck.
    Integrated in 3.1