java.lang.reflect.Executable#getDeclaringClass ( )源码实例Demo

下面列出了java.lang.reflect.Executable#getDeclaringClass ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: TencentKona-8   文件: TestCompilerInlining.java
public MethodDesc(Executable executable) {
    Class<?> aClass = executable.getDeclaringClass();
    className = Type.getInternalName(aClass).replace('.', '/');

    if (executable instanceof Constructor<?>) {
        methodName = "<init>";
        descriptor = Type.getConstructorDescriptor((Constructor<?>) executable);
    } else {
        methodName = executable.getName();
        descriptor = Type.getMethodDescriptor((Method) executable);
    }

}
 
源代码2 项目: AVM   文件: AvmDetails.java
private static boolean hasValidParamTypes(Executable method) {
    for (Class<?> c : method.getParameterTypes()) {
        if (!isShadowClass(c.getName()) &&
                !isArrayWrapperClass(c.getName()) &&
                !isPrimitive(c) &&
                !isSupportedInternalType(c.getName())) {
            if (method instanceof Method) {
                throw new AssertionError("transformed method " + method.getDeclaringClass() + "." + method.getName() + " should not have an unsupported parameter type: " + c.getName());
            }
            return false;
        }
    }
    return true;
}
 
源代码3 项目: openjdk-jdk8u   文件: TestCompilerInlining.java
public MethodDesc(Executable executable) {
    Class<?> aClass = executable.getDeclaringClass();
    className = Type.getInternalName(aClass).replace('.', '/');

    if (executable instanceof Constructor<?>) {
        methodName = "<init>";
        descriptor = Type.getConstructorDescriptor((Constructor<?>) executable);
    } else {
        methodName = executable.getName();
        descriptor = Type.getMethodDescriptor((Method) executable);
    }

}
 
源代码4 项目: openjdk-jdk9   文件: ClassType.java
public ClassType(Executable method) {
    // Use pack/subpack/Class::method separators style
    super(MethodDescriptor.Separator.SLASH);
    // Get package
    aClass = method.getDeclaringClass();
    Package aPackage = method.getDeclaringClass().getPackage();
    if (aPackage != null) {
        // split into directories
        packageDirs = aPackage.getName().split("\\.");
    } else {
        packageDirs = null;
    }
    setPackage = true;
    buildElement(setPackage);
}
 
源代码5 项目: armeria   文件: AnnotatedServiceFactory.java
/**
 * Returns the description of the specified {@link AnnotatedElement}.
 */
@Nullable
static String findDescription(AnnotatedElement annotatedElement) {
    requireNonNull(annotatedElement, "annotatedElement");
    final Description description = AnnotationUtil.findFirst(annotatedElement, Description.class);
    if (description != null) {
        final String value = description.value();
        if (DefaultValues.isSpecified(value)) {
            checkArgument(!value.isEmpty(), "value is empty.");
            return value;
        }
    } else if (annotatedElement instanceof Parameter) {
        // JavaDoc/KDoc descriptions only exist for method parameters
        final Parameter parameter = (Parameter) annotatedElement;
        final Executable executable = parameter.getDeclaringExecutable();
        final Class<?> clazz = executable.getDeclaringClass();
        final String fileName = getFileName(clazz.getCanonicalName());
        final String propertyName = executable.getName() + '.' + parameter.getName();
        final Properties cachedProperties = DOCUMENTATION_PROPERTIES_CACHE.getIfPresent(fileName);
        if (cachedProperties != null) {
            return cachedProperties.getProperty(propertyName);
        }
        try (InputStream stream = AnnotatedServiceFactory.class.getClassLoader()
                                                               .getResourceAsStream(fileName)) {
            if (stream == null) {
                return null;
            }
            final Properties properties = new Properties();
            properties.load(stream);
            DOCUMENTATION_PROPERTIES_CACHE.put(fileName, properties);
            return properties.getProperty(propertyName);
        } catch (IOException exception) {
            logger.warn("Failed to load an API description file: {}", fileName, exception);
        }
    }
    return null;
}