apache / apache/netbeans

Error parsing file (red mark) when having 2 or more java classes in the same java file or inside the same package, that share same class name (e.g after cloning/copying)

Open
#4,145 7 comments 0 reactions 0 assignees View on GitHub
Java kind:bug needs:triage
Dominant language
Java
Stars
3.1k
Forks
935
Avg merge
2d 3h
Merged PRs (30d)
17

Description

### Apache NetBeans version

Apache NetBeans 13

### What happened

Error parsing file (red mark) when having 2 or more java classes in the same java file, inside the same package, that share same class names (e.g after cloning/copying).
If public class then we give the file name of the class. If other classes (more than the main one) exist in the same java file (nested or separate non public), then we get this error without any guidance to resolve the naming conflict.
Background scanning of projects could then be triggered, and this scanning time period, will be long.

### How to reproduce

Create a public class, rename the New Class to the class name
Create a non public class inside the same file, nested and/or separated.
Copy Paste the Java file to the same package from projects list.
Let it live inside a project, sooner or later it will appear.

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

No

### Operating System

windows 7

### JDK

17

### Apache NetBeans packaging

Apache NetBeans provided installer

### Anything else

_No response_

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

No

### Code of Conduct

Yes

Contributor guide

Open the contributing guide

Research direction

No source file, test, or entry point is named. Reproduce the duplicate-class scenario in NetBeans 13 with JDK 17, then trace the Java parsing and error-marking path; done should include clear guidance for resolving the naming conflict and avoid an unnecessarily prolonged background scan.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.