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 200122 - Bogus "no enclosing instance of type ... is in scope" errors
Summary: Bogus "no enclosing instance of type ... is in scope" errors
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Source (show other bugs)
Version: 7.1
Hardware: PC Linux
: P3 normal with 1 vote (vote)
Assignee: Jan Lahoda
URL: http://hg.netbeans.org/core-main/rev/...
Keywords:
: 200455 207005 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-07-13 18:33 UTC by Jesse Glick
Modified: 2012-01-16 18:37 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
The current fix attempt. (1.32 KB, patch)
2011-11-03 11:49 UTC, Jan Lahoda
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Glick 2011-07-13 18:33:12 UTC
Not sure exactly when in dev builds I started having this problem. Sometimes, in a valid Java class (or a class with quite unrelated local errors), a use of Outer.this syntax from code in an inner class is flagged as an error. This error sometimes disappears after other edits are made - even just adding and removing and space and saving the file - then comes back.

See URL for sample code and workaround. core-main #46f59c7b2f72 is similar.
Comment 1 Jesse Glick 2011-07-13 18:36:33 UTC
The log file has errors like this:

SEVERE [org.netbeans.modules.java.source.save.ElementOverlay]: No element and no QualIdent
WARNING [org.netbeans.modules.java.source.tasklist.IncorrectErrorBadges]: Incorrect error badges detected, file=.../MavenNbModuleImpl.java.
WARNING [org.netbeans.modules.java.source.tasklist.IncorrectErrorBadges]: Going to recompute root=.../maven.apisupport/src, files in error=[].
INFO [org.netbeans.api.java.source.ElementHandle]: Cannot resolve: ElementHandle[kind=FIELD; sigs=org.netbeans.modules.maven.apisupport.MavenNbModuleImpl$DependencyAdder this Lorg/netbeans/modules/maven/apisupport/MavenNbModuleImpl$DependencyAdder; ]
SEVERE [org.netbeans.modules.java.source.save.ElementOverlay]: No element and no QualIdent
Comment 2 Jan Lahoda 2011-08-01 06:42:23 UTC
*** Bug 200455 has been marked as a duplicate of this bug. ***
Comment 3 Jan Lahoda 2011-08-01 11:52:31 UTC
The test case in bug #200455 appears to be more reliably reproducible. The root cause seems to be that the anonymous innerclass's type "enclosing type" is the enclosing class when parsing from sources, whereas it is the enclosing method when read from the classfile. This ultimately leads to inability to find the appropriate outter class.
Comment 4 Anton Chechel 2011-08-11 11:50:53 UTC
Product Version: NetBeans IDE 7.0.1 (Build 201107282000)
Java: 1.6.0_23; Java HotSpot(TM) 64-Bit Server VM 19.0-b09
System: Windows 7 version 6.1 running on amd64; Cp1252; en_US (nb)
Userdir: C:\Users\Manowar\.netbeans\7.0

I have same problem with E2EDataObject after adding annotation
=====
@Messages("Source=&Source") // NOI18N
=====
following code becomes annotated with error message "no enclosing instance of type org.netbeans.modules.mobility.end2end.E2EDataObject is in scope":
=====
if (E2EDataObject.this.getConfiguration().getServiceType().equals(elem.getServiceType())) {
final ServiceGeneratorResult service = elem.generateStubs(Lookups.singleton(E2EDataObject.this));
}
=====
But it is valid compilable code.
Comment 5 Jesse Glick 2011-11-01 20:27:50 UTC
If it is reproducible, is a fix possible? This bug continues to be a problem for me.
Comment 6 Jan Lahoda 2011-11-01 21:15:30 UTC
I will try, but the fix may have unpredictable side effects. Actually, I was considering delaying the fix post-7.1.
Comment 7 Quality Engineering 2011-11-02 15:15:36 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/9db83f910b14
User: Jesse Glick <jglick@netbeans.org>
Log: Warnings, and #200122 workaround.
Comment 8 Jan Lahoda 2011-11-03 11:49:39 UTC
Created attachment 112770 [details]
The current fix attempt.

This appears to fix the problem, and causes no immediately obvious problems. May still cause serious unpredictable regressions.
Comment 9 Quality Engineering 2011-11-03 15:38:36 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/9db83f910b14
User: Jesse Glick <jglick@netbeans.org>
Log: Warnings, and #200122 workaround.
Comment 10 Jan Lahoda 2012-01-16 18:34:56 UTC
Attempt to fix:
http://hg.netbeans.org/main/nb-javac/rev/25da9fc73da8

Integrated to NetBeans proper no later than in:
http://hg.netbeans.org/main-silver/rev/d79a38e669d0
Comment 11 Jan Lahoda 2012-01-16 18:37:07 UTC
*** Bug 207005 has been marked as a duplicate of this bug. ***