This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 252807 - Duplicate class hint for class in default package
Summary: Duplicate class hint for class in default package
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Compiler (show other bugs)
Version: 8.0.2
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-06-04 14:20 UTC by Jachym_Vojtek
Modified: 2015-07-22 04:38 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jachym_Vojtek 2015-06-04 14:20:19 UTC
NetBeans IDE 8.0.2

1) Create new Java Application project
Java Platform: JDK 1.8 (JDK 1.8.0_25)

2) Add two Java files into project


public class A {
    public static void main(String[] args)
    {
        System.out.println("Hello from A");
    }
}

--

package pckg;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;

public class ClassA {

    JButton btn = new JButton();
    
    void test() {
        btn.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new A().sayHello();
            }
            class A {
              void sayHello() {
                  System.out.println("Hello world");
              }
            }
        });                   
    }
    
    public static void main(String[] args)
    {
        ClassA ca = new ClassA();
        ca.test();
        ca.btn.doClick();
    }
}


NetBeans underlines the local class A in method test() with error message "duplicate class A".
Well, I am aware that using default package is not standard approach to Java packages, but JDK compiler does not complain about this.

cd project_dir
mkdir bin
cd src
javac -d ../bin A.java pckg/*.java
cd ../bin
java -cp ./*.class;pckg/*.class pckg.ClassA
Hello World
java -cp ./*.class;pckg/*.class A
Hello from A
Comment 2 Quality Engineering 2015-07-22 04:38:03 UTC
Integrated into 'main-silver', will be available in build *201507220303* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/6dcb44f8629e
User: Dusan Balek <dbalek@netbeans.org>
Log: Issues #252807, #253130, and #253406 - fixed.