String className = ((Class)jdkObject).getName().replace('.','/'); String typeName; if(className.charAt(0) == '[') { typeName = className; } else { typeName = "L" + className + ";"; } value = VM_TypeReference.findOrCreate(typeName).peekResolvedType();
value = VM_TypeReference.findOrCreate((Class)jdkObject).peekResolvedType();
  private static boolean copyKnownClasspathInstanceField(Object jdkObject, String rvmFieldName, VM_TypeReference rvmFieldType, Address rvmFieldAddress)    throws IllegalAccessException  {    if ((jdkObject instanceof java.lang.String) &&        (rvmFieldName.equals("cachedHashCode")) &&        (rvmFieldType.isIntType())        ) {      // Populate String's cachedHashCode value      bootImage.setFullWord(rvmFieldAddress, ((String)jdkObject).hashCode());      return true;    }    else if (jdkObject instanceof java.lang.Class)   {      Object value = null;      String fieldName = null;      boolean fieldIsFinal = false;      if(rvmFieldName.equals("type")) {        // Looks as though we're trying to write the type for Class,        // lets go over the common ones        if (jdkObject == java.lang.Boolean.TYPE) {          value = VM_Type.BooleanType;        }        else if (jdkObject == java.lang.Byte.TYPE) {          value = VM_Type.ByteType;        }        else if (jdkObject == java.lang.Character.TYPE) {          value = VM_Type.CharType;        }        else if (jdkObject == java.lang.Double.TYPE) {          value = VM_Type.DoubleType;        }        else if (jdkObject == java.lang.Float.TYPE) {          value = VM_Type.FloatType;        }        else if (jdkObject == java.lang.Integer.TYPE) {          value = VM_Type.IntType;        }        else if (jdkObject == java.lang.Long.TYPE) {          value = VM_Type.LongType;        }        else if (jdkObject == java.lang.Short.TYPE) {          value = VM_Type.ShortType;        }        else if (jdkObject == java.lang.Void.TYPE) {          value = VM_Type.VoidType;        }        else {          String className = ((Class)jdkObject).getName().replace('.','/');          String typeName;          if(className.charAt(0) == '[') {            typeName = className;          }          else {            typeName = "L" + className + ";";          }          value = VM_TypeReference.findOrCreate(typeName).peekResolvedType();          if (value == null) {            throw new Error("Failed to populate Class.type for " + typeName);          }        }        fieldName = "type";        fieldIsFinal = true;      }      if ((fieldName != null) && (value != null)) {        if (verbose >= 2) traceContext.push(value.getClass().getName(),                                            "java.lang.Class",                                            fieldName);        Address imageAddress = BootImageMap.findOrCreateEntry(value).imageAddress;        if (imageAddress.EQ(OBJECT_NOT_PRESENT)) {          // object not part of bootimage: install null reference          if (verbose >= 2) traceContext.traceObjectNotInBootImage();          bootImage.setNullAddressWord(rvmFieldAddress, true, false);        } else {          bootImage.setAddressWord(rvmFieldAddress, imageAddress.toWord(), !fieldIsFinal);        }        if (verbose >= 2) traceContext.pop();        return true;      } else {        // Unknown Class field or value for type        return false;      }    }    else if (jdkObject instanceof java.lang.reflect.Constructor)   {      Constructor cons = (Constructor)jdkObject;      if(rvmFieldName.equals("constructor")) {        // fill in this VM_Method field        String typeName = "L" + cons.getDeclaringClass().getName().replace('.','/') + ";";        VM_Type type = VM_TypeReference.findOrCreate(typeName).peekResolvedType();        if (type == null) {          throw new Error("Failed to find type for Constructor.constructor: " + cons + " " + typeName);        }        VM_Class klass = type.asClass();        if (klass == null) {          throw new Error("Failed to populate Constructor.constructor for " + cons);        }        Class consParams[] = cons.getParameterTypes();        VM_Method vmConstructors[] = klass.getConstructorMethods();        VM_Method constructor = null;        loop_over_all_constructors:        for(int i=0; i < vmConstructors.length; i++) {          VM_Method vmCons = vmConstructors[i];          VM_TypeReference vmConsParams[] = vmCons.getParameterTypes();          if (vmConsParams.length == consParams.length) {            for (int j=0; j < vmConsParams.length; j++) {              if(!consParams[j].equals(vmConsParams[j].resolve().getClassForType())) {                continue loop_over_all_constructors;              }            }            constructor = vmCons;            break loop_over_all_constructors;          }        }        if (constructor == null) {          throw new Error("Failed to populate Constructor.constructor for " + cons);        }        if (verbose >= 2) traceContext.push("VM_Method",                                            "java.lang.Constructor",                                            "constructor");        Address imageAddress = BootImageMap.findOrCreateEntry(constructor).imageAddress;        if (imageAddress.EQ(OBJECT_NOT_PRESENT)) {          // object not part of bootimage: install null reference          if (verbose >= 2) traceContext.traceObjectNotInBootImage();          bootImage.setNullAddressWord(rvmFieldAddress, true, false);        } else {          bootImage.setAddressWord(rvmFieldAddress, imageAddress.toWord(), false);        }        if (verbose >= 2) traceContext.pop();        return true;      } else if(rvmFieldName.equals("flag")) {        // This field is inherited accesible flag is actually part of        // AccessibleObject        bootImage.setFullWord(rvmFieldAddress, cons.isAccessible() ? 1 : 0);        return true;      } else {        // Unknown Constructor field        return false;      }    }     else {      // Unknown field      return false;    }  }