Bug 75607 - HCR "smart drop to frame" failure
Summary: HCR "smart drop to frame" failure
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 3.0   Edit
Hardware: PC All
: P2 normal (vote)
Target Milestone: 3.1 M6   Edit
Assignee: Darin Wright CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 77312
Blocks:
  Show dependency tree
 
Reported: 2004-10-04 17:22 EDT by Jared Burns CLA
Modified: 2005-03-15 09:53 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jared Burns CLA 2004-10-04 17:22:32 EDT
Using the test program below, 
1. Turn off autobuild.
2. Build the program in the original state
3. Place a breakpoint where indicated.
4. Debug to the breakpoint.
5. Change the string in method a() from "A" to "a"
6. Save.
7. Change the string in method b() from "B" to "b"
8. Save.
9. Build.
10. We only drop to method b() and a dialog appears stating that method a() is obsolete.

If you swap steps 5 and 7 (change method b() before a()), we get the correct results. Having 
debugged this a bit, the problem relates to our story for retrieving the correct compilation unit delta 
for "smart" drop to frame. We end up comparing the final version of the source with the version after 
step 6. Comparing the deltas, it looks like a() hasn't changed, so we don't pop it. This is wrong.


  public class Hello {
    public static void main(String[] args) {
      new Hello().a();
    }
    private void a() {
      b();
      System.out.println("A");
    }
    private void b() {
      c();
      System.out.println("B");
    }
    private void c() {
      System.out.println("C");   // BREAKPOINT HERE
    }
  }
Comment 1 Darin Wright CLA 2004-10-29 12:14:15 EDT
It looks like a PRE and POST_BUILD event are still fired when autobuild is 
*off*, but no build occurrs - the builder fires the PRE_BUILD event, checks if 
it should run (deosn't), and then fires the POST_BUILD. DJ is checking into 
this, it may not be the correct behavior
Comment 2 John Arthorne CLA 2004-10-29 14:29:19 EDT
This is specified behaviour (IResourceChangeEvent javadoc):

 *    If autobuilding is not enabled, these events still occur at times when 
 * autobuild would have occurred.

Also, note that POST_BUILD events include a delta for all changes since the last
POST_BUILD event. This includes projects that may not have been built. For
example, if you change two projects but only build one, you will see both
projects in the POST_BUILD delta. JavaHotCodeReplaceManager seems to be assuming
that the delta only includes changes made by builders.
Comment 3 John Arthorne CLA 2004-11-01 10:15:09 EST
We have entered an enhancement request against core, see bug 77312. Can you add
details there on your requirements?
Comment 4 John Arthorne CLA 2005-02-08 14:54:28 EST
I have just released some changes to resource change events that should allow
you to address this.

IResourceChangeEvent.getSource() will now return the project in case of single
project builds, and the workspace in case of workspace builds.  This will allow
you to correctly update your table of last build times.

IResourceChangeEvent.getBuildKind() will return the "build kind" that was used
for that build (incremental, full, clean, auto).  Again, this will allow you to
correctly update your state.  You will know that if the trigger is "auto" and
auto-build is turned off, that it didn't in fact build anything.

You can add feedback and further comments in bug 77312.
Comment 5 Jared Burns CLA 2005-03-08 18:10:17 EST
Fixed in JavaHotCodeReplaceManager.

Instead of using a visitor to figure out which projects changed, I just use the
two new methods to:
1. Only update the build state for a real build (no autobuilds with autobuilding
off).
2. Get the built project (or all projects) from the resource change event.

I also discovered that the HCR manager was removing itself as a resource change
listener whenever all launches terminated. This makes sense for trying to
perform HCR, but it's actually a problem related to our build timestamps. To be
accurate, we need to keep updating when builds occur while there's nothing
running. Otherwise, we end up thinking that everything has changed since the
last build that occurred with a target running - which can be way too far in the
past.

Please verify, DW.
Comment 6 Darin Wright CLA 2005-03-15 08:59:19 EST
Verified. I did add an additional check for event.getBuildKind() == 0, so we 
ingore POST_BUILD notifications that are not applicable to a build kind. I 
couldn't make it happen, but it seems fair to check as 0 is part of the spec.
Comment 7 John Arthorne CLA 2005-03-15 09:53:07 EST
Just FYI, getBuildKind() only returns 0 for resource change events that are
unrelated to builds, such as the PRE_CLOSE, PRE_DELETE, and POST_CHANGE event
types.  If you are only listening for build events, it shouldn't happen.  Never
hurts to put the safety check in though.