java.lang.reflect.Modifier#classModifiers ( )源码实例Demo

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

源代码1 项目: openjdk-jdk9   文件: TestResolvedJavaType.java
@Test
public void getModifiersTest() {
    for (Class<?> c : classes) {
        ResolvedJavaType type = metaAccess.lookupJavaType(c);
        int mask = Modifier.classModifiers() & ~Modifier.STATIC;
        int expected = c.getModifiers() & mask;
        int actual = type.getModifiers() & mask;
        Class<?> elementalType = c;
        while (elementalType.isArray()) {
            elementalType = elementalType.getComponentType();
        }
        if (elementalType.isMemberClass()) {
            // member class get their modifiers from the inner-class attribute in the JVM and
            // from the classfile header in jvmci
            expected &= ~(Modifier.PUBLIC | Modifier.PRIVATE | Modifier.PROTECTED);
            actual &= ~(Modifier.PUBLIC | Modifier.PRIVATE | Modifier.PROTECTED);
        }
        assertEquals(String.format("%s: 0x%x != 0x%x", type, expected, actual), expected, actual);
    }
}
 
源代码2 项目: es6draft   文件: Code.java
private static ClassCode newClass(ConstantPool constantPool, int access, String className, ClassSignature signature,
        Type superClass, List<Type> interfaces, SourceInfo sourceInfo) {
    if ((access & ~Modifier.classModifiers()) != 0) {
        throw new IllegalArgumentException();
    }
    ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
    cw.visit(JAVA_VERSION, access | Opcodes.ACC_SUPER, className, signature.toString(), superClass.internalName(),
            toInternalNames(interfaces));
    cw.visitSource(sourceInfo.getFileName(), sourceInfo.getSourceMap());

    return new ClassCode(constantPool, className, cw);
}
 
源代码3 项目: jdk1.8-source-analysis   文件: Class.java
/**
 * Returns a string describing this {@code Class}, including
 * information about modifiers and type parameters.
 *
 * The string is formatted as a list of type modifiers, if any,
 * followed by the kind of type (empty string for primitive types
 * and {@code class}, {@code enum}, {@code interface}, or
 * <code>&#64;</code>{@code interface}, as appropriate), followed
 * by the type's name, followed by an angle-bracketed
 * comma-separated list of the type's type parameters, if any.
 *
 * A space is used to separate modifiers from one another and to
 * separate any modifiers from the kind of type. The modifiers
 * occur in canonical order. If there are no type parameters, the
 * type parameter list is elided.
 *
 * <p>Note that since information about the runtime representation
 * of a type is being generated, modifiers not present on the
 * originating source code or illegal on the originating source
 * code may be present.
 *
 * @return a string describing this {@code Class}, including
 * information about modifiers and type parameters
 *
 * @since 1.8
 */
public String toGenericString() {
    if (isPrimitive()) {
        return toString();
    } else {
        StringBuilder sb = new StringBuilder();

        // Class modifiers are a superset of interface modifiers
        int modifiers = getModifiers() & Modifier.classModifiers();
        if (modifiers != 0) {
            sb.append(Modifier.toString(modifiers));
            sb.append(' ');
        }

        if (isAnnotation()) {
            sb.append('@');
        }
        if (isInterface()) { // Note: all annotation types are interfaces
            sb.append("interface");
        } else {
            if (isEnum())
                sb.append("enum");
            else
                sb.append("class");
        }
        sb.append(' ');
        sb.append(getName());

        TypeVariable<?>[] typeparms = getTypeParameters();
        if (typeparms.length > 0) {
            boolean first = true;
            sb.append('<');
            for(TypeVariable<?> typeparm: typeparms) {
                if (!first)
                    sb.append(',');
                sb.append(typeparm.getTypeName());
                first = false;
            }
            sb.append('>');
        }

        return sb.toString();
    }
}
 
源代码4 项目: AndroidComponentPlugin   文件: Class.java
/**
 * Returns a string describing this {@code Class}, including
 * information about modifiers and type parameters.
 *
 * The string is formatted as a list of type modifiers, if any,
 * followed by the kind of type (empty string for primitive types
 * and {@code class}, {@code enum}, {@code interface}, or
 * <code>&#64;</code>{@code interface}, as appropriate), followed
 * by the type's name, followed by an angle-bracketed
 * comma-separated list of the type's type parameters, if any.
 *
 * A space is used to separate modifiers from one another and to
 * separate any modifiers from the kind of type. The modifiers
 * occur in canonical order. If there are no type parameters, the
 * type parameter list is elided.
 *
 * <p>Note that since information about the runtime representation
 * of a type is being generated, modifiers not present on the
 * originating source code or illegal on the originating source
 * code may be present.
 *
 * @return a string describing this {@code Class}, including
 * information about modifiers and type parameters
 *
 * @since 1.8
 */
