Example #1
0
  public Constructor<?>[] getDeclaredConstructors() throws SecurityException {
    checkMemberAccess(Member.DECLARED);
    if (!type.isClassType()) return new Constructor[0];

    RVMMethod[] methods = type.asClass().getConstructorMethods();
    Constructor<?>[] ans = new Constructor[methods.length];
    for (int i = 0; i < methods.length; i++) {
      ans[i] = JikesRVMSupport.createConstructor(methods[i]);
    }
    return ans;
  }
Example #2
0
  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()]);
  }
Example #3
0
  public Constructor<T> getDeclaredConstructor(Class<?>... parameterTypes)
      throws NoSuchMethodException, SecurityException {
    checkMemberAccess(Member.DECLARED);
    if (!type.isClassType()) throwNoSuchMethodException("<init>", parameterTypes);

    RVMMethod answer = null;
    if (parameterTypes == null || parameterTypes.length == 0) {
      answer = getDefaultConstructor();
    } else {
      RVMMethod[] methods = type.asClass().getConstructorMethods();
      for (RVMMethod method : methods) {
        if (parametersMatch(method.getParameterTypes(), parameterTypes)) {
          answer = method;
          break;
        }
      }
    }
    if (answer == null) {
      throwNoSuchMethodException("<init>", parameterTypes);
    }
    return JikesRVMSupport.createConstructor(answer);
  }