use of org.jikesrvm.classloader.RVMMethod in project JikesRVM by JikesRVM.
the class Class method getConstructors.
public Constructor<?>[] getConstructors() throws SecurityException {
checkMemberAccess(Member.PUBLIC);
if (!type.isClassType())
return new Constructor[0];
RVMMethod[] methods = type.asClass().getConstructorMethods();
ArrayList<Constructor<T>> coll = new ArrayList<Constructor<T>>(methods.length);
for (RVMMethod method : methods) {
if (method.isPublic()) {
@SuppressWarnings("unchecked") Constructor<T> x = (Constructor<T>) JikesRVMSupport.createConstructor(method);
coll.add(x);
}
}
return coll.toArray(new Constructor[coll.size()]);
}
use of org.jikesrvm.classloader.RVMMethod in project JikesRVM by JikesRVM.
the class Class method getEnclosingConstructor.
public Constructor<?> getEnclosingConstructor() {
if (!(isAnonymousClass() || isLocalClass())) {
return null;
}
MethodReference enclosingMethodRef = type.asClass().getEnclosingMethod();
if (enclosingMethodRef == null) {
return null;
}
RVMMethod method = enclosingMethodRef.resolve();
if (!method.isObjectInitializer()) {
return null;
}
return JikesRVMSupport.createConstructor(method);
}
use of org.jikesrvm.classloader.RVMMethod in project JikesRVM by JikesRVM.
the class Class method getDeclaredMethods.
public Method[] getDeclaredMethods() throws SecurityException {
checkMemberAccess(Member.DECLARED);
if (!type.isClassType())
return new Method[0];
RVMMethod[] methods = type.asClass().getDeclaredMethods();
ArrayList<Method> coll = new ArrayList<Method>(methods.length);
for (RVMMethod meth : methods) {
if (!meth.isClassInitializer() && !meth.isObjectInitializer()) {
coll.add(JikesRVMSupport.createMethod(meth));
}
}
return coll.toArray(new Method[coll.size()]);
}
use of org.jikesrvm.classloader.RVMMethod in project JikesRVM by JikesRVM.
the class Class method getMethods.
public Method[] getMethods() throws SecurityException {
checkMemberAccess(Member.PUBLIC);
RVMMethod[] static_methods = type.getStaticMethods();
RVMMethod[] virtual_methods = type.getVirtualMethods();
HashSet<Method> coll = new HashSet<Method>(static_methods.length + virtual_methods.length);
for (RVMMethod meth : static_methods) {
if (meth.isPublic()) {
coll.add(JikesRVMSupport.createMethod(meth));
}
}
for (RVMMethod meth : virtual_methods) {
if (meth.isPublic()) {
coll.add(JikesRVMSupport.createMethod(meth));
}
}
// The Java API says that duplicate versions are returned if multiple
// versions of a method are defined by a class. This only applies to
// abstract classes and interfaces because normal classes always have
// exactly one definition for a given signature-name pair.
RVMClass thisClass = type.asClass();
boolean isAbstract = thisClass.isAbstract();
if (isInterface() || isAbstract) {
// For each virtual method , search all superinterfaces
// to find all declarations that aren't shadowed by superinterfaces and
// add those to the set of methods.
HashSet<Method> methods = new HashSet<Method>();
for (RVMMethod m : virtual_methods) {
Atom name = m.getName();
Atom desc = m.getDescriptor();
if (isAbstract && !m.getDeclaringClass().isInterface()) {
// method.
continue;
}
collectDeclarations(thisClass, name, desc, methods);
}
coll.addAll(methods);
}
return coll.toArray(new Method[coll.size()]);
}
use of org.jikesrvm.classloader.RVMMethod in project JikesRVM by JikesRVM.
the class Class method getDeclaredMethod.
public Method getDeclaredMethod(String name, Class<?>... parameterTypes) throws NoSuchMethodException, SecurityException {
throwNPEWhenNameIsNull(name);
checkMemberAccess(Member.DECLARED);
if (!type.isClassType())
throwNoSuchMethodException(name, parameterTypes);
if (name == null) {
throwNoSuchMethodException(name, parameterTypes);
}
Atom aName = Atom.findOrCreateUnicodeAtom(name);
if (aName == RVMClassLoader.StandardClassInitializerMethodName || aName == RVMClassLoader.StandardObjectInitializerMethodName) {
// <init> and <clinit> are not methods.
throwNoSuchMethodException(name, parameterTypes);
}
RVMMethod[] methods = type.asClass().getDeclaredMethods();
RVMMethod answer = null;
for (RVMMethod meth : methods) {
if (meth.getName() == aName && parametersMatch(meth.getParameterTypes(), parameterTypes)) {
if (answer == null) {
answer = meth;
} else {
RVMMethod m2 = meth;
if (answer.getReturnType().resolve().isAssignableFrom(m2.getReturnType().resolve())) {
answer = m2;
}
}
}
}
if (answer == null) {
throwNoSuchMethodException(name, parameterTypes);
}
return JikesRVMSupport.createMethod(answer);
}
Aggregations