public String toGenericString() {
    if (isPrimitive()) {
        return toString();
    } else {
        StringBuilder sb = new StringBuilder();

        // Class modifiers are a superset of interface modifiers
        int modifiers = getModifiers() & Modifier.classModifiers();
        if (modifiers != 0) {
            sb.append(Modifier.toString(modifiers));
            sb.append(' ');
        }

        if (isAnnotation()) {
            sb.append('@');
        }
        if (isInterface()) { // Note: all annotation types are interfaces
            sb.append("interface");
        } else {
            if (isEnum())
                sb.append("enum");
            else
                sb.append("class");
        }
        sb.append(' ');
        sb.append(getName());

        TypeVariable<?>[] typeparms = getTypeParameters();
        if (typeparms.length > 0) {
            boolean first = true;
            sb.append('<');
            for(TypeVariable<?> typeparm: typeparms) {
                if (!first)
                    sb.append(',');
                sb.append(typeparm.getTypeName());
                first = false;
            }
            sb.append('>');
        }

        return sb.toString();
    }
}
 
源代码5 项目: AndroidComponentPlugin   文件: Class.java
/**
 * Returns a string describing this {@code Class}, including
 * information about modifiers and type parameters.
 *
 * The string is formatted as a list of type modifiers, if any,
 * followed by the kind of type (empty string for primitive types
 * and {@code class}, {@code enum}, {@code interface}, or
 * <code>&#64;</code>{@code interface}, as appropriate), followed
 * by the type's name, followed by an angle-bracketed
 * comma-separated list of the type's type parameters, if any.
 *
 * A space is used to separate modifiers from one another and to
 * separate any modifiers from the kind of type. The modifiers
 * occur in canonical order. If there are no type parameters, the
 * type parameter list is elided.
 *
 * <p>Note that since information about the runtime representation
 * of a type is being generated, modifiers not present on the
 * originating source code or illegal on the originating source
 * code may be present.
 *
 * @return a string describing this {@code Class}, including
 * information about modifiers and type parameters
 *
 * @since 1.8
 */
public String toGenericString() {
    if (isPrimitive()) {
        return toString();
    } else {
        StringBuilder sb = new StringBuilder();

        // Class modifiers are a superset of interface modifiers
        int modifiers = getModifiers() & Modifier.classModifiers();
        if (modifiers != 0) {
            sb.append(Modifier.toString(modifiers));
            sb.append(' ');
        }

        if (isAnnotation()) {
            sb.append('@');
        }
        if (isInterface()) { // Note: all annotation types are interfaces
            sb.append("interface");
        } else {
            if (isEnum())
                sb.append("enum");
            else
                sb.append("class");
        }
        sb.append(' ');
        sb.append(getName());

        TypeVariable<?>[] typeparms = getTypeParameters();
        if (typeparms.length > 0) {
            boolean first = true;
            sb.append('<');
            for(TypeVariable<?> typeparm: typeparms) {
                if (!first)
                    sb.append(',');
                sb.append(typeparm.getTypeName());
                first = false;
            }
            sb.append('>');
        }

        return sb.toString();
    }
}
 
源代码6 项目: dragonwell8_jdk   文件: Class.java
/**
 * Returns a string describing this {@code Class}, including
 * information about modifiers and type parameters.
 *
 * The string is formatted as a list of type modifiers, if any,
 * followed by the kind of type (empty string for primitive types
 * and {@code class}, {@code enum}, {@code interface}, or
 * <code>&#64;</code>{@code interface}, as appropriate), followed
 * by the type's name, followed by an angle-bracketed
 * comma-separated list of the type's type parameters, if any.
 *
 * A space is used to separate modifiers from one another and to
 * separate any modifiers from the kind of type. The modifiers
 * occur in canonical order. If there are no type parameters, the
 * type parameter list is elided.
 *
 * <p>Note that since information about the runtime representation
 * of a type is being generated, modifiers not present on the
 * originating source code or illegal on the originating source
 * code may be present.
 *
 * @return a string describing this {@code Class}, including
 * information about modifiers and type parameters
 *
 * @since 1.8
 */
public String toGenericString() {
    if (isPrimitive()) {
        return toString();
    } else {
        StringBuilder sb = new StringBuilder();

        // Class modifiers are a superset of interface modifiers
        int modifiers = getModifiers() & Modifier.classModifiers();
        if (modifiers != 0) {
            sb.append(Modifier.toString(modifiers));
            sb.append(' ');
        }

        if (isAnnotation()) {
            sb.append('@');
        }
        if (isInterface()) { // Note: all annotation types are interfaces
            sb.append("interface");
        } else {
            if (isEnum())
                sb.append("enum");
            else
                sb.append("class");
        }
        sb.append(' ');
        sb.append(getName());

        TypeVariable<?>[] typeparms = getTypeParameters();
        if (typeparms.length > 0) {
            boolean first = true;
            sb.append('<');
            for(TypeVariable<?> typeparm: typeparms) {
                if (!first)
                    sb.append(',');
                sb.append(typeparm.getTypeName());
                first = false;
            }
            sb.append('>');
        }

        return sb.toString();
    }
}
 
