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 123886 - "cannot find symbol"-error hint is shown even if the class exists
Summary: "cannot find symbol"-error hint is shown even if the class exists
Status: RESOLVED WORKSFORME
Alias: None
Product: java
Classification: Unclassified
Component: Editor (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker with 2 votes (vote)
Assignee: Jan Lahoda
URL:
Keywords:
: 117502 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-12-12 14:57 UTC by fireblaze
Modified: 2019-04-03 06:35 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
stacktrace (471 bytes, text/plain)
2008-03-26 10:31 UTC, ndganesan
Details
stacktrace (471 bytes, text/plain)
2008-06-23 12:51 UTC, amit_yadav
Details

Note You need to log in before you can comment on or make changes to this bug.
Description fireblaze 2007-12-12 14:57:38 UTC
"cannot find symbol"-error hint light up on some package-local classes, the code compiles but Netbeans IDE report that 
the code can not be found. It does not happen if the file that contains the package-local class is open.
Comment 1 Jan Lahoda 2007-12-12 22:28:58 UTC
Do you have a test case reproducible from scratch? It is very hard to do anything about it without a reproducible test case.
Comment 2 nicolo 2008-01-07 13:25:19 UTC
It happened to me too: when i call a method of a class which doesn't have directly the method but extends a class which
extends a class whitch extends a class of a Jar imported in the project.
for example i call x.meth(); x is an istance of the class X. X doesn't have the method meth() but extends A. A doesn't
have the method meth() but extends B. B is contained in a Jar imported as library
Comment 3 fireblaze 2008-01-07 14:03:00 UTC
file one:
Main.java

public class Main implements Finder {

    public static void main(String[] args) {
        new FindMe().find();
    }

    public void find() {
        throw new UnsupportedOperationException("Not supported yet.");
    }
}

file two:
Calling.java
interface Finder {

    void find();
}

class FindMe {

    public void find() {
    }
}

public class Calling {
}

Create a new project and open only Main.java and see the error:
Error in "public class Main implements Finder" - "cannot find symbol class Finder"
Comment 4 evilcat 2008-02-14 08:56:33 UTC
I have this problem too with a package of javax.swing (JPasswordField). Netbeans seems to don't recognize the symbol,
but it compiles perfectly and the Passwordfield works normaly. It happened suddenly and don't know which was the trigger.
---> Error	cannot find symbol symbol  : class JPasswordField location: package javax.swing	Inicio.java	336
D:/Alex/consultaTelecargas/src/interfaz
Comment 5 Max Sauer 2008-03-20 16:22:53 UTC
The use case described in desc4 is a duplicate of 118879 (class-living-elsewhere). Moreover, I cannot reproduce it in
---
Product Version: NetBeans IDE Dev (Build 080319)
Java: 1.5.0_13; Java HotSpot(TM) Client VM 1.5.0_13-119
System: Mac OS X version 10.5.2 running on i386; MacRoman; en_US (nb)
Userdir: /Volumes/Sources/trunk_hg/main/nbbuild/testuserdir

Comment 6 Max Sauer 2008-03-20 16:23:35 UTC
*** Issue 117502 has been marked as a duplicate of this issue. ***
Comment 7 ndganesan 2008-03-26 10:31:42 UTC
Build: NetBeans IDE 6.1 Beta (Build 200803050202)
VM: Java HotSpot(TM) Client VM, 1.6.0_03-b05
OS: Windows XP, 5.1, x86

User Comments: 
Comment 8 ndganesan 2008-03-26 10:31:46 UTC
Created attachment 59116 [details]
stacktrace
Comment 9 pribyl 2008-04-24 13:43:42 UTC
Product Version: NetBeans IDE 6.1 RC2 (Build 200804170002)
Java: 1.6.0_10-beta; Java HotSpot(TM) Client VM 11.0-b11
System: Windows XP version 5.1 running on x86; Cp1250; cs_CZ (nb)

I am not able to reproduce this (desc4) either. Well, when I try to compile the example classes, compiler really informs
about the missing classes (caused by the "class in a class"), but after a succesful build, everything seems to be OK -
no error badges, no problems during compiling.

I am removing the INCOMPLETE status for now (otherwise it should be closed now as nobody responds for 4 weeks now).
To be honest I am not quite sure, whether it is still one issue (for example: is the reported NPE really connected with
the original issue?)

Please, can someone evaluate this?

Thanks
Comment 10 Jiri Prox 2008-04-24 14:51:33 UTC
I'm marking this as duplicate 118879 - the original report is class-living-else problem. I cannot reproduce it now as
well, but this may be dependent on current thread scheduling (e.g dependent on OS, JDK version, project structure etc...).

*** This issue has been marked as a duplicate of 118879 ***
Comment 11 Exceptions Reporter 2008-06-10 16:23:05 UTC
This issue has already 10 duplicates 
see http://statistics.netbeans.org/exceptions/detail.do?id=5894
Comment 12 amit_yadav 2008-06-23 12:51:47 UTC
Created attachment 63249 [details]
stacktrace
Comment 13 agshpak 2008-07-19 13:16:19 UTC
for my case solution is quite simple:
NetBeans holds some information for projects loaded (or "opened") into the IDE outside of projects workshop. That 
information caused exception I noted and it is preserved by IDE while opening and closing NetBeans IDE itself. So, to 
resolve "Existent classes appear as non-existent" bug, just select "File|Close Project" and then, reload the same 
project by selecting them into "File|Open Recent Project>" submenu.
Note again, this will definitely help only if trouble started by following steps:
1. Java Class (simple or Swing JPanel, JForm etc.), called fex. SomeName, created inside of IDE;
2. SomeName deleted (even non-"safe", totally) inside of IDE;
3. SomeName created again (no matter which type) at the same package level.

P.S. Once upon a time, similar bug - but not so easy-to-resolve, was produced by Visual Studio v.5... or v.6... 
something. Is it caused now by the same programmer fired out of Microsoft due to incompetency?;)
Comment 14 Exceptions Reporter 2008-09-02 06:28:56 UTC
This issue has already 20 duplicates 
see http://statistics.netbeans.org/exceptions/detail.do?id=5894
Comment 15 patricblues 2019-04-03 06:35:01 UTC
The "Cannot find symbol" errors generally occur when you try to reference an undeclared variable in your code. A "Cannot find symbol" error means that the compiler cannot do this. Your code appears to be referring to something that the compiler doesn't understand.

When your code is compiled, the compiler needs to work out what each and every identifier in your code means. As the compiler is going through the code it will find something and know what to do with it or not. Your Cannot find symbol error relates to the identifiers and means that Java cannot figure out what the "symbol" means.

The general causes for a Cannot find symbol error are things like:

Incorrect spelling.

Wrong case. Halo is different from halo.

Improper use of acceptable identifier values (letters, numbers, underscore, dollar sign), my-class is not the same as myclass.

No variable declaration or variable is outside of the scope you are referencing it in.

http://net-informations.com/java/cjava/symbol.htm