Fixing race condition when using Java reflection.
Authored by: agalal 2012-09-29
Parent: [r1299]
Child: [r1301]