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.
Environment: Product Version: NetBeans IDE Dev (Build 201308300001) Java: 1.7.0_40; Java HotSpot(TM) 64-Bit Server VM 24.0-b55 Runtime: Java(TM) SE Runtime Environment 1.7.0_40-b40 System: Mac OS X version 10.7.5 running on x86_64; UTF-8; en_US (nb) User directory: /Users/ionuion/Library/Application Support/NetBeans/dev Cache directory: /Users/ionuion/Library/Caches/NetBeans/dev 1. Create new project form samples (Java > Anagram Game) 2. Open class StaticWordLibrary 3.replace line 37 with 'final class StaticWordLibrarySuffix extends WordLibrary {' 4. replace line 32 with 'package com.toy.anagrams.newpackage;' 5. click the suggestion bulb on line 32. Select 'Move class to correct folder' 6. hover over the line 37. Expected result: - 'class StaticWordLibrarySuffix is public, should be declared in a file named StaticWordLibrarySuffix.java' displayed - option in the suggestion box 'Rename file to StaticWordLibrarySuffix.java' offered Actual result: - 'duplicate class: com.toy.anagrams.newpackage.StaticWordLibrarySuffix' message displayed' - No option to rename the file to the new class name
In fact, after step 3, NB 7.4 will start to complain about duplicate class StaticWordLibrarySuffix - the file must be saved though. In the original scenario, the file was auto-saved at the start of refactoring. The StaticWordLibrarySuffix ClassSymbol was entered based on the .sig file listed by ProxyFileManager; taken from .sig file. StaticWordLibrary ClassSymbol is entered into the package based on the .java filename. Then Enter phase begins, classEnter/visitClassDef is called on the CompilationUnitTree subtrees. On the StaticWordLibrarySuffix, the ClassSymbol (coming from the .sig) file is found and reused. During Attrib phase, the constructor refrerence provokes findGlobalType, which completes the ClassType for "StaticWordLibrary" (originally created based on .java file existence), and the StaticWordLibrary.java file is processed again. Then the 'duplicate' error is issued as visitClassDef encounters the same class definition from the source twice. Since after entering the entire CU of the source file, all classes from that file should have been entered and completed, if it would be great if, before attribution phase, the ClassSymbol with the same name as the source file, if it exists and is not complete, was replaced with a complete error (not exists) symbol. Or some other way :)
I had the error Duplicate Class 'toto' for a class located in the package 'titi.tata'. In the header of the file the line was missing: package toto.titi; Adding "package toto.titi;" solved the problem. I post it because the error message could have been more explicit.
Created attachment 158982 [details] mano