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 201511 - Numerous Assertion Errors during source scanning
Summary: Numerous Assertion Errors during source scanning
Status: RESOLVED WONTFIX
Alias: None
Product: java
Classification: Unclassified
Component: Source (show other bugs)
Version: 7.0.1
Hardware: PC Windows 7 x64
: P3 normal (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-01 11:34 UTC by jessholle
Modified: 2014-08-29 11:39 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Stack of assertion (4.35 KB, text/plain)
2011-09-01 11:34 UTC, jessholle
Details

Note You need to log in before you can comment on or make changes to this bug.
Description jessholle 2011-09-01 11:34:44 UTC
Created attachment 110312 [details]
Stack of assertion

When scanning sources I get numerous assertions errors in the IDE log file.

The projects involved are free-form web projects which also use an annotation processor that generates sources.

One other odd thing that may be related.  Our annotation processor was getting NPE's when invoked by NetBeans' scanner because processingEnv.getElementUtils().getTypeElement(className) was returning null in cases where it should not.  This does not occur when the annotation processor is invoked from normal javac usage or even when it is invoked by Eclipse -- only when it is invoked by NetBeans.  This leads the annotation processor author to blame NetBeans.

The end result besides assertions in the log file is that we get numerous erroneous error badges in our projects.  Whenever a file with erroneous error badges is opened, the IDE tries to correct this by re-scanning.  This takes forever thanks to the project size and annotation processing involved.  It also doesn't succeed in correcting the error badges.  Something is clearly wrong as the project builds fine and the classpath, etc, in the free-form project are the same as those used by Ant.
Comment 1 jessholle 2011-09-01 12:03:51 UTC
FYI, one of our engineers notes:

With the IncorrectErrorBadge module disabled I am seeing some possibly suggestive messages:

    INFO [org.netbeans.modules.java.hints.WrongPackageSuggestion]: source cp is either null or does not contain the compiled source cp=
    INFO [org.netbeans.api.java.source.ElementHandle]: Cannot resolve: ElementHandle[kind=CLASS; sigs=wt.access._AccessControlSurrogate ]
    INFO [org.netbeans.api.java.source.ElementHandle]: Cannot resolve: ElementHandle[kind=CLASS; sigs=wt.eff._PendingDateEffectivity ]
    INFO [org.netbeans.api.java.source.ElementHandle]: Cannot resolve: ElementHandle[kind=CLASS; sigs=wt.epm.alternaterep._EPMDefinitionRule ]
    INFO [org.netbeans.api.java.source.ElementHandle]: Cannot resolve: ElementHandle[kind=CLASS; sigs=wt.part._ProductBlockEffectivity ]
    INFO [org.netbeans.api.java.source.ElementHandle]: Cannot resolve: ElementHandle[kind=CLASS; sigs=wt.eff._PendingSerialNumberEffectivity ]
    INFO [org.netbeans.api.java.source.ElementHandle]: Cannot resolve: ElementHandle[kind=CLASS; sigs=wt.change2._SupportingDataFor ]
    INFO [org.netbeans.api.java.source.ElementHandle]: Cannot resolve: ElementHandle[kind=CLASS; sigs=wt.epm.structure.occurrences._EPMUsesOccurrence ]
    INFO [org.netbeans.api.java.source.ElementHandle]: Cannot resolve: ElementHandle[kind=CLASS; sigs=wt.part._PartUsesOccurrence ]
    INFO [org.netbeans.api.java.source.ElementHandle]: Cannot resolve: ElementHandle[kind=CLASS; sigs=wt.eff._EffChangeAudit ]
    INFO [org.netbeans.api.java.source.ElementHandle]: Cannot resolve: ElementHandle[kind=CLASS; sigs=wt.occurrence._CombinedPathOccurrenceUserIBAs ]
    INFO [org.netbeans.modules.java.hints.WrongPackageSuggestion]: source cp is either null or does not contain the compiled source cp=
    INFO [org.netbeans.api.java.source.ElementHandle]: Cannot resolve: ElementHandle[kind=CLASS; sigs=wt.access._AccessControlSurrogate ]
    INFO [org.netbeans.api.java.source.ElementHandle]: Cannot resolve: ElementHandle[kind=CLASS; sigs=wt.eff._PendingDateEffectivity ]
    INFO [org.netbeans.api.java.source.ElementHandle]: Cannot resolve: ElementHandle[kind=CLASS; sigs=wt.epm.alternaterep._EPMDefinitionRule ]
    INFO [org.netbeans.api.java.source.ElementHandle]: Cannot resolve: ElementHandle[kind=CLASS; sigs=wt.part._ProductBlockEffectivity ]
    INFO [org.netbeans.api.java.source.ElementHandle]: Cannot resolve: ElementHandle[kind=CLASS; sigs=wt.eff._PendingSerialNumberEffectivity ]
    INFO [org.netbeans.api.java.source.ElementHandle]: Cannot resolve: ElementHandle[kind=CLASS; sigs=wt.change2._SupportingDataFor ]
    INFO [org.netbeans.api.java.source.ElementHandle]: Cannot resolve: ElementHandle[kind=CLASS; sigs=wt.epm.structure.occurrences._EPMUsesOccurrence ]
    INFO [org.netbeans.api.java.source.ElementHandle]: Cannot resolve: ElementHandle[kind=CLASS; sigs=wt.part._PartUsesOccurrence ]
    INFO [org.netbeans.api.java.source.ElementHandle]: Cannot resolve: ElementHandle[kind=CLASS; sigs=wt.eff._EffChangeAudit ]
    INFO [org.netbeans.api.java.source.ElementHandle]: Cannot resolve: ElementHandle[kind=CLASS; sigs=wt.occurrence._CombinedPathOccurrenceUserIBAs ]
    INFO [org.netbeans.modules.java.hints.WrongPackageSuggestion]: source cp is either null or does not contain the compiled source cp=
    INFO [org.netbeans.modules.java.hints.WrongPackageSuggestion]: source cp is either null or does not contain the compiled source cp=

As far as what I've fed to the free-form project is concerned, the source path is projectDir/src here.  All the _Xxxx classes are generated by the annotation processor and NetBeans seems to be getting confused and trying to scan classes using the annotation processor results too soon.  The pattern here is

  @GeneratingAnnotation( ... )
  public class Foo extends _Foo { ... }

where _Foo is generated by the annotation processor based on @GeneratingAnnotation.
Comment 2 Jan Lahoda 2011-09-02 09:57:33 UTC
As always, reproducible testcases are the most sure way to find the cause of a problem and fix it.

I can see three different parts in the above description that may or may not be related:
-incorrect error badges: I can reproduce something similar with a simple test project when I disable the single pass workers. I will attach the test project, download, unpack, open APUse and APDef in the IDE (with clean caches). When the single pass workers are enabled, the project is parsed without errors. When the single pass workers are disabled (-J-Dorg.netbeans.modules.java.source.indexing.JavaCustomIndexer.no.one.pass.compile.worker=true), there is an incorrect badge in apuse.Main (about missing superclass).
-processingEnv.getElementUtils().getTypeElement(className) returning null: sorry, but I do not think there is enough information. What class is being looked-up? Is it part of a jar on classpath, part of a source file in the source directory, is it a class generated by the AP? When exactly does this lookup occur?
-the AssertionError is quite possibly unrelated to the annotation processing. A reproducible test case would be ideal.

Dusan, could you please take a look on this? Thanks.
Comment 3 jessholle 2011-09-02 11:18:39 UTC
I don't have a reproducible test case simple because:
  1) The project is huge and complex.
  2) The annotation processor is complex.
  3) I have no idea why the issues are occurring and thus no idea how to produce
     a simplified reproduction of the issues.

I've not seen this issue on simple projects.
Comment 4 josepy 2011-09-08 13:59:57 UTC
I believe this may be related. Our _Classes are generated as part of annotation processing with the base class extending the _class. I'm not all that familiar with how the freeform project is written but it seems like the JavacParser doesn't know where the class is, or where it should go.

WARNING [org.netbeans.modules.java.source.parsing.JavacParser]: ClassPath identity changed for
MasterFileObject[/views/windchill-x22.0.0.xx/ccsrc/Windchill/DevModules/Foundation/src_gen/wt/fc/_ObjectReference.java@60f997d6:225f9457,valid=true], class path owner: /views/windchill-x22.0.0.xx/ccsrc/Windchill/DevModules/Foundation (class
org.netbeans.modules.ant.freeform.FreeformProject) original sourcePath:  new sourcePath: null
INFO [org.netbeans.modules.java.hints.WrongPackageSuggestion]: source cp is either null or does not contain the compiled source cp=
Comment 5 Svata Dedic 2014-08-29 11:39:23 UTC
Ancient report, no further data. If something similar happens with a recent NB version, reopen or file a new defect