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 221116 - Compile single in NetBeans Module projects causes deletion of dependent classes but no re-comile of those afterwards
Summary: Compile single in NetBeans Module projects causes deletion of dependent class...
Status: RESOLVED FIXED
Alias: None
Product: apisupport
Classification: Unclassified
Component: Harness (show other bugs)
Version: 7.3
Hardware: PC Mac OS X
: P2 normal (vote)
Assignee: Jaroslav Tulach
URL:
Keywords:
Depends on:
Blocks: 77858 85707
  Show dependency tree
 
Reported: 2012-10-30 17:11 UTC by gregersen
Modified: 2012-11-28 02:35 UTC (History)
5 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
project showing the issue (1.16 MB, application/zip)
2012-10-30 17:11 UTC, gregersen
Details

Note You need to log in before you can comment on or make changes to this bug.
Description gregersen 2012-10-30 17:11:55 UTC
Created attachment 126792 [details]
project showing the issue

I have a problem with an older project that contains just one NB module. The problem is that compile single file (F9) causes other dependent classes to be deleted but not recompiled. The project is attached. Steps to reproduce:

1. Clean & Build the module project
2. In the files view browse to build/classes/org/javeleon/demos/spaceinvaders/
2. Open the org.javeleon.demos.spaceinvaders.entities.Laser Java file
3. Make a trivial change to the class, save and hit F9 (why is compile on save not available for NB module projects?)
4. Look what happens in the files view, as many classes are deleted, but not re-compiled.

I know this issue is not a huge problem for normal operation, since whenever you try to run the project afterwards the missing files are compiled beforehand. 

This issue completely breaks class reloading systems such as JRebel or Javeleon, since they reflect changes to workspace classes into the running instance at runtime. So I get lots of ClassNotFoundExceptions for this project.

Setting ant to verbose gives some hints about what happens, but nothing I can really use from a users point of view.

I can't seem to reproduce this issue in a simple project created with NB 7.2, 7.3 Beta or NB dev (201210300001). 

I can't remember what version of NetBeans was used to create the project, one of my Italian student did this project but it's a couple of years back.
Comment 1 Milos Kleint 2012-11-05 08:29:29 UTC
issue 153635 is the enhancement to support compile on save in nb platform ant projects.
Comment 2 Milos Kleint 2012-11-05 08:56:23 UTC
from what I can tell the ant module project just calls the compile-single action which in turn calls the equivalent ant target. The target is defined in common.xml build script, reassigning to harness subcomponent for evaluation
Comment 3 Jaroslav Tulach 2012-11-05 11:31:13 UTC
The deletion happens because of 

<depend/>

Ant task preceeding the compilation. The task is there is fix for bug 77858. 

The proper fix probably requires to capture the list of deleted classes by depend and add them to the list of classes that should be compiled by javac. Alas, depend task does not seem to record the list of deleted classes, so there is no easy way to find out what has been deleted.

Easiest fix is to comment out the use of <depend/> completely as it clearly does not make any sense for "compile-single" targets.

Alan, try to comment it yourself and verify it would work for you.
Comment 4 gregersen 2012-11-05 16:33:28 UTC
I can verify that commenting out <depend> solves the issue. However, the behavior of compile single will in this case not consider re-compilation of classes for which there exist inlined final constants declared within the compiled class. However, this is a small price to pay compared to deleting dependent classes completely. From my perspective <depend> should be just commented out from compile single completely. 

Thank you for your involvement.
Comment 5 Jesse Glick 2012-11-05 18:22:59 UTC
Better to run a full compile and not use compile-single in this case. But if you do want to use F9, then the fix of bug #85707 should be used: a force-recompile macro used in place of <depend> for *-single targets.
Comment 6 Jaroslav Tulach 2012-11-21 15:48:30 UTC
It took me and Tomáš Zezula a while to realize what Jesse meant by his recommendation, but yes, force-recompile is good approach: ergonomics#89e755caa396
Thanks for pointing that out.
Comment 7 Quality Engineering 2012-11-28 02:35:00 UTC
Integrated into 'main-golden', will be available in build *201211280002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/89e755caa396
User: Jaroslav Tulach <jtulach@netbeans.org>
Log: #221116: Using force-recompile approach instead of depend task for compile-single as depend removes too much