2

consider the following code snippet

synchronized (A.class) {
 foo();
 synchronized (B.class) {
 bar();
 }
}

And another code where A and B are swapped. This is might cause deadlock, and I'm trying to detect this using ASM (in particular, I only detect if A, B are classes which I know one should NOT synchronize on, eg Exceptions). Currently, I have an Analyzer which uses a SimpleVerifier. Using this, I can obtain the BasicValue on top of the stack and get its Type, but in the code example the internal name would be java/lang/Class, which does not tell me about which class it is. I can't seem to find a simple way to find which class the class represents. Any help is greatly appreciated. Thanks!

Jonathan Leffler
759k145 gold badges961 silver badges1.3k bronze badges
asked Jun 21, 2012 at 19:02
1
  • Are you looking at static or dynamic analysis? Commented Jun 21, 2012 at 20:37

1 Answer 1

2

You will have to use ASM's SourceInterpreter to track down where the value came from and then evaluate yourself what the value is.

PS: BTW, synchronizing on a Class is a bad idea...

answered Jun 21, 2012 at 19:32
Sign up to request clarification or add additional context in comments.

1 Comment

He might even fancy writing his own Interpreter which operates on a higher-level abstraction e.g. aggregate expressions.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.