当前位置: 首页>>代码示例>>Java>>正文


Java MethodFinder类代码示例

本文整理汇总了Java中com.sun.beans.finder.MethodFinder的典型用法代码示例。如果您正苦于以下问题:Java MethodFinder类的具体用法?Java MethodFinder怎么用?Java MethodFinder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MethodFinder类属于com.sun.beans.finder包,在下文中一共展示了MethodFinder类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getValueObject

import com.sun.beans.finder.MethodFinder; //导入依赖的package包/类
/**
 * Returns the result of method execution.
 *
 * @param type  the base class
 * @param args  the array of arguments
 * @return the value of this element
 * @throws Exception if calculation is failed
 */
@Override
protected ValueObject getValueObject(Class<?> type, Object[] args) throws Exception {
    Object bean = getContextBean();
    Class<?>[] types = getArgumentTypes(args);
    Method method = (type != null)
            ? MethodFinder.findStaticMethod(type, this.name, types)
            : MethodFinder.findMethod(bean.getClass(), this.name, types);

    if (method.isVarArgs()) {
        args = getArguments(args, method.getParameterTypes());
    }
    Object value = MethodUtil.invoke(method, bean, args);
    return method.getReturnType().equals(void.class)
            ? ValueObjectImpl.VOID
            : ValueObjectImpl.create(value);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:MethodElementHandler.java

示例2: getValueObject

import com.sun.beans.finder.MethodFinder; //导入依赖的package包/类
/**
 * Returns the result of method execution.
 *
 * @param type  the base class
 * @param args  the array of arguments
 * @return the value of this element
 * @throws Exception if calculation is failed
 */
@Override
protected ValueObject getValueObject(Class<?> type, Object[] args) throws Exception {
    Object bean = getContextBean();
    Class<?>[] types = getArgumentTypes(args);
    Method method = (type != null)
            ? MethodFinder.findStaticMethod(type, this.name, types)
            : MethodFinder.findMethod(bean.getClass(), this.name, types);

    if (method.isVarArgs()) {
        args = getArguments(args, method.getParameterTypes());
    }
    Object value = method.invoke(bean, args);
    return method.getReturnType().equals(void.class)
            ? ValueObjectImpl.VOID
            : ValueObjectImpl.create(value);
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:25,代码来源:MethodElementHandler.java

示例3: getPublicDeclaredMethods

import com.sun.beans.finder.MethodFinder; //导入依赖的package包/类
private static Method[] getPublicDeclaredMethods(Class<?> clz) {
    // Looking up Class.getDeclaredMethods is relatively expensive,
    // so we cache the results.
    if (!ReflectUtil.isPackageAccessible(clz)) {
        return new Method[0];
    }
    synchronized (declaredMethodCache) {
        Method[] result = declaredMethodCache.get(clz);
        if (result == null) {
            result = clz.getMethods();
            for (int i = 0; i < result.length; i++) {
                Method method = result[i];
                if (!method.getDeclaringClass().equals(clz)) {
                    result[i] = null; // ignore methods declared elsewhere
                }
                else {
                    try {
                        method = MethodFinder.findAccessibleMethod(method);
                        Class<?> type = method.getDeclaringClass();
                        result[i] = type.equals(clz) || type.isInterface()
                                ? method
                                : null; // ignore methods from superclasses
                    }
                    catch (NoSuchMethodException exception) {
                        // commented out because of 6976577
                        // result[i] = null; // ignore inaccessible methods
                    }
                }
            }
            declaredMethodCache.put(clz, result);
        }
        return result;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:35,代码来源:Introspector.java

示例4: getMethod

import com.sun.beans.finder.MethodFinder; //导入依赖的package包/类
static Method getMethod(Class<?> type, String name, Class<?>... args) {
    try {
        return MethodFinder.findMethod(type, name, args);
    }
    catch (NoSuchMethodException exception) {
        return null;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:Statement.java

示例5: main

import com.sun.beans.finder.MethodFinder; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    List<Class<?>> classes = Task.getClasses(4000);
    List<Method> methods = new ArrayList<>();
    for (Class<?> type : classes) {
        Collections.addAll(methods, type.getMethods());
    }
    Task.print("found " + methods.size() + " methods in " + classes.size() + " classes");

    List<Task> tasks = new ArrayList<>();
    for (int i = 0; i < 50; i++) {
        tasks.add(new Task<Method>(methods) {
            @Override
            protected void process(Method method) throws NoSuchMethodException {
                MethodFinder.findMethod(method.getDeclaringClass(), method.getName(), method.getParameterTypes());
            }
        });
    }
    int alarm = 0;
    while (true) {
        int alive = 0;
        int working = 0;
        for (Task task : tasks) {
            if (task.isWorking()) {
                working++;
                alive++;
            } else if (task.isAlive()) {
                alive++;
            }
        }
        if (alive == 0) {
            break;
        }
        Task.print(working + " out of " + alive + " threads are working");
        if ((working == 0) && (++alarm == 10)) {
            Task.print("DEADLOCK DETECTED");
            System.exit(100);
        }
        Thread.sleep(1000);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:41,代码来源:TestMethodFinder.java

示例6: get

import com.sun.beans.finder.MethodFinder; //导入依赖的package包/类
static List<Method> get(Class<?> type) {
    List<Method> list = null;
    if (type != null) {
        boolean inaccessible = !Modifier.isPublic(type.getModifiers());
        for (Method method : type.getMethods()) {
            if (method.getDeclaringClass().equals(type)) {
                if (inaccessible) {
                    try {
                        method = MethodFinder.findAccessibleMethod(method);
                        if (!method.getDeclaringClass().isInterface()) {
                            method = null; // ignore methods from superclasses
                        }
                    } catch (NoSuchMethodException exception) {
                        // commented out because of 6976577
                        // method = null; // ignore inaccessible methods
                    }
                }
                if (method != null) {
                    if (list == null) {
                        list = new ArrayList<>();
                    }
                    list.add(method);
                }
            }
        }
    }
    if (list != null) {
        list.sort(MethodOrder.instance);
        return Collections.unmodifiableList(list);
    }
    return Collections.emptyList();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:33,代码来源:MethodInfo.java

示例7: main

import com.sun.beans.finder.MethodFinder; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    List<Class<?>> classes = Task.getClasses(4000);
    List<Method> methods = new ArrayList<>();
    for (Class<?> type : classes) {
        Collections.addAll(methods, type.getMethods());
    }
    Task.print("found " + methods.size() + " methods in " + classes.size() + " classes");

    List<Task> tasks = new ArrayList<>();
    for (int i = 0; i < 50; i++) {
        tasks.add(new Task<Method>(methods) {
            @Override
            protected void process(Method method) throws NoSuchMethodException {
                MethodFinder.findMethod(method.getDeclaringClass(), method.getName(), method.getParameterTypes());
            }
        });
    }
    int alarm = 0;
    while (true) {
        int alive = 0;
        int working = 0;
        for (Task task : tasks) {
            if (task.isWorking()) {
                working++;
                alive++;
            } else if (task.isAlive()) {
                alive++;
            }
        }
        if (alive == 0) {
            break;
        }
        Task.print(working + " out of " + alive + " threads are working");
        if ((working == 0) && (++alarm == 10)) {
            throw new RuntimeException("FAIL - DEADLOCK DETECTED");
        }
        Thread.sleep(1000);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:40,代码来源:TestMethodFinder.java

示例8: get

import com.sun.beans.finder.MethodFinder; //导入依赖的package包/类
static List<Method> get(Class<?> type) {
    List<Method> list = null;
    if (type != null) {
        boolean inaccessible = !Modifier.isPublic(type.getModifiers());
        for (Method method : type.getMethods()) {
            if (method.getDeclaringClass().equals(type)) {
                if (inaccessible) {
                    try {
                        method = MethodFinder.findAccessibleMethod(method);
                        if (!method.getDeclaringClass().isInterface()) {
                            method = null; // ignore methods from superclasses
                        }
                    } catch (NoSuchMethodException exception) {
                        // commented out because of 6976577
                        // method = null; // ignore inaccessible methods
                    }
                }
                if (method != null) {
                    if (list == null) {
                        list = new ArrayList<>();
                    }
                    list.add(method);
                }
            }
        }
    }
    return (list != null)
            ? Collections.unmodifiableList(list)
            : Collections.emptyList();
}
 
开发者ID:campolake,项目名称:openjdk9,代码行数:31,代码来源:MethodInfo.java


注:本文中的com.sun.beans.finder.MethodFinder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。