Implement our own class loading locks

This is to work around a problem in the implementation of the class
loading locks in IBM Java.