New issue
Advanced search Search tips

Issue 671655 link

Starred by 1 user

Issue metadata

Status: Untriaged
Owner: ----
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

Java Lint suppression failed on enum switch statement.

Project Member Reported by aber...@chromium.org, Dec 6 2016

Issue description

The following code gave newApi errors on BasicReason, in spite of the method being protected by @TargetApi:

    @TargetApi(Build.VERSION_CODES.N)
    private static AndroidCertVerifyResult validationError(CertPathValidatorException e) {
        CertPathValidatorException.Reason reason = e.getReason();
        if (reason instanceof CertPathValidatorException.BasicReason) {
            switch ((CertPathValidatorException.BasicReason) e.getReason()) {
                case EXPIRED:
                    return new AndroidCertVerifyResult(CertVerifyStatusAndroid.EXPIRED);
                case NOT_YET_VALID:
                    return new AndroidCertVerifyResult(CertVerifyStatusAndroid.NOT_YET_VALID);
                case REVOKED:
                    return new AndroidCertVerifyResult(CertVerifyStatusAndroid.REVOKED);
                default:
                    return new AndroidCertVerifyResult(CertVerifyStatusAndroid.FAILED);
            }
        } else {
            return new AndroidCertVerifyResult(CertVerifyStatusAndroid.FAILED);
        }
    }


The reason seems to be that the Java compiler generates an inner class to handle the enum switch, and Java Lint isn't applying the annotation to the inner class. The only workaround I could find was to replace the switch statement with an if statement.

The Lint error xml file is attached.
 
result.xml
87 bytes View Download

Sign in to add a comment