apache / apache/netbeans

False collection warnings

Open
#5,659 1 comment 0 reactions 0 assignees View on GitHub
hints Java kind:bug
Dominant language
Java
Stars
3.1k
Forks
935
Avg merge
2d 3h
Merged PRs (30d)
17

Description

### Apache NetBeans version

Apache NetBeans 17

### What happened

There are many cases in which Netbeans won't recognize, that a collection has been accessed, one of them are functional operators. But it also gives this warning for class variables when they have been passed to the outside as method result, also when wrapped in a unmodifiable collection.
![grafik](https://user-images.githubusercontent.com/77264698/224641815-1ccb33a7-ae75-4879-bde9-f9074c5cee84.png)

### How to reproduce

` var allDirs = new ArrayList();
allDirs.add(new File("directoryname"));
allDirs.forEach(oneDir -> System.out.println(oneDir.getName()));
`

### Did this work correctly in an earlier version?

No / Don't know

### Operating System

Windows 10

### JDK

17

### Apache NetBeans packaging

Apache NetBeans provided installer

### Anything else

All the time.
It's nothing serious, just annoying.

### Are you willing to submit a pull request?

No

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the warning in Apache NetBeans 17 with the provided ArrayList and forEach example on Windows 10/JDK 17. Investigate the collection-access analysis behind this inspection, including cases where a class variable is returned or wrapped in an unmodifiable collection. Done means valid collection accesses no longer produce false warnings.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.