use of com.oracle.truffle.espresso.classfile.RuntimeConstantPool in project graal by oracle.
the class Method method redefine.
public SharedRedefinitionContent redefine(ObjectKlass.KlassVersion klassVersion, ParserMethod newMethod, ParserKlass newKlass, Ids<Object> ids) {
// install the new method version immediately
LinkedMethod newLinkedMethod = new LinkedMethod(newMethod);
RuntimeConstantPool runtimePool = new RuntimeConstantPool(getContext(), newKlass.getConstantPool(), getDeclaringKlass().getDefiningClassLoader());
CodeAttribute newCodeAttribute = (CodeAttribute) newMethod.getAttribute(Name.Code);
MethodVersion oldVersion = methodVersion;
methodVersion = oldVersion.replace(klassVersion, runtimePool, newLinkedMethod, newCodeAttribute);
ids.replaceObject(oldVersion, methodVersion);
return new SharedRedefinitionContent(newLinkedMethod, runtimePool, newCodeAttribute);
}
use of com.oracle.truffle.espresso.classfile.RuntimeConstantPool in project graal by oracle.
the class ObjectKlass method getNestMembers.
@Override
public Klass[] getNestMembers() {
if (this != nest()) {
return nest().getNestMembers();
}
NestMembersAttribute nestMembers = (NestMembersAttribute) getAttribute(NestMembersAttribute.NAME);
if (nestMembers == null || nestMembers.getClasses().length == 0) {
return new Klass[] { nest() };
}
RuntimeConstantPool pool = getConstantPool();
ArrayList<Klass> klasses = new ArrayList<>(1 + nestMembers.getClasses().length);
klasses.add(nest());
for (int i = 0; i < nestMembers.getClasses().length; i++) {
int index = nestMembers.getClasses()[i];
try {
klasses.add(pool.resolvedKlassAt(this, index));
} catch (EspressoException e) {
/*
* Don't allow badly constructed nest members to break execution here, only report
* well-constructed entries.
*/
}
}
return klasses.toArray(Klass.EMPTY_ARRAY);
}
use of com.oracle.truffle.espresso.classfile.RuntimeConstantPool in project graal by oracle.
the class ObjectKlass method nestMembersCheck.
@Override
public boolean nestMembersCheck(Klass k) {
NestMembersAttribute nestMembers = (NestMembersAttribute) getAttribute(NestMembersAttribute.NAME);
if (nestMembers == null) {
return false;
}
if (!this.sameRuntimePackage(k)) {
return false;
}
RuntimeConstantPool pool = getConstantPool();
for (int index : nestMembers.getClasses()) {
if (k.getName().equals(pool.classAt(index).getName(pool))) {
if (k == pool.resolvedKlassAt(this, index)) {
return true;
}
}
}
return false;
}
use of com.oracle.truffle.espresso.classfile.RuntimeConstantPool 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;
}
use of com.oracle.truffle.espresso.classfile.RuntimeConstantPool in project graal by oracle.
the class VM method JVM_GetEnclosingMethodInfo.
@VmImpl(isJni = true)
@JavaType(Object[].class)
public StaticObject JVM_GetEnclosingMethodInfo(@JavaType(Class.class) StaticObject self) {
Meta meta = getMeta();
InterpreterToVM vm = meta.getInterpreterToVM();
if (self.getMirrorKlass() instanceof ObjectKlass) {
ObjectKlass klass = (ObjectKlass) self.getMirrorKlass();
EnclosingMethodAttribute enclosingMethodAttr = klass.getEnclosingMethod();
if (enclosingMethodAttr == null) {
return StaticObject.NULL;
}
int classIndex = enclosingMethodAttr.getClassIndex();
if (classIndex == 0) {
return StaticObject.NULL;
}
StaticObject arr = meta.java_lang_Object.allocateReferenceArray(3);
RuntimeConstantPool pool = klass.getConstantPool();
Klass enclosingKlass = pool.resolvedKlassAt(klass, classIndex);
vm.setArrayObject(enclosingKlass.mirror(), 0, arr);
int methodIndex = enclosingMethodAttr.getMethodIndex();
if (methodIndex != 0) {
NameAndTypeConstant nmt = pool.nameAndTypeAt(methodIndex);
StaticObject name = meta.toGuestString(nmt.getName(pool));
StaticObject desc = meta.toGuestString(nmt.getDescriptor(pool));
vm.setArrayObject(name, 1, arr);
vm.setArrayObject(desc, 2, arr);
}
return arr;
}
return StaticObject.NULL;
}
Aggregations