* cleared, create a new instance.
*/
if (object == null) {
if (key instanceof Instance) {
// look for well-known classes
Symbol className = key.getKlass().getName();
if (Assert.ASSERTS_ENABLED) {
Assert.that(className != null, "Null class name");
}
Instance inst = (Instance) key;
if (className.equals(javaLangString)) {
object = new StringReferenceImpl(this, inst);
} else if (className.equals(javaLangThread)) {
object = new ThreadReferenceImpl(this, inst);
} else if (className.equals(javaLangThreadGroup)) {
object = new ThreadGroupReferenceImpl(this, inst);
} else if (className.equals(javaLangClass)) {
object = new ClassObjectReferenceImpl(this, inst);
} else if (className.equals(javaLangClassLoader)) {
object = new ClassLoaderReferenceImpl(this, inst);
} else {
// not a well-known class. But the base class may be
// one of the known classes.
Klass kls = key.getKlass().getSuper();
while (kls != null) {
className = kls.getName();
// java.lang.Class and java.lang.String are final classes
if (className.equals(javaLangThread)) {
object = new ThreadReferenceImpl(this, inst);
break;
} else if(className.equals(javaLangThreadGroup)) {
object = new ThreadGroupReferenceImpl(this, inst);
break;
} else if (className.equals(javaLangClassLoader)) {
object = new ClassLoaderReferenceImpl(this, inst);
break;
}
kls = kls.getSuper();
}