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 256805 - "Apply Code Changes" seems to be broken (maven project)
Summary: "Apply Code Changes" seems to be broken (maven project)
Status: RESOLVED INVALID
Alias: None
Product: debugger
Classification: Unclassified
Component: Java (show other bugs)
Version: 8.1
Hardware: PC Windows 7
: P2 normal (vote)
Assignee: Martin Entlicher
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-11-26 11:41 UTC by asbachb
Modified: 2015-11-26 16:24 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
test project (7.05 KB, application/zip)
2015-11-26 11:41 UTC, asbachb
Details

Note You need to log in before you can comment on or make changes to this bug.
Description asbachb 2015-11-26 11:41:45 UTC
Created attachment 157503 [details]
test project

Hello,

I think the "Apply Code Changes" feature is broken. I tests it via remote debugging on a Windows system (maven webapp) and with a local project on MacOsX (maven java application).

#HOW TO REPRODUCE#

1) Open my attached maven project
2) Set a breakpoint to line 15
3) Hit "Debug File"
4) Change System.out.println line to print out another line
5) Hit "Apply Code Changes"

When you step over or continue program execution the changed line is not applied.

If you need any further information I'll try to provide them.

Thanks in advance
Benjamin
Comment 1 Martin Entlicher 2015-11-26 15:47:47 UTC
This can not work.
Apply code changes does not work that way. It uses redefineClasses() method to change the user code, there's nothing else debugger could use:
http://docs.oracle.com/javase/8/docs/jdk/api/jpda/jdi/com/sun/jdi/VirtualMachine.html#redefineClasses-java.util.Map-
According to the description:
"If a redefined method has active stack frames, those active frames continue to run the bytecodes of the previous version of the method."

If the program is modified in following way:

    public static void main(String[] args) throws InterruptedException {
        print();
    }
    
    private static void print() {
        System.out.println("TEST1");
        System.out.println("TEST3");
    }

and you pot a breakpoint on the println() call, after you apply code changes, debugger will pop from the print() method and re-enter the updated code. In this case, apply code changes will work. Or if you call the print() method in a loop, after a change of the method body and a re-enter of the method, it will start executing the new code.
Comment 2 asbachb 2015-11-26 16:17:06 UTC
Thanks for you fast feedback. It seems that reproducing the problem is not as easy as I thought. I'll try to provide another test case for the problem and repoen the ticket in that case.
Comment 3 Martin Entlicher 2015-11-26 16:24:35 UTC
O.K.