Java Code Examples for com.sun.javadoc.Type#asClassDoc()

The following examples show how to use com.sun.javadoc.Type#asClassDoc() . 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: StubSkeletonWriter.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns a snippet of Java code to wrap a value named "name" of
 * type "type" into an object as appropriate for use by the Java
 * Reflection API.
 *
 * For primitive types, an appropriate wrapper class is
 * instantiated with the primitive value.  For object types
 * (including arrays), no wrapping is necessary, so the value is
 * named directly.
 **/
private static String wrapArgumentCode(Type type, String name) {
    if (type.dimension().length() > 0 || type.asClassDoc() != null) {
        return name;
    } else if (type.typeName().equals("boolean")) {
        return ("(" + name +
                " ? java.lang.Boolean.TRUE : java.lang.Boolean.FALSE)");
    } else if (type.typeName().equals("byte")) {
        return "new java.lang.Byte(" + name + ")";
    } else if (type.typeName().equals("char")) {
        return "new java.lang.Character(" + name + ")";
    } else if (type.typeName().equals("short")) {
        return "new java.lang.Short(" + name + ")";
    } else if (type.typeName().equals("int")) {
        return "new java.lang.Integer(" + name + ")";
    } else if (type.typeName().equals("long")) {
        return "new java.lang.Long(" + name + ")";
    } else if (type.typeName().equals("float")) {
        return "new java.lang.Float(" + name + ")";
    } else if (type.typeName().equals("double")) {
        return "new java.lang.Double(" + name + ")";
    } else {
        throw new AssertionError(type);
    }
}
 
Example 2
Source File: StubSkeletonWriter.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns a snippet of Java code to wrap a value named "name" of
 * type "type" into an object as appropriate for use by the Java
 * Reflection API.
 *
 * For primitive types, an appropriate wrapper class is
 * instantiated with the primitive value.  For object types
 * (including arrays), no wrapping is necessary, so the value is
 * named directly.
 **/
private static String wrapArgumentCode(Type type, String name) {
    if (type.dimension().length() > 0 || type.asClassDoc() != null) {
        return name;
    } else if (type.typeName().equals("boolean")) {
        return ("(" + name +
                " ? java.lang.Boolean.TRUE : java.lang.Boolean.FALSE)");
    } else if (type.typeName().equals("byte")) {
        return "new java.lang.Byte(" + name + ")";
    } else if (type.typeName().equals("char")) {
        return "new java.lang.Character(" + name + ")";
    } else if (type.typeName().equals("short")) {
        return "new java.lang.Short(" + name + ")";
    } else if (type.typeName().equals("int")) {
        return "new java.lang.Integer(" + name + ")";
    } else if (type.typeName().equals("long")) {
        return "new java.lang.Long(" + name + ")";
    } else if (type.typeName().equals("float")) {
        return "new java.lang.Float(" + name + ")";
    } else if (type.typeName().equals("double")) {
        return "new java.lang.Double(" + name + ")";
    } else {
        throw new AssertionError(type);
    }
}
 
Example 3
Source File: StubSkeletonWriter.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns a snippet of Java code to wrap a value named "name" of
 * type "type" into an object as appropriate for use by the Java
 * Reflection API.
 *
 * For primitive types, an appropriate wrapper class is
 * instantiated with the primitive value.  For object types
 * (including arrays), no wrapping is necessary, so the value is
 * named directly.
 **/
