1

I have a class (i.e A) that has a lot of class that inherit from it, and I have a protected variable (i.e foo) in this class.

Is there any way to get notification every time that some object change this var?

Because it's protected, any class that inherit from it can simply change it's value outside A class (i.e

public class B extends A
{
    public void changeAFoo()
    {
        foo = 4;
    }
}

)

It's a big project and I can't simply go one by one and put a breakpoints, and I also can't put breakpoints inside A class because require that it will change through there.

How can follow this var value under those circumstances?

Thanks!

Dvir
  • 301
  • 1
  • 2
  • 16
  • unless it is static I don't see the problem. the instance variable will be unique even for inherited instance variables. – Jack Flamp Nov 08 '17 at 11:30

2 Answers2

1

On the next sentence put "conditional" debug with condition foo != 4 Then debugger would only stop when foo is something else than 4.

Generally, on most machine when you click on the left pane to put debug point - you again right click on it to open conditional debug window, and put condition.

This can help How to use conditional breakpoint in Eclipse?

enator
  • 2,431
  • 2
  • 28
  • 46
1

Create a watchpoint on foo with 'Access Modification'.

When a foo is accessed or modified your program execution will halt and the debug view will be activated.

For example:

enter image description here

glytching
  • 44,936
  • 9
  • 114
  • 120
  • I tried it now and it seems like it working, but for some how - when I make this watchpoint, and make a change in the JSF, the site screen freezes, the eclipse resume button is disable, and the only thing that makes everything carry on is the press the "Disable breakpoints" button. The debugger doesn't go the any line. – Dvir Nov 08 '17 at 12:09