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

Method GenericTypeReflector#getArrayComponentType(Type) throws NullPointerException is a non-array Class type #32

Open
sigpwned opened this issue Nov 1, 2024 · 0 comments

Comments

@sigpwned
Copy link

sigpwned commented Nov 1, 2024

The following code fails under (current) master (and v1.3.16, and v2.0.0):

    GenericTypeReflector.getArrayComponentType(Integer.class);

Specifically, it throws a NullPointerException.

The (current) documentation for all overloads of the getArrayComponentType method is:

    /**
     * If type is an array type, returns the annotated type of the component of the array.
     * Otherwise, returns null.
     */
    public static AnnotatedType getArrayComponentType(AnnotatedType type) {
        // implementation
    }

    /**
     * If type is an array type, returns the type of the component of the array.
     * Otherwise, returns null.
     */
    public static Type getArrayComponentType(Type type) {
        // implementation
    }

Based on my read, it should be safe to pass non-array Class objects to the method, and I would expect the method to return null when I do so.

Hopefully it's not presumptuous, but I have opened PR #33 with a proposed solution.

I hope this all made sense. If not, please don't hesitate to send me any questions or concerns!

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

No branches or pull requests

1 participant