use of org.vmmagic.pragma.Pure in project JikesRVM by JikesRVM.
the class Class method getDefaultConstructor.
// --- Constructors ---
@Pure
private RVMMethod getDefaultConstructor() {
if (this.defaultConstructor == null) {
RVMMethod defaultConstructor = null;
RVMMethod[] methods = type.asClass().getConstructorMethods();
for (RVMMethod method : methods) {
if (method.getParameterTypes().length == 0) {
defaultConstructor = method;
break;
}
}
this.defaultConstructor = defaultConstructor;
}
return this.defaultConstructor;
}
use of org.vmmagic.pragma.Pure in project JikesRVM by JikesRVM.
the class Class method getFieldInternal.
// --- Fields ---
@Pure
private RVMField getFieldInternal(Atom name) {
RVMClass ctype = type.asClass();
// (1) Check my public declared fields
RVMField[] fields = ctype.getDeclaredFields();
for (RVMField field : fields) {
if (field.isPublic() && field.getName() == name) {
return field;
}
}
// (2) Check superinterfaces
RVMClass[] interfaces = ctype.getDeclaredInterfaces();
for (RVMClass anInterface : interfaces) {
RVMField ans = anInterface.getClassForType().getFieldInternal(name);
if (ans != null)
return ans;
}
// (3) Check superclass (if I have one).
if (ctype.getSuperClass() != null) {
return ctype.getSuperClass().getClassForType().getFieldInternal(name);
}
return null;
}
use of org.vmmagic.pragma.Pure in project JikesRVM by JikesRVM.
the class Class method getMethodInternal2.
@Pure
private RVMMethod getMethodInternal2(Atom aName, Class<?>... parameterTypes) {
RVMMethod answer = null;
RVMMethod[] methods = type.asClass().getVirtualMethods();
for (RVMMethod meth : methods) {
if (meth.getName() == aName && meth.isPublic() && parametersMatch(meth.getParameterTypes(), parameterTypes)) {
if (answer == null) {
answer = meth;
} else {
RVMMethod m2 = meth;
if (answer.getReturnType().resolve().isAssignableFrom(m2.getReturnType().resolve())) {
answer = m2;
}
}
}
}
return answer;
}
use of org.vmmagic.pragma.Pure in project JikesRVM by JikesRVM.
the class RVMClass method getAllImplementedInterfaces.
/**
* @return All of the interfaces implemented by this class either
* directly or by inheritance from superclass and superinterfaces
* recursively.
*/
@Pure
public RVMClass[] getAllImplementedInterfaces() {
if (VM.VerifyAssertions)
VM._assert(isResolved());
int count = 0;
int[] doesImplement = getDoesImplement();
for (int mask : doesImplement) {
while (mask != 0) {
count++;
// clear lsb 1 bit
mask &= (mask - 1);
}
}
if (count == 0)
return emptyVMClass;
RVMClass[] ans = new RVMClass[count];
for (int i = 0, idx = 0; i < doesImplement.length; i++) {
int mask = doesImplement[i];
if (mask != 0) {
for (int j = 0; j < 32; j++) {
if ((mask & (1 << j)) != 0) {
int id = 32 * i + j;
ans[idx++] = RVMClass.getInterface(id);
}
}
}
}
return ans;
}
Aggregations