private static String wrapArgumentCode(Type type, String name) {
    if (type.dimension().length() > 0 || type.asClassDoc() != null) {
        return name;
    } else if (type.typeName().equals("boolean")) {
        return ("(" + name +
                " ? java.lang.Boolean.TRUE : java.lang.Boolean.FALSE)");
    } else if (type.typeName().equals("byte")) {
        return "new java.lang.Byte(" + name + ")";
    } else if (type.typeName().equals("char")) {
        return "new java.lang.Character(" + name + ")";
    } else if (type.typeName().equals("short")) {
        return "new java.lang.Short(" + name + ")";
    } else if (type.typeName().equals("int")) {
        return "new java.lang.Integer(" + name + ")";
    } else if (type.typeName().equals("long")) {
        return "new java.lang.Long(" + name + ")";
    } else if (type.typeName().equals("float")) {
        return "new java.lang.Float(" + name + ")";
    } else if (type.typeName().equals("double")) {
        return "new java.lang.Double(" + name + ")";
    } else {
        throw new AssertionError(type);
    }
}
 
Example 4
Source File: StubSkeletonWriter.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns a snippet of Java code to unwrap a value named "name"
 * into a value of type "type", as appropriate for the Java
 * Reflection API.
 *
 * For primitive types, the value is assumed to be of the
 * corresponding wrapper class, and a method is called on the
 * wrapper to retrieve the primitive value.  For object types
 * (include arrays), no unwrapping is necessary; the value is
 * simply cast to the expected real object type.
 **/
private static String unwrapArgumentCode(Type type, String name) {
    if (type.dimension().length() > 0 || type.asClassDoc() != null) {
        return "((" + type.toString() + ") " + name + ")";
    } else if (type.typeName().equals("boolean")) {
        return "((java.lang.Boolean) " + name + ").booleanValue()";
    } else if (type.typeName().equals("byte")) {
        return "((java.lang.Byte) " + name + ").byteValue()";
    } else if (type.typeName().equals("char")) {
        return "((java.lang.Character) " + name + ").charValue()";
    } else if (type.typeName().equals("short")) {
        return "((java.lang.Short) " + name + ").shortValue()";
    } else if (type.typeName().equals("int")) {
        return "((java.lang.Integer) " + name + ").intValue()";
    } else if (type.typeName().equals("long")) {
        return "((java.lang.Long) " + name + ").longValue()";
    } else if (type.typeName().equals("float")) {
        return "((java.lang.Float) " + name + ").floatValue()";
    } else if (type.typeName().equals("double")) {
        return "((java.lang.Double) " + name + ").doubleValue()";
    } else {
        throw new AssertionError(type);
    }
}
 
Example 5
Source File: StubSkeletonWriter.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns a snippet of Java code to unwrap a value named "name"
 * into a value of type "type", as appropriate for the Java
 * Reflection API.
 *
 * For primitive types, the value is assumed to be of the
 * corresponding wrapper class, and a method is called on the
 * wrapper to retrieve the primitive value.  For object types
 * (include arrays), no unwrapping is necessary; the value is
 * simply cast to the expected real object type.
 **/
private static String unwrapArgumentCode(Type type, String name) {
    if (type.dimension().length() > 0 || type.asClassDoc() != null) {
        return "((" + type.toString() + ") " + name + ")";
    } else if (type.typeName().equals("boolean")) {
        return "((java.lang.Boolean) " + name + ").booleanValue()";
    } else if (type.typeName().equals("byte")) {
        return "((java.lang.Byte) " + name + ").byteValue()";
    } else if (type.typeName().equals("char")) {
        return "((java.lang.Character) " + name + ").charValue()";
    } else if (type.typeName().equals("short")) {
        return "((java.lang.Short) " + name + ").shortValue()";
    } else if (type.typeName().equals("int")) {
        return "((java.lang.Integer) " + name + ").intValue()";
    } else if (type.typeName().equals("long")) {
        return "((java.lang.Long) " + name + ").longValue()";
    } else if (type.typeName().equals("float")) {
        return "((java.lang.Float) " + name + ").floatValue()";
    } else if (type.typeName().equals("double")) {
        return "((java.lang.Double) " + name + ").doubleValue()";
    } else {
        throw new AssertionError(type);
    }
}
 
Example 6
Source File: StubSkeletonWriter.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns a snippet of Java code to unwrap a value named "name"
 * into a value of type "type", as appropriate for the Java
 * Reflection API.
 *
 * For primitive types, the value is assumed to be of the
 * corresponding wrapper class, and a method is called on the
 * wrapper to retrieve the primitive value.  For object types
 * (include arrays), no unwrapping is necessary; the value is
 * simply cast to the expected real object type.
 **/
private static String unwrapArgumentCode(Type type, String name) {
    if (type.dimension().length() > 0 || type.asClassDoc() != null) {
        return "((" + type.toString() + ") " + name + ")";
    } else if (type.typeName().equals("boolean")) {
        return "((java.lang.Boolean) " + name + ").booleanValue()";
    } else if (type.typeName().equals("byte")) {
        return "((java.lang.Byte) " + name + ").byteValue()";
    } else if (type.typeName().equals("char")) {
        return "((java.lang.Character) " + name + ").charValue()";
    } else if (type.typeName().equals("short")) {
        return "((java.lang.Short) " + name + ").shortValue()";
    } else if (type.typeName().equals("int")) {
        return "((java.lang.Integer) " + name + ").intValue()";
    } else if (type.typeName().equals("long")) {
        return "((java.lang.Long) " + name + ").longValue()";
    } else if (type.typeName().equals("float")) {
        return "((java.lang.Float) " + name + ").floatValue()";
    } else if (type.typeName().equals("double")) {
        return "((java.lang.Double) " + name + ").doubleValue()";
    } else {
        throw new AssertionError(type);
    }
}
 
Example 7
Source File: StubSkeletonWriter.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Writes a snippet of Java code to marshal a value named "name"
 * of type "type" to the java.io.ObjectOutput stream named
 * "stream".
 *
 * Primitive types are marshalled with their corresponding methods
 * in the java.io.DataOutput interface, and objects (including
 * arrays) are marshalled using the writeObject method.
 **/
private static void writeMarshalArgument(IndentingWriter p,
                                         String streamName,
                                         Type type, String name)
    throws IOException
{
    if (type.dimension().length() > 0 || type.asClassDoc() != null) {
        p.p(streamName + ".writeObject(" + name + ")");
    } else if (type.typeName().equals("boolean")) {
        p.p(streamName + ".writeBoolean(" + name + ")");
    } else if (type.typeName().equals("byte")) {
        p.p(streamName + ".writeByte(" + name + ")");
    } else if (type.typeName().equals("char")) {
        p.p(streamName + ".writeChar(" + name + ")");
    } else if (type.typeName().equals("short")) {
        p.p(streamName + ".writeShort(" + name + ")");
    } else if (type.typeName().equals("int")) {
        p.p(streamName + ".writeInt(" + name + ")");
    } else if (type.typeName().equals("long")) {
        p.p(streamName + ".writeLong(" + name + ")");
    } else if (type.typeName().equals("float")) {
        p.p(streamName + ".writeFloat(" + name + ")");
    } else if (type.typeName().equals("double")) {
        p.p(streamName + ".writeDouble(" + name + ")");
    } else {
        throw new AssertionError(type);
    }
}
 
Example 8
Source File: StubSkeletonWriter.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Writes a snippet of Java code to unmarshal a value of type
 * "type" from the java.io.ObjectInput stream named "stream" into
 * a variable named "name" (if "name" is null, the value is
 * unmarshalled and discarded).
 *
 * Primitive types are unmarshalled with their corresponding
 * methods in the java.io.DataInput interface, and objects
 * (including arrays) are unmarshalled using the readObject
 * method.
 *
 * Returns true if code to invoke readObject was written, and
 * false otherwise.
 **/
