In Eclipse, how to find all java synchronized blocks / methods that block instances of a specific class

I use Eclipse to develop java, I want to find all synchronized methods / blocks that are locked on the monitor of an instance of ClassA class. How to do it?

+4
source share
2 answers

Eclipse offers text search only. What you are asking for will require some kind of compiler, such as support, to evaluate the type of object you are synchronizing.

As a workaround, you can add comments to synchronized statements explaining the syncobjects class.

synchronized(nobodyKnowsMyName)  // sync(Rumpelstiltskin)

It will be an effort, but you will get what you want.

+1
source

, : " Eclipse ".

, , , , , IDE, . ( , .)

:

  • , MySpecialLock .

  • :

    MySpecialLock lock = getTheParticularInstanceInSomeDomainSpecificWay();
    synchronized (lock) { ...  }
    
  • Eclipse Java Search ( , MySpecialLock), "" - " ", Ctrl + Shift + G Windows). ,

    , ClassA , . , , , .

+1

Source: https://habr.com/ru/post/1547887/


All Articles