use of com.oracle.truffle.espresso.impl.ObjectKlass in project graal by oracle.
the class JDKCacheRedefinitionPlugin method postClassRedefinition.
@Override
public void postClassRedefinition(ObjectKlass[] changedKlasses) {
synchronized (threadGroupContexts) {
for (ObjectKlass changedKlass : changedKlasses) {
if (flushFromCachesMethod != null) {
flushFromCachesMethod.invokeDirect(null, changedKlass.mirror());
}
Iterator<WeakReference<StaticObject>> iterator = threadGroupContexts.iterator();
while (iterator.hasNext()) {
WeakReference<StaticObject> ref = iterator.next();
StaticObject context = ref.get();
if (context != null) {
removeBeanInfoMethod.invokeDirect(context, changedKlass.mirror());
} else {
// clean up list when context was reclaimed
iterator.remove();
}
}
}
}
}
use of com.oracle.truffle.espresso.impl.ObjectKlass in project graal by oracle.
the class JDWPContextImpl method getNestedTypes.
@Override
public KlassRef[] getNestedTypes(KlassRef klass) {
if (klass instanceof ObjectKlass) {
ArrayList<KlassRef> result = new ArrayList<>();
ObjectKlass objectKlass = (ObjectKlass) klass;
List<Symbol<Symbol.Name>> nestedTypeNames = objectKlass.getNestedTypeNames();
StaticObject classLoader = objectKlass.getDefiningClassLoader();
for (Symbol<Symbol.Name> nestedType : nestedTypeNames) {
Symbol<Symbol.Type> type = context.getTypes().fromClassGetName(nestedType.toString());
KlassRef loadedKlass = context.getRegistries().findLoadedClass(type, classLoader);
if (loadedKlass != null && loadedKlass != klass) {
result.add(loadedKlass);
}
}
return result.toArray(new KlassRef[0]);
}
return null;
}
use of com.oracle.truffle.espresso.impl.ObjectKlass in project graal by oracle.
the class StaticObject method createClass.
public static StaticObject createClass(Klass klass) {
assert klass != null;
ObjectKlass guestClass = klass.getMeta().java_lang_Class;
StaticObject newObj = guestClass.getLinkedKlass().getShape(false).getFactory().create(guestClass);
newObj.initInstanceFields(guestClass);
klass.getMeta().java_lang_Class_classLoader.setObject(newObj, klass.getDefiningClassLoader());
if (klass.getContext().getJavaVersion().modulesEnabled()) {
newObj.setModule(klass);
}
if (klass.isArray() && klass.getMeta().java_lang_Class_componentType != null) {
klass.getMeta().java_lang_Class_componentType.setObject(newObj, ((ArrayKlass) klass).getComponentType().mirror());
}
// Will be overriden if necessary, but should be initialized to non-host null.
klass.getMeta().HIDDEN_PROTECTION_DOMAIN.setHiddenObject(newObj, StaticObject.NULL);
// Final hidden field assignment
klass.getMeta().HIDDEN_MIRROR_KLASS.setHiddenObject(newObj, klass);
return trackAllocation(klass, newObj);
}
use of com.oracle.truffle.espresso.impl.ObjectKlass in project graal by oracle.
the class StaticObject method toVerboseString.
@TruffleBoundary
public final String toVerboseString() {
if (this == NULL) {
return "null";
}
if (isForeignObject()) {
return String.format("foreign object: %s\n%s", getKlass().getTypeAsString(), InteropLibrary.getUncached().toDisplayString(rawForeignObject()));
}
if (getKlass() == getKlass().getMeta().java_lang_String) {
Meta meta = getKlass().getMeta();
StaticObject value = meta.java_lang_String_value.getObject(this);
if (value == null || isNull(value)) {
// Prevents debugger crashes when trying to inspect a string in construction.
return "<UNINITIALIZED>";
}
return Meta.toHostStringStatic(this);
}
if (isArray()) {
return unwrap().toString();
}
if (getKlass() == getKlass().getMeta().java_lang_Class) {
return "mirror: " + getMirrorKlass().toString();
}
StringBuilder str = new StringBuilder(getKlass().getType().toString());
for (Field f : ((ObjectKlass) getKlass()).getFieldTable()) {
// Also prints hidden fields
if (!f.isRemoved()) {
str.append("\n ").append(f.getName()).append(": ").append(f.get(this).toString());
}
}
return str.toString();
}
use of com.oracle.truffle.espresso.impl.ObjectKlass in project graal by oracle.
the class EspressoInterop method isMemberInvocable.
@ExportMessage
static boolean isMemberInvocable(StaticObject receiver, String member, @Exclusive @Cached LookupVirtualMethodNode lookupMethod) {
receiver.checkNotForeign();
if (isNull(receiver)) {
return false;
}
ObjectKlass k = getInteropKlass(receiver);
return lookupMethod.isInvocable(k, member);
}
Aggregations