Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I find all synchronized on the same monitor in Java with Eclipse?

With Eclipse it is possible to find all references of a method, member or class. Is it also possible to find all references to the monitor of a synchronized?

If this is not possible with Eclipse then is it possible with another Java IDE?

My problem is that the monitor object hat many references. A search for all references will return to many results. I will only see where are synchronized with this object.

EDIT: I add a sample what i means:

public class LockClass{
  public synchronized void add(Object any){
  }
}

public class AnyOther{
  private LockClass lock;

  public AnyOther(LockClass lock){
    this.lock = lock;
  }

  public void doSomethings(){
    synchronized(lock){
      //...
    }
}

Now I want search all synchronized which use the LockClass as monitor. This is a static analyses. In my sample I want find:

  • LockClass.add
  • AnyOther.doSomethigs
like image 737
Horcrux7 Avatar asked Jun 24 '11 07:06

Horcrux7


1 Answers

To find references: Select your element->rt-click menu->References->workspace

Its not possible to find all possible synchronized blocks on the same object, because the actual object pointed by a reference would depend at runtime.

like image 71
Suraj Chandran Avatar answered Oct 17 '22 17:10

Suraj Chandran