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 242559 - Apply Code Changes seems to be not working (testing in MAVEN project)
Summary: Apply Code Changes seems to be not working (testing in MAVEN project)
Status: RESOLVED WONTFIX
Alias: None
Product: projects
Classification: Unclassified
Component: Maven (show other bugs)
Version: 8.0
Hardware: PC All
: P3 normal with 6 votes (vote)
Assignee: Tomas Stupka
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-03-04 20:17 UTC by NukemBy
Modified: 2016-07-07 08:37 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
sample maven project (1.38 KB, application/octet-stream)
2014-03-04 20:17 UTC, NukemBy
Details

Note You need to log in before you can comment on or make changes to this bug.
Description NukemBy 2014-03-04 20:17:54 UTC
Created attachment 145765 [details]
sample maven project

I was going to file a bug that Apply Code Changes does not work, but during collection of the steps to reproduce I see it does work, but not the way it was before and code changes are not explicitly noticeable.

Behaviour in 7.4
----------------
1. Run the program
2. Edit some java files
3. Click "Debug -> Apply Code Changes"
 3.1 Netbeans automatically saves modified files
 3.2 Netbeans compiles the project via MAVEN
 3.3 Netbeans applies code changes ...
 3.4 ... and writes following message to debug output window 
     "NetBeans: classes to reload: [test.DummyMainClass]"

Now, testing with in Dev (Build 201403040001),
----------------------------------------------
I'm getting following behavior
 3.1 Files are not saved automatically and I have the impression that "Apply Code Changes" is silently ignored.
 3.2 MAVEN is not invoked (and i guess this is OK sinse it is very lengthy operation)
 3.3 Code changes are silently applied only to already save files ...
 3.4 ... and i do not receive any feedback in IDE about success/failure of the operation and which files were reloaded ...

I think point 3.4 should be fixed and probably 3.1 should behave like in 7.4.


===================================================
Below is the report i was going to send before

Steps to reproduce
- take MAVEN project from attachment
- start
- go change some text e.g. "line #" -> "changed line #"

    public static void outputLine(int n) {
        System.out.println("line #"  + n);
    }

- Click from menu Debug -> Apply Code Changes ...


Nothing happens. 
NetBeans IDE Dev (Build 201403010001)

For reference - single test file from attached archive is copy/pasted below
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

package test;

public class DummyMainClass {

    public static void main(String[] args) throws Exception {
        int n = 0;
        while( true ) {
            outputLine(++n);
            try {
                Thread.sleep(333);
            }
            catch( Exception e) {}
        }
    }
    
    public static void outputLine(int n) {
        System.out.println("line #"  + n);
    }
}
Comment 1 Milos Kleint 2014-04-03 13:14:51 UTC
 1. in 7.4 netbeans saving all files was a direct consequence of executing a maven build. before each maven build, we save all unsaved files.
 2. The fact that we no longer execute a maven build before apply code changes is a "feature" - see issue #186558

I've ran your example twice. The first time it didn't update the the method, the second time around it did however.

The null output feedback is a problem indeed. There is some code that suggests output should be printed to status bar.
A commented block of code suggests that maybe apply code changes action should only be enabled when there are saved changes to be applied but that didn't work for me today.
Comment 2 ilgrosso 2014-04-03 14:50:49 UTC
Same problem here (no feedback) on Linux x64.
Comment 3 skaplon 2014-04-03 17:00:19 UTC
After configuring a server in the project (it's a complex EAR maven with a root pom.xml) and disable the automatic deploy on save (dunno the exact wording, not using the english locale here), then the apply code changes seems to be working, very fast (which is good) but with no feedback that it really did anything (which is bad). I don't think both features should really be done in the same IDE action, specially if I'm using the debugged. And having the feedback that the JVM could apply the action is a necessity (sometimes it can't due to the kind of changed done, static, final's and the like)
Comment 4 skaplon 2014-04-11 14:41:54 UTC
After a week using the feature, sometimes it simple doesn't work in situations that the 7.4 nb works. In my case, I have a seam component which is a annotated POJO with non-application scope that doesn't apply changes when using the IDE. The IDE log doesn't show anything suspicious either
Comment 5 Tomas Stupka 2014-07-16 14:26:05 UTC
> The null output feedback is a problem indeed. There is some code that suggests output should be printed to status bar.
fixed in core-main #4c2c724222a3

> A commented block of code suggests that maybe apply code changes action should only be enabled 
> when there are saved changes to be applied but that didn't work for me today.
it should not, but until we figure out how to fix, lets uncomment it as a hotfix - core-main #450c831585bc

problem shouldn't be that pregnant anymore -> lowering priority
Comment 6 Quality Engineering 2014-07-19 10:20:00 UTC
Integrated into 'main-silver', will be available in build *201407190718* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/d5364163e868
User: Tomas Stupka <tstupka@netbeans.org>
Log: show output info when applying code changes in a debug session
issue #242559 - Apply Code Changes seems to be not working (testing in MAVEN project)
Comment 7 brettryan 2014-11-25 13:50:40 UTC
Was this fixed for 8.0.1? I can not get the debugger to recognise changes in any form, I have "Apply code changes after save" turned on, and the IDE reports changes applied in "Apply Code Changes" output tab, but the changes are not applied:

NetBeans: classes to reload:
 test.DummyMainClass

Code updated

At first I thought this was because I was trying to "Debug File" as opposed to "Debug Project", but neither seem to work for me.


Could this be JDK related? I have been running the IDE with JDK8 and no other JDK installed. Will try to get JDK8 but am on dialup connection so will take a moment.
Comment 8 milanka 2014-11-25 14:22:27 UTC
I'm attaching debugger via JPDA+SocketAttach to Tomcat6 (running on JDK6) and changes are applied.

Product Version: NetBeans IDE 8.0.1 (Build 201408251540)
Java: 1.7.0_45; Java HotSpot(TM) 64-Bit Server VM 24.45-b08
Runtime: Java(TM) SE Runtime Environment 1.7.0_45-b18
System: Windows 7 version 6.1 running on amd64; Cp1252; en_US (nb)
Comment 9 Martin Balin 2016-07-07 08:37:08 UTC
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue.

Thanks for your cooperation,
NetBeans IDE 8.2 Release Boss