com.sun.javadoc.Type Java Examples

The following examples show how to use com.sun.javadoc.Type. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RemoteClass.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #2
Source File: StubSkeletonWriter.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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("});");
    }
}
 
Example #3
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 #4
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 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 #5
Source File: StubSkeletonWriter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #6
Source File: StubSkeletonWriter.java    From openjdk-jdk8u-backup 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 #7
Source File: RemoteClass.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #8
Source File: StubSkeletonWriter.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #9
Source File: StubSkeletonWriter.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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("});");
    }
}
 
Example #10
Source File: StubSkeletonWriter.java    From openjdk-8 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 #11
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 #12
Source File: StubSkeletonWriter.java    From openjdk-jdk8u 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 #13
Source File: StubSkeletonWriter.java    From openjdk-8-source 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 #14
Source File: StubSkeletonWriter.java    From TencentKona-8 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 #15
Source File: StubSkeletonWriter.java    From TencentKona-8 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 #16
Source File: StubSkeletonWriter.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #17
Source File: RemoteClass.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #18
Source File: StubSkeletonWriter.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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("});");
    }
}
 
Example #19
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 #20
Source File: StubSkeletonWriter.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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("});");
    }
}
 
Example #21
Source File: StubSkeletonWriter.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #22
Source File: StubSkeletonWriter.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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("});");
    }
}
 
Example #23
Source File: SarlLinkFactory.java    From sarl with Apache License 2.0 6 votes vote down vote up
/** Build the link for the wildcard.
 *
 * @param link the link.
 * @param linkInfo the information on the link.
 * @param type the type.
 */
protected void getLinkForWildcard(Content link, LinkInfo linkInfo, Type type) {
	linkInfo.isTypeBound = true;
	link.addContent("?"); //$NON-NLS-1$
	final WildcardType wildcardType = type.asWildcardType();
	final Type[] extendsBounds = wildcardType.extendsBounds();
	final SARLFeatureAccess kw = Utils.getKeywords();
	for (int i = 0; i < extendsBounds.length; i++) {
		link.addContent(i > 0 ? kw.getCommaKeyword() + " " //$NON-NLS-1$
				: " " + kw.getExtendsKeyword() + " "); //$NON-NLS-1$ //$NON-NLS-2$
		setBoundsLinkInfo(linkInfo, extendsBounds[i]);
		link.addContent(getLink(linkInfo));
	}
	final Type[] superBounds = wildcardType.superBounds();
	for (int i = 0; i < superBounds.length; i++) {
		link.addContent(i > 0 ? kw.getCommaKeyword() + " " //$NON-NLS-1$
				: " " + kw.getSuperKeyword() + " "); //$NON-NLS-1$ //$NON-NLS-2$
		setBoundsLinkInfo(linkInfo, superBounds[i]);
		link.addContent(getLink(linkInfo));
	}
}
 
Example #24
Source File: StubSkeletonWriter.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #25
Source File: RemoteClass.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #26
Source File: StubSkeletonWriter.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #27
Source File: RemoteClass.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #28
Source File: Util.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns a reader-friendly string representation of the
 * specified method's signature.  Names of reference types are not
 * package-qualified.
 **/
static String getFriendlyUnqualifiedSignature(MethodDoc method) {
    String sig = method.name() + "(";
    Parameter[] parameters = method.parameters();
    for (int i = 0; i < parameters.length; i++) {
        if (i > 0) {
            sig += ", ";
        }
        Type paramType = parameters[i].type();
        sig += paramType.typeName() + paramType.dimension();
    }
    sig += ")";
    return sig;
}
 
Example #29
Source File: StubSkeletonWriter.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Writes Java statements to marshal a series of values in order
 * as named in the "names" array, with types as specified in the
 * "types" array, to the java.io.ObjectOutput stream named
 * "stream".
 **/
private static void writeMarshalArguments(IndentingWriter p,
                                          String streamName,
                                          Type[] types, String[] names)
    throws IOException
{
    assert types.length == names.length;

    for (int i = 0; i < types.length; i++) {
        writeMarshalArgument(p, streamName, types[i], names[i]);
        p.pln(";");
    }
}
 
Example #30
Source File: StubSkeletonWriter.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Writes Java statements to marshal a series of values in order
 * as named in the "names" array, with types as specified in the
 * "types" array, to the java.io.ObjectOutput stream named
 * "stream".
 **/
private static void writeMarshalArguments(IndentingWriter p,
                                          String streamName,
                                          Type[] types, String[] names)
    throws IOException
{
    assert types.length == names.length;

    for (int i = 0; i < types.length; i++) {
        writeMarshalArgument(p, streamName, types[i], names[i]);
        p.pln(";");
    }
}