源代码7 项目: TencentKona-8   文件: Class.java
/**
 * Returns a string describing this {@code Class}, including
 * information about modifiers and type parameters.
 *
 * The string is formatted as a list of type modifiers, if any,
 * followed by the kind of type (empty string for primitive types
 * and {@code class}, {@code enum}, {@code interface}, or
 * <code>&#64;</code>{@code interface}, as appropriate), followed
 * by the type's name, followed by an angle-bracketed
 * comma-separated list of the type's type parameters, if any.
 *
 * A space is used to separate modifiers from one another and to
 * separate any modifiers from the kind of type. The modifiers
 * occur in canonical order. If there are no type parameters, the
 * type parameter list is elided.
 *
 * <p>Note that since information about the runtime representation
 * of a type is being generated, modifiers not present on the
 * originating source code or illegal on the originating source
 * code may be present.
 *
 * @return a string describing this {@code Class}, including
 * information about modifiers and type parameters
 *
 * @since 1.8
 */
public String toGenericString() {
    if (isPrimitive()) {
        return toString();
    } else {
        StringBuilder sb = new StringBuilder();

        // Class modifiers are a superset of interface modifiers
        int modifiers = getModifiers() & Modifier.classModifiers();
        if (modifiers != 0) {
            sb.append(Modifier.toString(modifiers));
            sb.append(' ');
        }

        if (isAnnotation()) {
            sb.append('@');
        }
        if (isInterface()) { // Note: all annotation types are interfaces
            sb.append("interface");
        } else {
            if (isEnum())
                sb.append("enum");
            else
                sb.append("class");
        }
        sb.append(' ');
        sb.append(getName());

        TypeVariable<?>[] typeparms = getTypeParameters();
        if (typeparms.length > 0) {
            boolean first = true;
            sb.append('<');
            for(TypeVariable<?> typeparm: typeparms) {
                if (!first)
                    sb.append(',');
                sb.append(typeparm.getTypeName());
                first = false;
            }
            sb.append('>');
        }

        return sb.toString();
    }
}
 
源代码8 项目: jdk8u60   文件: Class.java
/**
 * Returns a string describing this {@code Class}, including
 * information about modifiers and type parameters.
 *
 * The string is formatted as a list of type modifiers, if any,
 * followed by the kind of type (empty string for primitive types
 * and {@code class}, {@code enum}, {@code interface}, or
 * <code>&#64;</code>{@code interface}, as appropriate), followed
 * by the type's name, followed by an angle-bracketed
 * comma-separated list of the type's type parameters, if any.
 *
 * A space is used to separate modifiers from one another and to
 * separate any modifiers from the kind of type. The modifiers
 * occur in canonical order. If there are no type parameters, the
 * type parameter list is elided.
 *
 * <p>Note that since information about the runtime representation
 * of a type is being generated, modifiers not present on the
 * originating source code or illegal on the originating source
 * code may be present.
 *
 * @return a string describing this {@code Class}, including
 * information about modifiers and type parameters
 *
 * @since 1.8
 */
public String toGenericString() {
    if (isPrimitive()) {
        return toString();
    } else {
        StringBuilder sb = new StringBuilder();

        // Class modifiers are a superset of interface modifiers
        int modifiers = getModifiers() & Modifier.classModifiers();
        if (modifiers != 0) {
            sb.append(Modifier.toString(modifiers));
            sb.append(' ');
        }

        if (isAnnotation()) {
            sb.append('@');
        }
        if (isInterface()) { // Note: all annotation types are interfaces
            sb.append("interface");
        } else {
            if (isEnum())
                sb.append("enum");
            else
                sb.append("class");
        }
        sb.append(' ');
        sb.append(getName());

        TypeVariable<?>[] typeparms = getTypeParameters();
        if (typeparms.length > 0) {
            boolean first = true;
            sb.append('<');
            for(TypeVariable<?> typeparm: typeparms) {
                if (!first)
                    sb.append(',');
                sb.append(typeparm.getTypeName());
                first = false;
            }
            sb.append('>');
        }

        return sb.toString();
    }
}
 
源代码9 项目: JDKSourceCode1.8   文件: Class.java
/**
 * Returns a string describing this {@code Class}, including
 * information about modifiers and type parameters.
 *
 * The string is formatted as a list of type modifiers, if any,
 * followed by the kind of type (empty string for primitive types
 * and {@code class}, {@code enum}, {@code interface}, or
 * <code>&#64;</code>{@code interface}, as appropriate), followed
 * by the type's name, followed by an angle-bracketed
 * comma-separated list of the type's type parameters, if any.
 *
 * A space is used to separate modifiers from one another and to
 * separate any modifiers from the kind of type. The modifiers
 * occur in canonical order. If there are no type parameters, the
 * type parameter list is elided.
 *
 * <p>Note that since information about the runtime representation
 * of a type is being generated, modifiers not present on the
 * originating source code or illegal on the originating source
 * code may be present.
 *
 * @return a string describing this {@code Class}, including
 * information about modifiers and type parameters
 *
 * @since 1.8
 */