private static boolean writeUnmarshalArgument(IndentingWriter p,
                                              String streamName,
                                              Type type, String name)
    throws IOException
{
    boolean readObject = false;

    if (name != null) {
        p.p(name + " = ");
    }

    if (type.dimension().length() > 0 || type.asClassDoc() != null) {
        p.p("(" + type.toString() + ") " + streamName + ".readObject()");
        readObject = true;
    } else if (type.typeName().equals("boolean")) {
        p.p(streamName + ".readBoolean()");
    } else if (type.typeName().equals("byte")) {
        p.p(streamName + ".readByte()");
    } else if (type.typeName().equals("char")) {
        p.p(streamName + ".readChar()");
    } else if (type.typeName().equals("short")) {
        p.p(streamName + ".readShort()");
    } else if (type.typeName().equals("int")) {
        p.p(streamName + ".readInt()");
    } else if (type.typeName().equals("long")) {
        p.p(streamName + ".readLong()");
    } else if (type.typeName().equals("float")) {
        p.p(streamName + ".readFloat()");
    } else if (type.typeName().equals("double")) {
        p.p(streamName + ".readDouble()");
    } else {
        throw new AssertionError(type);
    }

    return readObject;
}
 
Example 9
Source File: StubSkeletonWriter.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Writes a snippet of Java code to unmarshal a value of type
 * "type" from the java.io.ObjectInput stream named "stream" into
 * a variable named "name" (if "name" is null, the value is
 * unmarshalled and discarded).
 *
 * Primitive types are unmarshalled with their corresponding
 * methods in the java.io.DataInput interface, and objects
 * (including arrays) are unmarshalled using the readObject
 * method.
 *
 * Returns true if code to invoke readObject was written, and
 * false otherwise.
 **/
private static boolean writeUnmarshalArgument(IndentingWriter p,
                                              String streamName,
                                              Type type, String name)
    throws IOException
{
    boolean readObject = false;

    if (name != null) {
        p.p(name + " = ");
    }

    if (type.dimension().length() > 0 || type.asClassDoc() != null) {
        p.p("(" + type.toString() + ") " + streamName + ".readObject()");
        readObject = true;
    } else if (type.typeName().equals("boolean")) {
        p.p(streamName + ".readBoolean()");
    } else if (type.typeName().equals("byte")) {
        p.p(streamName + ".readByte()");
    } else if (type.typeName().equals("char")) {
        p.p(streamName + ".readChar()");
    } else if (type.typeName().equals("short")) {
        p.p(streamName + ".readShort()");
    } else if (type.typeName().equals("int")) {
        p.p(streamName + ".readInt()");
    } else if (type.typeName().equals("long")) {
        p.p(streamName + ".readLong()");
    } else if (type.typeName().equals("float")) {
        p.p(streamName + ".readFloat()");
    } else if (type.typeName().equals("double")) {
        p.p(streamName + ".readDouble()");
    } else {
        throw new AssertionError(type);
    }

    return readObject;
}
 
Example 10
Source File: StubSkeletonWriter.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Writes a snippet of Java code to marshal a value named "name"
 * of type "type" to the java.io.ObjectOutput stream named
 * "stream".
 *
 * Primitive types are marshalled with their corresponding methods
 * in the java.io.DataOutput interface, and objects (including
 * arrays) are marshalled using the writeObject method.
 **/
private static void writeMarshalArgument(IndentingWriter p,
                                         String streamName,
                                         Type type, String name)
    throws IOException
{
    if (type.dimension().length() > 0 || type.asClassDoc() != null) {
        p.p(streamName + ".writeObject(" + name + ")");
    } else if (type.typeName().equals("boolean")) {
        p.p(streamName + ".writeBoolean(" + name + ")");
    } else if (type.typeName().equals("byte")) {
        p.p(streamName + ".writeByte(" + name + ")");
    } else if (type.typeName().equals("char")) {
        p.p(streamName + ".writeChar(" + name + ")");
    } else if (type.typeName().equals("short")) {
        p.p(streamName + ".writeShort(" + name + ")");
    } else if (type.typeName().equals("int")) {
        p.p(streamName + ".writeInt(" + name + ")");
    } else if (type.typeName().equals("long")) {
        p.p(streamName + ".writeLong(" + name + ")");
    } else if (type.typeName().equals("float")) {
        p.p(streamName + ".writeFloat(" + name + ")");
    } else if (type.typeName().equals("double")) {
        p.p(streamName + ".writeDouble(" + name + ")");
    } else {
        throw new AssertionError(type);
    }
}
 
