use of com.oracle.truffle.espresso.impl.Field in project graal by oracle.
the class ClassRedefinition method createDelegationFrom.
public synchronized Field createDelegationFrom(Field field) {
Field delegationField = RedefineAddedField.createDelegationField(field);
if (currentDelegationFields == null) {
currentDelegationFields = new ArrayList<>(1);
}
currentDelegationFields.add(delegationField);
return delegationField;
}
use of com.oracle.truffle.espresso.impl.Field 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.Field in project graal by oracle.
the class Target_java_lang_invoke_MethodHandleNatives method plantFieldMemberName.
private static void plantFieldMemberName(StaticObject memberName, Klass resolutionKlass, Symbol<Name> name, Symbol<Type> type, int refKind, Klass callerKlass, boolean constraintsCheck, Meta meta) {
Field field = resolutionKlass.lookupField(name, type);
if (field == null) {
throw meta.throwExceptionWithMessage(meta.java_lang_NoSuchFieldError, cat("Failed lookup for field ", resolutionKlass.getName(), "#", name, ":", type));
}
if (constraintsCheck) {
field.checkLoadingConstraints(callerKlass.getDefiningClassLoader(), resolutionKlass.getDefiningClassLoader());
}
plantResolvedField(memberName, field, refKind, meta);
}
use of com.oracle.truffle.espresso.impl.Field in project graal by oracle.
the class EspressoInterop method writeMember.
@ExportMessage
static void writeMember(StaticObject receiver, String member, Object value, @Cached @Exclusive LookupInstanceFieldNode lookup, @Cached ToEspressoNode toEspresso, @Shared("error") @Cached BranchProfile error) throws UnsupportedTypeException, UnknownIdentifierException, UnsupportedMessageException {
receiver.checkNotForeign();
Field f = lookup.execute(getInteropKlass(receiver), member);
if (f != null) {
if (f.isFinalFlagSet()) {
error.enter();
throw UnsupportedMessageException.create();
}
f.set(receiver, toEspresso.execute(value, f.resolveTypeKlass()));
return;
}
error.enter();
throw UnknownIdentifierException.create(member);
}
use of com.oracle.truffle.espresso.impl.Field in project graal by oracle.
the class Target_sun_misc_Unsafe method putCharVolatile.
@TruffleBoundary(allowInlining = true)
@Substitution(hasReceiver = true)
public static void putCharVolatile(@SuppressWarnings("unused") @JavaType(Unsafe.class) StaticObject self, @JavaType(Object.class) StaticObject holder, long offset, char value, @Inject Meta meta) {
if (isNullOrArray(holder)) {
UnsafeAccess.getIfAllowed(meta).putCharVolatile(unwrapNullOrArray(holder), offset, value);
return;
}
// TODO(peterssen): Current workaround assumes it's a field access, encoding is offset <->
// field index.
Field f = getInstanceFieldFromIndex(holder, Math.toIntExact(offset) - SAFETY_FIELD_OFFSET);
assert f != null;
assert f.getKind().isSubWord();
f.setChar(holder, value, true);
}
Aggregations