Method[] validations = customValidations.get(type);
Method[] validations = null; WeakReference<Method[]> ref = customValidations.get(type); if (ref != null) validations = ref.get();
    public static Method[] findCustomValidationMethods(Class<? extends ActionBean> type) throws Exception {        Method[] validations = customValidations.get(type);        // Lazily examine the ActionBean and collect this information        if (validations == null) {            // A sorted set with a custom comparator that will order the methods in            // the set based upon the priority in their custom validation annotation            SortedSet<Method> validationMethods = new TreeSet<Method>( new Comparator<Method>() {                public int compare(Method o1, Method o2) {                    // If one of the methods overrides the others, return equal!                    if (o1.getName().equals(o2.getName()) &&                            Arrays.equals(o1.getParameterTypes(), o2.getParameterTypes())) {                        return 0;                    }                    ValidationMethod ann1 = o1.getAnnotation(ValidationMethod.class);                    ValidationMethod ann2 = o2.getAnnotation(ValidationMethod.class);                    int returnValue =  new Integer(ann1.priority()).compareTo(ann2.priority());                    if (returnValue == 0) {                        returnValue = o1.getName().compareTo(o2.getName());                    }                    return returnValue;                }            });            Class temp = type;            while ( temp != null ) {                for (Method method : temp.getDeclaredMethods()) {                    if (method.getAnnotation(ValidationMethod.class) != null) {                        validationMethods.add(method);                    }                }                temp = temp.getSuperclass();            }            validations = validationMethods.toArray(new Method[validationMethods.size()]);            customValidations.put(type, validations);        }        return validations;    }