Java 类com.sun.javadoc.Type 实例源码

项目:PrivacyStreams    文件:Utils.java   
public static String getSimpleTypeName(Type type) {
    if (type instanceof ParameterizedType) {
        String typeName = type.typeName() + "<";
        boolean firstParameter = true;
        for (Type parameter : ((ParameterizedType) type).typeArguments()) {
            if (firstParameter) {
                typeName += getSimpleTypeName(parameter);
                firstParameter = false;
            }
            else {
                typeName += "," + getSimpleTypeName(parameter);
            }
        }
        typeName += ">";
        return typeName;
    }
    return type.typeName();
}
项目:OpenJSharp    文件:StubSkeletonWriter.java   
/**
 * Writes code to initialize the static fields for each method
 * using the Java Reflection API.
 **/
private void writeMethodFieldInitializers(IndentingWriter p)
    throws IOException
{
    for (int i = 0; i < methodFieldNames.length; i++) {
        p.p(methodFieldNames[i] + " = ");
        /*
         * Look up the Method object in the somewhat arbitrary
         * interface that we find in the Method object.
         */
        RemoteClass.Method method = remoteMethods[i];
        MethodDoc methodDoc = method.methodDoc();
        String methodName = methodDoc.name();
        Type paramTypes[] = method.parameterTypes();

        p.p(methodDoc.containingClass().qualifiedName() + ".class.getMethod(\"" +
            methodName + "\", new java.lang.Class[] {");
        for (int j = 0; j < paramTypes.length; j++) {
            if (j > 0)
                p.p(", ");
            p.p(paramTypes[j].toString() + ".class");
        }
        p.pln("});");
    }
}
项目:OpenJSharp    文件:StubSkeletonWriter.java   
/**
 * Writes Java statements to unmarshal a series of values in order
 * of types as in the "types" array from the java.io.ObjectInput
 * stream named "stream" into variables as named in "names" (for
 * any element of "names" that is null, the corresponding value is
 * unmarshalled and discarded).
 **/
private static boolean writeUnmarshalArguments(IndentingWriter p,
                                               String streamName,
                                               Type[] types,
                                               String[] names)
    throws IOException
{
    assert types.length == names.length;

    boolean readObject = false;
    for (int i = 0; i < types.length; i++) {
        if (writeUnmarshalArgument(p, streamName, types[i], names[i])) {
            readObject = true;
        }
        p.pln(";");
    }
    return readObject;
}
项目:OpenJSharp    文件:StubSkeletonWriter.java   
/**
 * 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);
    }
}
项目:OpenJSharp    文件:StubSkeletonWriter.java   
/**
 * 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);
    }
}
项目:OpenJSharp    文件:RemoteClass.java   
/**
 * Computes the string representation of this method
 * appropriate for the construction of a
 * java.rmi.server.Operation object.
 **/
private String computeOperationString() {
    /*
     * To be consistent with previous implementations, we use
     * the deprecated style of placing the "[]" for the return
     * type (if any) after the parameter list.
     */
    Type returnType = methodDoc.returnType();
    String op = returnType.qualifiedTypeName() + " " +
        methodDoc.name() + "(";
    Parameter[] parameters = methodDoc.parameters();
    for (int i = 0; i < parameters.length; i++) {
        if (i > 0) {
            op += ", ";
        }
        op += parameters[i].type().toString();
    }
    op += ")" + returnType.dimension();
    return op;
}
项目:jdk8u-jdk    文件:StubSkeletonWriter.java   
/**
 * Writes code to initialize the static fields for each method
 * using the Java Reflection API.
 **/
private void writeMethodFieldInitializers(IndentingWriter p)
    throws IOException
{
    for (int i = 0; i < methodFieldNames.length; i++) {
        p.p(methodFieldNames[i] + " = ");
        /*
         * Look up the Method object in the somewhat arbitrary
         * interface that we find in the Method object.
         */
        RemoteClass.Method method = remoteMethods[i];
        MethodDoc methodDoc = method.methodDoc();
        String methodName = methodDoc.name();
        Type paramTypes[] = method.parameterTypes();

        p.p(methodDoc.containingClass().qualifiedName() + ".class.getMethod(\"" +
            methodName + "\", new java.lang.Class[] {");
        for (int j = 0; j < paramTypes.length; j++) {
            if (j > 0)
                p.p(", ");
            p.p(paramTypes[j].toString() + ".class");
        }
        p.pln("});");
    }
}
项目:jdk8u-jdk    文件:StubSkeletonWriter.java   
/**
 * Writes Java statements to unmarshal a series of values in order
 * of types as in the "types" array from the java.io.ObjectInput
 * stream named "stream" into variables as named in "names" (for
 * any element of "names" that is null, the corresponding value is
 * unmarshalled and discarded).
 **/
private static boolean writeUnmarshalArguments(IndentingWriter p,
                                               String streamName,
                                               Type[] types,
                                               String[] names)
    throws IOException
{
    assert types.length == names.length;

    boolean readObject = false;
    for (int i = 0; i < types.length; i++) {
        if (writeUnmarshalArgument(p, streamName, types[i], names[i])) {
            readObject = true;
        }
        p.pln(";");
    }
    return readObject;
}
项目:jdk8u-jdk    文件:StubSkeletonWriter.java   
/**
 * 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);
    }
}
项目:jdk8u-jdk    文件:StubSkeletonWriter.java   
/**
 * 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);
    }
}
项目:jdk8u-jdk    文件:RemoteClass.java   
/**
 * Computes the string representation of this method
 * appropriate for the construction of a
 * java.rmi.server.Operation object.
 **/
private String computeOperationString() {
    /*
     * To be consistent with previous implementations, we use
     * the deprecated style of placing the "[]" for the return
     * type (if any) after the parameter list.
     */
    Type returnType = methodDoc.returnType();
    String op = returnType.qualifiedTypeName() + " " +
        methodDoc.name() + "(";
    Parameter[] parameters = methodDoc.parameters();
    for (int i = 0; i < parameters.length; i++) {
        if (i > 0) {
            op += ", ";
        }
        op += parameters[i].type().toString();
    }
    op += ")" + returnType.dimension();
    return op;
}
项目:openjdk-jdk10    文件:StubSkeletonWriter.java   
/**
 * Writes code to initialize the static fields for each method
 * using the Java Reflection API.
 **/
private void writeMethodFieldInitializers(IndentingWriter p)
    throws IOException
{
    for (int i = 0; i < methodFieldNames.length; i++) {
        p.p(methodFieldNames[i] + " = ");
        /*
         * Look up the Method object in the somewhat arbitrary
         * interface that we find in the Method object.
         */
        RemoteClass.Method method = remoteMethods[i];
        MethodDoc methodDoc = method.methodDoc();
        String methodName = methodDoc.name();
        Type paramTypes[] = method.parameterTypes();

        p.p(methodDoc.containingClass().qualifiedName() + ".class.getMethod(\"" +
            methodName + "\", new java.lang.Class[] {");
        for (int j = 0; j < paramTypes.length; j++) {
            if (j > 0)
                p.p(", ");
            p.p(paramTypes[j].toString() + ".class");
        }
        p.pln("});");
    }
}
项目:openjdk-jdk10    文件:StubSkeletonWriter.java   
/**
 * Writes Java statements to unmarshal a series of values in order
 * of types as in the "types" array from the java.io.ObjectInput
 * stream named "stream" into variables as named in "names" (for
 * any element of "names" that is null, the corresponding value is
 * unmarshalled and discarded).
 **/
private static boolean writeUnmarshalArguments(IndentingWriter p,
                                               String streamName,
                                               Type[] types,
                                               String[] names)
    throws IOException
{
    assert types.length == names.length;

    boolean readObject = false;
    for (int i = 0; i < types.length; i++) {
        if (writeUnmarshalArgument(p, streamName, types[i], names[i])) {
            readObject = true;
        }
        p.pln(";");
    }
    return readObject;
}
项目:openjdk-jdk10    文件:StubSkeletonWriter.java   
/**
 * 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);
    }
}
项目:openjdk-jdk10    文件:StubSkeletonWriter.java   
/**
 * 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);
    }
}
项目:openjdk-jdk10    文件:RemoteClass.java   
/**
 * Computes the string representation of this method
 * appropriate for the construction of a
 * java.rmi.server.Operation object.
 **/
private String computeOperationString() {
    /*
     * To be consistent with previous implementations, we use
     * the deprecated style of placing the "[]" for the return
     * type (if any) after the parameter list.
     */
    Type returnType = methodDoc.returnType();
    String op = returnType.qualifiedTypeName() + " " +
        methodDoc.name() + "(";
    Parameter[] parameters = methodDoc.parameters();
    for (int i = 0; i < parameters.length; i++) {
        if (i > 0) {
            op += ", ";
        }
        op += parameters[i].type().toString();
    }
    op += ")" + returnType.dimension();
    return op;
}
项目:openjdk9    文件:StubSkeletonWriter.java   
/**
 * Writes code to initialize the static fields for each method
 * using the Java Reflection API.
 **/
private void writeMethodFieldInitializers(IndentingWriter p)
    throws IOException
{
    for (int i = 0; i < methodFieldNames.length; i++) {
        p.p(methodFieldNames[i] + " = ");
        /*
         * Look up the Method object in the somewhat arbitrary
         * interface that we find in the Method object.
         */
        RemoteClass.Method method = remoteMethods[i];
        MethodDoc methodDoc = method.methodDoc();
        String methodName = methodDoc.name();
        Type paramTypes[] = method.parameterTypes();

        p.p(methodDoc.containingClass().qualifiedName() + ".class.getMethod(\"" +
            methodName + "\", new java.lang.Class[] {");
        for (int j = 0; j < paramTypes.length; j++) {
            if (j > 0)
                p.p(", ");
            p.p(paramTypes[j].toString() + ".class");
        }
        p.pln("});");
    }
}
项目:openjdk9    文件:StubSkeletonWriter.java   
/**
 * Writes Java statements to unmarshal a series of values in order
 * of types as in the "types" array from the java.io.ObjectInput
 * stream named "stream" into variables as named in "names" (for
 * any element of "names" that is null, the corresponding value is
 * unmarshalled and discarded).
 **/
private static boolean writeUnmarshalArguments(IndentingWriter p,
                                               String streamName,
                                               Type[] types,
                                               String[] names)
    throws IOException
{
    assert types.length == names.length;

    boolean readObject = false;
    for (int i = 0; i < types.length; i++) {
        if (writeUnmarshalArgument(p, streamName, types[i], names[i])) {
            readObject = true;
        }
        p.pln(";");
    }
    return readObject;
}
项目:openjdk9    文件:StubSkeletonWriter.java   
/**
 * 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);
    }
}
项目:openjdk9    文件:StubSkeletonWriter.java   
/**
 * 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);
    }
}
项目:openjdk9    文件:RemoteClass.java   
/**
 * Computes the string representation of this method
 * appropriate for the construction of a
 * java.rmi.server.Operation object.
 **/
private String computeOperationString() {
    /*
     * To be consistent with previous implementations, we use
     * the deprecated style of placing the "[]" for the return
     * type (if any) after the parameter list.
     */
    Type returnType = methodDoc.returnType();
    String op = returnType.qualifiedTypeName() + " " +
        methodDoc.name() + "(";
    Parameter[] parameters = methodDoc.parameters();
    for (int i = 0; i < parameters.length; i++) {
        if (i > 0) {
            op += ", ";
        }
        op += parameters[i].type().toString();
    }
    op += ")" + returnType.dimension();
    return op;
}
项目:umldoclet    文件:Renderer.java   
protected static IndentingPrintWriter writeTypeTo(IndentingPrintWriter out, Type type) {
    if (type != null) {
        out.append(type.typeName());
        final ParameterizedType parameterizedType = type.asParameterizedType();
        if (parameterizedType != null) {
            final Type[] generics = parameterizedType.typeArguments();
            if (generics.length > 0) {
                out.append("<");
                String sep = "";
                for (Type generic : generics) {
                    writeTypeTo(out.append(sep), generic);
                    sep = ", ";
                }
                out.append(">");
            }
        }
        out.append(type.dimension());
    }
    return out;
}
项目:jdk8u_jdk    文件:StubSkeletonWriter.java   
/**
 * Writes code to initialize the static fields for each method
 * using the Java Reflection API.
 **/
private void writeMethodFieldInitializers(IndentingWriter p)
    throws IOException
{
    for (int i = 0; i < methodFieldNames.length; i++) {
        p.p(methodFieldNames[i] + " = ");
        /*
         * Look up the Method object in the somewhat arbitrary
         * interface that we find in the Method object.
         */
        RemoteClass.Method method = remoteMethods[i];
        MethodDoc methodDoc = method.methodDoc();
        String methodName = methodDoc.name();
        Type paramTypes[] = method.parameterTypes();

        p.p(methodDoc.containingClass().qualifiedName() + ".class.getMethod(\"" +
            methodName + "\", new java.lang.Class[] {");
        for (int j = 0; j < paramTypes.length; j++) {
            if (j > 0)
                p.p(", ");
            p.p(paramTypes[j].toString() + ".class");
        }
        p.pln("});");
    }
}
项目:jdk8u_jdk    文件:StubSkeletonWriter.java   
/**
 * Writes Java statements to unmarshal a series of values in order
 * of types as in the "types" array from the java.io.ObjectInput
 * stream named "stream" into variables as named in "names" (for
 * any element of "names" that is null, the corresponding value is
 * unmarshalled and discarded).
 **/
private static boolean writeUnmarshalArguments(IndentingWriter p,
                                               String streamName,
                                               Type[] types,
                                               String[] names)
    throws IOException
{
    assert types.length == names.length;

    boolean readObject = false;
    for (int i = 0; i < types.length; i++) {
        if (writeUnmarshalArgument(p, streamName, types[i], names[i])) {
            readObject = true;
        }
        p.pln(";");
    }
    return readObject;
}
项目:jdk8u_jdk    文件:StubSkeletonWriter.java   
/**
 * 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);
    }
}
项目:jdk8u_jdk    文件:StubSkeletonWriter.java   
/**
 * 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);
    }
}
项目:jdk8u_jdk    文件:RemoteClass.java   
/**
 * Computes the string representation of this method
 * appropriate for the construction of a
 * java.rmi.server.Operation object.
 **/
private String computeOperationString() {
    /*
     * To be consistent with previous implementations, we use
     * the deprecated style of placing the "[]" for the return
     * type (if any) after the parameter list.
     */
    Type returnType = methodDoc.returnType();
    String op = returnType.qualifiedTypeName() + " " +
        methodDoc.name() + "(";
    Parameter[] parameters = methodDoc.parameters();
    for (int i = 0; i < parameters.length; i++) {
        if (i > 0) {
            op += ", ";
        }
        op += parameters[i].type().toString();
    }
    op += ")" + returnType.dimension();
    return op;
}
项目:lookaside_java-1.8.0-openjdk    文件:StubSkeletonWriter.java   
/**
 * Writes code to initialize the static fields for each method
 * using the Java Reflection API.
 **/
private void writeMethodFieldInitializers(IndentingWriter p)
    throws IOException
{
    for (int i = 0; i < methodFieldNames.length; i++) {
        p.p(methodFieldNames[i] + " = ");
        /*
         * Look up the Method object in the somewhat arbitrary
         * interface that we find in the Method object.
         */
        RemoteClass.Method method = remoteMethods[i];
        MethodDoc methodDoc = method.methodDoc();
        String methodName = methodDoc.name();
        Type paramTypes[] = method.parameterTypes();

        p.p(methodDoc.containingClass().qualifiedName() + ".class.getMethod(\"" +
            methodName + "\", new java.lang.Class[] {");
        for (int j = 0; j < paramTypes.length; j++) {
            if (j > 0)
                p.p(", ");
            p.p(paramTypes[j].toString() + ".class");
        }
        p.pln("});");
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:StubSkeletonWriter.java   
/**
 * Writes Java statements to unmarshal a series of values in order
 * of types as in the "types" array from the java.io.ObjectInput
 * stream named "stream" into variables as named in "names" (for
 * any element of "names" that is null, the corresponding value is
 * unmarshalled and discarded).
 **/
private static boolean writeUnmarshalArguments(IndentingWriter p,
                                               String streamName,
                                               Type[] types,
                                               String[] names)
    throws IOException
{
    assert types.length == names.length;

    boolean readObject = false;
    for (int i = 0; i < types.length; i++) {
        if (writeUnmarshalArgument(p, streamName, types[i], names[i])) {
            readObject = true;
        }
        p.pln(";");
    }
    return readObject;
}
项目:lookaside_java-1.8.0-openjdk    文件:StubSkeletonWriter.java   
/**
 * 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);
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:StubSkeletonWriter.java   
/**
 * 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);
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:RemoteClass.java   
/**
 * Computes the string representation of this method
 * appropriate for the construction of a
 * java.rmi.server.Operation object.
 **/
private String computeOperationString() {
    /*
     * To be consistent with previous implementations, we use
     * the deprecated style of placing the "[]" for the return
     * type (if any) after the parameter list.
     */
    Type returnType = methodDoc.returnType();
    String op = returnType.qualifiedTypeName() + " " +
        methodDoc.name() + "(";
    Parameter[] parameters = methodDoc.parameters();
    for (int i = 0; i < parameters.length; i++) {
        if (i > 0) {
            op += ", ";
        }
        op += parameters[i].type().toString();
    }
    op += ")" + returnType.dimension();
    return op;
}
项目:infobip-open-jdk-8    文件:StubSkeletonWriter.java   
/**
 * Writes code to initialize the static fields for each method
 * using the Java Reflection API.
 **/
private void writeMethodFieldInitializers(IndentingWriter p)
    throws IOException
{
    for (int i = 0; i < methodFieldNames.length; i++) {
        p.p(methodFieldNames[i] + " = ");
        /*
         * Look up the Method object in the somewhat arbitrary
         * interface that we find in the Method object.
         */
        RemoteClass.Method method = remoteMethods[i];
        MethodDoc methodDoc = method.methodDoc();
        String methodName = methodDoc.name();
        Type paramTypes[] = method.parameterTypes();

        p.p(methodDoc.containingClass().qualifiedName() + ".class.getMethod(\"" +
            methodName + "\", new java.lang.Class[] {");
        for (int j = 0; j < paramTypes.length; j++) {
            if (j > 0)
                p.p(", ");
            p.p(paramTypes[j].toString() + ".class");
        }
        p.pln("});");
    }
}
项目:infobip-open-jdk-8    文件:StubSkeletonWriter.java   
/**
 * Writes Java statements to unmarshal a series of values in order
 * of types as in the "types" array from the java.io.ObjectInput
 * stream named "stream" into variables as named in "names" (for
 * any element of "names" that is null, the corresponding value is
 * unmarshalled and discarded).
 **/
private static boolean writeUnmarshalArguments(IndentingWriter p,
                                               String streamName,
                                               Type[] types,
                                               String[] names)
    throws IOException
{
    assert types.length == names.length;

    boolean readObject = false;
    for (int i = 0; i < types.length; i++) {
        if (writeUnmarshalArgument(p, streamName, types[i], names[i])) {
            readObject = true;
        }
        p.pln(";");
    }
    return readObject;
}
项目:infobip-open-jdk-8    文件:StubSkeletonWriter.java   
/**
 * 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);
    }
}
项目:infobip-open-jdk-8    文件:StubSkeletonWriter.java   
/**
 * 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);
    }
}
项目:infobip-open-jdk-8    文件:RemoteClass.java   
/**
 * Computes the string representation of this method
 * appropriate for the construction of a
 * java.rmi.server.Operation object.
 **/
private String computeOperationString() {
    /*
     * To be consistent with previous implementations, we use
     * the deprecated style of placing the "[]" for the return
     * type (if any) after the parameter list.
     */
    Type returnType = methodDoc.returnType();
    String op = returnType.qualifiedTypeName() + " " +
        methodDoc.name() + "(";
    Parameter[] parameters = methodDoc.parameters();
    for (int i = 0; i < parameters.length; i++) {
        if (i > 0) {
            op += ", ";
        }
        op += parameters[i].type().toString();
    }
    op += ")" + returnType.dimension();
    return op;
}
项目:jdk8u-dev-jdk    文件:StubSkeletonWriter.java   
/**
 * Writes code to initialize the static fields for each method
 * using the Java Reflection API.
 **/
private void writeMethodFieldInitializers(IndentingWriter p)
    throws IOException
{
    for (int i = 0; i < methodFieldNames.length; i++) {
        p.p(methodFieldNames[i] + " = ");
        /*
         * Look up the Method object in the somewhat arbitrary
         * interface that we find in the Method object.
         */
        RemoteClass.Method method = remoteMethods[i];
        MethodDoc methodDoc = method.methodDoc();
        String methodName = methodDoc.name();
        Type paramTypes[] = method.parameterTypes();

        p.p(methodDoc.containingClass().qualifiedName() + ".class.getMethod(\"" +
            methodName + "\", new java.lang.Class[] {");
        for (int j = 0; j < paramTypes.length; j++) {
            if (j > 0)
                p.p(", ");
            p.p(paramTypes[j].toString() + ".class");
        }
        p.pln("});");
    }
}
项目:jdk8u-dev-jdk    文件:StubSkeletonWriter.java   
/**
 * Writes Java statements to unmarshal a series of values in order
 * of types as in the "types" array from the java.io.ObjectInput
 * stream named "stream" into variables as named in "names" (for
 * any element of "names" that is null, the corresponding value is
 * unmarshalled and discarded).
 **/
private static boolean writeUnmarshalArguments(IndentingWriter p,
                                               String streamName,
                                               Type[] types,
                                               String[] names)
    throws IOException
{
    assert types.length == names.length;

    boolean readObject = false;
    for (int i = 0; i < types.length; i++) {
        if (writeUnmarshalArgument(p, streamName, types[i], names[i])) {
            readObject = true;
        }
        p.pln(";");
    }
    return readObject;
}
项目:jdk8u-dev-jdk    文件:StubSkeletonWriter.java   
/**
 * 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);
    }
}