Example 11
Source File: StubSkeletonWriter.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Writes a snippet of Java code to marshal a value named "name"
 * of type "type" to the java.io.ObjectOutput stream named
 * "stream".
 *
 * Primitive types are marshalled with their corresponding methods
 * in the java.io.DataOutput interface, and objects (including
 * arrays) are marshalled using the writeObject method.
 **/
private static void writeMarshalArgument(IndentingWriter p,
                                         String streamName,
                                         Type type, String name)
    throws IOException
{
    if (type.dimension().length() > 0 || type.asClassDoc() != null) {
        p.p(streamName + ".writeObject(" + name + ")");
    } else if (type.typeName().equals("boolean")) {
        p.p(streamName + ".writeBoolean(" + name + ")");
    } else if (type.typeName().equals("byte")) {
        p.p(streamName + ".writeByte(" + name + ")");
    } else if (type.typeName().equals("char")) {
        p.p(streamName + ".writeChar(" + name + ")");
    } else if (type.typeName().equals("short")) {
        p.p(streamName + ".writeShort(" + name + ")");
    } else if (type.typeName().equals("int")) {
        p.p(streamName + ".writeInt(" + name + ")");
    } else if (type.typeName().equals("long")) {
        p.p(streamName + ".writeLong(" + name + ")");
    } else if (type.typeName().equals("float")) {
        p.p(streamName + ".writeFloat(" + name + ")");
    } else if (type.typeName().equals("double")) {
        p.p(streamName + ".writeDouble(" + name + ")");
    } else {
        throw new AssertionError(type);
    }
}
 
Example 12
Source File: StubSkeletonWriter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Writes a snippet of Java code to unmarshal a value of type
 * "type" from the java.io.ObjectInput stream named "stream" into
 * a variable named "name" (if "name" is null, the value is
 * unmarshalled and discarded).
 *
 * Primitive types are unmarshalled with their corresponding
 * methods in the java.io.DataInput interface, and objects
 * (including arrays) are unmarshalled using the readObject
 * method.
 *
 * Returns true if code to invoke readObject was written, and
 * false otherwise.
 **/
private static boolean writeUnmarshalArgument(IndentingWriter p,
                                              String streamName,
                                              Type type, String name)
    throws IOException
{
    boolean readObject = false;

    if (name != null) {
        p.p(name + " = ");
    }

    if (type.dimension().length() > 0 || type.asClassDoc() != null) {
        p.p("(" + type.toString() + ") " + streamName + ".readObject()");
        readObject = true;
    } else if (type.typeName().equals("boolean")) {
        p.p(streamName + ".readBoolean()");
    } else if (type.typeName().equals("byte")) {
        p.p(streamName + ".readByte()");
    } else if (type.typeName().equals("char")) {
        p.p(streamName + ".readChar()");
    } else if (type.typeName().equals("short")) {
        p.p(streamName + ".readShort()");
    } else if (type.typeName().equals("int")) {
        p.p(streamName + ".readInt()");
    } else if (type.typeName().equals("long")) {
        p.p(streamName + ".readLong()");
    } else if (type.typeName().equals("float")) {
        p.p(streamName + ".readFloat()");
    } else if (type.typeName().equals("double")) {
        p.p(streamName + ".readDouble()");
    } else {
        throw new AssertionError(type);
    }

    return readObject;
}
 
Example 13
Source File: StubSkeletonWriter.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Writes a snippet of Java code to unmarshal a value of type
 * "type" from the java.io.ObjectInput stream named "stream" into
 * a variable named "name" (if "name" is null, the value is
 * unmarshalled and discarded).
 *
 * Primitive types are unmarshalled with their corresponding
 * methods in the java.io.DataInput interface, and objects
 * (including arrays) are unmarshalled using the readObject
 * method.
 *
 * Returns true if code to invoke readObject was written, and
 * false otherwise.
 **/
private static boolean writeUnmarshalArgument(IndentingWriter p,
                                              String streamName,
                                              Type type, String name)
    throws IOException
{
    boolean readObject = false;

    if (name != null) {
        p.p(name + " = ");
    }

    if (type.dimension().length() > 0 || type.asClassDoc() != null) {
        p.p("(" + type.toString() + ") " + streamName + ".readObject()");
        readObject = true;
    } else if (type.typeName().equals("boolean")) {
        p.p(streamName + ".readBoolean()");
    } else if (type.typeName().equals("byte")) {
        p.p(streamName + ".readByte()");
    } else if (type.typeName().equals("char")) {
        p.p(streamName + ".readChar()");
    } else if (type.typeName().equals("short")) {
        p.p(streamName + ".readShort()");
    } else if (type.typeName().equals("int")) {
        p.p(streamName + ".readInt()");
    } else if (type.typeName().equals("long")) {
        p.p(streamName + ".readLong()");
    } else if (type.typeName().equals("float")) {
        p.p(streamName + ".readFloat()");
    } else if (type.typeName().equals("double")) {
        p.p(streamName + ".readDouble()");
    } else {
        throw new AssertionError(type);
    }

    return readObject;
}
 
Example 14
Source File: StubSkeletonWriter.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Writes a snippet of Java code to marshal a value named "name"
 * of type "type" to the java.io.ObjectOutput stream named
 * "stream".
 *
 * Primitive types are marshalled with their corresponding methods
 * in the java.io.DataOutput interface, and objects (including
 * arrays) are marshalled using the writeObject method.
 **/
private static void writeMarshalArgument(IndentingWriter p,
                                         String streamName,
                                         Type type, String name)
    throws IOException
{
    if (type.dimension().length() > 0 || type.asClassDoc() != null) {
        p.p(streamName + ".writeObject(" + name + ")");
    } else if (type.typeName().equals("boolean")) {
        p.p(streamName + ".writeBoolean(" + name + ")");
    } else if (type.typeName().equals("byte")) {
        p.p(streamName + ".writeByte(" + name + ")");
    } else if (type.typeName().equals("char")) {
        p.p(streamName + ".writeChar(" + name + ")");
    } else if (type.typeName().equals("short")) {
        p.p(streamName + ".writeShort(" + name + ")");
    } else if (type.typeName().equals("int")) {
        p.p(streamName + ".writeInt(" + name + ")");
    } else if (type.typeName().equals("long")) {
        p.p(streamName + ".writeLong(" + name + ")");
    } else if (type.typeName().equals("float")) {
        p.p(streamName + ".writeFloat(" + name + ")");
    } else if (type.typeName().equals("double")) {
        p.p(streamName + ".writeDouble(" + name + ")");
    } else {
        throw new AssertionError(type);
    }
}
 
Example 15
Source File: Util.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns the descriptor for the specified type, as appropriate
 * for either a parameter or return type in a method descriptor.
 **/
private static String typeDescriptorOf(Type type) {
    String desc;
    ClassDoc classDoc = type.asClassDoc();
    if (classDoc == null) {
        /*
         * Handle primitive types.
         */
        String name = type.typeName();
        if (name.equals("boolean")) {
            desc = "Z";
        } else if (name.equals("byte")) {
            desc = "B";
        } else if (name.equals("char")) {
            desc = "C";
        } else if (name.equals("short")) {
            desc = "S";
        } else if (name.equals("int")) {
            desc = "I";
        } else if (name.equals("long")) {
            desc = "J";
        } else if (name.equals("float")) {
            desc = "F";
        } else if (name.equals("double")) {
            desc = "D";
        } else if (name.equals("void")) {
            desc = "V";
        } else {
            throw new AssertionError(
                "unrecognized primitive type: " + name);
        }
    } else {
        /*
         * Handle non-array reference types.
         */
        desc = "L" + binaryNameOf(classDoc).replace('.', '/') + ";";
    }

    /*
     * Handle array types.
     */
    int dimensions = type.dimension().length() / 2;
    for (int i = 0; i < dimensions; i++) {
        desc = "[" + desc;
    }

    return desc;
}
 
Example 16
Source File: Util.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns true if the specified type is void.
 **/
static boolean isVoid(Type type) {
    return type.asClassDoc() == null && type.typeName().equals("void");
}
 
Example 17
Source File: Util.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns true if the specified type is void.
 **/
static boolean isVoid(Type type) {
    return type.asClassDoc() == null && type.typeName().equals("void");
}
 
Example 18
Source File: Util.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns the descriptor for the specified type, as appropriate
 * for either a parameter or return type in a method descriptor.
 **/
private static String typeDescriptorOf(Type type) {
    String desc;
    ClassDoc classDoc = type.asClassDoc();
    if (classDoc == null) {
        /*
         * Handle primitive types.
         */
        String name = type.typeName();
        if (name.equals("boolean")) {
            desc = "Z";
        } else if (name.equals("byte")) {
            desc = "B";
        } else if (name.equals("char")) {
            desc = "C";
        } else if (name.equals("short")) {
            desc = "S";
        } else if (name.equals("int")) {
            desc = "I";
        } else if (name.equals("long")) {
            desc = "J";
        } else if (name.equals("float")) {
            desc = "F";
        } else if (name.equals("double")) {
            desc = "D";
        } else if (name.equals("void")) {
            desc = "V";
        } else {
            throw new AssertionError(
                "unrecognized primitive type: " + name);
        }
    } else {
        /*
         * Handle non-array reference types.
         */
        desc = "L" + binaryNameOf(classDoc).replace('.', '/') + ";";
    }

    /*
     * Handle array types.
     */
    int dimensions = type.dimension().length() / 2;
    for (int i = 0; i < dimensions; i++) {
        desc = "[" + desc;
    }

    return desc;
}
 
Example 19
Source File: Util.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns true if the specified type is void.
 **/
static boolean isVoid(Type type) {
    return type.asClassDoc() == null && type.typeName().equals("void");
}
 
Example 20
Source File: Util.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns the descriptor for the specified type, as appropriate
 * for either a parameter or return type in a method descriptor.
 **/
private static String typeDescriptorOf(Type type) {
    String desc;
    ClassDoc classDoc = type.asClassDoc();
    if (classDoc == null) {
        /*
         * Handle primitive types.
         */
        String name = type.typeName();
        if (name.equals("boolean")) {
            desc = "Z";
        } else if (name.equals("byte")) {
            desc = "B";
        } else if (name.equals("char")) {
            desc = "C";
        } else if (name.equals("short")) {
            desc = "S";
        } else if (name.equals("int")) {
            desc = "I";
        } else if (name.equals("long")) {
            desc = "J";
        } else if (name.equals("float")) {
            desc = "F";
        } else if (name.equals("double")) {
            desc = "D";
        } else if (name.equals("void")) {
            desc = "V";
        } else {
            throw new AssertionError(
                "unrecognized primitive type: " + name);
        }
    } else {
        /*
         * Handle non-array reference types.
         */
        desc = "L" + binaryNameOf(classDoc).replace('.', '/') + ";";
    }

    /*
     * Handle array types.
     */
    int dimensions = type.dimension().length() / 2;
    for (int i = 0; i < dimensions; i++) {
        desc = "[" + desc;
    }

    return desc;
}