ExceptionUsageTest: ExceptionUsagf$Foo.qux is falsely annotated.

Issue #135 closed
Michael Reif created an issue
@DoesNotThrowException(
            reason="just returns constant, is not final, class is private, may not be overridden",
            requires={}
        )
        public int qux() {
            return 42;
        }

This issue is related to issue #134 but more tricky. It's not obvious how to handle it. But we have this public, non-final method in a private, non-final class.

The method has (style-wise) the same signature as the method from issue #134 but this time it is declared within an inner class that appears to be private. However, even if the class is declared private there are no guarantees that the JVM will evaluate the class' modifier. (see JVM 9 spec 4.7 group 2 on page 102). Therefore, the class will most likely be package visible which renders the decision, whether the method can throw an exception or not, dependent on class' location. When the class is located in an open package, the method will throw an exception and not otherwise.

Again, I don't know if that can be expressed in the required clause or not.

Comments (3)

  1. Andreas M

    Similar to my comment in #134, the concrete implementation in this class for this method doesn't throw an exception. If we look at the hierarchy, it might be overridden and therefore any subclass implementation may throw an exception.

  2. Log in to comment