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!
-
Are you looking at static or dynamic analysis?Jochen– Jochen2012年06月21日 20:37:51 +00:00Commented Jun 21, 2012 at 20:37
1 Answer 1
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...