public String toGenericString() {
    if (isPrimitive()) {
        return toString();
    } else {
        StringBuilder sb = new StringBuilder();

        // Class modifiers are a superset of interface modifiers
        int modifiers = getModifiers() & Modifier.classModifiers();
        if (modifiers != 0) {
            sb.append(Modifier.toString(modifiers));
            sb.append(' ');
        }

        if (isAnnotation()) {
            sb.append('@');
        }
        if (isInterface()) { // Note: all annotation types are interfaces
            sb.append("interface");
        } else {
            if (isEnum())
                sb.append("enum");
            else
                sb.append("class");
        }
        sb.append(' ');
        sb.append(getName());

        TypeVariable<?>[] typeparms = getTypeParameters();
        if (typeparms.length > 0) {
            boolean first = true;
            sb.append('<');
            for(TypeVariable<?> typeparm: typeparms) {
                if (!first)
                    sb.append(',');
                sb.append(typeparm.getTypeName());
                first = false;
            }
            sb.append('>');
        }

        return sb.toString();
    }
}
 
源代码10 项目: openjdk-jdk8u   文件: Class.java
/**
 * Returns a string describing this {@code Class}, including
 * information about modifiers and type parameters.
 *
 * The string is formatted as a list of type modifiers, if any,
 * followed by the kind of type (empty string for primitive types
 * and {@code class}, {@code enum}, {@code interface}, or
 * <code>&#64;</code>{@code interface}, as appropriate), followed
 * by the type's name, followed by an angle-bracketed
 * comma-separated list of the type's type parameters, if any.
 *
 * A space is used to separate modifiers from one another and to
 * separate any modifiers from the kind of type. The modifiers
 * occur in canonical order. If there are no type parameters, the
 * type parameter list is elided.
 *
 * <p>Note that since information about the runtime representation
 * of a type is being generated, modifiers not present on the
 * originating source code or illegal on the originating source
 * code may be present.
 *
 * @return a string describing this {@code Class}, including
 * information about modifiers and type parameters
 *
 * @since 1.8
 */
public String toGenericString() {
    if (isPrimitive()) {
        return toString();
    } else {
        StringBuilder sb = new StringBuilder();

        // Class modifiers are a superset of interface modifiers
        int modifiers = getModifiers() & Modifier.classModifiers();
        if (modifiers != 0) {
            sb.append(Modifier.toString(modifiers));
            sb.append(' ');
        }

        if (isAnnotation()) {
            sb.append('@');
        }
        if (isInterface()) { // Note: all annotation types are interfaces
            sb.append("interface");
        } else {
            if (isEnum())
                sb.append("enum");
            else
                sb.append("class");
        }
        sb.append(' ');
        sb.append(getName());

        TypeVariable<?>[] typeparms = getTypeParameters();
        if (typeparms.length > 0) {
            boolean first = true;
            sb.append('<');
            for(TypeVariable<?> typeparm: typeparms) {
                if (!first)
                    sb.append(',');
                sb.append(typeparm.getTypeName());
                first = false;
            }
            sb.append('>');
        }

        return sb.toString();
    }
}
 
源代码11 项目: openjdk-jdk8u-backup   文件: Class.java
/**
 * Returns a string describing this {@code Class}, including
 * information about modifiers and type parameters.
 *
 * The string is formatted as a list of type modifiers, if any,
 * followed by the kind of type (empty string for primitive types
 * and {@code class}, {@code enum}, {@code interface}, or
 * <code>&#64;</code>{@code interface}, as appropriate), followed
 * by the type's name, followed by an angle-bracketed
 * comma-separated list of the type's type parameters, if any.
 *
 * A space is used to separate modifiers from one another and to
 * separate any modifiers from the kind of type. The modifiers
 * occur in canonical order. If there are no type parameters, the
 * type parameter list is elided.
 *
 * <p>Note that since information about the runtime representation
 * of a type is being generated, modifiers not present on the
 * originating source code or illegal on the originating source
 * code may be present.
 *
 * @return a string describing this {@code Class}, including
 * information about modifiers and type parameters
 *
 * @since 1.8
 */
public String toGenericString() {
    if (isPrimitive()) {
        return toString();
    } else {
        StringBuilder sb = new StringBuilder();

        // Class modifiers are a superset of interface modifiers
        int modifiers = getModifiers() & Modifier.classModifiers();
        if (modifiers != 0) {
            sb.append(Modifier.toString(modifiers));
            sb.append(' ');
        }

        if (isAnnotation()) {
            sb.append('@');
        }
        if (isInterface()) { // Note: all annotation types are interfaces
            sb.append("interface");
        } else {
            if (isEnum())
                sb.append("enum");
            else
                sb.append("class");
        }
        sb.append(' ');
        sb.append(getName());

        TypeVariable<?>[] typeparms = getTypeParameters();
        if (typeparms.length > 0) {
            boolean first = true;
            sb.append('<');
            for(TypeVariable<?> typeparm: typeparms) {
                if (!first)
                    sb.append(',');
                sb.append(typeparm.getTypeName());
                first = false;
            }
            sb.append('>');
        }

        return sb.toString();
    }
}
 
