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 196782 - [70cat] LayerGeneratingProcessor should delete stale entries during incremental builds
Summary: [70cat] LayerGeneratingProcessor should delete stale entries during increment...
Status: RESOLVED WONTFIX
Alias: None
Product: platform
Classification: Unclassified
Component: Filesystems (show other bugs)
Version: 7.0
Hardware: All All
: P4 normal (vote)
Assignee: Jaroslav Tulach
URL:
Keywords:
Depends on:
Blocks: 199095
  Show dependency tree
 
Reported: 2011-03-16 15:15 UTC by misterm
Modified: 2013-01-29 14:56 UTC (History)
6 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter: 177630


Attachments
stacktrace (1.95 KB, text/plain)
2011-03-16 15:15 UTC, misterm
Details
module (2.81 MB, application/octet-stream)
2011-04-13 17:15 UTC, misterm
Details
stacktrace (1.95 KB, text/plain)
2011-04-13 17:15 UTC, misterm
Details

Note You need to log in before you can comment on or make changes to this bug.
Description misterm 2011-03-16 15:15:50 UTC
Build: NetBeans IDE Dev (Build 110315-fd2f2b39bc08)
VM: Java HotSpot(TM) Client VM, 16.2-b04, Java(TM) SE Runtime Environment, 1.6.0_19-b04
OS: Windows 7

Stacktrace: 
java.lang.NoSuchMethodException: org.netbeans.modules.java.hints.jdk.ConvertToARM.hint1(org.netbeans.modules.java.hints.jackpot.spi.HintContext)
   at java.lang.Class.getDeclaredMethod(Class.java:1937)
   at org.netbeans.modules.java.hints.jackpot.code.FSWrapper.resolveMethod(FSWrapper.java:88)
   at org.netbeans.modules.java.hints.jackpot.code.CodeHintProviderImpl$WorkerImpl.getMethod(CodeHintProviderImpl.java:299)
   at org.netbeans.modules.java.hints.jackpot.code.CodeHintProviderImpl$WorkerImpl.createErrors(CodeHintProviderImpl.java:258)
   at org.netbeans.modules.java.hints.jackpot.impl.hints.HintsInvoker.runHint(HintsInvoker.java:685)
   at org.netbeans.modules.java.hints.jackpot.impl.hints.HintsInvoker.doComputeHints(HintsInvoker.java:465)
Comment 1 misterm 2011-03-16 15:15:53 UTC
Created attachment 107056 [details]
stacktrace
Comment 2 Jan Lahoda 2011-03-16 15:30:44 UTC
How exactly did you get the build on which this happened? Could you please attach ${INSTALL_DIR}/java/modules/org-netbeans-modules-java-hints.jar? Thanks.
Comment 3 Jan Lahoda 2011-03-24 12:20:17 UTC
The code reads the hint description from the layer. The code that reads the description from the layer apparently sees that the hint1 method should be used, but that has been renamed recently. Clean build should produce the correct layer. So possible causes include a not-clean build, or the layer-cache bug. Without the org-netbeans-modules-java-hints.jar, we cannot even guess if any of these is more likely or if there is a possibility of another problem.
Comment 4 misterm 2011-04-13 17:14:36 UTC
Attached module as requested
Comment 5 misterm 2011-04-13 17:15:35 UTC
Created attachment 107728 [details]
module
Comment 6 misterm 2011-04-13 17:15:42 UTC
Created attachment 107729 [details]
stacktrace
Comment 7 Jan Lahoda 2011-04-13 17:39:16 UTC
It appears that the module is a product of an incremental build - I would not recommend using such builds for production work.

It appears that the LayerGeneratingProcessor is not correctly deleting the entries from the layer. When I did this:
-put a Test.java into org.netbeans.modules.java.hints.bugs in java.hints, with content:
----------
package org.netbeans.modules.java.hints.bugs;

import org.netbeans.modules.java.hints.jackpot.code.spi.Hint;
import org.netbeans.modules.java.hints.jackpot.code.spi.TriggerPattern;
import org.netbeans.modules.java.hints.jackpot.spi.HintContext;
import org.netbeans.spi.editor.hints.ErrorDescription;

@Hint(category="jdk")
public class Test {

    @TriggerPattern("")
    public static ErrorDescription t(HintContext ctx) {
        return null;
    }
}
-------------
-enhanced the Bundle.properties with required keys:
DN_org.netbeans.modules.java.hints.bugs.Test=X
DESC_org.netbeans.modules.java.hints.bugs.Test=X
-built the project (F11)
-changed the method name to t2, built again
-the resulting generated-layer.xml contains metadata for both methods, which is incorrect

I do not think that the JavaHintsAnnotationProcessor can do more than it is doing now: when it calls LayerGeneratingProcessor.layer it provides the corresponding TypeElement, so the LGP should delete the obsolete entries.
Comment 8 Jesse Glick 2011-04-14 14:28:56 UTC
There are several possible cases that can arise when LayerBuilder is used during an incremental build:

1. The layer entry - identified by SFS path - has not been produced before. So it should be created.

2. The entry has been produced before by the same class, and is produced again. It should be overwritten.

3. The class produces some entries, but not all of what was produced before. The older entries should be removed (newer ones falling under #1 or #2). A special case is that the class is scanned by one or more (LGP-based) APs but produces no entries at all; another is that the paths of one or more entries have changed (as in this bug I think).

4. The class produced some entries before, but is no longer scanned by any AP (generally due to all layer-generating annotations being deleted), though some APs are active on other classes. The old entries should be removed. A special case is that a class has been renamed.

5. One or more classes produced some entries before, but there are no longer any classes in the source root being scanned by any AP. The old entries (if not the whole layer) should be removed.

#1 and #2 are common and already work.

#3 is probably not hard to fix; LayerBuilder already records (in a comment) the originating element (OE), assuming there is exactly one, so close() ought to be able to delete prior entries which were not overwritten.

#4 is probably fixable with some more work; need to track everything written by any AP from any OE.

#5 cannot be fixed with current 269 implementations, since LGP will not be called at all.

I do not consider this a high priority; you should do a clean build of a module if making major structure changes, and when creating a full build you should always 'ant clean' first. (If you fail to do so, and run across LinkageError's or ClassNotFoundException's or NoSuchMethodException's, please do not bother reporting them.)
Comment 9 Jaroslav Tulach 2013-01-29 11:19:26 UTC
Just do clean build.
Comment 10 Jesse Glick 2013-01-29 14:56:44 UTC
FWIW #5 might be collapsed into the #4 case with a special processor marked @SupportedAnnotationTypes("*").