Java Code Examples for java.lang.reflect.Modifier#classModifiers()
The following examples show how to use
java.lang.reflect.Modifier#classModifiers() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestResolvedJavaType.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@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); } }
Example 2
Source File: Code.java From es6draft with MIT License | 5 votes |
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); }
Example 3
Source File: Class.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
/** * 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>@</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(); } }
Example 4
Source File: Class.java From jdk1.8-source-analysis with Apache License 2.0 | 4 votes |
/** * 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>@</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(); } }
Example 5
Source File: Class.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
/** * 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>@</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(); } }
Example 6
Source File: Class.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
/** * 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>@</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(); } }
Example 7
Source File: Class.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
/** * 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>@</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(); } }
Example 8
Source File: Class.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
/** * 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>@</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(); } }
Example 9
Source File: Class.java From hottub with GNU General Public License v2.0 | 4 votes |
/** * 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>@</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(); } }
Example 10
Source File: Class.java From Java8CN with Apache License 2.0 | 4 votes |
/** * 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>@</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(); } }
Example 11
Source File: Class.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
/** * 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>@</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(); } }
Example 12
Source File: Class.java From AndroidComponentPlugin with Apache License 2.0 | 4 votes |
/** * 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>@</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(); } }
Example 13
Source File: Class.java From AndroidComponentPlugin with Apache License 2.0 | 4 votes |
/** * 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>@</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(); } }
Example 14
Source File: Class.java From Bytecoder with Apache License 2.0 | 4 votes |
/** * 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>@</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(); } }
Example 15
Source File: Class.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
/** * 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>@</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(); } }
Example 16
Source File: Class.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
/** * 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>@</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(); } }
Example 17
Source File: Class.java From JDKSourceCode1.8 with MIT License | 4 votes |
/** * 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>@</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(); } }
Example 18
Source File: Class.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
/** * 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>@</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(); } }
Example 19
Source File: Class.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
/** * 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>@</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(); } }
Example 20
Source File: Class.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
/** * 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>@</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(); } }