コード例 #1
0
  /** Is a finalizer method extended from Object: {@code protected void finalize()} */
  @Pure
  public static boolean isFinalizer(final RVMMethod method) {
    if (!method.isProtected()) return false;

    // is the method name "finalize"
    byte[] name = method.getName().getBytes();
    if (name.length != 8) return false;
    // is the desc "()V"?
    byte[] desc = method.getDescriptor().getBytes();
    if (desc.length != 3) return false;

    if (name[0] != 'f'
        || name[1] != 'i'
        || name[2] != 'n'
        || name[3] != 'a'
        || name[4] != 'l'
        || name[5] != 'i'
        || name[6] != 'z'
        || name[7] != 'e'
        || desc[8] != '('
        || desc[9] != ')'
        || desc[10] != 'V') return false;

    return true;
  }
コード例 #2
0
ファイル: Class.java プロジェクト: abhijangda/JikesRVM
  public Method getDeclaredMethod(String name, Class<?>... parameterTypes)
      throws NoSuchMethodException, SecurityException {
    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);
  }
コード例 #3
0
ファイル: RVMAnnotation.java プロジェクト: ut-osa/laminar
 /** Are two annotations equal? */
 private boolean annotationEquals(Annotation a, Annotation b) {
   if (a == b) {
     return true;
   } else if (a.getClass() != b.getClass()) {
     return false;
   } else {
     RVMClass annotationInterface = type.resolve().asClass();
     RVMMethod[] annotationMethods = annotationInterface.getDeclaredMethods();
     AnnotationFactory afB = (AnnotationFactory) Proxy.getInvocationHandler(b);
     try {
       for (RVMMethod method : annotationMethods) {
         String name = method.getName().toUnicodeString();
         Object objA = getElementValue(name, method.getReturnType().resolve().getClassForType());
         Object objB = afB.getValue(name, method.getReturnType().resolve().getClassForType());
         if (!objA.getClass().isArray()) {
           if (!objA.equals(objB)) {
             return false;
           }
         } else {
           if (!Arrays.equals((Object[]) objA, (Object[]) objB)) {
             return false;
           }
         }
       }
     } catch (java.io.UTFDataFormatException e) {
       throw new Error(e);
     }
     return true;
   }
 }
コード例 #4
0
 private boolean match(RVMMethod method) {
   if (excludePattern == null) return true;
   RVMClass cls = method.getDeclaringClass();
   String clsName = cls.toString();
   if (clsName.compareTo("org.jikesrvm.compilers.opt.runtimesupport.OptSaveVolatile") == 0)
     return true;
   String methodName = method.getName().toString();
   String fullName = clsName + "." + methodName;
   return (fullName.indexOf(excludePattern)) < 0;
 }
コード例 #5
0
ファイル: Class.java プロジェクト: abhijangda/JikesRVM
 @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;
 }
コード例 #6
0
ファイル: RVMAnnotation.java プロジェクト: ut-osa/laminar
 /** Hash code for annotation value */
 private int annotationHashCode() {
   RVMClass annotationInterface = type.resolve().asClass();
   RVMMethod[] annotationMethods = annotationInterface.getDeclaredMethods();
   String typeString = type.toString();
   int result = typeString.substring(1, typeString.length() - 1).hashCode();
   try {
     for (RVMMethod method : annotationMethods) {
       String name = method.getName().toUnicodeString();
       Object value = getElementValue(name, method.getReturnType().resolve().getClassForType());
       int part_result = name.hashCode() * 127;
       if (value.getClass().isArray()) {
         if (value instanceof Object[]) {
           part_result ^= Arrays.hashCode((Object[]) value);
         } else if (value instanceof boolean[]) {
           part_result ^= Arrays.hashCode((boolean[]) value);
         } else if (value instanceof byte[]) {
           part_result ^= Arrays.hashCode((byte[]) value);
         } else if (value instanceof char[]) {
           part_result ^= Arrays.hashCode((char[]) value);
         } else if (value instanceof short[]) {
           part_result ^= Arrays.hashCode((short[]) value);
         } else if (value instanceof int[]) {
           part_result ^= Arrays.hashCode((int[]) value);
         } else if (value instanceof long[]) {
           part_result ^= Arrays.hashCode((long[]) value);
         } else if (value instanceof float[]) {
           part_result ^= Arrays.hashCode((float[]) value);
         } else if (value instanceof double[]) {
           part_result ^= Arrays.hashCode((double[]) value);
         }
       } else {
         part_result ^= value.hashCode();
       }
       result += part_result;
     }
   } catch (java.io.UTFDataFormatException e) {
     throw new Error(e);
   }
   return result;
 }
コード例 #7
0
ファイル: Class.java プロジェクト: abhijangda/JikesRVM
 @Pure
 private RVMMethod getMethodInternal1(Atom aName, Class<?>... parameterTypes) {
   RVMMethod answer = null;
   for (RVMClass current = type.asClass();
       current != null && answer == null;
       current = current.getSuperClass()) {
     RVMMethod[] methods = current.getDeclaredMethods();
     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;
 }
コード例 #8
0
ファイル: VMMethod.java プロジェクト: luiseduardohdbackup/mrp
 public String getName() {
   return method.getName().toString();
 }