Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested anonymous class results in exception #210

Closed
wmdietl opened this issue Apr 5, 2022 · 0 comments · Fixed by #211
Closed

Nested anonymous class results in exception #210

wmdietl opened this issue Apr 5, 2022 · 0 comments · Fixed by #211

Comments

@wmdietl
Copy link
Member

wmdietl commented Apr 5, 2022

An Invalid variable and element passed to extractAndApply occurs, at least in Java 11, when an annotated nested anonymous class is encountered.

import org.checkerframework.checker.tainting.qual.Tainted;

class NestedAnonymous {
    Object o = new Outer.@Tainted Inner() {};

    static class Outer {
        static class Inner {}
    }
}

Running the Tainting Checker results in:

    :-1: other: error: handleInvalid(this=org.checkerframework.framework.util.element.VariableApplier):
      Invalid variable and element passed to extractAndApply; type: Object
        element: o2 (kind: FIELD), invalid annotations: @org.checkerframework.checker.tainting.qual.Tainted ([CLASS_EXTENDS, type_index = 65535, pos = 228])
      Targeted annotations: LOCAL_VARIABLE, RESOURCE_VARIABLE, EXCEPTION_PARAMETER, FIELD
      Valid annotations: NEW, CAST, INSTANCEOF, METHOD_INVOCATION_TYPE_ARGUMENT, CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT, METHOD_REFERENCE, CONSTRUCTOR_REFERENCE, METHOD_REFERENCE_TYPE_ARGUMENT, CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT, METHOD_FORMAL_PARAMETER
      ; The Checker Framework crashed.  Please report the crash.
      Compilation unit: /home/wdietl/workspaces-server/eisop-cf/checker-framework/checker/tests/tainting/NestedAnonymous.java
      Last visited tree at line 4 column 1:
      class NestedAnonymous {
      Exception: java.lang.Throwable; java.lang.Throwable
        at org.checkerframework.javacutil.BugInCF.<init>(BugInCF.java:22)
        at org.checkerframework.framework.util.element.TargetedElementAnnotationApplier.handleInvalid(TargetedElementAnnotationApplier.java:150)
        at org.checkerframework.framework.util.element.TargetedElementAnnotationApplier.extractAndApply(TargetedElementAnnotationApplier.java:214)
        at org.checkerframework.framework.util.element.VariableApplier.extractAndApply(VariableApplier.java:112)
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant