HCIUnit get(HClass hc) { HCIUnit hciu; HClass superclass; HCIUnit superclassInfo; hciu = (HCIUnit) m_table.get(hc); if (hciu == null) { if (hc.isArray()) { // Treat arrays differently int dims = HClassUtil.dims(hc); HClass baseclass = HClassUtil.baseClass(hc); // hc is not primitive, so hc.getLinker() is safe. superclass = baseclass.isPrimitive() ? hc.getLinker().forName("java.lang.Object") : (baseclass.getDescriptor().equals("Ljava/lang/Object;") ? (HClassUtil.arrayClass(hc.getLinker(), baseclass, dims - 1)) : HClassUtil.arrayClass(hc.getLinker(), baseclass.getSuperclass(), dims)); } else { superclass = hc.getSuperclass(); } if (superclass != null) { superclassInfo = get(superclass); hciu = new HCIUnit(hc, superclassInfo); } else { hciu = new HCIUnit(hc); } m_table.put(hc, hciu); } return hciu; }
/** * create a new objectref with default field values. * * @exception InterpretedThrowable if class initializer throws an exception. */ ObjectRef(StaticState ss, HClass type) { super(ss, type); this.fields = null; this.closure = null; // Initialize our fields. for (HClass sc = type; sc != null; sc = sc.getSuperclass()) { HField[] fl = sc.getDeclaredFields(); for (int i = 0; i < fl.length; i++) if (!fl[i].isStatic()) update(fl[i], defaultValue(fl[i])); } // yay, done. }