Skip to content

Parameters of native methods should be effectively final #1247

@aosen-xiong

Description

@aosen-xiong

Get the error from eisop/jdk#122

Take this code:

import org.checkerframework.checker.nullness.qual.EnsuresNonNullIf;

public class Demo{
    @EnsuresNonNullIf(expression = { "#1" }, result = true)
    public native void test(Object obj);
}

Error from Nullness Checker:

Demo.java:6: error: [flowexpr.parameter.not.final] parameter obj in 'obj' is not effectively final (i.e., it gets re-assigned)
    public native void test(Object obj);
                       ^
1 error

We should treat the parameters of native method as effective final, like abstract method.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions