Java Code Examples for sun.tools.java.Type#getTypeCode()

The following examples show how to use sun.tools.java.Type#getTypeCode() . 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: RMIGenerator.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Generate a readable string representing the given type suitable
 * for embedding within a Java identifier.
 */
private static String generateNameFromType(Type type) {
    int typeCode = type.getTypeCode();
    switch (typeCode) {
    case TC_BOOLEAN:
    case TC_BYTE:
    case TC_CHAR:
    case TC_SHORT:
    case TC_INT:
    case TC_LONG:
    case TC_FLOAT:
    case TC_DOUBLE:
        return type.toString();
    case TC_ARRAY:
        return "arrayOf_" + generateNameFromType(type.getElementType());
    case TC_CLASS:
        return Names.mangleClass(type.getClassName().getName()).toString();
    default:
        throw new Error("unexpected type code: " + typeCode);
    }
}
 
Example 2
Source File: RMIGenerator.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Generate a readable string representing the given type suitable
 * for embedding within a Java identifier.
 */
private static String generateNameFromType(Type type) {
    int typeCode = type.getTypeCode();
    switch (typeCode) {
    case TC_BOOLEAN:
    case TC_BYTE:
    case TC_CHAR:
    case TC_SHORT:
    case TC_INT:
    case TC_LONG:
    case TC_FLOAT:
    case TC_DOUBLE:
        return type.toString();
    case TC_ARRAY:
        return "arrayOf_" + generateNameFromType(type.getElementType());
    case TC_CLASS:
        return Names.mangleClass(type.getClassName().getName()).toString();
    default:
        throw new Error("unexpected type code: " + typeCode);
    }
}
 
Example 3
Source File: RMIGenerator.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Generate a readable string representing the given type suitable
 * for embedding within a Java identifier.
 */
private static String generateNameFromType(Type type) {
    int typeCode = type.getTypeCode();
    switch (typeCode) {
    case TC_BOOLEAN:
    case TC_BYTE:
    case TC_CHAR:
    case TC_SHORT:
    case TC_INT:
    case TC_LONG:
    case TC_FLOAT:
    case TC_DOUBLE:
        return type.toString();
    case TC_ARRAY:
        return "arrayOf_" + generateNameFromType(type.getElementType());
    case TC_CLASS:
        return Names.mangleClass(type.getClassName().getName()).toString();
    default:
        throw new Error("unexpected type code: " + typeCode);
    }
}
 
Example 4
Source File: RMIGenerator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Write 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
{
    int typeCode = type.getTypeCode();
    switch (typeCode) {
    case TC_BOOLEAN:
        p.p(streamName + ".writeBoolean(" + name + ")");
        break;
    case TC_BYTE:
        p.p(streamName + ".writeByte(" + name + ")");
        break;
    case TC_CHAR:
        p.p(streamName + ".writeChar(" + name + ")");
        break;
    case TC_SHORT:
        p.p(streamName + ".writeShort(" + name + ")");
        break;
    case TC_INT:
        p.p(streamName + ".writeInt(" + name + ")");
        break;
    case TC_LONG:
        p.p(streamName + ".writeLong(" + name + ")");
        break;
    case TC_FLOAT:
        p.p(streamName + ".writeFloat(" + name + ")");
        break;
    case TC_DOUBLE:
        p.p(streamName + ".writeDouble(" + name + ")");
        break;
    case TC_ARRAY:
    case TC_CLASS:
        p.p(streamName + ".writeObject(" + name + ")");
        break;
    default:
        throw new Error("unexpected type code: " + typeCode);
    }
}
 
Example 5
Source File: RMIGenerator.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return 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 type, and a method is called on the wrapper type 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) {
    int typeCode = type.getTypeCode();
    switch (typeCode) {
    case TC_BOOLEAN:
        return "((java.lang.Boolean) " + name + ").booleanValue()";
    case TC_BYTE:
        return "((java.lang.Byte) " + name + ").byteValue()";
    case TC_CHAR:
        return "((java.lang.Character) " + name + ").charValue()";
    case TC_SHORT:
        return "((java.lang.Short) " + name + ").shortValue()";
    case TC_INT:
        return "((java.lang.Integer) " + name + ").intValue()";
    case TC_LONG:
        return "((java.lang.Long) " + name + ").longValue()";
    case TC_FLOAT:
        return "((java.lang.Float) " + name + ").floatValue()";
    case TC_DOUBLE:
        return "((java.lang.Double) " + name + ").doubleValue()";
    case TC_ARRAY:
    case TC_CLASS:
        return "((" + type + ") " + name + ")";
    default:
        throw new Error("unexpected type code: " + typeCode);
    }
}
 
Example 6
Source File: RMIGenerator.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return 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 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) {
    int typeCode = type.getTypeCode();
    switch (typeCode) {
    case TC_BOOLEAN:
        return ("(" + name +
                " ? java.lang.Boolean.TRUE : java.lang.Boolean.FALSE)");
    case TC_BYTE:
        return "new java.lang.Byte(" + name + ")";
    case TC_CHAR:
        return "new java.lang.Character(" + name + ")";
    case TC_SHORT:
        return "new java.lang.Short(" + name + ")";
    case TC_INT:
        return "new java.lang.Integer(" + name + ")";
    case TC_LONG:
        return "new java.lang.Long(" + name + ")";
    case TC_FLOAT:
        return "new java.lang.Float(" + name + ")";
    case TC_DOUBLE:
        return "new java.lang.Double(" + name + ")";
    case TC_ARRAY:
    case TC_CLASS:
        return name;
    default:
        throw new Error("unexpected type code: " + typeCode);
    }
}
 
Example 7
Source File: RMIGenerator.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return 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 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) {
    int typeCode = type.getTypeCode();
    switch (typeCode) {
    case TC_BOOLEAN:
        return ("(" + name +
                " ? java.lang.Boolean.TRUE : java.lang.Boolean.FALSE)");
    case TC_BYTE:
        return "new java.lang.Byte(" + name + ")";
    case TC_CHAR:
        return "new java.lang.Character(" + name + ")";
    case TC_SHORT:
        return "new java.lang.Short(" + name + ")";
    case TC_INT:
        return "new java.lang.Integer(" + name + ")";
    case TC_LONG:
        return "new java.lang.Long(" + name + ")";
    case TC_FLOAT:
        return "new java.lang.Float(" + name + ")";
    case TC_DOUBLE:
        return "new java.lang.Double(" + name + ")";
    case TC_ARRAY:
    case TC_CLASS:
        return name;
    default:
        throw new Error("unexpected type code: " + typeCode);
    }
}
 
Example 8
Source File: RMIGenerator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return 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 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) {
    int typeCode = type.getTypeCode();
    switch (typeCode) {
    case TC_BOOLEAN:
        return ("(" + name +
                " ? java.lang.Boolean.TRUE : java.lang.Boolean.FALSE)");
    case TC_BYTE:
        return "new java.lang.Byte(" + name + ")";
    case TC_CHAR:
        return "new java.lang.Character(" + name + ")";
    case TC_SHORT:
        return "new java.lang.Short(" + name + ")";
    case TC_INT:
        return "new java.lang.Integer(" + name + ")";
    case TC_LONG:
        return "new java.lang.Long(" + name + ")";
    case TC_FLOAT:
        return "new java.lang.Float(" + name + ")";
    case TC_DOUBLE:
        return "new java.lang.Double(" + name + ")";
    case TC_ARRAY:
    case TC_CLASS:
        return name;
    default:
        throw new Error("unexpected type code: " + typeCode);
    }
}
 
Example 9
Source File: RMIGenerator.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return 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 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) {
    int typeCode = type.getTypeCode();
    switch (typeCode) {
    case TC_BOOLEAN:
        return ("(" + name +
                " ? java.lang.Boolean.TRUE : java.lang.Boolean.FALSE)");
    case TC_BYTE:
        return "new java.lang.Byte(" + name + ")";
    case TC_CHAR:
        return "new java.lang.Character(" + name + ")";
    case TC_SHORT:
        return "new java.lang.Short(" + name + ")";
    case TC_INT:
        return "new java.lang.Integer(" + name + ")";
    case TC_LONG:
        return "new java.lang.Long(" + name + ")";
    case TC_FLOAT:
        return "new java.lang.Float(" + name + ")";
    case TC_DOUBLE:
        return "new java.lang.Double(" + name + ")";
    case TC_ARRAY:
    case TC_CLASS:
        return name;
    default:
        throw new Error("unexpected type code: " + typeCode);
    }
}
 
Example 10
Source File: RMIGenerator.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Write 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
{
    int typeCode = type.getTypeCode();
    switch (typeCode) {
    case TC_BOOLEAN:
        p.p(streamName + ".writeBoolean(" + name + ")");
        break;
    case TC_BYTE:
        p.p(streamName + ".writeByte(" + name + ")");
        break;
    case TC_CHAR:
        p.p(streamName + ".writeChar(" + name + ")");
        break;
    case TC_SHORT:
        p.p(streamName + ".writeShort(" + name + ")");
        break;
    case TC_INT:
        p.p(streamName + ".writeInt(" + name + ")");
        break;
    case TC_LONG:
        p.p(streamName + ".writeLong(" + name + ")");
        break;
    case TC_FLOAT:
        p.p(streamName + ".writeFloat(" + name + ")");
        break;
    case TC_DOUBLE:
        p.p(streamName + ".writeDouble(" + name + ")");
        break;
    case TC_ARRAY:
    case TC_CLASS:
        p.p(streamName + ".writeObject(" + name + ")");
        break;
    default:
        throw new Error("unexpected type code: " + typeCode);
    }
}
 
Example 11
Source File: RMIGenerator.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Write 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
{
    int typeCode = type.getTypeCode();
    switch (typeCode) {
    case TC_BOOLEAN:
        p.p(streamName + ".writeBoolean(" + name + ")");
        break;
    case TC_BYTE:
        p.p(streamName + ".writeByte(" + name + ")");
        break;
    case TC_CHAR:
        p.p(streamName + ".writeChar(" + name + ")");
        break;
    case TC_SHORT:
        p.p(streamName + ".writeShort(" + name + ")");
        break;
    case TC_INT:
        p.p(streamName + ".writeInt(" + name + ")");
        break;
    case TC_LONG:
        p.p(streamName + ".writeLong(" + name + ")");
        break;
    case TC_FLOAT:
        p.p(streamName + ".writeFloat(" + name + ")");
        break;
    case TC_DOUBLE:
        p.p(streamName + ".writeDouble(" + name + ")");
        break;
    case TC_ARRAY:
    case TC_CLASS:
        p.p(streamName + ".writeObject(" + name + ")");
        break;
    default:
        throw new Error("unexpected type code: " + typeCode);
    }
}
 
Example 12
Source File: RMIGenerator.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return 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 type, and a method is called on the wrapper type 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) {
    int typeCode = type.getTypeCode();
    switch (typeCode) {
    case TC_BOOLEAN:
        return "((java.lang.Boolean) " + name + ").booleanValue()";
    case TC_BYTE:
        return "((java.lang.Byte) " + name + ").byteValue()";
    case TC_CHAR:
        return "((java.lang.Character) " + name + ").charValue()";
    case TC_SHORT:
        return "((java.lang.Short) " + name + ").shortValue()";
    case TC_INT:
        return "((java.lang.Integer) " + name + ").intValue()";
    case TC_LONG:
        return "((java.lang.Long) " + name + ").longValue()";
    case TC_FLOAT:
        return "((java.lang.Float) " + name + ").floatValue()";
    case TC_DOUBLE:
        return "((java.lang.Double) " + name + ").doubleValue()";
    case TC_ARRAY:
    case TC_CLASS:
        return "((" + type + ") " + name + ")";
    default:
        throw new Error("unexpected type code: " + typeCode);
    }
}
 
Example 13
Source File: RMIGenerator.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Write 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
{
    int typeCode = type.getTypeCode();
    switch (typeCode) {
    case TC_BOOLEAN:
        p.p(streamName + ".writeBoolean(" + name + ")");
        break;
    case TC_BYTE:
        p.p(streamName + ".writeByte(" + name + ")");
        break;
    case TC_CHAR:
        p.p(streamName + ".writeChar(" + name + ")");
        break;
    case TC_SHORT:
        p.p(streamName + ".writeShort(" + name + ")");
        break;
    case TC_INT:
        p.p(streamName + ".writeInt(" + name + ")");
        break;
    case TC_LONG:
        p.p(streamName + ".writeLong(" + name + ")");
        break;
    case TC_FLOAT:
        p.p(streamName + ".writeFloat(" + name + ")");
        break;
    case TC_DOUBLE:
        p.p(streamName + ".writeDouble(" + name + ")");
        break;
    case TC_ARRAY:
    case TC_CLASS:
        p.p(streamName + ".writeObject(" + name + ")");
        break;
    default:
        throw new Error("unexpected type code: " + typeCode);
    }
}
 
Example 14
Source File: RMIGenerator.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return 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 type, and a method is called on the wrapper type 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) {
    int typeCode = type.getTypeCode();
    switch (typeCode) {
    case TC_BOOLEAN:
        return "((java.lang.Boolean) " + name + ").booleanValue()";
    case TC_BYTE:
        return "((java.lang.Byte) " + name + ").byteValue()";
    case TC_CHAR:
        return "((java.lang.Character) " + name + ").charValue()";
    case TC_SHORT:
        return "((java.lang.Short) " + name + ").shortValue()";
    case TC_INT:
        return "((java.lang.Integer) " + name + ").intValue()";
    case TC_LONG:
        return "((java.lang.Long) " + name + ").longValue()";
    case TC_FLOAT:
        return "((java.lang.Float) " + name + ").floatValue()";
    case TC_DOUBLE:
        return "((java.lang.Double) " + name + ").doubleValue()";
    case TC_ARRAY:
    case TC_CLASS:
        return "((" + type + ") " + name + ")";
    default:
        throw new Error("unexpected type code: " + typeCode);
    }
}
 
Example 15
Source File: RMIGenerator.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Write 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
{
    int typeCode = type.getTypeCode();
    switch (typeCode) {
    case TC_BOOLEAN:
        p.p(streamName + ".writeBoolean(" + name + ")");
        break;
    case TC_BYTE:
        p.p(streamName + ".writeByte(" + name + ")");
        break;
    case TC_CHAR:
        p.p(streamName + ".writeChar(" + name + ")");
        break;
    case TC_SHORT:
        p.p(streamName + ".writeShort(" + name + ")");
        break;
    case TC_INT:
        p.p(streamName + ".writeInt(" + name + ")");
        break;
    case TC_LONG:
        p.p(streamName + ".writeLong(" + name + ")");
        break;
    case TC_FLOAT:
        p.p(streamName + ".writeFloat(" + name + ")");
        break;
    case TC_DOUBLE:
        p.p(streamName + ".writeDouble(" + name + ")");
        break;
    case TC_ARRAY:
    case TC_CLASS:
        p.p(streamName + ".writeObject(" + name + ")");
        break;
    default:
        throw new Error("unexpected type code: " + typeCode);
    }
}
 
Example 16
Source File: RMIGenerator.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return 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 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) {
    int typeCode = type.getTypeCode();
    switch (typeCode) {
    case TC_BOOLEAN:
        return ("(" + name +
                " ? java.lang.Boolean.TRUE : java.lang.Boolean.FALSE)");
    case TC_BYTE:
        return "new java.lang.Byte(" + name + ")";
    case TC_CHAR:
        return "new java.lang.Character(" + name + ")";
    case TC_SHORT:
        return "new java.lang.Short(" + name + ")";
    case TC_INT:
        return "new java.lang.Integer(" + name + ")";
    case TC_LONG:
        return "new java.lang.Long(" + name + ")";
    case TC_FLOAT:
        return "new java.lang.Float(" + name + ")";
    case TC_DOUBLE:
        return "new java.lang.Double(" + name + ")";
    case TC_ARRAY:
    case TC_CLASS:
        return name;
    default:
        throw new Error("unexpected type code: " + typeCode);
    }
}
 
Example 17
Source File: RMIGenerator.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Write 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 in 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.
 */
private static boolean writeUnmarshalArgument(IndentingWriter p,
                                              String streamName,
                                              Type type, String name)
    throws IOException
{
    boolean readObject = false;

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

    int typeCode = type.getTypeCode();
    switch (type.getTypeCode()) {
    case TC_BOOLEAN:
        p.p(streamName + ".readBoolean()");
        break;
    case TC_BYTE:
        p.p(streamName + ".readByte()");
        break;
    case TC_CHAR:
        p.p(streamName + ".readChar()");
        break;
    case TC_SHORT:
        p.p(streamName + ".readShort()");
        break;
    case TC_INT:
        p.p(streamName + ".readInt()");
        break;
    case TC_LONG:
        p.p(streamName + ".readLong()");
        break;
    case TC_FLOAT:
        p.p(streamName + ".readFloat()");
        break;
    case TC_DOUBLE:
        p.p(streamName + ".readDouble()");
        break;
    case TC_ARRAY:
    case TC_CLASS:
        p.p("(" + type + ") " + streamName + ".readObject()");
        readObject = true;
        break;
    default:
        throw new Error("unexpected type code: " + typeCode);
    }
    return readObject;
}
 
Example 18
Source File: RMIGenerator.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Write 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 in 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.
 */
private static boolean writeUnmarshalArgument(IndentingWriter p,
                                              String streamName,
                                              Type type, String name)
    throws IOException
{
    boolean readObject = false;

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

    int typeCode = type.getTypeCode();
    switch (type.getTypeCode()) {
    case TC_BOOLEAN:
        p.p(streamName + ".readBoolean()");
        break;
    case TC_BYTE:
        p.p(streamName + ".readByte()");
        break;
    case TC_CHAR:
        p.p(streamName + ".readChar()");
        break;
    case TC_SHORT:
        p.p(streamName + ".readShort()");
        break;
    case TC_INT:
        p.p(streamName + ".readInt()");
        break;
    case TC_LONG:
        p.p(streamName + ".readLong()");
        break;
    case TC_FLOAT:
        p.p(streamName + ".readFloat()");
        break;
    case TC_DOUBLE:
        p.p(streamName + ".readDouble()");
        break;
    case TC_ARRAY:
    case TC_CLASS:
        p.p("(" + type + ") " + streamName + ".readObject()");
        readObject = true;
        break;
    default:
        throw new Error("unexpected type code: " + typeCode);
    }
    return readObject;
}
 
Example 19
Source File: RMIGenerator.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Write 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 in 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.
 */
private static boolean writeUnmarshalArgument(IndentingWriter p,
                                              String streamName,
                                              Type type, String name)
    throws IOException
{
    boolean readObject = false;

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

    int typeCode = type.getTypeCode();
    switch (type.getTypeCode()) {
    case TC_BOOLEAN:
        p.p(streamName + ".readBoolean()");
        break;
    case TC_BYTE:
        p.p(streamName + ".readByte()");
        break;
    case TC_CHAR:
        p.p(streamName + ".readChar()");
        break;
    case TC_SHORT:
        p.p(streamName + ".readShort()");
        break;
    case TC_INT:
        p.p(streamName + ".readInt()");
        break;
    case TC_LONG:
        p.p(streamName + ".readLong()");
        break;
    case TC_FLOAT:
        p.p(streamName + ".readFloat()");
        break;
    case TC_DOUBLE:
        p.p(streamName + ".readDouble()");
        break;
    case TC_ARRAY:
    case TC_CLASS:
        p.p("(" + type + ") " + streamName + ".readObject()");
        readObject = true;
        break;
    default:
        throw new Error("unexpected type code: " + typeCode);
    }
    return readObject;
}
 
Example 20
Source File: RMIGenerator.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Write 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 in 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.
 */
private static boolean writeUnmarshalArgument(IndentingWriter p,
                                              String streamName,
                                              Type type, String name)
    throws IOException
{
    boolean readObject = false;

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

    int typeCode = type.getTypeCode();
    switch (type.getTypeCode()) {
    case TC_BOOLEAN:
        p.p(streamName + ".readBoolean()");
        break;
    case TC_BYTE:
        p.p(streamName + ".readByte()");
        break;
    case TC_CHAR:
        p.p(streamName + ".readChar()");
        break;
    case TC_SHORT:
        p.p(streamName + ".readShort()");
        break;
    case TC_INT:
        p.p(streamName + ".readInt()");
        break;
    case TC_LONG:
        p.p(streamName + ".readLong()");
        break;
    case TC_FLOAT:
        p.p(streamName + ".readFloat()");
        break;
    case TC_DOUBLE:
        p.p(streamName + ".readDouble()");
        break;
    case TC_ARRAY:
    case TC_CLASS:
        p.p("(" + type + ") " + streamName + ".readObject()");
        readObject = true;
        break;
    default:
        throw new Error("unexpected type code: " + typeCode);
    }
    return readObject;
}