use of com.oracle.truffle.espresso.impl.ObjectKlass in project graal by oracle.
the class InvokeInterface method methodLookup.
static Method.MethodVersion methodLookup(Method resolutionSeed, Klass receiverKlass) {
assert !receiverKlass.isArray();
if (resolutionSeed.isRemovedByRedefition()) {
/*
* Accept a slow path once the method has been removed put method behind a boundary to
* avoid a deopt loop
*/
return resolutionSeed.getContext().getClassRedefinition().handleRemovedMethod(resolutionSeed, receiverKlass).getMethodVersion();
}
int iTableIndex = resolutionSeed.getITableIndex();
Method method = ((ObjectKlass) receiverKlass).itableLookup(resolutionSeed.getDeclaringKlass(), iTableIndex);
if (!method.isPublic()) {
transferToInterpreterAndInvalidate();
Meta meta = receiverKlass.getMeta();
throw meta.throwException(meta.java_lang_IllegalAccessError);
}
return method.getMethodVersion();
}
use of com.oracle.truffle.espresso.impl.ObjectKlass in project graal by oracle.
the class DefaultClassHierarchyOracle method addImplementor.
/**
* Recursively adds {@code implementor} as an implementor of {@code superInterface} and its
* parent interfaces.
*/
private void addImplementor(ObjectKlass superInterface, ObjectKlass.KlassVersion implementor) {
superInterface.getNoConcreteSubclassesAssumption(ClassHierarchyAccessor.accessor).getAssumption().invalidate();
superInterface.getImplementor(ClassHierarchyAccessor.accessor).addImplementor(implementor);
for (ObjectKlass ancestorInterface : superInterface.getSuperInterfaces()) {
addImplementor(ancestorInterface, implementor);
}
}
use of com.oracle.truffle.espresso.impl.ObjectKlass in project graal by oracle.
the class DefaultClassHierarchyOracle method addImplementorToAncestors.
private void addImplementorToAncestors(ObjectKlass.KlassVersion newKlass) {
for (ObjectKlass superInterface : newKlass.getSuperInterfaces()) {
addImplementor(superInterface, newKlass);
}
ObjectKlass currentKlass = newKlass.getSuperKlass();
while (currentKlass != null) {
currentKlass.getNoConcreteSubclassesAssumption(ClassHierarchyAccessor.accessor).getAssumption().invalidate();
currentKlass.getImplementor(ClassHierarchyAccessor.accessor).addImplementor(newKlass);
for (ObjectKlass superInterface : currentKlass.getSuperInterfaces()) {
addImplementor(superInterface, newKlass);
}
currentKlass = currentKlass.getSuperKlass();
}
}
use of com.oracle.truffle.espresso.impl.ObjectKlass in project graal by oracle.
the class VM method JVM_LookupDefineClass.
@VmImpl(isJni = true)
@TruffleBoundary
@JavaType(Class.class)
public StaticObject JVM_LookupDefineClass(@JavaType(Class.class) StaticObject lookup, @Pointer TruffleObject namePtr, @Pointer TruffleObject bufPtr, int len, @JavaType(ProtectionDomain.class) StaticObject pd, boolean initialize, int flags, @JavaType(Object.class) StaticObject classData) {
if (StaticObject.isNull(lookup)) {
throw getMeta().throwExceptionWithMessage(getMeta().java_lang_InternalError, "Lookup class is null");
}
assert !getUncached().isNull(bufPtr);
assert lookup.getMirrorKlass() instanceof ObjectKlass;
boolean isNestMate = (flags & NESTMATE_CLASS) == NESTMATE_CLASS;
boolean isHidden = (flags & HIDDEN_CLASS) == HIDDEN_CLASS;
boolean isStrong = (flags & STRONG_LOADER_LINK) == STRONG_LOADER_LINK;
boolean vmAnnotations = (flags & ACCESS_VM_ANNOTATIONS) == ACCESS_VM_ANNOTATIONS;
ObjectKlass nest = null;
if (isNestMate) {
nest = (ObjectKlass) lookup.getMirrorKlass().nest();
}
if (!isHidden) {
if (!StaticObject.isNull(classData)) {
throw getMeta().throwExceptionWithMessage(getMeta().java_lang_IllegalArgumentException, "classData is only applicable for hidden classes");
}
if (isNestMate) {
throw getMeta().throwExceptionWithMessage(getMeta().java_lang_IllegalArgumentException, "dynamic nestmate is only applicable for hidden classes");
}
if (!isStrong) {
throw getMeta().throwExceptionWithMessage(getMeta().java_lang_IllegalArgumentException, "an ordinary class must be strongly referenced by its defining loader");
}
if (vmAnnotations) {
throw getMeta().throwExceptionWithMessage(getMeta().java_lang_IllegalArgumentException, "vm annotations only allowed for hidden classes");
}
if (flags != STRONG_LOADER_LINK) {
throw getMeta().throwExceptionWithMessage(getMeta().java_lang_IllegalArgumentException, String.format("invalid flag 0x%x", flags));
}
}
ByteBuffer buf = NativeUtils.directByteBuffer(bufPtr, len, JavaKind.Byte);
final byte[] bytes = new byte[len];
buf.get(bytes);
// can be null
Symbol<Type> type = namePtrToInternal(namePtr);
StaticObject loader = lookup.getMirrorKlass().getDefiningClassLoader();
ObjectKlass k;
if (isHidden) {
// Special handling
k = getRegistries().defineKlass(type, bytes, loader, new ClassRegistry.ClassDefinitionInfo(pd, nest, classData, isStrong));
} else {
k = getRegistries().defineKlass(type, bytes, loader, new ClassRegistry.ClassDefinitionInfo(pd));
}
if (initialize) {
k.safeInitialize();
} else {
k.ensureLinked();
}
return k.mirror();
}
use of com.oracle.truffle.espresso.impl.ObjectKlass in project graal by oracle.
the class VM method JVM_GetSimpleBinaryName.
@VmImpl(isJni = true)
@JavaType(String.class)
public StaticObject JVM_GetSimpleBinaryName(@JavaType(Class.class) StaticObject self) {
Klass k = self.getMirrorKlass();
if (k.isPrimitive() || k.isArray()) {
return StaticObject.NULL;
}
ObjectKlass klass = (ObjectKlass) k;
RuntimeConstantPool pool = klass.getConstantPool();
InnerClassesAttribute inner = klass.getInnerClasses();
for (InnerClassesAttribute.Entry entry : inner.entries()) {
int innerClassIndex = entry.innerClassIndex;
if (innerClassIndex != 0) {
if (pool.classAt(innerClassIndex).getName(pool) == klass.getName()) {
if (pool.resolvedKlassAt(k, innerClassIndex) == k) {
if (entry.innerNameIndex != 0) {
Symbol<Name> innerName = pool.symbolAt(entry.innerNameIndex);
return getMeta().toGuestString(innerName);
} else {
break;
}
}
}
}
}
return StaticObject.NULL;
}
Aggregations