Strange code in Class initalization

Bryce McKinlay bryce@albatross.co.nz
Mon Dec 6 17:37:00 GMT 1999


I'm a bit confused by this comment in natClass.cc ~line 400, in
Class.initializeClass():
 // do this before we enter the monitor below, since this can cause
 // exceptions. Here we assume, that reading "state" is an atomic
 // operation, I pressume that is true? --Kresten
Which is then followed by some ugly code. "do this" is referring to reading the
state variable for the class being initialized: "if (state < JV_STATE_LINKED)"
It seems to me that:
a) It doesn't matter whether or not reading state is atomic, because it could
have changed by the time the monitor gets aquired anyway. 
b) If _Jv_MonitorEnter throws an exception, we're in trouble either way. I don't
see how reading state first could help this situation.
So basically, I propose to clean this up with a single _Jv_MonitorEnter *before*
state is read, like it says to do in the JLS. 
Can anyone see the problem Kresten is talking about here? Or is this just a
mistake?
regards
 [ bryce ]


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /