com.sun.tools.classfile.Type Java Examples

The following examples show how to use com.sun.tools.classfile.Type. 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 Project: TencentKona-8   Author: Tencent   File: ClassWriter.java    License: GNU General Public License v2.0 6 votes vote down vote up
public StringBuilder visitTypeParamType(TypeParamType type, StringBuilder sb) {
    sb.append(type.name);
    String sep = " extends ";
    if (type.classBound != null
            && (options.verbose || !type.classBound.isObject())) {
        sb.append(sep);
        append(sb, type.classBound);
        sep = " & ";
    }
    if (type.interfaceBounds != null) {
        for (Type bound: type.interfaceBounds) {
            sb.append(sep);
            append(sb, bound);
            sep = " & ";
        }
    }
    return sb;
}
 
Example #2
Source Project: jdk8u60   Author: chenghanpeng   File: ClassWriter.java    License: GNU General Public License v2.0 6 votes vote down vote up
public StringBuilder visitTypeParamType(TypeParamType type, StringBuilder sb) {
    sb.append(type.name);
    String sep = " extends ";
    if (type.classBound != null
            && (options.verbose || !type.classBound.isObject())) {
        sb.append(sep);
        append(sb, type.classBound);
        sep = " & ";
    }
    if (type.interfaceBounds != null) {
        for (Type bound: type.interfaceBounds) {
            sb.append(sep);
            append(sb, bound);
            sep = " & ";
        }
    }
    return sb;
}
 
Example #3
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: ClassWriter.java    License: GNU General Public License v2.0 6 votes vote down vote up
public StringBuilder visitTypeParamType(TypeParamType type, StringBuilder sb) {
    sb.append(type.name);
    String sep = " extends ";
    if (type.classBound != null
            && (options.verbose || !type.classBound.isObject())) {
        sb.append(sep);
        append(sb, type.classBound);
        sep = " & ";
    }
    if (type.interfaceBounds != null) {
        for (Type bound: type.interfaceBounds) {
            sb.append(sep);
            append(sb, bound);
            sep = " & ";
        }
    }
    return sb;
}
 
Example #4
Source Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: ClassWriter.java    License: GNU General Public License v2.0 6 votes vote down vote up
public StringBuilder visitTypeParamType(TypeParamType type, StringBuilder sb) {
    sb.append(type.name);
    String sep = " extends ";
    if (type.classBound != null
            && (options.verbose || !type.classBound.isObject())) {
        sb.append(sep);
        append(sb, type.classBound);
        sep = " & ";
    }
    if (type.interfaceBounds != null) {
        for (Type bound: type.interfaceBounds) {
            sb.append(sep);
            append(sb, bound);
            sep = " & ";
        }
    }
    return sb;
}
 
Example #5
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: ClassWriter.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public StringBuilder visitTypeParamType(TypeParamType type, StringBuilder sb) {
    sb.append(type.name);
    String sep = " extends ";
    if (type.classBound != null
            && (options.verbose || !type.classBound.isObject())) {
        sb.append(sep);
        append(sb, type.classBound);
        sep = " & ";
    }
    if (type.interfaceBounds != null) {
        for (Type bound: type.interfaceBounds) {
            sb.append(sep);
            append(sb, bound);
            sep = " & ";
        }
    }
    return sb;
}
 
Example #6
Source Project: hottub   Author: dsrg-uoft   File: ClassWriter.java    License: GNU General Public License v2.0 6 votes vote down vote up
public StringBuilder visitTypeParamType(TypeParamType type, StringBuilder sb) {
    sb.append(type.name);
    String sep = " extends ";
    if (type.classBound != null
            && (options.verbose || !type.classBound.isObject())) {
        sb.append(sep);
        append(sb, type.classBound);
        sep = " & ";
    }
    if (type.interfaceBounds != null) {
        for (Type bound: type.interfaceBounds) {
            sb.append(sep);
            append(sb, bound);
            sep = " & ";
        }
    }
    return sb;
}
 
Example #7
Source Project: openjdk-8-source   Author: keerath   File: ClassWriter.java    License: GNU General Public License v2.0 6 votes vote down vote up
public StringBuilder visitTypeParamType(TypeParamType type, StringBuilder sb) {
    sb.append(type.name);
    String sep = " extends ";
    if (type.classBound != null
            && (options.verbose || !type.classBound.isObject())) {
        sb.append(sep);
        append(sb, type.classBound);
        sep = " & ";
    }
    if (type.interfaceBounds != null) {
        for (Type bound: type.interfaceBounds) {
            sb.append(sep);
            append(sb, bound);
            sep = " & ";
        }
    }
    return sb;
}
 
Example #8
Source Project: openjdk-8   Author: bpupadhyaya   File: ClassWriter.java    License: GNU General Public License v2.0 6 votes vote down vote up
public StringBuilder visitTypeParamType(TypeParamType type, StringBuilder sb) {
    sb.append(type.name);
    String sep = " extends ";
    if (type.classBound != null
            && (options.verbose || !type.classBound.isObject())) {
        sb.append(sep);
        append(sb, type.classBound);
        sep = " & ";
    }
    if (type.interfaceBounds != null) {
        for (Type bound: type.interfaceBounds) {
            sb.append(sep);
            append(sb, bound);
            sep = " & ";
        }
    }
    return sb;
}
 
Example #9
Source Project: TencentKona-8   Author: Tencent   File: ClassWriter.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void append(StringBuilder sb, String prefix, List<? extends Type> list, String suffix) {
    sb.append(prefix);
    String sep = "";
    for (Type t: list) {
        sb.append(sep);
        append(sb, t);
        sep = ", ";
    }
    sb.append(suffix);
}
 
Example #10
Source Project: jdk8u60   Author: chenghanpeng   File: ClassWriter.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void append(StringBuilder sb, String prefix, List<? extends Type> list, String suffix) {
    sb.append(prefix);
    String sep = "";
    for (Type t: list) {
        sb.append(sep);
        append(sb, t);
        sep = ", ";
    }
    sb.append(suffix);
}
 
Example #11
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: ClassWriter.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void append(StringBuilder sb, String prefix, List<? extends Type> list, String suffix) {
    sb.append(prefix);
    String sep = "";
    for (Type t: list) {
        sb.append(sep);
        append(sb, t);
        sep = ", ";
    }
    sb.append(suffix);
}
 
Example #12
Source Project: openjdk-jdk8u-backup   Author: AdoptOpenJDK   File: ClassWriter.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void append(StringBuilder sb, String prefix, List<? extends Type> list, String suffix) {
    sb.append(prefix);
    String sep = "";
    for (Type t: list) {
        sb.append(sep);
        append(sb, t);
        sep = ", ";
    }
    sb.append(suffix);
}
 
Example #13
Source Project: openjdk-jdk9   Author: AdoptOpenJDK   File: ClassWriter.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void append(StringBuilder sb, String prefix, List<? extends Type> list, String suffix) {
    sb.append(prefix);
    String sep = "";
    for (Type t: list) {
        sb.append(sep);
        append(sb, t);
        sep = ", ";
    }
    sb.append(suffix);
}
 
Example #14
Source Project: hottub   Author: dsrg-uoft   File: ClassWriter.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void append(StringBuilder sb, String prefix, List<? extends Type> list, String suffix) {
    sb.append(prefix);
    String sep = "";
    for (Type t: list) {
        sb.append(sep);
        append(sb, t);
        sep = ", ";
    }
    sb.append(suffix);
}
 
Example #15
Source Project: openjdk-8-source   Author: keerath   File: ClassWriter.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void append(StringBuilder sb, String prefix, List<? extends Type> list, String suffix) {
    sb.append(prefix);
    String sep = "";
    for (Type t: list) {
        sb.append(sep);
        append(sb, t);
        sep = ", ";
    }
    sb.append(suffix);
}
 
Example #16
Source Project: openjdk-8   Author: bpupadhyaya   File: ClassWriter.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void append(StringBuilder sb, String prefix, List<? extends Type> list, String suffix) {
    sb.append(prefix);
    String sep = "";
    for (Type t: list) {
        sb.append(sep);
        append(sb, t);
        sep = ", ";
    }
    sb.append(suffix);
}
 
Example #17
Source Project: TencentKona-8   Author: Tencent   File: ClassWriter.java    License: GNU General Public License v2.0 4 votes vote down vote up
String print(Type t) {
    return t.accept(this, new StringBuilder()).toString();
}
 
Example #18
Source Project: TencentKona-8   Author: Tencent   File: ClassWriter.java    License: GNU General Public License v2.0 4 votes vote down vote up
private void append(StringBuilder sb, Type t) {
    t.accept(this, sb);
}
 
Example #19
Source Project: TencentKona-8   Author: Tencent   File: ClassWriter.java    License: GNU General Public License v2.0 4 votes vote down vote up
private void appendIfNotEmpty(StringBuilder sb, String prefix, List<? extends Type> list, String suffix) {
    if (!isEmpty(list))
        append(sb, prefix, list, suffix);
}
 
Example #20
Source Project: TencentKona-8   Author: Tencent   File: ClassWriter.java    License: GNU General Public License v2.0 4 votes vote down vote up
private boolean isEmpty(List<? extends Type> list) {
    return (list == null || list.isEmpty());
}
 
Example #21
Source Project: TencentKona-8   Author: Tencent   File: ClassWriter.java    License: GNU General Public License v2.0 4 votes vote down vote up
protected void writeField(Field f) {
    if (!options.checkAccess(f.access_flags))
        return;

    AccessFlags flags = f.access_flags;
    writeModifiers(flags.getFieldModifiers());
    Signature_attribute sigAttr = getSignature(f.attributes);
    if (sigAttr == null)
        print(getJavaFieldType(f.descriptor));
    else {
        try {
            Type t = sigAttr.getParsedSignature().getType(constant_pool);
            print(getJavaName(t.toString()));
        } catch (ConstantPoolException e) {
            // report error?
            // fall back on non-generic descriptor
            print(getJavaFieldType(f.descriptor));
        }
    }
    print(" ");
    print(getFieldName(f));
    if (options.showConstants) {
        Attribute a = f.attributes.get(Attribute.ConstantValue);
        if (a instanceof ConstantValue_attribute) {
            print(" = ");
            ConstantValue_attribute cv = (ConstantValue_attribute) a;
            print(getConstantValue(f.descriptor, cv.constantvalue_index));
        }
    }
    print(";");
    println();

    indent(+1);

    boolean showBlank = false;

    if (options.showDescriptors)
        println("descriptor: " + getValue(f.descriptor));

    if (options.verbose)
        writeList("flags: ", flags.getFieldFlags(), "\n");

    if (options.showAllAttrs) {
        for (Attribute attr: f.attributes)
            attrWriter.write(f, attr, constant_pool);
        showBlank = true;
    }

    indent(-1);

    if (showBlank || options.showDisassembled || options.showLineAndLocalVariableTables)
        println();
}
 
Example #22
Source Project: jdk8u60   Author: chenghanpeng   File: ClassWriter.java    License: GNU General Public License v2.0 4 votes vote down vote up
String print(Type t) {
    return t.accept(this, new StringBuilder()).toString();
}
 
Example #23
Source Project: jdk8u60   Author: chenghanpeng   File: ClassWriter.java    License: GNU General Public License v2.0 4 votes vote down vote up
private void append(StringBuilder sb, Type t) {
    t.accept(this, sb);
}
 
Example #24
Source Project: jdk8u60   Author: chenghanpeng   File: ClassWriter.java    License: GNU General Public License v2.0 4 votes vote down vote up
private void appendIfNotEmpty(StringBuilder sb, String prefix, List<? extends Type> list, String suffix) {
    if (!isEmpty(list))
        append(sb, prefix, list, suffix);
}
 
Example #25
Source Project: jdk8u60   Author: chenghanpeng   File: ClassWriter.java    License: GNU General Public License v2.0 4 votes vote down vote up
private boolean isEmpty(List<? extends Type> list) {
    return (list == null || list.isEmpty());
}
 
Example #26
Source Project: jdk8u60   Author: chenghanpeng   File: ClassWriter.java    License: GNU General Public License v2.0 4 votes vote down vote up
protected void writeField(Field f) {
    if (!options.checkAccess(f.access_flags))
        return;

    AccessFlags flags = f.access_flags;
    writeModifiers(flags.getFieldModifiers());
    Signature_attribute sigAttr = getSignature(f.attributes);
    if (sigAttr == null)
        print(getJavaFieldType(f.descriptor));
    else {
        try {
            Type t = sigAttr.getParsedSignature().getType(constant_pool);
            print(getJavaName(t.toString()));
        } catch (ConstantPoolException e) {
            // report error?
            // fall back on non-generic descriptor
            print(getJavaFieldType(f.descriptor));
        }
    }
    print(" ");
    print(getFieldName(f));
    if (options.showConstants) {
        Attribute a = f.attributes.get(Attribute.ConstantValue);
        if (a instanceof ConstantValue_attribute) {
            print(" = ");
            ConstantValue_attribute cv = (ConstantValue_attribute) a;
            print(getConstantValue(f.descriptor, cv.constantvalue_index));
        }
    }
    print(";");
    println();

    indent(+1);

    boolean showBlank = false;

    if (options.showDescriptors)
        println("descriptor: " + getValue(f.descriptor));

    if (options.verbose)
        writeList("flags: ", flags.getFieldFlags(), "\n");

    if (options.showAllAttrs) {
        for (Attribute attr: f.attributes)
            attrWriter.write(f, attr, constant_pool);
        showBlank = true;
    }

    indent(-1);

    if (showBlank || options.showDisassembled || options.showLineAndLocalVariableTables)
        println();
}
 
Example #27
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: ClassWriter.java    License: GNU General Public License v2.0 4 votes vote down vote up
String print(Type t) {
    return t.accept(this, new StringBuilder()).toString();
}
 
Example #28
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: ClassWriter.java    License: GNU General Public License v2.0 4 votes vote down vote up
private void append(StringBuilder sb, Type t) {
    t.accept(this, sb);
}
 
Example #29
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: ClassWriter.java    License: GNU General Public License v2.0 4 votes vote down vote up
private void appendIfNotEmpty(StringBuilder sb, String prefix, List<? extends Type> list, String suffix) {
    if (!isEmpty(list))
        append(sb, prefix, list, suffix);
}
 
Example #30
Source Project: openjdk-jdk8u   Author: AdoptOpenJDK   File: ClassWriter.java    License: GNU General Public License v2.0 4 votes vote down vote up
private boolean isEmpty(List<? extends Type> list) {
    return (list == null || list.isEmpty());
}