源代码12 项目: Bytecoder   文件: Class.java
/**
 * Returns a string describing this {@code Class}, including
 * information about modifiers and type parameters.
 *
 * The string is formatted as a list of type modifiers, if any,
 * followed by the kind of type (empty string for primitive types
 * and {@code class}, {@code enum}, {@code interface},
 * <code>&#64;</code>{@code interface}, or {@code record} as appropriate), followed
 * by the type's name, followed by an angle-bracketed
 * comma-separated list of the type's type parameters, if any,
 * including informative bounds on the type parameters, if any.
 *
 * A space is used to separate modifiers from one another and to
 * separate any modifiers from the kind of type. The modifiers
 * occur in canonical order. If there are no type parameters, the
 * type parameter list is elided.
 *
 * For an array type, the string starts with the type name,
 * followed by an angle-bracketed comma-separated list of the
 * type's type parameters, if any, followed by a sequence of
 * {@code []} characters, one set of brackets per dimension of
 * the array.
 *
 * <p>Note that since information about the runtime representation
 * of a type is being generated, modifiers not present on the
 * originating source code or illegal on the originating source
 * code may be present.
 *
 * @return a string describing this {@code Class}, including
 * information about modifiers and type parameters
 *
 * @since 1.8
 */
@SuppressWarnings("preview")
public String toGenericString() {
    if (isPrimitive()) {
        return toString();
    } else {
        StringBuilder sb = new StringBuilder();
        Class<?> component = this;
        int arrayDepth = 0;

        if (isArray()) {
            do {
                arrayDepth++;
                component = component.getComponentType();
            } while (component.isArray());
            sb.append(component.getName());
        } else {
            // Class modifiers are a superset of interface modifiers
            int modifiers = getModifiers() & Modifier.classModifiers();
            if (modifiers != 0) {
                sb.append(Modifier.toString(modifiers));
                sb.append(' ');
            }

            if (isAnnotation()) {
                sb.append('@');
            }
            if (isInterface()) { // Note: all annotation types are interfaces
                sb.append("interface");
            } else {
                if (isEnum())
                    sb.append("enum");
                else if (isRecord())
                    sb.append("record");
                else
                    sb.append("class");
            }
            sb.append(' ');
            sb.append(getName());
        }

        TypeVariable<?>[] typeparms = component.getTypeParameters();
        if (typeparms.length > 0) {
            sb.append(Arrays.stream(typeparms)
                      .map(Class::typeVarBounds)
                      .collect(Collectors.joining(",", "<", ">")));
        }

        if (arrayDepth > 0) sb.append("[]".repeat(arrayDepth));

        return sb.toString();
    }
}
 
源代码13 项目: openjdk-jdk9   文件: Class.java
/**
 * Returns a string describing this {@code Class}, including
 * information about modifiers and type parameters.
 *
 * The string is formatted as a list of type modifiers, if any,
 * followed by the kind of type (empty string for primitive types
 * and {@code class}, {@code enum}, {@code interface}, or
 * <code>&#64;</code>{@code interface}, as appropriate), followed
 * by the type's name, followed by an angle-bracketed
 * comma-separated list of the type's type parameters, if any.
 *
 * A space is used to separate modifiers from one another and to
 * separate any modifiers from the kind of type. The modifiers
 * occur in canonical order. If there are no type parameters, the
 * type parameter list is elided.
 *
 * For an array type, the string starts with the type name,
 * followed by an angle-bracketed comma-separated list of the
 * type's type parameters, if any, followed by a sequence of
 * {@code []} characters, one set of brackets per dimension of
 * the array.
 *
 * <p>Note that since information about the runtime representation
 * of a type is being generated, modifiers not present on the
 * originating source code or illegal on the originating source
 * code may be present.
 *
 * @return a string describing this {@code Class}, including
 * information about modifiers and type parameters
 *
 * @since 1.8
 */
public String toGenericString() {
    if (isPrimitive()) {
        return toString();
    } else {
        StringBuilder sb = new StringBuilder();
        Class<?> component = this;
        int arrayDepth = 0;

        if (isArray()) {
            do {
                arrayDepth++;
                component = component.getComponentType();
            } while (component.isArray());
            sb.append(component.getName());
        } else {
            // Class modifiers are a superset of interface modifiers
            int modifiers = getModifiers() & Modifier.classModifiers();
            if (modifiers != 0) {
                sb.append(Modifier.toString(modifiers));
                sb.append(' ');
            }

            if (isAnnotation()) {
                sb.append('@');
            }
            if (isInterface()) { // Note: all annotation types are interfaces
                sb.append("interface");
            } else {
                if (isEnum())
                    sb.append("enum");
                else
                    sb.append("class");
            }
            sb.append(' ');
            sb.append(getName());
        }

        TypeVariable<?>[] typeparms = component.getTypeParameters();
        if (typeparms.length > 0) {
            StringJoiner sj = new StringJoiner(",", "<", ">");
            for(TypeVariable<?> typeparm: typeparms) {
                sj.add(typeparm.getTypeName());
            }
            sb.append(sj.toString());
        }

        for (int i = 0; i < arrayDepth; i++)
            sb.append("[]");

        return sb.toString();
    }
}
 
源代码14 项目: jdk8u-jdk   文件: Class.java
/**
 * Returns a string describing this {@code Class}, including
 * information about modifiers and type parameters.
 *
 * The string is formatted as a list of type modifiers, if any,
 * followed by the kind of type (empty string for primitive types
 * and {@code class}, {@code enum}, {@code interface}, or
 * <code>&#64;</code>{@code interface}, as appropriate), followed
 * by the type's name, followed by an angle-bracketed
 * comma-separated list of the type's type parameters, if any.
 *
 * A space is used to separate modifiers from one another and to
 * separate any modifiers from the kind of type. The modifiers
 * occur in canonical order. If there are no type parameters, the
 * type parameter list is elided.
 *
 * <p>Note that since information about the runtime representation
 * of a type is being generated, modifiers not present on the
 * originating source code or illegal on the originating source
 * code may be present.
 *
 * @return a string describing this {@code Class}, including
 * information about modifiers and type parameters
 *
 * @since 1.8
 */
public String toGenericString() {
    if (isPrimitive()) {
        return toString();
    } else {
        StringBuilder sb = new StringBuilder();

        // Class modifiers are a superset of interface modifiers
        int modifiers = getModifiers() & Modifier.classModifiers();
        if (modifiers != 0) {
            sb.append(Modifier.toString(modifiers));
            sb.append(' ');
        }

        if (isAnnotation()) {
            sb.append('@');
        }
        if (isInterface()) { // Note: all annotation types are interfaces
            sb.append("interface");
        } else {
            if (isEnum())
                sb.append("enum");
            else
                sb.append("class");
        }
        sb.append(' ');
        sb.append(getName());

        TypeVariable<?>[] typeparms = getTypeParameters();
        if (typeparms.length > 0) {
            boolean first = true;
            sb.append('<');
            for(TypeVariable<?> typeparm: typeparms) {
                if (!first)
                    sb.append(',');
                sb.append(typeparm.getTypeName());
                first = false;
            }
            sb.append('>');
        }

        return sb.toString();
    }
}
 
源代码15 项目: Java8CN   文件: Class.java
/**
 * Returns a string describing this {@code Class}, including
 * information about modifiers and type parameters.
 *
 * The string is formatted as a list of type modifiers, if any,
 * followed by the kind of type (empty string for primitive types
 * and {@code class}, {@code enum}, {@code interface}, or
 * <code>&#64;</code>{@code interface}, as appropriate), followed
 * by the type's name, followed by an angle-bracketed
 * comma-separated list of the type's type parameters, if any.
 *
 * A space is used to separate modifiers from one another and to
 * separate any modifiers from the kind of type. The modifiers
 * occur in canonical order. If there are no type parameters, the
 * type parameter list is elided.
 *
 * <p>Note that since information about the runtime representation
 * of a type is being generated, modifiers not present on the
 * originating source code or illegal on the originating source
 * code may be present.
 *
 * @return a string describing this {@code Class}, including
 * information about modifiers and type parameters
 *
 * @since 1.8
 */
public String toGenericString() {
    if (isPrimitive()) {
        return toString();
    } else {
        StringBuilder sb = new StringBuilder();

        // Class modifiers are a superset of interface modifiers
        int modifiers = getModifiers() & Modifier.classModifiers();
        if (modifiers != 0) {
            sb.append(Modifier.toString(modifiers));
            sb.append(' ');
        }

        if (isAnnotation()) {
            sb.append('@');
        }
        if (isInterface()) { // Note: all annotation types are interfaces
            sb.append("interface");
        } else {
            if (isEnum())
                sb.append("enum");
            else
                sb.append("class");
        }
        sb.append(' ');
        sb.append(getName());

        TypeVariable<?>[] typeparms = getTypeParameters();
        if (typeparms.length > 0) {
            boolean first = true;
            sb.append('<');
            for(TypeVariable<?> typeparm: typeparms) {
                if (!first)
                    sb.append(',');
                sb.append(typeparm.getTypeName());
                first = false;
            }
            sb.append('>');
        }

        return sb.toString();
    }
}
 
源代码16 项目: hottub   文件: Class.java
/**
 * Returns a string describing this {@code Class}, including
 * information about modifiers and type parameters.
 *
 * The string is formatted as a list of type modifiers, if any,
 * followed by the kind of type (empty string for primitive types
 * and {@code class}, {@code enum}, {@code interface}, or
 * <code>&#64;</code>{@code interface}, as appropriate), followed
 * by the type's name, followed by an angle-bracketed
 * comma-separated list of the type's type parameters, if any.
 *
 * A space is used to separate modifiers from one another and to
 * separate any modifiers from the kind of type. The modifiers
 * occur in canonical order. If there are no type parameters, the
 * type parameter list is elided.
 *
 * <p>Note that since information about the runtime representation
 * of a type is being generated, modifiers not present on the
 * originating source code or illegal on the originating source
 * code may be present.
 *
 * @return a string describing this {@code Class}, including
 * information about modifiers and type parameters
 *
 * @since 1.8
 */
public String toGenericString() {
    if (isPrimitive()) {
        return toString();
    } else {
        StringBuilder sb = new StringBuilder();

        // Class modifiers are a superset of interface modifiers
        int modifiers = getModifiers() & Modifier.classModifiers();
        if (modifiers != 0) {
            sb.append(Modifier.toString(modifiers));
            sb.append(' ');
        }

        if (isAnnotation()) {
            sb.append('@');
        }
        if (isInterface()) { // Note: all annotation types are interfaces
            sb.append("interface");
        } else {
            if (isEnum())
                sb.append("enum");
            else
                sb.append("class");
        }
        sb.append(' ');
        sb.append(getName());

        TypeVariable<?>[] typeparms = getTypeParameters();
        if (typeparms.length > 0) {
            boolean first = true;
            sb.append('<');
            for(TypeVariable<?> typeparm: typeparms) {
                if (!first)
                    sb.append(',');
                sb.append(typeparm.getTypeName());
                first = false;
            }
            sb.append('>');
        }

        return sb.toString();
    }
}
 
源代码17 项目: openjdk-8-source   文件: Class.java
/**
 * Returns a string describing this {@code Class}, including
 * information about modifiers and type parameters.
 *
 * The string is formatted as a list of type modifiers, if any,
 * followed by the kind of type (empty string for primitive types
 * and {@code class}, {@code enum}, {@code interface}, or
 * <code>&#64;</code>{@code interface}, as appropriate), followed
 * by the type's name, followed by an angle-bracketed
 * comma-separated list of the type's type parameters, if any.
 *
 * A space is used to separate modifiers from one another and to
 * separate any modifiers from the kind of type. The modifiers
 * occur in canonical order. If there are no type parameters, the
 * type parameter list is elided.
 *
 * <p>Note that since information about the runtime representation
 * of a type is being generated, modifiers not present on the
 * originating source code or illegal on the originating source
 * code may be present.
 *
 * @return a string describing this {@code Class}, including
 * information about modifiers and type parameters
 *
 * @since 1.8
 */
public String toGenericString() {
    if (isPrimitive()) {
        return toString();
    } else {
        StringBuilder sb = new StringBuilder();

        // Class modifiers are a superset of interface modifiers
        int modifiers = getModifiers() & Modifier.classModifiers();
        if (modifiers != 0) {
            sb.append(Modifier.toString(modifiers));
            sb.append(' ');
        }

        if (isAnnotation()) {
            sb.append('@');
        }
        if (isInterface()) { // Note: all annotation types are interfaces
            sb.append("interface");
        } else {
            if (isEnum())
                sb.append("enum");
            else
                sb.append("class");
        }
        sb.append(' ');
        sb.append(getName());

        TypeVariable<?>[] typeparms = getTypeParameters();
        if (typeparms.length > 0) {
            boolean first = true;
            sb.append('<');
            for(TypeVariable<?> typeparm: typeparms) {
                if (!first)
                    sb.append(',');
                sb.append(typeparm.getTypeName());
                first = false;
            }
            sb.append('>');
        }

        return sb.toString();
    }
}
 
源代码18 项目: openjdk-8   文件: Class.java
/**
 * Returns a string describing this {@code Class}, including
 * information about modifiers and type parameters.
 *
 * The string is formatted as a list of type modifiers, if any,
 * followed by the kind of type (empty string for primitive types
 * and {@code class}, {@code enum}, {@code interface}, or
 * <code>&#64;</code>{@code interface}, as appropriate), followed
 * by the type's name, followed by an angle-bracketed
 * comma-separated list of the type's type parameters, if any.
 *
 * A space is used to separate modifiers from one another and to
 * separate any modifiers from the kind of type. The modifiers
 * occur in canonical order. If there are no type parameters, the
 * type parameter list is elided.
 *
 * <p>Note that since information about the runtime representation
 * of a type is being generated, modifiers not present on the
 * originating source code or illegal on the originating source
 * code may be present.
 *
 * @return a string describing this {@code Class}, including
 * information about modifiers and type parameters
 *
 * @since 1.8
 */
public String toGenericString() {
    if (isPrimitive()) {
        return toString();
    } else {
        StringBuilder sb = new StringBuilder();

        // Class modifiers are a superset of interface modifiers
        int modifiers = getModifiers() & Modifier.classModifiers();
        if (modifiers != 0) {
            sb.append(Modifier.toString(modifiers));
            sb.append(' ');
        }

        if (isAnnotation()) {
            sb.append('@');
        }
        if (isInterface()) { // Note: all annotation types are interfaces
            sb.append("interface");
        } else {
            if (isEnum())
                sb.append("enum");
            else
                sb.append("class");
        }
        sb.append(' ');
        sb.append(getName());

        TypeVariable<?>[] typeparms = getTypeParameters();
        if (typeparms.length > 0) {
            boolean first = true;
            sb.append('<');
            for(TypeVariable<?> typeparm: typeparms) {
                if (!first)
                    sb.append(',');
                sb.append(typeparm.getTypeName());
                first = false;
            }
            sb.append('>');
        }

        return sb.toString();
    }
}
 
源代码19 项目: jdk8u_jdk   文件: Class.java
/**
 * Returns a string describing this {@code Class}, including
 * information about modifiers and type parameters.
 *
 * The string is formatted as a list of type modifiers, if any,
 * followed by the kind of type (empty string for primitive types
 * and {@code class}, {@code enum}, {@code interface}, or
 * <code>&#64;</code>{@code interface}, as appropriate), followed
 * by the type's name, followed by an angle-bracketed
 * comma-separated list of the type's type parameters, if any.
 *
 * A space is used to separate modifiers from one another and to
 * separate any modifiers from the kind of type. The modifiers
 * occur in canonical order. If there are no type parameters, the
 * type parameter list is elided.
 *
 * <p>Note that since information about the runtime representation
 * of a type is being generated, modifiers not present on the
 * originating source code or illegal on the originating source
 * code may be present.
 *
 * @return a string describing this {@code Class}, including
 * information about modifiers and type parameters
 *
 * @since 1.8
 */
public String toGenericString() {
    if (isPrimitive()) {
        return toString();
    } else {
        StringBuilder sb = new StringBuilder();

        // Class modifiers are a superset of interface modifiers
        int modifiers = getModifiers() & Modifier.classModifiers();
        if (modifiers != 0) {
            sb.append(Modifier.toString(modifiers));
            sb.append(' ');
        }

        if (isAnnotation()) {
            sb.append('@');
        }
        if (isInterface()) { // Note: all annotation types are interfaces
            sb.append("interface");
        } else {
            if (isEnum())
                sb.append("enum");
            else
                sb.append("class");
        }
        sb.append(' ');
        sb.append(getName());

        TypeVariable<?>[] typeparms = getTypeParameters();
        if (typeparms.length > 0) {
            boolean first = true;
            sb.append('<');
            for(TypeVariable<?> typeparm: typeparms) {
                if (!first)
                    sb.append(',');
                sb.append(typeparm.getTypeName());
                first = false;
            }
            sb.append('>');
        }

        return sb.toString();
    }
}
 
源代码20 项目: jdk8u-jdk   文件: Class.java
/**
 * Returns a string describing this {@code Class}, including
 * information about modifiers and type parameters.
 *
 * The string is formatted as a list of type modifiers, if any,
 * followed by the kind of type (empty string for primitive types
 * and {@code class}, {@code enum}, {@code interface}, or
 * <code>&#64;</code>{@code interface}, as appropriate), followed
 * by the type's name, followed by an angle-bracketed
 * comma-separated list of the type's type parameters, if any.
 *
 * A space is used to separate modifiers from one another and to
 * separate any modifiers from the kind of type. The modifiers
 * occur in canonical order. If there are no type parameters, the
 * type parameter list is elided.
 *
 * <p>Note that since information about the runtime representation
 * of a type is being generated, modifiers not present on the
 * originating source code or illegal on the originating source
 * code may be present.
 *
 * @return a string describing this {@code Class}, including
 * information about modifiers and type parameters
 *
 * @since 1.8
 */
public String toGenericString() {
    if (isPrimitive()) {
        return toString();
    } else {
        StringBuilder sb = new StringBuilder();

        // Class modifiers are a superset of interface modifiers
        int modifiers = getModifiers() & Modifier.classModifiers();
        if (modifiers != 0) {
            sb.append(Modifier.toString(modifiers));
            sb.append(' ');
        }

        if (isAnnotation()) {
            sb.append('@');
        }
        if (isInterface()) { // Note: all annotation types are interfaces
            sb.append("interface");
        } else {
            if (isEnum())
                sb.append("enum");
            else
                sb.append("class");
        }
        sb.append(' ');
        sb.append(getName());

        TypeVariable<?>[] typeparms = getTypeParameters();
        if (typeparms.length > 0) {
            boolean first = true;
            sb.append('<');
            for(TypeVariable<?> typeparm: typeparms) {
                if (!first)
                    sb.append(',');
                sb.append(typeparm.getTypeName());
                first = false;
            }
            sb.append('>');
        }

        return sb.toString();
    }
}