Skip to content

Array element types should be nullable when NRT is enabled. #917

@jpobst

Description

@jpobst

Context: #912 (comment)

Some of the nullable annotations we look for do support string?[]?, like Lorg/jetbrains/annotations/NotNull;:

package org.jetbrains.annotations;

@Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, ElementType.LOCAL_VARIABLE, ElementType.TYPE_USE})
public @interface NotNull { ... }

(source)

(My understanding is it's the ElementType.TYPE_USE that allows specifying string?[].)

However the Android ones we primarily use only support string[]?:

package androidx.annotation;

@Target({METHOD, PARAMETER, FIELD, LOCAL_VARIABLE, ANNOTATION_TYPE, PACKAGE})
public @interface NonNull { ... }

(source)

Our tools do not currently support specifying the array element nullability.

While we probably wouldn't gain much by adding support to our tools since the primary Android annotations don't support it, we probably should update generator to always emit nullable array elements, since the default should be nullable unless specified @NotNull.

That is, we should always emit string?[] or string?[]? when NRT is turned on.

Metadata

Metadata

Assignees

No one assigned

    Labels

    generatorIssues binding a Java library (generator, class-parse, etc.)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions