Skip to content

False positive hint "Return of Array field" #9753

Closed

Description

@jherkel

Apache NetBeans version

Apache NetBeans 32 latest release candidate

What happened

If there is a field declaration

private static final int[] TEST = new int[0];
// and method

public int[] test() {
  return TEST;
} 

I can see "Return of Array field" hint.
However, for a final variable with zero length (often used as a static constant), it is questionable whether this is truly a problem. This field is thread-safe and, for all practical purposes, behaves like an immutable object (except, of course, that it can be synchronized)."

I have a patch for this if we want to fix it...

Language / Project Type / NetBeans Component

Java

How to reproduce

public class Test {
  private static final int[] TEST = new int[0];
  // private static final int[] TEST = new int[] {};

  public static int[] getTest() {
    return TEST;
 }
}

Did this work correctly in an earlier version?

No / Don't know

Operating System

Fedora Silverblue 44

JDK

openjdk 27

Apache NetBeans packaging

Other

Anything else

No response

Are you willing to submit a pull request?

Yes

Activity

  1. added
    kind:bugBug report or fix
    needs:triageRequires attention from one of the committers
    on Oct 27, 2026
  2. added
    Java[ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form)
    and removed
    needs:triageRequires attention from one of the committers
    on Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Java[ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form)hintskind:bugBug report or fix

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions